@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.
Files changed (53) hide show
  1. package/README.md +149 -2
  2. package/dist/AcceptInvitePage.js +86 -0
  3. package/dist/AccountMenu.js +73 -0
  4. package/dist/ActivityPanel.js +48 -0
  5. package/dist/AdminBulkActions.js +109 -0
  6. package/dist/AdminCard.js +7 -0
  7. package/dist/AdminChromeContext.js +16 -0
  8. package/dist/AdminFloatingToolbar.js +147 -0
  9. package/dist/AdminInput.js +66 -0
  10. package/dist/AdminListPanel.js +26 -0
  11. package/dist/AdminModal.js +23 -0
  12. package/dist/AdminPageHero.js +101 -0
  13. package/dist/AdminPageLayout.js +54 -0
  14. package/dist/AdminPagination.js +92 -0
  15. package/dist/AdminSidePanel.js +479 -0
  16. package/dist/AdminSummaryCards.js +51 -0
  17. package/dist/AdminToolbarFilters.js +168 -0
  18. package/dist/AdminToolbarSearch.js +61 -0
  19. package/dist/AdminTutorial.js +221 -0
  20. package/dist/AuthContext.js +194 -0
  21. package/dist/AuthLayout.js +94 -0
  22. package/dist/CollaborationContext.js +84 -0
  23. package/dist/CollaboratorAvatars.js +36 -0
  24. package/dist/DashboardHeader.js +140 -0
  25. package/dist/DashboardProvider.js +45 -0
  26. package/dist/DashboardShell.js +93 -0
  27. package/dist/DashboardSidebar.js +97 -0
  28. package/dist/DeleteButton.js +21 -0
  29. package/dist/EditableFieldset.js +9 -0
  30. package/dist/EmptyState.js +22 -0
  31. package/dist/GoogleButton.js +22 -0
  32. package/dist/GoogleCallbackPage.js +81 -0
  33. package/dist/NotificationsBell.js +149 -0
  34. package/dist/QueryError.js +23 -0
  35. package/dist/SearchContext.js +16 -0
  36. package/dist/ShareModal.js +228 -0
  37. package/dist/SignInPage.js +198 -0
  38. package/dist/StatCard.js +33 -0
  39. package/dist/ToggleButton.js +26 -0
  40. package/dist/TwoFactorForm.js +26 -0
  41. package/dist/UnsavedChangesStatus.js +13 -0
  42. package/dist/VerifyEmailPage.js +42 -0
  43. package/dist/VersionHistoryDrawer.js +172 -0
  44. package/dist/index.js +125 -0
  45. package/dist/modules.js +32 -0
  46. package/dist/passkeys.js +84 -0
  47. package/dist/useActivityPanel.js +34 -0
  48. package/dist/useAdminAction.js +77 -0
  49. package/dist/useCrudHandlers.js +54 -0
  50. package/dist/useFilteredItems.js +19 -0
  51. package/dist/useSavedViews.js +30 -0
  52. package/dist/useUnsavedChangesGuard.js +41 -0
  53. package/package.json +40 -4
@@ -0,0 +1,479 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { AnimatePresence, Reorder, motion, useDragControls } from "framer-motion";
4
+ import { Check, CheckSquare, ChevronUp, GripVertical, ListChecks, PanelRightClose, PanelRightOpen, X } from "lucide-react";
5
+ import { Button, Overlay, buttonClass, usePermissions, useVisibleActions } from "@okjt/ui";
6
+ function Badge({ item }) {
7
+ if (item.badge > 0) {
8
+ return /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 min-w-[1.25rem] h-5 px-1.5 rounded-full bg-accent/15 text-accent-dark text-[11px] font-semibold flex items-center justify-center", children: item.badge > 99 ? "99+" : item.badge });
9
+ }
10
+ if (item.dot) {
11
+ return /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 w-2 h-2 rounded-full bg-amber-500", "aria-label": "Unsaved changes" });
12
+ }
13
+ if (item.count != null) {
14
+ return /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 text-xs tabular-nums text-tone-400", children: item.count });
15
+ }
16
+ return null;
17
+ }
18
+ function SidePanelNav({ panel, onPicked, selection, manage = {} }) {
19
+ const { items = [], activeId, onChange, navVariant = "list" } = panel;
20
+ if (!items.length) return null;
21
+ const pick = (id) => {
22
+ onChange?.(id);
23
+ onPicked?.(id);
24
+ };
25
+ if (navVariant === "grid") {
26
+ return /* @__PURE__ */ jsx("div", { className: `grid gap-1 ${items.length <= 5 ? "grid-cols-5" : "grid-cols-4"}`, role: "tablist", "aria-label": panel.title, children: items.map((item) => {
27
+ const Icon = item.icon;
28
+ const active = item.id === activeId;
29
+ return /* @__PURE__ */ jsxs(
30
+ "button",
31
+ {
32
+ type: "button",
33
+ role: "tab",
34
+ "aria-selected": active,
35
+ onClick: () => pick(item.id),
36
+ className: `relative flex flex-col items-center gap-1 py-2 px-0.5 rounded-xl text-[10px] font-semibold uppercase tracking-wide transition-colors border ${active ? "bg-accent/10 border-accent/30 text-accent-dark" : "border-transparent text-tone-500 hover:bg-tone-50 hover:text-tone-700"}`,
37
+ children: [
38
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4", "aria-hidden": "true" }),
39
+ item.label,
40
+ (item.badge > 0 || item.dot) && /* @__PURE__ */ jsx("span", { className: "absolute top-1 right-1.5 w-1.5 h-1.5 rounded-full bg-accent" })
41
+ ]
42
+ },
43
+ item.id
44
+ );
45
+ }) });
46
+ }
47
+ const listItems = items.map((item, index) => ({
48
+ item,
49
+ groupStart: item.group && item.group !== items[index - 1]?.group ? index > 0 ? "later" : "first" : null
50
+ }));
51
+ const fixed = listItems.filter(({ item }) => item.fixed);
52
+ const movable = listItems.filter(({ item }) => !item.fixed);
53
+ const selecting = !!selection?.selecting;
54
+ const canReorder = !!manage.canReorder && !selecting && movable.length > 1;
55
+ const row = ({ item, groupStart }, leading) => /* @__PURE__ */ jsxs(Fragment, { children: [
56
+ groupStart && /* @__PURE__ */ jsx("p", { className: `px-2 pb-1 text-[10px] font-bold uppercase tracking-[0.16em] text-tone-400 ${groupStart === "later" ? "pt-3" : ""}`, children: item.group }),
57
+ /* @__PURE__ */ jsx(
58
+ ItemRow,
59
+ {
60
+ item,
61
+ active: item.id === activeId,
62
+ leading,
63
+ selecting: selecting && !item.fixed,
64
+ checked: selecting && selection.isSelected(item.id),
65
+ onClick: () => selecting && !item.fixed ? selection.toggle(item.id) : pick(item.id)
66
+ }
67
+ )
68
+ ] });
69
+ return /* @__PURE__ */ jsxs("nav", { "aria-label": panel.title, children: [
70
+ /* @__PURE__ */ jsx("ul", { className: "space-y-0.5", children: fixed.map((entry) => /* @__PURE__ */ jsx("li", { className: canReorder ? "pl-6" : "", children: row(entry) }, entry.item.id)) }),
71
+ canReorder ? /* @__PURE__ */ jsx(ReorderableList, { entries: movable, onReorder: panel.onReorder, renderRow: row }) : /* @__PURE__ */ jsx("ul", { className: "space-y-0.5", children: movable.map((entry) => /* @__PURE__ */ jsx("li", { children: row(entry) }, entry.item.id)) })
72
+ ] });
73
+ }
74
+ function ItemRow({ item, active, leading, selecting, checked, onClick }) {
75
+ const Icon = item.icon;
76
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
77
+ leading,
78
+ /* @__PURE__ */ jsxs(
79
+ "button",
80
+ {
81
+ type: "button",
82
+ onClick,
83
+ "aria-current": !selecting && active ? "true" : void 0,
84
+ "aria-pressed": selecting ? checked : void 0,
85
+ className: `flex-1 min-w-0 text-left flex gap-3 p-2 rounded-xl transition-colors border ${selecting && checked ? "bg-accent/[0.07] border-accent/30" : !selecting && active ? "bg-accent/[0.07] border-accent/20" : "border-transparent hover:bg-tone-50"}`,
86
+ children: [
87
+ selecting && /* @__PURE__ */ jsx("span", { className: `mt-0.5 w-4 h-4 rounded border flex items-center justify-center shrink-0 ${checked ? "bg-accent border-accent text-white" : "border-tone-300 bg-white"}`, "aria-hidden": "true", children: checked && /* @__PURE__ */ jsx(Check, { className: "w-3 h-3", strokeWidth: 3 }) }),
88
+ Icon && /* @__PURE__ */ jsx("span", { className: `w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${active ? "bg-white shadow-sm" : "bg-tone-50"}`, children: /* @__PURE__ */ jsx(Icon, { className: `w-4 h-4 ${active ? "text-accent" : "text-tone-500"}`, "aria-hidden": "true" }) }),
89
+ /* @__PURE__ */ jsxs("span", { className: "min-w-0 flex-1", children: [
90
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
91
+ /* @__PURE__ */ jsx("span", { className: `text-sm font-medium truncate ${!selecting && active ? "text-accent-dark" : item.muted ? "text-tone-400" : "text-tone-800"}`, children: item.label }),
92
+ /* @__PURE__ */ jsx(Badge, { item })
93
+ ] }),
94
+ item.description && /* @__PURE__ */ jsx("span", { className: "block text-xs text-tone-500 leading-snug mt-0.5", children: item.description })
95
+ ] })
96
+ ]
97
+ }
98
+ )
99
+ ] });
100
+ }
101
+ function ReorderableList({ entries, onReorder, renderRow }) {
102
+ const ids = entries.map(({ item }) => item.id);
103
+ const idsKey = ids.join("|");
104
+ const [order, setOrderState] = useState(ids);
105
+ const orderRef = useRef(ids);
106
+ const setOrder = (next) => {
107
+ orderRef.current = next;
108
+ setOrderState(next);
109
+ };
110
+ useEffect(() => setOrder(ids), [idsKey]);
111
+ const commit = (next) => {
112
+ if (next.join("|") !== idsKey) onReorder(next);
113
+ };
114
+ const moveBy = (id, step) => {
115
+ const from = orderRef.current.indexOf(id);
116
+ const to = from + step;
117
+ if (from < 0 || to < 0 || to >= orderRef.current.length) return;
118
+ const next = [...orderRef.current];
119
+ next.splice(to, 0, next.splice(from, 1)[0]);
120
+ setOrder(next);
121
+ commit(next);
122
+ };
123
+ const byId = Object.fromEntries(entries.map((entry) => [entry.item.id, entry]));
124
+ return /* @__PURE__ */ jsx(Reorder.Group, { as: "ul", axis: "y", values: order, onReorder: setOrder, className: "space-y-0.5", children: order.filter((id) => byId[id]).map((id) => /* @__PURE__ */ jsx(DraggableRow, { entry: byId[id], onDrop: () => commit(orderRef.current), onMove: (step) => moveBy(id, step), renderRow }, id)) });
125
+ }
126
+ function DraggableRow({ entry, onDrop, onMove, renderRow }) {
127
+ const controls = useDragControls();
128
+ const handle = /* @__PURE__ */ jsx(
129
+ "button",
130
+ {
131
+ type: "button",
132
+ "aria-label": `Reorder ${entry.item.label}`,
133
+ title: "Drag to reorder (or use the arrow keys)",
134
+ onPointerDown: (e) => {
135
+ e.preventDefault();
136
+ controls.start(e);
137
+ },
138
+ onKeyDown: (e) => {
139
+ if (e.key === "ArrowUp" || e.key === "ArrowDown") {
140
+ e.preventDefault();
141
+ onMove(e.key === "ArrowUp" ? -1 : 1);
142
+ }
143
+ },
144
+ className: "shrink-0 w-5 py-2 flex justify-center rounded-md text-tone-300 hover:text-tone-500 focus-visible:text-accent cursor-grab active:cursor-grabbing touch-none",
145
+ children: /* @__PURE__ */ jsx(GripVertical, { className: "w-4 h-4", "aria-hidden": "true" })
146
+ }
147
+ );
148
+ return /* @__PURE__ */ jsx(
149
+ Reorder.Item,
150
+ {
151
+ value: entry.item.id,
152
+ dragListener: false,
153
+ dragControls: controls,
154
+ onDragEnd: onDrop,
155
+ className: "relative bg-white rounded-xl",
156
+ whileDrag: { scale: 1.02, boxShadow: "0 8px 24px rgba(0,0,0,0.08)", zIndex: 1 },
157
+ children: renderRow(entry, handle)
158
+ }
159
+ );
160
+ }
161
+ function usePanelManage(panel) {
162
+ const { canEdit } = usePermissions();
163
+ const bulkActions = useVisibleActions(panel.bulkActions || []);
164
+ const flatList = panel.items?.length > 0 && panel.navVariant !== "grid" && !panel.items.some((item) => item.group);
165
+ return {
166
+ canReorder: canEdit && flatList && !!panel.onReorder,
167
+ bulkActions: flatList ? bulkActions : []
168
+ };
169
+ }
170
+ function useSelection(panel) {
171
+ const [selecting, setSelecting] = useState(false);
172
+ const [picked, setPicked] = useState([]);
173
+ const selectable = (panel.items || []).filter((item) => !item.fixed).map((item) => item.id);
174
+ const selected = picked.filter((id) => selectable.includes(id));
175
+ const stop = () => {
176
+ setSelecting(false);
177
+ setPicked([]);
178
+ };
179
+ return {
180
+ selecting,
181
+ selected,
182
+ selectable,
183
+ start: () => setSelecting(true),
184
+ stop,
185
+ isSelected: (id) => selected.includes(id),
186
+ toggle: (id) => setPicked((ids) => ids.includes(id) ? ids.filter((x) => x !== id) : [...ids, id]),
187
+ toggleAll: () => setPicked(selected.length === selectable.length ? [] : selectable)
188
+ };
189
+ }
190
+ function SelectToggle({ selection }) {
191
+ if (selection.selecting) return null;
192
+ return /* @__PURE__ */ jsxs(
193
+ "button",
194
+ {
195
+ type: "button",
196
+ onClick: selection.start,
197
+ title: "Select several",
198
+ className: "px-2 py-1 -my-1 rounded-lg text-xs font-medium text-tone-500 hover:bg-tone-100 hover:text-accent flex items-center gap-1",
199
+ children: [
200
+ /* @__PURE__ */ jsx(CheckSquare, { className: "w-3.5 h-3.5", "aria-hidden": "true" }),
201
+ " Select"
202
+ ]
203
+ }
204
+ );
205
+ }
206
+ function BulkBar({ selection, actions }) {
207
+ const { selected, selectable } = selection;
208
+ const run = async (entry) => {
209
+ const result = entry.action ? await entry.action.run(selected) : await entry.onClick?.(selected);
210
+ if (result !== void 0) selection.stop();
211
+ };
212
+ return /* @__PURE__ */ jsxs("div", { className: "shrink-0 p-3 border-t border-tone-100 bg-accent/[0.04] space-y-2", role: "region", "aria-label": "Selected items", children: [
213
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-xs", children: [
214
+ /* @__PURE__ */ jsxs("span", { className: "font-medium text-tone-700", "aria-live": "polite", children: [
215
+ selected.length,
216
+ " selected"
217
+ ] }),
218
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: selection.toggleAll, className: "text-accent-dark hover:underline", children: selected.length === selectable.length && selectable.length > 0 ? "Select none" : "Select all" }),
219
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: selection.stop, className: "ml-auto px-2 py-1 rounded-lg font-medium text-tone-600 hover:bg-white", children: "Done" })
220
+ ] }),
221
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: actions.map((entry) => /* @__PURE__ */ jsx(
222
+ Button,
223
+ {
224
+ size: "sm",
225
+ variant: entry.variant || "primary",
226
+ icon: entry.icon,
227
+ disabled: !selected.length || entry.disabled,
228
+ onClick: () => run(entry),
229
+ children: entry.label
230
+ },
231
+ entry.id
232
+ )) })
233
+ ] });
234
+ }
235
+ function PanelHeader({ panel, children }) {
236
+ const Icon = panel.icon;
237
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2.5", children: [
238
+ Icon && /* @__PURE__ */ jsx(Icon, { className: "w-5 h-5 text-accent mt-0.5 shrink-0", "aria-hidden": "true" }),
239
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
240
+ /* @__PURE__ */ jsx("h2", { className: "text-base font-medium text-tone-800 leading-tight", children: panel.title }),
241
+ panel.subtitle && /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-500 mt-0.5", children: panel.subtitle })
242
+ ] }),
243
+ children
244
+ ] });
245
+ }
246
+ const storageKey = (panel) => `admin.sidePanel.${panel.id || panel.title}`;
247
+ function readCollapsed(panel) {
248
+ try {
249
+ const saved = localStorage.getItem(storageKey(panel));
250
+ if (saved) return saved === "collapsed";
251
+ } catch {
252
+ }
253
+ return !!panel.defaultCollapsed;
254
+ }
255
+ function SidePanelRail({ panel, onExpand }) {
256
+ const Icon = panel.icon;
257
+ return /* @__PURE__ */ jsxs(
258
+ "aside",
259
+ {
260
+ "aria-label": panel.title,
261
+ "data-side-panel": "collapsed",
262
+ className: "hidden lg:flex flex-col items-center gap-1.5 w-12 shrink-0 py-2 lg:sticky lg:top-20 self-start lg:max-h-[calc(100dvh-6.5rem)] overflow-y-auto scrollbar-hide bg-white rounded-2xl shadow-sm border border-tone-100",
263
+ children: [
264
+ /* @__PURE__ */ jsx(
265
+ "button",
266
+ {
267
+ type: "button",
268
+ onClick: onExpand,
269
+ "aria-label": `Show ${panel.title}`,
270
+ title: `Show ${panel.title}`,
271
+ className: "p-2 rounded-lg text-tone-500 hover:bg-tone-100 hover:text-accent",
272
+ children: /* @__PURE__ */ jsx(PanelRightOpen, { className: "w-4 h-4" })
273
+ }
274
+ ),
275
+ Icon && !panel.items?.length && /* @__PURE__ */ jsx(Icon, { className: "w-4 h-4 text-accent my-1", "aria-hidden": "true" }),
276
+ panel.items?.map((item) => {
277
+ const ItemIcon = item.icon;
278
+ const active = item.id === panel.activeId;
279
+ return /* @__PURE__ */ jsxs(
280
+ "button",
281
+ {
282
+ type: "button",
283
+ onClick: () => panel.onChange?.(item.id),
284
+ "aria-label": item.label,
285
+ title: item.label,
286
+ "aria-current": active ? "true" : void 0,
287
+ className: `relative p-2 rounded-lg ${active ? "bg-accent/10 text-accent" : "text-tone-500 hover:bg-tone-100"}`,
288
+ children: [
289
+ ItemIcon ? /* @__PURE__ */ jsx(ItemIcon, { className: "w-4 h-4" }) : item.label.slice(0, 2),
290
+ (item.badge > 0 || item.dot) && /* @__PURE__ */ jsx("span", { className: "absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent" })
291
+ ]
292
+ },
293
+ item.id
294
+ );
295
+ }),
296
+ panel.rail
297
+ ]
298
+ }
299
+ );
300
+ }
301
+ function SidePanelAside({ panel }) {
302
+ const [collapsed, setCollapsed] = useState(() => readCollapsed(panel));
303
+ const manage = usePanelManage(panel);
304
+ const selection = useSelection(panel);
305
+ const toggle = (next) => {
306
+ setCollapsed(next);
307
+ try {
308
+ localStorage.setItem(storageKey(panel), next ? "collapsed" : "expanded");
309
+ } catch {
310
+ }
311
+ };
312
+ if (collapsed) return /* @__PURE__ */ jsx(SidePanelRail, { panel, onExpand: () => toggle(false) });
313
+ const hasListNav = panel.items?.length > 0 && panel.navVariant !== "grid";
314
+ return /* @__PURE__ */ jsxs(
315
+ "aside",
316
+ {
317
+ "aria-label": panel.title,
318
+ "data-side-panel": true,
319
+ className: "hidden lg:flex flex-col w-80 xl:w-[22rem] shrink-0 lg:sticky lg:top-20 lg:max-h-[calc(100dvh-6.5rem)] fit:max-h-full self-start fit:self-stretch bg-white rounded-2xl shadow-sm border border-tone-100 overflow-hidden",
320
+ children: [
321
+ /* @__PURE__ */ jsxs("div", { className: "shrink-0 p-4 pb-3 space-y-3 border-b border-tone-100", children: [
322
+ /* @__PURE__ */ jsxs(PanelHeader, { panel, children: [
323
+ manage.bulkActions.length > 0 && /* @__PURE__ */ jsx(SelectToggle, { selection }),
324
+ /* @__PURE__ */ jsx(
325
+ "button",
326
+ {
327
+ type: "button",
328
+ onClick: () => toggle(true),
329
+ "aria-label": `Hide ${panel.title}`,
330
+ title: "Collapse panel",
331
+ className: "p-1.5 -m-1 rounded-lg text-tone-400 hover:bg-tone-100 hover:text-tone-600",
332
+ children: /* @__PURE__ */ jsx(PanelRightClose, { className: "w-4 h-4" })
333
+ }
334
+ )
335
+ ] }),
336
+ panel.navVariant === "grid" && /* @__PURE__ */ jsx(SidePanelNav, { panel })
337
+ ] }),
338
+ (hasListNav || panel.content) && /* @__PURE__ */ jsxs("div", { className: "flex-1 min-h-0 overflow-y-auto overscroll-contain p-3 space-y-4", children: [
339
+ hasListNav && /* @__PURE__ */ jsx(SidePanelNav, { panel, manage, selection }),
340
+ panel.content && /* @__PURE__ */ jsx("div", { className: "px-1", children: panel.content })
341
+ ] }),
342
+ selection.selecting && /* @__PURE__ */ jsx(BulkBar, { selection, actions: manage.bulkActions }),
343
+ panel.footer && !selection.selecting && /* @__PURE__ */ jsx("div", { className: "shrink-0 p-4 pt-3 border-t border-tone-100 bg-accent/[0.03]", children: panel.footer })
344
+ ]
345
+ }
346
+ );
347
+ }
348
+ function ChipRow({ panel, onPicked, className = "-mx-4 px-4" }) {
349
+ const rowRef = useRef(null);
350
+ const { items = [], activeId, onChange } = panel;
351
+ useEffect(() => {
352
+ const el = rowRef.current?.querySelector('[aria-current="true"]');
353
+ el?.scrollIntoView?.({ block: "nearest", inline: "center", behavior: "smooth" });
354
+ }, [activeId]);
355
+ return /* @__PURE__ */ jsx("div", { ref: rowRef, className: `flex gap-2 overflow-x-auto scrollbar-hide py-0.5 snap-x ${className}`, "aria-label": panel.title, role: "navigation", children: items.map((item) => {
356
+ const Icon = item.icon;
357
+ const active = item.id === activeId;
358
+ return /* @__PURE__ */ jsxs(
359
+ "button",
360
+ {
361
+ type: "button",
362
+ "aria-current": active ? "true" : void 0,
363
+ onClick: () => {
364
+ onChange?.(item.id);
365
+ onPicked?.(item.id);
366
+ },
367
+ className: `${buttonClass({ variant: active ? "secondary" : "primary", size: "sm" })} snap-start shrink-0 !rounded-full relative`,
368
+ children: [
369
+ Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": "true" }),
370
+ /* @__PURE__ */ jsx("span", { className: `max-w-[14rem] truncate ${item.muted && !active ? "opacity-60" : ""}`, children: item.label }),
371
+ item.count != null && /* @__PURE__ */ jsx("span", { className: `tabular-nums ${active ? "opacity-80" : "opacity-60"}`, children: item.count }),
372
+ (item.badge > 0 || item.dot) && /* @__PURE__ */ jsx("span", { className: `w-1.5 h-1.5 rounded-full ${active ? "bg-white" : "bg-accent"}`, "aria-hidden": "true" })
373
+ ]
374
+ },
375
+ item.id
376
+ );
377
+ }) });
378
+ }
379
+ function BottomSheet({ panel, manage, onClose }) {
380
+ const dragControls = useDragControls();
381
+ const selection = useSelection(panel);
382
+ return /* @__PURE__ */ jsx(Overlay, { onClose, className: "flex items-end justify-center", backdropClassName: "bg-black/25", zIndex: 60, children: /* @__PURE__ */ jsxs(
383
+ motion.div,
384
+ {
385
+ role: "dialog",
386
+ "aria-modal": "true",
387
+ "aria-label": panel.title,
388
+ initial: { y: "100%" },
389
+ animate: { y: 0 },
390
+ exit: { y: "100%" },
391
+ transition: { type: "spring", damping: 32, stiffness: 320 },
392
+ drag: "y",
393
+ dragListener: false,
394
+ dragControls,
395
+ dragConstraints: { top: 0, bottom: 0 },
396
+ dragElastic: { top: 0, bottom: 0.6 },
397
+ onDragEnd: (_, info) => {
398
+ if (info.offset.y > 90 || info.velocity.y > 500) onClose();
399
+ },
400
+ className: "w-full max-h-[78dvh] bg-white rounded-t-3xl shadow-2xl flex flex-col pb-[env(safe-area-inset-bottom)]",
401
+ onClick: (e) => e.stopPropagation(),
402
+ children: [
403
+ /* @__PURE__ */ jsxs(
404
+ "div",
405
+ {
406
+ className: "shrink-0 pt-2 pb-3 px-4 space-y-3 border-b border-tone-100 cursor-grab active:cursor-grabbing touch-none",
407
+ onPointerDown: (e) => dragControls.start(e),
408
+ children: [
409
+ /* @__PURE__ */ jsx("div", { className: "mx-auto w-10 h-1.5 rounded-full bg-tone-200", "aria-hidden": "true" }),
410
+ /* @__PURE__ */ jsxs(PanelHeader, { panel, children: [
411
+ manage && manage.bulkActions.length > 0 && /* @__PURE__ */ jsx(SelectToggle, { selection }),
412
+ /* @__PURE__ */ jsx("button", { type: "button", onClick: onClose, "aria-label": "Close panel", className: "p-1.5 -m-1 rounded-lg text-tone-500 hover:bg-tone-100", children: /* @__PURE__ */ jsx(X, { className: "w-5 h-5" }) })
413
+ ] }),
414
+ !manage && panel.items?.length > 0 && /* @__PURE__ */ jsx(ChipRow, { panel })
415
+ ]
416
+ }
417
+ ),
418
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-h-0 overflow-y-auto overscroll-contain p-4 space-y-4", children: [
419
+ manage && /* @__PURE__ */ jsx(SidePanelNav, { panel, manage, selection, onPicked: onClose }),
420
+ panel.content
421
+ ] }),
422
+ manage && selection.selecting && /* @__PURE__ */ jsx(BulkBar, { selection, actions: manage.bulkActions })
423
+ ]
424
+ }
425
+ ) });
426
+ }
427
+ function SidePanelMobileBar({ panel }) {
428
+ const [sheet, setSheet] = useState(null);
429
+ const manage = usePanelManage(panel);
430
+ const hasContent = !!panel.content;
431
+ const hasItems = panel.items?.length > 0;
432
+ const manageable = manage.canReorder || manage.bulkActions.length > 0;
433
+ const Icon = panel.icon;
434
+ return /* @__PURE__ */ jsxs("div", { className: "lg:hidden sticky top-16 z-20 -mx-4 sm:-mx-6 px-4 sm:px-6 py-2 bg-paper/95 backdrop-blur border-b border-accent/10", children: [
435
+ hasItems && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
436
+ /* @__PURE__ */ jsx(
437
+ ChipRow,
438
+ {
439
+ panel,
440
+ className: manageable ? "flex-1 min-w-0 -ml-4 pl-4 pr-1" : "-mx-4 px-4 flex-1 min-w-0",
441
+ onPicked: hasContent ? () => setSheet("content") : void 0
442
+ }
443
+ ),
444
+ manageable && /* @__PURE__ */ jsx(
445
+ Button,
446
+ {
447
+ size: "icon-sm",
448
+ icon: ListChecks,
449
+ "aria-label": `Arrange or select ${panel.title.toLowerCase()}`,
450
+ title: "Arrange / select",
451
+ "aria-haspopup": "dialog",
452
+ onClick: () => setSheet("manage")
453
+ }
454
+ )
455
+ ] }),
456
+ hasContent && !hasItems && /* @__PURE__ */ jsxs(
457
+ "button",
458
+ {
459
+ type: "button",
460
+ onClick: () => setSheet("content"),
461
+ className: `${buttonClass({ variant: "primary", size: "sm", fullWidth: true })} !justify-between`,
462
+ "aria-haspopup": "dialog",
463
+ children: [
464
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 min-w-0", children: [
465
+ Icon && /* @__PURE__ */ jsx(Icon, { "aria-hidden": "true" }),
466
+ /* @__PURE__ */ jsx("span", { className: "truncate", children: panel.sheetLabel || panel.title })
467
+ ] }),
468
+ /* @__PURE__ */ jsx(ChevronUp, { "aria-hidden": "true" })
469
+ ]
470
+ }
471
+ ),
472
+ /* @__PURE__ */ jsx(AnimatePresence, { children: sheet && (hasContent || sheet === "manage") && /* @__PURE__ */ jsx(BottomSheet, { panel, manage: sheet === "manage" ? manage : null, onClose: () => setSheet(null) }) })
473
+ ] });
474
+ }
475
+ export {
476
+ SidePanelAside,
477
+ SidePanelMobileBar,
478
+ SidePanelNav
479
+ };
@@ -0,0 +1,51 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { motion } from "framer-motion";
3
+ const gridColumns = {
4
+ 1: "md:grid-cols-1",
5
+ 2: "md:grid-cols-2",
6
+ 3: "md:grid-cols-3",
7
+ 4: "md:grid-cols-4",
8
+ 5: "md:grid-cols-3 xl:grid-cols-5",
9
+ 6: "md:grid-cols-3 xl:grid-cols-6"
10
+ };
11
+ function AdminSummaryCards({ cards = [], columns = 4 }) {
12
+ if (!cards.length) return null;
13
+ const gridCols = gridColumns[columns] || gridColumns[4];
14
+ const iconVisibility = columns >= 5 ? "flex xl:hidden 2xl:flex" : "flex";
15
+ return /* @__PURE__ */ jsx("div", { className: `grid grid-cols-2 ${gridCols} gap-3 lg:gap-4`, children: cards.map((stat, index) => {
16
+ const Icon = stat.icon;
17
+ const Tag = stat.onClick ? motion.button : motion.div;
18
+ return /* @__PURE__ */ jsxs(
19
+ Tag,
20
+ {
21
+ type: stat.onClick ? "button" : void 0,
22
+ onClick: stat.onClick,
23
+ initial: { opacity: 0, y: 12 },
24
+ animate: { opacity: 1, y: 0 },
25
+ transition: { delay: index * 0.05, duration: 0.2 },
26
+ "aria-pressed": stat.onClick ? !!stat.active : void 0,
27
+ className: `px-3.5 py-3 rounded-2xl bg-white flex items-center gap-3 text-left min-w-0 transition-shadow ${stat.onClick ? "cursor-pointer hover:ring-2 hover:ring-accent/20" : ""} ${stat.active ? "ring-2 ring-accent/50" : ""}`,
28
+ style: { boxShadow: "0 4px 20px rgba(166, 123, 91, 0.08)" },
29
+ children: [
30
+ /* @__PURE__ */ jsx(
31
+ "div",
32
+ {
33
+ className: `w-9 h-9 rounded-xl items-center justify-center shrink-0 ${iconVisibility}`,
34
+ style: { background: `${stat.color}15` },
35
+ children: Icon && /* @__PURE__ */ jsx(Icon, { className: "w-5 h-5", style: { color: stat.color } })
36
+ }
37
+ ),
38
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
39
+ /* @__PURE__ */ jsx("p", { className: "text-xl font-semibold leading-tight text-body", children: stat.value }),
40
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted leading-snug line-clamp-2", children: stat.label }),
41
+ stat.hint && /* @__PURE__ */ jsx("p", { className: "text-xs text-tone-400 truncate", title: stat.hint, children: stat.hint })
42
+ ] })
43
+ ]
44
+ },
45
+ stat.label
46
+ );
47
+ }) });
48
+ }
49
+ export {
50
+ AdminSummaryCards as default
51
+ };