@umituz/web-design-system 3.1.22 → 4.0.2

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 (84) hide show
  1. package/README.md +137 -469
  2. package/dist/styles.css +2 -0
  3. package/package.json +31 -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/cn.util.ts +1 -1
  14. package/src/infrastructure/utils/index.ts +12 -0
  15. package/src/presentation/atoms/IconButton.tsx +55 -0
  16. package/src/presentation/atoms/Progress.tsx +2 -1
  17. package/src/presentation/atoms/Spinner.tsx +1 -1
  18. package/src/presentation/atoms/Switch.tsx +2 -2
  19. package/src/presentation/atoms/Text.tsx +15 -13
  20. package/src/presentation/atoms/Tooltip.tsx +2 -1
  21. package/src/presentation/atoms/index.ts +3 -0
  22. package/src/presentation/hooks/index.ts +0 -3
  23. package/src/presentation/hooks/useClickOutside.ts +16 -10
  24. package/src/presentation/hooks/useClipboard.ts +30 -12
  25. package/src/presentation/hooks/useDebounce.ts +9 -11
  26. package/src/presentation/hooks/useLocalStorage.ts +32 -20
  27. package/src/presentation/hooks/useMediaQuery.ts +20 -15
  28. package/src/presentation/hooks/useScrollLock.ts +40 -12
  29. package/src/presentation/hooks/useToggle.ts +8 -6
  30. package/src/presentation/molecules/ActiveFilterTags.tsx +19 -18
  31. package/src/presentation/molecules/Avatar.tsx +1 -1
  32. package/src/presentation/molecules/CodeBlock.tsx +50 -48
  33. package/src/presentation/molecules/InputGroup.tsx +1 -1
  34. package/src/presentation/molecules/ListItem.tsx +40 -29
  35. package/src/presentation/molecules/Select.tsx +1 -1
  36. package/src/presentation/molecules/Toggle.tsx +4 -4
  37. package/src/presentation/molecules/index.ts +0 -3
  38. package/src/presentation/organisms/Alert.tsx +1 -1
  39. package/src/presentation/organisms/DataTable.tsx +26 -15
  40. package/src/presentation/organisms/Dialog.tsx +1 -1
  41. package/src/presentation/organisms/DropdownMenu.tsx +2 -2
  42. package/src/presentation/organisms/HoverCard.tsx +1 -1
  43. package/src/presentation/organisms/LoadingState.tsx +1 -5
  44. package/src/presentation/organisms/Popover.tsx +1 -1
  45. package/src/presentation/organisms/StatCard.tsx +2 -2
  46. package/src/presentation/organisms/Table.tsx +2 -2
  47. package/src/presentation/organisms/index.ts +0 -60
  48. package/src/styles/compile.css +18 -0
  49. package/src/styles/theme.css +131 -0
  50. package/src/domain/tokens/animation.tokens.ts +0 -87
  51. package/src/domain/tokens/color.tokens.ts +0 -95
  52. package/src/domain/tokens/radius.tokens.ts +0 -27
  53. package/src/domain/tokens/shadow.tokens.ts +0 -25
  54. package/src/domain/tokens/spacing.tokens.ts +0 -65
  55. package/src/domain/tokens/typography.tokens.ts +0 -74
  56. package/src/infrastructure/error/ErrorBoundary.tsx +0 -258
  57. package/src/infrastructure/error/ErrorDisplay.tsx +0 -346
  58. package/src/infrastructure/error/SuspenseWrapper.tsx +0 -133
  59. package/src/infrastructure/error/index.ts +0 -5
  60. package/src/infrastructure/performance/index.ts +0 -92
  61. package/src/infrastructure/performance/useLazyLoading.ts +0 -342
  62. package/src/infrastructure/performance/useMemoryOptimization.ts +0 -293
  63. package/src/infrastructure/performance/usePerformanceMonitor.ts +0 -158
  64. package/src/infrastructure/security/index.ts +0 -10
  65. package/src/infrastructure/security/security-config.ts +0 -171
  66. package/src/infrastructure/security/useFormValidation.ts +0 -216
  67. package/src/infrastructure/security/validation.ts +0 -246
  68. package/src/presentation/hooks/useLanguage.ts +0 -109
  69. package/src/presentation/molecules/Breadcrumb.tsx +0 -54
  70. package/src/presentation/organisms/AlertDialog.tsx +0 -181
  71. package/src/presentation/organisms/Calendar.tsx +0 -79
  72. package/src/presentation/organisms/Comments.tsx +0 -103
  73. package/src/presentation/organisms/ConfirmDialog.tsx +0 -97
  74. package/src/presentation/organisms/FilterBar.tsx +0 -244
  75. package/src/presentation/organisms/FilterSidebar.tsx +0 -172
  76. package/src/presentation/organisms/Footer.tsx +0 -86
  77. package/src/presentation/organisms/FormModal.tsx +0 -126
  78. package/src/presentation/organisms/Grid.tsx +0 -128
  79. package/src/presentation/organisms/ImageLightbox.tsx +0 -252
  80. package/src/presentation/organisms/MainNavbar.tsx +0 -320
  81. package/src/presentation/organisms/Modal.tsx +0 -173
  82. package/src/presentation/organisms/Navbar.tsx +0 -75
  83. package/src/presentation/organisms/NewsletterSignup.tsx +0 -165
  84. package/src/presentation/organisms/QuickActionCard.tsx +0 -93
@@ -1,246 +0,0 @@
1
- export interface ValidationResult {
2
- isValid: boolean;
3
- error?: string;
4
- }
5
-
6
- export interface ValidationConfig {
7
- allowHtml?: boolean;
8
- stripTags?: boolean;
9
- allowedTags?: string[];
10
- allowedAttributes?: string[];
11
- }
12
-
13
- /**
14
- * Input validation with XSS protection
15
- * Basic sanitization without external dependencies
16
- */
17
- export const validateInput = (
18
- input: string,
19
- maxLength: number = 1000,
20
- minLength: number = 0,
21
- config?: ValidationConfig
22
- ): ValidationResult => {
23
- const trimmed = input.trim();
24
-
25
- // Required field validation
26
- if (minLength > 0 && !trimmed) {
27
- return { isValid: false, error: "This field is required" };
28
- }
29
-
30
- // Length validation
31
- if (trimmed.length > maxLength) {
32
- return { isValid: false, error: `Must be less than ${maxLength} characters` };
33
- }
34
-
35
- if (trimmed.length < minLength) {
36
- return { isValid: false, error: `Must be at least ${minLength} characters` };
37
- }
38
-
39
- // HTML tag check for non-HTML content
40
- if (!config?.allowHtml) {
41
- // FIX: Better HTML detection that catches encoded variations
42
- const htmlPatterns = [
43
- /<[^>]*>/gi, // Standard HTML tags
44
- /&lt;[^&]*&gt;/gi, // HTML encoded tags
45
- /&lt;[a-z]/gi, // Partial encoded tags
46
- /javascript:/gi, // JavaScript protocol
47
- /vbscript:/gi, // VBScript protocol
48
- /data:text\/html/gi, // Data URI with HTML
49
- /on\w+\s*=/gi, // Inline event handlers
50
- /<script/gi, // Script tags (case-insensitive)
51
- /<\/script>/gi, // Closing script tags
52
- ];
53
-
54
- for (const pattern of htmlPatterns) {
55
- if (pattern.test(trimmed)) {
56
- return { isValid: false, error: "HTML tags or scripts are not allowed" };
57
- }
58
- }
59
- }
60
-
61
- return { isValid: true };
62
- };
63
-
64
- /**
65
- * Email validation with basic security checks
66
- */
67
- export const validateEmail = (email: string): ValidationResult => {
68
- const trimmed = email.trim();
69
-
70
- if (!trimmed) {
71
- return { isValid: false, error: "Email is required" };
72
- }
73
-
74
- // Check for HTML/script content
75
- if (/<[^>]*>/.test(trimmed)) {
76
- return { isValid: false, error: "Invalid characters in email address" };
77
- }
78
-
79
- // Email regex
80
- const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
81
-
82
- if (!emailRegex.test(trimmed)) {
83
- return { isValid: false, error: "Please enter a valid email address" };
84
- }
85
-
86
- // Check for suspicious patterns
87
- const suspiciousPatterns = [
88
- /javascript:/gi,
89
- /data:/gi,
90
- /<[^>]*>/gi
91
- ];
92
-
93
- for (const pattern of suspiciousPatterns) {
94
- if (pattern.test(trimmed)) {
95
- return { isValid: false, error: "Invalid email format" };
96
- }
97
- }
98
-
99
- return { isValid: true };
100
- };
101
-
102
- /**
103
- * URL validation with security checks
104
- */
105
- export const validateUrl = (url: string): ValidationResult => {
106
- const trimmed = url.trim();
107
-
108
- if (!trimmed) {
109
- return { isValid: false, error: "URL is required" };
110
- }
111
-
112
- // Check for HTML/script content
113
- if (/<[^>]*>/.test(trimmed)) {
114
- return { isValid: false, error: "Invalid characters in URL" };
115
- }
116
-
117
- try {
118
- const urlObj = new URL(trimmed);
119
-
120
- // Only allow safe protocols
121
- const allowedProtocols = ['http:', 'https:', 'ftp:', 'ftps:'];
122
- if (!allowedProtocols.includes(urlObj.protocol)) {
123
- return { isValid: false, error: "Only HTTP, HTTPS, and FTP URLs are allowed" };
124
- }
125
-
126
- return { isValid: true };
127
- } catch {
128
- return { isValid: false, error: "Please enter a valid URL" };
129
- }
130
- };
131
-
132
- /**
133
- * Required field validation
134
- */
135
- export const validateRequired = (value: string): ValidationResult => {
136
- const trimmed = value.trim();
137
-
138
- if (!trimmed) {
139
- return { isValid: false, error: "This field is required" };
140
- }
141
-
142
- return { isValid: true };
143
- };
144
-
145
- /**
146
- * Basic input sanitization
147
- * Removes potentially dangerous content
148
- */
149
- export const sanitizeInput = (
150
- input: string,
151
- config?: ValidationConfig
152
- ): string => {
153
- if (!input) return '';
154
-
155
- let sanitized = input.trim();
156
-
157
- // Remove dangerous content for non-HTML input
158
- if (!config?.allowHtml) {
159
- sanitized = sanitized
160
- .replace(/javascript:/gi, '')
161
- .replace(/vbscript:/gi, '')
162
- .replace(/data:text\/html/gi, '')
163
- .replace(/data:application\/javascript/gi, '')
164
- .replace(/on\w+\s*=/gi, '')
165
- .replace(/<[^>]*>/g, '');
166
- }
167
-
168
- // Limit length
169
- return sanitized.slice(0, config?.allowHtml ? 10000 : 1000);
170
- };
171
-
172
- /**
173
- * Validate and sanitize file names
174
- * Prevents directory traversal and other file-based attacks
175
- */
176
- export const validateFileName = (fileName: string): ValidationResult => {
177
- const trimmed = fileName.trim();
178
-
179
- if (!trimmed) {
180
- return { isValid: false, error: "File name is required" };
181
- }
182
-
183
- // FIX: Remove global flag from regex patterns to prevent lastIndex issues
184
- // Each pattern is tested once and should not have global flag
185
- const dangerousPatterns = [
186
- { pattern: /\.\./, name: 'Directory traversal' },
187
- { pattern: /[<>:"|?*]/, name: 'Invalid characters' },
188
- { pattern: /^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i, name: 'Windows reserved' },
189
- { pattern: /^\./, name: 'Hidden file' },
190
- { pattern: /\.$/, name: 'Trailing dot' },
191
- { pattern: /\s+$/, name: 'Trailing whitespace' }
192
- ];
193
-
194
- for (const { pattern, name } of dangerousPatterns) {
195
- if (pattern.test(trimmed)) {
196
- return { isValid: false, error: `Invalid file name: ${name}` };
197
- }
198
- }
199
-
200
- // Length check
201
- if (trimmed.length > 255) {
202
- return { isValid: false, error: "File name too long (max 255 characters)" };
203
- }
204
-
205
- return { isValid: true };
206
- };
207
-
208
- /**
209
- * Content Security Policy helper
210
- * Validates that content meets basic CSP requirements
211
- */
212
- export const validateCSPCompliance = (content: string): ValidationResult => {
213
- const violations = [];
214
-
215
- // FIX: Enhanced script detection - catch more variations
216
- const scriptPatterns = [
217
- /<script[^>]*>/gi,
218
- /<script/gi,
219
- /<\/script>/gi,
220
- /javascript:/gi,
221
- /vbscript:/gi,
222
- /data:\s*text\/html/gi,
223
- /data:\s*application\/javascript/gi
224
- ];
225
-
226
- for (const pattern of scriptPatterns) {
227
- if (pattern.test(content)) {
228
- violations.push("Potentially dangerous script content detected");
229
- break;
230
- }
231
- }
232
-
233
- // Check for inline styles (more lenient - styles are often used legitimately)
234
- if (/<style[^>]*>[\s\S]*?<\/style>/gi.test(content)) {
235
- violations.push("Inline style blocks not allowed");
236
- }
237
-
238
- if (violations.length > 0) {
239
- return {
240
- isValid: false,
241
- error: `Content Security Policy violations: ${violations.join(', ')}`
242
- };
243
- }
244
-
245
- return { isValid: true };
246
- };
@@ -1,109 +0,0 @@
1
- /**
2
- * useLanguage Hook
3
- * @description Language management with i18n integration
4
- */
5
-
6
- import { useTranslation } from 'react-i18next';
7
-
8
- export type Language = string;
9
-
10
- export interface SupportedLanguage {
11
- name: string;
12
- flag: string;
13
- }
14
-
15
- export interface UseLanguageReturn {
16
- currentLanguage: Language;
17
- changeLanguage: (language: Language) => void;
18
- t: (key: string, params?: Record<string, unknown>) => string;
19
- supportedLanguages: Record<Language, SupportedLanguage>;
20
- }
21
-
22
- /**
23
- * Validates if a language code exists in supported languages
24
- */
25
- function isValidLanguage(
26
- code: string,
27
- supportedLanguages: Record<Language, SupportedLanguage>
28
- ): boolean {
29
- return Object.keys(supportedLanguages).includes(code);
30
- }
31
-
32
- /**
33
- * Normalizes language code to match supported languages
34
- * Tries exact match first, then tries to match by language code prefix
35
- */
36
- function normalizeLanguage(
37
- code: string,
38
- supportedLanguages: Record<Language, SupportedLanguage>,
39
- defaultLanguage: Language
40
- ): Language {
41
- // If code is valid, return it
42
- if (isValidLanguage(code, supportedLanguages)) {
43
- return code;
44
- }
45
-
46
- // Try to extract language code (e.g., 'en-US' -> 'en')
47
- const [language] = code.split('-');
48
- const matchedKey = Object.keys(supportedLanguages).find((key) =>
49
- key.startsWith(language)
50
- );
51
-
52
- return (matchedKey as Language) || defaultLanguage;
53
- }
54
-
55
- /**
56
- * Language management hook with i18n integration
57
- *
58
- * @example
59
- * ```tsx
60
- * const { currentLanguage, changeLanguage, t, supportedLanguages } = useLanguage({
61
- * defaultLanguage: 'en-US',
62
- * supportedLanguages: {
63
- * 'en-US': { name: 'English', flag: '🇺🇸' },
64
- * 'tr-TR': { name: 'Türkçe', flag: '🇹🇷' },
65
- * }
66
- * });
67
- *
68
- * // Change language
69
- * changeLanguage('tr-TR');
70
- *
71
- * // Translate
72
- * const title = t('common.title');
73
- * ```
74
- */
75
- export function useLanguage(options?: {
76
- defaultLanguage?: Language;
77
- supportedLanguages?: Record<Language, SupportedLanguage>;
78
- }): UseLanguageReturn {
79
- const {
80
- defaultLanguage = 'en-US',
81
- supportedLanguages = {} as Record<Language, SupportedLanguage>,
82
- } = options || {};
83
-
84
- const { t, i18n } = useTranslation();
85
-
86
- // Safely get and validate current language
87
- const currentLanguage: Language = normalizeLanguage(
88
- i18n.language,
89
- supportedLanguages,
90
- defaultLanguage
91
- );
92
-
93
- const changeLanguage = (language: Language) => {
94
- // Validate language before changing
95
- if (isValidLanguage(language, supportedLanguages)) {
96
- i18n.changeLanguage(language);
97
- } else {
98
- // Fall back to default language
99
- i18n.changeLanguage(defaultLanguage);
100
- }
101
- };
102
-
103
- return {
104
- currentLanguage,
105
- changeLanguage,
106
- t,
107
- supportedLanguages,
108
- };
109
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * Breadcrumb Component (Molecule)
3
- * @description Navigation breadcrumb with home icon
4
- */
5
-
6
- // @ts-ignore - react-router-dom is a peer dependency, may not be available during package build
7
- import { Link } from 'react-router-dom';
8
- import type { BaseProps } from '../../domain/types';
9
-
10
- export interface BreadcrumbItem {
11
- label: string;
12
- href?: string;
13
- }
14
-
15
- export interface BreadcrumbProps extends BaseProps {
16
- items: BreadcrumbItem[];
17
- }
18
-
19
- export const Breadcrumb = ({ items, className }: BreadcrumbProps) => {
20
- return (
21
- <nav className={`flex items-center gap-2 text-sm mb-4 md:mb-6 ${className || ''}`} aria-label="Breadcrumb">
22
- {/* Home */}
23
- <Link
24
- to="/"
25
- className="flex items-center gap-1 text-text-secondary hover:text-primary-light transition-colors"
26
- aria-label="Home"
27
- >
28
- <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round">
29
- <path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
30
- <polyline points="9 22 9 12 15 12 15 22" />
31
- </svg>
32
- </Link>
33
-
34
- {/* Breadcrumb items */}
35
- {items.map((item, index) => (
36
- <div key={index} className="flex items-center gap-2">
37
- <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" className="text-text-secondary">
38
- <polyline points="9 18 15 12 9 6" />
39
- </svg>
40
- {item.href ? (
41
- <Link
42
- to={item.href}
43
- className="text-text-secondary hover:text-primary-light transition-colors"
44
- >
45
- {item.label}
46
- </Link>
47
- ) : (
48
- <span className="text-text-primary font-medium">{item.label}</span>
49
- )}
50
- </div>
51
- ))}
52
- </nav>
53
- );
54
- };
@@ -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 };