@olenbetong/synergi-react 3.2.1 → 4.0.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/chrome/AppShell/index.d.ts +10 -2
- package/es/chrome/AppShell/index.js +13 -97
- package/es/chrome/openReport.d.ts +22 -0
- package/es/chrome/openReport.js +21 -0
- package/es/colorScheme.d.ts +4 -4
- package/es/components/Toolbar/index.d.ts +20 -11
- package/es/components/Toolbar/index.js +47 -6
- package/es/elements/ElementLookup.d.ts +7 -2
- package/es/elements/ElementLookup.js +4 -6
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoder.d.ts +32 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.d.ts +28 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.js +81 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.d.ts +26 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/native.js +70 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.d.ts +20 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.js +69 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/decoders.test.js +103 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.d.ts +6 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.js +19 -0
- package/es/elements/ElementLookupDialog/BarcodeScanner/index.d.ts +14 -7
- package/es/elements/ElementLookupDialog/BarcodeScanner/index.js +10 -6
- package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.d.ts +14 -12
- package/es/elements/ElementLookupDialog/BarcodeScanner/useScanner.js +222 -116
- package/es/elements/ElementLookupDialog/index.d.ts +6 -0
- package/es/elements/ElementLookupDialog/index.js +2 -2
- package/es/index.d.ts +3 -4
- package/es/index.js +5 -4
- package/package.json +11 -10
- package/src/chrome/AppShell/index.tsx +13 -134
- package/src/chrome/openReport.ts +34 -0
- package/src/colorScheme.ts +4 -4
- package/src/components/Toolbar/index.tsx +65 -14
- package/src/elements/ElementLookup.tsx +12 -5
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoder.ts +32 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/dbr.ts +118 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/native.ts +103 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders/zxing.ts +95 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/decoders.test.ts +118 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/duplicateFilter.ts +21 -0
- package/src/elements/ElementLookupDialog/BarcodeScanner/index.tsx +29 -14
- package/src/elements/ElementLookupDialog/BarcodeScanner/useScanner.ts +246 -136
- package/src/elements/ElementLookupDialog/index.tsx +12 -4
- package/src/index.ts +6 -37
- package/es/chrome/AppMenu/AppMenu.css +0 -648
- package/es/chrome/AppMenu/AppMenu.d.ts +0 -56
- package/es/chrome/AppMenu/AppMenu.js +0 -145
- package/es/chrome/AppMenu/AppMenuColorScheme.d.ts +0 -2
- package/es/chrome/AppMenu/AppMenuColorScheme.js +0 -18
- package/es/chrome/AppMenu/AppMenuFavoriteButton.d.ts +0 -18
- package/es/chrome/AppMenu/AppMenuFavoriteButton.js +0 -11
- package/es/chrome/AppMenu/AppMenuHeader.d.ts +0 -24
- package/es/chrome/AppMenu/AppMenuHeader.js +0 -18
- package/es/chrome/AppMenu/AppMenuList.d.ts +0 -18
- package/es/chrome/AppMenu/AppMenuList.js +0 -39
- package/es/chrome/AppMenu/AppMenuRail.d.ts +0 -26
- package/es/chrome/AppMenu/AppMenuRail.js +0 -30
- package/es/chrome/AppMenu/AppMenuToggle.d.ts +0 -15
- package/es/chrome/AppMenu/AppMenuToggle.js +0 -14
- package/es/chrome/AppMenu/AppMenuUserMenu.d.ts +0 -32
- package/es/chrome/AppMenu/AppMenuUserMenu.js +0 -110
- package/es/chrome/AppMenu/developerCategories.d.ts +0 -24
- package/es/chrome/AppMenu/developerCategories.js +0 -116
- package/es/chrome/AppMenu/icons.d.ts +0 -15
- package/es/chrome/AppMenu/icons.js +0 -13
- package/es/chrome/AppMenu/index.d.ts +0 -12
- package/es/chrome/AppMenu/index.js +0 -10
- package/es/chrome/AppMenu/menuEntries.d.ts +0 -51
- package/es/chrome/AppMenu/menuEntries.js +0 -93
- package/es/chrome/AppMenu/types.d.ts +0 -43
- package/es/chrome/AppMenu/useFavorites.d.ts +0 -13
- package/es/chrome/AppMenu/useFavorites.js +0 -28
- package/es/chrome/AppMenu/useRovingTabIndex.d.ts +0 -28
- package/es/chrome/AppMenu/useRovingTabIndex.js +0 -114
- package/es/chrome/AppMenu/useServiceWorkerUpdate.d.ts +0 -16
- package/es/chrome/AppMenu/useServiceWorkerUpdate.js +0 -62
- package/es/report/ReportLauncher.css +0 -147
- package/es/report/ReportLauncher.d.ts +0 -55
- package/es/report/ReportLauncher.js +0 -142
- package/es/report/ReportLauncher.test.js +0 -231
- package/es/report/ReportParameters.css +0 -29
- package/es/report/ReportParameters.d.ts +0 -46
- package/es/report/ReportParameters.js +0 -65
- package/es/report/ReportParameters.test.d.ts +0 -1
- package/es/report/ReportParameters.test.js +0 -84
- package/es/report/index.d.ts +0 -2
- package/es/report/index.js +0 -2
- package/src/chrome/AppMenu/AppMenu.css +0 -648
- package/src/chrome/AppMenu/AppMenu.tsx +0 -285
- package/src/chrome/AppMenu/AppMenuColorScheme.tsx +0 -41
- package/src/chrome/AppMenu/AppMenuFavoriteButton.tsx +0 -47
- package/src/chrome/AppMenu/AppMenuHeader.tsx +0 -79
- package/src/chrome/AppMenu/AppMenuList.tsx +0 -89
- package/src/chrome/AppMenu/AppMenuRail.tsx +0 -117
- package/src/chrome/AppMenu/AppMenuToggle.tsx +0 -51
- package/src/chrome/AppMenu/AppMenuUserMenu.tsx +0 -190
- package/src/chrome/AppMenu/developerCategories.ts +0 -142
- package/src/chrome/AppMenu/icons.tsx +0 -76
- package/src/chrome/AppMenu/index.ts +0 -17
- package/src/chrome/AppMenu/menuEntries.ts +0 -128
- package/src/chrome/AppMenu/types.ts +0 -45
- package/src/chrome/AppMenu/useFavorites.ts +0 -40
- package/src/chrome/AppMenu/useRovingTabIndex.ts +0 -130
- package/src/chrome/AppMenu/useServiceWorkerUpdate.ts +0 -68
- package/src/report/ReportLauncher.css +0 -147
- package/src/report/ReportLauncher.test.tsx +0 -281
- package/src/report/ReportLauncher.tsx +0 -420
- package/src/report/ReportParameters.css +0 -29
- package/src/report/ReportParameters.test.tsx +0 -133
- package/src/report/ReportParameters.tsx +0 -198
- package/src/report/index.ts +0 -2
- /package/es/{chrome/AppMenu/types.js → elements/ElementLookupDialog/BarcodeScanner/decoder.js} +0 -0
- /package/es/{report/ReportLauncher.test.d.ts → elements/ElementLookupDialog/BarcodeScanner/decoders.test.d.ts} +0 -0
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import "./AppMenu.css";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
|
-
import { useData, useLoading } from "@olenbetong/appframe-react";
|
|
5
|
-
import clsx from "clsx";
|
|
6
|
-
import { useEffect, useMemo, useRef, useState } from "react";
|
|
7
|
-
import { AppMenuHeader } from "./AppMenuHeader.js";
|
|
8
|
-
import { AppMenuList } from "./AppMenuList.js";
|
|
9
|
-
import { AppMenuRail } from "./AppMenuRail.js";
|
|
10
|
-
import { countItems, FAVORITES, filterCategory, groupEntries, groupLabel, toAppEntries, } from "./menuEntries.js";
|
|
11
|
-
import { useFavorites } from "./useFavorites.js";
|
|
12
|
-
/**
|
|
13
|
-
* Two pane application menu. The left rail holds a local search field and the
|
|
14
|
-
* list of app categories (`MenuGroup`); the right pane lists the apps in the
|
|
15
|
-
* selected category, or every app when no category is selected.
|
|
16
|
-
*
|
|
17
|
-
* On narrow viewports only one pane is visible at a time, defaulting to the app
|
|
18
|
-
* list, with a button to switch to the category list.
|
|
19
|
-
*/
|
|
20
|
-
export function AppMenu({ dataObject, open, onClose, categories = [], userDataObject, userMenuItems, userSubtitle, onToggleFavorite, homeLink, hasUpdate = false, onInstallUpdate, id, className, }) {
|
|
21
|
-
let dialogRef = useRef(null);
|
|
22
|
-
let searchRef = useRef(null);
|
|
23
|
-
let [search, setSearch] = useState("");
|
|
24
|
-
let [selection, setSelection] = useState(null);
|
|
25
|
-
let [mobilePane, setMobilePane] = useState("apps");
|
|
26
|
-
let [hasLoaded, setHasLoaded] = useState(false);
|
|
27
|
-
/*
|
|
28
|
-
* True once the initial category has been decided, either by the menu picking
|
|
29
|
-
* the favorites when the apps arrive, or by the user picking one themselves.
|
|
30
|
-
* Without it the menu would jump to the favorites group the moment the first
|
|
31
|
-
* favorite is added.
|
|
32
|
-
*/
|
|
33
|
-
let [hasResolvedSelection, setHasResolvedSelection] = useState(false);
|
|
34
|
-
let isLoading = useLoading(dataObject);
|
|
35
|
-
let articles = useData(dataObject);
|
|
36
|
-
let { applyOverrides, toggleFavorite } = useFavorites(onToggleFavorite);
|
|
37
|
-
// Sync the native dialog with the `open` prop. Using showModal() puts the
|
|
38
|
-
// dialog in the top layer so it renders above the toolbar and page content.
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
let dialog = dialogRef.current;
|
|
41
|
-
if (!dialog)
|
|
42
|
-
return;
|
|
43
|
-
if (open && !dialog.open) {
|
|
44
|
-
dialog.showModal();
|
|
45
|
-
requestAnimationFrame(() => searchRef.current?.focus());
|
|
46
|
-
}
|
|
47
|
-
else if (!open && dialog.open) {
|
|
48
|
-
dialog.close();
|
|
49
|
-
}
|
|
50
|
-
}, [open]);
|
|
51
|
-
// Reset transient state whenever the menu is closed.
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (!open) {
|
|
54
|
-
setSearch("");
|
|
55
|
-
setSelection(null);
|
|
56
|
-
setMobilePane("apps");
|
|
57
|
-
setHasResolvedSelection(false);
|
|
58
|
-
}
|
|
59
|
-
}, [open]);
|
|
60
|
-
// Load the app list the first time the menu is opened.
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
if (open && !hasLoaded) {
|
|
63
|
-
setHasLoaded(true);
|
|
64
|
-
dataObject.refreshDataSource();
|
|
65
|
-
userDataObject?.refreshDataSource();
|
|
66
|
-
}
|
|
67
|
-
}, [open, hasLoaded, dataObject, userDataObject]);
|
|
68
|
-
let entries = useMemo(() => applyOverrides(toAppEntries(articles)), [articles, applyOverrides]);
|
|
69
|
-
let term = search.trim().toLowerCase();
|
|
70
|
-
let searchMatches = useMemo(() => {
|
|
71
|
-
if (!term)
|
|
72
|
-
return entries;
|
|
73
|
-
return entries.filter((entry) => entry.title.toLowerCase().includes(term) || entry.id.toLowerCase().includes(term));
|
|
74
|
-
}, [entries, term]);
|
|
75
|
-
let groups = useMemo(() => groupEntries(searchMatches), [searchMatches]);
|
|
76
|
-
let visibleCategories = useMemo(() => categories.map((category) => filterCategory(category, term)).filter((category) => countItems(category) > 0), [categories, term]);
|
|
77
|
-
let hasFavorites = groups.length > 0 && groups[0][0] === FAVORITES;
|
|
78
|
-
/*
|
|
79
|
-
* The favorites are the most likely target, so select them by default. The
|
|
80
|
-
* article list loads asynchronously, so this can't be done when opening the
|
|
81
|
-
* menu — it has to wait until the apps have arrived. It only ever runs once
|
|
82
|
-
* per open, so favoriting an app doesn't move the user to another group.
|
|
83
|
-
*/
|
|
84
|
-
useEffect(() => {
|
|
85
|
-
if (!open || hasResolvedSelection || entries.length === 0)
|
|
86
|
-
return;
|
|
87
|
-
setHasResolvedSelection(true);
|
|
88
|
-
if (hasFavorites)
|
|
89
|
-
setSelection({ type: "group", key: FAVORITES });
|
|
90
|
-
}, [open, hasResolvedSelection, entries.length, hasFavorites]);
|
|
91
|
-
// A selection that no longer has matches falls back to "all apps" so the pane
|
|
92
|
-
// never ends up empty while results exist elsewhere.
|
|
93
|
-
let activeSelection = null;
|
|
94
|
-
if (selection?.type === "group" && groups.some(([group]) => group === selection.key))
|
|
95
|
-
activeSelection = selection;
|
|
96
|
-
else if (selection?.type === "category" && visibleCategories.some((category) => category.id === selection.id)) {
|
|
97
|
-
activeSelection = selection;
|
|
98
|
-
}
|
|
99
|
-
let activeCategoryId = activeSelection?.type === "category" ? activeSelection.id : null;
|
|
100
|
-
let activeCategory = visibleCategories.find((category) => category.id === activeCategoryId);
|
|
101
|
-
let activeGroupKey = activeSelection?.type === "group" ? activeSelection.key : null;
|
|
102
|
-
// Everything the right hand pane renders, normalized to titled link groups.
|
|
103
|
-
// The favorites are left out of the "all apps" pane, since those apps are
|
|
104
|
-
// already listed in their own group.
|
|
105
|
-
let paneGroups = useMemo(() => {
|
|
106
|
-
if (activeCategory)
|
|
107
|
-
return activeCategory.groups;
|
|
108
|
-
return groups
|
|
109
|
-
.filter(([group]) => (activeGroupKey === null ? group !== FAVORITES : group === activeGroupKey))
|
|
110
|
-
.map(([group, items]) => ({
|
|
111
|
-
title: groupLabel(group),
|
|
112
|
-
items: items.map((entry) => ({
|
|
113
|
-
id: entry.id,
|
|
114
|
-
label: entry.title,
|
|
115
|
-
href: entry.href,
|
|
116
|
-
isFavorite: entry.isFavorite,
|
|
117
|
-
})),
|
|
118
|
-
}));
|
|
119
|
-
}, [activeCategory, activeGroupKey, groups]);
|
|
120
|
-
let paneItemCount = paneGroups.reduce((total, group) => total + group.items.length, 0);
|
|
121
|
-
let hasApps = searchMatches.length > 0;
|
|
122
|
-
let railGroups = groups.map(([key, items]) => ({ key, count: items.length }));
|
|
123
|
-
function select(next) {
|
|
124
|
-
setSelection(next);
|
|
125
|
-
setHasResolvedSelection(true);
|
|
126
|
-
setMobilePane("apps");
|
|
127
|
-
}
|
|
128
|
-
return (_jsx("dialog", { ref: dialogRef, id: id, className: clsx("ob-app-menu", className), "aria-label": getLocalizedString("Applications"), "data-pane": mobilePane, onCancel: (event) => {
|
|
129
|
-
// Let React own the open state instead of the browser's default close.
|
|
130
|
-
event.preventDefault();
|
|
131
|
-
onClose();
|
|
132
|
-
}, onKeyDown: (event) => {
|
|
133
|
-
// A `type="search"` input consumes Escape to clear itself, so the
|
|
134
|
-
// dialog's own cancel event never fires when the search has focus.
|
|
135
|
-
if (event.key === "Escape") {
|
|
136
|
-
event.preventDefault();
|
|
137
|
-
onClose();
|
|
138
|
-
}
|
|
139
|
-
}, onClick: (event) => {
|
|
140
|
-
// Clicks on the dialog element itself are backdrop clicks; anything
|
|
141
|
-
// inside the menu is caught by the inner wrapper below.
|
|
142
|
-
if (event.target === dialogRef.current)
|
|
143
|
-
onClose();
|
|
144
|
-
}, children: _jsxs("div", { className: "ob-app-menu__panel", children: [_jsx(AppMenuRail, { searchRef: searchRef, search: search, onSearchChange: setSearch, groups: railGroups, appCount: searchMatches.length, categories: visibleCategories, selection: activeSelection, onSelect: select }), _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(AppMenuList, { groups: paneGroups, itemCount: paneItemCount, onClose: onClose, onToggleFavorite: toggleFavorite })), _jsx(AppMenuHeader, { homeLink: homeLink, mobilePane: mobilePane, onToggleMobilePane: () => setMobilePane(mobilePane === "apps" ? "groups" : "apps"), hasUpdate: hasUpdate, onInstallUpdate: onInstallUpdate, userDataObject: userDataObject, userMenuItems: userMenuItems, userSubtitle: userSubtitle, onClose: onClose })] })] }) }));
|
|
145
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ToggleGroup, Tooltip } from "@digdir/designsystemet-react";
|
|
3
|
-
import { MonitorIcon, MoonIcon, SunIcon } from "@navikt/aksel-icons";
|
|
4
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
5
|
-
import { useColorSchemePreference } from "../../colorScheme.js";
|
|
6
|
-
const OPTIONS = [
|
|
7
|
-
{ value: "auto", label: "Follow system setting", Icon: MonitorIcon },
|
|
8
|
-
{ value: "light", label: "Light mode", Icon: SunIcon },
|
|
9
|
-
{ value: "dark", label: "Dark mode", Icon: MoonIcon },
|
|
10
|
-
];
|
|
11
|
-
/** Icon-only color scheme toggle, shown at the bottom of the app menu rail. */
|
|
12
|
-
export function AppMenuColorScheme() {
|
|
13
|
-
let [preference, setPreference] = useColorSchemePreference();
|
|
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
|
-
let localizedLabel = getLocalizedString(label);
|
|
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
|
-
}) }) }));
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export type AppMenuFavoriteButtonProps = {
|
|
2
|
-
/** Label of the app the toggle belongs to, used for the accessible name. */
|
|
3
|
-
appLabel: string;
|
|
4
|
-
isFavorite: boolean;
|
|
5
|
-
onToggle: () => void;
|
|
6
|
-
/**
|
|
7
|
-
* Shares the tab stop of the app link it belongs to, so Tab reaches it
|
|
8
|
-
* without adding a stop per app to the arrow key navigation. See
|
|
9
|
-
* `useRovingTabIndex().getSecondaryProps`.
|
|
10
|
-
*/
|
|
11
|
-
tabIndex: number;
|
|
12
|
-
onFocus: () => void;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Star toggle rendered next to an app link. It is only visible while the entry
|
|
16
|
-
* is hovered or focused, unless the app already is a favorite.
|
|
17
|
-
*/
|
|
18
|
-
export declare function AppMenuFavoriteButton({ appLabel, isFavorite, onToggle, tabIndex, onFocus, }: AppMenuFavoriteButtonProps): import("react").JSX.Element;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
3
|
-
import { StarIcon } from "./icons.js";
|
|
4
|
-
/**
|
|
5
|
-
* Star toggle rendered next to an app link. It is only visible while the entry
|
|
6
|
-
* is hovered or focused, unless the app already is a favorite.
|
|
7
|
-
*/
|
|
8
|
-
export function AppMenuFavoriteButton({ appLabel, isFavorite, onToggle, tabIndex, onFocus, }) {
|
|
9
|
-
let label = isFavorite ? getLocalizedString("Remove from favorites") : getLocalizedString("Add to favorites");
|
|
10
|
-
return (_jsx("button", { type: "button", className: "ob-app-menu__favorite", "aria-pressed": isFavorite, "aria-label": `${label}: ${appLabel}`, title: label, "data-favorite": isFavorite ? "true" : undefined, tabIndex: tabIndex, onFocus: onFocus, onClick: onToggle, children: _jsx(StarIcon, { filled: isFavorite }) }));
|
|
11
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { DataObject } from "@olenbetong/appframe-data";
|
|
2
|
-
import { type AppMenuUser } from "./AppMenuUserMenu.js";
|
|
3
|
-
import type { AppMenuLink } from "./types.js";
|
|
4
|
-
export type AppMenuHeaderProps = {
|
|
5
|
-
/** Link shown at the start of the header, e.g. the portal/front page. */
|
|
6
|
-
homeLink?: AppMenuLink;
|
|
7
|
-
/** Which pane is shown on narrow viewports. */
|
|
8
|
-
mobilePane: "apps" | "groups";
|
|
9
|
-
onToggleMobilePane: () => void;
|
|
10
|
-
hasUpdate: boolean;
|
|
11
|
-
onInstallUpdate?: () => void;
|
|
12
|
-
userDataObject?: DataObject<AppMenuUser>;
|
|
13
|
-
userMenuItems?: AppMenuLink[];
|
|
14
|
-
userSubtitle?: string;
|
|
15
|
-
onClose: () => void;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Header of the app menu's content pane, holding the navigation shortcuts on
|
|
19
|
-
* the start side and the user/update/close controls on the end side.
|
|
20
|
-
*
|
|
21
|
-
* It is rendered after the app list so it comes last in the tab order, and is
|
|
22
|
-
* moved back to the top visually with `order: -1`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function AppMenuHeader({ homeLink, mobilePane, onToggleMobilePane, hasUpdate, onInstallUpdate, userDataObject, userMenuItems, userSubtitle, onClose, }: AppMenuHeaderProps): import("react").JSX.Element;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
3
|
-
import { AppMenuUserMenu } from "./AppMenuUserMenu.js";
|
|
4
|
-
import { CloseIcon, HomeIcon, ReloadIcon } from "./icons.js";
|
|
5
|
-
/**
|
|
6
|
-
* Header of the app menu's content pane, holding the navigation shortcuts on
|
|
7
|
-
* the start side and the user/update/close controls on the end side.
|
|
8
|
-
*
|
|
9
|
-
* It is rendered after the app list so it comes last in the tab order, and is
|
|
10
|
-
* moved back to the top visually with `order: -1`.
|
|
11
|
-
*/
|
|
12
|
-
export function AppMenuHeader({ homeLink, mobilePane, onToggleMobilePane, hasUpdate, onInstallUpdate, userDataObject, userMenuItems, userSubtitle, onClose, }) {
|
|
13
|
-
return (_jsxs("div", { className: "ob-app-menu__content-header", children: [_jsxs("div", { className: "ob-app-menu__header-start", children: [homeLink && (_jsxs("a", { className: "ob-app-menu__home", href: homeLink.href, target: homeLink.target, rel: homeLink.rel, onClick: () => {
|
|
14
|
-
homeLink.onClick?.();
|
|
15
|
-
if (!homeLink.keepOpen)
|
|
16
|
-
onClose();
|
|
17
|
-
}, children: [_jsx(HomeIcon, {}), _jsx("span", { className: "ob-app-menu__home-label", children: homeLink.label })] })), _jsx("button", { type: "button", className: "ob-app-menu__pane-toggle", onClick: onToggleMobilePane, 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(ReloadIcon, {}), _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(CloseIcon, {}) })] }));
|
|
18
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AppMenuLinkGroup } from "./types.js";
|
|
2
|
-
export type AppMenuListProps = {
|
|
3
|
-
groups: AppMenuLinkGroup[];
|
|
4
|
-
/** Total number of links across all groups; the roving tab index size. */
|
|
5
|
-
itemCount: number;
|
|
6
|
-
/** Called when an entry that doesn't opt out with `keepOpen` is activated. */
|
|
7
|
-
onClose: () => void;
|
|
8
|
-
/** Without a handler no favorite toggles are rendered. */
|
|
9
|
-
onToggleFavorite?: (id: string, favorite: boolean) => void;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* The app menu's right hand pane: the selected category's links, laid out as
|
|
13
|
-
* titled groups of wrapping columns.
|
|
14
|
-
*
|
|
15
|
-
* The whole list is a single tab stop; the arrow keys move focus between the
|
|
16
|
-
* links, following the visual grid.
|
|
17
|
-
*/
|
|
18
|
-
export declare function AppMenuList({ groups, itemCount, onClose, onToggleFavorite }: AppMenuListProps): import("react").JSX.Element;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AppMenuFavoriteButton } from "./AppMenuFavoriteButton.js";
|
|
3
|
-
import { useRovingTabIndex } from "./useRovingTabIndex.js";
|
|
4
|
-
/**
|
|
5
|
-
* The app menu's right hand pane: the selected category's links, laid out as
|
|
6
|
-
* titled groups of wrapping columns.
|
|
7
|
-
*
|
|
8
|
-
* The whole list is a single tab stop; the arrow keys move focus between the
|
|
9
|
-
* links, following the visual grid.
|
|
10
|
-
*/
|
|
11
|
-
export function AppMenuList({ groups, itemCount, onClose, onToggleFavorite }) {
|
|
12
|
-
let roving = useRovingTabIndex(itemCount, { columns: true });
|
|
13
|
-
// Links are numbered across all groups, since they share one roving index.
|
|
14
|
-
let itemIndex = -1;
|
|
15
|
-
function renderItem(item, index) {
|
|
16
|
-
let props = {
|
|
17
|
-
className: "ob-app-menu__link",
|
|
18
|
-
...item.attributes,
|
|
19
|
-
...roving.getItemProps(index),
|
|
20
|
-
};
|
|
21
|
-
function activate() {
|
|
22
|
-
item.onClick?.();
|
|
23
|
-
if (!item.keepOpen)
|
|
24
|
-
onClose();
|
|
25
|
-
}
|
|
26
|
-
let link = item.href ? (_jsx("a", { ...props, href: item.href, target: item.target, rel: item.rel, onClick: activate, children: item.label })) : (_jsx("button", { ...props, type: "button", onClick: activate, children: item.label }));
|
|
27
|
-
// Only app entries carry an id and a favorite state; the fixed category
|
|
28
|
-
// links (e.g. the developer tools) can't be favorited.
|
|
29
|
-
if (!onToggleFavorite || item.id === undefined || typeof item.isFavorite !== "boolean")
|
|
30
|
-
return link;
|
|
31
|
-
let id = item.id;
|
|
32
|
-
let isFavorite = item.isFavorite;
|
|
33
|
-
return (_jsxs(_Fragment, { children: [link, _jsx(AppMenuFavoriteButton, { appLabel: item.label, isFavorite: isFavorite, onToggle: () => onToggleFavorite(id, !isFavorite), ...roving.getSecondaryProps(index) })] }));
|
|
34
|
-
}
|
|
35
|
-
return (_jsx("div", { className: "ob-app-menu__columns", onKeyDown: roving.onKeyDown, children: groups.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) => {
|
|
36
|
-
itemIndex += 1;
|
|
37
|
-
return (_jsx("li", { className: "ob-app-menu__item", children: renderItem(item, itemIndex) }, item.href ?? item.label));
|
|
38
|
-
}) })] }, group.title ?? groupIdx))) }));
|
|
39
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type RefObject } from "react";
|
|
2
|
-
import { type Selection } from "./menuEntries.js";
|
|
3
|
-
import type { AppMenuCategory } from "./types.js";
|
|
4
|
-
export type AppMenuRailProps = {
|
|
5
|
-
searchRef: RefObject<HTMLInputElement | null>;
|
|
6
|
-
search: string;
|
|
7
|
-
onSearchChange: (value: string) => void;
|
|
8
|
-
/** App groups, in the order they are listed. */
|
|
9
|
-
groups: {
|
|
10
|
-
key: string;
|
|
11
|
-
count: number;
|
|
12
|
-
}[];
|
|
13
|
-
/** Number of apps matching the search, shown next to "All applications". */
|
|
14
|
-
appCount: number;
|
|
15
|
-
/** Extra link categories, listed after the app groups. */
|
|
16
|
-
categories: AppMenuCategory[];
|
|
17
|
-
selection: Selection;
|
|
18
|
-
onSelect: (selection: Selection) => void;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* The app menu's left rail: the local search field, the app groups and any
|
|
22
|
-
* extra link categories.
|
|
23
|
-
*
|
|
24
|
-
* The rail is a single tab stop; the arrow keys move focus between the buttons.
|
|
25
|
-
*/
|
|
26
|
-
export declare function AppMenuRail({ searchRef, search, onSearchChange, groups, appCount, categories, selection, onSelect, }: AppMenuRailProps): import("react").JSX.Element;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
3
|
-
import { Fragment } from "react";
|
|
4
|
-
import { AppMenuColorScheme } from "./AppMenuColorScheme.js";
|
|
5
|
-
import { countItems, groupLabel, toRailSections } from "./menuEntries.js";
|
|
6
|
-
import { useRovingTabIndex } from "./useRovingTabIndex.js";
|
|
7
|
-
/**
|
|
8
|
-
* The app menu's left rail: the local search field, the app groups and any
|
|
9
|
-
* extra link categories.
|
|
10
|
-
*
|
|
11
|
-
* The rail is a single tab stop; the arrow keys move focus between the buttons.
|
|
12
|
-
*/
|
|
13
|
-
export function AppMenuRail({ searchRef, search, onSearchChange, groups, appCount, categories, selection, onSelect, }) {
|
|
14
|
-
// "All applications", then the app groups, then the categories.
|
|
15
|
-
let roving = useRovingTabIndex(groups.length + 1 + categories.length);
|
|
16
|
-
let railSections = toRailSections(categories);
|
|
17
|
-
let categoryIndex = groups.length;
|
|
18
|
-
function isSelected(next) {
|
|
19
|
-
if (selection === null)
|
|
20
|
-
return false;
|
|
21
|
-
if (next.type === "group")
|
|
22
|
-
return selection.type === "group" && selection.key === next.key;
|
|
23
|
-
return selection.type === "category" && selection.id === next.id;
|
|
24
|
-
}
|
|
25
|
-
return (_jsxs("div", { className: "ob-app-menu__rail", children: [_jsx("div", { className: "ds-search ob-app-menu__search", "data-size": "sm", children: _jsx("input", { ref: searchRef, className: "ds-input", type: "search", value: search, onChange: (event) => onSearchChange(event.target.value), placeholder: getLocalizedString("Search applications"), "aria-label": getLocalizedString("Search applications"), autoComplete: "off" }) }), _jsxs("nav", { className: "ob-app-menu__groups", "aria-label": getLocalizedString("Categories"), onKeyDown: roving.onKeyDown, children: [_jsxs("button", { type: "button", className: "ob-app-menu__group-button", "aria-current": selection === null ? "true" : undefined, onClick: () => onSelect(null), ...roving.getItemProps(0), children: [_jsx("span", { children: getLocalizedString("All applications") }), _jsx("span", { className: "ob-app-menu__count", children: appCount })] }), groups.map(({ key, count }, index) => (_jsxs("button", { type: "button", className: "ob-app-menu__group-button", "aria-current": isSelected({ type: "group", key }) ? "true" : undefined, onClick: () => onSelect({ type: "group", key }), ...roving.getItemProps(index + 1), children: [_jsx("span", { children: groupLabel(key) }), _jsx("span", { className: "ob-app-menu__count", children: count })] }, key))), railSections.map(([section, sectionCategories]) => (_jsxs(Fragment, { children: [section && _jsx("h2", { className: "ob-app-menu__rail-heading", children: section }), sectionCategories.map((category) => {
|
|
26
|
-
categoryIndex += 1;
|
|
27
|
-
let railIndex = categoryIndex;
|
|
28
|
-
return (_jsxs("button", { type: "button", className: "ob-app-menu__group-button", "aria-current": isSelected({ type: "category", id: category.id }) ? "true" : undefined, onClick: () => onSelect({ type: "category", id: category.id }), ...roving.getItemProps(railIndex), children: [_jsx("span", { children: category.label }), _jsx("span", { className: "ob-app-menu__count", children: countItems(category) })] }, category.id));
|
|
29
|
-
})] }, section || "\u0000default")))] }), _jsx(AppMenuColorScheme, {})] }));
|
|
30
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import "./AppMenu.css";
|
|
2
|
-
import type { ButtonHTMLAttributes, Ref } from "react";
|
|
3
|
-
export type AppMenuToggleProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "aria-expanded" | "type"> & {
|
|
4
|
-
/** Whether the app menu is currently open. Controls `aria-expanded`. */
|
|
5
|
-
open: boolean;
|
|
6
|
-
/** Shows a badge on the button, pointing at the install action inside the menu. */
|
|
7
|
-
hasUpdate?: boolean;
|
|
8
|
-
ref?: Ref<HTMLButtonElement>;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Toolbar button that opens the app menu. Rendering the button separately from
|
|
12
|
-
* the menu lets the toolbar place it wherever it needs to, while the menu itself
|
|
13
|
-
* is rendered as a top layer dialog.
|
|
14
|
-
*/
|
|
15
|
-
export declare function AppMenuToggle({ open, hasUpdate, className, ref, ...props }: AppMenuToggleProps): import("react").JSX.Element;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import "./AppMenu.css";
|
|
3
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
4
|
-
import clsx from "clsx";
|
|
5
|
-
/**
|
|
6
|
-
* Toolbar button that opens the app menu. Rendering the button separately from
|
|
7
|
-
* the menu lets the toolbar place it wherever it needs to, while the menu itself
|
|
8
|
-
* is rendered as a top layer dialog.
|
|
9
|
-
*/
|
|
10
|
-
export function AppMenuToggle({ open, hasUpdate, className, ref, ...props }) {
|
|
11
|
-
return (_jsxs("button", { ...props, ref: ref, type: "button", className: clsx("ob-app-menu-toggle", className), "aria-label": hasUpdate
|
|
12
|
-
? `${getLocalizedString("Applications")} (${getLocalizedString("Update available")})`
|
|
13
|
-
: getLocalizedString("Applications"), "aria-haspopup": "dialog", "aria-expanded": open, "data-update": hasUpdate ? "" : undefined, children: [_jsx("svg", { className: "ob-app-menu-toggle__icon", xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", width: "24", height: "24", children: _jsx("path", { d: "M4 4h4v4H4zm6 0h4v4h-4zm6 0h4v4h-4zM4 10h4v4H4zm6 0h4v4h-4zm6 0h4v4h-4zM4 16h4v4H4zm6 0h4v4h-4zm6 0h4v4h-4z" }) }), hasUpdate && _jsx("span", { className: "ob-app-menu-toggle__badge", "aria-hidden": "true" })] }));
|
|
14
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { DataObject } from "@olenbetong/appframe-data";
|
|
2
|
-
import type { AppMenuLink } from "./types.js";
|
|
3
|
-
/** Fields required from `aviw_Personnel_Employees_Lookup`. */
|
|
4
|
-
export type AppMenuUser = {
|
|
5
|
-
PrimKey: string;
|
|
6
|
-
PersonID: string;
|
|
7
|
-
FirstName: string | null;
|
|
8
|
-
LastName: string | null;
|
|
9
|
-
Fullname: string | null;
|
|
10
|
-
ImageHash: number | null;
|
|
11
|
-
};
|
|
12
|
-
/** Same entries as the sidebar user disclosure menu. */
|
|
13
|
-
export declare function defaultUserMenuItems(): AppMenuLink[];
|
|
14
|
-
export type AppMenuUserMenuProps = {
|
|
15
|
-
/**
|
|
16
|
-
* Data object over `aviw_Personnel_Employees_Lookup` filtered to the current
|
|
17
|
-
* user (`PersonID = af.userSession.login`). See `AppMenuUser`.
|
|
18
|
-
*/
|
|
19
|
-
dataObject: DataObject<AppMenuUser>;
|
|
20
|
-
/** Overrides the default menu entries. */
|
|
21
|
-
items?: AppMenuLink[];
|
|
22
|
-
/** Shown below the name. Defaults to `af.userSession.domain`. */
|
|
23
|
-
subtitle?: string;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* Disclosure menu showing the signed in user's photo and full name, with the
|
|
27
|
-
* account related links from the old sidebar.
|
|
28
|
-
*
|
|
29
|
-
* Users without an employee record still get the menu, using the name from the
|
|
30
|
-
* Appframe user session, so log out and password changes stay reachable.
|
|
31
|
-
*/
|
|
32
|
-
export declare function AppMenuUserMenu({ dataObject, items, subtitle }: AppMenuUserMenuProps): import("react").JSX.Element;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { getLocalizedString, getUserImage } from "@olenbetong/appframe-core";
|
|
3
|
-
import { useData } from "@olenbetong/appframe-react";
|
|
4
|
-
import { useEffect, useId, useRef, useState } from "react";
|
|
5
|
-
/** Same entries as the sidebar user disclosure menu. */
|
|
6
|
-
export function defaultUserMenuItems() {
|
|
7
|
-
return [
|
|
8
|
-
{ label: getLocalizedString("My profile"), href: "/edit-profile" },
|
|
9
|
-
{ label: getLocalizedString("Change domain"), href: "/change-domain" },
|
|
10
|
-
{ label: getLocalizedString("Change theme"), href: "/change-theme" },
|
|
11
|
-
{ label: getLocalizedString("Change password"), href: "/change-password" },
|
|
12
|
-
{ label: getLocalizedString("Troubleshooting"), href: "/diagnostics", separatorBefore: true },
|
|
13
|
-
{ label: getLocalizedString("Log out"), href: "/logout", separatorBefore: true },
|
|
14
|
-
];
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Disclosure menu showing the signed in user's photo and full name, with the
|
|
18
|
-
* account related links from the old sidebar.
|
|
19
|
-
*
|
|
20
|
-
* Users without an employee record still get the menu, using the name from the
|
|
21
|
-
* Appframe user session, so log out and password changes stay reachable.
|
|
22
|
-
*/
|
|
23
|
-
export function AppMenuUserMenu({ dataObject, items, subtitle }) {
|
|
24
|
-
let containerRef = useRef(null);
|
|
25
|
-
let triggerRef = useRef(null);
|
|
26
|
-
let listRef = useRef(null);
|
|
27
|
-
let panelId = useId();
|
|
28
|
-
let [isOpen, setIsOpen] = useState(false);
|
|
29
|
-
let [hasPhotoError, setHasPhotoError] = useState(false);
|
|
30
|
-
let [user] = useData(dataObject);
|
|
31
|
-
let session = globalThis.af?.userSession;
|
|
32
|
-
let menuItems = items ?? defaultUserMenuItems();
|
|
33
|
-
// Close when the pointer goes down outside the disclosure.
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
if (!isOpen)
|
|
36
|
-
return;
|
|
37
|
-
function onDocumentPointerDown(event) {
|
|
38
|
-
if (!containerRef.current?.contains(event.target))
|
|
39
|
-
setIsOpen(false);
|
|
40
|
-
}
|
|
41
|
-
document.addEventListener("pointerdown", onDocumentPointerDown);
|
|
42
|
-
return () => document.removeEventListener("pointerdown", onDocumentPointerDown);
|
|
43
|
-
}, [isOpen]);
|
|
44
|
-
function menuLinks() {
|
|
45
|
-
return [...(listRef.current?.querySelectorAll("a, button") ?? [])];
|
|
46
|
-
}
|
|
47
|
-
/** Focus a menu entry once the list has been shown. */
|
|
48
|
-
function focusEntry(position) {
|
|
49
|
-
requestAnimationFrame(() => {
|
|
50
|
-
let links = menuLinks();
|
|
51
|
-
(position === "first" ? links[0] : links[links.length - 1])?.focus();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
function close({ focusTrigger = true } = {}) {
|
|
55
|
-
setIsOpen(false);
|
|
56
|
-
if (focusTrigger)
|
|
57
|
-
triggerRef.current?.focus();
|
|
58
|
-
}
|
|
59
|
-
function onTriggerKeyDown(event) {
|
|
60
|
-
if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
61
|
-
event.preventDefault();
|
|
62
|
-
setIsOpen(true);
|
|
63
|
-
focusEntry(event.key === "ArrowDown" ? "first" : "last");
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function onListKeyDown(event) {
|
|
67
|
-
let links = menuLinks();
|
|
68
|
-
let index = links.indexOf(document.activeElement);
|
|
69
|
-
if (index < 0 || links.length === 0)
|
|
70
|
-
return;
|
|
71
|
-
let next;
|
|
72
|
-
if (event.key === "ArrowDown")
|
|
73
|
-
next = (index + 1) % links.length;
|
|
74
|
-
else if (event.key === "ArrowUp")
|
|
75
|
-
next = (index - 1 + links.length) % links.length;
|
|
76
|
-
else if (event.key === "Home")
|
|
77
|
-
next = 0;
|
|
78
|
-
else if (event.key === "End")
|
|
79
|
-
next = links.length - 1;
|
|
80
|
-
else
|
|
81
|
-
return;
|
|
82
|
-
event.preventDefault();
|
|
83
|
-
event.stopPropagation();
|
|
84
|
-
links[next].focus();
|
|
85
|
-
}
|
|
86
|
-
let fullName = user?.Fullname?.trim() ||
|
|
87
|
-
[user?.FirstName, user?.LastName].filter(Boolean).join(" ").trim() ||
|
|
88
|
-
session?.name ||
|
|
89
|
-
session?.login ||
|
|
90
|
-
getLocalizedString("Account");
|
|
91
|
-
let photo = user && !hasPhotoError ? getUserImage(user.PrimKey, user.PersonID, user.ImageHash, "sm") : "";
|
|
92
|
-
// The domain is set server side when the session is created.
|
|
93
|
-
let domain = subtitle ?? session?.domain ?? "";
|
|
94
|
-
return (_jsxs("div", { ref: containerRef, className: "ob-app-menu-user", onKeyDown: (event) => {
|
|
95
|
-
// Don't let Escape bubble to the dialog and close the whole menu.
|
|
96
|
-
if (event.key === "Escape" && isOpen) {
|
|
97
|
-
event.stopPropagation();
|
|
98
|
-
event.preventDefault();
|
|
99
|
-
close();
|
|
100
|
-
}
|
|
101
|
-
}, onBlur: (event) => {
|
|
102
|
-
// Tabbing (or clicking) out of the disclosure closes it.
|
|
103
|
-
if (isOpen && !event.currentTarget.contains(event.relatedTarget))
|
|
104
|
-
close({ focusTrigger: false });
|
|
105
|
-
}, children: [_jsxs("button", { ref: triggerRef, type: "button", className: "ob-app-menu-user__trigger", "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => setIsOpen((open) => !open), onKeyDown: onTriggerKeyDown, children: [_jsx("span", { className: "ob-app-menu-user__avatar", children: photo ? (_jsx("img", { className: "ob-app-menu-user__image", src: photo, alt: "", onError: () => setHasPhotoError(true) })) : (_jsx("svg", { viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", children: _jsx("path", { d: "M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10m0 2c-4.42 0-8 2.24-8 5v1a1 1 0 0 0 1 1h14a1 1 0 0 0 1-1v-1c0-2.76-3.58-5-8-5" }) })) }), _jsxs("span", { className: "ob-app-menu-user__meta", children: [_jsx("span", { className: "ob-app-menu-user__name", children: fullName }), domain && _jsx("span", { className: "ob-app-menu-user__domain", children: domain })] })] }), _jsx("ul", { id: panelId, ref: listRef, className: "ob-app-menu-user__list", hidden: !isOpen, onKeyDown: onListKeyDown, children: menuItems.map((item) => (_jsx("li", { className: item.separatorBefore ? "ob-app-menu-user__item--divided" : undefined, children: item.href ? (_jsx("a", { href: item.href, target: item.target, rel: item.rel, onClick: item.onClick, children: item.label })) : (_jsx("button", { type: "button", ...item.attributes, onClick: () => {
|
|
106
|
-
item.onClick?.();
|
|
107
|
-
if (!item.keepOpen)
|
|
108
|
-
close();
|
|
109
|
-
}, children: item.label })) }, item.label))) })] }));
|
|
110
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { AppMenuCategory } from "./types.js";
|
|
2
|
-
export type DeveloperCategoryOptions = {
|
|
3
|
-
/** Article the "Edit article"/"Edit app" links point at. Defaults to `af.article.id`. */
|
|
4
|
-
articleId?: string;
|
|
5
|
-
/** CMS host name used by the app designer links. Defaults to `af.article.hostName`. */
|
|
6
|
-
hostName?: string;
|
|
7
|
-
/** App designer host. */
|
|
8
|
-
devUrl?: string;
|
|
9
|
-
/** Content editor host. */
|
|
10
|
-
testUrl?: string;
|
|
11
|
-
/**
|
|
12
|
-
* Include the cache clearing buttons. They post to `/api/debug/cache/...`,
|
|
13
|
-
* which requires two verified authentication factors.
|
|
14
|
-
*/
|
|
15
|
-
includeCacheTools?: boolean;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Build the Articles/Developer/Debug categories that used to live in the
|
|
19
|
-
* sidebar's developer disclosure menu.
|
|
20
|
-
*
|
|
21
|
-
* Only render these for users where `af.userSession.isDeveloper` is true — the
|
|
22
|
-
* targets are all developer-only and will return 403 for everyone else.
|
|
23
|
-
*/
|
|
24
|
-
export declare function createDeveloperCategories({ articleId, hostName, devUrl, testUrl, includeCacheTools, }?: DeveloperCategoryOptions): AppMenuCategory[];
|