@okjt/dashboard 0.2.2 → 0.4.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.
@@ -0,0 +1,41 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useAuth } from "./AuthContext.js";
4
+ import AuthLayout, { AuthError, AuthField, AuthSubmit } from "./AuthLayout.js";
5
+ function ConfirmPasswordPage({
6
+ layout: Layout = AuthLayout,
7
+ onConfirmed,
8
+ title = "Confirm it\u2019s you",
9
+ subtitle = "This is a secure area. Please confirm your password to carry on.",
10
+ footer,
11
+ submitLabel = "Confirm",
12
+ idPrefix = "confirm"
13
+ }) {
14
+ const { confirmPassword } = useAuth();
15
+ const [password, setPassword] = useState("");
16
+ const [error, setError] = useState(null);
17
+ const [loading, setLoading] = useState(false);
18
+ const onSubmit = async (e) => {
19
+ e.preventDefault();
20
+ setLoading(true);
21
+ setError(null);
22
+ const result = await confirmPassword(password);
23
+ setLoading(false);
24
+ if (result.success) {
25
+ onConfirmed?.();
26
+ return;
27
+ }
28
+ setError(result.errors?.password?.[0] || result.message);
29
+ setPassword("");
30
+ };
31
+ return /* @__PURE__ */ jsxs(Layout, { title, subtitle, footer, children: [
32
+ /* @__PURE__ */ jsx(AuthError, { children: error }),
33
+ /* @__PURE__ */ jsxs("form", { onSubmit, className: "space-y-5", children: [
34
+ /* @__PURE__ */ jsx(AuthField, { id: `${idPrefix}-password`, label: "Password", type: "password", autoComplete: "current-password", value: password, onChange: (e) => setPassword(e.target.value), required: true, autoFocus: true }),
35
+ /* @__PURE__ */ jsx("div", { className: "pt-2", children: /* @__PURE__ */ jsx(AuthSubmit, { loading, children: loading ? "Checking\u2026" : submitLabel }) })
36
+ ] })
37
+ ] });
38
+ }
39
+ export {
40
+ ConfirmPasswordPage as default
41
+ };
@@ -5,7 +5,7 @@ import { usePermissions } from "@okjt/ui";
5
5
  import { useCollaboration } from "./CollaborationContext.js";
6
6
  import CollaboratorAvatars from "./CollaboratorAvatars.js";
7
7
  import { useDashboard } from "./DashboardProvider.js";
8
- function DashboardHeader({ onMenuClick, onRestartTutorial, titleSlotRef, statusSlotRef }) {
8
+ function DashboardHeader({ onMenuClick, onRestartTutorial, titleSlotRef, statusSlotRef, menuExpanded }) {
9
9
  const { pathname } = useLocation();
10
10
  const { presence, othersHere, openHistory, setShareOpen, badges } = useCollaboration();
11
11
  const hasNews = Object.values(badges).some(Boolean);
@@ -16,27 +16,29 @@ function DashboardHeader({ onMenuClick, onRestartTutorial, titleSlotRef, statusS
16
16
  "header",
17
17
  {
18
18
  id: "header",
19
- className: "sticky top-0 z-30 h-16 px-3 sm:px-6 flex items-center justify-between gap-3",
19
+ className: `sticky top-0 z-30 h-16 ${shell.headerClass} flex items-center justify-between gap-3`,
20
20
  style: {
21
21
  background: shell.headerBackground,
22
22
  backdropFilter: "blur(10px)",
23
23
  borderBottom: shell.headerBorder
24
24
  },
25
25
  children: [
26
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 sm:gap-4 min-w-0 flex-1", children: [
26
+ /* @__PURE__ */ jsxs("div", { className: `flex items-center ${shell.headerStartClass}`, children: [
27
27
  /* @__PURE__ */ jsxs(
28
28
  "button",
29
29
  {
30
30
  onClick: onMenuClick,
31
31
  "aria-label": hasNews ? "Open sidebar menu (new changes)" : "Open sidebar menu",
32
- className: "lg:hidden relative p-2 rounded-lg hover:bg-black/5 shrink-0",
32
+ "aria-expanded": shell.collapsible ? menuExpanded : void 0,
33
+ className: `${shell.collapsible ? "" : "lg:hidden "}relative p-2 rounded-lg shrink-0 ${shell.menuButtonClass}`,
33
34
  children: [
34
- /* @__PURE__ */ jsx(Menu, { className: "w-6 h-6 text-body" }),
35
- hasNews && /* @__PURE__ */ jsx("span", { className: "absolute top-1.5 right-1.5 w-2 h-2 rounded-full bg-accent ring-2 ring-paper", "aria-hidden": "true" })
35
+ shell.MenuIcon ? /* @__PURE__ */ jsx(shell.MenuIcon, {}) : /* @__PURE__ */ jsx(Menu, { className: "w-6 h-6 text-body" }),
36
+ hasNews && shell.menuNewsDot && /* @__PURE__ */ jsx("span", { className: `absolute top-1.5 right-1.5 w-2 h-2 rounded-full bg-accent ring-2 ring-paper ${shell.collapsible ? "lg:hidden" : ""}`, "aria-hidden": "true" })
36
37
  ]
37
38
  }
38
39
  ),
39
- /* @__PURE__ */ jsx("div", { ref: titleSlotRef, className: "min-w-0 flex-1" }),
40
+ /* @__PURE__ */ jsx("div", { ref: titleSlotRef, className: `min-w-0 ${shell.HeaderStart ? "empty:hidden" : "flex-1"}` }),
41
+ shell.HeaderStart && /* @__PURE__ */ jsx(shell.HeaderStart, {}),
40
42
  othersHere.length > 0 && /* @__PURE__ */ jsxs(
41
43
  "button",
42
44
  {
@@ -51,7 +53,7 @@ function DashboardHeader({ onMenuClick, onRestartTutorial, titleSlotRef, statusS
51
53
  }
52
54
  )
53
55
  ] }),
54
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 sm:gap-2 shrink-0", children: [
56
+ /* @__PURE__ */ jsxs("div", { className: `flex items-center ${shell.headerEndClass}`, children: [
55
57
  !canEdit && /* @__PURE__ */ jsx(
56
58
  "span",
57
59
  {
@@ -80,54 +82,67 @@ function DashboardHeader({ onMenuClick, onRestartTutorial, titleSlotRef, statusS
80
82
  link.path
81
83
  );
82
84
  }) }),
83
- presence.length > 0 && /* @__PURE__ */ jsx(
84
- "button",
85
- {
86
- type: "button",
87
- onClick: () => setShareOpen(true),
88
- className: "hidden md:flex p-1 rounded-full hover:bg-black/5",
89
- "aria-label": `${presence.length} collaborator${presence.length === 1 ? "" : "s"} online`,
90
- children: /* @__PURE__ */ jsx(CollaboratorAvatars, { people: presence, max: 3 })
85
+ shell.Search && /* @__PURE__ */ jsx(shell.Search, {}),
86
+ shell.headerActions.map((action, i) => {
87
+ if (typeof action === "function" || typeof action === "object") {
88
+ const Action = action;
89
+ return /* @__PURE__ */ jsx(Action, {}, `own-${i}`);
91
90
  }
92
- ),
93
- /* @__PURE__ */ jsxs(
94
- "button",
95
- {
96
- id: "header-share",
97
- type: "button",
98
- onClick: () => setShareOpen(true),
99
- "aria-label": "Share dashboard",
100
- title: "Share \u2014 invite collaborators",
101
- className: "flex items-center gap-2 p-2 xl:px-3 rounded-xl text-sm font-medium text-soft hover:bg-accent/10 hover:text-accent transition-colors",
102
- children: [
103
- /* @__PURE__ */ jsx(Share2, { className: "w-5 h-5" }),
104
- /* @__PURE__ */ jsx("span", { className: "hidden xl:inline", children: "Share" })
105
- ]
106
- }
107
- ),
108
- /* @__PURE__ */ jsx(
109
- "button",
110
- {
111
- id: "header-history",
112
- type: "button",
113
- onClick: openHistory,
114
- "aria-label": "Version history",
115
- title: "Version history",
116
- className: "p-2 rounded-xl text-soft hover:bg-accent/10 hover:text-accent transition-colors",
117
- children: /* @__PURE__ */ jsx(History, { className: "w-5 h-5" })
118
- }
119
- ),
120
- /* @__PURE__ */ jsx(
121
- "button",
122
- {
123
- "aria-label": "Restart Dashboard Tour",
124
- id: "header-restart",
125
- onClick: onRestartTutorial,
126
- className: "hidden sm:block p-2 rounded-xl text-muted hover:bg-black/5 transition-colors",
127
- title: "Restart Dashboard Tour",
128
- children: /* @__PURE__ */ jsx(Info, { className: "w-5 h-5" })
129
- }
130
- ),
91
+ if (action === "online") return presence.length > 0 && // Who's online (click for the share panel)
92
+ /* @__PURE__ */ jsx(
93
+ "button",
94
+ {
95
+ type: "button",
96
+ onClick: () => setShareOpen(true),
97
+ className: "hidden md:flex p-1 rounded-full hover:bg-contrast/5",
98
+ "aria-label": `${presence.length} collaborator${presence.length === 1 ? "" : "s"} online`,
99
+ children: /* @__PURE__ */ jsx(CollaboratorAvatars, { people: presence, max: 3 })
100
+ },
101
+ "online"
102
+ );
103
+ if (action === "share") return /* @__PURE__ */ jsxs(
104
+ "button",
105
+ {
106
+ id: "header-share",
107
+ type: "button",
108
+ onClick: () => setShareOpen(true),
109
+ "aria-label": "Share dashboard",
110
+ title: "Share \u2014 invite collaborators",
111
+ className: `flex items-center gap-2 p-2 xl:px-3 rounded-xl text-sm font-medium transition-colors ${shell.headerButtonClass}`,
112
+ children: [
113
+ /* @__PURE__ */ jsx(Share2, { className: "w-5 h-5" }),
114
+ /* @__PURE__ */ jsx("span", { className: "hidden xl:inline", children: "Share" })
115
+ ]
116
+ },
117
+ "share"
118
+ );
119
+ if (action === "history") return /* @__PURE__ */ jsx(
120
+ "button",
121
+ {
122
+ id: "header-history",
123
+ type: "button",
124
+ onClick: openHistory,
125
+ "aria-label": "Version history",
126
+ title: "Version history",
127
+ className: `p-2 rounded-xl transition-colors ${shell.headerButtonClass}`,
128
+ children: /* @__PURE__ */ jsx(History, { className: "w-5 h-5" })
129
+ },
130
+ "history"
131
+ );
132
+ if (action === "tour") return /* @__PURE__ */ jsx(
133
+ "button",
134
+ {
135
+ "aria-label": "Restart Dashboard Tour",
136
+ id: "header-restart",
137
+ onClick: onRestartTutorial,
138
+ className: "hidden sm:block p-2 rounded-xl text-muted hover:bg-contrast/5 transition-colors",
139
+ title: "Restart Dashboard Tour",
140
+ children: /* @__PURE__ */ jsx(Info, { className: "w-5 h-5" })
141
+ },
142
+ "tour"
143
+ );
144
+ return null;
145
+ }),
131
146
  shell.Notifications && /* @__PURE__ */ jsx(shell.Notifications, {}),
132
147
  shell.AccountMenu && /* @__PURE__ */ jsx(shell.AccountMenu, { compactLinks: quickLinks })
133
148
  ] })
@@ -0,0 +1,15 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useDashboard } from "./DashboardProvider.js";
3
+ function DashboardIcon({ icon, fallback = null, className = "", ...rest }) {
4
+ const { iconFor } = useDashboard();
5
+ const Icon = (typeof icon === "string" ? iconFor(icon) : icon) || fallback;
6
+ return Icon ? /* @__PURE__ */ jsx(Icon, { className, "aria-hidden": "true", ...rest }) : null;
7
+ }
8
+ function toIcon(icon, iconFor) {
9
+ if (!icon) return null;
10
+ return typeof icon === "string" ? iconFor?.(icon) || null : icon;
11
+ }
12
+ export {
13
+ DashboardIcon as default,
14
+ toIcon
15
+ };
@@ -16,7 +16,9 @@ const DEFAULTS = {
16
16
  roleLabel: (role) => DEFAULT_ROLES.find((r) => r.value === role)?.label || role,
17
17
  anonymousName: "Someone",
18
18
  removeCollaborator: null,
19
- tutorialSteps: []
19
+ tutorialSteps: [],
20
+ iconFor: () => null,
21
+ componentDefaults: {}
20
22
  };
21
23
  const DEFAULT_SHELL = {
22
24
  logo: { src: "", alt: "", to: "/" },
@@ -30,16 +32,49 @@ const DEFAULT_SHELL = {
30
32
  badgeClass: "bg-accent-soft text-body",
31
33
  Banner: null,
32
34
  Notifications: null,
33
- AccountMenu: null
35
+ AccountMenu: null,
36
+ // The frame's shape and look (defaults: Naoa's).
37
+ sidebarWidth: 280,
38
+ collapsible: false,
39
+ railWidth: 80,
40
+ sidebarClass: "",
41
+ logoBoxClass: "p-4",
42
+ logoClass: "h-10 w-auto",
43
+ railLogoClass: "h-9 w-12 object-contain",
44
+ navTitleClass: "px-3 mb-1 text-[10px] font-bold uppercase tracking-[0.18em] text-white/50",
45
+ navItemClass: "px-3 py-2 rounded-lg",
46
+ navActiveClass: "text-accent-dark bg-white shadow-sm",
47
+ navIdleClass: "text-white/75 hover:text-accent-dark hover:bg-white",
48
+ navLabelClass: "font-medium truncate",
49
+ navClass: "py-2 px-3",
50
+ headerClass: "px-3 sm:px-6",
51
+ headerStartClass: "gap-2 sm:gap-4 min-w-0 flex-1",
52
+ headerEndClass: "gap-1 sm:gap-2 shrink-0",
53
+ menuButtonClass: "hover:bg-contrast/5",
54
+ MenuIcon: null,
55
+ menuNewsDot: true,
56
+ mainClass: "p-4 sm:p-6",
57
+ headerButtonClass: "text-soft hover:bg-accent/10 hover:text-accent",
58
+ headerActions: ["online", "share", "history", "tour"],
59
+ HeaderStart: null,
60
+ Search: null,
61
+ HistoryDrawer: null,
62
+ ShareModal: null
34
63
  };
35
64
  function DashboardProvider({ dashboard, children }) {
36
65
  return /* @__PURE__ */ jsx(DashboardContext.Provider, { value: dashboard, children });
37
66
  }
67
+ function useComponentDefaults(name, props) {
68
+ const { componentDefaults } = useDashboard();
69
+ const defaults = componentDefaults?.[name];
70
+ return defaults ? { ...defaults, ...props } : props;
71
+ }
38
72
  function useDashboard() {
39
73
  const settings = useContext(DashboardContext);
40
74
  return { ...DEFAULTS, ...settings, shell: { ...DEFAULT_SHELL, ...settings?.shell, logo: { ...DEFAULT_SHELL.logo, ...settings?.shell?.logo } } };
41
75
  }
42
76
  export {
43
77
  DashboardProvider,
78
+ useComponentDefaults,
44
79
  useDashboard
45
80
  };
@@ -20,12 +20,22 @@ function ResetSearchOnNavigate({ pathname }) {
20
20
  return null;
21
21
  }
22
22
  function CollaborationPanels() {
23
+ const { shell } = useDashboard();
23
24
  const { shareOpen, setShareOpen, historyOpen, closeHistory, module, notifyDataRestored } = useCollaboration();
24
25
  return /* @__PURE__ */ jsxs(Fragment, { children: [
25
- /* @__PURE__ */ jsx(ShareModal, { isOpen: shareOpen, onClose: () => setShareOpen(false) }),
26
- /* @__PURE__ */ jsx(AnimatePresence, { children: historyOpen && /* @__PURE__ */ jsx(VersionHistoryDrawer, { module, onClose: closeHistory, onRestored: notifyDataRestored }) })
26
+ shell.ShareModal ? /* @__PURE__ */ jsx(shell.ShareModal, { open: shareOpen, onClose: () => setShareOpen(false) }) : /* @__PURE__ */ jsx(ShareModal, { isOpen: shareOpen, onClose: () => setShareOpen(false) }),
27
+ shell.HistoryDrawer ? /* @__PURE__ */ jsx(shell.HistoryDrawer, { open: historyOpen, onClose: closeHistory, module, onRestored: notifyDataRestored }) : /* @__PURE__ */ jsx(AnimatePresence, { children: historyOpen && /* @__PURE__ */ jsx(VersionHistoryDrawer, { module, onClose: closeHistory, onRestored: notifyDataRestored }) })
27
28
  ] });
28
29
  }
30
+ const COLLAPSED_KEY = "okjt.sidebar.collapsed";
31
+ const readCollapsed = () => {
32
+ try {
33
+ return localStorage.getItem(COLLAPSED_KEY) === "1";
34
+ } catch {
35
+ return false;
36
+ }
37
+ };
38
+ const isWide = () => typeof window !== "undefined" && window.matchMedia?.("(min-width: 1024px)").matches;
29
39
  function PageContent({ pathname, children }) {
30
40
  const { dataVersion } = useCollaboration();
31
41
  return /* @__PURE__ */ jsx(
@@ -42,6 +52,18 @@ function PageContent({ pathname, children }) {
42
52
  function DashboardShell({ children }) {
43
53
  const { shell, tutorialSteps } = useDashboard();
44
54
  const [sidebarOpen, setSidebarOpen] = useState(false);
55
+ const [collapsed, setCollapsed] = useState(() => shell.collapsible && readCollapsed());
56
+ const onMenuClick = () => {
57
+ if (!shell.collapsible || !isWide()) return setSidebarOpen(true);
58
+ setCollapsed((was) => {
59
+ try {
60
+ localStorage.setItem(COLLAPSED_KEY, was ? "0" : "1");
61
+ } catch {
62
+ }
63
+ return !was;
64
+ });
65
+ };
66
+ const sidebarWidth = collapsed ? shell.railWidth : shell.sidebarWidth;
45
67
  const [restartTutorial, setRestartTutorial] = useState(false);
46
68
  const location = useLocation();
47
69
  const [titleSlot, setTitleSlot] = useState(null);
@@ -50,6 +72,10 @@ function DashboardShell({ children }) {
50
72
  document.documentElement.classList.add("admin-theme");
51
73
  return () => document.documentElement.classList.remove("admin-theme");
52
74
  }, []);
75
+ useEffect(() => {
76
+ document.documentElement.style.setProperty("--okjt-sidebar-w", `${sidebarWidth}px`);
77
+ return () => document.documentElement.style.removeProperty("--okjt-sidebar-w");
78
+ }, [sidebarWidth]);
53
79
  return /* @__PURE__ */ jsx(MotionConfig, { reducedMotion: "user", children: /* @__PURE__ */ jsx(SearchProvider, { children: /* @__PURE__ */ jsx(AdminChromeProvider, { value: { titleSlot, statusSlot }, children: /* @__PURE__ */ jsxs(CollaborationProvider, { children: [
54
80
  /* @__PURE__ */ jsx(ResetSearchOnNavigate, { pathname: location.pathname }),
55
81
  /* @__PURE__ */ jsxs(
@@ -58,12 +84,13 @@ function DashboardShell({ children }) {
58
84
  className: "min-h-screen",
59
85
  style: { background: shell.background },
60
86
  children: [
61
- /* @__PURE__ */ jsx(DashboardSidebar, { isOpen: sidebarOpen, onClose: () => setSidebarOpen(false) }),
62
- /* @__PURE__ */ jsxs("div", { className: "lg:ml-[280px]", children: [
87
+ /* @__PURE__ */ jsx(DashboardSidebar, { isOpen: sidebarOpen, onClose: () => setSidebarOpen(false), collapsed }),
88
+ /* @__PURE__ */ jsxs("div", { className: "lg:ml-[var(--okjt-sidebar-w,280px)]", children: [
63
89
  /* @__PURE__ */ jsx(
64
90
  DashboardHeader,
65
91
  {
66
- onMenuClick: () => setSidebarOpen(true),
92
+ onMenuClick,
93
+ menuExpanded: !collapsed,
67
94
  onRestartTutorial: () => setRestartTutorial((prev) => !prev),
68
95
  titleSlotRef: setTitleSlot,
69
96
  statusSlotRef: setStatusSlot
@@ -81,7 +108,7 @@ function DashboardShell({ children }) {
81
108
  },
82
109
  restartTutorial ? "restarted" : "initial"
83
110
  ),
84
- /* @__PURE__ */ jsx("main", { className: "p-4 sm:p-6", children: /* @__PURE__ */ jsx(PageContent, { pathname: location.pathname, children }) })
111
+ /* @__PURE__ */ jsx("main", { id: "main-content", tabIndex: -1, className: shell.mainClass, children: /* @__PURE__ */ jsx(PageContent, { pathname: location.pathname, children }) })
85
112
  ] })
86
113
  ]
87
114
  }
@@ -6,11 +6,12 @@ import { useCollaboration } from "./CollaborationContext.js";
6
6
  import CollaboratorAvatars from "./CollaboratorAvatars.js";
7
7
  import { useDashboard } from "./DashboardProvider.js";
8
8
  import { useModules } from "./modules.js";
9
- function DashboardSidebar({ isOpen, onClose }) {
9
+ function DashboardSidebar({ isOpen, onClose, collapsed = false }) {
10
10
  const location = useLocation();
11
11
  const { home, shell } = useDashboard();
12
12
  const { moduleForPath } = useModules();
13
13
  const { badges, presence } = useCollaboration();
14
+ const rail = collapsed && !isOpen;
14
15
  return /* @__PURE__ */ jsxs(Fragment, { children: [
15
16
  /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(
16
17
  motion.div,
@@ -25,19 +26,19 @@ function DashboardSidebar({ isOpen, onClose }) {
25
26
  /* @__PURE__ */ jsx(
26
27
  motion.aside,
27
28
  {
28
- className: `admin-sidebar fixed left-0 top-0 h-full z-50 lg:translate-x-0 ${isOpen ? "translate-x-0" : "-translate-x-full"} transition-transform lg:transition-none`,
29
+ className: `admin-sidebar fixed left-0 top-0 h-full z-50 lg:translate-x-0 ${shell.sidebarClass} ${isOpen ? "translate-x-0" : "-translate-x-full"} transition-transform lg:transition-none`,
29
30
  style: {
30
- width: 280,
31
+ width: rail ? shell.railWidth : shell.sidebarWidth,
31
32
  background: shell.sidebarBackground
32
33
  },
33
34
  children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
34
- /* @__PURE__ */ jsxs("div", { className: "p-4 flex items-center justify-center relative", children: [
35
+ /* @__PURE__ */ jsxs("div", { className: `${rail ? "p-2 py-4" : shell.logoBoxClass} flex items-center justify-center relative`, children: [
35
36
  /* @__PURE__ */ jsx(Link, { to: shell.logo.to, className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
36
37
  "img",
37
38
  {
38
39
  src: shell.logo.src,
39
40
  alt: shell.logo.alt,
40
- className: "h-10 w-auto"
41
+ className: rail ? shell.railLogoClass : shell.logoClass
41
42
  }
42
43
  ) }),
43
44
  /* @__PURE__ */ jsx(
@@ -50,9 +51,10 @@ function DashboardSidebar({ isOpen, onClose }) {
50
51
  }
51
52
  )
52
53
  ] }),
53
- /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "flex-1 py-2 px-3 overflow-y-auto", style: { scrollbarWidth: "thin", scrollbarColor: shell.sidebarScrollbar }, children: shell.nav.map((section, sectionIndex) => /* @__PURE__ */ jsxs("div", { className: sectionIndex > 0 ? "mt-4" : "", children: [
54
- section.title && /* @__PURE__ */ jsx("p", { className: "px-3 mb-1 text-[10px] font-bold uppercase tracking-[0.18em] text-white/50", children: section.title }),
55
- /* @__PURE__ */ jsx("ul", { className: "space-y-0.5", children: section.items.map((item) => {
54
+ /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: `flex-1 ${shell.navClass} overflow-y-auto`, style: { scrollbarWidth: "thin", scrollbarColor: shell.sidebarScrollbar }, children: shell.nav.map((section, sectionIndex) => /* @__PURE__ */ jsxs("div", { className: sectionIndex > 0 ? "mt-4" : "", children: [
55
+ section.title && !rail && /* @__PURE__ */ jsx("p", { className: shell.navTitleClass, children: section.title }),
56
+ section.title && rail && /* @__PURE__ */ jsx("div", { "aria-hidden": "true", className: "mx-3 mb-2 h-px bg-white/10" }),
57
+ /* @__PURE__ */ jsx("ul", { className: "space-y-0.5", "aria-label": section.title || void 0, children: section.items.map((item) => {
56
58
  const isActive = location.pathname === item.path || item.path !== home.path && location.pathname.startsWith(item.path);
57
59
  const moduleKey = moduleForPath(item.path)?.key;
58
60
  const newCount = isActive ? 0 : badges[moduleKey] || 0;
@@ -65,16 +67,20 @@ function DashboardSidebar({ isOpen, onClose }) {
65
67
  to: item.path,
66
68
  onClick: () => onClose(),
67
69
  "aria-current": isActive ? "page" : void 0,
68
- "aria-label": label !== item.label ? label : void 0,
69
- className: `flex items-center gap-3 px-3 py-2 rounded-lg transition-all text-sm focus-visible:outline-2 focus-visible:outline-white ${isActive ? "text-accent-dark bg-white shadow-sm" : "text-white/75 hover:text-accent-dark hover:bg-white"}`,
70
+ "aria-label": rail || label !== item.label ? label : void 0,
71
+ title: rail ? item.label : void 0,
72
+ className: `flex items-center ${rail ? "justify-center" : "gap-3"} ${shell.navItemClass} transition-all text-sm focus-visible:outline-2 focus-visible:outline-white ${isActive ? shell.navActiveClass : shell.navIdleClass}`,
70
73
  children: [
71
- /* @__PURE__ */ jsx(item.icon, { className: "w-4 h-4 flex-shrink-0", "aria-hidden": "true" }),
72
- /* @__PURE__ */ jsx("span", { className: "font-medium truncate", children: item.label }),
73
- (here.length > 0 || newCount > 0) && /* @__PURE__ */ jsxs("span", { className: "ml-auto flex items-center gap-1.5 shrink-0", "aria-hidden": "true", children: [
74
+ rail ? /* @__PURE__ */ jsxs("span", { className: "relative flex flex-shrink-0", children: [
75
+ /* @__PURE__ */ jsx(item.icon, { className: "w-4 h-4", "aria-hidden": "true" }),
76
+ newCount > 0 && /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "absolute -right-1 -top-1 h-2 w-2 rounded-full bg-accent" })
77
+ ] }) : /* @__PURE__ */ jsx(item.icon, { className: "w-4 h-4 flex-shrink-0", "aria-hidden": "true" }),
78
+ !rail && /* @__PURE__ */ jsx("span", { className: shell.navLabelClass, children: item.label }),
79
+ !rail && (here.length > 0 || newCount > 0) && /* @__PURE__ */ jsxs("span", { className: "ml-auto flex items-center gap-1.5 shrink-0", "aria-hidden": "true", children: [
74
80
  /* @__PURE__ */ jsx(CollaboratorAvatars, { people: here, size: "xs", max: 2 }),
75
81
  newCount > 0 && /* @__PURE__ */ jsx("span", { className: `min-w-[1.25rem] h-5 px-1.5 rounded-full ${shell.badgeClass} text-[10px] font-bold flex items-center justify-center`, children: newCount > 99 ? "99+" : newCount })
76
82
  ] }),
77
- isActive && /* @__PURE__ */ jsx(
83
+ isActive && !rail && /* @__PURE__ */ jsx(
78
84
  motion.div,
79
85
  {
80
86
  layoutId: "sidebar-indicator",
@@ -1,22 +1,53 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Search } from "lucide-react";
2
3
  import { Button, Skeleton } from "@okjt/ui";
3
- function EmptyState({ icon: Icon, message, searchQuery, loading, rows = 5, action }) {
4
- if (loading) {
5
- return /* @__PURE__ */ jsx("div", { className: "p-6 space-y-4", role: "status", "aria-label": "Loading", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
6
- /* @__PURE__ */ jsx(Skeleton, { variant: "circle", width: "36px", height: "36px" }),
7
- /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2", children: [
8
- /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: `${60 - i % 3 * 12}%` }),
9
- /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "35%", height: "10px" })
10
- ] })
11
- ] }, i)) });
12
- }
4
+ import DashboardIcon from "./DashboardIcon.js";
5
+ import { useComponentDefaults } from "./DashboardProvider.js";
6
+ function EmptyState(ownProps) {
7
+ const { variant = "plain", ...props } = useComponentDefaults("EmptyState", ownProps);
8
+ if (props.loading) return /* @__PURE__ */ jsx(Loading, { rows: props.rows });
9
+ return variant === "card" ? /* @__PURE__ */ jsx(CardState, { ...props }) : /* @__PURE__ */ jsx(PlainState, { ...props });
10
+ }
11
+ function Loading({ rows = 5 }) {
12
+ return /* @__PURE__ */ jsx("div", { className: "p-6 space-y-4", role: "status", "aria-label": "Loading", children: Array.from({ length: rows }, (_, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
13
+ /* @__PURE__ */ jsx(Skeleton, { variant: "circle", width: "36px", height: "36px" }),
14
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 space-y-2", children: [
15
+ /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: `${60 - i % 3 * 12}%` }),
16
+ /* @__PURE__ */ jsx(Skeleton, { variant: "text", width: "35%", height: "10px" })
17
+ ] })
18
+ ] }, i)) });
19
+ }
20
+ function PlainState({ icon, message, searchQuery, action }) {
13
21
  return /* @__PURE__ */ jsxs("div", { className: "p-12 text-center text-tone-500", children: [
14
- Icon && /* @__PURE__ */ jsx(Icon, { className: "w-12 h-12 mx-auto mb-4 opacity-20", "aria-hidden": "true" }),
22
+ /* @__PURE__ */ jsx(DashboardIcon, { icon, className: "w-12 h-12 mx-auto mb-4 opacity-20" }),
15
23
  /* @__PURE__ */ jsx("p", { children: searchQuery ? `Nothing matches \u201C${searchQuery}\u201D` : message || "No items yet" }),
16
24
  searchQuery && /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-tone-500", children: "Try a different search or clear the filters." }),
17
25
  !searchQuery && action && /* @__PURE__ */ jsx(Button, { variant: "secondary", icon: action.icon, onClick: action.onClick, className: "mt-4", edit: !action.readOnly, children: action.label })
18
26
  ] });
19
27
  }
28
+ function CardState({ icon, title, message, action, compact = false, search, searchQuery, filtered = false, noun = "item", onClear }) {
29
+ const query = (search ?? searchQuery ?? "").trim();
30
+ if (query || filtered) {
31
+ icon = "search";
32
+ title = query ? `No ${noun}s match \u201C${query}\u201D` : `No ${noun}s match these filters`;
33
+ message = query && filtered ? "Try a different search, or clear the search and filters." : query ? "Try a different search." : "Try different filters.";
34
+ action = onClear ? { label: query && filtered ? "Clear search and filters" : query ? "Clear search" : "Clear filters", onClick: onClear } : null;
35
+ }
36
+ return /* @__PURE__ */ jsxs("div", { className: `rounded-2xl border text-center ${compact ? "border-transparent bg-transparent px-3 py-8" : "border-contrast/10 bg-ink-deep/50 p-12"}`, children: [
37
+ /* @__PURE__ */ jsx("div", { className: `inline-flex items-center justify-center rounded-full bg-contrast/5 ${compact ? "mb-3 h-12 w-12" : "mb-4 h-16 w-16"}`, children: /* @__PURE__ */ jsx(DashboardIcon, { icon, fallback: icon === "search" ? Search : null, className: `${compact ? "text-xl" : "text-2xl"} text-soft` }) }),
38
+ title && /* @__PURE__ */ jsx("h3", { className: "mb-2 text-lg font-semibold text-ink", children: title }),
39
+ message && /* @__PURE__ */ jsx("p", { className: "mx-auto mb-6 max-w-md text-sm text-soft", children: message }),
40
+ action && /* @__PURE__ */ jsx(
41
+ "button",
42
+ {
43
+ type: "button",
44
+ onClick: action.onClick,
45
+ className: "rounded-xl bg-action px-5 py-2.5 text-sm font-medium text-white transition hover:brightness-125",
46
+ children: action.label
47
+ }
48
+ )
49
+ ] });
50
+ }
20
51
  export {
21
52
  EmptyState as default
22
53
  };
@@ -0,0 +1,39 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { useAuth } from "./AuthContext.js";
4
+ import AuthLayout, { AuthError, AuthField, AuthSubmit } from "./AuthLayout.js";
5
+ function ForgotPasswordPage({
6
+ layout: Layout = AuthLayout,
7
+ title = "Forgot your password?",
8
+ subtitle = "Tell us your email address and we\u2019ll send you a link to choose a new one.",
9
+ footer,
10
+ email: initialEmail = "",
11
+ submitLabel = "Email me a reset link",
12
+ idPrefix = "forgot"
13
+ }) {
14
+ const { forgotPassword } = useAuth();
15
+ const [email, setEmail] = useState(initialEmail);
16
+ const [error, setError] = useState(null);
17
+ const [sent, setSent] = useState(null);
18
+ const [loading, setLoading] = useState(false);
19
+ const onSubmit = async (e) => {
20
+ e.preventDefault();
21
+ setLoading(true);
22
+ setError(null);
23
+ const result = await forgotPassword(email);
24
+ if (result.success) setSent(result.message || "If that address has an account, a reset link is on its way.");
25
+ else setError(result.errors?.email?.[0] || result.message);
26
+ setLoading(false);
27
+ };
28
+ return /* @__PURE__ */ jsxs(Layout, { title, subtitle, footer, children: [
29
+ sent && /* @__PURE__ */ jsx("div", { role: "status", className: "mb-5 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-center text-sm text-emerald-700", children: sent }),
30
+ /* @__PURE__ */ jsx(AuthError, { children: error }),
31
+ /* @__PURE__ */ jsxs("form", { onSubmit, className: "space-y-5", children: [
32
+ /* @__PURE__ */ jsx(AuthField, { id: `${idPrefix}-email`, label: "Email", type: "email", autoComplete: "email", placeholder: "you@example.com", value: email, onChange: (e) => setEmail(e.target.value), required: true, autoFocus: true }),
33
+ /* @__PURE__ */ jsx("div", { className: "pt-2", children: /* @__PURE__ */ jsx(AuthSubmit, { loading, children: loading ? "Sending\u2026" : submitLabel }) })
34
+ ] })
35
+ ] });
36
+ }
37
+ export {
38
+ ForgotPasswordPage as default
39
+ };
@@ -9,7 +9,7 @@ function GoogleCallbackPage({ layout: Layout = AuthLayout, onSignedIn, signInPat
9
9
  const { loginWithGoogle, verify2fa } = useAuth();
10
10
  const [error, setError] = useState(null);
11
11
  const [needs2fa, setNeeds2fa] = useState(false);
12
- const [emailFor2fa, setEmailFor2fa] = useState("");
12
+ const [challenge, setChallenge] = useState("");
13
13
  const [code2fa, setCode2fa] = useState("");
14
14
  const [loading, setLoading] = useState(true);
15
15
  const code = params.get("code");
@@ -25,7 +25,7 @@ function GoogleCallbackPage({ layout: Layout = AuthLayout, onSignedIn, signInPat
25
25
  if (cancelled) return;
26
26
  if (result.requires_2fa) {
27
27
  setNeeds2fa(true);
28
- setEmailFor2fa(result.email);
28
+ setChallenge(result.challenge);
29
29
  setLoading(false);
30
30
  return;
31
31
  }
@@ -48,7 +48,7 @@ function GoogleCallbackPage({ layout: Layout = AuthLayout, onSignedIn, signInPat
48
48
  e.preventDefault();
49
49
  setLoading(true);
50
50
  setError(null);
51
- const result = await verify2fa(emailFor2fa, code2fa);
51
+ const result = await verify2fa(challenge, code2fa);
52
52
  if (result.success) {
53
53
  const problem = onSignedIn?.(result);
54
54
  if (typeof problem === "string") setError(problem);
@@ -89,7 +89,7 @@ function NotificationsBell() {
89
89
  "aria-label": unreadCount > 0 ? `Notifications, ${unreadCount} unread` : "Notifications",
90
90
  "aria-haspopup": "true",
91
91
  "aria-expanded": showNotifications,
92
- className: "relative p-2 rounded-xl hover:bg-black/5",
92
+ className: "relative p-2 rounded-xl hover:bg-contrast/5",
93
93
  children: [
94
94
  /* @__PURE__ */ jsx(Bell, { className: "w-5 h-5 text-soft" }),
95
95
  /* @__PURE__ */ jsx(
@@ -108,7 +108,7 @@ function NotificationsBell() {
108
108
  initial: { opacity: 0, y: 10, scale: 0.95 },
109
109
  animate: { opacity: 1, y: 0, scale: 1 },
110
110
  exit: { opacity: 0, y: 10, scale: 0.95 },
111
- className: "absolute top-full right-0 mt-2 w-80 bg-white rounded-2xl shadow-xl border border-tone-100 py-2 z-50 overflow-hidden",
111
+ className: "absolute top-full right-0 mt-2 w-80 bg-surface rounded-2xl shadow-xl border border-tone-100 py-2 z-50 overflow-hidden",
112
112
  children: [
113
113
  /* @__PURE__ */ jsxs("div", { className: "px-4 py-2 border-b border-tone-50 flex justify-between items-center", children: [
114
114
  /* @__PURE__ */ jsx("span", { className: "text-tone-800 font-medium", children: "Notifications" }),