@umituz/web-dashboard 11.10.0 → 11.11.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "11.10.0",
3
+ "version": "11.11.0",
4
4
  "description": "Installable app skeleton for the fleet — layouts, analytics (dependency-free SVG charts), calendar, onboarding flow permissions/module registry; udb-* stylesheet on design-system tokens",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
@@ -1 +1,192 @@
1
+ .udb-cal-page {
2
+ display: flex;
3
+ flex-direction: column;
4
+ width: 100%;
5
+ gap: var(--udb-space-5, 20px);
6
+ }
1
7
 
8
+ .udb-cal-callout {
9
+ width: 100%;
10
+ }
11
+
12
+ .udb-cal-legend {
13
+ display: flex;
14
+ flex-wrap: wrap;
15
+ align-items: center;
16
+ gap: 8px;
17
+ }
18
+
19
+ .udb-cal-chip {
20
+ display: inline-flex;
21
+ align-items: center;
22
+ gap: 6px;
23
+ padding: 6px 12px;
24
+ font-size: 13px;
25
+ font-weight: 500;
26
+ border-radius: var(--radius-md, 8px);
27
+ border: 1px solid var(--color-border, #e2e8f0);
28
+ background: var(--color-card, #ffffff);
29
+ color: var(--color-foreground, #0f172a);
30
+ cursor: pointer;
31
+ transition: all 0.15s ease;
32
+ user-select: none;
33
+ }
34
+
35
+ .udb-cal-chip:hover {
36
+ background: var(--color-muted, #f1f5f9);
37
+ }
38
+
39
+ .udb-cal-chip:focus-visible {
40
+ outline: 2px solid var(--color-ring, #2563eb);
41
+ outline-offset: 2px;
42
+ }
43
+
44
+ .udb-cal-chip.is-active {
45
+ background: var(--color-primary, #2563eb);
46
+ color: var(--color-primary-foreground, #ffffff);
47
+ border-color: var(--color-primary, #2563eb);
48
+ }
49
+
50
+ .udb-cal-chip.is-active .udb-cal-count {
51
+ background: rgba(255, 255, 255, 0.2);
52
+ color: #ffffff;
53
+ }
54
+
55
+ .udb-cal-count {
56
+ display: inline-flex;
57
+ align-items: center;
58
+ justify-content: center;
59
+ padding: 1px 6px;
60
+ font-size: 11px;
61
+ border-radius: 9999px;
62
+ background: var(--color-muted, #f1f5f9);
63
+ color: var(--color-muted-foreground, #64748b);
64
+ font-variant-numeric: tabular-nums;
65
+ }
66
+
67
+ .udb-cal-card {
68
+ border-radius: var(--radius-lg, 12px);
69
+ border: 1px solid var(--color-border, #e2e8f0);
70
+ background: var(--color-card, #ffffff);
71
+ overflow: hidden;
72
+ }
73
+
74
+ .udb-cal-selected-card {
75
+ border-radius: var(--radius-lg, 12px);
76
+ border: 1px solid var(--color-border, #e2e8f0);
77
+ background: var(--color-card, #ffffff);
78
+ padding: 16px;
79
+ display: flex;
80
+ flex-direction: column;
81
+ gap: 12px;
82
+ }
83
+
84
+ .udb-cal-selected-header {
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: space-between;
88
+ flex-wrap: wrap;
89
+ gap: 8px;
90
+ }
91
+
92
+ .udb-cal-selected-header-left {
93
+ display: flex;
94
+ align-items: baseline;
95
+ gap: 10px;
96
+ }
97
+
98
+ .udb-cal-selected-eyebrow {
99
+ font-size: 11px;
100
+ text-transform: uppercase;
101
+ letter-spacing: 0.05em;
102
+ font-weight: 600;
103
+ color: var(--color-muted-foreground, #64748b);
104
+ }
105
+
106
+ .udb-cal-selected-title {
107
+ font-size: 16px;
108
+ font-weight: 600;
109
+ color: var(--color-foreground, #0f172a);
110
+ }
111
+
112
+ .udb-cal-feed-list {
113
+ display: flex;
114
+ flex-direction: column;
115
+ gap: 8px;
116
+ list-style: none;
117
+ padding: 0;
118
+ margin: 0;
119
+ }
120
+
121
+ .udb-cal-feed-item {
122
+ display: flex;
123
+ align-items: center;
124
+ gap: 12px;
125
+ padding: 10px 12px;
126
+ border-radius: var(--radius-md, 8px);
127
+ border: 1px solid var(--color-border, #e2e8f0);
128
+ background: var(--color-card, #ffffff);
129
+ transition: background 0.15s ease;
130
+ }
131
+
132
+ .udb-cal-feed-btn {
133
+ width: 100%;
134
+ text-align: left;
135
+ font: inherit;
136
+ color: inherit;
137
+ cursor: pointer;
138
+ }
139
+
140
+ .udb-cal-feed-btn:hover {
141
+ background: var(--color-muted, #f8fafc);
142
+ }
143
+
144
+ .udb-cal-feed-btn:focus-visible {
145
+ outline: 2px solid var(--color-ring, #2563eb);
146
+ outline-offset: 2px;
147
+ }
148
+
149
+ .udb-cal-feed-item.is-muted {
150
+ opacity: 0.55;
151
+ }
152
+
153
+ .udb-cal-feed-body {
154
+ flex: 1;
155
+ min-width: 0;
156
+ display: flex;
157
+ flex-direction: column;
158
+ gap: 2px;
159
+ }
160
+
161
+ .udb-cal-feed-title {
162
+ font-size: 14px;
163
+ font-weight: 500;
164
+ color: var(--color-foreground, #0f172a);
165
+ overflow: hidden;
166
+ text-overflow: ellipsis;
167
+ white-space: nowrap;
168
+ }
169
+
170
+ .udb-cal-feed-meta {
171
+ font-size: 12px;
172
+ color: var(--color-muted-foreground, #64748b);
173
+ }
174
+
175
+ .udb-cal-feed-end {
176
+ display: flex;
177
+ align-items: center;
178
+ gap: 8px;
179
+ font-size: 12px;
180
+ color: var(--color-muted-foreground, #64748b);
181
+ white-space: nowrap;
182
+ }
183
+
184
+ .udb-cal-empty {
185
+ padding: 16px 0;
186
+ font-size: 13px;
187
+ color: var(--color-muted-foreground, #64748b);
188
+ }
189
+
190
+ .udb-cal-footer {
191
+ width: 100%;
192
+ }
@@ -0,0 +1,178 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, fireEvent, within } from '@testing-library/react';
3
+ import { MemoryRouter } from 'react-router';
4
+ import { CalendarPage } from './CalendarPage';
5
+ import type { CalendarCategory, CalendarPageItem } from '../types';
6
+
7
+ interface TestPayload {
8
+ kind: 'task' | 'inspection';
9
+ priority: string;
10
+ }
11
+
12
+ const ITEMS: readonly CalendarPageItem<TestPayload>[] = [
13
+ {
14
+ id: 'evt-1',
15
+ dayKey: '2026-11-20',
16
+ title: 'HVAC Filter Replacement',
17
+ tone: 'info',
18
+ startMin: 540,
19
+ endMin: 600,
20
+ meta: 'HQ Tower · 3rd Floor',
21
+ kind: 'task',
22
+ payload: { kind: 'task', priority: 'high' },
23
+ },
24
+ {
25
+ id: 'evt-2',
26
+ dayKey: '2026-11-20',
27
+ title: 'Fire Safety Inspection',
28
+ tone: 'warning',
29
+ startMin: 660,
30
+ endMin: 720,
31
+ meta: 'DC Annex',
32
+ kind: 'inspection',
33
+ payload: { kind: 'inspection', priority: 'critical' },
34
+ },
35
+ {
36
+ id: 'evt-3',
37
+ dayKey: '2026-11-21',
38
+ title: 'Roof Membrane Check',
39
+ tone: 'info',
40
+ meta: 'HQ Tower',
41
+ kind: 'task',
42
+ payload: { kind: 'task', priority: 'medium' },
43
+ },
44
+ ];
45
+
46
+ const CATEGORIES: readonly CalendarCategory[] = [
47
+ { id: 'task', label: 'Tasks', tone: 'info' },
48
+ { id: 'inspection', label: 'Inspections', tone: 'warning' },
49
+ ];
50
+
51
+ function mount(props: Partial<Parameters<typeof CalendarPage<TestPayload>>[0]> = {}) {
52
+ return render(
53
+ <MemoryRouter>
54
+ <CalendarPage<TestPayload>
55
+ title="Site Operations"
56
+ subtitle="Operational schedule"
57
+ items={ITEMS}
58
+ initialCursor="2026-11-20"
59
+ initialSelectedDay="2026-11-20"
60
+ {...props}
61
+ />
62
+ </MemoryRouter>,
63
+ );
64
+ }
65
+
66
+ describe('CalendarPage', () => {
67
+ it('renders header, subtitle and calendar events', () => {
68
+ mount();
69
+ expect(screen.getByText('Site Operations')).toBeDefined();
70
+ expect(screen.getByText('Operational schedule')).toBeDefined();
71
+ expect(screen.getAllByText('HVAC Filter Replacement').length).toBeGreaterThan(0);
72
+ });
73
+
74
+ it('renders custom actions correctly', () => {
75
+ const handleAdd = vi.fn();
76
+ mount({
77
+ actions: {
78
+ label: 'Add Event',
79
+ onClick: handleAdd,
80
+ },
81
+ });
82
+ const addBtn = screen.getByRole('button', { name: /Add Event/i });
83
+ expect(addBtn).toBeDefined();
84
+ fireEvent.click(addBtn);
85
+ expect(handleAdd).toHaveBeenCalledTimes(1);
86
+ });
87
+
88
+ it('renders multiple actions as array', () => {
89
+ const fn1 = vi.fn();
90
+ const fn2 = vi.fn();
91
+ mount({
92
+ actions: [
93
+ { label: 'Action 1', onClick: fn1 },
94
+ { label: 'Action 2', onClick: fn2 },
95
+ ],
96
+ });
97
+ expect(screen.getByRole('button', { name: /Action 1/i })).toBeDefined();
98
+ expect(screen.getByRole('button', { name: /Action 2/i })).toBeDefined();
99
+ });
100
+
101
+ it('renders categories with counts and filters items on category click', () => {
102
+ mount({
103
+ categories: CATEGORIES,
104
+ selectedDayDetail: true,
105
+ });
106
+
107
+ expect(screen.getByText('Tasks')).toBeDefined();
108
+ expect(screen.getByText('Inspections')).toBeDefined();
109
+
110
+ const inspectionChip = screen.getByRole('button', { name: /Inspections/i });
111
+ fireEvent.click(inspectionChip);
112
+
113
+ const allChip = screen.getByRole('button', { name: /^All/i });
114
+ fireEvent.click(allChip);
115
+ expect(allChip.getAttribute('aria-pressed')).toBe('true');
116
+ });
117
+
118
+ it('supports single category filter mode', () => {
119
+ mount({
120
+ categories: CATEGORIES,
121
+ categoryMode: 'single',
122
+ selectedDayDetail: true,
123
+ });
124
+
125
+ const taskChip = screen.getByRole('button', { name: /Tasks/i });
126
+ fireEvent.click(taskChip);
127
+ expect(taskChip.getAttribute('aria-pressed')).toBe('true');
128
+
129
+ const allChip = screen.getByRole('button', { name: /^All/i });
130
+ expect(allChip.getAttribute('aria-pressed')).toBe('false');
131
+ });
132
+
133
+ it('renders selected day detail panel when enabled', () => {
134
+ const onSelect = vi.fn();
135
+ const onAddForDay = vi.fn();
136
+ mount({
137
+ selectedDayDetail: {
138
+ action: {
139
+ label: 'Create for day',
140
+ onClick: onAddForDay,
141
+ },
142
+ },
143
+ onSelectItem: onSelect,
144
+ });
145
+
146
+ const panel = screen.getByTestId('calendar-selected-day-panel');
147
+ expect(panel).toBeDefined();
148
+
149
+ const addForDayBtn = screen.getByRole('button', { name: /Create for day/i });
150
+ fireEvent.click(addForDayBtn);
151
+ expect(onAddForDay).toHaveBeenCalledWith('2026-11-20');
152
+
153
+ const itemRow = within(panel).getByText('HVAC Filter Replacement');
154
+ fireEvent.click(itemRow);
155
+ expect(onSelect).toHaveBeenCalled();
156
+ });
157
+
158
+ it('shows empty text in selected day detail panel when no items exist', () => {
159
+ mount({
160
+ selectedDay: '2026-11-25',
161
+ selectedDayDetail: {
162
+ emptyText: 'Zero tasks today.',
163
+ },
164
+ });
165
+
166
+ expect(screen.getByText('Zero tasks today.')).toBeDefined();
167
+ });
168
+
169
+ it('supports custom renderItem and renderEmpty in selected day panel', () => {
170
+ mount({
171
+ selectedDayDetail: {
172
+ renderItem: (item) => <div data-testid="custom-item">{item.title} (custom)</div>,
173
+ },
174
+ });
175
+
176
+ expect(screen.getByText('HVAC Filter Replacement (custom)')).toBeDefined();
177
+ });
178
+ });
@@ -0,0 +1,296 @@
1
+ import { useCallback, useMemo, useState, type ReactNode } from 'react';
2
+ import { PageHeader } from '@umituz/web-design-system/templates';
3
+ import { Calendar } from '@umituz/web-design-system/organisms';
4
+ import { Button } from '@umituz/web-design-system/atoms';
5
+ import { todayKey } from '@umituz/web-design-system/utils';
6
+ import type {
7
+ CalendarCategory,
8
+ CalendarPageAction,
9
+ CalendarPageItem,
10
+ CalendarPageProps,
11
+ CalendarScreenView,
12
+ CalendarSelectedDayConfig,
13
+ } from '../types';
14
+ import { CalendarSelectedDayPanel } from './CalendarSelectedDayPanel';
15
+
16
+ const matchesCategory = (
17
+ item: CalendarPageItem<unknown>,
18
+ cat: CalendarCategory,
19
+ ): boolean => {
20
+ if (cat.match) return cat.match(item);
21
+ if (item.category === cat.id) return true;
22
+ if (item.kind === cat.id) return true;
23
+ if (item.tone === cat.id) return true;
24
+ const payload = item.payload as Record<string, unknown> | null | undefined;
25
+ if (payload && typeof payload === 'object') {
26
+ if (payload.kind === cat.id) return true;
27
+ if (payload.type === cat.id) return true;
28
+ if (payload.category === cat.id) return true;
29
+ }
30
+ if (cat.tone && item.tone === cat.tone) return true;
31
+ return false;
32
+ };
33
+
34
+ export function CalendarPage<T = unknown>({
35
+ title,
36
+ subtitle,
37
+ kicker,
38
+ actions,
39
+ callout,
40
+ items,
41
+ categories,
42
+ categoryMode = 'multiple',
43
+ activeCategoryIds,
44
+ onActiveCategoriesChange,
45
+ views,
46
+ defaultView,
47
+ view,
48
+ onViewChange,
49
+ cursor,
50
+ initialCursor,
51
+ onCursorChange,
52
+ selectedDay,
53
+ initialSelectedDay,
54
+ onSelectDay,
55
+ selectedDayDetail,
56
+ onSelectItem,
57
+ onSlotClick,
58
+ weekStartsOn = 1,
59
+ dayStartMin,
60
+ dayEndMin,
61
+ maxPerDay,
62
+ agendaDays,
63
+ locale,
64
+ labels,
65
+ toolbarExtra,
66
+ footer,
67
+ children,
68
+ className,
69
+ }: CalendarPageProps<T>): ReactNode {
70
+ const [internalView, setInternalView] = useState<CalendarScreenView>(
71
+ () => defaultView ?? 'month',
72
+ );
73
+ const currentView = view ?? internalView;
74
+ const handleViewChange = useCallback(
75
+ (nextView: CalendarScreenView) => {
76
+ if (onViewChange) {
77
+ onViewChange(nextView);
78
+ }
79
+ setInternalView(nextView);
80
+ },
81
+ [onViewChange],
82
+ );
83
+
84
+ const [internalCategoryIds, setInternalCategoryIds] = useState<readonly string[]>(() =>
85
+ categories ? categories.map((c) => c.id) : [],
86
+ );
87
+ const activeIds = activeCategoryIds ?? internalCategoryIds;
88
+ const activeSet = useMemo(() => new Set(activeIds), [activeIds]);
89
+
90
+ const isAllActive =
91
+ !categories || categories.length === 0 || activeIds.length === categories.length;
92
+
93
+ const handleCategoryToggle = (catId: string) => {
94
+ let next: string[];
95
+ if (categoryMode === 'single') {
96
+ const isCurrentlySingle = activeIds.length === 1 && activeIds[0] === catId;
97
+ next = isCurrentlySingle ? (categories ?? []).map((c) => c.id) : [catId];
98
+ } else {
99
+ const set = new Set(activeIds);
100
+ if (set.has(catId)) {
101
+ set.delete(catId);
102
+ } else {
103
+ set.add(catId);
104
+ }
105
+ next = Array.from(set);
106
+ }
107
+ if (onActiveCategoriesChange) {
108
+ onActiveCategoriesChange(next);
109
+ } else {
110
+ setInternalCategoryIds(next);
111
+ }
112
+ };
113
+
114
+ const handleSelectAllCategories = () => {
115
+ const allIds = (categories ?? []).map((c) => c.id);
116
+ if (onActiveCategoriesChange) {
117
+ onActiveCategoriesChange(allIds);
118
+ } else {
119
+ setInternalCategoryIds(allIds);
120
+ }
121
+ };
122
+
123
+ const categoryCounts = useMemo(() => {
124
+ if (!categories) return new Map<string, number>();
125
+ const counts = new Map<string, number>();
126
+ for (const cat of categories) {
127
+ const count = items.filter((item) => matchesCategory(item, cat)).length;
128
+ counts.set(cat.id, count);
129
+ }
130
+ return counts;
131
+ }, [categories, items]);
132
+
133
+ const filteredItems = useMemo(() => {
134
+ if (!categories || categories.length === 0 || isAllActive) {
135
+ return items;
136
+ }
137
+ const activeCats = categories.filter((c) => activeSet.has(c.id));
138
+ return items.filter((item) => activeCats.some((cat) => matchesCategory(item, cat)));
139
+ }, [items, categories, isAllActive, activeSet]);
140
+
141
+ const [internalSelectedDay, setInternalSelectedDay] = useState<string>(() =>
142
+ initialSelectedDay ?? initialCursor ?? todayKey(),
143
+ );
144
+ const currentSelectedDay = selectedDay !== undefined ? selectedDay : internalSelectedDay;
145
+
146
+ const handleSelectDay = useCallback(
147
+ (dayKey: string) => {
148
+ if (onSelectDay) {
149
+ onSelectDay(dayKey);
150
+ }
151
+ setInternalSelectedDay(dayKey);
152
+ },
153
+ [onSelectDay],
154
+ );
155
+
156
+ const detailConfig: CalendarSelectedDayConfig<T> | null = useMemo(() => {
157
+ if (!selectedDayDetail) return null;
158
+ if (typeof selectedDayDetail === 'boolean') return {};
159
+ return selectedDayDetail;
160
+ }, [selectedDayDetail]);
161
+
162
+ const selectedDayItems = useMemo(() => {
163
+ if (!currentSelectedDay) return [];
164
+ return filteredItems.filter((item) => item.dayKey === currentSelectedDay);
165
+ }, [filteredItems, currentSelectedDay]);
166
+
167
+ const renderedActions = useMemo(() => {
168
+ if (!actions) return undefined;
169
+ if (Array.isArray(actions)) {
170
+ return (
171
+ <div className="flex items-center gap-2">
172
+ {actions.map((act) => (
173
+ <Button
174
+ key={act.label}
175
+ variant={act.variant ?? 'outline'}
176
+ onClick={act.onClick}
177
+ disabled={act.disabled}
178
+ size="sm"
179
+ >
180
+ {act.icon}
181
+ {act.label}
182
+ </Button>
183
+ ))}
184
+ </div>
185
+ );
186
+ }
187
+ if (
188
+ typeof actions === 'object' &&
189
+ actions !== null &&
190
+ 'onClick' in actions &&
191
+ 'label' in actions
192
+ ) {
193
+ const act = actions as CalendarPageAction;
194
+ return (
195
+ <Button
196
+ variant={act.variant ?? 'primary'}
197
+ onClick={act.onClick}
198
+ disabled={act.disabled}
199
+ size="sm"
200
+ >
201
+ {act.icon}
202
+ {act.label}
203
+ </Button>
204
+ );
205
+ }
206
+ return actions as ReactNode;
207
+ }, [actions]);
208
+
209
+ return (
210
+ <div className={`udb-cal-page ${className ?? ''}`.trim()}>
211
+ <PageHeader
212
+ kicker={kicker}
213
+ title={title}
214
+ subtitle={subtitle}
215
+ actions={renderedActions}
216
+ />
217
+
218
+ {callout && <div className="udb-cal-callout">{callout}</div>}
219
+
220
+ {categories && categories.length > 0 && (
221
+ <div className="udb-cal-legend" role="toolbar" aria-label="Filter by category">
222
+ <button
223
+ type="button"
224
+ className={`udb-cal-chip${isAllActive ? ' is-active' : ''}`}
225
+ onClick={handleSelectAllCategories}
226
+ aria-pressed={isAllActive}
227
+ >
228
+ <span>{labels?.allCategories ?? 'All'}</span>
229
+ <span className="udb-cal-count">{items.length}</span>
230
+ </button>
231
+ {categories.map((cat) => {
232
+ const isActive = activeSet.has(cat.id);
233
+ const count = categoryCounts.get(cat.id) ?? 0;
234
+ return (
235
+ <button
236
+ key={cat.id}
237
+ type="button"
238
+ className={`udb-cal-chip${isActive ? ' is-active' : ''}`}
239
+ onClick={() => handleCategoryToggle(cat.id)}
240
+ aria-pressed={isActive}
241
+ >
242
+ <span
243
+ className={`ds-cal-legend-dot ds-cal-dot--${cat.tone ?? 'primary'}`}
244
+ aria-hidden
245
+ />
246
+ {cat.icon}
247
+ <span>{cat.label}</span>
248
+ <span className="udb-cal-count">{count}</span>
249
+ </button>
250
+ );
251
+ })}
252
+ </div>
253
+ )}
254
+
255
+ <div className="udb-cal-card">
256
+ <Calendar
257
+ items={filteredItems}
258
+ views={views}
259
+ view={currentView}
260
+ onViewChange={handleViewChange}
261
+ cursor={cursor}
262
+ initialCursor={initialCursor}
263
+ onCursorChange={onCursorChange}
264
+ weekStartsOn={weekStartsOn}
265
+ dayStartMin={dayStartMin}
266
+ dayEndMin={dayEndMin}
267
+ maxPerDay={maxPerDay}
268
+ agendaDays={agendaDays}
269
+ locale={locale}
270
+ labels={labels}
271
+ toolbarExtra={toolbarExtra}
272
+ onSelectItem={
273
+ onSelectItem
274
+ ? (item) => onSelectItem(item as CalendarPageItem<T>)
275
+ : undefined
276
+ }
277
+ onSelectDay={handleSelectDay}
278
+ onSlotClick={onSlotClick}
279
+ />
280
+ </div>
281
+
282
+ {detailConfig && currentSelectedDay && (
283
+ <CalendarSelectedDayPanel
284
+ config={detailConfig}
285
+ dayKey={currentSelectedDay}
286
+ items={selectedDayItems}
287
+ labels={labels}
288
+ onSelectItem={onSelectItem}
289
+ />
290
+ )}
291
+
292
+ {footer && <div className="udb-cal-footer">{footer}</div>}
293
+ {children}
294
+ </div>
295
+ );
296
+ }
@@ -0,0 +1,136 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Badge, Button } from '@umituz/web-design-system/atoms';
3
+ import { formatDate } from '@umituz/web-design-system/utils';
4
+ import type {
5
+ CalendarPageItem,
6
+ CalendarPageLabels,
7
+ CalendarSelectedDayConfig,
8
+ } from '../types';
9
+
10
+ const formatTime = (minutes?: number): string => {
11
+ if (minutes === undefined || minutes === null) return '';
12
+ const h = Math.floor(minutes / 60);
13
+ const m = minutes % 60;
14
+ return `${String(h).padStart(2, '0')}:${String(m).padStart(2, '0')}`;
15
+ };
16
+
17
+ export interface CalendarSelectedDayPanelProps<T = unknown> {
18
+ config: CalendarSelectedDayConfig<T>;
19
+ dayKey: string;
20
+ items: readonly CalendarPageItem<T>[];
21
+ labels?: CalendarPageLabels;
22
+ onSelectItem?: (item: CalendarPageItem<T>) => void;
23
+ }
24
+
25
+ export function CalendarSelectedDayPanel<T = unknown>({
26
+ config,
27
+ dayKey,
28
+ items,
29
+ labels,
30
+ onSelectItem,
31
+ }: CalendarSelectedDayPanelProps<T>): ReactNode {
32
+ return (
33
+ <section
34
+ className="udb-cal-selected-card"
35
+ data-testid="calendar-selected-day-panel"
36
+ aria-label="Selected day events"
37
+ >
38
+ <header className="udb-cal-selected-header">
39
+ <div className="udb-cal-selected-header-left">
40
+ <span className="udb-cal-selected-eyebrow">
41
+ {labels?.selectedDay ?? 'Selected Day'}
42
+ </span>
43
+ <span className="udb-cal-selected-title">
44
+ {config.title ? config.title(dayKey) : formatDate(dayKey, 'medium')}
45
+ </span>
46
+ <span className="udb-cal-count">
47
+ {labels?.eventsCount ? labels.eventsCount(items.length) : items.length}
48
+ </span>
49
+ </div>
50
+ {config.action && (
51
+ <Button
52
+ size="sm"
53
+ variant="outline"
54
+ onClick={() => config.action!.onClick(dayKey)}
55
+ >
56
+ {config.action.label}
57
+ </Button>
58
+ )}
59
+ </header>
60
+
61
+ {items.length === 0 ? (
62
+ config.renderEmpty ? (
63
+ config.renderEmpty(dayKey)
64
+ ) : (
65
+ <div className="udb-cal-empty">
66
+ {config.emptyText ??
67
+ labels?.noEvents ??
68
+ 'No events scheduled for this day'}
69
+ </div>
70
+ )
71
+ ) : (
72
+ <ul className="udb-cal-feed-list">
73
+ {items.map((item) => (
74
+ <li key={item.id}>
75
+ {config.renderItem ? (
76
+ config.renderItem(item)
77
+ ) : onSelectItem ? (
78
+ <button
79
+ type="button"
80
+ onClick={() => onSelectItem(item)}
81
+ className={`udb-cal-feed-item udb-cal-feed-btn${item.muted ? ' is-muted' : ''}`}
82
+ >
83
+ <span
84
+ className={`ds-cal-legend-dot ds-cal-dot--${item.tone ?? 'primary'}`}
85
+ aria-hidden
86
+ />
87
+ <span className="udb-cal-feed-body">
88
+ <span className="udb-cal-feed-title">{item.title}</span>
89
+ {item.meta && (
90
+ <span className="udb-cal-feed-meta">{item.meta}</span>
91
+ )}
92
+ </span>
93
+ <span className="udb-cal-feed-end">
94
+ {item.startMin !== undefined && (
95
+ <span>
96
+ {item.endMin !== undefined
97
+ ? `${formatTime(item.startMin)} - ${formatTime(item.endMin)}`
98
+ : formatTime(item.startMin)}
99
+ </span>
100
+ )}
101
+ {item.kind && <Badge variant="neutral">{item.kind}</Badge>}
102
+ </span>
103
+ </button>
104
+ ) : (
105
+ <div
106
+ className={`udb-cal-feed-item${item.muted ? ' is-muted' : ''}`}
107
+ >
108
+ <span
109
+ className={`ds-cal-legend-dot ds-cal-dot--${item.tone ?? 'primary'}`}
110
+ aria-hidden
111
+ />
112
+ <div className="udb-cal-feed-body">
113
+ <div className="udb-cal-feed-title">{item.title}</div>
114
+ {item.meta && (
115
+ <div className="udb-cal-feed-meta">{item.meta}</div>
116
+ )}
117
+ </div>
118
+ <div className="udb-cal-feed-end">
119
+ {item.startMin !== undefined && (
120
+ <span>
121
+ {item.endMin !== undefined
122
+ ? `${formatTime(item.startMin)} - ${formatTime(item.endMin)}`
123
+ : formatTime(item.startMin)}
124
+ </span>
125
+ )}
126
+ {item.kind && <Badge variant="neutral">{item.kind}</Badge>}
127
+ </div>
128
+ </div>
129
+ )}
130
+ </li>
131
+ ))}
132
+ </ul>
133
+ )}
134
+ </section>
135
+ );
136
+ }
@@ -13,3 +13,8 @@ export type {
13
13
  CalendarResource,
14
14
  CalendarResourceTimelineProps,
15
15
  } from '@umituz/web-design-system/organisms';
16
+ export { CalendarPage } from './CalendarPage';
17
+ export {
18
+ CalendarSelectedDayPanel,
19
+ type CalendarSelectedDayPanelProps,
20
+ } from './CalendarSelectedDayPanel';
@@ -0,0 +1,91 @@
1
+ import type { ReactNode } from 'react';
2
+ import type {
3
+ CalendarItem,
4
+ CalendarLabels,
5
+ CalendarScreenView,
6
+ CalendarTone,
7
+ } from '@umituz/web-design-system/organisms';
8
+
9
+ export type CalendarPageItem<T = unknown> = CalendarItem & {
10
+ category?: string;
11
+ payload?: T;
12
+ };
13
+
14
+ export interface CalendarCategory {
15
+ id: string;
16
+ label: string;
17
+ tone?: CalendarTone;
18
+ icon?: ReactNode;
19
+ match?: (item: CalendarItem) => boolean;
20
+ }
21
+
22
+ export interface CalendarPageAction {
23
+ label: string;
24
+ onClick: () => void;
25
+ icon?: ReactNode;
26
+ variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'danger';
27
+ disabled?: boolean;
28
+ }
29
+
30
+ export interface CalendarSelectedDayConfig<T = unknown> {
31
+ title?: (dayKey: string) => ReactNode;
32
+ renderItem?: (item: CalendarPageItem<T>) => ReactNode;
33
+ renderEmpty?: (dayKey: string) => ReactNode;
34
+ emptyText?: string;
35
+ action?: {
36
+ label: string;
37
+ onClick: (dayKey: string) => void;
38
+ };
39
+ }
40
+
41
+ export interface CalendarPageLabels extends Partial<CalendarLabels> {
42
+ allCategories?: string;
43
+ selectedDay?: string;
44
+ noEvents?: string;
45
+ eventsCount?: (count: number) => string;
46
+ }
47
+
48
+ export interface CalendarPageProps<T = unknown> {
49
+ title: string;
50
+ subtitle?: string;
51
+ kicker?: ReactNode;
52
+ actions?: ReactNode | CalendarPageAction | readonly CalendarPageAction[];
53
+ callout?: ReactNode;
54
+
55
+ items: readonly CalendarPageItem<T>[];
56
+ categories?: readonly CalendarCategory[];
57
+ categoryMode?: 'single' | 'multiple';
58
+ activeCategoryIds?: readonly string[];
59
+ onActiveCategoriesChange?: (categoryIds: string[]) => void;
60
+
61
+ views?: readonly CalendarScreenView[];
62
+ defaultView?: CalendarScreenView;
63
+ view?: CalendarScreenView;
64
+ onViewChange?: (view: CalendarScreenView) => void;
65
+
66
+ cursor?: string;
67
+ initialCursor?: string;
68
+ onCursorChange?: (dayKey: string) => void;
69
+
70
+ selectedDay?: string | null;
71
+ initialSelectedDay?: string | null;
72
+ onSelectDay?: (dayKey: string) => void;
73
+ selectedDayDetail?: CalendarSelectedDayConfig<T> | boolean;
74
+
75
+ onSelectItem?: (item: CalendarPageItem<T>) => void;
76
+ onSlotClick?: (dayKey: string, minutes: number) => void;
77
+
78
+ weekStartsOn?: 0 | 1;
79
+ dayStartMin?: number;
80
+ dayEndMin?: number;
81
+ maxPerDay?: number;
82
+ agendaDays?: number;
83
+
84
+ locale?: string;
85
+ labels?: CalendarPageLabels;
86
+
87
+ toolbarExtra?: ReactNode;
88
+ footer?: ReactNode;
89
+ children?: ReactNode;
90
+ className?: string;
91
+ }
@@ -1,2 +1,3 @@
1
1
  export * from './calendar.types';
2
2
  export * from './view.types';
3
+ export * from './calendar-page.types';
@@ -78,8 +78,14 @@ export const DashboardHeader = ({
78
78
  return (
79
79
  <header className="udb-header">
80
80
  <div className="udb-header__lead">
81
- <Button variant="ghost" size="icon" className="udb-header__mobile-toggle" onClick={() => setMobileOpen(true)}>
82
- <Menu className="udb-header__toggle-icon" />
81
+ <Button
82
+ variant="ghost"
83
+ size="icon"
84
+ className="udb-header__mobile-toggle"
85
+ onClick={() => setMobileOpen(true)}
86
+ aria-label={labels.openSidebar ?? labels.expandSidebar}
87
+ >
88
+ <Menu className="udb-header__toggle-icon" aria-hidden="true" />
83
89
  </Button>
84
90
 
85
91
  <Button
@@ -132,7 +138,7 @@ export const DashboardHeader = ({
132
138
  <DropdownMenu>
133
139
  <DropdownMenuTrigger asChild>
134
140
  <Button variant="ghost" size="icon" className="udb-header__icon-btn" aria-label={labels.notificationsTitle}>
135
- <Bell className="udb-header__icon" />
141
+ <Bell className="udb-header__icon" aria-hidden="true" />
136
142
  {unreadCount > 0 && <span className="udb-header__unread"><span className="udb-header__unread-core" /></span>}
137
143
 
138
144
  </Button>
@@ -196,7 +196,12 @@ export const DashboardLayout = ({
196
196
 
197
197
  {mobileOpen && (
198
198
  <div className="udb-layout__mobile">
199
- <div className="udb-layout__backdrop" onClick={() => setMobileOpen(false)} />
199
+ <button
200
+ type="button"
201
+ className="udb-layout__backdrop"
202
+ onClick={() => setMobileOpen(false)}
203
+ aria-label={labels.header.collapseSidebar}
204
+ />
200
205
  <aside
201
206
  className="udb-layout__mobile-sidebar"
202
207
  role="dialog"
@@ -1,6 +1,7 @@
1
1
  export interface DashboardHeaderLabels {
2
2
  expandSidebar: string;
3
3
  collapseSidebar: string;
4
+ openSidebar?: string;
4
5
  switchToLight: string;
5
6
  switchToDark: string;
6
7
  notificationsTitle: string;
@@ -100,7 +100,11 @@
100
100
  .udb-layout__backdrop {
101
101
  position: absolute;
102
102
  inset: 0;
103
+ border: 0;
104
+ padding: 0;
105
+ margin: 0;
103
106
  background: rgba(15, 23, 42, 0.45);
107
+ cursor: pointer;
104
108
  }
105
109
  .udb-layout__mobile-sidebar {
106
110
  position: absolute;
@@ -1,2 +1,3 @@
1
1
  @import "@umituz/web-design-system/styles.css";
2
2
  @import "./chrome.css";
3
+ @import "../domains/calendar/calendar.css";