@olenbetong/synergi-react 4.1.1 → 4.1.3

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