@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.
Files changed (46) hide show
  1. package/README.md +144 -2
  2. package/dist/ActivityPanel.js +48 -0
  3. package/dist/AdminBulkActions.js +109 -0
  4. package/dist/AdminCard.js +7 -0
  5. package/dist/AdminChromeContext.js +16 -0
  6. package/dist/AdminFloatingToolbar.js +147 -0
  7. package/dist/AdminInput.js +66 -0
  8. package/dist/AdminListPanel.js +26 -0
  9. package/dist/AdminModal.js +23 -0
  10. package/dist/AdminPageHero.js +101 -0
  11. package/dist/AdminPageLayout.js +54 -0
  12. package/dist/AdminPagination.js +92 -0
  13. package/dist/AdminSidePanel.js +479 -0
  14. package/dist/AdminSummaryCards.js +51 -0
  15. package/dist/AdminToolbarFilters.js +168 -0
  16. package/dist/AdminToolbarSearch.js +61 -0
  17. package/dist/AdminTutorial.js +221 -0
  18. package/dist/AuthContext.js +189 -0
  19. package/dist/CollaborationContext.js +84 -0
  20. package/dist/CollaboratorAvatars.js +36 -0
  21. package/dist/DashboardHeader.js +140 -0
  22. package/dist/DashboardProvider.js +45 -0
  23. package/dist/DashboardShell.js +93 -0
  24. package/dist/DashboardSidebar.js +97 -0
  25. package/dist/DeleteButton.js +21 -0
  26. package/dist/EditableFieldset.js +9 -0
  27. package/dist/EmptyState.js +22 -0
  28. package/dist/GoogleButton.js +22 -0
  29. package/dist/NotificationsBell.js +149 -0
  30. package/dist/QueryError.js +23 -0
  31. package/dist/SearchContext.js +16 -0
  32. package/dist/ShareModal.js +228 -0
  33. package/dist/StatCard.js +33 -0
  34. package/dist/ToggleButton.js +26 -0
  35. package/dist/UnsavedChangesStatus.js +13 -0
  36. package/dist/VersionHistoryDrawer.js +172 -0
  37. package/dist/index.js +110 -0
  38. package/dist/modules.js +32 -0
  39. package/dist/passkeys.js +84 -0
  40. package/dist/useActivityPanel.js +34 -0
  41. package/dist/useAdminAction.js +77 -0
  42. package/dist/useCrudHandlers.js +54 -0
  43. package/dist/useFilteredItems.js +19 -0
  44. package/dist/useSavedViews.js +30 -0
  45. package/dist/useUnsavedChangesGuard.js +41 -0
  46. package/package.json +39 -4
package/README.md CHANGED
@@ -1,3 +1,145 @@
1
- # Temporary Holding Version
1
+ # @okjt/dashboard
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The pages of an OKJTech dashboard, as Naoa builds them: every page has the
4
+ same shape — a hero with breadcrumbs, optional summary cards that double as
5
+ filters, the page's content with a side panel beside it, and one floating
6
+ toolbar for search, filters, views and actions. Lists fit the screen and only
7
+ their rows scroll. Saving works one way everywhere (`useAdminAction`):
8
+ confirm, pending state, toast, refresh, and hidden for people who may only
9
+ view.
10
+
11
+ Colours and fonts come from `@okjt/ui`'s theme.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm i @okjt/dashboard @okjt/ui
17
+ ```
18
+
19
+ Peer dependencies: `react`, `react-dom`, `react-router-dom`,
20
+ `@tanstack/react-query`, `framer-motion`, `lucide-react`, `react-hot-toast`.
21
+
22
+ ```css
23
+ @import "tailwindcss";
24
+ @import "./okjt-theme.css";
25
+ @source "../node_modules/@okjt/ui/dist";
26
+ @source "../node_modules/@okjt/dashboard/dist";
27
+ ```
28
+
29
+ ## Set it up
30
+
31
+ ```jsx
32
+ import { PermissionsProvider, ConfirmHost } from '@okjt/ui';
33
+ import { DashboardProvider, SearchProvider, AdminChromeProvider } from '@okjt/dashboard';
34
+
35
+ const dashboard = {
36
+ home: { label: 'Dashboard', path: '/dashboard' }, // first breadcrumb on every page
37
+ useDefaultPanel: () => null, // side panel for pages without one
38
+ useAfterChange: () => undefined, // called after every successful save
39
+ };
40
+
41
+ function Providers({ children }) {
42
+ const permissions = useMyPermissions(); // { role, isOwner, canEdit }
43
+ return (
44
+ <PermissionsProvider value={permissions}>
45
+ <DashboardProvider dashboard={dashboard}>
46
+ <SearchProvider>
47
+ <AdminChromeProvider>
48
+ {children}
49
+ <ConfirmHost />
50
+ </AdminChromeProvider>
51
+ </SearchProvider>
52
+ </DashboardProvider>
53
+ </PermissionsProvider>
54
+ );
55
+ }
56
+ ```
57
+
58
+ Outside a `PermissionsProvider` everything is allowed; outside a
59
+ `DashboardProvider` the defaults above apply.
60
+
61
+ ## A page
62
+
63
+ ```jsx
64
+ import { Plus } from 'lucide-react';
65
+ import { AdminPageLayout, AdminPageHero, AdminSummaryCards, AdminListPanel, useAdminAction, useFilteredItems, useSearch } from '@okjt/dashboard';
66
+
67
+ export default function Expenses() {
68
+ const { data: expenses = [] } = useQuery({ queryKey: ['expenses'], queryFn: api.expenses });
69
+ const { searchQuery } = useSearch();
70
+ const shown = useFilteredItems(expenses, searchQuery);
71
+ const remove = useAdminAction((id) => api.deleteExpense(id), {
72
+ confirm: 'Delete this expense?', success: 'Expense deleted', invalidate: [['expenses']],
73
+ });
74
+
75
+ return (
76
+ <AdminPageLayout
77
+ fill
78
+ hero={<AdminPageHero title="Expenses" breadcrumb="Expenses" />}
79
+ summary={<AdminSummaryCards cards={[{ label: 'This month', value: total(expenses) }]} />}
80
+ search="Search expenses"
81
+ actions={[{ id: 'add', label: 'Add expense', icon: Plus, onClick: openForm }]}
82
+ >
83
+ <AdminListPanel>{shown.map((e) => <Row key={e.id} expense={e} onDelete={() => remove.run(e.id)} />)}</AdminListPanel>
84
+ </AdminPageLayout>
85
+ );
86
+ }
87
+ ```
88
+
89
+ ## Building blocks
90
+
91
+ | Export | What it is |
92
+ |---|---|
93
+ | `AdminPageLayout` | The page: `hero`, `summary`, content, `panel`, and the toolbar's `actions`, `search`, `filters`; `fill` fits the viewport |
94
+ | `AdminPageHero` | Title, breadcrumbs, description; a compact copy appears in the header once it scrolls away |
95
+ | `AdminSummaryCards`, `StatCard` | Summary numbers; a card can apply a filter |
96
+ | `AdminFloatingToolbar`, `AdminToolbarSearch`, `AdminToolbarFilters`, `countActiveFilters` | The toolbar and its parts |
97
+ | `SidePanelAside`, `SidePanelMobileBar`, `SidePanelNav` | The side panel: sections, tools, lists; chips and a sheet on phones |
98
+ | `AdminListPanel`, `AdminPagination`, `pageWindow`, `AdminBulkActions` | Lists, paging, actions on a selection |
99
+ | `AdminCard`, `AdminInput`, `AdminTextarea`, `AdminSelect`, `AdminModal` | Cards, fields, dialogs |
100
+ | `EditableFieldset`, `DeleteButton`, `ToggleButton` | Controls that disable or hide themselves for viewers |
101
+ | `EmptyState`, `QueryError` | Nothing to show; something failed to load |
102
+ | `UnsavedChangesStatus`, `useUnsavedChangesGuard`, `useUnsavedChanges` | Warn before leaving with unsaved edits |
103
+ | `AdminTutorial` | A guided tour; pass `steps` |
104
+ | `useAdminAction`, `useBulkAdminAction`, `useCrudHandlers` | One way to save |
105
+ | `useFilteredItems`, `useSavedViews` | Search across a list; remembered views |
106
+ | `SearchProvider`/`useSearch`, `AdminChromeProvider`/`useAdminChrome`, `AdminHeaderStatus` | The shared search box and the header's slots |
107
+ | `DashboardProvider`, `useDashboard` | The settings above |
108
+
109
+ ## Working together
110
+
111
+ With `okjt/laravel-kit`'s collaboration routes on the server, add to the
112
+ dashboard settings:
113
+
114
+ ```js
115
+ const dashboard = {
116
+ // …
117
+ api, // axios-like, sends the workspace header, resolves to the body
118
+ modules: [{ key: 'expenses', path: '/dashboard/expenses', label: 'Expenses' }],
119
+ roles: [{ value: 'owner', label: 'Owner', description: '…' }, /* editor, viewer */],
120
+ anonymousName: 'Someone', // changes nobody signed in made
121
+ useDefaultPanel: useActivityPanel, // who's here and what changed, on pages without a panel
122
+ useAfterChange: () => useCollaboration().refresh,
123
+ };
124
+ ```
125
+
126
+ and wrap the dashboard in `<CollaborationProvider>` (inside the router). Then
127
+ `ShareModal`, `VersionHistoryDrawer`, `ActivityPanel` and
128
+ `CollaboratorAvatars` work as in Naoa.
129
+
130
+ ## Signing in
131
+
132
+ | Export | What it is |
133
+ |---|---|
134
+ | `AuthProvider`, `useAuth` | Who is signed in: `api`, plus `extend` for what the project adds |
135
+ | `GoogleButton` | Sends the browser to the kit's Google route |
136
+ | `loginWithPasskey`, `registerPasskey`, `passkeysSupported` | Passkeys against the kit's `PasskeyController`; `{ base }` if the routes aren't under `/api` |
137
+ | `NotificationsBell` | The header's notifications |
138
+
139
+ ## The shell
140
+
141
+ `DashboardShell` (with `DashboardSidebar` and `DashboardHeader`) is the frame
142
+ around every page, set up through `shell` in the dashboard settings.
143
+
144
+ Still in the projects for now, moving next: the Console, teams, backups,
145
+ then the sign-in pages and the account menu.
@@ -0,0 +1,48 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { formatDistanceToNow } from "date-fns";
4
+ import { History, Share2 } from "lucide-react";
5
+ import { Button } from "@okjt/ui";
6
+ import { CollaboratorAvatar } from "./CollaboratorAvatars.js";
7
+ import { useCollaboration } from "./CollaborationContext.js";
8
+ import { useDashboard } from "./DashboardProvider.js";
9
+ const ACTION_WORDS = { created: "added", updated: "edited", deleted: "deleted", restored: "restored" };
10
+ function ActivityPanel() {
11
+ const { module, othersHere, openHistory, setShareOpen } = useCollaboration();
12
+ const { api, anonymousName } = useDashboard();
13
+ const { data: recent = [], isLoading } = useQuery({
14
+ queryKey: ["revisions", module, "recent"],
15
+ queryFn: async () => (await api.get("/revisions", { params: { module, per_page: 5 } })).data?.data || [],
16
+ enabled: !!module,
17
+ staleTime: 15e3
18
+ });
19
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-5", children: [
20
+ /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
21
+ /* @__PURE__ */ jsx("h3", { className: "text-[11px] font-bold uppercase tracking-wider text-tone-500", children: "On this page" }),
22
+ othersHere.length ? /* @__PURE__ */ jsxs("ul", { className: "space-y-1.5", children: [
23
+ othersHere.map((person) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-2 text-sm text-tone-700", children: [
24
+ /* @__PURE__ */ jsx(CollaboratorAvatar, { person, size: "xs" }),
25
+ " ",
26
+ person.name
27
+ ] }, person.id)),
28
+ /* @__PURE__ */ jsx("li", { className: "text-xs text-amber-700", children: "Save often \u2014 the last save wins if you edit the same thing." })
29
+ ] }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-500", children: "Only you right now." })
30
+ ] }),
31
+ /* @__PURE__ */ jsxs("section", { className: "space-y-2", children: [
32
+ /* @__PURE__ */ jsx("h3", { className: "text-[11px] font-bold uppercase tracking-wider text-tone-500", children: "Recent changes" }),
33
+ isLoading ? /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-400", children: "Loading\u2026" }) : recent.length ? /* @__PURE__ */ jsx("ul", { className: "space-y-2", children: recent.map((r) => /* @__PURE__ */ jsxs("li", { className: "text-xs text-tone-600 leading-snug", children: [
34
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-tone-800", children: r.user?.name || anonymousName }),
35
+ " ",
36
+ ACTION_WORDS[r.action] || r.action,
37
+ " ",
38
+ /* @__PURE__ */ jsx("span", { className: "font-medium text-tone-800", children: r.subject_label }),
39
+ /* @__PURE__ */ jsx("span", { className: "block text-[11px] text-tone-400", children: formatDistanceToNow(new Date(r.updated_at || r.created_at), { addSuffix: true }) })
40
+ ] }, r.id)) }) : /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-500", children: "No changes recorded here yet." }),
41
+ /* @__PURE__ */ jsx(Button, { size: "sm", icon: History, fullWidth: true, onClick: openHistory, children: "Version history" })
42
+ ] }),
43
+ /* @__PURE__ */ jsx(Button, { size: "sm", icon: Share2, fullWidth: true, onClick: () => setShareOpen(true), children: "Invite collaborators" })
44
+ ] });
45
+ }
46
+ export {
47
+ ActivityPanel as default
48
+ };
@@ -0,0 +1,109 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState, useRef, useEffect } from "react";
3
+ import { motion, AnimatePresence } from "framer-motion";
4
+ import { X, MoreHorizontal, Users } from "lucide-react";
5
+ import { Button, useVisibleActions } from "@okjt/ui";
6
+ function AdminBulkActions({ selectedCount = 0, onClearSelection, actions: allActions = [] }) {
7
+ const actions = useVisibleActions(allActions);
8
+ const [menuOpen, setMenuOpen] = useState(false);
9
+ const menuRef = useRef(null);
10
+ useEffect(() => {
11
+ function handleClickOutside(e) {
12
+ if (menuRef.current && !menuRef.current.contains(e.target)) {
13
+ setMenuOpen(false);
14
+ }
15
+ }
16
+ if (menuOpen) document.addEventListener("mousedown", handleClickOutside);
17
+ return () => document.removeEventListener("mousedown", handleClickOutside);
18
+ }, [menuOpen]);
19
+ if (selectedCount === 0 || actions.length === 0) return null;
20
+ const primaryActions = actions.slice(0, 3);
21
+ const overflowActions = actions.slice(3);
22
+ const hasOverflow = overflowActions.length > 0;
23
+ return /* @__PURE__ */ jsxs(
24
+ motion.div,
25
+ {
26
+ initial: { opacity: 0, y: -10 },
27
+ animate: { opacity: 1, y: 0 },
28
+ exit: { opacity: 0, y: -10 },
29
+ className: "mb-6 p-3 rounded-xl bg-accent/5 border border-accent/10 flex flex-col sm:flex-row sm:items-center justify-between gap-3",
30
+ children: [
31
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
32
+ /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-lg bg-accent/10 flex items-center justify-center", children: /* @__PURE__ */ jsx(Users, { className: "w-4 h-4 text-accent" }) }),
33
+ /* @__PURE__ */ jsxs("div", { children: [
34
+ /* @__PURE__ */ jsxs("p", { className: "text-sm font-medium text-body", children: [
35
+ selectedCount,
36
+ " selected"
37
+ ] }),
38
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-muted", children: "Use the actions below or click items to deselect." })
39
+ ] })
40
+ ] }),
41
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 flex-wrap", children: [
42
+ primaryActions.map((action) => /* @__PURE__ */ jsx(
43
+ Button,
44
+ {
45
+ variant: action.variant || "primary",
46
+ icon: action.icon,
47
+ onClick: action.onClick,
48
+ disabled: action.disabled,
49
+ children: /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: action.label })
50
+ },
51
+ action.id
52
+ )),
53
+ hasOverflow && /* @__PURE__ */ jsxs("div", { className: "relative", ref: menuRef, children: [
54
+ /* @__PURE__ */ jsx(
55
+ Button,
56
+ {
57
+ size: "icon",
58
+ icon: MoreHorizontal,
59
+ "aria-label": "More actions",
60
+ onClick: () => setMenuOpen((v) => !v)
61
+ }
62
+ ),
63
+ /* @__PURE__ */ jsx(AnimatePresence, { children: menuOpen && /* @__PURE__ */ jsx(
64
+ motion.div,
65
+ {
66
+ initial: { opacity: 0, y: 8, scale: 0.96 },
67
+ animate: { opacity: 1, y: 0, scale: 1 },
68
+ exit: { opacity: 0, y: 8, scale: 0.96 },
69
+ className: "absolute right-0 bottom-full mb-2 min-w-[10rem] bg-white rounded-xl shadow-xl border border-tone-100 py-2 overflow-hidden z-20",
70
+ children: overflowActions.map((action) => {
71
+ const Icon = action.icon;
72
+ return /* @__PURE__ */ jsxs(
73
+ "button",
74
+ {
75
+ onClick: () => {
76
+ action.onClick();
77
+ setMenuOpen(false);
78
+ },
79
+ disabled: action.disabled,
80
+ className: `w-full text-left px-4 py-2.5 text-sm flex items-center gap-2 hover:bg-tone-50 transition-colors ${action.variant === "danger" ? "text-red-600" : "text-tone-700"} ${action.disabled ? "opacity-50 cursor-not-allowed" : ""}`,
81
+ children: [
82
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4" }),
83
+ action.label
84
+ ]
85
+ },
86
+ action.id
87
+ );
88
+ })
89
+ }
90
+ ) })
91
+ ] }),
92
+ /* @__PURE__ */ jsx(
93
+ "button",
94
+ {
95
+ "aria-label": "Clear selection",
96
+ onClick: onClearSelection,
97
+ className: "p-2 rounded-lg text-tone-400 hover:text-tone-600 hover:bg-white transition-colors",
98
+ title: "Clear selection",
99
+ children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
100
+ }
101
+ )
102
+ ] })
103
+ ]
104
+ }
105
+ );
106
+ }
107
+ export {
108
+ AdminBulkActions as default
109
+ };
@@ -0,0 +1,7 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ function AdminCard({ children, className = "", padding = true }) {
3
+ return /* @__PURE__ */ jsx("div", { className: `bg-white rounded-2xl shadow-sm border border-tone-100 ${padding ? "p-4 sm:p-5" : ""} ${className}`, children });
4
+ }
5
+ export {
6
+ AdminCard as default
7
+ };
@@ -0,0 +1,16 @@
1
+ import { createContext, useContext } from "react";
2
+ import { createPortal } from "react-dom";
3
+ const AdminChromeContext = createContext({ titleSlot: null, statusSlot: null });
4
+ const AdminChromeProvider = AdminChromeContext.Provider;
5
+ function useAdminChrome() {
6
+ return useContext(AdminChromeContext);
7
+ }
8
+ function AdminHeaderStatus({ children }) {
9
+ const { statusSlot } = useAdminChrome();
10
+ return statusSlot ? createPortal(children, statusSlot) : null;
11
+ }
12
+ export {
13
+ AdminChromeProvider,
14
+ AdminHeaderStatus,
15
+ useAdminChrome
16
+ };
@@ -0,0 +1,147 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { motion, AnimatePresence } from "framer-motion";
5
+ import { MoreHorizontal, ChevronUp, ChevronDown, SlidersHorizontal } from "lucide-react";
6
+ import AdminToolbarSearch from "./AdminToolbarSearch.js";
7
+ import AdminToolbarFilters, { countActiveFilters } from "./AdminToolbarFilters.js";
8
+ import { useSearch } from "./SearchContext.js";
9
+ import { Button, useVisibleActions } from "@okjt/ui";
10
+ function AdminFloatingToolbar({
11
+ actions = [],
12
+ children = null,
13
+ search = null,
14
+ filters = null,
15
+ z = "z-50",
16
+ wrapperClassName = ""
17
+ }) {
18
+ const [menuOpen, setMenuOpen] = useState(false);
19
+ const [visible, setVisible] = useState(true);
20
+ const [toolsOpen, setToolsOpen] = useState(false);
21
+ const { searchQuery } = useSearch();
22
+ const visibleActions = useVisibleActions(actions).filter((a) => !a.hidden);
23
+ const searchProps = !search ? null : typeof search === "string" ? { placeholder: search } : typeof search === "object" ? search : {};
24
+ const hasLeading = !!searchProps || !!filters;
25
+ if (visibleActions.length === 0 && !children && !hasLeading) return null;
26
+ const narrowed = searchProps && (searchProps.value ?? searchQuery) || countActiveFilters(filters) > 0;
27
+ const maxPrimary = hasLeading ? 2 : 4;
28
+ const primaryActions = visibleActions.slice(0, maxPrimary);
29
+ const overflowActions = visibleActions.slice(maxPrimary);
30
+ const hasOverflow = overflowActions.length > 0;
31
+ return createPortal(
32
+ /* @__PURE__ */ jsx(AnimatePresence, { children: visible ? /* @__PURE__ */ jsx(
33
+ motion.div,
34
+ {
35
+ initial: { opacity: 0, y: 30, scale: 0.96 },
36
+ animate: { opacity: 1, y: 0, scale: 1 },
37
+ exit: { opacity: 0, y: 20, scale: 0.96 },
38
+ transition: { type: "spring", stiffness: 300, damping: 25 },
39
+ className: `fixed bottom-[max(0.75rem,env(safe-area-inset-bottom))] sm:bottom-6 left-1/2 lg:left-[calc(50%+140px)] -translate-x-1/2 ${z} w-max max-w-[calc(100vw-1rem)] sm:max-w-[calc(100vw-1.5rem)] lg:max-w-[calc(100vw-280px-1.5rem)] ${wrapperClassName}`,
40
+ children: /* @__PURE__ */ jsxs(
41
+ "div",
42
+ {
43
+ className: "admin-floating-toolbar flex flex-wrap items-center justify-center gap-1 sm:gap-2 p-1.5 sm:p-2 rounded-2xl border border-white/40 shadow-2xl backdrop-blur-md",
44
+ style: {
45
+ background: "rgba(255, 249, 245, 0.92)",
46
+ boxShadow: "0 12px 40px rgba(74, 63, 53, 0.18)"
47
+ },
48
+ children: [
49
+ searchProps && /* @__PURE__ */ jsx(AdminToolbarSearch, { ...searchProps }),
50
+ filters && /* @__PURE__ */ jsx(AdminToolbarFilters, { filters }),
51
+ hasLeading && (children || visibleActions.length > 0) && /* @__PURE__ */ jsx("div", { className: "hidden sm:block w-px h-6 bg-tone-200/70 mx-0.5" }),
52
+ children && /* @__PURE__ */ jsx(
53
+ Button,
54
+ {
55
+ variant: toolsOpen ? "secondary" : "primary",
56
+ icon: SlidersHorizontal,
57
+ onClick: () => setToolsOpen((v) => !v),
58
+ "aria-expanded": toolsOpen,
59
+ className: "sm:hidden",
60
+ children: "Tools"
61
+ }
62
+ ),
63
+ children && /* @__PURE__ */ jsx("div", { className: toolsOpen ? "contents" : "hidden sm:contents", children }),
64
+ children && visibleActions.length > 0 && /* @__PURE__ */ jsx("div", { className: "hidden sm:block w-px h-6 bg-tone-200/70 mx-0.5" }),
65
+ primaryActions.map((action) => /* @__PURE__ */ jsx(
66
+ Button,
67
+ {
68
+ variant: action.variant,
69
+ icon: action.icon,
70
+ onClick: action.onClick,
71
+ disabled: action.disabled,
72
+ title: action.label,
73
+ "aria-label": action.label,
74
+ children: /* @__PURE__ */ jsx("span", { className: children ? "hidden 2xl:inline" : "hidden sm:inline", children: action.label })
75
+ },
76
+ action.id
77
+ )),
78
+ hasOverflow && /* @__PURE__ */ jsxs("div", { className: "relative", children: [
79
+ /* @__PURE__ */ jsx(Button, { icon: MoreHorizontal, onClick: () => setMenuOpen((v) => !v), "aria-label": "More actions", children: /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: "More" }) }),
80
+ /* @__PURE__ */ jsx(AnimatePresence, { children: menuOpen && /* @__PURE__ */ jsx(
81
+ motion.div,
82
+ {
83
+ initial: { opacity: 0, y: 8, scale: 0.96 },
84
+ animate: { opacity: 1, y: 0, scale: 1 },
85
+ exit: { opacity: 0, y: 8, scale: 0.96 },
86
+ className: "absolute bottom-full left-1/2 -translate-x-1/2 mb-2 min-w-[10rem] bg-white rounded-xl shadow-xl border border-tone-100 py-2 overflow-hidden",
87
+ children: overflowActions.map((action) => {
88
+ const Icon = action.icon;
89
+ return /* @__PURE__ */ jsxs(
90
+ "button",
91
+ {
92
+ onClick: () => {
93
+ action.onClick();
94
+ setMenuOpen(false);
95
+ },
96
+ disabled: action.disabled,
97
+ className: `w-full text-left px-4 py-2.5 text-sm flex items-center gap-2 hover:bg-tone-50 transition-colors ${action.variant === "danger" ? "text-red-600" : "text-tone-700"} ${action.disabled ? "opacity-50 cursor-not-allowed" : ""}`,
98
+ children: [
99
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4" }),
100
+ action.label
101
+ ]
102
+ },
103
+ action.id
104
+ );
105
+ })
106
+ }
107
+ ) })
108
+ ] }),
109
+ /* @__PURE__ */ jsx(
110
+ "button",
111
+ {
112
+ "aria-label": "Hide toolbar",
113
+ onClick: () => setVisible(false),
114
+ className: "p-2 rounded-xl text-tone-400 hover:text-tone-600 hover:bg-white/60 transition-colors",
115
+ title: "Hide toolbar",
116
+ children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4" })
117
+ }
118
+ )
119
+ ]
120
+ }
121
+ )
122
+ },
123
+ "toolbar"
124
+ ) : /* @__PURE__ */ jsxs(
125
+ motion.button,
126
+ {
127
+ initial: { opacity: 0, y: 20 },
128
+ animate: { opacity: 1, y: 0 },
129
+ exit: { opacity: 0, y: 20 },
130
+ whileHover: { scale: 1.05 },
131
+ whileTap: { scale: 0.95 },
132
+ onClick: () => setVisible(true),
133
+ className: `fixed bottom-[max(0.75rem,env(safe-area-inset-bottom))] sm:bottom-6 left-1/2 lg:left-[calc(50%+140px)] -translate-x-1/2 ${z} p-2.5 rounded-full bg-white/90 border border-tone-200 shadow-lg text-accent hover:bg-white transition-colors ${wrapperClassName}`,
134
+ title: narrowed ? "Show toolbar (search or filters active)" : "Show toolbar",
135
+ children: [
136
+ /* @__PURE__ */ jsx(ChevronUp, { className: "w-5 h-5" }),
137
+ narrowed && /* @__PURE__ */ jsx("span", { className: "absolute top-1 right-1 w-2 h-2 rounded-full bg-accent" })
138
+ ]
139
+ },
140
+ "toolbar-toggle"
141
+ ) }),
142
+ document.body
143
+ );
144
+ }
145
+ export {
146
+ AdminFloatingToolbar as default
147
+ };
@@ -0,0 +1,66 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ const baseInputClasses = "w-full px-4 py-2 rounded-lg border border-tone-200 focus:outline-none focus:ring-2 focus:ring-accent/20 focus:border-accent transition-colors";
4
+ function AdminInput({ label, error, className = "", id, ...props }) {
5
+ const generatedId = useId();
6
+ const inputId = id || generatedId;
7
+ const errorId = `${inputId}-error`;
8
+ return /* @__PURE__ */ jsxs("div", { children: [
9
+ label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "block text-sm font-medium text-tone-600 mb-1", children: label }),
10
+ /* @__PURE__ */ jsx(
11
+ "input",
12
+ {
13
+ id: inputId,
14
+ "aria-invalid": error ? true : void 0,
15
+ "aria-describedby": error ? errorId : void 0,
16
+ className: `${baseInputClasses} ${error ? "border-red-400" : ""} ${className}`,
17
+ ...props
18
+ }
19
+ ),
20
+ error && /* @__PURE__ */ jsx("p", { id: errorId, className: "text-red-500 text-xs mt-1", children: error })
21
+ ] });
22
+ }
23
+ function AdminTextarea({ label, error, className = "", id, ...props }) {
24
+ const generatedId = useId();
25
+ const inputId = id || generatedId;
26
+ const errorId = `${inputId}-error`;
27
+ return /* @__PURE__ */ jsxs("div", { children: [
28
+ label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "block text-sm font-medium text-tone-600 mb-1", children: label }),
29
+ /* @__PURE__ */ jsx(
30
+ "textarea",
31
+ {
32
+ id: inputId,
33
+ "aria-invalid": error ? true : void 0,
34
+ "aria-describedby": error ? errorId : void 0,
35
+ className: `${baseInputClasses} resize-none ${error ? "border-red-400" : ""} ${className}`,
36
+ ...props
37
+ }
38
+ ),
39
+ error && /* @__PURE__ */ jsx("p", { id: errorId, className: "text-red-500 text-xs mt-1", children: error })
40
+ ] });
41
+ }
42
+ function AdminSelect({ label, error, children, className = "", id, ...props }) {
43
+ const generatedId = useId();
44
+ const inputId = id || generatedId;
45
+ const errorId = `${inputId}-error`;
46
+ return /* @__PURE__ */ jsxs("div", { children: [
47
+ label && /* @__PURE__ */ jsx("label", { htmlFor: inputId, className: "block text-sm font-medium text-tone-600 mb-1", children: label }),
48
+ /* @__PURE__ */ jsx(
49
+ "select",
50
+ {
51
+ id: inputId,
52
+ "aria-invalid": error ? true : void 0,
53
+ "aria-describedby": error ? errorId : void 0,
54
+ className: `${baseInputClasses} ${error ? "border-red-400" : ""} ${className}`,
55
+ ...props,
56
+ children
57
+ }
58
+ ),
59
+ error && /* @__PURE__ */ jsx("p", { id: errorId, className: "text-red-500 text-xs mt-1", children: error })
60
+ ] });
61
+ }
62
+ export {
63
+ AdminInput,
64
+ AdminSelect,
65
+ AdminTextarea
66
+ };
@@ -0,0 +1,26 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ function AdminListPanel({
3
+ children,
4
+ header,
5
+ footer,
6
+ plain = false,
7
+ className = "",
8
+ bodyClassName = ""
9
+ }) {
10
+ const chrome = plain ? "" : "bg-white rounded-2xl shadow-sm border border-tone-100 overflow-hidden";
11
+ return /* @__PURE__ */ jsxs("div", { className: `flex flex-col fit:flex-1 fit:min-h-0 ${chrome} ${className}`, children: [
12
+ header && /* @__PURE__ */ jsx("div", { className: "shrink-0", children: header }),
13
+ /* @__PURE__ */ jsx(
14
+ "div",
15
+ {
16
+ className: `fit:flex-1 fit:min-h-0 fit:overflow-y-auto overflow-x-auto overscroll-contain ${plain ? "fit:p-1 fit:-m-1" : ""} ${bodyClassName}`,
17
+ "data-scroll-region": true,
18
+ children
19
+ }
20
+ ),
21
+ footer && /* @__PURE__ */ jsx("div", { className: `shrink-0 ${plain ? "pt-3" : "border-t border-tone-100"}`, children: footer })
22
+ ] });
23
+ }
24
+ export {
25
+ AdminListPanel as default
26
+ };
@@ -0,0 +1,23 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Overlay } from "@okjt/ui";
3
+ import { X } from "lucide-react";
4
+ function AdminModal({ isOpen, onClose, title, children, size = "md" }) {
5
+ if (!isOpen) return null;
6
+ const sizeClasses = {
7
+ sm: "max-w-sm",
8
+ md: "max-w-md",
9
+ lg: "max-w-lg",
10
+ xl: "max-w-xl",
11
+ "2xl": "max-w-2xl"
12
+ };
13
+ return /* @__PURE__ */ jsx(Overlay, { onClose, closeOnBackdrop: false, children: /* @__PURE__ */ jsxs("div", { className: `bg-white rounded-2xl w-full ${sizeClasses[size]} p-6 shadow-xl animate-in zoom-in duration-200`, children: [
14
+ /* @__PURE__ */ jsxs("div", { className: "flex justify-between items-center mb-6", children: [
15
+ /* @__PURE__ */ jsx("h2", { className: "text-xl font-medium text-body", children: title }),
16
+ /* @__PURE__ */ jsx("button", { onClick: onClose, "aria-label": "Close dialog", className: "p-1 hover:bg-tone-100 rounded-lg transition-colors", children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5 text-tone-400" }) })
17
+ ] }),
18
+ children
19
+ ] }) });
20
+ }
21
+ export {
22
+ AdminModal as default
23
+ };