@brightlocal/ui-components 2.17.1 → 2.19.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 +83 -1
- package/component-meta.json +23 -7
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +23 -2
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +21 -19
- package/dist/blocks/input-list.cjs +2 -2
- package/dist/blocks/input-list.d.ts.map +1 -1
- package/dist/blocks/input-list.js +64 -63
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +2 -0
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +426 -403
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +22 -2
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +93 -72
- package/dist/chip.cjs +1 -1
- package/dist/chip.d.ts.map +1 -1
- package/dist/chip.js +1 -7
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +23 -3
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +44 -42
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts +10 -0
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +30 -29
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +5 -1
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +9 -7
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +44 -42
- package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
- package/dist/hooks/use-prefers-reduced-motion.d.ts +25 -2
- package/dist/hooks/use-prefers-reduced-motion.d.ts.map +1 -1
- package/dist/hooks/use-prefers-reduced-motion.js +17 -11
- package/dist/index.cjs +1 -1
- package/dist/index.js +38 -37
- package/dist/link.cjs +1 -1
- package/dist/link.d.ts +13 -2
- package/dist/link.d.ts.map +1 -1
- package/dist/link.js +110 -53
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +44 -37
- package/dist/map.cjs +1 -1
- package/dist/map.d.ts.map +1 -1
- package/dist/map.js +1 -1
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +26 -25
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +17 -2
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +29 -27
- package/dist/stepper.cjs +1 -1
- package/dist/stepper.d.ts +15 -13
- package/dist/stepper.d.ts.map +1 -1
- package/dist/stepper.js +84 -85
- package/package.json +3 -3
- package/src/blocks/input-list.tsx +8 -1
- package/src/blocks/sidebar.tsx +47 -7
- package/src/components/alert-dialog.tsx +38 -4
- package/src/components/card.tsx +56 -9
- package/src/components/chip.tsx +1 -4
- package/src/components/dialog.tsx +39 -6
- package/src/components/dropdown-menu.tsx +7 -1
- package/src/components/field.tsx +6 -0
- package/src/components/global-layout.tsx +3 -1
- package/src/components/link.tsx +103 -27
- package/src/components/logo.tsx +19 -25
- package/src/components/map.tsx +1 -2
- package/src/components/progress.tsx +12 -6
- package/src/components/sheet.tsx +30 -5
- package/src/components/stepper.tsx +93 -80
- package/src/hooks/use-prefers-reduced-motion.ts +35 -5
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useSyncExternalStore } from "react";
|
|
3
|
+
import { createContext, useContext, useSyncExternalStore } from "react";
|
|
4
4
|
|
|
5
5
|
const QUERY = "(prefers-reduced-motion: reduce)";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Optional override for the resolved reduced-motion value.
|
|
9
|
+
*
|
|
10
|
+
* - `null` (default): no override — {@link usePrefersReducedMotion} follows the
|
|
11
|
+
* OS/browser `prefers-reduced-motion` preference.
|
|
12
|
+
* - `true` / `false`: force the resolved value, ignoring the OS. Intended for
|
|
13
|
+
* tools that need to preview both states without changing OS settings (e.g.
|
|
14
|
+
* the Storybook "Reduce Motion" toolbar) — **not** for production app code.
|
|
15
|
+
*
|
|
16
|
+
* The override takes precedence so a component can never tell whether the value
|
|
17
|
+
* came from the OS or an override.
|
|
18
|
+
*/
|
|
19
|
+
export const ReducedMotionOverrideContext = createContext<boolean | null>(null);
|
|
20
|
+
|
|
7
21
|
function subscribe(callback: () => void) {
|
|
8
22
|
const mql = window.matchMedia(QUERY);
|
|
9
23
|
mql.addEventListener("change", callback);
|
|
@@ -19,10 +33,26 @@ function getServerSnapshot() {
|
|
|
19
33
|
}
|
|
20
34
|
|
|
21
35
|
/**
|
|
22
|
-
* Returns `true` when
|
|
23
|
-
*
|
|
36
|
+
* Returns `true` when reduced motion should be applied.
|
|
37
|
+
*
|
|
38
|
+
* Resolves from a layered source: an optional override (via
|
|
39
|
+
* {@link ReducedMotionOverrideContext}) wins; with no override it follows the
|
|
40
|
+
* OS/browser `prefers-reduced-motion` media query and updates in real time. The
|
|
41
|
+
* consuming component only ever sees the final boolean and cannot tell which
|
|
42
|
+
* layer produced it.
|
|
43
|
+
*
|
|
44
|
+
* Use it to gate any animation — framer-motion, CSS classes, or SVG. Note that
|
|
45
|
+
* raw CSS `@media (prefers-reduced-motion)` / Tailwind `motion-reduce:` bypass
|
|
46
|
+
* this hook (and any override) because they read the OS directly.
|
|
47
|
+
*
|
|
24
48
|
* SSR-safe: defaults to `false` on the server.
|
|
25
49
|
*/
|
|
26
|
-
export function usePrefersReducedMotion() {
|
|
27
|
-
|
|
50
|
+
export function usePrefersReducedMotion(): boolean {
|
|
51
|
+
const override = useContext(ReducedMotionOverrideContext);
|
|
52
|
+
const osPrefersReducedMotion = useSyncExternalStore(
|
|
53
|
+
subscribe,
|
|
54
|
+
getSnapshot,
|
|
55
|
+
getServerSnapshot
|
|
56
|
+
);
|
|
57
|
+
return override ?? osPrefersReducedMotion;
|
|
28
58
|
}
|