@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,116 +0,0 @@
|
|
|
1
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
2
|
-
/**
|
|
3
|
-
* Build the Articles/Developer/Debug categories that used to live in the
|
|
4
|
-
* sidebar's developer disclosure menu.
|
|
5
|
-
*
|
|
6
|
-
* Only render these for users where `af.userSession.isDeveloper` is true — the
|
|
7
|
-
* targets are all developer-only and will return 403 for everyone else.
|
|
8
|
-
*/
|
|
9
|
-
export function createDeveloperCategories({ articleId = globalThis.af?.article?.id ?? "", hostName = globalThis.af?.article?.hostName ?? "", devUrl = "https://dev.obet.no", testUrl = "https://test.synergi.olenbetong.no", includeCacheTools = true, } = {}) {
|
|
10
|
-
let section = getLocalizedString("Developer");
|
|
11
|
-
return [
|
|
12
|
-
{
|
|
13
|
-
id: "dev-articles",
|
|
14
|
-
label: getLocalizedString("Articles"),
|
|
15
|
-
section,
|
|
16
|
-
groups: [
|
|
17
|
-
{
|
|
18
|
-
title: getLocalizedString("Apps & articles"),
|
|
19
|
-
items: [
|
|
20
|
-
{ label: getLocalizedString("New article"), href: `${testUrl}/content` },
|
|
21
|
-
{ label: getLocalizedString("Edit article"), href: `${testUrl}/content?${articleId}` },
|
|
22
|
-
],
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
title: getLocalizedString("App designer"),
|
|
26
|
-
items: [
|
|
27
|
-
{ label: getLocalizedString("New app"), href: `${devUrl}/appdesigner?${hostName}` },
|
|
28
|
-
{ label: getLocalizedString("Edit app"), href: `${devUrl}/appdesigner?${hostName}/${articleId}` },
|
|
29
|
-
{ label: getLocalizedString("Article List"), href: "/appdesigner-articlelist" },
|
|
30
|
-
{ label: getLocalizedString("Manage translations"), href: "/system-translate" },
|
|
31
|
-
],
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
title: getLocalizedString("Navigation"),
|
|
35
|
-
items: [
|
|
36
|
-
{ label: getLocalizedString("Edit sidebar"), href: `${devUrl}/appdesigner?${hostName}/sidebar` },
|
|
37
|
-
{ label: getLocalizedString("Sidebar applications"), href: `${devUrl}/manage-sidebar-applications` },
|
|
38
|
-
{ label: getLocalizedString("Article Icons"), href: "/article-icons" },
|
|
39
|
-
],
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
id: "dev-tools",
|
|
45
|
-
label: getLocalizedString("Development"),
|
|
46
|
-
section,
|
|
47
|
-
groups: [
|
|
48
|
-
{
|
|
49
|
-
title: getLocalizedString("Developer"),
|
|
50
|
-
items: [
|
|
51
|
-
{ label: "DB Manager", href: "/af-dbmanager" },
|
|
52
|
-
{ label: "Code Modules", href: "/code-modules" },
|
|
53
|
-
{ label: "Assemblies", href: "/af-assemblies" },
|
|
54
|
-
{ label: "Site Setup", href: "/sitesetup" },
|
|
55
|
-
{ label: "Bundles", href: "/af-bundle" },
|
|
56
|
-
{ label: "Updater", href: "/af-updater" },
|
|
57
|
-
{ label: "Scheduler", href: "/af-scheduler" },
|
|
58
|
-
],
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
title: "System",
|
|
62
|
-
items: [
|
|
63
|
-
{ label: getLocalizedString("Manage Users"), href: "/system-users" },
|
|
64
|
-
{ label: getLocalizedString("Manage Roles"), href: "/system-roles" },
|
|
65
|
-
{ label: getLocalizedString("Manage Domains"), href: "/system-domains" },
|
|
66
|
-
],
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
id: "dev-debug",
|
|
72
|
-
label: getLocalizedString("Debugging"),
|
|
73
|
-
section,
|
|
74
|
-
groups: [
|
|
75
|
-
{
|
|
76
|
-
title: getLocalizedString("Debug"),
|
|
77
|
-
items: [
|
|
78
|
-
{ label: getLocalizedString("Cache Control"), href: "/api/debug/cache" },
|
|
79
|
-
{ label: getLocalizedString("Razor"), href: "/api/debug/razor" },
|
|
80
|
-
{ label: getLocalizedString("Placeholders"), href: "/api/debug/placeholders" },
|
|
81
|
-
{ label: getLocalizedString("Routes"), href: "/api/debug/routes" },
|
|
82
|
-
{ label: getLocalizedString("DB Trace"), href: "/api/debug/trace" },
|
|
83
|
-
{ label: getLocalizedString("DB Profiler"), href: "/api/debug/profiler" },
|
|
84
|
-
{ label: getLocalizedString("Errors"), href: "/api/debug/errors" },
|
|
85
|
-
{ label: getLocalizedString("Modules"), href: "/api/debug/modules" },
|
|
86
|
-
{ label: getLocalizedString("Assemblies"), href: "/api/debug/assemblies" },
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
...(includeCacheTools
|
|
90
|
-
? [
|
|
91
|
-
{
|
|
92
|
-
title: getLocalizedString("Clear cache"),
|
|
93
|
-
// Handled by the delegated `[data-action=clear-cache]` listener in the site scripts.
|
|
94
|
-
items: [
|
|
95
|
-
{ label: getLocalizedString("Data object definition"), cache: "object-definitions" },
|
|
96
|
-
{ label: getLocalizedString("Article"), cache: "article-cache" },
|
|
97
|
-
{ label: getLocalizedString("File groups"), cache: "file-groups" },
|
|
98
|
-
{ label: getLocalizedString("Content delivery"), cache: "content-delivery" },
|
|
99
|
-
{ label: getLocalizedString("Localization"), cache: "localization" },
|
|
100
|
-
{ label: getLocalizedString("Code modules"), cache: "code-modules", method: "reload" },
|
|
101
|
-
].map(({ label, cache, method }) => ({
|
|
102
|
-
label,
|
|
103
|
-
keepOpen: true,
|
|
104
|
-
attributes: {
|
|
105
|
-
"data-action": "clear-cache",
|
|
106
|
-
"data-cache": cache,
|
|
107
|
-
...(method ? { "data-cache-method": method } : {}),
|
|
108
|
-
},
|
|
109
|
-
})),
|
|
110
|
-
},
|
|
111
|
-
]
|
|
112
|
-
: []),
|
|
113
|
-
],
|
|
114
|
-
},
|
|
115
|
-
];
|
|
116
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Inline icons used by the app menu. They are kept here instead of using an
|
|
3
|
-
* icon package so the menu has no runtime dependencies beyond React — it is
|
|
4
|
-
* rendered on every page in the portal.
|
|
5
|
-
*/
|
|
6
|
-
type IconProps = {
|
|
7
|
-
size?: number;
|
|
8
|
-
};
|
|
9
|
-
export declare function StarIcon({ filled, size }: IconProps & {
|
|
10
|
-
filled?: boolean;
|
|
11
|
-
}): import("react").JSX.Element;
|
|
12
|
-
export declare function HomeIcon({ size }: IconProps): import("react").JSX.Element;
|
|
13
|
-
export declare function ReloadIcon({ size }: IconProps): import("react").JSX.Element;
|
|
14
|
-
export declare function CloseIcon({ size }: IconProps): import("react").JSX.Element;
|
|
15
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export function StarIcon({ filled = false, size = 16 }) {
|
|
3
|
-
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: filled ? "currentColor" : "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", width: size, height: size, children: _jsx("path", { d: "M12 3.25l2.72 5.51 6.08.89-4.4 4.29 1.04 6.06L12 17.14l-5.44 2.86 1.04-6.06-4.4-4.29 6.08-.89z" }) }));
|
|
4
|
-
}
|
|
5
|
-
export function HomeIcon({ size = 18 }) {
|
|
6
|
-
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", width: size, height: size, children: _jsx("path", { d: "M11.36 3.2a1 1 0 0 1 1.28 0l7.5 6.25a.75.75 0 0 1-.96 1.15L19 10.4V19a2 2 0 0 1-2 2h-2.75a.75.75 0 0 1-.75-.75V15.5h-3v4.75a.75.75 0 0 1-.75.75H7a2 2 0 0 1-2-2v-8.6l-.18.2a.75.75 0 1 1-.96-1.15zM6.5 9.15V19a.5.5 0 0 0 .5.5h2v-4.75a.75.75 0 0 1 .75-.75h4.5a.75.75 0 0 1 .75.75v4.75h2a.5.5 0 0 0 .5-.5V9.15L12 4.73z" }) }));
|
|
7
|
-
}
|
|
8
|
-
export function ReloadIcon({ size = 18 }) {
|
|
9
|
-
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", width: size, height: size, 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" }) }));
|
|
10
|
-
}
|
|
11
|
-
export function CloseIcon({ size = 20 }) {
|
|
12
|
-
return (_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", focusable: "false", width: size, height: size, 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" }) }));
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export { AppMenu, type AppMenuProps } from "./AppMenu.js";
|
|
2
|
-
export { AppMenuColorScheme } from "./AppMenuColorScheme.js";
|
|
3
|
-
export { AppMenuFavoriteButton, type AppMenuFavoriteButtonProps } from "./AppMenuFavoriteButton.js";
|
|
4
|
-
export { AppMenuHeader, type AppMenuHeaderProps } from "./AppMenuHeader.js";
|
|
5
|
-
export { AppMenuList, type AppMenuListProps } from "./AppMenuList.js";
|
|
6
|
-
export { AppMenuRail, type AppMenuRailProps } from "./AppMenuRail.js";
|
|
7
|
-
export { AppMenuToggle, type AppMenuToggleProps } from "./AppMenuToggle.js";
|
|
8
|
-
export { AppMenuUserMenu, type AppMenuUser, type AppMenuUserMenuProps, defaultUserMenuItems, } from "./AppMenuUserMenu.js";
|
|
9
|
-
export { createDeveloperCategories, type DeveloperCategoryOptions } from "./developerCategories.js";
|
|
10
|
-
export type { AppMenuArticle, Selection as AppMenuSelection } from "./menuEntries.js";
|
|
11
|
-
export type { AppMenuCategory, AppMenuLink, AppMenuLinkGroup } from "./types.js";
|
|
12
|
-
export { useServiceWorkerUpdate } from "./useServiceWorkerUpdate.js";
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export { AppMenu } from "./AppMenu.js";
|
|
2
|
-
export { AppMenuColorScheme } from "./AppMenuColorScheme.js";
|
|
3
|
-
export { AppMenuFavoriteButton } from "./AppMenuFavoriteButton.js";
|
|
4
|
-
export { AppMenuHeader } from "./AppMenuHeader.js";
|
|
5
|
-
export { AppMenuList } from "./AppMenuList.js";
|
|
6
|
-
export { AppMenuRail } from "./AppMenuRail.js";
|
|
7
|
-
export { AppMenuToggle } from "./AppMenuToggle.js";
|
|
8
|
-
export { AppMenuUserMenu, defaultUserMenuItems, } from "./AppMenuUserMenu.js";
|
|
9
|
-
export { createDeveloperCategories } from "./developerCategories.js";
|
|
10
|
-
export { useServiceWorkerUpdate } from "./useServiceWorkerUpdate.js";
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { AppMenuCategory } from "./types.js";
|
|
2
|
-
/** A single row from the articles data object backing the app list. */
|
|
3
|
-
export type AppMenuArticle = {
|
|
4
|
-
ArticleId: string;
|
|
5
|
-
Title: string | null;
|
|
6
|
-
MenuGroup: string | null;
|
|
7
|
-
Path: string | null;
|
|
8
|
-
IsFavorite?: boolean | null;
|
|
9
|
-
};
|
|
10
|
-
/** Sentinel group key for apps that have no MenuGroup set. */
|
|
11
|
-
export declare const UNGROUPED = "\0ungrouped";
|
|
12
|
-
/** Sentinel group key for the virtual group holding the user's favorites. */
|
|
13
|
-
export declare const FAVORITES = "\0favorites";
|
|
14
|
-
/** Strip version suffixes (`my-app.0000012`) from an ArticleId. */
|
|
15
|
-
export declare function stripVersionSuffix(articleId: string): string;
|
|
16
|
-
export type AppEntry = {
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
group: string;
|
|
20
|
-
href: string;
|
|
21
|
-
isFavorite: boolean;
|
|
22
|
-
};
|
|
23
|
-
/** The category currently selected in the rail. `null` means "all applications". */
|
|
24
|
-
export type Selection = {
|
|
25
|
-
type: "group";
|
|
26
|
-
key: string;
|
|
27
|
-
} | {
|
|
28
|
-
type: "category";
|
|
29
|
-
id: string;
|
|
30
|
-
} | null;
|
|
31
|
-
/**
|
|
32
|
-
* Normalize the raw article rows into a deduplicated, sorted list of apps.
|
|
33
|
-
*
|
|
34
|
-
* `aviw_WebShared_Articles` contains one row per published article version, so
|
|
35
|
-
* the same app can appear dozens of times. Deduplicating on the version-less
|
|
36
|
-
* ArticleId guarantees a single entry per app even if the data object's where
|
|
37
|
-
* clause is relaxed.
|
|
38
|
-
*/
|
|
39
|
-
export declare function toAppEntries(articles: readonly AppMenuArticle[]): AppEntry[];
|
|
40
|
-
/**
|
|
41
|
-
* Group entries by group key. The favorites are a virtual group listed first,
|
|
42
|
-
* and ungrouped apps are always listed last.
|
|
43
|
-
*/
|
|
44
|
-
export declare function groupEntries(entries: readonly AppEntry[]): [string, AppEntry[]][];
|
|
45
|
-
/** Human readable title for a group key, resolving the sentinel keys. */
|
|
46
|
-
export declare function groupLabel(group: string): string;
|
|
47
|
-
/** Drop entries that don't match the search term, then empty groups. */
|
|
48
|
-
export declare function filterCategory(category: AppMenuCategory, term: string): AppMenuCategory;
|
|
49
|
-
export declare function countItems(category: AppMenuCategory): number;
|
|
50
|
-
/** Split the categories into their rail sections, preserving the given order. */
|
|
51
|
-
export declare function toRailSections(categories: readonly AppMenuCategory[]): [string, AppMenuCategory[]][];
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { getLocalizedString } from "@olenbetong/appframe-core";
|
|
2
|
-
/** Sentinel group key for apps that have no MenuGroup set. */
|
|
3
|
-
export const UNGROUPED = "\u0000ungrouped";
|
|
4
|
-
/** Sentinel group key for the virtual group holding the user's favorites. */
|
|
5
|
-
export const FAVORITES = "\u0000favorites";
|
|
6
|
-
/** Strip version suffixes (`my-app.0000012`) from an ArticleId. */
|
|
7
|
-
export function stripVersionSuffix(articleId) {
|
|
8
|
-
return articleId.replace(/\.\d+$/, "");
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Normalize the raw article rows into a deduplicated, sorted list of apps.
|
|
12
|
-
*
|
|
13
|
-
* `aviw_WebShared_Articles` contains one row per published article version, so
|
|
14
|
-
* the same app can appear dozens of times. Deduplicating on the version-less
|
|
15
|
-
* ArticleId guarantees a single entry per app even if the data object's where
|
|
16
|
-
* clause is relaxed.
|
|
17
|
-
*/
|
|
18
|
-
export function toAppEntries(articles) {
|
|
19
|
-
let byId = new Map();
|
|
20
|
-
for (let article of articles) {
|
|
21
|
-
let id = stripVersionSuffix(article.ArticleId);
|
|
22
|
-
if (byId.has(id))
|
|
23
|
-
continue;
|
|
24
|
-
byId.set(id, {
|
|
25
|
-
id,
|
|
26
|
-
title: article.Title?.trim() || id,
|
|
27
|
-
group: article.MenuGroup?.trim() || UNGROUPED,
|
|
28
|
-
href: `/${article.Path?.trim() || id}`,
|
|
29
|
-
isFavorite: article.IsFavorite === true,
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
return [...byId.values()].sort((a, b) => a.title.localeCompare(b.title));
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Group entries by group key. The favorites are a virtual group listed first,
|
|
36
|
-
* and ungrouped apps are always listed last.
|
|
37
|
-
*/
|
|
38
|
-
export function groupEntries(entries) {
|
|
39
|
-
let map = new Map();
|
|
40
|
-
for (let entry of entries) {
|
|
41
|
-
let list = map.get(entry.group);
|
|
42
|
-
if (!list) {
|
|
43
|
-
list = [];
|
|
44
|
-
map.set(entry.group, list);
|
|
45
|
-
}
|
|
46
|
-
list.push(entry);
|
|
47
|
-
}
|
|
48
|
-
let groups = [...map.entries()].sort(([a], [b]) => {
|
|
49
|
-
if (a === b)
|
|
50
|
-
return 0;
|
|
51
|
-
if (a === UNGROUPED)
|
|
52
|
-
return 1;
|
|
53
|
-
if (b === UNGROUPED)
|
|
54
|
-
return -1;
|
|
55
|
-
return a.localeCompare(b);
|
|
56
|
-
});
|
|
57
|
-
let favorites = entries.filter((entry) => entry.isFavorite);
|
|
58
|
-
return favorites.length > 0 ? [[FAVORITES, favorites], ...groups] : groups;
|
|
59
|
-
}
|
|
60
|
-
/** Human readable title for a group key, resolving the sentinel keys. */
|
|
61
|
-
export function groupLabel(group) {
|
|
62
|
-
if (group === UNGROUPED)
|
|
63
|
-
return getLocalizedString("Other");
|
|
64
|
-
if (group === FAVORITES)
|
|
65
|
-
return getLocalizedString("Favorites");
|
|
66
|
-
return group;
|
|
67
|
-
}
|
|
68
|
-
/** Drop entries that don't match the search term, then empty groups. */
|
|
69
|
-
export function filterCategory(category, term) {
|
|
70
|
-
if (!term)
|
|
71
|
-
return category;
|
|
72
|
-
let groups = category.groups
|
|
73
|
-
.map((group) => ({ ...group, items: group.items.filter((item) => item.label.toLowerCase().includes(term)) }))
|
|
74
|
-
.filter((group) => group.items.length > 0);
|
|
75
|
-
return { ...category, groups };
|
|
76
|
-
}
|
|
77
|
-
export function countItems(category) {
|
|
78
|
-
return category.groups.reduce((total, group) => total + group.items.length, 0);
|
|
79
|
-
}
|
|
80
|
-
/** Split the categories into their rail sections, preserving the given order. */
|
|
81
|
-
export function toRailSections(categories) {
|
|
82
|
-
let sections = new Map();
|
|
83
|
-
for (let category of categories) {
|
|
84
|
-
let key = category.section ?? "";
|
|
85
|
-
let list = sections.get(key);
|
|
86
|
-
if (!list) {
|
|
87
|
-
list = [];
|
|
88
|
-
sections.set(key, list);
|
|
89
|
-
}
|
|
90
|
-
list.push(category);
|
|
91
|
-
}
|
|
92
|
-
return [...sections.entries()];
|
|
93
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/** A single entry in the app menu's right hand pane or in the user menu. */
|
|
2
|
-
export type AppMenuLink = {
|
|
3
|
-
label: string;
|
|
4
|
-
/**
|
|
5
|
-
* Stable identifier for the entry. Set for app entries (the version-less
|
|
6
|
-
* ArticleId), and used as the key when toggling the favorite state.
|
|
7
|
-
*/
|
|
8
|
-
id?: string;
|
|
9
|
-
/**
|
|
10
|
-
* Current favorite state. A favorite toggle is only rendered for entries
|
|
11
|
-
* where this is a boolean and the menu got an `onToggleFavorite` handler.
|
|
12
|
-
*/
|
|
13
|
-
isFavorite?: boolean;
|
|
14
|
-
/** Renders an anchor. Without an href the entry is rendered as a button. */
|
|
15
|
-
href?: string;
|
|
16
|
-
target?: string;
|
|
17
|
-
rel?: string;
|
|
18
|
-
onClick?: () => void;
|
|
19
|
-
/** Extra attributes, e.g. `{ "data-action": "clear-cache" }` for site scripts. */
|
|
20
|
-
attributes?: Record<string, string>;
|
|
21
|
-
/** Keep the menu open when the entry is activated. */
|
|
22
|
-
keepOpen?: boolean;
|
|
23
|
-
/** Render a divider above this entry (user menu only). */
|
|
24
|
-
separatorBefore?: boolean;
|
|
25
|
-
};
|
|
26
|
-
/** A titled block of links inside a category. */
|
|
27
|
-
export type AppMenuLinkGroup = {
|
|
28
|
-
title?: string;
|
|
29
|
-
items: AppMenuLink[];
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* A category listed in the app menu rail that shows a fixed set of links
|
|
33
|
-
* instead of apps, e.g. the developer tools.
|
|
34
|
-
*/
|
|
35
|
-
export type AppMenuCategory = {
|
|
36
|
-
/** Unique key, used for selection. */
|
|
37
|
-
id: string;
|
|
38
|
-
/** Label shown in the rail. */
|
|
39
|
-
label: string;
|
|
40
|
-
/** Sub header in the rail that this category is listed under. */
|
|
41
|
-
section?: string;
|
|
42
|
-
groups: AppMenuLinkGroup[];
|
|
43
|
-
};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { AppEntry } from "./menuEntries.js";
|
|
2
|
-
/**
|
|
3
|
-
* Tracks the favorite state the user has changed while the menu is open.
|
|
4
|
-
*
|
|
5
|
-
* The changes are applied optimistically on top of the article rows and rolled
|
|
6
|
-
* back if the handler rejects. The overrides are kept for the lifetime of the
|
|
7
|
-
* menu, since the article list is only loaded the first time it is opened and
|
|
8
|
-
* would otherwise show a stale state the second time around.
|
|
9
|
-
*/
|
|
10
|
-
export declare function useFavorites(onToggleFavorite?: (id: string, favorite: boolean) => void | Promise<unknown>): {
|
|
11
|
-
applyOverrides: (entries: AppEntry[]) => AppEntry[];
|
|
12
|
-
toggleFavorite: ((id: string, favorite: boolean) => Promise<void>) | undefined;
|
|
13
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useCallback, useState } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Tracks the favorite state the user has changed while the menu is open.
|
|
4
|
-
*
|
|
5
|
-
* The changes are applied optimistically on top of the article rows and rolled
|
|
6
|
-
* back if the handler rejects. The overrides are kept for the lifetime of the
|
|
7
|
-
* menu, since the article list is only loaded the first time it is opened and
|
|
8
|
-
* would otherwise show a stale state the second time around.
|
|
9
|
-
*/
|
|
10
|
-
export function useFavorites(onToggleFavorite) {
|
|
11
|
-
let [overrides, setOverrides] = useState({});
|
|
12
|
-
let applyOverrides = useCallback((entries) => {
|
|
13
|
-
if (Object.keys(overrides).length === 0)
|
|
14
|
-
return entries;
|
|
15
|
-
return entries.map((entry) => (entry.id in overrides ? { ...entry, isFavorite: overrides[entry.id] } : entry));
|
|
16
|
-
}, [overrides]);
|
|
17
|
-
let toggleFavorite = useCallback(async (id, favorite) => {
|
|
18
|
-
setOverrides((current) => ({ ...current, [id]: favorite }));
|
|
19
|
-
try {
|
|
20
|
-
await onToggleFavorite?.(id, favorite);
|
|
21
|
-
}
|
|
22
|
-
catch (error) {
|
|
23
|
-
console.error(error);
|
|
24
|
-
setOverrides((current) => ({ ...current, [id]: !favorite }));
|
|
25
|
-
}
|
|
26
|
-
}, [onToggleFavorite]);
|
|
27
|
-
return { applyOverrides, toggleFavorite: onToggleFavorite ? toggleFavorite : undefined };
|
|
28
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type KeyboardEvent } from "react";
|
|
2
|
-
export type RovingTabIndexOptions = {
|
|
3
|
-
/**
|
|
4
|
-
* When true, the arrow keys follow the visual layout of a wrapping grid
|
|
5
|
-
* instead of the DOM order: left/right move between columns and up/down
|
|
6
|
-
* between rows.
|
|
7
|
-
*/
|
|
8
|
-
columns?: boolean;
|
|
9
|
-
};
|
|
10
|
-
/**
|
|
11
|
-
* Roving tabindex: the container holds a single tab stop, and the arrow keys
|
|
12
|
-
* (plus Home/End) move focus between the items inside it.
|
|
13
|
-
*
|
|
14
|
-
* Spread `getItemProps(index)` on every focusable item and put `onKeyDown` on
|
|
15
|
-
* their common ancestor.
|
|
16
|
-
*/
|
|
17
|
-
export declare function useRovingTabIndex(itemCount: number, { columns }?: RovingTabIndexOptions): {
|
|
18
|
-
onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;
|
|
19
|
-
getItemProps: (index: number) => {
|
|
20
|
-
"data-roving-item": string;
|
|
21
|
-
tabIndex: number;
|
|
22
|
-
onFocus: () => void;
|
|
23
|
-
};
|
|
24
|
-
getSecondaryProps: (index: number) => {
|
|
25
|
-
tabIndex: number;
|
|
26
|
-
onFocus: () => void;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from "react";
|
|
2
|
-
const NEXT_KEYS = ["ArrowDown", "ArrowRight"];
|
|
3
|
-
const PREV_KEYS = ["ArrowUp", "ArrowLeft"];
|
|
4
|
-
const HORIZONTAL_KEYS = ["ArrowLeft", "ArrowRight"];
|
|
5
|
-
const ARROW_KEYS = [...HORIZONTAL_KEYS, "ArrowUp", "ArrowDown"];
|
|
6
|
-
/**
|
|
7
|
-
* Find the item closest to `from` in the neighbouring visual row or column.
|
|
8
|
-
*
|
|
9
|
-
* The app list is a grid whose column count depends on the available width, so
|
|
10
|
-
* which row and column an item ends up in is only known after layout. Comparing
|
|
11
|
-
* client rectangles is therefore the only reliable way to move in two
|
|
12
|
-
* dimensions.
|
|
13
|
-
*/
|
|
14
|
-
function findAdjacent(items, from, axis, direction) {
|
|
15
|
-
// `main` is the axis stepped along, `cross` the one used to pick the closest
|
|
16
|
-
// candidate within the target row/column.
|
|
17
|
-
let rects = items.map((item) => {
|
|
18
|
-
let rect = item.getBoundingClientRect();
|
|
19
|
-
return axis === "x" ? { main: rect.left, cross: rect.top } : { main: rect.top, cross: rect.left };
|
|
20
|
-
});
|
|
21
|
-
let origin = rects[from];
|
|
22
|
-
if (!origin)
|
|
23
|
-
return null;
|
|
24
|
-
// The nearest row/column edge in the requested direction.
|
|
25
|
-
let target = null;
|
|
26
|
-
for (let rect of rects) {
|
|
27
|
-
let delta = rect.main - origin.main;
|
|
28
|
-
if (direction > 0 ? delta <= 1 : delta >= -1)
|
|
29
|
-
continue;
|
|
30
|
-
if (target === null || Math.abs(rect.main - origin.main) < Math.abs(target - origin.main)) {
|
|
31
|
-
target = rect.main;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
if (target === null)
|
|
35
|
-
return null;
|
|
36
|
-
let best = null;
|
|
37
|
-
let bestDistance = Number.POSITIVE_INFINITY;
|
|
38
|
-
for (let index = 0; index < rects.length; index++) {
|
|
39
|
-
let rect = rects[index];
|
|
40
|
-
if (Math.abs(rect.main - target) > 1)
|
|
41
|
-
continue;
|
|
42
|
-
let distance = Math.abs(rect.cross - origin.cross);
|
|
43
|
-
if (distance < bestDistance) {
|
|
44
|
-
bestDistance = distance;
|
|
45
|
-
best = index;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
return best;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Roving tabindex: the container holds a single tab stop, and the arrow keys
|
|
52
|
-
* (plus Home/End) move focus between the items inside it.
|
|
53
|
-
*
|
|
54
|
-
* Spread `getItemProps(index)` on every focusable item and put `onKeyDown` on
|
|
55
|
-
* their common ancestor.
|
|
56
|
-
*/
|
|
57
|
-
export function useRovingTabIndex(itemCount, { columns = false } = {}) {
|
|
58
|
-
let [activeIndex, setActiveIndex] = useState(0);
|
|
59
|
-
// Keep the tab stop within the list when it shrinks (e.g. while searching).
|
|
60
|
-
useEffect(() => {
|
|
61
|
-
setActiveIndex((index) => (index >= itemCount ? 0 : index));
|
|
62
|
-
}, [itemCount]);
|
|
63
|
-
function onKeyDown(event) {
|
|
64
|
-
if (itemCount === 0)
|
|
65
|
-
return;
|
|
66
|
-
let items = [...event.currentTarget.querySelectorAll("[data-roving-item]")];
|
|
67
|
-
let next;
|
|
68
|
-
if (columns && ARROW_KEYS.includes(event.key)) {
|
|
69
|
-
event.preventDefault();
|
|
70
|
-
let isHorizontal = HORIZONTAL_KEYS.includes(event.key);
|
|
71
|
-
let direction = NEXT_KEYS.includes(event.key) ? 1 : -1;
|
|
72
|
-
next = findAdjacent(items, activeIndex, isHorizontal ? "x" : "y", direction);
|
|
73
|
-
if (next === null) {
|
|
74
|
-
// Stay put at the first/last column, but let up/down continue into the
|
|
75
|
-
// neighbouring item so the whole list stays reachable.
|
|
76
|
-
if (isHorizontal)
|
|
77
|
-
return;
|
|
78
|
-
next = (activeIndex + direction + itemCount) % itemCount;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
else if (NEXT_KEYS.includes(event.key))
|
|
82
|
-
next = (activeIndex + 1) % itemCount;
|
|
83
|
-
else if (PREV_KEYS.includes(event.key))
|
|
84
|
-
next = (activeIndex - 1 + itemCount) % itemCount;
|
|
85
|
-
else if (event.key === "Home")
|
|
86
|
-
next = 0;
|
|
87
|
-
else if (event.key === "End")
|
|
88
|
-
next = itemCount - 1;
|
|
89
|
-
else
|
|
90
|
-
return;
|
|
91
|
-
event.preventDefault();
|
|
92
|
-
setActiveIndex(next);
|
|
93
|
-
items[next]?.focus();
|
|
94
|
-
}
|
|
95
|
-
function getItemProps(index) {
|
|
96
|
-
return {
|
|
97
|
-
"data-roving-item": "",
|
|
98
|
-
tabIndex: index === activeIndex ? 0 : -1,
|
|
99
|
-
onFocus: () => setActiveIndex(index),
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Props for a secondary control belonging to item `index`, e.g. the favorite
|
|
104
|
-
* toggle next to an app link. It shares the item's tab stop — so Tab reaches
|
|
105
|
-
* it from the link — but the arrow keys skip it.
|
|
106
|
-
*/
|
|
107
|
-
function getSecondaryProps(index) {
|
|
108
|
-
return {
|
|
109
|
-
tabIndex: index === activeIndex ? 0 : -1,
|
|
110
|
-
onFocus: () => setActiveIndex(index),
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
return { onKeyDown, getItemProps, getSecondaryProps };
|
|
114
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Track whether a new version of the site has been downloaded by the service
|
|
3
|
-
* worker and is waiting to take over.
|
|
4
|
-
*
|
|
5
|
-
* A waiting worker means every asset of the new version is already cached, so
|
|
6
|
-
* installing it is just `skipWaiting` followed by a reload. The reload is
|
|
7
|
-
* triggered from the worker's `activated` state change rather than immediately,
|
|
8
|
-
* so the page never reloads into the old version.
|
|
9
|
-
*
|
|
10
|
-
* Replaces the DOM based `[data-update-worker]` wiring in the site bundle, which
|
|
11
|
-
* only works for markup that exists when the page loads.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useServiceWorkerUpdate(): {
|
|
14
|
-
isUpdateAvailable: boolean;
|
|
15
|
-
installUpdate: () => void;
|
|
16
|
-
};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from "react";
|
|
2
|
-
/**
|
|
3
|
-
* Track whether a new version of the site has been downloaded by the service
|
|
4
|
-
* worker and is waiting to take over.
|
|
5
|
-
*
|
|
6
|
-
* A waiting worker means every asset of the new version is already cached, so
|
|
7
|
-
* installing it is just `skipWaiting` followed by a reload. The reload is
|
|
8
|
-
* triggered from the worker's `activated` state change rather than immediately,
|
|
9
|
-
* so the page never reloads into the old version.
|
|
10
|
-
*
|
|
11
|
-
* Replaces the DOM based `[data-update-worker]` wiring in the site bundle, which
|
|
12
|
-
* only works for markup that exists when the page loads.
|
|
13
|
-
*/
|
|
14
|
-
export function useServiceWorkerUpdate() {
|
|
15
|
-
let [waitingWorker, setWaitingWorker] = useState(null);
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
if (!("serviceWorker" in navigator))
|
|
18
|
-
return;
|
|
19
|
-
let isCancelled = false;
|
|
20
|
-
let cleanups = [];
|
|
21
|
-
function watch(worker) {
|
|
22
|
-
if (isCancelled)
|
|
23
|
-
return;
|
|
24
|
-
setWaitingWorker(worker);
|
|
25
|
-
function onStateChange() {
|
|
26
|
-
// The new worker took over, so the page can safely reload into it.
|
|
27
|
-
if (worker.state === "activated")
|
|
28
|
-
window.location.reload();
|
|
29
|
-
}
|
|
30
|
-
worker.addEventListener("statechange", onStateChange);
|
|
31
|
-
cleanups.push(() => worker.removeEventListener("statechange", onStateChange));
|
|
32
|
-
}
|
|
33
|
-
navigator.serviceWorker.ready.then((registration) => {
|
|
34
|
-
if (isCancelled)
|
|
35
|
-
return;
|
|
36
|
-
if (registration.waiting)
|
|
37
|
-
watch(registration.waiting);
|
|
38
|
-
function onUpdateFound() {
|
|
39
|
-
let installing = registration.installing;
|
|
40
|
-
if (!installing)
|
|
41
|
-
return;
|
|
42
|
-
function onStateChange() {
|
|
43
|
-
if (installing?.state === "installed")
|
|
44
|
-
watch(installing);
|
|
45
|
-
}
|
|
46
|
-
installing.addEventListener("statechange", onStateChange);
|
|
47
|
-
cleanups.push(() => installing.removeEventListener("statechange", onStateChange));
|
|
48
|
-
}
|
|
49
|
-
registration.addEventListener("updatefound", onUpdateFound);
|
|
50
|
-
cleanups.push(() => registration.removeEventListener("updatefound", onUpdateFound));
|
|
51
|
-
});
|
|
52
|
-
return () => {
|
|
53
|
-
isCancelled = true;
|
|
54
|
-
for (let cleanup of cleanups)
|
|
55
|
-
cleanup();
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
|
-
let installUpdate = useCallback(() => {
|
|
59
|
-
waitingWorker?.postMessage({ action: "skipWaiting" });
|
|
60
|
-
}, [waitingWorker]);
|
|
61
|
-
return { isUpdateAvailable: waitingWorker !== null, installUpdate };
|
|
62
|
-
}
|