@brightlocal/ui-components 2.22.0 → 2.24.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 +1 -1
- package/README.md +4 -2
- package/component-meta.json +134 -25
- package/deprecations.json +22 -0
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +32 -35
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +151 -156
- package/dist/brand-illustration-motif.cjs +1 -0
- package/dist/brand-illustration-motif.d.ts +55 -0
- package/dist/brand-illustration-motif.d.ts.map +1 -0
- package/dist/brand-illustration-motif.js +67 -0
- package/dist/chart.cjs +7 -7
- package/dist/chart.d.ts +287 -2
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +408 -152
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +14 -1
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +387 -376
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +111 -109
- package/dist/data-table.cjs +1 -0
- package/dist/{blocks/data-table.d.ts → data-table.d.ts} +159 -4
- package/dist/data-table.d.ts.map +1 -0
- package/dist/data-table.js +721 -0
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +109 -121
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +16 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +23 -7
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +32 -2
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +179 -109
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +526 -509
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts +9 -0
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +26 -22
- package/dist/lib/spring-settle.cjs +1 -0
- package/dist/lib/spring-settle.d.ts +20 -0
- package/dist/lib/spring-settle.d.ts.map +1 -0
- package/dist/lib/spring-settle.js +4 -0
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +3 -2
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +22 -11
- package/dist/loading.cjs +1 -0
- package/dist/loading.d.ts +47 -0
- package/dist/loading.d.ts.map +1 -0
- package/dist/loading.js +163 -0
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +1 -1
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +97 -99
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +27 -26
- package/dist/select.cjs +2 -2
- package/dist/select.d.ts +16 -1
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +112 -85
- package/dist/table.cjs +1 -1
- package/dist/table.d.ts +29 -0
- package/dist/table.d.ts.map +1 -1
- package/dist/table.js +2 -2
- package/dist/text-reveal-motion.cjs +1 -1
- package/dist/text-reveal-motion.d.ts.map +1 -1
- package/dist/text-reveal-motion.js +236 -219
- package/dist/tooltip.cjs +1 -1
- package/dist/tooltip.d.ts +21 -2
- package/dist/tooltip.d.ts.map +1 -1
- package/dist/tooltip.js +35 -32
- package/dist/typography.cjs +1 -1
- package/dist/typography.d.ts +20 -4
- package/dist/typography.d.ts.map +1 -1
- package/dist/typography.js +263 -228
- package/package.json +7 -7
- package/src/blocks/sidebar.tsx +11 -23
- package/src/components/alert.tsx +10 -17
- package/src/components/brand-illustration-motif.tsx +143 -0
- package/src/components/chart.tsx +632 -1
- package/src/components/combobox.tsx +47 -0
- package/src/components/context-menu.tsx +8 -3
- package/src/{blocks → components}/data-table.tsx +272 -18
- package/src/components/dropdown-menu.tsx +6 -15
- package/src/components/field.tsx +31 -0
- package/src/components/global-layout.tsx +144 -5
- package/src/components/label.tsx +13 -1
- package/src/components/link.tsx +13 -1
- package/src/components/loading.tsx +355 -0
- package/src/components/map.tsx +3 -1
- package/src/components/menubar.tsx +6 -5
- package/src/components/popover.tsx +6 -2
- package/src/components/select.tsx +87 -10
- package/src/components/table.tsx +31 -2
- package/src/components/text-reveal-motion.tsx +90 -64
- package/src/components/tooltip.tsx +28 -3
- package/src/components/typography.tsx +74 -18
- package/src/index.ts +3 -1
- package/src/lib/spring-settle.ts +19 -0
- package/dist/blocks/data-table.cjs +0 -1
- package/dist/blocks/data-table.d.ts.map +0 -1
- package/dist/blocks/data-table.js +0 -654
|
@@ -5,7 +5,10 @@ import * as SelectPrimitive from "@radix-ui/react-select";
|
|
|
5
5
|
import { Check, ChevronDown, ChevronUp } from "@brightlocal/icons";
|
|
6
6
|
import { cva } from "class-variance-authority";
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
cn,
|
|
10
|
+
FLOATING_CONTENT_ANIMATION,
|
|
11
|
+
} from "@brightlocal/ui-components/lib/utils";
|
|
9
12
|
import { useDevWarning } from "../lib/use-dev-warning";
|
|
10
13
|
import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
|
|
11
14
|
|
|
@@ -18,6 +21,21 @@ interface SelectProps extends React.ComponentProps<
|
|
|
18
21
|
> {
|
|
19
22
|
/** Children to render inside the select */
|
|
20
23
|
children?: React.ReactNode;
|
|
24
|
+
/**
|
|
25
|
+
* Close-commit callback — fired once each time the dropdown actually
|
|
26
|
+
* closes, and guaranteed to fire **after** any pending `onValueChange` has
|
|
27
|
+
* been delivered. Designed for blur-based form validation — in React Hook
|
|
28
|
+
* Form's onBlur mode, pass `field.onBlur` here so validation runs against
|
|
29
|
+
* the committed value when the dropdown closes, keeping `onOpenChange`
|
|
30
|
+
* free for product logic.
|
|
31
|
+
*
|
|
32
|
+
* Fires only on resolved closes: a controlled consumer that vetoes a close
|
|
33
|
+
* request gets no callback, while a programmatic controlled close does
|
|
34
|
+
* fire it. Unmounting while open counts as a close. Note that Radix Select
|
|
35
|
+
* also closes the dropdown when the window loses focus or resizes — those
|
|
36
|
+
* closes fire this callback too.
|
|
37
|
+
*/
|
|
38
|
+
onClose?: () => void;
|
|
21
39
|
}
|
|
22
40
|
|
|
23
41
|
interface SelectContentProps extends React.ComponentProps<
|
|
@@ -55,9 +73,74 @@ interface SelectContentProps extends React.ComponentProps<
|
|
|
55
73
|
* </Field>
|
|
56
74
|
* ```
|
|
57
75
|
*/
|
|
58
|
-
function Select({
|
|
76
|
+
function Select({
|
|
77
|
+
children,
|
|
78
|
+
onClose,
|
|
79
|
+
onOpenChange,
|
|
80
|
+
open: openProp,
|
|
81
|
+
defaultOpen,
|
|
82
|
+
...props
|
|
83
|
+
}: SelectProps) {
|
|
84
|
+
// Mirror the open state Radix resolves. Radix calls onOpenChange on every
|
|
85
|
+
// close *request*, even when a controlled consumer vetoes it by keeping
|
|
86
|
+
// `open` true — so onClose must be driven by the resolved state, never the
|
|
87
|
+
// request. Mirroring also catches programmatic controlled closes, which
|
|
88
|
+
// never go through onOpenChange at all.
|
|
89
|
+
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(
|
|
90
|
+
defaultOpen ?? false
|
|
91
|
+
);
|
|
92
|
+
const isOpenControlled = openProp !== undefined;
|
|
93
|
+
const open = isOpenControlled ? openProp : uncontrolledOpen;
|
|
94
|
+
|
|
95
|
+
const handleOpenChange = React.useCallback(
|
|
96
|
+
(nextOpen: boolean) => {
|
|
97
|
+
if (!isOpenControlled) {
|
|
98
|
+
setUncontrolledOpen(nextOpen);
|
|
99
|
+
}
|
|
100
|
+
onOpenChange?.(nextOpen);
|
|
101
|
+
},
|
|
102
|
+
[isOpenControlled, onOpenChange]
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// Close-commit callback (kept in sync with the identical block in
|
|
106
|
+
// combobox.tsx): fire onClose on the open → closed transition of the
|
|
107
|
+
// resolved state. Running in the effect phase — after the Radix Root
|
|
108
|
+
// child's own effects — guarantees an uncontrolled value's onValueChange
|
|
109
|
+
// (which Radix delivers from a passive effect) lands before onClose.
|
|
110
|
+
const onCloseRef = React.useRef(onClose);
|
|
111
|
+
React.useEffect(() => {
|
|
112
|
+
onCloseRef.current = onClose;
|
|
113
|
+
}, [onClose]);
|
|
114
|
+
|
|
115
|
+
const prevOpenRef = React.useRef(open);
|
|
116
|
+
React.useEffect(() => {
|
|
117
|
+
if (prevOpenRef.current && !open) {
|
|
118
|
+
onCloseRef.current?.();
|
|
119
|
+
}
|
|
120
|
+
prevOpenRef.current = open;
|
|
121
|
+
}, [open]);
|
|
122
|
+
|
|
123
|
+
// An unmount can BE the close (e.g. the dropdown is open inside a Dialog
|
|
124
|
+
// the same click dismisses) — the transition effect above never runs for an
|
|
125
|
+
// unmounting component, so fire from cleanup instead. Cleanups run
|
|
126
|
+
// child-first, so a react-hook-form Controller wrapping this component is
|
|
127
|
+
// still registered when its onBlur is invoked here.
|
|
128
|
+
React.useEffect(() => {
|
|
129
|
+
return () => {
|
|
130
|
+
if (prevOpenRef.current) {
|
|
131
|
+
onCloseRef.current?.();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}, []);
|
|
135
|
+
|
|
59
136
|
return (
|
|
60
|
-
<SelectPrimitive.Root
|
|
137
|
+
<SelectPrimitive.Root
|
|
138
|
+
data-slot="select"
|
|
139
|
+
defaultOpen={defaultOpen}
|
|
140
|
+
open={openProp}
|
|
141
|
+
onOpenChange={handleOpenChange}
|
|
142
|
+
{...props}
|
|
143
|
+
>
|
|
61
144
|
{children}
|
|
62
145
|
</SelectPrimitive.Root>
|
|
63
146
|
);
|
|
@@ -237,13 +320,7 @@ function SelectContent({
|
|
|
237
320
|
"origin-[var(--radix-select-content-transform-origin)]",
|
|
238
321
|
|
|
239
322
|
// Animations
|
|
240
|
-
|
|
241
|
-
"data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
242
|
-
"data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95",
|
|
243
|
-
"data-[side=bottom]:slide-in-from-top-2",
|
|
244
|
-
"data-[side=left]:slide-in-from-right-2",
|
|
245
|
-
"data-[side=right]:slide-in-from-left-2",
|
|
246
|
-
"data-[side=top]:slide-in-from-bottom-2"
|
|
323
|
+
FLOATING_CONTENT_ANIMATION
|
|
247
324
|
);
|
|
248
325
|
|
|
249
326
|
const popperStyles =
|
package/src/components/table.tsx
CHANGED
|
@@ -32,7 +32,7 @@ const tableCellVariants = cva(
|
|
|
32
32
|
);
|
|
33
33
|
|
|
34
34
|
const tableHeadVariants = cva(
|
|
35
|
-
"h-
|
|
35
|
+
"h-12 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-150 ease-in-out",
|
|
36
36
|
{
|
|
37
37
|
variants: {
|
|
38
38
|
align: {
|
|
@@ -157,7 +157,7 @@ const TableHeader = React.forwardRef<HTMLTableSectionElement, TableHeaderProps>(
|
|
|
157
157
|
({ className, dataHook, ...props }, ref) => (
|
|
158
158
|
<thead
|
|
159
159
|
ref={ref}
|
|
160
|
-
className={cn(className)}
|
|
160
|
+
className={cn("bg-muted", className)}
|
|
161
161
|
data-hook={dataHook}
|
|
162
162
|
data-slot="table-header"
|
|
163
163
|
{...props}
|
|
@@ -355,6 +355,10 @@ TableCell.displayName = "TableCell";
|
|
|
355
355
|
* TableCaption
|
|
356
356
|
* -----------------------------------------------------------------------------------------------*/
|
|
357
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Props for the TableCaption component.
|
|
360
|
+
* @deprecated Name the table with a heading and `aria-labelledby` instead. TableCaption will be removed in the next major version.
|
|
361
|
+
*/
|
|
358
362
|
interface TableCaptionProps extends React.ComponentProps<"caption"> {
|
|
359
363
|
/**
|
|
360
364
|
* Data hook for automated testing
|
|
@@ -362,6 +366,31 @@ interface TableCaptionProps extends React.ComponentProps<"caption"> {
|
|
|
362
366
|
dataHook?: string;
|
|
363
367
|
}
|
|
364
368
|
|
|
369
|
+
/**
|
|
370
|
+
* @deprecated Name the table with a heading and `aria-labelledby` instead.
|
|
371
|
+
*
|
|
372
|
+
* A `<caption>` is placed solely by the CSS `caption-side` property, never by
|
|
373
|
+
* where it sits among the table's children, so it cannot participate in
|
|
374
|
+
* composition. It also supplies the table's accessible name while contributing
|
|
375
|
+
* nothing to the document outline, and it scrolls horizontally with the table
|
|
376
|
+
* when `minWidth` is set.
|
|
377
|
+
*
|
|
378
|
+
* ```tsx
|
|
379
|
+
* // Before
|
|
380
|
+
* <Table dataHook="transactions">
|
|
381
|
+
* <TableCaption>Recent transactions</TableCaption>
|
|
382
|
+
* ...
|
|
383
|
+
* </Table>
|
|
384
|
+
*
|
|
385
|
+
* // After
|
|
386
|
+
* <TypographyH3 dataHook="transactions-heading" id="transactions-heading">
|
|
387
|
+
* Recent transactions
|
|
388
|
+
* </TypographyH3>
|
|
389
|
+
* <Table aria-labelledby="transactions-heading" dataHook="transactions">
|
|
390
|
+
* ...
|
|
391
|
+
* </Table>
|
|
392
|
+
* ```
|
|
393
|
+
*/
|
|
365
394
|
const TableCaption = React.forwardRef<
|
|
366
395
|
HTMLTableCaptionElement,
|
|
367
396
|
TableCaptionProps
|
|
@@ -13,6 +13,7 @@ import { animate } from "framer-motion";
|
|
|
13
13
|
|
|
14
14
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
15
15
|
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion";
|
|
16
|
+
import { SETTLE_REST_DELTA } from "../lib/spring-settle";
|
|
16
17
|
|
|
17
18
|
// ---------------------------------------------------------------------------
|
|
18
19
|
// Shape paths (500×500 viewBox)
|
|
@@ -40,21 +41,6 @@ const DEFAULT_SHAPES: string[] = [
|
|
|
40
41
|
STAR_PATH,
|
|
41
42
|
];
|
|
42
43
|
|
|
43
|
-
/** Number of pre-sampled frames for flubber morphs */
|
|
44
|
-
const MORPH_SAMPLES = 30;
|
|
45
|
-
|
|
46
|
-
/** Fewer samples on low-end devices to reduce pre-computation + memory */
|
|
47
|
-
const MORPH_SAMPLES_LOW = 15;
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Detect low-performance devices via hardware concurrency.
|
|
51
|
-
* Falls back to false on SSR or when the API is unavailable.
|
|
52
|
-
*/
|
|
53
|
-
const isLowPerfDevice =
|
|
54
|
-
typeof navigator !== "undefined" &&
|
|
55
|
-
typeof navigator.hardwareConcurrency === "number" &&
|
|
56
|
-
navigator.hardwareConcurrency <= 4;
|
|
57
|
-
|
|
58
44
|
// ---------------------------------------------------------------------------
|
|
59
45
|
// rAF-batched DOM write scheduler
|
|
60
46
|
// ---------------------------------------------------------------------------
|
|
@@ -69,7 +55,8 @@ interface FrameState {
|
|
|
69
55
|
function createFrameScheduler(
|
|
70
56
|
ball: HTMLDivElement,
|
|
71
57
|
group: SVGGElement,
|
|
72
|
-
path: SVGPathElement
|
|
58
|
+
path: SVGPathElement,
|
|
59
|
+
gradient: SVGLinearGradientElement | null
|
|
73
60
|
) {
|
|
74
61
|
let pending = false;
|
|
75
62
|
let activeItemEl: HTMLSpanElement | null = null;
|
|
@@ -82,6 +69,12 @@ function createFrameScheduler(
|
|
|
82
69
|
activeItemEl.style.clipPath = `inset(0 ${state.clipRight}% 0 0)`;
|
|
83
70
|
}
|
|
84
71
|
group.style.transform = `rotate(${state.rotate}deg)`;
|
|
72
|
+
// Counter-rotate the gradient so its orientation stays fixed on screen
|
|
73
|
+
// (yellow anchored top-right) while the ball spins beneath it.
|
|
74
|
+
gradient?.setAttribute(
|
|
75
|
+
"gradientTransform",
|
|
76
|
+
`rotate(${-state.rotate} 0.5 0.5)`
|
|
77
|
+
);
|
|
85
78
|
path.setAttribute("d", state.pathD);
|
|
86
79
|
}
|
|
87
80
|
|
|
@@ -326,8 +319,13 @@ const TextRevealMotion = React.forwardRef<
|
|
|
326
319
|
function tick(now: number) {
|
|
327
320
|
if (!start) start = now;
|
|
328
321
|
const t = (now - start) / 1000;
|
|
322
|
+
// Anchored to the brand gradient direction — `from` colour glowing
|
|
323
|
+
// from top-right into the `to` colour toward bottom-left — drifting
|
|
324
|
+
// gently around it.
|
|
329
325
|
const angle =
|
|
330
|
-
Math.
|
|
326
|
+
-Math.PI / 4 +
|
|
327
|
+
Math.sin(t * sA + oA) * 0.5 +
|
|
328
|
+
Math.sin(t * sB + oB) * 0.25;
|
|
331
329
|
if (Math.abs(angle - prevAngle) > 0.01) {
|
|
332
330
|
prevAngle = angle;
|
|
333
331
|
const cos = Math.cos(angle);
|
|
@@ -412,25 +410,25 @@ const TextRevealMotion = React.forwardRef<
|
|
|
412
410
|
const { interpolate } = await import("flubber");
|
|
413
411
|
if (signal.cancelled) return;
|
|
414
412
|
|
|
415
|
-
//
|
|
416
|
-
//
|
|
417
|
-
//
|
|
418
|
-
|
|
419
|
-
|
|
413
|
+
// Build one interpolator per transition up-front — constructing them is
|
|
414
|
+
// the expensive part (point matching), calling one per frame is cheap
|
|
415
|
+
// (tens of µs). Do NOT pre-sample into a frame table: the hold spring's
|
|
416
|
+
// slow settle tail makes discrete frames visible as a pop into the
|
|
417
|
+
// final shape at ~99% (same fix as loading.tsx).
|
|
418
|
+
const morphs: Array<(t: number) => string> = [];
|
|
420
419
|
for (let i = 0; i < shapes.length; i++) {
|
|
421
|
-
|
|
422
|
-
shapes[i]!,
|
|
423
|
-
shapes[(i + 1) % shapes.length]!
|
|
420
|
+
morphs.push(
|
|
421
|
+
interpolate(shapes[i]!, shapes[(i + 1) % shapes.length]!)
|
|
424
422
|
);
|
|
425
|
-
const frames: string[] = [];
|
|
426
|
-
for (let j = 0; j <= sampleCount; j++) {
|
|
427
|
-
frames.push(interp(j / sampleCount));
|
|
428
|
-
}
|
|
429
|
-
sampledFrames.push(frames);
|
|
430
423
|
}
|
|
431
424
|
|
|
432
425
|
// Create scheduler once — reuse across all phases and items
|
|
433
|
-
const schedule = createFrameScheduler(
|
|
426
|
+
const schedule = createFrameScheduler(
|
|
427
|
+
ball,
|
|
428
|
+
group,
|
|
429
|
+
path,
|
|
430
|
+
gradientElRef.current
|
|
431
|
+
);
|
|
434
432
|
|
|
435
433
|
group.style.opacity = "1";
|
|
436
434
|
let wordIndex = 0;
|
|
@@ -462,7 +460,7 @@ const TextRevealMotion = React.forwardRef<
|
|
|
462
460
|
}
|
|
463
461
|
|
|
464
462
|
// Phase 1: Roll right → reveal
|
|
465
|
-
const
|
|
463
|
+
const morph1 = morphs[shapeStep]!;
|
|
466
464
|
const rollDeg = 360;
|
|
467
465
|
const startRot1 = totalRotation;
|
|
468
466
|
|
|
@@ -485,17 +483,16 @@ const TextRevealMotion = React.forwardRef<
|
|
|
485
483
|
const t = clamp01((x - startX) / travel);
|
|
486
484
|
const clipRight =
|
|
487
485
|
wordW > 0 ? 100 - clamp01(x / wordW) * 100 : 100;
|
|
488
|
-
|
|
489
|
-
schedule(
|
|
490
|
-
x,
|
|
491
|
-
clipRight,
|
|
492
|
-
startRot1 + t * rollDeg,
|
|
493
|
-
morphFrames1[frameIdx]!
|
|
494
|
-
);
|
|
486
|
+
schedule(x, clipRight, startRot1 + t * rollDeg, morph1(t));
|
|
495
487
|
},
|
|
496
488
|
onComplete: () => {
|
|
497
489
|
totalRotation = startRot1 + rollDeg;
|
|
498
490
|
shapeStep = (shapeStep + 1) % shapes.length;
|
|
491
|
+
// Pin the exact end state — don't rely on the final onUpdate
|
|
492
|
+
// having fired with the snapped target value.
|
|
493
|
+
if (!signal.cancelled) {
|
|
494
|
+
schedule(endX, 0, totalRotation, morph1(1));
|
|
495
|
+
}
|
|
499
496
|
resolve();
|
|
500
497
|
},
|
|
501
498
|
});
|
|
@@ -522,26 +519,46 @@ const TextRevealMotion = React.forwardRef<
|
|
|
522
519
|
break;
|
|
523
520
|
|
|
524
521
|
const nextStep = (shapeStep + 1) % shapes.length;
|
|
525
|
-
const
|
|
522
|
+
const holdMorph = morphs[shapeStep]!;
|
|
526
523
|
const startRotH = totalRotation;
|
|
527
524
|
const targetRotH = totalRotation + 360;
|
|
528
525
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
526
|
+
// Aim past 1 and clamp the rendered progress so the spring's
|
|
527
|
+
// terminal snap lands off-screen (see SETTLE_REST_DELTA).
|
|
528
|
+
await new Promise<void>((resolve) => {
|
|
529
|
+
if (signal.cancelled) {
|
|
530
|
+
resolve();
|
|
531
|
+
return;
|
|
532
|
+
}
|
|
533
|
+
const controls = animate(0, 1 + SETTLE_REST_DELTA, {
|
|
534
|
+
type: "spring",
|
|
535
|
+
stiffness: 30,
|
|
536
|
+
damping: 9,
|
|
537
|
+
mass: 0.5,
|
|
538
|
+
restDelta: SETTLE_REST_DELTA,
|
|
539
|
+
onUpdate: (v: number) => {
|
|
540
|
+
if (signal.cancelled) {
|
|
541
|
+
controls.stop();
|
|
542
|
+
resolve();
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const t = clamp01(v);
|
|
546
|
+
schedule(
|
|
547
|
+
holdBallX,
|
|
548
|
+
0,
|
|
549
|
+
startRotH + t * (targetRotH - startRotH),
|
|
550
|
+
holdMorph(t)
|
|
551
|
+
);
|
|
552
|
+
},
|
|
553
|
+
onComplete: resolve,
|
|
554
|
+
});
|
|
543
555
|
});
|
|
544
556
|
|
|
557
|
+
// Pin the exact end state before the next hold iteration
|
|
558
|
+
if (!signal.cancelled) {
|
|
559
|
+
schedule(holdBallX, 0, targetRotH, holdMorph(1));
|
|
560
|
+
}
|
|
561
|
+
|
|
545
562
|
totalRotation = targetRotH;
|
|
546
563
|
shapeStep = nextStep;
|
|
547
564
|
}
|
|
@@ -549,7 +566,7 @@ const TextRevealMotion = React.forwardRef<
|
|
|
549
566
|
if (signal.cancelled) break;
|
|
550
567
|
|
|
551
568
|
// Phase 2: Roll back left → hide
|
|
552
|
-
const
|
|
569
|
+
const morph2 = morphs[shapeStep]!;
|
|
553
570
|
const startRot2 = totalRotation;
|
|
554
571
|
|
|
555
572
|
await new Promise<void>((resolve) => {
|
|
@@ -571,17 +588,15 @@ const TextRevealMotion = React.forwardRef<
|
|
|
571
588
|
const t = clamp01(1 - (x - startX) / travel);
|
|
572
589
|
const clipRight =
|
|
573
590
|
wordW > 0 ? 100 - clamp01(x / wordW) * 100 : 100;
|
|
574
|
-
|
|
575
|
-
schedule(
|
|
576
|
-
x,
|
|
577
|
-
clipRight,
|
|
578
|
-
startRot2 - t * rollDeg,
|
|
579
|
-
morphFrames2[frameIdx]!
|
|
580
|
-
);
|
|
591
|
+
schedule(x, clipRight, startRot2 - t * rollDeg, morph2(t));
|
|
581
592
|
},
|
|
582
593
|
onComplete: () => {
|
|
583
594
|
totalRotation = startRot2 - rollDeg;
|
|
584
595
|
shapeStep = (shapeStep + 1) % shapes.length;
|
|
596
|
+
// Pin the exact end state (ball parked left, item hidden)
|
|
597
|
+
if (!signal.cancelled) {
|
|
598
|
+
schedule(startX, 100, totalRotation, morph2(1));
|
|
599
|
+
}
|
|
585
600
|
resolve();
|
|
586
601
|
},
|
|
587
602
|
});
|
|
@@ -706,8 +721,19 @@ const TextRevealMotion = React.forwardRef<
|
|
|
706
721
|
xmlns="http://www.w3.org/2000/svg"
|
|
707
722
|
>
|
|
708
723
|
<defs>
|
|
709
|
-
|
|
710
|
-
|
|
724
|
+
{/* Static direction matches the base angle for the first
|
|
725
|
+
frame and the reduced-motion render. */}
|
|
726
|
+
<linearGradient
|
|
727
|
+
ref={gradientElRef}
|
|
728
|
+
id={gradientId}
|
|
729
|
+
x1="81.8%"
|
|
730
|
+
x2="18.2%"
|
|
731
|
+
y1="18.2%"
|
|
732
|
+
y2="81.8%"
|
|
733
|
+
>
|
|
734
|
+
{/* From-stop far outside the shape — the brightest visible
|
|
735
|
+
point is already blended toward the to-colour. */}
|
|
736
|
+
<stop offset="-60%" stopColor={gradientFrom} />
|
|
711
737
|
<stop offset="120%" stopColor={gradientTo} />
|
|
712
738
|
</linearGradient>
|
|
713
739
|
</defs>
|
|
@@ -70,14 +70,39 @@ function Tooltip({
|
|
|
70
70
|
return <TooltipPrimitive.Root {...props} />;
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
+
interface TooltipTriggerProps extends React.ComponentProps<
|
|
74
|
+
typeof TooltipPrimitive.Trigger
|
|
75
|
+
> {
|
|
76
|
+
/**
|
|
77
|
+
* Data hook for automated testing, rendered as the `data-hook` attribute
|
|
78
|
+
* (the platform test-selector contract).
|
|
79
|
+
*
|
|
80
|
+
* Optional because `TooltipTrigger` is commonly used with `asChild`, where the
|
|
81
|
+
* child element (e.g. a `Button`) already carries its own `dataHook`. When
|
|
82
|
+
* `asChild` is set, the child's `data-hook` wins over this one.
|
|
83
|
+
*/
|
|
84
|
+
dataHook?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Optional analytics element identifier
|
|
87
|
+
*/
|
|
88
|
+
trackingEl?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Optional analytics label context
|
|
91
|
+
*/
|
|
92
|
+
trackingLabel?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
73
95
|
const TooltipTrigger = React.forwardRef<
|
|
74
96
|
React.ElementRef<typeof TooltipPrimitive.Trigger>,
|
|
75
|
-
|
|
76
|
-
>(({ ...props }, ref) => {
|
|
97
|
+
TooltipTriggerProps
|
|
98
|
+
>(({ dataHook, trackingEl, trackingLabel, ...props }, ref) => {
|
|
77
99
|
return (
|
|
78
100
|
<TooltipPrimitive.Trigger
|
|
79
101
|
ref={ref}
|
|
102
|
+
data-hook={dataHook}
|
|
80
103
|
data-slot="tooltip-trigger"
|
|
104
|
+
data-tracking-el={trackingEl}
|
|
105
|
+
data-tracking-label={trackingLabel}
|
|
81
106
|
{...props}
|
|
82
107
|
/>
|
|
83
108
|
);
|
|
@@ -158,4 +183,4 @@ const TooltipContent = React.forwardRef<
|
|
|
158
183
|
TooltipContent.displayName = "TooltipContent";
|
|
159
184
|
|
|
160
185
|
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
161
|
-
export type { TooltipContentProps, TooltipProviderProps };
|
|
186
|
+
export type { TooltipContentProps, TooltipProviderProps, TooltipTriggerProps };
|