@okjt/dashboard 0.0.0-stage → 0.1.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 +144 -2
- 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 +189 -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/NotificationsBell.js +149 -0
- package/dist/QueryError.js +23 -0
- package/dist/SearchContext.js +16 -0
- package/dist/ShareModal.js +228 -0
- package/dist/StatCard.js +33 -0
- package/dist/ToggleButton.js +26 -0
- package/dist/UnsavedChangesStatus.js +13 -0
- package/dist/VersionHistoryDrawer.js +172 -0
- package/dist/index.js +110 -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 +39 -4
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect, useRef } from "react";
|
|
3
|
+
import { useNavigate } from "react-router-dom";
|
|
4
|
+
import { motion, AnimatePresence } from "framer-motion";
|
|
5
|
+
import { Bell, BellRing, UserPlus, Gift, Mail, Calendar, CheckCircle, Settings } from "lucide-react";
|
|
6
|
+
import { useDashboard } from "./DashboardProvider.js";
|
|
7
|
+
const ICON_MAP = {
|
|
8
|
+
bell: BellRing,
|
|
9
|
+
user_plus: UserPlus,
|
|
10
|
+
gift: Gift,
|
|
11
|
+
mail: Mail,
|
|
12
|
+
calendar: Calendar,
|
|
13
|
+
check: CheckCircle,
|
|
14
|
+
settings: Settings
|
|
15
|
+
};
|
|
16
|
+
function timeAgo(dateStr) {
|
|
17
|
+
if (!dateStr) return "";
|
|
18
|
+
const now = /* @__PURE__ */ new Date();
|
|
19
|
+
const then = new Date(dateStr);
|
|
20
|
+
const seconds = Math.floor((now - then) / 1e3);
|
|
21
|
+
if (seconds < 60) return "Just now";
|
|
22
|
+
const minutes = Math.floor(seconds / 60);
|
|
23
|
+
if (minutes < 60) return `${minutes}m ago`;
|
|
24
|
+
const hours = Math.floor(minutes / 60);
|
|
25
|
+
if (hours < 24) return `${hours}h ago`;
|
|
26
|
+
const days = Math.floor(hours / 24);
|
|
27
|
+
if (days < 7) return `${days}d ago`;
|
|
28
|
+
return then.toLocaleDateString("en-US", { month: "short", day: "numeric" });
|
|
29
|
+
}
|
|
30
|
+
function NotificationIcon({ icon }) {
|
|
31
|
+
const IconComp = ICON_MAP[icon] || BellRing;
|
|
32
|
+
return /* @__PURE__ */ jsx(IconComp, { className: "w-4 h-4 text-accent" });
|
|
33
|
+
}
|
|
34
|
+
function NotificationsBell() {
|
|
35
|
+
const navigate = useNavigate();
|
|
36
|
+
const { api } = useDashboard();
|
|
37
|
+
const [showNotifications, setShowNotifications] = useState(false);
|
|
38
|
+
const [notifications, setNotifications] = useState([]);
|
|
39
|
+
const [unreadCount, setUnreadCount] = useState(0);
|
|
40
|
+
const fetchedRef = useRef(false);
|
|
41
|
+
const fetchNotifications = async () => {
|
|
42
|
+
try {
|
|
43
|
+
const res = await api.get("/notifications");
|
|
44
|
+
const payload = res.data;
|
|
45
|
+
const items = Array.isArray(payload) ? payload : Array.isArray(payload?.data) ? payload.data : [];
|
|
46
|
+
setNotifications(items);
|
|
47
|
+
setUnreadCount(items.filter((n) => !n.read_at).length);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
console.error("Failed to fetch notifications", e);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
let cancelled = false;
|
|
54
|
+
const init = async () => {
|
|
55
|
+
if (!fetchedRef.current) {
|
|
56
|
+
fetchedRef.current = true;
|
|
57
|
+
try {
|
|
58
|
+
const res = await api.get("/notifications");
|
|
59
|
+
if (cancelled) return;
|
|
60
|
+
const payload = res.data;
|
|
61
|
+
const items = Array.isArray(payload) ? payload : Array.isArray(payload?.data) ? payload.data : [];
|
|
62
|
+
setNotifications(items);
|
|
63
|
+
setUnreadCount(items.filter((n) => !n.read_at).length);
|
|
64
|
+
} catch (e) {
|
|
65
|
+
console.error("Failed to fetch notifications", e);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
init();
|
|
70
|
+
const interval = setInterval(fetchNotifications, 3e4);
|
|
71
|
+
return () => {
|
|
72
|
+
cancelled = true;
|
|
73
|
+
clearInterval(interval);
|
|
74
|
+
};
|
|
75
|
+
}, []);
|
|
76
|
+
const handleMarkAllRead = async () => {
|
|
77
|
+
try {
|
|
78
|
+
await api.post("/notifications/mark-read");
|
|
79
|
+
fetchNotifications();
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error("Failed to mark read", e);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
85
|
+
/* @__PURE__ */ jsxs(
|
|
86
|
+
"button",
|
|
87
|
+
{
|
|
88
|
+
onClick: () => setShowNotifications(!showNotifications),
|
|
89
|
+
"aria-label": unreadCount > 0 ? `Notifications, ${unreadCount} unread` : "Notifications",
|
|
90
|
+
"aria-haspopup": "true",
|
|
91
|
+
"aria-expanded": showNotifications,
|
|
92
|
+
className: "relative p-2 rounded-xl hover:bg-black/5",
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsx(Bell, { className: "w-5 h-5 text-soft" }),
|
|
95
|
+
/* @__PURE__ */ jsx(
|
|
96
|
+
"span",
|
|
97
|
+
{
|
|
98
|
+
className: "absolute top-1 right-1 w-2 h-2 rounded-full",
|
|
99
|
+
style: { background: "#A67B5B", display: unreadCount > 0 ? "block" : "none" }
|
|
100
|
+
}
|
|
101
|
+
)
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: showNotifications && /* @__PURE__ */ jsxs(
|
|
106
|
+
motion.div,
|
|
107
|
+
{
|
|
108
|
+
initial: { opacity: 0, y: 10, scale: 0.95 },
|
|
109
|
+
animate: { opacity: 1, y: 0, scale: 1 },
|
|
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",
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsxs("div", { className: "px-4 py-2 border-b border-tone-50 flex justify-between items-center", children: [
|
|
114
|
+
/* @__PURE__ */ jsx("span", { className: "text-tone-800 font-medium", children: "Notifications" }),
|
|
115
|
+
/* @__PURE__ */ jsx("button", { onClick: handleMarkAllRead, className: "text-xs text-accent hover:text-accent-dark", children: "Mark all read" })
|
|
116
|
+
] }),
|
|
117
|
+
/* @__PURE__ */ jsx("div", { className: "max-h-[300px] overflow-y-auto", children: notifications.length > 0 ? notifications.map((n) => {
|
|
118
|
+
const title = n.title || "Notification";
|
|
119
|
+
const message = n.message || "";
|
|
120
|
+
return /* @__PURE__ */ jsx(
|
|
121
|
+
"button",
|
|
122
|
+
{
|
|
123
|
+
type: "button",
|
|
124
|
+
className: "w-full text-left px-4 py-3 hover:bg-paper-warm focus:bg-paper-warm focus:outline-none border-b border-tone-50 last:border-0 transition-colors",
|
|
125
|
+
onClick: () => {
|
|
126
|
+
setShowNotifications(false);
|
|
127
|
+
if (n.link) navigate(n.link);
|
|
128
|
+
},
|
|
129
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
|
|
130
|
+
/* @__PURE__ */ jsx("div", { className: "mt-0.5 p-1.5 rounded-lg bg-accent/10 shrink-0", children: /* @__PURE__ */ jsx(NotificationIcon, { icon: n.icon }) }),
|
|
131
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
|
|
132
|
+
/* @__PURE__ */ jsx("p", { className: `text-sm ${!n.read_at ? "font-bold text-tone-900" : "font-medium text-tone-700"}`, children: title }),
|
|
133
|
+
message && /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-600 mt-0.5 truncate", children: message }),
|
|
134
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-tone-500 mt-1", children: timeAgo(n.created_at) })
|
|
135
|
+
] }),
|
|
136
|
+
!n.read_at && /* @__PURE__ */ jsx("span", { className: "w-2 h-2 rounded-full bg-accent shrink-0 mt-1.5", "aria-label": "Unread" })
|
|
137
|
+
] })
|
|
138
|
+
},
|
|
139
|
+
n.id
|
|
140
|
+
);
|
|
141
|
+
}) : /* @__PURE__ */ jsx("div", { className: "px-4 py-8 text-center text-xs text-tone-400 italic", children: "No notifications yet" }) })
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
) })
|
|
145
|
+
] });
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
NotificationsBell as default
|
|
149
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertTriangle, RefreshCw } from "lucide-react";
|
|
3
|
+
import { Button } from "@okjt/ui";
|
|
4
|
+
function QueryError({ what = "this data", onRetry, error }) {
|
|
5
|
+
const detail = error?.response?.data?.message || error?.message;
|
|
6
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", className: "p-6 rounded-2xl bg-red-50 border border-red-100 flex flex-col sm:flex-row sm:items-center gap-4", children: [
|
|
7
|
+
/* @__PURE__ */ jsx(AlertTriangle, { className: "w-6 h-6 text-red-600 shrink-0", "aria-hidden": "true" }),
|
|
8
|
+
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
9
|
+
/* @__PURE__ */ jsxs("p", { className: "font-semibold text-red-800", children: [
|
|
10
|
+
"Couldn\u2019t load ",
|
|
11
|
+
what
|
|
12
|
+
] }),
|
|
13
|
+
/* @__PURE__ */ jsxs("p", { className: "text-sm text-red-700", children: [
|
|
14
|
+
"The numbers below may be missing until it loads.",
|
|
15
|
+
detail ? ` (${detail})` : ""
|
|
16
|
+
] })
|
|
17
|
+
] }),
|
|
18
|
+
onRetry && /* @__PURE__ */ jsx(Button, { variant: "danger", icon: RefreshCw, onClick: onRetry, children: "Retry" })
|
|
19
|
+
] });
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
QueryError as default
|
|
23
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState } from "react";
|
|
3
|
+
const SearchContext = createContext(null);
|
|
4
|
+
const INERT_SEARCH = { searchQuery: "", setSearchQuery: () => {
|
|
5
|
+
} };
|
|
6
|
+
function SearchProvider({ children }) {
|
|
7
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
8
|
+
return /* @__PURE__ */ jsx(SearchContext.Provider, { value: { searchQuery, setSearchQuery }, children });
|
|
9
|
+
}
|
|
10
|
+
function useSearch() {
|
|
11
|
+
return useContext(SearchContext) ?? INERT_SEARCH;
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
SearchProvider,
|
|
15
|
+
useSearch
|
|
16
|
+
};
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
4
|
+
import { formatDistanceToNow } from "date-fns";
|
|
5
|
+
import { Copy, Link2, Send, Trash2, RefreshCw, Check } from "lucide-react";
|
|
6
|
+
import { Button, Spinner, notifyError, notifySuccess, usePermissions } from "@okjt/ui";
|
|
7
|
+
import AdminModal from "./AdminModal.js";
|
|
8
|
+
import { AdminInput, AdminTextarea } from "./AdminInput.js";
|
|
9
|
+
import useAdminAction from "./useAdminAction.js";
|
|
10
|
+
import { CollaboratorAvatar } from "./CollaboratorAvatars.js";
|
|
11
|
+
import { useDashboard } from "./DashboardProvider.js";
|
|
12
|
+
import { useModules } from "./modules.js";
|
|
13
|
+
const EMPTY_FORM = { name: "", email: "", message: "", role: "editor" };
|
|
14
|
+
const selectClass = "px-2 py-1.5 rounded-lg border border-tone-200 bg-white text-xs text-tone-700 focus:outline-none focus:ring-2 focus:ring-accent/20";
|
|
15
|
+
function CopyField({ value, label }) {
|
|
16
|
+
const [copied, setCopied] = useState(false);
|
|
17
|
+
const copy = async () => {
|
|
18
|
+
try {
|
|
19
|
+
await navigator.clipboard.writeText(value);
|
|
20
|
+
setCopied(true);
|
|
21
|
+
setTimeout(() => setCopied(false), 2e3);
|
|
22
|
+
} catch {
|
|
23
|
+
notifyError("Could not copy \u2014 select the link and copy it instead");
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
"input",
|
|
29
|
+
{
|
|
30
|
+
readOnly: true,
|
|
31
|
+
value,
|
|
32
|
+
"aria-label": label,
|
|
33
|
+
onFocus: (e) => e.target.select(),
|
|
34
|
+
className: "flex-1 min-w-0 px-3 py-2 rounded-lg border border-tone-200 bg-tone-50 text-xs font-mono text-tone-600"
|
|
35
|
+
}
|
|
36
|
+
),
|
|
37
|
+
/* @__PURE__ */ jsx(Button, { size: "sm", icon: copied ? Check : Copy, onClick: copy, children: copied ? "Copied" : "Copy" })
|
|
38
|
+
] });
|
|
39
|
+
}
|
|
40
|
+
function status(person, moduleByKey) {
|
|
41
|
+
if (person.is_you) return "You";
|
|
42
|
+
if (person.pending) return "Invitation pending";
|
|
43
|
+
if (person.online) {
|
|
44
|
+
const where = moduleByKey(person.current_module)?.label;
|
|
45
|
+
return where ? `Online \xB7 on ${where}` : "Online";
|
|
46
|
+
}
|
|
47
|
+
return person.last_active_at ? `Active ${formatDistanceToNow(new Date(person.last_active_at), { addSuffix: true })}` : "Not active yet";
|
|
48
|
+
}
|
|
49
|
+
function ShareModal({ isOpen, onClose }) {
|
|
50
|
+
const queryClient = useQueryClient();
|
|
51
|
+
const [form, setForm] = useState(EMPTY_FORM);
|
|
52
|
+
const [sending, setSending] = useState(false);
|
|
53
|
+
const [lastInvite, setLastInvite] = useState(null);
|
|
54
|
+
const { isOwner } = usePermissions();
|
|
55
|
+
const { api, roles: ROLES, roleLabel, removeCollaborator } = useDashboard();
|
|
56
|
+
const { moduleByKey } = useModules();
|
|
57
|
+
const { data: people = [], isLoading } = useQuery({
|
|
58
|
+
queryKey: ["collaborators"],
|
|
59
|
+
queryFn: async () => (await api.get("/collaborators")).data || [],
|
|
60
|
+
enabled: isOpen,
|
|
61
|
+
staleTime: 1e4
|
|
62
|
+
});
|
|
63
|
+
const sendInvite = async (payload) => {
|
|
64
|
+
setSending(true);
|
|
65
|
+
try {
|
|
66
|
+
const res = await api.post("/collaborators/invite", payload);
|
|
67
|
+
setLastInvite({ email: payload.email, ...res.data });
|
|
68
|
+
if (res.data?.emailed) notifySuccess(`Invitation sent to ${payload.email}`);
|
|
69
|
+
queryClient.invalidateQueries({ queryKey: ["collaborators"] });
|
|
70
|
+
return true;
|
|
71
|
+
} catch (err) {
|
|
72
|
+
notifyError(err, "Could not send the invitation");
|
|
73
|
+
return false;
|
|
74
|
+
} finally {
|
|
75
|
+
setSending(false);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const onSubmit = async (e) => {
|
|
79
|
+
e.preventDefault();
|
|
80
|
+
if (await sendInvite(form)) setForm(EMPTY_FORM);
|
|
81
|
+
};
|
|
82
|
+
const refreshPeople = () => queryClient.invalidateQueries({ queryKey: ["collaborators"] });
|
|
83
|
+
const removeAccessAction = useAdminAction((person) => removeCollaborator ? removeCollaborator(person) : api.delete(`/collaborators/${person.id}`), {
|
|
84
|
+
role: "owner",
|
|
85
|
+
key: (person) => person.id,
|
|
86
|
+
confirm: (person) => ({
|
|
87
|
+
title: `Remove ${person.name}?`,
|
|
88
|
+
message: `${person.email} will be signed out and can no longer open the dashboard.`,
|
|
89
|
+
confirmLabel: "Remove access",
|
|
90
|
+
tone: "danger"
|
|
91
|
+
}),
|
|
92
|
+
success: (_, person) => `${person.name} no longer has access`,
|
|
93
|
+
error: "Could not remove access",
|
|
94
|
+
onSuccess: refreshPeople
|
|
95
|
+
});
|
|
96
|
+
const removeAccess = removeAccessAction.run;
|
|
97
|
+
const changeRoleAction = useAdminAction((person, role) => api.patch(`/collaborators/${person.id}/role`, { role }), {
|
|
98
|
+
role: "owner",
|
|
99
|
+
key: (person) => person.id,
|
|
100
|
+
success: (res, person) => res.data?.role ? `${person.name} is now ${roleLabel(res.data.role).toLowerCase()}` : "Role updated",
|
|
101
|
+
error: "Could not change the role",
|
|
102
|
+
onSuccess: refreshPeople
|
|
103
|
+
});
|
|
104
|
+
const changeRole = changeRoleAction.run;
|
|
105
|
+
const close = () => {
|
|
106
|
+
setLastInvite(null);
|
|
107
|
+
onClose();
|
|
108
|
+
};
|
|
109
|
+
return /* @__PURE__ */ jsx(AdminModal, { isOpen, onClose: close, title: "Share dashboard", size: "lg", children: /* @__PURE__ */ jsxs("div", { className: "space-y-6 max-h-[70vh] overflow-y-auto -mx-1 px-1", children: [
|
|
110
|
+
!isOwner && /* @__PURE__ */ jsx("p", { className: "text-sm text-tone-600 p-3 rounded-xl bg-tone-50 border border-tone-100", children: "Only owners can invite people or change what they can do. Ask an owner below if someone needs access." }),
|
|
111
|
+
isOwner && /* @__PURE__ */ jsxs("form", { onSubmit, className: "space-y-3", children: [
|
|
112
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-tone-600", children: "Invite someone to plan with you. They get an email with a link to set their password." }),
|
|
113
|
+
/* @__PURE__ */ jsxs("div", { className: "grid sm:grid-cols-2 gap-3", children: [
|
|
114
|
+
/* @__PURE__ */ jsx(
|
|
115
|
+
AdminInput,
|
|
116
|
+
{
|
|
117
|
+
label: "Name",
|
|
118
|
+
required: true,
|
|
119
|
+
value: form.name,
|
|
120
|
+
placeholder: "e.g. Aunt Mei",
|
|
121
|
+
onChange: (e) => setForm({ ...form, name: e.target.value })
|
|
122
|
+
}
|
|
123
|
+
),
|
|
124
|
+
/* @__PURE__ */ jsx(
|
|
125
|
+
AdminInput,
|
|
126
|
+
{
|
|
127
|
+
label: "Email",
|
|
128
|
+
type: "email",
|
|
129
|
+
required: true,
|
|
130
|
+
value: form.email,
|
|
131
|
+
placeholder: "name@example.com",
|
|
132
|
+
onChange: (e) => setForm({ ...form, email: e.target.value })
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
] }),
|
|
136
|
+
/* @__PURE__ */ jsx(
|
|
137
|
+
AdminTextarea,
|
|
138
|
+
{
|
|
139
|
+
label: "Personal note (optional)",
|
|
140
|
+
rows: 2,
|
|
141
|
+
value: form.message,
|
|
142
|
+
maxLength: 1e3,
|
|
143
|
+
onChange: (e) => setForm({ ...form, message: e.target.value })
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
/* @__PURE__ */ jsxs("fieldset", { children: [
|
|
147
|
+
/* @__PURE__ */ jsx("legend", { className: "block text-sm font-medium text-tone-600 mb-1", children: "They can" }),
|
|
148
|
+
/* @__PURE__ */ jsx("div", { className: "grid sm:grid-cols-3 gap-2", children: ROLES.map((r) => /* @__PURE__ */ jsxs("label", { className: `p-2.5 rounded-xl border cursor-pointer text-xs transition-colors ${form.role === r.value ? "border-accent/50 bg-accent/5" : "border-tone-200 hover:bg-tone-50"}`, children: [
|
|
149
|
+
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 font-medium text-sm text-tone-800", children: [
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
"input",
|
|
152
|
+
{
|
|
153
|
+
type: "radio",
|
|
154
|
+
name: "invite-role",
|
|
155
|
+
value: r.value,
|
|
156
|
+
checked: form.role === r.value,
|
|
157
|
+
onChange: () => setForm({ ...form, role: r.value }),
|
|
158
|
+
className: "text-accent focus:ring-accent"
|
|
159
|
+
}
|
|
160
|
+
),
|
|
161
|
+
r.label
|
|
162
|
+
] }),
|
|
163
|
+
/* @__PURE__ */ jsx("span", { className: "block mt-1 text-tone-500 leading-snug", children: r.description })
|
|
164
|
+
] }, r.value)) })
|
|
165
|
+
] }),
|
|
166
|
+
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", variant: "secondary", icon: Send, loading: sending, children: "Send invite" }) })
|
|
167
|
+
] }),
|
|
168
|
+
lastInvite?.invite_link && /* @__PURE__ */ jsxs("div", { className: `p-3 rounded-xl border space-y-2 ${lastInvite.emailed ? "bg-tone-50 border-tone-100" : "bg-amber-50 border-amber-200"}`, children: [
|
|
169
|
+
/* @__PURE__ */ jsxs("p", { className: "text-xs text-tone-700 flex items-center gap-1.5", children: [
|
|
170
|
+
/* @__PURE__ */ jsx(Link2, { className: "w-3.5 h-3.5" }),
|
|
171
|
+
lastInvite.emailed ? `Or share this link with ${lastInvite.email} directly (valid ${lastInvite.expires_in_days} days):` : `The email couldn't be sent \u2014 share this link with ${lastInvite.email} (valid ${lastInvite.expires_in_days} days):`
|
|
172
|
+
] }),
|
|
173
|
+
/* @__PURE__ */ jsx(CopyField, { value: lastInvite.invite_link, label: "Invitation link" })
|
|
174
|
+
] }),
|
|
175
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
176
|
+
/* @__PURE__ */ jsx("h3", { className: "text-xs font-bold uppercase tracking-wider text-tone-500 mb-2", children: "People with access" }),
|
|
177
|
+
isLoading ? /* @__PURE__ */ jsx("div", { className: "py-6 flex justify-center", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsx("ul", { className: "divide-y divide-tone-100 border border-tone-100 rounded-xl", children: people.map((person) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-3 px-3 py-2", children: [
|
|
178
|
+
/* @__PURE__ */ jsxs("span", { className: "relative", children: [
|
|
179
|
+
/* @__PURE__ */ jsx(CollaboratorAvatar, { person }),
|
|
180
|
+
person.online && !person.is_you && /* @__PURE__ */ jsx("span", { className: "absolute -bottom-0.5 -right-0.5 w-2.5 h-2.5 rounded-full bg-green-500 ring-2 ring-white", "aria-hidden": "true" })
|
|
181
|
+
] }),
|
|
182
|
+
/* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
|
|
183
|
+
/* @__PURE__ */ jsx("span", { className: "block text-sm font-medium text-tone-800 truncate", children: person.name }),
|
|
184
|
+
/* @__PURE__ */ jsxs("span", { className: "block text-xs text-tone-500 truncate", children: [
|
|
185
|
+
person.email,
|
|
186
|
+
" \xB7 ",
|
|
187
|
+
status(person, moduleByKey)
|
|
188
|
+
] })
|
|
189
|
+
] }),
|
|
190
|
+
isOwner && !person.is_you ? /* @__PURE__ */ jsx(
|
|
191
|
+
"select",
|
|
192
|
+
{
|
|
193
|
+
value: person.role,
|
|
194
|
+
onChange: (e) => changeRole(person, e.target.value),
|
|
195
|
+
"aria-label": `What ${person.name} can do`,
|
|
196
|
+
className: selectClass,
|
|
197
|
+
children: ROLES.map((r) => /* @__PURE__ */ jsx("option", { value: r.value, children: r.label }, r.value))
|
|
198
|
+
}
|
|
199
|
+
) : /* @__PURE__ */ jsx("span", { className: "px-2 py-0.5 rounded-full bg-tone-100 text-[11px] font-medium text-tone-600", children: roleLabel(person.role) }),
|
|
200
|
+
isOwner && person.pending && /* @__PURE__ */ jsx(
|
|
201
|
+
Button,
|
|
202
|
+
{
|
|
203
|
+
size: "icon-sm",
|
|
204
|
+
icon: RefreshCw,
|
|
205
|
+
"aria-label": `Resend invitation to ${person.name}`,
|
|
206
|
+
title: "Resend invitation",
|
|
207
|
+
onClick: () => sendInvite({ name: person.name, email: person.email, role: person.role }),
|
|
208
|
+
disabled: sending
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
isOwner && !person.is_you && /* @__PURE__ */ jsx(
|
|
212
|
+
Button,
|
|
213
|
+
{
|
|
214
|
+
size: "icon-sm",
|
|
215
|
+
variant: "danger",
|
|
216
|
+
icon: Trash2,
|
|
217
|
+
"aria-label": `Remove ${person.name}`,
|
|
218
|
+
title: "Remove access",
|
|
219
|
+
onClick: () => removeAccess(person)
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] }, person.id)) })
|
|
223
|
+
] })
|
|
224
|
+
] }) });
|
|
225
|
+
}
|
|
226
|
+
export {
|
|
227
|
+
ShareModal as default
|
|
228
|
+
};
|
package/dist/StatCard.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { TrendingUp } from "lucide-react";
|
|
4
|
+
function StatCard({ icon, label, value, color }) {
|
|
5
|
+
return /* @__PURE__ */ jsxs(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
className: "p-6 rounded-2xl transition-all hover:scale-[1.02]",
|
|
9
|
+
style: {
|
|
10
|
+
background: "white",
|
|
11
|
+
boxShadow: "0 4px 20px rgba(166, 123, 91, 0.08)"
|
|
12
|
+
},
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-4", children: [
|
|
15
|
+
/* @__PURE__ */ jsx(
|
|
16
|
+
"div",
|
|
17
|
+
{
|
|
18
|
+
className: "w-12 h-12 rounded-xl flex items-center justify-center",
|
|
19
|
+
style: { background: `${color}15` },
|
|
20
|
+
children: React.cloneElement(icon, { style: { color } })
|
|
21
|
+
}
|
|
22
|
+
),
|
|
23
|
+
/* @__PURE__ */ jsx(TrendingUp, { className: "w-5 h-5 text-positive" })
|
|
24
|
+
] }),
|
|
25
|
+
/* @__PURE__ */ jsx("p", { className: "text-3xl font-semibold mb-1 text-body", children: value }),
|
|
26
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted", children: label })
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
StatCard as default
|
|
33
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { usePermissions } from "@okjt/ui";
|
|
3
|
+
function ToggleButton({ enabled, onToggle, label }) {
|
|
4
|
+
const { canEdit } = usePermissions();
|
|
5
|
+
return /* @__PURE__ */ jsxs(
|
|
6
|
+
"button",
|
|
7
|
+
{
|
|
8
|
+
type: "button",
|
|
9
|
+
onClick: onToggle,
|
|
10
|
+
disabled: !canEdit,
|
|
11
|
+
className: `relative inline-flex h-6 w-11 items-center rounded-full transition-colors disabled:opacity-60 disabled:cursor-not-allowed ${enabled ? "bg-accent" : "bg-tone-200"}`,
|
|
12
|
+
children: [
|
|
13
|
+
/* @__PURE__ */ jsx(
|
|
14
|
+
"span",
|
|
15
|
+
{
|
|
16
|
+
className: `inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${enabled ? "translate-x-6" : "translate-x-1"}`
|
|
17
|
+
}
|
|
18
|
+
),
|
|
19
|
+
label && /* @__PURE__ */ jsx("span", { className: "sr-only", children: label })
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
ToggleButton as default
|
|
26
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AlertCircle } from "lucide-react";
|
|
3
|
+
import { AdminHeaderStatus } from "./AdminChromeContext.js";
|
|
4
|
+
function UnsavedChangesStatus({ dirty }) {
|
|
5
|
+
if (!dirty) return null;
|
|
6
|
+
return /* @__PURE__ */ jsx(AdminHeaderStatus, { children: /* @__PURE__ */ jsxs("span", { role: "status", className: "px-3 py-1.5 rounded-full text-xs font-semibold flex items-center gap-2 bg-amber-50 text-amber-800 whitespace-nowrap", children: [
|
|
7
|
+
/* @__PURE__ */ jsx(AlertCircle, { className: "w-3.5 h-3.5" }),
|
|
8
|
+
" Unsaved changes"
|
|
9
|
+
] }) });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
UnsavedChangesStatus as default
|
|
13
|
+
};
|