@olenbetong/synergi-react 3.2.2 → 4.1.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/es/chrome/AppShell/index.d.ts +10 -2
- package/es/chrome/AppShell/index.js +13 -97
- package/es/chrome/openReport.d.ts +22 -0
- package/es/chrome/openReport.js +21 -0
- package/es/colorScheme.d.ts +4 -4
- package/es/components/DateNavigator/index.js +1 -1
- package/es/components/FilePond.js +1 -1
- package/es/components/ImageEditor/ImageEditor.js +1 -1
- package/es/components/ImageEditor/plugins/cropPlugin/CropOverlay.js +1 -1
- package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +1 -1
- package/es/components/ImageEditor/plugins/redactPlugin/RedactToolbar.js +1 -1
- package/es/components/ImageEditor/plugins/zoomPlugin/ZoomControls.js +1 -1
- package/es/components/MergeProgressDialog/index.js +1 -1
- package/es/components/Toolbar/index.d.ts +20 -11
- package/es/components/Toolbar/index.js +47 -6
- package/es/elements/ElementDamage/DamageFormButtons.js +1 -1
- package/es/elements/ElementDamage/DescriptionInput.js +1 -1
- package/es/elements/ElementDamage/DuplicateDamage/DesktopView.js +1 -1
- package/es/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.js +1 -1
- package/es/elements/ElementDamage/DuplicateDamage/PhoneView.js +1 -1
- package/es/elements/ElementDamage/ElementNumberTextField.js +1 -1
- package/es/elements/ElementDamage/RegisterFix.js +1 -1
- package/es/elements/ElementDamage/SubmitButtons.js +1 -1
- package/es/elements/ElementDamage/TransportElementSelect.js +1 -1
- package/es/elements/ElementLookup.d.ts +7 -2
- package/es/elements/ElementLookup.js +5 -7
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoder.d.ts +32 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.d.ts +28 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.js +81 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.d.ts +26 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.js +70 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.d.ts +20 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.js +69 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.js +103 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.d.ts +6 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.js +19 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/index.d.ts +14 -7
- package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +11 -7
- package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.d.ts +14 -12
- package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.js +223 -117
- package/es/elements/ElementLookupDialog/HIDScanner/index.js +1 -1
- package/es/elements/ElementLookupDialog/Manual/ManualForm.js +1 -1
- package/es/elements/ElementLookupDialog/index.d.ts +6 -0
- package/es/elements/ElementLookupDialog/index.js +3 -3
- package/es/elements/ElementLookupDialog/utils/Giai.js +1 -1
- package/es/elements/ProjectSelect.js +1 -1
- package/es/i18n.d.ts +6 -0
- package/es/i18n.js +10 -0
- package/es/index.d.ts +3 -4
- package/es/index.js +5 -4
- package/package.json +9 -8
- package/src/chrome/AppShell/index.tsx +13 -134
- package/src/chrome/openReport.ts +34 -0
- package/src/colorScheme.ts +4 -4
- package/src/components/DateNavigator/index.tsx +1 -1
- package/src/components/FilePond.tsx +1 -1
- package/src/components/ImageEditor/ImageEditor.tsx +1 -1
- package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +1 -1
- package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +1 -1
- package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +1 -1
- package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +1 -1
- package/src/components/MergeProgressDialog/index.tsx +1 -1
- package/src/components/Toolbar/index.tsx +65 -14
- package/src/elements/ElementDamage/DamageFormButtons.tsx +1 -1
- package/src/elements/ElementDamage/DescriptionInput.tsx +1 -1
- package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +1 -1
- package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +1 -1
- package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +1 -1
- package/src/elements/ElementDamage/ElementNumberTextField.tsx +1 -1
- package/src/elements/ElementDamage/RegisterFix.tsx +1 -1
- package/src/elements/ElementDamage/SubmitButtons.tsx +1 -1
- package/src/elements/ElementDamage/TransportElementSelect.tsx +1 -1
- package/src/elements/ElementLookup.tsx +13 -6
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoder.ts +32 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.ts +118 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/native.ts +103 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +95 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders.test.ts +118 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.ts +21 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +30 -15
- package/src/elements/ElementLookupDialog/BarcodeScanner/useScanner.ts +247 -137
- package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +1 -1
- package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +1 -1
- package/src/elements/ElementLookupDialog/index.tsx +13 -5
- package/src/elements/ElementLookupDialog/utils/Giai.ts +1 -1
- package/src/elements/ProjectSelect.tsx +1 -1
- package/src/i18n.ts +13 -0
- package/src/index.ts +6 -37
- package/es/chrome/AppMenu/AppMenu.css +0 -648
- package/es/chrome/AppMenu/AppMenu.d.ts +0 -56
- package/es/chrome/AppMenu/AppMenu.js +0 -145
- package/es/chrome/AppMenu/AppMenuColorScheme.d.ts +0 -2
- package/es/chrome/AppMenu/AppMenuColorScheme.js +0 -18
- package/es/chrome/AppMenu/AppMenuFavoriteButton.d.ts +0 -18
- package/es/chrome/AppMenu/AppMenuFavoriteButton.js +0 -11
- package/es/chrome/AppMenu/AppMenuHeader.d.ts +0 -24
- package/es/chrome/AppMenu/AppMenuHeader.js +0 -18
- package/es/chrome/AppMenu/AppMenuList.d.ts +0 -18
- package/es/chrome/AppMenu/AppMenuList.js +0 -39
- package/es/chrome/AppMenu/AppMenuRail.d.ts +0 -26
- package/es/chrome/AppMenu/AppMenuRail.js +0 -30
- package/es/chrome/AppMenu/AppMenuToggle.d.ts +0 -15
- package/es/chrome/AppMenu/AppMenuToggle.js +0 -14
- package/es/chrome/AppMenu/AppMenuUserMenu.d.ts +0 -32
- package/es/chrome/AppMenu/AppMenuUserMenu.js +0 -110
- package/es/chrome/AppMenu/developerCategories.d.ts +0 -24
- package/es/chrome/AppMenu/developerCategories.js +0 -116
- package/es/chrome/AppMenu/icons.d.ts +0 -15
- package/es/chrome/AppMenu/icons.js +0 -13
- package/es/chrome/AppMenu/index.d.ts +0 -12
- package/es/chrome/AppMenu/index.js +0 -10
- package/es/chrome/AppMenu/menuEntries.d.ts +0 -51
- package/es/chrome/AppMenu/menuEntries.js +0 -93
- package/es/chrome/AppMenu/types.d.ts +0 -43
- package/es/chrome/AppMenu/useFavorites.d.ts +0 -13
- package/es/chrome/AppMenu/useFavorites.js +0 -28
- package/es/chrome/AppMenu/useRovingTabIndex.d.ts +0 -28
- package/es/chrome/AppMenu/useRovingTabIndex.js +0 -114
- package/es/chrome/AppMenu/useServiceWorkerUpdate.d.ts +0 -16
- package/es/chrome/AppMenu/useServiceWorkerUpdate.js +0 -62
- package/es/report/ReportLauncher.css +0 -147
- package/es/report/ReportLauncher.d.ts +0 -55
- package/es/report/ReportLauncher.js +0 -142
- package/es/report/ReportLauncher.test.js +0 -231
- package/es/report/ReportParameters.css +0 -29
- package/es/report/ReportParameters.d.ts +0 -46
- package/es/report/ReportParameters.js +0 -65
- package/es/report/ReportParameters.test.d.ts +0 -1
- package/es/report/ReportParameters.test.js +0 -84
- package/es/report/index.d.ts +0 -2
- package/es/report/index.js +0 -2
- package/src/chrome/AppMenu/AppMenu.css +0 -648
- package/src/chrome/AppMenu/AppMenu.tsx +0 -285
- package/src/chrome/AppMenu/AppMenuColorScheme.tsx +0 -41
- package/src/chrome/AppMenu/AppMenuFavoriteButton.tsx +0 -47
- package/src/chrome/AppMenu/AppMenuHeader.tsx +0 -79
- package/src/chrome/AppMenu/AppMenuList.tsx +0 -89
- package/src/chrome/AppMenu/AppMenuRail.tsx +0 -117
- package/src/chrome/AppMenu/AppMenuToggle.tsx +0 -51
- package/src/chrome/AppMenu/AppMenuUserMenu.tsx +0 -190
- package/src/chrome/AppMenu/developerCategories.ts +0 -142
- package/src/chrome/AppMenu/icons.tsx +0 -76
- package/src/chrome/AppMenu/index.ts +0 -17
- package/src/chrome/AppMenu/menuEntries.ts +0 -128
- package/src/chrome/AppMenu/types.ts +0 -45
- package/src/chrome/AppMenu/useFavorites.ts +0 -40
- package/src/chrome/AppMenu/useRovingTabIndex.ts +0 -130
- package/src/chrome/AppMenu/useServiceWorkerUpdate.ts +0 -68
- package/src/report/ReportLauncher.css +0 -147
- package/src/report/ReportLauncher.test.tsx +0 -281
- package/src/report/ReportLauncher.tsx +0 -420
- package/src/report/ReportParameters.css +0 -29
- package/src/report/ReportParameters.test.tsx +0 -133
- package/src/report/ReportParameters.tsx +0 -198
- package/src/report/index.ts +0 -2
- /package/es/{chrome/AppMenu/types.js → elements/ElementLookupDialog/BarcodeScanner/decoder.js} +0 -0
- /package/es/{report/ReportLauncher.test.d.ts → elements/ElementLookupDialog/BarcodeScanner/decoders.test.d.ts} +0 -0
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
2
|
export type AppShellProps = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
6
|
-
* Standard Synergi app
|
|
6
|
+
* Standard Synergi app shell: the error boundary around the app.
|
|
7
|
+
*
|
|
8
|
+
* The site chrome (app menu, user menu, colour scheme, service worker update)
|
|
9
|
+
* is no longer part of the app. It is rendered by the `@olenbetong/synergi-chrome`
|
|
10
|
+
* bundle the `ob.2026.application` template loads, which marks the page with
|
|
11
|
+
* `<html data-ob-chrome="1">`. Toolbar slots stay app owned through
|
|
12
|
+
* `ToolbarPortal` and `ToolbarBreadcrumbs`.
|
|
7
13
|
*
|
|
8
14
|
* This component is Designsystemet-only. Apps that still render MUI components
|
|
9
15
|
* should additionally wrap it in `MuiThemeProvider` from
|
|
@@ -11,3 +17,5 @@ export type AppShellProps = {
|
|
|
11
17
|
* tokens into a MUI theme.
|
|
12
18
|
*/
|
|
13
19
|
export declare function AppShell({ children }: AppShellProps): import("react").JSX.Element;
|
|
20
|
+
/** Whether the page's template loaded the site chrome (`<html data-ob-chrome="1">`). */
|
|
21
|
+
export declare function hasSiteChrome(): boolean;
|
|
@@ -1,85 +1,13 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
2
|
import { AppErrorBoundary } from "@olenbetong/appframe-ds";
|
|
4
|
-
import { useCallback, useMemo, useState } from "react";
|
|
5
|
-
import { createPortal } from "react-dom";
|
|
6
|
-
import { AppMenu } from "../AppMenu/AppMenu.js";
|
|
7
|
-
import { AppMenuToggle } from "../AppMenu/AppMenuToggle.js";
|
|
8
|
-
import { createDeveloperCategories } from "../AppMenu/developerCategories.js";
|
|
9
|
-
import { useServiceWorkerUpdate } from "../AppMenu/useServiceWorkerUpdate.js";
|
|
10
|
-
const hostName = globalThis.af?.article?.hostName ?? globalThis.location?.hostname ?? "";
|
|
11
|
-
/*
|
|
12
|
-
* `aviw_WebShared_Articles` stores every published version of an article as its
|
|
13
|
-
* own row, and rows for all sites share the view. Without the host name filter
|
|
14
|
-
* and `ArticleVersion IS NULL` (which keeps only the development row, i.e. the
|
|
15
|
-
* canonical article) every app shows up once per published version.
|
|
16
|
-
*/
|
|
17
|
-
const menuArticlesWhereClause = [
|
|
18
|
-
`HostName = '${hostName.replace(/'/g, "''")}'`,
|
|
19
|
-
"ArticleVersion IS NULL",
|
|
20
|
-
"LastPublished IS NOT NULL",
|
|
21
|
-
"Authenticated = 1",
|
|
22
|
-
"ListOnFrontPage = 1",
|
|
23
|
-
"SysApp = 0",
|
|
24
|
-
"HideFromNav = 0",
|
|
25
|
-
"Hidden = 0",
|
|
26
|
-
"ISNULL(ParentArticleId, '') <> 'news'",
|
|
27
|
-
].join(" AND ");
|
|
28
|
-
// Created once — shared across all AppShell instances on a page.
|
|
29
|
-
const dsMenuArticles = af.data.generateApiDataObject({
|
|
30
|
-
resource: "aviw_WebShared_Articles",
|
|
31
|
-
id: "dsMenuArticles",
|
|
32
|
-
allowUpdate: false,
|
|
33
|
-
allowInsert: false,
|
|
34
|
-
allowDelete: false,
|
|
35
|
-
dynamicLoading: false,
|
|
36
|
-
fields: [
|
|
37
|
-
{ name: "ArticleId", type: "string", nullable: false },
|
|
38
|
-
{ name: "Title", type: "string", nullable: true },
|
|
39
|
-
{ name: "MenuGroup", type: "string", nullable: true },
|
|
40
|
-
{ name: "Path", type: "string", nullable: true },
|
|
41
|
-
{ name: "IsFavorite", type: "boolean", nullable: true },
|
|
42
|
-
],
|
|
43
|
-
parameters: {
|
|
44
|
-
maxRecords: -1,
|
|
45
|
-
whereClause: menuArticlesWhereClause,
|
|
46
|
-
sortOrder: [{ MenuGroup: af.data.SortOrder.Asc }, { Title: af.data.SortOrder.Asc }],
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
// Toggles the current user's favorite state for an article.
|
|
50
|
-
const procSetArticleFavorite = new af.ProcedureAPI({
|
|
51
|
-
procedureId: "astp_WebShared_SetArticleFavorite",
|
|
52
|
-
parameters: [
|
|
53
|
-
{ name: "HostName", type: "string", required: true, hasDefault: false },
|
|
54
|
-
{ name: "ArticleID", type: "string", required: true, hasDefault: false },
|
|
55
|
-
{ name: "Favorite", type: "boolean", required: false, hasDefault: true },
|
|
56
|
-
],
|
|
57
|
-
timeout: 30000,
|
|
58
|
-
});
|
|
59
|
-
// The current user's employee record, used for the photo and full name.
|
|
60
|
-
const dsAppMenuUser = af.data.generateApiDataObject({
|
|
61
|
-
resource: "aviw_Personnel_Employees_Lookup",
|
|
62
|
-
id: "dsAppMenuUser",
|
|
63
|
-
allowUpdate: false,
|
|
64
|
-
allowInsert: false,
|
|
65
|
-
allowDelete: false,
|
|
66
|
-
dynamicLoading: false,
|
|
67
|
-
fields: [
|
|
68
|
-
{ name: "PrimKey", type: "string", nullable: false },
|
|
69
|
-
{ name: "PersonID", type: "string", nullable: false },
|
|
70
|
-
{ name: "FirstName", type: "string", nullable: true },
|
|
71
|
-
{ name: "LastName", type: "string", nullable: true },
|
|
72
|
-
{ name: "Fullname", type: "string", nullable: true },
|
|
73
|
-
{ name: "ImageHash", type: "number", nullable: true },
|
|
74
|
-
],
|
|
75
|
-
parameters: {
|
|
76
|
-
maxRecords: 1,
|
|
77
|
-
// Resolved server side so it doesn't depend on the session being hydrated.
|
|
78
|
-
whereClause: "PersonID = SUSER_SNAME()",
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
3
|
/**
|
|
82
|
-
* Standard Synergi app
|
|
4
|
+
* Standard Synergi app shell: the error boundary around the app.
|
|
5
|
+
*
|
|
6
|
+
* The site chrome (app menu, user menu, colour scheme, service worker update)
|
|
7
|
+
* is no longer part of the app. It is rendered by the `@olenbetong/synergi-chrome`
|
|
8
|
+
* bundle the `ob.2026.application` template loads, which marks the page with
|
|
9
|
+
* `<html data-ob-chrome="1">`. Toolbar slots stay app owned through
|
|
10
|
+
* `ToolbarPortal` and `ToolbarBreadcrumbs`.
|
|
83
11
|
*
|
|
84
12
|
* This component is Designsystemet-only. Apps that still render MUI components
|
|
85
13
|
* should additionally wrap it in `MuiThemeProvider` from
|
|
@@ -87,21 +15,9 @@ const dsAppMenuUser = af.data.generateApiDataObject({
|
|
|
87
15
|
* tokens into a MUI theme.
|
|
88
16
|
*/
|
|
89
17
|
export function AppShell({ children }) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// The portal isn't listed with the apps, so link to it from the menu itself
|
|
96
|
-
// unless that's the article we're already on.
|
|
97
|
-
const homeLink = useMemo(() => {
|
|
98
|
-
const articleId = (globalThis.af?.article?.id ?? "").replace(/\.\d+$/, "");
|
|
99
|
-
return articleId === "portal" ? undefined : { label: getLocalizedString("Front page"), href: "/portal" };
|
|
100
|
-
}, []);
|
|
101
|
-
const toggleFavorite = useCallback(async (articleId, favorite) => {
|
|
102
|
-
await procSetArticleFavorite.execute({ HostName: hostName, ArticleID: articleId, Favorite: favorite });
|
|
103
|
-
}, []);
|
|
104
|
-
const appMenuSlot = document.getElementById("ob-toolbar-app-menu");
|
|
105
|
-
return (_jsxs(AppErrorBoundary, { children: [appMenuSlot &&
|
|
106
|
-
createPortal(_jsx(AppMenuToggle, { open: isAppMenuOpen, hasUpdate: isUpdateAvailable, "aria-controls": "ob-app-menu", onClick: () => setIsAppMenuOpen((open) => !open) }), appMenuSlot), _jsx(AppMenu, { id: "ob-app-menu", dataObject: dsMenuArticles, userDataObject: dsAppMenuUser, categories: categories, homeLink: homeLink, onToggleFavorite: toggleFavorite, hasUpdate: isUpdateAvailable, onInstallUpdate: installUpdate, open: isAppMenuOpen, onClose: () => setIsAppMenuOpen(false) }), children] }));
|
|
18
|
+
return _jsx(AppErrorBoundary, { children: children });
|
|
19
|
+
}
|
|
20
|
+
/** Whether the page's template loaded the site chrome (`<html data-ob-chrome="1">`). */
|
|
21
|
+
export function hasSiteChrome() {
|
|
22
|
+
return typeof document !== "undefined" && document.documentElement.dataset.obChrome !== undefined;
|
|
107
23
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
* Opens a report in the site chrome's report launcher, the way the app menu does.
|
|
12
|
+
*
|
|
13
|
+
* The launcher lives in the `@olenbetong/synergi-chrome` bundle the 2026 templates load,
|
|
14
|
+
* so an app never bundles it; this only forwards to `window.ob.chrome.openReport`.
|
|
15
|
+
* On a page without the chrome (a legacy template) the call is logged and ignored.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* openReport("arpt_Production_ElementsDaily", { initialFilter: `[ProjectID] = '${projectId}'` });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function openReport(reportId: string, options?: OpenReportOptions): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opens a report in the site chrome's report launcher, the way the app menu does.
|
|
3
|
+
*
|
|
4
|
+
* The launcher lives in the `@olenbetong/synergi-chrome` bundle the 2026 templates load,
|
|
5
|
+
* so an app never bundles it; this only forwards to `window.ob.chrome.openReport`.
|
|
6
|
+
* On a page without the chrome (a legacy template) the call is logged and ignored.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* openReport("arpt_Production_ElementsDaily", { initialFilter: `[ProjectID] = '${projectId}'` });
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export function openReport(reportId, options) {
|
|
14
|
+
let chrome = globalThis.ob?.chrome;
|
|
15
|
+
if (chrome?.openReport) {
|
|
16
|
+
chrome.openReport(reportId, options);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
console.warn(`openReport(${reportId}): the site chrome is not on this page, so there is no report launcher.`);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/es/colorScheme.d.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The preference lives in the `ob-color-scheme` cookie so the article template
|
|
5
5
|
* can read it server side and render `data-color-scheme` on `<html>` and
|
|
6
|
-
* `<body>` before the first paint. The site
|
|
7
|
-
* (`
|
|
8
|
-
*
|
|
9
|
-
* `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
|
|
6
|
+
* `<body>` before the first paint. The site chrome bundle
|
|
7
|
+
* (`@olenbetong/synergi-chrome`) owns the same cookie for the toolbar user menu
|
|
8
|
+
* and app menu toggles, so all of them write the cookie, apply the attributes,
|
|
9
|
+
* and dispatch `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
|
|
10
10
|
*/
|
|
11
11
|
export type ColorSchemePreference = "auto" | "light" | "dark";
|
|
12
12
|
/** Dispatched on `window` whenever the preference changes. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "./index.css";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
3
|
import clsx from "clsx";
|
|
5
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
6
6
|
function getUiCulture() {
|
|
7
7
|
return af?.userSession?.culture ?? "default";
|
|
8
8
|
}
|
|
@@ -2,7 +2,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import "filepond-plugin-file-poster/dist/filepond-plugin-file-poster.css";
|
|
3
3
|
import "filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css";
|
|
4
4
|
import "filepond/dist/filepond.css";
|
|
5
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
6
5
|
import { useData, useFetchData } from "@olenbetong/appframe-react";
|
|
7
6
|
import { create, FileStatus, registerPlugin, } from "filepond";
|
|
8
7
|
import FilePondPluginImageExifOrientation from "filepond-plugin-image-exif-orientation";
|
|
@@ -10,6 +9,7 @@ import FilePondPluginImagePreview from "filepond-plugin-image-preview";
|
|
|
10
9
|
import FilePondPluginImageResize from "filepond-plugin-image-resize";
|
|
11
10
|
import FilePondPluginImageTransform from "filepond-plugin-image-transform";
|
|
12
11
|
import { useEffect, useMemo, useRef } from "react";
|
|
12
|
+
import { getLocalizedString } from "../i18n.js";
|
|
13
13
|
export { FileStatus, registerPlugin };
|
|
14
14
|
registerPlugin(FilePondPluginImageExifOrientation, FilePondPluginImageResize, FilePondPluginImagePreview, FilePondPluginImageTransform);
|
|
15
15
|
let isMostLikelyMobile = navigator.userAgent.match(/Android/i) ||
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Spinner, Tooltip } from "@digdir/designsystemet-react";
|
|
3
3
|
import { ArrowCirclepathIcon, ArrowLeftIcon, ArrowRedoIcon, ArrowUndoIcon, CheckmarkIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
4
|
import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
6
5
|
import "./ImageEditor.css";
|
|
7
6
|
import { ResponsiveButton } from "./ResponsiveButton.js";
|
|
8
7
|
import { useActiveTool } from "./useActiveTool.js";
|
|
9
8
|
import { useImageHistory } from "./useImageHistory.js";
|
|
10
9
|
import { useIsSmall } from "./useIsSmall.js";
|
|
10
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
11
11
|
/**
|
|
12
12
|
* Full-screen image editor shell.
|
|
13
13
|
* Does not know about specific tools — behaviour is entirely driven by the `plugins` prop.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Paragraph, Spinner } from "@digdir/designsystemet-react";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
3
|
import { CropCanvas } from "../../CropCanvas.js";
|
|
5
4
|
import { DragHandle } from "../../DragHandle.js";
|
|
6
5
|
import { EdgeHandle } from "../../EdgeHandle.js";
|
|
7
6
|
import { useZoomLevel } from "../zoomPlugin/ZoomContext.js";
|
|
8
7
|
import { useCropContext } from "./CropContext.js";
|
|
8
|
+
import { getLocalizedString } from "../../../../i18n.js";
|
|
9
9
|
/** Canvas-area overlay for the crop tool. Reads all state from CropContext. */
|
|
10
10
|
export function CropOverlay() {
|
|
11
11
|
let { imageUrl, activeCorners, mode, hasSelection, scale, displaySize, canvasRef, cvReady, cvError, cropping, error, handleCanvasReady, updateCorner, startRectDraw, updateRectDraw, finishRectDraw, } = useCropContext();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Spinner } from "@digdir/designsystemet-react";
|
|
3
3
|
import { CheckmarkIcon, ExpandIcon, SquareIcon, XMarkIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
4
|
import { useCropContext } from "./CropContext.js";
|
|
5
|
+
import { getLocalizedString } from "../../../../i18n.js";
|
|
6
6
|
/** Toolbar shown while the crop tool is active. Reads state from CropContext. */
|
|
7
7
|
export function CropToolbar() {
|
|
8
8
|
let { applyCrop, cropping, mode, hasSelection, startRectMode, cancelRectMode, onApply, onCancel } = useCropContext();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Button, Spinner } from "@digdir/designsystemet-react";
|
|
3
3
|
import { CheckmarkIcon, EraserIcon, XMarkIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
4
|
import { useState } from "react";
|
|
6
5
|
import { useRedactContext } from "./RedactContext.js";
|
|
6
|
+
import { getLocalizedString } from "../../../../i18n.js";
|
|
7
7
|
/** Toolbar shown while the redact tool is active. Reads state from RedactContext. */
|
|
8
8
|
export function RedactToolbar() {
|
|
9
9
|
let { rects, clearAll, applyRedact, onApply, onCancel } = useRedactContext();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ShrinkIcon, ZoomMinusIcon, ZoomPlusIcon } from "@navikt/aksel-icons";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
3
|
import { ResponsiveButton } from "../../ResponsiveButton.js";
|
|
5
4
|
import { useZoom } from "./ZoomContext.js";
|
|
5
|
+
import { getLocalizedString } from "../../../../i18n.js";
|
|
6
6
|
export function ZoomControls({ disabled, isSmall = false }) {
|
|
7
7
|
let { zoom, zoomIn, zoomOut, resetZoom, canZoomIn, canZoomOut, isZoomed } = useZoom();
|
|
8
8
|
return (_jsxs(_Fragment, { children: [_jsx(ResponsiveButton, { icon: _jsx(ZoomMinusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom out"), onClick: zoomOut, disabled: disabled || !canZoomOut, isSmall: isSmall }), _jsxs("span", { className: "image-editor__zoom-level", children: [Math.round(zoom * 100), "%"] }), _jsx(ResponsiveButton, { icon: _jsx(ZoomPlusIcon, { "aria-hidden": true }), label: getLocalizedString("Zoom in"), onClick: zoomIn, disabled: disabled || !canZoomIn, isSmall: isSmall }), _jsx(ResponsiveButton, { disabled: !isZoomed, icon: _jsx(ShrinkIcon, { "aria-hidden": true }), label: getLocalizedString("Reset zoom"), onClick: resetZoom, isSmall: isSmall })] }));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Button, DialogActions, LinearProgress, Link, Typography } from "@mui/material";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
3
|
import { ResponsiveDialog } from "@olenbetong/appframe-mui";
|
|
5
4
|
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
6
6
|
function formatRemaining(ms) {
|
|
7
7
|
if (ms < 60_000)
|
|
8
8
|
return `~${Math.ceil(ms / 1000)}s`;
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import "./Toolbar.css";
|
|
2
2
|
import { type To } from "react-router";
|
|
3
|
-
/**
|
|
4
|
-
* The named regions of the site toolbar an app can render into.
|
|
5
|
-
*
|
|
6
|
-
* `menu-toggle` sits at the very start of the toolbar, before the logo: it is where an app that
|
|
7
|
-
* has a navigation drawer of its own hangs the button that opens it. That belongs on the same
|
|
8
|
-
* edge as the drawer it controls — a toggle in `actions`, at the opposite end of the toolbar,
|
|
9
|
-
* reads as unrelated to the panel that slides in on the left.
|
|
10
|
-
*/
|
|
11
|
-
export type ToolbarPortalSlot = "menu-toggle" | "breadcrumbs" | "search" | "actions";
|
|
12
3
|
export type ToolbarPortalProps = {
|
|
13
|
-
slot: ToolbarPortalSlot;
|
|
14
4
|
children: React.ReactNode;
|
|
15
5
|
};
|
|
16
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Renders its children into the toolbar's app region. Render `ToolbarBreadcrumbs` before any
|
|
8
|
+
* other `ToolbarPortal`, since the region lays its children out in mount order with the first
|
|
9
|
+
* one taking the free space. Renders nothing on a template without a toolbar.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ToolbarPortal({ children }: ToolbarPortalProps): import("react").ReactPortal | null;
|
|
12
|
+
export type ToolbarDrawerToggleProps = {
|
|
13
|
+
/** Whether the drawer is open; sets `aria-expanded`. */
|
|
14
|
+
open: boolean;
|
|
15
|
+
onToggle: () => void;
|
|
16
|
+
/** Accessible name. Defaults to the localized "Toggle menu". */
|
|
17
|
+
label?: string;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* The hamburger button for the app's navigation drawer, rendered into the toolbar's drawer slot.
|
|
21
|
+
* Styled by the site stylesheet (`.ob-toolbar__icon-button`) so it inherits the toolbar's
|
|
22
|
+
* contrast colour on every brand. Renders nothing on a template without a toolbar.
|
|
23
|
+
*/
|
|
24
|
+
export declare function ToolbarDrawerToggle({ open, onToggle, label }: ToolbarDrawerToggleProps): import("react").ReactPortal | null;
|
|
17
25
|
export type BreadcrumbItem = {
|
|
18
26
|
label: string;
|
|
19
27
|
/**
|
|
@@ -32,4 +40,5 @@ export type BreadcrumbItem = {
|
|
|
32
40
|
export type ToolbarBreadcrumbsProps = {
|
|
33
41
|
items: BreadcrumbItem[];
|
|
34
42
|
};
|
|
43
|
+
/** The app's breadcrumb trail, rendered into the toolbar's app region. The last item is the current page. */
|
|
35
44
|
export declare function ToolbarBreadcrumbs({ items }: ToolbarBreadcrumbsProps): import("react").JSX.Element;
|
|
@@ -1,17 +1,57 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "./Toolbar.css";
|
|
3
|
+
import { MenuHamburgerIcon } from "@navikt/aksel-icons";
|
|
3
4
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
5
|
import { createPortal } from "react-dom";
|
|
5
6
|
import { Link } from "react-router";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
8
|
+
/*
|
|
9
|
+
* The site template (`ob.2026.application`) renders the toolbar and leaves two regions to the
|
|
10
|
+
* app. Both are filled through portals, so the app's React tree (router, contexts, state) is
|
|
11
|
+
* preserved inside them:
|
|
12
|
+
*
|
|
13
|
+
* - the app region (`#ob-toolbar-app`): breadcrumbs first, then any per-app controls;
|
|
14
|
+
* - the drawer slot (`#ob-toolbar-drawer`) at the far left of the toolbar, reserved for the
|
|
15
|
+
* toggle of the app's navigation drawer — the same edge the drawer slides in from.
|
|
16
|
+
*
|
|
17
|
+
* Everything else in the toolbar (brand, Apps button, user menu) is the site's, rendered by the
|
|
18
|
+
* chrome bundle. The phase 1 template rendered separate slots instead; those ids are kept as
|
|
19
|
+
* fallbacks until every site runs the current template.
|
|
20
|
+
*/
|
|
21
|
+
const APP_REGION_IDS = ["ob-toolbar-app", "ob-toolbar-breadcrumbs"];
|
|
22
|
+
const DRAWER_SLOT_IDS = ["ob-toolbar-drawer", "ob-toolbar-menu-toggle"];
|
|
23
|
+
function findTarget(ids) {
|
|
24
|
+
if (typeof document === "undefined")
|
|
25
|
+
return null;
|
|
26
|
+
for (let id of ids) {
|
|
27
|
+
let element = document.getElementById(id);
|
|
28
|
+
if (element)
|
|
29
|
+
return element;
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Renders its children into the toolbar's app region. Render `ToolbarBreadcrumbs` before any
|
|
35
|
+
* other `ToolbarPortal`, since the region lays its children out in mount order with the first
|
|
36
|
+
* one taking the free space. Renders nothing on a template without a toolbar.
|
|
37
|
+
*/
|
|
38
|
+
export function ToolbarPortal({ children }) {
|
|
39
|
+
let target = findTarget(APP_REGION_IDS);
|
|
11
40
|
if (!target)
|
|
12
41
|
return null;
|
|
13
42
|
return createPortal(children, target);
|
|
14
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* The hamburger button for the app's navigation drawer, rendered into the toolbar's drawer slot.
|
|
46
|
+
* Styled by the site stylesheet (`.ob-toolbar__icon-button`) so it inherits the toolbar's
|
|
47
|
+
* contrast colour on every brand. Renders nothing on a template without a toolbar.
|
|
48
|
+
*/
|
|
49
|
+
export function ToolbarDrawerToggle({ open, onToggle, label }) {
|
|
50
|
+
let target = findTarget(DRAWER_SLOT_IDS);
|
|
51
|
+
if (!target)
|
|
52
|
+
return null;
|
|
53
|
+
return createPortal(_jsx("button", { type: "button", className: "ob-toolbar__icon-button", "aria-label": label ?? getLocalizedString("Toggle menu"), "aria-expanded": open, onClick: onToggle, children: _jsx(MenuHamburgerIcon, { "aria-hidden": true, fontSize: "1.5rem" }) }), target);
|
|
54
|
+
}
|
|
15
55
|
/**
|
|
16
56
|
* A crumb the user can follow. `to` goes through the router; `href` is an ordinary link.
|
|
17
57
|
*
|
|
@@ -75,6 +115,7 @@ function BreadcrumbsInner({ items }) {
|
|
|
75
115
|
return (_jsx("li", { className: "ob-breadcrumbs__item", children: isCurrent ? _jsx("span", { "aria-current": "page", children: item.label }) : _jsx(BreadcrumbLink, { item: item }) }, actualIndex));
|
|
76
116
|
})] }) }));
|
|
77
117
|
}
|
|
118
|
+
/** The app's breadcrumb trail, rendered into the toolbar's app region. The last item is the current page. */
|
|
78
119
|
export function ToolbarBreadcrumbs({ items }) {
|
|
79
|
-
return (_jsx(ToolbarPortal, {
|
|
120
|
+
return (_jsx(ToolbarPortal, { children: _jsx(BreadcrumbsInner, { items: items }) }));
|
|
80
121
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Add from "@mui/icons-material/Add";
|
|
3
3
|
import { Button } from "@mui/material";
|
|
4
|
-
import { getLocalizedString } from "
|
|
4
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
5
5
|
export function DamageFormButtons({ isEdit, loading, uploadingFile, handleDelete, handleCancel, }) {
|
|
6
6
|
return (_jsxs(_Fragment, { children: [isEdit && _jsx(Button, { onClick: handleDelete, children: getLocalizedString("Delete") }), _jsx(Button, { onClick: handleCancel, children: getLocalizedString("Cancel") }), _jsx(Button, { loading: loading || uploadingFile, loadingPosition: "start", startIcon: _jsx(Add, {}), type: "submit", variant: "contained", children: isEdit ? getLocalizedString("Save changes") : getLocalizedString("Register damage") })] }));
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Autocomplete, Button, TextField } from "@mui/material";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
3
|
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
5
5
|
export function DescriptionInput({ value, defaultValue, descriptionOptions = [
|
|
6
6
|
getLocalizedString("Tear in element"),
|
|
7
7
|
getLocalizedString("Damage around lifting anchor"),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Grid, Typography } from "@mui/material";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
3
|
import { Link } from "@olenbetong/appframe-mui";
|
|
4
|
+
import { getLocalizedString } from "../../../i18n.js";
|
|
5
5
|
function SummaryItem({ col, label, children, em, align, padding }) {
|
|
6
6
|
return (_jsxs(Grid, { size: col, sx: { p: padding ?? 2, borderBottom: (t) => `1px solid ${t.palette.divider}` }, children: [label && (_jsx(Typography, { variant: "body1", sx: { fontSize: "0.9rem", fontWeight: 500, mb: 1, textAlign: align }, children: getLocalizedString(label) })), children && (_jsx(Typography, { sx: {
|
|
7
7
|
fontSize: em ? "1.4rem" : "0.9rem",
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Add from "@mui/icons-material/Add";
|
|
3
3
|
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Grid, useMediaQuery } from "@mui/material";
|
|
4
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
4
|
import { theme } from "@olenbetong/appframe-mui";
|
|
6
5
|
import { ElementDamagesHeader, ElementDamagesItem } from "./DesktopView";
|
|
7
6
|
import { DuplicatePhoneViewItem } from "./PhoneView";
|
|
7
|
+
import { getLocalizedString } from "../../../i18n.js";
|
|
8
8
|
export function DuplicateElementDamageDialog({ open, onClose, record, onRegisterAnyway, loading, linkToDamage, }) {
|
|
9
9
|
let matches = useMediaQuery(theme.breakpoints.up("lg"));
|
|
10
10
|
let backgroundColor = "#e9ebee";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Card, CardContent, Typography } from "@mui/material";
|
|
3
|
-
import { getLocalizedString } from "
|
|
3
|
+
import { getLocalizedString } from "../../../i18n.js";
|
|
4
4
|
export function DuplicatePhoneViewItem({ record, linkToDamage }) {
|
|
5
5
|
return (_jsx(Card, { variant: "outlined", onClick: () => {
|
|
6
6
|
if (linkToDamage) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { TextField } from "@mui/material";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
3
|
import { useEffect, useState } from "react";
|
|
4
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
5
5
|
export function ElementNumberTextField({ value, defaultValue, onChange, disabled, sx }) {
|
|
6
6
|
let [elementNumber, setElementNumber] = useState(defaultValue ?? "");
|
|
7
7
|
let elementNumberValue = value === undefined ? elementNumber : value;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import CheckIcon from "@mui/icons-material/Check";
|
|
3
3
|
import { Button, Checkbox, FormControlLabel, Typography } from "@mui/material";
|
|
4
|
-
import { getLocalizedString, localize } from "@olenbetong/appframe-core";
|
|
5
4
|
import { useEffect, useRef, useState } from "react";
|
|
6
5
|
import { procApproveDamage } from "../data";
|
|
6
|
+
import { getLocalizedString, localize } from "../../i18n.js";
|
|
7
7
|
const formatter = new Intl.DateTimeFormat(af.userSession.culture, {
|
|
8
8
|
day: "numeric",
|
|
9
9
|
month: "long",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import Add from "@mui/icons-material/Add";
|
|
3
3
|
import { Box, Button } from "@mui/material";
|
|
4
|
-
import { getLocalizedString } from "
|
|
4
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
5
5
|
export function SubmitButtons({ edit, loading, onDelete, onCancel, onSubmit, sx }) {
|
|
6
6
|
return (_jsxs(Box, { sx: { display: "flex", flexWrap: "wrap", gap: 2, justifyContent: "flex-end", ...sx }, children: [edit && _jsx(Button, { onClick: onDelete, children: getLocalizedString("Delete") }), _jsx(Button, { onClick: onCancel, children: getLocalizedString("Cancel") }), _jsx(Button, { loading: loading, loadingPosition: "start", startIcon: _jsx(Add, {}), type: "submit", variant: "contained", onClick: onSubmit, children: edit ? getLocalizedString("Save changes") : getLocalizedString("Register damage") })] }));
|
|
7
7
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import DropDownArrowIcon from "@mui/icons-material/KeyboardArrowDown";
|
|
3
3
|
import { Button, ListItemText, Menu, MenuItem } from "@mui/material";
|
|
4
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
4
|
import { useState } from "react";
|
|
5
|
+
import { getLocalizedString } from "../../i18n.js";
|
|
6
6
|
export function TransportElementSelect({ elements, onSelect }) {
|
|
7
7
|
let [anchorEl, setAnchorEl] = useState(null);
|
|
8
8
|
let open = !!anchorEl;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type RefObject } from "react";
|
|
1
|
+
import { type ReactNode, type RefObject } from "react";
|
|
2
|
+
import type { DecoderFactory } from "./ElementLookupDialog/BarcodeScanner";
|
|
2
3
|
export type Element = {
|
|
3
4
|
Domain: string;
|
|
4
5
|
PrimKey: string;
|
|
@@ -18,5 +19,9 @@ export type ElementLookupProps = {
|
|
|
18
19
|
openLookupDialogIcon?: boolean;
|
|
19
20
|
onChange?: (value: Element | null) => void;
|
|
20
21
|
onDialogChange?: (open: boolean) => void;
|
|
22
|
+
/** Engine for the camera tab of the lookup dialog. Defaults to zxing-wasm. */
|
|
23
|
+
decoder?: DecoderFactory;
|
|
24
|
+
/** Extra controls in the camera tab footer, e.g. an engine picker. */
|
|
25
|
+
scannerActions?: ReactNode;
|
|
21
26
|
};
|
|
22
|
-
export declare function ElementLookup({ value, defaultValue, ref, elementIDRequired, openLookupDialogIcon, onChange, onDialogChange, }: ElementLookupProps): import("react").JSX.Element;
|
|
27
|
+
export declare function ElementLookup({ value, defaultValue, ref, elementIDRequired, openLookupDialogIcon, onChange, onDialogChange, decoder, scannerActions, }: ElementLookupProps): import("react").JSX.Element;
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import SearchIcon from "@mui/icons-material/Search";
|
|
3
3
|
import { IconButton, TextField } from "@mui/material";
|
|
4
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
4
|
import { useEffect, useImperativeHandle, useRef, useState } from "react";
|
|
6
5
|
import { ElementLookupDialog } from "./ElementLookupDialog";
|
|
7
|
-
|
|
6
|
+
import { getLocalizedString } from "../i18n.js";
|
|
7
|
+
export function ElementLookup({ value, defaultValue, ref, elementIDRequired = false, openLookupDialogIcon, onChange, onDialogChange, decoder, scannerActions, }) {
|
|
8
8
|
let initializedRef = useRef(false);
|
|
9
9
|
let [openElementLookupDialog, setOpenElementLookupDialog] = useState(false);
|
|
10
10
|
let [element, setElement] = useState(defaultValue ?? null);
|
|
11
11
|
let elementValue = value === undefined ? element : value;
|
|
12
|
-
// biome-ignore lint: intentionally skipping "value" dependency as this shouldn't run when "value" changes
|
|
13
12
|
useEffect(() => {
|
|
14
13
|
if (initializedRef.current) {
|
|
15
14
|
return;
|
|
@@ -18,7 +17,7 @@ export function ElementLookup({ value, defaultValue, ref, elementIDRequired = fa
|
|
|
18
17
|
setElement(defaultValue);
|
|
19
18
|
initializedRef.current = true;
|
|
20
19
|
}
|
|
21
|
-
}, [defaultValue]);
|
|
20
|
+
}, [defaultValue]); // oxlint-disable-line react-hooks/exhaustive-deps (intentionally skipping "value" dependency as this shouldn't run when "value" changes)
|
|
22
21
|
useImperativeHandle(ref, () => ({
|
|
23
22
|
openDialog: () => setOpenElementLookupDialog(true),
|
|
24
23
|
closeDialog: () => setOpenElementLookupDialog(false),
|
|
@@ -27,11 +26,10 @@ export function ElementLookup({ value, defaultValue, ref, elementIDRequired = fa
|
|
|
27
26
|
onChange?.(addElement.element);
|
|
28
27
|
setElement(addElement.element);
|
|
29
28
|
}
|
|
30
|
-
// biome-ignore lint: only run when openElementLookupDialog changes
|
|
31
29
|
useEffect(() => {
|
|
32
30
|
onDialogChange?.(openElementLookupDialog);
|
|
33
|
-
}, [openElementLookupDialog]);
|
|
34
|
-
return (_jsxs(_Fragment, { children: [_jsx(ElementLookupDialog, { open: openElementLookupDialog, mode: "single", onClose: () => setOpenElementLookupDialog(false), onAdd: handleAddElement, allowEmptyElement: !elementIDRequired }), _jsx("input", { type: "hidden", name: "ProjectID", value: elementValue?.ProjectID ?? "" }), _jsx("input", { type: "hidden", name: "ElementRef", value: elementValue?.PrimKey ?? "" }), _jsx(TextField, { id: "NewElementDamge_Project", value: elementValue ? `${elementValue.ProjectID}: ${elementValue.ProjectName}` : "", label: getLocalizedString("Project"), fullWidth: true, required: true, autoComplete: "off", slotProps: { htmlInput: { readOnly: true } } }), _jsx(TextField, { name: "ElementID", id: "NewElementDamage_ElementID", value: elementValue ? elementValue.ElementID : "", label: getLocalizedString("Element ID"), fullWidth: true, required: elementIDRequired, autoComplete: "off", slotProps: {
|
|
31
|
+
}, [openElementLookupDialog]); // oxlint-disable-line react-hooks/exhaustive-deps (only run when openElementLookupDialog changes)
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx(ElementLookupDialog, { open: openElementLookupDialog, mode: "single", onClose: () => setOpenElementLookupDialog(false), onAdd: handleAddElement, allowEmptyElement: !elementIDRequired, decoder: decoder, scannerActions: scannerActions }), _jsx("input", { type: "hidden", name: "ProjectID", value: elementValue?.ProjectID ?? "" }), _jsx("input", { type: "hidden", name: "ElementRef", value: elementValue?.PrimKey ?? "" }), _jsx(TextField, { id: "NewElementDamge_Project", value: elementValue ? `${elementValue.ProjectID}: ${elementValue.ProjectName}` : "", label: getLocalizedString("Project"), fullWidth: true, required: true, autoComplete: "off", slotProps: { htmlInput: { readOnly: true } } }), _jsx(TextField, { name: "ElementID", id: "NewElementDamage_ElementID", value: elementValue ? elementValue.ElementID : "", label: getLocalizedString("Element ID"), fullWidth: true, required: elementIDRequired, autoComplete: "off", slotProps: {
|
|
35
33
|
htmlInput: { readOnly: true },
|
|
36
34
|
input: {
|
|
37
35
|
endAdornment: openLookupDialogIcon ? (_jsx(IconButton, { onClick: () => setOpenElementLookupDialog(true), children: _jsx(SearchIcon, {}) })) : undefined,
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type DecodedPoint = {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
};
|
|
5
|
+
export type DecodedBarcode = {
|
|
6
|
+
/** Decoded text. GS1 DataMatrix keeps the FNC1 separators as U+001D. */
|
|
7
|
+
text: string;
|
|
8
|
+
/** Corners of the symbol in frame pixel coordinates: top-left, top-right, bottom-right, bottom-left. */
|
|
9
|
+
corners: [DecodedPoint, DecodedPoint, DecodedPoint, DecodedPoint];
|
|
10
|
+
/** Engine-specific format name, when reported. */
|
|
11
|
+
format?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A barcode decoding engine. `BarcodeScanner` owns the camera and the frame loop and only hands
|
|
15
|
+
* frames to the decoder, so any engine that can read a canvas or an image file can be plugged in.
|
|
16
|
+
*/
|
|
17
|
+
export interface BarcodeDecoder {
|
|
18
|
+
/** Short identifier shown in the scanner UI, e.g. "zxing", "native" or "dbr". */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** Decode one camera frame drawn on a canvas. The scanner never has more than one call in flight. */
|
|
21
|
+
decodeFrame(frame: HTMLCanvasElement): Promise<DecodedBarcode[]>;
|
|
22
|
+
/** Decode a still image, such as a photo upload. May use slower, more thorough settings. */
|
|
23
|
+
decodeImage(file: Blob): Promise<DecodedBarcode[]>;
|
|
24
|
+
/** Release engine resources. Called when the scanner unmounts. */
|
|
25
|
+
dispose?(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a decoder. The heavy work — downloading a WebAssembly build or a vendor script — happens
|
|
29
|
+
* here, not when the factory itself is created, so the factory is cheap to pass around and nothing
|
|
30
|
+
* is loaded until the scanner mounts.
|
|
31
|
+
*/
|
|
32
|
+
export type DecoderFactory = () => Promise<BarcodeDecoder>;
|