@olenbetong/synergi-react 4.2.3 → 4.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/package.json +7 -7
  2. package/src/chrome/AppShell/index.tsx +29 -29
  3. package/src/chrome/openReport.ts +34 -34
  4. package/src/colorScheme.ts +81 -81
  5. package/src/components/DateNavigator/index.tsx +186 -186
  6. package/src/components/FilePond.tsx +312 -312
  7. package/src/components/ImageEditor/ImageEditor.tsx +348 -348
  8. package/src/components/ImageEditor/index.ts +9 -9
  9. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  10. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
  11. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
  12. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  13. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  14. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  15. package/src/components/ImageEditor/useActiveTool.ts +21 -21
  16. package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
  17. package/src/components/ImageEditor/useImageHistory.ts +197 -197
  18. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  19. package/src/components/LinkedCardList/index.scss +95 -95
  20. package/src/components/MergeProgressDialog/index.tsx +249 -249
  21. package/src/components/PageBanner/index.tsx +80 -80
  22. package/src/components/PdfViewer/PdfViewer.tsx +158 -158
  23. package/src/components/ProgressBar/index.scss +96 -96
  24. package/src/components/SplitContainer/index.tsx +333 -333
  25. package/src/components/Toolbar/index.tsx +232 -232
  26. package/src/designsystemet-web-types.d.ts +24 -24
  27. package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
  28. package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
  29. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
  30. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
  31. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
  32. package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
  33. package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
  34. package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
  35. package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
  36. package/src/elements/ElementLookup.tsx +123 -123
  37. package/src/elements/ElementLookupDialog/BarcodeScanner/decoder.ts +32 -32
  38. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.ts +118 -118
  39. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/native.ts +103 -103
  40. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +95 -95
  41. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders.test.ts +118 -118
  42. package/src/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.ts +21 -21
  43. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +90 -90
  44. package/src/elements/ElementLookupDialog/BarcodeScanner/useScanner.ts +280 -280
  45. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  46. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  47. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  48. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  49. package/src/elements/ProjectSelect.tsx +130 -130
  50. package/src/elements/index.ts +15 -15
  51. package/src/filter/index.ts +34 -34
  52. package/src/i18n.ts +13 -13
  53. package/src/index.ts +77 -77
  54. package/src/mui/MuiThemeProvider.tsx +174 -174
  55. package/src/mui/index.ts +1 -1
  56. package/src/test/setup.ts +8 -8
@@ -1,9 +1,9 @@
1
- export { defaultPlugins, defaultViewPlugin } from "./defaultPlugins.js";
2
- export type { ImageEditorRef } from "./ImageEditor.js";
3
- export { ImageEditor } from "./ImageEditor.js";
4
- export { cropPlugin } from "./plugins/cropPlugin/index.js";
5
- export { redactPlugin } from "./plugins/redactPlugin/index.js";
6
- export { zoomPlugin } from "./plugins/zoomPlugin/index.js";
7
- export { rotateCcwPlugin, rotateCwPlugin } from "./plugins/rotatePlugin.js";
8
- export type { ActionPlugin, EditAction, Plugin, ToolPlugin, ViewPlugin } from "./types.js";
9
- export { configureOpenCV, DEFAULT_OPENCV_URLS, loadOpenCV } from "./useOpenCV.js";
1
+ export { defaultPlugins, defaultViewPlugin } from "./defaultPlugins.js";
2
+ export type { ImageEditorRef } from "./ImageEditor.js";
3
+ export { ImageEditor } from "./ImageEditor.js";
4
+ export { cropPlugin } from "./plugins/cropPlugin/index.js";
5
+ export { redactPlugin } from "./plugins/redactPlugin/index.js";
6
+ export { zoomPlugin } from "./plugins/zoomPlugin/index.js";
7
+ export { rotateCcwPlugin, rotateCwPlugin } from "./plugins/rotatePlugin.js";
8
+ export type { ActionPlugin, EditAction, Plugin, ToolPlugin, ViewPlugin } from "./types.js";
9
+ export { configureOpenCV, DEFAULT_OPENCV_URLS, loadOpenCV } from "./useOpenCV.js";
@@ -1,165 +1,165 @@
1
- import { Paragraph, Spinner } from "@digdir/designsystemet-react";
2
-
3
- import { CropCanvas } from "../../CropCanvas.js";
4
- import { DragHandle } from "../../DragHandle.js";
5
- import { EdgeHandle } from "../../EdgeHandle.js";
6
- import { useZoomLevel } from "../zoomPlugin/ZoomContext.js";
7
- import { useCropContext } from "./CropContext.js";
8
- import { getLocalizedString } from "../../../../i18n.js";
9
-
10
- /** Canvas-area overlay for the crop tool. Reads all state from CropContext. */
11
- export function CropOverlay() {
12
- let {
13
- imageUrl,
14
- activeCorners,
15
- mode,
16
- hasSelection,
17
- scale,
18
- displaySize,
19
- canvasRef,
20
- cvReady,
21
- cvError,
22
- cropping,
23
- error,
24
- handleCanvasReady,
25
- updateCorner,
26
- startRectDraw,
27
- updateRectDraw,
28
- finishRectDraw,
29
- } = useCropContext();
30
-
31
- let zoom = useZoomLevel();
32
- let showHandles = mode === "corners" && displaySize.width > 0;
33
-
34
- function pointerPosition(e: React.PointerEvent<HTMLDivElement>) {
35
- // getBoundingClientRect() is screen-space (affected by the zoom transform),
36
- // so divide by zoom to get back to the CSS-pixel space the tool expects.
37
- let rect = e.currentTarget.getBoundingClientRect();
38
- return { x: (e.clientX - rect.left) / zoom, y: (e.clientY - rect.top) / zoom };
39
- }
40
-
41
- function onPointerDown(e: React.PointerEvent<HTMLDivElement>) {
42
- e.currentTarget.setPointerCapture(e.pointerId);
43
- let { x, y } = pointerPosition(e);
44
- startRectDraw(x, y);
45
- }
46
-
47
- function onPointerMove(e: React.PointerEvent<HTMLDivElement>) {
48
- if (!(e.buttons & 1)) return;
49
- let { x, y } = pointerPosition(e);
50
- updateRectDraw(x, y);
51
- }
52
-
53
- return (
54
- <div className="crop-root">
55
- <div className="crop-inner">
56
- <CropCanvas ref={canvasRef} imageUrl={imageUrl} corners={activeCorners} onReady={handleCanvasReady} />
57
-
58
- {mode === "rect" && displaySize.width > 0 && (
59
- <div
60
- role="application"
61
- aria-label={getLocalizedString("Drag to draw a rectangle to crop to")}
62
- className="crop-draw-surface"
63
- onPointerDown={onPointerDown}
64
- onPointerMove={onPointerMove}
65
- onPointerUp={finishRectDraw}
66
- onPointerCancel={finishRectDraw}
67
- />
68
- )}
69
-
70
- {showHandles &&
71
- activeCorners.map((corner, i) => (
72
- <DragHandle
73
- key={i}
74
- x={corner.x * scale}
75
- y={corner.y * scale}
76
- onChange={(x, y) => updateCorner(i, x, y)}
77
- containerWidth={displaySize.width}
78
- containerHeight={displaySize.height}
79
- />
80
- ))}
81
-
82
- {showHandles &&
83
- (() => {
84
- let [tl, tr, br, bl] = activeCorners;
85
- let s = scale;
86
- return (
87
- <>
88
- {/* Top edge — moves TL (0) and TR (1) */}
89
- <EdgeHandle
90
- x={((tl.x + tr.x) / 2) * s}
91
- y={((tl.y + tr.y) / 2) * s}
92
- axis="y"
93
- onChange={(dx, dy) => {
94
- updateCorner(0, tl.x * s + dx, tl.y * s + dy);
95
- updateCorner(1, tr.x * s + dx, tr.y * s + dy);
96
- }}
97
- />
98
- {/* Right edge — moves TR (1) and BR (2) */}
99
- <EdgeHandle
100
- x={((tr.x + br.x) / 2) * s}
101
- y={((tr.y + br.y) / 2) * s}
102
- axis="x"
103
- onChange={(dx, dy) => {
104
- updateCorner(1, tr.x * s + dx, tr.y * s + dy);
105
- updateCorner(2, br.x * s + dx, br.y * s + dy);
106
- }}
107
- />
108
- {/* Bottom edge — moves BR (2) and BL (3) */}
109
- <EdgeHandle
110
- x={((br.x + bl.x) / 2) * s}
111
- y={((br.y + bl.y) / 2) * s}
112
- axis="y"
113
- onChange={(dx, dy) => {
114
- updateCorner(2, br.x * s + dx, br.y * s + dy);
115
- updateCorner(3, bl.x * s + dx, bl.y * s + dy);
116
- }}
117
- />
118
- {/* Left edge — moves BL (3) and TL (0) */}
119
- <EdgeHandle
120
- x={((bl.x + tl.x) / 2) * s}
121
- y={((bl.y + tl.y) / 2) * s}
122
- axis="x"
123
- onChange={(dx, dy) => {
124
- updateCorner(3, bl.x * s + dx, bl.y * s + dy);
125
- updateCorner(0, tl.x * s + dx, tl.y * s + dy);
126
- }}
127
- />
128
- </>
129
- );
130
- })()}
131
- </div>
132
-
133
- {/* Status line. OpenCV only powers the border suggestion, so a load failure is
134
- informational — cropping stays available either way. */}
135
- {cropping ? (
136
- <div className="crop-loading">
137
- <Spinner aria-hidden data-size="xs" />
138
- </div>
139
- ) : error ? (
140
- <div className="crop-loading">
141
- <Paragraph data-size="sm">{error}</Paragraph>
142
- </div>
143
- ) : mode === "rect" ? (
144
- <div className="crop-loading">
145
- <Paragraph data-size="sm">
146
- {hasSelection
147
- ? getLocalizedString("Release to use this rectangle")
148
- : getLocalizedString("Drag to draw a rectangle to crop to")}
149
- </Paragraph>
150
- </div>
151
- ) : !cvReady && !cvError ? (
152
- <div className="crop-loading">
153
- <Spinner aria-hidden data-size="xs" />
154
- <Paragraph data-size="sm">{getLocalizedString("Detecting borders…")}</Paragraph>
155
- </div>
156
- ) : cvError ? (
157
- <div className="crop-loading">
158
- <Paragraph data-size="sm">
159
- {getLocalizedString("Automatic border detection is unavailable. Adjust the selection manually.")}
160
- </Paragraph>
161
- </div>
162
- ) : null}
163
- </div>
164
- );
165
- }
1
+ import { Paragraph, Spinner } from "@digdir/designsystemet-react";
2
+
3
+ import { CropCanvas } from "../../CropCanvas.js";
4
+ import { DragHandle } from "../../DragHandle.js";
5
+ import { EdgeHandle } from "../../EdgeHandle.js";
6
+ import { useZoomLevel } from "../zoomPlugin/ZoomContext.js";
7
+ import { useCropContext } from "./CropContext.js";
8
+ import { getLocalizedString } from "../../../../i18n.js";
9
+
10
+ /** Canvas-area overlay for the crop tool. Reads all state from CropContext. */
11
+ export function CropOverlay() {
12
+ let {
13
+ imageUrl,
14
+ activeCorners,
15
+ mode,
16
+ hasSelection,
17
+ scale,
18
+ displaySize,
19
+ canvasRef,
20
+ cvReady,
21
+ cvError,
22
+ cropping,
23
+ error,
24
+ handleCanvasReady,
25
+ updateCorner,
26
+ startRectDraw,
27
+ updateRectDraw,
28
+ finishRectDraw,
29
+ } = useCropContext();
30
+
31
+ let zoom = useZoomLevel();
32
+ let showHandles = mode === "corners" && displaySize.width > 0;
33
+
34
+ function pointerPosition(e: React.PointerEvent<HTMLDivElement>) {
35
+ // getBoundingClientRect() is screen-space (affected by the zoom transform),
36
+ // so divide by zoom to get back to the CSS-pixel space the tool expects.
37
+ let rect = e.currentTarget.getBoundingClientRect();
38
+ return { x: (e.clientX - rect.left) / zoom, y: (e.clientY - rect.top) / zoom };
39
+ }
40
+
41
+ function onPointerDown(e: React.PointerEvent<HTMLDivElement>) {
42
+ e.currentTarget.setPointerCapture(e.pointerId);
43
+ let { x, y } = pointerPosition(e);
44
+ startRectDraw(x, y);
45
+ }
46
+
47
+ function onPointerMove(e: React.PointerEvent<HTMLDivElement>) {
48
+ if (!(e.buttons & 1)) return;
49
+ let { x, y } = pointerPosition(e);
50
+ updateRectDraw(x, y);
51
+ }
52
+
53
+ return (
54
+ <div className="crop-root">
55
+ <div className="crop-inner">
56
+ <CropCanvas ref={canvasRef} imageUrl={imageUrl} corners={activeCorners} onReady={handleCanvasReady} />
57
+
58
+ {mode === "rect" && displaySize.width > 0 && (
59
+ <div
60
+ role="application"
61
+ aria-label={getLocalizedString("Drag to draw a rectangle to crop to")}
62
+ className="crop-draw-surface"
63
+ onPointerDown={onPointerDown}
64
+ onPointerMove={onPointerMove}
65
+ onPointerUp={finishRectDraw}
66
+ onPointerCancel={finishRectDraw}
67
+ />
68
+ )}
69
+
70
+ {showHandles &&
71
+ activeCorners.map((corner, i) => (
72
+ <DragHandle
73
+ key={i}
74
+ x={corner.x * scale}
75
+ y={corner.y * scale}
76
+ onChange={(x, y) => updateCorner(i, x, y)}
77
+ containerWidth={displaySize.width}
78
+ containerHeight={displaySize.height}
79
+ />
80
+ ))}
81
+
82
+ {showHandles &&
83
+ (() => {
84
+ let [tl, tr, br, bl] = activeCorners;
85
+ let s = scale;
86
+ return (
87
+ <>
88
+ {/* Top edge — moves TL (0) and TR (1) */}
89
+ <EdgeHandle
90
+ x={((tl.x + tr.x) / 2) * s}
91
+ y={((tl.y + tr.y) / 2) * s}
92
+ axis="y"
93
+ onChange={(dx, dy) => {
94
+ updateCorner(0, tl.x * s + dx, tl.y * s + dy);
95
+ updateCorner(1, tr.x * s + dx, tr.y * s + dy);
96
+ }}
97
+ />
98
+ {/* Right edge — moves TR (1) and BR (2) */}
99
+ <EdgeHandle
100
+ x={((tr.x + br.x) / 2) * s}
101
+ y={((tr.y + br.y) / 2) * s}
102
+ axis="x"
103
+ onChange={(dx, dy) => {
104
+ updateCorner(1, tr.x * s + dx, tr.y * s + dy);
105
+ updateCorner(2, br.x * s + dx, br.y * s + dy);
106
+ }}
107
+ />
108
+ {/* Bottom edge — moves BR (2) and BL (3) */}
109
+ <EdgeHandle
110
+ x={((br.x + bl.x) / 2) * s}
111
+ y={((br.y + bl.y) / 2) * s}
112
+ axis="y"
113
+ onChange={(dx, dy) => {
114
+ updateCorner(2, br.x * s + dx, br.y * s + dy);
115
+ updateCorner(3, bl.x * s + dx, bl.y * s + dy);
116
+ }}
117
+ />
118
+ {/* Left edge — moves BL (3) and TL (0) */}
119
+ <EdgeHandle
120
+ x={((bl.x + tl.x) / 2) * s}
121
+ y={((bl.y + tl.y) / 2) * s}
122
+ axis="x"
123
+ onChange={(dx, dy) => {
124
+ updateCorner(3, bl.x * s + dx, bl.y * s + dy);
125
+ updateCorner(0, tl.x * s + dx, tl.y * s + dy);
126
+ }}
127
+ />
128
+ </>
129
+ );
130
+ })()}
131
+ </div>
132
+
133
+ {/* Status line. OpenCV only powers the border suggestion, so a load failure is
134
+ informational — cropping stays available either way. */}
135
+ {cropping ? (
136
+ <div className="crop-loading">
137
+ <Spinner aria-hidden data-size="xs" />
138
+ </div>
139
+ ) : error ? (
140
+ <div className="crop-loading">
141
+ <Paragraph data-size="sm">{error}</Paragraph>
142
+ </div>
143
+ ) : mode === "rect" ? (
144
+ <div className="crop-loading">
145
+ <Paragraph data-size="sm">
146
+ {hasSelection
147
+ ? getLocalizedString("Release to use this rectangle")
148
+ : getLocalizedString("Drag to draw a rectangle to crop to")}
149
+ </Paragraph>
150
+ </div>
151
+ ) : !cvReady && !cvError ? (
152
+ <div className="crop-loading">
153
+ <Spinner aria-hidden data-size="xs" />
154
+ <Paragraph data-size="sm">{getLocalizedString("Detecting borders…")}</Paragraph>
155
+ </div>
156
+ ) : cvError ? (
157
+ <div className="crop-loading">
158
+ <Paragraph data-size="sm">
159
+ {getLocalizedString("Automatic border detection is unavailable. Adjust the selection manually.")}
160
+ </Paragraph>
161
+ </div>
162
+ ) : null}
163
+ </div>
164
+ );
165
+ }
@@ -1,48 +1,48 @@
1
- import { Button, Spinner } from "@digdir/designsystemet-react";
2
- import { CheckmarkIcon, ExpandIcon, SquareIcon, XMarkIcon } from "@navikt/aksel-icons";
3
-
4
- import { useCropContext } from "./CropContext.js";
5
- import { getLocalizedString } from "../../../../i18n.js";
6
-
7
- /** Toolbar shown while the crop tool is active. Reads state from CropContext. */
8
- export function CropToolbar() {
9
- let { applyCrop, cropping, mode, hasSelection, startRectMode, cancelRectMode, onApply, onCancel } = useCropContext();
10
- let inRectMode = mode === "rect";
11
-
12
- async function handleApply() {
13
- let result = await applyCrop();
14
- if (result) onApply(result.blob, result.actions);
15
- }
16
-
17
- return (
18
- <>
19
- <div className="image-editor__toolbar-group">
20
- <Button variant="tertiary" data-size="sm" onClick={onCancel} disabled={cropping}>
21
- <XMarkIcon aria-hidden />
22
- {getLocalizedString("Cancel")}
23
- </Button>
24
- </div>
25
- <div className="image-editor__toolbar-group">
26
- <Button
27
- variant="tertiary"
28
- data-size="sm"
29
- aria-pressed={inRectMode}
30
- onClick={inRectMode ? cancelRectMode : startRectMode}
31
- disabled={cropping}
32
- >
33
- {inRectMode ? <ExpandIcon aria-hidden /> : <SquareIcon aria-hidden />}
34
- {inRectMode ? getLocalizedString("Adjust corners") : getLocalizedString("Draw rectangle")}
35
- </Button>
36
- <Button
37
- variant="primary"
38
- data-size="sm"
39
- onClick={handleApply}
40
- disabled={cropping || inRectMode || !hasSelection}
41
- >
42
- {cropping ? <Spinner aria-hidden data-size="xs" /> : <CheckmarkIcon aria-hidden />}
43
- {getLocalizedString("Apply crop")}
44
- </Button>
45
- </div>
46
- </>
47
- );
48
- }
1
+ import { Button, Spinner } from "@digdir/designsystemet-react";
2
+ import { CheckmarkIcon, ExpandIcon, SquareIcon, XMarkIcon } from "@navikt/aksel-icons";
3
+
4
+ import { useCropContext } from "./CropContext.js";
5
+ import { getLocalizedString } from "../../../../i18n.js";
6
+
7
+ /** Toolbar shown while the crop tool is active. Reads state from CropContext. */
8
+ export function CropToolbar() {
9
+ let { applyCrop, cropping, mode, hasSelection, startRectMode, cancelRectMode, onApply, onCancel } = useCropContext();
10
+ let inRectMode = mode === "rect";
11
+
12
+ async function handleApply() {
13
+ let result = await applyCrop();
14
+ if (result) onApply(result.blob, result.actions);
15
+ }
16
+
17
+ return (
18
+ <>
19
+ <div className="image-editor__toolbar-group">
20
+ <Button variant="tertiary" data-size="sm" onClick={onCancel} disabled={cropping}>
21
+ <XMarkIcon aria-hidden />
22
+ {getLocalizedString("Cancel")}
23
+ </Button>
24
+ </div>
25
+ <div className="image-editor__toolbar-group">
26
+ <Button
27
+ variant="tertiary"
28
+ data-size="sm"
29
+ aria-pressed={inRectMode}
30
+ onClick={inRectMode ? cancelRectMode : startRectMode}
31
+ disabled={cropping}
32
+ >
33
+ {inRectMode ? <ExpandIcon aria-hidden /> : <SquareIcon aria-hidden />}
34
+ {inRectMode ? getLocalizedString("Adjust corners") : getLocalizedString("Draw rectangle")}
35
+ </Button>
36
+ <Button
37
+ variant="primary"
38
+ data-size="sm"
39
+ onClick={handleApply}
40
+ disabled={cropping || inRectMode || !hasSelection}
41
+ >
42
+ {cropping ? <Spinner aria-hidden data-size="xs" /> : <CheckmarkIcon aria-hidden />}
43
+ {getLocalizedString("Apply crop")}
44
+ </Button>
45
+ </div>
46
+ </>
47
+ );
48
+ }