@brightweblabs/ui 1.2.0 → 1.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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@brightweblabs/ui",
3
3
  "private": false,
4
- "version": "1.2.0",
4
+ "version": "1.3.0",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
7
7
  "files": [
@@ -76,7 +76,7 @@
76
76
  "recharts": "^2.15.4",
77
77
  "sonner": "^2.0.7",
78
78
  "tailwind-merge": "^3.6.0",
79
- "@brightweblabs/theme": "0.5.1"
79
+ "@brightweblabs/theme": "0.6.0"
80
80
  },
81
81
  "peerDependencies": {
82
82
  "lucide-react": "^1.8.0",
@@ -3,14 +3,31 @@
3
3
  import * as React from "react";
4
4
  import { cn } from "../lib/utils";
5
5
 
6
- interface PasswordStrengthProps {
6
+ export type PasswordStrengthLevel = "weak" | "medium" | "strong" | null;
7
+
8
+ export interface PasswordStrengthLabels {
9
+ weak: string;
10
+ medium: string;
11
+ strong: string;
12
+ ariaLabel: string;
13
+ prefix: string;
14
+ }
15
+
16
+ export interface PasswordStrengthProps {
7
17
  password: string;
8
18
  className?: string;
19
+ labels?: Partial<PasswordStrengthLabels>;
9
20
  }
10
21
 
11
- type StrengthLevel = "weak" | "medium" | "strong" | null;
22
+ const defaultPasswordStrengthLabels: PasswordStrengthLabels = {
23
+ weak: "Fraca",
24
+ medium: "Média",
25
+ strong: "Forte",
26
+ ariaLabel: "Força da palavra-passe",
27
+ prefix: "Força",
28
+ };
12
29
 
13
- function calculatePasswordStrength(password: string): StrengthLevel {
30
+ export function calculatePasswordStrength(password: string): PasswordStrengthLevel {
14
31
  if (!password) return null;
15
32
 
16
33
  let score = 0;
@@ -31,37 +48,38 @@ function calculatePasswordStrength(password: string): StrengthLevel {
31
48
  return "strong";
32
49
  }
33
50
 
34
- function getStrengthConfig(strength: StrengthLevel) {
51
+ function getStrengthConfig(strength: PasswordStrengthLevel, labels: PasswordStrengthLabels) {
35
52
  switch (strength) {
36
53
  case "weak":
37
54
  return {
38
- label: "Fraca",
39
- color: "bg-rose-500",
55
+ label: labels.weak,
56
+ color: "bg-[color:var(--semantic-danger)]",
40
57
  width: "w-1/3",
41
- textColor: "text-rose-600 dark:text-rose-400",
58
+ textColor: "text-[color:var(--semantic-danger-strong)]",
42
59
  };
43
60
  case "medium":
44
61
  return {
45
- label: "Média",
46
- color: "bg-amber-500",
62
+ label: labels.medium,
63
+ color: "bg-[color:var(--semantic-warning)]",
47
64
  width: "w-2/3",
48
- textColor: "text-amber-600 dark:text-amber-400",
65
+ textColor: "text-[color:var(--semantic-warning-strong)]",
49
66
  };
50
67
  case "strong":
51
68
  return {
52
- label: "Forte",
53
- color: "bg-emerald-500",
69
+ label: labels.strong,
70
+ color: "bg-[color:var(--semantic-success)]",
54
71
  width: "w-full",
55
- textColor: "text-emerald-600 dark:text-emerald-400",
72
+ textColor: "text-[color:var(--semantic-success-strong)]",
56
73
  };
57
74
  default:
58
75
  return null;
59
76
  }
60
77
  }
61
78
 
62
- export function PasswordStrength({ password, className }: PasswordStrengthProps) {
79
+ export function PasswordStrength({ password, className, labels: labelsOverride }: PasswordStrengthProps) {
80
+ const labels = { ...defaultPasswordStrengthLabels, ...labelsOverride };
63
81
  const strength = calculatePasswordStrength(password);
64
- const config = getStrengthConfig(strength);
82
+ const config = getStrengthConfig(strength, labels);
65
83
 
66
84
  if (!config) return null;
67
85
 
@@ -69,18 +87,18 @@ export function PasswordStrength({ password, className }: PasswordStrengthProps)
69
87
  <div className={cn("flex flex-col gap-1.5", className)}>
70
88
  <div className="h-1 w-full overflow-hidden rounded-full bg-foreground/10">
71
89
  <div
72
- className={cn("h-full transition-all duration-300", config.color, config.width)}
90
+ className={cn("h-full transition-[width,background-color] duration-300 motion-reduce:transition-none", config.color, config.width)}
73
91
  role="progressbar"
74
92
  aria-valuenow={strength === "weak" ? 33 : strength === "medium" ? 66 : 100}
75
93
  aria-valuemin={0}
76
94
  aria-valuemax={100}
77
- aria-label="Força da palavra-passe"
95
+ aria-label={labels.ariaLabel}
78
96
  aria-valuetext={config.label}
79
97
  />
80
98
  </div>
81
99
 
82
- <p className={cn("text-meta !font-semibold transition-colors", config.textColor)}>
83
- Força: {config.label}
100
+ <p className={cn("text-meta !font-semibold transition-colors motion-reduce:transition-none", config.textColor)}>
101
+ {labels.prefix}: {config.label}
84
102
  </p>
85
103
  </div>
86
104
  );
package/src/index.ts CHANGED
@@ -16,7 +16,12 @@ export {
16
16
  export { Input } from "./components/input";
17
17
  export { PasswordInput } from "./components/password-input";
18
18
  export type { PasswordInputProps } from "./components/password-input";
19
- export { PasswordStrength } from "./components/password-strength";
19
+ export { PasswordStrength, calculatePasswordStrength } from "./components/password-strength";
20
+ export type {
21
+ PasswordStrengthLabels,
22
+ PasswordStrengthLevel,
23
+ PasswordStrengthProps,
24
+ } from "./components/password-strength";
20
25
  export { PhoneInput } from "./components/phone-input";
21
26
  export type { PhoneInputProps } from "./components/phone-input";
22
27
  export { SearchField } from "./components/search-field";