@olenbetong/synergi-react 5.0.0 → 5.2.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 (168) hide show
  1. package/dist/styles/styles.css +1 -1
  2. package/dist/styles/styles.css.map +1 -1
  3. package/es/components/Checkbox/index.css +1 -1
  4. package/es/components/Checkbox/index.js +1 -9
  5. package/es/components/CodeEditor/CodeEditor.css +6 -6
  6. package/es/components/ColorCard/index.css +17 -28
  7. package/es/components/DateNavigator/index.css +5 -7
  8. package/es/components/FilePond.js +3 -12
  9. package/es/components/ImageEditor/ImageEditor.css +10 -10
  10. package/es/components/ImageEditor/ImageEditor.js +4 -4
  11. package/es/components/ImageEditor/ResponsiveButton.js +2 -2
  12. package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +1 -1
  13. package/es/components/ImageEditor/plugins/redactPlugin/RedactToolbar.js +1 -1
  14. package/es/components/ImageEditor/plugins/redactPlugin/useRedactTool.js +18 -14
  15. package/es/components/ImageEditor/useImageHistory.js +13 -1
  16. package/es/components/MergeProgressDialog/MergeProgressDialogDs.js +3 -3
  17. package/es/components/MergeProgressDialog/useMergeJob.js +5 -4
  18. package/es/components/PageBanner/index.css +1 -1
  19. package/es/components/PdfViewer/PdfViewer.js +1 -1
  20. package/es/components/Portal/index.js +20 -20
  21. package/es/components/Spinner/index.css +1 -1
  22. package/es/components/SplitContainer/index.css +1 -1
  23. package/es/components/SplitContainer/index.js +3 -1
  24. package/es/components/Toolbar/Toolbar.css +137 -137
  25. package/es/components/Toolbar/index.js +6 -1
  26. package/es/components/ValueToggleGroup/index.css +2 -2
  27. package/es/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +7 -7
  28. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.js +8 -0
  29. package/es/elements/ElementLookupDialog/HIDScanner/useHIDScanner.js +3 -1
  30. package/es/elements-ds/DescriptionInput.d.ts +16 -0
  31. package/es/elements-ds/DescriptionInput.js +41 -0
  32. package/es/elements-ds/DuplicateElementDamage.d.ts +40 -0
  33. package/es/elements-ds/DuplicateElementDamage.js +57 -0
  34. package/es/elements-ds/ElementLookup.d.ts +23 -0
  35. package/es/elements-ds/ElementLookup.js +35 -0
  36. package/es/elements-ds/ElementLookupDialog.d.ts +7 -0
  37. package/es/elements-ds/ElementLookupDialog.js +84 -0
  38. package/es/elements-ds/FormFields.d.ts +43 -0
  39. package/es/elements-ds/FormFields.js +67 -0
  40. package/es/elements-ds/HIDScanner.d.ts +7 -0
  41. package/es/elements-ds/HIDScanner.js +36 -0
  42. package/es/elements-ds/ManualForm.d.ts +7 -0
  43. package/es/elements-ds/ManualForm.js +70 -0
  44. package/es/elements-ds/ProjectSelect.d.ts +28 -0
  45. package/es/elements-ds/ProjectSelect.js +45 -0
  46. package/es/elements-ds/elements-ds.css +157 -0
  47. package/es/elements-ds/index.d.ts +12 -0
  48. package/es/elements-ds/index.js +14 -0
  49. package/es/index.css +1 -1
  50. package/es/useTranslation/index.js +5 -3
  51. package/package.json +16 -4
  52. package/src/chrome/AppShell/AppShell.test.tsx +48 -0
  53. package/src/chrome/AppShell/index.tsx +29 -29
  54. package/src/chrome/openReport.test.ts +50 -0
  55. package/src/chrome/openReport.ts +34 -34
  56. package/src/colorScheme.test.ts +188 -0
  57. package/src/colorScheme.ts +125 -125
  58. package/src/components/Checkbox/Checkbox.browser.test.tsx +116 -0
  59. package/src/components/Checkbox/index.scss +2 -2
  60. package/src/components/Checkbox/index.tsx +1 -10
  61. package/src/components/CodeEditor/CodeEditor.css +6 -6
  62. package/src/components/CodeEditor/CodeEditor.tsx +173 -173
  63. package/src/components/CodeEditor/index.ts +1 -1
  64. package/src/components/ColorCard/ColorCard.test.tsx +34 -0
  65. package/src/components/ColorCard/index.css +17 -28
  66. package/src/components/DateNavigator/DateNavigator.test.tsx +175 -0
  67. package/src/components/DateNavigator/index.css +5 -7
  68. package/src/components/DateNavigator/index.tsx +186 -186
  69. package/src/components/FilePond.browser.test.tsx +389 -0
  70. package/src/components/FilePond.tsx +303 -312
  71. package/src/components/ImageEditor/ImageEditor.browser.test.tsx +286 -0
  72. package/src/components/ImageEditor/ImageEditor.css +10 -10
  73. package/src/components/ImageEditor/ImageEditor.test.tsx +299 -0
  74. package/src/components/ImageEditor/ImageEditor.tsx +348 -348
  75. package/src/components/ImageEditor/ResponsiveButton.tsx +2 -2
  76. package/src/components/ImageEditor/index.ts +9 -9
  77. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  78. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +42 -48
  79. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.test.ts +225 -0
  80. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +405 -405
  81. package/src/components/ImageEditor/plugins/plugins.browser.test.ts +252 -0
  82. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  83. package/src/components/ImageEditor/plugins/redactPlugin/useRedactTool.test.ts +89 -0
  84. package/src/components/ImageEditor/plugins/redactPlugin/useRedactTool.ts +16 -13
  85. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  86. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  87. package/src/components/ImageEditor/plugins/zoomPlugin/useZoomPan.test.ts +154 -0
  88. package/src/components/ImageEditor/useActiveTool.ts +21 -21
  89. package/src/components/ImageEditor/useEdgeDetection.test.ts +96 -0
  90. package/src/components/ImageEditor/useEdgeDetection.ts +319 -319
  91. package/src/components/ImageEditor/useImageHistory.test.ts +409 -0
  92. package/src/components/ImageEditor/useImageHistory.ts +206 -197
  93. package/src/components/ImageEditor/useOpenCV.test.ts +208 -0
  94. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  95. package/src/components/LinkedCardList/index.scss +95 -95
  96. package/src/components/MergeProgressDialog/MergeProgressDialogDs.browser.test.tsx +156 -0
  97. package/src/components/MergeProgressDialog/MergeProgressDialogDs.tsx +4 -3
  98. package/src/components/MergeProgressDialog/useMergeJob.test.ts +326 -0
  99. package/src/components/MergeProgressDialog/useMergeJob.ts +4 -3
  100. package/src/components/PageBanner/index.scss +10 -10
  101. package/src/components/PageBanner/index.tsx +80 -80
  102. package/src/components/PdfViewer/PdfViewer.browser.test.tsx +78 -0
  103. package/src/components/PdfViewer/PdfViewer.tsx +158 -158
  104. package/src/components/Portal/Portal.test.tsx +106 -0
  105. package/src/components/Portal/index.tsx +22 -25
  106. package/src/components/Sidebar/Sidebar.browser.test.tsx +57 -0
  107. package/src/components/Sidebar/Sidebar.test.tsx +123 -0
  108. package/src/components/Spinner/index.css +1 -1
  109. package/src/components/SplitContainer/SplitContainer.browser.test.tsx +304 -0
  110. package/src/components/SplitContainer/index.scss +5 -1
  111. package/src/components/SplitContainer/index.tsx +335 -333
  112. package/src/components/Toolbar/Toolbar.css +137 -137
  113. package/src/components/Toolbar/Toolbar.test.tsx +216 -0
  114. package/src/components/Toolbar/ToolbarBreadcrumbs.browser.test.tsx +137 -0
  115. package/src/components/Toolbar/index.tsx +270 -265
  116. package/src/components/ValueToggleGroup/ValueToggleGroup.test.tsx +112 -0
  117. package/src/components/ValueToggleGroup/index.css +2 -2
  118. package/src/designsystemet-web-types.d.ts +24 -24
  119. package/src/elements/ElementDamage/DamageFormButtons.tsx +35 -35
  120. package/src/elements/ElementDamage/DescriptionInput.tsx +120 -120
  121. package/src/elements/ElementDamage/DuplicateDamage/DesktopView.tsx +82 -82
  122. package/src/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.tsx +67 -67
  123. package/src/elements/ElementDamage/DuplicateDamage/PhoneView.tsx +45 -45
  124. package/src/elements/ElementDamage/ElementNumberTextField.tsx +41 -41
  125. package/src/elements/ElementDamage/RegisterFix.tsx +100 -100
  126. package/src/elements/ElementDamage/SubmitButtons.tsx +40 -40
  127. package/src/elements/ElementDamage/TransportElementSelect.tsx +52 -52
  128. package/src/elements/ElementLookup.tsx +123 -123
  129. package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.browser.test.tsx +175 -0
  130. package/src/elements/ElementLookupDialog/BarcodeScanner/BarcodeScanner.css +7 -7
  131. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +8 -0
  132. package/src/elements/ElementLookupDialog/BarcodeScanner/engines.browser.test.ts +225 -0
  133. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  134. package/src/elements/ElementLookupDialog/HIDScanner/useHIDScanner.test.ts +124 -0
  135. package/src/elements/ElementLookupDialog/HIDScanner/useHIDScanner.ts +2 -1
  136. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  137. package/src/elements/ElementLookupDialog/getElement.test.ts +133 -0
  138. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  139. package/src/elements/ElementLookupDialog/utils/Giai.test.ts +53 -0
  140. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  141. package/src/elements/ProjectSelect.tsx +130 -130
  142. package/src/elements/index.ts +15 -15
  143. package/src/elements-ds/DamageForm.browser.test.tsx +530 -0
  144. package/src/elements-ds/DescriptionInput.tsx +114 -0
  145. package/src/elements-ds/DuplicateElementDamage.tsx +185 -0
  146. package/src/elements-ds/ElementLookup.tsx +114 -0
  147. package/src/elements-ds/ElementLookupDialog.browser.test.tsx +207 -0
  148. package/src/elements-ds/ElementLookupDialog.tsx +194 -0
  149. package/src/elements-ds/FormFields.tsx +176 -0
  150. package/src/elements-ds/HIDScanner.tsx +53 -0
  151. package/src/elements-ds/ManualForm.tsx +129 -0
  152. package/src/elements-ds/ProjectSelect.tsx +120 -0
  153. package/src/elements-ds/elements-ds.css +157 -0
  154. package/src/elements-ds/index.ts +16 -0
  155. package/src/filter/index.ts +34 -34
  156. package/src/i18n.test.ts +31 -0
  157. package/src/i18n.ts +13 -13
  158. package/src/mui/MuiThemeProvider.tsx +135 -135
  159. package/src/test/fakeCamera.ts +98 -0
  160. package/src/test/fakeDataApi.ts +90 -0
  161. package/src/test/setup.browser.ts +21 -0
  162. package/src/test/setup.ts +23 -23
  163. package/src/useTranslation/index.ts +5 -3
  164. package/src/useTranslation/useTranslation.test.ts +128 -0
  165. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.d.ts +0 -1
  166. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.js +0 -103
  167. package/es/test/setup.d.ts +0 -6
  168. package/es/test/setup.js +0 -6
@@ -17,12 +17,12 @@
17
17
  }
18
18
 
19
19
  .ObValueToggleGroup {
20
- padding: 0.25rem;
20
+ padding: var(--ds-size-1, 0.25rem);
21
21
  border: 2px solid rgb(0 0 0 / 0.2);
22
22
  border-radius: 4px;
23
23
 
24
24
  display: flex;
25
- gap: 0.25rem;
25
+ gap: var(--ds-size-1, 0.25rem);
26
26
  flex-wrap: wrap;
27
27
 
28
28
  &.vertical {
@@ -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
+ }