@brightlocal/ui-components 0.1.4 → 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/README.md +2 -1
- 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.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +19 -19
- 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 +75 -59
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +244 -191
- 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 +428 -388
- 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.cjs +1 -1
- package/dist/input-group.d.ts +5 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +47 -39
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +45 -32
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +138 -114
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +151 -19
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +197 -91
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +26 -24
- package/dist/logo.cjs +1 -1
- package/dist/logo.js +13 -13
- 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/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +4 -0
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +49 -47
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +3 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +57 -56
- 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.cjs +1 -1
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +19 -18
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +17 -17
- 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 -3
- package/src/components/chip.tsx +249 -0
- package/src/components/combobox.tsx +490 -298
- 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 +17 -2
- package/src/components/input-otp.tsx +161 -78
- package/src/components/input-password.tsx +473 -128
- package/src/components/input.tsx +11 -3
- package/src/components/logo.tsx +1 -1
- package/src/components/progress.tsx +21 -2
- package/src/components/radio-group.tsx +11 -0
- package/src/components/select.tsx +5 -2
- package/src/components/slider.tsx +85 -15
- package/src/components/textarea.tsx +15 -5
- package/src/components/toggle.tsx +13 -15
- package/src/index.ts +3 -0
package/dist/input-otp.d.ts
CHANGED
|
@@ -1,45 +1,58 @@
|
|
|
1
1
|
import { OTPInput, REGEXP_ONLY_DIGITS, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS_AND_CHARS } from 'input-otp';
|
|
2
|
+
import { Label } from '../label';
|
|
2
3
|
import * as React from "react";
|
|
3
|
-
|
|
4
|
+
interface InputOTPProps extends Omit<React.ComponentProps<typeof OTPInput>, "render"> {
|
|
5
|
+
/** Custom class for the container element */
|
|
4
6
|
containerClassName?: string;
|
|
5
|
-
|
|
7
|
+
/** Data hook for automated testing (REQUIRED) */
|
|
6
8
|
dataHook: string;
|
|
9
|
+
/** Tracking element identifier for analytics */
|
|
10
|
+
trackingEl?: string;
|
|
11
|
+
/** Tracking label for analytics context */
|
|
7
12
|
trackingLabel?: string;
|
|
8
|
-
|
|
13
|
+
/** Whether the input has an error state */
|
|
14
|
+
error?: boolean;
|
|
15
|
+
/** Children components */
|
|
16
|
+
children: React.ReactNode;
|
|
17
|
+
}
|
|
18
|
+
declare const InputOTP: React.ForwardRefExoticComponent<Omit<InputOTPProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
9
19
|
type InputOTPGroupProps = React.ComponentProps<"div">;
|
|
10
|
-
|
|
20
|
+
declare function InputOTPGroup({ className, ...props }: InputOTPGroupProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
interface InputOTPSlotProps extends React.ComponentProps<"div"> {
|
|
22
|
+
/** The index of the slot in the OTP input */
|
|
11
23
|
index: number;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
24
|
+
}
|
|
25
|
+
declare function InputOTPSlot({ index, className, ...props }: InputOTPSlotProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
type InputOTPSeparatorProps = React.ComponentProps<"div">;
|
|
27
|
+
declare function InputOTPSeparator({ ...props }: InputOTPSeparatorProps): import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
interface InputOTPLabelProps extends React.ComponentProps<typeof Label> {
|
|
29
|
+
/** Data hook for automated testing */
|
|
30
|
+
dataHook?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function InputOTPLabel({ dataHook, className, ...props }: InputOTPLabelProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
interface InputOTPFieldProps extends Omit<InputOTPProps, "children"> {
|
|
34
|
+
/** Label text */
|
|
15
35
|
label?: string;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
children?: React.ReactNode;
|
|
20
|
-
maxLength: number;
|
|
21
|
-
containerClassName?: string;
|
|
22
|
-
inputMode?: "numeric" | "text" | "none" | "tel" | "url" | "email" | "decimal";
|
|
23
|
-
pasteTransformer?: (p: string) => string;
|
|
24
|
-
pattern?: string;
|
|
25
|
-
disabled?: boolean;
|
|
26
|
-
className?: string;
|
|
36
|
+
/** Custom ID for the input */
|
|
37
|
+
id?: string;
|
|
38
|
+
/** Accessible label when no visible label is provided */
|
|
27
39
|
"aria-label"?: string;
|
|
40
|
+
/** Children components */
|
|
41
|
+
children: React.ReactNode;
|
|
28
42
|
}
|
|
29
|
-
|
|
43
|
+
declare const InputOTPField: React.ForwardRefExoticComponent<Omit<InputOTPFieldProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
44
|
+
interface InputOTPVariantProps extends Omit<InputOTPFieldProps, "children" | "maxLength"> {
|
|
45
|
+
/** Number of OTP digits */
|
|
30
46
|
maxLength?: number;
|
|
31
|
-
dataHook: string;
|
|
32
|
-
trackingEl?: string;
|
|
33
|
-
trackingLabel?: string;
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
autoFocus?: boolean;
|
|
36
|
-
pattern?: string;
|
|
37
|
-
"aria-label"?: string;
|
|
38
47
|
}
|
|
39
|
-
|
|
40
|
-
declare const
|
|
41
|
-
|
|
42
|
-
declare const
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
/** Digits only OTP input with single group */
|
|
49
|
+
declare const InputOTPDigitsOnly: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
50
|
+
/** OTP input with spacing between slots */
|
|
51
|
+
declare const InputOTPWithSpacing: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
52
|
+
/** OTP input with two groups and a separator */
|
|
53
|
+
declare const InputOTPSimple: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
54
|
+
/** OTP input with separators between each pair of digits */
|
|
55
|
+
declare const InputOTPWithSeparator: React.ForwardRefExoticComponent<Omit<InputOTPVariantProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
|
|
56
|
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator, InputOTPLabel, InputOTPField, InputOTPDigitsOnly, InputOTPWithSpacing, InputOTPSimple, InputOTPWithSeparator, REGEXP_ONLY_DIGITS, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS_AND_CHARS, };
|
|
57
|
+
export type { InputOTPProps, InputOTPGroupProps, InputOTPSlotProps, InputOTPSeparatorProps, InputOTPLabelProps, InputOTPFieldProps, InputOTPVariantProps, };
|
|
45
58
|
//# sourceMappingURL=input-otp.d.ts.map
|
package/dist/input-otp.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-otp.d.ts","sourceRoot":"","sources":["../../src/components/input-otp.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EACL,QAAQ,EAGR,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,EAC7B,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"input-otp.d.ts","sourceRoot":"","sources":["../../src/components/input-otp.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,M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
import { REGEXP_ONLY_CHARS as
|
|
5
|
-
import { MinusIcon as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { Label as
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import * as s from "react";
|
|
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-
|
|
33
|
+
ref: l,
|
|
34
|
+
"aria-invalid": a ? "true" : void 0,
|
|
16
35
|
className: "disabled:cursor-not-allowed",
|
|
17
|
-
containerClassName:
|
|
36
|
+
containerClassName: I(
|
|
18
37
|
"group flex items-center gap-2 has-disabled:opacity-50 w-fit",
|
|
19
|
-
|
|
38
|
+
o
|
|
20
39
|
),
|
|
21
|
-
"data-hook":
|
|
40
|
+
"data-hook": t,
|
|
22
41
|
"data-slot": "input-otp",
|
|
23
|
-
"data-tracking-el":
|
|
24
|
-
"data-tracking-label":
|
|
25
|
-
|
|
42
|
+
"data-tracking-el": r,
|
|
43
|
+
"data-tracking-label": n,
|
|
44
|
+
disabled: u,
|
|
45
|
+
...d,
|
|
46
|
+
children: i
|
|
26
47
|
}
|
|
27
|
-
);
|
|
48
|
+
) });
|
|
28
49
|
}
|
|
29
50
|
);
|
|
30
|
-
|
|
31
|
-
function
|
|
32
|
-
return /* @__PURE__ */
|
|
51
|
+
T.displayName = "InputOTP";
|
|
52
|
+
function f({ className: t, ...r }) {
|
|
53
|
+
return /* @__PURE__ */ e(
|
|
33
54
|
"div",
|
|
34
55
|
{
|
|
35
|
-
className:
|
|
56
|
+
className: I("flex items-center rounded-md shadow-xs", t),
|
|
36
57
|
"data-slot": "input-otp-group",
|
|
37
|
-
...
|
|
58
|
+
...r
|
|
38
59
|
}
|
|
39
60
|
);
|
|
40
61
|
}
|
|
41
|
-
function
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
), { char:
|
|
45
|
-
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(
|
|
46
67
|
"div",
|
|
47
68
|
{
|
|
48
|
-
className:
|
|
69
|
+
className: I(
|
|
49
70
|
// Base styles
|
|
50
71
|
"relative flex h-9 w-9 items-center justify-center",
|
|
51
72
|
"border-input bg-background border-y border-r",
|
|
@@ -55,132 +76,135 @@ function u({ index: e, className: a, ...n }) {
|
|
|
55
76
|
"data-[active=true]:border-ring data-[active=true]:z-10",
|
|
56
77
|
"data-[active=true]:shadow-default",
|
|
57
78
|
// Error state
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"group-has-[input[aria-invalid=true]]:data-[active=true]:border-destructive",
|
|
79
|
+
o && "border-destructive",
|
|
80
|
+
o && d && "shadow-destructive",
|
|
61
81
|
// Dark mode
|
|
62
82
|
"dark:bg-input/30",
|
|
63
|
-
|
|
83
|
+
r
|
|
64
84
|
),
|
|
65
|
-
"data-active":
|
|
85
|
+
"data-active": d,
|
|
86
|
+
"data-error": o,
|
|
66
87
|
"data-slot": "input-otp-slot",
|
|
67
88
|
...n,
|
|
68
89
|
children: [
|
|
69
|
-
|
|
70
|
-
|
|
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" }) })
|
|
71
92
|
]
|
|
72
93
|
}
|
|
73
94
|
);
|
|
74
95
|
}
|
|
75
|
-
function
|
|
76
|
-
return /* @__PURE__ */
|
|
96
|
+
function g({ ...t }) {
|
|
97
|
+
return /* @__PURE__ */ e("div", { "data-slot": "input-otp-separator", role: "separator", ...t, children: /* @__PURE__ */ e(b, {}) });
|
|
77
98
|
}
|
|
78
|
-
|
|
79
|
-
(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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(
|
|
93
115
|
S,
|
|
94
116
|
{
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
children: e
|
|
117
|
+
dataHook: n ? `${n}-label` : void 0,
|
|
118
|
+
htmlFor: l,
|
|
119
|
+
children: t
|
|
99
120
|
}
|
|
100
121
|
),
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
|
|
122
|
+
/* @__PURE__ */ e(
|
|
123
|
+
T,
|
|
103
124
|
{
|
|
104
|
-
ref:
|
|
105
|
-
"aria-label":
|
|
106
|
-
containerClassName: s,
|
|
125
|
+
ref: i,
|
|
126
|
+
"aria-label": c,
|
|
107
127
|
dataHook: n,
|
|
108
|
-
id:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
...b,
|
|
112
|
-
children: o
|
|
128
|
+
id: t ? l : void 0,
|
|
129
|
+
...u,
|
|
130
|
+
children: a
|
|
113
131
|
}
|
|
114
132
|
)
|
|
115
133
|
] });
|
|
116
134
|
}
|
|
117
135
|
);
|
|
118
|
-
|
|
119
|
-
const _ =
|
|
120
|
-
|
|
136
|
+
m.displayName = "InputOTPField";
|
|
137
|
+
const _ = s.forwardRef(({ maxLength: t = 6, ...r }, n) => /* @__PURE__ */ e(
|
|
138
|
+
m,
|
|
121
139
|
{
|
|
122
|
-
ref:
|
|
140
|
+
ref: n,
|
|
123
141
|
inputMode: "numeric",
|
|
124
|
-
maxLength:
|
|
125
|
-
pasteTransformer: (
|
|
126
|
-
pattern:
|
|
127
|
-
...
|
|
128
|
-
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)) })
|
|
129
147
|
}
|
|
130
148
|
));
|
|
131
149
|
_.displayName = "InputOTPDigitsOnly";
|
|
132
|
-
const
|
|
133
|
-
|
|
150
|
+
const R = s.forwardRef(({ maxLength: t = 4, ...r }, n) => /* @__PURE__ */ e(
|
|
151
|
+
m,
|
|
134
152
|
{
|
|
135
153
|
ref: n,
|
|
136
154
|
containerClassName: "gap-2",
|
|
137
|
-
maxLength:
|
|
138
|
-
...
|
|
139
|
-
children: Array.from({ length:
|
|
140
|
-
|
|
155
|
+
maxLength: t,
|
|
156
|
+
...r,
|
|
157
|
+
children: Array.from({ length: t }, (o, a) => /* @__PURE__ */ e(
|
|
158
|
+
p,
|
|
141
159
|
{
|
|
142
160
|
className: "rounded-md border-l shadow-xs",
|
|
143
|
-
index:
|
|
161
|
+
index: a
|
|
144
162
|
},
|
|
145
|
-
|
|
163
|
+
a
|
|
146
164
|
))
|
|
147
165
|
}
|
|
148
166
|
));
|
|
149
|
-
|
|
150
|
-
const
|
|
151
|
-
({ maxLength:
|
|
152
|
-
const
|
|
153
|
-
return /* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */
|
|
155
|
-
/* @__PURE__ */
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
-
|
|
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,
|
|
158
176
|
{
|
|
159
|
-
index:
|
|
177
|
+
index: i + o
|
|
160
178
|
},
|
|
161
|
-
|
|
179
|
+
i + o
|
|
162
180
|
)) })
|
|
163
181
|
] });
|
|
164
182
|
}
|
|
165
183
|
);
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
return /* @__PURE__ */
|
|
170
|
-
const
|
|
171
|
-
return /* @__PURE__ */
|
|
172
|
-
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
-
] },
|
|
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);
|
|
175
193
|
}) });
|
|
176
194
|
});
|
|
177
|
-
|
|
195
|
+
A.displayName = "InputOTPWithSeparator";
|
|
178
196
|
export {
|
|
197
|
+
T as InputOTP,
|
|
179
198
|
_ as InputOTPDigitsOnly,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
|
186
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;
|