@olenbetong/synergi-react 4.3.0 → 5.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 (81) hide show
  1. package/dist/styles/styles.css +1 -1
  2. package/dist/styles/styles.css.map +1 -1
  3. package/es/components/CodeEditor/CodeEditor.css +6 -6
  4. package/es/components/MergeProgressDialog/MergeProgressDialogDs.d.ts +7 -0
  5. package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +20 -0
  6. package/es/components/MergeProgressDialog/index.d.ts +3 -8
  7. package/es/components/MergeProgressDialog/index.js +4 -113
  8. package/es/components/MergeProgressDialog/useMergeJob.d.ts +36 -0
  9. package/es/components/MergeProgressDialog/useMergeJob.js +141 -0
  10. package/es/components/ProgressBar/index.css +1 -1
  11. package/es/components/Toolbar/Toolbar.css +137 -137
  12. package/es/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
  13. package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.d.ts +2 -2
  14. package/es/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.js +1 -2
  15. package/es/elements/ElementLookupDialog/BarcodeScanner/Error.js +3 -29
  16. package/es/elements/ElementLookupDialog/BarcodeScanner/index.d.ts +1 -0
  17. package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +3 -28
  18. package/es/index.css +1 -1
  19. package/es/index.d.ts +2 -1
  20. package/es/index.js +2 -1
  21. package/es/mui/index.d.ts +1 -0
  22. package/es/mui/index.js +1 -0
  23. package/es/test/setup.d.ts +5 -0
  24. package/package.json +21 -14
  25. package/src/chrome/AppShell/index.tsx +29 -29
  26. package/src/chrome/openReport.ts +34 -34
  27. package/src/colorScheme.ts +125 -125
  28. package/src/components/CodeEditor/CodeEditor.css +6 -6
  29. package/src/components/CodeEditor/CodeEditor.tsx +173 -173
  30. package/src/components/CodeEditor/index.ts +1 -1
  31. package/src/components/DateNavigator/index.tsx +186 -186
  32. package/src/components/FilePond.tsx +312 -312
  33. package/src/components/ImageEditor/ImageEditor.tsx +348 -348
  34. package/src/components/ImageEditor/index.ts +9 -9
  35. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  36. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
  37. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
  38. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  39. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  40. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  41. package/src/components/ImageEditor/useActiveTool.ts +21 -21
  42. package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
  43. package/src/components/ImageEditor/useImageHistory.ts +197 -197
  44. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  45. package/src/components/LinkedCardList/index.scss +95 -95
  46. package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +91 -0
  47. package/src/components/MergeProgressDialog/index.tsx +5 -136
  48. package/src/components/MergeProgressDialog/useMergeJob.ts +169 -0
  49. package/src/components/PageBanner/index.tsx +80 -80
  50. package/src/components/PdfViewer/PdfViewer.tsx +158 -158
  51. package/src/components/ProgressBar/index.scss +23 -54
  52. package/src/components/SplitContainer/index.tsx +333 -333
  53. package/src/components/Toolbar/Toolbar.css +137 -137
  54. package/src/components/Toolbar/index.tsx +265 -265
  55. package/src/designsystemet-web-types.d.ts +24 -24
  56. package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
  57. package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
  58. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
  59. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
  60. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
  61. package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
  62. package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
  63. package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
  64. package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
  65. package/src/elements/ElementLookup.tsx +123 -123
  66. package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +81 -0
  67. package/src/elements/ElementLookupDialog/BarcodeScanner/DeadIcon.tsx +4 -4
  68. package/src/elements/ElementLookupDialog/BarcodeScanner/Error.tsx +7 -36
  69. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +20 -49
  70. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  71. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  72. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  73. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  74. package/src/elements/ProjectSelect.tsx +130 -130
  75. package/src/elements/index.ts +15 -15
  76. package/src/filter/index.ts +34 -34
  77. package/src/i18n.ts +13 -13
  78. package/src/index.ts +5 -1
  79. package/src/mui/MuiThemeProvider.tsx +135 -135
  80. package/src/mui/index.ts +1 -0
  81. package/src/test/setup.ts +23 -8
@@ -1,197 +1,197 @@
1
- import { useEffect, useRef, useState } from "react";
2
-
3
- import type { ActionRegistry, EditAction } from "./types.js";
4
-
5
- interface HistoryState {
6
- past: EditAction[][];
7
- future: EditAction[][];
8
- }
9
-
10
- interface CurrentState {
11
- url: string;
12
- blob: Blob | null;
13
- /** True if `url` is an object URL we created and must eventually revoke. */
14
- generated: boolean;
15
- }
16
-
17
- export interface UseImageHistoryResult {
18
- currentImageUrl: string;
19
- currentBlob: Blob | null;
20
- /** Synchronous read of the current image URL — valid immediately after `applyActions`. */
21
- getCurrentImageUrl: () => string;
22
- /** Synchronous read of the current blob — valid immediately after `applyActions`. */
23
- getCurrentBlob: () => Blob | null;
24
- canUndo: boolean;
25
- canRedo: boolean;
26
- /** True while an async replay (undo/redo) is in progress. */
27
- replaying: boolean;
28
- /** Applies a new blob to the current state and records it in history. Returns the new object URL. */
29
- applyActions: (blob: Blob, actions: EditAction[]) => string;
30
- undo: () => void;
31
- redo: () => void;
32
- reset: () => void;
33
- }
34
-
35
- /**
36
- * Manages undo/redo history for the image editor using action replay.
37
- *
38
- * Only action lists are stored — no intermediate blobs. Undo/redo replays
39
- * all remaining actions from the source image, keeping memory usage minimal
40
- * regardless of history depth. Only one blob is in memory at a time.
41
- */
42
- export function useImageHistory(sourceUrl: string, registry: ActionRegistry): UseImageHistoryResult {
43
- let [history, setHistory] = useState<HistoryState>({ past: [], future: [] });
44
- let [current, setCurrent] = useState<CurrentState>({ url: sourceUrl, blob: null, generated: false });
45
- let [replaying, setReplaying] = useState(false);
46
-
47
- let historyRef = useRef(history);
48
- historyRef.current = history;
49
- // Written synchronously by `replaceCurrent` so imperative callers can read the current
50
- // image/blob before React has committed the corresponding render.
51
- let currentRef = useRef(current);
52
- let isReplaying = useRef(false);
53
- let replayAbort = useRef<AbortController | null>(null);
54
-
55
- function replaceCurrent(next: CurrentState) {
56
- let prev = currentRef.current;
57
- if (prev.generated && prev.url !== next.url) URL.revokeObjectURL(prev.url);
58
- currentRef.current = next;
59
- setCurrent(next);
60
- }
61
-
62
- // When source changes (e.g. component remount with new image), reset fully.
63
- useEffect(() => {
64
- replayAbort.current?.abort();
65
- isReplaying.current = false;
66
- setReplaying(false);
67
- replaceCurrent({ url: sourceUrl, blob: null, generated: false });
68
- setHistory({ past: [], future: [] });
69
- }, [sourceUrl]);
70
-
71
- useEffect(() => {
72
- return () => {
73
- if (currentRef.current.generated) URL.revokeObjectURL(currentRef.current.url);
74
- replayAbort.current?.abort();
75
- };
76
- }, []);
77
-
78
- function applyActions(blob: Blob, actions: EditAction[]) {
79
- // A direct apply always takes priority — abort any in-flight replay.
80
- replayAbort.current?.abort();
81
- isReplaying.current = false;
82
- setReplaying(false);
83
-
84
- let newUrl = URL.createObjectURL(blob);
85
- replaceCurrent({ url: newUrl, blob, generated: true });
86
- setHistory((prev) => ({ past: [...prev.past, actions], future: [] }));
87
-
88
- return newUrl;
89
- }
90
-
91
- async function doReplay(newPast: EditAction[][], newFuture: EditAction[][]) {
92
- replayAbort.current?.abort();
93
- let abort = new AbortController();
94
- replayAbort.current = abort;
95
- isReplaying.current = true;
96
- setReplaying(true);
97
-
98
- try {
99
- let result = await replayAll(sourceUrl, newPast, registry, abort.signal);
100
- if (abort.signal.aborted) return;
101
-
102
- if (result) {
103
- replaceCurrent({ url: result.url, blob: result.blob, generated: true });
104
- } else {
105
- replaceCurrent({ url: sourceUrl, blob: null, generated: false });
106
- }
107
- setHistory({ past: newPast, future: newFuture });
108
- } finally {
109
- if (!abort.signal.aborted) {
110
- isReplaying.current = false;
111
- setReplaying(false);
112
- }
113
- }
114
- }
115
-
116
- function undo() {
117
- if (isReplaying.current) return;
118
- let { past, future } = historyRef.current;
119
- if (past.length === 0) return;
120
- doReplay(past.slice(0, -1), [past.at(-1)!, ...future]);
121
- }
122
-
123
- function redo() {
124
- if (isReplaying.current) return;
125
- let { past, future } = historyRef.current;
126
- if (future.length === 0) return;
127
- doReplay([...past, future[0]], future.slice(1));
128
- }
129
-
130
- function reset() {
131
- replayAbort.current?.abort();
132
- isReplaying.current = false;
133
- setReplaying(false);
134
- replaceCurrent({ url: sourceUrl, blob: null, generated: false });
135
- setHistory({ past: [], future: [] });
136
- }
137
-
138
- return {
139
- currentImageUrl: current.url,
140
- currentBlob: current.blob,
141
- getCurrentImageUrl: () => currentRef.current.url,
142
- getCurrentBlob: () => currentRef.current.blob,
143
- canUndo: history.past.length > 0,
144
- canRedo: history.future.length > 0,
145
- replaying,
146
- applyActions,
147
- undo,
148
- redo,
149
- reset,
150
- };
151
- }
152
-
153
- /**
154
- * Replays a sequence of action groups from a source URL.
155
- * Intermediate object URLs are revoked as soon as a new step succeeds.
156
- * Returns the final `{ url, blob }` or `null` if there were no actions.
157
- */
158
- async function replayAll(
159
- sourceUrl: string,
160
- actionGroups: EditAction[][],
161
- registry: ActionRegistry,
162
- signal: AbortSignal,
163
- ): Promise<{ url: string; blob: Blob } | null> {
164
- let prevUrl = sourceUrl;
165
- let prevGenerated = false;
166
- let lastBlob: Blob | null = null;
167
-
168
- for (let group of actionGroups) {
169
- for (let action of group) {
170
- if (signal.aborted) {
171
- if (prevGenerated) URL.revokeObjectURL(prevUrl);
172
- return null;
173
- }
174
-
175
- let apply = registry.get(action.type);
176
- if (!apply) {
177
- console.warn(`[ImageHistory] No replay handler for action type "${action.type}" — skipping`);
178
- continue;
179
- }
180
-
181
- let blob = await apply(prevUrl, action.params);
182
-
183
- if (signal.aborted) {
184
- if (prevGenerated) URL.revokeObjectURL(prevUrl);
185
- return null;
186
- }
187
-
188
- if (prevGenerated) URL.revokeObjectURL(prevUrl);
189
- lastBlob = blob;
190
- prevUrl = URL.createObjectURL(blob);
191
- prevGenerated = true;
192
- }
193
- }
194
-
195
- if (!lastBlob || !prevGenerated) return null;
196
- return { url: prevUrl, blob: lastBlob };
197
- }
1
+ import { useEffect, useRef, useState } from "react";
2
+
3
+ import type { ActionRegistry, EditAction } from "./types.js";
4
+
5
+ interface HistoryState {
6
+ past: EditAction[][];
7
+ future: EditAction[][];
8
+ }
9
+
10
+ interface CurrentState {
11
+ url: string;
12
+ blob: Blob | null;
13
+ /** True if `url` is an object URL we created and must eventually revoke. */
14
+ generated: boolean;
15
+ }
16
+
17
+ export interface UseImageHistoryResult {
18
+ currentImageUrl: string;
19
+ currentBlob: Blob | null;
20
+ /** Synchronous read of the current image URL — valid immediately after `applyActions`. */
21
+ getCurrentImageUrl: () => string;
22
+ /** Synchronous read of the current blob — valid immediately after `applyActions`. */
23
+ getCurrentBlob: () => Blob | null;
24
+ canUndo: boolean;
25
+ canRedo: boolean;
26
+ /** True while an async replay (undo/redo) is in progress. */
27
+ replaying: boolean;
28
+ /** Applies a new blob to the current state and records it in history. Returns the new object URL. */
29
+ applyActions: (blob: Blob, actions: EditAction[]) => string;
30
+ undo: () => void;
31
+ redo: () => void;
32
+ reset: () => void;
33
+ }
34
+
35
+ /**
36
+ * Manages undo/redo history for the image editor using action replay.
37
+ *
38
+ * Only action lists are stored — no intermediate blobs. Undo/redo replays
39
+ * all remaining actions from the source image, keeping memory usage minimal
40
+ * regardless of history depth. Only one blob is in memory at a time.
41
+ */
42
+ export function useImageHistory(sourceUrl: string, registry: ActionRegistry): UseImageHistoryResult {
43
+ let [history, setHistory] = useState<HistoryState>({ past: [], future: [] });
44
+ let [current, setCurrent] = useState<CurrentState>({ url: sourceUrl, blob: null, generated: false });
45
+ let [replaying, setReplaying] = useState(false);
46
+
47
+ let historyRef = useRef(history);
48
+ historyRef.current = history;
49
+ // Written synchronously by `replaceCurrent` so imperative callers can read the current
50
+ // image/blob before React has committed the corresponding render.
51
+ let currentRef = useRef(current);
52
+ let isReplaying = useRef(false);
53
+ let replayAbort = useRef<AbortController | null>(null);
54
+
55
+ function replaceCurrent(next: CurrentState) {
56
+ let prev = currentRef.current;
57
+ if (prev.generated && prev.url !== next.url) URL.revokeObjectURL(prev.url);
58
+ currentRef.current = next;
59
+ setCurrent(next);
60
+ }
61
+
62
+ // When source changes (e.g. component remount with new image), reset fully.
63
+ useEffect(() => {
64
+ replayAbort.current?.abort();
65
+ isReplaying.current = false;
66
+ setReplaying(false);
67
+ replaceCurrent({ url: sourceUrl, blob: null, generated: false });
68
+ setHistory({ past: [], future: [] });
69
+ }, [sourceUrl]);
70
+
71
+ useEffect(() => {
72
+ return () => {
73
+ if (currentRef.current.generated) URL.revokeObjectURL(currentRef.current.url);
74
+ replayAbort.current?.abort();
75
+ };
76
+ }, []);
77
+
78
+ function applyActions(blob: Blob, actions: EditAction[]) {
79
+ // A direct apply always takes priority — abort any in-flight replay.
80
+ replayAbort.current?.abort();
81
+ isReplaying.current = false;
82
+ setReplaying(false);
83
+
84
+ let newUrl = URL.createObjectURL(blob);
85
+ replaceCurrent({ url: newUrl, blob, generated: true });
86
+ setHistory((prev) => ({ past: [...prev.past, actions], future: [] }));
87
+
88
+ return newUrl;
89
+ }
90
+
91
+ async function doReplay(newPast: EditAction[][], newFuture: EditAction[][]) {
92
+ replayAbort.current?.abort();
93
+ let abort = new AbortController();
94
+ replayAbort.current = abort;
95
+ isReplaying.current = true;
96
+ setReplaying(true);
97
+
98
+ try {
99
+ let result = await replayAll(sourceUrl, newPast, registry, abort.signal);
100
+ if (abort.signal.aborted) return;
101
+
102
+ if (result) {
103
+ replaceCurrent({ url: result.url, blob: result.blob, generated: true });
104
+ } else {
105
+ replaceCurrent({ url: sourceUrl, blob: null, generated: false });
106
+ }
107
+ setHistory({ past: newPast, future: newFuture });
108
+ } finally {
109
+ if (!abort.signal.aborted) {
110
+ isReplaying.current = false;
111
+ setReplaying(false);
112
+ }
113
+ }
114
+ }
115
+
116
+ function undo() {
117
+ if (isReplaying.current) return;
118
+ let { past, future } = historyRef.current;
119
+ if (past.length === 0) return;
120
+ doReplay(past.slice(0, -1), [past.at(-1)!, ...future]);
121
+ }
122
+
123
+ function redo() {
124
+ if (isReplaying.current) return;
125
+ let { past, future } = historyRef.current;
126
+ if (future.length === 0) return;
127
+ doReplay([...past, future[0]], future.slice(1));
128
+ }
129
+
130
+ function reset() {
131
+ replayAbort.current?.abort();
132
+ isReplaying.current = false;
133
+ setReplaying(false);
134
+ replaceCurrent({ url: sourceUrl, blob: null, generated: false });
135
+ setHistory({ past: [], future: [] });
136
+ }
137
+
138
+ return {
139
+ currentImageUrl: current.url,
140
+ currentBlob: current.blob,
141
+ getCurrentImageUrl: () => currentRef.current.url,
142
+ getCurrentBlob: () => currentRef.current.blob,
143
+ canUndo: history.past.length > 0,
144
+ canRedo: history.future.length > 0,
145
+ replaying,
146
+ applyActions,
147
+ undo,
148
+ redo,
149
+ reset,
150
+ };
151
+ }
152
+
153
+ /**
154
+ * Replays a sequence of action groups from a source URL.
155
+ * Intermediate object URLs are revoked as soon as a new step succeeds.
156
+ * Returns the final `{ url, blob }` or `null` if there were no actions.
157
+ */
158
+ async function replayAll(
159
+ sourceUrl: string,
160
+ actionGroups: EditAction[][],
161
+ registry: ActionRegistry,
162
+ signal: AbortSignal,
163
+ ): Promise<{ url: string; blob: Blob } | null> {
164
+ let prevUrl = sourceUrl;
165
+ let prevGenerated = false;
166
+ let lastBlob: Blob | null = null;
167
+
168
+ for (let group of actionGroups) {
169
+ for (let action of group) {
170
+ if (signal.aborted) {
171
+ if (prevGenerated) URL.revokeObjectURL(prevUrl);
172
+ return null;
173
+ }
174
+
175
+ let apply = registry.get(action.type);
176
+ if (!apply) {
177
+ console.warn(`[ImageHistory] No replay handler for action type "${action.type}" — skipping`);
178
+ continue;
179
+ }
180
+
181
+ let blob = await apply(prevUrl, action.params);
182
+
183
+ if (signal.aborted) {
184
+ if (prevGenerated) URL.revokeObjectURL(prevUrl);
185
+ return null;
186
+ }
187
+
188
+ if (prevGenerated) URL.revokeObjectURL(prevUrl);
189
+ lastBlob = blob;
190
+ prevUrl = URL.createObjectURL(blob);
191
+ prevGenerated = true;
192
+ }
193
+ }
194
+
195
+ if (!lastBlob || !prevGenerated) return null;
196
+ return { url: prevUrl, blob: lastBlob };
197
+ }