@utrecht/calendar-react 1.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/LICENSE.md +288 -0
- package/dist/CalendarButton.d.ts +6 -0
- package/dist/CalendarButton.d.ts.map +1 -0
- package/dist/CalendarIcon.d.ts +5 -0
- package/dist/CalendarIcon.d.ts.map +1 -0
- package/dist/CalendarNavigation.d.ts +5 -0
- package/dist/CalendarNavigation.d.ts.map +1 -0
- package/dist/CalendarNavigationButtons.d.ts +13 -0
- package/dist/CalendarNavigationButtons.d.ts.map +1 -0
- package/dist/CalendarNavigationLabel.d.ts +5 -0
- package/dist/CalendarNavigationLabel.d.ts.map +1 -0
- package/dist/CalendarTableDaysContainer.d.ts +5 -0
- package/dist/CalendarTableDaysContainer.d.ts.map +1 -0
- package/dist/CalendarTableDaysItem.d.ts +5 -0
- package/dist/CalendarTableDaysItem.d.ts.map +1 -0
- package/dist/CalendarTableDaysItemDay.d.ts +12 -0
- package/dist/CalendarTableDaysItemDay.d.ts.map +1 -0
- package/dist/CalendarTableWeeksContainer.d.ts +3 -0
- package/dist/CalendarTableWeeksContainer.d.ts.map +1 -0
- package/dist/CalendarTableWeeksItem.d.ts +5 -0
- package/dist/CalendarTableWeeksItem.d.ts.map +1 -0
- package/dist/IconArrowLeft.d.ts +8 -0
- package/dist/IconArrowLeft.d.ts.map +1 -0
- package/dist/IconArrowLeftDouble.d.ts +8 -0
- package/dist/IconArrowLeftDouble.d.ts.map +1 -0
- package/dist/IconArrowRight.d.ts +8 -0
- package/dist/IconArrowRight.d.ts.map +1 -0
- package/dist/IconArrowRightDouble.d.ts +8 -0
- package/dist/IconArrowRightDouble.d.ts.map +1 -0
- package/dist/css.d.ts +8 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/css.js +493 -0
- package/dist/css.js.map +1 -0
- package/dist/css.mjs +491 -0
- package/dist/css.mjs.map +1 -0
- package/dist/index.cjs.js +493 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +491 -0
- package/dist/index.esm.js.map +1 -0
- package/package.json +43 -0
- package/src/CalendarButton.tsx +11 -0
- package/src/CalendarIcon.tsx +10 -0
- package/src/CalendarNavigation.tsx +9 -0
- package/src/CalendarNavigationButtons.tsx +30 -0
- package/src/CalendarNavigationLabel.tsx +9 -0
- package/src/CalendarTableDaysContainer.tsx +13 -0
- package/src/CalendarTableDaysItem.tsx +8 -0
- package/src/CalendarTableDaysItemDay.tsx +37 -0
- package/src/CalendarTableWeeksContainer.tsx +7 -0
- package/src/CalendarTableWeeksItem.tsx +10 -0
- package/src/IconArrowLeft.tsx +12 -0
- package/src/IconArrowLeftDouble.tsx +13 -0
- package/src/IconArrowRight.tsx +12 -0
- package/src/IconArrowRightDouble.tsx +13 -0
- package/src/css.tsx +9 -0
- package/src/index.test.tsx +145 -0
- package/src/index.tsx +199 -0
|
@@ -0,0 +1,491 @@
|
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { startOfWeek, endOfWeek, eachDayOfInterval, isSameDay, endOfDay, parseISO, setYear, getYear, addYears, setMonth, addMonths, format, isSameMonth, formatISO, isBefore, startOfDay, isAfter, startOfMonth, addWeeks } from 'date-fns';
|
|
3
|
+
import { enUS } from 'date-fns/locale';
|
|
4
|
+
import chunk from 'lodash.chunk';
|
|
5
|
+
import { forwardRef, useState } from 'react';
|
|
6
|
+
import clsx, { clsx as clsx$1 } from 'clsx';
|
|
7
|
+
|
|
8
|
+
/******************************************************************************
|
|
9
|
+
Copyright (c) Microsoft Corporation.
|
|
10
|
+
|
|
11
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
12
|
+
purpose with or without fee is hereby granted.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
15
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
16
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
17
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
18
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
19
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
20
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
21
|
+
***************************************************************************** */
|
|
22
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function __rest$1(s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
38
|
+
var e = new Error(message);
|
|
39
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const CalendarNavigation = _a => {
|
|
43
|
+
var {
|
|
44
|
+
children
|
|
45
|
+
} = _a,
|
|
46
|
+
props = __rest$1(_a, ["children"]);
|
|
47
|
+
return jsx("div", Object.assign({
|
|
48
|
+
className: "utrecht-calendar__navigation"
|
|
49
|
+
}, props, {
|
|
50
|
+
children: children
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/******************************************************************************
|
|
55
|
+
Copyright (c) Microsoft Corporation.
|
|
56
|
+
|
|
57
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
58
|
+
purpose with or without fee is hereby granted.
|
|
59
|
+
|
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
61
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
62
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
63
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
64
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
65
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
66
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
67
|
+
***************************************************************************** */
|
|
68
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
function __rest(s, e) {
|
|
72
|
+
var t = {};
|
|
73
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
74
|
+
t[p] = s[p];
|
|
75
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
76
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
77
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
78
|
+
t[p[i]] = s[p[i]];
|
|
79
|
+
}
|
|
80
|
+
return t;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
84
|
+
var e = new Error(message);
|
|
85
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const Button = /*#__PURE__*/forwardRef((_a, ref) => {
|
|
89
|
+
var {
|
|
90
|
+
appearance,
|
|
91
|
+
busy,
|
|
92
|
+
disabled,
|
|
93
|
+
children,
|
|
94
|
+
className,
|
|
95
|
+
hint,
|
|
96
|
+
pressed,
|
|
97
|
+
type
|
|
98
|
+
} = _a,
|
|
99
|
+
restProps = __rest(_a, ["appearance", "busy", "disabled", "children", "className", "hint", "pressed", "type"]);
|
|
100
|
+
return jsx("button", Object.assign({
|
|
101
|
+
ref: ref,
|
|
102
|
+
className: clsx('utrecht-button', busy && 'utrecht-button--busy', disabled && 'utrecht-button--disabled', type === 'submit' && 'utrecht-button--submit', appearance === 'primary-action-button' && 'utrecht-button--primary-action', appearance === 'secondary-action-button' && 'utrecht-button--secondary-action', appearance === 'subtle-button' && 'utrecht-button--subtle', hint === 'danger' && 'utrecht-button--danger', hint === 'warning' && 'utrecht-button--warning', hint === 'ready' && 'utrecht-button--ready', pressed === true && 'utrecht-button--pressed', className),
|
|
103
|
+
"aria-busy": busy || undefined,
|
|
104
|
+
"aria-pressed": typeof pressed === 'boolean' ? pressed : undefined,
|
|
105
|
+
disabled: disabled,
|
|
106
|
+
type: type || 'button'
|
|
107
|
+
}, restProps, {
|
|
108
|
+
children: children
|
|
109
|
+
}));
|
|
110
|
+
});
|
|
111
|
+
Button.displayName = 'Button';
|
|
112
|
+
|
|
113
|
+
const CalendarButton = _a => {
|
|
114
|
+
var {
|
|
115
|
+
children,
|
|
116
|
+
className
|
|
117
|
+
} = _a,
|
|
118
|
+
props = __rest$1(_a, ["children", "className"]);
|
|
119
|
+
return jsx(Button, Object.assign({
|
|
120
|
+
appearance: "subtle-button"
|
|
121
|
+
}, props, {
|
|
122
|
+
className: clsx$1('utrecht-calendar__button', className)
|
|
123
|
+
}, {
|
|
124
|
+
children: children
|
|
125
|
+
}));
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
const CalendarIcon = _a => {
|
|
129
|
+
var {
|
|
130
|
+
children
|
|
131
|
+
} = _a,
|
|
132
|
+
props = __rest$1(_a, ["children"]);
|
|
133
|
+
return jsx("div", Object.assign({
|
|
134
|
+
className: clsx$1('utrecht-calendar__icon')
|
|
135
|
+
}, props, {
|
|
136
|
+
children: children
|
|
137
|
+
}));
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const CalendarNavigationButtons = _a => {
|
|
141
|
+
var {
|
|
142
|
+
onPreviousClick,
|
|
143
|
+
onNextClick,
|
|
144
|
+
previousIcon,
|
|
145
|
+
nextIcon,
|
|
146
|
+
children
|
|
147
|
+
} = _a,
|
|
148
|
+
props = __rest$1(_a, ["onPreviousClick", "onNextClick", "previousIcon", "nextIcon", "children"]);
|
|
149
|
+
return jsxs("div", Object.assign({
|
|
150
|
+
className: "utrecht-calendar__navigation-buttons"
|
|
151
|
+
}, {
|
|
152
|
+
children: [jsx(CalendarButton, Object.assign({
|
|
153
|
+
onClick: onPreviousClick
|
|
154
|
+
}, props, {
|
|
155
|
+
children: jsx(CalendarIcon, {
|
|
156
|
+
children: previousIcon
|
|
157
|
+
})
|
|
158
|
+
})), children, jsx(CalendarButton, Object.assign({
|
|
159
|
+
onClick: onNextClick
|
|
160
|
+
}, props, {
|
|
161
|
+
children: jsx(CalendarIcon, {
|
|
162
|
+
children: nextIcon
|
|
163
|
+
})
|
|
164
|
+
}))]
|
|
165
|
+
}));
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const CalendarNavigationLabel = _a => {
|
|
169
|
+
var {
|
|
170
|
+
children
|
|
171
|
+
} = _a,
|
|
172
|
+
props = __rest$1(_a, ["children"]);
|
|
173
|
+
return jsx("time", Object.assign({
|
|
174
|
+
className: "utrecht-calendar__navigation-label"
|
|
175
|
+
}, props, {
|
|
176
|
+
children: children
|
|
177
|
+
}));
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const CalendarTableDaysContainer = _a => {
|
|
181
|
+
var {
|
|
182
|
+
children
|
|
183
|
+
} = _a,
|
|
184
|
+
props = __rest$1(_a, ["children"]);
|
|
185
|
+
return jsx("tbody", Object.assign({}, props, {
|
|
186
|
+
className: "utrecht-calendar__table-days-container"
|
|
187
|
+
}, {
|
|
188
|
+
children: children
|
|
189
|
+
}));
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const CalendarTableDaysItem = _a => {
|
|
193
|
+
var {
|
|
194
|
+
children
|
|
195
|
+
} = _a,
|
|
196
|
+
props = __rest$1(_a, ["children"]);
|
|
197
|
+
return jsx("tr", Object.assign({}, props, {
|
|
198
|
+
children: children
|
|
199
|
+
}));
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
const CalendarTableDaysItemDay = _a => {
|
|
203
|
+
var {
|
|
204
|
+
day,
|
|
205
|
+
dayOutOfTheMonth,
|
|
206
|
+
isToday,
|
|
207
|
+
emphasis,
|
|
208
|
+
selected,
|
|
209
|
+
disabled
|
|
210
|
+
} = _a,
|
|
211
|
+
props = __rest$1(_a, ["day", "dayOutOfTheMonth", "isToday", "emphasis", "selected", "disabled"]);
|
|
212
|
+
return jsx("td", {
|
|
213
|
+
children: jsx(CalendarButton, Object.assign({
|
|
214
|
+
className: clsx('utrecht-calendar__table-days-item-day', {
|
|
215
|
+
'utrecht-calendar__table-days-item-day--out-of-the-month': dayOutOfTheMonth
|
|
216
|
+
}, {
|
|
217
|
+
'utrecht-calendar__table-days-item-day--is-today': isToday
|
|
218
|
+
}, {
|
|
219
|
+
'utrecht-calendar__table-days-item-day--emphasis': emphasis
|
|
220
|
+
}, {
|
|
221
|
+
'utrecht-calendar__table-days-item-day--selected': selected
|
|
222
|
+
}),
|
|
223
|
+
disabled: disabled
|
|
224
|
+
}, props, {
|
|
225
|
+
children: day
|
|
226
|
+
}))
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
const CalendarTableWeeksContainer = ({
|
|
231
|
+
children
|
|
232
|
+
}) => jsx("thead", Object.assign({
|
|
233
|
+
className: "utrecht-calendar__table-weeks-container"
|
|
234
|
+
}, {
|
|
235
|
+
children: jsx("tr", Object.assign({
|
|
236
|
+
className: "utrecht-calendar__table-weeks-container-content"
|
|
237
|
+
}, {
|
|
238
|
+
children: children
|
|
239
|
+
}))
|
|
240
|
+
}));
|
|
241
|
+
|
|
242
|
+
const CalendarTableWeeksItem = _a => {
|
|
243
|
+
var {
|
|
244
|
+
children
|
|
245
|
+
} = _a,
|
|
246
|
+
props = __rest$1(_a, ["children"]);
|
|
247
|
+
return jsx("th", Object.assign({}, props, {
|
|
248
|
+
className: "utrecht-calendar__table-weeks-item"
|
|
249
|
+
}, {
|
|
250
|
+
children: children
|
|
251
|
+
}));
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
const IconArrowLeft = _a => {
|
|
255
|
+
var {
|
|
256
|
+
title,
|
|
257
|
+
titleId
|
|
258
|
+
} = _a,
|
|
259
|
+
props = __rest$1(_a, ["title", "titleId"]);
|
|
260
|
+
return jsxs("svg", Object.assign({
|
|
261
|
+
width: "100%",
|
|
262
|
+
height: "100%",
|
|
263
|
+
fill: "none",
|
|
264
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
265
|
+
"aria-labelledby": titleId
|
|
266
|
+
}, props, {
|
|
267
|
+
children: [title ? jsx("title", Object.assign({
|
|
268
|
+
id: titleId
|
|
269
|
+
}, {
|
|
270
|
+
children: title
|
|
271
|
+
})) : null, jsx("path", {
|
|
272
|
+
d: "M15.41 16.59 10.83 12l4.58-4.59L14 6l-6 6 6 6 1.41-1.41Z",
|
|
273
|
+
fill: "currentColor"
|
|
274
|
+
})]
|
|
275
|
+
}));
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
const IconArrowLeftDouble = _a => {
|
|
279
|
+
var {
|
|
280
|
+
title,
|
|
281
|
+
titleId
|
|
282
|
+
} = _a,
|
|
283
|
+
props = __rest$1(_a, ["title", "titleId"]);
|
|
284
|
+
return jsxs("svg", Object.assign({
|
|
285
|
+
width: "100%",
|
|
286
|
+
height: "100%",
|
|
287
|
+
fill: "none",
|
|
288
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
289
|
+
"aria-labelledby": titleId
|
|
290
|
+
}, props, {
|
|
291
|
+
children: [title ? jsx("title", Object.assign({
|
|
292
|
+
id: titleId
|
|
293
|
+
}, {
|
|
294
|
+
children: title
|
|
295
|
+
})) : null, jsx("path", {
|
|
296
|
+
d: "M17.59 18 19 16.59 14.42 12 19 7.41 17.59 6l-6 6 6 6Z",
|
|
297
|
+
fill: "currentColor"
|
|
298
|
+
}), jsx("path", {
|
|
299
|
+
d: "m11 18 1.41-1.41L7.83 12l4.58-4.59L11 6l-6 6 6 6Z",
|
|
300
|
+
fill: "currentColor"
|
|
301
|
+
})]
|
|
302
|
+
}));
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
const IconArrowRight = _a => {
|
|
306
|
+
var {
|
|
307
|
+
title,
|
|
308
|
+
titleId
|
|
309
|
+
} = _a,
|
|
310
|
+
props = __rest$1(_a, ["title", "titleId"]);
|
|
311
|
+
return jsxs("svg", Object.assign({
|
|
312
|
+
width: "100%",
|
|
313
|
+
height: "100%",
|
|
314
|
+
fill: "none",
|
|
315
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
316
|
+
"aria-labelledby": titleId
|
|
317
|
+
}, props, {
|
|
318
|
+
children: [title ? jsx("title", Object.assign({
|
|
319
|
+
id: titleId
|
|
320
|
+
}, {
|
|
321
|
+
children: title
|
|
322
|
+
})) : null, jsx("path", {
|
|
323
|
+
d: "M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41Z",
|
|
324
|
+
fill: "currentColor"
|
|
325
|
+
})]
|
|
326
|
+
}));
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
const IconArrowRightDouble = _a => {
|
|
330
|
+
var {
|
|
331
|
+
title,
|
|
332
|
+
titleId
|
|
333
|
+
} = _a,
|
|
334
|
+
props = __rest$1(_a, ["title", "titleId"]);
|
|
335
|
+
return jsxs("svg", Object.assign({
|
|
336
|
+
fill: "none",
|
|
337
|
+
width: "100%",
|
|
338
|
+
height: "100%",
|
|
339
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
340
|
+
"aria-labelledby": titleId
|
|
341
|
+
}, props, {
|
|
342
|
+
children: [title ? jsx("title", Object.assign({
|
|
343
|
+
id: titleId
|
|
344
|
+
}, {
|
|
345
|
+
children: title
|
|
346
|
+
})) : null, jsx("path", {
|
|
347
|
+
d: "M6.41 6 5 7.41 9.58 12 5 16.59 6.41 18l6-6-6-6Z",
|
|
348
|
+
fill: "currentColor"
|
|
349
|
+
}), jsx("path", {
|
|
350
|
+
d: "m13 6-1.41 1.41L16.17 12l-4.58 4.59L13 18l6-6-6-6Z",
|
|
351
|
+
fill: "currentColor"
|
|
352
|
+
})]
|
|
353
|
+
}));
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
function createCalendar(today) {
|
|
357
|
+
const start = startOfWeek(startOfMonth(today), {
|
|
358
|
+
weekStartsOn: 1 /* Monday */
|
|
359
|
+
});
|
|
360
|
+
const end = endOfWeek(addWeeks(start, 5), {
|
|
361
|
+
weekStartsOn: 1 /* Monday */
|
|
362
|
+
});
|
|
363
|
+
return eachDayOfInterval({
|
|
364
|
+
start,
|
|
365
|
+
end
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Calendar Component
|
|
370
|
+
* powered by date-fns, so that make it easy to use the `date-fns` date functions & locale
|
|
371
|
+
* */
|
|
372
|
+
const Calendar = ({
|
|
373
|
+
onCalendarClick,
|
|
374
|
+
events,
|
|
375
|
+
currentDate,
|
|
376
|
+
locale = enUS,
|
|
377
|
+
previousYearButtonTitle = 'Previous year',
|
|
378
|
+
nextYearButtonTitle = 'Next year',
|
|
379
|
+
previousMonthButtonTitle = 'Previous month',
|
|
380
|
+
nextMonthButtonTitle = 'Next month',
|
|
381
|
+
minDate,
|
|
382
|
+
maxDate
|
|
383
|
+
}) => {
|
|
384
|
+
const [visibleMonth, setVisibleMonth] = useState(currentDate || new Date());
|
|
385
|
+
const [selectedDate, setSelectedDate] = useState(currentDate);
|
|
386
|
+
const calendar = createCalendar(visibleMonth);
|
|
387
|
+
const start = startOfWeek(visibleMonth, {
|
|
388
|
+
weekStartsOn: 1
|
|
389
|
+
});
|
|
390
|
+
const end = endOfWeek(visibleMonth, {
|
|
391
|
+
weekStartsOn: 1
|
|
392
|
+
});
|
|
393
|
+
const currentWeek = eachDayOfInterval({
|
|
394
|
+
start,
|
|
395
|
+
end
|
|
396
|
+
}).map(day => day);
|
|
397
|
+
const chunksWeeks = chunk(calendar, calendar.length / 6);
|
|
398
|
+
const weeks = chunksWeeks.map(week => week.map(date => {
|
|
399
|
+
const currentEvent = events && events.length > 0 && events.find(e => isSameDay(endOfDay(parseISO(e.date)), date));
|
|
400
|
+
if (currentEvent) {
|
|
401
|
+
return {
|
|
402
|
+
date,
|
|
403
|
+
emphasis: currentEvent.emphasis,
|
|
404
|
+
selected: currentEvent.selected,
|
|
405
|
+
disabled: currentEvent.disabled
|
|
406
|
+
};
|
|
407
|
+
} else {
|
|
408
|
+
return {
|
|
409
|
+
date,
|
|
410
|
+
emphasis: false,
|
|
411
|
+
selected: false,
|
|
412
|
+
disabled: false
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
}));
|
|
416
|
+
return jsxs("div", Object.assign({
|
|
417
|
+
className: "utrecht-calendar"
|
|
418
|
+
}, {
|
|
419
|
+
children: [jsx(CalendarNavigation, {
|
|
420
|
+
children: jsx(CalendarNavigationButtons, Object.assign({
|
|
421
|
+
previousIcon: jsx(IconArrowLeftDouble, {
|
|
422
|
+
title: previousYearButtonTitle
|
|
423
|
+
}),
|
|
424
|
+
nextIcon: jsx(IconArrowRightDouble, {
|
|
425
|
+
title: nextYearButtonTitle
|
|
426
|
+
}),
|
|
427
|
+
onPreviousClick: () => setVisibleMonth(setYear(visibleMonth, getYear(visibleMonth) - 1)),
|
|
428
|
+
onNextClick: () => setVisibleMonth(addYears(visibleMonth, 1))
|
|
429
|
+
}, {
|
|
430
|
+
children: jsx(CalendarNavigationButtons, Object.assign({
|
|
431
|
+
previousIcon: jsx(IconArrowLeft, {
|
|
432
|
+
title: previousMonthButtonTitle
|
|
433
|
+
}),
|
|
434
|
+
nextIcon: jsx(IconArrowRight, {
|
|
435
|
+
title: nextMonthButtonTitle
|
|
436
|
+
}),
|
|
437
|
+
onPreviousClick: () => setVisibleMonth(setMonth(visibleMonth, visibleMonth.getMonth() - 1)),
|
|
438
|
+
onNextClick: () => setVisibleMonth(addMonths(visibleMonth, 1))
|
|
439
|
+
}, {
|
|
440
|
+
children: jsx(CalendarNavigationLabel, Object.assign({
|
|
441
|
+
dateTime: format(visibleMonth, 'yyyy-mm')
|
|
442
|
+
}, {
|
|
443
|
+
children: format(visibleMonth, 'LLLL Y', {
|
|
444
|
+
locale
|
|
445
|
+
})
|
|
446
|
+
}))
|
|
447
|
+
}))
|
|
448
|
+
}))
|
|
449
|
+
}), jsxs("table", Object.assign({
|
|
450
|
+
className: "utrecht-calendar__table",
|
|
451
|
+
role: "grid"
|
|
452
|
+
}, {
|
|
453
|
+
children: [jsx(CalendarTableWeeksContainer, {
|
|
454
|
+
children: currentWeek && currentWeek.length > 0 && currentWeek.map((day, index) => jsx(CalendarTableWeeksItem, Object.assign({
|
|
455
|
+
scope: "col",
|
|
456
|
+
abbr: format(day, 'EEEE', {
|
|
457
|
+
locale
|
|
458
|
+
})
|
|
459
|
+
}, {
|
|
460
|
+
children: format(day, 'EEEEEE', {
|
|
461
|
+
locale
|
|
462
|
+
})
|
|
463
|
+
}), index))
|
|
464
|
+
}), jsx(CalendarTableDaysContainer, {
|
|
465
|
+
children: weeks && weeks.length > 0 && weeks.map((week, index) => jsx(CalendarTableDaysItem, {
|
|
466
|
+
children: week.map((day, index) => {
|
|
467
|
+
return jsx(CalendarTableDaysItemDay, {
|
|
468
|
+
isToday: isSameDay(day.date, Date.now()),
|
|
469
|
+
dayOutOfTheMonth: !isSameMonth(day.date, visibleMonth),
|
|
470
|
+
onClick: () => {
|
|
471
|
+
setVisibleMonth(day.date);
|
|
472
|
+
setSelectedDate(day.date);
|
|
473
|
+
onCalendarClick(formatISO(day.date));
|
|
474
|
+
},
|
|
475
|
+
"aria-label": format(day.date, 'eeee dd LLLL Y', {
|
|
476
|
+
locale
|
|
477
|
+
}),
|
|
478
|
+
day: day.date.getDate().toString(),
|
|
479
|
+
emphasis: day.emphasis,
|
|
480
|
+
selected: day.selected || selectedDate && isSameDay(day.date, selectedDate),
|
|
481
|
+
disabled: day.disabled || minDate && isBefore(day.date, startOfDay(minDate)) || maxDate && isAfter(day.date, endOfDay(maxDate))
|
|
482
|
+
}, index);
|
|
483
|
+
})
|
|
484
|
+
}, index))
|
|
485
|
+
})]
|
|
486
|
+
}))]
|
|
487
|
+
}));
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
export { Calendar };
|
|
491
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../button-react/dist/index.esm.js"],"sourcesContent":["import { jsx } from 'react/jsx-runtime';\nimport clsx from 'clsx';\nimport { forwardRef } from 'react';\n\n/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise, SuppressedError, Symbol */\r\n\r\n\r\nfunction __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\ntypeof SuppressedError === \"function\" ? SuppressedError : function (error, suppressed, message) {\r\n var e = new Error(message);\r\n return e.name = \"SuppressedError\", e.error = error, e.suppressed = suppressed, e;\r\n};\n\nconst Button = /*#__PURE__*/forwardRef((_a, ref) => {\n var {\n appearance,\n busy,\n disabled,\n children,\n className,\n hint,\n pressed,\n type\n } = _a,\n restProps = __rest(_a, [\"appearance\", \"busy\", \"disabled\", \"children\", \"className\", \"hint\", \"pressed\", \"type\"]);\n return jsx(\"button\", Object.assign({\n ref: ref,\n className: clsx('utrecht-button', busy && 'utrecht-button--busy', disabled && 'utrecht-button--disabled', type === 'submit' && 'utrecht-button--submit', appearance === 'primary-action-button' && 'utrecht-button--primary-action', appearance === 'secondary-action-button' && 'utrecht-button--secondary-action', appearance === 'subtle-button' && 'utrecht-button--subtle', hint === 'danger' && 'utrecht-button--danger', hint === 'warning' && 'utrecht-button--warning', hint === 'ready' && 'utrecht-button--ready', pressed === true && 'utrecht-button--pressed', className),\n \"aria-busy\": busy || undefined,\n \"aria-pressed\": typeof pressed === 'boolean' ? pressed : undefined,\n disabled: disabled,\n type: type || 'button'\n }, restProps, {\n children: children\n }));\n});\nButton.displayName = 'Button';\nconst PrimaryActionButton = _a => {\n var args = __rest(_a, []);\n return jsx(Button, Object.assign({}, args, {\n appearance: \"primary-action-button\"\n }));\n};\nPrimaryActionButton.displayName = 'PrimaryActionButton';\nconst SecondaryActionButton = _a => {\n var args = __rest(_a, []);\n return jsx(Button, Object.assign({}, args, {\n appearance: \"secondary-action-button\"\n }));\n};\nSecondaryActionButton.displayName = 'SecondaryActionButton';\nconst SubtleButton = _a => {\n var args = __rest(_a, []);\n return jsx(Button, Object.assign({}, args, {\n appearance: \"subtle-button\"\n }));\n};\nSubtleButton.displayName = 'SubtleButton';\n\nexport { Button, PrimaryActionButton, SecondaryActionButton, SubtleButton };\n//# sourceMappingURL=index.esm.js.map\n"],"names":[],"mappings":"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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.0.0",
|
|
3
|
+
"author": "Community for NL Design System",
|
|
4
|
+
"description": "Calendar component for the Municipality of Utrecht based on the NL Design System architecture",
|
|
5
|
+
"license": "EUPL-1.2",
|
|
6
|
+
"name": "@utrecht/calendar-react",
|
|
7
|
+
"main": "./dist/index.cjs.js",
|
|
8
|
+
"module": "./dist/index.esm.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"files": [
|
|
11
|
+
"dist/",
|
|
12
|
+
"src/"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"date-fns": "2.30.0",
|
|
17
|
+
"jest": "29.7.0",
|
|
18
|
+
"rollup": "4.18.0",
|
|
19
|
+
"@utrecht/button-react": "1.0.0",
|
|
20
|
+
"@utrecht/calendar-css": "1.2.0"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"nl-design-system"
|
|
24
|
+
],
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git+ssh",
|
|
30
|
+
"url": "git@github.com:nl-design-system/utrecht.git",
|
|
31
|
+
"directory": "packages/component-library-react/packages/calendar-react"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@babel/runtime": "^7.23.6",
|
|
35
|
+
"react": "18",
|
|
36
|
+
"react-dom": "18"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "rollup -c ./rollup.config.mjs",
|
|
40
|
+
"clean": "rimraf dist",
|
|
41
|
+
"test": "mkdir -p pages && jest --coverage --verbose"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Button, ButtonProps } from '@utrecht/button-react';
|
|
2
|
+
import { clsx } from 'clsx';
|
|
3
|
+
import { PropsWithChildren } from 'react';
|
|
4
|
+
|
|
5
|
+
export interface CalendarButtonProps extends ButtonProps {}
|
|
6
|
+
|
|
7
|
+
export const CalendarButton = ({ children, className, ...props }: PropsWithChildren<CalendarButtonProps>) => (
|
|
8
|
+
<Button appearance="subtle-button" {...props} className={clsx('utrecht-calendar__button', className)}>
|
|
9
|
+
{children}
|
|
10
|
+
</Button>
|
|
11
|
+
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { clsx } from 'clsx';
|
|
2
|
+
import { DetailedHTMLProps, HTMLAttributes, PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
export interface CalendarIconProps extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {}
|
|
5
|
+
|
|
6
|
+
export const CalendarIcon = ({ children, ...props }: PropsWithChildren<CalendarIconProps>) => (
|
|
7
|
+
<div className={clsx('utrecht-calendar__icon')} {...props}>
|
|
8
|
+
{children}
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DetailedHTMLProps, HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CalendarNavigationProps extends DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> {}
|
|
4
|
+
|
|
5
|
+
export const CalendarNavigation = ({ children, ...props }: PropsWithChildren<CalendarNavigationProps>) => (
|
|
6
|
+
<div className="utrecht-calendar__navigation" {...props}>
|
|
7
|
+
{children}
|
|
8
|
+
</div>
|
|
9
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { MouseEventHandler, PropsWithChildren } from 'react';
|
|
2
|
+
import { CalendarButton, CalendarButtonProps } from './CalendarButton';
|
|
3
|
+
import { CalendarIcon } from './CalendarIcon';
|
|
4
|
+
interface CalendarNavigationButtonsProps extends CalendarButtonProps {
|
|
5
|
+
onPreviousClick?: MouseEventHandler<HTMLButtonElement>;
|
|
6
|
+
onNextClick?: MouseEventHandler<HTMLButtonElement>;
|
|
7
|
+
previousIcon?: any;
|
|
8
|
+
nextIcon?: any;
|
|
9
|
+
previousTitle?: string;
|
|
10
|
+
nextTitle?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const CalendarNavigationButtons = ({
|
|
14
|
+
onPreviousClick,
|
|
15
|
+
onNextClick,
|
|
16
|
+
previousIcon,
|
|
17
|
+
nextIcon,
|
|
18
|
+
children,
|
|
19
|
+
...props
|
|
20
|
+
}: PropsWithChildren<CalendarNavigationButtonsProps>) => (
|
|
21
|
+
<div className="utrecht-calendar__navigation-buttons">
|
|
22
|
+
<CalendarButton onClick={onPreviousClick} {...props}>
|
|
23
|
+
<CalendarIcon>{previousIcon}</CalendarIcon>
|
|
24
|
+
</CalendarButton>
|
|
25
|
+
{children}
|
|
26
|
+
<CalendarButton onClick={onNextClick} {...props}>
|
|
27
|
+
<CalendarIcon>{nextIcon}</CalendarIcon>
|
|
28
|
+
</CalendarButton>
|
|
29
|
+
</div>
|
|
30
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PropsWithChildren, TimeHTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
type CalendarNavigationLabelProps = TimeHTMLAttributes<HTMLTimeElement>;
|
|
4
|
+
|
|
5
|
+
export const CalendarNavigationLabel = ({ children, ...props }: PropsWithChildren<CalendarNavigationLabelProps>) => (
|
|
6
|
+
<time className="utrecht-calendar__navigation-label" {...props}>
|
|
7
|
+
{children}
|
|
8
|
+
</time>
|
|
9
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DetailedHTMLProps, HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CalendarTableDaysContainerProps
|
|
4
|
+
extends DetailedHTMLProps<HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement> {}
|
|
5
|
+
|
|
6
|
+
export const CalendarTableDaysContainer = ({
|
|
7
|
+
children,
|
|
8
|
+
...props
|
|
9
|
+
}: PropsWithChildren<CalendarTableDaysContainerProps>) => (
|
|
10
|
+
<tbody {...props} className="utrecht-calendar__table-days-container">
|
|
11
|
+
{children}
|
|
12
|
+
</tbody>
|
|
13
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DetailedHTMLProps, HTMLAttributes, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface CalendarTableDaysItemProps
|
|
4
|
+
extends DetailedHTMLProps<HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement> {}
|
|
5
|
+
|
|
6
|
+
export const CalendarTableDaysItem = ({ children, ...props }: PropsWithChildren<CalendarTableDaysItemProps>) => (
|
|
7
|
+
<tr {...props}>{children}</tr>
|
|
8
|
+
);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import clsx from 'clsx';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
import { CalendarButton, CalendarButtonProps } from './CalendarButton';
|
|
4
|
+
export interface CalendarTableDaysItemDayProps extends CalendarButtonProps {
|
|
5
|
+
day: string;
|
|
6
|
+
dayOutOfTheMonth?: boolean;
|
|
7
|
+
isToday: boolean;
|
|
8
|
+
emphasis?: boolean;
|
|
9
|
+
selected?: boolean;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const CalendarTableDaysItemDay = ({
|
|
14
|
+
day,
|
|
15
|
+
dayOutOfTheMonth,
|
|
16
|
+
isToday,
|
|
17
|
+
emphasis,
|
|
18
|
+
selected,
|
|
19
|
+
disabled,
|
|
20
|
+
...props
|
|
21
|
+
}: PropsWithChildren<CalendarTableDaysItemDayProps>) => (
|
|
22
|
+
<td>
|
|
23
|
+
<CalendarButton
|
|
24
|
+
className={clsx(
|
|
25
|
+
'utrecht-calendar__table-days-item-day',
|
|
26
|
+
{ 'utrecht-calendar__table-days-item-day--out-of-the-month': dayOutOfTheMonth },
|
|
27
|
+
{ 'utrecht-calendar__table-days-item-day--is-today': isToday },
|
|
28
|
+
{ 'utrecht-calendar__table-days-item-day--emphasis': emphasis },
|
|
29
|
+
{ 'utrecht-calendar__table-days-item-day--selected': selected },
|
|
30
|
+
)}
|
|
31
|
+
disabled={disabled}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
{day}
|
|
35
|
+
</CalendarButton>
|
|
36
|
+
</td>
|
|
37
|
+
);
|