@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.
Files changed (105) hide show
  1. package/README.md +2 -1
  2. package/dist/alert.cjs +1 -1
  3. package/dist/alert.d.ts +10 -1
  4. package/dist/alert.d.ts.map +1 -1
  5. package/dist/alert.js +6 -2
  6. package/dist/card.cjs +1 -1
  7. package/dist/card.d.ts +6 -2
  8. package/dist/card.d.ts.map +1 -1
  9. package/dist/card.js +89 -73
  10. package/dist/centred-layout.cjs +1 -1
  11. package/dist/centred-layout.d.ts +49 -25
  12. package/dist/centred-layout.d.ts.map +1 -1
  13. package/dist/centred-layout.js +57 -32
  14. package/dist/checkbox.cjs +1 -1
  15. package/dist/checkbox.d.ts.map +1 -1
  16. package/dist/checkbox.js +19 -19
  17. package/dist/chip.cjs +1 -0
  18. package/dist/chip.d.ts +61 -0
  19. package/dist/chip.d.ts.map +1 -0
  20. package/dist/chip.js +165 -0
  21. package/dist/combobox.cjs +1 -1
  22. package/dist/combobox.d.ts +75 -59
  23. package/dist/combobox.d.ts.map +1 -1
  24. package/dist/combobox.js +244 -191
  25. package/dist/date-picker.cjs +1 -1
  26. package/dist/date-picker.d.ts +89 -52
  27. package/dist/date-picker.d.ts.map +1 -1
  28. package/dist/date-picker.js +228 -210
  29. package/dist/dropdown-menu.d.ts.map +1 -1
  30. package/dist/header.cjs +1 -0
  31. package/dist/header.d.ts +42 -0
  32. package/dist/header.d.ts.map +1 -0
  33. package/dist/header.js +22 -0
  34. package/dist/index.cjs +1 -1
  35. package/dist/index.d.ts +3 -0
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +428 -388
  38. package/dist/input-chip.cjs +1 -0
  39. package/dist/input-chip.d.ts +117 -0
  40. package/dist/input-chip.d.ts.map +1 -0
  41. package/dist/input-chip.js +284 -0
  42. package/dist/input-group.cjs +1 -1
  43. package/dist/input-group.d.ts +5 -0
  44. package/dist/input-group.d.ts.map +1 -1
  45. package/dist/input-group.js +47 -39
  46. package/dist/input-otp.cjs +1 -1
  47. package/dist/input-otp.d.ts +45 -32
  48. package/dist/input-otp.d.ts.map +1 -1
  49. package/dist/input-otp.js +138 -114
  50. package/dist/input-password.cjs +1 -1
  51. package/dist/input-password.d.ts +151 -19
  52. package/dist/input-password.d.ts.map +1 -1
  53. package/dist/input-password.js +197 -91
  54. package/dist/input.cjs +1 -1
  55. package/dist/input.d.ts +4 -0
  56. package/dist/input.d.ts.map +1 -1
  57. package/dist/input.js +26 -24
  58. package/dist/logo.cjs +1 -1
  59. package/dist/logo.js +13 -13
  60. package/dist/progress.cjs +1 -1
  61. package/dist/progress.d.ts +10 -0
  62. package/dist/progress.d.ts.map +1 -1
  63. package/dist/progress.js +45 -36
  64. package/dist/radio-group.cjs +1 -1
  65. package/dist/radio-group.d.ts +4 -0
  66. package/dist/radio-group.d.ts.map +1 -1
  67. package/dist/radio-group.js +49 -47
  68. package/dist/select.cjs +1 -1
  69. package/dist/select.d.ts +3 -1
  70. package/dist/select.d.ts.map +1 -1
  71. package/dist/select.js +57 -56
  72. package/dist/slider.cjs +1 -1
  73. package/dist/slider.d.ts +31 -3
  74. package/dist/slider.d.ts.map +1 -1
  75. package/dist/slider.js +53 -43
  76. package/dist/textarea.cjs +1 -1
  77. package/dist/textarea.d.ts +4 -0
  78. package/dist/textarea.d.ts.map +1 -1
  79. package/dist/textarea.js +19 -18
  80. package/dist/toggle.cjs +1 -1
  81. package/dist/toggle.d.ts.map +1 -1
  82. package/dist/toggle.js +17 -17
  83. package/package.json +1 -1
  84. package/src/components/alert.tsx +10 -1
  85. package/src/components/card.tsx +66 -38
  86. package/src/components/centred-layout.tsx +115 -38
  87. package/src/components/checkbox.tsx +2 -3
  88. package/src/components/chip.tsx +249 -0
  89. package/src/components/combobox.tsx +490 -298
  90. package/src/components/date-picker.tsx +410 -266
  91. package/src/components/dropdown-menu.tsx +6 -1
  92. package/src/components/header.tsx +69 -0
  93. package/src/components/input-chip.tsx +548 -0
  94. package/src/components/input-group.tsx +17 -2
  95. package/src/components/input-otp.tsx +161 -78
  96. package/src/components/input-password.tsx +473 -128
  97. package/src/components/input.tsx +11 -3
  98. package/src/components/logo.tsx +1 -1
  99. package/src/components/progress.tsx +21 -2
  100. package/src/components/radio-group.tsx +11 -0
  101. package/src/components/select.tsx +5 -2
  102. package/src/components/slider.tsx +85 -15
  103. package/src/components/textarea.tsx +15 -5
  104. package/src/components/toggle.tsx +13 -15
  105. package/src/index.ts +3 -0
@@ -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
- type InputOTPProps = React.ComponentProps<typeof OTPInput> & {
4
+ interface InputOTPProps extends Omit<React.ComponentProps<typeof OTPInput>, "render"> {
5
+ /** Custom class for the container element */
4
6
  containerClassName?: string;
5
- trackingEl?: string;
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
- type InputOTPSlotProps = React.ComponentProps<"div"> & {
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
- interface InputOTPFieldProps {
14
- id?: string;
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
- dataHook: string;
17
- trackingEl?: string;
18
- trackingLabel?: string;
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
- interface VariantInputOTPProps extends Omit<InputOTPFieldProps, "children" | "maxLength"> {
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
- declare const InputOTPDigitsOnly: React.ForwardRefExoticComponent<VariantInputOTPProps & React.RefAttributes<HTMLInputElement>>;
40
- declare const InputOTPWithSpacing: React.ForwardRefExoticComponent<VariantInputOTPProps & React.RefAttributes<HTMLInputElement>>;
41
- declare const InputOTPSimple: React.ForwardRefExoticComponent<VariantInputOTPProps & React.RefAttributes<HTMLInputElement>>;
42
- declare const InputOTPWithSeparator: React.ForwardRefExoticComponent<VariantInputOTPProps & React.RefAttributes<HTMLInputElement>>;
43
- export { InputOTPDigitsOnly, InputOTPWithSpacing, InputOTPSimple, InputOTPWithSeparator, REGEXP_ONLY_DIGITS, REGEXP_ONLY_CHARS, REGEXP_ONLY_DIGITS_AND_CHARS, };
44
- export type { VariantInputOTPProps, InputOTPProps, InputOTPGroupProps, InputOTPSlotProps, };
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
@@ -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,Q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B,UAAU,GAAG,WAAW,CACzB;IACC,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,8CAA8C;AAC9C,QAAA,MAAM,kBAAkB,4GAsBtB,CAAC;AAIH,2CAA2C;AAC3C,QAAA,MAAM,mBAAmB,4GAoBvB,CAAC;AAIH,gDAAgD;AAChD,QAAA,MAAM,cAAc,4GAwBnB,CAAC;AAIF,4DAA4D;AAC5D,QAAA,MAAM,qBAAqB,4GA2BzB,CAAC;AAQH,OAAO,EAEL,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,aAAa,EACb,aAAa,EAEb,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EAErB,kBAAkB,EAClB,iBAAiB,EACjB,4BAA4B,GAC7B,CAAC;AAEF,YAAY,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,sBAAsB,EACtB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,GACrB,CAAC"}
package/dist/input-otp.js CHANGED
@@ -1,51 +1,72 @@
1
- import { jsx as t, jsxs as f } from "react/jsx-runtime";
2
- import * as d from "react";
3
- import { REGEXP_ONLY_DIGITS as T, OTPInputContext as N, OTPInput as y } from "input-otp";
4
- import { REGEXP_ONLY_CHARS as L, REGEXP_ONLY_DIGITS as M, REGEXP_ONLY_DIGITS_AND_CHARS as j } from "input-otp";
5
- import { MinusIcon as w } from "@brightlocal/icons";
6
- import { cn as g } from "@brightlocal/ui-components/lib/utils";
7
- import { Label as S } from "@brightlocal/ui-components/label";
8
- const v = d.forwardRef(
9
- ({ trackingEl: e, trackingLabel: a, dataHook: n, containerClassName: i, ...r }, s) => {
10
- const l = r.id || r["aria-label"] ? r["aria-label"] : "One-time password";
11
- return /* @__PURE__ */ t(
12
- y,
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: s,
15
- "aria-label": l,
33
+ ref: l,
34
+ "aria-invalid": a ? "true" : void 0,
16
35
  className: "disabled:cursor-not-allowed",
17
- containerClassName: g(
36
+ containerClassName: I(
18
37
  "group flex items-center gap-2 has-disabled:opacity-50 w-fit",
19
- i
38
+ o
20
39
  ),
21
- "data-hook": n,
40
+ "data-hook": t,
22
41
  "data-slot": "input-otp",
23
- "data-tracking-el": e,
24
- "data-tracking-label": a,
25
- ...r
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
- v.displayName = "InputOTP";
31
- function m({ className: e, ...a }) {
32
- return /* @__PURE__ */ t(
51
+ T.displayName = "InputOTP";
52
+ function f({ className: t, ...r }) {
53
+ return /* @__PURE__ */ e(
33
54
  "div",
34
55
  {
35
- className: g("flex items-center rounded-md shadow-xs", e),
56
+ className: I("flex items-center rounded-md shadow-xs", t),
36
57
  "data-slot": "input-otp-group",
37
- ...a
58
+ ...r
38
59
  }
39
60
  );
40
61
  }
41
- function u({ index: e, className: a, ...n }) {
42
- const i = d.useContext(
43
- N
44
- ), { char: r, hasFakeCaret: s, isActive: o } = i?.slots[e] ?? {};
45
- return /* @__PURE__ */ f(
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: g(
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
- "group-has-[input[aria-invalid=true]]:border-destructive",
59
- "group-has-[input[aria-invalid=true]]:data-[active=true]:shadow-destructive",
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
- a
83
+ r
64
84
  ),
65
- "data-active": o,
85
+ "data-active": d,
86
+ "data-error": o,
66
87
  "data-slot": "input-otp-slot",
67
88
  ...n,
68
89
  children: [
69
- r,
70
- s && /* @__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" }) })
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 O({ ...e }) {
76
- return /* @__PURE__ */ t("div", { "data-slot": "input-otp-separator", role: "separator", ...e, children: /* @__PURE__ */ t(w, {}) });
96
+ function g({ ...t }) {
97
+ return /* @__PURE__ */ e("div", { "data-slot": "input-otp-separator", role: "separator", ...t, children: /* @__PURE__ */ e(b, {}) });
77
98
  }
78
- const p = d.forwardRef(
79
- ({
80
- label: e,
81
- id: a,
82
- dataHook: n,
83
- trackingEl: i,
84
- trackingLabel: r,
85
- containerClassName: s,
86
- children: o,
87
- "aria-label": l,
88
- ...b
89
- }, h) => {
90
- const I = d.useId(), c = a || I, P = l || (e ? void 0 : "One-time password");
91
- return /* @__PURE__ */ f("div", { className: "w-fit", children: [
92
- e && /* @__PURE__ */ t(
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
- className: "mb-2",
96
- "data-hook": n ? `${n}-label` : void 0,
97
- htmlFor: c,
98
- children: e
117
+ dataHook: n ? `${n}-label` : void 0,
118
+ htmlFor: l,
119
+ children: t
99
120
  }
100
121
  ),
101
- /* @__PURE__ */ t(
102
- v,
122
+ /* @__PURE__ */ e(
123
+ T,
103
124
  {
104
- ref: h,
105
- "aria-label": P,
106
- containerClassName: s,
125
+ ref: i,
126
+ "aria-label": c,
107
127
  dataHook: n,
108
- id: e ? c : void 0,
109
- trackingEl: i,
110
- trackingLabel: r,
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
- p.displayName = "InputOTPField";
119
- const _ = d.forwardRef(({ maxLength: e = 6, pattern: a = T, ...n }, i) => /* @__PURE__ */ t(
120
- p,
136
+ m.displayName = "InputOTPField";
137
+ const _ = s.forwardRef(({ maxLength: t = 6, ...r }, n) => /* @__PURE__ */ e(
138
+ m,
121
139
  {
122
- ref: i,
140
+ ref: n,
123
141
  inputMode: "numeric",
124
- maxLength: e,
125
- pasteTransformer: (r) => r.replace(/\D+/g, "").slice(0, e),
126
- pattern: a,
127
- ...n,
128
- children: /* @__PURE__ */ t(m, { children: Array.from({ length: e }, (r, s) => /* @__PURE__ */ t(u, { index: s }, s)) })
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 x = d.forwardRef(({ maxLength: e = 4, ...a }, n) => /* @__PURE__ */ t(
133
- p,
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: e,
138
- ...a,
139
- children: Array.from({ length: e }, (i, r) => /* @__PURE__ */ t(
140
- u,
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: r
161
+ index: a
144
162
  },
145
- r
163
+ a
146
164
  ))
147
165
  }
148
166
  ));
149
- x.displayName = "InputOTPWithSpacing";
150
- const A = d.forwardRef(
151
- ({ maxLength: e = 6, ...a }, n) => {
152
- const i = Math.ceil(e / 2), r = e - i;
153
- return /* @__PURE__ */ f(p, { ref: n, maxLength: e, ...a, children: [
154
- /* @__PURE__ */ t(m, { children: Array.from({ length: i }, (s, o) => /* @__PURE__ */ t(u, { index: o }, o)) }),
155
- /* @__PURE__ */ t(O, {}),
156
- /* @__PURE__ */ t(m, { children: Array.from({ length: r }, (s, o) => /* @__PURE__ */ t(
157
- u,
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: o + i
177
+ index: i + o
160
178
  },
161
- o + i
179
+ i + o
162
180
  )) })
163
181
  ] });
164
182
  }
165
183
  );
166
- A.displayName = "InputOTPSimple";
167
- const R = d.forwardRef(({ maxLength: e = 6, ...a }, n) => {
168
- const r = Math.ceil(e / 2);
169
- return /* @__PURE__ */ t(p, { ref: n, maxLength: e, ...a, children: Array.from({ length: r }, (s, o) => {
170
- const l = o * 2, h = Math.min(l + 2, e) - l;
171
- return /* @__PURE__ */ f(d.Fragment, { children: [
172
- o > 0 && /* @__PURE__ */ t(O, {}),
173
- /* @__PURE__ */ t(m, { children: Array.from({ length: h }, (I, c) => /* @__PURE__ */ t(u, { index: l + c }, l + c)) })
174
- ] }, o);
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
- R.displayName = "InputOTPWithSeparator";
195
+ A.displayName = "InputOTPWithSeparator";
178
196
  export {
197
+ T as InputOTP,
179
198
  _ as InputOTPDigitsOnly,
180
- A as InputOTPSimple,
181
- R as InputOTPWithSeparator,
182
- x as InputOTPWithSpacing,
183
- L as REGEXP_ONLY_CHARS,
184
- M as REGEXP_ONLY_DIGITS,
185
- j as REGEXP_ONLY_DIGITS_AND_CHARS
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
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),q=require("react"),h=require("@brightlocal/icons"),A=require("@brightlocal/ui-components/progress"),E=require("@brightlocal/ui-components/lib/utils"),l=require("@brightlocal/ui-components/input-group");function _(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=_(q),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,...u},v)=>{const[c,P]=a.useState(!1),[I,y]=a.useState("meter"),[N,O]=a.useState(""),G=a.useId(),R=j||G,g=i!==void 0?String(i):N;a.useEffect(()=>{const o=setTimeout(()=>{const f=m(g);y(f),n?.(f)},180);return()=>clearTimeout(o)},[g,n]);const T=o=>{O(o.target.value),x?.(o)},k=()=>{P(o=>!o)},d=p[I];return r.jsxs("div",{className:"w-full",children:[r.jsxs(l.InputGroup,{className:e,dataHook:s,children:[r.jsx(l.InputGroupInput,{ref:v,id:R,trackingEl:w,trackingLabel:S,type:c?"text":"password",value:i,onChange:T,...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:k,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(A.Progress,{className:E.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;
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;