@olenbetong/synergi-react 3.1.1 → 3.2.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.
- package/es/chrome/AppMenu/AppMenuColorScheme.js +1 -1
- package/es/components/Toolbar/index.d.ts +21 -1
- package/es/components/Toolbar/index.js +19 -3
- package/package.json +16 -16
- package/src/chrome/AppMenu/AppMenuColorScheme.tsx +0 -1
- package/src/components/Toolbar/index.tsx +40 -11
- package/src/designsystemet-web-types.d.ts +24 -0
|
@@ -11,7 +11,7 @@ const OPTIONS = [
|
|
|
11
11
|
/** Icon-only color scheme toggle, shown at the bottom of the app menu rail. */
|
|
12
12
|
export function AppMenuColorScheme() {
|
|
13
13
|
let [preference, setPreference] = useColorSchemePreference();
|
|
14
|
-
return (_jsx("div", { className: "ob-app-menu__color-scheme", children: _jsx(ToggleGroup, { "data-size": "sm", "
|
|
14
|
+
return (_jsx("div", { className: "ob-app-menu__color-scheme", children: _jsx(ToggleGroup, { "data-size": "sm", "aria-label": getLocalizedString("Theme"), value: preference, onChange: (value) => setPreference(value), children: OPTIONS.map(({ value, label, Icon }) => {
|
|
15
15
|
let localizedLabel = getLocalizedString(label);
|
|
16
16
|
return (_jsx(Tooltip, { content: localizedLabel, children: _jsxs(ToggleGroup.Item, { value: value, children: [_jsx(Icon, { "aria-hidden": true, fontSize: "1.25rem" }), _jsx("span", { className: "ob-app-menu__color-scheme-label", children: localizedLabel })] }) }, value));
|
|
17
17
|
}) }) }));
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import "./Toolbar.css";
|
|
2
|
-
|
|
2
|
+
import { type To } from "react-router";
|
|
3
|
+
/**
|
|
4
|
+
* The named regions of the site toolbar an app can render into.
|
|
5
|
+
*
|
|
6
|
+
* `menu-toggle` sits at the very start of the toolbar, before the logo: it is where an app that
|
|
7
|
+
* has a navigation drawer of its own hangs the button that opens it. That belongs on the same
|
|
8
|
+
* edge as the drawer it controls — a toggle in `actions`, at the opposite end of the toolbar,
|
|
9
|
+
* reads as unrelated to the panel that slides in on the left.
|
|
10
|
+
*/
|
|
11
|
+
export type ToolbarPortalSlot = "menu-toggle" | "breadcrumbs" | "search" | "actions";
|
|
3
12
|
export type ToolbarPortalProps = {
|
|
4
13
|
slot: ToolbarPortalSlot;
|
|
5
14
|
children: React.ReactNode;
|
|
@@ -7,6 +16,17 @@ export type ToolbarPortalProps = {
|
|
|
7
16
|
export declare function ToolbarPortal({ slot, children }: ToolbarPortalProps): import("react").ReactPortal | null;
|
|
8
17
|
export type BreadcrumbItem = {
|
|
9
18
|
label: string;
|
|
19
|
+
/**
|
|
20
|
+
* A route inside the app, followed without reloading the page. Resolved through the router, so
|
|
21
|
+
* it is relative to the app's basename — the article root is `"/"`, not `"/my-article"`.
|
|
22
|
+
*
|
|
23
|
+
* Requires the breadcrumbs to be rendered inside a router, which the portal preserves.
|
|
24
|
+
*/
|
|
25
|
+
to?: To;
|
|
26
|
+
/**
|
|
27
|
+
* A plain URL, followed with a full page load. Use it to leave the app — the front page, or
|
|
28
|
+
* another article. `to` wins when both are given.
|
|
29
|
+
*/
|
|
10
30
|
href?: string;
|
|
11
31
|
};
|
|
12
32
|
export type ToolbarBreadcrumbsProps = {
|
|
@@ -2,13 +2,29 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import "./Toolbar.css";
|
|
3
3
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
+
import { Link } from "react-router";
|
|
5
6
|
export function ToolbarPortal({ slot, children }) {
|
|
6
|
-
// Target element IDs: ob-toolbar-
|
|
7
|
+
// Target element IDs: ob-toolbar-menu-toggle, ob-toolbar-breadcrumbs, ob-toolbar-search,
|
|
8
|
+
// ob-toolbar-actions. Older templates do not render every slot, so a missing one is not an
|
|
9
|
+
// error — the app simply renders nothing there.
|
|
7
10
|
const target = document.getElementById(`ob-toolbar-${slot}`);
|
|
8
11
|
if (!target)
|
|
9
12
|
return null;
|
|
10
13
|
return createPortal(children, target);
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* A crumb the user can follow. `to` goes through the router; `href` is an ordinary link.
|
|
17
|
+
*
|
|
18
|
+
* Either way it renders a real anchor with a real `href`, so ctrl-click, middle-click, "open in
|
|
19
|
+
* new tab" and the status bar all keep working — `Link` only intercepts a plain left click.
|
|
20
|
+
*/
|
|
21
|
+
function BreadcrumbLink({ item }) {
|
|
22
|
+
if (item.to != null)
|
|
23
|
+
return _jsx(Link, { to: item.to, children: item.label });
|
|
24
|
+
if (item.href)
|
|
25
|
+
return _jsx("a", { href: item.href, children: item.label });
|
|
26
|
+
return _jsx("span", { children: item.label });
|
|
27
|
+
}
|
|
12
28
|
function BreadcrumbsInner({ items }) {
|
|
13
29
|
let [firstVisible, setFirstVisible] = useState(0);
|
|
14
30
|
let [overflowOpen, setOverflowOpen] = useState(false);
|
|
@@ -53,10 +69,10 @@ function BreadcrumbsInner({ items }) {
|
|
|
53
69
|
}, [overflowOpen]);
|
|
54
70
|
let hiddenItems = items.slice(0, firstVisible);
|
|
55
71
|
let visibleItems = items.slice(firstVisible);
|
|
56
|
-
return (_jsx("nav", { className: "ob-breadcrumbs", "aria-label": "Breadcrumb", ref: navRef, children: _jsxs("ol", { className: "ob-breadcrumbs__list", ref: listRef, children: [firstVisible > 0 && (_jsxs("li", { className: "ob-breadcrumbs__item ob-breadcrumbs__overflow", ref: overflowItemRef, children: [_jsx("button", { type: "button", "aria-label": "Show hidden breadcrumbs", "aria-expanded": overflowOpen, "aria-haspopup": "true", onClick: () => setOverflowOpen((prev) => !prev), children: "\u2026" }), overflowOpen && (_jsx("ul", { className: "ob-breadcrumbs__overflow-menu", role: "menu", children: hiddenItems.map((item, index) => (_jsx("li", { role: "menuitem", children:
|
|
72
|
+
return (_jsx("nav", { className: "ob-breadcrumbs", "aria-label": "Breadcrumb", ref: navRef, children: _jsxs("ol", { className: "ob-breadcrumbs__list", ref: listRef, children: [firstVisible > 0 && (_jsxs("li", { className: "ob-breadcrumbs__item ob-breadcrumbs__overflow", ref: overflowItemRef, children: [_jsx("button", { type: "button", "aria-label": "Show hidden breadcrumbs", "aria-expanded": overflowOpen, "aria-haspopup": "true", onClick: () => setOverflowOpen((prev) => !prev), children: "\u2026" }), overflowOpen && (_jsx("ul", { className: "ob-breadcrumbs__overflow-menu", role: "menu", children: hiddenItems.map((item, index) => (_jsx("li", { role: "menuitem", children: _jsx(BreadcrumbLink, { item: item }) }, index))) }))] })), visibleItems.map((item, index) => {
|
|
57
73
|
let actualIndex = firstVisible + index;
|
|
58
74
|
let isCurrent = actualIndex === items.length - 1;
|
|
59
|
-
return (_jsx("li", { className: "ob-breadcrumbs__item", children: isCurrent ?
|
|
75
|
+
return (_jsx("li", { className: "ob-breadcrumbs__item", children: isCurrent ? _jsx("span", { "aria-current": "page", children: item.label }) : _jsx(BreadcrumbLink, { item: item }) }, actualIndex));
|
|
60
76
|
})] }) }));
|
|
61
77
|
}
|
|
62
78
|
export function ToolbarBreadcrumbs({ items }) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/synergi-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Standalone React component for SynergiWeb and Partner Portal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"@digdir/designsystemet-react": ">=1.18.0",
|
|
34
|
-
"@mui/material": ">=9.0.0",
|
|
35
34
|
"@navikt/aksel-icons": ">=8.16.1",
|
|
36
|
-
"react": ">=
|
|
37
|
-
"react-dom": ">=19.2.8"
|
|
35
|
+
"react-router": ">=8.3.0"
|
|
38
36
|
},
|
|
39
37
|
"sideEffects": false,
|
|
40
38
|
"dependencies": {
|
|
41
39
|
"@emotion/styled": "^11.14.1",
|
|
40
|
+
"@mui/icons-material": "9.4.0",
|
|
41
|
+
"@mui/material": "9.4.0",
|
|
42
42
|
"clsx": "^2.1.1",
|
|
43
43
|
"dynamsoft-javascript-barcode": "6.5.4",
|
|
44
44
|
"filepond": "^4.32.12",
|
|
@@ -51,12 +51,14 @@
|
|
|
51
51
|
"mitt": "^3.0.1",
|
|
52
52
|
"pdf-lib": "^1.17.1",
|
|
53
53
|
"pdfjs-dist": "5.7.284",
|
|
54
|
-
"react
|
|
54
|
+
"react": "19.3.0",
|
|
55
|
+
"react-dom": "19.3.0",
|
|
56
|
+
"react-pdf": "^10.5.0",
|
|
55
57
|
"@olenbetong/appframe-core": "2.13.1",
|
|
56
|
-
"@olenbetong/appframe-
|
|
57
|
-
"@olenbetong/appframe-data": "1.
|
|
58
|
-
"@olenbetong/appframe-react": "2.1.
|
|
59
|
-
"@olenbetong/appframe-
|
|
58
|
+
"@olenbetong/appframe-mui": "7.0.1",
|
|
59
|
+
"@olenbetong/appframe-data": "1.7.1",
|
|
60
|
+
"@olenbetong/appframe-react": "2.1.4",
|
|
61
|
+
"@olenbetong/appframe-ds": "1.0.1"
|
|
60
62
|
},
|
|
61
63
|
"repository": {
|
|
62
64
|
"type": "git",
|
|
@@ -70,15 +72,13 @@
|
|
|
70
72
|
]
|
|
71
73
|
},
|
|
72
74
|
"devDependencies": {
|
|
73
|
-
"@digdir/designsystemet-react": "1.
|
|
74
|
-
"@navikt/aksel-icons": "8.16.
|
|
75
|
+
"@digdir/designsystemet-react": "1.21.0",
|
|
76
|
+
"@navikt/aksel-icons": "8.16.2",
|
|
75
77
|
"@testing-library/jest-dom": "^7.0.1",
|
|
76
78
|
"@testing-library/dom": "^10.4.1",
|
|
77
|
-
"@testing-library/react": "16.3.
|
|
78
|
-
"@testing-library/user-event": "^14.6.
|
|
79
|
-
"happy-dom": "^20.
|
|
80
|
-
"react": "19.2.8",
|
|
81
|
-
"react-dom": "19.2.8",
|
|
79
|
+
"@testing-library/react": "16.3.3",
|
|
80
|
+
"@testing-library/user-event": "^14.6.7",
|
|
81
|
+
"happy-dom": "^20.14.3",
|
|
82
82
|
"replace-in-files": "^3.0.0"
|
|
83
83
|
},
|
|
84
84
|
"optionalDependencies": {},
|
|
@@ -18,7 +18,6 @@ export function AppMenuColorScheme() {
|
|
|
18
18
|
<div className="ob-app-menu__color-scheme">
|
|
19
19
|
<ToggleGroup
|
|
20
20
|
data-size="sm"
|
|
21
|
-
data-toggle-group={getLocalizedString("Theme")}
|
|
22
21
|
aria-label={getLocalizedString("Theme")}
|
|
23
22
|
value={preference}
|
|
24
23
|
onChange={(value) => setPreference(value as ColorSchemePreference)}
|
|
@@ -2,8 +2,17 @@ import "./Toolbar.css";
|
|
|
2
2
|
|
|
3
3
|
import { useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
4
4
|
import { createPortal } from "react-dom";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { Link, type To } from "react-router";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The named regions of the site toolbar an app can render into.
|
|
9
|
+
*
|
|
10
|
+
* `menu-toggle` sits at the very start of the toolbar, before the logo: it is where an app that
|
|
11
|
+
* has a navigation drawer of its own hangs the button that opens it. That belongs on the same
|
|
12
|
+
* edge as the drawer it controls — a toggle in `actions`, at the opposite end of the toolbar,
|
|
13
|
+
* reads as unrelated to the panel that slides in on the left.
|
|
14
|
+
*/
|
|
15
|
+
export type ToolbarPortalSlot = "menu-toggle" | "breadcrumbs" | "search" | "actions";
|
|
7
16
|
|
|
8
17
|
export type ToolbarPortalProps = {
|
|
9
18
|
slot: ToolbarPortalSlot;
|
|
@@ -11,7 +20,9 @@ export type ToolbarPortalProps = {
|
|
|
11
20
|
};
|
|
12
21
|
|
|
13
22
|
export function ToolbarPortal({ slot, children }: ToolbarPortalProps) {
|
|
14
|
-
// Target element IDs: ob-toolbar-
|
|
23
|
+
// Target element IDs: ob-toolbar-menu-toggle, ob-toolbar-breadcrumbs, ob-toolbar-search,
|
|
24
|
+
// ob-toolbar-actions. Older templates do not render every slot, so a missing one is not an
|
|
25
|
+
// error — the app simply renders nothing there.
|
|
15
26
|
const target = document.getElementById(`ob-toolbar-${slot}`);
|
|
16
27
|
if (!target) return null;
|
|
17
28
|
return createPortal(children, target);
|
|
@@ -19,9 +30,33 @@ export function ToolbarPortal({ slot, children }: ToolbarPortalProps) {
|
|
|
19
30
|
|
|
20
31
|
export type BreadcrumbItem = {
|
|
21
32
|
label: string;
|
|
33
|
+
/**
|
|
34
|
+
* A route inside the app, followed without reloading the page. Resolved through the router, so
|
|
35
|
+
* it is relative to the app's basename — the article root is `"/"`, not `"/my-article"`.
|
|
36
|
+
*
|
|
37
|
+
* Requires the breadcrumbs to be rendered inside a router, which the portal preserves.
|
|
38
|
+
*/
|
|
39
|
+
to?: To;
|
|
40
|
+
/**
|
|
41
|
+
* A plain URL, followed with a full page load. Use it to leave the app — the front page, or
|
|
42
|
+
* another article. `to` wins when both are given.
|
|
43
|
+
*/
|
|
22
44
|
href?: string;
|
|
23
45
|
};
|
|
24
46
|
|
|
47
|
+
/**
|
|
48
|
+
* A crumb the user can follow. `to` goes through the router; `href` is an ordinary link.
|
|
49
|
+
*
|
|
50
|
+
* Either way it renders a real anchor with a real `href`, so ctrl-click, middle-click, "open in
|
|
51
|
+
* new tab" and the status bar all keep working — `Link` only intercepts a plain left click.
|
|
52
|
+
*/
|
|
53
|
+
function BreadcrumbLink({ item }: { item: BreadcrumbItem }) {
|
|
54
|
+
if (item.to != null) return <Link to={item.to}>{item.label}</Link>;
|
|
55
|
+
if (item.href) return <a href={item.href}>{item.label}</a>;
|
|
56
|
+
|
|
57
|
+
return <span>{item.label}</span>;
|
|
58
|
+
}
|
|
59
|
+
|
|
25
60
|
export type ToolbarBreadcrumbsProps = {
|
|
26
61
|
items: BreadcrumbItem[];
|
|
27
62
|
};
|
|
@@ -96,7 +131,7 @@ function BreadcrumbsInner({ items }: ToolbarBreadcrumbsProps) {
|
|
|
96
131
|
{hiddenItems.map((item, index) => (
|
|
97
132
|
// oxlint-disable-next-line react/no-array-index-key -- stable list with no reordering
|
|
98
133
|
<li key={index} role="menuitem">
|
|
99
|
-
|
|
134
|
+
<BreadcrumbLink item={item} />
|
|
100
135
|
</li>
|
|
101
136
|
))}
|
|
102
137
|
</ul>
|
|
@@ -108,13 +143,7 @@ function BreadcrumbsInner({ items }: ToolbarBreadcrumbsProps) {
|
|
|
108
143
|
let isCurrent = actualIndex === items.length - 1;
|
|
109
144
|
return (
|
|
110
145
|
<li key={actualIndex} className="ob-breadcrumbs__item">
|
|
111
|
-
{isCurrent ?
|
|
112
|
-
<span aria-current="page">{item.label}</span>
|
|
113
|
-
) : item.href ? (
|
|
114
|
-
<a href={item.href}>{item.label}</a>
|
|
115
|
-
) : (
|
|
116
|
-
<span>{item.label}</span>
|
|
117
|
-
)}
|
|
146
|
+
{isCurrent ? <span aria-current="page">{item.label}</span> : <BreadcrumbLink item={item} />}
|
|
118
147
|
</li>
|
|
119
148
|
);
|
|
120
149
|
})}
|
|
@@ -0,0 +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
|
+
}
|