@brightlocal/ui-components 2.10.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/README.md +3 -1
- package/component-meta.json +200 -17
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +42 -25
- 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 +19 -10
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +173 -169
- 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/button.cjs +1 -1
- package/dist/button.js +25 -25
- 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/card.cjs +1 -1
- package/dist/card.d.ts +10 -1
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +85 -82
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +37 -4
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +213 -163
- 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 +106 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +385 -120
- 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/hooks/use-breakpoint.cjs +1 -1
- package/dist/hooks/use-breakpoint.d.ts.map +1 -1
- package/dist/hooks/use-breakpoint.js +10 -10
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +406 -395
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +8 -5
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +164 -170
- 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 -0
- package/dist/map.d.ts +207 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/map.js +256 -0
- 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/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +32 -30
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +4 -0
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +101 -52
- 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 +4 -5
- package/src/blocks/data-table.tsx +26 -9
- package/src/blocks/input-list.tsx +12 -1
- package/src/blocks/sidebar.tsx +61 -44
- package/src/components/badge.tsx +22 -5
- package/src/components/breadcrumb.tsx +43 -26
- package/src/components/button.tsx +13 -13
- package/src/components/callout.tsx +5 -4
- package/src/components/card.tsx +35 -19
- package/src/components/carousel.tsx +134 -13
- package/src/components/chip.tsx +22 -2
- package/src/components/combobox.tsx +18 -3
- package/src/components/command.tsx +644 -17
- 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 +114 -66
- 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 +597 -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/sonner.tsx +9 -3
- package/src/components/tabs.tsx +118 -22
- package/src/components/text-reveal-motion.tsx +7 -1
- package/src/components/typography.tsx +6 -7
- package/src/hooks/use-breakpoint.ts +2 -3
- package/src/index.ts +1 -0
|
@@ -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
|
|
package/src/components/sheet.tsx
CHANGED
|
@@ -185,6 +185,11 @@ interface SheetContentProps
|
|
|
185
185
|
* Tracking label for analytics context
|
|
186
186
|
*/
|
|
187
187
|
trackingLabel?: string;
|
|
188
|
+
/**
|
|
189
|
+
* Accessible label for the close button.
|
|
190
|
+
* @default "Close"
|
|
191
|
+
*/
|
|
192
|
+
closeLabel?: string;
|
|
188
193
|
}
|
|
189
194
|
|
|
190
195
|
/**
|
|
@@ -203,29 +208,32 @@ const SheetContent = React.forwardRef<
|
|
|
203
208
|
dataHook,
|
|
204
209
|
trackingEl,
|
|
205
210
|
trackingLabel,
|
|
211
|
+
closeLabel,
|
|
206
212
|
...props
|
|
207
213
|
},
|
|
208
214
|
ref
|
|
209
|
-
) =>
|
|
210
|
-
|
|
211
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
<
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
215
|
+
) => {
|
|
216
|
+
return (
|
|
217
|
+
<SheetPortal>
|
|
218
|
+
<SheetOverlay />
|
|
219
|
+
<SheetPrimitive.Content
|
|
220
|
+
ref={ref}
|
|
221
|
+
className={cn(sheetContentVariants({ side }), className)}
|
|
222
|
+
data-hook={dataHook}
|
|
223
|
+
data-slot="sheet-content"
|
|
224
|
+
data-tracking-el={trackingEl}
|
|
225
|
+
data-tracking-label={trackingLabel}
|
|
226
|
+
{...props}
|
|
227
|
+
>
|
|
228
|
+
{children}
|
|
229
|
+
<SheetPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0">
|
|
230
|
+
<X />
|
|
231
|
+
<span className="sr-only">{closeLabel ?? "Close"}</span>
|
|
232
|
+
</SheetPrimitive.Close>
|
|
233
|
+
</SheetPrimitive.Content>
|
|
234
|
+
</SheetPortal>
|
|
235
|
+
);
|
|
236
|
+
}
|
|
229
237
|
);
|
|
230
238
|
SheetContent.displayName = "SheetContent";
|
|
231
239
|
|
|
@@ -18,6 +18,11 @@ interface SkeletonProps extends React.ComponentProps<"div"> {
|
|
|
18
18
|
* Tracking label for analytics context
|
|
19
19
|
*/
|
|
20
20
|
trackingLabel?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Accessible label announced to screen readers during loading.
|
|
23
|
+
* @default "Loading"
|
|
24
|
+
*/
|
|
25
|
+
loadingLabel?: string;
|
|
21
26
|
}
|
|
22
27
|
|
|
23
28
|
/**
|
|
@@ -26,17 +31,23 @@ interface SkeletonProps extends React.ComponentProps<"div"> {
|
|
|
26
31
|
* Use to represent text, images, avatars, or any other content while data is being fetched.
|
|
27
32
|
*/
|
|
28
33
|
const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
|
|
29
|
-
(
|
|
34
|
+
(
|
|
35
|
+
{ className, dataHook, trackingEl, trackingLabel, loadingLabel, ...props },
|
|
36
|
+
ref
|
|
37
|
+
) => {
|
|
30
38
|
return (
|
|
31
39
|
<div
|
|
32
40
|
ref={ref}
|
|
41
|
+
aria-busy="true"
|
|
33
42
|
className={cn("bg-accent animate-pulse rounded-md", className)}
|
|
34
43
|
data-hook={dataHook}
|
|
35
44
|
data-slot="skeleton"
|
|
36
45
|
data-tracking-el={trackingEl}
|
|
37
46
|
data-tracking-label={trackingLabel}
|
|
38
47
|
{...props}
|
|
39
|
-
|
|
48
|
+
>
|
|
49
|
+
<span className="sr-only">{loadingLabel ?? "Loading"}</span>
|
|
50
|
+
</div>
|
|
40
51
|
);
|
|
41
52
|
}
|
|
42
53
|
);
|
|
@@ -254,7 +254,14 @@ function Toast(props: ToastProps) {
|
|
|
254
254
|
role="status"
|
|
255
255
|
>
|
|
256
256
|
<div className="flex flex-1 items-start gap-2">
|
|
257
|
-
{icon !== null &&
|
|
257
|
+
{icon !== null &&
|
|
258
|
+
icon !== undefined &&
|
|
259
|
+
(() => {
|
|
260
|
+
const iconEl = renderToastIcon(icon, schema);
|
|
261
|
+
return iconEl ? (
|
|
262
|
+
<span className="mt-0.5 shrink-0">{iconEl}</span>
|
|
263
|
+
) : null;
|
|
264
|
+
})()}
|
|
258
265
|
<div className="w-full">
|
|
259
266
|
<p className={cn(TITLE_VARIANTS({ colorSchema: schema }))}>{title}</p>
|
|
260
267
|
{description && (
|
|
@@ -268,9 +275,8 @@ function Toast(props: ToastProps) {
|
|
|
268
275
|
{button?.label && (
|
|
269
276
|
<Button
|
|
270
277
|
aria-label={button.label}
|
|
271
|
-
className="min-h-6 px-2 py-0 text-xs leading-normal font-medium"
|
|
272
278
|
dataHook="toast-action"
|
|
273
|
-
size="
|
|
279
|
+
size="sm"
|
|
274
280
|
variant={button.variant}
|
|
275
281
|
onClick={button.onClick}
|
|
276
282
|
>
|
package/src/components/tabs.tsx
CHANGED
|
@@ -5,6 +5,20 @@ import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
7
|
|
|
8
|
+
interface TabsContextValue {
|
|
9
|
+
lazyMount: boolean;
|
|
10
|
+
unmountOnExit: boolean;
|
|
11
|
+
activeValue: string | undefined;
|
|
12
|
+
visitedTabs: Set<string>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const TabsContext = React.createContext<TabsContextValue>({
|
|
16
|
+
lazyMount: false,
|
|
17
|
+
unmountOnExit: false,
|
|
18
|
+
activeValue: undefined,
|
|
19
|
+
visitedTabs: new Set(),
|
|
20
|
+
});
|
|
21
|
+
|
|
8
22
|
/**
|
|
9
23
|
* Props for the Tabs component
|
|
10
24
|
*/
|
|
@@ -15,22 +29,83 @@ interface TabsProps extends React.ComponentProps<typeof TabsPrimitive.Root> {
|
|
|
15
29
|
trackingEl?: string;
|
|
16
30
|
/** Tracking label for analytics context */
|
|
17
31
|
trackingLabel?: string;
|
|
32
|
+
/** Only mount tab panel content when the tab is first activated (opt-in) */
|
|
33
|
+
lazyMount?: boolean;
|
|
34
|
+
/** Unmount tab panel content when the tab becomes inactive */
|
|
35
|
+
unmountOnExit?: boolean;
|
|
18
36
|
}
|
|
19
37
|
|
|
20
38
|
const Tabs = React.forwardRef<
|
|
21
39
|
React.ComponentRef<typeof TabsPrimitive.Root>,
|
|
22
40
|
TabsProps
|
|
23
|
-
>(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
>(
|
|
42
|
+
(
|
|
43
|
+
{
|
|
44
|
+
className,
|
|
45
|
+
dataHook,
|
|
46
|
+
trackingEl,
|
|
47
|
+
trackingLabel,
|
|
48
|
+
lazyMount = false,
|
|
49
|
+
unmountOnExit = false,
|
|
50
|
+
value: controlledValue,
|
|
51
|
+
defaultValue,
|
|
52
|
+
onValueChange,
|
|
53
|
+
...props
|
|
54
|
+
},
|
|
55
|
+
ref
|
|
56
|
+
) => {
|
|
57
|
+
const needsTracking = lazyMount || unmountOnExit;
|
|
58
|
+
const [internalValue, setInternalValue] = React.useState(defaultValue);
|
|
59
|
+
const activeValue = controlledValue ?? internalValue;
|
|
60
|
+
|
|
61
|
+
const [visitedTabs, setVisitedTabs] = React.useState<Set<string>>(
|
|
62
|
+
() => new Set(activeValue != null ? [activeValue] : [])
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const handleValueChange = React.useCallback(
|
|
66
|
+
(newValue: string) => {
|
|
67
|
+
setInternalValue(newValue);
|
|
68
|
+
if (lazyMount) {
|
|
69
|
+
setVisitedTabs((prev) => {
|
|
70
|
+
if (prev.has(newValue)) return prev;
|
|
71
|
+
const next = new Set(prev);
|
|
72
|
+
next.add(newValue);
|
|
73
|
+
return next;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
onValueChange?.(newValue);
|
|
77
|
+
},
|
|
78
|
+
[lazyMount, onValueChange]
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const contextValue = React.useMemo(
|
|
82
|
+
() => ({
|
|
83
|
+
lazyMount,
|
|
84
|
+
unmountOnExit,
|
|
85
|
+
activeValue,
|
|
86
|
+
visitedTabs,
|
|
87
|
+
}),
|
|
88
|
+
[lazyMount, unmountOnExit, activeValue, visitedTabs]
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<TabsContext.Provider value={contextValue}>
|
|
93
|
+
<TabsPrimitive.Root
|
|
94
|
+
ref={ref}
|
|
95
|
+
className={cn("flex flex-col gap-2", className)}
|
|
96
|
+
data-hook={dataHook}
|
|
97
|
+
data-slot="tabs"
|
|
98
|
+
data-tracking-el={trackingEl}
|
|
99
|
+
data-tracking-label={trackingLabel}
|
|
100
|
+
defaultValue={needsTracking ? undefined : defaultValue}
|
|
101
|
+
value={needsTracking ? activeValue : controlledValue}
|
|
102
|
+
onValueChange={needsTracking ? handleValueChange : onValueChange}
|
|
103
|
+
{...props}
|
|
104
|
+
/>
|
|
105
|
+
</TabsContext.Provider>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
);
|
|
34
109
|
|
|
35
110
|
Tabs.displayName = "Tabs";
|
|
36
111
|
|
|
@@ -145,17 +220,38 @@ interface TabsContentProps extends React.ComponentProps<
|
|
|
145
220
|
const TabsContent = React.forwardRef<
|
|
146
221
|
React.ComponentRef<typeof TabsPrimitive.Content>,
|
|
147
222
|
TabsContentProps
|
|
148
|
-
>(
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
))
|
|
223
|
+
>(
|
|
224
|
+
(
|
|
225
|
+
{ className, dataHook, trackingEl, trackingLabel, value, ...props },
|
|
226
|
+
ref
|
|
227
|
+
) => {
|
|
228
|
+
const { lazyMount, unmountOnExit, activeValue, visitedTabs } =
|
|
229
|
+
React.useContext(TabsContext);
|
|
230
|
+
|
|
231
|
+
const isActive = value === activeValue;
|
|
232
|
+
|
|
233
|
+
if (lazyMount && !visitedTabs.has(value!)) {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (unmountOnExit && !isActive) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<TabsPrimitive.Content
|
|
243
|
+
ref={ref}
|
|
244
|
+
className={cn("flex-1 outline-none", className)}
|
|
245
|
+
data-hook={dataHook}
|
|
246
|
+
data-slot="tabs-content"
|
|
247
|
+
data-tracking-el={trackingEl}
|
|
248
|
+
data-tracking-label={trackingLabel}
|
|
249
|
+
value={value}
|
|
250
|
+
{...props}
|
|
251
|
+
/>
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
);
|
|
159
255
|
|
|
160
256
|
TabsContent.displayName = "TabsContent";
|
|
161
257
|
|
|
@@ -177,6 +177,11 @@ export interface TextRevealMotionProps extends Omit<
|
|
|
177
177
|
* @default "var(--loading-gradient-to)"
|
|
178
178
|
*/
|
|
179
179
|
gradientTo?: string;
|
|
180
|
+
/**
|
|
181
|
+
* Accessible label for the loading animation.
|
|
182
|
+
* @default "Loading"
|
|
183
|
+
*/
|
|
184
|
+
loadingLabel?: string;
|
|
180
185
|
/**
|
|
181
186
|
* Tracking element identifier for analytics.
|
|
182
187
|
*/
|
|
@@ -220,6 +225,7 @@ const TextRevealMotion = React.forwardRef<
|
|
|
220
225
|
shimmer = true,
|
|
221
226
|
gradientFrom = "var(--loading-gradient-from)",
|
|
222
227
|
gradientTo = "var(--loading-gradient-to)",
|
|
228
|
+
loadingLabel,
|
|
223
229
|
trackingEl,
|
|
224
230
|
trackingLabel,
|
|
225
231
|
children,
|
|
@@ -689,7 +695,7 @@ const TextRevealMotion = React.forwardRef<
|
|
|
689
695
|
}}
|
|
690
696
|
>
|
|
691
697
|
<svg
|
|
692
|
-
aria-label="Loading"
|
|
698
|
+
aria-label={loadingLabel ?? "Loading"}
|
|
693
699
|
data-slot="text-reveal-ball"
|
|
694
700
|
fill="none"
|
|
695
701
|
height={ballSize}
|