@umituz/web-dashboard 11.6.0 → 11.7.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/README.md +12 -0
- package/package.json +3 -3
- package/src/domains/calendar/calendar.css +0 -649
- package/src/domains/calendar/components/index.ts +12 -10
- package/src/domains/calendar/types/view.types.ts +8 -51
- package/src/domains/calendar/utils/layout.ts +31 -221
- package/src/styles/chrome.css +37 -32
- package/src/domains/calendar/components/Calendar.test.tsx +0 -106
- package/src/domains/calendar/components/Calendar.tsx +0 -211
- package/src/domains/calendar/components/CalendarAgenda.test.tsx +0 -73
- package/src/domains/calendar/components/CalendarAgenda.tsx +0 -105
- package/src/domains/calendar/components/CalendarMonth.test.tsx +0 -59
- package/src/domains/calendar/components/CalendarMonth.tsx +0 -109
- package/src/domains/calendar/components/CalendarResourceTimeline.test.tsx +0 -93
- package/src/domains/calendar/components/CalendarResourceTimeline.tsx +0 -164
- package/src/domains/calendar/components/CalendarTimeGrid.test.tsx +0 -99
- package/src/domains/calendar/components/CalendarTimeGrid.tsx +0 -182
- package/src/domains/calendar/utils/layout.test.ts +0 -144
|
@@ -1,51 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
dayKey: string;
|
|
10
|
-
startMin?: number;
|
|
11
|
-
endMin?: number;
|
|
12
|
-
title: ReactNode;
|
|
13
|
-
tone?: CalendarTone;
|
|
14
|
-
icon?: ReactNode;
|
|
15
|
-
meta?: ReactNode;
|
|
16
|
-
kind?: string;
|
|
17
|
-
muted?: boolean;
|
|
18
|
-
payload?: unknown;
|
|
19
|
-
resourceId?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface CalendarLegendEntry {
|
|
23
|
-
tone: CalendarTone;
|
|
24
|
-
label: string;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface CalendarLabels {
|
|
28
|
-
today: string;
|
|
29
|
-
previous: string;
|
|
30
|
-
next: string;
|
|
31
|
-
month: string;
|
|
32
|
-
week: string;
|
|
33
|
-
day: string;
|
|
34
|
-
agenda: string;
|
|
35
|
-
allDay: string;
|
|
36
|
-
more: string;
|
|
37
|
-
emptyDay: string;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const DEFAULT_CALENDAR_LABELS: CalendarLabels = {
|
|
41
|
-
today: 'Today',
|
|
42
|
-
previous: 'Previous',
|
|
43
|
-
next: 'Next',
|
|
44
|
-
month: 'Month',
|
|
45
|
-
week: 'Week',
|
|
46
|
-
day: 'Day',
|
|
47
|
-
agenda: 'Agenda',
|
|
48
|
-
allDay: 'All day',
|
|
49
|
-
more: '+{count} more',
|
|
50
|
-
emptyDay: 'Nothing scheduled',
|
|
51
|
-
};
|
|
1
|
+
export type {
|
|
2
|
+
CalendarTone,
|
|
3
|
+
CalendarScreenView,
|
|
4
|
+
CalendarItem,
|
|
5
|
+
CalendarLegendEntry,
|
|
6
|
+
CalendarLabels,
|
|
7
|
+
} from '@umituz/web-design-system/organisms';
|
|
8
|
+
export { DEFAULT_CALENDAR_LABELS } from '@umituz/web-design-system/organisms';
|
|
@@ -1,221 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function addMonthsKey(dayKey: string, months: number): string {
|
|
33
|
-
const date = parseDayKey(dayKey);
|
|
34
|
-
const dayOfMonth = date.getDate();
|
|
35
|
-
date.setDate(1);
|
|
36
|
-
date.setMonth(date.getMonth() + months);
|
|
37
|
-
const lastDay = new Date(date.getFullYear(), date.getMonth() + 1, 0).getDate();
|
|
38
|
-
date.setDate(Math.min(dayOfMonth, lastDay));
|
|
39
|
-
return toDayKey(date);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function startOfWeekKey(dayKey: string, weekStartsOn: 0 | 1 = 1): string {
|
|
43
|
-
const back = (parseDayKey(dayKey).getDay() + 7 - weekStartsOn) % 7;
|
|
44
|
-
return addDaysKey(dayKey, -back);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function weekDays(anchorKey: string, weekStartsOn: 0 | 1 = 1): string[] {
|
|
48
|
-
const start = startOfWeekKey(anchorKey, weekStartsOn);
|
|
49
|
-
return Array.from({ length: 7 }, (_, index) => addDaysKey(start, index));
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export function monthMatrix(anchorKey: string, weekStartsOn: 0 | 1 = 1): string[] {
|
|
53
|
-
const firstOfMonth = `${anchorKey.slice(0, 7)}-01`;
|
|
54
|
-
const start = startOfWeekKey(firstOfMonth, weekStartsOn);
|
|
55
|
-
return Array.from({ length: 42 }, (_, index) => addDaysKey(start, index));
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export function sameMonth(firstKey: string, secondKey: string): boolean {
|
|
59
|
-
return firstKey.slice(0, 7) === secondKey.slice(0, 7);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function formatWeekdayShort(dayKey: string, locale = 'en-US'): string {
|
|
63
|
-
return parseDayKey(dayKey).toLocaleDateString(locale, { weekday: 'short' });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function formatDayNumber(dayKey: string): string {
|
|
67
|
-
return String(Number(dayKey.slice(8)));
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export function formatMonthTitle(anchorKey: string, locale = 'en-US'): string {
|
|
71
|
-
return parseDayKey(anchorKey).toLocaleDateString(locale, { month: 'long', year: 'numeric' });
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export function formatWeekTitle(anchorKey: string, locale = 'en-US'): string {
|
|
75
|
-
const days = weekDays(anchorKey);
|
|
76
|
-
const first = parseDayKey(days[0] ?? anchorKey);
|
|
77
|
-
const last = parseDayKey(days[6] ?? anchorKey);
|
|
78
|
-
const left = first.toLocaleDateString(locale, { month: 'short', day: 'numeric' });
|
|
79
|
-
const rightOptions: Intl.DateTimeFormatOptions =
|
|
80
|
-
first.getMonth() === last.getMonth()
|
|
81
|
-
? { day: 'numeric', year: 'numeric' }
|
|
82
|
-
: { month: 'short', day: 'numeric', year: 'numeric' };
|
|
83
|
-
return `${left} – ${last.toLocaleDateString(locale, rightOptions)}`;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function formatDayTitle(dayKey: string, locale = 'en-US'): string {
|
|
87
|
-
return parseDayKey(dayKey).toLocaleDateString(locale, {
|
|
88
|
-
weekday: 'long',
|
|
89
|
-
month: 'long',
|
|
90
|
-
day: 'numeric',
|
|
91
|
-
year: 'numeric',
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function formatAgendaTitle(anchorKey: string, days: number, locale = 'en-US'): string {
|
|
96
|
-
const span = Math.max(days - 1, 0);
|
|
97
|
-
const from = parseDayKey(anchorKey).toLocaleDateString(locale, { month: 'short', day: 'numeric' });
|
|
98
|
-
const to = parseDayKey(addDaysKey(anchorKey, span)).toLocaleDateString(locale, {
|
|
99
|
-
month: 'short',
|
|
100
|
-
day: 'numeric',
|
|
101
|
-
year: 'numeric',
|
|
102
|
-
});
|
|
103
|
-
return `${from} – ${to}`;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function minutesToLabel(minutes: number): string {
|
|
107
|
-
const normalized = ((Math.round(minutes) % DAY_MINUTES) + DAY_MINUTES) % DAY_MINUTES;
|
|
108
|
-
return `${pad(Math.floor(normalized / 60))}:${pad(normalized % 60)}`;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
export interface CalendarSpan {
|
|
112
|
-
startMin: number;
|
|
113
|
-
endMin: number;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export function itemSpan(item: CalendarItem): CalendarSpan {
|
|
117
|
-
const startMin = item.startMin ?? 0;
|
|
118
|
-
const endMin = item.endMin ?? Math.min(startMin + 60, DAY_MINUTES);
|
|
119
|
-
return { startMin, endMin: Math.max(endMin, startMin) };
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function spansOverlap(first: CalendarSpan, second: CalendarSpan): boolean {
|
|
123
|
-
return first.startMin < second.endMin && second.startMin < first.endMin;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function findConflicts<T extends CalendarItem>(items: readonly T[]): T[] {
|
|
127
|
-
const sorted = [...items]
|
|
128
|
-
.map((item) => ({ item, span: itemSpan(item) }))
|
|
129
|
-
.sort((first, second) => first.span.startMin - second.span.startMin);
|
|
130
|
-
const conflicted = new Set<string>();
|
|
131
|
-
for (let index = 0; index < sorted.length; index += 1) {
|
|
132
|
-
for (let other = index + 1; other < sorted.length; other += 1) {
|
|
133
|
-
if (sorted[other]!.span.startMin >= sorted[index]!.span.endMin) break;
|
|
134
|
-
conflicted.add(sorted[index]!.item.id);
|
|
135
|
-
conflicted.add(sorted[other]!.item.id);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return items.filter((item) => conflicted.has(item.id));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
export interface PositionedItem<T extends CalendarItem> {
|
|
142
|
-
item: T;
|
|
143
|
-
column: number;
|
|
144
|
-
columns: number;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export function layoutColumns<T extends CalendarItem>(items: readonly T[]): PositionedItem<T>[] {
|
|
148
|
-
const sorted = [...items].sort((first, second) => {
|
|
149
|
-
const firstSpan = itemSpan(first);
|
|
150
|
-
const secondSpan = itemSpan(second);
|
|
151
|
-
return firstSpan.startMin === secondSpan.startMin
|
|
152
|
-
? secondSpan.endMin - firstSpan.endMin
|
|
153
|
-
: firstSpan.startMin - secondSpan.startMin;
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
const placed: PositionedItem<T>[] = [];
|
|
157
|
-
let cluster: PositionedItem<T>[] = [];
|
|
158
|
-
let clusterEnd = -1;
|
|
159
|
-
|
|
160
|
-
const flush = () => {
|
|
161
|
-
for (const entry of cluster) entry.columns = cluster.length;
|
|
162
|
-
placed.push(...cluster);
|
|
163
|
-
cluster = [];
|
|
164
|
-
clusterEnd = -1;
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
for (const item of sorted) {
|
|
168
|
-
const span = itemSpan(item);
|
|
169
|
-
if (cluster.length > 0 && span.startMin >= clusterEnd) flush();
|
|
170
|
-
clusterEnd = Math.max(clusterEnd, span.endMin);
|
|
171
|
-
const column = cluster.findIndex((entry) => itemSpan(entry.item).endMin <= span.startMin);
|
|
172
|
-
cluster.push({ item, column: column === -1 ? cluster.length : column, columns: 1 });
|
|
173
|
-
}
|
|
174
|
-
flush();
|
|
175
|
-
return placed;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export function eventGeometry(
|
|
179
|
-
item: CalendarItem,
|
|
180
|
-
dayStartMin: number,
|
|
181
|
-
dayEndMin: number,
|
|
182
|
-
): { top: number; height: number } {
|
|
183
|
-
const span = itemSpan(item);
|
|
184
|
-
const total = Math.max(dayEndMin - dayStartMin, 1);
|
|
185
|
-
const start = (span.startMin - dayStartMin) / total;
|
|
186
|
-
const end = Math.min((span.endMin - dayStartMin) / total, 1);
|
|
187
|
-
const clampedStart = Math.max(start, 0);
|
|
188
|
-
return { top: clampedStart * 100, height: Math.max(end - clampedStart, 0.012) * 100 };
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
export interface DaySlot {
|
|
192
|
-
startMin: number;
|
|
193
|
-
endMin: number;
|
|
194
|
-
taken: boolean;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export function generateDaySlots(
|
|
198
|
-
options: { startMin: number; endMin: number; durationMin: number; stepMin?: number },
|
|
199
|
-
booked: readonly CalendarSpan[] = [],
|
|
200
|
-
): DaySlot[] {
|
|
201
|
-
const step = options.stepMin ?? options.durationMin;
|
|
202
|
-
const slots: DaySlot[] = [];
|
|
203
|
-
for (let start = options.startMin; start + options.durationMin <= options.endMin; start += step) {
|
|
204
|
-
const slot = { startMin: start, endMin: start + options.durationMin };
|
|
205
|
-
slots.push({ ...slot, taken: booked.some((span) => spansOverlap(slot, span)) });
|
|
206
|
-
}
|
|
207
|
-
return slots;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
export function groupByDayKey<T extends CalendarItem>(items: readonly T[]): Map<string, T[]> {
|
|
211
|
-
const map = new Map<string, T[]>();
|
|
212
|
-
for (const item of items) {
|
|
213
|
-
const bucket = map.get(item.dayKey);
|
|
214
|
-
if (bucket) bucket.push(item);
|
|
215
|
-
else map.set(item.dayKey, [item]);
|
|
216
|
-
}
|
|
217
|
-
for (const bucket of map.values()) {
|
|
218
|
-
bucket.sort((first, second) => itemSpan(first).startMin - itemSpan(second).startMin);
|
|
219
|
-
}
|
|
220
|
-
return map;
|
|
221
|
-
}
|
|
1
|
+
export {
|
|
2
|
+
DAY_MINUTES,
|
|
3
|
+
DEFAULT_DAY_START_MIN,
|
|
4
|
+
DEFAULT_DAY_END_MIN,
|
|
5
|
+
DEFAULT_MAX_PER_DAY,
|
|
6
|
+
SLOT_QUANTUM_MIN,
|
|
7
|
+
parseDayKey,
|
|
8
|
+
toDayKey,
|
|
9
|
+
todayKey,
|
|
10
|
+
addDaysKey,
|
|
11
|
+
addMonthsKey,
|
|
12
|
+
startOfWeekKey,
|
|
13
|
+
weekDays,
|
|
14
|
+
monthMatrix,
|
|
15
|
+
sameMonth,
|
|
16
|
+
formatWeekdayShort,
|
|
17
|
+
formatDayNumber,
|
|
18
|
+
formatMonthTitle,
|
|
19
|
+
formatWeekTitle,
|
|
20
|
+
formatDayTitle,
|
|
21
|
+
formatAgendaTitle,
|
|
22
|
+
minutesToLabel,
|
|
23
|
+
itemSpan,
|
|
24
|
+
spansOverlap,
|
|
25
|
+
findConflicts,
|
|
26
|
+
layoutColumns,
|
|
27
|
+
eventGeometry,
|
|
28
|
+
generateDaySlots,
|
|
29
|
+
groupByDayKey,
|
|
30
|
+
} from '@umituz/web-design-system/organisms';
|
|
31
|
+
export type { CalendarSpan, DaySlot, PositionedItem } from '@umituz/web-design-system/organisms';
|
package/src/styles/chrome.css
CHANGED
|
@@ -1503,38 +1503,43 @@
|
|
|
1503
1503
|
font-size: var(--udb-font-size-md);
|
|
1504
1504
|
line-height: 1.5;
|
|
1505
1505
|
}
|
|
1506
|
-
|
|
1507
|
-
.
|
|
1508
|
-
.
|
|
1509
|
-
|
|
1510
|
-
.udb-onb
|
|
1511
|
-
.udb-onb
|
|
1512
|
-
.udb-onb
|
|
1513
|
-
.udb-onb
|
|
1514
|
-
.udb-onb
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
.udb-onb
|
|
1518
|
-
.udb-onb
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
.udb-onb
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1506
|
+
/* Element resets live in the base layer so consumer utility classes
|
|
1507
|
+
* (e.g. a Button's bg-primary/p-4 from @umituz/web-design-system) can
|
|
1508
|
+
* override them — unlayered resets would always win the cascade. */
|
|
1509
|
+
@layer base {
|
|
1510
|
+
.udb-onb h1,
|
|
1511
|
+
.udb-onb h2,
|
|
1512
|
+
.udb-onb h3,
|
|
1513
|
+
.udb-onb p,
|
|
1514
|
+
.udb-onb ul,
|
|
1515
|
+
.udb-onb ol,
|
|
1516
|
+
.udb-onb figure,
|
|
1517
|
+
.udb-onb blockquote,
|
|
1518
|
+
.udb-onb pre {
|
|
1519
|
+
margin: 0;
|
|
1520
|
+
}
|
|
1521
|
+
.udb-onb ul,
|
|
1522
|
+
.udb-onb ol {
|
|
1523
|
+
list-style: none;
|
|
1524
|
+
padding: 0;
|
|
1525
|
+
}
|
|
1526
|
+
.udb-onb button,
|
|
1527
|
+
.udb-onb input,
|
|
1528
|
+
.udb-onb select,
|
|
1529
|
+
.udb-onb textarea {
|
|
1530
|
+
font: inherit;
|
|
1531
|
+
color: inherit;
|
|
1532
|
+
margin: 0;
|
|
1533
|
+
}
|
|
1534
|
+
.udb-onb button {
|
|
1535
|
+
padding: 0;
|
|
1536
|
+
background: none;
|
|
1537
|
+
border: 0;
|
|
1538
|
+
cursor: pointer;
|
|
1539
|
+
}
|
|
1540
|
+
.udb-onb cite {
|
|
1541
|
+
font-style: normal;
|
|
1542
|
+
}
|
|
1538
1543
|
}
|
|
1539
1544
|
.udb-onb img,
|
|
1540
1545
|
.udb-onb svg {
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
-
import { Calendar } from './Calendar';
|
|
4
|
-
import type { CalendarItem } from '../types/view.types';
|
|
5
|
-
|
|
6
|
-
const item = (id: string, dayKey: string, startMin?: number, endMin?: number): CalendarItem => ({
|
|
7
|
-
id,
|
|
8
|
-
dayKey,
|
|
9
|
-
startMin,
|
|
10
|
-
endMin,
|
|
11
|
-
title: id,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const mount = (props: Partial<Parameters<typeof Calendar>[0]> = {}) =>
|
|
15
|
-
render(
|
|
16
|
-
<Calendar
|
|
17
|
-
items={[item('Kickoff', '2026-03-15', 600, 660)]}
|
|
18
|
-
cursor="2026-03-10"
|
|
19
|
-
{...props}
|
|
20
|
-
/>,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
describe('Calendar', () => {
|
|
24
|
-
it('renders the month grid with a localized title by default', () => {
|
|
25
|
-
const { container } = mount();
|
|
26
|
-
expect(screen.getByText('March 2026')).toBeTruthy();
|
|
27
|
-
expect(container.querySelectorAll('[role="gridcell"]')).toHaveLength(42);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it('switches to a seven-lane week grid and a single day grid', () => {
|
|
31
|
-
mount();
|
|
32
|
-
fireEvent.click(screen.getByText('Week'));
|
|
33
|
-
expect(screen.getByRole('region', { name: '2026-03-15' })).toBeTruthy();
|
|
34
|
-
fireEvent.click(screen.getByText('Day'));
|
|
35
|
-
expect(screen.getByText('Tuesday, March 10, 2026')).toBeTruthy();
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('drills from a month cell into the day view', () => {
|
|
39
|
-
const onSelectDay = vi.fn();
|
|
40
|
-
render(
|
|
41
|
-
<Calendar
|
|
42
|
-
items={[item('Kickoff', '2026-03-15', 600, 660)]}
|
|
43
|
-
initialCursor="2026-03-10"
|
|
44
|
-
onSelectDay={onSelectDay}
|
|
45
|
-
/>,
|
|
46
|
-
);
|
|
47
|
-
fireEvent.click(screen.getByRole('button', { name: '2026-03-15' }));
|
|
48
|
-
expect(onSelectDay).toHaveBeenCalledWith('2026-03-15');
|
|
49
|
-
expect(screen.getByText('Sunday, March 15, 2026')).toBeTruthy();
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it('stays in the month view when the day view is not offered', () => {
|
|
53
|
-
render(
|
|
54
|
-
<Calendar
|
|
55
|
-
items={[{ id: 'Expiry', dayKey: '2026-03-15', title: 'Expiry' }]}
|
|
56
|
-
initialCursor="2026-03-10"
|
|
57
|
-
views={['month', 'agenda']}
|
|
58
|
-
/>,
|
|
59
|
-
);
|
|
60
|
-
fireEvent.click(screen.getByRole('button', { name: '2026-03-15' }));
|
|
61
|
-
expect(screen.getByText('March 2026')).toBeTruthy();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('respects a controlled view', () => {
|
|
65
|
-
mount({ view: 'day' });
|
|
66
|
-
expect(screen.getByText('Tuesday, March 10, 2026')).toBeTruthy();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('reports view changes', () => {
|
|
70
|
-
const onViewChange = vi.fn();
|
|
71
|
-
mount({ onViewChange });
|
|
72
|
-
fireEvent.click(screen.getByText('Week'));
|
|
73
|
-
expect(onViewChange).toHaveBeenCalledWith('week');
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it('renders the legend', () => {
|
|
77
|
-
mount({ legend: [{ tone: 'success', label: 'Confirmed' }] });
|
|
78
|
-
expect(screen.getByText('Confirmed')).toBeTruthy();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it('renders toolbar extras inside the toolbar', () => {
|
|
82
|
-
mount({ toolbarExtra: <span className="calendar-count">4 appointments</span> });
|
|
83
|
-
const extra = screen.getByText('4 appointments').closest('.udb-cal-extra');
|
|
84
|
-
expect(extra).toBeTruthy();
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it('switches to the agenda view with a window title', () => {
|
|
88
|
-
mount({ views: ['month', 'agenda'] });
|
|
89
|
-
fireEvent.click(screen.getByText('Agenda'));
|
|
90
|
-
expect(screen.getByText('Mar 10 – Apr 8, 2026')).toBeTruthy();
|
|
91
|
-
expect(screen.getByRole('button', { name: /Kickoff/ })).toBeTruthy();
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('shifts the agenda window by agendaDays', () => {
|
|
95
|
-
render(
|
|
96
|
-
<Calendar
|
|
97
|
-
items={[item('Kickoff', '2026-03-15', 600, 660)]}
|
|
98
|
-
initialCursor="2026-03-10"
|
|
99
|
-
views={['agenda']}
|
|
100
|
-
agendaDays={30}
|
|
101
|
-
/>,
|
|
102
|
-
);
|
|
103
|
-
fireEvent.click(screen.getByRole('button', { name: 'Next' }));
|
|
104
|
-
expect(screen.getByText('Apr 9 – May 8, 2026')).toBeTruthy();
|
|
105
|
-
});
|
|
106
|
-
});
|