@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
package/src/components/card.tsx
CHANGED
|
@@ -8,21 +8,25 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
8
8
|
*/
|
|
9
9
|
type CardVariant = "filled" | "transparent" | "border" | "transparent-flush";
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Card density type
|
|
13
|
+
*/
|
|
14
|
+
type CardDensity = "default" | "condensed";
|
|
15
|
+
|
|
11
16
|
/**
|
|
12
17
|
* Context to pass variant information to sub-components
|
|
13
18
|
*/
|
|
14
|
-
const CardContext = React.createContext<{
|
|
19
|
+
const CardContext = React.createContext<{
|
|
20
|
+
flush: boolean;
|
|
21
|
+
density: CardDensity;
|
|
22
|
+
}>({ flush: false, density: "default" });
|
|
23
|
+
|
|
24
|
+
function subPadding(flush: boolean, density: CardDensity): string | false {
|
|
25
|
+
return !flush && (density === "condensed" ? "px-3" : "px-section-md");
|
|
26
|
+
}
|
|
15
27
|
|
|
16
28
|
const cardVariants = cva(
|
|
17
|
-
[
|
|
18
|
-
"flex",
|
|
19
|
-
"flex-col",
|
|
20
|
-
"gap-8",
|
|
21
|
-
"rounded-xl",
|
|
22
|
-
"py-section-md",
|
|
23
|
-
"transition-colors",
|
|
24
|
-
"w-full",
|
|
25
|
-
],
|
|
29
|
+
["flex", "flex-col", "rounded-xl", "transition-colors", "w-full"],
|
|
26
30
|
{
|
|
27
31
|
variants: {
|
|
28
32
|
variant: {
|
|
@@ -41,9 +45,14 @@ const cardVariants = cva(
|
|
|
41
45
|
],
|
|
42
46
|
"transparent-flush": ["bg-transparent", "text-foreground"],
|
|
43
47
|
},
|
|
48
|
+
density: {
|
|
49
|
+
default: ["gap-8", "py-section-md"],
|
|
50
|
+
condensed: ["gap-3", "py-3"],
|
|
51
|
+
},
|
|
44
52
|
},
|
|
45
53
|
defaultVariants: {
|
|
46
54
|
variant: "filled",
|
|
55
|
+
density: "default",
|
|
47
56
|
},
|
|
48
57
|
}
|
|
49
58
|
);
|
|
@@ -57,6 +66,11 @@ type CardProps = React.ComponentProps<"div"> & {
|
|
|
57
66
|
* @default "filled"
|
|
58
67
|
*/
|
|
59
68
|
variant?: CardVariant;
|
|
69
|
+
/**
|
|
70
|
+
* Spacing density of the card
|
|
71
|
+
* @default "default"
|
|
72
|
+
*/
|
|
73
|
+
density?: CardDensity;
|
|
60
74
|
/**
|
|
61
75
|
* Data hook for automated testing (required)
|
|
62
76
|
*/
|
|
@@ -85,6 +99,7 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
85
99
|
{
|
|
86
100
|
className,
|
|
87
101
|
variant = "filled",
|
|
102
|
+
density = "default",
|
|
88
103
|
dataHook,
|
|
89
104
|
trackingEl,
|
|
90
105
|
trackingLabel,
|
|
@@ -105,10 +120,11 @@ const Card = React.forwardRef<HTMLDivElement, CardProps>(
|
|
|
105
120
|
: undefined;
|
|
106
121
|
|
|
107
122
|
return (
|
|
108
|
-
<CardContext.Provider value={{ flush }}>
|
|
123
|
+
<CardContext.Provider value={{ flush, density }}>
|
|
109
124
|
<div
|
|
110
125
|
ref={ref}
|
|
111
|
-
className={cn(cardVariants({ variant }), className)}
|
|
126
|
+
className={cn(cardVariants({ variant, density }), className)}
|
|
127
|
+
data-density={density}
|
|
112
128
|
data-hook={dataHook}
|
|
113
129
|
data-slot="card"
|
|
114
130
|
data-tracking-el={trackingEl || `card-${variant}`}
|
|
@@ -144,13 +160,13 @@ type CardSubComponentProps = React.ComponentProps<"div"> & {
|
|
|
144
160
|
*/
|
|
145
161
|
const CardHeader = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
146
162
|
({ className, ...props }, ref) => {
|
|
147
|
-
const { flush } = React.useContext(CardContext);
|
|
163
|
+
const { flush, density } = React.useContext(CardContext);
|
|
148
164
|
return (
|
|
149
165
|
<div
|
|
150
166
|
ref={ref}
|
|
151
167
|
className={cn(
|
|
152
168
|
"@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
|
|
153
|
-
|
|
169
|
+
subPadding(flush, density),
|
|
154
170
|
className
|
|
155
171
|
)}
|
|
156
172
|
data-slot="card-header"
|
|
@@ -217,11 +233,11 @@ CardAction.displayName = "CardAction";
|
|
|
217
233
|
*/
|
|
218
234
|
const CardContent = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
219
235
|
({ className, ...props }, ref) => {
|
|
220
|
-
const { flush } = React.useContext(CardContext);
|
|
236
|
+
const { flush, density } = React.useContext(CardContext);
|
|
221
237
|
return (
|
|
222
238
|
<div
|
|
223
239
|
ref={ref}
|
|
224
|
-
className={cn(
|
|
240
|
+
className={cn(subPadding(flush, density), className)}
|
|
225
241
|
data-slot="card-content"
|
|
226
242
|
{...props}
|
|
227
243
|
/>
|
|
@@ -235,13 +251,13 @@ CardContent.displayName = "CardContent";
|
|
|
235
251
|
*/
|
|
236
252
|
const CardFooter = React.forwardRef<HTMLDivElement, CardSubComponentProps>(
|
|
237
253
|
({ className, ...props }, ref) => {
|
|
238
|
-
const { flush } = React.useContext(CardContext);
|
|
254
|
+
const { flush, density } = React.useContext(CardContext);
|
|
239
255
|
return (
|
|
240
256
|
<div
|
|
241
257
|
ref={ref}
|
|
242
258
|
className={cn(
|
|
243
259
|
"flex items-center",
|
|
244
|
-
|
|
260
|
+
subPadding(flush, density),
|
|
245
261
|
className
|
|
246
262
|
)}
|
|
247
263
|
data-slot="card-footer"
|
|
@@ -262,4 +278,4 @@ export {
|
|
|
262
278
|
CardContent,
|
|
263
279
|
};
|
|
264
280
|
|
|
265
|
-
export type { CardProps, CardSubComponentProps, CardVariant };
|
|
281
|
+
export type { CardProps, CardSubComponentProps, CardVariant, CardDensity };
|
|
@@ -47,6 +47,18 @@ interface CarouselProps extends React.ComponentProps<"div"> {
|
|
|
47
47
|
* Callback to receive the carousel API instance
|
|
48
48
|
*/
|
|
49
49
|
setApi?: (api: CarouselApi) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Enable lazy loading to only mount slides near the viewport.
|
|
52
|
+
* Off-screen slide children are not rendered until they scroll into view.
|
|
53
|
+
* @default false
|
|
54
|
+
*/
|
|
55
|
+
lazyLoad?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Number of off-screen slides to pre-render on each side of the viewport.
|
|
58
|
+
* Only applies when `lazyLoad` is enabled.
|
|
59
|
+
* @default 1
|
|
60
|
+
*/
|
|
61
|
+
overscan?: number;
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
type CarouselContextProps = {
|
|
@@ -60,6 +72,8 @@ type CarouselContextProps = {
|
|
|
60
72
|
plugins?: CarouselPlugin;
|
|
61
73
|
orientation?: "horizontal" | "vertical";
|
|
62
74
|
setApi?: (api: CarouselApi) => void;
|
|
75
|
+
lazyLoad: boolean;
|
|
76
|
+
loadedSlides: Set<number>;
|
|
63
77
|
};
|
|
64
78
|
|
|
65
79
|
const CarouselContext = React.createContext<CarouselContextProps | null>(null);
|
|
@@ -90,6 +104,8 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
|
|
|
90
104
|
dataHook,
|
|
91
105
|
trackingEl,
|
|
92
106
|
trackingLabel,
|
|
107
|
+
lazyLoad = false,
|
|
108
|
+
overscan = 1,
|
|
93
109
|
...props
|
|
94
110
|
},
|
|
95
111
|
ref
|
|
@@ -103,6 +119,20 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
|
|
|
103
119
|
);
|
|
104
120
|
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
105
121
|
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
122
|
+
const safeOverscan = Math.max(0, Math.floor(overscan));
|
|
123
|
+
const [loadedSlides, setLoadedSlides] = React.useState<Set<number>>(() => {
|
|
124
|
+
if (!lazyLoad) return new Set<number>();
|
|
125
|
+
const startIndex = opts?.startIndex ?? 0;
|
|
126
|
+
const initial = new Set<number>();
|
|
127
|
+
for (
|
|
128
|
+
let i = Math.max(0, startIndex - safeOverscan);
|
|
129
|
+
i <= startIndex + safeOverscan;
|
|
130
|
+
i++
|
|
131
|
+
) {
|
|
132
|
+
initial.add(i);
|
|
133
|
+
}
|
|
134
|
+
return initial;
|
|
135
|
+
});
|
|
106
136
|
|
|
107
137
|
const onSelect = React.useCallback((api: CarouselApi) => {
|
|
108
138
|
if (!api) return;
|
|
@@ -152,6 +182,40 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
|
|
|
152
182
|
};
|
|
153
183
|
}, [api, onSelect]);
|
|
154
184
|
|
|
185
|
+
const updateLoadedSlides = React.useCallback(
|
|
186
|
+
(emblaApi: CarouselApi) => {
|
|
187
|
+
if (!emblaApi || !lazyLoad) return;
|
|
188
|
+
const inView = emblaApi.slidesInView();
|
|
189
|
+
const slideCount = emblaApi.slideNodes().length;
|
|
190
|
+
setLoadedSlides((prev) => {
|
|
191
|
+
const next = new Set(prev);
|
|
192
|
+
for (const index of inView) {
|
|
193
|
+
const lo = Math.max(0, index - safeOverscan);
|
|
194
|
+
const hi = Math.min(slideCount - 1, index + safeOverscan);
|
|
195
|
+
for (let i = lo; i <= hi; i++) {
|
|
196
|
+
next.add(i);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (next.size === prev.size) return prev;
|
|
200
|
+
return next;
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
[lazyLoad, safeOverscan]
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
React.useEffect(() => {
|
|
207
|
+
if (!api || !lazyLoad) return;
|
|
208
|
+
updateLoadedSlides(api);
|
|
209
|
+
api.on("slidesInView", updateLoadedSlides);
|
|
210
|
+
api.on("select", updateLoadedSlides);
|
|
211
|
+
api.on("reInit", updateLoadedSlides);
|
|
212
|
+
return () => {
|
|
213
|
+
api.off("slidesInView", updateLoadedSlides);
|
|
214
|
+
api.off("select", updateLoadedSlides);
|
|
215
|
+
api.off("reInit", updateLoadedSlides);
|
|
216
|
+
};
|
|
217
|
+
}, [api, lazyLoad, updateLoadedSlides]);
|
|
218
|
+
|
|
155
219
|
return (
|
|
156
220
|
<CarouselContext.Provider
|
|
157
221
|
value={{
|
|
@@ -164,6 +228,8 @@ const Carousel = React.forwardRef<HTMLDivElement, CarouselProps>(
|
|
|
164
228
|
scrollNext,
|
|
165
229
|
canScrollPrev,
|
|
166
230
|
canScrollNext,
|
|
231
|
+
lazyLoad,
|
|
232
|
+
loadedSlides,
|
|
167
233
|
}}
|
|
168
234
|
>
|
|
169
235
|
<div
|
|
@@ -193,17 +259,30 @@ Carousel.displayName = "Carousel";
|
|
|
193
259
|
const CarouselContent = React.forwardRef<
|
|
194
260
|
HTMLDivElement,
|
|
195
261
|
React.ComponentProps<"div">
|
|
196
|
-
>(({ className, ...props }, ref) => {
|
|
197
|
-
const { carouselRef, orientation } = useCarousel();
|
|
262
|
+
>(({ className, children, ...props }, ref) => {
|
|
263
|
+
const { carouselRef, orientation, lazyLoad } = useCarousel();
|
|
198
264
|
const isVertical = orientation === "vertical";
|
|
199
265
|
|
|
266
|
+
let slideIndex = 0;
|
|
267
|
+
const processedChildren = lazyLoad
|
|
268
|
+
? React.Children.map(children, (child) => {
|
|
269
|
+
if (React.isValidElement(child) && child.type === CarouselItem) {
|
|
270
|
+
const idx = slideIndex++;
|
|
271
|
+
return React.cloneElement(
|
|
272
|
+
child as React.ReactElement<{ _lazyIndex?: number }>,
|
|
273
|
+
{ _lazyIndex: idx }
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
return child;
|
|
277
|
+
})
|
|
278
|
+
: children;
|
|
279
|
+
|
|
200
280
|
return (
|
|
201
281
|
<div
|
|
202
282
|
ref={carouselRef}
|
|
203
283
|
className={cn("overflow-hidden", isVertical && "w-full", className)}
|
|
204
284
|
data-slot="carousel-content"
|
|
205
285
|
>
|
|
206
|
-
{/* Negative margins offset the positive padding on CarouselItem children (pt-4/pl-4) to create consistent gaps */}
|
|
207
286
|
<div
|
|
208
287
|
ref={ref}
|
|
209
288
|
className={cn(
|
|
@@ -211,21 +290,29 @@ const CarouselContent = React.forwardRef<
|
|
|
211
290
|
isVertical ? "-mt-4 h-full w-full flex-col" : "-ml-4"
|
|
212
291
|
)}
|
|
213
292
|
{...props}
|
|
214
|
-
|
|
293
|
+
>
|
|
294
|
+
{processedChildren}
|
|
295
|
+
</div>
|
|
215
296
|
</div>
|
|
216
297
|
);
|
|
217
298
|
});
|
|
218
299
|
|
|
219
300
|
CarouselContent.displayName = "CarouselContent";
|
|
220
301
|
|
|
302
|
+
type CarouselItemInternalProps = React.ComponentProps<"div"> & {
|
|
303
|
+
_lazyIndex?: number;
|
|
304
|
+
};
|
|
305
|
+
|
|
221
306
|
/**
|
|
222
307
|
* Individual slide item within the carousel.
|
|
223
308
|
*/
|
|
224
309
|
const CarouselItem = React.forwardRef<
|
|
225
310
|
HTMLDivElement,
|
|
226
|
-
|
|
227
|
-
>(({ className, ...props }, ref) => {
|
|
228
|
-
const { orientation } = useCarousel();
|
|
311
|
+
CarouselItemInternalProps
|
|
312
|
+
>(({ className, children, _lazyIndex, ...props }, ref) => {
|
|
313
|
+
const { orientation, lazyLoad, loadedSlides } = useCarousel();
|
|
314
|
+
const isLoaded =
|
|
315
|
+
!lazyLoad || _lazyIndex === undefined || loadedSlides.has(_lazyIndex);
|
|
229
316
|
|
|
230
317
|
return (
|
|
231
318
|
<div
|
|
@@ -236,12 +323,17 @@ const CarouselItem = React.forwardRef<
|
|
|
236
323
|
orientation === "horizontal" ? "pl-4" : "w-full pt-4",
|
|
237
324
|
className
|
|
238
325
|
)}
|
|
326
|
+
data-lazy-loaded={lazyLoad ? String(isLoaded) : undefined}
|
|
239
327
|
data-slot="carousel-item"
|
|
240
328
|
role="group"
|
|
241
329
|
{...props}
|
|
242
|
-
|
|
330
|
+
>
|
|
331
|
+
{isLoaded ? children : null}
|
|
332
|
+
</div>
|
|
243
333
|
);
|
|
244
|
-
})
|
|
334
|
+
}) as React.ForwardRefExoticComponent<
|
|
335
|
+
React.ComponentPropsWithoutRef<"div"> & React.RefAttributes<HTMLDivElement>
|
|
336
|
+
>;
|
|
245
337
|
|
|
246
338
|
CarouselItem.displayName = "CarouselItem";
|
|
247
339
|
|
|
@@ -272,6 +364,11 @@ interface CarouselPreviousProps extends Omit<
|
|
|
272
364
|
* @default false
|
|
273
365
|
*/
|
|
274
366
|
hideWhenDisabled?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Accessible label for the previous slide button.
|
|
369
|
+
* @default "Previous slide"
|
|
370
|
+
*/
|
|
371
|
+
ariaLabel?: string;
|
|
275
372
|
}
|
|
276
373
|
|
|
277
374
|
/**
|
|
@@ -283,6 +380,7 @@ function CarouselPrevious({
|
|
|
283
380
|
size = "default",
|
|
284
381
|
dataHook = "carousel-previous",
|
|
285
382
|
hideWhenDisabled = false,
|
|
383
|
+
ariaLabel = "Previous slide",
|
|
286
384
|
...props
|
|
287
385
|
}: CarouselPreviousProps) {
|
|
288
386
|
const { orientation, scrollPrev, canScrollPrev } = useCarousel();
|
|
@@ -308,7 +406,7 @@ function CarouselPrevious({
|
|
|
308
406
|
{...props}
|
|
309
407
|
>
|
|
310
408
|
<ArrowLeft />
|
|
311
|
-
<span className="sr-only">
|
|
409
|
+
<span className="sr-only">{ariaLabel}</span>
|
|
312
410
|
</Button>
|
|
313
411
|
);
|
|
314
412
|
}
|
|
@@ -342,6 +440,11 @@ interface CarouselNextProps extends Omit<
|
|
|
342
440
|
* @default false
|
|
343
441
|
*/
|
|
344
442
|
hideWhenDisabled?: boolean;
|
|
443
|
+
/**
|
|
444
|
+
* Accessible label for the next slide button.
|
|
445
|
+
* @default "Next slide"
|
|
446
|
+
*/
|
|
447
|
+
ariaLabel?: string;
|
|
345
448
|
}
|
|
346
449
|
|
|
347
450
|
/**
|
|
@@ -353,6 +456,7 @@ function CarouselNext({
|
|
|
353
456
|
size = "default",
|
|
354
457
|
dataHook = "carousel-next",
|
|
355
458
|
hideWhenDisabled = false,
|
|
459
|
+
ariaLabel = "Next slide",
|
|
356
460
|
...props
|
|
357
461
|
}: CarouselNextProps) {
|
|
358
462
|
const { orientation, scrollNext, canScrollNext } = useCarousel();
|
|
@@ -378,7 +482,7 @@ function CarouselNext({
|
|
|
378
482
|
{...props}
|
|
379
483
|
>
|
|
380
484
|
<ArrowRight />
|
|
381
|
-
<span className="sr-only">
|
|
485
|
+
<span className="sr-only">{ariaLabel}</span>
|
|
382
486
|
</Button>
|
|
383
487
|
);
|
|
384
488
|
}
|
|
@@ -402,6 +506,17 @@ interface CarouselDotsProps extends React.ComponentProps<"div"> {
|
|
|
402
506
|
* Tracking label for analytics context
|
|
403
507
|
*/
|
|
404
508
|
trackingLabel?: string;
|
|
509
|
+
/**
|
|
510
|
+
* Accessible label for the slide navigation group.
|
|
511
|
+
* @default "Slide navigation"
|
|
512
|
+
*/
|
|
513
|
+
ariaLabel?: string;
|
|
514
|
+
/**
|
|
515
|
+
* Accessible label for each slide dot button.
|
|
516
|
+
* Supports `{slide}` placeholder for interpolation (1-based).
|
|
517
|
+
* @default "Go to slide {slide}"
|
|
518
|
+
*/
|
|
519
|
+
slideAriaLabel?: string;
|
|
405
520
|
}
|
|
406
521
|
|
|
407
522
|
/**
|
|
@@ -413,6 +528,8 @@ function CarouselDots({
|
|
|
413
528
|
dataHook = "carousel-dots",
|
|
414
529
|
trackingEl,
|
|
415
530
|
trackingLabel,
|
|
531
|
+
ariaLabel = "Slide navigation",
|
|
532
|
+
slideAriaLabel,
|
|
416
533
|
...props
|
|
417
534
|
}: CarouselDotsProps) {
|
|
418
535
|
const { api } = useCarousel();
|
|
@@ -447,7 +564,7 @@ function CarouselDots({
|
|
|
447
564
|
|
|
448
565
|
return (
|
|
449
566
|
<div
|
|
450
|
-
aria-label=
|
|
567
|
+
aria-label={ariaLabel}
|
|
451
568
|
className={cn(
|
|
452
569
|
"border-border dark:border-input dark:bg-input/30 inline-flex items-center justify-center gap-2 rounded-full border bg-white px-2.5 py-2",
|
|
453
570
|
className
|
|
@@ -463,7 +580,11 @@ function CarouselDots({
|
|
|
463
580
|
<button
|
|
464
581
|
key={index}
|
|
465
582
|
aria-current={index === selectedIndex ? "step" : undefined}
|
|
466
|
-
aria-label={
|
|
583
|
+
aria-label={
|
|
584
|
+
slideAriaLabel
|
|
585
|
+
? slideAriaLabel.replace("{slide}", String(index + 1))
|
|
586
|
+
: `Go to slide ${index + 1}`
|
|
587
|
+
}
|
|
467
588
|
className={cn(
|
|
468
589
|
"focus-visible:shadow-default size-3 rounded-full transition-[width,background-color] duration-200 ease-out outline-none",
|
|
469
590
|
index === selectedIndex
|
package/src/components/chip.tsx
CHANGED
|
@@ -136,6 +136,17 @@ interface ChipProps extends Omit<React.ComponentProps<"div">, "children"> {
|
|
|
136
136
|
* @default 200
|
|
137
137
|
*/
|
|
138
138
|
maxWidth?: number;
|
|
139
|
+
/**
|
|
140
|
+
* Accessible label for the loading spinner.
|
|
141
|
+
* @default "Loading"
|
|
142
|
+
*/
|
|
143
|
+
loadingLabel?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Accessible label for the remove button.
|
|
146
|
+
* Supports `{name}` placeholder for interpolation.
|
|
147
|
+
* @default "Remove {name}"
|
|
148
|
+
*/
|
|
149
|
+
removeAriaLabel?: string;
|
|
139
150
|
}
|
|
140
151
|
|
|
141
152
|
/**
|
|
@@ -155,6 +166,8 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
|
|
|
155
166
|
trackingEl,
|
|
156
167
|
trackingLabel,
|
|
157
168
|
maxWidth = 200,
|
|
169
|
+
loadingLabel,
|
|
170
|
+
removeAriaLabel,
|
|
158
171
|
...props
|
|
159
172
|
},
|
|
160
173
|
ref
|
|
@@ -214,7 +227,7 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
|
|
|
214
227
|
)}
|
|
215
228
|
{loading ? (
|
|
216
229
|
<span
|
|
217
|
-
aria-label="Loading"
|
|
230
|
+
aria-label={loadingLabel ?? "Loading"}
|
|
218
231
|
className={cn(chipDeleteButtonVariants({ size }))}
|
|
219
232
|
data-slot="chip-loading"
|
|
220
233
|
role="status"
|
|
@@ -226,7 +239,14 @@ const Chip = React.forwardRef<HTMLDivElement, ChipProps>(
|
|
|
226
239
|
</span>
|
|
227
240
|
) : (
|
|
228
241
|
<button
|
|
229
|
-
aria-label={
|
|
242
|
+
aria-label={
|
|
243
|
+
removeAriaLabel
|
|
244
|
+
? removeAriaLabel.replace(
|
|
245
|
+
"{name}",
|
|
246
|
+
typeof children === "string" ? children : "chip"
|
|
247
|
+
)
|
|
248
|
+
: `Remove ${typeof children === "string" ? children : "chip"}`
|
|
249
|
+
}
|
|
230
250
|
className={cn(chipDeleteButtonVariants({ size }))}
|
|
231
251
|
data-slot="chip-delete"
|
|
232
252
|
data-tracking-el={trackingEl ? `${trackingEl}-delete` : undefined}
|
|
@@ -611,6 +611,11 @@ export interface ComboboxContentProps {
|
|
|
611
611
|
* where you want to hide results until a minimum character count.
|
|
612
612
|
*/
|
|
613
613
|
hideList?: boolean;
|
|
614
|
+
/**
|
|
615
|
+
* Accessible label for the options popover.
|
|
616
|
+
* @default "Options"
|
|
617
|
+
*/
|
|
618
|
+
ariaLabel?: string;
|
|
614
619
|
}
|
|
615
620
|
|
|
616
621
|
function ComboboxContent({
|
|
@@ -622,6 +627,7 @@ function ComboboxContent({
|
|
|
622
627
|
sideOffset,
|
|
623
628
|
avoidCollisions,
|
|
624
629
|
hideList = false,
|
|
630
|
+
ariaLabel,
|
|
625
631
|
}: ComboboxContentProps) {
|
|
626
632
|
const { open, shouldFilter, filterFn, itemToStringValue } =
|
|
627
633
|
useComboboxContext();
|
|
@@ -731,7 +737,7 @@ function ComboboxContent({
|
|
|
731
737
|
<PopoverContent
|
|
732
738
|
ref={handleContentRef}
|
|
733
739
|
align={align}
|
|
734
|
-
aria-label="Options"
|
|
740
|
+
aria-label={ariaLabel ?? "Options"}
|
|
735
741
|
avoidCollisions={avoidCollisions}
|
|
736
742
|
className={cn(
|
|
737
743
|
"flex max-h-[var(--radix-popover-content-available-height)] w-[var(--radix-popover-trigger-width)] flex-col overflow-hidden p-0",
|
|
@@ -1515,9 +1521,18 @@ export interface ComboboxLoadingProps {
|
|
|
1515
1521
|
className?: string;
|
|
1516
1522
|
/** Children - custom loading content */
|
|
1517
1523
|
children?: React.ReactNode;
|
|
1524
|
+
/**
|
|
1525
|
+
* Loading text displayed next to the spinner.
|
|
1526
|
+
* @default "Loading..."
|
|
1527
|
+
*/
|
|
1528
|
+
loadingText?: string;
|
|
1518
1529
|
}
|
|
1519
1530
|
|
|
1520
|
-
function ComboboxLoading({
|
|
1531
|
+
function ComboboxLoading({
|
|
1532
|
+
className,
|
|
1533
|
+
children,
|
|
1534
|
+
loadingText,
|
|
1535
|
+
}: ComboboxLoadingProps) {
|
|
1521
1536
|
return (
|
|
1522
1537
|
<div
|
|
1523
1538
|
aria-live="polite"
|
|
@@ -1534,7 +1549,7 @@ function ComboboxLoading({ className, children }: ComboboxLoadingProps) {
|
|
|
1534
1549
|
aria-hidden="true"
|
|
1535
1550
|
className="size-4 animate-spin rounded-full border-2 border-current border-t-transparent [animation-duration:0.6s]"
|
|
1536
1551
|
/>
|
|
1537
|
-
Loading...
|
|
1552
|
+
{loadingText ?? "Loading..."}
|
|
1538
1553
|
</>
|
|
1539
1554
|
)}
|
|
1540
1555
|
</div>
|