@olenbetong/synergi-react 4.0.0 → 4.1.1

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 (85) hide show
  1. package/es/components/DateNavigator/index.js +1 -1
  2. package/es/components/FilePond.js +1 -1
  3. package/es/components/ImageEditor/ImageEditor.js +1 -1
  4. package/es/components/ImageEditor/plugins/cropPlugin/CropOverlay.js +1 -1
  5. package/es/components/ImageEditor/plugins/cropPlugin/CropToolbar.js +1 -1
  6. package/es/components/ImageEditor/plugins/redactPlugin/RedactToolbar.js +1 -1
  7. package/es/components/ImageEditor/plugins/zoomPlugin/ZoomControls.js +1 -1
  8. package/es/components/MergeProgressDialog/index.js +1 -1
  9. package/es/components/PdfViewer/PdfViewer.js +22 -3
  10. package/es/components/Toolbar/index.js +1 -1
  11. package/es/elements/ElementDamage/DamageFormButtons.js +1 -1
  12. package/es/elements/ElementDamage/DescriptionInput.js +1 -1
  13. package/es/elements/ElementDamage/DuplicateDamage/DesktopView.js +1 -1
  14. package/es/elements/ElementDamage/DuplicateDamage/DublicateElementDamageDialog.js +1 -1
  15. package/es/elements/ElementDamage/DuplicateDamage/PhoneView.js +1 -1
  16. package/es/elements/ElementDamage/ElementNumberTextField.js +1 -1
  17. package/es/elements/ElementDamage/RegisterFix.js +1 -1
  18. package/es/elements/ElementDamage/SubmitButtons.js +1 -1
  19. package/es/elements/ElementDamage/TransportElementSelect.js +1 -1
  20. package/es/elements/ElementLookup.js +1 -1
  21. package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.js +1 -1
  22. package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +1 -1
  23. package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.js +1 -1
  24. package/es/elements/ElementLookupDialog/HIDScanner/index.js +1 -1
  25. package/es/elements/ElementLookupDialog/Manual/ManualForm.js +1 -1
  26. package/es/elements/ElementLookupDialog/index.js +1 -1
  27. package/es/elements/ElementLookupDialog/utils/Giai.js +1 -1
  28. package/es/elements/ProjectSelect.js +1 -1
  29. package/es/i18n.d.ts +6 -0
  30. package/es/i18n.js +10 -0
  31. package/package.json +7 -7
  32. package/src/chrome/AppShell/index.tsx +29 -29
  33. package/src/chrome/openReport.ts +34 -34
  34. package/src/colorScheme.ts +81 -81
  35. package/src/components/DateNavigator/index.tsx +186 -186
  36. package/src/components/FilePond.tsx +312 -312
  37. package/src/components/ImageEditor/ImageEditor.tsx +343 -343
  38. package/src/components/ImageEditor/index.ts +9 -9
  39. package/src/components/ImageEditor/plugins/cropPlugin/CropOverlay.tsx +165 -165
  40. package/src/components/ImageEditor/plugins/cropPlugin/CropToolbar.tsx +48 -48
  41. package/src/components/ImageEditor/plugins/cropPlugin/useCropTool.ts +403 -403
  42. package/src/components/ImageEditor/plugins/redactPlugin/RedactToolbar.tsx +47 -47
  43. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomContext.tsx +23 -23
  44. package/src/components/ImageEditor/plugins/zoomPlugin/ZoomControls.tsx +40 -40
  45. package/src/components/ImageEditor/useEdgeDetection.ts +127 -127
  46. package/src/components/ImageEditor/useImageHistory.ts +197 -197
  47. package/src/components/ImageEditor/useOpenCV.ts +184 -184
  48. package/src/components/LinkedCardList/index.scss +95 -95
  49. package/src/components/MergeProgressDialog/index.tsx +249 -249
  50. package/src/components/PageBanner/index.tsx +80 -80
  51. package/src/components/PdfViewer/PdfViewer.tsx +158 -139
  52. package/src/components/ProgressBar/index.scss +96 -96
  53. package/src/components/SplitContainer/index.tsx +333 -333
  54. package/src/components/Toolbar/index.tsx +212 -212
  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/decoder.ts +32 -32
  67. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.ts +118 -118
  68. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/native.ts +103 -103
  69. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +95 -95
  70. package/src/elements/ElementLookupDialog/BarcodeScanner/decoders.test.ts +118 -118
  71. package/src/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.ts +21 -21
  72. package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +90 -90
  73. package/src/elements/ElementLookupDialog/BarcodeScanner/useScanner.ts +280 -280
  74. package/src/elements/ElementLookupDialog/HIDScanner/index.tsx +67 -67
  75. package/src/elements/ElementLookupDialog/Manual/ManualForm.tsx +141 -141
  76. package/src/elements/ElementLookupDialog/index.tsx +226 -226
  77. package/src/elements/ElementLookupDialog/utils/Giai.ts +209 -209
  78. package/src/elements/ProjectSelect.tsx +130 -130
  79. package/src/elements/index.ts +15 -15
  80. package/src/filter/index.ts +34 -34
  81. package/src/i18n.ts +13 -0
  82. package/src/index.ts +77 -77
  83. package/src/mui/MuiThemeProvider.tsx +174 -174
  84. package/src/mui/index.ts +1 -1
  85. package/src/test/setup.ts +8 -8
@@ -1,212 +1,212 @@
1
- import "./Toolbar.css";
2
-
3
- import { MenuHamburgerIcon } from "@navikt/aksel-icons";
4
- import { getLocalizedString } from "@olenbetong/appframe-core";
5
- import { useEffect, useLayoutEffect, useRef, useState } from "react";
6
- import { createPortal } from "react-dom";
7
- import { Link, type To } from "react-router";
8
-
9
- /*
10
- * The site template (`ob.2026.application`) renders the toolbar and leaves two regions to the
11
- * app. Both are filled through portals, so the app's React tree (router, contexts, state) is
12
- * preserved inside them:
13
- *
14
- * - the app region (`#ob-toolbar-app`): breadcrumbs first, then any per-app controls;
15
- * - the drawer slot (`#ob-toolbar-drawer`) at the far left of the toolbar, reserved for the
16
- * toggle of the app's navigation drawer — the same edge the drawer slides in from.
17
- *
18
- * Everything else in the toolbar (brand, Apps button, user menu) is the site's, rendered by the
19
- * chrome bundle. The phase 1 template rendered separate slots instead; those ids are kept as
20
- * fallbacks until every site runs the current template.
21
- */
22
-
23
- const APP_REGION_IDS = ["ob-toolbar-app", "ob-toolbar-breadcrumbs"];
24
- const DRAWER_SLOT_IDS = ["ob-toolbar-drawer", "ob-toolbar-menu-toggle"];
25
-
26
- function findTarget(ids: string[]) {
27
- if (typeof document === "undefined") return null;
28
- for (let id of ids) {
29
- let element = document.getElementById(id);
30
- if (element) return element;
31
- }
32
- return null;
33
- }
34
-
35
- export type ToolbarPortalProps = {
36
- children: React.ReactNode;
37
- };
38
-
39
- /**
40
- * Renders its children into the toolbar's app region. Render `ToolbarBreadcrumbs` before any
41
- * other `ToolbarPortal`, since the region lays its children out in mount order with the first
42
- * one taking the free space. Renders nothing on a template without a toolbar.
43
- */
44
- export function ToolbarPortal({ children }: ToolbarPortalProps) {
45
- let target = findTarget(APP_REGION_IDS);
46
- if (!target) return null;
47
- return createPortal(children, target);
48
- }
49
-
50
- export type ToolbarDrawerToggleProps = {
51
- /** Whether the drawer is open; sets `aria-expanded`. */
52
- open: boolean;
53
- onToggle: () => void;
54
- /** Accessible name. Defaults to the localized "Toggle menu". */
55
- label?: string;
56
- };
57
-
58
- /**
59
- * The hamburger button for the app's navigation drawer, rendered into the toolbar's drawer slot.
60
- * Styled by the site stylesheet (`.ob-toolbar__icon-button`) so it inherits the toolbar's
61
- * contrast colour on every brand. Renders nothing on a template without a toolbar.
62
- */
63
- export function ToolbarDrawerToggle({ open, onToggle, label }: ToolbarDrawerToggleProps) {
64
- let target = findTarget(DRAWER_SLOT_IDS);
65
- if (!target) return null;
66
-
67
- return createPortal(
68
- <button
69
- type="button"
70
- className="ob-toolbar__icon-button"
71
- aria-label={label ?? getLocalizedString("Toggle menu")}
72
- aria-expanded={open}
73
- onClick={onToggle}
74
- >
75
- <MenuHamburgerIcon aria-hidden fontSize="1.5rem" />
76
- </button>,
77
- target,
78
- );
79
- }
80
-
81
- export type BreadcrumbItem = {
82
- label: string;
83
- /**
84
- * A route inside the app, followed without reloading the page. Resolved through the router, so
85
- * it is relative to the app's basename — the article root is `"/"`, not `"/my-article"`.
86
- *
87
- * Requires the breadcrumbs to be rendered inside a router, which the portal preserves.
88
- */
89
- to?: To;
90
- /**
91
- * A plain URL, followed with a full page load. Use it to leave the app — the front page, or
92
- * another article. `to` wins when both are given.
93
- */
94
- href?: string;
95
- };
96
-
97
- /**
98
- * A crumb the user can follow. `to` goes through the router; `href` is an ordinary link.
99
- *
100
- * Either way it renders a real anchor with a real `href`, so ctrl-click, middle-click, "open in
101
- * new tab" and the status bar all keep working — `Link` only intercepts a plain left click.
102
- */
103
- function BreadcrumbLink({ item }: { item: BreadcrumbItem }) {
104
- if (item.to != null) return <Link to={item.to}>{item.label}</Link>;
105
- if (item.href) return <a href={item.href}>{item.label}</a>;
106
-
107
- return <span>{item.label}</span>;
108
- }
109
-
110
- export type ToolbarBreadcrumbsProps = {
111
- items: BreadcrumbItem[];
112
- };
113
-
114
- function BreadcrumbsInner({ items }: ToolbarBreadcrumbsProps) {
115
- let [firstVisible, setFirstVisible] = useState(0);
116
- let [overflowOpen, setOverflowOpen] = useState(false);
117
- let navRef = useRef<HTMLElement>(null);
118
- let listRef = useRef<HTMLOListElement>(null);
119
- let overflowItemRef = useRef<HTMLLIElement>(null);
120
-
121
- // Detect overflow: increment firstVisible until the list fits within the nav.
122
- // Runs after every render so it keeps pushing items into overflow until the
123
- // list stops overflowing or only the last item (current page) remains.
124
- useLayoutEffect(() => {
125
- let nav = navRef.current;
126
- let list = listRef.current;
127
- if (!nav || !list) return;
128
-
129
- if (list.scrollWidth > nav.clientWidth && firstVisible < items.length - 1) {
130
- setFirstVisible((prev) => prev + 1);
131
- }
132
- });
133
-
134
- // ResizeObserver resets firstVisible to 0 on container resize so that the
135
- // overflow calculation starts fresh at the new container width.
136
- useEffect(() => {
137
- let nav = navRef.current;
138
- if (!nav) return;
139
-
140
- let observer = new ResizeObserver(() => {
141
- setFirstVisible(0);
142
- });
143
-
144
- observer.observe(nav);
145
- return () => observer.disconnect();
146
- }, []);
147
-
148
- // Close the overflow dropdown when the user clicks outside of it.
149
- useEffect(() => {
150
- if (!overflowOpen) return;
151
-
152
- function handleClickOutside(event: MouseEvent) {
153
- if (overflowItemRef.current && !overflowItemRef.current.contains(event.target as Node)) {
154
- setOverflowOpen(false);
155
- }
156
- }
157
-
158
- document.addEventListener("mousedown", handleClickOutside);
159
- return () => document.removeEventListener("mousedown", handleClickOutside);
160
- }, [overflowOpen]);
161
-
162
- let hiddenItems = items.slice(0, firstVisible);
163
- let visibleItems = items.slice(firstVisible);
164
-
165
- return (
166
- <nav className="ob-breadcrumbs" aria-label="Breadcrumb" ref={navRef}>
167
- <ol className="ob-breadcrumbs__list" ref={listRef}>
168
- {firstVisible > 0 && (
169
- <li className="ob-breadcrumbs__item ob-breadcrumbs__overflow" ref={overflowItemRef}>
170
- <button
171
- type="button"
172
- aria-label="Show hidden breadcrumbs"
173
- aria-expanded={overflowOpen}
174
- aria-haspopup="true"
175
- onClick={() => setOverflowOpen((prev) => !prev)}
176
- >
177
- &hellip;
178
- </button>
179
- {overflowOpen && (
180
- <ul className="ob-breadcrumbs__overflow-menu" role="menu">
181
- {hiddenItems.map((item, index) => (
182
- // oxlint-disable-next-line react/no-array-index-key -- stable list with no reordering
183
- <li key={index} role="menuitem">
184
- <BreadcrumbLink item={item} />
185
- </li>
186
- ))}
187
- </ul>
188
- )}
189
- </li>
190
- )}
191
- {visibleItems.map((item, index) => {
192
- let actualIndex = firstVisible + index;
193
- let isCurrent = actualIndex === items.length - 1;
194
- return (
195
- <li key={actualIndex} className="ob-breadcrumbs__item">
196
- {isCurrent ? <span aria-current="page">{item.label}</span> : <BreadcrumbLink item={item} />}
197
- </li>
198
- );
199
- })}
200
- </ol>
201
- </nav>
202
- );
203
- }
204
-
205
- /** The app's breadcrumb trail, rendered into the toolbar's app region. The last item is the current page. */
206
- export function ToolbarBreadcrumbs({ items }: ToolbarBreadcrumbsProps) {
207
- return (
208
- <ToolbarPortal>
209
- <BreadcrumbsInner items={items} />
210
- </ToolbarPortal>
211
- );
212
- }
1
+ import "./Toolbar.css";
2
+
3
+ import { MenuHamburgerIcon } from "@navikt/aksel-icons";
4
+ import { useEffect, useLayoutEffect, useRef, useState } from "react";
5
+ import { createPortal } from "react-dom";
6
+ import { Link, type To } from "react-router";
7
+ import { getLocalizedString } from "../../i18n.js";
8
+
9
+ /*
10
+ * The site template (`ob.2026.application`) renders the toolbar and leaves two regions to the
11
+ * app. Both are filled through portals, so the app's React tree (router, contexts, state) is
12
+ * preserved inside them:
13
+ *
14
+ * - the app region (`#ob-toolbar-app`): breadcrumbs first, then any per-app controls;
15
+ * - the drawer slot (`#ob-toolbar-drawer`) at the far left of the toolbar, reserved for the
16
+ * toggle of the app's navigation drawer — the same edge the drawer slides in from.
17
+ *
18
+ * Everything else in the toolbar (brand, Apps button, user menu) is the site's, rendered by the
19
+ * chrome bundle. The phase 1 template rendered separate slots instead; those ids are kept as
20
+ * fallbacks until every site runs the current template.
21
+ */
22
+
23
+ const APP_REGION_IDS = ["ob-toolbar-app", "ob-toolbar-breadcrumbs"];
24
+ const DRAWER_SLOT_IDS = ["ob-toolbar-drawer", "ob-toolbar-menu-toggle"];
25
+
26
+ function findTarget(ids: string[]) {
27
+ if (typeof document === "undefined") return null;
28
+ for (let id of ids) {
29
+ let element = document.getElementById(id);
30
+ if (element) return element;
31
+ }
32
+ return null;
33
+ }
34
+
35
+ export type ToolbarPortalProps = {
36
+ children: React.ReactNode;
37
+ };
38
+
39
+ /**
40
+ * Renders its children into the toolbar's app region. Render `ToolbarBreadcrumbs` before any
41
+ * other `ToolbarPortal`, since the region lays its children out in mount order with the first
42
+ * one taking the free space. Renders nothing on a template without a toolbar.
43
+ */
44
+ export function ToolbarPortal({ children }: ToolbarPortalProps) {
45
+ let target = findTarget(APP_REGION_IDS);
46
+ if (!target) return null;
47
+ return createPortal(children, target);
48
+ }
49
+
50
+ export type ToolbarDrawerToggleProps = {
51
+ /** Whether the drawer is open; sets `aria-expanded`. */
52
+ open: boolean;
53
+ onToggle: () => void;
54
+ /** Accessible name. Defaults to the localized "Toggle menu". */
55
+ label?: string;
56
+ };
57
+
58
+ /**
59
+ * The hamburger button for the app's navigation drawer, rendered into the toolbar's drawer slot.
60
+ * Styled by the site stylesheet (`.ob-toolbar__icon-button`) so it inherits the toolbar's
61
+ * contrast colour on every brand. Renders nothing on a template without a toolbar.
62
+ */
63
+ export function ToolbarDrawerToggle({ open, onToggle, label }: ToolbarDrawerToggleProps) {
64
+ let target = findTarget(DRAWER_SLOT_IDS);
65
+ if (!target) return null;
66
+
67
+ return createPortal(
68
+ <button
69
+ type="button"
70
+ className="ob-toolbar__icon-button"
71
+ aria-label={label ?? getLocalizedString("Toggle menu")}
72
+ aria-expanded={open}
73
+ onClick={onToggle}
74
+ >
75
+ <MenuHamburgerIcon aria-hidden fontSize="1.5rem" />
76
+ </button>,
77
+ target,
78
+ );
79
+ }
80
+
81
+ export type BreadcrumbItem = {
82
+ label: string;
83
+ /**
84
+ * A route inside the app, followed without reloading the page. Resolved through the router, so
85
+ * it is relative to the app's basename — the article root is `"/"`, not `"/my-article"`.
86
+ *
87
+ * Requires the breadcrumbs to be rendered inside a router, which the portal preserves.
88
+ */
89
+ to?: To;
90
+ /**
91
+ * A plain URL, followed with a full page load. Use it to leave the app — the front page, or
92
+ * another article. `to` wins when both are given.
93
+ */
94
+ href?: string;
95
+ };
96
+
97
+ /**
98
+ * A crumb the user can follow. `to` goes through the router; `href` is an ordinary link.
99
+ *
100
+ * Either way it renders a real anchor with a real `href`, so ctrl-click, middle-click, "open in
101
+ * new tab" and the status bar all keep working — `Link` only intercepts a plain left click.
102
+ */
103
+ function BreadcrumbLink({ item }: { item: BreadcrumbItem }) {
104
+ if (item.to != null) return <Link to={item.to}>{item.label}</Link>;
105
+ if (item.href) return <a href={item.href}>{item.label}</a>;
106
+
107
+ return <span>{item.label}</span>;
108
+ }
109
+
110
+ export type ToolbarBreadcrumbsProps = {
111
+ items: BreadcrumbItem[];
112
+ };
113
+
114
+ function BreadcrumbsInner({ items }: ToolbarBreadcrumbsProps) {
115
+ let [firstVisible, setFirstVisible] = useState(0);
116
+ let [overflowOpen, setOverflowOpen] = useState(false);
117
+ let navRef = useRef<HTMLElement>(null);
118
+ let listRef = useRef<HTMLOListElement>(null);
119
+ let overflowItemRef = useRef<HTMLLIElement>(null);
120
+
121
+ // Detect overflow: increment firstVisible until the list fits within the nav.
122
+ // Runs after every render so it keeps pushing items into overflow until the
123
+ // list stops overflowing or only the last item (current page) remains.
124
+ useLayoutEffect(() => {
125
+ let nav = navRef.current;
126
+ let list = listRef.current;
127
+ if (!nav || !list) return;
128
+
129
+ if (list.scrollWidth > nav.clientWidth && firstVisible < items.length - 1) {
130
+ setFirstVisible((prev) => prev + 1);
131
+ }
132
+ });
133
+
134
+ // ResizeObserver resets firstVisible to 0 on container resize so that the
135
+ // overflow calculation starts fresh at the new container width.
136
+ useEffect(() => {
137
+ let nav = navRef.current;
138
+ if (!nav) return;
139
+
140
+ let observer = new ResizeObserver(() => {
141
+ setFirstVisible(0);
142
+ });
143
+
144
+ observer.observe(nav);
145
+ return () => observer.disconnect();
146
+ }, []);
147
+
148
+ // Close the overflow dropdown when the user clicks outside of it.
149
+ useEffect(() => {
150
+ if (!overflowOpen) return;
151
+
152
+ function handleClickOutside(event: MouseEvent) {
153
+ if (overflowItemRef.current && !overflowItemRef.current.contains(event.target as Node)) {
154
+ setOverflowOpen(false);
155
+ }
156
+ }
157
+
158
+ document.addEventListener("mousedown", handleClickOutside);
159
+ return () => document.removeEventListener("mousedown", handleClickOutside);
160
+ }, [overflowOpen]);
161
+
162
+ let hiddenItems = items.slice(0, firstVisible);
163
+ let visibleItems = items.slice(firstVisible);
164
+
165
+ return (
166
+ <nav className="ob-breadcrumbs" aria-label="Breadcrumb" ref={navRef}>
167
+ <ol className="ob-breadcrumbs__list" ref={listRef}>
168
+ {firstVisible > 0 && (
169
+ <li className="ob-breadcrumbs__item ob-breadcrumbs__overflow" ref={overflowItemRef}>
170
+ <button
171
+ type="button"
172
+ aria-label="Show hidden breadcrumbs"
173
+ aria-expanded={overflowOpen}
174
+ aria-haspopup="true"
175
+ onClick={() => setOverflowOpen((prev) => !prev)}
176
+ >
177
+ &hellip;
178
+ </button>
179
+ {overflowOpen && (
180
+ <ul className="ob-breadcrumbs__overflow-menu" role="menu">
181
+ {hiddenItems.map((item, index) => (
182
+ // oxlint-disable-next-line react/no-array-index-key -- stable list with no reordering
183
+ <li key={index} role="menuitem">
184
+ <BreadcrumbLink item={item} />
185
+ </li>
186
+ ))}
187
+ </ul>
188
+ )}
189
+ </li>
190
+ )}
191
+ {visibleItems.map((item, index) => {
192
+ let actualIndex = firstVisible + index;
193
+ let isCurrent = actualIndex === items.length - 1;
194
+ return (
195
+ <li key={actualIndex} className="ob-breadcrumbs__item">
196
+ {isCurrent ? <span aria-current="page">{item.label}</span> : <BreadcrumbLink item={item} />}
197
+ </li>
198
+ );
199
+ })}
200
+ </ol>
201
+ </nav>
202
+ );
203
+ }
204
+
205
+ /** The app's breadcrumb trail, rendered into the toolbar's app region. The last item is the current page. */
206
+ export function ToolbarBreadcrumbs({ items }: ToolbarBreadcrumbsProps) {
207
+ return (
208
+ <ToolbarPortal>
209
+ <BreadcrumbsInner items={items} />
210
+ </ToolbarPortal>
211
+ );
212
+ }
@@ -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 "@olenbetong/appframe-core";
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
+ }