@re-venue/ui-core-react 0.1.2 → 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 (48) hide show
  1. package/dist/index.d.ts +416 -0
  2. package/dist/ui-core-react.css +1 -1
  3. package/dist/ui-core-react.js +10072 -178
  4. package/dist/ui-core-react.umd.cjs +47 -1
  5. package/package.json +26 -1
  6. package/src/components/AppShell.tsx +14 -0
  7. package/src/components/common/ConfirmationModal.tsx +65 -0
  8. package/src/components/common/Container.tsx +15 -0
  9. package/src/components/common/DangerZoneSection.tsx +62 -0
  10. package/src/components/common/DetailPanel.tsx +115 -0
  11. package/src/components/common/DetailSheet.tsx +98 -0
  12. package/src/components/common/EditableTitle.tsx +119 -0
  13. package/src/components/common/EmptyState.tsx +36 -0
  14. package/src/components/common/FormModal.tsx +64 -0
  15. package/src/components/common/NavigationListItem.tsx +24 -0
  16. package/src/components/common/PanelEmptyState.tsx +17 -0
  17. package/src/components/ui/alert-dialog.tsx +104 -0
  18. package/src/components/ui/avatar.tsx +38 -0
  19. package/src/components/ui/badge.tsx +31 -0
  20. package/src/components/ui/button.tsx +47 -0
  21. package/src/components/ui/card.tsx +43 -0
  22. package/src/components/ui/checkbox.tsx +26 -0
  23. package/src/components/ui/dialog.tsx +95 -0
  24. package/src/components/ui/input.tsx +22 -0
  25. package/src/components/ui/label.tsx +17 -0
  26. package/src/components/ui/multi-select.tsx +109 -0
  27. package/src/components/ui/popover.tsx +29 -0
  28. package/src/components/ui/progress.tsx +23 -0
  29. package/src/components/ui/scroll-area.tsx +38 -0
  30. package/src/components/ui/select.tsx +143 -0
  31. package/src/components/ui/separator.tsx +20 -0
  32. package/src/components/ui/sheet.tsx +107 -0
  33. package/src/components/ui/skeleton.tsx +7 -0
  34. package/src/components/ui/sonner.tsx +27 -0
  35. package/src/components/ui/switch.tsx +27 -0
  36. package/src/components/ui/table.tsx +72 -0
  37. package/src/components/ui/toast.tsx +111 -0
  38. package/src/components/ui/toaster.tsx +24 -0
  39. package/src/components/ui/tooltip.tsx +28 -0
  40. package/src/components/ui/use-toast.ts +3 -0
  41. package/src/hooks/use-toast.ts +186 -0
  42. package/src/hooks/useDetailPanel.ts +21 -0
  43. package/src/hooks/useDetailSheetControls.ts +16 -0
  44. package/src/hooks/useTheme.ts +42 -0
  45. package/src/index.ts +49 -0
  46. package/src/lib/utils.ts +6 -0
  47. package/src/styles/shell.css +3 -0
  48. package/src/styles/utilities.css +1 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@re-venue/ui-core-react",
3
- "version": "0.1.2",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "main": "./dist/ui-core-react.umd.cjs",
6
6
  "module": "./dist/ui-core-react.js",
@@ -24,6 +24,27 @@
24
24
  "build": "tsc -p tsconfig.app.json --noEmit && vite build",
25
25
  "type-check": "tsc -p tsconfig.app.json --noEmit"
26
26
  },
27
+ "dependencies": {
28
+ "@radix-ui/react-alert-dialog": "^1.1.14",
29
+ "@radix-ui/react-avatar": "^1.1.10",
30
+ "@radix-ui/react-checkbox": "^1.3.2",
31
+ "@radix-ui/react-dialog": "^1.1.14",
32
+ "@radix-ui/react-label": "^2.1.7",
33
+ "@radix-ui/react-popover": "^1.1.15",
34
+ "@radix-ui/react-progress": "^1.1.7",
35
+ "@radix-ui/react-scroll-area": "^1.2.9",
36
+ "@radix-ui/react-select": "^2.2.5",
37
+ "@radix-ui/react-separator": "^1.1.7",
38
+ "@radix-ui/react-slot": "^1.2.3",
39
+ "@radix-ui/react-switch": "^1.2.5",
40
+ "@radix-ui/react-toast": "^1.2.14",
41
+ "@radix-ui/react-tooltip": "^1.2.7",
42
+ "class-variance-authority": "^0.7.1",
43
+ "clsx": "^2.1.1",
44
+ "lucide-react": "^0.462.0",
45
+ "sonner": "^1.7.4",
46
+ "tailwind-merge": "^2.6.0"
47
+ },
27
48
  "peerDependencies": {
28
49
  "react": "^18.0.0",
29
50
  "react-dom": "^18.0.0"
@@ -32,8 +53,12 @@
32
53
  "@types/react": "^18.3.0",
33
54
  "@types/react-dom": "^18.3.0",
34
55
  "@vitejs/plugin-react": "^4.5.0",
56
+ "autoprefixer": "^10.4.19",
57
+ "postcss": "^8.4.38",
35
58
  "react": "^18.3.0",
36
59
  "react-dom": "^18.3.0",
60
+ "tailwindcss": "^3.4.3",
61
+ "tailwindcss-animate": "^1.0.7",
37
62
  "vite-plugin-dts": "^4.5.4"
38
63
  }
39
64
  }
@@ -2,6 +2,7 @@ import { useMemo, useState, useEffect } from 'react'
2
2
  import type { ReactNode } from 'react'
3
3
  import { ConfirmModal } from './ConfirmModal'
4
4
  import { VenueSwitcher } from './VenueSwitcher'
5
+ import { useTheme } from '../hooks/useTheme'
5
6
  import type { AuthUser, SidebarNavItem, Venue } from '../types'
6
7
  import '../styles/shell.css'
7
8
 
@@ -69,6 +70,7 @@ export function AppShell({
69
70
  scrollable = true,
70
71
  children,
71
72
  }: Props) {
73
+ const { theme, toggleTheme } = useTheme()
72
74
  const [collapsed, setCollapsed] = useState(() => readSidebarCookie())
73
75
  const [showLogoutConfirm, setShowLogoutConfirm] = useState(false)
74
76
  const [currentHref, setCurrentHref] = useState(() => window.location.href)
@@ -213,6 +215,18 @@ export function AppShell({
213
215
  <span className="rv-user-email" title={user?.email ?? ''}>{user?.email}</span>
214
216
  </div>
215
217
  )}
218
+ <button
219
+ className="rv-theme-toggle-btn"
220
+ title={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
221
+ aria-label={`Switch to ${theme === 'light' ? 'dark' : 'light'} mode`}
222
+ onClick={toggleTheme}
223
+ >
224
+ {theme === 'light' ? (
225
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" /></svg>
226
+ ) : (
227
+ <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round"><circle cx="12" cy="12" r="5" /><line x1="12" y1="1" x2="12" y2="3" /><line x1="12" y1="21" x2="12" y2="23" /><line x1="4.22" y1="4.22" x2="5.64" y2="5.64" /><line x1="18.36" y1="18.36" x2="19.78" y2="19.78" /><line x1="1" y1="12" x2="3" y2="12" /><line x1="21" y1="12" x2="23" y2="12" /><line x1="4.22" y1="19.78" x2="5.64" y2="18.36" /><line x1="18.36" y1="5.64" x2="19.78" y2="4.22" /></svg>
228
+ )}
229
+ </button>
216
230
  {accountSettingsUrl && (
217
231
  <a className="rv-account-settings-btn" href={accountSettingsUrl} title="Account settings">
218
232
  <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
@@ -0,0 +1,65 @@
1
+ import {
2
+ AlertDialog,
3
+ AlertDialogAction,
4
+ AlertDialogCancel,
5
+ AlertDialogContent,
6
+ AlertDialogDescription,
7
+ AlertDialogFooter,
8
+ AlertDialogHeader,
9
+ AlertDialogTitle,
10
+ } from "../ui/alert-dialog";
11
+
12
+ interface ConfirmationModalProps {
13
+ open: boolean;
14
+ onOpenChange: (open: boolean) => void;
15
+ title: string;
16
+ description: string;
17
+ confirmLabel?: string;
18
+ cancelLabel?: string;
19
+ variant?: "default" | "destructive";
20
+ isLoading?: boolean;
21
+ onConfirm: () => void;
22
+ }
23
+
24
+ export function ConfirmationModal({
25
+ open,
26
+ onOpenChange,
27
+ title,
28
+ description,
29
+ confirmLabel = "Confirm",
30
+ cancelLabel = "Cancel",
31
+ variant = "default",
32
+ isLoading = false,
33
+ onConfirm,
34
+ }: ConfirmationModalProps) {
35
+ const handleConfirm = () => {
36
+ onConfirm();
37
+ };
38
+
39
+ return (
40
+ <AlertDialog open={open} onOpenChange={onOpenChange}>
41
+ <AlertDialogContent>
42
+ <AlertDialogHeader>
43
+ <AlertDialogTitle>{title}</AlertDialogTitle>
44
+ <AlertDialogDescription>{description}</AlertDialogDescription>
45
+ </AlertDialogHeader>
46
+ <AlertDialogFooter>
47
+ <AlertDialogCancel disabled={isLoading}>
48
+ {cancelLabel}
49
+ </AlertDialogCancel>
50
+ <AlertDialogAction
51
+ onClick={handleConfirm}
52
+ disabled={isLoading}
53
+ className={
54
+ variant === "destructive"
55
+ ? "bg-destructive text-destructive-foreground hover:bg-destructive/90"
56
+ : ""
57
+ }
58
+ >
59
+ {isLoading ? "Processing..." : confirmLabel}
60
+ </AlertDialogAction>
61
+ </AlertDialogFooter>
62
+ </AlertDialogContent>
63
+ </AlertDialog>
64
+ );
65
+ }
@@ -0,0 +1,15 @@
1
+ import { type ReactNode } from "react";
2
+ import { cn } from "../../lib/utils";
3
+
4
+ interface ContainerProps {
5
+ children: ReactNode;
6
+ className?: string;
7
+ }
8
+
9
+ export function Container({ children, className }: ContainerProps) {
10
+ return (
11
+ <main className={cn("p-6 space-y-6 pb-24", className)}>
12
+ {children}
13
+ </main>
14
+ );
15
+ }
@@ -0,0 +1,62 @@
1
+ import { useState } from "react";
2
+
3
+ import { Button } from "../ui/button";
4
+ import { ConfirmationModal } from "./ConfirmationModal";
5
+
6
+ export interface DangerAction {
7
+ buttonLabel: string;
8
+ confirmLabel?: string;
9
+ modalTitle: string;
10
+ modalDescription: string;
11
+ isLoading?: boolean;
12
+ onConfirm: () => Promise<void> | void;
13
+ }
14
+
15
+ interface DangerZoneSectionProps {
16
+ actions: DangerAction[];
17
+ }
18
+
19
+ function DangerActionItem({
20
+ buttonLabel,
21
+ confirmLabel = "Confirm",
22
+ modalTitle,
23
+ modalDescription,
24
+ isLoading,
25
+ onConfirm,
26
+ }: DangerAction) {
27
+ const [open, setOpen] = useState(false);
28
+
29
+ return (
30
+ <>
31
+ <Button
32
+ variant="outline"
33
+ size="sm"
34
+ className="border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground w-full"
35
+ onClick={() => setOpen(true)}
36
+ >
37
+ {buttonLabel}
38
+ </Button>
39
+ <ConfirmationModal
40
+ open={open}
41
+ onOpenChange={setOpen}
42
+ title={modalTitle}
43
+ description={modalDescription}
44
+ confirmLabel={confirmLabel}
45
+ variant="destructive"
46
+ isLoading={isLoading}
47
+ onConfirm={onConfirm}
48
+ />
49
+ </>
50
+ );
51
+ }
52
+
53
+ export function DangerZoneSection({ actions }: DangerZoneSectionProps) {
54
+ return (
55
+ <div className="space-y-2">
56
+ <h3 className="text-sm font-semibold text-foreground">Danger Zone</h3>
57
+ {actions.map((action, i) => (
58
+ <DangerActionItem key={i} {...action} />
59
+ ))}
60
+ </div>
61
+ );
62
+ }
@@ -0,0 +1,115 @@
1
+ import { useRef, useState, useCallback, useEffect, type ReactNode } from "react";
2
+ import { createPortal } from "react-dom";
3
+
4
+ import { cn } from "../../lib/utils";
5
+ import { useDetailPanel } from "../../hooks/useDetailPanel";
6
+
7
+ interface DetailPanelProps {
8
+ panelKey: string;
9
+ children: ReactNode;
10
+ }
11
+
12
+ export function DetailPanel({ panelKey, children }: DetailPanelProps) {
13
+ const { isActive, isTopPanel, depth, portalTarget, isDismissingRef } = useDetailPanel(panelKey);
14
+
15
+ const lastChildrenRef = useRef<ReactNode>(null);
16
+ const [hasEntered, setHasEntered] = useState(false);
17
+ const [isExiting, setIsExiting] = useState(false);
18
+ const prevIsActiveRef = useRef(false);
19
+
20
+ // Read wasActive BEFORE updating prevIsActiveRef (render-phase detection).
21
+ // This makes wasActive available to both shouldRender and the effect closure,
22
+ // ensuring the panel stays mounted for the one render needed before the CSS
23
+ // exit transition can start (effects run after render — too late for shouldRender).
24
+ const wasActive = prevIsActiveRef.current;
25
+ prevIsActiveRef.current = isActive;
26
+
27
+ // Cache children only when actively rendering valid content.
28
+ // When dismissing, handleClose nulls out content state — we must not let those
29
+ // null-prop re-renders overwrite the valid cached children the close animation needs.
30
+ if (isActive && !isDismissingRef.current) {
31
+ lastChildrenRef.current = children;
32
+ }
33
+
34
+ // Reset all local state when the sheet fully closes (portalTarget unmounts).
35
+ // Without this, prevIsActiveRef stays true for panels that were active before
36
+ // close, causing spurious exit animations on the next open.
37
+ useEffect(() => {
38
+ if (!portalTarget) {
39
+ prevIsActiveRef.current = false;
40
+ setIsExiting(false);
41
+ setHasEntered(false);
42
+ }
43
+ }, [portalTarget]);
44
+
45
+ // Detect transitions in isActive and start the appropriate animation.
46
+ // wasActive is captured from the render-phase closure — always the previous render's value.
47
+ useEffect(() => {
48
+ if (wasActive && !isActive) {
49
+ // Panel was popped from the stack
50
+ if (!isDismissingRef.current) {
51
+ setIsExiting(true);
52
+ }
53
+ }
54
+
55
+ if (!wasActive && isActive) {
56
+ // Panel was pushed onto the stack.
57
+ // Cancel any in-progress exit (e.g. rapid pop → push).
58
+ // Skip enter animation for root panel (depth 0).
59
+ setIsExiting(false);
60
+ setHasEntered(depth === 0);
61
+ }
62
+ // prevIsActiveRef is updated in the render phase — not here
63
+ }, [isActive, wasActive, depth, isDismissingRef]);
64
+
65
+ // Keep the panel in the DOM while:
66
+ // - Active
67
+ // - Running its exit transition (isExiting)
68
+ // - Just became inactive this render (wasActive && !isActive): the exit transition
69
+ // needs one render with the panel still mounted and in its natural position before
70
+ // the CSS "from" state exists. Without this, the panel unmounts then remounts at
71
+ // translate-x-full with no prior state → transitionend never fires → stuck forever.
72
+ const shouldRender = isActive || isExiting || (wasActive && !isActive && !isDismissingRef.current);
73
+
74
+ const handleAnimationEnd = useCallback((e: React.AnimationEvent) => {
75
+ if (e.animationName === "enter") {
76
+ setHasEntered(true);
77
+ }
78
+ }, []);
79
+
80
+ const handleTransitionEnd = useCallback((e: React.TransitionEvent) => {
81
+ if (isExiting && e.target === e.currentTarget && e.propertyName === "transform") {
82
+ setIsExiting(false);
83
+ }
84
+ }, [isExiting]);
85
+
86
+ if (!shouldRender || !portalTarget) return null;
87
+
88
+ const content = (isActive && !isDismissingRef.current) ? children : lastChildrenRef.current;
89
+ const isBehind = isActive && !isTopPanel && !isExiting;
90
+ const isEntering = !hasEntered && !isExiting && isActive;
91
+
92
+ return createPortal(
93
+ <div
94
+ className={cn(
95
+ "absolute inset-0 overflow-y-auto p-6 pt-10",
96
+ // Enter animation (depth > 0 only, removed after animationEnd)
97
+ isEntering && "animate-in slide-in-from-right duration-300",
98
+ // After enter complete — transitions take over
99
+ hasEntered && "transition-[transform,opacity] duration-300 ease-in-out",
100
+ // Top panel (normal position)
101
+ hasEntered && isTopPanel && !isExiting && "translate-x-0 opacity-100",
102
+ // Behind panel (pushed back)
103
+ isBehind && "-translate-x-8 scale-[0.97] opacity-0",
104
+ // Exiting (slide out to right)
105
+ isExiting && "transition-[transform,opacity] duration-300 ease-in-out translate-x-full opacity-0",
106
+ )}
107
+ style={{ zIndex: Math.max(depth, 0) }}
108
+ onAnimationEnd={handleAnimationEnd}
109
+ onTransitionEnd={handleTransitionEnd}
110
+ >
111
+ {content}
112
+ </div>,
113
+ portalTarget
114
+ );
115
+ }
@@ -0,0 +1,98 @@
1
+ import {
2
+ useState,
3
+ useRef,
4
+ useMemo,
5
+ useCallback,
6
+ forwardRef,
7
+ useImperativeHandle,
8
+ createContext,
9
+ type ReactNode,
10
+ type MutableRefObject,
11
+ } from "react";
12
+
13
+ import { Sheet, SheetContent } from "../ui/sheet";
14
+
15
+ export type DetailSheetContextType = {
16
+ displayStack: string[];
17
+ portalTarget: HTMLDivElement | null;
18
+ isDismissingRef: MutableRefObject<boolean>;
19
+ };
20
+
21
+ export const DetailSheetContext = createContext<DetailSheetContextType | null>(null);
22
+
23
+ export interface DetailSheetHandle {
24
+ push: (panelKey: string) => void;
25
+ pop: () => void;
26
+ }
27
+
28
+ interface DetailSheetProps {
29
+ onClose: () => void;
30
+ children: ReactNode;
31
+ }
32
+
33
+ export const DetailSheet = forwardRef<DetailSheetHandle, DetailSheetProps>(
34
+ ({ onClose, children }, ref) => {
35
+ const [stack, setStack] = useState<string[]>([]);
36
+ const [portalTarget, setPortalTarget] = useState<HTMLDivElement | null>(null);
37
+ const isDismissingRef = useRef(false);
38
+ const lastNonEmptyStackRef = useRef<string[]>([]);
39
+
40
+ const isOpen = stack.length > 0;
41
+
42
+ // Keep last non-empty stack so panels stay rendered during sheet close animation
43
+ if (stack.length > 0) {
44
+ lastNonEmptyStackRef.current = stack;
45
+ }
46
+
47
+ const displayStack = isOpen ? stack : lastNonEmptyStackRef.current;
48
+
49
+ // Reset dismissing flag once the sheet fully closes (portalTarget gone)
50
+ if (!isOpen && portalTarget === null) {
51
+ isDismissingRef.current = false;
52
+ }
53
+
54
+ const push = useCallback((panelKey: string) => {
55
+ setStack(prev => [...prev, panelKey]);
56
+ }, []);
57
+
58
+ const pop = useCallback(() => {
59
+ setStack(prev => {
60
+ const next = prev.slice(0, -1);
61
+ if (next.length === 0) {
62
+ isDismissingRef.current = true;
63
+ onClose();
64
+ }
65
+ return next;
66
+ });
67
+ }, [onClose]);
68
+
69
+ useImperativeHandle(ref, () => ({ push, pop }), [push, pop]);
70
+
71
+ const handleOpenChange = useCallback((open: boolean) => {
72
+ if (!open) {
73
+ isDismissingRef.current = true;
74
+ setStack([]);
75
+ onClose();
76
+ }
77
+ }, [onClose]);
78
+
79
+ const contextValue = useMemo(() => ({
80
+ displayStack,
81
+ portalTarget,
82
+ isDismissingRef,
83
+ }), [displayStack, portalTarget]);
84
+
85
+ return (
86
+ <DetailSheetContext.Provider value={contextValue}>
87
+ {children}
88
+ <Sheet open={isOpen} onOpenChange={handleOpenChange}>
89
+ <SheetContent className="w-full sm:max-w-md !p-0">
90
+ <div ref={setPortalTarget} className="relative h-full overflow-hidden isolate" />
91
+ </SheetContent>
92
+ </Sheet>
93
+ </DetailSheetContext.Provider>
94
+ );
95
+ }
96
+ );
97
+
98
+ DetailSheet.displayName = "DetailSheet";
@@ -0,0 +1,119 @@
1
+ import { useState, useCallback, useRef } from "react";
2
+ import { Loader2, Check, Pencil, X } from "lucide-react";
3
+
4
+ import { Input } from "../ui/input";
5
+ import { Button } from "../ui/button";
6
+ import { cn } from "../../lib/utils";
7
+
8
+ interface EditableTitleProps {
9
+ value: string;
10
+ onSave: (newValue: string) => Promise<void>;
11
+ className?: string;
12
+ readOnly?: boolean;
13
+ }
14
+
15
+ export function EditableTitle({ value, onSave, className, readOnly }: EditableTitleProps) {
16
+ const [isEditing, setIsEditing] = useState(false);
17
+ const [editValue, setEditValue] = useState(value);
18
+ const [isSaving, setIsSaving] = useState(false);
19
+ const saveButtonRef = useRef<HTMLButtonElement>(null);
20
+
21
+ const canSave = editValue.trim().length > 0 && editValue.trim() !== value;
22
+
23
+ const handleStartEdit = useCallback(() => {
24
+ setEditValue(value);
25
+ setIsEditing(true);
26
+ }, [value]);
27
+
28
+ const handleCancel = useCallback(() => {
29
+ setIsEditing(false);
30
+ setEditValue(value);
31
+ }, [value]);
32
+
33
+ const handleSave = useCallback(async () => {
34
+ if (!canSave) return;
35
+ setIsSaving(true);
36
+ try {
37
+ await onSave(editValue.trim());
38
+ setIsEditing(false);
39
+ } catch (error) {
40
+ console.error("Failed to save:", error);
41
+ } finally {
42
+ setIsSaving(false);
43
+ }
44
+ }, [canSave, editValue, onSave]);
45
+
46
+ const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
47
+ if (e.key === "Escape") {
48
+ handleCancel();
49
+ } else if (e.key === "Enter" && canSave) {
50
+ handleSave();
51
+ }
52
+ }, [handleCancel, handleSave, canSave]);
53
+
54
+ const handleBlur = useCallback((e: React.FocusEvent) => {
55
+ // Don't cancel if focus moved to the save button
56
+ if (saveButtonRef.current?.contains(e.relatedTarget as Node)) return;
57
+ handleCancel();
58
+ }, [handleCancel]);
59
+
60
+ if (readOnly) {
61
+ return <h2 className={cn("text-lg font-semibold truncate", className)}>{value}</h2>;
62
+ }
63
+
64
+ if (isEditing) {
65
+ return (
66
+ <div className="flex items-center gap-2">
67
+ <Input
68
+ value={editValue}
69
+ onChange={(e) => setEditValue(e.target.value)}
70
+ onKeyDown={handleKeyDown}
71
+ onBlur={handleBlur}
72
+ autoFocus
73
+ disabled={isSaving}
74
+ className={cn("h-8 text-lg font-semibold", className)}
75
+ />
76
+ <Button
77
+ ref={saveButtonRef}
78
+ size="icon"
79
+ onClick={canSave ? handleSave : handleCancel}
80
+ disabled={isSaving}
81
+ className={cn(
82
+ "h-8 w-8 shrink-0 text-white hover:translate-y-0 hover:shadow-none disabled:opacity-40",
83
+ canSave
84
+ ? "bg-green-500 hover:bg-green-600 disabled:bg-green-500"
85
+ : "bg-red-500 hover:bg-red-600"
86
+ )}
87
+ >
88
+ <div className="relative h-4 w-4">
89
+ <Loader2 className={cn("h-4 w-4 absolute transition-opacity duration-200 animate-spin", isSaving ? "opacity-100" : "opacity-0")} />
90
+ <Check className={cn("h-4 w-4 absolute transition-opacity duration-200", !isSaving && canSave ? "opacity-100" : "opacity-0")} />
91
+ <X className={cn("h-4 w-4 absolute transition-opacity duration-200", !isSaving && !canSave ? "opacity-100" : "opacity-0")} />
92
+ </div>
93
+ </Button>
94
+ </div>
95
+ );
96
+ }
97
+
98
+ return (
99
+ <div className="group flex items-center gap-2">
100
+ <h2
101
+ onClick={handleStartEdit}
102
+ className={cn(
103
+ "text-lg font-semibold truncate cursor-text transition-colors group-hover:text-primary/80",
104
+ className
105
+ )}
106
+ >
107
+ {value}
108
+ </h2>
109
+ <Button
110
+ size="icon"
111
+ variant="ghost"
112
+ onClick={handleStartEdit}
113
+ className="h-8 w-8 shrink-0 text-muted-foreground hover:bg-transparent hover:text-muted-foreground group-hover:bg-accent group-hover:text-foreground"
114
+ >
115
+ <Pencil className="h-3.5 w-3.5" />
116
+ </Button>
117
+ </div>
118
+ );
119
+ }
@@ -0,0 +1,36 @@
1
+ import { Button } from "../ui/button";
2
+ import { Users, UserPlus } from "lucide-react";
3
+
4
+ interface EmptyStateProps {
5
+ title?: string;
6
+ description?: string;
7
+ ctaLabel?: string;
8
+ showCTA?: boolean;
9
+ onCTA?: () => void;
10
+ }
11
+
12
+ export function EmptyState({
13
+ title = "No users found",
14
+ description = "Try adjusting your filters or invite a new user.",
15
+ showCTA = true,
16
+ onCTA,
17
+ ctaLabel = 'Invite'
18
+ }: EmptyStateProps) {
19
+ return (
20
+ <div className="flex flex-col items-center justify-center py-16 px-4">
21
+ <div className="w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4">
22
+ <Users className="h-8 w-8 text-muted-foreground" />
23
+ </div>
24
+ <h3 className="text-lg font-semibold text-foreground mb-1">{title}</h3>
25
+ <p className="text-sm text-muted-foreground text-center max-w-sm mb-6">
26
+ {description}
27
+ </p>
28
+ {showCTA && onCTA && (
29
+ <Button onClick={onCTA} className="gap-2">
30
+ <UserPlus className="h-4 w-4" />
31
+ {ctaLabel}
32
+ </Button>
33
+ )}
34
+ </div>
35
+ );
36
+ }
@@ -0,0 +1,64 @@
1
+ import { ReactNode } from "react";
2
+ import {
3
+ Dialog,
4
+ DialogContent,
5
+ DialogHeader,
6
+ DialogTitle,
7
+ DialogDescription,
8
+ DialogFooter,
9
+ } from "../ui/dialog";
10
+ import { Button } from "../ui/button";
11
+ import { Loader2 } from "lucide-react";
12
+
13
+ interface FormModalProps {
14
+ open: boolean;
15
+ onOpenChange: (open: boolean) => void;
16
+ title: string;
17
+ description?: string;
18
+ submitLabel?: string;
19
+ isSubmitting?: boolean;
20
+ onSubmit: () => void;
21
+ children: ReactNode;
22
+ }
23
+
24
+ export function FormModal({
25
+ open,
26
+ onOpenChange,
27
+ title,
28
+ description,
29
+ submitLabel = "Create",
30
+ isSubmitting = false,
31
+ onSubmit,
32
+ children,
33
+ }: FormModalProps) {
34
+ return (
35
+ <Dialog open={open} onOpenChange={onOpenChange}>
36
+ <DialogContent className="sm:max-w-[425px]">
37
+ <DialogHeader>
38
+ <DialogTitle>{title}</DialogTitle>
39
+ {description && <DialogDescription>{description}</DialogDescription>}
40
+ </DialogHeader>
41
+ {children}
42
+ <DialogFooter>
43
+ <Button
44
+ variant="ghost"
45
+ onClick={() => onOpenChange(false)}
46
+ disabled={isSubmitting}
47
+ >
48
+ Cancel
49
+ </Button>
50
+ <Button onClick={onSubmit} disabled={isSubmitting}>
51
+ {isSubmitting ? (
52
+ <>
53
+ <Loader2 className="h-4 w-4 mr-2 animate-spin" />
54
+ Submitting...
55
+ </>
56
+ ) : (
57
+ submitLabel
58
+ )}
59
+ </Button>
60
+ </DialogFooter>
61
+ </DialogContent>
62
+ </Dialog>
63
+ );
64
+ }
@@ -0,0 +1,24 @@
1
+ import { type ReactNode } from 'react'
2
+ import { ChevronRight } from 'lucide-react'
3
+
4
+ interface NavigationListItemProps {
5
+ icon: ReactNode
6
+ label: string
7
+ badge?: ReactNode
8
+ onClick: () => void
9
+ }
10
+
11
+ export function NavigationListItem({ icon, label, badge, onClick }: NavigationListItemProps) {
12
+ return (
13
+ <button
14
+ type="button"
15
+ onClick={onClick}
16
+ className="flex items-center gap-2 p-2 bg-muted/30 rounded-lg w-full text-left hover:bg-muted/50 transition-colors cursor-pointer"
17
+ >
18
+ <span className="text-muted-foreground [&>svg]:h-4 [&>svg]:w-4">{icon}</span>
19
+ <span className="text-sm text-foreground flex-1">{label}</span>
20
+ {badge}
21
+ <ChevronRight className="h-4 w-4 text-muted-foreground" />
22
+ </button>
23
+ )
24
+ }