@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.
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts +10 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +6 -2
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +6 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +89 -73
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +49 -25
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +57 -32
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/chip.cjs +1 -0
- package/dist/chip.d.ts +61 -0
- package/dist/chip.d.ts.map +1 -0
- package/dist/chip.js +165 -0
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +5 -2
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +89 -52
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +228 -210
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/header.cjs +1 -0
- package/dist/header.d.ts +42 -0
- package/dist/header.d.ts.map +1 -0
- package/dist/header.js +22 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +426 -396
- package/dist/input-chip.cjs +1 -0
- package/dist/input-chip.d.ts +117 -0
- package/dist/input-chip.d.ts.map +1 -0
- package/dist/input-chip.js +284 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +43 -36
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +140 -119
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +147 -19
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +197 -92
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +10 -0
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +45 -36
- package/dist/select.d.ts.map +1 -1
- package/dist/slider.cjs +1 -1
- package/dist/slider.d.ts +31 -3
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +53 -43
- package/dist/textarea.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/alert.tsx +10 -1
- package/src/components/card.tsx +66 -38
- package/src/components/centred-layout.tsx +115 -38
- package/src/components/checkbox.tsx +2 -2
- package/src/components/chip.tsx +249 -0
- package/src/components/combobox.tsx +17 -13
- package/src/components/date-picker.tsx +410 -266
- package/src/components/dropdown-menu.tsx +6 -1
- package/src/components/header.tsx +69 -0
- package/src/components/input-chip.tsx +548 -0
- package/src/components/input-group.tsx +4 -1
- package/src/components/input-otp.tsx +159 -91
- package/src/components/input-password.tsx +469 -129
- package/src/components/input.tsx +1 -1
- package/src/components/progress.tsx +21 -2
- package/src/components/select.tsx +1 -3
- package/src/components/slider.tsx +85 -15
- package/src/components/textarea.tsx +4 -1
- package/src/index.ts +3 -0
package/dist/input-otp.js
CHANGED
|
@@ -1,52 +1,72 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
2
|
import * as s from "react";
|
|
3
|
-
import {
|
|
4
|
-
import { REGEXP_ONLY_CHARS as
|
|
5
|
-
import { MinusIcon as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { Label as
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
import { OTPInput as v, OTPInputContext as x, REGEXP_ONLY_DIGITS as N } from "input-otp";
|
|
4
|
+
import { REGEXP_ONLY_CHARS as W, REGEXP_ONLY_DIGITS as X, REGEXP_ONLY_DIGITS_AND_CHARS as Y } from "input-otp";
|
|
5
|
+
import { MinusIcon as b } from "@brightlocal/icons";
|
|
6
|
+
import { cn as I } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { Label as w } from "@brightlocal/ui-components/label";
|
|
8
|
+
const P = s.createContext(null);
|
|
9
|
+
function y() {
|
|
10
|
+
const t = s.useContext(P);
|
|
11
|
+
if (!t)
|
|
12
|
+
throw new Error("InputOTP components must be used within an <InputOTP>");
|
|
13
|
+
return t;
|
|
14
|
+
}
|
|
15
|
+
const T = s.forwardRef(
|
|
16
|
+
({
|
|
17
|
+
dataHook: t,
|
|
18
|
+
trackingEl: r,
|
|
19
|
+
trackingLabel: n,
|
|
20
|
+
containerClassName: o,
|
|
21
|
+
error: a,
|
|
22
|
+
disabled: u,
|
|
23
|
+
children: i,
|
|
24
|
+
...d
|
|
25
|
+
}, l) => {
|
|
26
|
+
const c = s.useMemo(
|
|
27
|
+
() => ({ error: a, disabled: u }),
|
|
28
|
+
[a, u]
|
|
29
|
+
);
|
|
30
|
+
return /* @__PURE__ */ e(P.Provider, { value: c, children: /* @__PURE__ */ e(
|
|
31
|
+
v,
|
|
13
32
|
{
|
|
14
|
-
ref:
|
|
15
|
-
"aria-invalid":
|
|
16
|
-
"aria-label": m,
|
|
33
|
+
ref: l,
|
|
34
|
+
"aria-invalid": a ? "true" : void 0,
|
|
17
35
|
className: "disabled:cursor-not-allowed",
|
|
18
|
-
containerClassName:
|
|
36
|
+
containerClassName: I(
|
|
19
37
|
"group flex items-center gap-2 has-disabled:opacity-50 w-fit",
|
|
20
|
-
|
|
38
|
+
o
|
|
21
39
|
),
|
|
22
|
-
"data-hook":
|
|
40
|
+
"data-hook": t,
|
|
23
41
|
"data-slot": "input-otp",
|
|
24
|
-
"data-tracking-el":
|
|
25
|
-
"data-tracking-label":
|
|
26
|
-
|
|
42
|
+
"data-tracking-el": r,
|
|
43
|
+
"data-tracking-label": n,
|
|
44
|
+
disabled: u,
|
|
45
|
+
...d,
|
|
46
|
+
children: i
|
|
27
47
|
}
|
|
28
|
-
);
|
|
48
|
+
) });
|
|
29
49
|
}
|
|
30
50
|
);
|
|
31
|
-
|
|
32
|
-
function
|
|
33
|
-
return /* @__PURE__ */
|
|
51
|
+
T.displayName = "InputOTP";
|
|
52
|
+
function f({ className: t, ...r }) {
|
|
53
|
+
return /* @__PURE__ */ e(
|
|
34
54
|
"div",
|
|
35
55
|
{
|
|
36
|
-
className:
|
|
56
|
+
className: I("flex items-center rounded-md shadow-xs", t),
|
|
37
57
|
"data-slot": "input-otp-group",
|
|
38
|
-
...
|
|
58
|
+
...r
|
|
39
59
|
}
|
|
40
60
|
);
|
|
41
61
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
), { char:
|
|
46
|
-
return /* @__PURE__ */
|
|
62
|
+
function p({ index: t, className: r, ...n }) {
|
|
63
|
+
const { error: o } = y(), a = s.useContext(
|
|
64
|
+
x
|
|
65
|
+
), { char: u, hasFakeCaret: i, isActive: d } = a?.slots[t] ?? {};
|
|
66
|
+
return /* @__PURE__ */ h(
|
|
47
67
|
"div",
|
|
48
68
|
{
|
|
49
|
-
className:
|
|
69
|
+
className: I(
|
|
50
70
|
// Base styles
|
|
51
71
|
"relative flex h-9 w-9 items-center justify-center",
|
|
52
72
|
"border-input bg-background border-y border-r",
|
|
@@ -56,134 +76,135 @@ function u({ index: e, className: a, ...n }) {
|
|
|
56
76
|
"data-[active=true]:border-ring data-[active=true]:z-10",
|
|
57
77
|
"data-[active=true]:shadow-default",
|
|
58
78
|
// Error state
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"group-has-[input[aria-invalid=true]]:data-[active=true]:border-destructive",
|
|
79
|
+
o && "border-destructive",
|
|
80
|
+
o && d && "shadow-destructive",
|
|
62
81
|
// Dark mode
|
|
63
82
|
"dark:bg-input/30",
|
|
64
|
-
|
|
83
|
+
r
|
|
65
84
|
),
|
|
66
|
-
"data-active":
|
|
85
|
+
"data-active": d,
|
|
86
|
+
"data-error": o,
|
|
67
87
|
"data-slot": "input-otp-slot",
|
|
68
88
|
...n,
|
|
69
89
|
children: [
|
|
70
|
-
|
|
71
|
-
|
|
90
|
+
u,
|
|
91
|
+
i && /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "animate-caret-blink bg-foreground h-4 w-px duration-1000" }) })
|
|
72
92
|
]
|
|
73
93
|
}
|
|
74
94
|
);
|
|
75
95
|
}
|
|
76
|
-
function
|
|
77
|
-
return /* @__PURE__ */
|
|
96
|
+
function g({ ...t }) {
|
|
97
|
+
return /* @__PURE__ */ e("div", { "data-slot": "input-otp-separator", role: "separator", ...t, children: /* @__PURE__ */ e(b, {}) });
|
|
78
98
|
}
|
|
79
|
-
|
|
80
|
-
(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
const
|
|
93
|
-
return /* @__PURE__ */
|
|
94
|
-
|
|
95
|
-
|
|
99
|
+
function S({ dataHook: t, className: r, ...n }) {
|
|
100
|
+
return /* @__PURE__ */ e(
|
|
101
|
+
w,
|
|
102
|
+
{
|
|
103
|
+
className: I("mb-2", r),
|
|
104
|
+
"data-hook": t,
|
|
105
|
+
"data-slot": "input-otp-label",
|
|
106
|
+
...n
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
const m = s.forwardRef(
|
|
111
|
+
({ label: t, id: r, dataHook: n, "aria-label": o, children: a, ...u }, i) => {
|
|
112
|
+
const d = s.useId(), l = r || d, c = o || (t ? void 0 : "One-time password");
|
|
113
|
+
return /* @__PURE__ */ h("div", { className: "w-fit", "data-slot": "input-otp-field", children: [
|
|
114
|
+
t && /* @__PURE__ */ e(
|
|
115
|
+
S,
|
|
96
116
|
{
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
children: e
|
|
117
|
+
dataHook: n ? `${n}-label` : void 0,
|
|
118
|
+
htmlFor: l,
|
|
119
|
+
children: t
|
|
101
120
|
}
|
|
102
121
|
),
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
|
|
122
|
+
/* @__PURE__ */ e(
|
|
123
|
+
T,
|
|
105
124
|
{
|
|
106
|
-
ref:
|
|
107
|
-
"aria-label":
|
|
108
|
-
containerClassName: r,
|
|
125
|
+
ref: i,
|
|
126
|
+
"aria-label": c,
|
|
109
127
|
dataHook: n,
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
trackingLabel: i,
|
|
114
|
-
...c,
|
|
115
|
-
children: o
|
|
128
|
+
id: t ? l : void 0,
|
|
129
|
+
...u,
|
|
130
|
+
children: a
|
|
116
131
|
}
|
|
117
132
|
)
|
|
118
133
|
] });
|
|
119
134
|
}
|
|
120
135
|
);
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
136
|
+
m.displayName = "InputOTPField";
|
|
137
|
+
const _ = s.forwardRef(({ maxLength: t = 6, ...r }, n) => /* @__PURE__ */ e(
|
|
138
|
+
m,
|
|
124
139
|
{
|
|
125
|
-
ref:
|
|
140
|
+
ref: n,
|
|
126
141
|
inputMode: "numeric",
|
|
127
|
-
maxLength:
|
|
128
|
-
pasteTransformer: (
|
|
129
|
-
pattern:
|
|
130
|
-
...
|
|
131
|
-
children: /* @__PURE__ */
|
|
142
|
+
maxLength: t,
|
|
143
|
+
pasteTransformer: (o) => o.replace(/\D+/g, "").slice(0, t),
|
|
144
|
+
pattern: N,
|
|
145
|
+
...r,
|
|
146
|
+
children: /* @__PURE__ */ e(f, { children: Array.from({ length: t }, (o, a) => /* @__PURE__ */ e(p, { index: a }, a)) })
|
|
132
147
|
}
|
|
133
148
|
));
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
149
|
+
_.displayName = "InputOTPDigitsOnly";
|
|
150
|
+
const R = s.forwardRef(({ maxLength: t = 4, ...r }, n) => /* @__PURE__ */ e(
|
|
151
|
+
m,
|
|
137
152
|
{
|
|
138
153
|
ref: n,
|
|
139
154
|
containerClassName: "gap-2",
|
|
140
|
-
maxLength:
|
|
141
|
-
...
|
|
142
|
-
children: Array.from({ length:
|
|
143
|
-
|
|
155
|
+
maxLength: t,
|
|
156
|
+
...r,
|
|
157
|
+
children: Array.from({ length: t }, (o, a) => /* @__PURE__ */ e(
|
|
158
|
+
p,
|
|
144
159
|
{
|
|
145
160
|
className: "rounded-md border-l shadow-xs",
|
|
146
|
-
index:
|
|
161
|
+
index: a
|
|
147
162
|
},
|
|
148
|
-
|
|
163
|
+
a
|
|
149
164
|
))
|
|
150
165
|
}
|
|
151
166
|
));
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
({ maxLength:
|
|
155
|
-
const
|
|
156
|
-
return /* @__PURE__ */
|
|
157
|
-
/* @__PURE__ */
|
|
158
|
-
/* @__PURE__ */
|
|
159
|
-
/* @__PURE__ */
|
|
160
|
-
|
|
167
|
+
R.displayName = "InputOTPWithSpacing";
|
|
168
|
+
const C = s.forwardRef(
|
|
169
|
+
({ maxLength: t = 6, ...r }, n) => {
|
|
170
|
+
const o = Math.ceil(t / 2), a = t - o;
|
|
171
|
+
return /* @__PURE__ */ h(m, { ref: n, maxLength: t, ...r, children: [
|
|
172
|
+
/* @__PURE__ */ e(f, { children: Array.from({ length: o }, (u, i) => /* @__PURE__ */ e(p, { index: i }, i)) }),
|
|
173
|
+
/* @__PURE__ */ e(g, {}),
|
|
174
|
+
/* @__PURE__ */ e(f, { children: Array.from({ length: a }, (u, i) => /* @__PURE__ */ e(
|
|
175
|
+
p,
|
|
161
176
|
{
|
|
162
|
-
index:
|
|
177
|
+
index: i + o
|
|
163
178
|
},
|
|
164
|
-
|
|
179
|
+
i + o
|
|
165
180
|
)) })
|
|
166
181
|
] });
|
|
167
182
|
}
|
|
168
183
|
);
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
return /* @__PURE__ */
|
|
173
|
-
const
|
|
174
|
-
return /* @__PURE__ */
|
|
175
|
-
|
|
176
|
-
/* @__PURE__ */
|
|
177
|
-
] },
|
|
184
|
+
C.displayName = "InputOTPSimple";
|
|
185
|
+
const A = s.forwardRef(({ maxLength: t = 6, ...r }, n) => {
|
|
186
|
+
const a = Math.ceil(t / 2);
|
|
187
|
+
return /* @__PURE__ */ e(m, { ref: n, maxLength: t, ...r, children: Array.from({ length: a }, (u, i) => {
|
|
188
|
+
const d = i * 2, c = Math.min(d + 2, t) - d;
|
|
189
|
+
return /* @__PURE__ */ h(s.Fragment, { children: [
|
|
190
|
+
i > 0 && /* @__PURE__ */ e(g, {}),
|
|
191
|
+
/* @__PURE__ */ e(f, { children: Array.from({ length: c }, (G, O) => /* @__PURE__ */ e(p, { index: d + O }, d + O)) })
|
|
192
|
+
] }, i);
|
|
178
193
|
}) });
|
|
179
194
|
});
|
|
180
|
-
|
|
195
|
+
A.displayName = "InputOTPWithSeparator";
|
|
181
196
|
export {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
197
|
+
T as InputOTP,
|
|
198
|
+
_ as InputOTPDigitsOnly,
|
|
199
|
+
m as InputOTPField,
|
|
200
|
+
f as InputOTPGroup,
|
|
201
|
+
S as InputOTPLabel,
|
|
202
|
+
g as InputOTPSeparator,
|
|
203
|
+
C as InputOTPSimple,
|
|
204
|
+
p as InputOTPSlot,
|
|
205
|
+
A as InputOTPWithSeparator,
|
|
206
|
+
R as InputOTPWithSpacing,
|
|
207
|
+
W as REGEXP_ONLY_CHARS,
|
|
208
|
+
X as REGEXP_ONLY_DIGITS,
|
|
209
|
+
Y as REGEXP_ONLY_DIGITS_AND_CHARS
|
|
189
210
|
};
|
package/dist/input-password.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),D=require("react"),P=require("@brightlocal/icons"),M=require("@brightlocal/ui-components/progress"),S=require("@brightlocal/ui-components/lib/utils"),w=require("@brightlocal/ui-components/input-group");function $(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const a=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,a.get?a:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const r=$(D),C={meter:{label:"Meter",value:0,color:"bg-green-500"},weak:{label:"Weak",value:25,color:"bg-green-500"},ok:{label:"Ok",value:50,color:"bg-green-500"},good:{label:"Good",value:75,color:"bg-green-500"},great:{label:"Great",value:100,color:"bg-green-500"}};function O(e){if(!e||e.length===0)return"meter";if(e.length<12)return"weak";let t=0;return e.length>=16&&(t+=1),/[a-z]/.test(e)&&(t+=1),/[A-Z]/.test(e)&&(t+=1),/[0-9]/.test(e)&&(t+=1),/[^a-zA-Z0-9]/.test(e)&&(t+=1),t<=1?"ok":t<=3?"good":"great"}const L=r.createContext(null);function v(){const e=r.useContext(L);if(!e)throw new Error("InputPassword compound components must be used within InputPasswordRoot");return e}function H({children:e,dataHook:t,trackingEl:o,trackingLabel:a,disabled:c,value:n,onChange:l,onStrengthChange:u,strengthLevels:p,calculateStrength:d,error:i,id:x,className:I}){const[h,f]=r.useState(!1),[j,m]=r.useState(""),[y,A]=r.useState("meter"),F=r.useId(),k=x||F,b=n!==void 0?n:j,N=p??C,E=d??O,T=r.useCallback(g=>{n===void 0&&m(g),l?.(g)},[n,l]),R=r.useCallback(()=>{f(g=>!g)},[]);r.useEffect(()=>{const g=setTimeout(()=>{const G=E(b);A(G),u?.(G)},180);return()=>clearTimeout(g)},[b,E,u]);const z=r.useMemo(()=>({showPassword:h,setShowPassword:f,toggleVisibility:R,password:b,setPassword:T,strength:y,strengthLevels:N,disabled:c,dataHook:t,trackingEl:o,trackingLabel:a,inputId:k,error:i}),[h,R,b,T,y,N,c,t,o,a,k,i]);return s.jsx(L.Provider,{value:z,children:s.jsx("div",{className:S.cn("w-full",I),children:e})})}H.displayName="InputPasswordRoot";const _=r.forwardRef(({className:e,groupClassName:t,onChange:o,...a},c)=>{const{showPassword:n,toggleVisibility:l,password:u,setPassword:p,disabled:d,dataHook:i,trackingEl:x,trackingLabel:I,inputId:h,error:f}=v(),j=m=>{p(m.target.value),o?.(m)};return s.jsxs(w.InputGroup,{className:t,dataHook:i,error:f,children:[s.jsx(w.InputGroupInput,{ref:c,className:e,disabled:d,id:h,trackingEl:x,trackingLabel:I,type:n?"text":"password",value:u,onChange:j,...a}),s.jsx(w.InputGroupAddon,{align:"inline-end",children:s.jsx(w.InputGroupButton,{"aria-label":n?"Hide password":"Show password","data-hook":`${i}-toggle`,disabled:d,size:"icon",variant:"ghost",onClick:l,children:n?s.jsx(P.EyeOff,{className:"h-4 w-4"}):s.jsx(P.Eye,{className:"h-4 w-4"})})})]})});_.displayName="InputPasswordField";const q=r.forwardRef(({className:e,showLabel:t="Show password",hideLabel:o="Hide password",size:a="icon",variant:c="ghost",...n},l)=>{const{showPassword:u,toggleVisibility:p,disabled:d,dataHook:i}=v();return s.jsx(w.InputGroupButton,{ref:l,"aria-label":u?o:t,className:e,"data-hook":`${i}-toggle`,disabled:d,size:a,variant:c,onClick:p,...n,children:u?s.jsx(P.EyeOff,{className:"h-4 w-4"}):s.jsx(P.Eye,{className:"h-4 w-4"})})});q.displayName="InputPasswordToggle";function V({className:e,showLabel:t=!0}){const{strength:o,strengthLevels:a,dataHook:c,disabled:n}=v(),l=a[o]??{label:o,value:0,color:"bg-muted"};return s.jsx("div",{className:S.cn("mt-1 space-y-2",e),children:s.jsxs("div",{className:S.cn("flex items-center gap-2",n&&"opacity-50"),children:[s.jsx(M.Progress,{className:"h-2 flex-1",dataHook:`${c}-strength-progress`,indicatorClassName:l.color,value:l.value}),t&&s.jsx("span",{className:"text-foreground w-10 shrink-0 text-right text-sm font-medium whitespace-nowrap","data-hook":`${c}-strength-label`,children:l.label})]})})}V.displayName="InputPasswordStrength";exports.DEFAULT_STRENGTH_LEVELS=C;exports.InputPasswordField=_;exports.InputPasswordRoot=H;exports.InputPasswordStrength=V;exports.InputPasswordToggle=q;exports.calculatePasswordStrength=O;
|
package/dist/input-password.d.ts
CHANGED
|
@@ -1,42 +1,170 @@
|
|
|
1
|
+
import { InputGroupInput, InputGroupButton } from '../input-group';
|
|
1
2
|
import * as React from "react";
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Default password strength levels (industry standard)
|
|
5
|
+
*/
|
|
6
|
+
type DefaultPasswordStrength = "meter" | "weak" | "ok" | "good" | "great";
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for a single strength level
|
|
9
|
+
*/
|
|
10
|
+
interface StrengthLevelConfig {
|
|
4
11
|
label: string;
|
|
5
12
|
value: number;
|
|
6
13
|
color: string;
|
|
7
14
|
}
|
|
8
|
-
|
|
9
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Default strength levels configuration
|
|
17
|
+
*/
|
|
18
|
+
declare const DEFAULT_STRENGTH_LEVELS: Record<DefaultPasswordStrength, StrengthLevelConfig>;
|
|
19
|
+
/**
|
|
20
|
+
* Calculate password strength based on various criteria (default implementation)
|
|
21
|
+
* - Minimum 12 characters required for "ok" or better
|
|
22
|
+
*/
|
|
23
|
+
declare function calculatePasswordStrength(password: string): DefaultPasswordStrength;
|
|
24
|
+
export interface InputPasswordRootProps<T extends string = DefaultPasswordStrength> {
|
|
10
25
|
/**
|
|
11
|
-
*
|
|
26
|
+
* Data hook for automated testing (REQUIRED)
|
|
12
27
|
*/
|
|
13
|
-
|
|
28
|
+
dataHook: string;
|
|
14
29
|
/**
|
|
15
|
-
*
|
|
30
|
+
* Tracking element identifier for analytics
|
|
16
31
|
*/
|
|
17
|
-
|
|
32
|
+
trackingEl?: string;
|
|
18
33
|
/**
|
|
19
|
-
*
|
|
34
|
+
* Tracking label for analytics context
|
|
20
35
|
*/
|
|
21
|
-
|
|
36
|
+
trackingLabel?: string;
|
|
22
37
|
/**
|
|
23
|
-
*
|
|
38
|
+
* Disabled state
|
|
24
39
|
*/
|
|
25
|
-
|
|
40
|
+
disabled?: boolean;
|
|
26
41
|
/**
|
|
27
|
-
*
|
|
42
|
+
* Controlled password value
|
|
28
43
|
*/
|
|
29
|
-
|
|
44
|
+
value?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Callback fired when password changes
|
|
47
|
+
*/
|
|
48
|
+
onChange?: (value: string) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Callback fired when password strength changes
|
|
51
|
+
*/
|
|
52
|
+
onStrengthChange?: (strength: T) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Custom strength levels configuration.
|
|
55
|
+
* Define your own levels with custom keys, labels, values, and colors.
|
|
56
|
+
* @example
|
|
57
|
+
* strengthLevels={{
|
|
58
|
+
* empty: { label: "Enter password", value: 0, color: "bg-muted" },
|
|
59
|
+
* slow: { label: "Slow", value: 33, color: "bg-red-500" },
|
|
60
|
+
* medium: { label: "Medium", value: 66, color: "bg-yellow-500" },
|
|
61
|
+
* fast: { label: "Fast", value: 100, color: "bg-green-500" },
|
|
62
|
+
* }}
|
|
63
|
+
*/
|
|
64
|
+
strengthLevels?: Record<T, StrengthLevelConfig>;
|
|
65
|
+
/**
|
|
66
|
+
* Custom function to calculate password strength.
|
|
67
|
+
* Must return a key from strengthLevels (or default levels if not provided).
|
|
68
|
+
* @default calculatePasswordStrength (built-in)
|
|
69
|
+
*/
|
|
70
|
+
calculateStrength?: (password: string) => T;
|
|
30
71
|
/**
|
|
31
72
|
* Whether the input has an error state
|
|
32
73
|
*/
|
|
33
74
|
error?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* ID for the input element (for label association)
|
|
77
|
+
*/
|
|
78
|
+
id?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Children components
|
|
81
|
+
*/
|
|
82
|
+
children: React.ReactNode;
|
|
83
|
+
/**
|
|
84
|
+
* Additional class name for the root container
|
|
85
|
+
*/
|
|
86
|
+
className?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* InputPasswordRoot - Root component that provides context for all InputPassword parts
|
|
90
|
+
*
|
|
91
|
+
* Generic type parameter T allows custom strength levels:
|
|
92
|
+
* @example
|
|
93
|
+
* // Using default levels
|
|
94
|
+
* <InputPasswordRoot dataHook="password">...</InputPasswordRoot>
|
|
95
|
+
*
|
|
96
|
+
* // Using custom levels
|
|
97
|
+
* type MyStrength = "empty" | "slow" | "medium" | "fast";
|
|
98
|
+
* <InputPasswordRoot<MyStrength>
|
|
99
|
+
* dataHook="password"
|
|
100
|
+
* strengthLevels={{
|
|
101
|
+
* empty: { label: "Enter password", value: 0, color: "bg-muted" },
|
|
102
|
+
* slow: { label: "Slow", value: 33, color: "bg-red-500" },
|
|
103
|
+
* medium: { label: "Medium", value: 66, color: "bg-yellow-500" },
|
|
104
|
+
* fast: { label: "Fast", value: 100, color: "bg-green-500" },
|
|
105
|
+
* }}
|
|
106
|
+
* calculateStrength={(password) => {
|
|
107
|
+
* if (!password) return "empty";
|
|
108
|
+
* if (password.length < 8) return "slow";
|
|
109
|
+
* if (password.length < 12) return "medium";
|
|
110
|
+
* return "fast";
|
|
111
|
+
* }}
|
|
112
|
+
* >
|
|
113
|
+
* ...
|
|
114
|
+
* </InputPasswordRoot>
|
|
115
|
+
*/
|
|
116
|
+
declare function InputPasswordRoot<T extends string = DefaultPasswordStrength>({ children, dataHook, trackingEl, trackingLabel, disabled, value, onChange, onStrengthChange, strengthLevels, calculateStrength, error, id, className, }: InputPasswordRootProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
117
|
+
declare namespace InputPasswordRoot {
|
|
118
|
+
var displayName: string;
|
|
119
|
+
}
|
|
120
|
+
export interface InputPasswordFieldProps extends Omit<React.ComponentProps<typeof InputGroupInput>, "type"> {
|
|
121
|
+
/**
|
|
122
|
+
* Additional class name for the InputGroup wrapper
|
|
123
|
+
*/
|
|
124
|
+
groupClassName?: string;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* InputPasswordField - The password input field with toggle button
|
|
128
|
+
* Wraps InputGroup with InputGroupInput and InputGroupAddon for the toggle
|
|
129
|
+
*/
|
|
130
|
+
declare const InputPasswordField: React.ForwardRefExoticComponent<Omit<InputPasswordFieldProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
131
|
+
export interface InputPasswordToggleProps extends Omit<React.ComponentProps<typeof InputGroupButton>, "onClick" | "aria-label"> {
|
|
132
|
+
/**
|
|
133
|
+
* Custom aria-label for show state
|
|
134
|
+
* @default "Show password"
|
|
135
|
+
*/
|
|
136
|
+
showLabel?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Custom aria-label for hide state
|
|
139
|
+
* @default "Hide password"
|
|
140
|
+
*/
|
|
141
|
+
hideLabel?: string;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* InputPasswordToggle - Standalone toggle button for password visibility
|
|
145
|
+
* Use this when you need custom placement of the toggle button
|
|
146
|
+
*/
|
|
147
|
+
declare const InputPasswordToggle: React.ForwardRefExoticComponent<Omit<InputPasswordToggleProps, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
148
|
+
export interface InputPasswordStrengthProps {
|
|
149
|
+
/**
|
|
150
|
+
* Additional class name
|
|
151
|
+
*/
|
|
152
|
+
className?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Whether to show the label next to the progress bar
|
|
155
|
+
* @default true
|
|
156
|
+
*/
|
|
157
|
+
showLabel?: boolean;
|
|
34
158
|
}
|
|
35
159
|
/**
|
|
36
|
-
*
|
|
160
|
+
* InputPasswordStrength - Password strength indicator
|
|
161
|
+
* Displays a progress bar and optional label showing password strength.
|
|
162
|
+
* Automatically uses the strength levels configured on InputPasswordRoot.
|
|
37
163
|
*/
|
|
38
|
-
declare function
|
|
39
|
-
declare
|
|
40
|
-
|
|
41
|
-
|
|
164
|
+
declare function InputPasswordStrength({ className, showLabel, }: InputPasswordStrengthProps): import("react/jsx-runtime").JSX.Element;
|
|
165
|
+
declare namespace InputPasswordStrength {
|
|
166
|
+
var displayName: string;
|
|
167
|
+
}
|
|
168
|
+
export { InputPasswordRoot, InputPasswordField, InputPasswordToggle, InputPasswordStrength, calculatePasswordStrength, DEFAULT_STRENGTH_LEVELS, };
|
|
169
|
+
export type { DefaultPasswordStrength, StrengthLevelConfig };
|
|
42
170
|
//# sourceMappingURL=input-password.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-password.d.ts","sourceRoot":"","sources":["../../src/components/input-password.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"input-password.d.ts","sourceRoot":"","sources":["../../src/components/input-password.tsx"],"names":[],"mappings":"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"}
|