@umituz/web-dashboard 7.1.0 → 7.3.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 +1 -1
- package/src/domains/layouts/components/DashboardLayout.test.tsx +62 -0
- package/src/domains/layouts/components/DashboardLayout.tsx +6 -2
- package/src/domains/layouts/components/DashboardSidebar.tsx +4 -0
- package/src/domains/layouts/types/sidebar.ts +1 -0
- package/src/styles/chrome.css +9 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@umituz/web-dashboard",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.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,5 +1,6 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
|
+
import { lazy } from "react";
|
|
3
4
|
import { MemoryRouter, Routes, Route } from "react-router";
|
|
4
5
|
import { Home } from "lucide-react";
|
|
5
6
|
import { DashboardLayout } from "./DashboardLayout";
|
|
@@ -136,3 +137,64 @@ describe("DashboardLayout (command palette)", () => {
|
|
|
136
137
|
expect(await screen.findByRole("dialog")).toBeTruthy();
|
|
137
138
|
});
|
|
138
139
|
});
|
|
140
|
+
|
|
141
|
+
describe("DashboardSidebar (secondaryLabel)", () => {
|
|
142
|
+
const secondaryConfig: DashboardLayoutConfig = {
|
|
143
|
+
sidebarGroups: [
|
|
144
|
+
{
|
|
145
|
+
title: "Main",
|
|
146
|
+
items: [{ path: "/", label: "Home", icon: Home, end: false, secondaryLabel: "오늘" }],
|
|
147
|
+
},
|
|
148
|
+
],
|
|
149
|
+
brandName: "Test",
|
|
150
|
+
defaultTitle: "Workspace",
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
it("renders the secondary label next to the item label", () => {
|
|
154
|
+
renderAt("/", { config: secondaryConfig });
|
|
155
|
+
const link = screen.getByRole("link", { name: /home/i });
|
|
156
|
+
expect(link.textContent).toContain("오늘");
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
it("hides the secondary label when the sidebar is collapsed", () => {
|
|
160
|
+
window.localStorage.setItem("udb-collapsed-test", "1");
|
|
161
|
+
render(
|
|
162
|
+
<MemoryRouter initialEntries={["/"]}>
|
|
163
|
+
<Routes>
|
|
164
|
+
<Route
|
|
165
|
+
path="*"
|
|
166
|
+
element={
|
|
167
|
+
<DashboardLayout config={secondaryConfig} labels={labels} collapsedStorageKey="udb-collapsed-test" />
|
|
168
|
+
}
|
|
169
|
+
>
|
|
170
|
+
<Route path="*" element={<div>outlet-content</div>} />
|
|
171
|
+
</Route>
|
|
172
|
+
</Routes>
|
|
173
|
+
</MemoryRouter>
|
|
174
|
+
);
|
|
175
|
+
const link = screen.getByRole("link", { name: /home/i });
|
|
176
|
+
expect(link.textContent).not.toContain("오늘");
|
|
177
|
+
window.localStorage.removeItem("udb-collapsed-test");
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
describe("DashboardLayout (contentFallback)", () => {
|
|
182
|
+
const NeverResolves = lazy(() => new Promise<{ default: React.ComponentType }>(() => {}));
|
|
183
|
+
|
|
184
|
+
it("shows the fallback while a lazy route is suspending", () => {
|
|
185
|
+
render(
|
|
186
|
+
<MemoryRouter initialEntries={["/"]}>
|
|
187
|
+
<Routes>
|
|
188
|
+
<Route
|
|
189
|
+
path="*"
|
|
190
|
+
element={<DashboardLayout config={config} labels={labels} contentFallback={<div>loading-page</div>} />}
|
|
191
|
+
>
|
|
192
|
+
<Route path="*" element={<NeverResolves />} />
|
|
193
|
+
</Route>
|
|
194
|
+
</Routes>
|
|
195
|
+
</MemoryRouter>
|
|
196
|
+
);
|
|
197
|
+
const main = document.getElementById("udb-main");
|
|
198
|
+
expect(main?.textContent).toContain("loading-page");
|
|
199
|
+
});
|
|
200
|
+
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect, useRef, type ReactNode } from "react";
|
|
1
|
+
import { Suspense, useState, useEffect, useRef, type ReactNode } from "react";
|
|
2
2
|
import { useLocation, useNavigate, Outlet, Navigate } from "react-router";
|
|
3
3
|
import { Skeleton } from "@umituz/web-design-system/atoms";
|
|
4
4
|
import { CommandPalette, type CommandGroup, type CommandItem } from "@umituz/web-design-system/organisms";
|
|
@@ -26,6 +26,7 @@ interface DashboardLayoutProps {
|
|
|
26
26
|
collapsedStorageKey?: string;
|
|
27
27
|
footer?: ReactNode;
|
|
28
28
|
mainId?: string;
|
|
29
|
+
contentFallback?: ReactNode;
|
|
29
30
|
formatNotificationTime?: (createdAt: Date | string | number) => string;
|
|
30
31
|
}
|
|
31
32
|
|
|
@@ -55,6 +56,7 @@ export const DashboardLayout = ({
|
|
|
55
56
|
collapsedStorageKey,
|
|
56
57
|
footer,
|
|
57
58
|
mainId = "udb-main",
|
|
59
|
+
contentFallback,
|
|
58
60
|
formatNotificationTime,
|
|
59
61
|
}: DashboardLayoutProps) => {
|
|
60
62
|
const location = useLocation();
|
|
@@ -261,7 +263,9 @@ export const DashboardLayout = ({
|
|
|
261
263
|
</div>
|
|
262
264
|
|
|
263
265
|
) : (
|
|
264
|
-
<
|
|
266
|
+
<Suspense fallback={contentFallback ?? null}>
|
|
267
|
+
<Outlet />
|
|
268
|
+
</Suspense>
|
|
265
269
|
)}
|
|
266
270
|
</main>
|
|
267
271
|
|
|
@@ -136,6 +136,10 @@ export const DashboardSidebar = ({
|
|
|
136
136
|
<item.icon className="udb-sidebar__item-icon" />
|
|
137
137
|
{!collapsed && <span>{item.label}</span>}
|
|
138
138
|
|
|
139
|
+
{!collapsed && item.secondaryLabel && (
|
|
140
|
+
<span className="udb-sidebar__item-secondary">{item.secondaryLabel}</span>
|
|
141
|
+
)}
|
|
142
|
+
|
|
139
143
|
{!collapsed && item.badge !== undefined && item.badge !== "" && (
|
|
140
144
|
<span className="udb-sidebar__item-badge">{item.badge}</span>
|
|
141
145
|
|
package/src/styles/chrome.css
CHANGED
|
@@ -458,12 +458,20 @@
|
|
|
458
458
|
z-index: 50;
|
|
459
459
|
animation: udb-pop 0.18s ease;
|
|
460
460
|
}
|
|
461
|
-
/* Radix-portal variant: positioning/animation come from the dropdown primitive. */
|
|
462
461
|
.udb-menu--pop {
|
|
463
462
|
top: auto;
|
|
464
463
|
right: auto;
|
|
465
464
|
animation: none;
|
|
466
465
|
}
|
|
466
|
+
.udb-sidebar__item-secondary {
|
|
467
|
+
margin-left: auto;
|
|
468
|
+
font-size: 11px;
|
|
469
|
+
font-weight: var(--font-weight-normal);
|
|
470
|
+
color: var(--udb-sidebar-muted);
|
|
471
|
+
}
|
|
472
|
+
.udb-sidebar__item-secondary + .udb-sidebar__item-badge {
|
|
473
|
+
margin-left: var(--udb-space-2);
|
|
474
|
+
}
|
|
467
475
|
.udb-sidebar__item-badge {
|
|
468
476
|
margin-left: auto;
|
|
469
477
|
padding: 1px var(--udb-space-2);
|
|
@@ -529,8 +537,6 @@
|
|
|
529
537
|
color: var(--color-muted-foreground);
|
|
530
538
|
font-size: var(--udb-font-size-sm);
|
|
531
539
|
}
|
|
532
|
-
|
|
533
|
-
/* — Skip link: first focusable element, visible only when focused — */
|
|
534
540
|
.udb-skip-link {
|
|
535
541
|
position: fixed;
|
|
536
542
|
top: var(--udb-space-2);
|
|
@@ -549,12 +555,9 @@
|
|
|
549
555
|
.udb-skip-link:focus {
|
|
550
556
|
transform: translateY(0);
|
|
551
557
|
}
|
|
552
|
-
/* Programmatic focus (skip target) shows no ring — the jump itself is the cue. */
|
|
553
558
|
.udb-layout__content:focus {
|
|
554
559
|
outline: none;
|
|
555
560
|
}
|
|
556
|
-
|
|
557
|
-
/* Scroll lock applied to <html> while the mobile drawer is open. */
|
|
558
561
|
.udb-scroll-lock {
|
|
559
562
|
overflow: hidden;
|
|
560
563
|
}
|