@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.
- package/component-meta.json +163 -12
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts +16 -4
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +57 -53
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts +7 -1
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +82 -81
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +18 -7
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +143 -136
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts +14 -2
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +37 -37
- package/dist/callout.cjs +1 -1
- package/dist/callout.d.ts +3 -3
- package/dist/callout.d.ts.map +1 -1
- package/dist/callout.js +2 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +24 -3
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +121 -117
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts +11 -0
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +43 -38
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +12 -2
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +235 -230
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +5 -0
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +207 -206
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +10 -0
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +96 -96
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +7 -2
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +38 -30
- package/dist/drawer.d.ts +2 -2
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +5 -0
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +15 -7
- package/dist/index.cjs +1 -1
- package/dist/index.js +178 -178
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +7 -1
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +131 -130
- package/dist/input-group.d.ts +1 -1
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts +10 -0
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +108 -106
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +36 -37
- package/dist/list.d.ts +1 -1
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +6 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +25 -22
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts +17 -2
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +32 -26
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +29 -3
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +26 -25
- package/dist/rating.cjs +1 -1
- package/dist/rating.d.ts +6 -0
- package/dist/rating.d.ts.map +1 -1
- package/dist/rating.js +27 -19
- package/dist/resizable.d.ts +1 -1
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +7 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +52 -51
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +16 -4
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +38 -35
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +6 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +42 -41
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +5 -0
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +13 -11
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts +5 -0
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +111 -110
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts +1 -2
- package/dist/typography.d.ts.map +1 -1
- package/dist/typography.js +49 -50
- package/package.json +2 -3
- package/src/blocks/data-table.tsx +26 -9
- package/src/blocks/input-list.tsx +12 -1
- package/src/blocks/sidebar.tsx +43 -21
- package/src/components/breadcrumb.tsx +43 -26
- package/src/components/callout.tsx +5 -4
- package/src/components/carousel.tsx +33 -4
- package/src/components/chip.tsx +22 -2
- package/src/components/combobox.tsx +18 -3
- package/src/components/command.tsx +7 -1
- package/src/components/date-picker.tsx +17 -3
- package/src/components/dialog.tsx +17 -4
- package/src/components/drawer.tsx +2 -2
- package/src/components/global-layout.tsx +15 -2
- package/src/components/input-chip.tsx +12 -1
- package/src/components/input-password.tsx +73 -49
- package/src/components/link.tsx +29 -17
- package/src/components/logo.tsx +10 -2
- package/src/components/map.tsx +23 -0
- package/src/components/pagination.tsx +44 -11
- package/src/components/rating.tsx +20 -2
- package/src/components/select.tsx +9 -1
- package/src/components/separator.tsx +40 -25
- package/src/components/sheet.tsx +28 -20
- package/src/components/skeleton.tsx +13 -2
- package/src/components/text-reveal-motion.tsx +7 -1
- package/src/components/typography.tsx +6 -7
|
@@ -5,6 +5,7 @@ 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";
|
|
8
|
+
|
|
8
9
|
import {
|
|
9
10
|
InputGroup,
|
|
10
11
|
InputGroupInput,
|
|
@@ -336,6 +337,16 @@ export interface InputPasswordFieldProps extends Omit<
|
|
|
336
337
|
* Additional class name for the InputGroup wrapper
|
|
337
338
|
*/
|
|
338
339
|
groupClassName?: string;
|
|
340
|
+
/**
|
|
341
|
+
* Accessible label for the toggle button when password is hidden.
|
|
342
|
+
* @default "Show password"
|
|
343
|
+
*/
|
|
344
|
+
showLabel?: string;
|
|
345
|
+
/**
|
|
346
|
+
* Accessible label for the toggle button when password is visible.
|
|
347
|
+
* @default "Hide password"
|
|
348
|
+
*/
|
|
349
|
+
hideLabel?: string;
|
|
339
350
|
}
|
|
340
351
|
|
|
341
352
|
/**
|
|
@@ -345,54 +356,63 @@ export interface InputPasswordFieldProps extends Omit<
|
|
|
345
356
|
const InputPasswordField = React.forwardRef<
|
|
346
357
|
HTMLInputElement,
|
|
347
358
|
InputPasswordFieldProps
|
|
348
|
-
>(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
};
|
|
359
|
+
>(
|
|
360
|
+
(
|
|
361
|
+
{ className, groupClassName, onChange, showLabel, hideLabel, ...props },
|
|
362
|
+
ref
|
|
363
|
+
) => {
|
|
364
|
+
const {
|
|
365
|
+
showPassword,
|
|
366
|
+
toggleVisibility,
|
|
367
|
+
password,
|
|
368
|
+
setPassword,
|
|
369
|
+
disabled,
|
|
370
|
+
dataHook,
|
|
371
|
+
trackingEl,
|
|
372
|
+
trackingLabel,
|
|
373
|
+
inputId,
|
|
374
|
+
error,
|
|
375
|
+
} = useInputPasswordContext();
|
|
366
376
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
value={password}
|
|
378
|
-
onChange={handleChange}
|
|
379
|
-
{...props}
|
|
380
|
-
/>
|
|
381
|
-
<InputGroupAddon align="inline-end">
|
|
382
|
-
<InputGroupButton
|
|
383
|
-
aria-label={showPassword ? "Hide password" : "Show password"}
|
|
384
|
-
data-hook={`${dataHook}-toggle`}
|
|
377
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
378
|
+
setPassword(e.target.value);
|
|
379
|
+
onChange?.(e);
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
return (
|
|
383
|
+
<InputGroup className={groupClassName} dataHook={dataHook} error={error}>
|
|
384
|
+
<InputGroupInput
|
|
385
|
+
ref={ref}
|
|
386
|
+
className={className}
|
|
385
387
|
disabled={disabled}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
{
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
388
|
+
id={inputId}
|
|
389
|
+
trackingEl={trackingEl}
|
|
390
|
+
trackingLabel={trackingLabel}
|
|
391
|
+
type={showPassword ? "text" : "password"}
|
|
392
|
+
value={password}
|
|
393
|
+
onChange={handleChange}
|
|
394
|
+
{...props}
|
|
395
|
+
/>
|
|
396
|
+
<InputGroupAddon align="inline-end">
|
|
397
|
+
<InputGroupButton
|
|
398
|
+
aria-label={
|
|
399
|
+
showPassword
|
|
400
|
+
? (hideLabel ?? "Hide password")
|
|
401
|
+
: (showLabel ?? "Show password")
|
|
402
|
+
}
|
|
403
|
+
data-hook={`${dataHook}-toggle`}
|
|
404
|
+
disabled={disabled}
|
|
405
|
+
size="icon-sm"
|
|
406
|
+
variant="ghost"
|
|
407
|
+
onClick={toggleVisibility}
|
|
408
|
+
>
|
|
409
|
+
{showPassword ? <EyeOff /> : <Eye />}
|
|
410
|
+
</InputGroupButton>
|
|
411
|
+
</InputGroupAddon>
|
|
412
|
+
</InputGroup>
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
);
|
|
396
416
|
|
|
397
417
|
InputPasswordField.displayName = "InputPasswordField";
|
|
398
418
|
|
|
@@ -427,8 +447,8 @@ const InputPasswordToggle = React.forwardRef<
|
|
|
427
447
|
(
|
|
428
448
|
{
|
|
429
449
|
className,
|
|
430
|
-
showLabel
|
|
431
|
-
hideLabel
|
|
450
|
+
showLabel,
|
|
451
|
+
hideLabel,
|
|
432
452
|
size = "icon",
|
|
433
453
|
variant = "ghost",
|
|
434
454
|
...props
|
|
@@ -441,7 +461,11 @@ const InputPasswordToggle = React.forwardRef<
|
|
|
441
461
|
return (
|
|
442
462
|
<InputGroupButton
|
|
443
463
|
ref={ref}
|
|
444
|
-
aria-label={
|
|
464
|
+
aria-label={
|
|
465
|
+
showPassword
|
|
466
|
+
? (hideLabel ?? "Hide password")
|
|
467
|
+
: (showLabel ?? "Show password")
|
|
468
|
+
}
|
|
445
469
|
className={className}
|
|
446
470
|
data-hook={`${dataHook}-toggle`}
|
|
447
471
|
disabled={disabled}
|
package/src/components/link.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { ExternalLink } from "@brightlocal/icons";
|
|
3
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import { Slot, Slottable } from "@radix-ui/react-slot";
|
|
4
4
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
@@ -55,7 +55,7 @@ export interface LinkProps
|
|
|
55
55
|
*/
|
|
56
56
|
external?: boolean;
|
|
57
57
|
/**
|
|
58
|
-
* If true, shows the external link icon when external is true
|
|
58
|
+
* If true, shows the external link icon when external is true.
|
|
59
59
|
* @default true
|
|
60
60
|
*/
|
|
61
61
|
showExternalIcon?: boolean;
|
|
@@ -76,27 +76,39 @@ const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
|
|
|
76
76
|
},
|
|
77
77
|
ref
|
|
78
78
|
) => {
|
|
79
|
-
const Comp = asChild ? Slot : "a";
|
|
80
79
|
const externalProps = external
|
|
81
80
|
? { target: "_blank", rel: "noopener noreferrer" }
|
|
82
81
|
: {};
|
|
83
82
|
|
|
83
|
+
const sharedProps = {
|
|
84
|
+
ref,
|
|
85
|
+
className: cn(linkVariants(), className),
|
|
86
|
+
"data-hook": dataHook,
|
|
87
|
+
"data-slot": "link" as const,
|
|
88
|
+
"data-tracking-el": trackingEl || "link-default",
|
|
89
|
+
"data-tracking-label": trackingLabel,
|
|
90
|
+
...externalProps,
|
|
91
|
+
...props,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const externalIcon = external && showExternalIcon && (
|
|
95
|
+
<ExternalLink aria-hidden="true" data-slot="external-icon" />
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
if (asChild) {
|
|
99
|
+
return (
|
|
100
|
+
<Slot {...sharedProps}>
|
|
101
|
+
<Slottable>{children}</Slottable>
|
|
102
|
+
{externalIcon}
|
|
103
|
+
</Slot>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
84
107
|
return (
|
|
85
|
-
<
|
|
86
|
-
ref={ref}
|
|
87
|
-
className={cn(linkVariants(), className)}
|
|
88
|
-
data-hook={dataHook}
|
|
89
|
-
data-slot="link"
|
|
90
|
-
data-tracking-el={trackingEl || "link-default"}
|
|
91
|
-
data-tracking-label={trackingLabel}
|
|
92
|
-
{...externalProps}
|
|
93
|
-
{...props}
|
|
94
|
-
>
|
|
108
|
+
<a {...sharedProps}>
|
|
95
109
|
{children}
|
|
96
|
-
{
|
|
97
|
-
|
|
98
|
-
)}
|
|
99
|
-
</Comp>
|
|
110
|
+
{externalIcon}
|
|
111
|
+
</a>
|
|
100
112
|
);
|
|
101
113
|
}
|
|
102
114
|
);
|
package/src/components/logo.tsx
CHANGED
|
@@ -28,6 +28,11 @@ interface LogoProps
|
|
|
28
28
|
* Required data-hook attribute for testing and component identification
|
|
29
29
|
*/
|
|
30
30
|
dataHook: string;
|
|
31
|
+
/**
|
|
32
|
+
* Accessible label for the logo image.
|
|
33
|
+
* @default "BrightLocal Logo"
|
|
34
|
+
*/
|
|
35
|
+
ariaLabel?: string;
|
|
31
36
|
/**
|
|
32
37
|
* Optional tracking element identifier for analytics
|
|
33
38
|
*/
|
|
@@ -42,26 +47,27 @@ function Logo({
|
|
|
42
47
|
className,
|
|
43
48
|
variant = "logotype",
|
|
44
49
|
dataHook,
|
|
50
|
+
ariaLabel,
|
|
45
51
|
trackingEl,
|
|
46
52
|
trackingLabel,
|
|
47
53
|
...props
|
|
48
54
|
}: LogoProps) {
|
|
49
55
|
return (
|
|
50
56
|
<div
|
|
51
|
-
aria-label="BrightLocal Logo"
|
|
52
57
|
className={cn(logoVariants({ variant }), className)}
|
|
53
58
|
data-hook={dataHook}
|
|
54
59
|
data-slot="logo"
|
|
55
60
|
data-tracking-el={trackingEl}
|
|
56
61
|
data-tracking-label={trackingLabel}
|
|
57
62
|
data-variant={variant}
|
|
58
|
-
role="img"
|
|
59
63
|
{...props}
|
|
60
64
|
>
|
|
61
65
|
{variant === "logotype" && (
|
|
62
66
|
<svg
|
|
67
|
+
aria-label={ariaLabel ?? "BrightLocal Logo"}
|
|
63
68
|
fill="none"
|
|
64
69
|
height="24"
|
|
70
|
+
role="img"
|
|
65
71
|
viewBox="0 0 128 24.1509"
|
|
66
72
|
width="128"
|
|
67
73
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -81,8 +87,10 @@ function Logo({
|
|
|
81
87
|
)}
|
|
82
88
|
{variant === "mark" && (
|
|
83
89
|
<svg
|
|
90
|
+
aria-label={ariaLabel ?? "BrightLocal Logo"}
|
|
84
91
|
fill="none"
|
|
85
92
|
height="21"
|
|
93
|
+
role="img"
|
|
86
94
|
viewBox="0 0 23 21"
|
|
87
95
|
width="23"
|
|
88
96
|
xmlns="http://www.w3.org/2000/svg"
|
package/src/components/map.tsx
CHANGED
|
@@ -12,6 +12,27 @@ import {
|
|
|
12
12
|
type PopoverContentProps,
|
|
13
13
|
} from "@brightlocal/ui-components/popover";
|
|
14
14
|
|
|
15
|
+
// ──────────────────────────────────────
|
|
16
|
+
// MapTypeId
|
|
17
|
+
// ──────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Vendor-agnostic map type identifiers.
|
|
21
|
+
* Values match `google.maps.MapTypeId` so they can be passed directly
|
|
22
|
+
* to Google Maps or any provider that accepts the same string literals.
|
|
23
|
+
*/
|
|
24
|
+
const MapTypeId = {
|
|
25
|
+
/** Default road map view */
|
|
26
|
+
ROADMAP: "roadmap",
|
|
27
|
+
/** Satellite imagery */
|
|
28
|
+
SATELLITE: "satellite",
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Union of all map type identifier values.
|
|
33
|
+
*/
|
|
34
|
+
type MapTypeIdValue = (typeof MapTypeId)[keyof typeof MapTypeId];
|
|
35
|
+
|
|
15
36
|
// ──────────────────────────────────────
|
|
16
37
|
// MapGridPin
|
|
17
38
|
// ──────────────────────────────────────
|
|
@@ -547,6 +568,7 @@ MapPopoverContent.displayName = "MapPopoverContent";
|
|
|
547
568
|
// ──────────────────────────────────────
|
|
548
569
|
|
|
549
570
|
export {
|
|
571
|
+
MapTypeId,
|
|
550
572
|
MapLocationPin,
|
|
551
573
|
MapGridPin,
|
|
552
574
|
MapControlButton,
|
|
@@ -560,6 +582,7 @@ export {
|
|
|
560
582
|
};
|
|
561
583
|
|
|
562
584
|
export type {
|
|
585
|
+
MapTypeIdValue,
|
|
563
586
|
MapLocationPinProps,
|
|
564
587
|
MapGridPinProps,
|
|
565
588
|
MapGridPinVariant,
|
|
@@ -170,7 +170,10 @@ interface PaginationProps extends React.ComponentProps<"nav"> {
|
|
|
170
170
|
trackingEl?: string;
|
|
171
171
|
/** Tracking label for analytics context */
|
|
172
172
|
trackingLabel?: string;
|
|
173
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* Accessible label for the pagination navigation (for unique landmark identification).
|
|
175
|
+
* @default "Pagination"
|
|
176
|
+
*/
|
|
174
177
|
ariaLabel?: string;
|
|
175
178
|
}
|
|
176
179
|
|
|
@@ -179,12 +182,12 @@ function Pagination({
|
|
|
179
182
|
dataHook,
|
|
180
183
|
trackingEl,
|
|
181
184
|
trackingLabel,
|
|
182
|
-
ariaLabel
|
|
185
|
+
ariaLabel,
|
|
183
186
|
...props
|
|
184
187
|
}: PaginationProps) {
|
|
185
188
|
return (
|
|
186
189
|
<nav
|
|
187
|
-
aria-label={ariaLabel}
|
|
190
|
+
aria-label={ariaLabel ?? "Pagination"}
|
|
188
191
|
className={cn("mx-auto flex w-full justify-center", className)}
|
|
189
192
|
data-hook={dataHook}
|
|
190
193
|
data-slot="pagination"
|
|
@@ -250,17 +253,22 @@ interface PaginationPreviousProps extends Omit<
|
|
|
250
253
|
> {
|
|
251
254
|
/** Whether the previous button is disabled (on first page) */
|
|
252
255
|
disabled?: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Accessible label for the previous-page button.
|
|
258
|
+
* @default "Go to previous page"
|
|
259
|
+
*/
|
|
260
|
+
ariaLabel?: string;
|
|
253
261
|
}
|
|
254
262
|
|
|
255
263
|
const PaginationPrevious = React.forwardRef<
|
|
256
264
|
HTMLButtonElement,
|
|
257
265
|
PaginationPreviousProps
|
|
258
|
-
>(({ className, disabled, ...props }, ref) => {
|
|
266
|
+
>(({ className, disabled, ariaLabel, ...props }, ref) => {
|
|
259
267
|
return (
|
|
260
268
|
<PaginationButton
|
|
261
269
|
ref={ref}
|
|
262
270
|
aria-disabled={disabled}
|
|
263
|
-
aria-label="Go to previous page"
|
|
271
|
+
aria-label={ariaLabel ?? "Go to previous page"}
|
|
264
272
|
className={className}
|
|
265
273
|
disabled={disabled}
|
|
266
274
|
variant="previous"
|
|
@@ -276,15 +284,20 @@ PaginationPrevious.displayName = "PaginationPrevious";
|
|
|
276
284
|
interface PaginationNextProps extends Omit<PaginationButtonProps, "variant"> {
|
|
277
285
|
/** Whether the next button is disabled (on last page) */
|
|
278
286
|
disabled?: boolean;
|
|
287
|
+
/**
|
|
288
|
+
* Accessible label for the next-page button.
|
|
289
|
+
* @default "Go to next page"
|
|
290
|
+
*/
|
|
291
|
+
ariaLabel?: string;
|
|
279
292
|
}
|
|
280
293
|
|
|
281
294
|
const PaginationNext = React.forwardRef<HTMLButtonElement, PaginationNextProps>(
|
|
282
|
-
({ className, disabled, ...props }, ref) => {
|
|
295
|
+
({ className, disabled, ariaLabel, ...props }, ref) => {
|
|
283
296
|
return (
|
|
284
297
|
<PaginationButton
|
|
285
298
|
ref={ref}
|
|
286
299
|
aria-disabled={disabled}
|
|
287
|
-
aria-label="Go to next page"
|
|
300
|
+
aria-label={ariaLabel ?? "Go to next page"}
|
|
288
301
|
className={className}
|
|
289
302
|
disabled={disabled}
|
|
290
303
|
variant="next"
|
|
@@ -301,14 +314,24 @@ PaginationNext.displayName = "PaginationNext";
|
|
|
301
314
|
interface PaginationLinkProps extends Omit<PaginationButtonProps, "variant"> {
|
|
302
315
|
/** Page number to display */
|
|
303
316
|
page: number;
|
|
317
|
+
/**
|
|
318
|
+
* Accessible label for the page button.
|
|
319
|
+
* Supports `{page}` placeholder for interpolation.
|
|
320
|
+
* @default "Go to page {page}"
|
|
321
|
+
*/
|
|
322
|
+
ariaLabel?: string;
|
|
304
323
|
}
|
|
305
324
|
|
|
306
325
|
const PaginationLink = React.forwardRef<HTMLButtonElement, PaginationLinkProps>(
|
|
307
|
-
({ className, page, isActive, ...props }, ref) => {
|
|
326
|
+
({ className, page, isActive, ariaLabel, ...props }, ref) => {
|
|
308
327
|
return (
|
|
309
328
|
<PaginationButton
|
|
310
329
|
ref={ref}
|
|
311
|
-
aria-label={
|
|
330
|
+
aria-label={
|
|
331
|
+
ariaLabel
|
|
332
|
+
? ariaLabel.replace("{page}", String(page))
|
|
333
|
+
: `Go to page ${page}`
|
|
334
|
+
}
|
|
312
335
|
className={className}
|
|
313
336
|
isActive={isActive}
|
|
314
337
|
variant="link"
|
|
@@ -322,10 +345,19 @@ const PaginationLink = React.forwardRef<HTMLButtonElement, PaginationLinkProps>(
|
|
|
322
345
|
|
|
323
346
|
PaginationLink.displayName = "PaginationLink";
|
|
324
347
|
|
|
348
|
+
interface PaginationEllipsisProps extends React.ComponentProps<"span"> {
|
|
349
|
+
/**
|
|
350
|
+
* Screen-reader-only label for the ellipsis.
|
|
351
|
+
* @default "More pages"
|
|
352
|
+
*/
|
|
353
|
+
srLabel?: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
325
356
|
function PaginationEllipsis({
|
|
326
357
|
className,
|
|
358
|
+
srLabel = "More pages",
|
|
327
359
|
...props
|
|
328
|
-
}:
|
|
360
|
+
}: PaginationEllipsisProps) {
|
|
329
361
|
return (
|
|
330
362
|
<span
|
|
331
363
|
aria-hidden="true"
|
|
@@ -334,7 +366,7 @@ function PaginationEllipsis({
|
|
|
334
366
|
{...props}
|
|
335
367
|
>
|
|
336
368
|
<MoreHorizontal />
|
|
337
|
-
<span className="sr-only">
|
|
369
|
+
<span className="sr-only">{srLabel}</span>
|
|
338
370
|
</span>
|
|
339
371
|
);
|
|
340
372
|
}
|
|
@@ -355,4 +387,5 @@ export {
|
|
|
355
387
|
type PaginationLinkProps,
|
|
356
388
|
type PaginationPreviousProps,
|
|
357
389
|
type PaginationNextProps,
|
|
390
|
+
type PaginationEllipsisProps,
|
|
358
391
|
};
|
|
@@ -16,6 +16,12 @@ export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
16
16
|
* Data hook for testing
|
|
17
17
|
*/
|
|
18
18
|
dataHook: string;
|
|
19
|
+
/**
|
|
20
|
+
* Accessible label for the rating.
|
|
21
|
+
* Supports `{value}` placeholder for interpolation.
|
|
22
|
+
* @default "Rating: {value} out of 5 stars"
|
|
23
|
+
*/
|
|
24
|
+
ariaLabel?: string;
|
|
19
25
|
/**
|
|
20
26
|
* Optional tracking element identifier
|
|
21
27
|
*/
|
|
@@ -28,7 +34,15 @@ export interface RatingProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
28
34
|
|
|
29
35
|
const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
30
36
|
(
|
|
31
|
-
{
|
|
37
|
+
{
|
|
38
|
+
value,
|
|
39
|
+
dataHook,
|
|
40
|
+
ariaLabel,
|
|
41
|
+
trackingEl,
|
|
42
|
+
trackingLabel,
|
|
43
|
+
className,
|
|
44
|
+
...props
|
|
45
|
+
},
|
|
32
46
|
ref
|
|
33
47
|
) => {
|
|
34
48
|
// Clamp value between 0 and 5
|
|
@@ -37,7 +51,11 @@ const Rating = React.forwardRef<HTMLDivElement, RatingProps>(
|
|
|
37
51
|
return (
|
|
38
52
|
<div
|
|
39
53
|
ref={ref}
|
|
40
|
-
aria-label={
|
|
54
|
+
aria-label={
|
|
55
|
+
ariaLabel
|
|
56
|
+
? ariaLabel.replace("{value}", String(clampedValue))
|
|
57
|
+
: `Rating: ${clampedValue} out of 5 stars`
|
|
58
|
+
}
|
|
41
59
|
className={cn("flex items-center gap-0.5", className)}
|
|
42
60
|
data-hook={dataHook}
|
|
43
61
|
data-slot="rating"
|
|
@@ -121,6 +121,12 @@ interface SelectTriggerProps extends React.ComponentProps<
|
|
|
121
121
|
dataHook?: string;
|
|
122
122
|
/** Whether the select trigger has an error state */
|
|
123
123
|
error?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Accessible label for the select trigger.
|
|
126
|
+
* Priority: aria-label > selectLabel > placeholder > "Select an option"
|
|
127
|
+
* @default "Select an option"
|
|
128
|
+
*/
|
|
129
|
+
selectLabel?: string;
|
|
124
130
|
}
|
|
125
131
|
|
|
126
132
|
// ============================================================================
|
|
@@ -136,6 +142,7 @@ function SelectTrigger({
|
|
|
136
142
|
placeholder,
|
|
137
143
|
dataHook,
|
|
138
144
|
error,
|
|
145
|
+
selectLabel,
|
|
139
146
|
...props
|
|
140
147
|
}: SelectTriggerProps) {
|
|
141
148
|
// Support both error prop and aria-invalid for backwards compatibility
|
|
@@ -145,7 +152,8 @@ function SelectTrigger({
|
|
|
145
152
|
props["aria-required"] === true || props["aria-required"] === "true";
|
|
146
153
|
|
|
147
154
|
// Provide fallback label for accessibility
|
|
148
|
-
const ariaLabel =
|
|
155
|
+
const ariaLabel =
|
|
156
|
+
props["aria-label"] || selectLabel || placeholder || "Select an option";
|
|
149
157
|
|
|
150
158
|
const errorStyles = isError
|
|
151
159
|
? "border-destructive-40 dark:border-destructive-40 " +
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
5
4
|
|
|
6
5
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
6
|
|
|
@@ -13,9 +12,19 @@ export type SeparatorOrientation = "horizontal" | "vertical";
|
|
|
13
12
|
/**
|
|
14
13
|
* Props for the Separator component.
|
|
15
14
|
*/
|
|
16
|
-
interface SeparatorProps extends React.
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
interface SeparatorProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
16
|
+
/**
|
|
17
|
+
* Visual orientation of the separator.
|
|
18
|
+
* Horizontal renders a native `<hr>`, vertical renders a `<div>`.
|
|
19
|
+
* @default "horizontal"
|
|
20
|
+
*/
|
|
21
|
+
orientation?: SeparatorOrientation;
|
|
22
|
+
/**
|
|
23
|
+
* When true, the separator is purely decorative (role="none").
|
|
24
|
+
* When false, it carries separator semantics for assistive technology.
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
decorative?: boolean;
|
|
19
28
|
/**
|
|
20
29
|
* Data hook for automated testing
|
|
21
30
|
*/
|
|
@@ -32,12 +41,10 @@ interface SeparatorProps extends React.ComponentProps<
|
|
|
32
41
|
|
|
33
42
|
/**
|
|
34
43
|
* Separator visually divides content using a horizontal or vertical line.
|
|
35
|
-
*
|
|
44
|
+
* Horizontal orientation renders a semantic `<hr>` element.
|
|
45
|
+
* Vertical orientation renders a `<div>` with appropriate ARIA attributes.
|
|
36
46
|
*/
|
|
37
|
-
const Separator = React.forwardRef<
|
|
38
|
-
React.ComponentRef<typeof SeparatorPrimitive.Root>,
|
|
39
|
-
SeparatorProps
|
|
40
|
-
>(
|
|
47
|
+
const Separator = React.forwardRef<HTMLElement, SeparatorProps>(
|
|
41
48
|
(
|
|
42
49
|
{
|
|
43
50
|
className,
|
|
@@ -50,22 +57,30 @@ const Separator = React.forwardRef<
|
|
|
50
57
|
},
|
|
51
58
|
ref
|
|
52
59
|
) => {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
60
|
+
const ariaProps = decorative
|
|
61
|
+
? { role: "none" as const }
|
|
62
|
+
: orientation === "vertical"
|
|
63
|
+
? {
|
|
64
|
+
"aria-orientation": "vertical" as const,
|
|
65
|
+
role: "separator" as const,
|
|
66
|
+
}
|
|
67
|
+
: {};
|
|
68
|
+
|
|
69
|
+
return React.createElement(orientation === "horizontal" ? "hr" : "div", {
|
|
70
|
+
ref,
|
|
71
|
+
className: cn(
|
|
72
|
+
"bg-border shrink-0",
|
|
73
|
+
orientation === "horizontal" ? "h-px w-full border-0" : "h-full w-px",
|
|
74
|
+
className
|
|
75
|
+
),
|
|
76
|
+
"data-hook": dataHook,
|
|
77
|
+
"data-orientation": orientation,
|
|
78
|
+
"data-slot": "separator",
|
|
79
|
+
"data-tracking-el": trackingEl,
|
|
80
|
+
"data-tracking-label": trackingLabel,
|
|
81
|
+
...ariaProps,
|
|
82
|
+
...props,
|
|
83
|
+
});
|
|
69
84
|
}
|
|
70
85
|
);
|
|
71
86
|
|