@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.
Files changed (92) hide show
  1. package/package.json +11 -12
  2. package/src/domains/analytics/components/AnalyticsCard.tsx +11 -0
  3. package/src/domains/analytics/components/AnalyticsChart.tsx +24 -5
  4. package/src/domains/analytics/components/AnalyticsLayout.tsx +26 -26
  5. package/src/domains/analytics/components/MetricCard.tsx +2 -5
  6. package/src/domains/analytics/hooks/useAnalytics.ts +1 -7
  7. package/src/domains/analytics/index.ts +0 -1
  8. package/src/domains/analytics/types/analytics.ts +11 -0
  9. package/src/domains/analytics/utils/analytics.ts +2 -115
  10. package/src/domains/analytics/utils/index.ts +0 -1
  11. package/src/domains/calendar/services/CalendarService.ts +2 -25
  12. package/src/domains/charts/components.test.tsx +1 -0
  13. package/src/domains/charts/components.tsx +65 -0
  14. package/src/domains/layouts/components/BrandLogo.tsx +1 -0
  15. package/src/domains/layouts/components/DashboardHeader.tsx +57 -21
  16. package/src/domains/layouts/components/DashboardLayout.test.tsx +40 -22
  17. package/src/domains/layouts/components/DashboardLayout.tsx +60 -28
  18. package/src/domains/layouts/components/DashboardSidebar.tsx +34 -33
  19. package/src/domains/layouts/components/FilterBar.test.tsx +3 -0
  20. package/src/domains/layouts/components/FilterBar.tsx +5 -9
  21. package/src/domains/layouts/components/FilterSelect.test.tsx +28 -0
  22. package/src/domains/layouts/components/FilterSelect.tsx +47 -0
  23. package/src/domains/layouts/components/PageHeader.test.tsx +18 -0
  24. package/src/domains/layouts/components/PageHeader.tsx +13 -3
  25. package/src/domains/layouts/components/SectionHeader.tsx +7 -4
  26. package/src/domains/layouts/components/index.ts +2 -0
  27. package/src/domains/layouts/hooks/dashboard.ts +4 -7
  28. package/src/domains/layouts/types/index.ts +12 -1
  29. package/src/domains/layouts/types/layout.ts +72 -58
  30. package/src/domains/layouts/types/sidebar.ts +0 -8
  31. package/src/domains/layouts/utils/dashboard.test.ts +2 -2
  32. package/src/domains/layouts/utils/dashboard.ts +15 -11
  33. package/src/domains/layouts/utils/index.ts +2 -1
  34. package/src/domains/modules/build.test.tsx +4 -0
  35. package/src/domains/modules/build.tsx +1 -0
  36. package/src/domains/onboarding/calc/slider-value-bounds.ts +1 -1
  37. package/src/domains/onboarding/components/AnimationWrapper.tsx +3 -0
  38. package/src/domains/onboarding/components/OnboardingErrorBoundary.tsx +6 -0
  39. package/src/domains/onboarding/components/OnboardingFlow.test.tsx +48 -27
  40. package/src/domains/onboarding/components/OnboardingFlow.tsx +10 -2
  41. package/src/domains/onboarding/components/OnboardingIntl.tsx +7 -65
  42. package/src/domains/onboarding/components/PrimaryButton.tsx +3 -0
  43. package/src/domains/onboarding/components/ProgressBar.tsx +5 -1
  44. package/src/domains/onboarding/components/QuestionWrapper.tsx +5 -0
  45. package/src/domains/onboarding/components/ScreenContainer.tsx +4 -0
  46. package/src/domains/onboarding/components/SwipeCard.test.tsx +43 -1
  47. package/src/domains/onboarding/components/SwipeCard.tsx +7 -0
  48. package/src/domains/onboarding/components/screens/AccountGateScreen.tsx +7 -0
  49. package/src/domains/onboarding/components/screens/AppDemoScreen.tsx +4 -0
  50. package/src/domains/onboarding/components/screens/ComparisonScreen.tsx +9 -0
  51. package/src/domains/onboarding/components/screens/GoalQuestionScreen.tsx +3 -0
  52. package/src/domains/onboarding/components/screens/PainPointsScreen.tsx +3 -0
  53. package/src/domains/onboarding/components/screens/PaywallScreen.tsx +17 -0
  54. package/src/domains/onboarding/components/screens/PermissionPrimingScreen.tsx +10 -0
  55. package/src/domains/onboarding/components/screens/PersonalizedSolutionScreen.tsx +9 -0
  56. package/src/domains/onboarding/components/screens/PreferencesScreen.tsx +15 -0
  57. package/src/domains/onboarding/components/screens/ProcessingScreen.tsx +8 -0
  58. package/src/domains/onboarding/components/screens/SocialProofScreen.tsx +17 -0
  59. package/src/domains/onboarding/components/screens/TinderCardsScreen.tsx +12 -0
  60. package/src/domains/onboarding/components/screens/ValueDeliveryScreen.tsx +9 -0
  61. package/src/domains/onboarding/components/screens/WelcomeScreen.tsx +7 -0
  62. package/src/domains/onboarding/hooks/useOnboardingProgress.test.tsx +4 -5
  63. package/src/domains/onboarding/index.ts +0 -12
  64. package/src/domains/onboarding/predicates/predicates.test.ts +1 -1
  65. package/src/domains/onboarding/types/config.ts +1 -1
  66. package/src/domains/onboarding/types/labels.ts +1 -0
  67. package/src/domains/onboarding/utils/analytics-dispatch.ts +2 -2
  68. package/src/domains/onboarding/utils/local-storage-bridge.ts +1 -1
  69. package/src/domains/onboarding/validation/validation.test.ts +2 -2
  70. package/src/domains/permissions/PermissionsContext.tsx +6 -18
  71. package/src/domains/permissions/index.ts +0 -1
  72. package/src/domains/search/searchItems.test.ts +1 -1
  73. package/src/domains/search/searchItems.ts +0 -3
  74. package/src/domains/settings/components/AuditLogList.tsx +14 -7
  75. package/src/domains/settings/components/PermissionMatrixScreen.tsx +10 -0
  76. package/src/domains/settings/components/SettingsLayout.tsx +21 -4
  77. package/src/domains/settings/components/SettingsSection.tsx +13 -7
  78. package/src/domains/settings/components/UserManagementTable.tsx +16 -9
  79. package/src/domains/settings/types/settings.ts +7 -1
  80. package/src/domains/settings/utils/index.ts +0 -1
  81. package/src/domains/timing/hooks/useCountdown.test.ts +1 -2
  82. package/src/domains/timing/hooks/useCountdown.ts +0 -4
  83. package/src/internal/formatPattern.ts +8 -0
  84. package/src/domains/analytics/utils/i18nKeys.ts +0 -31
  85. package/src/domains/onboarding/templates/TemplateDemoFallback.tsx +0 -92
  86. package/src/domains/onboarding/templates/art-onboarding.ts +0 -71
  87. package/src/domains/onboarding/templates/health-onboarding.ts +0 -92
  88. package/src/domains/onboarding/templates/index.ts +0 -6
  89. package/src/domains/onboarding/templates/platform-onboarding.ts +0 -201
  90. package/src/domains/onboarding/templates/video-onboarding.ts +0 -95
  91. package/src/domains/permissions/utils/i18nKeys.ts +0 -6
  92. package/src/domains/settings/utils/i18nKeys.ts +0 -12
@@ -1,5 +1,7 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { renderToString } from 'react-dom/server';
3
+ import { render } from '@testing-library/react';
4
+ import { MemoryRouter } from 'react-router';
3
5
  import { PageHeader } from './PageHeader';
4
6
 
5
7
  describe('PageHeader markup smoke', () => {
@@ -22,7 +24,9 @@ describe('PageHeader markup smoke', () => {
22
24
  <PageHeader
23
25
  title="Claims"
24
26
  breadcrumbs={<a href="/policies">Policies</a>}
27
+
25
28
  actions={<button type="button">New claim</button>}
29
+
26
30
  />,
27
31
  );
28
32
  expect(html).toContain('udb-pageheader__breadcrumbs');
@@ -30,6 +34,20 @@ describe('PageHeader markup smoke', () => {
30
34
  expect(html).toContain('New claim');
31
35
  });
32
36
 
37
+ it('renders crumb lists as in-app links', () => {
38
+ const { container } = render(
39
+ <MemoryRouter>
40
+ <PageHeader
41
+ title="Claim 92"
42
+ breadcrumbs={[{ label: 'Policies', to: '/policies' }, { label: 'Claim 92' }]}
43
+ />
44
+ </MemoryRouter>,
45
+
46
+ );
47
+ expect(container.querySelectorAll("a[href='/policies']")).toHaveLength(1);
48
+ expect(container.querySelector('.udb-pageheader__crumb a')?.textContent).toBe('Policies');
49
+ });
50
+
33
51
  it('renders meta under the title block and omits it when undefined', () => {
34
52
  const html = renderToString(
35
53
  <PageHeader title="Policy AC-123" meta={<span>Renews 2027-01-15</span>} />,
@@ -1,4 +1,5 @@
1
1
  import type { ReactNode } from "react";
2
+ import { Link } from "react-router";
2
3
 
3
4
  export interface PageHeaderCrumb {
4
5
  label: string;
@@ -10,8 +11,7 @@ export interface PageHeaderProps {
10
11
  title?: ReactNode;
11
12
  subtitle?: ReactNode;
12
13
  description?: ReactNode;
13
- /** Small facts row (dates, counts, IDs…) under the title block. */
14
- meta?: ReactNode;
14
+ meta?: ReactNode;
15
15
  breadcrumbs?: ReactNode | readonly PageHeaderCrumb[];
16
16
  actions?: ReactNode;
17
17
  className?: string;
@@ -36,22 +36,32 @@ export const PageHeader = ({
36
36
  : isCrumbList(breadcrumbs)
37
37
  ? breadcrumbs.map((crumb, index) => (
38
38
  <span key={`${crumb.label}-${index}`} className="udb-pageheader__crumb">
39
- {crumb.to !== undefined ? <a href={crumb.to}>{crumb.label}</a> : crumb.label}
39
+ {crumb.to !== undefined ? <Link to={crumb.to}>{crumb.label}</Link> : crumb.label}
40
+
40
41
  </span>
42
+
41
43
  ))
42
44
  : breadcrumbs;
43
45
  return (
44
46
  <div className={`udb-pageheader${className ? ` ${className}` : ""}`}>
45
47
  {crumbNode !== undefined && <div className="udb-pageheader__breadcrumbs">{crumbNode}</div>}
48
+
46
49
  <div className="udb-pageheader__main">
47
50
  {kicker !== undefined && <p className="udb-pageheader__kicker">{kicker}</p>}
51
+
48
52
  {title !== undefined && <h1 className="udb-pageheader__title">{title}</h1>}
53
+
49
54
  {(subtitle ?? description) !== undefined && (
50
55
  <p className="udb-pageheader__subtitle">{subtitle ?? description}</p>
56
+
51
57
  )}
52
58
  {meta !== undefined && <div className="udb-pageheader__meta">{meta}</div>}
59
+
53
60
  </div>
61
+
54
62
  {actions !== undefined && <div className="udb-pageheader__actions">{actions}</div>}
63
+
55
64
  </div>
65
+
56
66
  );
57
67
  };
@@ -1,8 +1,7 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
3
  export interface SectionHeaderProps {
4
- /** Small uppercase label above the title. */
5
- kicker?: ReactNode;
4
+ kicker?: ReactNode;
6
5
  title?: ReactNode;
7
6
  subtitle?: ReactNode;
8
7
  description?: ReactNode;
@@ -10,8 +9,6 @@ export interface SectionHeaderProps {
10
9
  className?: string;
11
10
  }
12
11
 
13
- /** Section-level heading (h2) with an optional actions row — the in-page
14
- * counterpart to PageHeader for stacked dashboard sections. */
15
12
  export const SectionHeader = ({
16
13
  kicker,
17
14
  title,
@@ -23,11 +20,17 @@ export const SectionHeader = ({
23
20
  <div className={`udb-sectionheader${className ? ` ${className}` : ""}`}>
24
21
  <div className="udb-sectionheader__main">
25
22
  {kicker !== undefined && <p className="udb-sectionheader__kicker">{kicker}</p>}
23
+
26
24
  {title !== undefined && <h2 className="udb-sectionheader__title">{title}</h2>}
25
+
27
26
  {(subtitle ?? description) !== undefined && (
28
27
  <p className="udb-sectionheader__subtitle">{subtitle ?? description}</p>
28
+
29
29
  )}
30
30
  </div>
31
+
31
32
  {actions !== undefined && <div className="udb-sectionheader__actions">{actions}</div>}
33
+
32
34
  </div>
35
+
33
36
  );
@@ -4,6 +4,8 @@ export { DashboardSidebar } from './DashboardSidebar';
4
4
  export { BrandLogo } from './BrandLogo';
5
5
  export { FilterBar } from './FilterBar';
6
6
  export type { FilterBarProps, FilterBarSearch } from './FilterBar';
7
+ export { FilterSelect } from './FilterSelect';
8
+ export type { FilterSelectProps, FilterSelectOption } from './FilterSelect';
7
9
  export { PageHeader } from './PageHeader';
8
10
  export type { PageHeaderProps, PageHeaderCrumb } from './PageHeader';
9
11
  export { SectionHeader } from './SectionHeader';
@@ -2,22 +2,19 @@ import { useState, useCallback, useEffect } from "react";
2
2
  import type { DashboardNotification } from "../types/notification";
3
3
 
4
4
  export interface UsePageTitleOptions {
5
- /** Appended as `title · suffix` (e.g. the product name). */
6
5
  suffix?: string;
7
- /** Used when the route passes no title (e.g. the home route). */
8
6
  fallback?: string;
7
+ separator?: string;
9
8
  }
10
9
 
11
- /** Document title per route — `usePageTitle("Search", { suffix: "Lingora" })`
12
- * → "Search · Lingora". Restores nothing on unmount (the next route sets it). */
13
10
  export function usePageTitle(title?: string, options: UsePageTitleOptions = {}) {
14
- const { suffix, fallback } = options;
11
+ const { suffix, fallback, separator = "·" } = options;
15
12
 
16
13
  useEffect(() => {
17
- if (title && suffix) document.title = `${title} · ${suffix}`;
14
+ if (title && suffix) document.title = [title, suffix].join(` ${separator} `);
18
15
  else if (title) document.title = title;
19
16
  else if (fallback) document.title = fallback;
20
- }, [title, suffix, fallback]);
17
+ }, [title, suffix, fallback, separator]);
21
18
  }
22
19
 
23
20
  export function useNotifications(initialNotifications: DashboardNotification[] = []) {
@@ -1,5 +1,16 @@
1
1
  export type { SidebarItem, SidebarGroup } from './sidebar';
2
- export type { DashboardHeaderProps, DashboardSidebarProps, DashboardLayoutConfig, HeaderProfileItem } from './layout';
2
+ export type {
3
+ DashboardHeaderProps,
4
+ DashboardSidebarProps,
5
+ DashboardLayoutConfig,
6
+ DashboardLayoutLabels,
7
+ DashboardHeaderLabels,
8
+ DashboardSidebarLabels,
9
+ HeaderProfileItem,
10
+ SidebarAction,
11
+ HeaderSearchAction,
12
+ CommandPaletteConfig,
13
+ } from './layout';
3
14
  export type { DashboardTheme, DashboardThemePreset } from './theme';
4
15
  export type { DashboardNotification } from './notification';
5
16
  export type { DashboardUser, UserNavMenuItem } from './user';
@@ -1,78 +1,92 @@
1
+ export interface DashboardHeaderLabels {
2
+ switchToLight: string;
3
+ switchToDark: string;
4
+ notificationsTitle: string;
5
+ markAllRead: string;
6
+ dismissNotification: string;
7
+ noNotifications: string;
8
+ profile: string;
9
+ settings: string;
10
+ logout: string;
11
+ guestName: string;
12
+ }
13
+
14
+ export interface DashboardSidebarLabels {
15
+ system?: string;
16
+ }
17
+
18
+ export interface DashboardLayoutLabels {
19
+ skipToContent: string;
20
+ navigation: string;
21
+ searchResults: string;
22
+ header: DashboardHeaderLabels;
23
+ sidebar: DashboardSidebarLabels;
24
+ }
25
+
1
26
  export interface DashboardHeaderProps {
2
- collapsed: boolean;
3
- setCollapsed: (collapsed: boolean) => void;
4
- setMobileOpen: (open: boolean) => void;
5
- title: string;
6
- theme?: "light" | "dark";
7
- onToggleTheme?: () => void;
27
+ collapsed: boolean;
28
+ setCollapsed: (collapsed: boolean) => void;
29
+ setMobileOpen: (open: boolean) => void;
30
+ title: string;
31
+ labels: DashboardHeaderLabels;
32
+ theme?: "light" | "dark";
33
+ onToggleTheme?: () => void;
34
+ formatNotificationTime?: (createdAt: Date | string | number) => string;
8
35
  }
9
36
 
10
37
  export interface HeaderProfileItem {
11
- key: string;
12
- label: string;
13
- icon?: React.ReactNode;
14
- to?: string;
15
- onSelect?: () => void;
16
- /** Renders the item in destructive color (sign-out, delete…). */
17
- danger?: boolean;
38
+ key: string;
39
+ label: string;
40
+ icon?: React.ReactNode;
41
+ to?: string;
42
+ onSelect?: () => void;
43
+ danger?: boolean;
18
44
  }
19
45
 
20
- /** Optional primary action under the sidebar brand (replaces the legacy create-post button). */
21
46
  export interface SidebarAction {
22
- label: string;
23
- icon?: import("lucide-react").LucideIcon;
24
- to?: string;
25
- onClick?: () => void;
47
+ label: string;
48
+ icon?: import("lucide-react").LucideIcon;
49
+ to?: string;
50
+ onClick?: () => void;
26
51
  }
27
52
 
28
- /** Header search affordance — a button styled as a search field, e.g. routing to a search page. */
29
53
  export interface HeaderSearchAction {
30
- placeholder?: string;
31
- shortcut?: string;
32
- onActivate: () => void;
54
+ placeholder?: string;
55
+ shortcut?: string;
56
+ onActivate: () => void;
33
57
  }
34
58
 
35
- /** ⌘K command palette wired into the shell: renders the DS CommandPalette,
36
- * binds ⌘K/Ctrl+K, and (unless searchAction overrides it) makes the header
37
- * search button open the palette. */
38
59
  export interface CommandPaletteConfig {
39
- groups: import("@umituz/web-design-system/organisms").CommandGroup[];
40
- placeholder?: string;
41
- emptyLabel?: string;
42
- label?: string;
43
- /** Bind ⌘K/Ctrl+K to open the palette (default true). */
44
- shortcut?: boolean;
45
- /** Append the sidebar groups as navigation groups — derived from
46
- * sidebarGroups and routed internally, so apps never map their nav twice. */
47
- includeSidebar?: boolean;
60
+ groups: import("@umituz/web-design-system/organisms").CommandGroup[];
61
+ placeholder?: string;
62
+ emptyLabel?: string;
63
+ label?: string;
64
+ shortcut?: boolean;
65
+ includeSidebar?: boolean;
66
+ search?: (q: string) => Promise<import("@umituz/web-design-system/organisms").CommandItem[]>;
67
+ searchResultsHeading?: string;
48
68
  }
49
69
 
50
70
  export interface DashboardSidebarProps {
51
- collapsed: boolean;
52
- setCollapsed: (collapsed: boolean) => void;
71
+ collapsed: boolean;
72
+ setCollapsed: (collapsed: boolean) => void;
73
+ labels?: DashboardSidebarLabels;
53
74
  }
54
75
 
55
76
  export interface DashboardLayoutConfig {
56
- sidebarGroups: import('./sidebar').SidebarGroup[];
57
- extraTitleMap?: Record<string, string>;
58
- defaultTitle?: string;
59
- brandName?: string;
60
- brandTagline?: string;
61
- /** Custom brand mark for the sidebar — replaces the built-in logo; pair with brandName for the text block. */
62
- brand?: React.ReactNode;
63
- sidebarAction?: SidebarAction;
64
- /** Extra node rendered in the sidebar footer (above the collapse button; hidden when collapsed). */
65
- sidebarFooter?: React.ReactNode;
66
- /** Extra node rendered in the header actions area (app chips, clocks…). */
67
- headerExtra?: React.ReactNode;
68
- searchAction?: HeaderSearchAction;
69
- /** ⌘K palette — when set, the header search opens it (an explicit
70
- * searchAction.onActivate still wins). */
71
- commandPalette?: CommandPaletteConfig;
72
- /** Fully custom profile menu items — shown in addition to (or, with showDefaultProfileItems=false, instead of) the defaults. */
73
- profileItems?: HeaderProfileItem[];
74
- /** Hide the built-in profile/settings items (defaults to true). */
75
- showDefaultProfileItems?: boolean;
76
- /** "View all" row appended to the notifications dropdown. */
77
- notificationsViewAll?: { label: string; to: string };
77
+ sidebarGroups: import("./sidebar").SidebarGroup[];
78
+ extraTitleMap?: Record<string, string>;
79
+ defaultTitle?: string;
80
+ brandName?: string;
81
+ brandTagline?: string;
82
+ sidebarLabels?: DashboardSidebarLabels;
83
+ brand?: React.ReactNode;
84
+ sidebarAction?: SidebarAction;
85
+ sidebarFooter?: React.ReactNode;
86
+ headerExtra?: React.ReactNode;
87
+ searchAction?: HeaderSearchAction;
88
+ commandPalette?: CommandPaletteConfig;
89
+ profileItems?: HeaderProfileItem[];
90
+ showDefaultProfileItems?: boolean;
91
+ notificationsViewAll?: { label: string; to: string };
78
92
  }
@@ -6,19 +6,11 @@ export interface SidebarItem {
6
6
  path: string;
7
7
  requiredApp?: 'mobile' | 'web';
8
8
  enabled?: boolean;
9
- /** Count pill rendered next to the label (hidden while the sidebar is collapsed). */
10
9
  badge?: string | number;
11
- /**
12
- * Active-route matching: true (default) matches the exact path only;
13
- * false also marks prefix descendants active (e.g. /app on /app/vocab).
14
- */
15
10
  end?: boolean;
16
- /** Render the label verbatim — skip the localization humanizer (final display strings). */
17
- raw?: boolean;
18
11
  }
19
12
 
20
13
  export interface SidebarGroup {
21
14
  title: string;
22
15
  items: SidebarItem[];
23
- titleMap?: Record<string, string>;
24
16
  }
@@ -56,9 +56,9 @@ describe("getPageTitle", () => {
56
56
  ],
57
57
  },
58
58
  ];
59
- // An exact item always wins over prefix parents…
59
+
60
60
  expect(getPageTitle("/app/courses/lesson-1", nested)).toBe("Lesson");
61
- // …on deeper routes the longest prefix parent wins.
61
+
62
62
  expect(getPageTitle("/app/courses/lesson-1/summary", nested)).toBe("Courses");
63
63
  expect(getActiveSidebarItem("/nowhere", nested)).toBeNull();
64
64
  });
@@ -1,18 +1,25 @@
1
- export function formatNotificationTime(
1
+ import { formatPattern } from "../../../internal/formatPattern";
2
+
3
+ export interface RelativeTimeLabels {
4
+ justNow: string;
5
+ minutesAgo: string;
6
+ hoursAgo: string;
7
+ daysAgo: string;
8
+ }
9
+
10
+ export function formatRelativeTime(
2
11
  createdAt: Date | string | number,
3
- t: (key: string, params?: Record<string, unknown>) => string
12
+ labels: RelativeTimeLabels,
4
13
  ): string {
5
14
  const date = new Date(createdAt);
6
15
  const secs = Math.floor((Date.now() - date.getTime()) / 1000);
7
16
 
8
- if (secs < 60) return t("dashboard.activityFeed.times.justNow");
9
- if (secs < 3600) return t("dashboard.activityFeed.times.minutesAgo", { val: Math.floor(secs / 60) });
10
- if (secs < 86400) return t("dashboard.activityFeed.times.hoursAgo", { val: Math.floor(secs / 3600) });
11
- return t("dashboard.activityFeed.times.daysAgo", { val: Math.floor(secs / 86400) });
17
+ if (secs < 60) return labels.justNow;
18
+ if (secs < 3600) return formatPattern(labels.minutesAgo, { count: Math.floor(secs / 60) });
19
+ if (secs < 86400) return formatPattern(labels.hoursAgo, { count: Math.floor(secs / 3600) });
20
+ return formatPattern(labels.daysAgo, { count: Math.floor(secs / 86400) });
12
21
  }
13
22
 
14
- /** Exact match by default; `end: false` also matches the path's children
15
- * (`/app/courses` stays active on `/app/courses/lesson-1`). */
16
23
  export function isPathActive(currentPath: string, targetPath: string, end = true): boolean {
17
24
  return currentPath === targetPath || (!end && currentPath.startsWith(targetPath + "/"));
18
25
  }
@@ -23,9 +30,6 @@ export interface TitledPath {
23
30
  end?: boolean;
24
31
  }
25
32
 
26
- /** Most specific active item: an exact match always wins, otherwise the
27
- * longest `end: false` prefix parent (`/app/courses` beats `/app` on
28
- * `/app/courses/lesson-1`). */
29
33
  export function getActiveSidebarItem<T extends TitledPath>(
30
34
  pathname: string,
31
35
  sidebarGroups: Array<{ items: T[] }>
@@ -1,8 +1,9 @@
1
1
  export {
2
- formatNotificationTime,
2
+ formatRelativeTime,
3
3
  isPathActive,
4
4
  getActiveSidebarItem,
5
5
  getPageTitle,
6
6
  filterSidebarItems,
7
7
  generateNotificationId,
8
8
  } from './dashboard';
9
+ export type { RelativeTimeLabels } from './dashboard';
@@ -14,6 +14,7 @@ const MODULES: DashboardModule[] = [
14
14
  order: 1,
15
15
  permission: "dashboard.view",
16
16
  element: <div>dashboard</div>,
17
+
17
18
  },
18
19
  {
19
20
  path: "/sales",
@@ -23,6 +24,7 @@ const MODULES: DashboardModule[] = [
23
24
  order: 2,
24
25
  permission: "sales.view",
25
26
  element: <div>sales</div>,
27
+
26
28
  },
27
29
  {
28
30
  path: "/sales/:id",
@@ -32,6 +34,7 @@ const MODULES: DashboardModule[] = [
32
34
  inNav: false,
33
35
  permission: "sales.view",
34
36
  element: <div>sales detail</div>,
37
+
35
38
  },
36
39
  {
37
40
  path: "/reports",
@@ -40,6 +43,7 @@ const MODULES: DashboardModule[] = [
40
43
  navGroup: "nav.insight",
41
44
  order: 1,
42
45
  element: <div>reports</div>,
46
+
43
47
  },
44
48
  ];
45
49
 
@@ -16,6 +16,7 @@ export const buildRoutes = (modules: readonly DashboardModule[]): RouteConfig[]
16
16
  <RequirePermission permission={module.permission}>
17
17
  {module.element}
18
18
  </RequirePermission>
19
+
19
20
  ) : (
20
21
  module.element
21
22
  ),
@@ -22,7 +22,7 @@ export function clampValueToBounds(
22
22
  preferenceId: string,
23
23
  ): number {
24
24
  if (!areSliderBoundsValid(min, max)) {
25
-
25
+
26
26
  console.error(
27
27
  `[web-onboarding] preference "${preferenceId}" has min > max (${min} > ${max}); returning value as-is.`,
28
28
  );
@@ -49,6 +49,7 @@ export function AnimationWrapper({
49
49
  <div key={stepKey} className={className}>
50
50
  {children}
51
51
  </div>
52
+
52
53
  );
53
54
  }
54
55
  const variants = variantsByTransition[effective];
@@ -64,6 +65,8 @@ export function AnimationWrapper({
64
65
  >
65
66
  {children}
66
67
  </motion.div>
68
+
67
69
  </AnimatePresence>
70
+
68
71
  );
69
72
  }
@@ -42,6 +42,7 @@ export class OnboardingErrorBoundary extends Component<
42
42
 
43
43
  if (!error) {
44
44
  return <Fragment key={attempt}>{this.props.children}</Fragment>;
45
+
45
46
  }
46
47
 
47
48
  if (this.props.renderError) return this.props.renderError(error, this.retry);
@@ -52,10 +53,15 @@ export class OnboardingErrorBoundary extends Component<
52
53
  <div className="udb-onb-errorpage__icon" aria-hidden="true">
53
54
  <AlertTriangle className="udb-onb-icon--lg" />
54
55
  </div>
56
+
55
57
  <h2 className="udb-onb-title">{labels.somethingWentWrong}</h2>
58
+
56
59
  <p className="udb-onb-lead">{error.message || labels.unexpectedError}</p>
60
+
57
61
  <PrimaryButton onClick={this.retry}>{labels.tryAgain}</PrimaryButton>
62
+
58
63
  </div>
64
+
59
65
  );
60
66
  }
61
67
  }
@@ -1,14 +1,49 @@
1
1
  import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2
2
  import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
3
3
  import { OnboardingFlow } from './OnboardingFlow';
4
- import {
5
- artOnboardingTemplate,
6
- healthOnboardingTemplate,
7
- platformOnboardingTemplate,
8
- videoOnboardingTemplate,
9
- } from '../templates';
10
4
  import { defaultStorageKey } from '../utils/default-storage-key';
11
- import type { OnboardingConfig, OnboardingScreen } from '../types';
5
+ import type { OnboardingConfig, OnboardingScreen, OnboardingLabels } from '../types';
6
+
7
+ const labels: OnboardingLabels = {
8
+ progressLabel: 'Onboarding progress',
9
+ continueAction: 'Continue',
10
+ back: 'Back',
11
+ skip: 'Skip',
12
+ loading: 'Loading…',
13
+ stepOfPattern: 'Step {current} of {total}',
14
+ countOfPattern: '{current} of {total}',
15
+ selectAllThatApply: 'Select all that apply',
16
+ selectOne: 'Select one',
17
+ pickUpToPattern: 'Pick up to {max}',
18
+ pickTheOne: 'Pick the one that bothers you most',
19
+ tailorExperience: 'Tailor the experience to your needs',
20
+ agree: 'Agree',
21
+ disagree: 'Disagree',
22
+ swipeHint: 'Swipe right if you agree, left if you don’t. Or use the arrow keys.',
23
+ allDone: 'All done — that was easy.',
24
+ withoutUs: 'Without us',
25
+ withUs: 'With us',
26
+ previous: 'Previous',
27
+ nextAction: 'Next',
28
+ continueWithResult: 'Continue with my result',
29
+ allowAccess: 'Allow access',
30
+ permissionRequestFailed: 'Permission request failed',
31
+ continueWithEmail: 'Continue with email',
32
+ continueWithGoogle: 'Continue with Google',
33
+ continueWithApple: 'Continue with Apple',
34
+ continueWithGitHub: 'Continue with GitHub',
35
+ skipForNow: 'Skip for now',
36
+ signInFailed: 'Sign-in failed',
37
+ couldNotStartTrial: 'Could not start trial',
38
+ trialDaysPattern: '{count}-day free trial',
39
+ trialIntroPattern: '{price} for the first {days} days',
40
+ cancelAnytimeNote: 'Cancel anytime. No hidden fees.',
41
+ share: 'Share',
42
+ copied: 'Copied!',
43
+ somethingWentWrong: 'Something went wrong',
44
+ unexpectedError: 'An unexpected error occurred during onboarding.',
45
+ tryAgain: 'Try again',
46
+ };
12
47
 
13
48
  const paywall: OnboardingScreen = {
14
49
  id: 'pay',
@@ -42,6 +77,7 @@ const welcome: OnboardingScreen = {
42
77
  const minimalConfig = (overrides: Partial<OnboardingConfig> = {}): OnboardingConfig => ({
43
78
  category: 'health',
44
79
  screens: [welcome, accountGate, paywall],
80
+ labels,
45
81
  ...overrides,
46
82
  });
47
83
 
@@ -193,10 +229,13 @@ describe('OnboardingFlow — validation & error boundary', () => {
193
229
  renderError: (err: Error, retry: () => void) => (
194
230
  <div>
195
231
  <p>Custom handler: {err.message}</p>
232
+
196
233
  <button type="button" onClick={retry}>
197
234
  Retry anyway
198
235
  </button>
236
+
199
237
  </div>
238
+
200
239
  ),
201
240
  });
202
241
  fireEvent.click(screen.getByRole('button', { name: 'Get started' }));
@@ -226,10 +265,10 @@ describe('OnboardingFlow — persistence', () => {
226
265
  });
227
266
 
228
267
  describe('OnboardingFlow — labels & locale', () => {
229
- it('overrides default labels via config.labels', () => {
268
+ it('renders the supplied labels verbatim', () => {
230
269
  renderFlow(
231
270
  minimalConfig({
232
- labels: { back: 'Geri', skip: 'Atla' },
271
+ labels: { ...labels, back: 'Geri', skip: 'Atla' },
233
272
  onSkip: () => undefined,
234
273
  }),
235
274
  );
@@ -439,21 +478,3 @@ describe('processing screen — auto-advance', () => {
439
478
  }
440
479
  });
441
480
  });
442
-
443
- describe('templates — mount regression (§19)', () => {
444
- const cases: Array<[string, OnboardingConfig]> = [
445
- ['health', healthOnboardingTemplate],
446
- ['art', artOnboardingTemplate],
447
- ['video', videoOnboardingTemplate],
448
- ['platform', platformOnboardingTemplate],
449
- ];
450
-
451
- it.each(cases)('%s template renders its first screen without crashing', (name, template) => {
452
- expect(() =>
453
- render(<OnboardingFlow config={{ ...template, storageKey: `tpl:${name}` }} ephemeral />),
454
- ).not.toThrow();
455
- expect(
456
- screen.getByText(new RegExp(`Step 1 of ${template.screens.length}`)),
457
- ).toBeTruthy();
458
- });
459
- });