@olenbetong/synergi-react 3.2.2 → 4.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 (112) hide show
  1. package/es/chrome/AppShell/index.d.ts +10 -2
  2. package/es/chrome/AppShell/index.js +13 -97
  3. package/es/chrome/openReport.d.ts +22 -0
  4. package/es/chrome/openReport.js +21 -0
  5. package/es/colorScheme.d.ts +4 -4
  6. package/es/components/Toolbar/index.d.ts +20 -11
  7. package/es/components/Toolbar/index.js +47 -6
  8. package/es/elements/ElementLookup.d.ts +7 -2
  9. package/es/elements/ElementLookup.js +4 -6
  10. package/es/elements/ElementLookupDialog/BarcodeScanner/decoder.d.ts +32 -0
  11. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.d.ts +28 -0
  12. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.js +81 -0
  13. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.d.ts +26 -0
  14. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.js +70 -0
  15. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.d.ts +20 -0
  16. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.js +69 -0
  17. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.js +103 -0
  18. package/es/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.d.ts +6 -0
  19. package/es/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.js +19 -0
  20. package/es/elements/ElementLookupDialog/BarcodeScanner/index.d.ts +14 -7
  21. package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +10 -6
  22. package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.d.ts +14 -12
  23. package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.js +222 -116
  24. package/es/elements/ElementLookupDialog/index.d.ts +6 -0
  25. package/es/elements/ElementLookupDialog/index.js +2 -2
  26. package/es/index.d.ts +3 -4
  27. package/es/index.js +5 -4
  28. package/package.json +9 -8
  29. package/src/chrome/AppShell/index.tsx +13 -134
  30. package/src/chrome/openReport.ts +34 -0
  31. package/src/colorScheme.ts +4 -4
  32. package/src/components/Toolbar/index.tsx +65 -14
  33. package/src/elements/ElementLookup.tsx +12 -5
  34. package/src/elements/ElementLookupDialog/BarcodeScanner/decoder.ts +32 -0
  35. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.ts +118 -0
  36. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/native.ts +103 -0
  37. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +95 -0
  38. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders.test.ts +118 -0
  39. package/src/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.ts +21 -0
  40. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +29 -14
  41. package/src/elements/ElementLookupDialog/BarcodeScanner/useScanner.ts +246 -136
  42. package/src/elements/ElementLookupDialog/index.tsx +12 -4
  43. package/src/index.ts +6 -37
  44. package/es/chrome/AppMenu/AppMenu.css +0 -648
  45. package/es/chrome/AppMenu/AppMenu.d.ts +0 -56
  46. package/es/chrome/AppMenu/AppMenu.js +0 -145
  47. package/es/chrome/AppMenu/AppMenuColorScheme.d.ts +0 -2
  48. package/es/chrome/AppMenu/AppMenuColorScheme.js +0 -18
  49. package/es/chrome/AppMenu/AppMenuFavoriteButton.d.ts +0 -18
  50. package/es/chrome/AppMenu/AppMenuFavoriteButton.js +0 -11
  51. package/es/chrome/AppMenu/AppMenuHeader.d.ts +0 -24
  52. package/es/chrome/AppMenu/AppMenuHeader.js +0 -18
  53. package/es/chrome/AppMenu/AppMenuList.d.ts +0 -18
  54. package/es/chrome/AppMenu/AppMenuList.js +0 -39
  55. package/es/chrome/AppMenu/AppMenuRail.d.ts +0 -26
  56. package/es/chrome/AppMenu/AppMenuRail.js +0 -30
  57. package/es/chrome/AppMenu/AppMenuToggle.d.ts +0 -15
  58. package/es/chrome/AppMenu/AppMenuToggle.js +0 -14
  59. package/es/chrome/AppMenu/AppMenuUserMenu.d.ts +0 -32
  60. package/es/chrome/AppMenu/AppMenuUserMenu.js +0 -110
  61. package/es/chrome/AppMenu/developerCategories.d.ts +0 -24
  62. package/es/chrome/AppMenu/developerCategories.js +0 -116
  63. package/es/chrome/AppMenu/icons.d.ts +0 -15
  64. package/es/chrome/AppMenu/icons.js +0 -13
  65. package/es/chrome/AppMenu/index.d.ts +0 -12
  66. package/es/chrome/AppMenu/index.js +0 -10
  67. package/es/chrome/AppMenu/menuEntries.d.ts +0 -51
  68. package/es/chrome/AppMenu/menuEntries.js +0 -93
  69. package/es/chrome/AppMenu/types.d.ts +0 -43
  70. package/es/chrome/AppMenu/useFavorites.d.ts +0 -13
  71. package/es/chrome/AppMenu/useFavorites.js +0 -28
  72. package/es/chrome/AppMenu/useRovingTabIndex.d.ts +0 -28
  73. package/es/chrome/AppMenu/useRovingTabIndex.js +0 -114
  74. package/es/chrome/AppMenu/useServiceWorkerUpdate.d.ts +0 -16
  75. package/es/chrome/AppMenu/useServiceWorkerUpdate.js +0 -62
  76. package/es/report/ReportLauncher.css +0 -147
  77. package/es/report/ReportLauncher.d.ts +0 -55
  78. package/es/report/ReportLauncher.js +0 -142
  79. package/es/report/ReportLauncher.test.js +0 -231
  80. package/es/report/ReportParameters.css +0 -29
  81. package/es/report/ReportParameters.d.ts +0 -46
  82. package/es/report/ReportParameters.js +0 -65
  83. package/es/report/ReportParameters.test.d.ts +0 -1
  84. package/es/report/ReportParameters.test.js +0 -84
  85. package/es/report/index.d.ts +0 -2
  86. package/es/report/index.js +0 -2
  87. package/src/chrome/AppMenu/AppMenu.css +0 -648
  88. package/src/chrome/AppMenu/AppMenu.tsx +0 -285
  89. package/src/chrome/AppMenu/AppMenuColorScheme.tsx +0 -41
  90. package/src/chrome/AppMenu/AppMenuFavoriteButton.tsx +0 -47
  91. package/src/chrome/AppMenu/AppMenuHeader.tsx +0 -79
  92. package/src/chrome/AppMenu/AppMenuList.tsx +0 -89
  93. package/src/chrome/AppMenu/AppMenuRail.tsx +0 -117
  94. package/src/chrome/AppMenu/AppMenuToggle.tsx +0 -51
  95. package/src/chrome/AppMenu/AppMenuUserMenu.tsx +0 -190
  96. package/src/chrome/AppMenu/developerCategories.ts +0 -142
  97. package/src/chrome/AppMenu/icons.tsx +0 -76
  98. package/src/chrome/AppMenu/index.ts +0 -17
  99. package/src/chrome/AppMenu/menuEntries.ts +0 -128
  100. package/src/chrome/AppMenu/types.ts +0 -45
  101. package/src/chrome/AppMenu/useFavorites.ts +0 -40
  102. package/src/chrome/AppMenu/useRovingTabIndex.ts +0 -130
  103. package/src/chrome/AppMenu/useServiceWorkerUpdate.ts +0 -68
  104. package/src/report/ReportLauncher.css +0 -147
  105. package/src/report/ReportLauncher.test.tsx +0 -281
  106. package/src/report/ReportLauncher.tsx +0 -420
  107. package/src/report/ReportParameters.css +0 -29
  108. package/src/report/ReportParameters.test.tsx +0 -133
  109. package/src/report/ReportParameters.tsx +0 -198
  110. package/src/report/index.ts +0 -2
  111. /package/es/{chrome/AppMenu/types.js → elements/ElementLookupDialog/BarcodeScanner/decoder.js} +0 -0
  112. /package/es/{report/ReportLauncher.test.d.ts → elements/ElementLookupDialog/BarcodeScanner/decoders.test.d.ts} +0 -0
@@ -1,3 +1,5 @@
1
+ import { type ReactNode } from "react";
2
+ import { type DecoderFactory } from "./BarcodeScanner";
1
3
  import { type AddElementSource, type ElementDetails } from "./getElement";
2
4
  export type AddElement = {
3
5
  element: ElementDetails;
@@ -11,6 +13,10 @@ export type ElementLookupDialogSharedProps = {
11
13
  initialTab?: InitialTabProps | null;
12
14
  useSearch?: boolean;
13
15
  allowEmptyElement?: boolean;
16
+ /** Engine for the camera tab. Defaults to zxing-wasm. */
17
+ decoder?: DecoderFactory;
18
+ /** Extra controls in the camera tab footer, e.g. an engine picker. */
19
+ scannerActions?: ReactNode;
14
20
  };
15
21
  export type ElementLookupDialogSingleModeProps = ElementLookupDialogSharedProps & {
16
22
  mode: "single" | "search";
@@ -16,7 +16,7 @@ import { AddElementManualForm } from "./Manual/ManualForm";
16
16
  import { useBeeper } from "./utils/beep";
17
17
  import Giai from "./utils/Giai";
18
18
  export function ElementLookupDialog(props) {
19
- let { open, onClose, initialTab } = props;
19
+ let { open, onClose, initialTab, decoder, scannerActions } = props;
20
20
  let [tab, setTab] = useState("camera");
21
21
  let [elements, setElements] = useState([]);
22
22
  let [adding, setAdding] = useState(false);
@@ -72,7 +72,7 @@ export function ElementLookupDialog(props) {
72
72
  }
73
73
  return (_jsx(ResponsiveDialog, { open: open, onClose: onClose, slotProps: {
74
74
  paper: { sx: { overflow: "hidden" } },
75
- }, children: _jsxs(Box, { sx: { display: "flex", flexDirection: "column", maxHeight: "100%", overflow: "hidden", flexGrow: 1 }, children: [_jsxs(Tabs, { value: tab, onChange: (_, newTab) => setTab(newTab), variant: "fullWidth", sx: { flexShrink: 0 }, children: [props.mode !== "search" && _jsx(Tab, { icon: _jsx(Edit, {}), label: getLocalizedString("Manual"), value: "manual" }), _jsx(Tab, { icon: _jsx(TapAndPlay, {}), label: getLocalizedString("Scanner"), value: "scanner" }), _jsx(Tab, { icon: _jsx(QrCodeScanner, {}), label: getLocalizedString("Camera"), value: "camera" })] }), tab === "camera" && (_jsx(Box, { sx: { flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }, children: _jsx(BarcodeScanner, { onRead: (element) => handleElementAdd(element, "camera-barcode") }) })), tab === "manual" && (_jsx(Box, { sx: { p: 2 }, children: _jsx(AddElementManualForm, { onAdd: (element) => handleElementAdd(element, "manual"), allowEmptyElement: props.allowEmptyElement }) })), tab === "scanner" && (_jsx(Box, { sx: { flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }, children: _jsx(AddElementHIDScanner, { onScan: (element) => handleElementAdd(element, element.startsWith(Giai.BARCODE_PREFIX) ? "hid-barcode" : "hid-rfid") }) })), _jsxs(Box, { sx: { flex: "3 1 14rem", overflow: "auto" }, children: [props.mode === "multi" && (_jsx(Alert, { icon: false, severity: "info", sx: { justifyContent: "center", py: 0, position: "sticky", top: 0, zIndex: 1 }, slotProps: {
75
+ }, children: _jsxs(Box, { sx: { display: "flex", flexDirection: "column", maxHeight: "100%", overflow: "hidden", flexGrow: 1 }, children: [_jsxs(Tabs, { value: tab, onChange: (_, newTab) => setTab(newTab), variant: "fullWidth", sx: { flexShrink: 0 }, children: [props.mode !== "search" && _jsx(Tab, { icon: _jsx(Edit, {}), label: getLocalizedString("Manual"), value: "manual" }), _jsx(Tab, { icon: _jsx(TapAndPlay, {}), label: getLocalizedString("Scanner"), value: "scanner" }), _jsx(Tab, { icon: _jsx(QrCodeScanner, {}), label: getLocalizedString("Camera"), value: "camera" })] }), tab === "camera" && (_jsx(Box, { sx: { flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }, children: _jsx(BarcodeScanner, { decoder: decoder, actions: scannerActions, onRead: (element) => handleElementAdd(element, "camera-barcode") }) })), tab === "manual" && (_jsx(Box, { sx: { p: 2 }, children: _jsx(AddElementManualForm, { onAdd: (element) => handleElementAdd(element, "manual"), allowEmptyElement: props.allowEmptyElement }) })), tab === "scanner" && (_jsx(Box, { sx: { flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }, children: _jsx(AddElementHIDScanner, { onScan: (element) => handleElementAdd(element, element.startsWith(Giai.BARCODE_PREFIX) ? "hid-barcode" : "hid-rfid") }) })), _jsxs(Box, { sx: { flex: "3 1 14rem", overflow: "auto" }, children: [props.mode === "multi" && (_jsx(Alert, { icon: false, severity: "info", sx: { justifyContent: "center", py: 0, position: "sticky", top: 0, zIndex: 1 }, slotProps: {
76
76
  message: { sx: { py: 0.5 } },
77
77
  }, children: localize `${elements.length} elements selected` })), _jsx(List, { disablePadding: true, children: elements.map(({ element }) => (_jsx(ListItem, { "data-elementid": element.ElementID, secondaryAction: _jsx(Button, { color: "error", variant: "outlined", onClick: () => {
78
78
  setElements((current) => props.mode === "multi" ? current.filter((e) => e.element.ElementID !== element.ElementID) : []);
package/es/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export { AppMenu, type AppMenuArticle, type AppMenuCategory, AppMenuColorScheme, AppMenuFavoriteButton, type AppMenuFavoriteButtonProps, AppMenuHeader, type AppMenuHeaderProps, type AppMenuLink, type AppMenuLinkGroup, AppMenuList, type AppMenuListProps, type AppMenuProps, AppMenuRail, type AppMenuRailProps, type AppMenuSelection, AppMenuToggle, type AppMenuToggleProps, type AppMenuUser, AppMenuUserMenu, type AppMenuUserMenuProps, createDeveloperCategories, defaultUserMenuItems, type DeveloperCategoryOptions, useServiceWorkerUpdate, } from "./chrome/AppMenu/index.js";
2
- export { AppShell, type AppShellProps } from "./chrome/AppShell/index.js";
1
+ export { AppShell, type AppShellProps, hasSiteChrome } from "./chrome/AppShell/index.js";
3
2
  export { Checkbox, type CheckboxProps } from "./components/Checkbox/index.js";
4
3
  export { COLOR_SCHEME_CHANGE_EVENT, type ColorSchemePreference, getColorSchemePreference, setColorSchemePreference, useColorSchemePreference, } from "./colorScheme.js";
5
4
  export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
@@ -9,10 +8,10 @@ export * from "./components/ImageEditor/index.js";
9
8
  export { ChipListInput, type ChipListInputProps, FilterBuilder, type FilterBuilderProps, FilterEditor, type FilterEditorProps, type FilterEditorSize, FilterGroupEditor, type FilterGroupEditorProps, FilterNameDialog, type FilterNameDialogProps, FilterRow, type FilterRowProps, FilterShareDialog, type FilterShareDialogProps, FilterStringField, type FilterStringFieldProps, FilterValueEditor, type FilterValueEditorProps, type FilterValueOption, type GetFieldOptions, type SavedFilterSelection, type SavedFilterValues, SavedFilterTree, type SavedFilterTreeProps, } from "./filter/index.js";
10
9
  export { Card, LinkedList, LinkedListItem } from "./components/LinkedCardList/index.js";
11
10
  export { MergeProgressDialog, type MergeProgressDialogProps } from "./components/MergeProgressDialog/index.js";
12
- export { ReportLauncher, type ReportLauncherProps, type ReportLauncherTab, ReportParameterField, ReportParameters, type ReportParametersProps, } from "./report/index.js";
11
+ export { type OpenReportOptions, openReport } from "./chrome/openReport.js";
13
12
  export { BannerImage as PageBannerImage, type BannerImageProps, PageBanner, type PageBannerProps, Tab as PageBannerTab, TabList as PageBannerTabList, type TabListProps as PageBannerTabListProps, type TabProps as PageBannerTabProps, Title as PageBannerTitle, type TitleProps as PageBannerTitleProps, } from "./components/PageBanner/index.js";
14
13
  export { Portal } from "./components/Portal/index.js";
15
- export { ToolbarBreadcrumbs, ToolbarPortal, type BreadcrumbItem, type ToolbarBreadcrumbsProps, type ToolbarPortalProps, type ToolbarPortalSlot, } from "./components/Toolbar/index.js";
14
+ export { ToolbarBreadcrumbs, ToolbarDrawerToggle, ToolbarPortal, type BreadcrumbItem, type ToolbarBreadcrumbsProps, type ToolbarDrawerToggleProps, type ToolbarPortalProps, } from "./components/Toolbar/index.js";
16
15
  export { ProgressBar } from "./components/ProgressBar/index.js";
17
16
  export { Sidebar, type SidebarProps } from "./components/Sidebar/index.js";
18
17
  export { Spinner, type SpinnerProps } from "./components/Spinner/index.js";
package/es/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export { AppMenu, AppMenuColorScheme, AppMenuFavoriteButton, AppMenuHeader, AppMenuList, AppMenuRail, AppMenuToggle, AppMenuUserMenu, createDeveloperCategories, defaultUserMenuItems, useServiceWorkerUpdate, } from "./chrome/AppMenu/index.js";
2
- export { AppShell } from "./chrome/AppShell/index.js";
1
+ // The app menu and the rest of the site chrome live in @olenbetong/synergi-chrome,
2
+ // loaded once per page by the site template rather than bundled into every app.
3
+ export { AppShell, hasSiteChrome } from "./chrome/AppShell/index.js";
3
4
  export { Checkbox } from "./components/Checkbox/index.js";
4
5
  export { COLOR_SCHEME_CHANGE_EVENT, getColorSchemePreference, setColorSchemePreference, useColorSchemePreference, } from "./colorScheme.js";
5
6
  export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
@@ -9,14 +10,14 @@ export * from "./components/ImageEditor/index.js";
9
10
  export { ChipListInput, FilterBuilder, FilterEditor, FilterGroupEditor, FilterNameDialog, FilterRow, FilterShareDialog, FilterStringField, FilterValueEditor, SavedFilterTree, } from "./filter/index.js";
10
11
  export { Card, LinkedList, LinkedListItem } from "./components/LinkedCardList/index.js";
11
12
  export { MergeProgressDialog } from "./components/MergeProgressDialog/index.js";
12
- export { ReportLauncher, ReportParameterField, ReportParameters, } from "./report/index.js";
13
+ export { openReport } from "./chrome/openReport.js";
13
14
  export { BannerImage as PageBannerImage, PageBanner, Tab as PageBannerTab, TabList as PageBannerTabList, Title as PageBannerTitle, } from "./components/PageBanner/index.js";
14
15
  // PdfViewer is intentionally not re-exported here. It references the pdf.js worker
15
16
  // with `new URL(..., import.meta.url)`, which makes bundlers emit the 1.2 MB worker
16
17
  // asset for every app that touches this barrel, even when no PDF is ever rendered.
17
18
  // Import it from "@olenbetong/synergi-react/pdf" instead.
18
19
  export { Portal } from "./components/Portal/index.js";
19
- export { ToolbarBreadcrumbs, ToolbarPortal, } from "./components/Toolbar/index.js";
20
+ export { ToolbarBreadcrumbs, ToolbarDrawerToggle, ToolbarPortal, } from "./components/Toolbar/index.js";
20
21
  export { ProgressBar } from "./components/ProgressBar/index.js";
21
22
  export { Sidebar } from "./components/Sidebar/index.js";
22
23
  export { Spinner } from "./components/Spinner/index.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/synergi-react",
3
- "version": "3.2.2",
3
+ "version": "4.0.0",
4
4
  "description": "Standalone React component for SynergiWeb and Partner Portal",
5
5
  "type": "module",
6
6
  "exports": {
@@ -40,7 +40,6 @@
40
40
  "@mui/icons-material": "9.4.0",
41
41
  "@mui/material": "9.4.0",
42
42
  "clsx": "^2.1.1",
43
- "dynamsoft-javascript-barcode": "6.5.4",
44
43
  "filepond": "^4.32.12",
45
44
  "filepond-plugin-file-poster": "^2.5.2",
46
45
  "filepond-plugin-image-exif-orientation": "^1.0.11",
@@ -54,11 +53,12 @@
54
53
  "react": "19.3.0",
55
54
  "react-dom": "19.3.0",
56
55
  "react-pdf": "^10.5.0",
57
- "@olenbetong/appframe-core": "2.13.1",
58
- "@olenbetong/appframe-data": "1.7.1",
59
- "@olenbetong/appframe-mui": "7.0.2",
60
- "@olenbetong/appframe-react": "2.2.0",
61
- "@olenbetong/appframe-ds": "1.0.2"
56
+ "zxing-wasm": "3.1.4",
57
+ "@olenbetong/appframe-core": "2.14.0",
58
+ "@olenbetong/appframe-ds": "1.0.3",
59
+ "@olenbetong/appframe-data": "1.7.2",
60
+ "@olenbetong/appframe-mui": "7.0.3",
61
+ "@olenbetong/appframe-react": "2.2.1"
62
62
  },
63
63
  "repository": {
64
64
  "type": "git",
@@ -74,10 +74,11 @@
74
74
  "devDependencies": {
75
75
  "@digdir/designsystemet-react": "1.21.1",
76
76
  "@navikt/aksel-icons": "8.16.2",
77
- "@testing-library/jest-dom": "^7.0.1",
78
77
  "@testing-library/dom": "^10.4.1",
78
+ "@testing-library/jest-dom": "^7.0.1",
79
79
  "@testing-library/react": "16.3.3",
80
80
  "@testing-library/user-event": "^14.6.7",
81
+ "dynamsoft-javascript-barcode": "6.5.4",
81
82
  "happy-dom": "20.14.5",
82
83
  "replace-in-files": "^3.0.0"
83
84
  },
@@ -1,98 +1,18 @@
1
- import { getLocalizedString } from "@olenbetong/appframe-core";
2
1
  import { AppErrorBoundary } from "@olenbetong/appframe-ds";
3
- import { type ReactNode, useCallback, useMemo, useState } from "react";
4
- import { createPortal } from "react-dom";
5
-
6
- import { AppMenu, type AppMenuArticle } from "../AppMenu/AppMenu.js";
7
- import { AppMenuToggle } from "../AppMenu/AppMenuToggle.js";
8
- import type { AppMenuUser } from "../AppMenu/AppMenuUserMenu.js";
9
- import { createDeveloperCategories } from "../AppMenu/developerCategories.js";
10
- import { useServiceWorkerUpdate } from "../AppMenu/useServiceWorkerUpdate.js";
11
-
12
- const hostName = globalThis.af?.article?.hostName ?? globalThis.location?.hostname ?? "";
13
-
14
- /*
15
- * `aviw_WebShared_Articles` stores every published version of an article as its
16
- * own row, and rows for all sites share the view. Without the host name filter
17
- * and `ArticleVersion IS NULL` (which keeps only the development row, i.e. the
18
- * canonical article) every app shows up once per published version.
19
- */
20
- const menuArticlesWhereClause = [
21
- `HostName = '${hostName.replace(/'/g, "''")}'`,
22
- "ArticleVersion IS NULL",
23
- "LastPublished IS NOT NULL",
24
- "Authenticated = 1",
25
- "ListOnFrontPage = 1",
26
- "SysApp = 0",
27
- "HideFromNav = 0",
28
- "Hidden = 0",
29
- "ISNULL(ParentArticleId, '') <> 'news'",
30
- ].join(" AND ");
31
-
32
- // Created once — shared across all AppShell instances on a page.
33
- const dsMenuArticles = af.data.generateApiDataObject<AppMenuArticle>({
34
- resource: "aviw_WebShared_Articles",
35
- id: "dsMenuArticles",
36
- allowUpdate: false,
37
- allowInsert: false,
38
- allowDelete: false,
39
- dynamicLoading: false,
40
- fields: [
41
- { name: "ArticleId", type: "string", nullable: false },
42
- { name: "Title", type: "string", nullable: true },
43
- { name: "MenuGroup", type: "string", nullable: true },
44
- { name: "Path", type: "string", nullable: true },
45
- { name: "IsFavorite", type: "boolean", nullable: true },
46
- ],
47
- parameters: {
48
- maxRecords: -1,
49
- whereClause: menuArticlesWhereClause,
50
- sortOrder: [{ MenuGroup: af.data.SortOrder.Asc }, { Title: af.data.SortOrder.Asc }],
51
- },
52
- });
53
-
54
- // Toggles the current user's favorite state for an article.
55
- const procSetArticleFavorite = new af.ProcedureAPI<{ HostName: string; ArticleID: string; Favorite: boolean }, unknown>(
56
- {
57
- procedureId: "astp_WebShared_SetArticleFavorite",
58
- parameters: [
59
- { name: "HostName", type: "string", required: true, hasDefault: false },
60
- { name: "ArticleID", type: "string", required: true, hasDefault: false },
61
- { name: "Favorite", type: "boolean", required: false, hasDefault: true },
62
- ],
63
- timeout: 30000,
64
- },
65
- );
66
-
67
- // The current user's employee record, used for the photo and full name.
68
- const dsAppMenuUser = af.data.generateApiDataObject<AppMenuUser>({
69
- resource: "aviw_Personnel_Employees_Lookup",
70
- id: "dsAppMenuUser",
71
- allowUpdate: false,
72
- allowInsert: false,
73
- allowDelete: false,
74
- dynamicLoading: false,
75
- fields: [
76
- { name: "PrimKey", type: "string", nullable: false },
77
- { name: "PersonID", type: "string", nullable: false },
78
- { name: "FirstName", type: "string", nullable: true },
79
- { name: "LastName", type: "string", nullable: true },
80
- { name: "Fullname", type: "string", nullable: true },
81
- { name: "ImageHash", type: "number", nullable: true },
82
- ],
83
- parameters: {
84
- maxRecords: 1,
85
- // Resolved server side so it doesn't depend on the session being hydrated.
86
- whereClause: "PersonID = SUSER_SNAME()",
87
- },
88
- });
2
+ import type { ReactNode } from "react";
89
3
 
90
4
  export type AppShellProps = {
91
5
  children: ReactNode;
92
6
  };
93
7
 
94
8
  /**
95
- * Standard Synergi app chrome: error boundary, app menu and the toolbar toggle.
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`.
96
16
  *
97
17
  * This component is Designsystemet-only. Apps that still render MUI components
98
18
  * should additionally wrap it in `MuiThemeProvider` from
@@ -100,51 +20,10 @@ export type AppShellProps = {
100
20
  * tokens into a MUI theme.
101
21
  */
102
22
  export function AppShell({ children }: AppShellProps) {
103
- const [isAppMenuOpen, setIsAppMenuOpen] = useState(false);
104
- const { isUpdateAvailable, installUpdate } = useServiceWorkerUpdate();
105
-
106
- // The developer tools are only reachable for developers, so hide them for
107
- // everyone else instead of showing links that all return 403.
108
- const categories = useMemo(() => (globalThis.af?.userSession?.isDeveloper ? createDeveloperCategories() : []), []);
109
-
110
- // The portal isn't listed with the apps, so link to it from the menu itself
111
- // unless that's the article we're already on.
112
- const homeLink = useMemo(() => {
113
- const articleId = (globalThis.af?.article?.id ?? "").replace(/\.\d+$/, "");
114
- return articleId === "portal" ? undefined : { label: getLocalizedString("Front page"), href: "/portal" };
115
- }, []);
116
-
117
- const toggleFavorite = useCallback(async (articleId: string, favorite: boolean) => {
118
- await procSetArticleFavorite.execute({ HostName: hostName, ArticleID: articleId, Favorite: favorite });
119
- }, []);
120
-
121
- const appMenuSlot = document.getElementById("ob-toolbar-app-menu");
23
+ return <AppErrorBoundary>{children}</AppErrorBoundary>;
24
+ }
122
25
 
123
- return (
124
- <AppErrorBoundary>
125
- {appMenuSlot &&
126
- createPortal(
127
- <AppMenuToggle
128
- open={isAppMenuOpen}
129
- hasUpdate={isUpdateAvailable}
130
- aria-controls="ob-app-menu"
131
- onClick={() => setIsAppMenuOpen((open) => !open)}
132
- />,
133
- appMenuSlot,
134
- )}
135
- <AppMenu
136
- id="ob-app-menu"
137
- dataObject={dsMenuArticles}
138
- userDataObject={dsAppMenuUser}
139
- categories={categories}
140
- homeLink={homeLink}
141
- onToggleFavorite={toggleFavorite}
142
- hasUpdate={isUpdateAvailable}
143
- onInstallUpdate={installUpdate}
144
- open={isAppMenuOpen}
145
- onClose={() => setIsAppMenuOpen(false)}
146
- />
147
- {children}
148
- </AppErrorBoundary>
149
- );
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;
150
29
  }
@@ -0,0 +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
+ }
@@ -5,10 +5,10 @@ import { useCallback, useEffect, useState } from "react";
5
5
  *
6
6
  * The preference lives in the `ob-color-scheme` cookie so the article template
7
7
  * can read it server side and render `data-color-scheme` on `<html>` and
8
- * `<body>` before the first paint. The site script for the 2026 template
9
- * (`ob.2026.application.min.js`) owns the same cookie for the toolbar user menu
10
- * toggle, so both write the cookie, apply the attributes, and dispatch
11
- * `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
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
12
  */
13
13
 
14
14
  export type ColorSchemePreference = "auto" | "light" | "dark";
@@ -1,33 +1,83 @@
1
1
  import "./Toolbar.css";
2
2
 
3
+ import { MenuHamburgerIcon } from "@navikt/aksel-icons";
4
+ import { getLocalizedString } from "@olenbetong/appframe-core";
3
5
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
4
6
  import { createPortal } from "react-dom";
5
7
  import { Link, type To } from "react-router";
6
8
 
7
- /**
8
- * The named regions of the site toolbar an app can render into.
9
+ /*
10
+ * The site template (`ob.2026.application`) renders the toolbar and leaves two regions to the
11
+ * app. Both are filled through portals, so the app's React tree (router, contexts, state) is
12
+ * preserved inside them:
13
+ *
14
+ * - the app region (`#ob-toolbar-app`): breadcrumbs first, then any per-app controls;
15
+ * - the drawer slot (`#ob-toolbar-drawer`) at the far left of the toolbar, reserved for the
16
+ * toggle of the app's navigation drawer — the same edge the drawer slides in from.
9
17
  *
10
- * `menu-toggle` sits at the very start of the toolbar, before the logo: it is where an app that
11
- * has a navigation drawer of its own hangs the button that opens it. That belongs on the same
12
- * edge as the drawer it controls — a toggle in `actions`, at the opposite end of the toolbar,
13
- * reads as unrelated to the panel that slides in on the left.
18
+ * Everything else in the toolbar (brand, Apps button, user menu) is the site's, rendered by the
19
+ * chrome bundle. The phase 1 template rendered separate slots instead; those ids are kept as
20
+ * fallbacks until every site runs the current template.
14
21
  */
15
- export type ToolbarPortalSlot = "menu-toggle" | "breadcrumbs" | "search" | "actions";
22
+
23
+ const APP_REGION_IDS = ["ob-toolbar-app", "ob-toolbar-breadcrumbs"];
24
+ const DRAWER_SLOT_IDS = ["ob-toolbar-drawer", "ob-toolbar-menu-toggle"];
25
+
26
+ function findTarget(ids: string[]) {
27
+ if (typeof document === "undefined") return null;
28
+ for (let id of ids) {
29
+ let element = document.getElementById(id);
30
+ if (element) return element;
31
+ }
32
+ return null;
33
+ }
16
34
 
17
35
  export type ToolbarPortalProps = {
18
- slot: ToolbarPortalSlot;
19
36
  children: React.ReactNode;
20
37
  };
21
38
 
22
- export function ToolbarPortal({ slot, children }: ToolbarPortalProps) {
23
- // Target element IDs: ob-toolbar-menu-toggle, ob-toolbar-breadcrumbs, ob-toolbar-search,
24
- // ob-toolbar-actions. Older templates do not render every slot, so a missing one is not an
25
- // error — the app simply renders nothing there.
26
- const target = document.getElementById(`ob-toolbar-${slot}`);
39
+ /**
40
+ * Renders its children into the toolbar's app region. Render `ToolbarBreadcrumbs` before any
41
+ * other `ToolbarPortal`, since the region lays its children out in mount order with the first
42
+ * one taking the free space. Renders nothing on a template without a toolbar.
43
+ */
44
+ export function ToolbarPortal({ children }: ToolbarPortalProps) {
45
+ let target = findTarget(APP_REGION_IDS);
27
46
  if (!target) return null;
28
47
  return createPortal(children, target);
29
48
  }
30
49
 
50
+ export type ToolbarDrawerToggleProps = {
51
+ /** Whether the drawer is open; sets `aria-expanded`. */
52
+ open: boolean;
53
+ onToggle: () => void;
54
+ /** Accessible name. Defaults to the localized "Toggle menu". */
55
+ label?: string;
56
+ };
57
+
58
+ /**
59
+ * The hamburger button for the app's navigation drawer, rendered into the toolbar's drawer slot.
60
+ * Styled by the site stylesheet (`.ob-toolbar__icon-button`) so it inherits the toolbar's
61
+ * contrast colour on every brand. Renders nothing on a template without a toolbar.
62
+ */
63
+ export function ToolbarDrawerToggle({ open, onToggle, label }: ToolbarDrawerToggleProps) {
64
+ let target = findTarget(DRAWER_SLOT_IDS);
65
+ if (!target) return null;
66
+
67
+ return createPortal(
68
+ <button
69
+ type="button"
70
+ className="ob-toolbar__icon-button"
71
+ aria-label={label ?? getLocalizedString("Toggle menu")}
72
+ aria-expanded={open}
73
+ onClick={onToggle}
74
+ >
75
+ <MenuHamburgerIcon aria-hidden fontSize="1.5rem" />
76
+ </button>,
77
+ target,
78
+ );
79
+ }
80
+
31
81
  export type BreadcrumbItem = {
32
82
  label: string;
33
83
  /**
@@ -152,9 +202,10 @@ function BreadcrumbsInner({ items }: ToolbarBreadcrumbsProps) {
152
202
  );
153
203
  }
154
204
 
205
+ /** The app's breadcrumb trail, rendered into the toolbar's app region. The last item is the current page. */
155
206
  export function ToolbarBreadcrumbs({ items }: ToolbarBreadcrumbsProps) {
156
207
  return (
157
- <ToolbarPortal slot="breadcrumbs">
208
+ <ToolbarPortal>
158
209
  <BreadcrumbsInner items={items} />
159
210
  </ToolbarPortal>
160
211
  );
@@ -1,8 +1,9 @@
1
1
  import SearchIcon from "@mui/icons-material/Search";
2
2
  import { IconButton, TextField } from "@mui/material";
3
3
  import { getLocalizedString } from "@olenbetong/appframe-core";
4
- import { type RefObject, useEffect, useImperativeHandle, useRef, useState } from "react";
4
+ import { type ReactNode, type RefObject, useEffect, useImperativeHandle, useRef, useState } from "react";
5
5
  import { type AddElement, ElementLookupDialog } from "./ElementLookupDialog";
6
+ import type { DecoderFactory } from "./ElementLookupDialog/BarcodeScanner";
6
7
 
7
8
  export type Element = {
8
9
  Domain: string;
@@ -25,6 +26,10 @@ export type ElementLookupProps = {
25
26
  openLookupDialogIcon?: boolean;
26
27
  onChange?: (value: Element | null) => void;
27
28
  onDialogChange?: (open: boolean) => void;
29
+ /** Engine for the camera tab of the lookup dialog. Defaults to zxing-wasm. */
30
+ decoder?: DecoderFactory;
31
+ /** Extra controls in the camera tab footer, e.g. an engine picker. */
32
+ scannerActions?: ReactNode;
28
33
  };
29
34
 
30
35
  export function ElementLookup({
@@ -35,6 +40,8 @@ export function ElementLookup({
35
40
  openLookupDialogIcon,
36
41
  onChange,
37
42
  onDialogChange,
43
+ decoder,
44
+ scannerActions,
38
45
  }: ElementLookupProps) {
39
46
  let initializedRef = useRef<boolean>(false);
40
47
 
@@ -42,7 +49,6 @@ export function ElementLookup({
42
49
  let [element, setElement] = useState<Element | null>(defaultValue ?? null);
43
50
  let elementValue = value === undefined ? element : value;
44
51
 
45
- // biome-ignore lint: intentionally skipping "value" dependency as this shouldn't run when "value" changes
46
52
  useEffect(() => {
47
53
  if (initializedRef.current) {
48
54
  return;
@@ -52,7 +58,7 @@ export function ElementLookup({
52
58
  setElement(defaultValue);
53
59
  initializedRef.current = true;
54
60
  }
55
- }, [defaultValue]);
61
+ }, [defaultValue]); // oxlint-disable-line react-hooks/exhaustive-deps (intentionally skipping "value" dependency as this shouldn't run when "value" changes)
56
62
 
57
63
  useImperativeHandle(ref, () => ({
58
64
  openDialog: () => setOpenElementLookupDialog(true),
@@ -64,10 +70,9 @@ export function ElementLookup({
64
70
  setElement(addElement.element);
65
71
  }
66
72
 
67
- // biome-ignore lint: only run when openElementLookupDialog changes
68
73
  useEffect(() => {
69
74
  onDialogChange?.(openElementLookupDialog);
70
- }, [openElementLookupDialog]);
75
+ }, [openElementLookupDialog]); // oxlint-disable-line react-hooks/exhaustive-deps (only run when openElementLookupDialog changes)
71
76
 
72
77
  return (
73
78
  <>
@@ -77,6 +82,8 @@ export function ElementLookup({
77
82
  onClose={() => setOpenElementLookupDialog(false)}
78
83
  onAdd={handleAddElement}
79
84
  allowEmptyElement={!elementIDRequired}
85
+ decoder={decoder}
86
+ scannerActions={scannerActions}
80
87
  />
81
88
 
82
89
  <input type="hidden" name="ProjectID" value={elementValue?.ProjectID ?? ""} />
@@ -0,0 +1,32 @@
1
+ export type DecodedPoint = { x: number; y: number };
2
+
3
+ export type DecodedBarcode = {
4
+ /** Decoded text. GS1 DataMatrix keeps the FNC1 separators as U+001D. */
5
+ text: string;
6
+ /** Corners of the symbol in frame pixel coordinates: top-left, top-right, bottom-right, bottom-left. */
7
+ corners: [DecodedPoint, DecodedPoint, DecodedPoint, DecodedPoint];
8
+ /** Engine-specific format name, when reported. */
9
+ format?: string;
10
+ };
11
+
12
+ /**
13
+ * A barcode decoding engine. `BarcodeScanner` owns the camera and the frame loop and only hands
14
+ * frames to the decoder, so any engine that can read a canvas or an image file can be plugged in.
15
+ */
16
+ export interface BarcodeDecoder {
17
+ /** Short identifier shown in the scanner UI, e.g. "zxing", "native" or "dbr". */
18
+ readonly name: string;
19
+ /** Decode one camera frame drawn on a canvas. The scanner never has more than one call in flight. */
20
+ decodeFrame(frame: HTMLCanvasElement): Promise<DecodedBarcode[]>;
21
+ /** Decode a still image, such as a photo upload. May use slower, more thorough settings. */
22
+ decodeImage(file: Blob): Promise<DecodedBarcode[]>;
23
+ /** Release engine resources. Called when the scanner unmounts. */
24
+ dispose?(): void;
25
+ }
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>;