@zentauri-ui/zentauri-components 2.2.0 → 2.2.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.
- package/README.md +9 -7
- package/cli/props.json +1495 -798
- package/cli/registry.json +12 -0
- package/dist/chunk-46HJFCP7.js +87 -0
- package/dist/chunk-46HJFCP7.js.map +1 -0
- package/dist/{chunk-EPJYLBXV.js → chunk-5I4GAURE.js} +6 -6
- package/dist/{chunk-EPJYLBXV.js.map → chunk-5I4GAURE.js.map} +1 -1
- package/dist/chunk-ATE5SCTR.mjs +39 -0
- package/dist/chunk-ATE5SCTR.mjs.map +1 -0
- package/dist/chunk-DIAA5VH4.mjs +64 -0
- package/dist/chunk-DIAA5VH4.mjs.map +1 -0
- package/dist/{chunk-AMNJ35TT.mjs → chunk-GFE6ZX5Y.mjs} +25 -6
- package/dist/chunk-GFE6ZX5Y.mjs.map +1 -0
- package/dist/chunk-H3BJOK22.js +74 -0
- package/dist/chunk-H3BJOK22.js.map +1 -0
- package/dist/chunk-HR6MGXNI.mjs +212 -0
- package/dist/chunk-HR6MGXNI.mjs.map +1 -0
- package/dist/chunk-ILPPXWR3.js +19 -0
- package/dist/{chunk-VQJXOJ7G.js.map → chunk-ILPPXWR3.js.map} +1 -1
- package/dist/{chunk-YTCVWOBC.js → chunk-IY72Z65Z.js} +12 -12
- package/dist/{chunk-YTCVWOBC.js.map → chunk-IY72Z65Z.js.map} +1 -1
- package/dist/chunk-LOEKM3FL.mjs +78 -0
- package/dist/chunk-LOEKM3FL.mjs.map +1 -0
- package/dist/{chunk-5XSW5JYA.mjs → chunk-N2G7IWHS.mjs} +4 -4
- package/dist/{chunk-5XSW5JYA.mjs.map → chunk-N2G7IWHS.mjs.map} +1 -1
- package/dist/{chunk-37KMH77M.mjs → chunk-NUV2I337.mjs} +3 -3
- package/dist/{chunk-37KMH77M.mjs.map → chunk-NUV2I337.mjs.map} +1 -1
- package/dist/chunk-PQ2XTY3M.js +44 -0
- package/dist/chunk-PQ2XTY3M.js.map +1 -0
- package/dist/{chunk-F3G3RL2N.js → chunk-UZ6Y5CSV.js} +25 -6
- package/dist/chunk-UZ6Y5CSV.js.map +1 -0
- package/dist/{chunk-TACF7MJE.mjs → chunk-W5MTZJPE.mjs} +3 -3
- package/dist/{chunk-TACF7MJE.mjs.map → chunk-W5MTZJPE.mjs.map} +1 -1
- package/dist/chunk-WMM42MAC.js +222 -0
- package/dist/chunk-WMM42MAC.js.map +1 -0
- package/dist/design-system/facade.js +8 -6
- package/dist/design-system/facade.js.map +1 -1
- package/dist/design-system/facade.mjs +7 -5
- package/dist/design-system/facade.mjs.map +1 -1
- package/dist/design-system/index.d.ts +2 -0
- package/dist/design-system/index.d.ts.map +1 -1
- package/dist/design-system/password-strength-meter.d.ts +74 -0
- package/dist/design-system/password-strength-meter.d.ts.map +1 -0
- package/dist/design-system/secret-reveal.d.ts +57 -0
- package/dist/design-system/secret-reveal.d.ts.map +1 -0
- package/dist/ui/buttons/animated.js +10 -8
- package/dist/ui/buttons/animated.js.map +1 -1
- package/dist/ui/buttons/animated.mjs +8 -6
- package/dist/ui/buttons/animated.mjs.map +1 -1
- package/dist/ui/buttons.js +11 -9
- package/dist/ui/buttons.mjs +9 -7
- package/dist/ui/data-table.js +21 -19
- package/dist/ui/data-table.js.map +1 -1
- package/dist/ui/data-table.mjs +11 -9
- package/dist/ui/data-table.mjs.map +1 -1
- package/dist/ui/dynamic-stepper.js +20 -18
- package/dist/ui/dynamic-stepper.js.map +1 -1
- package/dist/ui/dynamic-stepper.mjs +9 -7
- package/dist/ui/dynamic-stepper.mjs.map +1 -1
- package/dist/ui/pagination.js +12 -10
- package/dist/ui/pagination.mjs +9 -7
- package/dist/ui/password-strength-meter/animated/animations.d.ts +3 -0
- package/dist/ui/password-strength-meter/animated/animations.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/animated/index.d.ts +4 -0
- package/dist/ui/password-strength-meter/animated/index.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/animated/password-strength-meter-animated.d.ts +14 -0
- package/dist/ui/password-strength-meter/animated/password-strength-meter-animated.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/animated/types.d.ts +21 -0
- package/dist/ui/password-strength-meter/animated/types.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/animated.js +169 -0
- package/dist/ui/password-strength-meter/animated.js.map +1 -0
- package/dist/ui/password-strength-meter/animated.mjs +165 -0
- package/dist/ui/password-strength-meter/animated.mjs.map +1 -0
- package/dist/ui/password-strength-meter/index.d.ts +5 -0
- package/dist/ui/password-strength-meter/index.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/password-strength-meter-base.d.ts +17 -0
- package/dist/ui/password-strength-meter/password-strength-meter-base.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/password-strength-meter.d.ts +6 -0
- package/dist/ui/password-strength-meter/password-strength-meter.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/types.d.ts +33 -0
- package/dist/ui/password-strength-meter/types.d.ts.map +1 -0
- package/dist/ui/password-strength-meter/variants.d.ts +13 -0
- package/dist/ui/password-strength-meter/variants.d.ts.map +1 -0
- package/dist/ui/password-strength-meter.js +37 -0
- package/dist/ui/password-strength-meter.js.map +1 -0
- package/dist/ui/password-strength-meter.mjs +16 -0
- package/dist/ui/password-strength-meter.mjs.map +1 -0
- package/dist/ui/secret-reveal/animated/animations.d.ts +8 -0
- package/dist/ui/secret-reveal/animated/animations.d.ts.map +1 -0
- package/dist/ui/secret-reveal/animated/index.d.ts +4 -0
- package/dist/ui/secret-reveal/animated/index.d.ts.map +1 -0
- package/dist/ui/secret-reveal/animated/secret-reveal-animated.d.ts +6 -0
- package/dist/ui/secret-reveal/animated/secret-reveal-animated.d.ts.map +1 -0
- package/dist/ui/secret-reveal/animated/types.d.ts +9 -0
- package/dist/ui/secret-reveal/animated/types.d.ts.map +1 -0
- package/dist/ui/secret-reveal/animated.js +194 -0
- package/dist/ui/secret-reveal/animated.js.map +1 -0
- package/dist/ui/secret-reveal/animated.mjs +191 -0
- package/dist/ui/secret-reveal/animated.mjs.map +1 -0
- package/dist/ui/secret-reveal/index.d.ts +4 -0
- package/dist/ui/secret-reveal/index.d.ts.map +1 -0
- package/dist/ui/secret-reveal/secret-reveal-base.d.ts +6 -0
- package/dist/ui/secret-reveal/secret-reveal-base.d.ts.map +1 -0
- package/dist/ui/secret-reveal/secret-reveal.d.ts +2 -0
- package/dist/ui/secret-reveal/secret-reveal.d.ts.map +1 -0
- package/dist/ui/secret-reveal/types.d.ts +15 -0
- package/dist/ui/secret-reveal/types.d.ts.map +1 -0
- package/dist/ui/secret-reveal/variants.d.ts +15 -0
- package/dist/ui/secret-reveal/variants.d.ts.map +1 -0
- package/dist/ui/secret-reveal.js +136 -0
- package/dist/ui/secret-reveal.js.map +1 -0
- package/dist/ui/secret-reveal.mjs +119 -0
- package/dist/ui/secret-reveal.mjs.map +1 -0
- package/dist/ui/split-button.js +22 -20
- package/dist/ui/split-button.js.map +1 -1
- package/dist/ui/split-button.mjs +9 -7
- package/dist/ui/split-button.mjs.map +1 -1
- package/package.json +1 -1
- package/src/design-system/index.ts +2 -0
- package/src/design-system/password-strength-meter.ts +115 -0
- package/src/design-system/secret-reveal.ts +75 -0
- package/src/ui/password-strength-meter/animated/animations.ts +10 -0
- package/src/ui/password-strength-meter/animated/index.ts +14 -0
- package/src/ui/password-strength-meter/animated/password-strength-meter-animated.tsx +186 -0
- package/src/ui/password-strength-meter/animated/types.ts +35 -0
- package/src/ui/password-strength-meter/index.ts +18 -0
- package/src/ui/password-strength-meter/password-strength-meter-base.tsx +202 -0
- package/src/ui/password-strength-meter/password-strength-meter.test.tsx +103 -0
- package/src/ui/password-strength-meter/password-strength-meter.tsx +8 -0
- package/src/ui/password-strength-meter/types.ts +40 -0
- package/src/ui/password-strength-meter/variants.ts +49 -0
- package/src/ui/secret-reveal/animated/animations.ts +74 -0
- package/src/ui/secret-reveal/animated/index.ts +5 -0
- package/src/ui/secret-reveal/animated/secret-reveal-animated.tsx +132 -0
- package/src/ui/secret-reveal/animated/types.ts +11 -0
- package/src/ui/secret-reveal/index.ts +14 -0
- package/src/ui/secret-reveal/secret-reveal-base.tsx +116 -0
- package/src/ui/secret-reveal/secret-reveal.test.tsx +75 -0
- package/src/ui/secret-reveal/secret-reveal.tsx +2 -0
- package/src/ui/secret-reveal/types.ts +21 -0
- package/src/ui/secret-reveal/variants.ts +49 -0
- package/dist/chunk-AMNJ35TT.mjs.map +0 -1
- package/dist/chunk-F3G3RL2N.js.map +0 -1
- package/dist/chunk-VQJXOJ7G.js +0 -19
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export const zuiSecretRevealContainerBase =
|
|
2
|
+
"inline-flex items-center gap-2 rounded-xl border px-3 py-2";
|
|
3
|
+
|
|
4
|
+
export const zuiSecretRevealLabelBase = "font-medium";
|
|
5
|
+
|
|
6
|
+
export const zuiSecretRevealValueBase = "font-mono tracking-wider select-all";
|
|
7
|
+
|
|
8
|
+
export const zuiSecretRevealToggleBase =
|
|
9
|
+
"inline-flex items-center justify-center rounded-lg transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-sky-500";
|
|
10
|
+
|
|
11
|
+
const zuiSecretRevealFg =
|
|
12
|
+
"text-[color:var(--zui-secret-reveal-fg,var(--zui-fg,oklch(20.8%_0.042_265.755)))] dark:text-[color:var(--zui-secret-reveal-fg-dark,var(--zui-fg-dark,oklch(98.4%_0.003_247.858)))]";
|
|
13
|
+
|
|
14
|
+
const zuiSecretRevealInvertedFg =
|
|
15
|
+
"text-[color:var(--zui-secret-reveal-fg,var(--zui-fg-dark,oklch(98.4%_0.003_247.858)))] dark:text-[color:var(--zui-secret-reveal-fg-dark,var(--zui-fg,oklch(20.8%_0.042_265.755)))]";
|
|
16
|
+
|
|
17
|
+
const zuiSecretRevealGradientFg =
|
|
18
|
+
"text-[color:var(--zui-secret-reveal-fg,var(--zui-brand-fg,oklch(96.8%_0.007_247.896)))] dark:text-[color:var(--zui-secret-reveal-fg-dark,var(--zui-brand-fg-dark,oklch(98.4%_0.003_247.858)))]";
|
|
19
|
+
|
|
20
|
+
export const zuiSecretRevealAppearances = {
|
|
21
|
+
default: `border-[var(--zui-secret-reveal-default-border,var(--zui-border,oklch(87.5%_0.01_258.338)))] dark:border-[var(--zui-secret-reveal-default-border-dark,var(--zui-border-dark,oklch(27.9%_0.041_260.031)))] bg-[var(--zui-secret-reveal-default-bg,var(--zui-surface,oklch(96.8%_0.003_264.542)))] dark:bg-[var(--zui-secret-reveal-default-bg-dark,var(--zui-surface-dark,oklch(21.6%_0.036_260.031)))] ${zuiSecretRevealFg}`,
|
|
22
|
+
subtle: `border-transparent bg-[var(--zui-secret-reveal-subtle-bg,var(--zui-surface-muted,oklch(92.9%_0.013_255.508)))] dark:bg-[var(--zui-secret-reveal-subtle-bg-dark,var(--zui-surface-muted-dark,oklch(27.9%_0.041_260.031)))] ${zuiSecretRevealFg}`,
|
|
23
|
+
muted: `border-transparent bg-[var(--zui-secret-reveal-muted-bg,var(--zui-fg-muted,oklch(44.6%_0.043_257.281)))] dark:bg-[var(--zui-secret-reveal-muted-bg-dark,var(--zui-fg-muted-dark,oklch(86.9%_0.022_252.894)))] ${zuiSecretRevealInvertedFg}`,
|
|
24
|
+
primary: `border-[var(--zui-secret-reveal-primary-border,var(--zui-brand,oklch(20.8%_0.042_265.755)))] dark:border-[var(--zui-secret-reveal-primary-border-dark,var(--zui-brand-dark,oklch(98.4%_0.003_247.858)))] bg-[var(--zui-secret-reveal-primary-bg,var(--zui-brand,oklch(20.8%_0.042_265.755)))] dark:bg-[var(--zui-secret-reveal-primary-bg-dark,var(--zui-brand-dark,oklch(98.4%_0.003_247.858)))] ${zuiSecretRevealInvertedFg}`,
|
|
25
|
+
blue: `border-[var(--zui-secret-reveal-blue-border,var(--zui-color-blue,#2563eb))] dark:border-[var(--zui-secret-reveal-blue-border-dark,var(--zui-color-blue-dark,#3b82f6))] bg-[var(--zui-secret-reveal-blue-bg,oklch(93.5%_0.055_262.881))] dark:bg-[var(--zui-secret-reveal-blue-bg-dark,oklch(30.6%_0.126_262.881))] ${zuiSecretRevealFg}`,
|
|
26
|
+
cyan: `border-[var(--zui-secret-reveal-cyan-border,var(--zui-color-cyan,#0891b2))] dark:border-[var(--zui-secret-reveal-cyan-border-dark,var(--zui-color-cyan-dark,#22d3ee))] bg-[var(--zui-secret-reveal-cyan-bg,oklch(95%_0.025_236.42))] dark:bg-[var(--zui-secret-reveal-cyan-bg-dark,oklch(31.1%_0.085_231.74))] ${zuiSecretRevealFg}`,
|
|
27
|
+
green: `border-[var(--zui-secret-reveal-green-border,var(--zui-color-green,#16a34a))] dark:border-[var(--zui-secret-reveal-green-border-dark,var(--zui-color-green-dark,#22c55e))] bg-[var(--zui-secret-reveal-green-bg,oklch(94.2%_0.053_146.17))] dark:bg-[var(--zui-secret-reveal-green-bg-dark,oklch(30.8%_0.085_149.21))] ${zuiSecretRevealFg}`,
|
|
28
|
+
lime: `border-[var(--zui-secret-reveal-lime-border,var(--zui-color-lime,#65a30d))] dark:border-[var(--zui-secret-reveal-lime-border-dark,var(--zui-color-lime-dark,#a3e635))] bg-[var(--zui-secret-reveal-lime-bg,oklch(93.9%_0.077_125.02))] dark:bg-[var(--zui-secret-reveal-lime-bg-dark,oklch(33.1%_0.098_131.68))] ${zuiSecretRevealFg}`,
|
|
29
|
+
emerald: `border-[var(--zui-secret-reveal-emerald-border,var(--zui-color-emerald,oklch(69.6%_0.17_162.48)))] dark:border-[var(--zui-secret-reveal-emerald-border-dark,var(--zui-color-emerald-dark,oklch(43.2%_0.095_166.913)))] bg-[var(--zui-secret-reveal-emerald-bg,oklch(93.5%_0.062_163.17))] dark:bg-[var(--zui-secret-reveal-emerald-bg-dark,oklch(25.4%_0.065_166.91))] ${zuiSecretRevealFg}`,
|
|
30
|
+
indigo: `border-[var(--zui-secret-reveal-indigo-border,var(--zui-color-indigo,oklch(39.8%_0.195_277.366)))] dark:border-[var(--zui-secret-reveal-indigo-border-dark,var(--zui-color-indigo-dark,oklch(51.1%_0.262_276.966)))] bg-[var(--zui-secret-reveal-indigo-bg,oklch(92.8%_0.067_276.37))] dark:bg-[var(--zui-secret-reveal-indigo-bg-dark,oklch(27.5%_0.153_276.97))] ${zuiSecretRevealFg}`,
|
|
31
|
+
purple: `border-[var(--zui-secret-reveal-purple-border,var(--zui-color-purple,oklch(43.8%_0.218_303.724)))] dark:border-[var(--zui-secret-reveal-purple-border-dark,var(--zui-color-purple-dark,oklch(55.8%_0.288_302.321)))] bg-[var(--zui-secret-reveal-purple-bg,oklch(92.4%_0.075_302.32))] dark:bg-[var(--zui-secret-reveal-purple-bg-dark,oklch(27.8%_0.171_302.32))] ${zuiSecretRevealFg}`,
|
|
32
|
+
pink: `border-[var(--zui-secret-reveal-pink-border,var(--zui-color-pink,oklch(45.9%_0.187_3.815)))] dark:border-[var(--zui-secret-reveal-pink-border-dark,var(--zui-color-pink-dark,oklch(59.2%_0.249_0.584)))] bg-[var(--zui-secret-reveal-pink-bg,oklch(93.5%_0.048_3.82))] dark:bg-[var(--zui-secret-reveal-pink-bg-dark,oklch(29.1%_0.134_0.58))] ${zuiSecretRevealFg}`,
|
|
33
|
+
rose: `border-[var(--zui-secret-reveal-rose-border,var(--zui-color-rose,oklch(64.5%_0.246_16.439)))] dark:border-[var(--zui-secret-reveal-rose-border-dark,var(--zui-color-rose-dark,oklch(51.4%_0.222_16.935)))] bg-[var(--zui-secret-reveal-rose-bg,oklch(93.2%_0.065_16.44))] dark:bg-[var(--zui-secret-reveal-rose-bg-dark,oklch(30.2%_0.157_16.94))] ${zuiSecretRevealFg}`,
|
|
34
|
+
sky: `border-[var(--zui-secret-reveal-sky-border,var(--zui-color-sky,oklch(68.5%_0.169_237.323)))] dark:border-[var(--zui-secret-reveal-sky-border-dark,var(--zui-color-sky-dark,oklch(50%_0.134_242.749)))] bg-[var(--zui-secret-reveal-sky-bg,oklch(94.5%_0.041_237.32))] dark:bg-[var(--zui-secret-reveal-sky-bg-dark,oklch(29.4%_0.108_242.75))] ${zuiSecretRevealFg}`,
|
|
35
|
+
teal: `border-[var(--zui-secret-reveal-teal-border,var(--zui-color-teal,oklch(70.4%_0.14_182.503)))] dark:border-[var(--zui-secret-reveal-teal-border-dark,var(--zui-color-teal-dark,oklch(51.1%_0.096_186.391)))] bg-[var(--zui-secret-reveal-teal-bg,oklch(94.1%_0.046_182.5))] dark:bg-[var(--zui-secret-reveal-teal-bg-dark,oklch(30.2%_0.075_186.4))] ${zuiSecretRevealFg}`,
|
|
36
|
+
yellow: `border-[var(--zui-secret-reveal-yellow-border,var(--zui-color-yellow,oklch(79.5%_0.184_86.047)))] dark:border-[var(--zui-secret-reveal-yellow-border-dark,var(--zui-color-yellow-dark,oklch(47.6%_0.114_61.907)))] bg-[var(--zui-secret-reveal-yellow-bg,oklch(94.1%_0.06_86.05))] dark:bg-[var(--zui-secret-reveal-yellow-bg-dark,oklch(31.5%_0.084_61.91))] ${zuiSecretRevealFg}`,
|
|
37
|
+
orange: `border-[var(--zui-secret-reveal-orange-border,var(--zui-color-orange,oklch(70.5%_0.213_47.604)))] dark:border-[var(--zui-secret-reveal-orange-border-dark,var(--zui-color-orange-dark,oklch(47%_0.157_37.304)))] bg-[var(--zui-secret-reveal-orange-bg,oklch(93.5%_0.076_47.6))] dark:bg-[var(--zui-secret-reveal-orange-bg-dark,oklch(30.1%_0.129_37.3))] ${zuiSecretRevealFg}`,
|
|
38
|
+
red: `border-[var(--zui-secret-reveal-red-border,var(--zui-color-red,#dc2626))] dark:border-[var(--zui-secret-reveal-red-border-dark,var(--zui-color-red-dark,#ef4444))] bg-[var(--zui-secret-reveal-red-bg,oklch(93.9%_0.053_19.85))] dark:bg-[var(--zui-secret-reveal-red-bg-dark,oklch(32.1%_0.111_19.85))] ${zuiSecretRevealFg}`,
|
|
39
|
+
slate: `border-[var(--zui-secret-reveal-slate-border,var(--zui-color-slate,#475569))] dark:border-[var(--zui-secret-reveal-slate-border-dark,var(--zui-color-slate-dark,#64748b))] bg-[var(--zui-secret-reveal-slate-bg,oklch(92.8%_0.011_262.88))] dark:bg-[var(--zui-secret-reveal-slate-bg-dark,oklch(29.6%_0.036_262.88))] ${zuiSecretRevealFg}`,
|
|
40
|
+
gray: `border-[var(--zui-secret-reveal-gray-border,var(--zui-color-gray,oklch(55.1%_0.027_264.364)))] dark:border-[var(--zui-secret-reveal-gray-border-dark,var(--zui-color-gray-dark,oklch(55.1%_0.027_264.364)))] bg-[var(--zui-secret-reveal-gray-bg,oklch(92.8%_0.007_264.36))] dark:bg-[var(--zui-secret-reveal-gray-bg-dark,oklch(29.4%_0.018_264.36))] ${zuiSecretRevealFg}`,
|
|
41
|
+
zinc: `border-[var(--zui-secret-reveal-zinc-border,var(--zui-color-zinc,#52525b))] dark:border-[var(--zui-secret-reveal-zinc-border-dark,var(--zui-color-zinc-dark,#71717a))] bg-[var(--zui-secret-reveal-zinc-bg,oklch(92.9%_0.004_262.88))] dark:bg-[var(--zui-secret-reveal-zinc-bg-dark,oklch(29.4%_0.014_262.88))] ${zuiSecretRevealFg}`,
|
|
42
|
+
"gradient-blue": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-blue-from,var(--zui-color-blue,oklch(42.4%_0.199_265.638)))] dark:from-[var(--zui-secret-reveal-gradient-blue-from-dark,var(--zui-color-blue-dark,oklch(54.6%_0.245_262.881)))] to-[var(--zui-secret-reveal-gradient-blue-to,var(--zui-color-purple,oklch(43.8%_0.218_303.724)))] dark:to-[var(--zui-secret-reveal-gradient-blue-to-dark,var(--zui-color-purple-dark,oklch(55.8%_0.288_302.321)))] ${zuiSecretRevealGradientFg}`,
|
|
43
|
+
"gradient-green": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-green-from,var(--zui-color-green,oklch(44.8%_0.119_151.328)))] dark:from-[var(--zui-secret-reveal-gradient-green-from-dark,var(--zui-color-green-dark,oklch(62.7%_0.194_149.214)))] to-[var(--zui-secret-reveal-gradient-green-to,var(--zui-color-lime,oklch(45.3%_0.124_130.933)))] dark:to-[var(--zui-secret-reveal-gradient-green-to-dark,var(--zui-color-lime-dark,oklch(64.8%_0.2_131.684)))] ${zuiSecretRevealGradientFg}`,
|
|
44
|
+
"gradient-red": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-red-from,var(--zui-color-red,oklch(44.4%_0.177_26.899)))] dark:from-[var(--zui-secret-reveal-gradient-red-from-dark,var(--zui-color-red-dark,oklch(57.7%_0.245_27.325)))] to-[var(--zui-secret-reveal-gradient-red-to,var(--zui-color-pink,oklch(45.9%_0.187_3.815)))] dark:to-[var(--zui-secret-reveal-gradient-red-to-dark,var(--zui-color-pink-dark,oklch(59.2%_0.249_0.584)))] ${zuiSecretRevealGradientFg}`,
|
|
45
|
+
"gradient-yellow": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-yellow-from,var(--zui-color-yellow,oklch(47.6%_0.114_61.907)))] dark:from-[var(--zui-secret-reveal-gradient-yellow-from-dark,var(--zui-color-yellow-dark,oklch(68.1%_0.162_75.834)))] to-[var(--zui-secret-reveal-gradient-yellow-to,var(--zui-color-orange,oklch(47%_0.157_37.304)))] dark:to-[var(--zui-secret-reveal-gradient-yellow-to-dark,var(--zui-color-orange-dark,oklch(64.6%_0.222_41.116)))] ${zuiSecretRevealGradientFg}`,
|
|
46
|
+
"gradient-purple": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-purple-from,var(--zui-color-purple,oklch(43.8%_0.218_303.724)))] dark:from-[var(--zui-secret-reveal-gradient-purple-from-dark,var(--zui-color-purple-dark,oklch(55.8%_0.288_302.321)))] to-[var(--zui-secret-reveal-gradient-purple-to,var(--zui-color-pink,oklch(45.9%_0.187_3.815)))] dark:to-[var(--zui-secret-reveal-gradient-purple-to-dark,var(--zui-color-pink-dark,oklch(59.2%_0.249_0.584)))] ${zuiSecretRevealGradientFg}`,
|
|
47
|
+
"gradient-teal": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-teal-from,var(--zui-color-teal,oklch(43.7%_0.078_188.216)))] dark:from-[var(--zui-secret-reveal-gradient-teal-from-dark,var(--zui-color-teal-dark,oklch(60%_0.118_184.704)))] to-[var(--zui-secret-reveal-gradient-teal-to,var(--zui-color-cyan,oklch(45%_0.085_224.283)))] dark:to-[var(--zui-secret-reveal-gradient-teal-to-dark,var(--zui-color-cyan-dark,oklch(60.9%_0.126_221.723)))] ${zuiSecretRevealGradientFg}`,
|
|
48
|
+
"gradient-indigo": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-indigo-from,var(--zui-color-indigo,oklch(39.8%_0.195_277.366)))] dark:from-[var(--zui-secret-reveal-gradient-indigo-from-dark,var(--zui-color-indigo-dark,oklch(51.1%_0.262_276.966)))] to-[var(--zui-secret-reveal-gradient-indigo-to,var(--zui-color-purple,oklch(43.8%_0.218_303.724)))] dark:to-[var(--zui-secret-reveal-gradient-indigo-to-dark,var(--zui-color-purple-dark,oklch(55.8%_0.288_302.321)))] ${zuiSecretRevealGradientFg}`,
|
|
49
|
+
"gradient-pink": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-pink-from,var(--zui-color-pink,oklch(45.9%_0.187_3.815)))] dark:from-[var(--zui-secret-reveal-gradient-pink-from-dark,var(--zui-color-pink-dark,oklch(59.2%_0.249_0.584)))] to-[var(--zui-secret-reveal-gradient-pink-to,var(--zui-color-rose,oklch(45.5%_0.188_13.697)))] dark:to-[var(--zui-secret-reveal-gradient-pink-to-dark,var(--zui-color-rose-dark,oklch(58.6%_0.253_17.585)))] ${zuiSecretRevealGradientFg}`,
|
|
50
|
+
"gradient-orange": `border-transparent bg-linear-to-r from-[var(--zui-secret-reveal-gradient-orange-from,var(--zui-color-orange,oklch(47%_0.157_37.304)))] dark:from-[var(--zui-secret-reveal-gradient-orange-from-dark,var(--zui-color-orange-dark,oklch(64.6%_0.222_41.116)))] to-[var(--zui-secret-reveal-gradient-orange-to,var(--zui-color-red,oklch(44.4%_0.177_26.899)))] dark:to-[var(--zui-secret-reveal-gradient-orange-to-dark,var(--zui-color-red-dark,oklch(57.7%_0.245_27.325)))] ${zuiSecretRevealGradientFg}`,
|
|
51
|
+
} as const;
|
|
52
|
+
|
|
53
|
+
export const zuiSecretRevealSizes = {
|
|
54
|
+
sm: "gap-1.5 px-2 py-1.5 text-xs",
|
|
55
|
+
md: "gap-2 px-3 py-2 text-sm",
|
|
56
|
+
lg: "gap-2.5 px-4 py-2.5 text-base",
|
|
57
|
+
} as const;
|
|
58
|
+
|
|
59
|
+
export const zuiSecretRevealLabelSizes = {
|
|
60
|
+
sm: "text-xs",
|
|
61
|
+
md: "text-sm",
|
|
62
|
+
lg: "text-base",
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
export const zuiSecretRevealValueSizes = {
|
|
66
|
+
sm: "text-xs",
|
|
67
|
+
md: "text-sm",
|
|
68
|
+
lg: "text-base",
|
|
69
|
+
} as const;
|
|
70
|
+
|
|
71
|
+
export const zuiSecretRevealToggleSizes = {
|
|
72
|
+
sm: "size-6 [&_svg]:size-3.5",
|
|
73
|
+
md: "size-7 [&_svg]:size-4",
|
|
74
|
+
lg: "size-8 [&_svg]:size-5",
|
|
75
|
+
} as const;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PasswordStrengthMeterAnimationPresets } from "./types";
|
|
2
|
+
|
|
3
|
+
export const passwordStrengthMeterAnimationPresets: PasswordStrengthMeterAnimationPresets =
|
|
4
|
+
{
|
|
5
|
+
none: {},
|
|
6
|
+
shimmer: {
|
|
7
|
+
animate: { backgroundPosition: ["0% 0%", "100% 0%"] },
|
|
8
|
+
transition: { repeat: Infinity, duration: 1.2, ease: "linear" },
|
|
9
|
+
},
|
|
10
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
PasswordStrengthMeterAnimated,
|
|
5
|
+
PasswordStrengthMeterBarAnimated,
|
|
6
|
+
} from "./password-strength-meter-animated";
|
|
7
|
+
export type {
|
|
8
|
+
PasswordStrengthMeterAnimatedProps,
|
|
9
|
+
PasswordStrengthMeterAnimation,
|
|
10
|
+
PasswordStrengthMeterAnimationPresets,
|
|
11
|
+
PasswordStrengthMeterPresetMotionProps,
|
|
12
|
+
PasswordStrengthMeterVariantProps,
|
|
13
|
+
} from "./types";
|
|
14
|
+
export { passwordStrengthMeterAnimationPresets } from "./animations";
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useId, useMemo } from "react";
|
|
4
|
+
import { motion } from "framer-motion";
|
|
5
|
+
|
|
6
|
+
import { cn, clamp } from "../../../lib/utils";
|
|
7
|
+
|
|
8
|
+
import { passwordStrengthMeterAnimationPresets } from "./animations";
|
|
9
|
+
import type { PasswordStrengthMeterAnimatedProps } from "./types";
|
|
10
|
+
import type {
|
|
11
|
+
PasswordStrengthMeterCtx,
|
|
12
|
+
PasswordStrengthMeterSectionProps,
|
|
13
|
+
} from "../types";
|
|
14
|
+
import {
|
|
15
|
+
passwordStrengthMeterBarVariants,
|
|
16
|
+
passwordStrengthMeterTrackVariants,
|
|
17
|
+
passwordStrengthMeterVariants,
|
|
18
|
+
} from "../variants";
|
|
19
|
+
import {
|
|
20
|
+
getStrengthColor,
|
|
21
|
+
getStrengthLabel,
|
|
22
|
+
PasswordStrengthMeterContext,
|
|
23
|
+
usePasswordStrengthMeterContext,
|
|
24
|
+
} from "../password-strength-meter-base";
|
|
25
|
+
|
|
26
|
+
export function PasswordStrengthMeterAnimated({
|
|
27
|
+
className,
|
|
28
|
+
appearance = "default",
|
|
29
|
+
size = "md",
|
|
30
|
+
shape = "rounded",
|
|
31
|
+
animated = false,
|
|
32
|
+
segmented = false,
|
|
33
|
+
value = 0,
|
|
34
|
+
min = 0,
|
|
35
|
+
max = 100,
|
|
36
|
+
label,
|
|
37
|
+
scoreLabel,
|
|
38
|
+
showScoreLabel = true,
|
|
39
|
+
children,
|
|
40
|
+
ref,
|
|
41
|
+
animation = "none",
|
|
42
|
+
...rest
|
|
43
|
+
}: PasswordStrengthMeterAnimatedProps) {
|
|
44
|
+
const clamped = clamp(value, min, max);
|
|
45
|
+
const percent = max === min ? 0 : ((clamped - min) / (max - min)) * 100;
|
|
46
|
+
const labelSlotId = `${useId()}-password-strength-meter-label`;
|
|
47
|
+
const hasInlineLabelProp = Boolean(label?.trim().length);
|
|
48
|
+
|
|
49
|
+
const labelingProps = useMemo(() => {
|
|
50
|
+
if (hasInlineLabelProp) {
|
|
51
|
+
return { "aria-label": label?.trim() ?? "Password strength" };
|
|
52
|
+
}
|
|
53
|
+
return { "aria-label": "Password strength" };
|
|
54
|
+
}, [hasInlineLabelProp, label]);
|
|
55
|
+
|
|
56
|
+
const ctx = useMemo<PasswordStrengthMeterCtx>(
|
|
57
|
+
() => ({
|
|
58
|
+
value: clamped,
|
|
59
|
+
min,
|
|
60
|
+
max,
|
|
61
|
+
size: size ?? "md",
|
|
62
|
+
shape: shape ?? "rounded",
|
|
63
|
+
animated: Boolean(animated),
|
|
64
|
+
segmented: Boolean(segmented),
|
|
65
|
+
appearance: appearance ?? "default",
|
|
66
|
+
labelSlotId,
|
|
67
|
+
}),
|
|
68
|
+
[
|
|
69
|
+
animated,
|
|
70
|
+
appearance,
|
|
71
|
+
clamped,
|
|
72
|
+
labelSlotId,
|
|
73
|
+
max,
|
|
74
|
+
min,
|
|
75
|
+
shape,
|
|
76
|
+
size,
|
|
77
|
+
segmented,
|
|
78
|
+
],
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const motionProps = passwordStrengthMeterAnimationPresets[animation];
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<PasswordStrengthMeterContext.Provider value={ctx}>
|
|
85
|
+
<motion.div
|
|
86
|
+
ref={ref}
|
|
87
|
+
data-slot="password-strength-meter"
|
|
88
|
+
role="meter"
|
|
89
|
+
aria-valuemin={min}
|
|
90
|
+
aria-valuemax={max}
|
|
91
|
+
aria-valuenow={clamped}
|
|
92
|
+
aria-valuetext={getStrengthLabel(percent)}
|
|
93
|
+
{...labelingProps}
|
|
94
|
+
className={cn(
|
|
95
|
+
passwordStrengthMeterVariants({ appearance, size, shape }),
|
|
96
|
+
className,
|
|
97
|
+
)}
|
|
98
|
+
initial={animation === "none" ? false : undefined}
|
|
99
|
+
{...motionProps}
|
|
100
|
+
{...rest}
|
|
101
|
+
>
|
|
102
|
+
{children ?? (
|
|
103
|
+
<>
|
|
104
|
+
{(label || showScoreLabel) && (
|
|
105
|
+
<div className="flex items-center justify-between mb-1.5">
|
|
106
|
+
{label && (
|
|
107
|
+
<span
|
|
108
|
+
id={labelSlotId}
|
|
109
|
+
data-slot="password-strength-meter-label"
|
|
110
|
+
className="text-xs font-medium"
|
|
111
|
+
>
|
|
112
|
+
{label}
|
|
113
|
+
</span>
|
|
114
|
+
)}
|
|
115
|
+
{showScoreLabel && (
|
|
116
|
+
<span
|
|
117
|
+
data-slot="password-strength-meter-score-label"
|
|
118
|
+
className={cn(
|
|
119
|
+
"text-xs font-semibold",
|
|
120
|
+
getStrengthColor(percent),
|
|
121
|
+
)}
|
|
122
|
+
>
|
|
123
|
+
{scoreLabel ?? getStrengthLabel(percent)}
|
|
124
|
+
</span>
|
|
125
|
+
)}
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
<PasswordStrengthMeterBarAnimated
|
|
129
|
+
style={{ transform: `scaleX(${percent / 100})` }}
|
|
130
|
+
/>
|
|
131
|
+
</>
|
|
132
|
+
)}
|
|
133
|
+
</motion.div>
|
|
134
|
+
</PasswordStrengthMeterContext.Provider>
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
PasswordStrengthMeterAnimated.displayName = "PasswordStrengthMeterAnimated";
|
|
139
|
+
|
|
140
|
+
export function PasswordStrengthMeterBarAnimated({
|
|
141
|
+
className,
|
|
142
|
+
style,
|
|
143
|
+
ref,
|
|
144
|
+
...rest
|
|
145
|
+
}: PasswordStrengthMeterSectionProps & {
|
|
146
|
+
style?: React.CSSProperties;
|
|
147
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
148
|
+
}) {
|
|
149
|
+
const { size, shape, animated, segmented } = usePasswordStrengthMeterContext(
|
|
150
|
+
"PasswordStrengthMeterBar",
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
return (
|
|
154
|
+
<div
|
|
155
|
+
data-slot="password-strength-meter-track"
|
|
156
|
+
className={cn(
|
|
157
|
+
passwordStrengthMeterTrackVariants({ size, shape }),
|
|
158
|
+
"text-current",
|
|
159
|
+
)}
|
|
160
|
+
>
|
|
161
|
+
<motion.div
|
|
162
|
+
ref={ref}
|
|
163
|
+
data-slot="password-strength-meter-bar"
|
|
164
|
+
className={cn(
|
|
165
|
+
passwordStrengthMeterBarVariants({ segmented }),
|
|
166
|
+
className,
|
|
167
|
+
)}
|
|
168
|
+
style={{
|
|
169
|
+
transformOrigin: "left center",
|
|
170
|
+
...style,
|
|
171
|
+
}}
|
|
172
|
+
animate={
|
|
173
|
+
animated ? { x: ["-30%", "0%"], opacity: [0.85, 1] } : undefined
|
|
174
|
+
}
|
|
175
|
+
transition={
|
|
176
|
+
animated
|
|
177
|
+
? { repeat: Infinity, duration: 1.1, ease: "easeInOut" }
|
|
178
|
+
: undefined
|
|
179
|
+
}
|
|
180
|
+
{...rest}
|
|
181
|
+
/>
|
|
182
|
+
</div>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
PasswordStrengthMeterBarAnimated.displayName = "PasswordStrengthMeterBar";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { VariantProps } from "class-variance-authority";
|
|
2
|
+
import type { HTMLMotionProps } from "framer-motion";
|
|
3
|
+
import type { ReactNode } from "react";
|
|
4
|
+
import type { passwordStrengthMeterVariants } from "../variants";
|
|
5
|
+
|
|
6
|
+
export type PasswordStrengthMeterVariantProps = VariantProps<
|
|
7
|
+
typeof passwordStrengthMeterVariants
|
|
8
|
+
>;
|
|
9
|
+
|
|
10
|
+
export type PasswordStrengthMeterAnimation = "none" | "shimmer";
|
|
11
|
+
|
|
12
|
+
export type PasswordStrengthMeterPresetMotionProps = Pick<
|
|
13
|
+
HTMLMotionProps<"div">,
|
|
14
|
+
"transition" | "animate"
|
|
15
|
+
>;
|
|
16
|
+
|
|
17
|
+
export type PasswordStrengthMeterAnimationPresets = Record<
|
|
18
|
+
PasswordStrengthMeterAnimation,
|
|
19
|
+
PasswordStrengthMeterPresetMotionProps
|
|
20
|
+
>;
|
|
21
|
+
|
|
22
|
+
export type PasswordStrengthMeterAnimatedProps =
|
|
23
|
+
PasswordStrengthMeterVariantProps &
|
|
24
|
+
Omit<HTMLMotionProps<"div">, "children"> & {
|
|
25
|
+
value: number;
|
|
26
|
+
min?: number;
|
|
27
|
+
max?: number;
|
|
28
|
+
label?: string;
|
|
29
|
+
scoreLabel?: string;
|
|
30
|
+
showScoreLabel?: boolean;
|
|
31
|
+
animated?: boolean;
|
|
32
|
+
segmented?: boolean;
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
animation?: PasswordStrengthMeterAnimation;
|
|
35
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
export { PasswordStrengthMeter } from "./password-strength-meter";
|
|
4
|
+
export {
|
|
5
|
+
PasswordStrengthMeterBar,
|
|
6
|
+
PasswordStrengthMeterBase,
|
|
7
|
+
} from "./password-strength-meter-base";
|
|
8
|
+
export type {
|
|
9
|
+
PasswordStrengthMeterProps,
|
|
10
|
+
PasswordStrengthMeterSectionProps,
|
|
11
|
+
PasswordStrengthMeterCtx,
|
|
12
|
+
PasswordStrengthMeterVariantProps,
|
|
13
|
+
} from "./types";
|
|
14
|
+
export {
|
|
15
|
+
passwordStrengthMeterVariants,
|
|
16
|
+
passwordStrengthMeterTrackVariants,
|
|
17
|
+
passwordStrengthMeterBarVariants,
|
|
18
|
+
} from "./variants";
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { createContext, useContext, useMemo, useId } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn, clamp } from "../../lib/utils";
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
PasswordStrengthMeterProps,
|
|
9
|
+
PasswordStrengthMeterSectionProps,
|
|
10
|
+
PasswordStrengthMeterCtx,
|
|
11
|
+
} from "./types";
|
|
12
|
+
import {
|
|
13
|
+
passwordStrengthMeterBarVariants,
|
|
14
|
+
passwordStrengthMeterTrackVariants,
|
|
15
|
+
passwordStrengthMeterVariants,
|
|
16
|
+
} from "./variants";
|
|
17
|
+
|
|
18
|
+
export const PasswordStrengthMeterContext =
|
|
19
|
+
createContext<PasswordStrengthMeterCtx | null>(null);
|
|
20
|
+
|
|
21
|
+
export function usePasswordStrengthMeterContext(
|
|
22
|
+
component: string,
|
|
23
|
+
): PasswordStrengthMeterCtx {
|
|
24
|
+
const ctx = useContext(PasswordStrengthMeterContext);
|
|
25
|
+
if (!ctx) {
|
|
26
|
+
throw new Error(`${component} must be used within <PasswordStrengthMeter>`);
|
|
27
|
+
}
|
|
28
|
+
return ctx;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function getStrengthLabel(percent: number): string {
|
|
32
|
+
if (percent <= 20) return "Weak";
|
|
33
|
+
if (percent <= 40) return "Fair";
|
|
34
|
+
if (percent <= 60) return "Good";
|
|
35
|
+
if (percent <= 80) return "Strong";
|
|
36
|
+
return "Very strong";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getStrengthColor(percent: number): string {
|
|
40
|
+
if (percent <= 20)
|
|
41
|
+
return "text-[var(--zui-status-error,#dc2626)] dark:text-[var(--zui-status-error-dark,#ef4444)]";
|
|
42
|
+
if (percent <= 40)
|
|
43
|
+
return "text-[var(--zui-color-orange,#ea580c)] dark:text-[var(--zui-color-orange-dark,#fb923c)]";
|
|
44
|
+
if (percent <= 60)
|
|
45
|
+
return "text-[var(--zui-color-yellow,#ca8a04)] dark:text-[var(--zui-color-yellow-dark,#facc15)]";
|
|
46
|
+
if (percent <= 80)
|
|
47
|
+
return "text-[var(--zui-color-emerald,#16a34a)] dark:text-[var(--zui-color-emerald-dark,#22c55e)]";
|
|
48
|
+
return "text-[var(--zui-color-indigo,#4338ca)] dark:text-[var(--zui-color-indigo-dark,#818cf8)]";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function PasswordStrengthMeterBase(props: PasswordStrengthMeterProps) {
|
|
52
|
+
const {
|
|
53
|
+
className,
|
|
54
|
+
appearance = "default",
|
|
55
|
+
size = "md",
|
|
56
|
+
shape = "rounded",
|
|
57
|
+
animated = false,
|
|
58
|
+
segmented = false,
|
|
59
|
+
value = 0,
|
|
60
|
+
min = 0,
|
|
61
|
+
max = 100,
|
|
62
|
+
label,
|
|
63
|
+
scoreLabel,
|
|
64
|
+
showScoreLabel = true,
|
|
65
|
+
children,
|
|
66
|
+
ref,
|
|
67
|
+
as: Wrapper = "div",
|
|
68
|
+
...rest
|
|
69
|
+
} = props;
|
|
70
|
+
const clamped = clamp(value, min, max);
|
|
71
|
+
const percent = max === min ? 0 : ((clamped - min) / (max - min)) * 100;
|
|
72
|
+
const labelSlotId = `${useId()}-password-strength-meter-label`;
|
|
73
|
+
const hasInlineLabelProp = Boolean(label?.trim().length);
|
|
74
|
+
|
|
75
|
+
const labelingProps = useMemo(() => {
|
|
76
|
+
if (hasInlineLabelProp) {
|
|
77
|
+
return { "aria-label": label?.trim() ?? "Password strength" };
|
|
78
|
+
}
|
|
79
|
+
return { "aria-label": "Password strength" };
|
|
80
|
+
}, [hasInlineLabelProp, label]);
|
|
81
|
+
|
|
82
|
+
const ctx = useMemo(
|
|
83
|
+
() => ({
|
|
84
|
+
value: clamped,
|
|
85
|
+
min,
|
|
86
|
+
max,
|
|
87
|
+
size: size ?? "md",
|
|
88
|
+
shape: shape ?? "rounded",
|
|
89
|
+
animated: Boolean(animated),
|
|
90
|
+
segmented: Boolean(segmented),
|
|
91
|
+
appearance: appearance ?? "default",
|
|
92
|
+
labelSlotId,
|
|
93
|
+
}),
|
|
94
|
+
[
|
|
95
|
+
animated,
|
|
96
|
+
appearance,
|
|
97
|
+
clamped,
|
|
98
|
+
labelSlotId,
|
|
99
|
+
max,
|
|
100
|
+
min,
|
|
101
|
+
shape,
|
|
102
|
+
size,
|
|
103
|
+
segmented,
|
|
104
|
+
],
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<PasswordStrengthMeterContext.Provider value={ctx}>
|
|
109
|
+
<Wrapper
|
|
110
|
+
ref={ref}
|
|
111
|
+
data-slot="password-strength-meter"
|
|
112
|
+
role="meter"
|
|
113
|
+
aria-valuemin={min}
|
|
114
|
+
aria-valuemax={max}
|
|
115
|
+
aria-valuenow={clamped}
|
|
116
|
+
aria-valuetext={getStrengthLabel(percent)}
|
|
117
|
+
{...labelingProps}
|
|
118
|
+
className={cn(
|
|
119
|
+
passwordStrengthMeterVariants({ appearance, size, shape }),
|
|
120
|
+
className,
|
|
121
|
+
)}
|
|
122
|
+
{...rest}
|
|
123
|
+
>
|
|
124
|
+
{children ?? (
|
|
125
|
+
<>
|
|
126
|
+
{(label || showScoreLabel) && (
|
|
127
|
+
<div className="flex items-center justify-between mb-1.5">
|
|
128
|
+
{label && (
|
|
129
|
+
<span
|
|
130
|
+
id={labelSlotId}
|
|
131
|
+
data-slot="password-strength-meter-label"
|
|
132
|
+
className="text-xs font-medium"
|
|
133
|
+
>
|
|
134
|
+
{label}
|
|
135
|
+
</span>
|
|
136
|
+
)}
|
|
137
|
+
{showScoreLabel && (
|
|
138
|
+
<span
|
|
139
|
+
data-slot="password-strength-meter-score-label"
|
|
140
|
+
className={cn(
|
|
141
|
+
"text-xs font-semibold",
|
|
142
|
+
getStrengthColor(percent),
|
|
143
|
+
)}
|
|
144
|
+
>
|
|
145
|
+
{scoreLabel ?? getStrengthLabel(percent)}
|
|
146
|
+
</span>
|
|
147
|
+
)}
|
|
148
|
+
</div>
|
|
149
|
+
)}
|
|
150
|
+
<PasswordStrengthMeterBar
|
|
151
|
+
style={{ transform: `scaleX(${percent / 100})` }}
|
|
152
|
+
/>
|
|
153
|
+
</>
|
|
154
|
+
)}
|
|
155
|
+
</Wrapper>
|
|
156
|
+
</PasswordStrengthMeterContext.Provider>
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
PasswordStrengthMeterBase.displayName = "PasswordStrengthMeter";
|
|
161
|
+
|
|
162
|
+
export function PasswordStrengthMeterBar({
|
|
163
|
+
className,
|
|
164
|
+
style,
|
|
165
|
+
ref,
|
|
166
|
+
as: Wrapper = "div",
|
|
167
|
+
...rest
|
|
168
|
+
}: PasswordStrengthMeterSectionProps & {
|
|
169
|
+
style?: React.CSSProperties;
|
|
170
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
171
|
+
}) {
|
|
172
|
+
const { size, shape, animated, segmented } = usePasswordStrengthMeterContext(
|
|
173
|
+
"PasswordStrengthMeterBar",
|
|
174
|
+
);
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<Wrapper
|
|
178
|
+
data-slot="password-strength-meter-track"
|
|
179
|
+
className={cn(
|
|
180
|
+
passwordStrengthMeterTrackVariants({ size, shape }),
|
|
181
|
+
"text-current",
|
|
182
|
+
)}
|
|
183
|
+
>
|
|
184
|
+
<div
|
|
185
|
+
ref={ref}
|
|
186
|
+
data-slot="password-strength-meter-bar"
|
|
187
|
+
className={cn(
|
|
188
|
+
passwordStrengthMeterBarVariants({ segmented }),
|
|
189
|
+
animated ? "animate-pulse" : undefined,
|
|
190
|
+
className,
|
|
191
|
+
)}
|
|
192
|
+
style={{
|
|
193
|
+
transformOrigin: "left center",
|
|
194
|
+
...style,
|
|
195
|
+
}}
|
|
196
|
+
{...rest}
|
|
197
|
+
/>
|
|
198
|
+
</Wrapper>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
PasswordStrengthMeterBar.displayName = "PasswordStrengthMeterBar";
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { createRef } from "react";
|
|
2
|
+
import { render, screen } from "@testing-library/react";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { PasswordStrengthMeter } from "./password-strength-meter";
|
|
6
|
+
import { PasswordStrengthMeterBar } from "./password-strength-meter-base";
|
|
7
|
+
|
|
8
|
+
describe("PasswordStrengthMeter", () => {
|
|
9
|
+
it("should expose displayName on compound parts", () => {
|
|
10
|
+
expect(PasswordStrengthMeter.displayName).toBe("PasswordStrengthMeter");
|
|
11
|
+
expect(PasswordStrengthMeterBar.displayName).toBe(
|
|
12
|
+
"PasswordStrengthMeterBar",
|
|
13
|
+
);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it("should stamp data-slot on the root and default bar track", () => {
|
|
17
|
+
render(<PasswordStrengthMeter value={40} />);
|
|
18
|
+
expect(
|
|
19
|
+
document.querySelector('[data-slot="password-strength-meter"]'),
|
|
20
|
+
).toBeTruthy();
|
|
21
|
+
expect(
|
|
22
|
+
document.querySelector('[data-slot="password-strength-meter-track"]'),
|
|
23
|
+
).toBeTruthy();
|
|
24
|
+
expect(
|
|
25
|
+
document.querySelector('[data-slot="password-strength-meter-bar"]'),
|
|
26
|
+
).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("should expose meter semantics with clamped value", () => {
|
|
30
|
+
render(<PasswordStrengthMeter value={120} min={0} max={100} />);
|
|
31
|
+
const meter = screen.getByRole("meter");
|
|
32
|
+
expect(meter.getAttribute("aria-valuemin")).toBe("0");
|
|
33
|
+
expect(meter.getAttribute("aria-valuemax")).toBe("100");
|
|
34
|
+
expect(meter.getAttribute("aria-valuenow")).toBe("100");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("should clamp below the minimum", () => {
|
|
38
|
+
render(<PasswordStrengthMeter value={-5} min={0} max={100} />);
|
|
39
|
+
expect(screen.getByRole("meter").getAttribute("aria-valuenow")).toBe("0");
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it("should render strength label based on value", () => {
|
|
43
|
+
render(<PasswordStrengthMeter value={10} showScoreLabel />);
|
|
44
|
+
expect(
|
|
45
|
+
document.querySelector(
|
|
46
|
+
'[data-slot="password-strength-meter-score-label"]',
|
|
47
|
+
),
|
|
48
|
+
).toHaveTextContent("Weak");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("should render 'Very strong' for high values", () => {
|
|
52
|
+
render(<PasswordStrengthMeter value={95} showScoreLabel />);
|
|
53
|
+
expect(
|
|
54
|
+
document.querySelector(
|
|
55
|
+
'[data-slot="password-strength-meter-score-label"]',
|
|
56
|
+
),
|
|
57
|
+
).toHaveTextContent("Very strong");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("should not show score label when showScoreLabel is false", () => {
|
|
61
|
+
render(<PasswordStrengthMeter value={50} showScoreLabel={false} />);
|
|
62
|
+
expect(
|
|
63
|
+
document.querySelector(
|
|
64
|
+
'[data-slot="password-strength-meter-score-label"]',
|
|
65
|
+
),
|
|
66
|
+
).toBeNull();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("should render custom label", () => {
|
|
70
|
+
render(<PasswordStrengthMeter value={50} label="Password" />);
|
|
71
|
+
expect(
|
|
72
|
+
document.querySelector('[data-slot="password-strength-meter-label"]'),
|
|
73
|
+
).toHaveTextContent("Password");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("should render custom scoreLabel", () => {
|
|
77
|
+
render(<PasswordStrengthMeter value={50} scoreLabel="Medium" />);
|
|
78
|
+
expect(
|
|
79
|
+
document.querySelector(
|
|
80
|
+
'[data-slot="password-strength-meter-score-label"]',
|
|
81
|
+
),
|
|
82
|
+
).toHaveTextContent("Medium");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should apply appearance classes from the variant recipe", () => {
|
|
86
|
+
render(<PasswordStrengthMeter value={50} appearance="emerald" />);
|
|
87
|
+
const root = document.querySelector(
|
|
88
|
+
'[data-slot="password-strength-meter"]',
|
|
89
|
+
) as HTMLElement;
|
|
90
|
+
expect(root.className).toMatch(/--psm-fill/);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe("ref forwarding", () => {
|
|
94
|
+
it("should forward ref to the root", () => {
|
|
95
|
+
const ref = createRef<HTMLDivElement>();
|
|
96
|
+
render(<PasswordStrengthMeter ref={ref} value={5} />);
|
|
97
|
+
expect(ref.current).toBeInstanceOf(HTMLDivElement);
|
|
98
|
+
expect(ref.current?.getAttribute("data-slot")).toBe(
|
|
99
|
+
"password-strength-meter",
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PasswordStrengthMeterBase } from "./password-strength-meter-base";
|
|
2
|
+
import type { PasswordStrengthMeterProps } from "./types";
|
|
3
|
+
|
|
4
|
+
export const PasswordStrengthMeter = (props: PasswordStrengthMeterProps) => {
|
|
5
|
+
return <PasswordStrengthMeterBase {...props} />;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
PasswordStrengthMeter.displayName = "PasswordStrengthMeter";
|