@olenbetong/synergi-react 4.2.4 → 4.2.6

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 (56) hide show
  1. package/package.json +5 -5
  2. package/src/chrome/AppShell/index.tsx +29 -29
  3. package/src/chrome/openReport.ts +34 -34
  4. package/src/colorScheme.ts +81 -81
  5. package/src/components/DateNavigator/index.tsx +186 -186
  6. package/src/components/FilePond.tsx +312 -312
  7. package/src/components/ImageEditor/ImageEditor.tsx +348 -348
  8. package/src/components/ImageEditor/index.ts +9 -9
  9. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  10. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
  11. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
  12. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  13. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  14. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  15. package/src/components/ImageEditor/useActiveTool.ts +21 -21
  16. package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
  17. package/src/components/ImageEditor/useImageHistory.ts +197 -197
  18. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  19. package/src/components/LinkedCardList/index.scss +95 -95
  20. package/src/components/MergeProgressDialog/index.tsx +249 -249
  21. package/src/components/PageBanner/index.tsx +80 -80
  22. package/src/components/PdfViewer/PdfViewer.tsx +158 -158
  23. package/src/components/ProgressBar/index.scss +96 -96
  24. package/src/components/SplitContainer/index.tsx +333 -333
  25. package/src/components/Toolbar/index.tsx +232 -232
  26. package/src/designsystemet-web-types.d.ts +24 -24
  27. package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
  28. package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
  29. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
  30. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
  31. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
  32. package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
  33. package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
  34. package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
  35. package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
  36. package/src/elements/ElementLookup.tsx +123 -123
  37. package/src/elements/ElementLookupDialog/BarcodeScanner/decoder.ts +32 -32
  38. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.ts +118 -118
  39. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/native.ts +103 -103
  40. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +95 -95
  41. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders.test.ts +118 -118
  42. package/src/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.ts +21 -21
  43. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +90 -90
  44. package/src/elements/ElementLookupDialog/BarcodeScanner/useScanner.ts +280 -280
  45. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  46. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  47. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  48. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  49. package/src/elements/ProjectSelect.tsx +130 -130
  50. package/src/elements/index.ts +15 -15
  51. package/src/filter/index.ts +34 -34
  52. package/src/i18n.ts +13 -13
  53. package/src/index.ts +77 -77
  54. package/src/mui/MuiThemeProvider.tsx +174 -174
  55. package/src/mui/index.ts +1 -1
  56. package/src/test/setup.ts +8 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/synergi-react",
3
- "version": "4.2.4",
3
+ "version": "4.2.6",
4
4
  "description": "Standalone React component for SynergiWeb and Partner Portal",
5
5
  "type": "module",
6
6
  "exports": {
@@ -40,10 +40,10 @@
40
40
  "@mui/icons-material": "9.4.0",
41
41
  "@mui/material": "9.4.0",
42
42
  "@olenbetong/appframe-core": "2.15.1",
43
- "@olenbetong/appframe-data": "1.8.0",
44
- "@olenbetong/appframe-ds": "1.3.5",
45
- "@olenbetong/appframe-mui": "7.0.7",
46
- "@olenbetong/appframe-react": "2.2.5",
43
+ "@olenbetong/appframe-data": "1.8.2",
44
+ "@olenbetong/appframe-ds": "1.3.7",
45
+ "@olenbetong/appframe-mui": "7.0.9",
46
+ "@olenbetong/appframe-react": "2.2.7",
47
47
  "clsx": "^2.1.1",
48
48
  "filepond": "^4.32.12",
49
49
  "filepond-plugin-file-poster": "^2.5.2",
@@ -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,81 +1,81 @@
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
- }
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
+ }