@olenbetong/synergi-react 4.3.1 → 5.0.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 (81) hide show
  1. package/dist/styles/styles.css +1 -1
  2. package/dist/styles/styles.css.map +1 -1
  3. package/es/components/CodeEditor/CodeEditor.css +6 -6
  4. package/es/components/MergeProgressDialog/MergeProgressDialogDs.d.ts +7 -0
  5. package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +20 -0
  6. package/es/components/MergeProgressDialog/index.d.ts +3 -8
  7. package/es/components/MergeProgressDialog/index.js +4 -133
  8. package/es/components/MergeProgressDialog/useMergeJob.d.ts +36 -0
  9. package/es/components/MergeProgressDialog/useMergeJob.js +141 -0
  10. package/es/components/ProgressBar/index.css +1 -1
  11. package/es/components/Toolbar/Toolbar.css +137 -137
  12. package/es/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
  13. package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.d.ts +2 -2
  14. package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.js +1 -2
  15. package/es/elements/ElementLookupDialog/BarcodeScanner/Error.js +3 -29
  16. package/es/elements/ElementLookupDialog/BarcodeScanner/index.d.ts +1 -0
  17. package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +3 -28
  18. package/es/index.css +1 -1
  19. package/es/index.d.ts +2 -1
  20. package/es/index.js +2 -1
  21. package/es/mui/index.d.ts +1 -0
  22. package/es/mui/index.js +1 -0
  23. package/es/test/setup.d.ts +5 -0
  24. package/package.json +21 -14
  25. package/src/chrome/AppShell/index.tsx +29 -29
  26. package/src/chrome/openReport.ts +34 -34
  27. package/src/colorScheme.ts +125 -125
  28. package/src/components/CodeEditor/CodeEditor.css +6 -6
  29. package/src/components/CodeEditor/CodeEditor.tsx +173 -173
  30. package/src/components/CodeEditor/index.ts +1 -1
  31. package/src/components/DateNavigator/index.tsx +186 -186
  32. package/src/components/FilePond.tsx +312 -312
  33. package/src/components/ImageEditor/ImageEditor.tsx +348 -348
  34. package/src/components/ImageEditor/index.ts +9 -9
  35. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  36. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
  37. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
  38. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  39. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  40. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  41. package/src/components/ImageEditor/useActiveTool.ts +21 -21
  42. package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
  43. package/src/components/ImageEditor/useImageHistory.ts +197 -197
  44. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  45. package/src/components/LinkedCardList/index.scss +95 -95
  46. package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +91 -0
  47. package/src/components/MergeProgressDialog/index.tsx +5 -158
  48. package/src/components/MergeProgressDialog/useMergeJob.ts +169 -0
  49. package/src/components/PageBanner/index.tsx +80 -80
  50. package/src/components/PdfViewer/PdfViewer.tsx +158 -158
  51. package/src/components/ProgressBar/index.scss +23 -54
  52. package/src/components/SplitContainer/index.tsx +333 -333
  53. package/src/components/Toolbar/Toolbar.css +137 -137
  54. package/src/components/Toolbar/index.tsx +265 -265
  55. package/src/designsystemet-web-types.d.ts +24 -24
  56. package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
  57. package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
  58. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
  59. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
  60. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
  61. package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
  62. package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
  63. package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
  64. package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
  65. package/src/elements/ElementLookup.tsx +123 -123
  66. package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
  67. package/src/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.tsx +4 -4
  68. package/src/elements/ElementLookupDialog/BarcodeScanner/Error.tsx +7 -36
  69. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +20 -49
  70. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  71. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  72. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  73. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  74. package/src/elements/ProjectSelect.tsx +130 -130
  75. package/src/elements/index.ts +15 -15
  76. package/src/filter/index.ts +34 -34
  77. package/src/i18n.ts +13 -13
  78. package/src/index.ts +5 -1
  79. package/src/mui/MuiThemeProvider.tsx +135 -135
  80. package/src/mui/index.ts +1 -0
  81. package/src/test/setup.ts +23 -8
@@ -1,29 +1,29 @@
1
- import { AppErrorBoundary } from "@olenbetong/appframe-ds";
2
- import type { ReactNode } from "react";
3
-
4
- export type AppShellProps = {
5
- children: ReactNode;
6
- };
7
-
8
- /**
9
- * Standard Synergi app shell: the error boundary around the app.
10
- *
11
- * The site chrome (app menu, user menu, colour scheme, service worker update)
12
- * is no longer part of the app. It is rendered by the `@olenbetong/synergi-chrome`
13
- * bundle the `ob.2026.application` template loads, which marks the page with
14
- * `<html data-ob-chrome="1">`. Toolbar slots stay app owned through
15
- * `ToolbarPortal` and `ToolbarBreadcrumbs`.
16
- *
17
- * This component is Designsystemet-only. Apps that still render MUI components
18
- * should additionally wrap it in `MuiThemeProvider` from
19
- * `@olenbetong/synergi-react/mui`, which bridges the Designsystemet colour
20
- * tokens into a MUI theme.
21
- */
22
- export function AppShell({ children }: AppShellProps) {
23
- return <AppErrorBoundary>{children}</AppErrorBoundary>;
24
- }
25
-
26
- /** Whether the page's template loaded the site chrome (`<html data-ob-chrome="1">`). */
27
- export function hasSiteChrome() {
28
- return typeof document !== "undefined" && document.documentElement.dataset.obChrome !== undefined;
29
- }
1
+ import { AppErrorBoundary } from "@olenbetong/appframe-ds";
2
+ import type { ReactNode } from "react";
3
+
4
+ export type AppShellProps = {
5
+ children: ReactNode;
6
+ };
7
+
8
+ /**
9
+ * Standard Synergi app shell: the error boundary around the app.
10
+ *
11
+ * The site chrome (app menu, user menu, colour scheme, service worker update)
12
+ * is no longer part of the app. It is rendered by the `@olenbetong/synergi-chrome`
13
+ * bundle the `ob.2026.application` template loads, which marks the page with
14
+ * `<html data-ob-chrome="1">`. Toolbar slots stay app owned through
15
+ * `ToolbarPortal` and `ToolbarBreadcrumbs`.
16
+ *
17
+ * This component is Designsystemet-only. Apps that still render MUI components
18
+ * should additionally wrap it in `MuiThemeProvider` from
19
+ * `@olenbetong/synergi-react/mui`, which bridges the Designsystemet colour
20
+ * tokens into a MUI theme.
21
+ */
22
+ export function AppShell({ children }: AppShellProps) {
23
+ return <AppErrorBoundary>{children}</AppErrorBoundary>;
24
+ }
25
+
26
+ /** Whether the page's template loaded the site chrome (`<html data-ob-chrome="1">`). */
27
+ export function hasSiteChrome() {
28
+ return typeof document !== "undefined" && document.documentElement.dataset.obChrome !== undefined;
29
+ }
@@ -1,34 +1,34 @@
1
- export type OpenReportOptions = {
2
- /**
3
- * Overrides the filter the report was designed with, as a criteria string.
4
- * An empty string starts the launcher with no filter at all.
5
- */
6
- initialFilter?: string | null;
7
- /** The tab shown first. */
8
- defaultTab?: "parameters" | "filter";
9
- };
10
-
11
- type ChromeWithReports = {
12
- openReport?: (reportId: string, options?: OpenReportOptions) => void;
13
- };
14
-
15
- /**
16
- * Opens a report in the site chrome's report launcher, the way the app menu does.
17
- *
18
- * The launcher lives in the `@olenbetong/synergi-chrome` bundle the 2026 templates load,
19
- * so an app never bundles it; this only forwards to `window.ob.chrome.openReport`.
20
- * On a page without the chrome (a legacy template) the call is logged and ignored.
21
- *
22
- * @example
23
- * ```ts
24
- * openReport("arpt_Production_ElementsDaily", { initialFilter: `[ProjectID] = '${projectId}'` });
25
- * ```
26
- */
27
- export function openReport(reportId: string, options?: OpenReportOptions) {
28
- let chrome = (globalThis as { ob?: { chrome?: ChromeWithReports } }).ob?.chrome;
29
- if (chrome?.openReport) {
30
- chrome.openReport(reportId, options);
31
- } else {
32
- console.warn(`openReport(${reportId}): the site chrome is not on this page, so there is no report launcher.`);
33
- }
34
- }
1
+ export type OpenReportOptions = {
2
+ /**
3
+ * Overrides the filter the report was designed with, as a criteria string.
4
+ * An empty string starts the launcher with no filter at all.
5
+ */
6
+ initialFilter?: string | null;
7
+ /** The tab shown first. */
8
+ defaultTab?: "parameters" | "filter";
9
+ };
10
+
11
+ type ChromeWithReports = {
12
+ openReport?: (reportId: string, options?: OpenReportOptions) => void;
13
+ };
14
+
15
+ /**
16
+ * Opens a report in the site chrome's report launcher, the way the app menu does.
17
+ *
18
+ * The launcher lives in the `@olenbetong/synergi-chrome` bundle the 2026 templates load,
19
+ * so an app never bundles it; this only forwards to `window.ob.chrome.openReport`.
20
+ * On a page without the chrome (a legacy template) the call is logged and ignored.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * openReport("arpt_Production_ElementsDaily", { initialFilter: `[ProjectID] = '${projectId}'` });
25
+ * ```
26
+ */
27
+ export function openReport(reportId: string, options?: OpenReportOptions) {
28
+ let chrome = (globalThis as { ob?: { chrome?: ChromeWithReports } }).ob?.chrome;
29
+ if (chrome?.openReport) {
30
+ chrome.openReport(reportId, options);
31
+ } else {
32
+ console.warn(`openReport(${reportId}): the site chrome is not on this page, so there is no report launcher.`);
33
+ }
34
+ }
@@ -1,125 +1,125 @@
1
- import { useCallback, useEffect, useState } from "react";
2
-
3
- /**
4
- * Color scheme preference (system / light / dark).
5
- *
6
- * The preference lives in the `ob-color-scheme` cookie so the article template
7
- * can read it server side and render `data-color-scheme` on `<html>` and
8
- * `<body>` before the first paint. The site chrome bundle
9
- * (`@olenbetong/synergi-chrome`) owns the same cookie for the toolbar user menu
10
- * and app menu toggles, so all of them write the cookie, apply the attributes,
11
- * and dispatch `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
12
- */
13
-
14
- export type ColorSchemePreference = "auto" | "light" | "dark";
15
-
16
- const COOKIE_NAME = "ob-color-scheme";
17
- const COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
18
- const DEFAULT_PREFERENCE: ColorSchemePreference = "auto";
19
- const PREFERENCES: ColorSchemePreference[] = ["auto", "light", "dark"];
20
-
21
- /** Dispatched on `window` whenever the preference changes. */
22
- export const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
23
-
24
- function isColorSchemePreference(value: unknown): value is ColorSchemePreference {
25
- return typeof value === "string" && PREFERENCES.includes(value as ColorSchemePreference);
26
- }
27
-
28
- export function getColorSchemePreference(): ColorSchemePreference {
29
- if (typeof document === "undefined") return DEFAULT_PREFERENCE;
30
-
31
- let match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]*)`));
32
- let value = match ? decodeURIComponent(match[1]) : null;
33
-
34
- return isColorSchemePreference(value) ? value : DEFAULT_PREFERENCE;
35
- }
36
-
37
- export function setColorSchemePreference(preference: ColorSchemePreference) {
38
- if (typeof document === "undefined" || !isColorSchemePreference(preference)) return;
39
-
40
- let secure = window.location.protocol === "https:" ? ";secure" : "";
41
- document.cookie = `${COOKIE_NAME}=${preference};path=/;max-age=${COOKIE_MAX_AGE};samesite=lax${secure}`;
42
-
43
- /*
44
- * Both elements are updated: `<html>` so the browser applies `color-scheme`
45
- * to scrollbars and native controls, `<body>` because Designsystemet declares
46
- * the light tokens on `:root` as well (`:root, [data-color-scheme="light"]`).
47
- */
48
- document.documentElement.dataset.colorScheme = preference;
49
- if (document.body) document.body.dataset.colorScheme = preference;
50
-
51
- window.dispatchEvent(new CustomEvent(COLOR_SCHEME_CHANGE_EVENT, { detail: preference }));
52
- }
53
-
54
- /** Reads the stored preference and keeps it in sync with other toggles on the page. */
55
- export function useColorSchemePreference(): [ColorSchemePreference, (value: ColorSchemePreference) => void] {
56
- let [preference, setPreference] = useState<ColorSchemePreference>(() => getColorSchemePreference());
57
-
58
- useEffect(() => {
59
- function update() {
60
- setPreference(getColorSchemePreference());
61
- }
62
-
63
- update();
64
-
65
- window.addEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
66
- // Cookies fire no change event, so also pick up changes made in another tab.
67
- document.addEventListener("visibilitychange", update);
68
-
69
- return () => {
70
- window.removeEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
71
- document.removeEventListener("visibilitychange", update);
72
- };
73
- }, []);
74
-
75
- let setValue = useCallback((value: ColorSchemePreference) => {
76
- setColorSchemePreference(value);
77
- setPreference(value);
78
- }, []);
79
-
80
- return [preference, setValue];
81
- }
82
-
83
- /** The scheme Designsystemet is rendering with right now: the preference, with `auto` resolved. */
84
- export function getResolvedColorScheme(): "light" | "dark" {
85
- if (typeof document === "undefined") return "light";
86
-
87
- let scheme = document.body?.dataset.colorScheme ?? document.documentElement?.dataset.colorScheme ?? "light";
88
-
89
- if (scheme === "auto") {
90
- return globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
91
- }
92
-
93
- return scheme === "dark" ? "dark" : "light";
94
- }
95
-
96
- /**
97
- * Tracks the color scheme Designsystemet is rendering with. The article template
98
- * sets `data-color-scheme` on `<body>`, so watch that attribute as well as the
99
- * OS preference (used when the scheme is `auto`).
100
- */
101
- export function useResolvedColorScheme(): "light" | "dark" {
102
- let [scheme, setScheme] = useState<"light" | "dark">(() => getResolvedColorScheme());
103
-
104
- useEffect(() => {
105
- function update() {
106
- setScheme(getResolvedColorScheme());
107
- }
108
-
109
- update();
110
-
111
- let observer = new MutationObserver(update);
112
- observer.observe(document.body, { attributes: true, attributeFilter: ["data-color-scheme"] });
113
- observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-color-scheme"] });
114
-
115
- let media = globalThis.matchMedia?.("(prefers-color-scheme: dark)");
116
- media?.addEventListener("change", update);
117
-
118
- return () => {
119
- observer.disconnect();
120
- media?.removeEventListener("change", update);
121
- };
122
- }, []);
123
-
124
- return scheme;
125
- }
1
+ import { useCallback, useEffect, useState } from "react";
2
+
3
+ /**
4
+ * Color scheme preference (system / light / dark).
5
+ *
6
+ * The preference lives in the `ob-color-scheme` cookie so the article template
7
+ * can read it server side and render `data-color-scheme` on `<html>` and
8
+ * `<body>` before the first paint. The site chrome bundle
9
+ * (`@olenbetong/synergi-chrome`) owns the same cookie for the toolbar user menu
10
+ * and app menu toggles, so all of them write the cookie, apply the attributes,
11
+ * and dispatch `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
12
+ */
13
+
14
+ export type ColorSchemePreference = "auto" | "light" | "dark";
15
+
16
+ const COOKIE_NAME = "ob-color-scheme";
17
+ const COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
18
+ const DEFAULT_PREFERENCE: ColorSchemePreference = "auto";
19
+ const PREFERENCES: ColorSchemePreference[] = ["auto", "light", "dark"];
20
+
21
+ /** Dispatched on `window` whenever the preference changes. */
22
+ export const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
23
+
24
+ function isColorSchemePreference(value: unknown): value is ColorSchemePreference {
25
+ return typeof value === "string" && PREFERENCES.includes(value as ColorSchemePreference);
26
+ }
27
+
28
+ export function getColorSchemePreference(): ColorSchemePreference {
29
+ if (typeof document === "undefined") return DEFAULT_PREFERENCE;
30
+
31
+ let match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]*)`));
32
+ let value = match ? decodeURIComponent(match[1]) : null;
33
+
34
+ return isColorSchemePreference(value) ? value : DEFAULT_PREFERENCE;
35
+ }
36
+
37
+ export function setColorSchemePreference(preference: ColorSchemePreference) {
38
+ if (typeof document === "undefined" || !isColorSchemePreference(preference)) return;
39
+
40
+ let secure = window.location.protocol === "https:" ? ";secure" : "";
41
+ document.cookie = `${COOKIE_NAME}=${preference};path=/;max-age=${COOKIE_MAX_AGE};samesite=lax${secure}`;
42
+
43
+ /*
44
+ * Both elements are updated: `<html>` so the browser applies `color-scheme`
45
+ * to scrollbars and native controls, `<body>` because Designsystemet declares
46
+ * the light tokens on `:root` as well (`:root, [data-color-scheme="light"]`).
47
+ */
48
+ document.documentElement.dataset.colorScheme = preference;
49
+ if (document.body) document.body.dataset.colorScheme = preference;
50
+
51
+ window.dispatchEvent(new CustomEvent(COLOR_SCHEME_CHANGE_EVENT, { detail: preference }));
52
+ }
53
+
54
+ /** Reads the stored preference and keeps it in sync with other toggles on the page. */
55
+ export function useColorSchemePreference(): [ColorSchemePreference, (value: ColorSchemePreference) => void] {
56
+ let [preference, setPreference] = useState<ColorSchemePreference>(() => getColorSchemePreference());
57
+
58
+ useEffect(() => {
59
+ function update() {
60
+ setPreference(getColorSchemePreference());
61
+ }
62
+
63
+ update();
64
+
65
+ window.addEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
66
+ // Cookies fire no change event, so also pick up changes made in another tab.
67
+ document.addEventListener("visibilitychange", update);
68
+
69
+ return () => {
70
+ window.removeEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
71
+ document.removeEventListener("visibilitychange", update);
72
+ };
73
+ }, []);
74
+
75
+ let setValue = useCallback((value: ColorSchemePreference) => {
76
+ setColorSchemePreference(value);
77
+ setPreference(value);
78
+ }, []);
79
+
80
+ return [preference, setValue];
81
+ }
82
+
83
+ /** The scheme Designsystemet is rendering with right now: the preference, with `auto` resolved. */
84
+ export function getResolvedColorScheme(): "light" | "dark" {
85
+ if (typeof document === "undefined") return "light";
86
+
87
+ let scheme = document.body?.dataset.colorScheme ?? document.documentElement?.dataset.colorScheme ?? "light";
88
+
89
+ if (scheme === "auto") {
90
+ return globalThis.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light";
91
+ }
92
+
93
+ return scheme === "dark" ? "dark" : "light";
94
+ }
95
+
96
+ /**
97
+ * Tracks the color scheme Designsystemet is rendering with. The article template
98
+ * sets `data-color-scheme` on `<body>`, so watch that attribute as well as the
99
+ * OS preference (used when the scheme is `auto`).
100
+ */
101
+ export function useResolvedColorScheme(): "light" | "dark" {
102
+ let [scheme, setScheme] = useState<"light" | "dark">(() => getResolvedColorScheme());
103
+
104
+ useEffect(() => {
105
+ function update() {
106
+ setScheme(getResolvedColorScheme());
107
+ }
108
+
109
+ update();
110
+
111
+ let observer = new MutationObserver(update);
112
+ observer.observe(document.body, { attributes: true, attributeFilter: ["data-color-scheme"] });
113
+ observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-color-scheme"] });
114
+
115
+ let media = globalThis.matchMedia?.("(prefers-color-scheme: dark)");
116
+ media?.addEventListener("change", update);
117
+
118
+ return () => {
119
+ observer.disconnect();
120
+ media?.removeEventListener("change", update);
121
+ };
122
+ }, []);
123
+
124
+ return scheme;
125
+ }
@@ -1,6 +1,6 @@
1
- .ObCodeEditor-root {
2
- min-height: 10rem;
3
- border: 1px solid var(--ds-color-neutral-border-subtle);
4
- border-radius: var(--ds-border-radius-md);
5
- overflow: hidden;
6
- }
1
+ .ObCodeEditor-root {
2
+ min-height: 10rem;
3
+ border: 1px solid var(--ds-color-neutral-border-subtle);
4
+ border-radius: var(--ds-border-radius-md);
5
+ overflow: hidden;
6
+ }