@umituz/web-design-system 3.1.21 → 4.0.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 (82) hide show
  1. package/README.md +137 -469
  2. package/dist/styles.css +2 -0
  3. package/package.json +30 -31
  4. package/src/__tests__/cn.test.ts +24 -0
  5. package/src/__tests__/components.smoke.test.tsx +78 -0
  6. package/src/__tests__/styles.contract.test.ts +60 -0
  7. package/src/domain/tokens/index.ts +8 -49
  8. package/src/index.ts +8 -10
  9. package/src/infrastructure/constants/component.constants.ts +3 -17
  10. package/src/infrastructure/constants/index.ts +4 -2
  11. package/src/infrastructure/constants/timing.constants.ts +46 -0
  12. package/src/infrastructure/utils/calculation.utils.ts +74 -0
  13. package/src/infrastructure/utils/index.ts +12 -0
  14. package/src/presentation/atoms/IconButton.tsx +55 -0
  15. package/src/presentation/atoms/Progress.tsx +2 -1
  16. package/src/presentation/atoms/Spinner.tsx +1 -1
  17. package/src/presentation/atoms/Switch.tsx +2 -2
  18. package/src/presentation/atoms/Text.tsx +15 -13
  19. package/src/presentation/atoms/Tooltip.tsx +2 -1
  20. package/src/presentation/atoms/index.ts +3 -0
  21. package/src/presentation/hooks/index.ts +0 -3
  22. package/src/presentation/hooks/useClickOutside.ts +14 -10
  23. package/src/presentation/hooks/useClipboard.ts +30 -12
  24. package/src/presentation/hooks/useDebounce.ts +8 -10
  25. package/src/presentation/hooks/useLocalStorage.ts +28 -18
  26. package/src/presentation/hooks/useMediaQuery.ts +2 -1
  27. package/src/presentation/hooks/useScrollLock.ts +40 -12
  28. package/src/presentation/hooks/useToggle.ts +8 -6
  29. package/src/presentation/molecules/ActiveFilterTags.tsx +19 -18
  30. package/src/presentation/molecules/Avatar.tsx +1 -1
  31. package/src/presentation/molecules/CodeBlock.tsx +51 -48
  32. package/src/presentation/molecules/ListItem.tsx +40 -29
  33. package/src/presentation/molecules/Select.tsx +1 -1
  34. package/src/presentation/molecules/Toggle.tsx +4 -4
  35. package/src/presentation/molecules/index.ts +0 -3
  36. package/src/presentation/organisms/Alert.tsx +1 -1
  37. package/src/presentation/organisms/DataTable.tsx +24 -11
  38. package/src/presentation/organisms/Dialog.tsx +1 -1
  39. package/src/presentation/organisms/DropdownMenu.tsx +2 -2
  40. package/src/presentation/organisms/HoverCard.tsx +1 -1
  41. package/src/presentation/organisms/LoadingState.tsx +1 -5
  42. package/src/presentation/organisms/Popover.tsx +1 -1
  43. package/src/presentation/organisms/StatCard.tsx +2 -2
  44. package/src/presentation/organisms/Table.tsx +2 -2
  45. package/src/presentation/organisms/index.ts +0 -60
  46. package/src/styles/compile.css +18 -0
  47. package/src/styles/theme.css +131 -0
  48. package/src/domain/tokens/animation.tokens.ts +0 -87
  49. package/src/domain/tokens/color.tokens.ts +0 -95
  50. package/src/domain/tokens/radius.tokens.ts +0 -27
  51. package/src/domain/tokens/shadow.tokens.ts +0 -25
  52. package/src/domain/tokens/spacing.tokens.ts +0 -65
  53. package/src/domain/tokens/typography.tokens.ts +0 -74
  54. package/src/infrastructure/error/ErrorBoundary.tsx +0 -258
  55. package/src/infrastructure/error/ErrorDisplay.tsx +0 -346
  56. package/src/infrastructure/error/SuspenseWrapper.tsx +0 -133
  57. package/src/infrastructure/error/index.ts +0 -5
  58. package/src/infrastructure/performance/index.ts +0 -92
  59. package/src/infrastructure/performance/useLazyLoading.ts +0 -342
  60. package/src/infrastructure/performance/useMemoryOptimization.ts +0 -293
  61. package/src/infrastructure/performance/usePerformanceMonitor.ts +0 -158
  62. package/src/infrastructure/security/index.ts +0 -10
  63. package/src/infrastructure/security/security-config.ts +0 -171
  64. package/src/infrastructure/security/useFormValidation.ts +0 -216
  65. package/src/infrastructure/security/validation.ts +0 -246
  66. package/src/presentation/hooks/useLanguage.ts +0 -109
  67. package/src/presentation/molecules/Breadcrumb.tsx +0 -54
  68. package/src/presentation/organisms/AlertDialog.tsx +0 -181
  69. package/src/presentation/organisms/Calendar.tsx +0 -79
  70. package/src/presentation/organisms/Comments.tsx +0 -103
  71. package/src/presentation/organisms/ConfirmDialog.tsx +0 -97
  72. package/src/presentation/organisms/FilterBar.tsx +0 -244
  73. package/src/presentation/organisms/FilterSidebar.tsx +0 -172
  74. package/src/presentation/organisms/Footer.tsx +0 -86
  75. package/src/presentation/organisms/FormModal.tsx +0 -126
  76. package/src/presentation/organisms/Grid.tsx +0 -128
  77. package/src/presentation/organisms/ImageLightbox.tsx +0 -252
  78. package/src/presentation/organisms/MainNavbar.tsx +0 -320
  79. package/src/presentation/organisms/Modal.tsx +0 -173
  80. package/src/presentation/organisms/Navbar.tsx +0 -75
  81. package/src/presentation/organisms/NewsletterSignup.tsx +0 -165
  82. package/src/presentation/organisms/QuickActionCard.tsx +0 -93
@@ -1,181 +0,0 @@
1
- /**
2
- * AlertDialog Component
3
- * @description Alert dialog component for critical confirmations using @radix-ui/react-alert-dialog
4
- * @example
5
- * import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from '@umituz/web-design-system/organisms';
6
- *
7
- * <AlertDialog>
8
- * <AlertDialogTrigger asChild>
9
- * <Button>Open Alert Dialog</Button>
10
- * </AlertDialogTrigger>
11
- * <AlertDialogContent>
12
- * <AlertDialogHeader>
13
- * <AlertDialogTitle>Are you sure?</AlertDialogTitle>
14
- * <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
15
- * </AlertDialogHeader>
16
- * <AlertDialogFooter>
17
- * <AlertDialogCancel>Cancel</AlertDialogCancel>
18
- * <AlertDialogAction>Continue</AlertDialogAction>
19
- * </AlertDialogFooter>
20
- * </AlertDialogContent>
21
- * </AlertDialog>
22
- */
23
-
24
- import * as React from "react";
25
- import * as AlertDialogPrimitive from "@radix-ui/react-alert-dialog";
26
-
27
- import { cn } from "../../infrastructure/utils";
28
-
29
- // Import buttonVariants from the atoms folder
30
- // We need to define it here since Button uses cva
31
- import { cva } from "class-variance-authority";
32
-
33
- const buttonVariants = cva(
34
- "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
35
- {
36
- variants: {
37
- variant: {
38
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
39
- destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
40
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
41
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
42
- ghost: "hover:bg-accent hover:text-accent-foreground",
43
- link: "text-primary underline-offset-4 hover:underline",
44
- },
45
- },
46
- }
47
- );
48
-
49
- const AlertDialog = AlertDialogPrimitive.Root;
50
-
51
- const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
52
-
53
- const AlertDialogPortal = AlertDialogPrimitive.Portal;
54
-
55
- const AlertDialogOverlay = React.forwardRef<
56
- React.ElementRef<typeof AlertDialogPrimitive.Overlay>,
57
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Overlay>
58
- >(({ className, ...props }, ref) => (
59
- <AlertDialogPrimitive.Overlay
60
- className={cn(
61
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
62
- className
63
- )}
64
- {...props}
65
- ref={ref}
66
- />
67
- ));
68
- AlertDialogOverlay.displayName = AlertDialogPrimitive.Overlay.displayName;
69
-
70
- const AlertDialogContent = React.forwardRef<
71
- React.ElementRef<typeof AlertDialogPrimitive.Content>,
72
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Content>
73
- >(({ className, ...props }, ref) => (
74
- <AlertDialogPortal>
75
- <AlertDialogOverlay />
76
- <AlertDialogPrimitive.Content
77
- ref={ref}
78
- className={cn(
79
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
80
- className
81
- )}
82
- {...props}
83
- />
84
- </AlertDialogPortal>
85
- ));
86
- AlertDialogContent.displayName = AlertDialogPrimitive.Content.displayName;
87
-
88
- const AlertDialogHeader = ({
89
- className,
90
- ...props
91
- }: React.HTMLAttributes<HTMLDivElement>) => (
92
- <div
93
- className={cn(
94
- "flex flex-col space-y-2 text-center sm:text-left",
95
- className
96
- )}
97
- {...props}
98
- />
99
- );
100
- AlertDialogHeader.displayName = "AlertDialogHeader";
101
-
102
- const AlertDialogFooter = ({
103
- className,
104
- ...props
105
- }: React.HTMLAttributes<HTMLDivElement>) => (
106
- <div
107
- className={cn(
108
- "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
109
- className
110
- )}
111
- {...props}
112
- />
113
- );
114
- AlertDialogFooter.displayName = "AlertDialogFooter";
115
-
116
- const AlertDialogTitle = React.forwardRef<
117
- React.ElementRef<typeof AlertDialogPrimitive.Title>,
118
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Title>
119
- >(({ className, ...props }, ref) => (
120
- <AlertDialogPrimitive.Title
121
- ref={ref}
122
- className={cn("text-lg font-semibold", className)}
123
- {...props}
124
- />
125
- ));
126
- AlertDialogTitle.displayName = AlertDialogPrimitive.Title.displayName;
127
-
128
- const AlertDialogDescription = React.forwardRef<
129
- React.ElementRef<typeof AlertDialogPrimitive.Description>,
130
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Description>
131
- >(({ className, ...props }, ref) => (
132
- <AlertDialogPrimitive.Description
133
- ref={ref}
134
- className={cn("text-sm text-muted-foreground", className)}
135
- {...props}
136
- />
137
- ));
138
- AlertDialogDescription.displayName =
139
- AlertDialogPrimitive.Description.displayName;
140
-
141
- const AlertDialogAction = React.forwardRef<
142
- React.ElementRef<typeof AlertDialogPrimitive.Action>,
143
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Action>
144
- >(({ className, ...props }, ref) => (
145
- <AlertDialogPrimitive.Action
146
- ref={ref}
147
- className={cn(buttonVariants(), className)}
148
- {...props}
149
- />
150
- ));
151
- AlertDialogAction.displayName = AlertDialogPrimitive.Action.displayName;
152
-
153
- const AlertDialogCancel = React.forwardRef<
154
- React.ElementRef<typeof AlertDialogPrimitive.Cancel>,
155
- React.ComponentPropsWithoutRef<typeof AlertDialogPrimitive.Cancel>
156
- >(({ className, ...props }, ref) => (
157
- <AlertDialogPrimitive.Cancel
158
- ref={ref}
159
- className={cn(
160
- buttonVariants({ variant: "outline" }),
161
- "mt-2 sm:mt-0",
162
- className
163
- )}
164
- {...props}
165
- />
166
- ));
167
- AlertDialogCancel.displayName = AlertDialogPrimitive.Cancel.displayName;
168
-
169
- export {
170
- AlertDialog,
171
- AlertDialogPortal,
172
- AlertDialogOverlay,
173
- AlertDialogTrigger,
174
- AlertDialogContent,
175
- AlertDialogHeader,
176
- AlertDialogFooter,
177
- AlertDialogTitle,
178
- AlertDialogDescription,
179
- AlertDialogAction,
180
- AlertDialogCancel,
181
- };
@@ -1,79 +0,0 @@
1
- /**
2
- * Calendar Component
3
- * @description Date picker component using react-day-picker
4
- * @example
5
- * import { Calendar } from '@umituz/web-design-system/organisms';
6
- *
7
- * <Calendar
8
- * mode="single"
9
- * selected={date}
10
- * onSelect={setDate}
11
- * className="rounded-md border"
12
- * />
13
- */
14
-
15
- import * as React from "react";
16
- import { ChevronLeft, ChevronRight } from "lucide-react";
17
- import { DayPicker } from "react-day-picker";
18
-
19
- import { cn } from "../../infrastructure/utils";
20
-
21
- export type CalendarProps = React.ComponentProps<typeof DayPicker>;
22
-
23
- function Calendar({
24
- className,
25
- classNames,
26
- showOutsideDays = true,
27
- ...props
28
- }: CalendarProps) {
29
- return (
30
- <DayPicker
31
- showOutsideDays={showOutsideDays}
32
- className={cn("p-3", className)}
33
- classNames={{
34
- months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0",
35
- month: "space-y-4",
36
- caption: "flex justify-center pt-1 relative items-center",
37
- caption_label: "text-sm font-medium",
38
- nav: "space-x-1 flex items-center",
39
- nav_button: cn(
40
- "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 border border-input bg-background hover:bg-accent hover:text-accent-foreground h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100"
41
- ),
42
- nav_button_previous: "absolute left-1",
43
- nav_button_next: "absolute right-1",
44
- table: "w-full border-collapse space-y-1",
45
- head_row: "flex",
46
- head_cell:
47
- "text-muted-foreground rounded-md w-9 font-normal text-[0.8rem]",
48
- row: "flex w-full mt-2",
49
- cell: "h-9 w-9 text-center text-sm p-0 relative [&:has([aria-selected].day-range-end)]:rounded-r-md [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected])]:bg-accent first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md focus-within:relative focus-within:z-20",
50
- day: cn(
51
- "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 hover:bg-accent hover:text-accent-foreground h-9 w-9 p-0 font-normal aria-selected:opacity-100"
52
- ),
53
- day_range_end: "day-range-end",
54
- day_selected:
55
- "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground",
56
- day_today: "bg-accent text-accent-foreground",
57
- day_outside:
58
- "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30",
59
- day_disabled: "text-muted-foreground opacity-50",
60
- day_range_middle:
61
- "aria-selected:bg-accent aria-selected:text-accent-foreground",
62
- day_hidden: "invisible",
63
- ...classNames,
64
- }}
65
- components={{
66
- Chevron: ({ orientation, ...props }) =>
67
- orientation === 'left' ? (
68
- <ChevronLeft className="h-4 w-4" {...props} />
69
- ) : (
70
- <ChevronRight className="h-4 w-4" {...props} />
71
- ),
72
- }}
73
- {...props}
74
- />
75
- );
76
- }
77
- Calendar.displayName = "Calendar";
78
-
79
- export { Calendar };
@@ -1,103 +0,0 @@
1
- /**
2
- * Comments Component (Organism)
3
- * @description Giscus-based GitHub Discussions comment widget
4
- */
5
-
6
- import { useEffect, useRef } from 'react';
7
- import { cn } from '../../infrastructure/utils';
8
- import type { BaseProps } from '../../domain/types';
9
-
10
- export interface GiscusConfig {
11
- repo: string;
12
- repoId: string;
13
- category?: string;
14
- mapping?: 'pathname' | 'url' | 'title' | 'og:title' | 'custom';
15
- term?: string;
16
- strict?: '0' | '1';
17
- reactionsEnabled?: '0' | '1';
18
- emitMetadata?: '0' | '1';
19
- inputPosition?: 'top' | 'bottom';
20
- theme?: 'light' | 'dark' | 'dark_dimmed' | 'transparent_dark' | 'preferred_color_scheme';
21
- lang?: string;
22
- }
23
-
24
- export interface CommentsProps extends BaseProps {
25
- slug: string;
26
- config?: Partial<GiscusConfig>;
27
- title?: string;
28
- description?: string;
29
- }
30
-
31
- declare global {
32
- interface Window {
33
- giscus?: {
34
- render: (element: HTMLElement, config: Record<string, unknown>) => void;
35
- };
36
- }
37
- }
38
-
39
- export const Comments = ({
40
- slug,
41
- config,
42
- title = 'Comments',
43
- description = 'Join the discussion! Share your thoughts and questions below.',
44
- className,
45
- }: CommentsProps) => {
46
- const rootRef = useRef<HTMLDivElement>(null);
47
-
48
- useEffect(() => {
49
- // Load Giscus script dynamically
50
- const script = document.createElement('script');
51
- script.src = 'https://giscus.app/client.js';
52
- script.async = true;
53
- script.crossOrigin = 'anonymous';
54
-
55
- script.addEventListener('load', () => {
56
- if (window.giscus && rootRef.current) {
57
- const defaultConfig: GiscusConfig = {
58
- repo: 'umituz/umituz-apps',
59
- repoId: 'R_kgDONJ7RJw',
60
- category: 'Announcements',
61
- mapping: 'pathname',
62
- term: slug,
63
- strict: '0',
64
- reactionsEnabled: '1',
65
- emitMetadata: '0',
66
- inputPosition: 'top',
67
- theme: 'dark',
68
- lang: 'en',
69
- ...config,
70
- };
71
-
72
- window.giscus.render(rootRef.current, defaultConfig as unknown as Record<string, unknown>);
73
- }
74
- });
75
-
76
- document.head.appendChild(script);
77
-
78
- return () => {
79
- // Only remove if script exists and is in DOM
80
- if (script.parentNode === document.head) {
81
- document.head.removeChild(script);
82
- }
83
- };
84
- }, [slug, config]);
85
-
86
- return (
87
- <div className={cn('mt-8', className)}>
88
- <div className="bg-bg-card rounded-xl p-6 border border-border transition-theme">
89
- <h3 className="text-xl font-bold text-text-primary mb-4">{title}</h3>
90
- <p className="text-text-secondary text-sm mb-4">
91
- {description}
92
- </p>
93
- <div
94
- ref={rootRef}
95
- id="giscus-comments"
96
- className="min-h-[200px]"
97
- />
98
- </div>
99
- </div>
100
- );
101
- };
102
-
103
- Comments.displayName = 'Comments';
@@ -1,97 +0,0 @@
1
- /**
2
- * ConfirmDialog Component (Organism)
3
- * @description Confirmation dialog for destructive actions
4
- * Reduces boilerplate in delete/remove confirmation modals
5
- */
6
-
7
- import { forwardRef, type ReactNode } from 'react';
8
- import { cn } from '../../infrastructure/utils';
9
- import {
10
- Dialog,
11
- DialogContent,
12
- DialogDescription,
13
- DialogFooter,
14
- DialogHeader,
15
- DialogTitle,
16
- } from './Dialog';
17
- import { Button } from '../atoms';
18
- import { AlertTriangle } from 'lucide-react';
19
- import type { BaseProps } from '../../domain/types';
20
-
21
- export interface ConfirmDialogProps extends BaseProps {
22
- open: boolean;
23
- onOpenChange: (open: boolean) => void;
24
- title: string;
25
- message?: string;
26
- description?: string;
27
- onConfirm: () => void | Promise<void>;
28
- loading?: boolean;
29
- confirmText?: string;
30
- cancelText?: string;
31
- variant?: 'default' | 'destructive';
32
- icon?: ReactNode;
33
- }
34
-
35
- export const ConfirmDialog = forwardRef<HTMLDivElement, ConfirmDialogProps>(
36
- (
37
- {
38
- className,
39
- open,
40
- onOpenChange,
41
- title,
42
- message,
43
- description,
44
- onConfirm,
45
- loading = false,
46
- confirmText = 'Confirm',
47
- cancelText = 'Cancel',
48
- variant = 'destructive',
49
- icon,
50
- ...props
51
- },
52
- ref
53
- ) => {
54
- const handleConfirm = async () => {
55
- if (!loading) {
56
- await onConfirm();
57
- onOpenChange(false);
58
- }
59
- };
60
-
61
- return (
62
- <Dialog open={open} onOpenChange={onOpenChange}>
63
- <DialogContent className={cn('sm:max-w-[425px]', className)} ref={ref} {...props}>
64
- <DialogHeader>
65
- <div className="flex items-center gap-3">
66
- {icon || (
67
- variant === 'destructive' && (
68
- <div className="w-10 h-10 rounded-full bg-destructive/10 flex items-center justify-center">
69
- <AlertTriangle className="h-5 w-5 text-destructive" />
70
- </div>
71
- )
72
- )}
73
- <DialogTitle>{title}</DialogTitle>
74
- </div>
75
- {description && <DialogDescription>{description}</DialogDescription>}
76
- </DialogHeader>
77
- {message && (
78
- <div className="py-4">
79
- <p className="text-sm text-muted-foreground">{message}</p>
80
- </div>
81
- )}
82
- <DialogFooter>
83
- <Button variant="outline" onClick={() => onOpenChange(false)} disabled={loading}>
84
- {cancelText}
85
- </Button>
86
- <Button variant={variant} onClick={handleConfirm} disabled={loading}>
87
- {loading && <span className="mr-2 h-4 w-4 animate-spin">⟳</span>}
88
- {confirmText}
89
- </Button>
90
- </DialogFooter>
91
- </DialogContent>
92
- </Dialog>
93
- );
94
- }
95
- );
96
-
97
- ConfirmDialog.displayName = 'ConfirmDialog';