@brightlocal/ui-components 2.21.0 → 2.22.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/component-meta.json +22 -5
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts +35 -3
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +178 -152
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +45 -45
- package/dist/index.cjs +1 -1
- package/dist/index.js +69 -68
- package/dist/lib/utils.cjs +1 -1
- package/dist/lib/utils.d.ts +1 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +7 -5
- package/dist/navigation-menu.cjs +1 -1
- package/dist/navigation-menu.d.ts +5 -7
- package/dist/navigation-menu.d.ts.map +1 -1
- package/dist/navigation-menu.js +82 -90
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +22 -2
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +57 -43
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +36 -36
- package/package.json +1 -1
- package/src/blocks/data-table.tsx +56 -2
- package/src/components/hover-card.tsx +6 -3
- package/src/components/navigation-menu.tsx +80 -101
- package/src/components/table.tsx +44 -7
- package/src/components/tooltip.tsx +8 -5
- package/src/lib/utils.ts +3 -0
package/dist/tooltip.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as a, jsxs as c } from "react/jsx-runtime";
|
|
2
2
|
import * as i from "react";
|
|
3
|
-
import * as
|
|
4
|
-
import { cn as f } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
-
function
|
|
6
|
-
delayDuration:
|
|
7
|
-
skipDelayDuration:
|
|
3
|
+
import * as t from "@radix-ui/react-tooltip";
|
|
4
|
+
import { cn as f, FLOATING_CONTENT_ANIMATION as g } from "@brightlocal/ui-components/lib/utils";
|
|
5
|
+
function w({
|
|
6
|
+
delayDuration: o = 0,
|
|
7
|
+
skipDelayDuration: r = 0,
|
|
8
8
|
...e
|
|
9
9
|
}) {
|
|
10
|
-
return /* @__PURE__ */
|
|
11
|
-
|
|
10
|
+
return /* @__PURE__ */ a(
|
|
11
|
+
t.Provider,
|
|
12
12
|
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
skipDelayDuration: a,
|
|
13
|
+
delayDuration: o,
|
|
14
|
+
skipDelayDuration: r,
|
|
16
15
|
...e
|
|
17
16
|
}
|
|
18
17
|
);
|
|
19
18
|
}
|
|
20
19
|
function y({
|
|
21
|
-
...
|
|
20
|
+
...o
|
|
22
21
|
}) {
|
|
23
|
-
return /* @__PURE__ */
|
|
22
|
+
return /* @__PURE__ */ a(t.Root, { ...o });
|
|
24
23
|
}
|
|
25
|
-
const
|
|
26
|
-
|
|
24
|
+
const T = i.forwardRef(({ ...o }, r) => /* @__PURE__ */ a(
|
|
25
|
+
t.Trigger,
|
|
27
26
|
{
|
|
28
|
-
ref:
|
|
27
|
+
ref: r,
|
|
29
28
|
"data-slot": "tooltip-trigger",
|
|
30
|
-
...
|
|
29
|
+
...o
|
|
31
30
|
}
|
|
32
31
|
));
|
|
33
|
-
|
|
32
|
+
T.displayName = "TooltipTrigger";
|
|
34
33
|
const x = i.forwardRef(
|
|
35
34
|
({
|
|
36
|
-
className:
|
|
37
|
-
sideOffset:
|
|
35
|
+
className: o,
|
|
36
|
+
sideOffset: r = 0,
|
|
38
37
|
dataHook: e,
|
|
39
|
-
trackingEl:
|
|
40
|
-
trackingLabel:
|
|
41
|
-
hideArrow:
|
|
38
|
+
trackingEl: n,
|
|
39
|
+
trackingLabel: l,
|
|
40
|
+
hideArrow: d = !1,
|
|
42
41
|
children: s,
|
|
43
42
|
...p
|
|
44
|
-
},
|
|
45
|
-
|
|
43
|
+
}, m) => /* @__PURE__ */ a(t.Portal, { children: /* @__PURE__ */ c(
|
|
44
|
+
t.Content,
|
|
46
45
|
{
|
|
47
|
-
ref:
|
|
46
|
+
ref: m,
|
|
48
47
|
className: f(
|
|
49
|
-
"bg-secondary text-secondary-foreground z-50 rounded-md px-3 py-1.5 text-xs leading-4 font-normal",
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
"bg-secondary text-secondary-foreground z-50 w-max max-w-sm rounded-md px-3 py-1.5 text-xs leading-4 font-normal",
|
|
49
|
+
g,
|
|
50
|
+
"**:data-[slot=tooltip-arrow]:-translate-y-px",
|
|
51
|
+
o
|
|
52
52
|
),
|
|
53
53
|
"data-hook": e,
|
|
54
54
|
"data-slot": "tooltip-content",
|
|
55
|
-
"data-tracking-el":
|
|
56
|
-
"data-tracking-label":
|
|
57
|
-
sideOffset:
|
|
55
|
+
"data-tracking-el": n,
|
|
56
|
+
"data-tracking-label": l,
|
|
57
|
+
sideOffset: r,
|
|
58
58
|
...p,
|
|
59
59
|
children: [
|
|
60
60
|
s,
|
|
61
|
-
!
|
|
62
|
-
|
|
61
|
+
!d && /* @__PURE__ */ a(
|
|
62
|
+
t.Arrow,
|
|
63
63
|
{
|
|
64
64
|
className: "fill-secondary",
|
|
65
65
|
"data-slot": "tooltip-arrow",
|
|
@@ -75,6 +75,6 @@ x.displayName = "TooltipContent";
|
|
|
75
75
|
export {
|
|
76
76
|
y as Tooltip,
|
|
77
77
|
x as TooltipContent,
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
w as TooltipProvider,
|
|
79
|
+
T as TooltipTrigger
|
|
80
80
|
};
|
package/package.json
CHANGED
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
type ExpandedState,
|
|
29
29
|
type PaginationState,
|
|
30
30
|
type Row,
|
|
31
|
+
type RowData,
|
|
31
32
|
type RowSelectionState,
|
|
32
33
|
type SortingState,
|
|
33
34
|
type Table as TanStackTable,
|
|
@@ -39,6 +40,16 @@ import {
|
|
|
39
40
|
getSortedRowModel,
|
|
40
41
|
useReactTable,
|
|
41
42
|
} from "@tanstack/react-table";
|
|
43
|
+
|
|
44
|
+
declare module "@tanstack/react-table" {
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
46
|
+
interface ColumnMeta<TData extends RowData, TValue> {
|
|
47
|
+
/** Explicit column width (e.g., "200px", "50%", "10rem"). */
|
|
48
|
+
width?: string;
|
|
49
|
+
/** Minimum column width (e.g., "100px", "8rem"). */
|
|
50
|
+
minWidth?: string;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
42
53
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
43
54
|
import { ArrowDown, ArrowUp, ArrowUpDown, Search, X } from "@brightlocal/icons";
|
|
44
55
|
|
|
@@ -400,6 +411,30 @@ export interface DataTableProps<TData> {
|
|
|
400
411
|
stickyHeader?: boolean;
|
|
401
412
|
/** Additional class name for the outer wrapper. */
|
|
402
413
|
className?: string;
|
|
414
|
+
/**
|
|
415
|
+
* Table layout algorithm.
|
|
416
|
+
* - `"auto"` (default) — browser sizes columns based on content.
|
|
417
|
+
* - `"fixed"` — columns respect explicit `width` values on `TableHead`/`TableCell`
|
|
418
|
+
* and split remaining space equally. Use when you set `width` on headers.
|
|
419
|
+
*
|
|
420
|
+
* **Migration note:** `"fixed"` will become the default in the next major release.
|
|
421
|
+
* Consumers should start setting explicit `width` on columns now.
|
|
422
|
+
* @default "auto"
|
|
423
|
+
*/
|
|
424
|
+
layout?: "auto" | "fixed";
|
|
425
|
+
/**
|
|
426
|
+
* Minimum width for the table (e.g., "1100px", "60rem"). Prevents columns
|
|
427
|
+
* from compressing on narrow viewports and enables horizontal scroll.
|
|
428
|
+
* When set, the scroll container becomes a focusable region for
|
|
429
|
+
* keyboard accessibility.
|
|
430
|
+
*/
|
|
431
|
+
minWidth?: string;
|
|
432
|
+
/**
|
|
433
|
+
* Accessible label for the scroll container region.
|
|
434
|
+
* Used when `minWidth` is set to provide context for keyboard users.
|
|
435
|
+
* @default "Scrollable table"
|
|
436
|
+
*/
|
|
437
|
+
scrollRegionLabel?: string;
|
|
403
438
|
/**
|
|
404
439
|
* Optional footer rendered inside the `<table>` element after `<tbody>`.
|
|
405
440
|
* Use for summary rows or totals. Pass a `<TableFooter>` with rows.
|
|
@@ -428,6 +463,9 @@ export function DataTable<TData>({
|
|
|
428
463
|
noResultsMessage = "No results.",
|
|
429
464
|
stickyHeader = false,
|
|
430
465
|
className,
|
|
466
|
+
layout,
|
|
467
|
+
minWidth,
|
|
468
|
+
scrollRegionLabel,
|
|
431
469
|
footer,
|
|
432
470
|
}: DataTableProps<TData>) {
|
|
433
471
|
const columnCount = table.getVisibleLeafColumns().length;
|
|
@@ -443,7 +481,12 @@ export function DataTable<TData>({
|
|
|
443
481
|
data-tracking-el={trackingEl}
|
|
444
482
|
data-tracking-label={trackingLabel}
|
|
445
483
|
>
|
|
446
|
-
<Table
|
|
484
|
+
<Table
|
|
485
|
+
dataHook={`${dataHook}-table`}
|
|
486
|
+
layout={layout}
|
|
487
|
+
minWidth={minWidth}
|
|
488
|
+
scrollRegionLabel={scrollRegionLabel}
|
|
489
|
+
>
|
|
447
490
|
<DataTableHeaderRows stickyHeader={stickyHeader} table={table} />
|
|
448
491
|
<TableBody>
|
|
449
492
|
{isLoading ? (
|
|
@@ -515,11 +558,14 @@ function DataTableHeaderRows<TData>({
|
|
|
515
558
|
: header.column.getCanSort()
|
|
516
559
|
? "none"
|
|
517
560
|
: undefined;
|
|
561
|
+
const meta = header.column.columnDef.meta;
|
|
518
562
|
return (
|
|
519
563
|
<TableHead
|
|
520
564
|
key={header.id}
|
|
521
565
|
aria-sort={ariaSort}
|
|
522
566
|
colSpan={header.colSpan}
|
|
567
|
+
minWidth={meta?.minWidth}
|
|
568
|
+
width={meta?.width}
|
|
523
569
|
>
|
|
524
570
|
{header.isPlaceholder
|
|
525
571
|
? null
|
|
@@ -646,6 +692,9 @@ export function VirtualizedDataTable<TData>({
|
|
|
646
692
|
noResultsMessage = "No results.",
|
|
647
693
|
stickyHeader = false,
|
|
648
694
|
className,
|
|
695
|
+
layout,
|
|
696
|
+
minWidth,
|
|
697
|
+
scrollRegionLabel,
|
|
649
698
|
footer,
|
|
650
699
|
height,
|
|
651
700
|
estimateSize = 48,
|
|
@@ -688,7 +737,12 @@ export function VirtualizedDataTable<TData>({
|
|
|
688
737
|
data-tracking-label={trackingLabel}
|
|
689
738
|
style={height != null ? { height } : undefined}
|
|
690
739
|
>
|
|
691
|
-
<Table
|
|
740
|
+
<Table
|
|
741
|
+
dataHook={`${dataHook}-table`}
|
|
742
|
+
layout={layout}
|
|
743
|
+
minWidth={minWidth}
|
|
744
|
+
scrollRegionLabel={scrollRegionLabel}
|
|
745
|
+
>
|
|
692
746
|
<DataTableHeaderRows stickyHeader={stickyHeader} table={table} />
|
|
693
747
|
<TableBody>
|
|
694
748
|
{isLoading ? (
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
cn,
|
|
7
|
+
FLOATING_CONTENT_ANIMATION,
|
|
8
|
+
} from "@brightlocal/ui-components/lib/utils";
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* HoverCard props
|
|
@@ -142,8 +145,8 @@ const HoverCardContent = React.forwardRef<
|
|
|
142
145
|
ref={ref}
|
|
143
146
|
align={align}
|
|
144
147
|
className={cn(
|
|
145
|
-
"border-border bg-popover text-popover-foreground z-50 w-
|
|
146
|
-
|
|
148
|
+
"border-border bg-popover text-popover-foreground z-50 w-max max-w-sm rounded-lg border p-4 shadow-md outline-hidden",
|
|
149
|
+
FLOATING_CONTENT_ANIMATION,
|
|
147
150
|
className
|
|
148
151
|
)}
|
|
149
152
|
data-hook={dataHook}
|
|
@@ -92,11 +92,12 @@ type NavigationMenuTriggerProps = React.ComponentPropsWithoutRef<
|
|
|
92
92
|
>;
|
|
93
93
|
|
|
94
94
|
/**
|
|
95
|
-
* Window (ms) after the
|
|
96
|
-
* instinctive and is NOT allowed to close the menu.
|
|
97
|
-
* "patient click" threshold (PATIENT_CLICK_THRESHOLD)
|
|
95
|
+
* Window (ms) after the pointer enters an open trigger during which a mouse
|
|
96
|
+
* click is treated as instinctive and is NOT allowed to close the menu. Based
|
|
97
|
+
* on Base UI's "patient click" threshold (PATIENT_CLICK_THRESHOLD = 500), tuned
|
|
98
|
+
* slightly shorter so the trigger becomes a deliberate toggle a touch sooner.
|
|
98
99
|
*/
|
|
99
|
-
const PATIENT_CLICK_THRESHOLD_MS =
|
|
100
|
+
const PATIENT_CLICK_THRESHOLD_MS = 400;
|
|
100
101
|
|
|
101
102
|
/**
|
|
102
103
|
* Trigger button that opens a dropdown menu
|
|
@@ -107,109 +108,87 @@ const PATIENT_CLICK_THRESHOLD_MS = 500;
|
|
|
107
108
|
* closes it immediately (see radix-ui/primitives#1630).
|
|
108
109
|
*
|
|
109
110
|
* We port Base UI's "patient click" behaviour: an instinctive mouse click made
|
|
110
|
-
* within {@link PATIENT_CLICK_THRESHOLD_MS} of the
|
|
111
|
-
* (calling `preventDefault()` makes Radix's internal
|
|
112
|
-
* skip its toggle).
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* menu shut, and touch taps and keyboard activation are left untouched so they
|
|
116
|
-
* can toggle it too.
|
|
111
|
+
* within {@link PATIENT_CLICK_THRESHOLD_MS} of the pointer entering an open
|
|
112
|
+
* trigger keeps the menu open (calling `preventDefault()` makes Radix's internal
|
|
113
|
+
* `composeEventHandlers` skip its toggle). A deliberate click after that window
|
|
114
|
+
* still toggles the menu shut, and touch taps and keyboard activation are left
|
|
115
|
+
* untouched so they can toggle it too.
|
|
117
116
|
*/
|
|
118
117
|
const NavigationMenuTrigger = React.forwardRef<
|
|
119
118
|
React.ElementRef<typeof NavigationMenuPrimitive.Trigger>,
|
|
120
119
|
NavigationMenuTriggerProps
|
|
121
|
-
>(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
120
|
+
>(
|
|
121
|
+
(
|
|
122
|
+
{ className, children, onClick, onPointerDown, onPointerEnter, ...props },
|
|
123
|
+
ref
|
|
124
|
+
) => {
|
|
125
|
+
// Pointer type of the interaction, so the keep-open behaviour only applies
|
|
126
|
+
// to mouse (the only input that hover-opens before a click).
|
|
127
|
+
const lastPointerTypeRef = React.useRef<string>("");
|
|
128
|
+
// Timestamp of the last pointer enter, used to measure whether a click is
|
|
129
|
+
// "instinctive" (right after hover) or "patient" (deliberate). Captured from
|
|
130
|
+
// the SAME `event.timeStamp` clock the click uses so the subtraction is
|
|
131
|
+
// valid — never compare against `performance.now()`, which is a different
|
|
132
|
+
// origin and makes every click read as "patient" (i.e. always closes).
|
|
133
|
+
const pointerEnterAtRef = React.useRef(0);
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
135
|
+
return (
|
|
136
|
+
<NavigationMenuPrimitive.Trigger
|
|
137
|
+
ref={ref}
|
|
138
|
+
className={cn(
|
|
139
|
+
[
|
|
140
|
+
"group inline-flex h-9 w-max items-center justify-center gap-1",
|
|
141
|
+
"rounded-md px-4 py-2",
|
|
142
|
+
"text-sm font-medium",
|
|
143
|
+
"text-foreground",
|
|
144
|
+
"transition-colors",
|
|
145
|
+
"hover:bg-accent hover:text-accent-foreground",
|
|
146
|
+
"focus:bg-accent focus:text-accent-foreground",
|
|
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",
|
|
148
|
+
"disabled:pointer-events-none disabled:opacity-50",
|
|
149
|
+
"data-[state=open]:bg-accent/50",
|
|
150
|
+
],
|
|
151
|
+
className
|
|
152
|
+
)}
|
|
153
|
+
data-slot="navigation-menu-trigger"
|
|
154
|
+
onClick={(event) => {
|
|
155
|
+
// `data-state` is "open" only when hover already opened this trigger.
|
|
156
|
+
// `event.detail > 0` excludes keyboard-synthesised clicks (detail === 0).
|
|
157
|
+
const isOpen =
|
|
158
|
+
event.currentTarget.getAttribute("data-state") === "open";
|
|
159
|
+
const isInstinctiveClick =
|
|
160
|
+
event.timeStamp - pointerEnterAtRef.current <
|
|
161
|
+
PATIENT_CLICK_THRESHOLD_MS;
|
|
162
|
+
if (
|
|
163
|
+
lastPointerTypeRef.current === "mouse" &&
|
|
164
|
+
event.detail > 0 &&
|
|
165
|
+
isOpen &&
|
|
166
|
+
isInstinctiveClick
|
|
167
|
+
) {
|
|
168
|
+
event.preventDefault();
|
|
150
169
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
"focus:bg-accent focus:text-accent-foreground",
|
|
174
|
-
"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",
|
|
175
|
-
"disabled:pointer-events-none disabled:opacity-50",
|
|
176
|
-
"data-[state=open]:bg-accent/50",
|
|
177
|
-
],
|
|
178
|
-
className
|
|
179
|
-
)}
|
|
180
|
-
data-slot="navigation-menu-trigger"
|
|
181
|
-
onClick={(event) => {
|
|
182
|
-
// `data-state` is "open" only when hover already opened this trigger.
|
|
183
|
-
// `event.detail > 0` excludes keyboard-synthesised clicks (detail === 0).
|
|
184
|
-
const isOpen =
|
|
185
|
-
event.currentTarget.getAttribute("data-state") === "open";
|
|
186
|
-
const isInstinctiveClick =
|
|
187
|
-
event.timeStamp - openedAtRef.current < PATIENT_CLICK_THRESHOLD_MS;
|
|
188
|
-
if (
|
|
189
|
-
lastPointerTypeRef.current === "mouse" &&
|
|
190
|
-
event.detail > 0 &&
|
|
191
|
-
isOpen &&
|
|
192
|
-
isInstinctiveClick
|
|
193
|
-
) {
|
|
194
|
-
event.preventDefault();
|
|
195
|
-
}
|
|
196
|
-
onClick?.(event);
|
|
197
|
-
}}
|
|
198
|
-
onPointerDown={(event) => {
|
|
199
|
-
lastPointerTypeRef.current = event.pointerType;
|
|
200
|
-
onPointerDown?.(event);
|
|
201
|
-
}}
|
|
202
|
-
{...props}
|
|
203
|
-
>
|
|
204
|
-
{children}
|
|
205
|
-
<ChevronDown
|
|
206
|
-
aria-hidden="true"
|
|
207
|
-
className="relative top-[1px] ml-1 transition duration-300 group-data-[state=open]:rotate-180"
|
|
208
|
-
size={12}
|
|
209
|
-
/>
|
|
210
|
-
</NavigationMenuPrimitive.Trigger>
|
|
211
|
-
);
|
|
212
|
-
});
|
|
170
|
+
onClick?.(event);
|
|
171
|
+
}}
|
|
172
|
+
onPointerDown={(event) => {
|
|
173
|
+
lastPointerTypeRef.current = event.pointerType;
|
|
174
|
+
onPointerDown?.(event);
|
|
175
|
+
}}
|
|
176
|
+
onPointerEnter={(event) => {
|
|
177
|
+
pointerEnterAtRef.current = event.timeStamp;
|
|
178
|
+
onPointerEnter?.(event);
|
|
179
|
+
}}
|
|
180
|
+
{...props}
|
|
181
|
+
>
|
|
182
|
+
{children}
|
|
183
|
+
<ChevronDown
|
|
184
|
+
aria-hidden="true"
|
|
185
|
+
className="relative top-[1px] ml-1 transition duration-300 group-data-[state=open]:rotate-180"
|
|
186
|
+
size={12}
|
|
187
|
+
/>
|
|
188
|
+
</NavigationMenuPrimitive.Trigger>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
);
|
|
213
192
|
|
|
214
193
|
NavigationMenuTrigger.displayName = "NavigationMenuTrigger";
|
|
215
194
|
|
package/src/components/table.tsx
CHANGED
|
@@ -64,6 +64,17 @@ interface TableProps extends React.ComponentProps<"table"> {
|
|
|
64
64
|
* Tracking label for analytics context
|
|
65
65
|
*/
|
|
66
66
|
trackingLabel?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Table layout algorithm.
|
|
69
|
+
* - `"auto"` (default) — browser sizes columns based on content.
|
|
70
|
+
* - `"fixed"` — columns respect explicit `width` values on `TableHead`/`TableCell`
|
|
71
|
+
* and split remaining space equally. Use when you set `width` on headers.
|
|
72
|
+
*
|
|
73
|
+
* **Migration note:** `"fixed"` will become the default in the next major release.
|
|
74
|
+
* Consumers should start setting explicit `width` on `TableHead` columns now.
|
|
75
|
+
* @default "auto"
|
|
76
|
+
*/
|
|
77
|
+
layout?: "auto" | "fixed";
|
|
67
78
|
/**
|
|
68
79
|
* Minimum width for the table (e.g., "600px", "40rem").
|
|
69
80
|
* Prevents columns from compressing on narrow viewports and enables
|
|
@@ -87,6 +98,7 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
|
87
98
|
dataHook,
|
|
88
99
|
trackingEl,
|
|
89
100
|
trackingLabel,
|
|
101
|
+
layout = "auto",
|
|
90
102
|
minWidth,
|
|
91
103
|
scrollRegionLabel,
|
|
92
104
|
style,
|
|
@@ -111,7 +123,11 @@ const Table = React.forwardRef<HTMLTableElement, TableProps>(
|
|
|
111
123
|
>
|
|
112
124
|
<table
|
|
113
125
|
ref={ref}
|
|
114
|
-
className={cn(
|
|
126
|
+
className={cn(
|
|
127
|
+
"w-full caption-bottom text-sm",
|
|
128
|
+
layout === "fixed" && "table-fixed",
|
|
129
|
+
className
|
|
130
|
+
)}
|
|
115
131
|
data-hook={dataHook}
|
|
116
132
|
data-slot="table"
|
|
117
133
|
data-tracking-el={trackingEl}
|
|
@@ -242,7 +258,11 @@ interface TableHeadProps
|
|
|
242
258
|
*/
|
|
243
259
|
dataHook?: string;
|
|
244
260
|
/**
|
|
245
|
-
*
|
|
261
|
+
* Explicit width for the column (e.g., "200px", "50%", "10rem").
|
|
262
|
+
*/
|
|
263
|
+
width?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Minimum width for the column (e.g., "100px", "8rem").
|
|
246
266
|
*/
|
|
247
267
|
minWidth?: string;
|
|
248
268
|
/**
|
|
@@ -254,7 +274,16 @@ interface TableHeadProps
|
|
|
254
274
|
|
|
255
275
|
const TableHead = React.forwardRef<HTMLTableCellElement, TableHeadProps>(
|
|
256
276
|
(
|
|
257
|
-
{
|
|
277
|
+
{
|
|
278
|
+
className,
|
|
279
|
+
dataHook,
|
|
280
|
+
align,
|
|
281
|
+
width,
|
|
282
|
+
minWidth,
|
|
283
|
+
style,
|
|
284
|
+
scope = "col",
|
|
285
|
+
...props
|
|
286
|
+
},
|
|
258
287
|
ref
|
|
259
288
|
) => (
|
|
260
289
|
<th
|
|
@@ -263,7 +292,7 @@ const TableHead = React.forwardRef<HTMLTableCellElement, TableHeadProps>(
|
|
|
263
292
|
data-hook={dataHook}
|
|
264
293
|
data-slot="table-head"
|
|
265
294
|
scope={scope}
|
|
266
|
-
style={{ minWidth, ...style }}
|
|
295
|
+
style={{ width, minWidth, ...style }}
|
|
267
296
|
{...props}
|
|
268
297
|
/>
|
|
269
298
|
)
|
|
@@ -284,7 +313,12 @@ interface TableCellProps
|
|
|
284
313
|
*/
|
|
285
314
|
dataHook?: string;
|
|
286
315
|
/**
|
|
287
|
-
*
|
|
316
|
+
* Width for the cell (e.g., "200px", "50%", "10rem").
|
|
317
|
+
* Set `layout="fixed"` on the parent `Table` for this value to be respected as an exact constraint.
|
|
318
|
+
*/
|
|
319
|
+
width?: string;
|
|
320
|
+
/**
|
|
321
|
+
* Minimum width for the cell (e.g., "100px", "8rem").
|
|
288
322
|
*/
|
|
289
323
|
minWidth?: string;
|
|
290
324
|
/**
|
|
@@ -300,13 +334,16 @@ interface TableCellProps
|
|
|
300
334
|
}
|
|
301
335
|
|
|
302
336
|
const TableCell = React.forwardRef<HTMLTableCellElement, TableCellProps>(
|
|
303
|
-
(
|
|
337
|
+
(
|
|
338
|
+
{ className, dataHook, size, align, width, minWidth, style, ...props },
|
|
339
|
+
ref
|
|
340
|
+
) => (
|
|
304
341
|
<td
|
|
305
342
|
ref={ref}
|
|
306
343
|
className={cn(tableCellVariants({ size, align }), className)}
|
|
307
344
|
data-hook={dataHook}
|
|
308
345
|
data-slot="table-cell"
|
|
309
|
-
style={{ minWidth, ...style }}
|
|
346
|
+
style={{ width, minWidth, ...style }}
|
|
310
347
|
{...props}
|
|
311
348
|
/>
|
|
312
349
|
)
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
cn,
|
|
8
|
+
FLOATING_CONTENT_ANIMATION,
|
|
9
|
+
} from "@brightlocal/ui-components/lib/utils";
|
|
7
10
|
|
|
8
11
|
interface TooltipProviderProps extends React.ComponentProps<
|
|
9
12
|
typeof TooltipPrimitive.Provider
|
|
@@ -35,7 +38,6 @@ function TooltipProvider({
|
|
|
35
38
|
}: TooltipProviderProps) {
|
|
36
39
|
return (
|
|
37
40
|
<TooltipPrimitive.Provider
|
|
38
|
-
data-slot="tooltip-provider"
|
|
39
41
|
delayDuration={delayDuration}
|
|
40
42
|
skipDelayDuration={skipDelayDuration}
|
|
41
43
|
{...props}
|
|
@@ -65,7 +67,7 @@ function TooltipProvider({
|
|
|
65
67
|
function Tooltip({
|
|
66
68
|
...props
|
|
67
69
|
}: React.ComponentProps<typeof TooltipPrimitive.Root>) {
|
|
68
|
-
return <TooltipPrimitive.Root
|
|
70
|
+
return <TooltipPrimitive.Root {...props} />;
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
const TooltipTrigger = React.forwardRef<
|
|
@@ -126,8 +128,9 @@ const TooltipContent = React.forwardRef<
|
|
|
126
128
|
<TooltipPrimitive.Content
|
|
127
129
|
ref={ref}
|
|
128
130
|
className={cn(
|
|
129
|
-
"bg-secondary text-secondary-foreground z-50 rounded-md px-3 py-1.5 text-xs leading-4 font-normal",
|
|
130
|
-
|
|
131
|
+
"bg-secondary text-secondary-foreground z-50 w-max max-w-sm rounded-md px-3 py-1.5 text-xs leading-4 font-normal",
|
|
132
|
+
FLOATING_CONTENT_ANIMATION,
|
|
133
|
+
"**:data-[slot=tooltip-arrow]:-translate-y-px",
|
|
131
134
|
className
|
|
132
135
|
)}
|
|
133
136
|
data-hook={dataHook}
|
package/src/lib/utils.ts
CHANGED
|
@@ -4,3 +4,6 @@ import { twMerge } from "tailwind-merge";
|
|
|
4
4
|
export function cn(...inputs: ClassValue[]) {
|
|
5
5
|
return twMerge(clsx(inputs));
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
export const FLOATING_CONTENT_ANIMATION =
|
|
9
|
+
"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";
|