@alfadocs/ui-kit 0.7.2 → 0.8.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/dist/_chunks/use-password-requirements-DgEYdN4H.js +446 -0
- package/dist/agent-catalog.json +1 -1
- package/dist/components/password-input/index.d.ts +3 -1
- package/dist/components/password-input/index.js +3 -2
- package/dist/components/password-input/password-input.d.ts +31 -0
- package/dist/components/password-input/use-password-requirements.d.ts +39 -0
- package/dist/i18n/config.js +32 -2
- package/dist/i18n/resources.d.ts +30 -0
- package/dist/index.js +389 -388
- package/dist/locales/de.json +10 -0
- package/dist/locales/en.json +10 -0
- package/dist/locales/it.json +10 -0
- package/dist/tokens.css +1 -1
- package/package.json +1 -1
- package/dist/_chunks/password-input-C4LmjIH1.js +0 -301
|
@@ -0,0 +1,446 @@
|
|
|
1
|
+
import { jsxs as g, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as ts, useRef as as, useState as C, useEffect as is, useCallback as u, useMemo as V } from "react";
|
|
3
|
+
import { c as L } from "./index-D2ZczOXr.js";
|
|
4
|
+
import { useTranslation as W } from "react-i18next";
|
|
5
|
+
import { T as rs } from "./text-input-DZwt9L8H.js";
|
|
6
|
+
import { u as ns } from "./form-field-context-B3APVHKx.js";
|
|
7
|
+
import { c as os } from "./compose-refs-C0k0tdqF.js";
|
|
8
|
+
import { u as ds } from "./registry-C9nwlNyL.js";
|
|
9
|
+
import { E as ls } from "./eye-off-xEXDAh5z.js";
|
|
10
|
+
import { c as cs } from "./createLucideIcon-CrFbzy84.js";
|
|
11
|
+
import { C as us } from "./check-DPdL_Sm7.js";
|
|
12
|
+
import { C as ps } from "./circle-BkqTgYmt.js";
|
|
13
|
+
import { T as ms } from "./triangle-alert-CBPUIzQo.js";
|
|
14
|
+
/**
|
|
15
|
+
* @license lucide-react v1.8.0 - ISC
|
|
16
|
+
*
|
|
17
|
+
* This source code is licensed under the ISC license.
|
|
18
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
19
|
+
*/
|
|
20
|
+
const fs = [
|
|
21
|
+
[
|
|
22
|
+
"path",
|
|
23
|
+
{
|
|
24
|
+
d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
|
|
25
|
+
key: "1nclc0"
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
|
|
29
|
+
], gs = cs("eye", fs), hs = {
|
|
30
|
+
id: "password-input",
|
|
31
|
+
capabilities: ["edit_inline"],
|
|
32
|
+
state: {
|
|
33
|
+
value: {
|
|
34
|
+
type: "string",
|
|
35
|
+
descriptionKey: "ui.agent.passwordInput.state.value",
|
|
36
|
+
description: "Current password value. Never log or persist this off-device.",
|
|
37
|
+
read: (e) => e.getValue()
|
|
38
|
+
},
|
|
39
|
+
isEmpty: {
|
|
40
|
+
type: "boolean",
|
|
41
|
+
descriptionKey: "ui.agent.passwordInput.state.isEmpty",
|
|
42
|
+
description: "Whether the input has no value.",
|
|
43
|
+
read: (e) => e.getValue() === ""
|
|
44
|
+
},
|
|
45
|
+
isRevealed: {
|
|
46
|
+
type: "boolean",
|
|
47
|
+
descriptionKey: "ui.agent.passwordInput.state.isRevealed",
|
|
48
|
+
description: "Whether the password is currently shown in plain text.",
|
|
49
|
+
read: (e) => e.isRevealed()
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
actions: {
|
|
53
|
+
set_value: {
|
|
54
|
+
safety: "write",
|
|
55
|
+
argsType: "{ value: string }",
|
|
56
|
+
descriptionKey: "ui.agent.passwordInput.actions.setValue",
|
|
57
|
+
description: "Replace the password value.",
|
|
58
|
+
invoke: (e, r) => {
|
|
59
|
+
e.setValue(r.value);
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
clear: {
|
|
63
|
+
safety: "destructive",
|
|
64
|
+
descriptionKey: "ui.agent.passwordInput.actions.clear",
|
|
65
|
+
description: "Empty the input. Loses any typed value.",
|
|
66
|
+
invoke: (e) => {
|
|
67
|
+
e.clear();
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
focus: {
|
|
71
|
+
safety: "read",
|
|
72
|
+
descriptionKey: "ui.agent.passwordInput.actions.focus",
|
|
73
|
+
description: "Move keyboard focus to the input.",
|
|
74
|
+
invoke: (e) => {
|
|
75
|
+
e.focus();
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
toggle_visibility: {
|
|
79
|
+
safety: "read",
|
|
80
|
+
descriptionKey: "ui.agent.passwordInput.actions.toggleVisibility",
|
|
81
|
+
description: "Toggle between masked and plain-text display.",
|
|
82
|
+
invoke: (e) => {
|
|
83
|
+
e.toggleVisibility();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
domHooks: {
|
|
88
|
+
root: {
|
|
89
|
+
attr: "data-component",
|
|
90
|
+
value: "password-input",
|
|
91
|
+
description: "Marks the PasswordInput wrapper."
|
|
92
|
+
},
|
|
93
|
+
instanceId: {
|
|
94
|
+
attr: "data-component-id",
|
|
95
|
+
sourceProp: "id",
|
|
96
|
+
description: "Sourced from the id prop."
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}, ws = {
|
|
100
|
+
sm: "ds:size-4",
|
|
101
|
+
md: "ds:size-[18px]",
|
|
102
|
+
lg: "ds:size-5"
|
|
103
|
+
}, bs = L(
|
|
104
|
+
[
|
|
105
|
+
"ds:absolute ds:inset-y-0 ds:end-0 ds:ps-2 ds:pe-3",
|
|
106
|
+
"ds:inline-flex ds:items-center ds:justify-center",
|
|
107
|
+
"ds:text-muted-foreground ds:hover:text-foreground",
|
|
108
|
+
"ds:bg-transparent ds:border-0 ds:cursor-pointer",
|
|
109
|
+
"ds:rounded-[var(--radius-sm)]",
|
|
110
|
+
"ds:min-w-[var(--min-target-size)]",
|
|
111
|
+
"ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
|
|
112
|
+
"ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-solid",
|
|
113
|
+
"ds:focus-visible:outline-ring ds:focus-visible:outline-offset-[length:var(--focus-ring-offset)]",
|
|
114
|
+
"ds:forced-colors:focus-visible:outline-[CanvasText]",
|
|
115
|
+
"ds:disabled:cursor-not-allowed ds:disabled:opacity-50"
|
|
116
|
+
].join(" ")
|
|
117
|
+
), vs = L(
|
|
118
|
+
"ds:h-1 ds:w-full ds:overflow-hidden ds:rounded-[var(--radius-full)] ds:bg-muted"
|
|
119
|
+
), ys = L(
|
|
120
|
+
[
|
|
121
|
+
"ds:h-full ds:rounded-[var(--radius-full)]",
|
|
122
|
+
"ds:transition-all ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none"
|
|
123
|
+
].join(" "),
|
|
124
|
+
{
|
|
125
|
+
variants: {
|
|
126
|
+
level: {
|
|
127
|
+
0: "ds:w-1/4 ds:bg-destructive",
|
|
128
|
+
1: "ds:w-1/2 ds:bg-warning",
|
|
129
|
+
2: "ds:w-3/4 ds:bg-success",
|
|
130
|
+
3: "ds:w-full ds:bg-success"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
defaultVariants: { level: 0 }
|
|
134
|
+
}
|
|
135
|
+
), xs = {
|
|
136
|
+
0: "weak",
|
|
137
|
+
1: "fair",
|
|
138
|
+
2: "good",
|
|
139
|
+
3: "strong"
|
|
140
|
+
}, ks = L(
|
|
141
|
+
"ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-meta",
|
|
142
|
+
{
|
|
143
|
+
variants: {
|
|
144
|
+
met: {
|
|
145
|
+
true: "ds:text-success",
|
|
146
|
+
false: "ds:text-muted-foreground"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
defaultVariants: { met: !1 }
|
|
150
|
+
}
|
|
151
|
+
), Ns = ts(
|
|
152
|
+
({
|
|
153
|
+
onRevealChange: e,
|
|
154
|
+
showStrength: r = !1,
|
|
155
|
+
strength: n,
|
|
156
|
+
requirements: l,
|
|
157
|
+
deriveStrength: p = !1,
|
|
158
|
+
autoComplete: w,
|
|
159
|
+
size: h = "md",
|
|
160
|
+
disabled: d,
|
|
161
|
+
name: i,
|
|
162
|
+
id: I,
|
|
163
|
+
onKeyDown: b,
|
|
164
|
+
onKeyUp: v,
|
|
165
|
+
onBlur: y,
|
|
166
|
+
onInput: x,
|
|
167
|
+
defaultValue: T,
|
|
168
|
+
value: m,
|
|
169
|
+
className: $,
|
|
170
|
+
...B
|
|
171
|
+
}, G) => {
|
|
172
|
+
const { t: f } = W(), M = ns().disabled || d, k = as(null), J = os(G, k), [c, j] = C(!1), [Q, A] = C(!1), [_, H] = C(() => typeof m == "string" ? m : typeof T == "string" ? T : "");
|
|
173
|
+
is(() => {
|
|
174
|
+
typeof m == "string" && H(m);
|
|
175
|
+
}, [m]);
|
|
176
|
+
const X = u(
|
|
177
|
+
(s) => {
|
|
178
|
+
H(s.currentTarget.value), x == null || x(s);
|
|
179
|
+
},
|
|
180
|
+
[x]
|
|
181
|
+
), z = u((s) => {
|
|
182
|
+
var R;
|
|
183
|
+
const t = k.current;
|
|
184
|
+
if (!t) return;
|
|
185
|
+
const P = Object.getPrototypeOf(t), S = (R = Object.getOwnPropertyDescriptor(P, "value")) == null ? void 0 : R.set;
|
|
186
|
+
S == null || S.call(t, s), t.dispatchEvent(new Event("input", { bubbles: !0 })), t.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
187
|
+
}, []), Y = u(() => {
|
|
188
|
+
j((s) => {
|
|
189
|
+
const t = !s;
|
|
190
|
+
return e == null || e(t), t;
|
|
191
|
+
});
|
|
192
|
+
}, [e]), N = u((s) => {
|
|
193
|
+
typeof s.getModifierState == "function" && A(s.getModifierState("CapsLock"));
|
|
194
|
+
}, []), Z = u(
|
|
195
|
+
(s) => {
|
|
196
|
+
N(s), b == null || b(s);
|
|
197
|
+
},
|
|
198
|
+
[N, b]
|
|
199
|
+
), D = u(
|
|
200
|
+
(s) => {
|
|
201
|
+
N(s), v == null || v(s);
|
|
202
|
+
},
|
|
203
|
+
[N, v]
|
|
204
|
+
), q = u(
|
|
205
|
+
(s) => {
|
|
206
|
+
A(!1), y == null || y(s);
|
|
207
|
+
},
|
|
208
|
+
[y]
|
|
209
|
+
), U = V(
|
|
210
|
+
() => ({
|
|
211
|
+
getValue: () => {
|
|
212
|
+
var s;
|
|
213
|
+
return ((s = k.current) == null ? void 0 : s.value) ?? "";
|
|
214
|
+
},
|
|
215
|
+
setValue: (s) => z(s),
|
|
216
|
+
clear: () => z(""),
|
|
217
|
+
focus: () => {
|
|
218
|
+
var s;
|
|
219
|
+
return (s = k.current) == null ? void 0 : s.focus();
|
|
220
|
+
},
|
|
221
|
+
isRevealed: () => c,
|
|
222
|
+
toggleVisibility: () => {
|
|
223
|
+
j((s) => {
|
|
224
|
+
const t = !s;
|
|
225
|
+
return e == null || e(t), t;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
}),
|
|
229
|
+
[e, c, z]
|
|
230
|
+
);
|
|
231
|
+
ds(hs, U, I);
|
|
232
|
+
const F = ws[h], ss = f(
|
|
233
|
+
c ? "ui.inputs.password.toggleHide" : "ui.inputs.password.toggleShow",
|
|
234
|
+
c ? "Hide password" : "Show password"
|
|
235
|
+
), o = V(
|
|
236
|
+
() => (l == null ? void 0 : l.map((s) => ({
|
|
237
|
+
...s,
|
|
238
|
+
met: s.test(_)
|
|
239
|
+
}))) ?? null,
|
|
240
|
+
[l, _]
|
|
241
|
+
), es = V(() => {
|
|
242
|
+
if (!p || !(o != null && o.length)) return 0;
|
|
243
|
+
const s = o.filter((P) => P.met).length, t = o.length;
|
|
244
|
+
return Math.min(3, Math.floor(s / t * 4));
|
|
245
|
+
}, [p, o]), E = n !== void 0 ? n : p ? es : 0, O = xs[E], K = f(
|
|
246
|
+
`ui.inputs.password.strength.${O}`,
|
|
247
|
+
O.charAt(0).toUpperCase() + O.slice(1)
|
|
248
|
+
);
|
|
249
|
+
return /* @__PURE__ */ g(
|
|
250
|
+
"div",
|
|
251
|
+
{
|
|
252
|
+
"data-component": "password-input",
|
|
253
|
+
"data-component-id": I,
|
|
254
|
+
className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]",
|
|
255
|
+
children: [
|
|
256
|
+
/* @__PURE__ */ g("div", { className: "ds:relative", children: [
|
|
257
|
+
/* @__PURE__ */ a(
|
|
258
|
+
rs,
|
|
259
|
+
{
|
|
260
|
+
ref: J,
|
|
261
|
+
id: I,
|
|
262
|
+
type: c ? "text" : "password",
|
|
263
|
+
autoComplete: w ?? "current-password",
|
|
264
|
+
name: i ?? "password",
|
|
265
|
+
spellCheck: !1,
|
|
266
|
+
autoCapitalize: "none",
|
|
267
|
+
autoCorrect: "off",
|
|
268
|
+
size: h,
|
|
269
|
+
disabled: M,
|
|
270
|
+
onKeyDown: Z,
|
|
271
|
+
onKeyUp: D,
|
|
272
|
+
onBlur: q,
|
|
273
|
+
onInput: X,
|
|
274
|
+
value: m,
|
|
275
|
+
defaultValue: T,
|
|
276
|
+
endAdornment: /* @__PURE__ */ a("span", { "aria-hidden": "true", className: "ds:block ds:size-4" }),
|
|
277
|
+
className: $,
|
|
278
|
+
...B
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
/* @__PURE__ */ a(
|
|
282
|
+
"button",
|
|
283
|
+
{
|
|
284
|
+
type: "button",
|
|
285
|
+
"aria-pressed": c,
|
|
286
|
+
"aria-label": ss,
|
|
287
|
+
disabled: M,
|
|
288
|
+
onClick: Y,
|
|
289
|
+
className: bs(),
|
|
290
|
+
children: c ? /* @__PURE__ */ a(ls, { "aria-hidden": "true", className: F }) : /* @__PURE__ */ a(gs, { "aria-hidden": "true", className: F })
|
|
291
|
+
}
|
|
292
|
+
)
|
|
293
|
+
] }),
|
|
294
|
+
o && o.length > 0 ? (
|
|
295
|
+
// `role="list"` / `role="listitem"` are set explicitly even
|
|
296
|
+
// though they're the implicit roles on <ul>/<li> — Safari
|
|
297
|
+
// VoiceOver strips the implicit list role when CSS sets
|
|
298
|
+
// `list-style: none` (which `ds:list-none` does), so the
|
|
299
|
+
// redundancy is load-bearing for AT, not a lint nit.
|
|
300
|
+
//
|
|
301
|
+
// aria-live="polite" announces transitions as the per-row
|
|
302
|
+
// `.ds:sr-only` state suffix flips between "met" / "not yet
|
|
303
|
+
// met". aria-live observes text-content mutations, not
|
|
304
|
+
// attribute or class changes, so the data-state attribute
|
|
305
|
+
// alone wouldn't trigger an announcement — the sr-only span
|
|
306
|
+
// is the load-bearing piece for AT users.
|
|
307
|
+
// eslint-disable-next-line jsx-a11y/no-redundant-roles
|
|
308
|
+
/* @__PURE__ */ a(
|
|
309
|
+
"ul",
|
|
310
|
+
{
|
|
311
|
+
role: "list",
|
|
312
|
+
"aria-live": "polite",
|
|
313
|
+
"data-component": "password-requirements",
|
|
314
|
+
className: "ds:list-none ds:m-0 ds:p-0 ds:flex ds:flex-col ds:gap-[var(--spacing-2xs)]",
|
|
315
|
+
children: o.map((s) => (
|
|
316
|
+
// eslint-disable-next-line jsx-a11y/no-redundant-roles
|
|
317
|
+
/* @__PURE__ */ g(
|
|
318
|
+
"li",
|
|
319
|
+
{
|
|
320
|
+
role: "listitem",
|
|
321
|
+
"data-state": s.met ? "met" : "unmet",
|
|
322
|
+
className: ks({ met: s.met }),
|
|
323
|
+
children: [
|
|
324
|
+
s.met ? /* @__PURE__ */ a(
|
|
325
|
+
us,
|
|
326
|
+
{
|
|
327
|
+
"aria-hidden": "true",
|
|
328
|
+
className: "ds:size-3.5 ds:text-success ds:shrink-0"
|
|
329
|
+
}
|
|
330
|
+
) : /* @__PURE__ */ a(
|
|
331
|
+
ps,
|
|
332
|
+
{
|
|
333
|
+
"aria-hidden": "true",
|
|
334
|
+
className: "ds:size-3.5 ds:shrink-0"
|
|
335
|
+
}
|
|
336
|
+
),
|
|
337
|
+
/* @__PURE__ */ a("span", { children: s.label }),
|
|
338
|
+
/* @__PURE__ */ g("span", { className: "ds:sr-only", children: [
|
|
339
|
+
" — ",
|
|
340
|
+
s.met ? f("ui.inputs.password.requirements.met", "met") : f(
|
|
341
|
+
"ui.inputs.password.requirements.unmet",
|
|
342
|
+
"not yet met"
|
|
343
|
+
)
|
|
344
|
+
] })
|
|
345
|
+
]
|
|
346
|
+
},
|
|
347
|
+
s.id
|
|
348
|
+
)
|
|
349
|
+
))
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
) : null,
|
|
353
|
+
Q ? /* @__PURE__ */ g(
|
|
354
|
+
"span",
|
|
355
|
+
{
|
|
356
|
+
role: "status",
|
|
357
|
+
"aria-live": "polite",
|
|
358
|
+
className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)] type-meta ds:text-warning",
|
|
359
|
+
children: [
|
|
360
|
+
/* @__PURE__ */ a(ms, { "aria-hidden": "true", className: "ds:size-3.5" }),
|
|
361
|
+
f("ui.inputs.password.capsLock", "Caps Lock is on")
|
|
362
|
+
]
|
|
363
|
+
}
|
|
364
|
+
) : null,
|
|
365
|
+
r ? /* @__PURE__ */ g("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]", children: [
|
|
366
|
+
/* @__PURE__ */ a(
|
|
367
|
+
"div",
|
|
368
|
+
{
|
|
369
|
+
role: "progressbar",
|
|
370
|
+
"aria-valuenow": E,
|
|
371
|
+
"aria-valuemin": 0,
|
|
372
|
+
"aria-valuemax": 3,
|
|
373
|
+
"aria-label": f(
|
|
374
|
+
"ui.inputs.password.strengthLabel",
|
|
375
|
+
"Password strength"
|
|
376
|
+
),
|
|
377
|
+
"aria-valuetext": K,
|
|
378
|
+
className: vs(),
|
|
379
|
+
children: /* @__PURE__ */ a(
|
|
380
|
+
"div",
|
|
381
|
+
{
|
|
382
|
+
className: ys({ level: E })
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
}
|
|
386
|
+
),
|
|
387
|
+
/* @__PURE__ */ a(
|
|
388
|
+
"span",
|
|
389
|
+
{
|
|
390
|
+
"aria-hidden": "true",
|
|
391
|
+
className: "type-meta ds:text-muted-foreground",
|
|
392
|
+
children: K
|
|
393
|
+
}
|
|
394
|
+
)
|
|
395
|
+
] }) : null
|
|
396
|
+
]
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
);
|
|
401
|
+
Ns.displayName = "PasswordInput";
|
|
402
|
+
function Hs(e = {}) {
|
|
403
|
+
const { t: r } = W(), { minLength: n, uppercase: l, lowercase: p, digit: w, symbol: h } = e;
|
|
404
|
+
return V(() => {
|
|
405
|
+
const d = [];
|
|
406
|
+
return typeof n == "number" && n > 0 && d.push({
|
|
407
|
+
id: "length",
|
|
408
|
+
label: r("ui.inputs.password.requirements.length", {
|
|
409
|
+
count: n,
|
|
410
|
+
defaultValue: `At least ${n} characters`
|
|
411
|
+
}),
|
|
412
|
+
test: (i) => i.length >= n
|
|
413
|
+
}), l && d.push({
|
|
414
|
+
id: "uppercase",
|
|
415
|
+
label: r(
|
|
416
|
+
"ui.inputs.password.requirements.uppercase",
|
|
417
|
+
"One uppercase letter"
|
|
418
|
+
),
|
|
419
|
+
test: (i) => new RegExp("\\p{Lu}", "u").test(i)
|
|
420
|
+
}), p && d.push({
|
|
421
|
+
id: "lowercase",
|
|
422
|
+
label: r(
|
|
423
|
+
"ui.inputs.password.requirements.lowercase",
|
|
424
|
+
"One lowercase letter"
|
|
425
|
+
),
|
|
426
|
+
test: (i) => new RegExp("\\p{Ll}", "u").test(i)
|
|
427
|
+
}), w && d.push({
|
|
428
|
+
id: "digit",
|
|
429
|
+
label: r("ui.inputs.password.requirements.digit", "One number"),
|
|
430
|
+
test: (i) => new RegExp("\\p{Nd}", "u").test(i)
|
|
431
|
+
}), h && d.push({
|
|
432
|
+
id: "symbol",
|
|
433
|
+
label: r("ui.inputs.password.requirements.symbol", "One symbol"),
|
|
434
|
+
// Anything that isn't a letter, number, or whitespace counts.
|
|
435
|
+
// `\p{L}` + `\p{N}` keep this Unicode-aware so non-Latin
|
|
436
|
+
// alphabets (Arabic, Chinese, …) aren't mis-classified as
|
|
437
|
+
// symbols.
|
|
438
|
+
test: (i) => /[^\p{L}\p{N}\s]/u.test(i)
|
|
439
|
+
}), d;
|
|
440
|
+
}, [r, n, l, p, w, h]);
|
|
441
|
+
}
|
|
442
|
+
export {
|
|
443
|
+
Ns as P,
|
|
444
|
+
Hs as u
|
|
445
|
+
};
|
|
446
|
+
//# sourceMappingURL=use-password-requirements-DgEYdN4H.js.map
|
package/dist/agent-catalog.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { PasswordInput } from './password-input';
|
|
2
|
-
export type { PasswordInputProps } from './password-input';
|
|
2
|
+
export type { PasswordInputProps, PasswordRequirement } from './password-input';
|
|
3
|
+
export { usePasswordRequirements } from './use-password-requirements';
|
|
4
|
+
export type { UsePasswordRequirementsOptions } from './use-password-requirements';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { P as
|
|
1
|
+
import { P as r, u as a } from "../../_chunks/use-password-requirements-DgEYdN4H.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
r as PasswordInput,
|
|
4
|
+
a as usePasswordRequirements
|
|
4
5
|
};
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -13,6 +13,18 @@ type Strength = 0 | 1 | 2 | 3;
|
|
|
13
13
|
declare const strengthBarVariants: (props?: ({
|
|
14
14
|
level?: 0 | 2 | 1 | 3 | null | undefined;
|
|
15
15
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
16
|
+
/**
|
|
17
|
+
* One row in the live requirements checklist. Consumers either build
|
|
18
|
+
* these inline or pull a pre-built set from `usePasswordRequirements`.
|
|
19
|
+
*/
|
|
20
|
+
export interface PasswordRequirement {
|
|
21
|
+
/** Stable id — keyed render + a11y. */
|
|
22
|
+
id: string;
|
|
23
|
+
/** Already-translated label. The consumer owns the wording. */
|
|
24
|
+
label: string;
|
|
25
|
+
/** Predicate against the current value. Pure, runs on every keystroke. */
|
|
26
|
+
test: (value: string) => boolean;
|
|
27
|
+
}
|
|
16
28
|
export interface PasswordInputProps extends Omit<TextInputProps, 'type' | 'endAdornment' | 'startAdornment'>, VariantProps<typeof strengthBarVariants> {
|
|
17
29
|
/** Callback when reveal state changes (for analytics). */
|
|
18
30
|
onRevealChange?: (revealed: boolean) => void;
|
|
@@ -20,6 +32,25 @@ export interface PasswordInputProps extends Omit<TextInputProps, 'type' | 'endAd
|
|
|
20
32
|
showStrength?: boolean;
|
|
21
33
|
/** Strength score: 0 = weak, 1 = fair, 2 = good, 3 = strong. */
|
|
22
34
|
strength?: Strength;
|
|
35
|
+
/**
|
|
36
|
+
* Live requirements checklist rendered between the input and the
|
|
37
|
+
* strength meter / caps-lock notice. Each row's predicate runs on
|
|
38
|
+
* every keystroke and the row's `data-state` flips between `"met"`
|
|
39
|
+
* and `"unmet"`. Backed by `aria-live="polite"` so screen readers
|
|
40
|
+
* announce each transition as a visually-hidden suffix span flips
|
|
41
|
+
* between localised "met" / "not yet met" copy.
|
|
42
|
+
*
|
|
43
|
+
* Tip: hoist or `useMemo` the array — inlining it in JSX makes the
|
|
44
|
+
* predicate-results memo bust every render. The kit's
|
|
45
|
+
* `usePasswordRequirements` helper already does this.
|
|
46
|
+
*/
|
|
47
|
+
requirements?: ReadonlyArray<PasswordRequirement>;
|
|
48
|
+
/**
|
|
49
|
+
* When `true` AND `strength` is not provided, derive a 0–3 score
|
|
50
|
+
* from the proportion of `requirements` satisfied. Lets consumers
|
|
51
|
+
* get the strength bar "for free" once they declare requirements.
|
|
52
|
+
*/
|
|
53
|
+
deriveStrength?: boolean;
|
|
23
54
|
/**
|
|
24
55
|
* Autocomplete hint. Defaults to 'current-password'.
|
|
25
56
|
* Use 'new-password' for registration/change-password forms.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { PasswordRequirement } from './password-input';
|
|
2
|
+
export interface UsePasswordRequirementsOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Minimum password length. When set, adds a "length" requirement.
|
|
5
|
+
* Pass `12` (or whatever the server-side regex enforces) so the
|
|
6
|
+
* inline checklist tells users the same rule they'll bounce off
|
|
7
|
+
* server-side. When omitted, no length row is rendered.
|
|
8
|
+
*/
|
|
9
|
+
minLength?: number;
|
|
10
|
+
/** Adds an "uppercase letter" requirement when true. */
|
|
11
|
+
uppercase?: boolean;
|
|
12
|
+
/** Adds a "lowercase letter" requirement when true. */
|
|
13
|
+
lowercase?: boolean;
|
|
14
|
+
/** Adds a "digit" requirement when true. */
|
|
15
|
+
digit?: boolean;
|
|
16
|
+
/** Adds a "symbol" requirement when true. Matches anything outside `[A-Za-z0-9\s]`. */
|
|
17
|
+
symbol?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Builds the common set of password requirements with i18n-resolved
|
|
21
|
+
* labels. Designed for the AlfaDocs platform's patient-registration
|
|
22
|
+
* server-side regex (`/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d).{12,}$/`) but
|
|
23
|
+
* generic enough for any consumer.
|
|
24
|
+
*
|
|
25
|
+
* Each opt-in flag adds one row to the returned array, in a stable
|
|
26
|
+
* visual order (length → uppercase → lowercase → digit → symbol).
|
|
27
|
+
* Predicates are pure and run on every keystroke.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const requirements = usePasswordRequirements({
|
|
31
|
+
* minLength: 12,
|
|
32
|
+
* uppercase: true,
|
|
33
|
+
* lowercase: true,
|
|
34
|
+
* digit: true,
|
|
35
|
+
* });
|
|
36
|
+
* <PasswordInput requirements={requirements} deriveStrength />
|
|
37
|
+
*/
|
|
38
|
+
export declare function usePasswordRequirements(opts?: UsePasswordRequirementsOptions): PasswordRequirement[];
|
|
39
|
+
//# sourceMappingURL=use-password-requirements.d.ts.map
|
package/dist/i18n/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import n from "i18next";
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as g } from "i18next";
|
|
3
3
|
import { initReactI18next as i } from "react-i18next";
|
|
4
4
|
const e = {
|
|
5
5
|
common: {
|
|
@@ -66,6 +66,16 @@ const e = {
|
|
|
66
66
|
fair: "Fair",
|
|
67
67
|
good: "Good",
|
|
68
68
|
strong: "Strong"
|
|
69
|
+
},
|
|
70
|
+
requirements: {
|
|
71
|
+
length_one: "At least {{count}} character",
|
|
72
|
+
length_other: "At least {{count}} characters",
|
|
73
|
+
uppercase: "One uppercase letter",
|
|
74
|
+
lowercase: "One lowercase letter",
|
|
75
|
+
digit: "One number",
|
|
76
|
+
symbol: "One symbol",
|
|
77
|
+
met: "met",
|
|
78
|
+
unmet: "not yet met"
|
|
69
79
|
}
|
|
70
80
|
},
|
|
71
81
|
textarea: {
|
|
@@ -1028,6 +1038,16 @@ const e = {
|
|
|
1028
1038
|
fair: "Discreta",
|
|
1029
1039
|
good: "Buona",
|
|
1030
1040
|
strong: "Forte"
|
|
1041
|
+
},
|
|
1042
|
+
requirements: {
|
|
1043
|
+
length_one: "Almeno {{count}} carattere",
|
|
1044
|
+
length_other: "Almeno {{count}} caratteri",
|
|
1045
|
+
uppercase: "Una lettera maiuscola",
|
|
1046
|
+
lowercase: "Una lettera minuscola",
|
|
1047
|
+
digit: "Un numero",
|
|
1048
|
+
symbol: "Un simbolo",
|
|
1049
|
+
met: "soddisfatto",
|
|
1050
|
+
unmet: "non ancora soddisfatto"
|
|
1031
1051
|
}
|
|
1032
1052
|
},
|
|
1033
1053
|
textarea: {
|
|
@@ -1958,6 +1978,16 @@ const e = {
|
|
|
1958
1978
|
toggleHide: "Passwort verbergen",
|
|
1959
1979
|
capsLock: "Feststelltaste ist aktiviert",
|
|
1960
1980
|
strengthLabel: "Passwortstärke",
|
|
1981
|
+
requirements: {
|
|
1982
|
+
length_one: "Mindestens {{count}} Zeichen",
|
|
1983
|
+
length_other: "Mindestens {{count}} Zeichen",
|
|
1984
|
+
uppercase: "Ein Großbuchstabe",
|
|
1985
|
+
lowercase: "Ein Kleinbuchstabe",
|
|
1986
|
+
digit: "Eine Zahl",
|
|
1987
|
+
symbol: "Ein Sonderzeichen",
|
|
1988
|
+
met: "erfüllt",
|
|
1989
|
+
unmet: "noch nicht erfüllt"
|
|
1990
|
+
},
|
|
1961
1991
|
strength: {
|
|
1962
1992
|
weak: "Schwach",
|
|
1963
1993
|
fair: "Mittel",
|
|
@@ -2874,7 +2904,7 @@ n.use(i).init({
|
|
|
2874
2904
|
export {
|
|
2875
2905
|
u as LOCALES_WITH_BUNDLES,
|
|
2876
2906
|
t as arUi,
|
|
2877
|
-
|
|
2907
|
+
g as default,
|
|
2878
2908
|
e as enUi,
|
|
2879
2909
|
d as uiResources
|
|
2880
2910
|
};
|
package/dist/i18n/resources.d.ts
CHANGED
|
@@ -65,6 +65,16 @@ export declare const enUi: {
|
|
|
65
65
|
readonly good: "Good";
|
|
66
66
|
readonly strong: "Strong";
|
|
67
67
|
};
|
|
68
|
+
readonly requirements: {
|
|
69
|
+
readonly length_one: "At least {{count}} character";
|
|
70
|
+
readonly length_other: "At least {{count}} characters";
|
|
71
|
+
readonly uppercase: "One uppercase letter";
|
|
72
|
+
readonly lowercase: "One lowercase letter";
|
|
73
|
+
readonly digit: "One number";
|
|
74
|
+
readonly symbol: "One symbol";
|
|
75
|
+
readonly met: "met";
|
|
76
|
+
readonly unmet: "not yet met";
|
|
77
|
+
};
|
|
68
78
|
};
|
|
69
79
|
readonly textarea: {
|
|
70
80
|
readonly charactersRemaining_one: "{{count}} character remaining";
|
|
@@ -1046,6 +1056,16 @@ export declare const itUi: {
|
|
|
1046
1056
|
readonly good: "Buona";
|
|
1047
1057
|
readonly strong: "Forte";
|
|
1048
1058
|
};
|
|
1059
|
+
readonly requirements: {
|
|
1060
|
+
readonly length_one: "Almeno {{count}} carattere";
|
|
1061
|
+
readonly length_other: "Almeno {{count}} caratteri";
|
|
1062
|
+
readonly uppercase: "Una lettera maiuscola";
|
|
1063
|
+
readonly lowercase: "Una lettera minuscola";
|
|
1064
|
+
readonly digit: "Un numero";
|
|
1065
|
+
readonly symbol: "Un simbolo";
|
|
1066
|
+
readonly met: "soddisfatto";
|
|
1067
|
+
readonly unmet: "non ancora soddisfatto";
|
|
1068
|
+
};
|
|
1049
1069
|
};
|
|
1050
1070
|
readonly textarea: {
|
|
1051
1071
|
readonly charactersRemaining_one: "{{count}} carattere rimanente";
|
|
@@ -2000,6 +2020,16 @@ export declare const deUi: {
|
|
|
2000
2020
|
readonly toggleHide: "Passwort verbergen";
|
|
2001
2021
|
readonly capsLock: "Feststelltaste ist aktiviert";
|
|
2002
2022
|
readonly strengthLabel: "Passwortstärke";
|
|
2023
|
+
readonly requirements: {
|
|
2024
|
+
readonly length_one: "Mindestens {{count}} Zeichen";
|
|
2025
|
+
readonly length_other: "Mindestens {{count}} Zeichen";
|
|
2026
|
+
readonly uppercase: "Ein Großbuchstabe";
|
|
2027
|
+
readonly lowercase: "Ein Kleinbuchstabe";
|
|
2028
|
+
readonly digit: "Eine Zahl";
|
|
2029
|
+
readonly symbol: "Ein Sonderzeichen";
|
|
2030
|
+
readonly met: "erfüllt";
|
|
2031
|
+
readonly unmet: "noch nicht erfüllt";
|
|
2032
|
+
};
|
|
2003
2033
|
readonly strength: {
|
|
2004
2034
|
readonly weak: "Schwach";
|
|
2005
2035
|
readonly fair: "Mittel";
|