@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
|
@@ -254,6 +254,11 @@ export interface DatePickerTriggerProps extends Omit<
|
|
|
254
254
|
* Whether the trigger has an error state
|
|
255
255
|
*/
|
|
256
256
|
error?: boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Accessible label for the trigger button.
|
|
259
|
+
* @default "Select date" (single) or "Select date range" (range)
|
|
260
|
+
*/
|
|
261
|
+
triggerLabel?: string;
|
|
257
262
|
}
|
|
258
263
|
|
|
259
264
|
/**
|
|
@@ -262,7 +267,7 @@ export interface DatePickerTriggerProps extends Omit<
|
|
|
262
267
|
const DatePickerTrigger = React.forwardRef<
|
|
263
268
|
HTMLButtonElement,
|
|
264
269
|
DatePickerTriggerProps
|
|
265
|
-
>(({ className, children, id, error, ...props }, ref) => {
|
|
270
|
+
>(({ className, children, id, error, triggerLabel, ...props }, ref) => {
|
|
266
271
|
const {
|
|
267
272
|
mode,
|
|
268
273
|
date,
|
|
@@ -315,6 +320,7 @@ const DatePickerTrigger = React.forwardRef<
|
|
|
315
320
|
ref={combinedRef}
|
|
316
321
|
aria-label={
|
|
317
322
|
props["aria-label"] ??
|
|
323
|
+
triggerLabel ??
|
|
318
324
|
(mode === "single" ? "Select date" : "Select date range")
|
|
319
325
|
}
|
|
320
326
|
className={cn(
|
|
@@ -360,6 +366,11 @@ export interface DatePickerContentProps extends Omit<
|
|
|
360
366
|
* Children to render inside the popover
|
|
361
367
|
*/
|
|
362
368
|
children: React.ReactNode;
|
|
369
|
+
/**
|
|
370
|
+
* Accessible label for the date picker popover.
|
|
371
|
+
* @default "Date picker" (single) or "Date range picker" (range)
|
|
372
|
+
*/
|
|
373
|
+
contentLabel?: string;
|
|
363
374
|
}
|
|
364
375
|
|
|
365
376
|
/**
|
|
@@ -368,14 +379,17 @@ export interface DatePickerContentProps extends Omit<
|
|
|
368
379
|
const DatePickerContent = React.forwardRef<
|
|
369
380
|
HTMLDivElement,
|
|
370
381
|
DatePickerContentProps
|
|
371
|
-
>(({ className, children, ...props }, ref) => {
|
|
382
|
+
>(({ className, children, contentLabel, ...props }, ref) => {
|
|
372
383
|
const { dataHook, mode } = useDatePickerContext();
|
|
373
384
|
|
|
374
385
|
return (
|
|
375
386
|
<PopoverContent
|
|
376
387
|
ref={ref}
|
|
377
388
|
align="start"
|
|
378
|
-
aria-label={
|
|
389
|
+
aria-label={
|
|
390
|
+
contentLabel ??
|
|
391
|
+
(mode === "single" ? "Date picker" : "Date range picker")
|
|
392
|
+
}
|
|
379
393
|
className={cn("w-auto rounded-lg p-0", className)}
|
|
380
394
|
dataHook={`${dataHook}-content`}
|
|
381
395
|
{...props}
|
|
@@ -103,6 +103,11 @@ interface DialogContentProps extends React.ComponentProps<
|
|
|
103
103
|
* Tracking label for analytics context
|
|
104
104
|
*/
|
|
105
105
|
trackingLabel?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Accessible label for the close button.
|
|
108
|
+
* @default "Close"
|
|
109
|
+
*/
|
|
110
|
+
closeLabel?: string;
|
|
106
111
|
}
|
|
107
112
|
|
|
108
113
|
/**
|
|
@@ -111,7 +116,15 @@ interface DialogContentProps extends React.ComponentProps<
|
|
|
111
116
|
*/
|
|
112
117
|
const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
|
113
118
|
(
|
|
114
|
-
{
|
|
119
|
+
{
|
|
120
|
+
className,
|
|
121
|
+
children,
|
|
122
|
+
dataHook,
|
|
123
|
+
trackingEl,
|
|
124
|
+
trackingLabel,
|
|
125
|
+
closeLabel,
|
|
126
|
+
...props
|
|
127
|
+
},
|
|
115
128
|
ref
|
|
116
129
|
) => {
|
|
117
130
|
return (
|
|
@@ -132,7 +145,7 @@ const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
132
145
|
{children}
|
|
133
146
|
<DialogPrimitive.Close className="ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-8 right-8 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">
|
|
134
147
|
<X />
|
|
135
|
-
<span className="sr-only">Close</span>
|
|
148
|
+
<span className="sr-only">{closeLabel ?? "Close"}</span>
|
|
136
149
|
</DialogPrimitive.Close>
|
|
137
150
|
</DialogPrimitive.Content>
|
|
138
151
|
</DialogPortal>
|
|
@@ -142,7 +155,7 @@ const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
142
155
|
DialogContent.displayName = "DialogContent";
|
|
143
156
|
|
|
144
157
|
/**
|
|
145
|
-
* DialogHeader - Container for dialog title and description
|
|
158
|
+
* DialogHeader - Container for dialog title and description.
|
|
146
159
|
* @description Groups the title and description at the top of the dialog
|
|
147
160
|
*/
|
|
148
161
|
const DialogHeader = React.forwardRef<
|
|
@@ -159,7 +172,7 @@ const DialogHeader = React.forwardRef<
|
|
|
159
172
|
DialogHeader.displayName = "DialogHeader";
|
|
160
173
|
|
|
161
174
|
/**
|
|
162
|
-
* DialogFooter - Container for dialog action buttons
|
|
175
|
+
* DialogFooter - Container for dialog action buttons.
|
|
163
176
|
* @description Groups action buttons at the bottom of the dialog
|
|
164
177
|
*/
|
|
165
178
|
const DialogFooter = React.forwardRef<
|
|
@@ -132,7 +132,7 @@ function DrawerContent({
|
|
|
132
132
|
DrawerContent.displayName = "DrawerContent";
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
|
-
* DrawerHeader - Container for drawer title and description
|
|
135
|
+
* DrawerHeader - Container for drawer title and description.
|
|
136
136
|
* @description Groups the title and description at the top of the drawer
|
|
137
137
|
*/
|
|
138
138
|
function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -169,7 +169,7 @@ function DrawerBody({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
169
169
|
DrawerBody.displayName = "DrawerBody";
|
|
170
170
|
|
|
171
171
|
/**
|
|
172
|
-
* DrawerFooter - Container for drawer action buttons
|
|
172
|
+
* DrawerFooter - Container for drawer action buttons.
|
|
173
173
|
* @description Groups action buttons at the bottom of the drawer
|
|
174
174
|
*/
|
|
175
175
|
function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
@@ -251,6 +251,11 @@ interface GlobalLayoutMobileHeaderProps extends React.ComponentProps<"div"> {
|
|
|
251
251
|
* Data hook for automated testing (required)
|
|
252
252
|
*/
|
|
253
253
|
dataHook: string;
|
|
254
|
+
/**
|
|
255
|
+
* Accessible label for the mobile navigation toolbar.
|
|
256
|
+
* @default "Mobile navigation"
|
|
257
|
+
*/
|
|
258
|
+
ariaLabel?: string;
|
|
254
259
|
/**
|
|
255
260
|
* Tracking element identifier for analytics
|
|
256
261
|
*/
|
|
@@ -266,13 +271,21 @@ const GlobalLayoutMobileHeader = React.forwardRef<
|
|
|
266
271
|
GlobalLayoutMobileHeaderProps
|
|
267
272
|
>(
|
|
268
273
|
(
|
|
269
|
-
{
|
|
274
|
+
{
|
|
275
|
+
className,
|
|
276
|
+
dataHook,
|
|
277
|
+
ariaLabel,
|
|
278
|
+
trackingEl,
|
|
279
|
+
trackingLabel,
|
|
280
|
+
children,
|
|
281
|
+
...props
|
|
282
|
+
},
|
|
270
283
|
ref
|
|
271
284
|
) => {
|
|
272
285
|
return (
|
|
273
286
|
<div
|
|
274
287
|
ref={ref}
|
|
275
|
-
aria-label="Mobile navigation"
|
|
288
|
+
aria-label={ariaLabel ?? "Mobile navigation"}
|
|
276
289
|
className={cn(
|
|
277
290
|
"flex w-full items-center justify-start gap-2.5 py-2 lg:hidden",
|
|
278
291
|
className
|
|
@@ -28,18 +28,70 @@ interface InputChipContextValue {
|
|
|
28
28
|
chipRefs: React.RefObject<(HTMLDivElement | null)[]>;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
31
|
+
interface InputChipDispatchContextValue {
|
|
32
|
+
onValueChange: (value: string[]) => void;
|
|
33
|
+
setInputValue: (value: string) => void;
|
|
34
|
+
addItem: (item: string) => void;
|
|
35
|
+
removeItem: (index: number) => void;
|
|
36
|
+
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
37
|
+
setFocusedChipIndex: (index: number) => void;
|
|
38
|
+
chipRefs: React.RefObject<(HTMLDivElement | null)[]>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface InputChipValueContextValue {
|
|
42
|
+
value: string[];
|
|
43
|
+
disabled: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface InputChipInputContextValue {
|
|
47
|
+
inputValue: string;
|
|
48
|
+
focusedChipIndex: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const InputChipDispatchContext =
|
|
52
|
+
React.createContext<InputChipDispatchContextValue | null>(null);
|
|
53
|
+
const InputChipValueContext =
|
|
54
|
+
React.createContext<InputChipValueContextValue | null>(null);
|
|
55
|
+
const InputChipInputContext =
|
|
56
|
+
React.createContext<InputChipInputContextValue | null>(null);
|
|
57
|
+
|
|
58
|
+
function useInputChipDispatch() {
|
|
59
|
+
const context = React.useContext(InputChipDispatchContext);
|
|
60
|
+
if (!context) {
|
|
61
|
+
throw new Error("InputChip components must be used within an <InputChip>");
|
|
62
|
+
}
|
|
63
|
+
return context;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function useInputChipValue() {
|
|
67
|
+
const context = React.useContext(InputChipValueContext);
|
|
68
|
+
if (!context) {
|
|
69
|
+
throw new Error("InputChip components must be used within an <InputChip>");
|
|
70
|
+
}
|
|
71
|
+
return context;
|
|
72
|
+
}
|
|
34
73
|
|
|
35
|
-
function
|
|
36
|
-
const context = React.useContext(
|
|
74
|
+
function useInputChipInput() {
|
|
75
|
+
const context = React.useContext(InputChipInputContext);
|
|
37
76
|
if (!context) {
|
|
38
77
|
throw new Error("InputChip components must be used within an <InputChip>");
|
|
39
78
|
}
|
|
40
79
|
return context;
|
|
41
80
|
}
|
|
42
81
|
|
|
82
|
+
function useInputChipContext(): InputChipContextValue {
|
|
83
|
+
const dispatch = useInputChipDispatch();
|
|
84
|
+
const { value, disabled } = useInputChipValue();
|
|
85
|
+
const { inputValue, focusedChipIndex } = useInputChipInput();
|
|
86
|
+
return {
|
|
87
|
+
...dispatch,
|
|
88
|
+
value,
|
|
89
|
+
disabled,
|
|
90
|
+
inputValue,
|
|
91
|
+
focusedChipIndex,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
43
95
|
/* -------------------------------------------------------------------------------------------------
|
|
44
96
|
* InputChip (Context provider)
|
|
45
97
|
* -----------------------------------------------------------------------------------------------*/
|
|
@@ -98,12 +150,20 @@ function InputChip({
|
|
|
98
150
|
const isControlled = controlledValue !== undefined;
|
|
99
151
|
const value = isControlled ? controlledValue : uncontrolledValue;
|
|
100
152
|
|
|
153
|
+
const valueRef = React.useRef(value);
|
|
154
|
+
const controlledOnValueChangeRef = React.useRef(controlledOnValueChange);
|
|
155
|
+
const disabledRef = React.useRef(disabled);
|
|
156
|
+
React.useLayoutEffect(() => {
|
|
157
|
+
valueRef.current = value;
|
|
158
|
+
controlledOnValueChangeRef.current = controlledOnValueChange;
|
|
159
|
+
disabledRef.current = disabled;
|
|
160
|
+
});
|
|
161
|
+
|
|
101
162
|
// Cleanup when chips are removed: trim refs and reset stale focus index
|
|
102
163
|
React.useEffect(() => {
|
|
103
164
|
if (chipRefs.current.length > value.length) {
|
|
104
165
|
chipRefs.current.length = value.length;
|
|
105
166
|
}
|
|
106
|
-
// Reset focus index if it's out of bounds (e.g., chip was removed externally)
|
|
107
167
|
if (focusedChipIndex >= value.length) {
|
|
108
168
|
setFocusedChipIndex(-1);
|
|
109
169
|
}
|
|
@@ -114,64 +174,62 @@ function InputChip({
|
|
|
114
174
|
if (!isControlled) {
|
|
115
175
|
setUncontrolledValue(newValue);
|
|
116
176
|
}
|
|
117
|
-
|
|
177
|
+
controlledOnValueChangeRef.current?.(newValue);
|
|
118
178
|
},
|
|
119
|
-
[isControlled
|
|
179
|
+
[isControlled]
|
|
120
180
|
);
|
|
121
181
|
|
|
122
182
|
const addItem = React.useCallback(
|
|
123
183
|
(item: string) => {
|
|
124
|
-
if (
|
|
184
|
+
if (disabledRef.current) return;
|
|
125
185
|
const trimmed = item.trim();
|
|
126
|
-
if (trimmed && (allowDuplicates || !
|
|
127
|
-
onValueChange([...
|
|
186
|
+
if (trimmed && (allowDuplicates || !valueRef.current.includes(trimmed))) {
|
|
187
|
+
onValueChange([...valueRef.current, trimmed]);
|
|
128
188
|
setInputValue("");
|
|
129
189
|
}
|
|
130
190
|
},
|
|
131
|
-
[
|
|
191
|
+
[allowDuplicates, onValueChange]
|
|
132
192
|
);
|
|
133
193
|
|
|
134
194
|
const removeItem = React.useCallback(
|
|
135
195
|
(index: number) => {
|
|
136
|
-
if (
|
|
137
|
-
onValueChange(
|
|
196
|
+
if (disabledRef.current) return;
|
|
197
|
+
onValueChange(valueRef.current.filter((_, i) => i !== index));
|
|
138
198
|
},
|
|
139
|
-
[
|
|
199
|
+
[onValueChange]
|
|
140
200
|
);
|
|
141
201
|
|
|
142
|
-
const
|
|
202
|
+
const dispatchValue = React.useMemo<InputChipDispatchContextValue>(
|
|
143
203
|
() => ({
|
|
144
|
-
value,
|
|
145
204
|
onValueChange,
|
|
146
|
-
inputValue,
|
|
147
205
|
setInputValue,
|
|
148
|
-
disabled,
|
|
149
206
|
addItem,
|
|
150
207
|
removeItem,
|
|
151
208
|
inputRef,
|
|
152
|
-
focusedChipIndex,
|
|
153
209
|
setFocusedChipIndex,
|
|
154
210
|
chipRefs,
|
|
155
211
|
}),
|
|
156
|
-
[
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
chipRefs,
|
|
168
|
-
]
|
|
212
|
+
[onValueChange, addItem, removeItem]
|
|
213
|
+
);
|
|
214
|
+
|
|
215
|
+
const valueContextValue = React.useMemo<InputChipValueContextValue>(
|
|
216
|
+
() => ({ value, disabled }),
|
|
217
|
+
[value, disabled]
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const inputContextValue = React.useMemo<InputChipInputContextValue>(
|
|
221
|
+
() => ({ inputValue, focusedChipIndex }),
|
|
222
|
+
[inputValue, focusedChipIndex]
|
|
169
223
|
);
|
|
170
224
|
|
|
171
225
|
return (
|
|
172
|
-
<
|
|
173
|
-
{
|
|
174
|
-
|
|
226
|
+
<InputChipDispatchContext.Provider value={dispatchValue}>
|
|
227
|
+
<InputChipValueContext.Provider value={valueContextValue}>
|
|
228
|
+
<InputChipInputContext.Provider value={inputContextValue}>
|
|
229
|
+
{children}
|
|
230
|
+
</InputChipInputContext.Provider>
|
|
231
|
+
</InputChipValueContext.Provider>
|
|
232
|
+
</InputChipDispatchContext.Provider>
|
|
175
233
|
);
|
|
176
234
|
}
|
|
177
235
|
|
|
@@ -290,16 +348,10 @@ const InputChipInput = React.forwardRef<HTMLDivElement, InputChipInputProps>(
|
|
|
290
348
|
},
|
|
291
349
|
ref
|
|
292
350
|
) => {
|
|
293
|
-
const {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
disabled,
|
|
298
|
-
addItem,
|
|
299
|
-
inputRef,
|
|
300
|
-
setFocusedChipIndex,
|
|
301
|
-
chipRefs,
|
|
302
|
-
} = useInputChipContext();
|
|
351
|
+
const { setInputValue, addItem, inputRef, setFocusedChipIndex, chipRefs } =
|
|
352
|
+
useInputChipDispatch();
|
|
353
|
+
const { value, disabled } = useInputChipValue();
|
|
354
|
+
const { inputValue } = useInputChipInput();
|
|
303
355
|
|
|
304
356
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
305
357
|
setInputValue(e.target.value);
|
|
@@ -368,6 +420,12 @@ export interface InputChipItemsProps {
|
|
|
368
420
|
className?: string;
|
|
369
421
|
/** Data hook prefix for chips */
|
|
370
422
|
dataHookPrefix?: string;
|
|
423
|
+
/**
|
|
424
|
+
* Accessible label for each chip item.
|
|
425
|
+
* Supports `{item}` placeholder for interpolation.
|
|
426
|
+
* @default "{item}, press Delete to remove"
|
|
427
|
+
*/
|
|
428
|
+
itemAriaLabel?: string;
|
|
371
429
|
}
|
|
372
430
|
|
|
373
431
|
/**
|
|
@@ -377,15 +435,11 @@ export interface InputChipItemsProps {
|
|
|
377
435
|
function InputChipItems({
|
|
378
436
|
className,
|
|
379
437
|
dataHookPrefix = "chip",
|
|
438
|
+
itemAriaLabel,
|
|
380
439
|
}: InputChipItemsProps) {
|
|
381
|
-
const {
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
removeItem,
|
|
385
|
-
inputRef,
|
|
386
|
-
setFocusedChipIndex,
|
|
387
|
-
chipRefs,
|
|
388
|
-
} = useInputChipContext();
|
|
440
|
+
const { removeItem, inputRef, setFocusedChipIndex, chipRefs } =
|
|
441
|
+
useInputChipDispatch();
|
|
442
|
+
const { value, disabled } = useInputChipValue();
|
|
389
443
|
|
|
390
444
|
// Track pending focus to apply after DOM updates (avoids race conditions with rapid deletions)
|
|
391
445
|
const pendingFocusRef = React.useRef<number | "input" | null>(null);
|
|
@@ -511,7 +565,11 @@ function InputChipItems({
|
|
|
511
565
|
ref={(el) => {
|
|
512
566
|
chipRefs.current[index] = el;
|
|
513
567
|
}}
|
|
514
|
-
aria-label={
|
|
568
|
+
aria-label={
|
|
569
|
+
itemAriaLabel
|
|
570
|
+
? itemAriaLabel.replace("{item}", item)
|
|
571
|
+
: `${item}, press Delete to remove`
|
|
572
|
+
}
|
|
515
573
|
dataHook={`${dataHookPrefix}-${index}`}
|
|
516
574
|
disabled={disabled}
|
|
517
575
|
role="group"
|
|
@@ -532,14 +590,4 @@ function InputChipItems({
|
|
|
532
590
|
* Exports
|
|
533
591
|
* -----------------------------------------------------------------------------------------------*/
|
|
534
592
|
|
|
535
|
-
|
|
536
|
-
const inputChipVariants = inputChipInputVariants;
|
|
537
|
-
|
|
538
|
-
export {
|
|
539
|
-
InputChip,
|
|
540
|
-
InputChipInput,
|
|
541
|
-
InputChipItems,
|
|
542
|
-
inputChipVariants,
|
|
543
|
-
inputChipInputVariants,
|
|
544
|
-
useInputChipContext,
|
|
545
|
-
};
|
|
593
|
+
export { InputChip, InputChipInput, InputChipItems, useInputChipContext };
|
|
@@ -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
|
);
|