@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.
Files changed (79) hide show
  1. package/README.md +83 -1
  2. package/component-meta.json +23 -7
  3. package/dist/alert-dialog.cjs +1 -1
  4. package/dist/alert-dialog.d.ts +23 -2
  5. package/dist/alert-dialog.d.ts.map +1 -1
  6. package/dist/alert-dialog.js +21 -19
  7. package/dist/blocks/input-list.cjs +2 -2
  8. package/dist/blocks/input-list.d.ts.map +1 -1
  9. package/dist/blocks/input-list.js +64 -63
  10. package/dist/blocks/sidebar.cjs +1 -1
  11. package/dist/blocks/sidebar.d.ts +2 -0
  12. package/dist/blocks/sidebar.d.ts.map +1 -1
  13. package/dist/blocks/sidebar.js +426 -403
  14. package/dist/card.cjs +1 -1
  15. package/dist/card.d.ts +22 -2
  16. package/dist/card.d.ts.map +1 -1
  17. package/dist/card.js +93 -72
  18. package/dist/chip.cjs +1 -1
  19. package/dist/chip.d.ts.map +1 -1
  20. package/dist/chip.js +1 -7
  21. package/dist/dialog.cjs +1 -1
  22. package/dist/dialog.d.ts +23 -3
  23. package/dist/dialog.d.ts.map +1 -1
  24. package/dist/dialog.js +44 -42
  25. package/dist/dropdown-menu.cjs +1 -1
  26. package/dist/dropdown-menu.d.ts +10 -0
  27. package/dist/dropdown-menu.d.ts.map +1 -1
  28. package/dist/dropdown-menu.js +30 -29
  29. package/dist/field.cjs +1 -1
  30. package/dist/field.d.ts +5 -1
  31. package/dist/field.d.ts.map +1 -1
  32. package/dist/field.js +9 -7
  33. package/dist/global-layout.cjs +1 -1
  34. package/dist/global-layout.d.ts.map +1 -1
  35. package/dist/global-layout.js +44 -42
  36. package/dist/hooks/use-prefers-reduced-motion.cjs +1 -1
  37. package/dist/hooks/use-prefers-reduced-motion.d.ts +25 -2
  38. package/dist/hooks/use-prefers-reduced-motion.d.ts.map +1 -1
  39. package/dist/hooks/use-prefers-reduced-motion.js +17 -11
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.js +38 -37
  42. package/dist/link.cjs +1 -1
  43. package/dist/link.d.ts +13 -2
  44. package/dist/link.d.ts.map +1 -1
  45. package/dist/link.js +110 -53
  46. package/dist/logo.cjs +1 -1
  47. package/dist/logo.d.ts.map +1 -1
  48. package/dist/logo.js +44 -37
  49. package/dist/map.cjs +1 -1
  50. package/dist/map.d.ts.map +1 -1
  51. package/dist/map.js +1 -1
  52. package/dist/progress.cjs +1 -1
  53. package/dist/progress.d.ts.map +1 -1
  54. package/dist/progress.js +26 -25
  55. package/dist/sheet.cjs +1 -1
  56. package/dist/sheet.d.ts +17 -2
  57. package/dist/sheet.d.ts.map +1 -1
  58. package/dist/sheet.js +29 -27
  59. package/dist/stepper.cjs +1 -1
  60. package/dist/stepper.d.ts +15 -13
  61. package/dist/stepper.d.ts.map +1 -1
  62. package/dist/stepper.js +84 -85
  63. package/package.json +3 -3
  64. package/src/blocks/input-list.tsx +8 -1
  65. package/src/blocks/sidebar.tsx +47 -7
  66. package/src/components/alert-dialog.tsx +38 -4
  67. package/src/components/card.tsx +56 -9
  68. package/src/components/chip.tsx +1 -4
  69. package/src/components/dialog.tsx +39 -6
  70. package/src/components/dropdown-menu.tsx +7 -1
  71. package/src/components/field.tsx +6 -0
  72. package/src/components/global-layout.tsx +3 -1
  73. package/src/components/link.tsx +103 -27
  74. package/src/components/logo.tsx +19 -25
  75. package/src/components/map.tsx +1 -2
  76. package/src/components/progress.tsx +12 -6
  77. package/src/components/sheet.tsx +30 -5
  78. package/src/components/stepper.tsx +93 -80
  79. 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 the user prefers reduced motion.
23
- * Listens to OS/browser preference changes in real time.
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
- return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
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
  }