@brightlocal/ui-components 2.11.0 → 2.12.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 (134) hide show
  1. package/component-meta.json +163 -12
  2. package/dist/blocks/data-table.cjs +1 -1
  3. package/dist/blocks/data-table.d.ts +16 -4
  4. package/dist/blocks/data-table.d.ts.map +1 -1
  5. package/dist/blocks/data-table.js +57 -53
  6. package/dist/blocks/input-list.cjs +2 -2
  7. package/dist/blocks/input-list.d.ts +7 -1
  8. package/dist/blocks/input-list.d.ts.map +1 -1
  9. package/dist/blocks/input-list.js +82 -81
  10. package/dist/blocks/sidebar.cjs +1 -1
  11. package/dist/blocks/sidebar.d.ts +18 -7
  12. package/dist/blocks/sidebar.d.ts.map +1 -1
  13. package/dist/blocks/sidebar.js +143 -136
  14. package/dist/breadcrumb.cjs +1 -1
  15. package/dist/breadcrumb.d.ts +14 -2
  16. package/dist/breadcrumb.d.ts.map +1 -1
  17. package/dist/breadcrumb.js +37 -37
  18. package/dist/callout.cjs +1 -1
  19. package/dist/callout.d.ts +3 -3
  20. package/dist/callout.d.ts.map +1 -1
  21. package/dist/callout.js +2 -1
  22. package/dist/carousel.cjs +1 -1
  23. package/dist/carousel.d.ts +24 -3
  24. package/dist/carousel.d.ts.map +1 -1
  25. package/dist/carousel.js +121 -117
  26. package/dist/chip.cjs +1 -1
  27. package/dist/chip.d.ts +11 -0
  28. package/dist/chip.d.ts.map +1 -1
  29. package/dist/chip.js +43 -38
  30. package/dist/combobox.cjs +3 -3
  31. package/dist/combobox.d.ts +12 -2
  32. package/dist/combobox.d.ts.map +1 -1
  33. package/dist/combobox.js +235 -230
  34. package/dist/command.cjs +1 -1
  35. package/dist/command.d.ts +5 -0
  36. package/dist/command.d.ts.map +1 -1
  37. package/dist/command.js +207 -206
  38. package/dist/date-picker.cjs +1 -1
  39. package/dist/date-picker.d.ts +10 -0
  40. package/dist/date-picker.d.ts.map +1 -1
  41. package/dist/date-picker.js +96 -96
  42. package/dist/dialog.cjs +1 -1
  43. package/dist/dialog.d.ts +7 -2
  44. package/dist/dialog.d.ts.map +1 -1
  45. package/dist/dialog.js +38 -30
  46. package/dist/drawer.d.ts +2 -2
  47. package/dist/global-layout.cjs +1 -1
  48. package/dist/global-layout.d.ts +5 -0
  49. package/dist/global-layout.d.ts.map +1 -1
  50. package/dist/global-layout.js +15 -7
  51. package/dist/index.cjs +1 -1
  52. package/dist/index.js +178 -178
  53. package/dist/input-chip.cjs +1 -1
  54. package/dist/input-chip.d.ts +7 -1
  55. package/dist/input-chip.d.ts.map +1 -1
  56. package/dist/input-chip.js +131 -130
  57. package/dist/input-group.d.ts +1 -1
  58. package/dist/input-password.cjs +1 -1
  59. package/dist/input-password.d.ts +10 -0
  60. package/dist/input-password.d.ts.map +1 -1
  61. package/dist/input-password.js +108 -106
  62. package/dist/link.cjs +1 -1
  63. package/dist/link.d.ts +1 -1
  64. package/dist/link.d.ts.map +1 -1
  65. package/dist/link.js +36 -37
  66. package/dist/list.d.ts +1 -1
  67. package/dist/logo.cjs +1 -1
  68. package/dist/logo.d.ts +6 -1
  69. package/dist/logo.d.ts.map +1 -1
  70. package/dist/logo.js +25 -22
  71. package/dist/map.cjs +1 -1
  72. package/dist/map.d.ts +17 -2
  73. package/dist/map.d.ts.map +1 -1
  74. package/dist/map.js +32 -26
  75. package/dist/pagination.cjs +1 -1
  76. package/dist/pagination.d.ts +29 -3
  77. package/dist/pagination.d.ts.map +1 -1
  78. package/dist/pagination.js +26 -25
  79. package/dist/rating.cjs +1 -1
  80. package/dist/rating.d.ts +6 -0
  81. package/dist/rating.d.ts.map +1 -1
  82. package/dist/rating.js +27 -19
  83. package/dist/resizable.d.ts +1 -1
  84. package/dist/select.cjs +2 -2
  85. package/dist/select.d.ts +7 -1
  86. package/dist/select.d.ts.map +1 -1
  87. package/dist/select.js +52 -51
  88. package/dist/separator.cjs +1 -1
  89. package/dist/separator.d.ts +16 -4
  90. package/dist/separator.d.ts.map +1 -1
  91. package/dist/separator.js +38 -35
  92. package/dist/sheet.cjs +1 -1
  93. package/dist/sheet.d.ts +6 -1
  94. package/dist/sheet.d.ts.map +1 -1
  95. package/dist/sheet.js +42 -41
  96. package/dist/skeleton.cjs +1 -1
  97. package/dist/skeleton.d.ts +5 -0
  98. package/dist/skeleton.d.ts.map +1 -1
  99. package/dist/skeleton.js +13 -11
  100. package/dist/text-reveal-motion.cjs +1 -1
  101. package/dist/text-reveal-motion.d.ts +5 -0
  102. package/dist/text-reveal-motion.d.ts.map +1 -1
  103. package/dist/text-reveal-motion.js +111 -110
  104. package/dist/typography.cjs +1 -1
  105. package/dist/typography.d.ts +1 -2
  106. package/dist/typography.d.ts.map +1 -1
  107. package/dist/typography.js +49 -50
  108. package/package.json +2 -3
  109. package/src/blocks/data-table.tsx +26 -9
  110. package/src/blocks/input-list.tsx +12 -1
  111. package/src/blocks/sidebar.tsx +43 -21
  112. package/src/components/breadcrumb.tsx +43 -26
  113. package/src/components/callout.tsx +5 -4
  114. package/src/components/carousel.tsx +33 -4
  115. package/src/components/chip.tsx +22 -2
  116. package/src/components/combobox.tsx +18 -3
  117. package/src/components/command.tsx +7 -1
  118. package/src/components/date-picker.tsx +17 -3
  119. package/src/components/dialog.tsx +17 -4
  120. package/src/components/drawer.tsx +2 -2
  121. package/src/components/global-layout.tsx +15 -2
  122. package/src/components/input-chip.tsx +12 -1
  123. package/src/components/input-password.tsx +73 -49
  124. package/src/components/link.tsx +29 -17
  125. package/src/components/logo.tsx +10 -2
  126. package/src/components/map.tsx +23 -0
  127. package/src/components/pagination.tsx +44 -11
  128. package/src/components/rating.tsx +20 -2
  129. package/src/components/select.tsx +9 -1
  130. package/src/components/separator.tsx +40 -25
  131. package/src/components/sheet.tsx +28 -20
  132. package/src/components/skeleton.tsx +13 -2
  133. package/src/components/text-reveal-motion.tsx +7 -1
  134. package/src/components/typography.tsx +6 -7
@@ -1,87 +1,87 @@
1
- import { jsx as k, jsxs as M } from "react/jsx-runtime";
2
- import * as t from "react";
1
+ import { jsx as x, jsxs as M } from "react/jsx-runtime";
2
+ import * as n from "react";
3
3
  import { cva as P } from "class-variance-authority";
4
4
  import { cn as E } from "@brightlocal/ui-components/lib/utils";
5
5
  import { Chip as j } from "@brightlocal/ui-components/chip";
6
- const $ = t.createContext(null), B = t.createContext(null), K = t.createContext(null);
6
+ const A = n.createContext(null), B = n.createContext(null), K = n.createContext(null);
7
7
  function F() {
8
- const r = t.useContext($);
9
- if (!r)
8
+ const u = n.useContext(A);
9
+ if (!u)
10
10
  throw new Error("InputChip components must be used within an <InputChip>");
11
- return r;
11
+ return u;
12
12
  }
13
- function A() {
14
- const r = t.useContext(B);
15
- if (!r)
13
+ function $() {
14
+ const u = n.useContext(B);
15
+ if (!u)
16
16
  throw new Error("InputChip components must be used within an <InputChip>");
17
- return r;
17
+ return u;
18
18
  }
19
- function L() {
20
- const r = t.useContext(K);
21
- if (!r)
19
+ function N() {
20
+ const u = n.useContext(K);
21
+ if (!u)
22
22
  throw new Error("InputChip components must be used within an <InputChip>");
23
- return r;
23
+ return u;
24
24
  }
25
25
  function G() {
26
- const r = F(), { value: C, disabled: p } = A(), { inputValue: s, focusedChipIndex: u } = L();
26
+ const u = F(), { value: b, disabled: d } = $(), { inputValue: o, focusedChipIndex: c } = N();
27
27
  return {
28
- ...r,
29
- value: C,
30
- disabled: p,
31
- inputValue: s,
32
- focusedChipIndex: u
28
+ ...u,
29
+ value: b,
30
+ disabled: d,
31
+ inputValue: o,
32
+ focusedChipIndex: c
33
33
  };
34
34
  }
35
35
  function J({
36
- value: r,
37
- defaultValue: C = [],
38
- onValueChange: p,
39
- disabled: s = !1,
40
- allowDuplicates: u = !1,
41
- children: f
36
+ value: u,
37
+ defaultValue: b = [],
38
+ onValueChange: d,
39
+ disabled: o = !1,
40
+ allowDuplicates: c = !1,
41
+ children: s
42
42
  }) {
43
- const [c, g] = t.useState(C), [l, I] = t.useState(""), [d, w] = t.useState(-1), n = t.useRef(null), e = t.useRef([]), o = r !== void 0, a = o ? r : c, b = t.useRef(a), m = t.useRef(p), R = t.useRef(s);
44
- t.useLayoutEffect(() => {
45
- b.current = a, m.current = p, R.current = s;
46
- }), t.useEffect(() => {
47
- e.current.length > a.length && (e.current.length = a.length), d >= a.length && w(-1);
48
- }, [a.length, d]);
49
- const i = t.useCallback(
50
- (x) => {
51
- o || g(x), m.current?.(x);
43
+ const [p, a] = n.useState(b), [v, l] = n.useState(""), [C, I] = n.useState(-1), k = n.useRef(null), t = n.useRef([]), e = u !== void 0, r = e ? u : p, f = n.useRef(r), g = n.useRef(d), R = n.useRef(o);
44
+ n.useLayoutEffect(() => {
45
+ f.current = r, g.current = d, R.current = o;
46
+ }), n.useEffect(() => {
47
+ t.current.length > r.length && (t.current.length = r.length), C >= r.length && I(-1);
48
+ }, [r.length, C]);
49
+ const i = n.useCallback(
50
+ (w) => {
51
+ e || a(w), g.current?.(w);
52
52
  },
53
- [o]
54
- ), y = t.useCallback(
55
- (x) => {
53
+ [e]
54
+ ), y = n.useCallback(
55
+ (w) => {
56
56
  if (R.current) return;
57
- const V = x.trim();
58
- V && (u || !b.current.includes(V)) && (i([...b.current, V]), I(""));
57
+ const V = w.trim();
58
+ V && (c || !f.current.includes(V)) && (i([...f.current, V]), l(""));
59
59
  },
60
- [u, i]
61
- ), D = t.useCallback(
62
- (x) => {
63
- R.current || i(b.current.filter((V, S) => S !== x));
60
+ [c, i]
61
+ ), D = n.useCallback(
62
+ (w) => {
63
+ R.current || i(f.current.filter((V, L) => L !== w));
64
64
  },
65
65
  [i]
66
- ), h = t.useMemo(
66
+ ), h = n.useMemo(
67
67
  () => ({
68
68
  onValueChange: i,
69
- setInputValue: I,
69
+ setInputValue: l,
70
70
  addItem: y,
71
71
  removeItem: D,
72
- inputRef: n,
73
- setFocusedChipIndex: w,
74
- chipRefs: e
72
+ inputRef: k,
73
+ setFocusedChipIndex: I,
74
+ chipRefs: t
75
75
  }),
76
76
  [i, y, D]
77
- ), v = t.useMemo(
78
- () => ({ value: a, disabled: s }),
79
- [a, s]
80
- ), N = t.useMemo(
81
- () => ({ inputValue: l, focusedChipIndex: d }),
82
- [l, d]
77
+ ), m = n.useMemo(
78
+ () => ({ value: r, disabled: o }),
79
+ [r, o]
80
+ ), S = n.useMemo(
81
+ () => ({ inputValue: v, focusedChipIndex: C }),
82
+ [v, C]
83
83
  );
84
- return /* @__PURE__ */ k($.Provider, { value: h, children: /* @__PURE__ */ k(B.Provider, { value: v, children: /* @__PURE__ */ k(K.Provider, { value: N, children: f }) }) });
84
+ return /* @__PURE__ */ x(A.Provider, { value: h, children: /* @__PURE__ */ x(B.Provider, { value: m, children: /* @__PURE__ */ x(K.Provider, { value: S, children: s }) }) });
85
85
  }
86
86
  const H = P(
87
87
  [
@@ -128,57 +128,57 @@ const H = P(
128
128
  "focus:outline-none focus-visible:outline-none",
129
129
  // Disabled
130
130
  "disabled:cursor-not-allowed disabled:opacity-50"
131
- ], W = t.forwardRef(
131
+ ], W = n.forwardRef(
132
132
  ({
133
- className: r,
134
- error: C = !1,
135
- dataHook: p,
136
- trackingEl: s,
137
- trackingLabel: u,
138
- placeholder: f,
139
- inputId: c,
140
- "aria-label": g,
141
- "aria-labelledby": l,
142
- children: I,
143
- ...d
144
- }, w) => {
145
- const { setInputValue: n, addItem: e, inputRef: o, setFocusedChipIndex: a, chipRefs: b } = F(), { value: m, disabled: R } = A(), { inputValue: i } = L(), y = (h) => {
146
- n(h.target.value);
133
+ className: u,
134
+ error: b = !1,
135
+ dataHook: d,
136
+ trackingEl: o,
137
+ trackingLabel: c,
138
+ placeholder: s,
139
+ inputId: p,
140
+ "aria-label": a,
141
+ "aria-labelledby": v,
142
+ children: l,
143
+ ...C
144
+ }, I) => {
145
+ const { setInputValue: k, addItem: t, inputRef: e, setFocusedChipIndex: r, chipRefs: f } = F(), { value: g, disabled: R } = $(), { inputValue: i } = N(), y = (h) => {
146
+ k(h.target.value);
147
147
  }, D = (h) => {
148
- if (h.key === "Enter" && i.trim() && (h.preventDefault(), e(i)), h.key === "ArrowLeft" && !i && m.length > 0) {
148
+ if (h.key === "Enter" && i.trim() && (h.preventDefault(), t(i)), h.key === "ArrowLeft" && !i && g.length > 0) {
149
149
  h.preventDefault();
150
- const v = m.length - 1;
151
- a(v), b.current[v]?.focus();
150
+ const m = g.length - 1;
151
+ r(m), f.current[m]?.focus();
152
152
  }
153
- if (h.key === "Backspace" && !i && m.length > 0) {
153
+ if (h.key === "Backspace" && !i && g.length > 0) {
154
154
  h.preventDefault();
155
- const v = m.length - 1;
156
- a(v), b.current[v]?.focus();
155
+ const m = g.length - 1;
156
+ r(m), f.current[m]?.focus();
157
157
  }
158
158
  };
159
159
  return /* @__PURE__ */ M(
160
160
  "div",
161
161
  {
162
- ref: w,
163
- className: E(H({ error: C }), r),
164
- "data-hook": p,
162
+ ref: I,
163
+ className: E(H({ error: b }), u),
164
+ "data-hook": d,
165
165
  "data-slot": "input-chip",
166
- "data-tracking-el": s,
167
- "data-tracking-label": u,
168
- ...d,
166
+ "data-tracking-el": o,
167
+ "data-tracking-label": c,
168
+ ...C,
169
169
  children: [
170
- I,
171
- /* @__PURE__ */ k(
170
+ l,
171
+ /* @__PURE__ */ x(
172
172
  "input",
173
173
  {
174
- ref: o,
175
- "aria-label": g,
176
- "aria-labelledby": l,
174
+ ref: e,
175
+ "aria-label": a,
176
+ "aria-labelledby": v,
177
177
  className: E(T),
178
178
  "data-slot": "input-chip-input",
179
179
  disabled: R,
180
- id: c,
181
- placeholder: f,
180
+ id: p,
181
+ placeholder: s,
182
182
  type: "text",
183
183
  value: i,
184
184
  onChange: y,
@@ -192,74 +192,75 @@ const H = P(
192
192
  );
193
193
  W.displayName = "InputChipInput";
194
194
  function O({
195
- className: r,
196
- dataHookPrefix: C = "chip"
195
+ className: u,
196
+ dataHookPrefix: b = "chip",
197
+ itemAriaLabel: d
197
198
  }) {
198
- const { removeItem: p, inputRef: s, setFocusedChipIndex: u, chipRefs: f } = F(), { value: c, disabled: g } = A(), l = t.useRef(null);
199
- t.useEffect(() => {
199
+ const { removeItem: o, inputRef: c, setFocusedChipIndex: s, chipRefs: p } = F(), { value: a, disabled: v } = $(), l = n.useRef(null);
200
+ n.useEffect(() => {
200
201
  if (l.current !== null) {
201
202
  if (l.current === "input")
202
- s.current?.focus();
203
+ c.current?.focus();
203
204
  else {
204
- const n = l.current;
205
- n >= 0 && n < c.length ? f.current[n]?.focus() : c.length > 0 ? f.current[c.length - 1]?.focus() : s.current?.focus();
205
+ const t = l.current;
206
+ t >= 0 && t < a.length ? p.current[t]?.focus() : a.length > 0 ? p.current[a.length - 1]?.focus() : c.current?.focus();
206
207
  }
207
208
  l.current = null;
208
209
  }
209
- }, [c.length, s, f]);
210
- const I = (n, e) => {
211
- if (!g)
212
- switch (n.key) {
210
+ }, [a.length, c, p]);
211
+ const C = (t, e) => {
212
+ if (!v)
213
+ switch (t.key) {
213
214
  case "ArrowLeft":
214
- n.preventDefault(), e > 0 && (u(e - 1), f.current[e - 1]?.focus());
215
+ t.preventDefault(), e > 0 && (s(e - 1), p.current[e - 1]?.focus());
215
216
  break;
216
217
  case "ArrowRight":
217
- n.preventDefault(), e < c.length - 1 ? (u(e + 1), f.current[e + 1]?.focus()) : (u(-1), s.current?.focus());
218
+ t.preventDefault(), e < a.length - 1 ? (s(e + 1), p.current[e + 1]?.focus()) : (s(-1), c.current?.focus());
218
219
  break;
219
220
  case "Backspace":
220
221
  case "Delete": {
221
- n.preventDefault();
222
- const o = c.length - 1;
223
- if (o === 0)
224
- u(-1), l.current = "input", p(e);
225
- else if (e >= o) {
226
- const a = o - 1;
227
- u(a), l.current = a, p(e);
222
+ t.preventDefault();
223
+ const r = a.length - 1;
224
+ if (r === 0)
225
+ s(-1), l.current = "input", o(e);
226
+ else if (e >= r) {
227
+ const f = r - 1;
228
+ s(f), l.current = f, o(e);
228
229
  } else
229
- u(e), l.current = e, p(e);
230
+ s(e), l.current = e, o(e);
230
231
  break;
231
232
  }
232
233
  case "Home":
233
- n.preventDefault(), c.length > 0 && (u(0), f.current[0]?.focus());
234
+ t.preventDefault(), a.length > 0 && (s(0), p.current[0]?.focus());
234
235
  break;
235
236
  case "End":
236
- n.preventDefault(), u(-1), s.current?.focus();
237
+ t.preventDefault(), s(-1), c.current?.focus();
237
238
  break;
238
239
  }
239
- }, d = (n) => {
240
- u(n);
241
- }, w = (n) => {
242
- const e = n.relatedTarget;
243
- e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") || u(-1);
240
+ }, I = (t) => {
241
+ s(t);
242
+ }, k = (t) => {
243
+ const e = t.relatedTarget;
244
+ e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") || s(-1);
244
245
  };
245
- return c.length === 0 ? null : /* @__PURE__ */ k("div", { className: E("contents", r), "data-slot": "input-chip-items", children: c.map((n, e) => /* @__PURE__ */ k(
246
+ return a.length === 0 ? null : /* @__PURE__ */ x("div", { className: E("contents", u), "data-slot": "input-chip-items", children: a.map((t, e) => /* @__PURE__ */ x(
246
247
  j,
247
248
  {
248
- ref: (o) => {
249
- f.current[e] = o;
249
+ ref: (r) => {
250
+ p.current[e] = r;
250
251
  },
251
- "aria-label": `${n}, press Delete to remove`,
252
- dataHook: `${C}-${e}`,
253
- disabled: g,
252
+ "aria-label": d ? d.replace("{item}", t) : `${t}, press Delete to remove`,
253
+ dataHook: `${b}-${e}`,
254
+ disabled: v,
254
255
  role: "group",
255
256
  tabIndex: -1,
256
- onBlur: w,
257
- onFocus: () => d(e),
258
- onKeyDown: (o) => I(o, e),
259
- onRemove: () => p(e),
260
- children: n
257
+ onBlur: k,
258
+ onFocus: () => I(e),
259
+ onKeyDown: (r) => C(r, e),
260
+ onRemove: () => o(e),
261
+ children: t
261
262
  },
262
- `${n}-${e}`
263
+ `${t}-${e}`
263
264
  )) });
264
265
  }
265
266
  export {
@@ -34,7 +34,7 @@ interface InputGroupAddonProps extends React.HTMLAttributes<HTMLDivElement>, Var
34
34
  declare const InputGroupAddon: React.ForwardRefExoticComponent<InputGroupAddonProps & React.RefAttributes<HTMLDivElement>>;
35
35
  declare const inputGroupButtonVariants: (props?: ({
36
36
  variant?: "default" | "ghost" | null | undefined;
37
- size?: "default" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
37
+ size?: "default" | "icon" | "sm" | "lg" | "icon-xs" | "icon-sm" | "icon-lg" | null | undefined;
38
38
  } & import('class-variance-authority/types').ClassProp) | undefined) => string;
39
39
  interface InputGroupButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof inputGroupButtonVariants> {
40
40
  asChild?: boolean;
@@ -1 +1 @@
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 _({children:e,dataHook:t,trackingEl:o,trackingLabel:a,disabled:u,value:n,onChange:l,onStrengthChange:i,strengthLevels:p,calculateStrength:d,error:c,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,E=p??C,N=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=N(b);A(G),i?.(G)},180);return()=>clearTimeout(g)},[b,N,i]);const z=r.useMemo(()=>({showPassword:h,setShowPassword:f,toggleVisibility:R,password:b,setPassword:T,strength:y,strengthLevels:E,disabled:u,dataHook:t,trackingEl:o,trackingLabel:a,inputId:k,error:c}),[h,R,b,T,y,E,u,t,o,a,k,c]);return s.jsx(L.Provider,{value:z,children:s.jsx("div",{className:S.cn("w-full",I),"data-hook":t,"data-slot":"input-password",children:e})})}_.displayName="InputPasswordRoot";const q=r.forwardRef(({className:e,groupClassName:t,onChange:o,...a},u)=>{const{showPassword:n,toggleVisibility:l,password:i,setPassword:p,disabled:d,dataHook:c,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:c,error:f,children:[s.jsx(w.InputGroupInput,{ref:u,className:e,disabled:d,id:h,trackingEl:x,trackingLabel:I,type:n?"text":"password",value:i,onChange:j,...a}),s.jsx(w.InputGroupAddon,{align:"inline-end",children:s.jsx(w.InputGroupButton,{"aria-label":n?"Hide password":"Show password","data-hook":`${c}-toggle`,disabled:d,size:"icon-sm",variant:"ghost",onClick:l,children:n?s.jsx(P.EyeOff,{}):s.jsx(P.Eye,{})})})]})});q.displayName="InputPasswordField";const H=r.forwardRef(({className:e,showLabel:t="Show password",hideLabel:o="Hide password",size:a="icon",variant:u="ghost",...n},l)=>{const{showPassword:i,toggleVisibility:p,disabled:d,dataHook:c}=v();return s.jsx(w.InputGroupButton,{ref:l,"aria-label":i?o:t,className:e,"data-hook":`${c}-toggle`,disabled:d,size:a,variant:u,onClick:p,...n,children:i?s.jsx(P.EyeOff,{}):s.jsx(P.Eye,{})})});H.displayName="InputPasswordToggle";function V({className:e,showLabel:t=!0}){const{strength:o,strengthLevels:a,dataHook:u,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:`${u}-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":`${u}-strength-label`,children:l.label})]})})}V.displayName="InputPasswordStrength";exports.DEFAULT_STRENGTH_LEVELS=C;exports.InputPasswordField=q;exports.InputPasswordRoot=_;exports.InputPasswordStrength=V;exports.InputPasswordToggle=H;exports.calculatePasswordStrength=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),D=require("react"),j=require("@brightlocal/icons"),M=require("@brightlocal/ui-components/progress"),y=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 r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const n=$(D),O={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 L(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 _=n.createContext(null);function k(){const e=n.useContext(_);if(!e)throw new Error("InputPassword compound components must be used within InputPasswordRoot");return e}function q({children:e,dataHook:t,trackingEl:o,trackingLabel:r,disabled:u,value:a,onChange:l,onStrengthChange:i,strengthLevels:g,calculateStrength:p,error:c,id:h,className:f}){const[m,b]=n.useState(!1),[S,v]=n.useState(""),[P,x]=n.useState("meter"),F=n.useId(),E=h||F,I=a!==void 0?a:S,N=g??O,T=p??L,R=n.useCallback(d=>{a===void 0&&v(d),l?.(d)},[a,l]),G=n.useCallback(()=>{b(d=>!d)},[]);n.useEffect(()=>{const d=setTimeout(()=>{const C=T(I);x(C),i?.(C)},180);return()=>clearTimeout(d)},[I,T,i]);const z=n.useMemo(()=>({showPassword:m,setShowPassword:b,toggleVisibility:G,password:I,setPassword:R,strength:P,strengthLevels:N,disabled:u,dataHook:t,trackingEl:o,trackingLabel:r,inputId:E,error:c}),[m,G,I,R,P,N,u,t,o,r,E,c]);return s.jsx(_.Provider,{value:z,children:s.jsx("div",{className:y.cn("w-full",f),"data-hook":t,"data-slot":"input-password",children:e})})}q.displayName="InputPasswordRoot";const H=n.forwardRef(({className:e,groupClassName:t,onChange:o,showLabel:r,hideLabel:u,...a},l)=>{const{showPassword:i,toggleVisibility:g,password:p,setPassword:c,disabled:h,dataHook:f,trackingEl:m,trackingLabel:b,inputId:S,error:v}=k(),P=x=>{c(x.target.value),o?.(x)};return s.jsxs(w.InputGroup,{className:t,dataHook:f,error:v,children:[s.jsx(w.InputGroupInput,{ref:l,className:e,disabled:h,id:S,trackingEl:m,trackingLabel:b,type:i?"text":"password",value:p,onChange:P,...a}),s.jsx(w.InputGroupAddon,{align:"inline-end",children:s.jsx(w.InputGroupButton,{"aria-label":i?u??"Hide password":r??"Show password","data-hook":`${f}-toggle`,disabled:h,size:"icon-sm",variant:"ghost",onClick:g,children:i?s.jsx(j.EyeOff,{}):s.jsx(j.Eye,{})})})]})});H.displayName="InputPasswordField";const V=n.forwardRef(({className:e,showLabel:t,hideLabel:o,size:r="icon",variant:u="ghost",...a},l)=>{const{showPassword:i,toggleVisibility:g,disabled:p,dataHook:c}=k();return s.jsx(w.InputGroupButton,{ref:l,"aria-label":i?o??"Hide password":t??"Show password",className:e,"data-hook":`${c}-toggle`,disabled:p,size:r,variant:u,onClick:g,...a,children:i?s.jsx(j.EyeOff,{}):s.jsx(j.Eye,{})})});V.displayName="InputPasswordToggle";function A({className:e,showLabel:t=!0}){const{strength:o,strengthLevels:r,dataHook:u,disabled:a}=k(),l=r[o]??{label:o,value:0,color:"bg-muted"};return s.jsx("div",{className:y.cn("mt-1 space-y-2",e),children:s.jsxs("div",{className:y.cn("flex items-center gap-2",a&&"opacity-50"),children:[s.jsx(M.Progress,{className:"h-2 flex-1",dataHook:`${u}-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":`${u}-strength-label`,children:l.label})]})})}A.displayName="InputPasswordStrength";exports.DEFAULT_STRENGTH_LEVELS=O;exports.InputPasswordField=H;exports.InputPasswordRoot=q;exports.InputPasswordStrength=A;exports.InputPasswordToggle=V;exports.calculatePasswordStrength=L;
@@ -122,6 +122,16 @@ export interface InputPasswordFieldProps extends Omit<React.ComponentProps<typeo
122
122
  * Additional class name for the InputGroup wrapper
123
123
  */
124
124
  groupClassName?: string;
125
+ /**
126
+ * Accessible label for the toggle button when password is hidden.
127
+ * @default "Show password"
128
+ */
129
+ showLabel?: string;
130
+ /**
131
+ * Accessible label for the toggle button when password is visible.
132
+ * @default "Hide password"
133
+ */
134
+ hideLabel?: string;
125
135
  }
126
136
  /**
127
137
  * InputPasswordField - The password input field with toggle button
@@ -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,CA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