@olenbetong/synergi-react 4.0.0 → 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.
Files changed (58) hide show
  1. package/es/components/DateNavigator/index.js +1 -1
  2. package/es/components/FilePond.js +1 -1
  3. package/es/components/ImageEditor/ImageEditor.js +1 -1
  4. package/es/components/ImageEditor/plugins/cropPlugin/CropOverlay.js +1 -1
  5. package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +1 -1
  6. package/es/components/ImageEditor/plugins/redactPlugin/RedactToolbar.js +1 -1
  7. package/es/components/ImageEditor/plugins/zoomPlugin/ZoomControls.js +1 -1
  8. package/es/components/MergeProgressDialog/index.js +1 -1
  9. package/es/components/Toolbar/index.js +1 -1
  10. package/es/elements/ElementDamage/DamageFormButtons.js +1 -1
  11. package/es/elements/ElementDamage/DescriptionInput.js +1 -1
  12. package/es/elements/ElementDamage/DuplicateDamage/DesktopView.js +1 -1
  13. package/es/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.js +1 -1
  14. package/es/elements/ElementDamage/DuplicateDamage/PhoneView.js +1 -1
  15. package/es/elements/ElementDamage/ElementNumberTextField.js +1 -1
  16. package/es/elements/ElementDamage/RegisterFix.js +1 -1
  17. package/es/elements/ElementDamage/SubmitButtons.js +1 -1
  18. package/es/elements/ElementDamage/TransportElementSelect.js +1 -1
  19. package/es/elements/ElementLookup.js +1 -1
  20. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.js +1 -1
  21. package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +1 -1
  22. package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.js +1 -1
  23. package/es/elements/ElementLookupDialog/HIDScanner/index.js +1 -1
  24. package/es/elements/ElementLookupDialog/Manual/ManualForm.js +1 -1
  25. package/es/elements/ElementLookupDialog/index.js +1 -1
  26. package/es/elements/ElementLookupDialog/utils/Giai.js +1 -1
  27. package/es/elements/ProjectSelect.js +1 -1
  28. package/es/i18n.d.ts +6 -0
  29. package/es/i18n.js +10 -0
  30. package/package.json +3 -3
  31. package/src/components/DateNavigator/index.tsx +1 -1
  32. package/src/components/FilePond.tsx +1 -1
  33. package/src/components/ImageEditor/ImageEditor.tsx +1 -1
  34. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +1 -1
  35. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +1 -1
  36. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +1 -1
  37. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +1 -1
  38. package/src/components/MergeProgressDialog/index.tsx +1 -1
  39. package/src/components/Toolbar/index.tsx +1 -1
  40. package/src/elements/ElementDamage/DamageFormButtons.tsx +1 -1
  41. package/src/elements/ElementDamage/DescriptionInput.tsx +1 -1
  42. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +1 -1
  43. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +1 -1
  44. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +1 -1
  45. package/src/elements/ElementDamage/ElementNumberTextField.tsx +1 -1
  46. package/src/elements/ElementDamage/RegisterFix.tsx +1 -1
  47. package/src/elements/ElementDamage/SubmitButtons.tsx +1 -1
  48. package/src/elements/ElementDamage/TransportElementSelect.tsx +1 -1
  49. package/src/elements/ElementLookup.tsx +1 -1
  50. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/native.ts +1 -1
  51. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +1 -1
  52. package/src/elements/ElementLookupDialog/BarcodeScanner/useScanner.ts +1 -1
  53. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +1 -1
  54. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +1 -1
  55. package/src/elements/ElementLookupDialog/index.tsx +1 -1
  56. package/src/elements/ElementLookupDialog/utils/Giai.ts +1 -1
  57. package/src/elements/ProjectSelect.tsx +1 -1
  58. package/src/i18n.ts +13 -0
@@ -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,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import "./Toolbar.css";
3
3
  import { MenuHamburgerIcon } from "@navikt/aksel-icons";
4
- import { getLocalizedString } from "@olenbetong/appframe-core";
5
4
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
6
5
  import { createPortal } from "react-dom";
7
6
  import { Link } from "react-router";
7
+ import { getLocalizedString } from "../../i18n.js";
8
8
  /*
9
9
  * The site template (`ob.2026.application`) renders the toolbar and leaves two regions to the
10
10
  * app. Both are filled through portals, so the app's React tree (router, contexts, state) is
@@ -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 "@olenbetong/appframe-core";
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 "@olenbetong/appframe-core";
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 "@olenbetong/appframe-core";
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,9 +1,9 @@
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";
6
+ import { getLocalizedString } from "../i18n.js";
7
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);
@@ -1,4 +1,4 @@
1
- import { getLocalizedString } from "@olenbetong/appframe-core";
1
+ import { getLocalizedString } from "../../../../i18n.js";
2
2
  const DATA_MATRIX = "data_matrix";
3
3
  function getNativeDetector() {
4
4
  return globalThis.BarcodeDetector;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import SwitchCameraOutlined from "@mui/icons-material/SwitchCameraOutlined";
3
3
  import { Box, IconButton, Typography } from "@mui/material";
4
- import { getLocalizedString } from "@olenbetong/appframe-core";
5
4
  import { useRef } from "react";
6
5
  import { ErrorIcon } from "./Error";
7
6
  import { useScanner } from "./useScanner";
7
+ import { getLocalizedString } from "../../../i18n.js";
8
8
  export { createDbrDecoder } from "./decoders/dbr";
9
9
  export { createNativeDecoder, isNativeDecoderAvailable } from "./decoders/native";
10
10
  export { createZxingDecoder } from "./decoders/zxing";
@@ -1,7 +1,7 @@
1
- import { getLocalizedString } from "@olenbetong/appframe-core";
2
1
  import { useEffect, useRef, useState } from "react";
3
2
  import { createZxingDecoder } from "./decoders/zxing";
4
3
  import { createDuplicateFilter } from "./duplicateFilter";
4
+ import { getLocalizedString } from "../../../i18n.js";
5
5
  /** Longest side of the frame handed to the decoder. Larger frames cost decode time without helping DataMatrix reads. */
6
6
  const MAX_FRAME_SIDE = 720;
7
7
  /** Minimum time between two decode attempts. */
@@ -1,9 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import "./index.css";
3
3
  import { Box, Button } from "@mui/material";
4
- import { getLocalizedString } from "@olenbetong/appframe-core";
5
4
  import { useEffect, useRef, useState } from "react";
6
5
  import { useHIDScanner } from "./useHIDScanner";
6
+ import { getLocalizedString } from "../../../i18n.js";
7
7
  export function AddElementHIDScanner({ onScan }) {
8
8
  let [enabled, setEnabled] = useState(false);
9
9
  let root = useRef(null);
@@ -1,10 +1,10 @@
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 { Alert, Button, TextField } from "@mui/material";
4
- import { getLocalizedString } from "@olenbetong/appframe-core";
5
4
  import { useId, useRef, useState } from "react";
6
5
  import { ProjectSelect } from "../../ProjectSelect";
7
6
  import { getElement } from "../getElement";
7
+ import { getLocalizedString } from "../../../i18n.js";
8
8
  const isElementsOnly = /^([a-z]{2,4}[\s]*[0-9]{4,8}[\s,]*)+$/i;
9
9
  const matchElements = /([a-z]{2,4}[\s]*[0-9]{4,8})/gi;
10
10
  export function AddElementManualForm({ onAdd, mode, defaultProject, allowEmptyElement = false, }) {
@@ -5,7 +5,6 @@ import Edit from "@mui/icons-material/Edit";
5
5
  import QrCodeScanner from "@mui/icons-material/QrCodeScanner";
6
6
  import TapAndPlay from "@mui/icons-material/TapAndPlay";
7
7
  import { Alert, Box, Button, DialogActions, List, ListItem, ListItemText, Tab, Tabs } from "@mui/material";
8
- import { getLocalizedString, localize } from "@olenbetong/appframe-core";
9
8
  import { ResponsiveDialog } from "@olenbetong/appframe-mui";
10
9
  import { useEffect, useState } from "react";
11
10
  import { flushSync } from "react-dom";
@@ -15,6 +14,7 @@ import { AddElementHIDScanner } from "./HIDScanner";
15
14
  import { AddElementManualForm } from "./Manual/ManualForm";
16
15
  import { useBeeper } from "./utils/beep";
17
16
  import Giai from "./utils/Giai";
17
+ import { getLocalizedString, localize } from "../../i18n.js";
18
18
  export function ElementLookupDialog(props) {
19
19
  let { open, onClose, initialTab, decoder, scannerActions } = props;
20
20
  let [tab, setTab] = useState("camera");
@@ -1,4 +1,4 @@
1
- import { getLocalizedString } from "@olenbetong/appframe-core";
1
+ import { getLocalizedString } from "../../../i18n.js";
2
2
  /**
3
3
  * GIAI-96 encoder and decoder as defined by the GS1 EPC Tag data standard
4
4
  */
@@ -1,10 +1,10 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Autocomplete, ListItem, ListItemText, TextField } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { useDataWithFilter, useDebounce } from "@olenbetong/appframe-react";
5
4
  import { useMemo, useRef, useState } from "react";
6
5
  import { dsProjects } from "./data/dsProjects";
7
6
  import { dsReportProjects } from "./data/dsReportProjects";
7
+ import { getLocalizedString } from "../i18n.js";
8
8
  export function ProjectSelect({ className, disabled, id, names, onChange, readOnly, required, defaultValue, value, label, sx, report, }) {
9
9
  let [selected, setSelected] = useState(defaultValue ?? null);
10
10
  let [query, setQuery] = useState("");
package/es/i18n.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare const PROJECT = "synergi-react";
2
+ export declare const getLocalizedString: {
3
+ (string: undefined | null): undefined | null;
4
+ (string: string): string;
5
+ (string: string, wait: true): Promise<string>;
6
+ }, localize: (stringParts: TemplateStringsArray, ...args: unknown[]) => string;
package/es/i18n.js ADDED
@@ -0,0 +1,10 @@
1
+ /*
2
+ * The package's strings live in their own globalization project, `synergi-react`, so one
3
+ * translation covers every app and the package can word a term its own way. The templates
4
+ * render the dictionary as af.i18n["synergi-react"]; on a page that does not (a legacy
5
+ * template) the localizer falls back to the article's strings, exactly as before. See
6
+ * `createLocalizer` in @olenbetong/appframe-core.
7
+ */
8
+ import { createLocalizer } from "@olenbetong/appframe-core";
9
+ export const PROJECT = "synergi-react";
10
+ export const { getLocalizedString, localize } = createLocalizer(PROJECT);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olenbetong/synergi-react",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Standalone React component for SynergiWeb and Partner Portal",
5
5
  "type": "module",
6
6
  "exports": {
@@ -55,10 +55,10 @@
55
55
  "react-pdf": "^10.5.0",
56
56
  "zxing-wasm": "3.1.4",
57
57
  "@olenbetong/appframe-core": "2.14.0",
58
- "@olenbetong/appframe-ds": "1.0.3",
59
58
  "@olenbetong/appframe-data": "1.7.2",
60
59
  "@olenbetong/appframe-mui": "7.0.3",
61
- "@olenbetong/appframe-react": "2.2.1"
60
+ "@olenbetong/appframe-react": "2.2.1",
61
+ "@olenbetong/appframe-ds": "1.1.0"
62
62
  },
63
63
  "repository": {
64
64
  "type": "git",
@@ -1,8 +1,8 @@
1
1
  import "./index.css";
2
2
 
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
 
7
7
  function getUiCulture() {
8
8
  return af?.userSession?.culture ?? "default";
@@ -2,7 +2,6 @@ import "filepond-plugin-file-poster/dist/filepond-plugin-file-poster.css";
2
2
  import "filepond-plugin-image-preview/dist/filepond-plugin-image-preview.css";
3
3
  import "filepond/dist/filepond.css";
4
4
 
5
- import { getLocalizedString } from "@olenbetong/appframe-core";
6
5
  import type { DataObject } from "@olenbetong/appframe-data";
7
6
  import { useData, useFetchData } from "@olenbetong/appframe-react";
8
7
 
@@ -21,6 +20,7 @@ import FilePondPluginImagePreview from "filepond-plugin-image-preview";
21
20
  import FilePondPluginImageResize from "filepond-plugin-image-resize";
22
21
  import FilePondPluginImageTransform from "filepond-plugin-image-transform";
23
22
  import { type RefObject, useEffect, useMemo, useRef } from "react";
23
+ import { getLocalizedString } from "../i18n.js";
24
24
 
25
25
  export { FileStatus, registerPlugin };
26
26
 
@@ -1,6 +1,5 @@
1
1
  import { Button, Spinner, Tooltip } from "@digdir/designsystemet-react";
2
2
  import { ArrowCirclepathIcon, ArrowLeftIcon, ArrowRedoIcon, ArrowUndoIcon, CheckmarkIcon } from "@navikt/aksel-icons";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
5
4
 
6
5
  import "./ImageEditor.css";
@@ -9,6 +8,7 @@ import type { ActionPlugin, ActionRegistry, EditAction, Plugin, ToolPlugin, View
9
8
  import { useActiveTool } from "./useActiveTool.js";
10
9
  import { useImageHistory } from "./useImageHistory.js";
11
10
  import { useIsSmall } from "./useIsSmall.js";
11
+ import { getLocalizedString } from "../../i18n.js";
12
12
 
13
13
  export type ImageEditorRef = {
14
14
  /** Returns the current edited blob, or null if no edits have been applied since the last source image. */
@@ -1,11 +1,11 @@
1
1
  import { Paragraph, Spinner } from "@digdir/designsystemet-react";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
 
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
 
10
10
  /** Canvas-area overlay for the crop tool. Reads all state from CropContext. */
11
11
  export function CropOverlay() {
@@ -1,8 +1,8 @@
1
1
  import { Button, Spinner } from "@digdir/designsystemet-react";
2
2
  import { CheckmarkIcon, ExpandIcon, SquareIcon, XMarkIcon } from "@navikt/aksel-icons";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
 
5
4
  import { useCropContext } from "./CropContext.js";
5
+ import { getLocalizedString } from "../../../../i18n.js";
6
6
 
7
7
  /** Toolbar shown while the crop tool is active. Reads state from CropContext. */
8
8
  export function CropToolbar() {
@@ -1,9 +1,9 @@
1
1
  import { Button, Spinner } from "@digdir/designsystemet-react";
2
2
  import { CheckmarkIcon, EraserIcon, XMarkIcon } from "@navikt/aksel-icons";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { useState } from "react";
5
4
 
6
5
  import { useRedactContext } from "./RedactContext.js";
6
+ import { getLocalizedString } from "../../../../i18n.js";
7
7
 
8
8
  /** Toolbar shown while the redact tool is active. Reads state from RedactContext. */
9
9
  export function RedactToolbar() {
@@ -1,7 +1,7 @@
1
1
  import { ShrinkIcon, ZoomMinusIcon, ZoomPlusIcon } from "@navikt/aksel-icons";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
  import { ResponsiveButton } from "../../ResponsiveButton.js";
4
3
  import { useZoom } from "./ZoomContext.js";
4
+ import { getLocalizedString } from "../../../../i18n.js";
5
5
 
6
6
  interface Props {
7
7
  disabled?: boolean;
@@ -1,7 +1,7 @@
1
1
  import { Box, Button, DialogActions, LinearProgress, Link, Typography } from "@mui/material";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
  import { ResponsiveDialog } from "@olenbetong/appframe-mui";
4
3
  import { useEffect, useRef, useState } from "react";
4
+ import { getLocalizedString } from "../../i18n.js";
5
5
 
6
6
  export type MergeProgressDialogProps = {
7
7
  open: boolean;
@@ -1,10 +1,10 @@
1
1
  import "./Toolbar.css";
2
2
 
3
3
  import { MenuHamburgerIcon } from "@navikt/aksel-icons";
4
- import { getLocalizedString } from "@olenbetong/appframe-core";
5
4
  import { useEffect, useLayoutEffect, useRef, useState } from "react";
6
5
  import { createPortal } from "react-dom";
7
6
  import { Link, type To } from "react-router";
7
+ import { getLocalizedString } from "../../i18n.js";
8
8
 
9
9
  /*
10
10
  * The site template (`ob.2026.application`) renders the toolbar and leaves two regions to the
@@ -1,6 +1,6 @@
1
1
  import Add from "@mui/icons-material/Add";
2
2
  import { Button } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
+ import { getLocalizedString } from "../../i18n.js";
4
4
 
5
5
  export type DamageFormButtonsProps = {
6
6
  isEdit: boolean;
@@ -1,6 +1,6 @@
1
1
  import { Autocomplete, Button, TextField } from "@mui/material";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
  import { useEffect, useRef, useState } from "react";
3
+ import { getLocalizedString } from "../../i18n.js";
4
4
 
5
5
  export type DescriptionInputType = {
6
6
  Description?: string | null;
@@ -1,7 +1,7 @@
1
1
  import { Grid, type GridSize, Typography } from "@mui/material";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
  import { Link } from "@olenbetong/appframe-mui";
4
3
  import type { DamagesRecord } from "../../data";
4
+ import { getLocalizedString } from "../../../i18n.js";
5
5
 
6
6
  type SummaryItemProps = {
7
7
  col: GridSize;
@@ -1,10 +1,10 @@
1
1
  import Add from "@mui/icons-material/Add";
2
2
  import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Grid, useMediaQuery } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { theme } from "@olenbetong/appframe-mui";
5
4
  import type { DamagesRecord } from "../../data";
6
5
  import { ElementDamagesHeader, ElementDamagesItem } from "./DesktopView";
7
6
  import { DuplicatePhoneViewItem } from "./PhoneView";
7
+ import { getLocalizedString } from "../../../i18n.js";
8
8
 
9
9
  type DuplicateElementDamageDialogProps = {
10
10
  open: boolean;
@@ -1,6 +1,6 @@
1
1
  import { Card, CardContent, Typography } from "@mui/material";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
  import type { DamagesRecord } from "../../data";
3
+ import { getLocalizedString } from "../../../i18n.js";
4
4
 
5
5
  type DuplicatePhoneViewItemProps = {
6
6
  record: DamagesRecord;
@@ -1,6 +1,6 @@
1
1
  import { type SxProps, TextField, type Theme } from "@mui/material";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
  import { useEffect, useState } from "react";
3
+ import { getLocalizedString } from "../../i18n.js";
4
4
 
5
5
  type ElementNumberTextFieldProps = {
6
6
  value?: string | null;
@@ -1,10 +1,10 @@
1
1
  import CheckIcon from "@mui/icons-material/Check";
2
2
  import { Button, Checkbox, FormControlLabel, Typography } from "@mui/material";
3
- import { getLocalizedString, localize } from "@olenbetong/appframe-core";
4
3
 
5
4
  import { useEffect, useRef, useState } from "react";
6
5
 
7
6
  import { procApproveDamage } from "../data";
7
+ import { getLocalizedString, localize } from "../../i18n.js";
8
8
 
9
9
  const formatter = new Intl.DateTimeFormat(af.userSession.culture, {
10
10
  day: "numeric",
@@ -1,6 +1,6 @@
1
1
  import Add from "@mui/icons-material/Add";
2
2
  import { Box, Button, type SxProps, type Theme } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
+ import { getLocalizedString } from "../../i18n.js";
4
4
 
5
5
  type SubmitButtonsProps = {
6
6
  /**
@@ -1,8 +1,8 @@
1
1
  import DropDownArrowIcon from "@mui/icons-material/KeyboardArrowDown";
2
2
  import { Button, ListItemText, Menu, MenuItem } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { useState } from "react";
5
4
  import type { TransportElementsRecord } from "../data/dsTransportElements.js";
5
+ import { getLocalizedString } from "../../i18n.js";
6
6
 
7
7
  export type TransportElementSelectProps = {
8
8
  elements: TransportElementsRecord[];
@@ -1,9 +1,9 @@
1
1
  import SearchIcon from "@mui/icons-material/Search";
2
2
  import { IconButton, TextField } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { type ReactNode, type RefObject, useEffect, useImperativeHandle, useRef, useState } from "react";
5
4
  import { type AddElement, ElementLookupDialog } from "./ElementLookupDialog";
6
5
  import type { DecoderFactory } from "./ElementLookupDialog/BarcodeScanner";
6
+ import { getLocalizedString } from "../i18n.js";
7
7
 
8
8
  export type Element = {
9
9
  Domain: string;
@@ -1,5 +1,5 @@
1
- import { getLocalizedString } from "@olenbetong/appframe-core";
2
1
  import type { BarcodeDecoder, DecodedBarcode, DecoderFactory } from "../decoder";
2
+ import { getLocalizedString } from "../../../../i18n.js";
3
3
 
4
4
  /**
5
5
  * Minimal typing of the Barcode Detection API. It is not part of the TypeScript DOM lib because
@@ -1,10 +1,10 @@
1
1
  import SwitchCameraOutlined from "@mui/icons-material/SwitchCameraOutlined";
2
2
  import { Box, IconButton, type SxProps, Typography } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { type ReactNode, useRef } from "react";
5
4
  import type { DecoderFactory } from "./decoder";
6
5
  import { ErrorIcon } from "./Error";
7
6
  import { useScanner } from "./useScanner";
7
+ import { getLocalizedString } from "../../../i18n.js";
8
8
 
9
9
  export type { BarcodeDecoder, DecodedBarcode, DecodedPoint, DecoderFactory } from "./decoder";
10
10
  export { createDbrDecoder, type DbrDecoderOptions } from "./decoders/dbr";
@@ -1,8 +1,8 @@
1
- import { getLocalizedString } from "@olenbetong/appframe-core";
2
1
  import { type RefObject, useEffect, useRef, useState } from "react";
3
2
  import type { BarcodeDecoder, DecodedBarcode, DecoderFactory } from "./decoder";
4
3
  import { createZxingDecoder } from "./decoders/zxing";
5
4
  import { createDuplicateFilter } from "./duplicateFilter";
5
+ import { getLocalizedString } from "../../../i18n.js";
6
6
 
7
7
  export type ScannerError = { message: string; icon: "unsupported" | "camera" | "generic" };
8
8
 
@@ -1,11 +1,11 @@
1
1
  import "./index.css";
2
2
 
3
3
  import { Box, Button } from "@mui/material";
4
- import { getLocalizedString } from "@olenbetong/appframe-core";
5
4
 
6
5
  import { useEffect, useRef, useState } from "react";
7
6
 
8
7
  import { useHIDScanner } from "./useHIDScanner";
8
+ import { getLocalizedString } from "../../../i18n.js";
9
9
 
10
10
  export function AddElementHIDScanner({ onScan }: { onScan: (id: string) => void }) {
11
11
  let [enabled, setEnabled] = useState(false);
@@ -1,10 +1,10 @@
1
1
  import Add from "@mui/icons-material/Add";
2
2
  import { Alert, Button, TextField } from "@mui/material";
3
- import { getLocalizedString } from "@olenbetong/appframe-core";
4
3
  import { useId, useRef, useState } from "react";
5
4
  import type { ProjectsRecord } from "../../data/dsProjects";
6
5
  import { ProjectSelect } from "../../ProjectSelect";
7
6
  import { type ElementDetails, getElement } from "../getElement";
7
+ import { getLocalizedString } from "../../../i18n.js";
8
8
 
9
9
  const isElementsOnly = /^([a-z]{2,4}[\s]*[0-9]{4,8}[\s,]*)+$/i;
10
10
  const matchElements = /([a-z]{2,4}[\s]*[0-9]{4,8})/gi;
@@ -4,7 +4,6 @@ import Edit from "@mui/icons-material/Edit";
4
4
  import QrCodeScanner from "@mui/icons-material/QrCodeScanner";
5
5
  import TapAndPlay from "@mui/icons-material/TapAndPlay";
6
6
  import { Alert, Box, Button, DialogActions, List, ListItem, ListItemText, Tab, Tabs } from "@mui/material";
7
- import { getLocalizedString, localize } from "@olenbetong/appframe-core";
8
7
  import { ResponsiveDialog } from "@olenbetong/appframe-mui";
9
8
  import { type ReactNode, useEffect, useState } from "react";
10
9
  import { flushSync } from "react-dom";
@@ -14,6 +13,7 @@ import { AddElementHIDScanner } from "./HIDScanner";
14
13
  import { AddElementManualForm } from "./Manual/ManualForm";
15
14
  import { useBeeper } from "./utils/beep";
16
15
  import Giai from "./utils/Giai";
16
+ import { getLocalizedString, localize } from "../../i18n.js";
17
17
 
18
18
  export type AddElement = {
19
19
  element: ElementDetails;
@@ -1,4 +1,4 @@
1
- import { getLocalizedString } from "@olenbetong/appframe-core";
1
+ import { getLocalizedString } from "../../../i18n.js";
2
2
 
3
3
  export type GiaiProps = {
4
4
  assetReference: string | number | bigint;
@@ -1,9 +1,9 @@
1
1
  import { Autocomplete, ListItem, ListItemText, type SxProps, TextField, type Theme } from "@mui/material";
2
- import { getLocalizedString } from "@olenbetong/appframe-core";
3
2
  import { useDataWithFilter, useDebounce } from "@olenbetong/appframe-react";
4
3
  import { useMemo, useRef, useState } from "react";
5
4
  import { dsProjects, type ProjectsRecord } from "./data/dsProjects";
6
5
  import { dsReportProjects } from "./data/dsReportProjects";
6
+ import { getLocalizedString } from "../i18n.js";
7
7
 
8
8
  type ProjectSelectProps = {
9
9
  className?: string;
package/src/i18n.ts ADDED
@@ -0,0 +1,13 @@
1
+ /*
2
+ * The package's strings live in their own globalization project, `synergi-react`, so one
3
+ * translation covers every app and the package can word a term its own way. The templates
4
+ * render the dictionary as af.i18n["synergi-react"]; on a page that does not (a legacy
5
+ * template) the localizer falls back to the article's strings, exactly as before. See
6
+ * `createLocalizer` in @olenbetong/appframe-core.
7
+ */
8
+
9
+ import { createLocalizer } from "@olenbetong/appframe-core";
10
+
11
+ export const PROJECT = "synergi-react";
12
+
13
+ export const { getLocalizedString, localize } = createLocalizer(PROJECT);