@brightlocal/ui-components 2.24.1 → 2.25.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 +2 -1
- package/component-meta.json +93 -79
- package/dist/accordion.cjs +1 -1
- package/dist/accordion.js +2 -2
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.js +17 -17
- package/dist/badge.cjs +1 -1
- package/dist/badge.js +9 -9
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +43 -46
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.js +14 -14
- package/dist/brand-illustration-motif.cjs +1 -1
- package/dist/brand-illustration-motif.js +11 -11
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button.cjs +1 -1
- package/dist/button.js +10 -10
- package/dist/card.cjs +1 -1
- package/dist/card.js +1 -1
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.js +12 -12
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.js +7 -7
- package/dist/chip.cjs +1 -1
- package/dist/chip.js +7 -7
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.js +1 -1
- package/dist/data-table.d.ts +29 -0
- package/dist/data-table.d.ts.map +1 -1
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.js +61 -61
- package/dist/field.cjs +1 -1
- package/dist/field.js +1 -1
- package/dist/height-transition.cjs +1 -0
- package/dist/height-transition.d.ts +44 -0
- package/dist/height-transition.d.ts.map +1 -0
- package/dist/height-transition.js +63 -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 +326 -324
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.js +2 -2
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.js +15 -15
- package/dist/input-otp.cjs +1 -1
- package/dist/input-otp.js +1 -1
- package/dist/input.cjs +1 -1
- package/dist/input.js +1 -1
- package/dist/lib/motion.cjs +1 -0
- package/dist/lib/motion.d.ts +70 -0
- package/dist/lib/motion.d.ts.map +1 -0
- package/dist/lib/motion.js +25 -0
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +12 -4
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +17 -16
- package/dist/list.cjs +1 -1
- package/dist/list.js +10 -10
- package/dist/loading.cjs +1 -1
- package/dist/loading.d.ts.map +1 -1
- package/dist/loading.js +45 -47
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +2 -2
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.js +5 -5
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.js +13 -13
- package/dist/pagination.cjs +1 -1
- package/dist/pagination.js +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +21 -25
- package/dist/radio-group.cjs +1 -1
- package/dist/radio-group.js +12 -12
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.js +11 -11
- package/dist/select.cjs +1 -1
- package/dist/select.js +12 -12
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +54 -50
- package/dist/slider.cjs +1 -1
- package/dist/slider.js +13 -13
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.js +4 -4
- package/dist/switch.cjs +1 -1
- package/dist/switch.js +5 -5
- package/dist/table.cjs +1 -1
- package/dist/table.js +2 -2
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +77 -79
- package/dist/textarea.cjs +1 -1
- package/dist/textarea.js +11 -11
- package/dist/toggle.cjs +1 -1
- package/dist/toggle.js +5 -5
- package/package.json +13 -4
- package/src/blocks/input-list.tsx +3 -6
- package/src/blocks/sidebar.tsx +14 -14
- package/src/components/accordion.tsx +2 -2
- package/src/components/alert-dialog.tsx +2 -2
- package/src/components/badge.tsx +1 -1
- package/src/components/brand-illustration-motif.tsx +1 -1
- package/src/components/breadcrumb.tsx +1 -1
- package/src/components/button.tsx +2 -2
- package/src/components/card.tsx +1 -1
- package/src/components/carousel.tsx +1 -1
- package/src/components/checkbox.tsx +1 -1
- package/src/components/chip.tsx +2 -2
- package/src/components/combobox.tsx +1 -1
- package/src/components/data-table.tsx +29 -0
- package/src/components/dialog.tsx +3 -3
- package/src/components/field.tsx +1 -1
- package/src/components/height-transition.tsx +164 -0
- package/src/components/input-chip.tsx +2 -2
- package/src/components/input-group.tsx +2 -2
- package/src/components/input-otp.tsx +1 -1
- package/src/components/input.tsx +1 -1
- package/src/components/link.tsx +4 -3
- package/src/components/list.tsx +1 -1
- package/src/components/loading.tsx +2 -15
- package/src/components/map.tsx +3 -2
- package/src/components/menubar.tsx +5 -5
- package/src/components/navigation-menu.tsx +6 -6
- package/src/components/pagination.tsx +1 -1
- package/src/components/progress.tsx +2 -10
- package/src/components/radio-group.tsx +1 -1
- package/src/components/scroll-area.tsx +2 -2
- package/src/components/select.tsx +1 -1
- package/src/components/sheet.tsx +9 -5
- package/src/components/slider.tsx +1 -1
- package/src/components/stepper.tsx +4 -4
- package/src/components/switch.tsx +2 -2
- package/src/components/table.tsx +2 -2
- package/src/components/tabs.tsx +1 -1
- package/src/components/text-reveal-motion.tsx +3 -8
- package/src/components/textarea.tsx +1 -1
- package/src/components/toggle.tsx +1 -1
- package/src/index.ts +1 -0
- package/src/lib/motion.ts +75 -0
- package/src/lib/utils.ts +14 -2
|
@@ -178,14 +178,14 @@ const AccordionTrigger = React.forwardRef<
|
|
|
178
178
|
<AccordionPrimitive.Trigger
|
|
179
179
|
ref={ref}
|
|
180
180
|
className={cn(
|
|
181
|
-
"focus-visible:border-ring focus-visible:shadow-default flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-shadow outline-none hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
|
|
181
|
+
"focus-visible:border-ring focus-visible:shadow-default duration-fast flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-shadow ease-out outline-none hover:underline disabled:pointer-events-none disabled:opacity-50 [&[data-state=open]>svg]:rotate-180",
|
|
182
182
|
className
|
|
183
183
|
)}
|
|
184
184
|
data-slot="accordion-trigger"
|
|
185
185
|
{...props}
|
|
186
186
|
>
|
|
187
187
|
{children}
|
|
188
|
-
<ChevronDown className="text-muted-foreground pointer-events-none shrink-0 translate-y-0.5 transition-transform
|
|
188
|
+
<ChevronDown className="text-muted-foreground duration-base pointer-events-none shrink-0 translate-y-0.5 transition-transform ease-in-out" />
|
|
189
189
|
</AccordionPrimitive.Trigger>
|
|
190
190
|
</AccordionPrimitive.Header>
|
|
191
191
|
));
|
|
@@ -71,7 +71,7 @@ const AlertDialogOverlay = React.forwardRef<
|
|
|
71
71
|
<AlertDialogPrimitive.Overlay
|
|
72
72
|
ref={ref}
|
|
73
73
|
className={cn(
|
|
74
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
74
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=open]:duration-slow fixed inset-0 z-50 bg-black/50 ease-out data-[state=closed]:duration-250 data-[state=closed]:ease-in",
|
|
75
75
|
className
|
|
76
76
|
)}
|
|
77
77
|
data-slot="alert-dialog-overlay"
|
|
@@ -94,7 +94,7 @@ const AlertDialogContent = React.forwardRef<
|
|
|
94
94
|
<AlertDialogPrimitive.Content
|
|
95
95
|
ref={ref}
|
|
96
96
|
className={cn(
|
|
97
|
-
"border-border bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-
|
|
97
|
+
"border-border bg-background 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-[state=open]:duration-slow fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg ease-out data-[state=closed]:duration-250 data-[state=closed]:ease-in sm:max-w-lg",
|
|
98
98
|
className
|
|
99
99
|
)}
|
|
100
100
|
data-slot="alert-dialog-content"
|
package/src/components/badge.tsx
CHANGED
|
@@ -15,7 +15,7 @@ const badgeVariants = cva(
|
|
|
15
15
|
// Icons
|
|
16
16
|
"[&>svg]:size-3 [&>svg]:pointer-events-none",
|
|
17
17
|
// Transition
|
|
18
|
-
"transition-[color,background-color,border-color,box-shadow] duration-
|
|
18
|
+
"transition-[color,background-color,border-color,box-shadow] duration-fast ease-out",
|
|
19
19
|
// Focus
|
|
20
20
|
"focus-visible:outline-none",
|
|
21
21
|
"focus-visible:shadow-[0_0_0_1px_white,0_0_0_2px_var(--color-ring),0_0_0_4px_rgba(0,0,0,0.1)]",
|
|
@@ -123,7 +123,7 @@ const BrandIllustrationMotif = React.forwardRef<
|
|
|
123
123
|
>
|
|
124
124
|
<div
|
|
125
125
|
aria-hidden="true"
|
|
126
|
-
className={cn("absolute inset-0", spinning && "animate-
|
|
126
|
+
className={cn("absolute inset-0", spinning && "animate-ambient-spin")}
|
|
127
127
|
>
|
|
128
128
|
<MotifIcon className="size-full" size="100%" />
|
|
129
129
|
</div>
|
|
@@ -109,7 +109,7 @@ const BreadcrumbLink = React.forwardRef<HTMLAnchorElement, BreadcrumbLinkProps>(
|
|
|
109
109
|
<Comp
|
|
110
110
|
ref={ref}
|
|
111
111
|
className={cn(
|
|
112
|
-
"hover:text-foreground focus-visible:shadow-default rounded-sm transition-colors outline-none",
|
|
112
|
+
"hover:text-foreground focus-visible:shadow-default duration-fast rounded-sm transition-colors ease-out outline-none",
|
|
113
113
|
className
|
|
114
114
|
)}
|
|
115
115
|
data-slot="breadcrumb-link"
|
|
@@ -43,8 +43,8 @@ const ButtonVariants = cva(
|
|
|
43
43
|
"gap-2",
|
|
44
44
|
"whitespace-nowrap",
|
|
45
45
|
"transition-[color,background-color,border-color,box-shadow,opacity]",
|
|
46
|
-
"duration-
|
|
47
|
-
"ease-
|
|
46
|
+
"duration-fast",
|
|
47
|
+
"ease-out",
|
|
48
48
|
"cursor-pointer",
|
|
49
49
|
"disabled:pointer-events-none",
|
|
50
50
|
"disabled:cursor-not-allowed",
|
package/src/components/card.tsx
CHANGED
|
@@ -586,7 +586,7 @@ function CarouselDots({
|
|
|
586
586
|
: `Go to slide ${index + 1}`
|
|
587
587
|
}
|
|
588
588
|
className={cn(
|
|
589
|
-
"focus-visible:shadow-default size-3 rounded-full transition-[width,background-color]
|
|
589
|
+
"focus-visible:shadow-default duration-base size-3 rounded-full transition-[width,background-color] ease-in-out outline-none",
|
|
590
590
|
index === selectedIndex
|
|
591
591
|
? "bg-muted-foreground/50 dark:bg-muted-foreground/70 w-9"
|
|
592
592
|
: "bg-input hover:bg-muted-foreground/30 dark:bg-input/80 dark:hover:bg-muted-foreground/50"
|
|
@@ -10,7 +10,7 @@ const checkboxVariants = cva(
|
|
|
10
10
|
// Layout & Size
|
|
11
11
|
"size-[18px] shrink-0 self-start mt-0.5",
|
|
12
12
|
// Appearance
|
|
13
|
-
"bg-background peer border border-ring dark:bg-input/30 rounded-xs transition-colors outline-none",
|
|
13
|
+
"bg-background peer border border-ring dark:bg-input/30 rounded-xs transition-colors duration-fast ease-out outline-none",
|
|
14
14
|
// Checked State
|
|
15
15
|
"data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary",
|
|
16
16
|
// Focus States
|
package/src/components/chip.tsx
CHANGED
|
@@ -34,8 +34,8 @@ const chipVariants = cva(
|
|
|
34
34
|
"text-foreground",
|
|
35
35
|
// Transitions
|
|
36
36
|
"transition-[color,background-color,box-shadow]",
|
|
37
|
-
"duration-
|
|
38
|
-
"ease-
|
|
37
|
+
"duration-fast",
|
|
38
|
+
"ease-out",
|
|
39
39
|
// Hover state
|
|
40
40
|
"hover:bg-secondary/80",
|
|
41
41
|
// Focus state - direct focus on chip (for keyboard navigation)
|
|
@@ -399,7 +399,7 @@ const comboboxTriggerVariants = cva([
|
|
|
399
399
|
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
400
400
|
|
|
401
401
|
// Transitions
|
|
402
|
-
"transition-[background-color,border-color,box-shadow] duration-
|
|
402
|
+
"transition-[background-color,border-color,box-shadow] duration-fast ease-out",
|
|
403
403
|
|
|
404
404
|
// Icon styles
|
|
405
405
|
"[&_svg]:pointer-events-none [&_svg]:shrink-0",
|
|
@@ -447,9 +447,33 @@ export interface DataTableProps<TData> {
|
|
|
447
447
|
* the table primitives. Keep it focused on rendering — toolbars, search,
|
|
448
448
|
* pagination, etc. are composed around it.
|
|
449
449
|
*
|
|
450
|
+
* **Compose as one slot.** The table and its companions — `DataTableToolbar`
|
|
451
|
+
* rows (search, filters, pagination, counters), `DataTableBulkActions` — form
|
|
452
|
+
* a single unit. When the parent lays out its children with a gap (e.g.
|
|
453
|
+
* `DialogContent` with `gap-8`, a Card body, a page section), wrap the whole
|
|
454
|
+
* unit in one flex-column container so the parent's gap applies around the
|
|
455
|
+
* table block, not between the toolbars and the table. Vertical rhythm inside
|
|
456
|
+
* the block comes from the toolbars' built-in padding — don't add custom
|
|
457
|
+
* margins between the parts.
|
|
458
|
+
*
|
|
450
459
|
* @example
|
|
451
460
|
* const table = useDataTable({ columns, data, enableSorting: true });
|
|
452
461
|
* return <DataTable table={table} dataHook="my-table" />;
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* // One slot inside a gapped parent (dialog, card, page section).
|
|
465
|
+
* // min-h-0/flex-1 keep the table scrollable in height-capped parents.
|
|
466
|
+
* <div className="flex min-h-0 flex-1 flex-col">
|
|
467
|
+
* <DataTableToolbar dataHook="toolbar-top">
|
|
468
|
+
* <DataTableToolbarLeft>{heading or search}</DataTableToolbarLeft>
|
|
469
|
+
* <DataTableToolbarRight>{filters}</DataTableToolbarRight>
|
|
470
|
+
* </DataTableToolbar>
|
|
471
|
+
* <DataTable table={table} dataHook="my-table" className="min-h-0 flex-1 overflow-y-auto" />
|
|
472
|
+
* <DataTableToolbar dataHook="toolbar-bottom">
|
|
473
|
+
* <DataTableToolbarLeft>{selection counter}</DataTableToolbarLeft>
|
|
474
|
+
* <DataTableToolbarRight>{pagination}</DataTableToolbarRight>
|
|
475
|
+
* </DataTableToolbar>
|
|
476
|
+
* </div>
|
|
453
477
|
*/
|
|
454
478
|
export function DataTable<TData>({
|
|
455
479
|
table,
|
|
@@ -1792,6 +1816,11 @@ export interface DataTableToolbarProps {
|
|
|
1792
1816
|
* row on `sm:` and up. Layout-only — no dependency on a TanStack Table
|
|
1793
1817
|
* instance, so it works for table footers or any search-plus-pagination row.
|
|
1794
1818
|
*
|
|
1819
|
+
* Toolbars belong in the same flex-column container as their `DataTable` so
|
|
1820
|
+
* the group reads as one slot inside gapped parents — see the composition
|
|
1821
|
+
* note on `DataTable`. The built-in vertical padding provides the spacing
|
|
1822
|
+
* between a toolbar and its table; don't add custom margins or padding.
|
|
1823
|
+
*
|
|
1795
1824
|
* @example
|
|
1796
1825
|
* <DataTableToolbar dataHook="locations-toolbar">
|
|
1797
1826
|
* <DataTableToolbarLeft>
|
|
@@ -77,7 +77,7 @@ const DialogOverlay = React.forwardRef<
|
|
|
77
77
|
<DialogPrimitive.Overlay
|
|
78
78
|
ref={ref}
|
|
79
79
|
className={cn(
|
|
80
|
-
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
80
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=open]:duration-slow fixed inset-0 z-50 bg-black/50 ease-out data-[state=closed]:duration-250 data-[state=closed]:ease-in",
|
|
81
81
|
className
|
|
82
82
|
)}
|
|
83
83
|
data-slot="dialog-overlay"
|
|
@@ -137,7 +137,7 @@ const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
137
137
|
<DialogPrimitive.Content
|
|
138
138
|
ref={ref}
|
|
139
139
|
className={cn(
|
|
140
|
-
"bg-background text-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 border-card-border fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-8 rounded-xl border p-8 shadow-lg duration-
|
|
140
|
+
"bg-background text-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 border-card-border data-[state=open]:duration-slow fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-8 rounded-xl border p-8 shadow-lg ease-out data-[state=closed]:duration-250 data-[state=closed]:ease-in sm:max-w-lg",
|
|
141
141
|
className
|
|
142
142
|
)}
|
|
143
143
|
data-hook={dataHook}
|
|
@@ -147,7 +147,7 @@ const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
147
147
|
{...props}
|
|
148
148
|
>
|
|
149
149
|
{children}
|
|
150
|
-
<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
|
|
150
|
+
<DialogPrimitive.Close className="ring-offset-background focus-visible:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground duration-fast absolute top-8 right-8 rounded-xs opacity-70 outline-hidden transition-opacity ease-out hover:opacity-100 focus-visible:ring-2 focus-visible:ring-offset-2 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0">
|
|
151
151
|
<X />
|
|
152
152
|
<span className="sr-only">{closeLabel ?? "Close"}</span>
|
|
153
153
|
</DialogPrimitive.Close>
|
package/src/components/field.tsx
CHANGED
|
@@ -118,7 +118,7 @@ const fieldVariants = cva(
|
|
|
118
118
|
box: [
|
|
119
119
|
"relative cursor-pointer gap-3",
|
|
120
120
|
"rounded-lg border border-border bg-background p-3",
|
|
121
|
-
"transition-colors",
|
|
121
|
+
"transition-colors duration-fast ease-out",
|
|
122
122
|
"[&_[data-slot=field-label]]:after:absolute [&_[data-slot=field-label]]:after:inset-0 [&_[data-slot=field-label]]:after:cursor-pointer",
|
|
123
123
|
// Focus ring when a child control receives focus
|
|
124
124
|
"has-[:focus-visible]:shadow-default has-[:focus-visible]:border-ring",
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Result of {@link useHeightTransition}: attach `contentRef` to the element
|
|
9
|
+
* whose natural height should be tracked, and apply `height` (px) to the
|
|
10
|
+
* clipping wrapper around it.
|
|
11
|
+
*/
|
|
12
|
+
interface UseHeightTransitionResult {
|
|
13
|
+
/** Ref for the inner content element the hook measures. */
|
|
14
|
+
contentRef: React.RefObject<HTMLDivElement | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Measured content height in pixels, or `undefined` before the first
|
|
17
|
+
* measurement (render `auto` until then so mounting never animates).
|
|
18
|
+
*/
|
|
19
|
+
height: number | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Measures an element's natural height with a ResizeObserver so a wrapper
|
|
24
|
+
* can set an explicit pixel height and CSS-transition between values —
|
|
25
|
+
* the same idea the Accordion uses (`--radix-accordion-content-height`),
|
|
26
|
+
* generalized to arbitrary content changes.
|
|
27
|
+
*
|
|
28
|
+
* Module-private on purpose: no external consumer exists yet, and keeping it
|
|
29
|
+
* out of the public API leaves the ref/height contract free to change.
|
|
30
|
+
*/
|
|
31
|
+
function useHeightTransition(): UseHeightTransitionResult {
|
|
32
|
+
const contentRef = React.useRef<HTMLDivElement>(null);
|
|
33
|
+
const [height, setHeight] = React.useState<number>();
|
|
34
|
+
|
|
35
|
+
React.useLayoutEffect(() => {
|
|
36
|
+
const node = contentRef.current;
|
|
37
|
+
if (!node) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
// Missing in some non-browser runtimes (e.g. jsdom without a polyfill);
|
|
41
|
+
// height stays undefined there, so the wrapper renders `auto` with no
|
|
42
|
+
// animation instead of throwing.
|
|
43
|
+
if (typeof ResizeObserver === "undefined") {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const observer = new ResizeObserver((entries) => {
|
|
47
|
+
// A display:none ancestor reports size 0 — keep the last real height
|
|
48
|
+
// so re-showing doesn't animate the content open from 0px.
|
|
49
|
+
if (node.offsetParent === null) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const entry = entries[0];
|
|
53
|
+
const next =
|
|
54
|
+
entry?.borderBoxSize?.[0]?.blockSize ??
|
|
55
|
+
node.getBoundingClientRect().height;
|
|
56
|
+
setHeight(next);
|
|
57
|
+
});
|
|
58
|
+
// No manual first measurement: observe() always delivers an initial
|
|
59
|
+
// entry, and getBoundingClientRect would bake ancestor entrance
|
|
60
|
+
// transforms (e.g. the Dialog's zoom-in-95) into the recorded height —
|
|
61
|
+
// the observer's borderBoxSize doesn't.
|
|
62
|
+
observer.observe(node);
|
|
63
|
+
return () => observer.disconnect();
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
return { contentRef, height };
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Props for the HeightTransition component.
|
|
71
|
+
* Extends native `<div>` props with testing and analytics attributes.
|
|
72
|
+
*/
|
|
73
|
+
export interface HeightTransitionProps extends React.ComponentPropsWithoutRef<"div"> {
|
|
74
|
+
/**
|
|
75
|
+
* Data hook for automated testing (required).
|
|
76
|
+
* @example "suggest-prompts-list-height"
|
|
77
|
+
*/
|
|
78
|
+
dataHook: string;
|
|
79
|
+
/** Tracking element identifier for analytics. */
|
|
80
|
+
trackingEl?: string;
|
|
81
|
+
/** Tracking label for analytics context. */
|
|
82
|
+
trackingLabel?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Smoothly transitions its own height whenever the children's natural
|
|
87
|
+
* height changes (content swap, filtering, inline expansion). A
|
|
88
|
+
* ResizeObserver measures the content and the wrapper transitions an
|
|
89
|
+
* explicit pixel height over `duration-base` with `ease-out` (matching the
|
|
90
|
+
* Accordion's reveal timing), clipping overflow while the transition runs.
|
|
91
|
+
*
|
|
92
|
+
* The anchor point of the resize comes from the surrounding layout, not from
|
|
93
|
+
* this component: in normal flow the top edge is pinned and growth extends
|
|
94
|
+
* downward; inside a vertically centered parent (a Dialog's
|
|
95
|
+
* `top-[50%] translate-y-[-50%]`, or `grid place-items-center`) the same
|
|
96
|
+
* transition reshapes around the center with both edges moving. Pick the
|
|
97
|
+
* parent positioning to pick the motion.
|
|
98
|
+
*
|
|
99
|
+
* Reduced motion is handled by the DS global kill-switch — no
|
|
100
|
+
* component-level handling needed or allowed.
|
|
101
|
+
*
|
|
102
|
+
* Note: animating `height` reflows on every frame — reserve this for
|
|
103
|
+
* occasional content swaps (dialogs, panels), not for anything that
|
|
104
|
+
* resizes continuously.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* <HeightTransition dataHook="results-height">
|
|
108
|
+
* {loading ? <ResultsSkeleton /> : <Results items={items} />}
|
|
109
|
+
* </HeightTransition>
|
|
110
|
+
*/
|
|
111
|
+
export const HeightTransition = React.forwardRef<
|
|
112
|
+
HTMLDivElement,
|
|
113
|
+
HeightTransitionProps
|
|
114
|
+
>(
|
|
115
|
+
(
|
|
116
|
+
{
|
|
117
|
+
className,
|
|
118
|
+
style,
|
|
119
|
+
dataHook,
|
|
120
|
+
trackingEl,
|
|
121
|
+
trackingLabel,
|
|
122
|
+
children,
|
|
123
|
+
...props
|
|
124
|
+
},
|
|
125
|
+
ref
|
|
126
|
+
) => {
|
|
127
|
+
const { contentRef, height } = useHeightTransition();
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div
|
|
131
|
+
ref={ref}
|
|
132
|
+
className={cn(
|
|
133
|
+
"duration-base overflow-hidden transition-[height] ease-out",
|
|
134
|
+
className
|
|
135
|
+
)}
|
|
136
|
+
data-hook={dataHook}
|
|
137
|
+
data-slot="height-transition"
|
|
138
|
+
data-tracking-el={trackingEl || "height-transition"}
|
|
139
|
+
data-tracking-label={trackingLabel}
|
|
140
|
+
// Managed height last: the component's one job is controlling
|
|
141
|
+
// height, so a consumer style={{height}} must not silently
|
|
142
|
+
// disable the transition (and clip content).
|
|
143
|
+
style={{
|
|
144
|
+
...style,
|
|
145
|
+
height,
|
|
146
|
+
}}
|
|
147
|
+
{...props}
|
|
148
|
+
>
|
|
149
|
+
{/* flow-root keeps children's vertical margins inside the measured
|
|
150
|
+
border-box — otherwise they collapse through this div and the
|
|
151
|
+
wrapper's overflow-hidden clips the uncounted space. */}
|
|
152
|
+
<div
|
|
153
|
+
ref={contentRef}
|
|
154
|
+
className="flow-root"
|
|
155
|
+
data-slot="height-transition-content"
|
|
156
|
+
>
|
|
157
|
+
{children}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
HeightTransition.displayName = "HeightTransition";
|
|
@@ -251,8 +251,8 @@ const inputChipInputVariants = cva(
|
|
|
251
251
|
"has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50",
|
|
252
252
|
// Transition
|
|
253
253
|
"transition-[color,box-shadow,border-color]",
|
|
254
|
-
"duration-
|
|
255
|
-
"ease-
|
|
254
|
+
"duration-fast",
|
|
255
|
+
"ease-out",
|
|
256
256
|
],
|
|
257
257
|
{
|
|
258
258
|
variants: {
|
|
@@ -8,7 +8,7 @@ import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
|
8
8
|
import { Input, type InputProps } from "./input";
|
|
9
9
|
|
|
10
10
|
const inputGroupVariants = cva(
|
|
11
|
-
"relative flex w-full items-center rounded-sm border border-input bg-background transition-
|
|
11
|
+
"relative flex w-full items-center rounded-sm border border-input bg-background transition-[color,background-color,border-color,box-shadow] duration-fast ease-out has-[input:focus-visible]:border-ring has-[input:focus-visible]:shadow-default has-[:disabled]:opacity-50",
|
|
12
12
|
{
|
|
13
13
|
variants: {
|
|
14
14
|
size: {
|
|
@@ -137,7 +137,7 @@ InputGroupAddon.displayName = "InputGroupAddon";
|
|
|
137
137
|
const inputGroupButtonVariants = cva(
|
|
138
138
|
[
|
|
139
139
|
"inline-flex items-center justify-center gap-2",
|
|
140
|
-
"text-sm font-medium transition-colors",
|
|
140
|
+
"text-sm font-medium transition-colors duration-fast ease-out",
|
|
141
141
|
"outline-none focus-visible:shadow-default rounded-sm",
|
|
142
142
|
"disabled:pointer-events-none disabled:opacity-50",
|
|
143
143
|
"text-muted-foreground hover:text-foreground",
|
|
@@ -137,7 +137,7 @@ function InputOTPSlot({ index, className, ...props }: InputOTPSlotProps) {
|
|
|
137
137
|
// Base styles
|
|
138
138
|
"relative flex h-9 w-9 items-center justify-center",
|
|
139
139
|
"border-input bg-background border-y border-r",
|
|
140
|
-
"text-foreground text-base font-normal transition-[border-color,box-shadow] outline-none",
|
|
140
|
+
"text-foreground duration-fast text-base font-normal transition-[border-color,box-shadow] ease-out outline-none",
|
|
141
141
|
"first:rounded-l-md first:border-l last:rounded-r-md",
|
|
142
142
|
// Focus state
|
|
143
143
|
"data-[active=true]:border-ring data-[active=true]:z-10",
|
package/src/components/input.tsx
CHANGED
|
@@ -14,7 +14,7 @@ export const inputVariants = cva(
|
|
|
14
14
|
"flex w-full min-w-0 h-9",
|
|
15
15
|
// Appearance
|
|
16
16
|
"border border-input bg-background rounded-sm",
|
|
17
|
-
"outline-none transition-[border-color,box-shadow,background-color]",
|
|
17
|
+
"outline-none transition-[border-color,box-shadow,background-color] duration-fast ease-out",
|
|
18
18
|
// Typography
|
|
19
19
|
"text-base font-sans",
|
|
20
20
|
"text-foreground",
|
package/src/components/link.tsx
CHANGED
|
@@ -22,8 +22,8 @@ const buttonStyledBase = [
|
|
|
22
22
|
"[&_svg]:pointer-events-none",
|
|
23
23
|
"[&_svg]:shrink-0",
|
|
24
24
|
"transition-[color,background-color,border-color,box-shadow]",
|
|
25
|
-
"duration-
|
|
26
|
-
"ease-
|
|
25
|
+
"duration-fast",
|
|
26
|
+
"ease-out",
|
|
27
27
|
"focus-visible:shadow-default",
|
|
28
28
|
];
|
|
29
29
|
|
|
@@ -48,7 +48,8 @@ const linkVariants = cva(
|
|
|
48
48
|
"visited:dark:text-link-visited-dark",
|
|
49
49
|
// Transitions
|
|
50
50
|
"transition-[text-decoration,text-decoration-color,text-underline-offset,color]",
|
|
51
|
-
"duration-
|
|
51
|
+
"duration-fast",
|
|
52
|
+
"ease-out",
|
|
52
53
|
// Focus state
|
|
53
54
|
"focus-visible:shadow-default",
|
|
54
55
|
],
|
package/src/components/list.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import { animate } from "framer-motion";
|
|
|
6
6
|
|
|
7
7
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
8
|
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion";
|
|
9
|
-
import { SETTLE_REST_DELTA } from "../lib/
|
|
9
|
+
import { SETTLE_REST_DELTA, SPRING_SETTLE } from "../lib/motion";
|
|
10
10
|
|
|
11
11
|
// ---------------------------------------------------------------------------
|
|
12
12
|
// Shape paths (500×500 viewBox)
|
|
@@ -46,16 +46,6 @@ const LOADING_SHAPES: string[] = [
|
|
|
46
46
|
|
|
47
47
|
/** Pause (ms) each shape holds before morphing to the next */
|
|
48
48
|
const HOLD_MS = 150;
|
|
49
|
-
/** Spring stiffness for the morph + rotation */
|
|
50
|
-
const STIFFNESS = 30;
|
|
51
|
-
/**
|
|
52
|
-
* Spring damping — higher = less oscillation.
|
|
53
|
-
* Must stay ≥ 2×√(STIFFNESS×MASS) (≈7.75) so the spring never overshoots —
|
|
54
|
-
* the settle trick below depends on it (see SETTLE_REST_DELTA).
|
|
55
|
-
*/
|
|
56
|
-
const DAMPING = 9;
|
|
57
|
-
/** Spring mass — higher = more inertia */
|
|
58
|
-
const MASS = 0.5;
|
|
59
49
|
/** Degrees of rotation per morph cycle (clockwise) */
|
|
60
50
|
const ROTATION_DEG = 360;
|
|
61
51
|
/** Rendered size of the loader in pixels (width and height) */
|
|
@@ -254,10 +244,7 @@ const Loading = React.forwardRef<SVGSVGElement, LoadingProps>(
|
|
|
254
244
|
return;
|
|
255
245
|
}
|
|
256
246
|
const controls = animate(0, 1 + SETTLE_REST_DELTA, {
|
|
257
|
-
|
|
258
|
-
stiffness: STIFFNESS,
|
|
259
|
-
damping: DAMPING,
|
|
260
|
-
mass: MASS,
|
|
247
|
+
...SPRING_SETTLE,
|
|
261
248
|
restDelta: SETTLE_REST_DELTA,
|
|
262
249
|
onUpdate: (v: number) => {
|
|
263
250
|
if (signal.cancelled) {
|
package/src/components/map.tsx
CHANGED
|
@@ -289,7 +289,7 @@ const mapGridPinColorMap: Record<ResolvedVariant, string> = Object.fromEntries(
|
|
|
289
289
|
) as Record<ResolvedVariant, string>;
|
|
290
290
|
|
|
291
291
|
const mapGridPinVariants = cva(
|
|
292
|
-
"inline-flex items-center justify-center rounded-full font-sans text-sm font-semibold text-foreground dark:text-neutral-900 border-2 border-white shadow-sm transition-shadow duration-
|
|
292
|
+
"inline-flex items-center justify-center rounded-full font-sans text-sm font-semibold text-foreground dark:text-neutral-900 border-2 border-white shadow-sm transition-shadow duration-fast ease-out hover:shadow-md",
|
|
293
293
|
{
|
|
294
294
|
variants: {
|
|
295
295
|
variant: {
|
|
@@ -827,7 +827,8 @@ const MapLocationPin = React.forwardRef<HTMLDivElement, MapLocationPinProps>(
|
|
|
827
827
|
aria-hidden="true"
|
|
828
828
|
className={cn(
|
|
829
829
|
"relative flex size-full",
|
|
830
|
-
animateIn &&
|
|
830
|
+
animateIn &&
|
|
831
|
+
"animate-emphasis-pop origin-bottom will-change-transform"
|
|
831
832
|
)}
|
|
832
833
|
>
|
|
833
834
|
<svg
|
|
@@ -85,7 +85,7 @@ function MenubarTrigger({
|
|
|
85
85
|
return (
|
|
86
86
|
<MenubarPrimitive.Trigger
|
|
87
87
|
className={cn(
|
|
88
|
-
"text-foreground flex cursor-pointer items-center justify-center gap-2 rounded-xs px-3 py-1 text-sm font-normal transition-colors",
|
|
88
|
+
"text-foreground duration-fast flex cursor-pointer items-center justify-center gap-2 rounded-xs px-3 py-1 text-sm font-normal transition-colors ease-out",
|
|
89
89
|
"hover:bg-accent hover:text-accent-foreground",
|
|
90
90
|
"focus:bg-accent focus:text-accent-foreground focus:outline-none",
|
|
91
91
|
"data-[state=open]:bg-accent data-[state=open]:text-accent-foreground",
|
|
@@ -147,7 +147,7 @@ function MenubarItem({
|
|
|
147
147
|
return (
|
|
148
148
|
<MenubarPrimitive.Item
|
|
149
149
|
className={cn(
|
|
150
|
-
"text-foreground relative flex cursor-pointer items-center justify-between rounded-sm px-2 py-1.5 text-sm font-normal transition-colors outline-none",
|
|
150
|
+
"text-foreground duration-fast relative flex cursor-pointer items-center justify-between rounded-sm px-2 py-1.5 text-sm font-normal transition-colors ease-out outline-none",
|
|
151
151
|
"hover:bg-accent hover:text-foreground",
|
|
152
152
|
"focus:bg-accent focus:text-foreground",
|
|
153
153
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -191,7 +191,7 @@ function MenubarCheckboxItem({
|
|
|
191
191
|
<MenubarPrimitive.CheckboxItem
|
|
192
192
|
checked={checked}
|
|
193
193
|
className={cn(
|
|
194
|
-
"text-foreground relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 text-sm font-normal transition-colors outline-none",
|
|
194
|
+
"text-foreground duration-fast relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 text-sm font-normal transition-colors ease-out outline-none",
|
|
195
195
|
"hover:bg-accent hover:text-foreground",
|
|
196
196
|
"focus:bg-accent focus:text-foreground",
|
|
197
197
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -268,7 +268,7 @@ function MenubarRadioItem({
|
|
|
268
268
|
return (
|
|
269
269
|
<MenubarPrimitive.RadioItem
|
|
270
270
|
className={cn(
|
|
271
|
-
"text-foreground relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 text-sm font-normal transition-colors outline-none",
|
|
271
|
+
"text-foreground duration-fast relative flex cursor-pointer items-center justify-between rounded-sm py-1.5 pr-2 pl-8 text-sm font-normal transition-colors ease-out outline-none",
|
|
272
272
|
"hover:bg-accent hover:text-foreground",
|
|
273
273
|
"focus:bg-accent focus:text-foreground",
|
|
274
274
|
"data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
@@ -381,7 +381,7 @@ function MenubarSubTrigger({
|
|
|
381
381
|
return (
|
|
382
382
|
<MenubarPrimitive.SubTrigger
|
|
383
383
|
className={cn(
|
|
384
|
-
"text-foreground flex cursor-pointer items-center justify-between rounded-xs px-2 py-1.5 text-sm font-normal transition-colors outline-none",
|
|
384
|
+
"text-foreground duration-fast flex cursor-pointer items-center justify-between rounded-xs px-2 py-1.5 text-sm font-normal transition-colors ease-out outline-none",
|
|
385
385
|
"hover:bg-accent hover:text-foreground",
|
|
386
386
|
"focus:bg-accent focus:text-foreground",
|
|
387
387
|
"data-[state=open]:bg-accent data-[state=open]:text-foreground",
|
|
@@ -141,7 +141,7 @@ const NavigationMenuTrigger = React.forwardRef<
|
|
|
141
141
|
"rounded-md px-4 py-2",
|
|
142
142
|
"text-sm font-medium",
|
|
143
143
|
"text-foreground",
|
|
144
|
-
"transition-colors",
|
|
144
|
+
"duration-fast transition-colors ease-out",
|
|
145
145
|
"hover:bg-accent hover:text-accent-foreground",
|
|
146
146
|
"focus:bg-accent focus:text-accent-foreground",
|
|
147
147
|
"focus-visible:bg-accent focus-visible:ring-ring focus-visible:shadow-[0_0_0_4px_rgba(163,163,163,0.1)] focus-visible:ring-1 focus-visible:outline-none",
|
|
@@ -182,7 +182,7 @@ const NavigationMenuTrigger = React.forwardRef<
|
|
|
182
182
|
{children}
|
|
183
183
|
<ChevronDown
|
|
184
184
|
aria-hidden="true"
|
|
185
|
-
className="relative top-[1px] ml-1 transition
|
|
185
|
+
className="duration-base relative top-[1px] ml-1 transition-transform ease-in-out group-data-[state=open]:rotate-180"
|
|
186
186
|
size={12}
|
|
187
187
|
/>
|
|
188
188
|
</NavigationMenuPrimitive.Trigger>
|
|
@@ -218,7 +218,7 @@ const NavigationMenuContent = React.forwardRef<
|
|
|
218
218
|
// Match the viewport's easeOutQuint timing so the directional slide and
|
|
219
219
|
// the container morph feel like one motion (kept snappy so content
|
|
220
220
|
// appears without a perceptible fade-in delay).
|
|
221
|
-
"duration-
|
|
221
|
+
"duration-base ease-emphasized",
|
|
222
222
|
"md:absolute md:w-auto",
|
|
223
223
|
],
|
|
224
224
|
className
|
|
@@ -251,7 +251,7 @@ const NavigationMenuLink = React.forwardRef<
|
|
|
251
251
|
className={cn(
|
|
252
252
|
[
|
|
253
253
|
"block rounded-md p-3 leading-none no-underline select-none",
|
|
254
|
-
"transition-colors outline-none",
|
|
254
|
+
"duration-fast transition-colors ease-out outline-none",
|
|
255
255
|
"hover:bg-accent hover:text-accent-foreground",
|
|
256
256
|
"focus:bg-accent focus:text-accent-foreground",
|
|
257
257
|
"focus-visible:bg-accent focus-visible:ring-ring focus-visible:shadow-[0_0_0_4px_rgba(163,163,163,0.1)] focus-visible:ring-1 focus-visible:outline-none",
|
|
@@ -285,9 +285,9 @@ const NavigationMenuViewport = React.forwardRef<
|
|
|
285
285
|
// 150ms out) so the panel and its content appear immediately rather
|
|
286
286
|
// than fading in slowly. Reduced motion is neutralised globally by the
|
|
287
287
|
// token preset, so no per-element motion-reduce guard is needed.
|
|
288
|
-
"
|
|
288
|
+
"duration-base ease-emphasized transition-[width,height]",
|
|
289
289
|
"data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95",
|
|
290
|
-
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-
|
|
290
|
+
"data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=closed]:duration-fast data-[state=closed]:ease-in",
|
|
291
291
|
"md:w-[var(--radix-navigation-menu-viewport-width)]",
|
|
292
292
|
],
|
|
293
293
|
className
|
|
@@ -100,7 +100,7 @@ const paginationItemVariants = cva(
|
|
|
100
100
|
"h-9 w-9",
|
|
101
101
|
"rounded-full",
|
|
102
102
|
"text-sm font-medium",
|
|
103
|
-
"transition-colors duration-
|
|
103
|
+
"transition-colors duration-fast ease-out",
|
|
104
104
|
"focus-visible:outline-none focus-visible:shadow-default",
|
|
105
105
|
],
|
|
106
106
|
{
|