@umituz/web-dashboard 6.10.0 → 7.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 +11 -12
- package/src/domains/analytics/components/AnalyticsCard.tsx +11 -0
- package/src/domains/analytics/components/AnalyticsChart.tsx +24 -5
- package/src/domains/analytics/components/AnalyticsLayout.tsx +26 -26
- package/src/domains/analytics/components/MetricCard.tsx +2 -5
- package/src/domains/analytics/hooks/useAnalytics.ts +1 -7
- package/src/domains/analytics/index.ts +0 -1
- package/src/domains/analytics/types/analytics.ts +11 -0
- package/src/domains/analytics/utils/analytics.ts +2 -115
- package/src/domains/analytics/utils/index.ts +0 -1
- package/src/domains/calendar/services/CalendarService.ts +2 -25
- package/src/domains/charts/components.test.tsx +1 -0
- package/src/domains/charts/components.tsx +65 -0
- package/src/domains/layouts/components/BrandLogo.tsx +1 -0
- package/src/domains/layouts/components/DashboardHeader.tsx +57 -21
- package/src/domains/layouts/components/DashboardLayout.test.tsx +40 -22
- package/src/domains/layouts/components/DashboardLayout.tsx +60 -28
- package/src/domains/layouts/components/DashboardSidebar.tsx +34 -33
- package/src/domains/layouts/components/FilterBar.test.tsx +3 -0
- package/src/domains/layouts/components/FilterBar.tsx +5 -9
- package/src/domains/layouts/components/FilterSelect.test.tsx +28 -0
- package/src/domains/layouts/components/FilterSelect.tsx +47 -0
- package/src/domains/layouts/components/PageHeader.test.tsx +18 -0
- package/src/domains/layouts/components/PageHeader.tsx +13 -3
- package/src/domains/layouts/components/SectionHeader.tsx +7 -4
- package/src/domains/layouts/components/index.ts +2 -0
- package/src/domains/layouts/hooks/dashboard.ts +4 -7
- package/src/domains/layouts/types/index.ts +12 -1
- package/src/domains/layouts/types/layout.ts +72 -58
- package/src/domains/layouts/types/sidebar.ts +0 -8
- package/src/domains/layouts/utils/dashboard.test.ts +2 -2
- package/src/domains/layouts/utils/dashboard.ts +15 -11
- package/src/domains/layouts/utils/index.ts +2 -1
- package/src/domains/modules/build.test.tsx +4 -0
- package/src/domains/modules/build.tsx +1 -0
- package/src/domains/onboarding/calc/slider-value-bounds.ts +1 -1
- package/src/domains/onboarding/components/AnimationWrapper.tsx +3 -0
- package/src/domains/onboarding/components/OnboardingErrorBoundary.tsx +6 -0
- package/src/domains/onboarding/components/OnboardingFlow.test.tsx +48 -27
- package/src/domains/onboarding/components/OnboardingFlow.tsx +10 -2
- package/src/domains/onboarding/components/OnboardingIntl.tsx +7 -65
- package/src/domains/onboarding/components/PrimaryButton.tsx +3 -0
- package/src/domains/onboarding/components/ProgressBar.tsx +5 -1
- package/src/domains/onboarding/components/QuestionWrapper.tsx +5 -0
- package/src/domains/onboarding/components/ScreenContainer.tsx +4 -0
- package/src/domains/onboarding/components/SwipeCard.test.tsx +43 -1
- package/src/domains/onboarding/components/SwipeCard.tsx +7 -0
- package/src/domains/onboarding/components/screens/AccountGateScreen.tsx +7 -0
- package/src/domains/onboarding/components/screens/AppDemoScreen.tsx +4 -0
- package/src/domains/onboarding/components/screens/ComparisonScreen.tsx +9 -0
- package/src/domains/onboarding/components/screens/GoalQuestionScreen.tsx +3 -0
- package/src/domains/onboarding/components/screens/PainPointsScreen.tsx +3 -0
- package/src/domains/onboarding/components/screens/PaywallScreen.tsx +17 -0
- package/src/domains/onboarding/components/screens/PermissionPrimingScreen.tsx +10 -0
- package/src/domains/onboarding/components/screens/PersonalizedSolutionScreen.tsx +9 -0
- package/src/domains/onboarding/components/screens/PreferencesScreen.tsx +15 -0
- package/src/domains/onboarding/components/screens/ProcessingScreen.tsx +8 -0
- package/src/domains/onboarding/components/screens/SocialProofScreen.tsx +17 -0
- package/src/domains/onboarding/components/screens/TinderCardsScreen.tsx +12 -0
- package/src/domains/onboarding/components/screens/ValueDeliveryScreen.tsx +9 -0
- package/src/domains/onboarding/components/screens/WelcomeScreen.tsx +7 -0
- package/src/domains/onboarding/hooks/useOnboardingProgress.test.tsx +4 -5
- package/src/domains/onboarding/index.ts +0 -12
- package/src/domains/onboarding/predicates/predicates.test.ts +1 -1
- package/src/domains/onboarding/types/config.ts +1 -1
- package/src/domains/onboarding/types/labels.ts +1 -0
- package/src/domains/onboarding/utils/analytics-dispatch.ts +2 -2
- package/src/domains/onboarding/utils/local-storage-bridge.ts +1 -1
- package/src/domains/onboarding/validation/validation.test.ts +2 -2
- package/src/domains/permissions/PermissionsContext.tsx +6 -18
- package/src/domains/permissions/index.ts +0 -1
- package/src/domains/search/searchItems.test.ts +1 -1
- package/src/domains/search/searchItems.ts +0 -3
- package/src/domains/settings/components/AuditLogList.tsx +14 -7
- package/src/domains/settings/components/PermissionMatrixScreen.tsx +10 -0
- package/src/domains/settings/components/SettingsLayout.tsx +21 -4
- package/src/domains/settings/components/SettingsSection.tsx +13 -7
- package/src/domains/settings/components/UserManagementTable.tsx +16 -9
- package/src/domains/settings/types/settings.ts +7 -1
- package/src/domains/settings/utils/index.ts +0 -1
- package/src/domains/timing/hooks/useCountdown.test.ts +1 -2
- package/src/domains/timing/hooks/useCountdown.ts +0 -4
- package/src/internal/formatPattern.ts +8 -0
- package/src/domains/analytics/utils/i18nKeys.ts +0 -31
- package/src/domains/onboarding/templates/TemplateDemoFallback.tsx +0 -92
- package/src/domains/onboarding/templates/art-onboarding.ts +0 -71
- package/src/domains/onboarding/templates/health-onboarding.ts +0 -92
- package/src/domains/onboarding/templates/index.ts +0 -6
- package/src/domains/onboarding/templates/platform-onboarding.ts +0 -201
- package/src/domains/onboarding/templates/video-onboarding.ts +0 -95
- package/src/domains/permissions/utils/i18nKeys.ts +0 -6
- package/src/domains/settings/utils/i18nKeys.ts +0 -12
|
@@ -1,9 +1,28 @@
|
|
|
1
1
|
import { describe, expect, it, vi } from "vitest";
|
|
2
2
|
import { render, screen, fireEvent } from "@testing-library/react";
|
|
3
|
-
import { MemoryRouter, Routes, Route } from "react-router
|
|
3
|
+
import { MemoryRouter, Routes, Route } from "react-router";
|
|
4
4
|
import { Home } from "lucide-react";
|
|
5
5
|
import { DashboardLayout } from "./DashboardLayout";
|
|
6
|
-
import type { DashboardLayoutConfig } from "../types/layout";
|
|
6
|
+
import type { DashboardLayoutConfig, DashboardLayoutLabels } from "../types/layout";
|
|
7
|
+
|
|
8
|
+
const labels: DashboardLayoutLabels = {
|
|
9
|
+
skipToContent: "Skip to content",
|
|
10
|
+
navigation: "Navigation",
|
|
11
|
+
searchResults: "Search results",
|
|
12
|
+
header: {
|
|
13
|
+
switchToLight: "Switch to light",
|
|
14
|
+
switchToDark: "Switch to dark",
|
|
15
|
+
notificationsTitle: "Notifications",
|
|
16
|
+
markAllRead: "Mark all read",
|
|
17
|
+
dismissNotification: "Dismiss",
|
|
18
|
+
noNotifications: "No notifications",
|
|
19
|
+
profile: "Profile",
|
|
20
|
+
settings: "Settings",
|
|
21
|
+
logout: "Log out",
|
|
22
|
+
guestName: "Guest",
|
|
23
|
+
},
|
|
24
|
+
sidebar: { system: "System" },
|
|
25
|
+
};
|
|
7
26
|
|
|
8
27
|
const config: DashboardLayoutConfig = {
|
|
9
28
|
sidebarGroups: [
|
|
@@ -16,15 +35,16 @@ const config: DashboardLayoutConfig = {
|
|
|
16
35
|
defaultTitle: "Workspace",
|
|
17
36
|
};
|
|
18
37
|
|
|
19
|
-
function renderAt(path: string, mainId?: string
|
|
38
|
+
function renderAt(path: string, overrides: { config?: DashboardLayoutConfig; mainId?: string } = {}) {
|
|
39
|
+
const { config: cfg = config, mainId } = overrides;
|
|
20
40
|
return render(
|
|
21
41
|
<MemoryRouter initialEntries={[path]}>
|
|
22
42
|
<Routes>
|
|
23
43
|
<Route
|
|
24
44
|
path="*"
|
|
25
45
|
element={
|
|
26
|
-
<DashboardLayout config={
|
|
27
|
-
{
|
|
46
|
+
<DashboardLayout config={cfg} labels={labels} mainId={mainId}>
|
|
47
|
+
{}
|
|
28
48
|
</DashboardLayout>
|
|
29
49
|
}
|
|
30
50
|
>
|
|
@@ -44,7 +64,7 @@ describe("DashboardLayout (shell a11y)", () => {
|
|
|
44
64
|
});
|
|
45
65
|
|
|
46
66
|
it("honours a custom mainId on both the link and the landmark", () => {
|
|
47
|
-
renderAt("/", "main-content");
|
|
67
|
+
renderAt("/", { mainId: "main-content" });
|
|
48
68
|
expect(screen.getByRole("link", { name: /skip to content/i }).getAttribute("href")).toBe("#main-content");
|
|
49
69
|
expect(document.getElementById("main-content")).not.toBeNull();
|
|
50
70
|
});
|
|
@@ -67,14 +87,14 @@ describe("DashboardLayout (command palette)", () => {
|
|
|
67
87
|
});
|
|
68
88
|
|
|
69
89
|
it("renders the palette's search button in the header and opens it on click", async () => {
|
|
70
|
-
renderAt("/",
|
|
90
|
+
renderAt("/", { config: paletteConfig() });
|
|
71
91
|
fireEvent.click(screen.getByRole("button", { name: /search commands/i }));
|
|
72
92
|
expect(await screen.findByRole("dialog")).toBeTruthy();
|
|
73
93
|
expect(await screen.findByRole("option", { name: "Home" })).toBeTruthy();
|
|
74
94
|
});
|
|
75
95
|
|
|
76
96
|
it("toggles the palette with ⌘K / Ctrl+K", async () => {
|
|
77
|
-
renderAt("/",
|
|
97
|
+
renderAt("/", { config: paletteConfig() });
|
|
78
98
|
expect(screen.queryByRole("dialog")).toBeNull();
|
|
79
99
|
fireEvent.keyDown(window, { key: "k", metaKey: true });
|
|
80
100
|
expect(await screen.findByRole("dialog")).toBeTruthy();
|
|
@@ -83,42 +103,40 @@ describe("DashboardLayout (command palette)", () => {
|
|
|
83
103
|
});
|
|
84
104
|
|
|
85
105
|
it("does not bind the shortcut when shortcut: false", () => {
|
|
86
|
-
renderAt("/",
|
|
87
|
-
...config,
|
|
88
|
-
commandPalette: { groups: [], shortcut: false },
|
|
89
|
-
});
|
|
106
|
+
renderAt("/", { config: { ...config, commandPalette: { groups: [], shortcut: false } } });
|
|
90
107
|
fireEvent.keyDown(window, { key: "k", ctrlKey: true });
|
|
91
108
|
expect(screen.queryByRole("dialog")).toBeNull();
|
|
92
109
|
});
|
|
93
110
|
|
|
94
111
|
it("keeps an explicit searchAction.onActivate over the palette takeover", () => {
|
|
95
112
|
const onActivate = vi.fn();
|
|
96
|
-
renderAt("/",
|
|
113
|
+
renderAt("/", { config: paletteConfig({ searchAction: { placeholder: "Go search", onActivate } }) });
|
|
97
114
|
fireEvent.click(screen.getByRole("button", { name: /go search/i }));
|
|
98
115
|
expect(onActivate).toHaveBeenCalledTimes(1);
|
|
99
116
|
expect(screen.queryByRole("dialog")).toBeNull();
|
|
100
117
|
});
|
|
101
118
|
|
|
102
119
|
it("derives navigation groups from the sidebar when includeSidebar is set", async () => {
|
|
103
|
-
renderAt("/",
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
120
|
+
renderAt("/", {
|
|
121
|
+
config: {
|
|
122
|
+
...config,
|
|
123
|
+
commandPalette: {
|
|
124
|
+
includeSidebar: true,
|
|
125
|
+
groups: [{ heading: "Quick", items: [{ id: "q", label: "Quick action", onSelect: () => {} }] }],
|
|
126
|
+
},
|
|
108
127
|
},
|
|
109
128
|
});
|
|
110
129
|
fireEvent.keyDown(window, { key: "k", metaKey: true });
|
|
111
130
|
expect(await screen.findByRole("option", { name: "Quick action" })).toBeTruthy();
|
|
112
|
-
|
|
113
|
-
// carrying the path as its hint (accessible name "Home /").
|
|
131
|
+
|
|
114
132
|
const derived = screen.getByRole("option", { name: /home/i });
|
|
115
133
|
expect(derived.textContent).toContain("/");
|
|
116
134
|
});
|
|
117
135
|
|
|
118
136
|
it("omits sidebar-derived items from the palette by default", async () => {
|
|
119
|
-
renderAt("/",
|
|
137
|
+
renderAt("/", { config: paletteConfig() });
|
|
120
138
|
fireEvent.keyDown(window, { key: "k", metaKey: true });
|
|
121
|
-
|
|
139
|
+
|
|
122
140
|
const own = await screen.findByRole("option", { name: "Home" });
|
|
123
141
|
expect(own.textContent).toBe("Home");
|
|
124
142
|
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { useState, useEffect, type ReactNode } from "react";
|
|
2
|
-
import { useLocation, useNavigate, Outlet, Navigate } from "react-router
|
|
3
|
-
import { useT } from "@umituz/web-localization/react";
|
|
1
|
+
import { useState, useEffect, useRef, type ReactNode } from "react";
|
|
2
|
+
import { useLocation, useNavigate, Outlet, Navigate } from "react-router";
|
|
4
3
|
import { Skeleton } from "@umituz/web-design-system/atoms";
|
|
5
|
-
import { CommandPalette } from "@umituz/web-design-system/organisms";
|
|
4
|
+
import { CommandPalette, type CommandGroup, type CommandItem } from "@umituz/web-design-system/organisms";
|
|
6
5
|
import { DashboardSidebar } from "./DashboardSidebar";
|
|
7
6
|
import { DashboardHeader } from "./DashboardHeader";
|
|
8
7
|
import { getActiveSidebarItem } from "../utils/dashboard";
|
|
9
|
-
import type { DashboardLayoutConfig } from "../types/layout";
|
|
8
|
+
import type { DashboardLayoutConfig, DashboardLayoutLabels } from "../types/layout";
|
|
10
9
|
import type { DashboardNotification } from "../types/notification";
|
|
11
10
|
import type { DashboardUser } from "../types/user";
|
|
12
11
|
|
|
13
12
|
interface DashboardLayoutProps {
|
|
14
13
|
config: DashboardLayoutConfig;
|
|
14
|
+
labels: DashboardLayoutLabels;
|
|
15
15
|
user?: DashboardUser;
|
|
16
16
|
authLoading?: boolean;
|
|
17
17
|
isAuthenticated?: boolean;
|
|
@@ -23,14 +23,10 @@ interface DashboardLayoutProps {
|
|
|
23
23
|
theme?: "light" | "dark";
|
|
24
24
|
onToggleTheme?: () => void;
|
|
25
25
|
routeTransitionMs?: number;
|
|
26
|
-
/** Persists the sidebar collapse state under this localStorage key ('1'/'0'). */
|
|
27
26
|
collapsedStorageKey?: string;
|
|
28
|
-
/** Optional page footer rendered under the outlet column. */
|
|
29
27
|
footer?: ReactNode;
|
|
30
|
-
/** id of the main landmark — also the skip-link target. */
|
|
31
28
|
mainId?: string;
|
|
32
|
-
|
|
33
|
-
skipToContentLabel?: string;
|
|
29
|
+
formatNotificationTime?: (createdAt: Date | string | number) => string;
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
const readCollapsed = (key?: string): boolean => {
|
|
@@ -44,6 +40,7 @@ const readCollapsed = (key?: string): boolean => {
|
|
|
44
40
|
|
|
45
41
|
export const DashboardLayout = ({
|
|
46
42
|
config,
|
|
43
|
+
labels,
|
|
47
44
|
user,
|
|
48
45
|
authLoading = false,
|
|
49
46
|
isAuthenticated = true,
|
|
@@ -58,23 +55,25 @@ export const DashboardLayout = ({
|
|
|
58
55
|
collapsedStorageKey,
|
|
59
56
|
footer,
|
|
60
57
|
mainId = "udb-main",
|
|
61
|
-
|
|
58
|
+
formatNotificationTime,
|
|
62
59
|
}: DashboardLayoutProps) => {
|
|
63
60
|
const location = useLocation();
|
|
64
61
|
const navigate = useNavigate();
|
|
65
|
-
const t = useT();
|
|
66
62
|
const [collapsed, setCollapsed] = useState(() => readCollapsed(collapsedStorageKey));
|
|
67
63
|
const [mobileOpen, setMobileOpen] = useState(false);
|
|
68
64
|
const [loading, setLoading] = useState(routeTransitionMs > 0);
|
|
69
65
|
const [paletteOpen, setPaletteOpen] = useState(false);
|
|
66
|
+
const [searchItems, setSearchItems] = useState<CommandItem[]>([]);
|
|
67
|
+
const searchTimer = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
68
|
+
const searchSeq = useRef(0);
|
|
70
69
|
const palette = config.commandPalette;
|
|
70
|
+
const paletteSearch = palette?.search;
|
|
71
71
|
|
|
72
72
|
useEffect(() => {
|
|
73
73
|
if (!collapsedStorageKey || typeof window === "undefined") return;
|
|
74
74
|
try {
|
|
75
75
|
window.localStorage.setItem(collapsedStorageKey, collapsed ? "1" : "0");
|
|
76
76
|
} catch {
|
|
77
|
-
/* storage unavailable — state stays in-memory only */
|
|
78
77
|
}
|
|
79
78
|
}, [collapsed, collapsedStorageKey]);
|
|
80
79
|
|
|
@@ -113,6 +112,31 @@ export const DashboardLayout = ({
|
|
|
113
112
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
114
113
|
}, [mobileOpen]);
|
|
115
114
|
|
|
115
|
+
useEffect(
|
|
116
|
+
() => () => {
|
|
117
|
+
if (searchTimer.current) clearTimeout(searchTimer.current);
|
|
118
|
+
},
|
|
119
|
+
[]
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
const handlePaletteQuery = (q: string) => {
|
|
123
|
+
if (searchTimer.current) clearTimeout(searchTimer.current);
|
|
124
|
+
const seq = ++searchSeq.current;
|
|
125
|
+
if (!paletteSearch || q.trim() === "") {
|
|
126
|
+
setSearchItems([]);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
searchTimer.current = setTimeout(() => {
|
|
130
|
+
paletteSearch(q)
|
|
131
|
+
.then((items) => {
|
|
132
|
+
if (seq === searchSeq.current) setSearchItems(items);
|
|
133
|
+
})
|
|
134
|
+
.catch(() => {
|
|
135
|
+
if (seq === searchSeq.current) setSearchItems([]);
|
|
136
|
+
});
|
|
137
|
+
}, 180);
|
|
138
|
+
};
|
|
139
|
+
|
|
116
140
|
useEffect(() => {
|
|
117
141
|
if (typeof document === "undefined") return;
|
|
118
142
|
document.documentElement.classList.toggle("udb-scroll-lock", mobileOpen);
|
|
@@ -124,24 +148,23 @@ export const DashboardLayout = ({
|
|
|
124
148
|
|
|
125
149
|
const activeItem = getActiveSidebarItem(location.pathname, config.sidebarGroups);
|
|
126
150
|
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
const extraTitle = config.extraTitleMap?.[location.pathname];
|
|
130
|
-
if (extraTitle) return t(extraTitle);
|
|
131
|
-
return config.defaultTitle ?? "Dashboard";
|
|
132
|
-
};
|
|
151
|
+
const currentTitle =
|
|
152
|
+
(activeItem?.label ?? config.extraTitleMap?.[location.pathname] ?? config.defaultTitle) || "";
|
|
133
153
|
|
|
134
|
-
const
|
|
154
|
+
const searchGroup: CommandGroup | null =
|
|
155
|
+
paletteSearch && searchItems.length > 0
|
|
156
|
+
? { heading: palette?.searchResultsHeading ?? labels.searchResults, items: searchItems }
|
|
157
|
+
: null;
|
|
158
|
+
const basePaletteGroups = searchGroup ? [searchGroup, ...(palette?.groups ?? [])] : (palette?.groups ?? []);
|
|
135
159
|
|
|
136
|
-
// Sidebar-derived navigation groups — one nav definition feeds both chrome surfaces.
|
|
137
160
|
const paletteGroups = palette?.includeSidebar
|
|
138
161
|
? [
|
|
139
|
-
...
|
|
162
|
+
...basePaletteGroups,
|
|
140
163
|
...config.sidebarGroups.map((group) => ({
|
|
141
164
|
heading: group.title,
|
|
142
165
|
items: group.items.map((item) => ({
|
|
143
166
|
id: `nav-${item.path}`,
|
|
144
|
-
label: item.
|
|
167
|
+
label: item.label,
|
|
145
168
|
icon: <item.icon size={16} aria-hidden="true" />,
|
|
146
169
|
hint: item.path,
|
|
147
170
|
onSelect: () => navigate(item.path),
|
|
@@ -158,12 +181,13 @@ export const DashboardLayout = ({
|
|
|
158
181
|
sidebarAction: config.sidebarAction,
|
|
159
182
|
sidebarFooter: config.sidebarFooter,
|
|
160
183
|
user,
|
|
184
|
+
labels: config.sidebarLabels ?? labels.sidebar,
|
|
161
185
|
};
|
|
162
186
|
|
|
163
187
|
return (
|
|
164
188
|
<div className="udb-root udb-layout">
|
|
165
189
|
<a href={`#${mainId}`} className="udb-skip-link">
|
|
166
|
-
{
|
|
190
|
+
{labels.skipToContent}
|
|
167
191
|
</a>
|
|
168
192
|
|
|
169
193
|
<aside
|
|
@@ -183,7 +207,7 @@ export const DashboardLayout = ({
|
|
|
183
207
|
className="udb-layout__mobile-sidebar"
|
|
184
208
|
role="dialog"
|
|
185
209
|
aria-modal="true"
|
|
186
|
-
aria-label={config.brandName ? `${config.brandName} — ${
|
|
210
|
+
aria-label={config.brandName ? `${config.brandName} — ${labels.navigation}` : labels.navigation}
|
|
187
211
|
>
|
|
188
212
|
<DashboardSidebar
|
|
189
213
|
collapsed={false}
|
|
@@ -191,7 +215,9 @@ export const DashboardLayout = ({
|
|
|
191
215
|
{...sidebarProps}
|
|
192
216
|
/>
|
|
193
217
|
</aside>
|
|
218
|
+
|
|
194
219
|
</div>
|
|
220
|
+
|
|
195
221
|
)}
|
|
196
222
|
|
|
197
223
|
<div className="udb-layout__main">
|
|
@@ -200,6 +226,7 @@ export const DashboardLayout = ({
|
|
|
200
226
|
setCollapsed={setCollapsed}
|
|
201
227
|
setMobileOpen={setMobileOpen}
|
|
202
228
|
title={currentTitle}
|
|
229
|
+
labels={labels.header}
|
|
203
230
|
theme={theme}
|
|
204
231
|
onToggleTheme={onToggleTheme}
|
|
205
232
|
user={user}
|
|
@@ -208,10 +235,10 @@ export const DashboardLayout = ({
|
|
|
208
235
|
onMarkAllRead={onMarkAllRead}
|
|
209
236
|
onDismissNotification={onDismissNotification}
|
|
210
237
|
loginRoute={loginRoute}
|
|
238
|
+
formatNotificationTime={formatNotificationTime}
|
|
211
239
|
searchAction={
|
|
212
240
|
palette
|
|
213
|
-
?
|
|
214
|
-
{ placeholder: palette.placeholder, shortcut: "⌘K", ...config.searchAction, onActivate: config.searchAction?.onActivate ?? (() => setPaletteOpen(true)) }
|
|
241
|
+
? { placeholder: palette.placeholder, shortcut: "⌘K", ...config.searchAction, onActivate: config.searchAction?.onActivate ?? (() => setPaletteOpen(true)) }
|
|
215
242
|
: config.searchAction
|
|
216
243
|
}
|
|
217
244
|
headerExtra={config.headerExtra}
|
|
@@ -229,27 +256,32 @@ export const DashboardLayout = ({
|
|
|
229
256
|
<Skeleton key={i} className="udb-skeleton--card" />
|
|
230
257
|
))}
|
|
231
258
|
</div>
|
|
259
|
+
|
|
232
260
|
<Skeleton className="udb-skeleton--section" />
|
|
233
261
|
</div>
|
|
262
|
+
|
|
234
263
|
) : (
|
|
235
264
|
<Outlet />
|
|
236
265
|
)}
|
|
237
266
|
</main>
|
|
238
267
|
|
|
239
268
|
{footer && <footer className="udb-layout__footer">{footer}</footer>}
|
|
269
|
+
|
|
240
270
|
</div>
|
|
241
271
|
|
|
242
272
|
{palette && (
|
|
243
273
|
<CommandPalette
|
|
244
274
|
open={paletteOpen}
|
|
245
275
|
onOpenChange={setPaletteOpen}
|
|
246
|
-
groups={paletteGroups ??
|
|
276
|
+
groups={paletteGroups ?? basePaletteGroups}
|
|
247
277
|
placeholder={palette.placeholder}
|
|
248
278
|
emptyLabel={palette.emptyLabel}
|
|
249
279
|
label={palette.label}
|
|
280
|
+
onQueryChange={paletteSearch ? handlePaletteQuery : undefined}
|
|
250
281
|
/>
|
|
251
282
|
)}
|
|
252
283
|
</div>
|
|
284
|
+
|
|
253
285
|
);
|
|
254
286
|
};
|
|
255
287
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { useState, type ReactNode } from "react";
|
|
2
|
-
import { Link, useLocation } from "react-router
|
|
3
|
-
import { useT } from "@umituz/web-localization/react";
|
|
2
|
+
import { Link, useLocation } from "react-router";
|
|
4
3
|
|
|
5
4
|
import { Button } from "@umituz/web-design-system/atoms";
|
|
6
5
|
import { cn } from "@umituz/web-design-system/utils/cn";
|
|
7
6
|
import { BrandLogo } from "./BrandLogo";
|
|
8
7
|
import { isPathActive } from "../utils/dashboard";
|
|
9
|
-
import {
|
|
8
|
+
import { Menu, ChevronLeft, ChevronDown, ChevronRight } from "lucide-react";
|
|
10
9
|
import type { DashboardSidebarProps, SidebarAction } from "../types/layout";
|
|
11
10
|
import type { DashboardUser } from "../types/user";
|
|
12
11
|
import type { SidebarGroup } from "../types/sidebar";
|
|
@@ -16,14 +15,9 @@ interface DashboardSidebarPropsExtended extends DashboardSidebarProps {
|
|
|
16
15
|
sidebarGroups: SidebarGroup[];
|
|
17
16
|
brandName?: string;
|
|
18
17
|
brandTagline?: string;
|
|
19
|
-
/** Custom brand mark — replaces the built-in logo (text block still follows brandName). */
|
|
20
18
|
brand?: ReactNode;
|
|
21
|
-
/** Generic primary action — replaces the legacy create-post button. */
|
|
22
19
|
sidebarAction?: SidebarAction;
|
|
23
|
-
/** Extra node above the collapse button in the footer (hidden while collapsed). */
|
|
24
20
|
sidebarFooter?: ReactNode;
|
|
25
|
-
createPostRoute?: string;
|
|
26
|
-
showCreatePost?: boolean;
|
|
27
21
|
user?: DashboardUser;
|
|
28
22
|
}
|
|
29
23
|
|
|
@@ -31,17 +25,15 @@ export const DashboardSidebar = ({
|
|
|
31
25
|
collapsed,
|
|
32
26
|
setCollapsed,
|
|
33
27
|
sidebarGroups,
|
|
34
|
-
brandName
|
|
35
|
-
brandTagline
|
|
28
|
+
brandName,
|
|
29
|
+
brandTagline,
|
|
36
30
|
brand,
|
|
37
31
|
sidebarAction,
|
|
38
32
|
sidebarFooter,
|
|
39
|
-
|
|
40
|
-
showCreatePost = true,
|
|
33
|
+
labels,
|
|
41
34
|
user,
|
|
42
35
|
}: DashboardSidebarPropsExtended) => {
|
|
43
36
|
const location = useLocation();
|
|
44
|
-
const t = useT();
|
|
45
37
|
const [collapsedGroups, setCollapsedGroups] = useState<Record<string, boolean>>({});
|
|
46
38
|
|
|
47
39
|
const toggleGroup = (title: string) => {
|
|
@@ -61,24 +53,30 @@ export const DashboardSidebar = ({
|
|
|
61
53
|
>
|
|
62
54
|
{icon}
|
|
63
55
|
{!collapsed && <span className="udb-sidebar__create-label">{label}</span>}
|
|
56
|
+
|
|
64
57
|
</Button>
|
|
58
|
+
|
|
65
59
|
);
|
|
66
60
|
return linkProps ? <Link to={linkProps.to}>{button}</Link> : button;
|
|
61
|
+
|
|
67
62
|
};
|
|
68
63
|
|
|
69
64
|
return (
|
|
70
65
|
<div className={cn("udb-sidebar", collapsed && "udb-sidebar--collapsed")}>
|
|
71
66
|
<div className="udb-sidebar__brand">
|
|
72
67
|
{brand ?? <BrandLogo size={32} />}
|
|
73
|
-
{!collapsed && brandName
|
|
68
|
+
{!collapsed && (brandName || brandTagline) && (
|
|
74
69
|
<div className="udb-sidebar__brand-text">
|
|
75
|
-
<span className="udb-sidebar__brand-name">{brandName
|
|
70
|
+
<span className="udb-sidebar__brand-name">{brandName}</span>
|
|
71
|
+
|
|
76
72
|
<span className="udb-sidebar__brand-tagline">{brandTagline}</span>
|
|
73
|
+
|
|
77
74
|
</div>
|
|
75
|
+
|
|
78
76
|
)}
|
|
79
77
|
</div>
|
|
80
78
|
|
|
81
|
-
{sidebarAction
|
|
79
|
+
{sidebarAction && (
|
|
82
80
|
<div className="udb-sidebar__create">
|
|
83
81
|
{renderAction(
|
|
84
82
|
sidebarAction.label,
|
|
@@ -86,16 +84,7 @@ export const DashboardSidebar = ({
|
|
|
86
84
|
sidebarAction.to ? { to: sidebarAction.to } : undefined
|
|
87
85
|
)}
|
|
88
86
|
</div>
|
|
89
|
-
|
|
90
|
-
showCreatePost && createPostRoute && (
|
|
91
|
-
<div className="udb-sidebar__create">
|
|
92
|
-
{renderAction(
|
|
93
|
-
t('sidebar.createPost'),
|
|
94
|
-
<PenTool className="udb-sidebar__create-icon" />,
|
|
95
|
-
{ to: createPostRoute }
|
|
96
|
-
)}
|
|
97
|
-
</div>
|
|
98
|
-
)
|
|
87
|
+
|
|
99
88
|
)}
|
|
100
89
|
|
|
101
90
|
<nav className="udb-sidebar__nav">
|
|
@@ -116,8 +105,9 @@ export const DashboardSidebar = ({
|
|
|
116
105
|
className="udb-sidebar__group-toggle"
|
|
117
106
|
>
|
|
118
107
|
<span className="udb-sidebar__group-title">
|
|
119
|
-
{
|
|
108
|
+
{group.title}
|
|
120
109
|
</span>
|
|
110
|
+
|
|
121
111
|
<span className="udb-sidebar__group-chevron">
|
|
122
112
|
{isGroupCollapsed ? (
|
|
123
113
|
<ChevronRight className="udb-sidebar__chevron-icon" />
|
|
@@ -125,16 +115,17 @@ export const DashboardSidebar = ({
|
|
|
125
115
|
<ChevronDown className="udb-sidebar__chevron-icon" />
|
|
126
116
|
)}
|
|
127
117
|
</span>
|
|
118
|
+
|
|
128
119
|
</button>
|
|
120
|
+
|
|
129
121
|
)}
|
|
130
122
|
|
|
131
123
|
{(!isGroupCollapsed || collapsed) && filteredItems.map((item) => {
|
|
132
124
|
const active = isPathActive(location.pathname, item.path, item.end);
|
|
133
|
-
const labelText = item.raw ? item.label : t(item.label);
|
|
134
125
|
const collapsedTitle =
|
|
135
126
|
item.badge !== undefined && item.badge !== ""
|
|
136
|
-
? `${
|
|
137
|
-
:
|
|
127
|
+
? `${item.label} (${item.badge})`
|
|
128
|
+
: item.label;
|
|
138
129
|
return (
|
|
139
130
|
<Link
|
|
140
131
|
key={item.path}
|
|
@@ -143,30 +134,40 @@ export const DashboardSidebar = ({
|
|
|
143
134
|
title={collapsed ? collapsedTitle : undefined}
|
|
144
135
|
>
|
|
145
136
|
<item.icon className="udb-sidebar__item-icon" />
|
|
146
|
-
{!collapsed && <span>{
|
|
137
|
+
{!collapsed && <span>{item.label}</span>}
|
|
138
|
+
|
|
147
139
|
{!collapsed && item.badge !== undefined && item.badge !== "" && (
|
|
148
140
|
<span className="udb-sidebar__item-badge">{item.badge}</span>
|
|
141
|
+
|
|
149
142
|
)}
|
|
150
143
|
</Link>
|
|
144
|
+
|
|
151
145
|
);
|
|
152
146
|
})}
|
|
153
147
|
</div>
|
|
148
|
+
|
|
154
149
|
);
|
|
155
150
|
})}
|
|
156
151
|
</div>
|
|
152
|
+
|
|
157
153
|
</nav>
|
|
158
154
|
|
|
159
155
|
<div className="udb-sidebar__footer">
|
|
160
156
|
{sidebarFooter && <div className="udb-sidebar__footer-slot">{sidebarFooter}</div>}
|
|
161
|
-
|
|
157
|
+
|
|
158
|
+
{!collapsed && labels?.system && (
|
|
162
159
|
<p className="udb-sidebar__footer-label">
|
|
163
|
-
{
|
|
160
|
+
{labels.system}
|
|
164
161
|
</p>
|
|
162
|
+
|
|
165
163
|
)}
|
|
166
164
|
<Button variant="ghost" size="icon" onClick={() => setCollapsed(!collapsed)} className="udb-sidebar__footer-btn">
|
|
167
165
|
{collapsed ? <Menu className="udb-sidebar__footer-icon" /> : <ChevronLeft className="udb-sidebar__footer-icon" />}
|
|
168
166
|
</Button>
|
|
167
|
+
|
|
169
168
|
</div>
|
|
169
|
+
|
|
170
170
|
</div>
|
|
171
|
+
|
|
171
172
|
);
|
|
172
173
|
};
|
|
@@ -8,9 +8,12 @@ describe("FilterBar", () => {
|
|
|
8
8
|
<FilterBar
|
|
9
9
|
search={{ value: "", onChange: () => {}, placeholder: "Find…" }}
|
|
10
10
|
actions={<button type="button">Sort</button>}
|
|
11
|
+
|
|
11
12
|
>
|
|
12
13
|
<span>a chip</span>
|
|
14
|
+
|
|
13
15
|
</FilterBar>
|
|
16
|
+
|
|
14
17
|
);
|
|
15
18
|
expect(html).toContain("udb-filter-bar");
|
|
16
19
|
expect(html).toContain("udb-filter-bar__search");
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* FilterBar Component (Layout)
|
|
3
|
-
* @description Horizontal filter strip: search box + chip row + trailing actions
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
1
|
import type { ReactNode } from "react";
|
|
7
2
|
import { SearchBox } from "@umituz/web-design-system/molecules";
|
|
8
3
|
import { cn } from "@umituz/web-design-system/utils/cn";
|
|
@@ -16,10 +11,8 @@ export interface FilterBarSearch {
|
|
|
16
11
|
|
|
17
12
|
export interface FilterBarProps extends BaseProps {
|
|
18
13
|
search?: FilterBarSearch;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/** Trailing controls (sort, primary buttons…). */
|
|
22
|
-
actions?: ReactNode;
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
actions?: ReactNode;
|
|
23
16
|
}
|
|
24
17
|
|
|
25
18
|
export const FilterBar = ({ search, children, actions, className, ...props }: FilterBarProps) => {
|
|
@@ -34,8 +27,11 @@ export const FilterBar = ({ search, children, actions, className, ...props }: Fi
|
|
|
34
27
|
/>
|
|
35
28
|
)}
|
|
36
29
|
{children && <div className="udb-filter-bar__fields">{children}</div>}
|
|
30
|
+
|
|
37
31
|
{actions && <div className="udb-filter-bar__actions">{actions}</div>}
|
|
32
|
+
|
|
38
33
|
</div>
|
|
34
|
+
|
|
39
35
|
);
|
|
40
36
|
};
|
|
41
37
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { renderToString } from "react-dom/server";
|
|
3
|
+
import { FilterSelect } from "./FilterSelect";
|
|
4
|
+
|
|
5
|
+
describe("FilterSelect", () => {
|
|
6
|
+
const options = [
|
|
7
|
+
{ value: "open", label: "Open" },
|
|
8
|
+
{ value: "closed", label: "Closed" },
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
it("renders the all-entry plus options and reports the chosen value", () => {
|
|
12
|
+
const chosen: string[] = [];
|
|
13
|
+
const html = renderToString(
|
|
14
|
+
<FilterSelect
|
|
15
|
+
value="open"
|
|
16
|
+
options={options}
|
|
17
|
+
ariaLabel="Filter by status"
|
|
18
|
+
allLabel="Any status"
|
|
19
|
+
onChange={(v) => chosen.push(v)}
|
|
20
|
+
/>,
|
|
21
|
+
);
|
|
22
|
+
expect(html).toContain('aria-label="Filter by status"');
|
|
23
|
+
expect(html).toContain("Any status");
|
|
24
|
+
expect(html).toContain("Open");
|
|
25
|
+
expect(html).toContain("Closed");
|
|
26
|
+
expect(chosen).toEqual([]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SelectHTMLAttributes } from "react";
|
|
2
|
+
|
|
3
|
+
export interface FilterSelectOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface FilterSelectProps
|
|
9
|
+
extends Omit<SelectHTMLAttributes<HTMLSelectElement>, "onChange" | "value" | "size"> {
|
|
10
|
+
value: string;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
options: readonly FilterSelectOption[];
|
|
13
|
+
ariaLabel: string;
|
|
14
|
+
allLabel: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const FilterSelect = ({
|
|
18
|
+
value,
|
|
19
|
+
onChange,
|
|
20
|
+
options,
|
|
21
|
+
ariaLabel,
|
|
22
|
+
allLabel,
|
|
23
|
+
className,
|
|
24
|
+
...props
|
|
25
|
+
}: FilterSelectProps) => {
|
|
26
|
+
return (
|
|
27
|
+
<select
|
|
28
|
+
aria-label={ariaLabel}
|
|
29
|
+
className={className ? `udb-filter-select ${className}` : "udb-filter-select"}
|
|
30
|
+
value={value}
|
|
31
|
+
onChange={(event) => onChange(event.target.value)}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
<option value="">{allLabel}</option>
|
|
35
|
+
|
|
36
|
+
{options.map((option) => (
|
|
37
|
+
<option key={option.value} value={option.value}>
|
|
38
|
+
{option.label}
|
|
39
|
+
</option>
|
|
40
|
+
|
|
41
|
+
))}
|
|
42
|
+
</select>
|
|
43
|
+
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
FilterSelect.displayName = "FilterSelect";
|