@okjt/dashboard 0.0.0-stage → 0.2.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/README.md +149 -2
- package/dist/AcceptInvitePage.js +86 -0
- package/dist/AccountMenu.js +73 -0
- package/dist/ActivityPanel.js +48 -0
- package/dist/AdminBulkActions.js +109 -0
- package/dist/AdminCard.js +7 -0
- package/dist/AdminChromeContext.js +16 -0
- package/dist/AdminFloatingToolbar.js +147 -0
- package/dist/AdminInput.js +66 -0
- package/dist/AdminListPanel.js +26 -0
- package/dist/AdminModal.js +23 -0
- package/dist/AdminPageHero.js +101 -0
- package/dist/AdminPageLayout.js +54 -0
- package/dist/AdminPagination.js +92 -0
- package/dist/AdminSidePanel.js +479 -0
- package/dist/AdminSummaryCards.js +51 -0
- package/dist/AdminToolbarFilters.js +168 -0
- package/dist/AdminToolbarSearch.js +61 -0
- package/dist/AdminTutorial.js +221 -0
- package/dist/AuthContext.js +194 -0
- package/dist/AuthLayout.js +94 -0
- package/dist/CollaborationContext.js +84 -0
- package/dist/CollaboratorAvatars.js +36 -0
- package/dist/DashboardHeader.js +140 -0
- package/dist/DashboardProvider.js +45 -0
- package/dist/DashboardShell.js +93 -0
- package/dist/DashboardSidebar.js +97 -0
- package/dist/DeleteButton.js +21 -0
- package/dist/EditableFieldset.js +9 -0
- package/dist/EmptyState.js +22 -0
- package/dist/GoogleButton.js +22 -0
- package/dist/GoogleCallbackPage.js +81 -0
- package/dist/NotificationsBell.js +149 -0
- package/dist/QueryError.js +23 -0
- package/dist/SearchContext.js +16 -0
- package/dist/ShareModal.js +228 -0
- package/dist/SignInPage.js +198 -0
- package/dist/StatCard.js +33 -0
- package/dist/ToggleButton.js +26 -0
- package/dist/TwoFactorForm.js +26 -0
- package/dist/UnsavedChangesStatus.js +13 -0
- package/dist/VerifyEmailPage.js +42 -0
- package/dist/VersionHistoryDrawer.js +172 -0
- package/dist/index.js +125 -0
- package/dist/modules.js +32 -0
- package/dist/passkeys.js +84 -0
- package/dist/useActivityPanel.js +34 -0
- package/dist/useAdminAction.js +77 -0
- package/dist/useCrudHandlers.js +54 -0
- package/dist/useFilteredItems.js +19 -0
- package/dist/useSavedViews.js +30 -0
- package/dist/useUnsavedChangesGuard.js +41 -0
- package/package.json +40 -4
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { motion } from "framer-motion";
|
|
4
|
+
import { AlertCircle, ArrowLeft, Eye, EyeOff, Loader2 } from "lucide-react";
|
|
5
|
+
import { Link } from "react-router-dom";
|
|
6
|
+
function AuthLayout({ title, subtitle, children, footer, brand, backLabel = "Back to the website", aside }) {
|
|
7
|
+
return /* @__PURE__ */ jsx("div", { className: "auth-page min-h-dvh flex items-center justify-center p-3 sm:p-6 lg:p-10 bg-tint", children: /* @__PURE__ */ jsxs(
|
|
8
|
+
motion.div,
|
|
9
|
+
{
|
|
10
|
+
initial: { opacity: 0, y: 16 },
|
|
11
|
+
animate: { opacity: 1, y: 0 },
|
|
12
|
+
transition: { duration: 0.45 },
|
|
13
|
+
className: `w-full ${aside ? "max-w-6xl grid lg:grid-cols-2" : "max-w-xl grid"} gap-3 p-3 rounded-[2rem] bg-paper border border-white shadow-[0_30px_80px_-30px_color-mix(in_srgb,var(--color-body)_35%,transparent)]`,
|
|
14
|
+
children: [
|
|
15
|
+
/* @__PURE__ */ jsxs("section", { className: "flex flex-col px-5 py-8 sm:px-10 lg:px-14 lg:py-12", children: [
|
|
16
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
17
|
+
brand && /* @__PURE__ */ jsx(Link, { to: "/", className: "flex items-center gap-2.5", "aria-label": "Back to the home page", children: brand }),
|
|
18
|
+
/* @__PURE__ */ jsxs(Link, { to: "/", className: "inline-flex items-center gap-1.5 rounded-full border border-line px-3 py-1.5 text-xs font-medium text-soft hover:border-accent hover:text-ink", children: [
|
|
19
|
+
/* @__PURE__ */ jsx(ArrowLeft, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
|
|
20
|
+
backLabel
|
|
21
|
+
] })
|
|
22
|
+
] }),
|
|
23
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col justify-center w-full max-w-sm mx-auto lg:mx-0 py-10", children: [
|
|
24
|
+
/* @__PURE__ */ jsx("h1", { className: "!text-3xl !font-semibold tracking-tight !text-ink", children: title }),
|
|
25
|
+
subtitle && /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm leading-relaxed text-muted", children: subtitle }),
|
|
26
|
+
/* @__PURE__ */ jsx("div", { className: "mt-8", children })
|
|
27
|
+
] }),
|
|
28
|
+
footer && /* @__PURE__ */ jsx("div", { className: "w-full max-w-sm mx-auto lg:mx-0 text-sm text-muted", children: footer })
|
|
29
|
+
] }),
|
|
30
|
+
aside
|
|
31
|
+
]
|
|
32
|
+
}
|
|
33
|
+
) });
|
|
34
|
+
}
|
|
35
|
+
const fieldClass = "w-full h-12 px-5 rounded-full bg-white border border-line text-sm text-ink placeholder:text-[#B8A898] shadow-[0_1px_2px_color-mix(in_srgb,var(--color-body)_4%,transparent)] outline-none transition focus:border-[#C49274] focus:ring-4 focus:ring-[#C49274]/15 read-only:bg-tint read-only:text-muted";
|
|
36
|
+
function AuthField({ id, label, type = "text", error, className = "", inputClassName = "", ...props }) {
|
|
37
|
+
const [visible, setVisible] = useState(false);
|
|
38
|
+
const isPassword = type === "password";
|
|
39
|
+
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
40
|
+
/* @__PURE__ */ jsx("label", { htmlFor: id, className: "block text-xs font-semibold text-body mb-2", children: label }),
|
|
41
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
"input",
|
|
44
|
+
{
|
|
45
|
+
id,
|
|
46
|
+
type: isPassword && visible ? "text" : type,
|
|
47
|
+
"aria-invalid": error ? "true" : void 0,
|
|
48
|
+
"aria-describedby": error ? `${id}-error` : void 0,
|
|
49
|
+
className: `${fieldClass} ${isPassword ? "pr-12" : ""} ${error ? "!border-red-300" : ""} ${inputClassName}`,
|
|
50
|
+
...props
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
isPassword && /* @__PURE__ */ jsx(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
onClick: () => setVisible((v) => !v),
|
|
58
|
+
"aria-label": visible ? "Hide password" : "Show password",
|
|
59
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 p-1.5 rounded-full text-faint hover:text-body hover:bg-tint",
|
|
60
|
+
children: visible ? /* @__PURE__ */ jsx(EyeOff, { className: "w-4 h-4" }) : /* @__PURE__ */ jsx(Eye, { className: "w-4 h-4" })
|
|
61
|
+
}
|
|
62
|
+
)
|
|
63
|
+
] }),
|
|
64
|
+
error && /* @__PURE__ */ jsx("div", { id: `${id}-error`, className: "mt-1.5 pl-5 text-xs text-red-600", children: error })
|
|
65
|
+
] });
|
|
66
|
+
}
|
|
67
|
+
function AuthSubmit({ loading, children, ...props }) {
|
|
68
|
+
return /* @__PURE__ */ jsxs(
|
|
69
|
+
"button",
|
|
70
|
+
{
|
|
71
|
+
type: "submit",
|
|
72
|
+
disabled: loading,
|
|
73
|
+
className: "w-full h-12 rounded-full text-sm font-semibold text-white bg-gradient-to-r from-accent-dark via-accent-strong to-[#D08A5E] shadow-[0_10px_24px_-10px_color-mix(in_srgb,var(--color-accent-strong)_80%,transparent)] transition hover:brightness-105 active:brightness-95 disabled:opacity-70 flex items-center justify-center gap-2 focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-[#C49274]/30",
|
|
74
|
+
...props,
|
|
75
|
+
children: [
|
|
76
|
+
loading && /* @__PURE__ */ jsx(Loader2, { className: "w-4 h-4 animate-spin", "aria-hidden": "true" }),
|
|
77
|
+
children
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
function AuthError({ children }) {
|
|
83
|
+
if (!children) return null;
|
|
84
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", className: "mb-5 flex items-start gap-2.5 rounded-2xl border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700", children: [
|
|
85
|
+
/* @__PURE__ */ jsx(AlertCircle, { className: "w-4 h-4 mt-0.5 shrink-0" }),
|
|
86
|
+
/* @__PURE__ */ jsx("span", { children })
|
|
87
|
+
] });
|
|
88
|
+
}
|
|
89
|
+
export {
|
|
90
|
+
AuthError,
|
|
91
|
+
AuthField,
|
|
92
|
+
AuthSubmit,
|
|
93
|
+
AuthLayout as default
|
|
94
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useLocation } from "react-router-dom";
|
|
4
|
+
import { useDashboard } from "./DashboardProvider.js";
|
|
5
|
+
import { useModules } from "./modules.js";
|
|
6
|
+
const HEARTBEAT_MS = 2e4;
|
|
7
|
+
const CollaborationContext = createContext({
|
|
8
|
+
presence: [],
|
|
9
|
+
badges: {},
|
|
10
|
+
module: null,
|
|
11
|
+
othersHere: [],
|
|
12
|
+
historyOpen: false,
|
|
13
|
+
openHistory: () => {
|
|
14
|
+
},
|
|
15
|
+
closeHistory: () => {
|
|
16
|
+
},
|
|
17
|
+
shareOpen: false,
|
|
18
|
+
setShareOpen: () => {
|
|
19
|
+
},
|
|
20
|
+
dataVersion: 0,
|
|
21
|
+
notifyDataRestored: () => {
|
|
22
|
+
},
|
|
23
|
+
refresh: () => {
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
function CollaborationProvider({ children }) {
|
|
27
|
+
const { pathname } = useLocation();
|
|
28
|
+
const { api } = useDashboard();
|
|
29
|
+
const { moduleForPath } = useModules();
|
|
30
|
+
const module = moduleForPath(pathname)?.key || null;
|
|
31
|
+
const [state, setState] = useState({ presence: [], badges: {} });
|
|
32
|
+
const [historyOpen, setHistoryOpen] = useState(false);
|
|
33
|
+
const [shareOpen, setShareOpen] = useState(false);
|
|
34
|
+
const [dataVersion, setDataVersion] = useState(0);
|
|
35
|
+
const latest = useRef({ module, pathname });
|
|
36
|
+
latest.current = { module, pathname };
|
|
37
|
+
const beat = useCallback(async () => {
|
|
38
|
+
if (document.visibilityState === "hidden") return;
|
|
39
|
+
try {
|
|
40
|
+
const res = await api.post("/collaboration/heartbeat", { module: latest.current.module, path: latest.current.pathname });
|
|
41
|
+
setState({ presence: res.data?.presence || [], badges: res.data?.badges || {} });
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}, [api]);
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
beat();
|
|
47
|
+
}, [module, pathname, beat]);
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
const timer = setInterval(beat, HEARTBEAT_MS);
|
|
50
|
+
const onVisible = () => {
|
|
51
|
+
if (document.visibilityState === "visible") beat();
|
|
52
|
+
};
|
|
53
|
+
document.addEventListener("visibilitychange", onVisible);
|
|
54
|
+
return () => {
|
|
55
|
+
clearInterval(timer);
|
|
56
|
+
document.removeEventListener("visibilitychange", onVisible);
|
|
57
|
+
};
|
|
58
|
+
}, [beat]);
|
|
59
|
+
const value = useMemo(() => ({
|
|
60
|
+
...state,
|
|
61
|
+
module,
|
|
62
|
+
othersHere: state.presence.filter((p) => module && p.current_module === module),
|
|
63
|
+
historyOpen,
|
|
64
|
+
openHistory: () => setHistoryOpen(true),
|
|
65
|
+
closeHistory: () => setHistoryOpen(false),
|
|
66
|
+
shareOpen,
|
|
67
|
+
setShareOpen,
|
|
68
|
+
dataVersion,
|
|
69
|
+
notifyDataRestored: () => {
|
|
70
|
+
setDataVersion((v) => v + 1);
|
|
71
|
+
beat();
|
|
72
|
+
},
|
|
73
|
+
refresh: beat
|
|
74
|
+
}), [state, module, historyOpen, shareOpen, dataVersion, beat]);
|
|
75
|
+
return /* @__PURE__ */ jsx(CollaborationContext.Provider, { value, children });
|
|
76
|
+
}
|
|
77
|
+
function useCollaboration() {
|
|
78
|
+
return useContext(CollaborationContext);
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
CollaborationProvider,
|
|
82
|
+
HEARTBEAT_MS,
|
|
83
|
+
useCollaboration
|
|
84
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { collaboratorColor, initials, useModules } from "./modules.js";
|
|
3
|
+
const SIZES = {
|
|
4
|
+
xs: "w-5 h-5 text-[9px]",
|
|
5
|
+
sm: "w-7 h-7 text-[11px]",
|
|
6
|
+
md: "w-9 h-9 text-xs"
|
|
7
|
+
};
|
|
8
|
+
function CollaboratorAvatar({ person, size = "sm", className = "" }) {
|
|
9
|
+
const { moduleByKey } = useModules();
|
|
10
|
+
const where = moduleByKey(person.current_module)?.label;
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"span",
|
|
13
|
+
{
|
|
14
|
+
className: `${SIZES[size]} rounded-full ring-2 ring-paper text-white font-semibold flex items-center justify-center shrink-0 ${className}`,
|
|
15
|
+
style: { background: collaboratorColor(person.id) },
|
|
16
|
+
title: where ? `${person.name} \u2014 on ${where}` : person.name,
|
|
17
|
+
children: initials(person.name)
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function CollaboratorAvatars({ people = [], max = 3, size = "sm" }) {
|
|
22
|
+
if (!people.length) return null;
|
|
23
|
+
const shown = people.slice(0, max);
|
|
24
|
+
const extra = people.length - shown.length;
|
|
25
|
+
return /* @__PURE__ */ jsxs("span", { className: "flex items-center -space-x-1.5", children: [
|
|
26
|
+
shown.map((person) => /* @__PURE__ */ jsx(CollaboratorAvatar, { person, size }, person.id)),
|
|
27
|
+
extra > 0 && /* @__PURE__ */ jsxs("span", { className: `${SIZES[size]} rounded-full ring-2 ring-paper bg-tone-200 text-tone-700 font-semibold flex items-center justify-center`, children: [
|
|
28
|
+
"+",
|
|
29
|
+
extra
|
|
30
|
+
] })
|
|
31
|
+
] });
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
CollaboratorAvatar,
|
|
35
|
+
CollaboratorAvatars as default
|
|
36
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link, useLocation } from "react-router-dom";
|
|
3
|
+
import { Menu, Info, History, Share2 } from "lucide-react";
|
|
4
|
+
import { usePermissions } from "@okjt/ui";
|
|
5
|
+
import { useCollaboration } from "./CollaborationContext.js";
|
|
6
|
+
import CollaboratorAvatars from "./CollaboratorAvatars.js";
|
|
7
|
+
import { useDashboard } from "./DashboardProvider.js";
|
|
8
|
+
function DashboardHeader({ onMenuClick, onRestartTutorial, titleSlotRef, statusSlotRef }) {
|
|
9
|
+
const { pathname } = useLocation();
|
|
10
|
+
const { presence, othersHere, openHistory, setShareOpen, badges } = useCollaboration();
|
|
11
|
+
const hasNews = Object.values(badges).some(Boolean);
|
|
12
|
+
const { canEdit } = usePermissions();
|
|
13
|
+
const { shell } = useDashboard();
|
|
14
|
+
const quickLinks = shell.quickLinks;
|
|
15
|
+
return /* @__PURE__ */ jsxs(
|
|
16
|
+
"header",
|
|
17
|
+
{
|
|
18
|
+
id: "header",
|
|
19
|
+
className: "sticky top-0 z-30 h-16 px-3 sm:px-6 flex items-center justify-between gap-3",
|
|
20
|
+
style: {
|
|
21
|
+
background: shell.headerBackground,
|
|
22
|
+
backdropFilter: "blur(10px)",
|
|
23
|
+
borderBottom: shell.headerBorder
|
|
24
|
+
},
|
|
25
|
+
children: [
|
|
26
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 sm:gap-4 min-w-0 flex-1", children: [
|
|
27
|
+
/* @__PURE__ */ jsxs(
|
|
28
|
+
"button",
|
|
29
|
+
{
|
|
30
|
+
onClick: onMenuClick,
|
|
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",
|
|
33
|
+
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" })
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
),
|
|
39
|
+
/* @__PURE__ */ jsx("div", { ref: titleSlotRef, className: "min-w-0 flex-1" }),
|
|
40
|
+
othersHere.length > 0 && /* @__PURE__ */ jsxs(
|
|
41
|
+
"button",
|
|
42
|
+
{
|
|
43
|
+
type: "button",
|
|
44
|
+
onClick: () => setShareOpen(true),
|
|
45
|
+
className: "hidden sm:flex items-center gap-2 shrink-0 pl-1 pr-3 py-1 rounded-full bg-amber-50 border border-amber-200 text-xs text-amber-800",
|
|
46
|
+
title: "Others editing here may overwrite each other's unsaved changes",
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsx(CollaboratorAvatars, { people: othersHere, size: "xs", max: 2 }),
|
|
49
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[14rem] truncate", children: othersHere.length === 1 ? `${othersHere[0].name} is here too` : `${othersHere.length} others are here too` })
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
] }),
|
|
54
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 sm:gap-2 shrink-0", children: [
|
|
55
|
+
!canEdit && /* @__PURE__ */ jsx(
|
|
56
|
+
"span",
|
|
57
|
+
{
|
|
58
|
+
className: "px-2.5 py-1 rounded-full bg-tone-100 border border-tone-200 text-xs font-medium text-tone-600 whitespace-nowrap",
|
|
59
|
+
title: "You can look around, but changes won't be saved. Ask an owner for edit access.",
|
|
60
|
+
children: "View only"
|
|
61
|
+
}
|
|
62
|
+
),
|
|
63
|
+
/* @__PURE__ */ jsx("div", { ref: statusSlotRef, className: "flex items-center empty:hidden mr-1" }),
|
|
64
|
+
/* @__PURE__ */ jsx("nav", { "aria-label": "Quick links", className: "hidden md:flex items-center gap-1 pr-2 mr-1 border-r border-tone-200/70", children: quickLinks.map((link) => {
|
|
65
|
+
const active = pathname.startsWith(link.path);
|
|
66
|
+
return /* @__PURE__ */ jsxs(
|
|
67
|
+
Link,
|
|
68
|
+
{
|
|
69
|
+
id: link.id,
|
|
70
|
+
to: link.path,
|
|
71
|
+
title: link.label,
|
|
72
|
+
"aria-label": link.label,
|
|
73
|
+
"aria-current": active ? "page" : void 0,
|
|
74
|
+
className: `flex items-center gap-2 p-2 2xl:px-3 rounded-xl text-sm font-medium transition-colors ${active ? "bg-accent text-white" : "text-soft hover:bg-accent/10 hover:text-accent"}`,
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx(link.icon, { className: "w-5 h-5" }),
|
|
77
|
+
/* @__PURE__ */ jsx("span", { className: "hidden 2xl:inline", children: link.label })
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
link.path
|
|
81
|
+
);
|
|
82
|
+
}) }),
|
|
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 })
|
|
91
|
+
}
|
|
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
|
+
),
|
|
131
|
+
shell.Notifications && /* @__PURE__ */ jsx(shell.Notifications, {}),
|
|
132
|
+
shell.AccountMenu && /* @__PURE__ */ jsx(shell.AccountMenu, { compactLinks: quickLinks })
|
|
133
|
+
] })
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
DashboardHeader as default
|
|
140
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const DashboardContext = createContext(null);
|
|
4
|
+
const DEFAULT_ROLES = [
|
|
5
|
+
{ value: "owner", label: "Owner", description: "Everything, including people and roles" },
|
|
6
|
+
{ value: "editor", label: "Editor", description: "Changes what is in the dashboard" },
|
|
7
|
+
{ value: "viewer", label: "Viewer", description: "Can look around but not change anything" }
|
|
8
|
+
];
|
|
9
|
+
const DEFAULTS = {
|
|
10
|
+
home: { label: "Dashboard", path: "/" },
|
|
11
|
+
useDefaultPanel: () => null,
|
|
12
|
+
useAfterChange: () => void 0,
|
|
13
|
+
api: null,
|
|
14
|
+
modules: [],
|
|
15
|
+
roles: DEFAULT_ROLES,
|
|
16
|
+
roleLabel: (role) => DEFAULT_ROLES.find((r) => r.value === role)?.label || role,
|
|
17
|
+
anonymousName: "Someone",
|
|
18
|
+
removeCollaborator: null,
|
|
19
|
+
tutorialSteps: []
|
|
20
|
+
};
|
|
21
|
+
const DEFAULT_SHELL = {
|
|
22
|
+
logo: { src: "", alt: "", to: "/" },
|
|
23
|
+
nav: [],
|
|
24
|
+
quickLinks: [],
|
|
25
|
+
background: "linear-gradient(180deg, var(--color-paper) 0%, var(--color-tint) 100%)",
|
|
26
|
+
sidebarBackground: "linear-gradient(180deg, var(--color-body) 0%, var(--color-ink) 100%)",
|
|
27
|
+
sidebarScrollbar: "var(--color-soft) var(--color-body)",
|
|
28
|
+
headerBackground: "color-mix(in srgb, var(--color-paper) 95%, transparent)",
|
|
29
|
+
headerBorder: "1px solid color-mix(in srgb, var(--color-accent) 10%, transparent)",
|
|
30
|
+
badgeClass: "bg-accent-soft text-body",
|
|
31
|
+
Banner: null,
|
|
32
|
+
Notifications: null,
|
|
33
|
+
AccountMenu: null
|
|
34
|
+
};
|
|
35
|
+
function DashboardProvider({ dashboard, children }) {
|
|
36
|
+
return /* @__PURE__ */ jsx(DashboardContext.Provider, { value: dashboard, children });
|
|
37
|
+
}
|
|
38
|
+
function useDashboard() {
|
|
39
|
+
const settings = useContext(DashboardContext);
|
|
40
|
+
return { ...DEFAULTS, ...settings, shell: { ...DEFAULT_SHELL, ...settings?.shell, logo: { ...DEFAULT_SHELL.logo, ...settings?.shell?.logo } } };
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
DashboardProvider,
|
|
44
|
+
useDashboard
|
|
45
|
+
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { useLocation } from "react-router-dom";
|
|
4
|
+
import { AnimatePresence, motion, MotionConfig } from "framer-motion";
|
|
5
|
+
import { ConfirmHost } from "@okjt/ui";
|
|
6
|
+
import { SearchProvider, useSearch } from "./SearchContext.js";
|
|
7
|
+
import { AdminChromeProvider } from "./AdminChromeContext.js";
|
|
8
|
+
import AdminTutorial from "./AdminTutorial.js";
|
|
9
|
+
import { CollaborationProvider, useCollaboration } from "./CollaborationContext.js";
|
|
10
|
+
import ShareModal from "./ShareModal.js";
|
|
11
|
+
import VersionHistoryDrawer from "./VersionHistoryDrawer.js";
|
|
12
|
+
import DashboardSidebar from "./DashboardSidebar.js";
|
|
13
|
+
import DashboardHeader from "./DashboardHeader.js";
|
|
14
|
+
import { useDashboard } from "./DashboardProvider.js";
|
|
15
|
+
function ResetSearchOnNavigate({ pathname }) {
|
|
16
|
+
const { setSearchQuery } = useSearch();
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
setSearchQuery("");
|
|
19
|
+
}, [pathname, setSearchQuery]);
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
function CollaborationPanels() {
|
|
23
|
+
const { shareOpen, setShareOpen, historyOpen, closeHistory, module, notifyDataRestored } = useCollaboration();
|
|
24
|
+
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 }) })
|
|
27
|
+
] });
|
|
28
|
+
}
|
|
29
|
+
function PageContent({ pathname, children }) {
|
|
30
|
+
const { dataVersion } = useCollaboration();
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
motion.div,
|
|
33
|
+
{
|
|
34
|
+
initial: { opacity: 0, y: 20 },
|
|
35
|
+
animate: { opacity: 1, y: 0 },
|
|
36
|
+
transition: { duration: 0.3 },
|
|
37
|
+
children
|
|
38
|
+
},
|
|
39
|
+
`${pathname}#${dataVersion}`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
function DashboardShell({ children }) {
|
|
43
|
+
const { shell, tutorialSteps } = useDashboard();
|
|
44
|
+
const [sidebarOpen, setSidebarOpen] = useState(false);
|
|
45
|
+
const [restartTutorial, setRestartTutorial] = useState(false);
|
|
46
|
+
const location = useLocation();
|
|
47
|
+
const [titleSlot, setTitleSlot] = useState(null);
|
|
48
|
+
const [statusSlot, setStatusSlot] = useState(null);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
document.documentElement.classList.add("admin-theme");
|
|
51
|
+
return () => document.documentElement.classList.remove("admin-theme");
|
|
52
|
+
}, []);
|
|
53
|
+
return /* @__PURE__ */ jsx(MotionConfig, { reducedMotion: "user", children: /* @__PURE__ */ jsx(SearchProvider, { children: /* @__PURE__ */ jsx(AdminChromeProvider, { value: { titleSlot, statusSlot }, children: /* @__PURE__ */ jsxs(CollaborationProvider, { children: [
|
|
54
|
+
/* @__PURE__ */ jsx(ResetSearchOnNavigate, { pathname: location.pathname }),
|
|
55
|
+
/* @__PURE__ */ jsxs(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
className: "min-h-screen",
|
|
59
|
+
style: { background: shell.background },
|
|
60
|
+
children: [
|
|
61
|
+
/* @__PURE__ */ jsx(DashboardSidebar, { isOpen: sidebarOpen, onClose: () => setSidebarOpen(false) }),
|
|
62
|
+
/* @__PURE__ */ jsxs("div", { className: "lg:ml-[280px]", children: [
|
|
63
|
+
/* @__PURE__ */ jsx(
|
|
64
|
+
DashboardHeader,
|
|
65
|
+
{
|
|
66
|
+
onMenuClick: () => setSidebarOpen(true),
|
|
67
|
+
onRestartTutorial: () => setRestartTutorial((prev) => !prev),
|
|
68
|
+
titleSlotRef: setTitleSlot,
|
|
69
|
+
statusSlotRef: setStatusSlot
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ jsx(ConfirmHost, {}),
|
|
73
|
+
/* @__PURE__ */ jsx(CollaborationPanels, {}),
|
|
74
|
+
shell.Banner && /* @__PURE__ */ jsx(shell.Banner, {}),
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
AdminTutorial,
|
|
77
|
+
{
|
|
78
|
+
isRestarted: restartTutorial,
|
|
79
|
+
onComplete: () => setRestartTutorial(false),
|
|
80
|
+
steps: tutorialSteps
|
|
81
|
+
},
|
|
82
|
+
restartTutorial ? "restarted" : "initial"
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ jsx("main", { className: "p-4 sm:p-6", children: /* @__PURE__ */ jsx(PageContent, { pathname: location.pathname, children }) })
|
|
85
|
+
] })
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
] }) }) }) });
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
DashboardShell as default
|
|
93
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link, useLocation } from "react-router-dom";
|
|
3
|
+
import { motion, AnimatePresence } from "framer-motion";
|
|
4
|
+
import { X } from "lucide-react";
|
|
5
|
+
import { useCollaboration } from "./CollaborationContext.js";
|
|
6
|
+
import CollaboratorAvatars from "./CollaboratorAvatars.js";
|
|
7
|
+
import { useDashboard } from "./DashboardProvider.js";
|
|
8
|
+
import { useModules } from "./modules.js";
|
|
9
|
+
function DashboardSidebar({ isOpen, onClose }) {
|
|
10
|
+
const location = useLocation();
|
|
11
|
+
const { home, shell } = useDashboard();
|
|
12
|
+
const { moduleForPath } = useModules();
|
|
13
|
+
const { badges, presence } = useCollaboration();
|
|
14
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
15
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(
|
|
16
|
+
motion.div,
|
|
17
|
+
{
|
|
18
|
+
initial: { opacity: 0 },
|
|
19
|
+
animate: { opacity: 1 },
|
|
20
|
+
exit: { opacity: 0 },
|
|
21
|
+
className: "fixed inset-0 bg-black/50 z-40 lg:hidden",
|
|
22
|
+
onClick: onClose
|
|
23
|
+
}
|
|
24
|
+
) }),
|
|
25
|
+
/* @__PURE__ */ jsx(
|
|
26
|
+
motion.aside,
|
|
27
|
+
{
|
|
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
|
+
style: {
|
|
30
|
+
width: 280,
|
|
31
|
+
background: shell.sidebarBackground
|
|
32
|
+
},
|
|
33
|
+
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__ */ jsx(Link, { to: shell.logo.to, className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
36
|
+
"img",
|
|
37
|
+
{
|
|
38
|
+
src: shell.logo.src,
|
|
39
|
+
alt: shell.logo.alt,
|
|
40
|
+
className: "h-10 w-auto"
|
|
41
|
+
}
|
|
42
|
+
) }),
|
|
43
|
+
/* @__PURE__ */ jsx(
|
|
44
|
+
"button",
|
|
45
|
+
{
|
|
46
|
+
"aria-label": "Close menu",
|
|
47
|
+
onClick: onClose,
|
|
48
|
+
className: "lg:hidden absolute right-4 top-1/2 -translate-y-1/2 text-white/60 hover:text-white",
|
|
49
|
+
children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" })
|
|
50
|
+
}
|
|
51
|
+
)
|
|
52
|
+
] }),
|
|
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) => {
|
|
56
|
+
const isActive = location.pathname === item.path || item.path !== home.path && location.pathname.startsWith(item.path);
|
|
57
|
+
const moduleKey = moduleForPath(item.path)?.key;
|
|
58
|
+
const newCount = isActive ? 0 : badges[moduleKey] || 0;
|
|
59
|
+
const here = presence.filter((p) => p.current_module === moduleKey);
|
|
60
|
+
const label = [item.label, newCount && `${newCount} new`, here.length && `${here.map((p) => p.name).join(", ")} here`].filter(Boolean).join(", ");
|
|
61
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
|
|
62
|
+
Link,
|
|
63
|
+
{
|
|
64
|
+
id: item.id,
|
|
65
|
+
to: item.path,
|
|
66
|
+
onClick: () => onClose(),
|
|
67
|
+
"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
|
+
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
|
+
/* @__PURE__ */ jsx(CollaboratorAvatars, { people: here, size: "xs", max: 2 }),
|
|
75
|
+
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
|
+
] }),
|
|
77
|
+
isActive && /* @__PURE__ */ jsx(
|
|
78
|
+
motion.div,
|
|
79
|
+
{
|
|
80
|
+
layoutId: "sidebar-indicator",
|
|
81
|
+
className: `${here.length ? "" : "ml-auto"} w-1.5 h-1.5 rounded-full flex-shrink-0`,
|
|
82
|
+
style: { background: "var(--color-accent)" }
|
|
83
|
+
}
|
|
84
|
+
)
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
) }, item.path);
|
|
88
|
+
}) })
|
|
89
|
+
] }, section.title || sectionIndex)) })
|
|
90
|
+
] })
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
export {
|
|
96
|
+
DashboardSidebar as default
|
|
97
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Trash2 } from "lucide-react";
|
|
3
|
+
import { Button } from "@okjt/ui";
|
|
4
|
+
function DeleteButton({ onClick, processing, title = "Delete" }) {
|
|
5
|
+
return /* @__PURE__ */ jsx(
|
|
6
|
+
Button,
|
|
7
|
+
{
|
|
8
|
+
variant: "danger",
|
|
9
|
+
size: "icon",
|
|
10
|
+
icon: Trash2,
|
|
11
|
+
loading: processing,
|
|
12
|
+
onClick,
|
|
13
|
+
edit: true,
|
|
14
|
+
title,
|
|
15
|
+
"aria-label": title
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
DeleteButton as default
|
|
21
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { usePermissions } from "@okjt/ui";
|
|
3
|
+
function EditableFieldset({ children, className = "contents", allow = false }) {
|
|
4
|
+
const { canEdit } = usePermissions();
|
|
5
|
+
return /* @__PURE__ */ jsx("fieldset", { disabled: !canEdit && !allow, className: `min-w-0 border-0 p-0 m-0 ${className}`, children });
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
EditableFieldset as default
|
|
9
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
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
|
+
}
|
|
13
|
+
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" }),
|
|
15
|
+
/* @__PURE__ */ jsx("p", { children: searchQuery ? `Nothing matches \u201C${searchQuery}\u201D` : message || "No items yet" }),
|
|
16
|
+
searchQuery && /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-tone-500", children: "Try a different search or clear the filters." }),
|
|
17
|
+
!searchQuery && action && /* @__PURE__ */ jsx(Button, { variant: "secondary", icon: action.icon, onClick: action.onClick, className: "mt-4", edit: !action.readOnly, children: action.label })
|
|
18
|
+
] });
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
EmptyState as default
|
|
22
|
+
};
|