@brightlocal/ui-components 0.2.0 → 0.3.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 (78) hide show
  1. package/dist/alert.cjs +1 -1
  2. package/dist/alert.d.ts +10 -1
  3. package/dist/alert.d.ts.map +1 -1
  4. package/dist/alert.js +6 -2
  5. package/dist/card.cjs +1 -1
  6. package/dist/card.d.ts +6 -2
  7. package/dist/card.d.ts.map +1 -1
  8. package/dist/card.js +89 -73
  9. package/dist/centred-layout.cjs +1 -1
  10. package/dist/centred-layout.d.ts +49 -25
  11. package/dist/centred-layout.d.ts.map +1 -1
  12. package/dist/centred-layout.js +57 -32
  13. package/dist/checkbox.d.ts.map +1 -1
  14. package/dist/chip.cjs +1 -0
  15. package/dist/chip.d.ts +61 -0
  16. package/dist/chip.d.ts.map +1 -0
  17. package/dist/chip.js +165 -0
  18. package/dist/combobox.cjs +1 -1
  19. package/dist/combobox.d.ts.map +1 -1
  20. package/dist/combobox.js +5 -2
  21. package/dist/date-picker.cjs +1 -1
  22. package/dist/date-picker.d.ts +89 -52
  23. package/dist/date-picker.d.ts.map +1 -1
  24. package/dist/date-picker.js +228 -210
  25. package/dist/dropdown-menu.d.ts.map +1 -1
  26. package/dist/header.cjs +1 -0
  27. package/dist/header.d.ts +42 -0
  28. package/dist/header.d.ts.map +1 -0
  29. package/dist/header.js +22 -0
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +3 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +426 -396
  34. package/dist/input-chip.cjs +1 -0
  35. package/dist/input-chip.d.ts +117 -0
  36. package/dist/input-chip.d.ts.map +1 -0
  37. package/dist/input-chip.js +284 -0
  38. package/dist/input-group.d.ts.map +1 -1
  39. package/dist/input-otp.cjs +1 -1
  40. package/dist/input-otp.d.ts +43 -36
  41. package/dist/input-otp.d.ts.map +1 -1
  42. package/dist/input-otp.js +140 -119
  43. package/dist/input-password.cjs +1 -1
  44. package/dist/input-password.d.ts +147 -19
  45. package/dist/input-password.d.ts.map +1 -1
  46. package/dist/input-password.js +197 -92
  47. package/dist/input.cjs +1 -1
  48. package/dist/input.js +1 -1
  49. package/dist/progress.cjs +1 -1
  50. package/dist/progress.d.ts +10 -0
  51. package/dist/progress.d.ts.map +1 -1
  52. package/dist/progress.js +45 -36
  53. package/dist/select.d.ts.map +1 -1
  54. package/dist/slider.cjs +1 -1
  55. package/dist/slider.d.ts +31 -3
  56. package/dist/slider.d.ts.map +1 -1
  57. package/dist/slider.js +53 -43
  58. package/dist/textarea.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/src/components/alert.tsx +10 -1
  61. package/src/components/card.tsx +66 -38
  62. package/src/components/centred-layout.tsx +115 -38
  63. package/src/components/checkbox.tsx +2 -2
  64. package/src/components/chip.tsx +249 -0
  65. package/src/components/combobox.tsx +17 -13
  66. package/src/components/date-picker.tsx +410 -266
  67. package/src/components/dropdown-menu.tsx +6 -1
  68. package/src/components/header.tsx +69 -0
  69. package/src/components/input-chip.tsx +548 -0
  70. package/src/components/input-group.tsx +4 -1
  71. package/src/components/input-otp.tsx +159 -91
  72. package/src/components/input-password.tsx +469 -129
  73. package/src/components/input.tsx +1 -1
  74. package/src/components/progress.tsx +21 -2
  75. package/src/components/select.tsx +1 -3
  76. package/src/components/slider.tsx +85 -15
  77. package/src/components/textarea.tsx +4 -1
  78. package/src/index.ts +3 -0
@@ -12,184 +12,524 @@ import {
12
12
  InputGroupButton,
13
13
  } from "@brightlocal/ui-components/input-group";
14
14
 
15
- type PasswordStrength = "meter" | "weak" | "ok" | "good" | "great";
15
+ // ============================================================================
16
+ // Types
17
+ // ============================================================================
16
18
 
17
- interface PasswordStrengthConfig {
19
+ /**
20
+ * Default password strength levels (industry standard)
21
+ */
22
+ type DefaultPasswordStrength = "meter" | "weak" | "ok" | "good" | "great";
23
+
24
+ /**
25
+ * Configuration for a single strength level
26
+ */
27
+ interface StrengthLevelConfig {
18
28
  label: string;
19
29
  value: number;
20
30
  color: string;
21
31
  }
22
32
 
23
- const PASSWORD_STRENGTH: Record<PasswordStrength, PasswordStrengthConfig> = {
24
- meter: { label: "Meter", value: 0, color: "bg-muted" },
25
- weak: { label: "Weak", value: 25, color: "bg-red-500" },
26
- ok: { label: "Ok", value: 50, color: "bg-orange-500" },
33
+ /**
34
+ * Default strength levels configuration
35
+ */
36
+ const DEFAULT_STRENGTH_LEVELS: Record<
37
+ DefaultPasswordStrength,
38
+ StrengthLevelConfig
39
+ > = {
40
+ meter: { label: "Meter", value: 0, color: "bg-green-500" },
41
+ weak: { label: "Weak", value: 25, color: "bg-green-500" },
42
+ ok: { label: "Ok", value: 50, color: "bg-green-500" },
27
43
  good: { label: "Good", value: 75, color: "bg-green-500" },
28
- great: { label: "Great", value: 100, color: "bg-green-600" },
44
+ great: { label: "Great", value: 100, color: "bg-green-500" },
29
45
  };
30
46
 
31
- interface InputPasswordProps extends Omit<
32
- React.ComponentProps<"input">,
33
- "type"
47
+ /**
48
+ * Calculate password strength based on various criteria (default implementation)
49
+ * - Minimum 12 characters required for "ok" or better
50
+ */
51
+ function calculatePasswordStrength(password: string): DefaultPasswordStrength {
52
+ if (!password || password.length === 0) {
53
+ return "meter";
54
+ }
55
+
56
+ // Minimum 12 characters required for "ok" or better
57
+ if (password.length < 12) {
58
+ return "weak";
59
+ }
60
+
61
+ let score = 0;
62
+
63
+ // Length bonuses
64
+ if (password.length >= 16) score += 1;
65
+
66
+ // Character variety checks
67
+ if (/[a-z]/.test(password)) score += 1; // lowercase
68
+ if (/[A-Z]/.test(password)) score += 1; // uppercase
69
+ if (/[0-9]/.test(password)) score += 1; // numbers
70
+ if (/[^a-zA-Z0-9]/.test(password)) score += 1; // special characters
71
+
72
+ // Determine strength based on score
73
+ if (score <= 1) return "ok";
74
+ if (score <= 3) return "good";
75
+ return "great";
76
+ }
77
+
78
+ // ============================================================================
79
+ // Context
80
+ // ============================================================================
81
+
82
+ interface InputPasswordContextValue {
83
+ // Visibility state
84
+ showPassword: boolean;
85
+ setShowPassword: (show: boolean) => void;
86
+ toggleVisibility: () => void;
87
+
88
+ // Password value and strength
89
+ password: string;
90
+ setPassword: (password: string) => void;
91
+ strength: string;
92
+ strengthLevels: Record<string, StrengthLevelConfig>;
93
+
94
+ // Disabled state
95
+ disabled?: boolean;
96
+
97
+ // Data attributes
98
+ dataHook: string;
99
+ trackingEl?: string;
100
+ trackingLabel?: string;
101
+
102
+ // Input ID for label association
103
+ inputId: string;
104
+
105
+ // Error state
106
+ error?: boolean;
107
+ }
108
+
109
+ const InputPasswordContext =
110
+ React.createContext<InputPasswordContextValue | null>(null);
111
+
112
+ function useInputPasswordContext() {
113
+ const context = React.useContext(InputPasswordContext);
114
+ if (!context) {
115
+ throw new Error(
116
+ "InputPassword compound components must be used within InputPasswordRoot"
117
+ );
118
+ }
119
+ return context;
120
+ }
121
+
122
+ // ============================================================================
123
+ // InputPasswordRoot
124
+ // ============================================================================
125
+
126
+ export interface InputPasswordRootProps<
127
+ T extends string = DefaultPasswordStrength,
34
128
  > {
35
129
  /**
36
- * Show password strength indicator below the input
130
+ * Data hook for automated testing (REQUIRED)
37
131
  */
38
- showStrength?: boolean;
132
+ dataHook: string;
39
133
  /**
40
- * Callback when password strength changes
134
+ * Tracking element identifier for analytics
41
135
  */
42
- onStrengthChange?: (strength: PasswordStrength) => void;
136
+ trackingEl?: string;
43
137
  /**
44
- * Required data-hook attribute for testing
138
+ * Tracking label for analytics context
45
139
  */
46
- dataHook: string;
140
+ trackingLabel?: string;
47
141
  /**
48
- * Optional tracking element identifier
142
+ * Disabled state
49
143
  */
50
- trackingEl?: string;
144
+ disabled?: boolean;
51
145
  /**
52
- * Optional tracking label
146
+ * Controlled password value
53
147
  */
54
- trackingLabel?: string;
148
+ value?: string;
149
+ /**
150
+ * Callback fired when password changes
151
+ */
152
+ onChange?: (value: string) => void;
153
+ /**
154
+ * Callback fired when password strength changes
155
+ */
156
+ onStrengthChange?: (strength: T) => void;
157
+ /**
158
+ * Custom strength levels configuration.
159
+ * Define your own levels with custom keys, labels, values, and colors.
160
+ * @example
161
+ * strengthLevels={{
162
+ * empty: { label: "Enter password", value: 0, color: "bg-muted" },
163
+ * slow: { label: "Slow", value: 33, color: "bg-red-500" },
164
+ * medium: { label: "Medium", value: 66, color: "bg-yellow-500" },
165
+ * fast: { label: "Fast", value: 100, color: "bg-green-500" },
166
+ * }}
167
+ */
168
+ strengthLevels?: Record<T, StrengthLevelConfig>;
169
+ /**
170
+ * Custom function to calculate password strength.
171
+ * Must return a key from strengthLevels (or default levels if not provided).
172
+ * @default calculatePasswordStrength (built-in)
173
+ */
174
+ calculateStrength?: (password: string) => T;
55
175
  /**
56
176
  * Whether the input has an error state
57
177
  */
58
178
  error?: boolean;
179
+ /**
180
+ * ID for the input element (for label association)
181
+ */
182
+ id?: string;
183
+ /**
184
+ * Children components
185
+ */
186
+ children: React.ReactNode;
187
+ /**
188
+ * Additional class name for the root container
189
+ */
190
+ className?: string;
59
191
  }
60
192
 
61
193
  /**
62
- * Calculate password strength based on various criteria
194
+ * InputPasswordRoot - Root component that provides context for all InputPassword parts
195
+ *
196
+ * Generic type parameter T allows custom strength levels:
197
+ * @example
198
+ * // Using default levels
199
+ * <InputPasswordRoot dataHook="password">...</InputPasswordRoot>
200
+ *
201
+ * // Using custom levels
202
+ * type MyStrength = "empty" | "slow" | "medium" | "fast";
203
+ * <InputPasswordRoot<MyStrength>
204
+ * dataHook="password"
205
+ * strengthLevels={{
206
+ * empty: { label: "Enter password", value: 0, color: "bg-muted" },
207
+ * slow: { label: "Slow", value: 33, color: "bg-red-500" },
208
+ * medium: { label: "Medium", value: 66, color: "bg-yellow-500" },
209
+ * fast: { label: "Fast", value: 100, color: "bg-green-500" },
210
+ * }}
211
+ * calculateStrength={(password) => {
212
+ * if (!password) return "empty";
213
+ * if (password.length < 8) return "slow";
214
+ * if (password.length < 12) return "medium";
215
+ * return "fast";
216
+ * }}
217
+ * >
218
+ * ...
219
+ * </InputPasswordRoot>
63
220
  */
64
- function calculatePasswordStrength(password: string): PasswordStrength {
65
- if (!password || password.length === 0) {
66
- return "meter";
67
- }
221
+ function InputPasswordRoot<T extends string = DefaultPasswordStrength>({
222
+ children,
223
+ dataHook,
224
+ trackingEl,
225
+ trackingLabel,
226
+ disabled,
227
+ value,
228
+ onChange,
229
+ onStrengthChange,
230
+ strengthLevels,
231
+ calculateStrength,
232
+ error,
233
+ id,
234
+ className,
235
+ }: InputPasswordRootProps<T>) {
236
+ const [showPassword, setShowPassword] = React.useState(false);
237
+ const [internalPassword, setInternalPassword] = React.useState("");
238
+ const [strength, setStrength] = React.useState<string>("meter");
68
239
 
69
- let score = 0;
240
+ const generatedId = React.useId();
241
+ const inputId = id || generatedId;
70
242
 
71
- // Length check
72
- if (password.length >= 8) score += 1;
73
- if (password.length >= 12) score += 1;
243
+ const password = value !== undefined ? value : internalPassword;
74
244
 
75
- // Character variety checks
76
- if (/[a-z]/.test(password)) score += 1; // lowercase
77
- if (/[A-Z]/.test(password)) score += 1; // uppercase
78
- if (/[0-9]/.test(password)) score += 1; // numbers
79
- if (/[^a-zA-Z0-9]/.test(password)) score += 1; // special characters
245
+ // Use provided levels or defaults
246
+ const levels = (strengthLevels ?? DEFAULT_STRENGTH_LEVELS) as Record<
247
+ string,
248
+ StrengthLevelConfig
249
+ >;
80
250
 
81
- // Determine strength based on score
82
- if (score <= 2) return "weak";
83
- if (score <= 3) return "ok";
84
- if (score <= 4) return "good";
85
- return "great";
86
- }
251
+ // Use provided calculator or default
252
+ const calculator =
253
+ calculateStrength ?? (calculatePasswordStrength as (password: string) => T);
87
254
 
88
- const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(
89
- (
90
- {
91
- className,
92
- showStrength = true,
93
- onStrengthChange,
255
+ const handleSetPassword = React.useCallback(
256
+ (newPassword: string) => {
257
+ if (value === undefined) {
258
+ setInternalPassword(newPassword);
259
+ }
260
+ onChange?.(newPassword);
261
+ },
262
+ [value, onChange]
263
+ );
264
+
265
+ const toggleVisibility = React.useCallback(() => {
266
+ setShowPassword((prev) => !prev);
267
+ }, []);
268
+
269
+ // Calculate password strength with debounce
270
+ React.useEffect(() => {
271
+ const timeoutId = setTimeout(() => {
272
+ const newStrength = calculator(password);
273
+ setStrength(newStrength);
274
+ onStrengthChange?.(newStrength);
275
+ }, 180);
276
+
277
+ return () => clearTimeout(timeoutId);
278
+ }, [password, calculator, onStrengthChange]);
279
+
280
+ const contextValue = React.useMemo<InputPasswordContextValue>(
281
+ () => ({
282
+ showPassword,
283
+ setShowPassword,
284
+ toggleVisibility,
285
+ password,
286
+ setPassword: handleSetPassword,
287
+ strength,
288
+ strengthLevels: levels,
289
+ disabled,
94
290
  dataHook,
95
291
  trackingEl,
96
292
  trackingLabel,
97
- onChange,
98
- value,
99
- id,
293
+ inputId,
100
294
  error,
295
+ }),
296
+ [
297
+ showPassword,
298
+ toggleVisibility,
299
+ password,
300
+ handleSetPassword,
301
+ strength,
302
+ levels,
303
+ disabled,
304
+ dataHook,
305
+ trackingEl,
306
+ trackingLabel,
307
+ inputId,
308
+ error,
309
+ ]
310
+ );
311
+
312
+ return (
313
+ <InputPasswordContext.Provider value={contextValue}>
314
+ <div className={cn("w-full", className)}>{children}</div>
315
+ </InputPasswordContext.Provider>
316
+ );
317
+ }
318
+
319
+ InputPasswordRoot.displayName = "InputPasswordRoot";
320
+
321
+ // ============================================================================
322
+ // InputPasswordField
323
+ // ============================================================================
324
+
325
+ export interface InputPasswordFieldProps extends Omit<
326
+ React.ComponentProps<typeof InputGroupInput>,
327
+ "type"
328
+ > {
329
+ /**
330
+ * Additional class name for the InputGroup wrapper
331
+ */
332
+ groupClassName?: string;
333
+ }
334
+
335
+ /**
336
+ * InputPasswordField - The password input field with toggle button
337
+ * Wraps InputGroup with InputGroupInput and InputGroupAddon for the toggle
338
+ */
339
+ const InputPasswordField = React.forwardRef<
340
+ HTMLInputElement,
341
+ InputPasswordFieldProps
342
+ >(({ className, groupClassName, onChange, ...props }, ref) => {
343
+ const {
344
+ showPassword,
345
+ toggleVisibility,
346
+ password,
347
+ setPassword,
348
+ disabled,
349
+ dataHook,
350
+ trackingEl,
351
+ trackingLabel,
352
+ inputId,
353
+ error,
354
+ } = useInputPasswordContext();
355
+
356
+ const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
357
+ setPassword(e.target.value);
358
+ onChange?.(e);
359
+ };
360
+
361
+ return (
362
+ <InputGroup className={groupClassName} dataHook={dataHook} error={error}>
363
+ <InputGroupInput
364
+ ref={ref}
365
+ className={className}
366
+ disabled={disabled}
367
+ id={inputId}
368
+ trackingEl={trackingEl}
369
+ trackingLabel={trackingLabel}
370
+ type={showPassword ? "text" : "password"}
371
+ value={password}
372
+ onChange={handleChange}
373
+ {...props}
374
+ />
375
+ <InputGroupAddon align="inline-end">
376
+ <InputGroupButton
377
+ aria-label={showPassword ? "Hide password" : "Show password"}
378
+ data-hook={`${dataHook}-toggle`}
379
+ disabled={disabled}
380
+ size="icon"
381
+ variant="ghost"
382
+ onClick={toggleVisibility}
383
+ >
384
+ {showPassword ? (
385
+ <EyeOff className="h-4 w-4" />
386
+ ) : (
387
+ <Eye className="h-4 w-4" />
388
+ )}
389
+ </InputGroupButton>
390
+ </InputGroupAddon>
391
+ </InputGroup>
392
+ );
393
+ });
394
+
395
+ InputPasswordField.displayName = "InputPasswordField";
396
+
397
+ // ============================================================================
398
+ // InputPasswordToggle
399
+ // ============================================================================
400
+
401
+ export interface InputPasswordToggleProps extends Omit<
402
+ React.ComponentProps<typeof InputGroupButton>,
403
+ "onClick" | "aria-label"
404
+ > {
405
+ /**
406
+ * Custom aria-label for show state
407
+ * @default "Show password"
408
+ */
409
+ showLabel?: string;
410
+ /**
411
+ * Custom aria-label for hide state
412
+ * @default "Hide password"
413
+ */
414
+ hideLabel?: string;
415
+ }
416
+
417
+ /**
418
+ * InputPasswordToggle - Standalone toggle button for password visibility
419
+ * Use this when you need custom placement of the toggle button
420
+ */
421
+ const InputPasswordToggle = React.forwardRef<
422
+ HTMLButtonElement,
423
+ InputPasswordToggleProps
424
+ >(
425
+ (
426
+ {
427
+ className,
428
+ showLabel = "Show password",
429
+ hideLabel = "Hide password",
430
+ size = "icon",
431
+ variant = "ghost",
101
432
  ...props
102
433
  },
103
434
  ref
104
435
  ) => {
105
- const [showPassword, setShowPassword] = React.useState(false);
106
- const [strength, setStrength] = React.useState<PasswordStrength>("meter");
107
- const [internalValue, setInternalValue] = React.useState("");
436
+ const { showPassword, toggleVisibility, disabled, dataHook } =
437
+ useInputPasswordContext();
108
438
 
109
- const generatedId = React.useId();
110
- const inputId = id || generatedId;
111
- const currentValue = value !== undefined ? String(value) : internalValue;
439
+ return (
440
+ <InputGroupButton
441
+ ref={ref}
442
+ aria-label={showPassword ? hideLabel : showLabel}
443
+ className={className}
444
+ data-hook={`${dataHook}-toggle`}
445
+ disabled={disabled}
446
+ size={size}
447
+ variant={variant}
448
+ onClick={toggleVisibility}
449
+ {...props}
450
+ >
451
+ {showPassword ? (
452
+ <EyeOff className="h-4 w-4" />
453
+ ) : (
454
+ <Eye className="h-4 w-4" />
455
+ )}
456
+ </InputGroupButton>
457
+ );
458
+ }
459
+ );
112
460
 
113
- // Calculate password strength with debounce
114
- React.useEffect(() => {
115
- const timeoutId = setTimeout(() => {
116
- const newStrength = calculatePasswordStrength(currentValue);
117
- setStrength(newStrength);
118
- onStrengthChange?.(newStrength);
119
- }, 180);
461
+ InputPasswordToggle.displayName = "InputPasswordToggle";
120
462
 
121
- return () => clearTimeout(timeoutId);
122
- }, [currentValue, onStrengthChange]);
463
+ // ============================================================================
464
+ // InputPasswordStrength
465
+ // ============================================================================
123
466
 
124
- const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
125
- setInternalValue(e.target.value);
126
- onChange?.(e);
127
- };
467
+ export interface InputPasswordStrengthProps {
468
+ /**
469
+ * Additional class name
470
+ */
471
+ className?: string;
472
+ /**
473
+ * Whether to show the label next to the progress bar
474
+ * @default true
475
+ */
476
+ showLabel?: boolean;
477
+ }
128
478
 
129
- const togglePasswordVisibility = () => {
130
- setShowPassword((prev) => !prev);
131
- };
479
+ /**
480
+ * InputPasswordStrength - Password strength indicator
481
+ * Displays a progress bar and optional label showing password strength.
482
+ * Automatically uses the strength levels configured on InputPasswordRoot.
483
+ */
484
+ function InputPasswordStrength({
485
+ className,
486
+ showLabel = true,
487
+ }: InputPasswordStrengthProps) {
488
+ const { strength, strengthLevels, dataHook, disabled } =
489
+ useInputPasswordContext();
132
490
 
133
- const strengthConfig = PASSWORD_STRENGTH[strength];
491
+ // Get config for current strength level
492
+ const config = strengthLevels[strength] ?? {
493
+ label: strength,
494
+ value: 0,
495
+ color: "bg-muted",
496
+ };
134
497
 
135
- return (
136
- <div className="w-full">
137
- <InputGroup className={className} dataHook={dataHook} error={error}>
138
- <InputGroupInput
139
- ref={ref}
140
- id={inputId}
141
- trackingEl={trackingEl}
142
- trackingLabel={trackingLabel}
143
- type={showPassword ? "text" : "password"}
144
- value={value}
145
- onChange={handleChange}
146
- {...props}
147
- />
148
- <InputGroupAddon align="inline-end">
149
- <InputGroupButton
150
- aria-label={showPassword ? "Hide password" : "Show password"}
151
- data-hook={dataHook ? `${dataHook}-toggle` : undefined}
152
- disabled={props.disabled}
153
- size="icon"
154
- variant="ghost"
155
- onClick={togglePasswordVisibility}
156
- >
157
- {showPassword ? (
158
- <EyeOff className="h-4 w-4" />
159
- ) : (
160
- <Eye className="h-4 w-4" />
161
- )}
162
- </InputGroupButton>
163
- </InputGroupAddon>
164
- </InputGroup>
165
-
166
- {showStrength && (
167
- <div className="mt-1 space-y-2">
168
- <div className="flex items-center gap-2">
169
- <Progress
170
- className={cn("h-2 flex-1")}
171
- dataHook={
172
- dataHook
173
- ? `${dataHook}-strength-progress`
174
- : "password-strength-progress"
175
- }
176
- value={strengthConfig.value}
177
- />
178
- <span
179
- className="text-foreground w-10 shrink-0 text-right text-sm font-medium whitespace-nowrap"
180
- data-hook={dataHook ? `${dataHook}-strength-label` : undefined}
181
- >
182
- {strengthConfig.label}
183
- </span>
184
- </div>
185
- </div>
498
+ return (
499
+ <div className={cn("mt-1 space-y-2", className)}>
500
+ <div className={cn("flex items-center gap-2", disabled && "opacity-50")}>
501
+ <Progress
502
+ className="h-2 flex-1"
503
+ dataHook={`${dataHook}-strength-progress`}
504
+ indicatorClassName={config.color}
505
+ value={config.value}
506
+ />
507
+ {showLabel && (
508
+ <span
509
+ className="text-foreground w-10 shrink-0 text-right text-sm font-medium whitespace-nowrap"
510
+ data-hook={`${dataHook}-strength-label`}
511
+ >
512
+ {config.label}
513
+ </span>
186
514
  )}
187
515
  </div>
188
- );
189
- }
190
- );
516
+ </div>
517
+ );
518
+ }
519
+
520
+ InputPasswordStrength.displayName = "InputPasswordStrength";
191
521
 
192
- InputPassword.displayName = "InputPassword";
522
+ // ============================================================================
523
+ // Exports
524
+ // ============================================================================
525
+
526
+ export {
527
+ InputPasswordRoot,
528
+ InputPasswordField,
529
+ InputPasswordToggle,
530
+ InputPasswordStrength,
531
+ calculatePasswordStrength,
532
+ DEFAULT_STRENGTH_LEVELS,
533
+ };
193
534
 
194
- export { InputPassword, calculatePasswordStrength, PASSWORD_STRENGTH };
195
- export type { InputPasswordProps, PasswordStrength };
535
+ export type { DefaultPasswordStrength, StrengthLevelConfig };
@@ -119,7 +119,7 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
119
119
  className={cn(
120
120
  inputVariants({ hasIcon, hasSecondaryIcon }),
121
121
  hasError &&
122
- "border-red-600/40 dark:border-red-400/60 focus-visible:border-destructive focus-visible:shadow-destructive",
122
+ "focus-visible:border-destructive focus-visible:shadow-destructive border-red-600/40 dark:border-red-400/60",
123
123
  className
124
124
  )}
125
125
  data-hook={dataHook}