@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,165 +0,0 @@
1
- /**
2
- * NewsletterSignup Component (Organism)
3
- * @description Newsletter subscription form with email validation
4
- */
5
-
6
- import { useState, useEffect, useMemo } from 'react';
7
- import { cn } from '../../infrastructure/utils';
8
- import type { BaseProps } from '../../domain/types';
9
- import { Icon } from '../atoms/Icon';
10
-
11
- const SUBSCRIBER_COUNT_MIN = 1000;
12
- const SUBSCRIBER_COUNT_MAX = 6000;
13
-
14
- export interface NewsletterSignupProps extends BaseProps {
15
- onSubscribe?: (email: string) => Promise<void>;
16
- subscriberCountMin?: number;
17
- subscriberCountMax?: number;
18
- }
19
-
20
- export const NewsletterSignup = ({
21
- onSubscribe,
22
- subscriberCountMin = SUBSCRIBER_COUNT_MIN,
23
- subscriberCountMax = SUBSCRIBER_COUNT_MAX,
24
- className,
25
- }: NewsletterSignupProps) => {
26
- const [email, setEmail] = useState('');
27
- const [isSubscribed, setIsSubscribed] = useState(false);
28
- const [isLoading, setIsLoading] = useState(false);
29
- const [error, setError] = useState('');
30
-
31
- // FIXED: Generate random count per component instance, not at module load
32
- const subscriberCount = useMemo(
33
- () => Math.floor(Math.random() * (subscriberCountMax - subscriberCountMin + 1)) + subscriberCountMin,
34
- [subscriberCountMin, subscriberCountMax]
35
- );
36
-
37
- const validateEmail = (email: string) => {
38
- const re = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
39
- return re.test(email);
40
- };
41
-
42
- // Reset success message after 5 seconds with cleanup
43
- useEffect(() => {
44
- if (isSubscribed) {
45
- const timeout = setTimeout(() => {
46
- setIsSubscribed(false);
47
- }, 5000);
48
- return () => clearTimeout(timeout);
49
- }
50
- }, [isSubscribed]);
51
-
52
- const handleSubmit = async (e: React.FormEvent) => {
53
- e.preventDefault();
54
- setError('');
55
-
56
- // Validate email
57
- if (!email) {
58
- setError('Please enter your email address');
59
- return;
60
- }
61
-
62
- if (!validateEmail(email)) {
63
- setError('Please enter a valid email address');
64
- return;
65
- }
66
-
67
- setIsLoading(true);
68
-
69
- try {
70
- // Call the subscribe function if provided
71
- if (onSubscribe) {
72
- await onSubscribe(email);
73
- } else {
74
- // Simulate API call for demo purposes
75
- await new Promise(resolve => setTimeout(resolve, 1000));
76
- }
77
-
78
- setIsLoading(false);
79
- setIsSubscribed(true);
80
- setEmail('');
81
- } catch (err) {
82
- setIsLoading(false);
83
- setError('Failed to subscribe. Please try again.');
84
- }
85
- };
86
-
87
- if (isSubscribed) {
88
- return (
89
- <div className={cn('bg-bg-card rounded-xl p-4 border border-border', className)}>
90
- <div className="flex items-center gap-3 text-green-600">
91
- <Icon className="text-green-600" size="lg">
92
- <path
93
- strokeLinecap="round"
94
- strokeLinejoin="round"
95
- strokeWidth={2}
96
- d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
97
- />
98
- </Icon>
99
- <div>
100
- <div className="font-semibold text-sm">Thanks for subscribing!</div>
101
- <div className="text-xs text-text-secondary">Check your inbox to confirm your subscription</div>
102
- </div>
103
- </div>
104
- </div>
105
- );
106
- }
107
-
108
- return (
109
- <div className={cn('bg-bg-card rounded-xl p-4 border border-border', className)}>
110
- <div className="flex items-center gap-2 mb-3">
111
- <Icon className="text-primary-light" size="lg">
112
- <path
113
- strokeLinecap="round"
114
- strokeLinejoin="round"
115
- strokeWidth={2}
116
- d="M3 8l7.89 5.26a2 2 0 002.22 0l7.89-5.26a2 2 0 002.22 0L21 8V5a2 2 0 00-2-2H5a2 2 0 00-2 2v3a2 2 0 002.22 0z"
117
- />
118
- </Icon>
119
- <h3 className="text-sm font-semibold text-text-primary">Newsletter</h3>
120
- </div>
121
- <p className="text-xs text-text-secondary mb-3">
122
- Get the latest articles delivered straight to your inbox. No spam, ever.
123
- </p>
124
- <form onSubmit={handleSubmit} className="space-y-2">
125
- <input
126
- type="email"
127
- placeholder="your@email.com"
128
- value={email}
129
- onChange={(e) => setEmail(e.target.value)}
130
- className="w-full px-3 py-2 bg-bg-secondary text-text-primary rounded-lg border border-border focus:border-primary-light focus:outline-none placeholder-text-secondary/50 transition-theme text-sm"
131
- disabled={isLoading}
132
- />
133
- {error && (
134
- <p className="text-xs text-red-500">{error}</p>
135
- )}
136
- <button
137
- type="submit"
138
- disabled={isLoading}
139
- className="w-full flex items-center justify-center gap-2 px-4 py-2 bg-primary-gradient text-text-primary rounded-lg font-medium hover:shadow-lg transition-all disabled:opacity-50 disabled:cursor-not-allowed text-sm"
140
- >
141
- {isLoading ? (
142
- <>Subscribing...</>
143
- ) : (
144
- <>
145
- <Icon size="sm">
146
- <path
147
- strokeLinecap="round"
148
- strokeLinejoin="round"
149
- strokeWidth={2}
150
- d="M22 2L11 13M22 2l-7 20M2 2l15 15L2 2l15-15"
151
- />
152
- </Icon>
153
- Subscribe
154
- </>
155
- )}
156
- </button>
157
- </form>
158
- <p className="text-xs text-text-secondary mt-2">
159
- Join {subscriberCount.toLocaleString()}+ subscribers
160
- </p>
161
- </div>
162
- );
163
- };
164
-
165
- NewsletterSignup.displayName = 'NewsletterSignup';
@@ -1,93 +0,0 @@
1
- /**
2
- * QuickActionCard Component (Organism)
3
- * @description Card component for quick navigation actions with icon (Responsive)
4
- */
5
-
6
- import { forwardRef } from 'react';
7
- import { cn, getSpacing, getIconSize, getContainerSize, getTextSize, getGap } from '../../infrastructure/utils';
8
- import type { BaseProps, SizeVariant } from '../../domain/types';
9
-
10
- export interface QuickActionCardProps extends BaseProps {
11
- label: string;
12
- icon?: React.ComponentType<{ className?: string }>;
13
- iconColor?: string;
14
- iconBgColor?: string;
15
- onClick?: () => void;
16
- href?: string;
17
- size?: Extract<SizeVariant, 'sm' | 'md' | 'lg'>;
18
- target?: '_blank' | '_self' | '_parent' | '_top';
19
- responsiveLayout?: boolean; // Enable responsive layout changes
20
- }
21
-
22
- export const QuickActionCard = forwardRef<HTMLAnchorElement | HTMLDivElement, QuickActionCardProps>(
23
- (
24
- {
25
- className,
26
- label,
27
- icon: Icon,
28
- iconColor = 'text-white',
29
- iconBgColor = 'bg-primary',
30
- onClick,
31
- href,
32
- size = 'md',
33
- target = '_self',
34
- responsiveLayout = true,
35
- ...props
36
- },
37
- ref
38
- ) => {
39
- const content = (
40
- <>
41
- {Icon && (
42
- <div className={cn(getContainerSize(size), 'rounded-lg flex items-center justify-center flex-shrink-0', iconBgColor)}>
43
- <Icon className={cn(getIconSize(size), iconColor)} />
44
- </div>
45
- )}
46
- <span className={cn(
47
- 'font-medium text-foreground group-hover:text-primary transition-colors',
48
- getTextSize(size),
49
- responsiveLayout && 'text-center sm:text-left'
50
- )}>
51
- {label}
52
- </span>
53
- </>
54
- );
55
-
56
- const baseClasses = cn(
57
- 'bg-card border border-border rounded-xl',
58
- responsiveLayout ? 'flex flex-col sm:flex-row items-center justify-center sm:justify-start' : 'flex items-center',
59
- 'hover:border-primary/50 hover:shadow-md transition-all duration-200 group',
60
- getSpacing('p', size),
61
- getGap(size === 'sm' ? 'sm' : size),
62
- className
63
- );
64
-
65
- if (href) {
66
- return (
67
- <a
68
- ref={ref as React.Ref<HTMLAnchorElement>}
69
- href={href}
70
- target={target}
71
- className={baseClasses}
72
- onClick={onClick}
73
- {...props}
74
- >
75
- {content}
76
- </a>
77
- );
78
- }
79
-
80
- return (
81
- <div
82
- ref={ref as React.Ref<HTMLDivElement>}
83
- className={baseClasses}
84
- onClick={onClick}
85
- {...props}
86
- >
87
- {content}
88
- </div>
89
- );
90
- }
91
- );
92
-
93
- QuickActionCard.displayName = 'QuickActionCard';