@brightlocal/ui-components 2.19.0 → 2.21.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/AI_USAGE.md +2 -0
- package/README.md +27 -14
- package/component-meta.json +27 -11
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +34 -33
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +14 -16
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +20 -2
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +99 -89
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +9 -6
- package/dist/browser-entry.d.ts +2 -0
- package/dist/browser-entry.d.ts.map +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +12 -12
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +47 -46
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +35 -34
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +48 -47
- package/dist/hooks/use-overlay-pointer-lock.cjs +1 -0
- package/dist/hooks/use-overlay-pointer-lock.d.ts +20 -0
- package/dist/hooks/use-overlay-pointer-lock.d.ts.map +1 -0
- package/dist/hooks/use-overlay-pointer-lock.js +39 -0
- 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 +88 -86
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +1 -1
- package/dist/logo.js +2 -2
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts +19 -0
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +134 -96
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.d.ts +12 -8
- package/dist/pagination.d.ts.map +1 -1
- package/dist/pagination.js +117 -113
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +21 -20
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +28 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +90 -49
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +25 -23
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +14 -0
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +90 -44
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +29 -28
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/sonner.d.ts +1 -1
- package/package.json +5 -1
- package/src/blocks/data-table.tsx +0 -2
- package/src/blocks/sidebar.tsx +40 -13
- package/src/browser-entry.ts +10 -0
- package/src/components/alert-dialog.tsx +20 -14
- package/src/components/breadcrumb.tsx +6 -3
- package/src/components/button.tsx +7 -1
- package/src/components/context-menu.tsx +19 -13
- package/src/components/dialog.tsx +4 -0
- package/src/components/dropdown-menu.tsx +4 -0
- package/src/components/logo.tsx +3 -3
- package/src/components/navigation-menu.tsx +134 -32
- package/src/components/pagination.tsx +47 -67
- package/src/components/popover.tsx +22 -16
- package/src/components/progress.tsx +118 -14
- package/src/components/select.tsx +4 -0
- package/src/components/separator.tsx +91 -23
- package/src/components/sheet.tsx +4 -0
- package/src/components/skeleton.tsx +1 -1
- package/src/components/sonner.tsx +1 -1
- package/src/hooks/use-overlay-pointer-lock.ts +128 -0
- package/src/index.ts +1 -0
|
@@ -2,6 +2,7 @@ import * as React from "react";
|
|
|
2
2
|
import { ChevronLeft, ChevronRight, MoreHorizontal } from "@brightlocal/icons";
|
|
3
3
|
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
4
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
import { useIsBelowBreakpoint } from "@brightlocal/ui-components/hooks/use-breakpoint";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Pagination item variants
|
|
@@ -20,10 +21,6 @@ export interface UsePaginationParams {
|
|
|
20
21
|
page: number;
|
|
21
22
|
/** Total number of pages */
|
|
22
23
|
totalPages: number;
|
|
23
|
-
/** Number of siblings to show on each side of current page */
|
|
24
|
-
siblingCount?: number;
|
|
25
|
-
/** Number of boundary pages to show at start and end */
|
|
26
|
-
boundaryCount?: number;
|
|
27
24
|
}
|
|
28
25
|
|
|
29
26
|
/**
|
|
@@ -32,88 +29,66 @@ export interface UsePaginationParams {
|
|
|
32
29
|
type PaginationItemType = number | "previous" | "next" | "ellipsis";
|
|
33
30
|
|
|
34
31
|
/**
|
|
35
|
-
* Custom hook for pagination logic
|
|
36
|
-
* Returns
|
|
32
|
+
* Custom hook for pagination logic.
|
|
33
|
+
* Returns a fixed-width list of pagination items — the count never changes
|
|
34
|
+
* as the user navigates. Page 1 and totalPages are always visible as boundary
|
|
35
|
+
* anchors. Ellipsis only appears when hiding 2+ pages.
|
|
37
36
|
*
|
|
38
37
|
* @example
|
|
39
|
-
* const items = usePagination({ page:
|
|
38
|
+
* const items = usePagination({ page: 2, totalPages: 10 });
|
|
39
|
+
* // Returns: ["previous", 1, 2, 3, 4, 5, "ellipsis", 10, "next"]
|
|
40
|
+
*
|
|
41
|
+
* const items = usePagination({ page: 5, totalPages: 10 });
|
|
40
42
|
* // Returns: ["previous", 1, "ellipsis", 4, 5, 6, "ellipsis", 10, "next"]
|
|
43
|
+
*
|
|
44
|
+
* // Automatically uses 5 slots below the `sm` breakpoint (640px)
|
|
45
|
+
* const items = usePagination({ page, totalPages });
|
|
41
46
|
*/
|
|
42
47
|
export function usePagination({
|
|
43
48
|
page,
|
|
44
49
|
totalPages,
|
|
45
|
-
siblingCount = 1,
|
|
46
|
-
boundaryCount = 1,
|
|
47
50
|
}: UsePaginationParams): PaginationItemType[] {
|
|
51
|
+
const isCompact = useIsBelowBreakpoint("sm");
|
|
52
|
+
const maxVisible = isCompact ? 5 : 7;
|
|
53
|
+
|
|
48
54
|
const items: PaginationItemType[] = React.useMemo(() => {
|
|
55
|
+
const slots = Math.max(5, maxVisible);
|
|
49
56
|
const result: PaginationItemType[] = [];
|
|
50
57
|
|
|
51
|
-
// Add previous button
|
|
52
58
|
result.push("previous");
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const rightSiblingIndex = Math.min(
|
|
57
|
-
page + siblingCount,
|
|
58
|
-
totalPages - boundaryCount
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const showLeftEllipsis = leftSiblingIndex > boundaryCount + 2;
|
|
62
|
-
const showRightEllipsis =
|
|
63
|
-
rightSiblingIndex < totalPages - boundaryCount - 1;
|
|
64
|
-
|
|
65
|
-
// Add first boundary pages
|
|
66
|
-
for (let i = 1; i <= Math.min(boundaryCount, totalPages); i++) {
|
|
67
|
-
result.push(i);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// Add left ellipsis if needed
|
|
71
|
-
if (showLeftEllipsis) {
|
|
72
|
-
result.push("ellipsis");
|
|
73
|
-
} else if (boundaryCount + 1 < leftSiblingIndex) {
|
|
74
|
-
// Add pages between boundary and left sibling
|
|
75
|
-
for (let i = boundaryCount + 1; i < leftSiblingIndex; i++) {
|
|
76
|
-
result.push(i);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Add sibling pages around current page
|
|
81
|
-
for (let i = leftSiblingIndex; i <= rightSiblingIndex; i++) {
|
|
82
|
-
if (i > boundaryCount && i <= totalPages - boundaryCount) {
|
|
60
|
+
if (totalPages <= slots) {
|
|
61
|
+
for (let i = 1; i <= totalPages; i++) {
|
|
83
62
|
result.push(i);
|
|
84
63
|
}
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
) {
|
|
107
|
-
if (i > boundaryCount) {
|
|
108
|
-
result.push(i);
|
|
64
|
+
} else {
|
|
65
|
+
const siblings = Math.floor((slots - 5) / 2);
|
|
66
|
+
const startThreshold = slots - 3; // e.g. 4 for slots=7, 2 for slots=5
|
|
67
|
+
const endThreshold = totalPages - startThreshold;
|
|
68
|
+
|
|
69
|
+
if (page <= startThreshold) {
|
|
70
|
+
for (let i = 1; i <= slots - 2; i++) {
|
|
71
|
+
result.push(i);
|
|
72
|
+
}
|
|
73
|
+
result.push("ellipsis", totalPages);
|
|
74
|
+
} else if (page >= endThreshold) {
|
|
75
|
+
result.push(1, "ellipsis");
|
|
76
|
+
for (let i = totalPages - (slots - 3); i <= totalPages; i++) {
|
|
77
|
+
result.push(i);
|
|
78
|
+
}
|
|
79
|
+
} else {
|
|
80
|
+
result.push(1, "ellipsis");
|
|
81
|
+
for (let i = page - siblings; i <= page + siblings; i++) {
|
|
82
|
+
result.push(i);
|
|
83
|
+
}
|
|
84
|
+
result.push("ellipsis", totalPages);
|
|
109
85
|
}
|
|
110
86
|
}
|
|
111
87
|
|
|
112
|
-
// Add next button
|
|
113
88
|
result.push("next");
|
|
114
89
|
|
|
115
90
|
return result;
|
|
116
|
-
}, [page, totalPages,
|
|
91
|
+
}, [page, totalPages, maxVisible]);
|
|
117
92
|
|
|
118
93
|
return items;
|
|
119
94
|
}
|
|
@@ -125,7 +100,7 @@ const paginationItemVariants = cva(
|
|
|
125
100
|
"h-9 w-9",
|
|
126
101
|
"rounded-full",
|
|
127
102
|
"text-sm font-medium",
|
|
128
|
-
"transition-colors",
|
|
103
|
+
"transition-colors duration-200 ease-out",
|
|
129
104
|
"focus-visible:outline-none focus-visible:shadow-default",
|
|
130
105
|
],
|
|
131
106
|
{
|
|
@@ -154,7 +129,12 @@ const paginationItemVariants = cva(
|
|
|
154
129
|
// Disabled state
|
|
155
130
|
"aria-disabled:opacity-50 aria-disabled:cursor-default aria-disabled:pointer-events-none",
|
|
156
131
|
],
|
|
157
|
-
ellipsis: [
|
|
132
|
+
ellipsis: [
|
|
133
|
+
"relative",
|
|
134
|
+
"cursor-default",
|
|
135
|
+
"text-foreground",
|
|
136
|
+
"pointer-events-none",
|
|
137
|
+
],
|
|
158
138
|
},
|
|
159
139
|
},
|
|
160
140
|
defaultVariants: {
|
|
@@ -4,6 +4,7 @@ import * as React from "react";
|
|
|
4
4
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
5
|
|
|
6
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
7
|
+
import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
|
|
7
8
|
|
|
8
9
|
export interface PopoverProps extends React.ComponentProps<
|
|
9
10
|
typeof PopoverPrimitive.Root
|
|
@@ -82,22 +83,27 @@ const PopoverContent = React.forwardRef<
|
|
|
82
83
|
(
|
|
83
84
|
{ className, align = "center", sideOffset = 4, dataHook, ...props },
|
|
84
85
|
ref
|
|
85
|
-
) =>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
86
|
+
) => {
|
|
87
|
+
// Safety net for the Radix dismissable-layer body-lock leak (DS-634).
|
|
88
|
+
useOverlayPointerLock();
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<PopoverPrimitive.Portal>
|
|
92
|
+
<PopoverPrimitive.Content
|
|
93
|
+
ref={ref}
|
|
94
|
+
align={align}
|
|
95
|
+
className={cn(
|
|
96
|
+
"bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
|
97
|
+
className
|
|
98
|
+
)}
|
|
99
|
+
data-hook={dataHook}
|
|
100
|
+
data-slot="popover-content"
|
|
101
|
+
sideOffset={sideOffset}
|
|
102
|
+
{...props}
|
|
103
|
+
/>
|
|
104
|
+
</PopoverPrimitive.Portal>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
101
107
|
);
|
|
102
108
|
PopoverContent.displayName = "PopoverContent";
|
|
103
109
|
|
|
@@ -7,6 +7,71 @@ import { motion } from "framer-motion";
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
import { usePrefersReducedMotion } from "@brightlocal/ui-components/hooks/use-prefers-reduced-motion";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Brand color for the progress indicator, drawn from the shared brand palette.
|
|
12
|
+
* - `green` — strong / healthy / complete
|
|
13
|
+
* - `yellow` — moderate / acceptable
|
|
14
|
+
* - `orange` — weak / needs attention
|
|
15
|
+
* - `red` — critical / urgent
|
|
16
|
+
*/
|
|
17
|
+
type ProgressColor = "green" | "red" | "orange" | "yellow";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Track and indicator color classes for each brand color.
|
|
21
|
+
* Single source of truth — the `/20` track tint blends with the surface so it
|
|
22
|
+
* adapts automatically to light and dark modes.
|
|
23
|
+
*/
|
|
24
|
+
const COLOR_STYLES: Record<
|
|
25
|
+
ProgressColor,
|
|
26
|
+
{ track: string; indicator: string }
|
|
27
|
+
> = {
|
|
28
|
+
green: {
|
|
29
|
+
track: "bg-brand-primary-foreground/20",
|
|
30
|
+
indicator: "bg-green-400",
|
|
31
|
+
},
|
|
32
|
+
red: {
|
|
33
|
+
track: "bg-brand-red/20",
|
|
34
|
+
indicator: "bg-brand-red",
|
|
35
|
+
},
|
|
36
|
+
orange: {
|
|
37
|
+
track: "bg-brand-orange/20",
|
|
38
|
+
indicator: "bg-brand-orange",
|
|
39
|
+
},
|
|
40
|
+
yellow: {
|
|
41
|
+
track: "bg-brand-yellow/20",
|
|
42
|
+
indicator: "bg-brand-yellow",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Formats the numeric value shown beside the progress bar.
|
|
48
|
+
* - Percentage form (`unit === "%"`): the value as a percentage of `max`,
|
|
49
|
+
* clamped to 0–100 to match the bar fill, e.g. `90` of `100` → `"90%"`,
|
|
50
|
+
* `3` of `5` → `"60%"`
|
|
51
|
+
* - Fraction form (any other unit): `"3 / 5 steps"`, `"45 / 60 min"`, `"90 / 100"`
|
|
52
|
+
* - No value: falls back to `"–"` so the row layout stays consistent.
|
|
53
|
+
* @param value - Current progress value.
|
|
54
|
+
* @param max - Maximum progress value (denominator).
|
|
55
|
+
* @param unit - Optional unit/suffix, e.g. `"%"`, `"steps"`, `"min"`.
|
|
56
|
+
*/
|
|
57
|
+
function formatProgressValue(
|
|
58
|
+
value: number | null | undefined,
|
|
59
|
+
max: number,
|
|
60
|
+
unit: string
|
|
61
|
+
): string {
|
|
62
|
+
if (value === null || value === undefined) {
|
|
63
|
+
return "–";
|
|
64
|
+
}
|
|
65
|
+
if (unit === "%") {
|
|
66
|
+
const percentage =
|
|
67
|
+
max > 0 ? Math.min(100, Math.max(0, Math.round((value / max) * 100))) : 0;
|
|
68
|
+
return `${percentage}%`;
|
|
69
|
+
}
|
|
70
|
+
// Only show the denominator when max is a meaningful positive number.
|
|
71
|
+
const suffix = unit ? ` ${unit}` : "";
|
|
72
|
+
return max > 0 ? `${value} / ${max}${suffix}` : `${value}${suffix}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
10
75
|
/**
|
|
11
76
|
* Props for the Progress component.
|
|
12
77
|
*/
|
|
@@ -31,9 +96,27 @@ interface ProgressProps extends React.ComponentProps<
|
|
|
31
96
|
*/
|
|
32
97
|
ariaLabel?: string;
|
|
33
98
|
/**
|
|
34
|
-
* Optional visible label text displayed
|
|
99
|
+
* Optional visible label text displayed to the left of the progress bar
|
|
35
100
|
*/
|
|
36
101
|
label?: string;
|
|
102
|
+
/**
|
|
103
|
+
* Brand color for the indicator.
|
|
104
|
+
* @default "green"
|
|
105
|
+
*/
|
|
106
|
+
color?: ProgressColor;
|
|
107
|
+
/**
|
|
108
|
+
* Whether to render the numeric value to the right of the progress bar.
|
|
109
|
+
* Falls back to `–` when no value is provided so the layout stays consistent.
|
|
110
|
+
* @default false
|
|
111
|
+
*/
|
|
112
|
+
showValue?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Unit/suffix appended to the displayed value. Use `"%"` for percentage form
|
|
115
|
+
* (value as a percentage of `max`, e.g. `90%`); any other unit renders
|
|
116
|
+
* fraction form (`3 / 5 steps`).
|
|
117
|
+
* @default "%"
|
|
118
|
+
*/
|
|
119
|
+
unit?: string;
|
|
37
120
|
/**
|
|
38
121
|
* Custom class name for the indicator (progress fill)
|
|
39
122
|
* Use this to customize the color, e.g., "bg-red-500"
|
|
@@ -58,11 +141,15 @@ const Progress = React.forwardRef<
|
|
|
58
141
|
{
|
|
59
142
|
className,
|
|
60
143
|
value,
|
|
144
|
+
max = 100,
|
|
61
145
|
dataHook,
|
|
62
146
|
trackingEl,
|
|
63
147
|
trackingLabel,
|
|
64
148
|
ariaLabel = "Progress",
|
|
65
149
|
label,
|
|
150
|
+
color = "green",
|
|
151
|
+
showValue = false,
|
|
152
|
+
unit = "%",
|
|
66
153
|
indicatorClassName,
|
|
67
154
|
disabled,
|
|
68
155
|
...props
|
|
@@ -73,6 +160,10 @@ const Progress = React.forwardRef<
|
|
|
73
160
|
const hasVisibleLabel = !!label;
|
|
74
161
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
75
162
|
|
|
163
|
+
const colorStyles = COLOR_STYLES[color] ?? COLOR_STYLES.green;
|
|
164
|
+
const percentage =
|
|
165
|
+
max > 0 ? Math.min(100, Math.max(0, ((value ?? 0) / max) * 100)) : 0;
|
|
166
|
+
|
|
76
167
|
const progressBar = (
|
|
77
168
|
<ProgressPrimitive.Root
|
|
78
169
|
ref={ref}
|
|
@@ -80,23 +171,26 @@ const Progress = React.forwardRef<
|
|
|
80
171
|
aria-labelledby={hasVisibleLabel ? labelId : undefined}
|
|
81
172
|
className={cn(
|
|
82
173
|
"relative h-2 w-full overflow-hidden rounded-full",
|
|
83
|
-
|
|
84
|
-
!hasVisibleLabel && disabled && "opacity-50",
|
|
174
|
+
colorStyles.track,
|
|
175
|
+
!hasVisibleLabel && !showValue && disabled && "opacity-50",
|
|
85
176
|
className
|
|
86
177
|
)}
|
|
87
178
|
data-hook={dataHook}
|
|
88
179
|
data-slot="progress"
|
|
89
180
|
data-tracking-el={trackingEl}
|
|
90
181
|
data-tracking-label={trackingLabel}
|
|
182
|
+
max={max}
|
|
183
|
+
value={value}
|
|
91
184
|
{...props}
|
|
92
185
|
>
|
|
93
186
|
<ProgressPrimitive.Indicator asChild>
|
|
94
187
|
<motion.div
|
|
95
188
|
animate={{
|
|
96
|
-
transform: `translateX(-${100 -
|
|
189
|
+
transform: `translateX(-${100 - percentage}%)`,
|
|
97
190
|
}}
|
|
98
191
|
className={cn(
|
|
99
|
-
"h-full w-full flex-1
|
|
192
|
+
"h-full w-full flex-1",
|
|
193
|
+
colorStyles.indicator,
|
|
100
194
|
indicatorClassName
|
|
101
195
|
)}
|
|
102
196
|
data-slot="progress-indicator"
|
|
@@ -116,7 +210,7 @@ const Progress = React.forwardRef<
|
|
|
116
210
|
</ProgressPrimitive.Root>
|
|
117
211
|
);
|
|
118
212
|
|
|
119
|
-
if (!
|
|
213
|
+
if (!hasVisibleLabel && !showValue) {
|
|
120
214
|
return progressBar;
|
|
121
215
|
}
|
|
122
216
|
|
|
@@ -128,14 +222,24 @@ const Progress = React.forwardRef<
|
|
|
128
222
|
)}
|
|
129
223
|
data-slot="progress-wrapper"
|
|
130
224
|
>
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
225
|
+
{hasVisibleLabel && (
|
|
226
|
+
<span
|
|
227
|
+
className="text-foreground text-xs leading-none font-medium"
|
|
228
|
+
data-slot="progress-label"
|
|
229
|
+
id={labelId}
|
|
230
|
+
>
|
|
231
|
+
{label}
|
|
232
|
+
</span>
|
|
233
|
+
)}
|
|
138
234
|
{progressBar}
|
|
235
|
+
{showValue && (
|
|
236
|
+
<span
|
|
237
|
+
className="text-muted-foreground shrink-0 text-xs leading-none tabular-nums"
|
|
238
|
+
data-slot="progress-value"
|
|
239
|
+
>
|
|
240
|
+
{formatProgressValue(value, max, unit)}
|
|
241
|
+
</span>
|
|
242
|
+
)}
|
|
139
243
|
</div>
|
|
140
244
|
);
|
|
141
245
|
}
|
|
@@ -144,4 +248,4 @@ const Progress = React.forwardRef<
|
|
|
144
248
|
Progress.displayName = "Progress";
|
|
145
249
|
|
|
146
250
|
export { Progress };
|
|
147
|
-
export type { ProgressProps };
|
|
251
|
+
export type { ProgressProps, ProgressColor };
|
|
@@ -7,6 +7,7 @@ import { cva } from "class-variance-authority";
|
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
9
|
import { useDevWarning } from "../lib/use-dev-warning";
|
|
10
|
+
import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
|
|
10
11
|
|
|
11
12
|
// ============================================================================
|
|
12
13
|
// Types
|
|
@@ -206,6 +207,9 @@ function SelectContent({
|
|
|
206
207
|
style,
|
|
207
208
|
...props
|
|
208
209
|
}: SelectContentProps) {
|
|
210
|
+
// Safety net for the Radix dismissable-layer body-lock leak (DS-634).
|
|
211
|
+
useOverlayPointerLock();
|
|
212
|
+
|
|
209
213
|
const viewportRef = React.useRef<HTMLDivElement>(null);
|
|
210
214
|
|
|
211
215
|
useDevWarning(
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
4
5
|
|
|
5
6
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
7
|
|
|
@@ -9,6 +10,54 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
9
10
|
*/
|
|
10
11
|
export type SeparatorOrientation = "horizontal" | "vertical";
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Spacing variants for Separator
|
|
15
|
+
*/
|
|
16
|
+
export type SeparatorSpacing = "default" | "sm" | "md" | "lg";
|
|
17
|
+
|
|
18
|
+
const separatorStyles = cva("bg-border shrink-0", {
|
|
19
|
+
variants: {
|
|
20
|
+
orientation: {
|
|
21
|
+
horizontal: "h-px border-0",
|
|
22
|
+
vertical: "w-px",
|
|
23
|
+
},
|
|
24
|
+
spacing: {
|
|
25
|
+
default: "",
|
|
26
|
+
sm: "",
|
|
27
|
+
md: "",
|
|
28
|
+
lg: "",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
compoundVariants: [
|
|
32
|
+
{ orientation: "horizontal", spacing: "default", className: "w-full" },
|
|
33
|
+
{ orientation: "horizontal", spacing: "sm", className: "my-2 mx-6 w-auto" },
|
|
34
|
+
{ orientation: "horizontal", spacing: "md", className: "my-4 mx-6 w-auto" },
|
|
35
|
+
{ orientation: "horizontal", spacing: "lg", className: "m-6 w-auto" },
|
|
36
|
+
{ orientation: "vertical", spacing: "default", className: "h-full" },
|
|
37
|
+
{ orientation: "vertical", spacing: "sm", className: "self-stretch mx-2" },
|
|
38
|
+
{ orientation: "vertical", spacing: "md", className: "self-stretch mx-4" },
|
|
39
|
+
{ orientation: "vertical", spacing: "lg", className: "self-stretch mx-6" },
|
|
40
|
+
],
|
|
41
|
+
defaultVariants: {
|
|
42
|
+
orientation: "horizontal",
|
|
43
|
+
spacing: "default",
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const separatorWithTextStyles = cva("flex items-center gap-2", {
|
|
48
|
+
variants: {
|
|
49
|
+
spacing: {
|
|
50
|
+
default: "",
|
|
51
|
+
sm: "py-2 px-6",
|
|
52
|
+
md: "py-4 px-6",
|
|
53
|
+
lg: "p-6",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
defaultVariants: {
|
|
57
|
+
spacing: "default",
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
|
|
12
61
|
/**
|
|
13
62
|
* Props for the Separator component.
|
|
14
63
|
*/
|
|
@@ -19,6 +68,11 @@ interface SeparatorProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
|
19
68
|
* @default "horizontal"
|
|
20
69
|
*/
|
|
21
70
|
orientation?: SeparatorOrientation;
|
|
71
|
+
/**
|
|
72
|
+
* Controls the spacing around the separator.
|
|
73
|
+
* @default "default"
|
|
74
|
+
*/
|
|
75
|
+
spacing?: SeparatorSpacing;
|
|
22
76
|
/**
|
|
23
77
|
* When true, the separator is purely decorative (role="none").
|
|
24
78
|
* When false, it carries separator semantics for assistive technology.
|
|
@@ -49,6 +103,7 @@ const Separator = React.forwardRef<HTMLElement, SeparatorProps>(
|
|
|
49
103
|
{
|
|
50
104
|
className,
|
|
51
105
|
orientation = "horizontal",
|
|
106
|
+
spacing = "default",
|
|
52
107
|
decorative = true,
|
|
53
108
|
dataHook,
|
|
54
109
|
trackingEl,
|
|
@@ -68,11 +123,7 @@ const Separator = React.forwardRef<HTMLElement, SeparatorProps>(
|
|
|
68
123
|
|
|
69
124
|
return React.createElement(orientation === "horizontal" ? "hr" : "div", {
|
|
70
125
|
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
|
-
),
|
|
126
|
+
className: cn(separatorStyles({ orientation, spacing }), className),
|
|
76
127
|
"data-hook": dataHook,
|
|
77
128
|
"data-orientation": orientation,
|
|
78
129
|
"data-slot": "separator",
|
|
@@ -98,6 +149,11 @@ interface SeparatorWithTextProps {
|
|
|
98
149
|
* Text content to display between separators
|
|
99
150
|
*/
|
|
100
151
|
children: React.ReactNode;
|
|
152
|
+
/**
|
|
153
|
+
* Controls the spacing around the separator.
|
|
154
|
+
* @default "default"
|
|
155
|
+
*/
|
|
156
|
+
spacing?: SeparatorSpacing;
|
|
101
157
|
/**
|
|
102
158
|
* Data hook for automated testing
|
|
103
159
|
*/
|
|
@@ -119,24 +175,36 @@ interface SeparatorWithTextProps {
|
|
|
119
175
|
const SeparatorWithText = React.forwardRef<
|
|
120
176
|
HTMLDivElement,
|
|
121
177
|
SeparatorWithTextProps
|
|
122
|
-
>(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
178
|
+
>(
|
|
179
|
+
(
|
|
180
|
+
{
|
|
181
|
+
className,
|
|
182
|
+
children,
|
|
183
|
+
spacing = "default",
|
|
184
|
+
dataHook,
|
|
185
|
+
trackingEl,
|
|
186
|
+
trackingLabel,
|
|
187
|
+
},
|
|
188
|
+
ref
|
|
189
|
+
) => {
|
|
190
|
+
return (
|
|
191
|
+
<div
|
|
192
|
+
ref={ref}
|
|
193
|
+
className={cn(separatorWithTextStyles({ spacing }), className)}
|
|
194
|
+
data-hook={dataHook}
|
|
195
|
+
data-slot="separator-with-text"
|
|
196
|
+
data-tracking-el={trackingEl}
|
|
197
|
+
data-tracking-label={trackingLabel}
|
|
198
|
+
>
|
|
199
|
+
<Separator className="flex-1" />
|
|
200
|
+
<span className="text-muted-foreground shrink-0 text-sm leading-none font-medium whitespace-nowrap">
|
|
201
|
+
{children}
|
|
202
|
+
</span>
|
|
203
|
+
<Separator className="flex-1" />
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
);
|
|
140
208
|
|
|
141
209
|
SeparatorWithText.displayName = "SeparatorWithText";
|
|
142
210
|
|
package/src/components/sheet.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import { cva, type VariantProps } from "class-variance-authority";
|
|
|
6
6
|
import { X } from "@brightlocal/icons";
|
|
7
7
|
|
|
8
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
9
|
+
import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Available sheet side variants
|
|
@@ -213,6 +214,9 @@ const SheetContent = React.forwardRef<
|
|
|
213
214
|
},
|
|
214
215
|
ref
|
|
215
216
|
) => {
|
|
217
|
+
// Safety net for the Radix dismissable-layer body-lock leak (DS-634).
|
|
218
|
+
useOverlayPointerLock();
|
|
219
|
+
|
|
216
220
|
return (
|
|
217
221
|
<SheetPortal>
|
|
218
222
|
<SheetOverlay />
|
|
@@ -39,7 +39,7 @@ const Skeleton = React.forwardRef<HTMLDivElement, SkeletonProps>(
|
|
|
39
39
|
<div
|
|
40
40
|
ref={ref}
|
|
41
41
|
aria-busy="true"
|
|
42
|
-
className={cn("bg-accent animate-pulse rounded-md", className)}
|
|
42
|
+
className={cn("bg-accent relative animate-pulse rounded-md", className)}
|
|
43
43
|
data-hook={dataHook}
|
|
44
44
|
data-slot="skeleton"
|
|
45
45
|
data-tracking-el={trackingEl}
|
|
@@ -402,7 +402,7 @@ Sonner.displayName = "Sonner";
|
|
|
402
402
|
* // Show loading toast
|
|
403
403
|
* sonner({
|
|
404
404
|
* title: "Uploading...",
|
|
405
|
-
* description: "
|
|
405
|
+
* description: "Uploading your file.",
|
|
406
406
|
* icon: "loading",
|
|
407
407
|
* id: loadingToastId
|
|
408
408
|
* });
|