@brightlocal/ui-components 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +1 -1
- package/dist/alert.cjs +1 -1
- package/dist/alert.js +1 -1
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +1 -1
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +37 -306
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +392 -489
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +4 -1
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +33 -33
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +5 -18
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +21 -23
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +19 -19
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +75 -67
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +241 -194
- package/dist/command.cjs +1 -1
- package/dist/command.js +1 -1
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.js +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +1 -1
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.js +1 -1
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +3 -0
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +5 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +361 -366
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +5 -0
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +47 -39
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.d.ts +6 -0
- package/dist/input-otp.d.ts.map +1 -1
- package/dist/input-otp.js +79 -76
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +4 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +32 -31
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +4 -0
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +26 -24
- package/dist/link.cjs +1 -1
- package/dist/link.js +1 -1
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +6 -4
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +17 -20
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +3 -0
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +31 -30
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts +6 -54
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +73 -84
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +8 -10
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +78 -86
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.d.ts +10 -23
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/radio-group.js +47 -55
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +19 -28
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +24 -40
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +3 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +57 -56
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +4 -4
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +19 -21
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +5 -10
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +24 -26
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +17 -20
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +42 -45
- package/dist/switch.cjs +1 -1
- package/dist/switch.d.ts +2 -12
- package/dist/switch.d.ts.map +1 -1
- package/dist/switch.js +37 -41
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +16 -12
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +56 -58
- package/dist/tabs.d.ts +27 -3
- package/dist/tabs.d.ts.map +1 -1
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.d.ts +4 -0
- package/dist/textarea.d.ts.map +1 -1
- package/dist/textarea.js +19 -18
- package/dist/toggle-group.cjs +1 -1
- package/dist/toggle-group.d.ts +57 -7
- package/dist/toggle-group.d.ts.map +1 -1
- package/dist/toggle-group.js +60 -67
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.d.ts +12 -26
- package/dist/toggle.d.ts.map +1 -1
- package/dist/toggle.js +18 -22
- package/package.json +2 -2
- package/src/blocks/data-table.tsx +1 -1
- package/src/blocks/sidebar.tsx +157 -532
- package/src/components/accordion.tsx +1 -1
- package/src/components/alert.tsx +1 -1
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +1 -1
- package/src/components/calendar.tsx +6 -4
- package/src/components/centred-layout.tsx +11 -24
- package/src/components/checkbox.tsx +5 -6
- package/src/components/combobox.tsx +481 -301
- package/src/components/command.tsx +1 -1
- package/src/components/context-menu.tsx +1 -1
- package/src/components/date-picker.tsx +1 -1
- package/src/components/dialog.tsx +1 -1
- package/src/components/dropdown-menu.tsx +1 -1
- package/src/components/field.tsx +2 -0
- package/src/components/input-group.tsx +14 -2
- package/src/components/input-otp.tsx +17 -2
- package/src/components/input-password.tsx +7 -2
- package/src/components/input.tsx +11 -3
- package/src/components/link.tsx +1 -1
- package/src/components/logo.tsx +10 -8
- package/src/components/menubar.tsx +3 -1
- package/src/components/navigation-menu.tsx +37 -99
- package/src/components/pagination.tsx +13 -19
- package/src/components/radio-group.tsx +28 -38
- package/src/components/resizable.tsx +5 -43
- package/src/components/select.tsx +8 -3
- package/src/components/separator.tsx +5 -5
- package/src/components/sheet.tsx +6 -11
- package/src/components/sonner.tsx +24 -27
- package/src/components/switch.figma.tsx +7 -11
- package/src/components/switch.tsx +9 -19
- package/src/components/table.tsx +23 -18
- package/src/components/tabs.tsx +27 -3
- package/src/components/textarea.tsx +12 -5
- package/src/components/toggle-group.tsx +115 -86
- package/src/components/toggle.figma.tsx +13 -19
- package/src/components/toggle.tsx +32 -48
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Command as CommandPrimitive } from "cmdk";
|
|
5
|
-
import { CheckIcon, SearchIcon, XIcon } from "
|
|
5
|
+
import { CheckIcon, SearchIcon, XIcon } from "@brightlocal/icons";
|
|
6
6
|
|
|
7
7
|
import { Button } from "@brightlocal/ui-components/button";
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
4
|
-
import { Check, ChevronRight, Circle } from "
|
|
4
|
+
import { Check, ChevronRight, Circle } from "@brightlocal/icons";
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { format } from "date-fns";
|
|
5
|
-
import { Calendar as CalendarIcon } from "
|
|
5
|
+
import { Calendar as CalendarIcon } from "@brightlocal/icons";
|
|
6
6
|
import type { DateRange } from "react-day-picker";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
5
|
-
import { Check, ChevronRight, Circle, ChevronsUpDown } from "
|
|
5
|
+
import { Check, ChevronRight, Circle, ChevronsUpDown } from "@brightlocal/icons";
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
package/src/components/field.tsx
CHANGED
|
@@ -16,9 +16,17 @@ const inputGroupVariants = cva(
|
|
|
16
16
|
sm: "h-8",
|
|
17
17
|
lg: "h-10",
|
|
18
18
|
},
|
|
19
|
+
error: {
|
|
20
|
+
true: [
|
|
21
|
+
"border-red-600/40 dark:border-red-400/60",
|
|
22
|
+
"has-[:focus-visible]:border-destructive has-[:focus-visible]:shadow-destructive",
|
|
23
|
+
],
|
|
24
|
+
false: "",
|
|
25
|
+
},
|
|
19
26
|
},
|
|
20
27
|
defaultVariants: {
|
|
21
28
|
size: "default",
|
|
29
|
+
error: false,
|
|
22
30
|
},
|
|
23
31
|
}
|
|
24
32
|
);
|
|
@@ -39,14 +47,18 @@ interface InputGroupProps
|
|
|
39
47
|
* Tracking label for analytics context
|
|
40
48
|
*/
|
|
41
49
|
trackingLabel?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether the input group has an error state
|
|
52
|
+
*/
|
|
53
|
+
error?: boolean;
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
const InputGroup = React.forwardRef<HTMLDivElement, InputGroupProps>(
|
|
45
|
-
({ className, size, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
57
|
+
({ className, size, error, dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
46
58
|
return (
|
|
47
59
|
<div
|
|
48
60
|
ref={ref}
|
|
49
|
-
className={cn(inputGroupVariants({ size }), className)}
|
|
61
|
+
className={cn(inputGroupVariants({ size, error }), className)}
|
|
50
62
|
data-hook={dataHook}
|
|
51
63
|
data-slot="input-group"
|
|
52
64
|
data-tracking-el={trackingEl}
|
|
@@ -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 "
|
|
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";
|
|
@@ -19,11 +19,13 @@ type InputOTPProps = React.ComponentProps<typeof OTPInput> & {
|
|
|
19
19
|
trackingEl?: string;
|
|
20
20
|
dataHook: string;
|
|
21
21
|
trackingLabel?: string;
|
|
22
|
+
/** Whether the input has an error state */
|
|
23
|
+
error?: boolean;
|
|
22
24
|
};
|
|
23
25
|
|
|
24
26
|
const InputOTP = React.forwardRef<HTMLInputElement, InputOTPProps>(
|
|
25
27
|
(
|
|
26
|
-
{ trackingEl, trackingLabel, dataHook, containerClassName, ...props },
|
|
28
|
+
{ trackingEl, trackingLabel, dataHook, containerClassName, error, ...props },
|
|
27
29
|
ref
|
|
28
30
|
) => {
|
|
29
31
|
// Ensure we always have an accessible label if none is provided
|
|
@@ -32,9 +34,16 @@ const InputOTP = React.forwardRef<HTMLInputElement, InputOTPProps>(
|
|
|
32
34
|
? "One-time password"
|
|
33
35
|
: props["aria-label"];
|
|
34
36
|
|
|
37
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
38
|
+
const hasError =
|
|
39
|
+
error ||
|
|
40
|
+
props["aria-invalid"] === true ||
|
|
41
|
+
props["aria-invalid"] === "true";
|
|
42
|
+
|
|
35
43
|
return (
|
|
36
44
|
<OTPInput
|
|
37
45
|
ref={ref}
|
|
46
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
38
47
|
aria-label={effectiveAriaLabel}
|
|
39
48
|
className="disabled:cursor-not-allowed"
|
|
40
49
|
containerClassName={cn(
|
|
@@ -132,6 +141,8 @@ interface InputOTPFieldProps {
|
|
|
132
141
|
disabled?: boolean;
|
|
133
142
|
className?: string;
|
|
134
143
|
"aria-label"?: string;
|
|
144
|
+
/** Whether the input has an error state */
|
|
145
|
+
error?: boolean;
|
|
135
146
|
}
|
|
136
147
|
|
|
137
148
|
const InputOTPField = React.forwardRef<HTMLInputElement, InputOTPFieldProps>(
|
|
@@ -144,6 +155,7 @@ const InputOTPField = React.forwardRef<HTMLInputElement, InputOTPFieldProps>(
|
|
|
144
155
|
trackingLabel,
|
|
145
156
|
containerClassName,
|
|
146
157
|
children,
|
|
158
|
+
error,
|
|
147
159
|
"aria-label": ariaLabel,
|
|
148
160
|
...props
|
|
149
161
|
},
|
|
@@ -172,6 +184,7 @@ const InputOTPField = React.forwardRef<HTMLInputElement, InputOTPFieldProps>(
|
|
|
172
184
|
aria-label={effectiveAriaLabel}
|
|
173
185
|
containerClassName={containerClassName}
|
|
174
186
|
dataHook={dataHook}
|
|
187
|
+
error={error}
|
|
175
188
|
id={label ? inputId : undefined}
|
|
176
189
|
trackingEl={trackingEl}
|
|
177
190
|
trackingLabel={trackingLabel}
|
|
@@ -198,6 +211,8 @@ interface VariantInputOTPProps extends Omit<
|
|
|
198
211
|
autoFocus?: boolean;
|
|
199
212
|
pattern?: string;
|
|
200
213
|
"aria-label"?: string;
|
|
214
|
+
/** Whether the input has an error state */
|
|
215
|
+
error?: boolean;
|
|
201
216
|
}
|
|
202
217
|
|
|
203
218
|
const InputOTPDigitsOnly = React.forwardRef<
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { Eye, EyeOff } from "
|
|
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";
|
|
@@ -52,6 +52,10 @@ interface InputPasswordProps extends Omit<
|
|
|
52
52
|
* Optional tracking label
|
|
53
53
|
*/
|
|
54
54
|
trackingLabel?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the input has an error state
|
|
57
|
+
*/
|
|
58
|
+
error?: boolean;
|
|
55
59
|
}
|
|
56
60
|
|
|
57
61
|
/**
|
|
@@ -93,6 +97,7 @@ const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(
|
|
|
93
97
|
onChange,
|
|
94
98
|
value,
|
|
95
99
|
id,
|
|
100
|
+
error,
|
|
96
101
|
...props
|
|
97
102
|
},
|
|
98
103
|
ref
|
|
@@ -129,7 +134,7 @@ const InputPassword = React.forwardRef<HTMLInputElement, InputPasswordProps>(
|
|
|
129
134
|
|
|
130
135
|
return (
|
|
131
136
|
<div className="w-full">
|
|
132
|
-
<InputGroup className={className} dataHook={dataHook}>
|
|
137
|
+
<InputGroup className={className} dataHook={dataHook} error={error}>
|
|
133
138
|
<InputGroupInput
|
|
134
139
|
ref={ref}
|
|
135
140
|
id={inputId}
|
package/src/components/input.tsx
CHANGED
|
@@ -78,6 +78,10 @@ export interface InputProps
|
|
|
78
78
|
* Required data-hook attribute for automated testing
|
|
79
79
|
*/
|
|
80
80
|
dataHook: string;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the input has an error state
|
|
83
|
+
*/
|
|
84
|
+
error?: boolean;
|
|
81
85
|
/**
|
|
82
86
|
* Optional tracking element identifier for analytics
|
|
83
87
|
*/
|
|
@@ -95,23 +99,27 @@ export const Input = React.forwardRef<HTMLInputElement, InputProps>(
|
|
|
95
99
|
hasIcon = false,
|
|
96
100
|
hasSecondaryIcon = false,
|
|
97
101
|
dataHook,
|
|
102
|
+
error,
|
|
98
103
|
trackingEl,
|
|
99
104
|
trackingLabel,
|
|
100
105
|
...props
|
|
101
106
|
},
|
|
102
107
|
ref
|
|
103
108
|
) => {
|
|
104
|
-
//
|
|
109
|
+
// Support both error prop and aria-invalid for backwards compatibility
|
|
105
110
|
const hasError =
|
|
106
|
-
|
|
111
|
+
error ||
|
|
112
|
+
props["aria-invalid"] === true ||
|
|
113
|
+
props["aria-invalid"] === "true";
|
|
107
114
|
|
|
108
115
|
return (
|
|
109
116
|
<input
|
|
110
117
|
ref={ref}
|
|
118
|
+
aria-invalid={hasError ? "true" : undefined}
|
|
111
119
|
className={cn(
|
|
112
120
|
inputVariants({ hasIcon, hasSecondaryIcon }),
|
|
113
121
|
hasError &&
|
|
114
|
-
"border-
|
|
122
|
+
"border-red-600/40 dark:border-red-400/60 focus-visible:border-destructive focus-visible:shadow-destructive",
|
|
115
123
|
className
|
|
116
124
|
)}
|
|
117
125
|
data-hook={dataHook}
|
package/src/components/link.tsx
CHANGED
package/src/components/logo.tsx
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { cva, VariantProps } from "class-variance-authority";
|
|
2
2
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Visual style variants for the Logo component.
|
|
6
|
+
* - `logotype`: Full BrightLocal logo with text
|
|
7
|
+
* - `mark`: Icon-only logo mark
|
|
8
|
+
*/
|
|
9
|
+
export type LogoVariant = "logotype" | "mark";
|
|
8
10
|
|
|
9
|
-
const logoVariants = cva("inline-flex [&_path]:fill-primary", {
|
|
11
|
+
const logoVariants = cva("inline-flex [&_path]:fill-brand-primary-foreground", {
|
|
10
12
|
variants: {
|
|
11
13
|
variant: {
|
|
12
14
|
logotype: "h-6",
|
|
@@ -14,7 +16,7 @@ const logoVariants = cva("inline-flex [&_path]:fill-primary", {
|
|
|
14
16
|
},
|
|
15
17
|
},
|
|
16
18
|
defaultVariants: {
|
|
17
|
-
variant:
|
|
19
|
+
variant: "logotype",
|
|
18
20
|
},
|
|
19
21
|
});
|
|
20
22
|
|
|
@@ -55,7 +57,7 @@ function Logo({
|
|
|
55
57
|
role="img"
|
|
56
58
|
{...props}
|
|
57
59
|
>
|
|
58
|
-
{variant ===
|
|
60
|
+
{variant === "logotype" && (
|
|
59
61
|
<svg
|
|
60
62
|
fill="none"
|
|
61
63
|
height="30"
|
|
@@ -73,7 +75,7 @@ function Logo({
|
|
|
73
75
|
</defs>
|
|
74
76
|
</svg>
|
|
75
77
|
)}
|
|
76
|
-
{variant ===
|
|
78
|
+
{variant === "mark" && (
|
|
77
79
|
<svg
|
|
78
80
|
fill="none"
|
|
79
81
|
height="21"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
|
4
|
-
import { Check, ChevronRight, Circle } from "
|
|
4
|
+
import { Check, ChevronRight, Circle } from "@brightlocal/icons";
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
@@ -53,6 +53,8 @@ function Menubar({
|
|
|
53
53
|
);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
Menubar.displayName = "Menubar";
|
|
57
|
+
|
|
56
58
|
/**
|
|
57
59
|
* MenubarMenu - Individual menu within the menubar
|
|
58
60
|
*/
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";
|
|
5
|
-
import { ChevronDown } from "
|
|
5
|
+
import { ChevronDown } from "@brightlocal/icons";
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
|
|
@@ -78,25 +78,9 @@ NavigationMenuItem.displayName = "NavigationMenuItem";
|
|
|
78
78
|
/**
|
|
79
79
|
* Props for NavigationMenuTrigger component
|
|
80
80
|
*/
|
|
81
|
-
|
|
81
|
+
type NavigationMenuTriggerProps = React.ComponentPropsWithoutRef<
|
|
82
82
|
typeof NavigationMenuPrimitive.Trigger
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Data hook for automated testing (REQUIRED)
|
|
86
|
-
* Used to identify component in tests and E2E automation
|
|
87
|
-
*/
|
|
88
|
-
dataHook: string;
|
|
89
|
-
/**
|
|
90
|
-
* Tracking element identifier for analytics
|
|
91
|
-
* Defaults to component name if not provided
|
|
92
|
-
*/
|
|
93
|
-
trackingEl?: string;
|
|
94
|
-
/**
|
|
95
|
-
* Tracking label for analytics context
|
|
96
|
-
* Additional context for tracking events
|
|
97
|
-
*/
|
|
98
|
-
trackingLabel?: string;
|
|
99
|
-
}
|
|
83
|
+
>;
|
|
100
84
|
|
|
101
85
|
/**
|
|
102
86
|
* Trigger button that opens a dropdown menu
|
|
@@ -105,67 +89,43 @@ interface NavigationMenuTriggerProps extends React.ComponentPropsWithoutRef<
|
|
|
105
89
|
const NavigationMenuTrigger = React.forwardRef<
|
|
106
90
|
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
|
107
91
|
NavigationMenuTriggerProps
|
|
108
|
-
>(
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
{children}
|
|
137
|
-
<ChevronDown
|
|
138
|
-
aria-hidden="true"
|
|
139
|
-
className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
|
|
140
|
-
/>
|
|
141
|
-
</NavigationMenuPrimitive.Trigger>
|
|
142
|
-
)
|
|
143
|
-
);
|
|
92
|
+
>(({ className, children, ...props }, ref) => (
|
|
93
|
+
<NavigationMenuPrimitive.Trigger
|
|
94
|
+
ref={ref}
|
|
95
|
+
className={cn(
|
|
96
|
+
[
|
|
97
|
+
"group inline-flex h-9 w-max items-center justify-center gap-1",
|
|
98
|
+
"rounded-md px-4 py-2",
|
|
99
|
+
"text-sm font-medium",
|
|
100
|
+
"text-foreground",
|
|
101
|
+
"transition-colors",
|
|
102
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
103
|
+
"focus:bg-accent focus:text-accent-foreground",
|
|
104
|
+
"focus-visible:bg-accent focus-visible:ring-ring focus-visible:shadow-[0_0_0_4px_rgba(163,163,163,0.1)] focus-visible:ring-1 focus-visible:outline-none",
|
|
105
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
106
|
+
"data-[state=open]:bg-accent/50",
|
|
107
|
+
],
|
|
108
|
+
className
|
|
109
|
+
)}
|
|
110
|
+
data-slot="navigation-menu-trigger"
|
|
111
|
+
{...props}
|
|
112
|
+
>
|
|
113
|
+
{children}
|
|
114
|
+
<ChevronDown
|
|
115
|
+
aria-hidden="true"
|
|
116
|
+
className="relative top-[1px] ml-1 h-3 w-3 transition duration-300 group-data-[state=open]:rotate-180"
|
|
117
|
+
/>
|
|
118
|
+
</NavigationMenuPrimitive.Trigger>
|
|
119
|
+
));
|
|
144
120
|
|
|
145
121
|
NavigationMenuTrigger.displayName = "NavigationMenuTrigger";
|
|
146
122
|
|
|
147
123
|
/**
|
|
148
124
|
* Props for NavigationMenuContent component
|
|
149
125
|
*/
|
|
150
|
-
|
|
126
|
+
type NavigationMenuContentProps = React.ComponentPropsWithoutRef<
|
|
151
127
|
typeof NavigationMenuPrimitive.Content
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Data hook for automated testing (REQUIRED)
|
|
155
|
-
* Used to identify component in tests and E2E automation
|
|
156
|
-
*/
|
|
157
|
-
dataHook: string;
|
|
158
|
-
/**
|
|
159
|
-
* Tracking element identifier for analytics
|
|
160
|
-
* Defaults to component name if not provided
|
|
161
|
-
*/
|
|
162
|
-
trackingEl?: string;
|
|
163
|
-
/**
|
|
164
|
-
* Tracking label for analytics context
|
|
165
|
-
* Additional context for tracking events
|
|
166
|
-
*/
|
|
167
|
-
trackingLabel?: string;
|
|
168
|
-
}
|
|
128
|
+
>;
|
|
169
129
|
|
|
170
130
|
/**
|
|
171
131
|
* Dropdown content container
|
|
@@ -174,7 +134,7 @@ interface NavigationMenuContentProps extends React.ComponentPropsWithoutRef<
|
|
|
174
134
|
const NavigationMenuContent = React.forwardRef<
|
|
175
135
|
React.ElementRef<typeof NavigationMenuPrimitive.Content>,
|
|
176
136
|
NavigationMenuContentProps
|
|
177
|
-
>(({ className,
|
|
137
|
+
>(({ className, ...props }, ref) => (
|
|
178
138
|
<NavigationMenuPrimitive.Content
|
|
179
139
|
ref={ref}
|
|
180
140
|
className={cn(
|
|
@@ -187,10 +147,7 @@ const NavigationMenuContent = React.forwardRef<
|
|
|
187
147
|
],
|
|
188
148
|
className
|
|
189
149
|
)}
|
|
190
|
-
data-hook={dataHook}
|
|
191
150
|
data-slot="navigation-menu-content"
|
|
192
|
-
data-tracking-el={trackingEl || "navigation-menu-content"}
|
|
193
|
-
data-tracking-label={trackingLabel}
|
|
194
151
|
{...props}
|
|
195
152
|
/>
|
|
196
153
|
));
|
|
@@ -200,25 +157,9 @@ NavigationMenuContent.displayName = "NavigationMenuContent";
|
|
|
200
157
|
/**
|
|
201
158
|
* Props for NavigationMenuLink component
|
|
202
159
|
*/
|
|
203
|
-
|
|
160
|
+
type NavigationMenuLinkProps = React.ComponentPropsWithoutRef<
|
|
204
161
|
typeof NavigationMenuPrimitive.Link
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Data hook for automated testing (REQUIRED)
|
|
208
|
-
* Used to identify component in tests and E2E automation
|
|
209
|
-
*/
|
|
210
|
-
dataHook: string;
|
|
211
|
-
/**
|
|
212
|
-
* Tracking element identifier for analytics
|
|
213
|
-
* Defaults to component name if not provided
|
|
214
|
-
*/
|
|
215
|
-
trackingEl?: string;
|
|
216
|
-
/**
|
|
217
|
-
* Tracking label for analytics context
|
|
218
|
-
* Additional context for tracking events
|
|
219
|
-
*/
|
|
220
|
-
trackingLabel?: string;
|
|
221
|
-
}
|
|
162
|
+
>;
|
|
222
163
|
|
|
223
164
|
/**
|
|
224
165
|
* Navigation link within the menu
|
|
@@ -227,7 +168,7 @@ interface NavigationMenuLinkProps extends React.ComponentPropsWithoutRef<
|
|
|
227
168
|
const NavigationMenuLink = React.forwardRef<
|
|
228
169
|
React.ElementRef<typeof NavigationMenuPrimitive.Link>,
|
|
229
170
|
NavigationMenuLinkProps
|
|
230
|
-
>(({ className,
|
|
171
|
+
>(({ className, ...props }, ref) => (
|
|
231
172
|
<NavigationMenuPrimitive.Link
|
|
232
173
|
ref={ref}
|
|
233
174
|
className={cn(
|
|
@@ -240,10 +181,7 @@ const NavigationMenuLink = React.forwardRef<
|
|
|
240
181
|
],
|
|
241
182
|
className
|
|
242
183
|
)}
|
|
243
|
-
data-hook={dataHook}
|
|
244
184
|
data-slot="navigation-menu-link"
|
|
245
|
-
data-tracking-el={trackingEl || "navigation-menu-link"}
|
|
246
|
-
data-tracking-label={trackingLabel}
|
|
247
185
|
{...props}
|
|
248
186
|
/>
|
|
249
187
|
));
|
|
@@ -3,23 +3,18 @@ import {
|
|
|
3
3
|
ChevronLeftIcon,
|
|
4
4
|
ChevronRightIcon,
|
|
5
5
|
MoreHorizontalIcon,
|
|
6
|
-
} from "
|
|
6
|
+
} from "@brightlocal/icons";
|
|
7
7
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Pagination item variants
|
|
12
|
+
* - `previous`: Previous navigation button
|
|
13
|
+
* - `next`: Next navigation button
|
|
14
|
+
* - `link`: Page number link
|
|
15
|
+
* - `ellipsis`: Ellipsis indicator for skipped pages
|
|
12
16
|
*/
|
|
13
|
-
export
|
|
14
|
-
/** Previous navigation button */
|
|
15
|
-
PREVIOUS = "previous",
|
|
16
|
-
/** Next navigation button */
|
|
17
|
-
NEXT = "next",
|
|
18
|
-
/** Page number link */
|
|
19
|
-
LINK = "link",
|
|
20
|
-
/** Ellipsis indicator for skipped pages */
|
|
21
|
-
ELLIPSIS = "ellipsis",
|
|
22
|
-
}
|
|
17
|
+
export type PaginationVariant = "previous" | "next" | "link" | "ellipsis";
|
|
23
18
|
|
|
24
19
|
/**
|
|
25
20
|
* Pagination hook parameters
|
|
@@ -167,7 +162,7 @@ const paginationItemVariants = cva(
|
|
|
167
162
|
},
|
|
168
163
|
},
|
|
169
164
|
defaultVariants: {
|
|
170
|
-
variant:
|
|
165
|
+
variant: "link",
|
|
171
166
|
},
|
|
172
167
|
}
|
|
173
168
|
);
|
|
@@ -205,6 +200,8 @@ function Pagination({
|
|
|
205
200
|
);
|
|
206
201
|
}
|
|
207
202
|
|
|
203
|
+
Pagination.displayName = "Pagination";
|
|
204
|
+
|
|
208
205
|
function PaginationContent({
|
|
209
206
|
className,
|
|
210
207
|
...props
|
|
@@ -270,7 +267,7 @@ const PaginationPrevious = React.forwardRef<
|
|
|
270
267
|
aria-label="Go to previous page"
|
|
271
268
|
className={className}
|
|
272
269
|
disabled={disabled}
|
|
273
|
-
variant=
|
|
270
|
+
variant="previous"
|
|
274
271
|
{...props}
|
|
275
272
|
>
|
|
276
273
|
<ChevronLeftIcon className="size-4" />
|
|
@@ -294,7 +291,7 @@ const PaginationNext = React.forwardRef<HTMLButtonElement, PaginationNextProps>(
|
|
|
294
291
|
aria-label="Go to next page"
|
|
295
292
|
className={className}
|
|
296
293
|
disabled={disabled}
|
|
297
|
-
variant=
|
|
294
|
+
variant="next"
|
|
298
295
|
{...props}
|
|
299
296
|
>
|
|
300
297
|
<ChevronRightIcon className="size-4" />
|
|
@@ -318,7 +315,7 @@ const PaginationLink = React.forwardRef<HTMLButtonElement, PaginationLinkProps>(
|
|
|
318
315
|
aria-label={`Go to page ${page}`}
|
|
319
316
|
className={className}
|
|
320
317
|
isActive={isActive}
|
|
321
|
-
variant=
|
|
318
|
+
variant="link"
|
|
322
319
|
{...props}
|
|
323
320
|
>
|
|
324
321
|
{page}
|
|
@@ -336,10 +333,7 @@ function PaginationEllipsis({
|
|
|
336
333
|
return (
|
|
337
334
|
<span
|
|
338
335
|
aria-hidden="true"
|
|
339
|
-
className={cn(
|
|
340
|
-
paginationItemVariants({ variant: PaginationVariant.ELLIPSIS }),
|
|
341
|
-
className
|
|
342
|
-
)}
|
|
336
|
+
className={cn(paginationItemVariants({ variant: "ellipsis" }), className)}
|
|
343
337
|
data-slot="pagination-ellipsis"
|
|
344
338
|
{...props}
|
|
345
339
|
>
|