@brightlocal/ui-components 0.1.2 → 0.1.4

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 (281) hide show
  1. package/dist/accordion.cjs +1 -1
  2. package/dist/accordion.d.ts +74 -4
  3. package/dist/accordion.d.ts.map +1 -1
  4. package/dist/accordion.js +100 -105
  5. package/dist/alert-dialog.cjs +1 -1
  6. package/dist/alert-dialog.d.ts +30 -10
  7. package/dist/alert-dialog.d.ts.map +1 -1
  8. package/dist/alert-dialog.js +129 -132
  9. package/dist/alert.cjs +1 -1
  10. package/dist/alert.d.ts +22 -1
  11. package/dist/alert.d.ts.map +1 -1
  12. package/dist/alert.js +1 -1
  13. package/dist/aspect-ratio.cjs +1 -1
  14. package/dist/aspect-ratio.d.ts +11 -1
  15. package/dist/aspect-ratio.d.ts.map +1 -1
  16. package/dist/aspect-ratio.js +16 -20
  17. package/dist/avatar.cjs +1 -1
  18. package/dist/avatar.d.ts +43 -3
  19. package/dist/avatar.d.ts.map +1 -1
  20. package/dist/avatar.js +18 -16
  21. package/dist/badge.cjs +1 -1
  22. package/dist/badge.d.ts +24 -9
  23. package/dist/badge.d.ts.map +1 -1
  24. package/dist/badge.js +34 -32
  25. package/dist/blocks/data-table.cjs +1 -1
  26. package/dist/blocks/data-table.d.ts.map +1 -1
  27. package/dist/blocks/data-table.js +177 -170
  28. package/dist/blocks/sidebar.cjs +1 -1
  29. package/dist/blocks/sidebar.d.ts +38 -307
  30. package/dist/blocks/sidebar.d.ts.map +1 -1
  31. package/dist/blocks/sidebar.js +411 -508
  32. package/dist/breadcrumb.cjs +1 -1
  33. package/dist/breadcrumb.d.ts +63 -8
  34. package/dist/breadcrumb.d.ts.map +1 -1
  35. package/dist/breadcrumb.js +97 -93
  36. package/dist/button.cjs +1 -1
  37. package/dist/button.d.ts +17 -45
  38. package/dist/button.d.ts.map +1 -1
  39. package/dist/button.js +49 -50
  40. package/dist/calendar.cjs +1 -1
  41. package/dist/calendar.d.ts +16 -1
  42. package/dist/calendar.d.ts.map +1 -1
  43. package/dist/calendar.js +31 -29
  44. package/dist/card.cjs +1 -1
  45. package/dist/card.d.ts +58 -18
  46. package/dist/card.d.ts.map +1 -1
  47. package/dist/card.js +60 -51
  48. package/dist/carousel.cjs +1 -1
  49. package/dist/carousel.d.ts +99 -9
  50. package/dist/carousel.d.ts.map +1 -1
  51. package/dist/carousel.js +142 -128
  52. package/dist/centred-layout.cjs +1 -1
  53. package/dist/centred-layout.d.ts +18 -15
  54. package/dist/centred-layout.d.ts.map +1 -1
  55. package/dist/centred-layout.js +44 -33
  56. package/dist/chart.cjs +4 -4
  57. package/dist/chart.d.ts +70 -7
  58. package/dist/chart.d.ts.map +1 -1
  59. package/dist/chart.js +71 -66
  60. package/dist/checkbox.cjs +1 -1
  61. package/dist/checkbox.d.ts +9 -5
  62. package/dist/checkbox.d.ts.map +1 -1
  63. package/dist/checkbox.js +61 -82
  64. package/dist/collapsible.cjs +1 -1
  65. package/dist/collapsible.d.ts +65 -8
  66. package/dist/collapsible.d.ts.map +1 -1
  67. package/dist/collapsible.js +41 -55
  68. package/dist/combobox.cjs +1 -1
  69. package/dist/combobox.d.ts +28 -18
  70. package/dist/combobox.d.ts.map +1 -1
  71. package/dist/combobox.js +191 -160
  72. package/dist/command.cjs +1 -1
  73. package/dist/command.d.ts +115 -9
  74. package/dist/command.d.ts.map +1 -1
  75. package/dist/command.js +176 -152
  76. package/dist/context-menu.cjs +1 -1
  77. package/dist/context-menu.d.ts +188 -20
  78. package/dist/context-menu.d.ts.map +1 -1
  79. package/dist/context-menu.js +120 -122
  80. package/dist/date-picker.cjs +1 -1
  81. package/dist/date-picker.d.ts +75 -9
  82. package/dist/date-picker.d.ts.map +1 -1
  83. package/dist/date-picker.js +221 -82
  84. package/dist/description.cjs +1 -0
  85. package/dist/description.d.ts +37 -0
  86. package/dist/description.d.ts.map +1 -0
  87. package/dist/description.js +25 -0
  88. package/dist/dialog.cjs +1 -1
  89. package/dist/dialog.d.ts +73 -9
  90. package/dist/dialog.d.ts.map +1 -1
  91. package/dist/dialog.js +103 -112
  92. package/dist/drawer.cjs +1 -1
  93. package/dist/drawer.d.ts +92 -0
  94. package/dist/drawer.d.ts.map +1 -1
  95. package/dist/drawer.js +67 -52
  96. package/dist/dropdown-menu.cjs +1 -1
  97. package/dist/dropdown-menu.d.ts +95 -11
  98. package/dist/dropdown-menu.d.ts.map +1 -1
  99. package/dist/dropdown-menu.js +146 -106
  100. package/dist/field.cjs +1 -1
  101. package/dist/field.d.ts +26 -6
  102. package/dist/field.d.ts.map +1 -1
  103. package/dist/field.js +55 -53
  104. package/dist/global-layout.cjs +1 -1
  105. package/dist/global-layout.d.ts +27 -17
  106. package/dist/global-layout.d.ts.map +1 -1
  107. package/dist/global-layout.js +86 -79
  108. package/dist/hover-card.cjs +1 -1
  109. package/dist/hover-card.d.ts +36 -6
  110. package/dist/hover-card.d.ts.map +1 -1
  111. package/dist/hover-card.js +44 -42
  112. package/dist/index.cjs +1 -1
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.d.ts.map +1 -1
  115. package/dist/index.js +367 -386
  116. package/dist/input-group.cjs +1 -1
  117. package/dist/input-group.d.ts +21 -2
  118. package/dist/input-group.d.ts.map +1 -1
  119. package/dist/input-group.js +51 -41
  120. package/dist/input-otp.cjs +1 -1
  121. package/dist/input-otp.js +1 -1
  122. package/dist/input-password.cjs +1 -1
  123. package/dist/input-password.d.ts.map +1 -1
  124. package/dist/input-password.js +25 -26
  125. package/dist/input.cjs +1 -1
  126. package/dist/input.d.ts +38 -24
  127. package/dist/input.d.ts.map +1 -1
  128. package/dist/input.js +68 -136
  129. package/dist/label.cjs +1 -1
  130. package/dist/label.d.ts +20 -1
  131. package/dist/label.d.ts.map +1 -1
  132. package/dist/label.js +31 -18
  133. package/dist/link.cjs +1 -1
  134. package/dist/link.js +1 -1
  135. package/dist/logo.cjs +1 -1
  136. package/dist/logo.d.ts +9 -4
  137. package/dist/logo.d.ts.map +1 -1
  138. package/dist/logo.js +20 -21
  139. package/dist/menubar.cjs +1 -1
  140. package/dist/menubar.d.ts +43 -6
  141. package/dist/menubar.d.ts.map +1 -1
  142. package/dist/menubar.js +100 -78
  143. package/dist/navigation-menu.cjs +1 -1
  144. package/dist/navigation-menu.d.ts +6 -54
  145. package/dist/navigation-menu.d.ts.map +1 -1
  146. package/dist/navigation-menu.js +73 -84
  147. package/dist/pagination.cjs +1 -1
  148. package/dist/pagination.d.ts +8 -10
  149. package/dist/pagination.d.ts.map +1 -1
  150. package/dist/pagination.js +78 -86
  151. package/dist/popover.cjs +1 -1
  152. package/dist/popover.d.ts +59 -4
  153. package/dist/popover.d.ts.map +1 -1
  154. package/dist/popover.js +42 -34
  155. package/dist/progress.cjs +1 -1
  156. package/dist/progress.d.ts +9 -2
  157. package/dist/progress.d.ts.map +1 -1
  158. package/dist/progress.js +71 -59
  159. package/dist/radio-group.cjs +1 -1
  160. package/dist/radio-group.d.ts +33 -10
  161. package/dist/radio-group.d.ts.map +1 -1
  162. package/dist/radio-group.js +56 -66
  163. package/dist/rating.d.ts +4 -0
  164. package/dist/rating.d.ts.map +1 -1
  165. package/dist/resizable.cjs +1 -1
  166. package/dist/resizable.d.ts +58 -6
  167. package/dist/resizable.d.ts.map +1 -1
  168. package/dist/resizable.js +38 -37
  169. package/dist/scroll-area.cjs +1 -1
  170. package/dist/scroll-area.d.ts +46 -5
  171. package/dist/scroll-area.d.ts.map +1 -1
  172. package/dist/scroll-area.js +42 -38
  173. package/dist/select.cjs +1 -1
  174. package/dist/select.d.ts +30 -0
  175. package/dist/select.d.ts.map +1 -1
  176. package/dist/select.js +64 -54
  177. package/dist/separator.cjs +1 -1
  178. package/dist/separator.d.ts +52 -5
  179. package/dist/separator.d.ts.map +1 -1
  180. package/dist/separator.js +45 -35
  181. package/dist/sheet.cjs +1 -1
  182. package/dist/sheet.d.ts +85 -19
  183. package/dist/sheet.d.ts.map +1 -1
  184. package/dist/sheet.js +117 -115
  185. package/dist/skeleton.cjs +1 -1
  186. package/dist/skeleton.d.ts +24 -2
  187. package/dist/skeleton.d.ts.map +1 -1
  188. package/dist/skeleton.js +15 -9
  189. package/dist/slider.cjs +1 -1
  190. package/dist/slider.d.ts +18 -4
  191. package/dist/slider.d.ts.map +1 -1
  192. package/dist/slider.js +72 -66
  193. package/dist/sonner.cjs +1 -1
  194. package/dist/sonner.d.ts +21 -22
  195. package/dist/sonner.d.ts.map +1 -1
  196. package/dist/sonner.js +46 -48
  197. package/dist/split-layout.d.ts +4 -1
  198. package/dist/split-layout.d.ts.map +1 -1
  199. package/dist/switch.cjs +1 -1
  200. package/dist/switch.d.ts +2 -12
  201. package/dist/switch.d.ts.map +1 -1
  202. package/dist/switch.js +37 -41
  203. package/dist/table.cjs +1 -1
  204. package/dist/table.d.ts +16 -12
  205. package/dist/table.d.ts.map +1 -1
  206. package/dist/table.js +56 -58
  207. package/dist/tabs.d.ts +27 -3
  208. package/dist/tabs.d.ts.map +1 -1
  209. package/dist/toggle-group.cjs +1 -1
  210. package/dist/toggle-group.d.ts +57 -7
  211. package/dist/toggle-group.d.ts.map +1 -1
  212. package/dist/toggle-group.js +60 -67
  213. package/dist/toggle.cjs +1 -1
  214. package/dist/toggle.d.ts +12 -26
  215. package/dist/toggle.d.ts.map +1 -1
  216. package/dist/toggle.js +16 -20
  217. package/package.json +9 -3
  218. package/src/blocks/data-table.tsx +43 -33
  219. package/src/blocks/sidebar.tsx +158 -541
  220. package/src/components/accordion.tsx +164 -78
  221. package/src/components/alert-dialog.tsx +156 -111
  222. package/src/components/alert.tsx +27 -14
  223. package/src/components/aspect-ratio.tsx +25 -16
  224. package/src/components/avatar.tsx +56 -8
  225. package/src/components/badge.tsx +65 -42
  226. package/src/components/breadcrumb.tsx +159 -83
  227. package/src/components/button.tsx +42 -63
  228. package/src/components/calendar.tsx +22 -6
  229. package/src/components/card.tsx +92 -40
  230. package/src/components/carousel.tsx +240 -115
  231. package/src/components/centred-layout.tsx +68 -49
  232. package/src/components/chart.tsx +118 -47
  233. package/src/components/checkbox.tsx +43 -79
  234. package/src/components/collapsible.tsx +95 -26
  235. package/src/components/combobox.tsx +243 -153
  236. package/src/components/command.tsx +295 -121
  237. package/src/components/context-menu.tsx +279 -82
  238. package/src/components/date-picker.tsx +282 -31
  239. package/src/components/description.tsx +60 -0
  240. package/src/components/dialog.tsx +163 -87
  241. package/src/components/drawer.tsx +76 -2
  242. package/src/components/dropdown-menu.tsx +143 -37
  243. package/src/components/field.tsx +38 -11
  244. package/src/components/global-layout.tsx +116 -77
  245. package/src/components/hover-card.tsx +54 -14
  246. package/src/components/input-group.tsx +56 -18
  247. package/src/components/input-otp.tsx +1 -1
  248. package/src/components/input-password.tsx +4 -5
  249. package/src/components/input.tsx +93 -186
  250. package/src/components/label.tsx +56 -15
  251. package/src/components/link.tsx +1 -1
  252. package/src/components/logo.tsx +12 -7
  253. package/src/components/menubar.tsx +61 -5
  254. package/src/components/navigation-menu.tsx +37 -99
  255. package/src/components/pagination.tsx +13 -19
  256. package/src/components/popover.tsx +103 -20
  257. package/src/components/progress.tsx +82 -60
  258. package/src/components/radio-group.tsx +44 -25
  259. package/src/components/rating.tsx +4 -0
  260. package/src/components/resizable.tsx +88 -38
  261. package/src/components/scroll-area.tsx +123 -56
  262. package/src/components/select.tsx +22 -2
  263. package/src/components/separator.tsx +101 -24
  264. package/src/components/sheet.tsx +186 -90
  265. package/src/components/skeleton.tsx +40 -10
  266. package/src/components/slider.tsx +83 -57
  267. package/src/components/sonner.tsx +34 -34
  268. package/src/components/split-layout.tsx +4 -1
  269. package/src/components/switch.figma.tsx +7 -11
  270. package/src/components/switch.tsx +9 -19
  271. package/src/components/table.tsx +23 -18
  272. package/src/components/tabs.tsx +27 -3
  273. package/src/components/toggle-group.tsx +115 -86
  274. package/src/components/toggle.figma.tsx +13 -19
  275. package/src/components/toggle.tsx +20 -34
  276. package/src/index.ts +1 -1
  277. package/dist/input-base.cjs +0 -1
  278. package/dist/input-base.d.ts +0 -28
  279. package/dist/input-base.d.ts.map +0 -1
  280. package/dist/input-base.js +0 -56
  281. package/src/components/input-base.tsx +0 -86
@@ -4,6 +4,24 @@ import * as React from "react";
4
4
  import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
5
5
  import { cn } from "@brightlocal/ui-components/lib/utils";
6
6
 
7
+ /**
8
+ * HoverCard props
9
+ */
10
+ export interface HoverCardProps extends React.ComponentProps<
11
+ typeof HoverCardPrimitive.Root
12
+ > {
13
+ /**
14
+ * Time in milliseconds to delay opening the hover card
15
+ * @default 300
16
+ */
17
+ openDelay?: number;
18
+ /**
19
+ * Time in milliseconds to delay closing the hover card
20
+ * @default 300
21
+ */
22
+ closeDelay?: number;
23
+ }
24
+
7
25
  /**
8
26
  * HoverCard - A component that displays content on hover
9
27
  *
@@ -11,14 +29,14 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
11
29
  * @see https://www.radix-ui.com/docs/primitives/components/hover-card
12
30
  *
13
31
  * Default timing:
14
- * - openDelay: 200ms (vs Radix default of 700ms)
15
- * - closeDelay: 300ms (Radix default)
32
+ * - openDelay: 300ms
33
+ * - closeDelay: 300ms
16
34
  */
17
35
  function HoverCard({
18
36
  openDelay = 300,
19
37
  closeDelay = 300,
20
38
  ...props
21
- }: React.ComponentProps<typeof HoverCardPrimitive.Root>) {
39
+ }: HoverCardProps) {
22
40
  // Note: HoverCardPrimitive.Root is a context provider that doesn't render to DOM
23
41
  // Data attributes should be placed on HoverCardContent instead
24
42
  return (
@@ -30,44 +48,66 @@ function HoverCard({
30
48
  );
31
49
  }
32
50
 
51
+ HoverCard.displayName = "HoverCard";
52
+
33
53
  export interface HoverCardTriggerProps extends React.ComponentProps<
34
54
  typeof HoverCardPrimitive.Trigger
35
55
  > {
56
+ /**
57
+ * Data hook for automated testing
58
+ */
59
+ dataHook?: string;
36
60
  /**
37
61
  * Whether the trigger is disabled
38
62
  */
39
63
  disabled?: boolean;
64
+ /**
65
+ * Optional analytics element identifier
66
+ */
67
+ trackingEl?: string;
68
+ /**
69
+ * Optional analytics label context
70
+ */
71
+ trackingLabel?: string;
40
72
  }
41
73
 
42
74
  /**
43
75
  * HoverCardTrigger - The element that triggers the hover card
44
76
  */
45
- function HoverCardTrigger({
46
- className,
47
- disabled,
48
- ...props
49
- }: HoverCardTriggerProps) {
50
- return (
77
+ const HoverCardTrigger = React.forwardRef<
78
+ React.ElementRef<typeof HoverCardPrimitive.Trigger>,
79
+ HoverCardTriggerProps
80
+ >(
81
+ (
82
+ { className, disabled, dataHook, trackingEl, trackingLabel, ...props },
83
+ ref
84
+ ) => (
51
85
  <HoverCardPrimitive.Trigger
86
+ ref={ref}
52
87
  aria-disabled={disabled}
53
88
  className={cn(
54
89
  "text-link cursor-pointer text-sm leading-5 font-medium underline",
55
90
  disabled && "pointer-events-none cursor-not-allowed opacity-50",
56
91
  className
57
92
  )}
93
+ data-hook={dataHook}
58
94
  data-slot="hover-card-trigger"
95
+ data-tracking-el={trackingEl}
96
+ data-tracking-label={trackingLabel}
59
97
  {...props}
60
98
  />
61
- );
62
- }
99
+ )
100
+ );
101
+
102
+ HoverCardTrigger.displayName = "HoverCardTrigger";
63
103
 
64
104
  export interface HoverCardContentProps extends React.ComponentPropsWithoutRef<
65
105
  typeof HoverCardPrimitive.Content
66
106
  > {
67
107
  /**
68
- * Required data-hook attribute for testing and analytics
108
+ * Data hook for automated testing
69
109
  */
70
- dataHook: string;
110
+ dataHook?: string;
71
111
  /**
72
112
  * Optional analytics element identifier
73
113
  */
@@ -116,6 +156,6 @@ const HoverCardContent = React.forwardRef<
116
156
  </HoverCardPrimitive.Portal>
117
157
  )
118
158
  );
119
- HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
159
+ HoverCardContent.displayName = "HoverCardContent";
120
160
 
121
161
  export { HoverCard, HoverCardTrigger, HoverCardContent };
@@ -5,7 +5,7 @@ import { Slot } from "@radix-ui/react-slot";
5
5
  import { cva, type VariantProps } from "class-variance-authority";
6
6
 
7
7
  import { cn } from "@brightlocal/ui-components/lib/utils";
8
- import { BaseInputElement } from "@brightlocal/ui-components/input-base";
8
+ import { Input, type InputProps } from "./input";
9
9
 
10
10
  const inputGroupVariants = cva(
11
11
  "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",
@@ -26,14 +26,31 @@ const inputGroupVariants = cva(
26
26
  interface InputGroupProps
27
27
  extends
28
28
  React.HTMLAttributes<HTMLDivElement>,
29
- VariantProps<typeof inputGroupVariants> {}
29
+ VariantProps<typeof inputGroupVariants> {
30
+ /**
31
+ * Data hook for automated testing (REQUIRED)
32
+ */
33
+ dataHook: string;
34
+ /**
35
+ * Tracking element identifier for analytics
36
+ */
37
+ trackingEl?: string;
38
+ /**
39
+ * Tracking label for analytics context
40
+ */
41
+ trackingLabel?: string;
42
+ }
30
43
 
31
44
  const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
32
- ({ className, size, ...props }, ref) => {
45
+ ({ className, size, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
33
46
  return (
34
47
  <div
35
48
  ref={ref}
36
49
  className={cn(inputGroupVariants({ size }), className)}
50
+ data-hook={dataHook}
51
+ data-slot="input-group"
52
+ data-tracking-el={trackingEl}
53
+ data-tracking-label={trackingLabel}
37
54
  {...props}
38
55
  />
39
56
  );
@@ -41,12 +58,17 @@ const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
41
58
  );
42
59
  InputGroup.displayName = "InputGroup";
43
60
 
61
+ type InputGroupInputProps = Omit<
62
+ InputProps,
63
+ "hasIcon" | "hasSecondaryIcon" | "dataHook"
64
+ >;
65
+
44
66
  const InputGroupInput = React.forwardRef<
45
67
  HTMLInputElement,
46
- React.InputHTMLAttributes<HTMLInputElement>
68
+ InputGroupInputProps
47
69
  >(({ className, ...props }, ref) => {
48
70
  return (
49
- <BaseInputElement
71
+ <Input
50
72
  ref={ref}
51
73
  className={cn(
52
74
  // Override border and focus styles since InputGroup handles them
@@ -54,25 +76,29 @@ const InputGroupInput = React.forwardRef<
54
76
  "h-full",
55
77
  className
56
78
  )}
79
+ dataHook="input-group-input"
57
80
  {...props}
58
81
  />
59
82
  );
60
83
  });
61
84
  InputGroupInput.displayName = "InputGroupInput";
62
85
 
63
- const inputGroupAddonVariants = cva("flex shrink-0 items-center", {
64
- variants: {
65
- align: {
66
- "inline-start": "",
67
- "inline-end": "ml-auto",
68
- "block-start": "self-start",
69
- "block-end": "self-end",
86
+ const inputGroupAddonVariants = cva(
87
+ "flex shrink-0 items-center text-muted-foreground",
88
+ {
89
+ variants: {
90
+ align: {
91
+ "inline-start": "",
92
+ "inline-end": "ml-auto",
93
+ "block-start": "self-start",
94
+ "block-end": "self-end",
95
+ },
70
96
  },
71
- },
72
- defaultVariants: {
73
- align: "inline-start",
74
- },
75
- });
97
+ defaultVariants: {
98
+ align: "inline-start",
99
+ },
100
+ }
101
+ );
76
102
 
77
103
  interface InputGroupAddonProps
78
104
  extends
@@ -85,6 +111,7 @@ const InputGroupAddon = React.forwardRef<HTMLDivElement, InputGroupAddonProps>(
85
111
  <div
86
112
  ref={ref}
87
113
  className={cn(inputGroupAddonVariants({ align }), className)}
114
+ data-slot="input-group-addon"
88
115
  {...props}
89
116
  />
90
117
  );
@@ -129,6 +156,11 @@ interface InputGroupButtonProps
129
156
  React.ButtonHTMLAttributes<HTMLButtonElement>,
130
157
  VariantProps<typeof inputGroupButtonVariants> {
131
158
  asChild?: boolean;
159
+ /**
160
+ * Size variant for the button.
161
+ * Options: "default" | "sm" | "lg" | "icon" | "icon-xs" | "icon-sm" | "icon-lg"
162
+ */
163
+ size?: NonNullable<VariantProps<typeof inputGroupButtonVariants>["size"]>;
132
164
  }
133
165
 
134
166
  const InputGroupButton = React.forwardRef<
@@ -140,6 +172,7 @@ const InputGroupButton = React.forwardRef<
140
172
  <Comp
141
173
  ref={ref}
142
174
  className={cn(inputGroupButtonVariants({ variant, size, className }))}
175
+ data-slot="input-group-button"
143
176
  type={asChild ? undefined : "button"}
144
177
  {...props}
145
178
  />
@@ -155,4 +188,9 @@ export {
155
188
  inputGroupVariants,
156
189
  inputGroupButtonVariants,
157
190
  };
158
- export type { InputGroupProps, InputGroupAddonProps, InputGroupButtonProps };
191
+ export type {
192
+ InputGroupProps,
193
+ InputGroupInputProps,
194
+ InputGroupAddonProps,
195
+ InputGroupButtonProps,
196
+ };
@@ -9,7 +9,7 @@ import {
9
9
  REGEXP_ONLY_CHARS,
10
10
  REGEXP_ONLY_DIGITS_AND_CHARS,
11
11
  } from "input-otp";
12
- import { MinusIcon } from "lucide-react";
12
+ import { MinusIcon } from "@brightlocal/icons";
13
13
 
14
14
  import { cn } from "@brightlocal/ui-components/lib/utils";
15
15
  import { Label } from "@brightlocal/ui-components/label";
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
- import { Eye, EyeOff } from "lucide-react";
4
+ import { Eye, EyeOff } from "@brightlocal/icons";
5
5
 
6
6
  import { Progress } from "@brightlocal/ui-components/progress";
7
7
  import { cn } from "@brightlocal/ui-components/lib/utils";
@@ -129,13 +129,12 @@ const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(
129
129
 
130
130
  return (
131
131
  <div className="w-full">
132
- <InputGroup className={className}>
132
+ <InputGroup className={className} dataHook={dataHook}>
133
133
  <InputGroupInput
134
134
  ref={ref}
135
- data-hook={dataHook}
136
- data-tracking-el={trackingEl}
137
- data-tracking-label={trackingLabel}
138
135
  id={inputId}
136
+ trackingEl={trackingEl}
137
+ trackingLabel={trackingLabel}
139
138
  type={showPassword ? "text" : "password"}
140
139
  value={value}
141
140
  onChange={handleChange}
@@ -1,220 +1,127 @@
1
1
  "use client";
2
2
 
3
3
  import * as React from "react";
4
- import { cva } from "class-variance-authority";
5
-
4
+ import { cva, type VariantProps } from "class-variance-authority";
6
5
  import { cn } from "@brightlocal/ui-components/lib/utils";
7
- import { Label } from "@brightlocal/ui-components/label";
8
- import { BaseInputElement } from "@brightlocal/ui-components/input-base";
9
-
10
- enum InputLayout {
11
- VERTICAL = "vertical",
12
- HORIZONTAL = "horizontal",
13
- }
14
-
15
- enum InputState {
16
- NORMAL = "normal",
17
- }
18
6
 
19
- const descriptionStates = cva(["text-sm mt-2 text-left"], {
20
- variants: {
21
- state: {
22
- [InputState.NORMAL]: "text-muted-foreground",
7
+ /**
8
+ * Shared input variant styles
9
+ * These can be reused across different input components
10
+ */
11
+ export const inputVariants = cva(
12
+ [
13
+ // Layout & Size
14
+ "flex w-full min-w-0 h-9",
15
+ // Appearance
16
+ "border border-input bg-background rounded-sm",
17
+ "outline-none transition-all",
18
+ // Typography
19
+ "text-sm font-sans",
20
+ "text-foreground",
21
+ "overflow-hidden text-ellipsis",
22
+ // States - Focus
23
+ "focus-visible:outline-none focus-visible:border-ring focus-visible:bg-background",
24
+ "focus-visible:shadow-default",
25
+ // States - Disabled
26
+ "disabled:cursor-not-allowed disabled:opacity-50",
27
+ // Pseudo-elements
28
+ "placeholder:text-muted-foreground",
29
+ "placeholder:overflow-hidden placeholder:text-ellipsis",
30
+ // Text input alignment - uses design token for text/sm line-height (20px)
31
+ "items-center px-3 pb-[1px] leading-5",
32
+ // Hide default browser icons for date/time inputs
33
+ "[&::-webkit-calendar-picker-indicator]:hidden",
34
+ ],
35
+ {
36
+ variants: {
37
+ hasIcon: {
38
+ true: "pl-9",
39
+ false: "",
40
+ },
41
+ hasSecondaryIcon: {
42
+ true: "pr-9",
43
+ false: "",
44
+ },
23
45
  },
24
- },
25
- defaultVariants: {
26
- state: InputState.NORMAL,
27
- },
28
- });
29
-
30
- const linkVariants = cva([
31
- "block text-sm font-normal leading-none text-muted-foreground font-sans mb-2",
32
- "text-foreground hover:text-green-900",
33
- "underline transition-colors cursor-pointer",
34
- ]);
46
+ defaultVariants: {
47
+ hasIcon: false,
48
+ hasSecondaryIcon: false,
49
+ },
50
+ }
51
+ );
35
52
 
36
- interface InputProps extends Omit<React.ComponentProps<"input">, "size"> {
53
+ /**
54
+ * Simple styled input element
55
+ *
56
+ * For inputs with label/description, compose with Field, FieldLabel, FieldDescription:
57
+ * ```tsx
58
+ * <Field>
59
+ * <FieldLabel htmlFor="email">Email</FieldLabel>
60
+ * <Input id="email" placeholder="Enter email" dataHook="email-input" />
61
+ * <FieldDescription>We'll never share your email</FieldDescription>
62
+ * </Field>
63
+ * ```
64
+ *
65
+ * For decorative icons, use InputGroup:
66
+ * ```tsx
67
+ * <InputGroup>
68
+ * <InputGroupAddon><SearchIcon /></InputGroupAddon>
69
+ * <InputGroupInput placeholder="Search..." />
70
+ * </InputGroup>
71
+ * ```
72
+ */
73
+ export interface InputProps
74
+ extends
75
+ Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">,
76
+ VariantProps<typeof inputVariants> {
37
77
  /**
38
- * Visible label for the input field.
39
- * If not provided, use aria-label for accessibility.
78
+ * Required data-hook attribute for automated testing
40
79
  */
41
- label?: string;
42
- description?: string;
43
- link?: {
44
- text: string & { length: 1 }; // Ensures non-empty string
45
- href?: string;
46
- onClick?: () => void;
47
- target?: "_blank" | "_self" | "_parent" | "_top";
48
- };
49
80
  dataHook: string;
50
- optional?: boolean;
51
- layout?: InputLayout;
81
+ /**
82
+ * Optional tracking element identifier for analytics
83
+ */
52
84
  trackingEl?: string;
85
+ /**
86
+ * Optional tracking label for analytics context
87
+ */
53
88
  trackingLabel?: string;
54
- icon?: React.ReactNode;
55
- secondaryIcon?: React.ReactNode;
56
89
  }
57
90
 
58
- const Input = React.forwardRef<HTMLInputElement, InputProps>(
91
+ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
59
92
  (
60
93
  {
61
94
  className,
62
- type,
63
- label,
64
- description,
65
- link,
66
- icon,
67
- secondaryIcon,
68
- optional,
69
- layout = InputLayout.VERTICAL,
95
+ hasIcon = false,
96
+ hasSecondaryIcon = false,
70
97
  dataHook,
71
98
  trackingEl,
72
99
  trackingLabel,
73
- id,
74
100
  ...props
75
101
  },
76
102
  ref
77
103
  ) => {
78
- const generatedId = React.useId();
79
- const inputId = id || generatedId;
80
- const descriptionId = `${inputId}-description`;
81
-
82
104
  // Check for error state from aria-invalid attribute
83
- const hasErrorStyling =
105
+ const hasError =
84
106
  props["aria-invalid"] === true || props["aria-invalid"] === "true";
85
107
 
86
- const inputElement = (
87
- <div className="relative flex items-center">
88
- {icon && (
89
- <div
90
- className={cn(
91
- "text-muted-foreground pointer-events-none absolute left-3 flex items-center",
92
- props.disabled && "opacity-50"
93
- )}
94
- >
95
- {icon}
96
- </div>
97
- )}
98
- <BaseInputElement
99
- ref={ref}
100
- aria-label={!label ? props["aria-label"] : undefined}
101
- className={cn(
102
- hasErrorStyling &&
103
- "border-destructive dark:border-destructive focus-visible:border-destructive focus-visible:shadow-destructive",
104
- type === "time" &&
105
- "appearance-none [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none",
106
- className
107
- )}
108
- data-hook={dataHook}
109
- data-tracking-el={trackingEl}
110
- data-tracking-label={trackingLabel}
111
- hasIcon={!!icon}
112
- hasSecondaryIcon={!!secondaryIcon}
113
- id={inputId}
114
- type={type}
115
- {...props}
116
- />
117
- {secondaryIcon && (
118
- <div
119
- className={cn(
120
- "text-muted-foreground pointer-events-none absolute right-3 flex items-center",
121
- props.disabled && "opacity-50"
122
- )}
123
- >
124
- {secondaryIcon}
125
- </div>
126
- )}
127
- </div>
128
- );
129
-
130
- const labelElement = label && (
131
- <Label
132
- className={cn(layout === InputLayout.VERTICAL && "mb-2")}
133
- data-hook={dataHook ? `${dataHook}-label` : undefined}
134
- htmlFor={inputId}
135
- optional={optional}
136
- >
137
- {label}
138
- </Label>
139
- );
140
-
141
- const descriptionElement = description && (
142
- <div
143
- className={cn(
144
- descriptionStates({
145
- state: InputState.NORMAL,
146
- }),
147
- layout === InputLayout.HORIZONTAL && "mt-2"
148
- )}
149
- data-hook={dataHook ? `${dataHook}-${"description"}` : undefined}
150
- id={descriptionId}
151
- >
152
- {description}
153
- </div>
154
- );
155
-
156
- const linkText = link?.text?.trim();
157
- const linkElement = linkText && (
158
- <div>
159
- {link?.href ? (
160
- <a
161
- className={linkVariants()}
162
- data-hook={dataHook ? `${dataHook}-link` : undefined}
163
- href={link.href}
164
- target={link.target}
165
- {...(link.target === "_blank" && {
166
- rel: "noopener noreferrer",
167
- })}
168
- >
169
- {linkText}
170
- </a>
171
- ) : linkText ? (
172
- <button
173
- aria-label={linkText}
174
- className={linkVariants()}
175
- data-hook={dataHook ? `${dataHook}-link` : undefined}
176
- type="button"
177
- onClick={link?.onClick}
178
- >
179
- {linkText}
180
- </button>
181
- ) : null}
182
- </div>
183
- );
184
-
185
- if (layout === InputLayout.HORIZONTAL) {
186
- return (
187
- <div className="flex items-start gap-4">
188
- <div className="flex h-9 flex-shrink-0 items-center">
189
- {labelElement}
190
- </div>
191
- <div className="flex-1">
192
- {inputElement}
193
- {descriptionElement}
194
- </div>
195
- </div>
196
- );
197
- }
198
-
199
108
  return (
200
- <div>
201
- {link ? (
202
- <div className="flex items-end justify-between">
203
- {labelElement}
204
- {linkElement}
205
- </div>
206
- ) : (
207
- labelElement
109
+ <input
110
+ ref={ref}
111
+ className={cn(
112
+ inputVariants({ hasIcon, hasSecondaryIcon }),
113
+ hasError &&
114
+ "border-destructive dark:border-destructive focus-visible:border-destructive focus-visible:shadow-destructive",
115
+ className
208
116
  )}
209
- {inputElement}
210
- {descriptionElement}
211
- </div>
117
+ data-hook={dataHook}
118
+ data-slot="input"
119
+ data-tracking-el={trackingEl}
120
+ data-tracking-label={trackingLabel}
121
+ {...props}
122
+ />
212
123
  );
213
124
  }
214
125
  );
215
126
 
216
127
  Input.displayName = "Input";
217
-
218
- export { Input, InputLayout };
219
-
220
- export type { InputProps };
@@ -18,24 +18,65 @@ const labelVariants = cva(
18
18
  );
19
19
 
20
20
  interface LabelProps extends React.ComponentProps<typeof LabelPrimitive.Root> {
21
+ /**
22
+ * Data hook for automated testing
23
+ * Used to identify component in tests and E2E automation
24
+ */
25
+ dataHook?: string;
26
+ /**
27
+ * Tracking element identifier for analytics
28
+ * Defaults to "label" if not provided
29
+ */
30
+ trackingEl?: string;
31
+ /**
32
+ * Tracking label for analytics context
33
+ * Additional context for tracking events
34
+ */
35
+ trackingLabel?: string;
36
+ /**
37
+ * Display "(optional)" suffix after label text
38
+ * @default false
39
+ */
21
40
  optional?: boolean;
22
41
  }
23
42
 
24
- function Label({ className, optional, ...props }: LabelProps) {
25
- return (
26
- <LabelPrimitive.Root
27
- className={cn(
28
- "flex items-center select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
29
- labelVariants({ optional }),
30
- className
31
- )}
32
- data-slot="label"
33
- {...props}
34
- >
35
- {props.children}
36
- </LabelPrimitive.Root>
37
- );
38
- }
43
+ const Label = React.forwardRef<
44
+ React.ComponentRef<typeof LabelPrimitive.Root>,
45
+ LabelProps
46
+ >(
47
+ (
48
+ {
49
+ className,
50
+ optional,
51
+ dataHook,
52
+ trackingEl,
53
+ trackingLabel,
54
+ children,
55
+ ...props
56
+ },
57
+ ref
58
+ ) => {
59
+ return (
60
+ <LabelPrimitive.Root
61
+ ref={ref}
62
+ className={cn(
63
+ "flex items-center select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
64
+ labelVariants({ optional }),
65
+ className
66
+ )}
67
+ data-hook={dataHook}
68
+ data-slot="label"
69
+ data-tracking-el={trackingEl || "label"}
70
+ data-tracking-label={trackingLabel}
71
+ {...props}
72
+ >
73
+ {children}
74
+ </LabelPrimitive.Root>
75
+ );
76
+ }
77
+ );
78
+
79
+ Label.displayName = "Label";
39
80
 
40
81
  export { Label, labelVariants };
41
82