@brightlocal/ui-components 0.5.0 → 1.0.1

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 (52) hide show
  1. package/dist/alert.d.ts +2 -2
  2. package/dist/blocks/sidebar.d.ts +6 -6
  3. package/dist/button.d.ts +2 -2
  4. package/dist/carousel.d.ts +1 -1
  5. package/dist/combobox.cjs +1 -1
  6. package/dist/combobox.d.ts +11 -7
  7. package/dist/combobox.d.ts.map +1 -1
  8. package/dist/combobox.js +144 -133
  9. package/dist/date-picker.d.ts +2 -2
  10. package/dist/field.cjs +1 -1
  11. package/dist/field.d.ts +11 -4
  12. package/dist/field.d.ts.map +1 -1
  13. package/dist/field.js +113 -80
  14. package/dist/index.cjs +1 -1
  15. package/dist/index.js +253 -255
  16. package/dist/input-group.d.ts +1 -1
  17. package/dist/input-otp.cjs +1 -1
  18. package/dist/input-otp.d.ts +3 -20
  19. package/dist/input-otp.d.ts.map +1 -1
  20. package/dist/input-otp.js +91 -132
  21. package/dist/input-password.d.ts +1 -1
  22. package/dist/label.d.ts +2 -3
  23. package/dist/label.d.ts.map +1 -1
  24. package/dist/radio-group.cjs +1 -1
  25. package/dist/radio-group.d.ts +3 -19
  26. package/dist/radio-group.d.ts.map +1 -1
  27. package/dist/radio-group.js +92 -120
  28. package/dist/resizable.d.ts +1 -1
  29. package/dist/select.cjs +1 -1
  30. package/dist/select.d.ts.map +1 -1
  31. package/dist/select.js +19 -19
  32. package/dist/switch.cjs +1 -1
  33. package/dist/switch.d.ts +1 -21
  34. package/dist/switch.d.ts.map +1 -1
  35. package/dist/switch.js +31 -100
  36. package/package.json +2 -2
  37. package/src/components/combobox.tsx +22 -2
  38. package/src/components/field.tsx +47 -7
  39. package/src/components/input-otp.tsx +9 -89
  40. package/src/components/label.tsx +2 -2
  41. package/src/components/radio-group.tsx +65 -129
  42. package/src/components/select.tsx +3 -2
  43. package/src/components/switch.tsx +29 -140
  44. package/dist/link.figma.d.ts +0 -2
  45. package/dist/link.figma.d.ts.map +0 -1
  46. package/dist/switch.figma.d.ts +0 -2
  47. package/dist/switch.figma.d.ts.map +0 -1
  48. package/dist/toggle.figma.d.ts +0 -2
  49. package/dist/toggle.figma.d.ts.map +0 -1
  50. package/src/components/link.figma.tsx +0 -71
  51. package/src/components/switch.figma.tsx +0 -111
  52. package/src/components/toggle.figma.tsx +0 -75
@@ -147,8 +147,9 @@ function SelectTrigger({
147
147
  const ariaLabel = props["aria-label"] || placeholder || "Select an option";
148
148
 
149
149
  const errorStyles = isError
150
- ? "border-destructive dark:border-destructive " +
151
- "focus-visible:border-destructive focus-visible:shadow-destructive"
150
+ ? "border-red-600/40 dark:border-red-400/60 " +
151
+ "focus-visible:border-destructive focus-visible:shadow-destructive " +
152
+ "data-[state=open]:border-destructive data-[state=open]:shadow-destructive"
152
153
  : "";
153
154
 
154
155
  return (
@@ -2,161 +2,50 @@
2
2
 
3
3
  import * as React from "react";
4
4
  import * as SwitchPrimitive from "@radix-ui/react-switch";
5
- import { cva, type VariantProps } from "class-variance-authority";
6
5
 
7
6
  import { cn } from "@brightlocal/ui-components/lib/utils";
8
7
 
9
- /**
10
- * Visual style variants for Switch component
11
- */
12
- export type SwitchVariant = "default" | "box";
13
-
14
- /**
15
- * Label position for switch (used in Default variant)
16
- */
17
- export type SwitchSide = "left" | "right";
18
-
19
- const switchVariants = cva(
20
- [
21
- "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:focus-visible:border-neutral-500 dark:data-[state=unchecked]:bg-input/80",
22
- "inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none focus-visible:shadow-default",
23
- "disabled:cursor-not-allowed disabled:opacity-50",
24
- "pl-[1px]",
25
- ],
26
- {
27
- variants: {
28
- variant: {
29
- default: [],
30
- box: [],
31
- },
32
- },
33
- defaultVariants: {
34
- variant: "default",
35
- },
36
- }
37
- );
38
-
39
8
  interface SwitchProps
40
- extends
41
- Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, "asChild">,
42
- VariantProps<typeof switchVariants> {
9
+ extends Omit<React.ComponentProps<typeof SwitchPrimitive.Root>, "asChild"> {
43
10
  /** Data hook for automated testing (REQUIRED) */
44
11
  dataHook: string;
45
12
  /** Tracking element identifier for analytics */
46
13
  trackingEl?: string;
47
14
  /** Tracking label for analytics context */
48
15
  trackingLabel?: string;
49
- /** Visual style variant */
50
- variant?: SwitchVariant;
51
- /** Label text for the switch */
52
- label?: string;
53
- /** Description text (visible in Box variant) */
54
- description?: string;
55
- /** Label position - left or right (for Default variant) */
56
- side?: SwitchSide;
57
16
  }
58
17
 
59
18
  const Switch = React.forwardRef<
60
19
  React.ElementRef<typeof SwitchPrimitive.Root>,
61
20
  SwitchProps
62
- >(
63
- (
64
- {
65
- className,
66
- variant = "default",
67
- dataHook,
68
- trackingEl,
69
- trackingLabel,
70
- label,
71
- description,
72
- side = "right",
73
- ...props
74
- },
75
- ref
76
- ) => {
77
- const switchElement = (
78
- <SwitchPrimitive.Root
79
- ref={ref}
80
- className={cn(switchVariants({ variant }), className)}
81
- data-hook={dataHook}
82
- data-slot="switch"
83
- data-tracking-el={trackingEl || `switch-${variant}`}
84
- data-tracking-label={trackingLabel}
85
- {...props}
86
- >
87
- <SwitchPrimitive.Thumb
88
- className={cn(
89
- "bg-background",
90
- "pointer-events-none block size-4 rounded-full ring-0 transition-transform",
91
- "data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
92
- )}
93
- data-slot="switch-thumb"
94
- />
95
- </SwitchPrimitive.Root>
96
- );
97
-
98
- // Default variant: inline switch with side label
99
- if (variant === "default") {
100
- return (
101
- <div
102
- className={cn(
103
- "flex items-center gap-2",
104
- side === "left" && "flex-row-reverse"
105
- )}
106
- >
107
- {switchElement}
108
- {label && (
109
- <label
110
- className="cursor-pointer text-sm leading-none font-medium peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
111
- htmlFor={props.id}
112
- >
113
- {label}
114
- </label>
115
- )}
116
- </div>
117
- );
118
- }
119
-
120
- // Box variant: switch in bordered container with label and description
121
- if (variant === "box") {
122
- const textContent = (
123
- <div className="flex flex-col gap-2">
124
- {label && (
125
- <label
126
- className="cursor-pointer text-sm leading-none font-medium"
127
- htmlFor={props.id}
128
- >
129
- {label}
130
- </label>
131
- )}
132
- {description && (
133
- <p className="text-muted-foreground text-sm leading-normal">
134
- {description}
135
- </p>
136
- )}
137
- </div>
138
- );
139
-
140
- return (
141
- <div className="border-border flex items-center justify-between gap-4 rounded-lg border p-4">
142
- {side === "left" ? (
143
- <>
144
- {switchElement}
145
- {textContent}
146
- </>
147
- ) : (
148
- <>
149
- {textContent}
150
- {switchElement}
151
- </>
152
- )}
153
- </div>
154
- );
155
- }
156
-
157
- return switchElement;
158
- }
159
- );
21
+ >(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
22
+ return (
23
+ <SwitchPrimitive.Root
24
+ ref={ref}
25
+ className={cn(
26
+ "peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring dark:focus-visible:border-neutral-500 dark:data-[state=unchecked]:bg-input/80",
27
+ "inline-flex h-5 w-9 shrink-0 items-center rounded-full border-1 border-transparent shadow-xs transition-[background-color,border-color,box-shadow] outline-none focus-visible:shadow-default",
28
+ "disabled:cursor-not-allowed disabled:opacity-50",
29
+ "pl-[1px]",
30
+ className
31
+ )}
32
+ data-hook={dataHook}
33
+ data-slot="switch"
34
+ data-tracking-el={trackingEl || "switch"}
35
+ data-tracking-label={trackingLabel}
36
+ {...props}
37
+ >
38
+ <SwitchPrimitive.Thumb
39
+ className={cn(
40
+ "bg-background",
41
+ "pointer-events-none block size-4 rounded-full ring-0 transition-transform",
42
+ "data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0"
43
+ )}
44
+ data-slot="switch-thumb"
45
+ />
46
+ </SwitchPrimitive.Root>
47
+ );
48
+ });
160
49
 
161
50
  Switch.displayName = "Switch";
162
51
 
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=link.figma.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"link.figma.d.ts","sourceRoot":"","sources":["../../src/components/link.figma.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=switch.figma.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"switch.figma.d.ts","sourceRoot":"","sources":["../../src/components/switch.figma.tsx"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=toggle.figma.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"toggle.figma.d.ts","sourceRoot":"","sources":["../../src/components/toggle.figma.tsx"],"names":[],"mappings":""}
@@ -1,71 +0,0 @@
1
- import { figma } from "@figma/code-connect";
2
- import { Link } from "@brightlocal/ui-components/link";
3
-
4
- /**
5
- * Figma Code Connect mapping for Link component
6
- *
7
- * File: Design System - UI Components
8
- * Last Updated: 2025-10-29
9
- *
10
- * The Link component has a single "default" variant with multiple states:
11
- * - Default state (normal interactive)
12
- * - Hover state (mouse over)
13
- * - Active state (while clicking)
14
- */
15
-
16
- // Link Component - Default State
17
- figma.connect(
18
- Link,
19
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---UI-Components?node-id=23024-2865&m=dev",
20
- {
21
- imports: ["import { Link } from '@brightlocal/ui-components/link'"],
22
- variant: { State: "Default" },
23
- props: {
24
- text: figma.string("Link Text"),
25
- href: figma.string("URL"),
26
- },
27
- example: ({ text, href }) => (
28
- <Link dataHook="link" href={href || "#"}>
29
- {text || "Link"}
30
- </Link>
31
- ),
32
- }
33
- );
34
-
35
- // Link Component - Hover State
36
- figma.connect(
37
- Link,
38
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---UI-Components?node-id=23024-2865&m=dev",
39
- {
40
- imports: ["import { Link } from '@brightlocal/ui-components/link'"],
41
- variant: { State: "Hover" },
42
- props: {
43
- text: figma.string("Link Text"),
44
- href: figma.string("URL"),
45
- },
46
- example: ({ text, href }) => (
47
- <Link dataHook="link" href={href || "#"}>
48
- {text || "Link"}
49
- </Link>
50
- ),
51
- }
52
- );
53
-
54
- // Link Component - Active State
55
- figma.connect(
56
- Link,
57
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---UI-Components?node-id=23024-2865&m=dev",
58
- {
59
- imports: ["import { Link } from '@brightlocal/ui-components/link'"],
60
- variant: { State: "Active" },
61
- props: {
62
- text: figma.string("Link Text"),
63
- href: figma.string("URL"),
64
- },
65
- example: ({ text, href }) => (
66
- <Link dataHook="link" href={href || "#"}>
67
- {text || "Link"}
68
- </Link>
69
- ),
70
- }
71
- );
@@ -1,111 +0,0 @@
1
- import * as React from "react";
2
- import { figma } from "@figma/code-connect";
3
- import { Switch } from "@brightlocal/ui-components/switch";
4
-
5
- /**
6
- * Figma Code Connect mapping for Switch component
7
- *
8
- * File: Design System - Components
9
- * Component URL: https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---Components?node-id=60-438
10
- * Last Updated: 2025-11-05
11
- */
12
-
13
- // Default variant - label on right side
14
- figma.connect(
15
- Switch,
16
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---Components?node-id=428-1425",
17
- {
18
- imports: [
19
- "import { Switch, SwitchVariant, SwitchSide } from '@brightlocal/ui-components/switch'",
20
- ],
21
- variant: { Type: "Default", Side: "Right" },
22
- props: {
23
- checked: figma.boolean("Active"),
24
- },
25
- example: ({ checked }) => (
26
- <Switch
27
- checked={checked}
28
- dataHook="switch-default"
29
- id="switch"
30
- label="Switch Text"
31
- side="right"
32
- variant="default"
33
- />
34
- ),
35
- }
36
- );
37
-
38
- // Default variant - label on left side
39
- figma.connect(
40
- Switch,
41
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---Components?node-id=17118-18360",
42
- {
43
- imports: [
44
- "import { Switch, SwitchVariant, SwitchSide } from '@brightlocal/ui-components/switch'",
45
- ],
46
- variant: { Type: "Default", Side: "Left" },
47
- props: {
48
- checked: figma.boolean("Active"),
49
- },
50
- example: ({ checked }) => (
51
- <Switch
52
- checked={checked}
53
- dataHook="switch-default-left"
54
- id="switch-left"
55
- label="Switch Text"
56
- side="left"
57
- variant="default"
58
- />
59
- ),
60
- }
61
- );
62
-
63
- // Box variant - label on left side
64
- figma.connect(
65
- Switch,
66
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---Components?node-id=17119-18448",
67
- {
68
- imports: [
69
- "import { Switch, SwitchVariant } from '@brightlocal/ui-components/switch'",
70
- ],
71
- variant: { Type: "Box", Side: "Left" },
72
- props: {
73
- checked: figma.boolean("Active"),
74
- },
75
- example: ({ checked }) => (
76
- <Switch
77
- checked={checked}
78
- dataHook="switch-box"
79
- description="This is a switch description."
80
- id="switch-box"
81
- label="Switch Text"
82
- variant="box"
83
- />
84
- ),
85
- }
86
- );
87
-
88
- // Box variant - label on right side
89
- figma.connect(
90
- Switch,
91
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---Components?node-id=17119-18455",
92
- {
93
- imports: [
94
- "import { Switch, SwitchVariant } from '@brightlocal/ui-components/switch'",
95
- ],
96
- variant: { Type: "Box", Side: "Right" },
97
- props: {
98
- checked: figma.boolean("Active"),
99
- },
100
- example: ({ checked }) => (
101
- <Switch
102
- checked={checked}
103
- dataHook="switch-box-right"
104
- description="This is a switch description."
105
- id="switch-box-right"
106
- label="Switch Text"
107
- variant="box"
108
- />
109
- ),
110
- }
111
- );
@@ -1,75 +0,0 @@
1
- import * as React from "react";
2
- import { figma } from "@figma/code-connect";
3
- import { Toggle } from "@brightlocal/ui-components/toggle";
4
-
5
- /**
6
- * Figma Code Connect mapping for Toggle component
7
- *
8
- * File: Design System - UI Components
9
- * Component URL: https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---UI-Components?node-id=17429-129988
10
- * Last Updated: 2025-11-04
11
- */
12
-
13
- figma.connect(
14
- Toggle,
15
- "https://www.figma.com/design/p3krmC8DBUgqpbq6cLzaal/Design-System---UI-Components?node-id=17429-129988&m=dev",
16
- {
17
- imports: ["import { Toggle } from '@brightlocal/ui-components/toggle'"],
18
- props: {
19
- // Map Figma variant property to code string
20
- variant: figma.enum("Variant", {
21
- Default: "default",
22
- Outline: "outline",
23
- }),
24
- // Map Figma size property to code string
25
- size: figma.enum("Size", {
26
- sm: "sm",
27
- default: "default",
28
- lg: "lg",
29
- }),
30
- // Map Figma properties
31
- disabled: figma.boolean("Disabled"),
32
- pressed: figma.boolean("Pressed"),
33
- showText: figma.boolean("Show Text"),
34
- showIcon: figma.boolean("Show Icon"),
35
- text: figma.string("Text"),
36
- // Tracking and testing attributes
37
- dataHook: figma.string("Data Hook"),
38
- trackingEl: figma.string("Tracking El"),
39
- trackingLabel: figma.string("Tracking Label"),
40
- ariaLabel: figma.string("ARIA Label"),
41
- },
42
- example: (props: {
43
- variant?: "default" | "outline";
44
- size?: "default" | "sm" | "lg";
45
- disabled?: boolean;
46
- pressed?: boolean;
47
- showText?: boolean;
48
- showIcon?: boolean;
49
- text?: string;
50
- dataHook?: string;
51
- trackingEl?: string;
52
- trackingLabel?: string;
53
- ariaLabel?: string;
54
- }) => {
55
- // Render icon if showIcon is true (using Bold as placeholder)
56
- const icon = props.showIcon ? <span>B</span> : null;
57
-
58
- return (
59
- <Toggle
60
- ariaLabel={props.ariaLabel}
61
- dataHook={props.dataHook || "toggle"}
62
- disabled={props.disabled}
63
- pressed={props.pressed}
64
- size={props.size || "default"}
65
- trackingEl={props.trackingEl}
66
- trackingLabel={props.trackingLabel}
67
- variant={props.variant || "default"}
68
- >
69
- {icon}
70
- {props.showText && (props.text || "Toggle")}
71
- </Toggle>
72
- );
73
- },
74
- }
75
- );