@brightlocal/ui-components 0.1.3 → 0.2.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/accordion.cjs +1 -1
- package/dist/accordion.js +1 -1
- package/dist/alert.cjs +1 -1
- package/dist/alert.js +1 -1
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +1 -1
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +37 -306
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +392 -489
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +4 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +33 -33
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +5 -18
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +21 -23
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +19 -19
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +75 -67
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +241 -194
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +3 -0
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +5 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +361 -366
- 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 +6 -0
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +79 -76
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +4 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +32 -31
- 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/link.cjs +1 -1
- package/dist/link.js +1 -1
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +6 -4
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +17 -20
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +3 -0
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +31 -30
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts +6 -54
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +73 -84
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +8 -10
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +78 -86
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +10 -23
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +47 -55
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +19 -28
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +24 -40
- 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/separator.cjs +1 -1
- package/dist/separator.d.ts +4 -4
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +19 -21
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +5 -10
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +24 -26
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +17 -20
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +42 -45
- package/dist/switch.cjs +1 -1
- package/dist/switch.d.ts +2 -12
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +37 -41
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +16 -12
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +56 -58
- package/dist/tabs.d.ts +27 -3
- package/dist/tabs.d.ts.map +1 -1
- 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-group.cjs +1 -1
- package/dist/toggle-group.d.ts +57 -7
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle-group.js +60 -67
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts +12 -26
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +18 -22
- package/package.json +2 -2
- package/src/blocks/data-table.tsx +1 -1
- package/src/blocks/sidebar.tsx +157 -532
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert.tsx +1 -1
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/calendar.tsx +6 -4
- package/src/components/centred-layout.tsx +11 -24
- package/src/components/checkbox.tsx +5 -6
- package/src/components/combobox.tsx +481 -301
- package/src/components/command.tsx +1 -1
- package/src/components/context-menu.tsx +1 -1
- package/src/components/date-picker.tsx +1 -1
- package/src/components/dialog.tsx +1 -1
- package/src/components/dropdown-menu.tsx +1 -1
- package/src/components/field.tsx +2 -0
- package/src/components/input-group.tsx +14 -2
- package/src/components/input-otp.tsx +17 -2
- package/src/components/input-password.tsx +7 -2
- package/src/components/input.tsx +11 -3
- package/src/components/link.tsx +1 -1
- package/src/components/logo.tsx +10 -8
- package/src/components/menubar.tsx +3 -1
- package/src/components/navigation-menu.tsx +37 -99
- package/src/components/pagination.tsx +13 -19
- package/src/components/radio-group.tsx +28 -38
- package/src/components/resizable.tsx +5 -43
- package/src/components/select.tsx +8 -3
- package/src/components/separator.tsx +5 -5
- package/src/components/sheet.tsx +6 -11
- package/src/components/sonner.tsx +24 -27
- package/src/components/switch.figma.tsx +7 -11
- package/src/components/switch.tsx +9 -19
- package/src/components/table.tsx +23 -18
- package/src/components/tabs.tsx +27 -3
- package/src/components/textarea.tsx +12 -5
- package/src/components/toggle-group.tsx +115 -86
- package/src/components/toggle.figma.tsx +13 -19
- package/src/components/toggle.tsx +32 -48
package/dist/input-group.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 o=require("react/jsx-runtime"),h=require("react"),G=require("@radix-ui/react-slot"),l=require("class-variance-authority"),a=require("@brightlocal/ui-components/lib/utils"),x=require("./input.cjs");function I(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const s=I(h),c=l.cva("relative flex w-full items-center overflow-hidden rounded-md border border-input bg-background transition-colors has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-default has-[:disabled]:opacity-50",{variants:{size:{default:"h-9",sm:"h-8",lg:"h-10"},error:{true:["border-red-600/40 dark:border-red-400/60","has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{size:"default",error:!1}}),p=s.forwardRef(({className:t,size:n,error:e,dataHook:r,trackingEl:i,trackingLabel:u,...d},m)=>o.jsx("div",{ref:m,className:a.cn(c({size:n,error:e}),t),"data-hook":r,"data-slot":"input-group","data-tracking-el":i,"data-tracking-label":u,...d}));p.displayName="InputGroup";const f=s.forwardRef(({className:t,...n},e)=>o.jsx(x.Input,{ref:e,className:a.cn("border-0 focus-visible:border-0 focus-visible:shadow-[none]","h-full",t),dataHook:"input-group-input",...n}));f.displayName="InputGroupInput";const w=l.cva("flex shrink-0 items-center text-muted-foreground",{variants:{align:{"inline-start":"","inline-end":"ml-auto","block-start":"self-start","block-end":"self-end"}},defaultVariants:{align:"inline-start"}}),b=s.forwardRef(({className:t,align:n,...e},r)=>o.jsx("div",{ref:r,className:a.cn(w({align:n}),t),"data-slot":"input-group-addon",...e}));b.displayName="InputGroupAddon";const g=l.cva(["inline-flex items-center justify-center gap-2","text-sm font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2","disabled:pointer-events-none disabled:opacity-50","text-muted-foreground hover:text-foreground","[&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0"],{variants:{variant:{default:"hover:bg-accent",ghost:""},size:{default:"h-9 px-3",sm:"h-8 px-2",lg:"h-10 px-4",icon:"h-9 w-9","icon-xs":"h-6 w-6","icon-sm":"h-8 w-8","icon-lg":"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),v=s.forwardRef(({className:t,variant:n,size:e,asChild:r=!1,...i},u)=>{const d=r?G.Slot:"button";return o.jsx(d,{ref:u,className:a.cn(g({variant:n,size:e,className:t})),"data-slot":"input-group-button",type:r?void 0:"button",...i})});v.displayName="InputGroupButton";exports.InputGroup=p;exports.InputGroupAddon=b;exports.InputGroupButton=v;exports.InputGroupInput=f;exports.inputGroupButtonVariants=g;exports.inputGroupVariants=c;
|
package/dist/input-group.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { InputProps } from './input';
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
declare const inputGroupVariants: (props?: ({
|
|
5
5
|
size?: "default" | "sm" | "lg" | null | undefined;
|
|
6
|
+
error?: boolean | null | undefined;
|
|
6
7
|
} & import('class-variance-authority/types').ClassProp) | undefined) => string;
|
|
7
8
|
interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof inputGroupVariants> {
|
|
8
9
|
/**
|
|
@@ -17,6 +18,10 @@ interface InputGroupProps extends React.HTMLAttributes<HTMLDivElement>, VariantP
|
|
|
17
18
|
* Tracking label for analytics context
|
|
18
19
|
*/
|
|
19
20
|
trackingLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Whether the input group has an error state
|
|
23
|
+
*/
|
|
24
|
+
error?: boolean;
|
|
20
25
|
}
|
|
21
26
|
declare const InputGroup: React.ForwardRefExoticComponent<InputGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
22
27
|
type InputGroupInputProps = Omit<InputProps, "hasIcon" | "hasSecondaryIcon" | "dataHook">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input-group.d.ts","sourceRoot":"","sources":["../../src/components/input-group.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjD,QAAA,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"input-group.d.ts","sourceRoot":"","sources":["../../src/components/input-group.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,OAAO,EAAS,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEjD,QAAA,MAAM,kBAAkB;;;8EAsBvB,CAAC;AAEF,UAAU,eACR,SACE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,YAAY,CAAC,OAAO,kBAAkB,CAAC;IACzC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,UAAU,wFAcf,CAAC;AAGF,KAAK,oBAAoB,GAAG,IAAI,CAC9B,UAAU,EACV,SAAS,GAAG,kBAAkB,GAAG,UAAU,CAC5C,CAAC;AAEF,QAAA,MAAM,eAAe,+FAiBnB,CAAC;AAGH,QAAA,MAAM,uBAAuB;;8EAe5B,CAAC;AAEF,UAAU,oBACR,SACE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EACpC,YAAY,CAAC,OAAO,uBAAuB,CAAC;CAAG;AAEnD,QAAA,MAAM,eAAe,6FAWpB,CAAC;AAGF,QAAA,MAAM,wBAAwB;;;8EA8B7B,CAAC;AAEF,UAAU,qBACR,SACE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAC7C,YAAY,CAAC,OAAO,wBAAwB,CAAC;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;CAC3E;AAED,QAAA,MAAM,gBAAgB,iGAcpB,CAAC;AAGH,OAAO,EACL,UAAU,EACV,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAClB,wBAAwB,GACzB,CAAC;AACF,YAAY,EACV,eAAe,EACf,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,GACtB,CAAC"}
|
package/dist/input-group.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import * as a from "react";
|
|
3
|
-
import { Slot as
|
|
3
|
+
import { Slot as f } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva as d } from "class-variance-authority";
|
|
5
|
-
import { cn as
|
|
6
|
-
import { Input as
|
|
7
|
-
const
|
|
5
|
+
import { cn as s } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
import { Input as c } from "./input.js";
|
|
7
|
+
const m = d(
|
|
8
8
|
"relative flex w-full items-center overflow-hidden rounded-md border border-input bg-background transition-colors has-[:focus-visible]:border-ring has-[:focus-visible]:shadow-default has-[:disabled]:opacity-50",
|
|
9
9
|
{
|
|
10
10
|
variants: {
|
|
@@ -12,43 +12,51 @@ const c = d(
|
|
|
12
12
|
default: "h-9",
|
|
13
13
|
sm: "h-8",
|
|
14
14
|
lg: "h-10"
|
|
15
|
+
},
|
|
16
|
+
error: {
|
|
17
|
+
true: [
|
|
18
|
+
"border-red-600/40 dark:border-red-400/60",
|
|
19
|
+
"has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive"
|
|
20
|
+
],
|
|
21
|
+
false: ""
|
|
15
22
|
}
|
|
16
23
|
},
|
|
17
24
|
defaultVariants: {
|
|
18
|
-
size: "default"
|
|
25
|
+
size: "default",
|
|
26
|
+
error: !1
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
|
-
),
|
|
22
|
-
({ className: t, size: o, dataHook:
|
|
29
|
+
), b = a.forwardRef(
|
|
30
|
+
({ className: t, size: e, error: o, dataHook: r, trackingEl: i, trackingLabel: u, ...l }, p) => /* @__PURE__ */ n(
|
|
23
31
|
"div",
|
|
24
32
|
{
|
|
25
|
-
ref:
|
|
26
|
-
className:
|
|
27
|
-
"data-hook":
|
|
33
|
+
ref: p,
|
|
34
|
+
className: s(m({ size: e, error: o }), t),
|
|
35
|
+
"data-hook": r,
|
|
28
36
|
"data-slot": "input-group",
|
|
29
|
-
"data-tracking-el":
|
|
30
|
-
"data-tracking-label":
|
|
31
|
-
...
|
|
37
|
+
"data-tracking-el": i,
|
|
38
|
+
"data-tracking-label": u,
|
|
39
|
+
...l
|
|
32
40
|
}
|
|
33
41
|
)
|
|
34
42
|
);
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
43
|
+
b.displayName = "InputGroup";
|
|
44
|
+
const v = a.forwardRef(({ className: t, ...e }, o) => /* @__PURE__ */ n(
|
|
45
|
+
c,
|
|
38
46
|
{
|
|
39
|
-
ref:
|
|
40
|
-
className:
|
|
47
|
+
ref: o,
|
|
48
|
+
className: s(
|
|
41
49
|
// Override border and focus styles since InputGroup handles them
|
|
42
50
|
"border-0 focus-visible:border-0 focus-visible:shadow-[none]",
|
|
43
51
|
"h-full",
|
|
44
52
|
t
|
|
45
53
|
),
|
|
46
54
|
dataHook: "input-group-input",
|
|
47
|
-
...
|
|
55
|
+
...e
|
|
48
56
|
}
|
|
49
57
|
));
|
|
50
|
-
|
|
51
|
-
const
|
|
58
|
+
v.displayName = "InputGroupInput";
|
|
59
|
+
const g = d(
|
|
52
60
|
"flex shrink-0 items-center text-muted-foreground",
|
|
53
61
|
{
|
|
54
62
|
variants: {
|
|
@@ -63,19 +71,19 @@ const v = d(
|
|
|
63
71
|
align: "inline-start"
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
|
-
),
|
|
67
|
-
({ className: t, align:
|
|
74
|
+
), h = a.forwardRef(
|
|
75
|
+
({ className: t, align: e, ...o }, r) => /* @__PURE__ */ n(
|
|
68
76
|
"div",
|
|
69
77
|
{
|
|
70
|
-
ref:
|
|
71
|
-
className:
|
|
78
|
+
ref: r,
|
|
79
|
+
className: s(g({ align: e }), t),
|
|
72
80
|
"data-slot": "input-group-addon",
|
|
73
|
-
...
|
|
81
|
+
...o
|
|
74
82
|
}
|
|
75
83
|
)
|
|
76
84
|
);
|
|
77
|
-
|
|
78
|
-
const
|
|
85
|
+
h.displayName = "InputGroupAddon";
|
|
86
|
+
const w = d(
|
|
79
87
|
[
|
|
80
88
|
"inline-flex items-center justify-center gap-2",
|
|
81
89
|
"text-sm font-medium transition-colors",
|
|
@@ -105,22 +113,22 @@ const h = d(
|
|
|
105
113
|
size: "default"
|
|
106
114
|
}
|
|
107
115
|
}
|
|
108
|
-
), x = a.forwardRef(({ className: t, variant:
|
|
109
|
-
|
|
116
|
+
), x = a.forwardRef(({ className: t, variant: e, size: o, asChild: r = !1, ...i }, u) => /* @__PURE__ */ n(
|
|
117
|
+
r ? f : "button",
|
|
110
118
|
{
|
|
111
119
|
ref: u,
|
|
112
|
-
className:
|
|
120
|
+
className: s(w({ variant: e, size: o, className: t })),
|
|
113
121
|
"data-slot": "input-group-button",
|
|
114
|
-
type:
|
|
115
|
-
...
|
|
122
|
+
type: r ? void 0 : "button",
|
|
123
|
+
...i
|
|
116
124
|
}
|
|
117
125
|
));
|
|
118
126
|
x.displayName = "InputGroupButton";
|
|
119
127
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
128
|
+
b as InputGroup,
|
|
129
|
+
h as InputGroupAddon,
|
|
122
130
|
x as InputGroupButton,
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
v as InputGroupInput,
|
|
132
|
+
w as inputGroupButtonVariants,
|
|
133
|
+
m as inputGroupVariants
|
|
126
134
|
};
|
package/dist/input-otp.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),_=require("react"),u=require("input-otp"),N=require("@brightlocal/icons"),h=require("@brightlocal/ui-components/lib/utils"),R=require("@brightlocal/ui-components/label");function w(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return n.default=e,Object.freeze(n)}const d=w(_),j=d.forwardRef(({trackingEl:e,trackingLabel:n,dataHook:r,containerClassName:a,error:s,...i},o)=>{const m=i.id||i["aria-label"]?i["aria-label"]:"One-time password",c=s||i["aria-invalid"]===!0||i["aria-invalid"]==="true";return t.jsx(u.OTPInput,{ref:o,"aria-invalid":c?"true":void 0,"aria-label":m,className:"disabled:cursor-not-allowed",containerClassName:h.cn("group flex items-center gap-2 has-disabled:opacity-50 w-fit",a),"data-hook":r,"data-slot":"input-otp","data-tracking-el":e,"data-tracking-label":n,...i})});j.displayName="InputOTP";function O({className:e,...n}){return t.jsx("div",{className:h.cn("flex items-center rounded-md shadow-xs",e),"data-slot":"input-otp-group",...n})}function p({index:e,className:n,...r}){const a=d.useContext(u.OTPInputContext),{char:s,hasFakeCaret:i,isActive:o}=a?.slots[e]??{};return t.jsxs("div",{className:h.cn("relative flex h-9 w-9 items-center justify-center","border-input bg-background border-y border-r","text-foreground text-sm font-normal transition-all outline-none","first:rounded-l-md first:border-l last:rounded-r-md","data-[active=true]:border-ring data-[active=true]:z-10","data-[active=true]:shadow-default","group-has-[input[aria-invalid=true]]:border-destructive","group-has-[input[aria-invalid=true]]:data-[active=true]:shadow-destructive","group-has-[input[aria-invalid=true]]:data-[active=true]:border-destructive","dark:bg-input/30",n),"data-active":o,"data-slot":"input-otp-slot",...r,children:[s,i&&t.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t.jsx("div",{className:"animate-caret-blink bg-foreground h-4 w-px duration-1000"})})]})}function I({...e}){return t.jsx("div",{"data-slot":"input-otp-separator",role:"separator",...e,children:t.jsx(N.MinusIcon,{})})}const f=d.forwardRef(({label:e,id:n,dataHook:r,trackingEl:a,trackingLabel:s,containerClassName:i,children:o,error:l,"aria-label":m,...c},g)=>{const b=d.useId(),x=n||b,y=m||(e?void 0:"One-time password");return t.jsxs("div",{className:"w-fit",children:[e&&t.jsx(R.Label,{className:"mb-2","data-hook":r?`${r}-label`:void 0,htmlFor:x,children:e}),t.jsx(j,{ref:g,"aria-label":y,containerClassName:i,dataHook:r,error:l,id:e?x:void 0,trackingEl:a,trackingLabel:s,...c,children:o})]})});f.displayName="InputOTPField";const P=d.forwardRef(({maxLength:e=6,pattern:n=u.REGEXP_ONLY_DIGITS,...r},a)=>t.jsx(f,{ref:a,inputMode:"numeric",maxLength:e,pasteTransformer:s=>s.replace(/\D+/g,"").slice(0,e),pattern:n,...r,children:t.jsx(O,{children:Array.from({length:e},(s,i)=>t.jsx(p,{index:i},i))})}));P.displayName="InputOTPDigitsOnly";const v=d.forwardRef(({maxLength:e=4,...n},r)=>t.jsx(f,{ref:r,containerClassName:"gap-2",maxLength:e,...n,children:Array.from({length:e},(a,s)=>t.jsx(p,{className:"rounded-md border-l shadow-xs",index:s},s))}));v.displayName="InputOTPWithSpacing";const T=d.forwardRef(({maxLength:e=6,...n},r)=>{const a=Math.ceil(e/2),s=e-a;return t.jsxs(f,{ref:r,maxLength:e,...n,children:[t.jsx(O,{children:Array.from({length:a},(i,o)=>t.jsx(p,{index:o},o))}),t.jsx(I,{}),t.jsx(O,{children:Array.from({length:s},(i,o)=>t.jsx(p,{index:o+a},o+a))})]})});T.displayName="InputOTPSimple";const S=d.forwardRef(({maxLength:e=6,...n},r)=>{const s=Math.ceil(e/2);return t.jsx(f,{ref:r,maxLength:e,...n,children:Array.from({length:s},(i,o)=>{const l=o*2,c=Math.min(l+2,e)-l;return t.jsxs(d.Fragment,{children:[o>0&&t.jsx(I,{}),t.jsx(O,{children:Array.from({length:c},(g,b)=>t.jsx(p,{index:l+b},l+b))})]},o)})})});S.displayName="InputOTPWithSeparator";Object.defineProperty(exports,"REGEXP_ONLY_CHARS",{enumerable:!0,get:()=>u.REGEXP_ONLY_CHARS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS",{enumerable:!0,get:()=>u.REGEXP_ONLY_DIGITS});Object.defineProperty(exports,"REGEXP_ONLY_DIGITS_AND_CHARS",{enumerable:!0,get:()=>u.REGEXP_ONLY_DIGITS_AND_CHARS});exports.InputOTPDigitsOnly=P;exports.InputOTPSimple=T;exports.InputOTPWithSeparator=S;exports.InputOTPWithSpacing=v;
|
package/dist/input-otp.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ type InputOTPProps = React.ComponentProps<typeof OTPInput> & {
|
|
|
5
5
|
trackingEl?: string;
|
|
6
6
|
dataHook: string;
|
|
7
7
|
trackingLabel?: string;
|
|
8
|
+
/** Whether the input has an error state */
|
|
9
|
+
error?: boolean;
|
|
8
10
|
};
|
|
9
11
|
type InputOTPGroupProps = React.ComponentProps<"div">;
|
|
10
12
|
type InputOTPSlotProps = React.ComponentProps<"div"> & {
|
|
@@ -25,6 +27,8 @@ interface InputOTPFieldProps {
|
|
|
25
27
|
disabled?: boolean;
|
|
26
28
|
className?: string;
|
|
27
29
|
"aria-label"?: string;
|
|
30
|
+
/** Whether the input has an error state */
|
|
31
|
+
error?: boolean;
|
|
28
32
|
}
|
|
29
33
|
interface VariantInputOTPProps extends Omit<InputOTPFieldProps, "children" | "maxLength"> {
|
|
30
34
|
maxLength?: number;
|
|
@@ -35,6 +39,8 @@ interface VariantInputOTPProps extends Omit<InputOTPFieldProps, "children" | "ma
|
|
|
35
39
|
autoFocus?: boolean;
|
|
36
40
|
pattern?: string;
|
|
37
41
|
"aria-label"?: string;
|
|
42
|
+
/** Whether the input has an error state */
|
|
43
|
+
error?: boolean;
|
|
38
44
|
}
|
|
39
45
|
declare const InputOTPDigitsOnly: React.ForwardRefExoticComponent<VariantInputOTPProps & React.RefAttributes<HTMLInputElement>>;
|
|
40
46
|
declare const InputOTPWithSpacing: React.ForwardRefExoticComponent<VariantInputOTPProps & React.RefAttributes<HTMLInputElement>>;
|
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;AAMnB,KAAK,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,GAAG;IAC3D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
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;AAMnB,KAAK,aAAa,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,QAAQ,CAAC,GAAG;IAC3D,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAyCF,KAAK,kBAAkB,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;AAYtD,KAAK,iBAAiB,GAAG,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG;IACrD,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAkDF,UAAU,kBAAkB;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,CAAC;IAC9E,gBAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAwDD,UAAU,oBAAqB,SAAQ,IAAI,CACzC,kBAAkB,EAClB,UAAU,GAAG,WAAW,CACzB;IACC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,kBAAkB,+FAsBtB,CAAC;AAIH,QAAA,MAAM,mBAAmB,+FAoBvB,CAAC;AAIH,QAAA,MAAM,cAAc,+FAwBnB,CAAC;AAIF,QAAA,MAAM,qBAAqB,+FA2BzB,CAAC;AAIH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,GAC7B,CAAC;AAEF,YAAY,EACV,oBAAoB,EACpB,aAAa,EACb,kBAAkB,EAClB,iBAAiB,GAClB,CAAC"}
|
package/dist/input-otp.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { REGEXP_ONLY_DIGITS as
|
|
4
|
-
import { REGEXP_ONLY_CHARS as
|
|
5
|
-
import { MinusIcon as
|
|
1
|
+
import { jsx as t, jsxs as v } from "react/jsx-runtime";
|
|
2
|
+
import * as s from "react";
|
|
3
|
+
import { REGEXP_ONLY_DIGITS as N, OTPInputContext as y, OTPInput as w } from "input-otp";
|
|
4
|
+
import { REGEXP_ONLY_CHARS as M, REGEXP_ONLY_DIGITS as j, REGEXP_ONLY_DIGITS_AND_CHARS as W } from "input-otp";
|
|
5
|
+
import { MinusIcon as S } from "@brightlocal/icons";
|
|
6
6
|
import { cn as g } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
-
import { Label as
|
|
8
|
-
const
|
|
9
|
-
({ trackingEl: e, trackingLabel: a, dataHook: n, containerClassName: i, ...r },
|
|
10
|
-
const
|
|
7
|
+
import { Label as _ } from "@brightlocal/ui-components/label";
|
|
8
|
+
const O = s.forwardRef(
|
|
9
|
+
({ trackingEl: e, trackingLabel: a, dataHook: n, containerClassName: d, error: i, ...r }, o) => {
|
|
10
|
+
const m = r.id || r["aria-label"] ? r["aria-label"] : "One-time password", c = i || r["aria-invalid"] === !0 || r["aria-invalid"] === "true";
|
|
11
11
|
return /* @__PURE__ */ t(
|
|
12
|
-
|
|
12
|
+
w,
|
|
13
13
|
{
|
|
14
|
-
ref:
|
|
15
|
-
"aria-
|
|
14
|
+
ref: o,
|
|
15
|
+
"aria-invalid": c ? "true" : void 0,
|
|
16
|
+
"aria-label": m,
|
|
16
17
|
className: "disabled:cursor-not-allowed",
|
|
17
18
|
containerClassName: g(
|
|
18
19
|
"group flex items-center gap-2 has-disabled:opacity-50 w-fit",
|
|
19
|
-
|
|
20
|
+
d
|
|
20
21
|
),
|
|
21
22
|
"data-hook": n,
|
|
22
23
|
"data-slot": "input-otp",
|
|
@@ -27,8 +28,8 @@ const v = d.forwardRef(
|
|
|
27
28
|
);
|
|
28
29
|
}
|
|
29
30
|
);
|
|
30
|
-
|
|
31
|
-
function
|
|
31
|
+
O.displayName = "InputOTP";
|
|
32
|
+
function h({ className: e, ...a }) {
|
|
32
33
|
return /* @__PURE__ */ t(
|
|
33
34
|
"div",
|
|
34
35
|
{
|
|
@@ -39,10 +40,10 @@ function m({ className: e, ...a }) {
|
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
function u({ index: e, className: a, ...n }) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
), { char:
|
|
45
|
-
return /* @__PURE__ */
|
|
43
|
+
const d = s.useContext(
|
|
44
|
+
y
|
|
45
|
+
), { char: i, hasFakeCaret: r, isActive: o } = d?.slots[e] ?? {};
|
|
46
|
+
return /* @__PURE__ */ v(
|
|
46
47
|
"div",
|
|
47
48
|
{
|
|
48
49
|
className: g(
|
|
@@ -66,49 +67,51 @@ function u({ index: e, className: a, ...n }) {
|
|
|
66
67
|
"data-slot": "input-otp-slot",
|
|
67
68
|
...n,
|
|
68
69
|
children: [
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
i,
|
|
71
|
+
r && /* @__PURE__ */ t("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ t("div", { className: "animate-caret-blink bg-foreground h-4 w-px duration-1000" }) })
|
|
71
72
|
]
|
|
72
73
|
}
|
|
73
74
|
);
|
|
74
75
|
}
|
|
75
|
-
function
|
|
76
|
-
return /* @__PURE__ */ t("div", { "data-slot": "input-otp-separator", role: "separator", ...e, children: /* @__PURE__ */ t(
|
|
76
|
+
function P({ ...e }) {
|
|
77
|
+
return /* @__PURE__ */ t("div", { "data-slot": "input-otp-separator", role: "separator", ...e, children: /* @__PURE__ */ t(S, {}) });
|
|
77
78
|
}
|
|
78
|
-
const p =
|
|
79
|
+
const p = s.forwardRef(
|
|
79
80
|
({
|
|
80
81
|
label: e,
|
|
81
82
|
id: a,
|
|
82
83
|
dataHook: n,
|
|
83
|
-
trackingEl:
|
|
84
|
-
trackingLabel:
|
|
85
|
-
containerClassName:
|
|
84
|
+
trackingEl: d,
|
|
85
|
+
trackingLabel: i,
|
|
86
|
+
containerClassName: r,
|
|
86
87
|
children: o,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
error: l,
|
|
89
|
+
"aria-label": m,
|
|
90
|
+
...c
|
|
91
|
+
}, b) => {
|
|
92
|
+
const f = s.useId(), I = a || f, T = m || (e ? void 0 : "One-time password");
|
|
93
|
+
return /* @__PURE__ */ v("div", { className: "w-fit", children: [
|
|
92
94
|
e && /* @__PURE__ */ t(
|
|
93
|
-
|
|
95
|
+
_,
|
|
94
96
|
{
|
|
95
97
|
className: "mb-2",
|
|
96
98
|
"data-hook": n ? `${n}-label` : void 0,
|
|
97
|
-
htmlFor:
|
|
99
|
+
htmlFor: I,
|
|
98
100
|
children: e
|
|
99
101
|
}
|
|
100
102
|
),
|
|
101
103
|
/* @__PURE__ */ t(
|
|
102
|
-
|
|
104
|
+
O,
|
|
103
105
|
{
|
|
104
|
-
ref:
|
|
105
|
-
"aria-label":
|
|
106
|
-
containerClassName:
|
|
106
|
+
ref: b,
|
|
107
|
+
"aria-label": T,
|
|
108
|
+
containerClassName: r,
|
|
107
109
|
dataHook: n,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
error: l,
|
|
111
|
+
id: e ? I : void 0,
|
|
112
|
+
trackingEl: d,
|
|
113
|
+
trackingLabel: i,
|
|
114
|
+
...c,
|
|
112
115
|
children: o
|
|
113
116
|
}
|
|
114
117
|
)
|
|
@@ -116,71 +119,71 @@ const p = d.forwardRef(
|
|
|
116
119
|
}
|
|
117
120
|
);
|
|
118
121
|
p.displayName = "InputOTPField";
|
|
119
|
-
const
|
|
122
|
+
const x = s.forwardRef(({ maxLength: e = 6, pattern: a = N, ...n }, d) => /* @__PURE__ */ t(
|
|
120
123
|
p,
|
|
121
124
|
{
|
|
122
|
-
ref:
|
|
125
|
+
ref: d,
|
|
123
126
|
inputMode: "numeric",
|
|
124
127
|
maxLength: e,
|
|
125
|
-
pasteTransformer: (
|
|
128
|
+
pasteTransformer: (i) => i.replace(/\D+/g, "").slice(0, e),
|
|
126
129
|
pattern: a,
|
|
127
130
|
...n,
|
|
128
|
-
children: /* @__PURE__ */ t(
|
|
131
|
+
children: /* @__PURE__ */ t(h, { children: Array.from({ length: e }, (i, r) => /* @__PURE__ */ t(u, { index: r }, r)) })
|
|
129
132
|
}
|
|
130
133
|
));
|
|
131
|
-
|
|
132
|
-
const
|
|
134
|
+
x.displayName = "InputOTPDigitsOnly";
|
|
135
|
+
const A = s.forwardRef(({ maxLength: e = 4, ...a }, n) => /* @__PURE__ */ t(
|
|
133
136
|
p,
|
|
134
137
|
{
|
|
135
138
|
ref: n,
|
|
136
139
|
containerClassName: "gap-2",
|
|
137
140
|
maxLength: e,
|
|
138
141
|
...a,
|
|
139
|
-
children: Array.from({ length: e }, (
|
|
142
|
+
children: Array.from({ length: e }, (d, i) => /* @__PURE__ */ t(
|
|
140
143
|
u,
|
|
141
144
|
{
|
|
142
145
|
className: "rounded-md border-l shadow-xs",
|
|
143
|
-
index:
|
|
146
|
+
index: i
|
|
144
147
|
},
|
|
145
|
-
|
|
148
|
+
i
|
|
146
149
|
))
|
|
147
150
|
}
|
|
148
151
|
));
|
|
149
|
-
|
|
150
|
-
const
|
|
152
|
+
A.displayName = "InputOTPWithSpacing";
|
|
153
|
+
const R = s.forwardRef(
|
|
151
154
|
({ maxLength: e = 6, ...a }, n) => {
|
|
152
|
-
const
|
|
153
|
-
return /* @__PURE__ */
|
|
154
|
-
/* @__PURE__ */ t(
|
|
155
|
-
/* @__PURE__ */ t(
|
|
156
|
-
/* @__PURE__ */ t(
|
|
155
|
+
const d = Math.ceil(e / 2), i = e - d;
|
|
156
|
+
return /* @__PURE__ */ v(p, { ref: n, maxLength: e, ...a, children: [
|
|
157
|
+
/* @__PURE__ */ t(h, { children: Array.from({ length: d }, (r, o) => /* @__PURE__ */ t(u, { index: o }, o)) }),
|
|
158
|
+
/* @__PURE__ */ t(P, {}),
|
|
159
|
+
/* @__PURE__ */ t(h, { children: Array.from({ length: i }, (r, o) => /* @__PURE__ */ t(
|
|
157
160
|
u,
|
|
158
161
|
{
|
|
159
|
-
index: o +
|
|
162
|
+
index: o + d
|
|
160
163
|
},
|
|
161
|
-
o +
|
|
164
|
+
o + d
|
|
162
165
|
)) })
|
|
163
166
|
] });
|
|
164
167
|
}
|
|
165
168
|
);
|
|
166
|
-
|
|
167
|
-
const
|
|
168
|
-
const
|
|
169
|
-
return /* @__PURE__ */ t(p, { ref: n, maxLength: e, ...a, children: Array.from({ length:
|
|
170
|
-
const l = o * 2,
|
|
171
|
-
return /* @__PURE__ */
|
|
172
|
-
o > 0 && /* @__PURE__ */ t(
|
|
173
|
-
/* @__PURE__ */ t(
|
|
169
|
+
R.displayName = "InputOTPSimple";
|
|
170
|
+
const G = s.forwardRef(({ maxLength: e = 6, ...a }, n) => {
|
|
171
|
+
const i = Math.ceil(e / 2);
|
|
172
|
+
return /* @__PURE__ */ t(p, { ref: n, maxLength: e, ...a, children: Array.from({ length: i }, (r, o) => {
|
|
173
|
+
const l = o * 2, c = Math.min(l + 2, e) - l;
|
|
174
|
+
return /* @__PURE__ */ v(s.Fragment, { children: [
|
|
175
|
+
o > 0 && /* @__PURE__ */ t(P, {}),
|
|
176
|
+
/* @__PURE__ */ t(h, { children: Array.from({ length: c }, (b, f) => /* @__PURE__ */ t(u, { index: l + f }, l + f)) })
|
|
174
177
|
] }, o);
|
|
175
178
|
}) });
|
|
176
179
|
});
|
|
177
|
-
|
|
180
|
+
G.displayName = "InputOTPWithSeparator";
|
|
178
181
|
export {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
182
|
+
x as InputOTPDigitsOnly,
|
|
183
|
+
R as InputOTPSimple,
|
|
184
|
+
G as InputOTPWithSeparator,
|
|
185
|
+
A as InputOTPWithSpacing,
|
|
186
|
+
M as REGEXP_ONLY_CHARS,
|
|
187
|
+
j as REGEXP_ONLY_DIGITS,
|
|
188
|
+
W as REGEXP_ONLY_DIGITS_AND_CHARS
|
|
186
189
|
};
|
package/dist/input-password.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),A=require("react"),h=require("@brightlocal/icons"),E=require("@brightlocal/ui-components/progress"),_=require("@brightlocal/ui-components/lib/utils"),l=require("@brightlocal/ui-components/input-group");function z(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const a=z(A),p={meter:{label:"Meter",value:0,color:"bg-muted"},weak:{label:"Weak",value:25,color:"bg-red-500"},ok:{label:"Ok",value:50,color:"bg-orange-500"},good:{label:"Good",value:75,color:"bg-green-500"},great:{label:"Great",value:100,color:"bg-green-600"}};function m(e){if(!e||e.length===0)return"meter";let t=0;return e.length>=8&&(t+=1),e.length>=12&&(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<=2?"weak":t<=3?"ok":t<=4?"good":"great"}const b=a.forwardRef(({className:e,showStrength:t=!0,onStrengthChange:n,dataHook:s,trackingEl:w,trackingLabel:S,onChange:x,value:i,id:j,error:v,...u},P)=>{const[c,I]=a.useState(!1),[y,N]=a.useState("meter"),[O,G]=a.useState(""),R=a.useId(),T=j||R,g=i!==void 0?String(i):O;a.useEffect(()=>{const o=setTimeout(()=>{const f=m(g);N(f),n?.(f)},180);return()=>clearTimeout(o)},[g,n]);const k=o=>{G(o.target.value),x?.(o)},q=()=>{I(o=>!o)},d=p[y];return r.jsxs("div",{className:"w-full",children:[r.jsxs(l.InputGroup,{className:e,dataHook:s,error:v,children:[r.jsx(l.InputGroupInput,{ref:P,id:T,trackingEl:w,trackingLabel:S,type:c?"text":"password",value:i,onChange:k,...u}),r.jsx(l.InputGroupAddon,{align:"inline-end",children:r.jsx(l.InputGroupButton,{"aria-label":c?"Hide password":"Show password","data-hook":s?`${s}-toggle`:void 0,disabled:u.disabled,size:"icon",variant:"ghost",onClick:q,children:c?r.jsx(h.EyeOff,{className:"h-4 w-4"}):r.jsx(h.Eye,{className:"h-4 w-4"})})})]}),t&&r.jsx("div",{className:"mt-1 space-y-2",children:r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(E.Progress,{className:_.cn("h-2 flex-1"),dataHook:s?`${s}-strength-progress`:"password-strength-progress",value:d.value}),r.jsx("span",{className:"text-foreground w-10 shrink-0 text-right text-sm font-medium whitespace-nowrap","data-hook":s?`${s}-strength-label`:void 0,children:d.label})]})})]})});b.displayName="InputPassword";exports.InputPassword=b;exports.PASSWORD_STRENGTH=p;exports.calculatePasswordStrength=m;
|
package/dist/input-password.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ interface InputPasswordProps extends Omit<React.ComponentProps<"input">, "type">
|
|
|
27
27
|
* Optional tracking label
|
|
28
28
|
*/
|
|
29
29
|
trackingLabel?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the input has an error state
|
|
32
|
+
*/
|
|
33
|
+
error?: boolean;
|
|
30
34
|
}
|
|
31
35
|
/**
|
|
32
36
|
* Calculate password strength based on various criteria
|
|
@@ -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;AAY/B,KAAK,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAMvE,CAAC;AAEF,UAAU,kBAAmB,SAAQ,IAAI,CACvC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAC7B,MAAM,CACP;IACC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACxD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"input-password.d.ts","sourceRoot":"","sources":["../../src/components/input-password.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B,KAAK,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,OAAO,CAAC;AAEnE,UAAU,sBAAsB;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,gBAAgB,EAAE,sBAAsB,CAMvE,CAAC;AAEF,UAAU,kBAAmB,SAAQ,IAAI,CACvC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,EAC7B,MAAM,CACP;IACC;;OAEG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;OAEG;IACH,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,IAAI,CAAC;IACxD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;GAEG;AACH,iBAAS,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAsBrE;AAED,QAAA,MAAM,aAAa,0GAsGlB,CAAC;AAIF,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,CAAC;AACvE,YAAY,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}
|