@olenbetong/synergi-react 4.2.5 → 4.2.6

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 +5 -5
  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,41 +1,41 @@
1
- import { type SxProps, TextField, type Theme } from "@mui/material";
2
- import { useEffect, useState } from "react";
3
- import { getLocalizedString } from "../../i18n.js";
4
-
5
- type ElementNumberTextFieldProps = {
6
- value?: string | null;
7
- defaultValue?: string | null;
8
- onChange?: (value: string) => void;
9
- disabled?: boolean;
10
- sx?: SxProps<Theme>;
11
- };
12
-
13
- export function ElementNumberTextField({ value, defaultValue, onChange, disabled, sx }: ElementNumberTextFieldProps) {
14
- let [elementNumber, setElementNumber] = useState<string>(defaultValue ?? "");
15
- let elementNumberValue = value === undefined ? elementNumber : value;
16
-
17
- useEffect(() => {
18
- if (value === undefined && defaultValue) {
19
- setElementNumber(defaultValue);
20
- }
21
- }, [defaultValue, value]);
22
-
23
- function handleChange(value: string) {
24
- onChange?.(value);
25
- setElementNumber(value);
26
- }
27
-
28
- return (
29
- <TextField
30
- name="ElementNumber"
31
- id="NewElementDamage_ElementNr"
32
- value={elementNumberValue}
33
- onChange={(event) => handleChange(event.currentTarget.value)}
34
- label={getLocalizedString("Element number")}
35
- fullWidth
36
- autoComplete="off"
37
- disabled={disabled ?? false}
38
- sx={{ ...sx }}
39
- />
40
- );
41
- }
1
+ import { type SxProps, TextField, type Theme } from "@mui/material";
2
+ import { useEffect, useState } from "react";
3
+ import { getLocalizedString } from "../../i18n.js";
4
+
5
+ type ElementNumberTextFieldProps = {
6
+ value?: string | null;
7
+ defaultValue?: string | null;
8
+ onChange?: (value: string) => void;
9
+ disabled?: boolean;
10
+ sx?: SxProps<Theme>;
11
+ };
12
+
13
+ export function ElementNumberTextField({ value, defaultValue, onChange, disabled, sx }: ElementNumberTextFieldProps) {
14
+ let [elementNumber, setElementNumber] = useState<string>(defaultValue ?? "");
15
+ let elementNumberValue = value === undefined ? elementNumber : value;
16
+
17
+ useEffect(() => {
18
+ if (value === undefined && defaultValue) {
19
+ setElementNumber(defaultValue);
20
+ }
21
+ }, [defaultValue, value]);
22
+
23
+ function handleChange(value: string) {
24
+ onChange?.(value);
25
+ setElementNumber(value);
26
+ }
27
+
28
+ return (
29
+ <TextField
30
+ name="ElementNumber"
31
+ id="NewElementDamage_ElementNr"
32
+ value={elementNumberValue}
33
+ onChange={(event) => handleChange(event.currentTarget.value)}
34
+ label={getLocalizedString("Element number")}
35
+ fullWidth
36
+ autoComplete="off"
37
+ disabled={disabled ?? false}
38
+ sx={{ ...sx }}
39
+ />
40
+ );
41
+ }
@@ -1,100 +1,100 @@
1
- import CheckIcon from "@mui/icons-material/Check";
2
- import { Button, Checkbox, FormControlLabel, Typography } from "@mui/material";
3
-
4
- import { useEffect, useRef, useState } from "react";
5
-
6
- import { procApproveDamage } from "../data";
7
- import { getLocalizedString, localize } from "../../i18n.js";
8
-
9
- const formatter = new Intl.DateTimeFormat(af.userSession.culture, {
10
- day: "numeric",
11
- month: "long",
12
- year: "numeric",
13
- hour: "2-digit",
14
- minute: "2-digit",
15
- timeZone: "UTC",
16
- });
17
-
18
- type RegisterFixType = {
19
- ID: number;
20
- RegisteredFixFullName: string | null;
21
- RegisteredFix: Date | null;
22
- RegisteredFixBy: string | null;
23
- };
24
-
25
- type ApproveDamageProcedureRecord = {
26
- Table: Array<Required<RegisterFixType>>;
27
- };
28
-
29
- type RegisterFixProps = {
30
- value?: RegisterFixType | null;
31
- defaultValue?: RegisterFixType | null;
32
- onFix?: (ID: number) => void;
33
- edit?: boolean;
34
- };
35
-
36
- export function RegisterFix({ value, defaultValue, onFix, edit }: RegisterFixProps) {
37
- let [loading, setLoading] = useState<boolean>(false);
38
- let initializedRef = useRef<boolean>(false);
39
-
40
- let [fix, setFix] = useState<RegisterFixType | null>(defaultValue ?? null);
41
- let fixValue = value === undefined ? fix : value;
42
-
43
- // biome-ignore lint: intentionally skipping "value" dependency as this should never run when "value" changes
44
- useEffect(() => {
45
- if (initializedRef.current) {
46
- return;
47
- }
48
-
49
- if (value === undefined && defaultValue) {
50
- setFix(defaultValue);
51
- initializedRef.current = true;
52
- }
53
- }, [defaultValue]);
54
-
55
- async function handleRegisterFix() {
56
- try {
57
- if (confirm(getLocalizedString("Are you sure you want to register a fix for this damage?"))) {
58
- setLoading(true);
59
- let record = (await procApproveDamage.execute({ ID: fixValue?.ID })) as ApproveDamageProcedureRecord;
60
-
61
- setFix({ ...record.Table[0] });
62
-
63
- setLoading(false);
64
- onFix?.(fixValue?.ID ?? -1);
65
- }
66
- } catch (error) {
67
- alert((error as Error).message);
68
- }
69
- }
70
-
71
- return (
72
- <>
73
- {edit ? (
74
- <Button
75
- loading={loading}
76
- loadingPosition="end"
77
- endIcon={<CheckIcon />}
78
- onClick={handleRegisterFix}
79
- disabled={!!fixValue?.RegisteredFix}
80
- variant="contained"
81
- >
82
- {getLocalizedString("Register fix")}
83
- </Button>
84
- ) : (
85
- <FormControlLabel
86
- control={<Checkbox />}
87
- label={getLocalizedString("Register fixed")}
88
- name="RegisteredFix"
89
- id="NewElementDamage_RegisteredFix"
90
- />
91
- )}
92
-
93
- {fixValue?.RegisteredFix && (
94
- <Typography sx={{ mb: 1.5 }} color="text.secondary">
95
- {localize`Registered fix by ${fixValue.RegisteredFixFullName ?? fixValue.RegisteredFixBy} on the ${formatter.format(fixValue.RegisteredFix)}`}
96
- </Typography>
97
- )}
98
- </>
99
- );
100
- }
1
+ import CheckIcon from "@mui/icons-material/Check";
2
+ import { Button, Checkbox, FormControlLabel, Typography } from "@mui/material";
3
+
4
+ import { useEffect, useRef, useState } from "react";
5
+
6
+ import { procApproveDamage } from "../data";
7
+ import { getLocalizedString, localize } from "../../i18n.js";
8
+
9
+ const formatter = new Intl.DateTimeFormat(af.userSession.culture, {
10
+ day: "numeric",
11
+ month: "long",
12
+ year: "numeric",
13
+ hour: "2-digit",
14
+ minute: "2-digit",
15
+ timeZone: "UTC",
16
+ });
17
+
18
+ type RegisterFixType = {
19
+ ID: number;
20
+ RegisteredFixFullName: string | null;
21
+ RegisteredFix: Date | null;
22
+ RegisteredFixBy: string | null;
23
+ };
24
+
25
+ type ApproveDamageProcedureRecord = {
26
+ Table: Array<Required<RegisterFixType>>;
27
+ };
28
+
29
+ type RegisterFixProps = {
30
+ value?: RegisterFixType | null;
31
+ defaultValue?: RegisterFixType | null;
32
+ onFix?: (ID: number) => void;
33
+ edit?: boolean;
34
+ };
35
+
36
+ export function RegisterFix({ value, defaultValue, onFix, edit }: RegisterFixProps) {
37
+ let [loading, setLoading] = useState<boolean>(false);
38
+ let initializedRef = useRef<boolean>(false);
39
+
40
+ let [fix, setFix] = useState<RegisterFixType | null>(defaultValue ?? null);
41
+ let fixValue = value === undefined ? fix : value;
42
+
43
+ // biome-ignore lint: intentionally skipping "value" dependency as this should never run when "value" changes
44
+ useEffect(() => {
45
+ if (initializedRef.current) {
46
+ return;
47
+ }
48
+
49
+ if (value === undefined && defaultValue) {
50
+ setFix(defaultValue);
51
+ initializedRef.current = true;
52
+ }
53
+ }, [defaultValue]);
54
+
55
+ async function handleRegisterFix() {
56
+ try {
57
+ if (confirm(getLocalizedString("Are you sure you want to register a fix for this damage?"))) {
58
+ setLoading(true);
59
+ let record = (await procApproveDamage.execute({ ID: fixValue?.ID })) as ApproveDamageProcedureRecord;
60
+
61
+ setFix({ ...record.Table[0] });
62
+
63
+ setLoading(false);
64
+ onFix?.(fixValue?.ID ?? -1);
65
+ }
66
+ } catch (error) {
67
+ alert((error as Error).message);
68
+ }
69
+ }
70
+
71
+ return (
72
+ <>
73
+ {edit ? (
74
+ <Button
75
+ loading={loading}
76
+ loadingPosition="end"
77
+ endIcon={<CheckIcon />}
78
+ onClick={handleRegisterFix}
79
+ disabled={!!fixValue?.RegisteredFix}
80
+ variant="contained"
81
+ >
82
+ {getLocalizedString("Register fix")}
83
+ </Button>
84
+ ) : (
85
+ <FormControlLabel
86
+ control={<Checkbox />}
87
+ label={getLocalizedString("Register fixed")}
88
+ name="RegisteredFix"
89
+ id="NewElementDamage_RegisteredFix"
90
+ />
91
+ )}
92
+
93
+ {fixValue?.RegisteredFix && (
94
+ <Typography sx={{ mb: 1.5 }} color="text.secondary">
95
+ {localize`Registered fix by ${fixValue.RegisteredFixFullName ?? fixValue.RegisteredFixBy} on the ${formatter.format(fixValue.RegisteredFix)}`}
96
+ </Typography>
97
+ )}
98
+ </>
99
+ );
100
+ }
@@ -1,40 +1,40 @@
1
- import Add from "@mui/icons-material/Add";
2
- import { Box, Button, type SxProps, type Theme } from "@mui/material";
3
- import { getLocalizedString } from "../../i18n.js";
4
-
5
- type SubmitButtonsProps = {
6
- /**
7
- * Whether the form is in edit mode. If true, delete button is visible and submit button's text changes.
8
- */
9
- edit?: boolean;
10
- /**
11
- * Set loading state for submit button
12
- */
13
- loading?: boolean;
14
- /**
15
- * Custom styles for Box wrapper around buttons
16
- */
17
- sx?: SxProps<Theme>;
18
- onDelete?: () => void;
19
- onCancel?: () => void;
20
- onSubmit?: () => void;
21
- };
22
-
23
- export function SubmitButtons({ edit, loading, onDelete, onCancel, onSubmit, sx }: SubmitButtonsProps) {
24
- return (
25
- <Box sx={{ display: "flex", flexWrap: "wrap", gap: 2, justifyContent: "flex-end", ...sx }}>
26
- {edit && <Button onClick={onDelete}>{getLocalizedString("Delete")}</Button>}
27
- <Button onClick={onCancel}>{getLocalizedString("Cancel")}</Button>
28
- <Button
29
- loading={loading}
30
- loadingPosition="start"
31
- startIcon={<Add />}
32
- type="submit"
33
- variant="contained"
34
- onClick={onSubmit}
35
- >
36
- {edit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
37
- </Button>
38
- </Box>
39
- );
40
- }
1
+ import Add from "@mui/icons-material/Add";
2
+ import { Box, Button, type SxProps, type Theme } from "@mui/material";
3
+ import { getLocalizedString } from "../../i18n.js";
4
+
5
+ type SubmitButtonsProps = {
6
+ /**
7
+ * Whether the form is in edit mode. If true, delete button is visible and submit button's text changes.
8
+ */
9
+ edit?: boolean;
10
+ /**
11
+ * Set loading state for submit button
12
+ */
13
+ loading?: boolean;
14
+ /**
15
+ * Custom styles for Box wrapper around buttons
16
+ */
17
+ sx?: SxProps<Theme>;
18
+ onDelete?: () => void;
19
+ onCancel?: () => void;
20
+ onSubmit?: () => void;
21
+ };
22
+
23
+ export function SubmitButtons({ edit, loading, onDelete, onCancel, onSubmit, sx }: SubmitButtonsProps) {
24
+ return (
25
+ <Box sx={{ display: "flex", flexWrap: "wrap", gap: 2, justifyContent: "flex-end", ...sx }}>
26
+ {edit && <Button onClick={onDelete}>{getLocalizedString("Delete")}</Button>}
27
+ <Button onClick={onCancel}>{getLocalizedString("Cancel")}</Button>
28
+ <Button
29
+ loading={loading}
30
+ loadingPosition="start"
31
+ startIcon={<Add />}
32
+ type="submit"
33
+ variant="contained"
34
+ onClick={onSubmit}
35
+ >
36
+ {edit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
37
+ </Button>
38
+ </Box>
39
+ );
40
+ }
@@ -1,52 +1,52 @@
1
- import DropDownArrowIcon from "@mui/icons-material/KeyboardArrowDown";
2
- import { Button, ListItemText, Menu, MenuItem } from "@mui/material";
3
- import { useState } from "react";
4
- import type { TransportElementsRecord } from "../data/dsTransportElements.js";
5
- import { getLocalizedString } from "../../i18n.js";
6
-
7
- export type TransportElementSelectProps = {
8
- elements: TransportElementsRecord[];
9
- onSelect: (element: TransportElementsRecord) => void;
10
- };
11
-
12
- export function TransportElementSelect({ elements, onSelect }: TransportElementSelectProps) {
13
- let [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
14
- let open = !!anchorEl;
15
- let [selected, setSelected] = useState<TransportElementsRecord | null>(null);
16
-
17
- function handleChange(element: TransportElementsRecord) {
18
- setAnchorEl(null);
19
- onSelect(element);
20
- setSelected(element);
21
- }
22
-
23
- return (
24
- <>
25
- <Button
26
- id="select_element"
27
- variant="contained"
28
- endIcon={
29
- <DropDownArrowIcon
30
- style={{ transform: open ? "rotate(180deg)" : "rotate(0deg)", transition: "transform 0.2s" }}
31
- />
32
- }
33
- sx={{ width: "165px" }}
34
- aria-controls={open ? "basic-menu" : undefined}
35
- aria-haspopup="true"
36
- aria-expanded={open ? "true" : undefined}
37
- onClick={(event) => setAnchorEl(event.currentTarget)}
38
- >
39
- {selected ? `${selected.ElementID} - ${selected.Name}` : getLocalizedString("Select element")}
40
- </Button>
41
- <Menu id="menu_element" anchorEl={anchorEl} open={open} onClose={() => setAnchorEl(null)}>
42
- {elements.map((element) => (
43
- <MenuItem key={element.PrimKey} onClick={() => handleChange(element)}>
44
- <ListItemText>
45
- {element.ElementID} - {element.Name}
46
- </ListItemText>
47
- </MenuItem>
48
- ))}
49
- </Menu>
50
- </>
51
- );
52
- }
1
+ import DropDownArrowIcon from "@mui/icons-material/KeyboardArrowDown";
2
+ import { Button, ListItemText, Menu, MenuItem } from "@mui/material";
3
+ import { useState } from "react";
4
+ import type { TransportElementsRecord } from "../data/dsTransportElements.js";
5
+ import { getLocalizedString } from "../../i18n.js";
6
+
7
+ export type TransportElementSelectProps = {
8
+ elements: TransportElementsRecord[];
9
+ onSelect: (element: TransportElementsRecord) => void;
10
+ };
11
+
12
+ export function TransportElementSelect({ elements, onSelect }: TransportElementSelectProps) {
13
+ let [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null);
14
+ let open = !!anchorEl;
15
+ let [selected, setSelected] = useState<TransportElementsRecord | null>(null);
16
+
17
+ function handleChange(element: TransportElementsRecord) {
18
+ setAnchorEl(null);
19
+ onSelect(element);
20
+ setSelected(element);
21
+ }
22
+
23
+ return (
24
+ <>
25
+ <Button
26
+ id="select_element"
27
+ variant="contained"
28
+ endIcon={
29
+ <DropDownArrowIcon
30
+ style={{ transform: open ? "rotate(180deg)" : "rotate(0deg)", transition: "transform 0.2s" }}
31
+ />
32
+ }
33
+ sx={{ width: "165px" }}
34
+ aria-controls={open ? "basic-menu" : undefined}
35
+ aria-haspopup="true"
36
+ aria-expanded={open ? "true" : undefined}
37
+ onClick={(event) => setAnchorEl(event.currentTarget)}
38
+ >
39
+ {selected ? `${selected.ElementID} - ${selected.Name}` : getLocalizedString("Select element")}
40
+ </Button>
41
+ <Menu id="menu_element" anchorEl={anchorEl} open={open} onClose={() => setAnchorEl(null)}>
42
+ {elements.map((element) => (
43
+ <MenuItem key={element.PrimKey} onClick={() => handleChange(element)}>
44
+ <ListItemText>
45
+ {element.ElementID} - {element.Name}
46
+ </ListItemText>
47
+ </MenuItem>
48
+ ))}
49
+ </Menu>
50
+ </>
51
+ );
52
+ }