@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,226 +1,226 @@
1
- import Add from "@mui/icons-material/Add";
2
- import DeleteForeverOutlined from "@mui/icons-material/DeleteForeverOutlined";
3
- import Edit from "@mui/icons-material/Edit";
4
- import QrCodeScanner from "@mui/icons-material/QrCodeScanner";
5
- import TapAndPlay from "@mui/icons-material/TapAndPlay";
6
- import { Alert, Box, Button, DialogActions, List, ListItem, ListItemText, Tab, Tabs } from "@mui/material";
7
- import { ResponsiveDialog } from "@olenbetong/appframe-mui";
8
- import { type ReactNode, useEffect, useState } from "react";
9
- import { flushSync } from "react-dom";
10
- import { BarcodeScanner, type DecoderFactory } from "./BarcodeScanner";
11
- import { type AddElementSource, type ElementDetails, getElement } from "./getElement";
12
- import { AddElementHIDScanner } from "./HIDScanner";
13
- import { AddElementManualForm } from "./Manual/ManualForm";
14
- import { useBeeper } from "./utils/beep";
15
- import Giai from "./utils/Giai";
16
- import { getLocalizedString, localize } from "../../i18n.js";
17
-
18
- export type AddElement = {
19
- element: ElementDetails;
20
- mode: AddElementSource;
21
- scanTime?: number;
22
- };
23
-
24
- type InitialTabProps = "camera" | "scanner" | "manual";
25
-
26
- export type ElementLookupDialogSharedProps = {
27
- open: boolean;
28
- onClose: () => void;
29
- initialTab?: InitialTabProps | null;
30
- useSearch?: boolean;
31
- allowEmptyElement?: boolean;
32
- /** Engine for the camera tab. Defaults to zxing-wasm. */
33
- decoder?: DecoderFactory;
34
- /** Extra controls in the camera tab footer, e.g. an engine picker. */
35
- scannerActions?: ReactNode;
36
- };
37
-
38
- export type ElementLookupDialogSingleModeProps = ElementLookupDialogSharedProps & {
39
- mode: "single" | "search";
40
- onAdd: (element: AddElement) => Promise<void>;
41
- };
42
-
43
- export type ElementLookupDialogMultiModeProps = ElementLookupDialogSharedProps & {
44
- mode: "multi";
45
- onAdd: (element: AddElement[]) => Promise<void>;
46
- };
47
-
48
- export type ElementLookupDialogProps = ElementLookupDialogSingleModeProps | ElementLookupDialogMultiModeProps;
49
-
50
- export function ElementLookupDialog(props: ElementLookupDialogProps) {
51
- let { open, onClose, initialTab, decoder, scannerActions } = props;
52
- let [tab, setTab] = useState<"camera" | "scanner" | "manual">("camera");
53
- let [elements, setElements] = useState<Array<AddElement>>([]);
54
- let [adding, setAdding] = useState(false);
55
- let beeper = useBeeper();
56
-
57
- useEffect(() => {
58
- if (open && initialTab) {
59
- setTab(initialTab);
60
- }
61
- }, [open, initialTab]);
62
-
63
- async function handleElementAdd(element: string | ElementDetails, mode: AddElementSource) {
64
- try {
65
- let record = typeof element === "string" ? await getElement(element.replace("\u001d", ""), { mode }) : element;
66
-
67
- // Flush changes to DOM to be able to query newly added elements and animate their background
68
- flushSync(() => {
69
- setElements((current) => {
70
- let now = Date.now();
71
- let exists = current.some((e) => e.element.ElementID === record.ElementID);
72
- let updated: Array<AddElement>;
73
-
74
- if (exists) {
75
- updated = current.map((e) => (e.element.ElementID === record.ElementID ? { ...e, scanTime: now } : e));
76
- } else {
77
- beeper();
78
- updated =
79
- props.mode === "multi"
80
- ? [{ element: record, mode, scanTime: now }, ...current]
81
- : [{ element: record, mode, scanTime: now }];
82
- }
83
-
84
- if (props.mode === "multi") {
85
- updated.sort((a, b) => (b.scanTime ?? 0) - (a.scanTime ?? 0));
86
- }
87
-
88
- return updated;
89
- });
90
- });
91
-
92
- let addedDomElement = document.querySelector(`[data-elementid="${record.ElementID}"]`);
93
- if (addedDomElement) {
94
- addedDomElement.animate(
95
- [
96
- { backgroundColor: "var(--brand-light)", offset: 0 },
97
- { backgroundColor: "var(--brand-light)", offset: 0.2 },
98
- { backgroundColor: "transparent" },
99
- ],
100
- {
101
- duration: 1000,
102
- easing: "ease-out",
103
- },
104
- );
105
- }
106
- } catch (error) {
107
- alert((error as Error).message);
108
- }
109
- }
110
-
111
- if (tab === "manual" && props.mode === "search") {
112
- tab = "camera";
113
- }
114
-
115
- return (
116
- <ResponsiveDialog
117
- open={open}
118
- onClose={onClose}
119
- slotProps={{
120
- paper: { sx: { overflow: "hidden" } },
121
- }}
122
- >
123
- <Box sx={{ display: "flex", flexDirection: "column", maxHeight: "100%", overflow: "hidden", flexGrow: 1 }}>
124
- <Tabs value={tab} onChange={(_, newTab) => setTab(newTab)} variant="fullWidth" sx={{ flexShrink: 0 }}>
125
- {props.mode !== "search" && <Tab icon={<Edit />} label={getLocalizedString("Manual")} value="manual" />}
126
- <Tab icon={<TapAndPlay />} label={getLocalizedString("Scanner")} value="scanner" />
127
- <Tab icon={<QrCodeScanner />} label={getLocalizedString("Camera")} value="camera" />
128
- </Tabs>
129
- {tab === "camera" && (
130
- <Box sx={{ flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }}>
131
- <BarcodeScanner
132
- decoder={decoder}
133
- actions={scannerActions}
134
- onRead={(element) => handleElementAdd(element, "camera-barcode")}
135
- />
136
- </Box>
137
- )}
138
- {tab === "manual" && (
139
- <Box sx={{ p: 2 }}>
140
- <AddElementManualForm
141
- onAdd={(element) => handleElementAdd(element, "manual")}
142
- allowEmptyElement={props.allowEmptyElement}
143
- />
144
- </Box>
145
- )}
146
- {tab === "scanner" && (
147
- <Box sx={{ flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }}>
148
- <AddElementHIDScanner
149
- onScan={(element) =>
150
- handleElementAdd(element, element.startsWith(Giai.BARCODE_PREFIX) ? "hid-barcode" : "hid-rfid")
151
- }
152
- />
153
- </Box>
154
- )}
155
-
156
- <Box sx={{ flex: "3 1 14rem", overflow: "auto" }}>
157
- {props.mode === "multi" && (
158
- <Alert
159
- icon={false}
160
- severity="info"
161
- sx={{ justifyContent: "center", py: 0, position: "sticky", top: 0, zIndex: 1 }}
162
- slotProps={{
163
- message: { sx: { py: 0.5 } },
164
- }}
165
- >{localize`${elements.length} elements selected`}</Alert>
166
- )}
167
- <List disablePadding>
168
- {elements.map(({ element }) => (
169
- <ListItem
170
- key={element.ElementID}
171
- data-elementid={element.ElementID}
172
- secondaryAction={
173
- <Button
174
- color="error"
175
- variant="outlined"
176
- onClick={() => {
177
- setElements((current) =>
178
- props.mode === "multi" ? current.filter((e) => e.element.ElementID !== element.ElementID) : [],
179
- );
180
- }}
181
- >
182
- <DeleteForeverOutlined />
183
- </Button>
184
- }
185
- >
186
- <ListItemText
187
- primary={element.DisplayName || element.ProjectName}
188
- secondary={element.ElementID || element.ProjectID}
189
- />
190
- </ListItem>
191
- ))}
192
- </List>
193
- </Box>
194
-
195
- <DialogActions sx={{ flexShrink: 0 }}>
196
- <Button onClick={onClose}>{getLocalizedString("Cancel")}</Button>
197
- <Button
198
- variant="contained"
199
- loading={adding}
200
- onClick={async () => {
201
- try {
202
- setAdding(true);
203
- if (props.mode === "multi") {
204
- await props.onAdd(elements);
205
- } else {
206
- await props.onAdd(elements[0]!);
207
- }
208
- setElements([]);
209
- setAdding(false);
210
- onClose();
211
- } catch (error) {
212
- setAdding(false);
213
- alert((error as Error).message);
214
- }
215
- }}
216
- startIcon={<Add />}
217
- loadingPosition="start"
218
- disabled={!elements.length}
219
- >
220
- {props.mode === "search" ? getLocalizedString("Search for element") : getLocalizedString("Add element")}
221
- </Button>
222
- </DialogActions>
223
- </Box>
224
- </ResponsiveDialog>
225
- );
226
- }
1
+ import Add from "@mui/icons-material/Add";
2
+ import DeleteForeverOutlined from "@mui/icons-material/DeleteForeverOutlined";
3
+ import Edit from "@mui/icons-material/Edit";
4
+ import QrCodeScanner from "@mui/icons-material/QrCodeScanner";
5
+ import TapAndPlay from "@mui/icons-material/TapAndPlay";
6
+ import { Alert, Box, Button, DialogActions, List, ListItem, ListItemText, Tab, Tabs } from "@mui/material";
7
+ import { ResponsiveDialog } from "@olenbetong/appframe-mui";
8
+ import { type ReactNode, useEffect, useState } from "react";
9
+ import { flushSync } from "react-dom";
10
+ import { BarcodeScanner, type DecoderFactory } from "./BarcodeScanner";
11
+ import { type AddElementSource, type ElementDetails, getElement } from "./getElement";
12
+ import { AddElementHIDScanner } from "./HIDScanner";
13
+ import { AddElementManualForm } from "./Manual/ManualForm";
14
+ import { useBeeper } from "./utils/beep";
15
+ import Giai from "./utils/Giai";
16
+ import { getLocalizedString, localize } from "../../i18n.js";
17
+
18
+ export type AddElement = {
19
+ element: ElementDetails;
20
+ mode: AddElementSource;
21
+ scanTime?: number;
22
+ };
23
+
24
+ type InitialTabProps = "camera" | "scanner" | "manual";
25
+
26
+ export type ElementLookupDialogSharedProps = {
27
+ open: boolean;
28
+ onClose: () => void;
29
+ initialTab?: InitialTabProps | null;
30
+ useSearch?: boolean;
31
+ allowEmptyElement?: boolean;
32
+ /** Engine for the camera tab. Defaults to zxing-wasm. */
33
+ decoder?: DecoderFactory;
34
+ /** Extra controls in the camera tab footer, e.g. an engine picker. */
35
+ scannerActions?: ReactNode;
36
+ };
37
+
38
+ export type ElementLookupDialogSingleModeProps = ElementLookupDialogSharedProps & {
39
+ mode: "single" | "search";
40
+ onAdd: (element: AddElement) => Promise<void>;
41
+ };
42
+
43
+ export type ElementLookupDialogMultiModeProps = ElementLookupDialogSharedProps & {
44
+ mode: "multi";
45
+ onAdd: (element: AddElement[]) => Promise<void>;
46
+ };
47
+
48
+ export type ElementLookupDialogProps = ElementLookupDialogSingleModeProps | ElementLookupDialogMultiModeProps;
49
+
50
+ export function ElementLookupDialog(props: ElementLookupDialogProps) {
51
+ let { open, onClose, initialTab, decoder, scannerActions } = props;
52
+ let [tab, setTab] = useState<"camera" | "scanner" | "manual">("camera");
53
+ let [elements, setElements] = useState<Array<AddElement>>([]);
54
+ let [adding, setAdding] = useState(false);
55
+ let beeper = useBeeper();
56
+
57
+ useEffect(() => {
58
+ if (open && initialTab) {
59
+ setTab(initialTab);
60
+ }
61
+ }, [open, initialTab]);
62
+
63
+ async function handleElementAdd(element: string | ElementDetails, mode: AddElementSource) {
64
+ try {
65
+ let record = typeof element === "string" ? await getElement(element.replace("\u001d", ""), { mode }) : element;
66
+
67
+ // Flush changes to DOM to be able to query newly added elements and animate their background
68
+ flushSync(() => {
69
+ setElements((current) => {
70
+ let now = Date.now();
71
+ let exists = current.some((e) => e.element.ElementID === record.ElementID);
72
+ let updated: Array<AddElement>;
73
+
74
+ if (exists) {
75
+ updated = current.map((e) => (e.element.ElementID === record.ElementID ? { ...e, scanTime: now } : e));
76
+ } else {
77
+ beeper();
78
+ updated =
79
+ props.mode === "multi"
80
+ ? [{ element: record, mode, scanTime: now }, ...current]
81
+ : [{ element: record, mode, scanTime: now }];
82
+ }
83
+
84
+ if (props.mode === "multi") {
85
+ updated.sort((a, b) => (b.scanTime ?? 0) - (a.scanTime ?? 0));
86
+ }
87
+
88
+ return updated;
89
+ });
90
+ });
91
+
92
+ let addedDomElement = document.querySelector(`[data-elementid="${record.ElementID}"]`);
93
+ if (addedDomElement) {
94
+ addedDomElement.animate(
95
+ [
96
+ { backgroundColor: "var(--brand-light)", offset: 0 },
97
+ { backgroundColor: "var(--brand-light)", offset: 0.2 },
98
+ { backgroundColor: "transparent" },
99
+ ],
100
+ {
101
+ duration: 1000,
102
+ easing: "ease-out",
103
+ },
104
+ );
105
+ }
106
+ } catch (error) {
107
+ alert((error as Error).message);
108
+ }
109
+ }
110
+
111
+ if (tab === "manual" && props.mode === "search") {
112
+ tab = "camera";
113
+ }
114
+
115
+ return (
116
+ <ResponsiveDialog
117
+ open={open}
118
+ onClose={onClose}
119
+ slotProps={{
120
+ paper: { sx: { overflow: "hidden" } },
121
+ }}
122
+ >
123
+ <Box sx={{ display: "flex", flexDirection: "column", maxHeight: "100%", overflow: "hidden", flexGrow: 1 }}>
124
+ <Tabs value={tab} onChange={(_, newTab) => setTab(newTab)} variant="fullWidth" sx={{ flexShrink: 0 }}>
125
+ {props.mode !== "search" && <Tab icon={<Edit />} label={getLocalizedString("Manual")} value="manual" />}
126
+ <Tab icon={<TapAndPlay />} label={getLocalizedString("Scanner")} value="scanner" />
127
+ <Tab icon={<QrCodeScanner />} label={getLocalizedString("Camera")} value="camera" />
128
+ </Tabs>
129
+ {tab === "camera" && (
130
+ <Box sx={{ flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }}>
131
+ <BarcodeScanner
132
+ decoder={decoder}
133
+ actions={scannerActions}
134
+ onRead={(element) => handleElementAdd(element, "camera-barcode")}
135
+ />
136
+ </Box>
137
+ )}
138
+ {tab === "manual" && (
139
+ <Box sx={{ p: 2 }}>
140
+ <AddElementManualForm
141
+ onAdd={(element) => handleElementAdd(element, "manual")}
142
+ allowEmptyElement={props.allowEmptyElement}
143
+ />
144
+ </Box>
145
+ )}
146
+ {tab === "scanner" && (
147
+ <Box sx={{ flexBasis: "12rem", flexGrow: 1, flexShrink: 2 }}>
148
+ <AddElementHIDScanner
149
+ onScan={(element) =>
150
+ handleElementAdd(element, element.startsWith(Giai.BARCODE_PREFIX) ? "hid-barcode" : "hid-rfid")
151
+ }
152
+ />
153
+ </Box>
154
+ )}
155
+
156
+ <Box sx={{ flex: "3 1 14rem", overflow: "auto" }}>
157
+ {props.mode === "multi" && (
158
+ <Alert
159
+ icon={false}
160
+ severity="info"
161
+ sx={{ justifyContent: "center", py: 0, position: "sticky", top: 0, zIndex: 1 }}
162
+ slotProps={{
163
+ message: { sx: { py: 0.5 } },
164
+ }}
165
+ >{localize`${elements.length} elements selected`}</Alert>
166
+ )}
167
+ <List disablePadding>
168
+ {elements.map(({ element }) => (
169
+ <ListItem
170
+ key={element.ElementID}
171
+ data-elementid={element.ElementID}
172
+ secondaryAction={
173
+ <Button
174
+ color="error"
175
+ variant="outlined"
176
+ onClick={() => {
177
+ setElements((current) =>
178
+ props.mode === "multi" ? current.filter((e) => e.element.ElementID !== element.ElementID) : [],
179
+ );
180
+ }}
181
+ >
182
+ <DeleteForeverOutlined />
183
+ </Button>
184
+ }
185
+ >
186
+ <ListItemText
187
+ primary={element.DisplayName || element.ProjectName}
188
+ secondary={element.ElementID || element.ProjectID}
189
+ />
190
+ </ListItem>
191
+ ))}
192
+ </List>
193
+ </Box>
194
+
195
+ <DialogActions sx={{ flexShrink: 0 }}>
196
+ <Button onClick={onClose}>{getLocalizedString("Cancel")}</Button>
197
+ <Button
198
+ variant="contained"
199
+ loading={adding}
200
+ onClick={async () => {
201
+ try {
202
+ setAdding(true);
203
+ if (props.mode === "multi") {
204
+ await props.onAdd(elements);
205
+ } else {
206
+ await props.onAdd(elements[0]!);
207
+ }
208
+ setElements([]);
209
+ setAdding(false);
210
+ onClose();
211
+ } catch (error) {
212
+ setAdding(false);
213
+ alert((error as Error).message);
214
+ }
215
+ }}
216
+ startIcon={<Add />}
217
+ loadingPosition="start"
218
+ disabled={!elements.length}
219
+ >
220
+ {props.mode === "search" ? getLocalizedString("Search for element") : getLocalizedString("Add element")}
221
+ </Button>
222
+ </DialogActions>
223
+ </Box>
224
+ </ResponsiveDialog>
225
+ );
226
+ }