@brightlocal/ui-components 2.22.0 → 2.23.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 +19 -1
- package/dist/alert.cjs +1 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/alert.js +31 -31
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.js +2 -2
- 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/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +109 -121
- 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 +295 -293
- package/dist/loading.cjs +1 -0
- package/dist/loading.d.ts +46 -0
- package/dist/loading.d.ts.map +1 -0
- package/dist/loading.js +142 -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.map +1 -1
- package/dist/select.js +29 -35
- 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/package.json +1 -1
- package/src/blocks/data-table.tsx +2 -2
- package/src/components/alert.tsx +9 -13
- package/src/components/context-menu.tsx +8 -3
- package/src/components/dropdown-menu.tsx +6 -15
- package/src/components/loading.tsx +322 -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 +5 -8
- package/src/components/tooltip.tsx +28 -3
- package/src/index.ts +1 -0
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { useEffect, useId, useMemo, useRef } from "react";
|
|
5
|
+
import { animate } from "framer-motion";
|
|
6
|
+
|
|
7
|
+
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
|
+
import { usePrefersReducedMotion } from "../hooks/use-prefers-reduced-motion";
|
|
9
|
+
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
// Shape paths (500×500 viewBox)
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
|
|
14
|
+
const CIRCLE_PATH =
|
|
15
|
+
"M250 500C388.071 500 500 388.071 500 250C500 111.929 388.071 0 250 0C111.929 0 0 111.929 0 250C0 388.071 111.929 500 250 500Z";
|
|
16
|
+
|
|
17
|
+
const STAR_PATH =
|
|
18
|
+
"M492.425 259.355C332.265 293.145 293.145 332.265 259.355 492.425C257.225 502.525 242.775 502.525 240.645 492.425C206.855 332.265 167.735 293.145 7.575 259.355C-2.525 257.225 -2.525 242.775 7.575 240.645C167.735 206.855 206.855 167.735 240.645 7.575C242.775 -2.525 257.225 -2.525 259.355 7.575C293.145 167.735 332.265 206.855 492.425 240.645C502.525 242.775 502.525 257.225 492.425 259.355Z";
|
|
19
|
+
|
|
20
|
+
const STAR_BURST =
|
|
21
|
+
"M258.366 5.58795L296.379 97.3854C298.509 102.526 304.729 104.546 309.47 101.636L394.177 49.7215C401.057 45.5112 409.598 51.7117 407.708 59.5523L384.506 156.16C383.206 161.571 387.046 166.861 392.596 167.301L491.645 175.092C499.685 175.722 502.945 185.763 496.815 191.003L421.259 255.528C417.029 259.138 417.029 265.679 421.259 269.299L496.815 333.824C502.945 339.065 499.685 349.106 491.645 349.736L392.596 357.526C387.046 357.966 383.206 363.257 384.506 368.667L407.708 465.275C409.588 473.116 401.047 479.326 394.177 475.106L309.47 423.192C304.729 420.282 298.509 422.302 296.379 427.442L258.366 519.24C255.275 526.69 244.725 526.69 241.634 519.24L203.621 427.442C201.491 422.302 195.271 420.282 190.53 423.192L105.823 475.106C98.9428 479.316 90.4021 473.116 92.2922 465.275L115.494 368.667C116.794 363.257 112.954 357.966 107.403 357.526L8.35543 349.736C0.314784 349.106 -2.94548 339.065 3.18502 333.824L78.7411 269.299C82.9715 265.689 82.9715 259.148 78.7411 255.528L3.18502 191.003C-2.94548 185.763 0.314784 175.722 8.35543 175.092L107.403 167.301C112.954 166.861 116.794 161.571 115.494 156.16L92.2922 59.5523C90.4121 51.7117 98.9528 45.5012 105.823 49.7215L190.53 101.636C195.271 104.546 201.491 102.526 203.621 97.3854L241.634 5.58795C244.725 -1.86265 255.275 -1.86265 258.366 5.58795Z";
|
|
22
|
+
|
|
23
|
+
/** Clamp value to [0, 1] — avoids repeated Math.min/max in hot loops */
|
|
24
|
+
const clamp01 = (v: number) => (v < 0 ? 0 : v > 1 ? 1 : v);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Default 6-shape morph sequence: circle → star → burst → circle → burst → star.
|
|
28
|
+
* The repeated circle acts as a natural "blink" beat between orderings.
|
|
29
|
+
*/
|
|
30
|
+
const LOADING_SHAPES: string[] = [
|
|
31
|
+
CIRCLE_PATH,
|
|
32
|
+
STAR_PATH,
|
|
33
|
+
STAR_BURST,
|
|
34
|
+
CIRCLE_PATH,
|
|
35
|
+
STAR_BURST,
|
|
36
|
+
STAR_PATH,
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// Baked-in animation tuning
|
|
41
|
+
//
|
|
42
|
+
// These values are fixed, not consumer-configurable — the balance was tuned in
|
|
43
|
+
// the Lab playground (DS-770). Consumers get a single, opinionated loader.
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
/** Pause (ms) each shape holds before morphing to the next */
|
|
47
|
+
const HOLD_MS = 150;
|
|
48
|
+
/** Spring stiffness for the morph + rotation */
|
|
49
|
+
const STIFFNESS = 30;
|
|
50
|
+
/** Spring damping — higher = less oscillation */
|
|
51
|
+
const DAMPING = 9;
|
|
52
|
+
/** Spring mass — higher = more inertia */
|
|
53
|
+
const MASS = 0.5;
|
|
54
|
+
/** Degrees of rotation per morph cycle (clockwise) */
|
|
55
|
+
const ROTATION_DEG = 360;
|
|
56
|
+
/** Rendered size of the loader in pixels (width and height) */
|
|
57
|
+
const SIZE = 56;
|
|
58
|
+
/** Speed of the gradient angle drift */
|
|
59
|
+
const GRADIENT_WANDER_SPEED = 0.15;
|
|
60
|
+
/** How far the gradient endpoints swing from centre */
|
|
61
|
+
const GRADIENT_WANDER_RADIUS = 45;
|
|
62
|
+
|
|
63
|
+
/** Number of pre-sampled frames per flubber morph */
|
|
64
|
+
const MORPH_SAMPLES = 30;
|
|
65
|
+
/** Fewer samples on low-end devices to reduce pre-computation + memory */
|
|
66
|
+
const MORPH_SAMPLES_LOW = 15;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Detect low-performance devices via hardware concurrency.
|
|
70
|
+
* Falls back to false on SSR or when the API is unavailable.
|
|
71
|
+
*/
|
|
72
|
+
const isLowPerfDevice =
|
|
73
|
+
typeof navigator !== "undefined" &&
|
|
74
|
+
typeof navigator.hardwareConcurrency === "number" &&
|
|
75
|
+
navigator.hardwareConcurrency <= 4;
|
|
76
|
+
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
// Props
|
|
79
|
+
// ---------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Props for the Loading component.
|
|
83
|
+
* Extends native `svg` props for full attribute + layout-className support.
|
|
84
|
+
*/
|
|
85
|
+
export interface LoadingProps extends Omit<
|
|
86
|
+
React.ComponentPropsWithoutRef<"svg">,
|
|
87
|
+
"children"
|
|
88
|
+
> {
|
|
89
|
+
/**
|
|
90
|
+
* Required data-hook attribute for automated testing.
|
|
91
|
+
* @example "page-loading"
|
|
92
|
+
*/
|
|
93
|
+
dataHook: string;
|
|
94
|
+
/**
|
|
95
|
+
* Accessible label for the loading animation, announced by screen readers.
|
|
96
|
+
* @default "Loading"
|
|
97
|
+
*/
|
|
98
|
+
loadingLabel?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Tracking element identifier for analytics.
|
|
101
|
+
*/
|
|
102
|
+
trackingEl?: string;
|
|
103
|
+
/**
|
|
104
|
+
* Tracking label for analytics context.
|
|
105
|
+
*/
|
|
106
|
+
trackingLabel?: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// ---------------------------------------------------------------------------
|
|
110
|
+
// Component
|
|
111
|
+
// ---------------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Brand loading animation — a gradient shape that morphs between a circle, a
|
|
115
|
+
* star, and a starburst while gently rotating, with a slowly wandering gradient.
|
|
116
|
+
*
|
|
117
|
+
* The animation is fully self-contained and opinionated: size, timing, spring
|
|
118
|
+
* physics and colours are all baked in. The only accessibility hook is an
|
|
119
|
+
* optional `loadingLabel`. Colours come from the `--loading-gradient-from` /
|
|
120
|
+
* `--loading-gradient-to` design tokens.
|
|
121
|
+
*
|
|
122
|
+
* Respects `prefers-reduced-motion`: renders a static shape when reduced motion
|
|
123
|
+
* is requested.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```tsx
|
|
127
|
+
* <Loading dataHook="page-loading" />
|
|
128
|
+
* <Loading dataHook="page-loading" loadingLabel={t("common.loading")} />
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
const Loading = React.forwardRef<SVGSVGElement, LoadingProps>(
|
|
132
|
+
(
|
|
133
|
+
{ className, dataHook, loadingLabel, trackingEl, trackingLabel, ...props },
|
|
134
|
+
ref
|
|
135
|
+
) => {
|
|
136
|
+
const reducedMotion = usePrefersReducedMotion();
|
|
137
|
+
const rawId = useId();
|
|
138
|
+
const gradientId = useMemo(
|
|
139
|
+
() => `loading-gradient-${rawId.replace(/:/g, "")}`,
|
|
140
|
+
[rawId]
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const pathRef = useRef<SVGPathElement>(null);
|
|
144
|
+
const groupRef = useRef<SVGGElement>(null);
|
|
145
|
+
const gradientElRef = useRef<SVGLinearGradientElement>(null);
|
|
146
|
+
|
|
147
|
+
// -----------------------------------------------------------------------
|
|
148
|
+
// Slow wandering gradient direction
|
|
149
|
+
// -----------------------------------------------------------------------
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
if (reducedMotion) return;
|
|
152
|
+
const grad = gradientElRef.current;
|
|
153
|
+
if (!grad) return;
|
|
154
|
+
const gradEl: SVGLinearGradientElement = grad;
|
|
155
|
+
let raf: number;
|
|
156
|
+
let start: number | null = null;
|
|
157
|
+
const sA =
|
|
158
|
+
GRADIENT_WANDER_SPEED * 0.8 +
|
|
159
|
+
Math.random() * GRADIENT_WANDER_SPEED * 0.4;
|
|
160
|
+
const sB =
|
|
161
|
+
GRADIENT_WANDER_SPEED * 0.53 +
|
|
162
|
+
Math.random() * GRADIENT_WANDER_SPEED * 0.27;
|
|
163
|
+
const oA = Math.random() * Math.PI * 2;
|
|
164
|
+
const oB = Math.random() * Math.PI * 2;
|
|
165
|
+
let prevAngle = -Infinity;
|
|
166
|
+
function tick(now: number) {
|
|
167
|
+
if (start === null) start = now;
|
|
168
|
+
const t = (now - start) / 1000;
|
|
169
|
+
const angle =
|
|
170
|
+
Math.sin(t * sA + oA) * Math.PI + Math.sin(t * sB + oB) * 0.5;
|
|
171
|
+
if (Math.abs(angle - prevAngle) > 0.01) {
|
|
172
|
+
prevAngle = angle;
|
|
173
|
+
const cos = Math.cos(angle);
|
|
174
|
+
const sin = Math.sin(angle);
|
|
175
|
+
gradEl.setAttribute("x1", `${50 + GRADIENT_WANDER_RADIUS * cos}%`);
|
|
176
|
+
gradEl.setAttribute("y1", `${50 + GRADIENT_WANDER_RADIUS * sin}%`);
|
|
177
|
+
gradEl.setAttribute("x2", `${50 - GRADIENT_WANDER_RADIUS * cos}%`);
|
|
178
|
+
gradEl.setAttribute("y2", `${50 - GRADIENT_WANDER_RADIUS * sin}%`);
|
|
179
|
+
}
|
|
180
|
+
raf = requestAnimationFrame(tick);
|
|
181
|
+
}
|
|
182
|
+
raf = requestAnimationFrame(tick);
|
|
183
|
+
return () => cancelAnimationFrame(raf);
|
|
184
|
+
}, [reducedMotion]);
|
|
185
|
+
|
|
186
|
+
// -----------------------------------------------------------------------
|
|
187
|
+
// Morph + rotation loop with holds between shapes
|
|
188
|
+
// -----------------------------------------------------------------------
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
const path = pathRef.current;
|
|
191
|
+
const group = groupRef.current;
|
|
192
|
+
if (!path || !group) return;
|
|
193
|
+
|
|
194
|
+
if (reducedMotion) {
|
|
195
|
+
path.setAttribute("d", LOADING_SHAPES[0]!);
|
|
196
|
+
group.style.opacity = "1";
|
|
197
|
+
group.style.transform = "rotate(0deg)";
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const signal = { cancelled: false };
|
|
202
|
+
|
|
203
|
+
async function loop() {
|
|
204
|
+
// Lazy-load flubber so it doesn't block first paint
|
|
205
|
+
const { interpolate } = await import("flubber");
|
|
206
|
+
if (signal.cancelled) return;
|
|
207
|
+
|
|
208
|
+
// Pre-sample every morph transition into a lookup table so we don't
|
|
209
|
+
// regenerate flubber interpolators on every frame.
|
|
210
|
+
const sampleCount = isLowPerfDevice ? MORPH_SAMPLES_LOW : MORPH_SAMPLES;
|
|
211
|
+
const sampledFrames: string[][] = [];
|
|
212
|
+
for (let i = 0; i < LOADING_SHAPES.length; i++) {
|
|
213
|
+
const interp = interpolate(
|
|
214
|
+
LOADING_SHAPES[i]!,
|
|
215
|
+
LOADING_SHAPES[(i + 1) % LOADING_SHAPES.length]!
|
|
216
|
+
);
|
|
217
|
+
const frames: string[] = [];
|
|
218
|
+
for (let j = 0; j <= sampleCount; j++) {
|
|
219
|
+
frames.push(interp(j / sampleCount));
|
|
220
|
+
}
|
|
221
|
+
sampledFrames.push(frames);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
group!.style.opacity = "1";
|
|
225
|
+
let step = 0;
|
|
226
|
+
let rotation = 0;
|
|
227
|
+
|
|
228
|
+
while (!signal.cancelled) {
|
|
229
|
+
const morphFrames = sampledFrames[step % LOADING_SHAPES.length]!;
|
|
230
|
+
|
|
231
|
+
// Hold on the current shape
|
|
232
|
+
await new Promise<void>((r) => setTimeout(r, HOLD_MS));
|
|
233
|
+
if (signal.cancelled) break;
|
|
234
|
+
|
|
235
|
+
const startRotation = rotation;
|
|
236
|
+
const targetRotation = rotation + ROTATION_DEG;
|
|
237
|
+
|
|
238
|
+
// Wrap animate so an in-flight spring is stopped on cleanup — without
|
|
239
|
+
// this, onUpdate keeps writing to detached DOM nodes if the component
|
|
240
|
+
// unmounts mid-morph (mirrors text-reveal-motion.tsx).
|
|
241
|
+
await new Promise<void>((resolve) => {
|
|
242
|
+
if (signal.cancelled) {
|
|
243
|
+
resolve();
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const controls = animate(0, 1, {
|
|
247
|
+
type: "spring",
|
|
248
|
+
stiffness: STIFFNESS,
|
|
249
|
+
damping: DAMPING,
|
|
250
|
+
mass: MASS,
|
|
251
|
+
onUpdate: (v: number) => {
|
|
252
|
+
if (signal.cancelled) {
|
|
253
|
+
controls.stop();
|
|
254
|
+
resolve();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const t = clamp01(v);
|
|
258
|
+
const frameIdx = Math.round(t * sampleCount);
|
|
259
|
+
path!.setAttribute("d", morphFrames[frameIdx]!);
|
|
260
|
+
group!.style.transform = `rotate(${startRotation + t * (targetRotation - startRotation)}deg)`;
|
|
261
|
+
},
|
|
262
|
+
onComplete: () => resolve(),
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
rotation = targetRotation;
|
|
267
|
+
step = (step + 1) % LOADING_SHAPES.length;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
loop();
|
|
272
|
+
return () => {
|
|
273
|
+
signal.cancelled = true;
|
|
274
|
+
};
|
|
275
|
+
}, [reducedMotion]);
|
|
276
|
+
|
|
277
|
+
return (
|
|
278
|
+
<svg
|
|
279
|
+
ref={ref}
|
|
280
|
+
aria-label={loadingLabel ?? "Loading"}
|
|
281
|
+
className={cn("shrink-0", className)}
|
|
282
|
+
data-hook={dataHook}
|
|
283
|
+
data-slot="loading"
|
|
284
|
+
data-tracking-el={trackingEl}
|
|
285
|
+
data-tracking-label={trackingLabel}
|
|
286
|
+
fill="none"
|
|
287
|
+
height={SIZE}
|
|
288
|
+
role="img"
|
|
289
|
+
style={{ overflow: "visible" }}
|
|
290
|
+
viewBox="-30 -30 560 560"
|
|
291
|
+
width={SIZE}
|
|
292
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
293
|
+
{...props}
|
|
294
|
+
>
|
|
295
|
+
<defs>
|
|
296
|
+
<linearGradient ref={gradientElRef} id={gradientId}>
|
|
297
|
+
<stop offset="-20%" stopColor="var(--loading-gradient-from)" />
|
|
298
|
+
<stop offset="120%" stopColor="var(--loading-gradient-to)" />
|
|
299
|
+
</linearGradient>
|
|
300
|
+
</defs>
|
|
301
|
+
<g
|
|
302
|
+
ref={groupRef}
|
|
303
|
+
style={{
|
|
304
|
+
opacity: 0,
|
|
305
|
+
transformOrigin: "250px 250px",
|
|
306
|
+
willChange: "transform",
|
|
307
|
+
}}
|
|
308
|
+
>
|
|
309
|
+
<path
|
|
310
|
+
ref={pathRef}
|
|
311
|
+
d={LOADING_SHAPES[0]}
|
|
312
|
+
fill={`url(#${gradientId})`}
|
|
313
|
+
/>
|
|
314
|
+
</g>
|
|
315
|
+
</svg>
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
Loading.displayName = "Loading";
|
|
321
|
+
|
|
322
|
+
export { Loading };
|
package/src/components/map.tsx
CHANGED
|
@@ -141,7 +141,9 @@ const MAP_STYLES: Record<
|
|
|
141
141
|
// Shared dark mode store — one MutationObserver for all consumers
|
|
142
142
|
const _darkModeListeners = new Set<() => void>();
|
|
143
143
|
let _isDark =
|
|
144
|
-
typeof document !== "undefined" &&
|
|
144
|
+
typeof document !== "undefined" &&
|
|
145
|
+
!!document.body &&
|
|
146
|
+
document.body.classList.contains("dark");
|
|
145
147
|
let _darkModeObserverStarted = false;
|
|
146
148
|
|
|
147
149
|
function _initDarkModeObserver() {
|
|
@@ -3,7 +3,10 @@ import * as React from "react";
|
|
|
3
3
|
import * as MenubarPrimitive from "@radix-ui/react-menubar";
|
|
4
4
|
import { Check, ChevronRight, Circle } from "@brightlocal/icons";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
cn,
|
|
8
|
+
FLOATING_CONTENT_ANIMATION,
|
|
9
|
+
} from "@brightlocal/ui-components/lib/utils";
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* Menubar component - A horizontal menu bar with multiple dropdown menus
|
|
@@ -112,8 +115,7 @@ function MenubarContent({
|
|
|
112
115
|
alignOffset={alignOffset}
|
|
113
116
|
className={cn(
|
|
114
117
|
"border-border bg-popover text-popover-foreground z-50 min-w-[12rem] origin-(--radix-menubar-content-transform-origin) rounded-md border p-1 shadow-md",
|
|
115
|
-
|
|
116
|
-
"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",
|
|
118
|
+
FLOATING_CONTENT_ANIMATION,
|
|
117
119
|
className
|
|
118
120
|
)}
|
|
119
121
|
data-slot="menubar-content"
|
|
@@ -407,8 +409,7 @@ function MenubarSubContent({
|
|
|
407
409
|
<MenubarPrimitive.SubContent
|
|
408
410
|
className={cn(
|
|
409
411
|
"border-border bg-popover text-popover-foreground z-50 min-w-[8rem] origin-(--radix-menubar-content-transform-origin) rounded-md border p-1 shadow-lg",
|
|
410
|
-
|
|
411
|
-
"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",
|
|
412
|
+
FLOATING_CONTENT_ANIMATION,
|
|
412
413
|
className
|
|
413
414
|
)}
|
|
414
415
|
data-slot="menubar-sub-content"
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
cn,
|
|
8
|
+
FLOATING_CONTENT_ANIMATION,
|
|
9
|
+
} from "@brightlocal/ui-components/lib/utils";
|
|
7
10
|
import { useOverlayPointerLock } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
|
|
8
11
|
|
|
9
12
|
export interface PopoverProps extends React.ComponentProps<
|
|
@@ -93,7 +96,8 @@ const PopoverContent = React.forwardRef<
|
|
|
93
96
|
ref={ref}
|
|
94
97
|
align={align}
|
|
95
98
|
className={cn(
|
|
96
|
-
"bg-popover text-popover-foreground
|
|
99
|
+
"bg-popover text-popover-foreground z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",
|
|
100
|
+
FLOATING_CONTENT_ANIMATION,
|
|
97
101
|
className
|
|
98
102
|
)}
|
|
99
103
|
data-hook={dataHook}
|
|
@@ -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
|
|
|
@@ -237,13 +240,7 @@ function SelectContent({
|
|
|
237
240
|
"origin-[var(--radix-select-content-transform-origin)]",
|
|
238
241
|
|
|
239
242
|
// 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"
|
|
243
|
+
FLOATING_CONTENT_ANIMATION
|
|
247
244
|
);
|
|
248
245
|
|
|
249
246
|
const popperStyles =
|
|
@@ -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 };
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export * from "./components/input-otp";
|
|
|
35
35
|
export * from "./components/label";
|
|
36
36
|
export * from "./components/link";
|
|
37
37
|
export * from "./components/list";
|
|
38
|
+
export * from "./components/loading";
|
|
38
39
|
export * from "./components/logo";
|
|
39
40
|
export * from "./components/map";
|
|
40
41
|
export * from "./components/menubar";
|