@umituz/web-dashboard 7.10.0 → 8.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": "
|
|
3
|
+
"version": "8.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",
|
|
@@ -157,14 +157,13 @@ describe("DashboardSidebar (secondaryLabel)", () => {
|
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
it("hides the secondary label when the sidebar is collapsed", () => {
|
|
160
|
-
window.localStorage.setItem("udb-collapsed-test", "1");
|
|
161
160
|
render(
|
|
162
161
|
<MemoryRouter initialEntries={["/"]}>
|
|
163
162
|
<Routes>
|
|
164
163
|
<Route
|
|
165
164
|
path="*"
|
|
166
165
|
element={
|
|
167
|
-
<DashboardLayout config={secondaryConfig} labels={labels}
|
|
166
|
+
<DashboardLayout config={secondaryConfig} labels={labels} collapsed />
|
|
168
167
|
}
|
|
169
168
|
>
|
|
170
169
|
<Route path="*" element={<div>outlet-content</div>} />
|
|
@@ -174,7 +173,27 @@ describe("DashboardSidebar (secondaryLabel)", () => {
|
|
|
174
173
|
);
|
|
175
174
|
const link = screen.getByRole("link", { name: /home/i });
|
|
176
175
|
expect(link.textContent).not.toContain("오늘");
|
|
177
|
-
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it("reports toggle events through onCollapsedChange", () => {
|
|
179
|
+
const onCollapsedChange = vi.fn();
|
|
180
|
+
render(
|
|
181
|
+
<MemoryRouter initialEntries={["/"]}>
|
|
182
|
+
<Routes>
|
|
183
|
+
<Route
|
|
184
|
+
path="*"
|
|
185
|
+
element={
|
|
186
|
+
<DashboardLayout config={secondaryConfig} labels={labels} onCollapsedChange={onCollapsedChange} />
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
<Route path="*" element={<div>outlet-content</div>} />
|
|
190
|
+
</Route>
|
|
191
|
+
</Routes>
|
|
192
|
+
</MemoryRouter>
|
|
193
|
+
);
|
|
194
|
+
const toggle = document.querySelector("button.udb-sidebar__footer-btn");
|
|
195
|
+
toggle?.click();
|
|
196
|
+
expect(onCollapsedChange).toHaveBeenCalledWith(true);
|
|
178
197
|
});
|
|
179
198
|
});
|
|
180
199
|
|
|
@@ -23,22 +23,14 @@ interface DashboardLayoutProps {
|
|
|
23
23
|
theme?: "light" | "dark";
|
|
24
24
|
onToggleTheme?: () => void;
|
|
25
25
|
routeTransitionMs?: number;
|
|
26
|
-
|
|
26
|
+
collapsed?: boolean;
|
|
27
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
27
28
|
footer?: ReactNode;
|
|
28
29
|
mainId?: string;
|
|
29
30
|
contentFallback?: ReactNode;
|
|
30
31
|
formatNotificationTime?: (createdAt: Date | string | number) => string;
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
const readCollapsed = (key?: string): boolean => {
|
|
34
|
-
if (!key || typeof window === "undefined") return false;
|
|
35
|
-
try {
|
|
36
|
-
return window.localStorage.getItem(key) === "1";
|
|
37
|
-
} catch {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
34
|
export const DashboardLayout = ({
|
|
43
35
|
config,
|
|
44
36
|
labels,
|
|
@@ -53,7 +45,8 @@ export const DashboardLayout = ({
|
|
|
53
45
|
theme,
|
|
54
46
|
onToggleTheme,
|
|
55
47
|
routeTransitionMs = 0,
|
|
56
|
-
|
|
48
|
+
collapsed: collapsedProp,
|
|
49
|
+
onCollapsedChange,
|
|
57
50
|
footer,
|
|
58
51
|
mainId = "udb-main",
|
|
59
52
|
contentFallback,
|
|
@@ -61,7 +54,12 @@ export const DashboardLayout = ({
|
|
|
61
54
|
}: DashboardLayoutProps) => {
|
|
62
55
|
const location = useLocation();
|
|
63
56
|
const navigate = useNavigate();
|
|
64
|
-
const [
|
|
57
|
+
const [internalCollapsed, setInternalCollapsed] = useState(false);
|
|
58
|
+
const collapsed = collapsedProp ?? internalCollapsed;
|
|
59
|
+
const setCollapsed = (next: boolean) => {
|
|
60
|
+
setInternalCollapsed(next);
|
|
61
|
+
onCollapsedChange?.(next);
|
|
62
|
+
};
|
|
65
63
|
const [mobileOpen, setMobileOpen] = useState(false);
|
|
66
64
|
const [loading, setLoading] = useState(routeTransitionMs > 0);
|
|
67
65
|
const [paletteOpen, setPaletteOpen] = useState(false);
|
|
@@ -71,14 +69,6 @@ export const DashboardLayout = ({
|
|
|
71
69
|
const palette = config.commandPalette;
|
|
72
70
|
const paletteSearch = palette?.search;
|
|
73
71
|
|
|
74
|
-
useEffect(() => {
|
|
75
|
-
if (!collapsedStorageKey || typeof window === "undefined") return;
|
|
76
|
-
try {
|
|
77
|
-
window.localStorage.setItem(collapsedStorageKey, collapsed ? "1" : "0");
|
|
78
|
-
} catch {
|
|
79
|
-
}
|
|
80
|
-
}, [collapsed, collapsedStorageKey]);
|
|
81
|
-
|
|
82
72
|
useEffect(() => {
|
|
83
73
|
if (routeTransitionMs <= 0) {
|
|
84
74
|
setLoading(false);
|