@olenbetong/synergi-react 2.5.7 → 2.6.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 (63) hide show
  1. package/es/colorScheme.d.ts +17 -0
  2. package/es/colorScheme.js +54 -0
  3. package/es/components/AppMenu/AppMenu.css +480 -92
  4. package/es/components/AppMenu/AppMenu.d.ts +47 -0
  5. package/es/components/AppMenu/AppMenu.js +224 -0
  6. package/es/components/AppMenu/AppMenuColorScheme.d.ts +2 -0
  7. package/es/components/AppMenu/AppMenuColorScheme.js +18 -0
  8. package/es/components/AppMenu/AppMenuToggle.d.ts +15 -0
  9. package/es/components/AppMenu/AppMenuToggle.js +14 -0
  10. package/es/components/AppMenu/AppMenuUserMenu.d.ts +32 -0
  11. package/es/components/AppMenu/AppMenuUserMenu.js +110 -0
  12. package/es/components/AppMenu/developerCategories.d.ts +24 -0
  13. package/es/components/AppMenu/developerCategories.js +116 -0
  14. package/es/components/AppMenu/index.d.ts +7 -12
  15. package/es/components/AppMenu/index.js +6 -85
  16. package/es/components/AppMenu/types.d.ts +33 -0
  17. package/es/components/AppMenu/types.js +1 -0
  18. package/es/components/AppMenu/useRovingTabIndex.d.ts +24 -0
  19. package/es/components/AppMenu/useRovingTabIndex.js +103 -0
  20. package/es/components/AppMenu/useServiceWorkerUpdate.d.ts +16 -0
  21. package/es/components/AppMenu/useServiceWorkerUpdate.js +62 -0
  22. package/es/components/AppShell/index.js +107 -13
  23. package/es/components/ImageEditor/ImageEditor.css +22 -11
  24. package/es/components/ImageEditor/ImageEditor.js +12 -12
  25. package/es/components/ImageEditor/ResponsiveButton.d.ts +1 -1
  26. package/es/components/ImageEditor/ResponsiveButton.js +5 -5
  27. package/es/components/ImageEditor/plugins/cropPlugin/CropOverlay.js +2 -2
  28. package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +3 -4
  29. package/es/components/ImageEditor/plugins/cropPlugin/index.js +2 -2
  30. package/es/components/ImageEditor/plugins/redactPlugin/RedactToolbar.js +3 -5
  31. package/es/components/ImageEditor/plugins/redactPlugin/index.js +2 -2
  32. package/es/components/ImageEditor/plugins/rotatePlugin.js +1 -2
  33. package/es/components/ImageEditor/plugins/zoomPlugin/ZoomControls.js +2 -4
  34. package/es/components/ImageEditor/useIsSmall.d.ts +5 -0
  35. package/es/components/ImageEditor/useIsSmall.js +21 -0
  36. package/es/index.d.ts +2 -1
  37. package/es/index.js +2 -1
  38. package/package.json +7 -3
  39. package/src/colorScheme.ts +81 -0
  40. package/src/components/AppMenu/AppMenu.css +480 -92
  41. package/src/components/AppMenu/AppMenu.tsx +478 -0
  42. package/src/components/AppMenu/AppMenuColorScheme.tsx +41 -0
  43. package/src/components/AppMenu/AppMenuToggle.tsx +51 -0
  44. package/src/components/AppMenu/AppMenuUserMenu.tsx +190 -0
  45. package/src/components/AppMenu/developerCategories.ts +142 -0
  46. package/src/components/AppMenu/index.ts +12 -0
  47. package/src/components/AppMenu/types.ts +35 -0
  48. package/src/components/AppMenu/useRovingTabIndex.ts +118 -0
  49. package/src/components/AppMenu/useServiceWorkerUpdate.ts +68 -0
  50. package/src/components/AppShell/index.tsx +140 -14
  51. package/src/components/ImageEditor/ImageEditor.css +22 -11
  52. package/src/components/ImageEditor/ImageEditor.tsx +38 -40
  53. package/src/components/ImageEditor/ResponsiveButton.tsx +8 -10
  54. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +6 -6
  55. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +6 -10
  56. package/src/components/ImageEditor/plugins/cropPlugin/index.ts +2 -2
  57. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +8 -17
  58. package/src/components/ImageEditor/plugins/redactPlugin/index.ts +2 -2
  59. package/src/components/ImageEditor/plugins/rotatePlugin.ts +1 -2
  60. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +4 -6
  61. package/src/components/ImageEditor/useIsSmall.ts +27 -0
  62. package/src/index.ts +25 -1
  63. package/src/components/AppMenu/index.tsx +0 -179
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Color scheme preference (system / light / dark).
3
+ *
4
+ * The preference lives in the `ob-color-scheme` cookie so the article template
5
+ * can read it server side and render `data-color-scheme` on `<html>` and
6
+ * `<body>` before the first paint. The site script for the 2026 template
7
+ * (`ob.2026.application.min.js`) owns the same cookie for the toolbar user menu
8
+ * toggle, so both write the cookie, apply the attributes, and dispatch
9
+ * `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
10
+ */
11
+ export type ColorSchemePreference = "auto" | "light" | "dark";
12
+ /** Dispatched on `window` whenever the preference changes. */
13
+ export declare const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
14
+ export declare function getColorSchemePreference(): ColorSchemePreference;
15
+ export declare function setColorSchemePreference(preference: ColorSchemePreference): void;
16
+ /** Reads the stored preference and keeps it in sync with other toggles on the page. */
17
+ export declare function useColorSchemePreference(): [ColorSchemePreference, (value: ColorSchemePreference) => void];
@@ -0,0 +1,54 @@
1
+ import { useCallback, useEffect, useState } from "react";
2
+ const COOKIE_NAME = "ob-color-scheme";
3
+ const COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
4
+ const DEFAULT_PREFERENCE = "auto";
5
+ const PREFERENCES = ["auto", "light", "dark"];
6
+ /** Dispatched on `window` whenever the preference changes. */
7
+ export const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
8
+ function isColorSchemePreference(value) {
9
+ return typeof value === "string" && PREFERENCES.includes(value);
10
+ }
11
+ export function getColorSchemePreference() {
12
+ if (typeof document === "undefined")
13
+ return DEFAULT_PREFERENCE;
14
+ let match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]*)`));
15
+ let value = match ? decodeURIComponent(match[1]) : null;
16
+ return isColorSchemePreference(value) ? value : DEFAULT_PREFERENCE;
17
+ }
18
+ export function setColorSchemePreference(preference) {
19
+ if (typeof document === "undefined" || !isColorSchemePreference(preference))
20
+ return;
21
+ let secure = window.location.protocol === "https:" ? ";secure" : "";
22
+ document.cookie = `${COOKIE_NAME}=${preference};path=/;max-age=${COOKIE_MAX_AGE};samesite=lax${secure}`;
23
+ /*
24
+ * Both elements are updated: `<html>` so the browser applies `color-scheme`
25
+ * to scrollbars and native controls, `<body>` because Designsystemet declares
26
+ * the light tokens on `:root` as well (`:root, [data-color-scheme="light"]`).
27
+ */
28
+ document.documentElement.dataset.colorScheme = preference;
29
+ if (document.body)
30
+ document.body.dataset.colorScheme = preference;
31
+ window.dispatchEvent(new CustomEvent(COLOR_SCHEME_CHANGE_EVENT, { detail: preference }));
32
+ }
33
+ /** Reads the stored preference and keeps it in sync with other toggles on the page. */
34
+ export function useColorSchemePreference() {
35
+ let [preference, setPreference] = useState(() => getColorSchemePreference());
36
+ useEffect(() => {
37
+ function update() {
38
+ setPreference(getColorSchemePreference());
39
+ }
40
+ update();
41
+ window.addEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
42
+ // Cookies fire no change event, so also pick up changes made in another tab.
43
+ document.addEventListener("visibilitychange", update);
44
+ return () => {
45
+ window.removeEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
46
+ document.removeEventListener("visibilitychange", update);
47
+ };
48
+ }, []);
49
+ let setValue = useCallback((value) => {
50
+ setColorSchemePreference(value);
51
+ setPreference(value);
52
+ }, []);
53
+ return [preference, setValue];
54
+ }