@umituz/web-dashboard 9.0.1 → 10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/web-dashboard",
3
- "version": "9.0.1",
3
+ "version": "10.0.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",
@@ -4,20 +4,25 @@ export { mapCalendarDocument, mapPostDocument } from './contentItemMapper';
4
4
  export * from './layout';
5
5
  export type { FirestoreDocument } from './contentItemMapper';
6
6
 
7
- export function getWeekDates(date: Date, startOfWeek: number = 0): Date[] {
8
- const week: Date[] = [];
9
- const current = new Date(date);
7
+ /** Always seven consecutive days starting at the week anchor — the tuple
8
+ * type states that guarantee, so index access stays `Date` (not
9
+ * `Date | undefined`) under consumer `noUncheckedIndexedAccess`. */
10
+ export function getWeekDates(
11
+ date: Date,
12
+ startOfWeek: number = 0,
13
+ ): [Date, Date, Date, Date, Date, Date, Date] {
14
+ const anchor = new Date(date);
10
15
 
11
- const day = current.getDay();
16
+ const day = anchor.getDay();
12
17
  const diff = (day < startOfWeek ? 7 : 0) + day - startOfWeek;
13
- current.setDate(current.getDate() - diff);
14
-
15
- for (let i = 0; i < 7; i++) {
16
- week.push(new Date(current));
17
- current.setDate(current.getDate() + 1);
18
- }
19
-
20
- return week;
18
+ anchor.setDate(anchor.getDate() - diff);
19
+
20
+ const at = (offset: number): Date => {
21
+ const dayAt = new Date(anchor);
22
+ dayAt.setDate(anchor.getDate() + offset);
23
+ return dayAt;
24
+ };
25
+ return [at(0), at(1), at(2), at(3), at(4), at(5), at(6)];
21
26
  }
22
27
 
23
28
  export function getMonthDays(date: Date): Date[] {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Bell, X, Sun, Moon, Menu, User, Settings, LogOut,
3
- ChevronDown, Search
3
+ ChevronDown, Search, PanelLeftOpen, PanelLeftClose
4
4
  } from "lucide-react";
5
5
  import { Button, Kbd } from "@umituz/web-design-system/atoms";
6
6
  import { Avatar, AvatarImage } from "@umituz/web-design-system/molecules";
@@ -82,12 +82,18 @@ export const DashboardHeader = ({
82
82
  <Menu className="udb-header__toggle-icon" />
83
83
  </Button>
84
84
 
85
- {collapsed && (
86
- <Button variant="ghost" size="icon" className="udb-header__desktop-toggle" onClick={() => setCollapsed(false)}>
87
- <Menu className="udb-header__toggle-icon" />
88
- </Button>
89
-
90
- )}
85
+ <Button
86
+ variant="ghost"
87
+ size="icon"
88
+ className="udb-header__desktop-toggle"
89
+ onClick={() => setCollapsed(!collapsed)}
90
+ title={collapsed ? labels.expandSidebar : labels.collapseSidebar}
91
+ aria-label={collapsed ? labels.expandSidebar : labels.collapseSidebar}
92
+ >
93
+ {collapsed
94
+ ? <PanelLeftOpen className="udb-header__toggle-icon" aria-hidden="true" />
95
+ : <PanelLeftClose className="udb-header__toggle-icon" aria-hidden="true" />}
96
+ </Button>
91
97
  <h2 className="udb-header__title">
92
98
  {title}
93
99
  </h2>
@@ -191,7 +191,7 @@ describe("DashboardSidebar (secondaryLabel)", () => {
191
191
  </Routes>
192
192
  </MemoryRouter>
193
193
  );
194
- const toggle = document.querySelector<HTMLButtonElement>("button.udb-sidebar__footer-btn");
194
+ const toggle = document.querySelector<HTMLButtonElement>("button.udb-header__desktop-toggle");
195
195
  toggle?.click();
196
196
  expect(onCollapsedChange).toHaveBeenCalledWith(true);
197
197
  });
@@ -190,7 +190,6 @@ export const DashboardLayout = ({
190
190
  >
191
191
  <DashboardSidebar
192
192
  collapsed={collapsed}
193
- setCollapsed={setCollapsed}
194
193
  {...sidebarProps}
195
194
  />
196
195
  </aside>
@@ -206,7 +205,6 @@ export const DashboardLayout = ({
206
205
  >
207
206
  <DashboardSidebar
208
207
  collapsed={false}
209
- setCollapsed={() => setMobileOpen(false)}
210
208
  {...sidebarProps}
211
209
  />
212
210
  </aside>
@@ -5,7 +5,7 @@ import { Button } from "@umituz/web-design-system/atoms";
5
5
  import { cn } from "@umituz/web-design-system/utils/cn";
6
6
  import { BrandLogo } from "./BrandLogo";
7
7
  import { isPathActive } from "../utils/dashboard";
8
- import { Menu, ChevronLeft, ChevronDown, ChevronRight } from "lucide-react";
8
+ import { ChevronDown, ChevronRight } from "lucide-react";
9
9
  import type { DashboardSidebarProps, SidebarAction } from "../types/layout";
10
10
  import type { DashboardUser } from "../types/user";
11
11
  import type { SidebarGroup } from "../types/sidebar";
@@ -23,7 +23,6 @@ interface DashboardSidebarPropsExtended extends DashboardSidebarProps {
23
23
 
24
24
  export const DashboardSidebar = ({
25
25
  collapsed,
26
- setCollapsed,
27
26
  sidebarGroups,
28
27
  brandName,
29
28
  brandTagline,
@@ -158,20 +157,17 @@ export const DashboardSidebar = ({
158
157
 
159
158
  </nav>
160
159
 
161
- <div className="udb-sidebar__footer">
162
- {sidebarFooter && <div className="udb-sidebar__footer-slot">{sidebarFooter}</div>}
160
+ {(sidebarFooter || (!collapsed && labels?.system)) && (
161
+ <div className="udb-sidebar__footer">
162
+ {sidebarFooter && <div className="udb-sidebar__footer-slot">{sidebarFooter}</div>}
163
163
 
164
- {!collapsed && labels?.system && (
165
- <p className="udb-sidebar__footer-label">
166
- {labels.system}
167
- </p>
168
-
169
- )}
170
- <Button variant="ghost" size="icon" onClick={() => setCollapsed(!collapsed)} className="udb-sidebar__footer-btn">
171
- {collapsed ? <Menu className="udb-sidebar__footer-icon" /> : <ChevronLeft className="udb-sidebar__footer-icon" />}
172
- </Button>
173
-
174
- </div>
164
+ {!collapsed && labels?.system && (
165
+ <p className="udb-sidebar__footer-label">
166
+ {labels.system}
167
+ </p>
168
+ )}
169
+ </div>
170
+ )}
175
171
 
176
172
  </div>
177
173
 
@@ -3,14 +3,15 @@ import type { DashboardLayoutLabels } from '../types/layout';
3
3
  /**
4
4
  * English shell labels — the reference text for `DashboardLayout`.
5
5
  * Hosts rendering English pass this constant instead of re-declaring the
6
- * thirteen strings; localized hosts build their own object from the same
7
- * shape.
6
+ * strings; localized hosts build their own object from the same shape.
8
7
  */
9
8
  export const defaultLayoutLabels: DashboardLayoutLabels = {
10
9
  skipToContent: 'Skip to content',
11
10
  navigation: 'Navigation',
12
11
  searchResults: 'Search results',
13
12
  header: {
13
+ expandSidebar: 'Expand sidebar',
14
+ collapseSidebar: 'Collapse sidebar',
14
15
  switchToLight: 'Switch to light',
15
16
  switchToDark: 'Switch to dark',
16
17
  notificationsTitle: 'Notifications',
@@ -1,4 +1,6 @@
1
1
  export interface DashboardHeaderLabels {
2
+ expandSidebar: string;
3
+ collapseSidebar: string;
2
4
  switchToLight: string;
3
5
  switchToDark: string;
4
6
  notificationsTitle: string;
@@ -74,7 +76,6 @@ export interface CommandPaletteConfig {
74
76
 
75
77
  export interface DashboardSidebarProps {
76
78
  collapsed: boolean;
77
- setCollapsed: (collapsed: boolean) => void;
78
79
  labels?: DashboardSidebarLabels;
79
80
  }
80
81
 
@@ -335,13 +335,6 @@
335
335
  letter-spacing: 0.1em;
336
336
  color: var(--udb-sidebar-muted);
337
337
  }
338
- .udb-sidebar__footer-btn {
339
- color: var(--udb-sidebar-text);
340
- }
341
- .udb-sidebar__footer-icon {
342
- width: 16px;
343
- height: 16px;
344
- }
345
338
  .udb-header {
346
339
  display: flex;
347
340
  height: var(--udb-header-height);