@olenbetong/synergi-react 5.0.0 → 5.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 (141) hide show
  1. package/es/components/Checkbox/index.js +1 -9
  2. package/es/components/CodeEditor/CodeEditor.css +6 -6
  3. package/es/components/FilePond.js +3 -12
  4. package/es/components/ImageEditor/plugins/redactPlugin/useRedactTool.js +18 -14
  5. package/es/components/ImageEditor/useImageHistory.js +13 -1
  6. package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +1 -1
  7. package/es/components/MergeProgressDialog/useMergeJob.js +5 -4
  8. package/es/components/Portal/index.js +20 -20
  9. package/es/components/SplitContainer/index.js +3 -1
  10. package/es/components/Toolbar/Toolbar.css +137 -137
  11. package/es/components/Toolbar/index.js +6 -1
  12. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.js +8 -0
  13. package/es/elements/ElementLookupDialog/HIDScanner/useHIDScanner.js +3 -1
  14. package/es/elements-ds/DescriptionInput.d.ts +16 -0
  15. package/es/elements-ds/DescriptionInput.js +41 -0
  16. package/es/elements-ds/DuplicateElementDamage.d.ts +40 -0
  17. package/es/elements-ds/DuplicateElementDamage.js +57 -0
  18. package/es/elements-ds/ElementLookup.d.ts +23 -0
  19. package/es/elements-ds/ElementLookup.js +35 -0
  20. package/es/elements-ds/ElementLookupDialog.d.ts +7 -0
  21. package/es/elements-ds/ElementLookupDialog.js +84 -0
  22. package/es/elements-ds/FormFields.d.ts +43 -0
  23. package/es/elements-ds/FormFields.js +67 -0
  24. package/es/elements-ds/HIDScanner.d.ts +7 -0
  25. package/es/elements-ds/HIDScanner.js +36 -0
  26. package/es/elements-ds/ManualForm.d.ts +7 -0
  27. package/es/elements-ds/ManualForm.js +70 -0
  28. package/es/elements-ds/ProjectSelect.d.ts +28 -0
  29. package/es/elements-ds/ProjectSelect.js +45 -0
  30. package/es/elements-ds/elements-ds.css +157 -0
  31. package/es/elements-ds/index.d.ts +12 -0
  32. package/es/elements-ds/index.js +14 -0
  33. package/es/useTranslation/index.js +5 -3
  34. package/package.json +15 -3
  35. package/src/chrome/AppShell/AppShell.test.tsx +48 -0
  36. package/src/chrome/AppShell/index.tsx +29 -29
  37. package/src/chrome/openReport.test.ts +50 -0
  38. package/src/chrome/openReport.ts +34 -34
  39. package/src/colorScheme.test.ts +188 -0
  40. package/src/colorScheme.ts +125 -125
  41. package/src/components/Checkbox/Checkbox.browser.test.tsx +116 -0
  42. package/src/components/Checkbox/index.tsx +1 -10
  43. package/src/components/CodeEditor/CodeEditor.css +6 -6
  44. package/src/components/CodeEditor/CodeEditor.tsx +173 -173
  45. package/src/components/CodeEditor/index.ts +1 -1
  46. package/src/components/ColorCard/ColorCard.test.tsx +34 -0
  47. package/src/components/DateNavigator/DateNavigator.test.tsx +175 -0
  48. package/src/components/DateNavigator/index.tsx +186 -186
  49. package/src/components/FilePond.browser.test.tsx +389 -0
  50. package/src/components/FilePond.tsx +303 -312
  51. package/src/components/ImageEditor/ImageEditor.browser.test.tsx +286 -0
  52. package/src/components/ImageEditor/ImageEditor.test.tsx +299 -0
  53. package/src/components/ImageEditor/ImageEditor.tsx +348 -348
  54. package/src/components/ImageEditor/index.ts +9 -9
  55. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  56. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
  57. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.test.ts +225 -0
  58. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
  59. package/src/components/ImageEditor/plugins/plugins.browser.test.ts +252 -0
  60. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  61. package/src/components/ImageEditor/plugins/redactPlugin/useRedactTool.test.ts +89 -0
  62. package/src/components/ImageEditor/plugins/redactPlugin/useRedactTool.ts +16 -13
  63. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  64. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  65. package/src/components/ImageEditor/plugins/zoomPlugin/useZoomPan.test.ts +154 -0
  66. package/src/components/ImageEditor/useActiveTool.ts +21 -21
  67. package/src/components/ImageEditor/useEdgeDetection.test.ts +96 -0
  68. package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
  69. package/src/components/ImageEditor/useImageHistory.test.ts +409 -0
  70. package/src/components/ImageEditor/useImageHistory.ts +206 -197
  71. package/src/components/ImageEditor/useOpenCV.test.ts +208 -0
  72. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  73. package/src/components/LinkedCardList/index.scss +95 -95
  74. package/src/components/MergeProgressDialog/MergeProgressDialogDs.browser.test.tsx +156 -0
  75. package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +1 -0
  76. package/src/components/MergeProgressDialog/useMergeJob.test.ts +326 -0
  77. package/src/components/MergeProgressDialog/useMergeJob.ts +4 -3
  78. package/src/components/PageBanner/index.tsx +80 -80
  79. package/src/components/PdfViewer/PdfViewer.browser.test.tsx +78 -0
  80. package/src/components/PdfViewer/PdfViewer.tsx +158 -158
  81. package/src/components/Portal/Portal.test.tsx +106 -0
  82. package/src/components/Portal/index.tsx +22 -25
  83. package/src/components/Sidebar/Sidebar.browser.test.tsx +57 -0
  84. package/src/components/Sidebar/Sidebar.test.tsx +123 -0
  85. package/src/components/SplitContainer/SplitContainer.browser.test.tsx +304 -0
  86. package/src/components/SplitContainer/index.tsx +335 -333
  87. package/src/components/Toolbar/Toolbar.css +137 -137
  88. package/src/components/Toolbar/Toolbar.test.tsx +216 -0
  89. package/src/components/Toolbar/ToolbarBreadcrumbs.browser.test.tsx +137 -0
  90. package/src/components/Toolbar/index.tsx +270 -265
  91. package/src/components/ValueToggleGroup/ValueToggleGroup.test.tsx +112 -0
  92. package/src/designsystemet-web-types.d.ts +24 -24
  93. package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
  94. package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
  95. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
  96. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
  97. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
  98. package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
  99. package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
  100. package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
  101. package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
  102. package/src/elements/ElementLookup.tsx +123 -123
  103. package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.browser.test.tsx +175 -0
  104. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +8 -0
  105. package/src/elements/ElementLookupDialog/BarcodeScanner/engines.browser.test.ts +225 -0
  106. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  107. package/src/elements/ElementLookupDialog/HIDScanner/useHIDScanner.test.ts +124 -0
  108. package/src/elements/ElementLookupDialog/HIDScanner/useHIDScanner.ts +2 -1
  109. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  110. package/src/elements/ElementLookupDialog/getElement.test.ts +133 -0
  111. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  112. package/src/elements/ElementLookupDialog/utils/Giai.test.ts +53 -0
  113. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  114. package/src/elements/ProjectSelect.tsx +130 -130
  115. package/src/elements/index.ts +15 -15
  116. package/src/elements-ds/DamageForm.browser.test.tsx +530 -0
  117. package/src/elements-ds/DescriptionInput.tsx +114 -0
  118. package/src/elements-ds/DuplicateElementDamage.tsx +185 -0
  119. package/src/elements-ds/ElementLookup.tsx +114 -0
  120. package/src/elements-ds/ElementLookupDialog.browser.test.tsx +207 -0
  121. package/src/elements-ds/ElementLookupDialog.tsx +196 -0
  122. package/src/elements-ds/FormFields.tsx +176 -0
  123. package/src/elements-ds/HIDScanner.tsx +53 -0
  124. package/src/elements-ds/ManualForm.tsx +129 -0
  125. package/src/elements-ds/ProjectSelect.tsx +120 -0
  126. package/src/elements-ds/elements-ds.css +157 -0
  127. package/src/elements-ds/index.ts +16 -0
  128. package/src/filter/index.ts +34 -34
  129. package/src/i18n.test.ts +31 -0
  130. package/src/i18n.ts +13 -13
  131. package/src/mui/MuiThemeProvider.tsx +135 -135
  132. package/src/test/fakeCamera.ts +98 -0
  133. package/src/test/fakeDataApi.ts +90 -0
  134. package/src/test/setup.browser.ts +21 -0
  135. package/src/test/setup.ts +23 -23
  136. package/src/useTranslation/index.ts +5 -3
  137. package/src/useTranslation/useTranslation.test.ts +128 -0
  138. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.d.ts +0 -1
  139. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.js +0 -103
  140. package/es/test/setup.d.ts +0 -6
  141. package/es/test/setup.js +0 -6
@@ -1,24 +1,24 @@
1
- import type * as ReactModule from "react";
2
-
3
- /**
4
- * `@digdir/designsystemet-web` registers its custom elements (`ds-tabs`,
5
- * `ds-field`, …) in `React.JSX.IntrinsicElements` and types them with
6
- * `ReactTypes.*` — but its bundled `index.d.ts` lost the matching
7
- * `import type * as ReactTypes from "react"`. Those entries therefore resolve
8
- * to an error type, which `skipLibCheck` hides while `React.ElementType`
9
- * (a mapped type over `keyof JSX.IntrinsicElements`) silently degrades.
10
- *
11
- * The fallout lands on MUI, which is only pulled into the same program here:
12
- * `<Box component="…" />` stops accepting the element's own props, and MUI
13
- * callback parameters (`sx` theme, `onClick` event, `Tabs onChange`) turn into
14
- * implicit `any`.
15
- *
16
- * Declaring the `ReactTypes` namespace globally gives that file what it is
17
- * missing. Remove this once Designsystemet ships the import in its `.d.ts`.
18
- */
19
- declare global {
20
- namespace ReactTypes {
21
- type HTMLAttributes<T> = ReactModule.HTMLAttributes<T>;
22
- type DetailedHTMLProps<E extends ReactModule.HTMLAttributes<T>, T> = ReactModule.DetailedHTMLProps<E, T>;
23
- }
24
- }
1
+ import type * as ReactModule from "react";
2
+
3
+ /**
4
+ * `@digdir/designsystemet-web` registers its custom elements (`ds-tabs`,
5
+ * `ds-field`, …) in `React.JSX.IntrinsicElements` and types them with
6
+ * `ReactTypes.*` — but its bundled `index.d.ts` lost the matching
7
+ * `import type * as ReactTypes from "react"`. Those entries therefore resolve
8
+ * to an error type, which `skipLibCheck` hides while `React.ElementType`
9
+ * (a mapped type over `keyof JSX.IntrinsicElements`) silently degrades.
10
+ *
11
+ * The fallout lands on MUI, which is only pulled into the same program here:
12
+ * `<Box component="…" />` stops accepting the element's own props, and MUI
13
+ * callback parameters (`sx` theme, `onClick` event, `Tabs onChange`) turn into
14
+ * implicit `any`.
15
+ *
16
+ * Declaring the `ReactTypes` namespace globally gives that file what it is
17
+ * missing. Remove this once Designsystemet ships the import in its `.d.ts`.
18
+ */
19
+ declare global {
20
+ namespace ReactTypes {
21
+ type HTMLAttributes<T> = ReactModule.HTMLAttributes<T>;
22
+ type DetailedHTMLProps<E extends ReactModule.HTMLAttributes<T>, T> = ReactModule.DetailedHTMLProps<E, T>;
23
+ }
24
+ }
@@ -1,35 +1,35 @@
1
- import Add from "@mui/icons-material/Add";
2
- import { Button } from "@mui/material";
3
- import { getLocalizedString } from "../../i18n.js";
4
-
5
- export type DamageFormButtonsProps = {
6
- isEdit: boolean;
7
- loading: boolean;
8
- uploadingFile: boolean;
9
- handleDelete: () => void;
10
- handleCancel: () => void;
11
- };
12
-
13
- export function DamageFormButtons({
14
- isEdit,
15
- loading,
16
- uploadingFile,
17
- handleDelete,
18
- handleCancel,
19
- }: DamageFormButtonsProps) {
20
- return (
21
- <>
22
- {isEdit && <Button onClick={handleDelete}>{getLocalizedString("Delete")}</Button>}
23
- <Button onClick={handleCancel}>{getLocalizedString("Cancel")}</Button>
24
- <Button
25
- loading={loading || uploadingFile}
26
- loadingPosition="start"
27
- startIcon={<Add />}
28
- type="submit"
29
- variant="contained"
30
- >
31
- {isEdit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
32
- </Button>
33
- </>
34
- );
35
- }
1
+ import Add from "@mui/icons-material/Add";
2
+ import { Button } from "@mui/material";
3
+ import { getLocalizedString } from "../../i18n.js";
4
+
5
+ export type DamageFormButtonsProps = {
6
+ isEdit: boolean;
7
+ loading: boolean;
8
+ uploadingFile: boolean;
9
+ handleDelete: () => void;
10
+ handleCancel: () => void;
11
+ };
12
+
13
+ export function DamageFormButtons({
14
+ isEdit,
15
+ loading,
16
+ uploadingFile,
17
+ handleDelete,
18
+ handleCancel,
19
+ }: DamageFormButtonsProps) {
20
+ return (
21
+ <>
22
+ {isEdit && <Button onClick={handleDelete}>{getLocalizedString("Delete")}</Button>}
23
+ <Button onClick={handleCancel}>{getLocalizedString("Cancel")}</Button>
24
+ <Button
25
+ loading={loading || uploadingFile}
26
+ loadingPosition="start"
27
+ startIcon={<Add />}
28
+ type="submit"
29
+ variant="contained"
30
+ >
31
+ {isEdit ? getLocalizedString("Save changes") : getLocalizedString("Register damage")}
32
+ </Button>
33
+ </>
34
+ );
35
+ }
@@ -1,120 +1,120 @@
1
- import { Autocomplete, Button, TextField } from "@mui/material";
2
- import { useEffect, useRef, useState } from "react";
3
- import { getLocalizedString } from "../../i18n.js";
4
-
5
- export type DescriptionInputType = {
6
- Description?: string | null;
7
- Cause?: string | null;
8
- Action?: string | null;
9
- Date?: Date;
10
- };
11
-
12
- type DescriptionInputProps = {
13
- value?: DescriptionInputType | null;
14
- defaultValue?: DescriptionInputType | null;
15
- descriptionOptions?: string[];
16
- storageNamespace?: string;
17
- onCopyPrevDamage?: (value: DescriptionInputType) => void;
18
- onChange?: (value: DescriptionInputType) => void;
19
- };
20
-
21
- export function DescriptionInput({
22
- value,
23
- defaultValue,
24
- descriptionOptions = [
25
- getLocalizedString("Tear in element"),
26
- getLocalizedString("Damage around lifting anchor"),
27
- getLocalizedString("Damage on underside"),
28
- ],
29
- storageNamespace = "ElementDamage",
30
- onCopyPrevDamage,
31
- onChange,
32
- }: DescriptionInputProps) {
33
- let initializedRef = useRef<boolean>(false);
34
-
35
- let [input, setInput] = useState<DescriptionInputType | null>(defaultValue ?? null);
36
- let inputValue = value === undefined ? input : value;
37
-
38
- // biome-ignore lint: intentionally skipping "value" dependency as this shouldn't run when "value" changes
39
- useEffect(() => {
40
- if (initializedRef.current) {
41
- return;
42
- }
43
-
44
- if (value === undefined && defaultValue) {
45
- setInput(defaultValue);
46
- initializedRef.current = true;
47
- }
48
- }, [defaultValue]);
49
-
50
- function handleCopyPrevDamage() {
51
- let description = localStorage.getItem(`${storageNamespace}_Description`) ?? "";
52
- let cause = localStorage.getItem(`${storageNamespace}_Cause`) ?? "";
53
- let action = localStorage.getItem(`${storageNamespace}_Action`) ?? "";
54
-
55
- onCopyPrevDamage?.({
56
- Description: description,
57
- Cause: cause,
58
- Action: action,
59
- });
60
- setInput({
61
- ...inputValue,
62
- Description: description,
63
- Cause: cause,
64
- Action: action,
65
- });
66
- }
67
-
68
- function handleOnChange(value: DescriptionInputType) {
69
- onChange?.(value);
70
- setInput(value);
71
- }
72
-
73
- return (
74
- <>
75
- <TextField
76
- name="Date"
77
- type="date"
78
- value={(inputValue?.Date ?? new Date()).toISOString().split("T")[0]}
79
- onChange={(event) => handleOnChange({ ...inputValue, Date: new Date(event.target.value) })}
80
- id="NewElementDamage_Date"
81
- label={getLocalizedString("Date")}
82
- fullWidth
83
- required
84
- slotProps={{ inputLabel: { shrink: true } }}
85
- />
86
-
87
- <Button variant="contained" onClick={handleCopyPrevDamage}>
88
- {getLocalizedString("Copy previous damage")}
89
- </Button>
90
-
91
- <Autocomplete
92
- value={inputValue?.Description ?? ""}
93
- onChange={(_event, value) => handleOnChange({ ...inputValue, Description: value ?? "" })}
94
- options={descriptionOptions}
95
- freeSolo
96
- renderInput={(params) => (
97
- <TextField name="Description" required {...(params as any)} label={getLocalizedString("Description")} />
98
- )}
99
- />
100
-
101
- <TextField
102
- name="Cause"
103
- id="NewElementDamage_Cause"
104
- value={inputValue?.Cause ?? ""}
105
- onChange={(event) => handleOnChange({ ...inputValue, Cause: event.currentTarget.value })}
106
- label={getLocalizedString("Cause")}
107
- fullWidth
108
- />
109
-
110
- <TextField
111
- name="Action"
112
- id="NewElementDamage_Action"
113
- value={inputValue?.Action ?? ""}
114
- onChange={(event) => handleOnChange({ ...inputValue, Action: event.currentTarget.value })}
115
- label={getLocalizedString("Action")}
116
- fullWidth
117
- />
118
- </>
119
- );
120
- }
1
+ import { Autocomplete, Button, TextField } from "@mui/material";
2
+ import { useEffect, useRef, useState } from "react";
3
+ import { getLocalizedString } from "../../i18n.js";
4
+
5
+ export type DescriptionInputType = {
6
+ Description?: string | null;
7
+ Cause?: string | null;
8
+ Action?: string | null;
9
+ Date?: Date;
10
+ };
11
+
12
+ type DescriptionInputProps = {
13
+ value?: DescriptionInputType | null;
14
+ defaultValue?: DescriptionInputType | null;
15
+ descriptionOptions?: string[];
16
+ storageNamespace?: string;
17
+ onCopyPrevDamage?: (value: DescriptionInputType) => void;
18
+ onChange?: (value: DescriptionInputType) => void;
19
+ };
20
+
21
+ export function DescriptionInput({
22
+ value,
23
+ defaultValue,
24
+ descriptionOptions = [
25
+ getLocalizedString("Tear in element"),
26
+ getLocalizedString("Damage around lifting anchor"),
27
+ getLocalizedString("Damage on underside"),
28
+ ],
29
+ storageNamespace = "ElementDamage",
30
+ onCopyPrevDamage,
31
+ onChange,
32
+ }: DescriptionInputProps) {
33
+ let initializedRef = useRef<boolean>(false);
34
+
35
+ let [input, setInput] = useState<DescriptionInputType | null>(defaultValue ?? null);
36
+ let inputValue = value === undefined ? input : value;
37
+
38
+ // biome-ignore lint: intentionally skipping "value" dependency as this shouldn't run when "value" changes
39
+ useEffect(() => {
40
+ if (initializedRef.current) {
41
+ return;
42
+ }
43
+
44
+ if (value === undefined && defaultValue) {
45
+ setInput(defaultValue);
46
+ initializedRef.current = true;
47
+ }
48
+ }, [defaultValue]);
49
+
50
+ function handleCopyPrevDamage() {
51
+ let description = localStorage.getItem(`${storageNamespace}_Description`) ?? "";
52
+ let cause = localStorage.getItem(`${storageNamespace}_Cause`) ?? "";
53
+ let action = localStorage.getItem(`${storageNamespace}_Action`) ?? "";
54
+
55
+ onCopyPrevDamage?.({
56
+ Description: description,
57
+ Cause: cause,
58
+ Action: action,
59
+ });
60
+ setInput({
61
+ ...inputValue,
62
+ Description: description,
63
+ Cause: cause,
64
+ Action: action,
65
+ });
66
+ }
67
+
68
+ function handleOnChange(value: DescriptionInputType) {
69
+ onChange?.(value);
70
+ setInput(value);
71
+ }
72
+
73
+ return (
74
+ <>
75
+ <TextField
76
+ name="Date"
77
+ type="date"
78
+ value={(inputValue?.Date ?? new Date()).toISOString().split("T")[0]}
79
+ onChange={(event) => handleOnChange({ ...inputValue, Date: new Date(event.target.value) })}
80
+ id="NewElementDamage_Date"
81
+ label={getLocalizedString("Date")}
82
+ fullWidth
83
+ required
84
+ slotProps={{ inputLabel: { shrink: true } }}
85
+ />
86
+
87
+ <Button variant="contained" onClick={handleCopyPrevDamage}>
88
+ {getLocalizedString("Copy previous damage")}
89
+ </Button>
90
+
91
+ <Autocomplete
92
+ value={inputValue?.Description ?? ""}
93
+ onChange={(_event, value) => handleOnChange({ ...inputValue, Description: value ?? "" })}
94
+ options={descriptionOptions}
95
+ freeSolo
96
+ renderInput={(params) => (
97
+ <TextField name="Description" required {...(params as any)} label={getLocalizedString("Description")} />
98
+ )}
99
+ />
100
+
101
+ <TextField
102
+ name="Cause"
103
+ id="NewElementDamage_Cause"
104
+ value={inputValue?.Cause ?? ""}
105
+ onChange={(event) => handleOnChange({ ...inputValue, Cause: event.currentTarget.value })}
106
+ label={getLocalizedString("Cause")}
107
+ fullWidth
108
+ />
109
+
110
+ <TextField
111
+ name="Action"
112
+ id="NewElementDamage_Action"
113
+ value={inputValue?.Action ?? ""}
114
+ onChange={(event) => handleOnChange({ ...inputValue, Action: event.currentTarget.value })}
115
+ label={getLocalizedString("Action")}
116
+ fullWidth
117
+ />
118
+ </>
119
+ );
120
+ }
@@ -1,82 +1,82 @@
1
- import { Grid, type GridSize, Typography } from "@mui/material";
2
- import { Link } from "@olenbetong/appframe-mui";
3
- import type { DamagesRecord } from "../../data";
4
- import { getLocalizedString } from "../../../i18n.js";
5
-
6
- type SummaryItemProps = {
7
- col: GridSize;
8
- label?: string;
9
- children?: React.ReactNode;
10
- em?: boolean;
11
- align?: "center" | "left" | "right";
12
- padding?: string | number;
13
- };
14
-
15
- function SummaryItem({ col, label, children, em, align, padding }: SummaryItemProps) {
16
- return (
17
- <Grid size={col} sx={{ p: padding ?? 2, borderBottom: (t) => `1px solid ${t.palette.divider}` }}>
18
- {label && (
19
- <Typography variant="body1" sx={{ fontSize: "0.9rem", fontWeight: 500, mb: 1, textAlign: align }}>
20
- {getLocalizedString(label)}
21
- </Typography>
22
- )}
23
- {children && (
24
- <Typography
25
- sx={{
26
- fontSize: em ? "1.4rem" : "0.9rem",
27
- fontWeight: em ? 600 : undefined,
28
- textAlign: align,
29
- whiteSpace: "pre-line",
30
- }}
31
- >
32
- {children}
33
- </Typography>
34
- )}
35
- </Grid>
36
- );
37
- }
38
-
39
- type ElementDamagesItemProps = {
40
- record: DamagesRecord;
41
- linkToDamage: boolean;
42
- };
43
-
44
- export function ElementDamagesItem({ record, linkToDamage }: ElementDamagesItemProps) {
45
- return (
46
- <>
47
- <SummaryItem col={1.5}>
48
- {linkToDamage ? (
49
- <Link
50
- href="#"
51
- onClick={(e) => {
52
- e.preventDefault();
53
- window.location.href = `${record.ID}`;
54
- }}
55
- >
56
- {record.ID}
57
- </Link>
58
- ) : (
59
- <span>{record.ID}</span>
60
- )}
61
- </SummaryItem>
62
- <SummaryItem col={2.5} align="right">
63
- {record.Date.toISOString().split("T")[0]}
64
- </SummaryItem>
65
- <SummaryItem col={3}>{record.Description}</SummaryItem>
66
- <SummaryItem col={2.5}>{record.Cause}</SummaryItem>
67
- <SummaryItem col={2.5}>{record.Action}</SummaryItem>
68
- </>
69
- );
70
- }
71
-
72
- export function ElementDamagesHeader() {
73
- return (
74
- <>
75
- <SummaryItem col={1.5} label="ID" />
76
- <SummaryItem col={2.5} label="Date" align="right" />
77
- <SummaryItem col={3} label="Description" />
78
- <SummaryItem col={2.5} label="Cause" />
79
- <SummaryItem col={2.5} label="Action" />
80
- </>
81
- );
82
- }
1
+ import { Grid, type GridSize, Typography } from "@mui/material";
2
+ import { Link } from "@olenbetong/appframe-mui";
3
+ import type { DamagesRecord } from "../../data";
4
+ import { getLocalizedString } from "../../../i18n.js";
5
+
6
+ type SummaryItemProps = {
7
+ col: GridSize;
8
+ label?: string;
9
+ children?: React.ReactNode;
10
+ em?: boolean;
11
+ align?: "center" | "left" | "right";
12
+ padding?: string | number;
13
+ };
14
+
15
+ function SummaryItem({ col, label, children, em, align, padding }: SummaryItemProps) {
16
+ return (
17
+ <Grid size={col} sx={{ p: padding ?? 2, borderBottom: (t) => `1px solid ${t.palette.divider}` }}>
18
+ {label && (
19
+ <Typography variant="body1" sx={{ fontSize: "0.9rem", fontWeight: 500, mb: 1, textAlign: align }}>
20
+ {getLocalizedString(label)}
21
+ </Typography>
22
+ )}
23
+ {children && (
24
+ <Typography
25
+ sx={{
26
+ fontSize: em ? "1.4rem" : "0.9rem",
27
+ fontWeight: em ? 600 : undefined,
28
+ textAlign: align,
29
+ whiteSpace: "pre-line",
30
+ }}
31
+ >
32
+ {children}
33
+ </Typography>
34
+ )}
35
+ </Grid>
36
+ );
37
+ }
38
+
39
+ type ElementDamagesItemProps = {
40
+ record: DamagesRecord;
41
+ linkToDamage: boolean;
42
+ };
43
+
44
+ export function ElementDamagesItem({ record, linkToDamage }: ElementDamagesItemProps) {
45
+ return (
46
+ <>
47
+ <SummaryItem col={1.5}>
48
+ {linkToDamage ? (
49
+ <Link
50
+ href="#"
51
+ onClick={(e) => {
52
+ e.preventDefault();
53
+ window.location.href = `${record.ID}`;
54
+ }}
55
+ >
56
+ {record.ID}
57
+ </Link>
58
+ ) : (
59
+ <span>{record.ID}</span>
60
+ )}
61
+ </SummaryItem>
62
+ <SummaryItem col={2.5} align="right">
63
+ {record.Date.toISOString().split("T")[0]}
64
+ </SummaryItem>
65
+ <SummaryItem col={3}>{record.Description}</SummaryItem>
66
+ <SummaryItem col={2.5}>{record.Cause}</SummaryItem>
67
+ <SummaryItem col={2.5}>{record.Action}</SummaryItem>
68
+ </>
69
+ );
70
+ }
71
+
72
+ export function ElementDamagesHeader() {
73
+ return (
74
+ <>
75
+ <SummaryItem col={1.5} label="ID" />
76
+ <SummaryItem col={2.5} label="Date" align="right" />
77
+ <SummaryItem col={3} label="Description" />
78
+ <SummaryItem col={2.5} label="Cause" />
79
+ <SummaryItem col={2.5} label="Action" />
80
+ </>
81
+ );
82
+ }
@@ -1,67 +1,67 @@
1
- import Add from "@mui/icons-material/Add";
2
- import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Grid, useMediaQuery } from "@mui/material";
3
- import { theme } from "@olenbetong/appframe-mui";
4
- import type { DamagesRecord } from "../../data";
5
- import { ElementDamagesHeader, ElementDamagesItem } from "./DesktopView";
6
- import { DuplicatePhoneViewItem } from "./PhoneView";
7
- import { getLocalizedString } from "../../../i18n.js";
8
-
9
- type DuplicateElementDamageDialogProps = {
10
- open: boolean;
11
- onClose: () => void;
12
- record: DamagesRecord[];
13
- onRegisterAnyway: () => void;
14
- loading: boolean;
15
- linkToDamage: boolean;
16
- };
17
-
18
- export function DuplicateElementDamageDialog({
19
- open,
20
- onClose,
21
- record,
22
- onRegisterAnyway,
23
- loading,
24
- linkToDamage,
25
- }: DuplicateElementDamageDialogProps) {
26
- let matches = useMediaQuery(theme.breakpoints.up("lg"));
27
- let backgroundColor = "#e9ebee";
28
-
29
- return (
30
- <Dialog open={open} onClose={onClose} fullWidth fullScreen={!matches}>
31
- <DialogTitle sx={{ backgroundColor: backgroundColor }}>
32
- {getLocalizedString("This element has one or more unfixed registered damage")}
33
- </DialogTitle>
34
- <DialogContent sx={{ backgroundColor: backgroundColor }}>
35
- <Grid container>
36
- {matches ? (
37
- <>
38
- <ElementDamagesHeader />
39
- {record.map((record) => (
40
- <ElementDamagesItem key={record.PrimKey} record={record} linkToDamage={linkToDamage} />
41
- ))}
42
- </>
43
- ) : (
44
- <div className="flow" style={{ width: "100%" }}>
45
- {record.map((record) => (
46
- <DuplicatePhoneViewItem key={record.PrimKey} record={record} linkToDamage={linkToDamage} />
47
- ))}
48
- </div>
49
- )}
50
- </Grid>
51
- </DialogContent>
52
- <DialogActions sx={{ backgroundColor: backgroundColor }}>
53
- <Button onClick={onClose}>{getLocalizedString("Cancel")}</Button>
54
- <Button
55
- startIcon={<Add />}
56
- variant="contained"
57
- type="submit"
58
- onClick={onRegisterAnyway}
59
- loading={loading}
60
- loadingPosition="start"
61
- >
62
- {getLocalizedString("Register damage anyway")}
63
- </Button>
64
- </DialogActions>
65
- </Dialog>
66
- );
67
- }
1
+ import Add from "@mui/icons-material/Add";
2
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Grid, useMediaQuery } from "@mui/material";
3
+ import { theme } from "@olenbetong/appframe-mui";
4
+ import type { DamagesRecord } from "../../data";
5
+ import { ElementDamagesHeader, ElementDamagesItem } from "./DesktopView";
6
+ import { DuplicatePhoneViewItem } from "./PhoneView";
7
+ import { getLocalizedString } from "../../../i18n.js";
8
+
9
+ type DuplicateElementDamageDialogProps = {
10
+ open: boolean;
11
+ onClose: () => void;
12
+ record: DamagesRecord[];
13
+ onRegisterAnyway: () => void;
14
+ loading: boolean;
15
+ linkToDamage: boolean;
16
+ };
17
+
18
+ export function DuplicateElementDamageDialog({
19
+ open,
20
+ onClose,
21
+ record,
22
+ onRegisterAnyway,
23
+ loading,
24
+ linkToDamage,
25
+ }: DuplicateElementDamageDialogProps) {
26
+ let matches = useMediaQuery(theme.breakpoints.up("lg"));
27
+ let backgroundColor = "#e9ebee";
28
+
29
+ return (
30
+ <Dialog open={open} onClose={onClose} fullWidth fullScreen={!matches}>
31
+ <DialogTitle sx={{ backgroundColor: backgroundColor }}>
32
+ {getLocalizedString("This element has one or more unfixed registered damage")}
33
+ </DialogTitle>
34
+ <DialogContent sx={{ backgroundColor: backgroundColor }}>
35
+ <Grid container>
36
+ {matches ? (
37
+ <>
38
+ <ElementDamagesHeader />
39
+ {record.map((record) => (
40
+ <ElementDamagesItem key={record.PrimKey} record={record} linkToDamage={linkToDamage} />
41
+ ))}
42
+ </>
43
+ ) : (
44
+ <div className="flow" style={{ width: "100%" }}>
45
+ {record.map((record) => (
46
+ <DuplicatePhoneViewItem key={record.PrimKey} record={record} linkToDamage={linkToDamage} />
47
+ ))}
48
+ </div>
49
+ )}
50
+ </Grid>
51
+ </DialogContent>
52
+ <DialogActions sx={{ backgroundColor: backgroundColor }}>
53
+ <Button onClick={onClose}>{getLocalizedString("Cancel")}</Button>
54
+ <Button
55
+ startIcon={<Add />}
56
+ variant="contained"
57
+ type="submit"
58
+ onClick={onRegisterAnyway}
59
+ loading={loading}
60
+ loadingPosition="start"
61
+ >
62
+ {getLocalizedString("Register damage anyway")}
63
+ </Button>
64
+ </DialogActions>
65
+ </Dialog>
66
+ );
67
+ }