@olenbetong/synergi-react 2.6.0 → 2.7.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.
- package/es/components/AppMenu/AppMenu.css +0 -25
- package/es/components/AppMenu/AppMenu.js +1 -2
- package/es/components/AppMenu/index.d.ts +0 -1
- package/es/components/AppMenu/index.js +0 -1
- package/es/index.d.ts +1 -2
- package/es/index.js +1 -2
- package/package.json +3 -3
- package/src/colorScheme.ts +81 -81
- package/src/components/AppMenu/AppMenu.css +648 -546
- package/src/components/AppMenu/AppMenu.tsx +285 -478
- package/src/components/AppMenu/AppMenuColorScheme.tsx +41 -41
- package/src/components/AppMenu/AppMenuFavoriteButton.tsx +47 -0
- package/src/components/AppMenu/AppMenuHeader.tsx +79 -0
- package/src/components/AppMenu/AppMenuList.tsx +89 -0
- package/src/components/AppMenu/AppMenuRail.tsx +117 -0
- package/src/components/AppMenu/icons.tsx +76 -0
- package/src/components/AppMenu/index.ts +17 -12
- package/src/components/AppMenu/menuEntries.ts +128 -0
- package/src/components/AppMenu/types.ts +45 -35
- package/src/components/AppMenu/useFavorites.ts +40 -0
- package/src/components/AppMenu/useRovingTabIndex.ts +130 -118
- package/src/components/AppShell/index.tsx +287 -259
- package/src/components/LinkedCardList/index.scss +93 -93
- package/src/components/ProgressBar/index.scss +94 -94
- package/src/index.ts +61 -61
- package/es/colorScheme.d.ts +0 -17
- package/es/colorScheme.js +0 -54
- package/es/components/AppMenu/AppMenuColorScheme.d.ts +0 -2
- package/es/components/AppMenu/AppMenuColorScheme.js +0 -18
|
@@ -179,31 +179,6 @@
|
|
|
179
179
|
letter-spacing: 0.04em;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
/*
|
|
183
|
-
* Color scheme toggle. `margin-block-start: auto` pins it to the bottom of the
|
|
184
|
-
* rail; the group list above shrinks and scrolls instead of pushing it down.
|
|
185
|
-
*/
|
|
186
|
-
.ob-app-menu__color-scheme {
|
|
187
|
-
display: flex;
|
|
188
|
-
flex: 0 0 auto;
|
|
189
|
-
justify-content: center;
|
|
190
|
-
margin-block-start: auto;
|
|
191
|
-
padding-block-start: var(--ds-size-3);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/* Icon-only buttons: the label text stays in the DOM as the accessible name. */
|
|
195
|
-
.ob-app-menu__color-scheme-label {
|
|
196
|
-
position: absolute;
|
|
197
|
-
width: 1px;
|
|
198
|
-
height: 1px;
|
|
199
|
-
margin: -1px;
|
|
200
|
-
padding: 0;
|
|
201
|
-
overflow: hidden;
|
|
202
|
-
clip-path: inset(50%);
|
|
203
|
-
white-space: nowrap;
|
|
204
|
-
border: 0;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
182
|
/* -------------------------------------------------------------------------- */
|
|
208
183
|
/* Right pane: app list */
|
|
209
184
|
/* -------------------------------------------------------------------------- */
|
|
@@ -4,7 +4,6 @@ import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
|
4
4
|
import { useData, useLoading } from "@olenbetong/appframe-react";
|
|
5
5
|
import clsx from "clsx";
|
|
6
6
|
import { Fragment, useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
import { AppMenuColorScheme } from "./AppMenuColorScheme.js";
|
|
8
7
|
import { AppMenuUserMenu } from "./AppMenuUserMenu.js";
|
|
9
8
|
import { useRovingTabIndex } from "./useRovingTabIndex.js";
|
|
10
9
|
/** Sentinel group key for apps that have no MenuGroup set. */
|
|
@@ -217,7 +216,7 @@ export function AppMenu({ dataObject, open, onClose, categories = [], userDataOb
|
|
|
217
216
|
categoryIndex += 1;
|
|
218
217
|
let railIndex = categoryIndex;
|
|
219
218
|
return (_jsxs("button", { type: "button", className: "ob-app-menu__group-button", "aria-current": isSelected({ type: "category", id: category.id }) ? "true" : undefined, onClick: () => select({ type: "category", id: category.id }), ...groupRoving.getItemProps(railIndex), children: [_jsx("span", { children: category.label }), _jsx("span", { className: "ob-app-menu__count", children: countItems(category) })] }, category.id));
|
|
220
|
-
})] }, section || "\u0000default")))] })
|
|
219
|
+
})] }, section || "\u0000default")))] })] }), _jsxs("div", { className: "ob-app-menu__content", children: [isLoading && !hasApps && !activeCategory && (_jsx("p", { className: "ob-app-menu__message", children: getLocalizedString("Loading...") })), !isLoading && paneItemCount === 0 && (_jsx("p", { className: "ob-app-menu__message", children: getLocalizedString("No applications found") })), paneItemCount > 0 && (_jsx("div", { className: "ob-app-menu__columns", onKeyDown: appRoving.onKeyDown, children: paneGroups.map((group, groupIdx) => (_jsxs("section", { className: "ob-app-menu__group", children: [group.title && _jsx("h2", { className: "ob-app-menu__group-title", children: group.title }), _jsx("ul", { className: "ob-app-menu__list", children: group.items.map((item) => {
|
|
221
220
|
itemIndex += 1;
|
|
222
221
|
return _jsx("li", { children: renderItem(item, itemIndex) }, item.href ?? item.label);
|
|
223
222
|
}) })] }, group.title ?? groupIdx))) })), _jsxs("div", { className: "ob-app-menu__content-header", children: [_jsx("button", { type: "button", className: "ob-app-menu__pane-toggle", onClick: () => setMobilePane(mobilePane === "apps" ? "groups" : "apps"), children: mobilePane === "apps" ? getLocalizedString("Categories") : getLocalizedString("Applications") }), hasUpdate && (_jsxs("button", { type: "button", className: "ob-app-menu__update", "aria-label": getLocalizedString("Install update and reload"), onClick: onInstallUpdate, children: [_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", width: "18", height: "18", children: _jsx("path", { d: "M12 4a8 8 0 0 1 7.5 5.2.75.75 0 1 1-1.4.5A6.5 6.5 0 0 0 6.2 9.25H8.5a.75.75 0 0 1 0 1.5H4.75A.75.75 0 0 1 4 10V6.25a.75.75 0 0 1 1.5 0v1.86A8 8 0 0 1 12 4m-7.6 9.55a.75.75 0 0 1 .95.45A6.5 6.5 0 0 0 17.8 14.75H15.5a.75.75 0 0 1 0-1.5h3.75a.75.75 0 0 1 .75.75V17.75a.75.75 0 0 1-1.5 0v-1.86A8 8 0 0 1 4.5 14.5a.75.75 0 0 1 .45-.95z" }) }), _jsx("span", { className: "ob-app-menu__update-label", children: getLocalizedString("Install update and reload") })] })), userDataObject && (_jsx(AppMenuUserMenu, { dataObject: userDataObject, items: userMenuItems, subtitle: userSubtitle })), _jsx("button", { type: "button", className: "ob-app-menu__close", "aria-label": getLocalizedString("Close"), onClick: onClose, children: _jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", width: "20", height: "20", children: _jsx("path", { d: "M6.53 5.47a.75.75 0 0 0-1.06 1.06L10.94 12l-5.47 5.47a.75.75 0 1 0 1.06 1.06L12 13.06l5.47 5.47a.75.75 0 1 0 1.06-1.06L13.06 12l5.47-5.47a.75.75 0 0 0-1.06-1.06L12 10.94z" }) }) })] })] })] }) }));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { AppMenu, type AppMenuArticle, type AppMenuProps } from "./AppMenu.js";
|
|
2
|
-
export { AppMenuColorScheme } from "./AppMenuColorScheme.js";
|
|
3
2
|
export { AppMenuToggle, type AppMenuToggleProps } from "./AppMenuToggle.js";
|
|
4
3
|
export { AppMenuUserMenu, type AppMenuUser, type AppMenuUserMenuProps, defaultUserMenuItems, } from "./AppMenuUserMenu.js";
|
|
5
4
|
export { createDeveloperCategories, type DeveloperCategoryOptions } from "./developerCategories.js";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { AppMenu } from "./AppMenu.js";
|
|
2
|
-
export { AppMenuColorScheme } from "./AppMenuColorScheme.js";
|
|
3
2
|
export { AppMenuToggle } from "./AppMenuToggle.js";
|
|
4
3
|
export { AppMenuUserMenu, defaultUserMenuItems, } from "./AppMenuUserMenu.js";
|
|
5
4
|
export { createDeveloperCategories } from "./developerCategories.js";
|
package/es/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { AppMenu, type AppMenuArticle, type AppMenuCategory,
|
|
1
|
+
export { AppMenu, type AppMenuArticle, type AppMenuCategory, type AppMenuLink, type AppMenuLinkGroup, type AppMenuProps, AppMenuToggle, type AppMenuToggleProps, type AppMenuUser, AppMenuUserMenu, type AppMenuUserMenuProps, createDeveloperCategories, defaultUserMenuItems, type DeveloperCategoryOptions, useServiceWorkerUpdate, } from "./components/AppMenu/index.js";
|
|
2
2
|
export { AppShell, type AppShellProps } from "./components/AppShell/index.js";
|
|
3
3
|
export { Checkbox, type CheckboxProps } from "./components/Checkbox/index.js";
|
|
4
|
-
export { COLOR_SCHEME_CHANGE_EVENT, type ColorSchemePreference, getColorSchemePreference, setColorSchemePreference, useColorSchemePreference, } from "./colorScheme.js";
|
|
5
4
|
export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
|
|
6
5
|
export { DateNavigator } from "./components/DateNavigator/index.js";
|
|
7
6
|
export * from "./components/FilePond.js";
|
package/es/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export { AppMenu,
|
|
1
|
+
export { AppMenu, AppMenuToggle, AppMenuUserMenu, createDeveloperCategories, defaultUserMenuItems, useServiceWorkerUpdate, } from "./components/AppMenu/index.js";
|
|
2
2
|
export { AppShell } from "./components/AppShell/index.js";
|
|
3
3
|
export { Checkbox } from "./components/Checkbox/index.js";
|
|
4
|
-
export { COLOR_SCHEME_CHANGE_EVENT, getColorSchemePreference, setColorSchemePreference, useColorSchemePreference, } from "./colorScheme.js";
|
|
5
4
|
export { CardColumn, CardDetail, CardLabel, CardStep, CardStepList, ColorCard } from "./components/ColorCard/index.js";
|
|
6
5
|
export { DateNavigator } from "./components/DateNavigator/index.js";
|
|
7
6
|
export * from "./components/FilePond.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olenbetong/synergi-react",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "Standalone React component for SynergiWeb and Partner Portal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"pdfjs-dist": "5.7.284",
|
|
46
46
|
"react-pdf": "^10.4.1",
|
|
47
47
|
"@olenbetong/appframe-core": "2.11.10",
|
|
48
|
-
"@olenbetong/appframe-
|
|
48
|
+
"@olenbetong/appframe-react": "2.0.0",
|
|
49
49
|
"@olenbetong/appframe-data": "1.5.0",
|
|
50
|
-
"@olenbetong/appframe-
|
|
50
|
+
"@olenbetong/appframe-mui": "6.6.0"
|
|
51
51
|
},
|
|
52
52
|
"repository": {
|
|
53
53
|
"type": "git",
|
package/src/colorScheme.ts
CHANGED
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Color scheme preference (system / light / dark).
|
|
5
|
-
*
|
|
6
|
-
* The preference lives in the `ob-color-scheme` cookie so the article template
|
|
7
|
-
* can read it server side and render `data-color-scheme` on `<html>` and
|
|
8
|
-
* `<body>` before the first paint. The site script for the 2026 template
|
|
9
|
-
* (`ob.2026.application.min.js`) owns the same cookie for the toolbar user menu
|
|
10
|
-
* toggle, so both write the cookie, apply the attributes, and dispatch
|
|
11
|
-
* `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
export type ColorSchemePreference = "auto" | "light" | "dark";
|
|
15
|
-
|
|
16
|
-
const COOKIE_NAME = "ob-color-scheme";
|
|
17
|
-
const COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
|
|
18
|
-
const DEFAULT_PREFERENCE: ColorSchemePreference = "auto";
|
|
19
|
-
const PREFERENCES: ColorSchemePreference[] = ["auto", "light", "dark"];
|
|
20
|
-
|
|
21
|
-
/** Dispatched on `window` whenever the preference changes. */
|
|
22
|
-
export const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
|
|
23
|
-
|
|
24
|
-
function isColorSchemePreference(value: unknown): value is ColorSchemePreference {
|
|
25
|
-
return typeof value === "string" && PREFERENCES.includes(value as ColorSchemePreference);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function getColorSchemePreference(): ColorSchemePreference {
|
|
29
|
-
if (typeof document === "undefined") return DEFAULT_PREFERENCE;
|
|
30
|
-
|
|
31
|
-
let match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]*)`));
|
|
32
|
-
let value = match ? decodeURIComponent(match[1]) : null;
|
|
33
|
-
|
|
34
|
-
return isColorSchemePreference(value) ? value : DEFAULT_PREFERENCE;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function setColorSchemePreference(preference: ColorSchemePreference) {
|
|
38
|
-
if (typeof document === "undefined" || !isColorSchemePreference(preference)) return;
|
|
39
|
-
|
|
40
|
-
let secure = window.location.protocol === "https:" ? ";secure" : "";
|
|
41
|
-
document.cookie = `${COOKIE_NAME}=${preference};path=/;max-age=${COOKIE_MAX_AGE};samesite=lax${secure}`;
|
|
42
|
-
|
|
43
|
-
/*
|
|
44
|
-
* Both elements are updated: `<html>` so the browser applies `color-scheme`
|
|
45
|
-
* to scrollbars and native controls, `<body>` because Designsystemet declares
|
|
46
|
-
* the light tokens on `:root` as well (`:root, [data-color-scheme="light"]`).
|
|
47
|
-
*/
|
|
48
|
-
document.documentElement.dataset.colorScheme = preference;
|
|
49
|
-
if (document.body) document.body.dataset.colorScheme = preference;
|
|
50
|
-
|
|
51
|
-
window.dispatchEvent(new CustomEvent(COLOR_SCHEME_CHANGE_EVENT, { detail: preference }));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Reads the stored preference and keeps it in sync with other toggles on the page. */
|
|
55
|
-
export function useColorSchemePreference(): [ColorSchemePreference, (value: ColorSchemePreference) => void] {
|
|
56
|
-
let [preference, setPreference] = useState<ColorSchemePreference>(() => getColorSchemePreference());
|
|
57
|
-
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
function update() {
|
|
60
|
-
setPreference(getColorSchemePreference());
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
update();
|
|
64
|
-
|
|
65
|
-
window.addEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
|
|
66
|
-
// Cookies fire no change event, so also pick up changes made in another tab.
|
|
67
|
-
document.addEventListener("visibilitychange", update);
|
|
68
|
-
|
|
69
|
-
return () => {
|
|
70
|
-
window.removeEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
|
|
71
|
-
document.removeEventListener("visibilitychange", update);
|
|
72
|
-
};
|
|
73
|
-
}, []);
|
|
74
|
-
|
|
75
|
-
let setValue = useCallback((value: ColorSchemePreference) => {
|
|
76
|
-
setColorSchemePreference(value);
|
|
77
|
-
setPreference(value);
|
|
78
|
-
}, []);
|
|
79
|
-
|
|
80
|
-
return [preference, setValue];
|
|
81
|
-
}
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Color scheme preference (system / light / dark).
|
|
5
|
+
*
|
|
6
|
+
* The preference lives in the `ob-color-scheme` cookie so the article template
|
|
7
|
+
* can read it server side and render `data-color-scheme` on `<html>` and
|
|
8
|
+
* `<body>` before the first paint. The site script for the 2026 template
|
|
9
|
+
* (`ob.2026.application.min.js`) owns the same cookie for the toolbar user menu
|
|
10
|
+
* toggle, so both write the cookie, apply the attributes, and dispatch
|
|
11
|
+
* `COLOR_SCHEME_CHANGE_EVENT` to keep every toggle on the page in sync.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export type ColorSchemePreference = "auto" | "light" | "dark";
|
|
15
|
+
|
|
16
|
+
const COOKIE_NAME = "ob-color-scheme";
|
|
17
|
+
const COOKIE_MAX_AGE = 60 * 60 * 24 * 365;
|
|
18
|
+
const DEFAULT_PREFERENCE: ColorSchemePreference = "auto";
|
|
19
|
+
const PREFERENCES: ColorSchemePreference[] = ["auto", "light", "dark"];
|
|
20
|
+
|
|
21
|
+
/** Dispatched on `window` whenever the preference changes. */
|
|
22
|
+
export const COLOR_SCHEME_CHANGE_EVENT = "ob:colorschemechange";
|
|
23
|
+
|
|
24
|
+
function isColorSchemePreference(value: unknown): value is ColorSchemePreference {
|
|
25
|
+
return typeof value === "string" && PREFERENCES.includes(value as ColorSchemePreference);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function getColorSchemePreference(): ColorSchemePreference {
|
|
29
|
+
if (typeof document === "undefined") return DEFAULT_PREFERENCE;
|
|
30
|
+
|
|
31
|
+
let match = document.cookie.match(new RegExp(`(?:^|;\\s*)${COOKIE_NAME}=([^;]*)`));
|
|
32
|
+
let value = match ? decodeURIComponent(match[1]) : null;
|
|
33
|
+
|
|
34
|
+
return isColorSchemePreference(value) ? value : DEFAULT_PREFERENCE;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function setColorSchemePreference(preference: ColorSchemePreference) {
|
|
38
|
+
if (typeof document === "undefined" || !isColorSchemePreference(preference)) return;
|
|
39
|
+
|
|
40
|
+
let secure = window.location.protocol === "https:" ? ";secure" : "";
|
|
41
|
+
document.cookie = `${COOKIE_NAME}=${preference};path=/;max-age=${COOKIE_MAX_AGE};samesite=lax${secure}`;
|
|
42
|
+
|
|
43
|
+
/*
|
|
44
|
+
* Both elements are updated: `<html>` so the browser applies `color-scheme`
|
|
45
|
+
* to scrollbars and native controls, `<body>` because Designsystemet declares
|
|
46
|
+
* the light tokens on `:root` as well (`:root, [data-color-scheme="light"]`).
|
|
47
|
+
*/
|
|
48
|
+
document.documentElement.dataset.colorScheme = preference;
|
|
49
|
+
if (document.body) document.body.dataset.colorScheme = preference;
|
|
50
|
+
|
|
51
|
+
window.dispatchEvent(new CustomEvent(COLOR_SCHEME_CHANGE_EVENT, { detail: preference }));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Reads the stored preference and keeps it in sync with other toggles on the page. */
|
|
55
|
+
export function useColorSchemePreference(): [ColorSchemePreference, (value: ColorSchemePreference) => void] {
|
|
56
|
+
let [preference, setPreference] = useState<ColorSchemePreference>(() => getColorSchemePreference());
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
function update() {
|
|
60
|
+
setPreference(getColorSchemePreference());
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
update();
|
|
64
|
+
|
|
65
|
+
window.addEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
|
|
66
|
+
// Cookies fire no change event, so also pick up changes made in another tab.
|
|
67
|
+
document.addEventListener("visibilitychange", update);
|
|
68
|
+
|
|
69
|
+
return () => {
|
|
70
|
+
window.removeEventListener(COLOR_SCHEME_CHANGE_EVENT, update);
|
|
71
|
+
document.removeEventListener("visibilitychange", update);
|
|
72
|
+
};
|
|
73
|
+
}, []);
|
|
74
|
+
|
|
75
|
+
let setValue = useCallback((value: ColorSchemePreference) => {
|
|
76
|
+
setColorSchemePreference(value);
|
|
77
|
+
setPreference(value);
|
|
78
|
+
}, []);
|
|
79
|
+
|
|
80
|
+
return [preference, setValue];
|
|
81
|
+
}
|