@peers-app/peers-ui 0.33.8 → 0.33.11
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/dist/apps-home/app-menu.d.ts +55 -0
- package/dist/apps-home/app-menu.js +126 -0
- package/dist/apps-home/app-status.d.ts +34 -0
- package/dist/apps-home/app-status.js +85 -0
- package/dist/apps-home/app-tile.d.ts +33 -0
- package/dist/apps-home/app-tile.js +106 -0
- package/dist/apps-home/apps-home.d.ts +29 -0
- package/dist/apps-home/apps-home.js +311 -0
- package/dist/apps-home/get-apps-sheet.d.ts +52 -0
- package/dist/apps-home/get-apps-sheet.js +130 -0
- package/dist/apps-home/pinned-apps.d.ts +73 -0
- package/dist/apps-home/pinned-apps.js +213 -0
- package/dist/apps-home/remove-app-dialog.d.ts +20 -0
- package/dist/apps-home/remove-app-dialog.js +62 -0
- package/dist/command-palette/command-palette-ui.js +2 -33
- package/dist/root-layout/root-layout-host.js +0 -1
- package/dist/screens/search/global-search.js +2 -33
- package/dist/tabs-layout/tabs-layout.js +2 -127
- package/dist/tabs-layout/tabs-state.d.ts +7 -10
- package/dist/tabs-layout/tabs-state.js +8 -63
- package/dist/theme.css +797 -0
- package/dist/ui-router/app-catalog.d.ts +55 -0
- package/dist/ui-router/app-catalog.js +74 -0
- package/package.json +3 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type AppColor, type IAppNav } from "@peers-app/peers-sdk";
|
|
2
|
+
import { type IPackageWithNavs } from "./routes-loader";
|
|
3
|
+
/** Whether an app is built into Peers or comes from an installed package. */
|
|
4
|
+
export type AppKind = "system" | "package";
|
|
5
|
+
/** One app: a screen that the Apps screen, the command palette and Search can open. */
|
|
6
|
+
export interface IAppEntry {
|
|
7
|
+
/** The app's canonical path, which opens it and identifies it (in pins, for example). */
|
|
8
|
+
path: string;
|
|
9
|
+
/** The package that adds it, `system-apps` for a built-in app. */
|
|
10
|
+
packageId: string;
|
|
11
|
+
/** The package's name. */
|
|
12
|
+
packageName: string;
|
|
13
|
+
/** The package's description, if it has one. */
|
|
14
|
+
packageDescription?: string;
|
|
15
|
+
/** The app nav it was built from. */
|
|
16
|
+
navItem: IAppNav;
|
|
17
|
+
/** The nav's name. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** The name to show: the nav's display name, or its name. */
|
|
20
|
+
displayName: string;
|
|
21
|
+
/** The Bootstrap icon class. */
|
|
22
|
+
iconClassName: string;
|
|
23
|
+
/** The icon's palette color, or `system` for a built-in app, which is drawn in grey. */
|
|
24
|
+
color: AppColor | "system";
|
|
25
|
+
/** Built in, or from a package. */
|
|
26
|
+
kind: AppKind;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The canonical path of an app: a built-in app's own route, or `package-nav/<packageId>/<nav>`
|
|
30
|
+
* for a package's app, with the nav path lowercased and its other characters made dashes.
|
|
31
|
+
*
|
|
32
|
+
* @param packageId - The package that adds the app, `system-apps` for a built-in one.
|
|
33
|
+
* @param navItem - The app nav.
|
|
34
|
+
*/
|
|
35
|
+
export declare function appPath(packageId: string, navItem: IAppNav): string;
|
|
36
|
+
/**
|
|
37
|
+
* Every app in the installed packages, then the built-in apps, in that order. A disabled
|
|
38
|
+
* package, or one without app navs, adds nothing.
|
|
39
|
+
*
|
|
40
|
+
* @param packages - Installed packages with the app navs of the version each runs here.
|
|
41
|
+
* @param system - The built-in apps' package.
|
|
42
|
+
*/
|
|
43
|
+
export declare function buildAppCatalog(packages: readonly IPackageWithNavs[], system?: IPackageWithNavs): IAppEntry[];
|
|
44
|
+
/**
|
|
45
|
+
* Whether an app matches a search: its display name, nav name, package name or package
|
|
46
|
+
* description contains the query, ignoring case. A built-in app matches on its own names only:
|
|
47
|
+
* they all share one package name and description, so those would match every one of them. An
|
|
48
|
+
* empty query matches everything.
|
|
49
|
+
*
|
|
50
|
+
* @param entry - The app.
|
|
51
|
+
* @param query - What the user typed.
|
|
52
|
+
*/
|
|
53
|
+
export declare function appMatchesQuery(entry: IAppEntry, query: string): boolean;
|
|
54
|
+
/** Every app in the current context, rebuilt when its installed packages change. */
|
|
55
|
+
export declare function useAppCatalog(): IAppEntry[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appPath = appPath;
|
|
4
|
+
exports.buildAppCatalog = buildAppCatalog;
|
|
5
|
+
exports.appMatchesQuery = appMatchesQuery;
|
|
6
|
+
exports.useAppCatalog = useAppCatalog;
|
|
7
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const use_observable_1 = require("../hooks/use-observable");
|
|
10
|
+
const system_apps_1 = require("../system-apps");
|
|
11
|
+
const routes_loader_1 = require("./routes-loader");
|
|
12
|
+
/**
|
|
13
|
+
* The canonical path of an app: a built-in app's own route, or `package-nav/<packageId>/<nav>`
|
|
14
|
+
* for a package's app, with the nav path lowercased and its other characters made dashes.
|
|
15
|
+
*
|
|
16
|
+
* @param packageId - The package that adds the app, `system-apps` for a built-in one.
|
|
17
|
+
* @param navItem - The app nav.
|
|
18
|
+
*/
|
|
19
|
+
function appPath(packageId, navItem) {
|
|
20
|
+
if (packageId === system_apps_1.systemPackage.packageId) {
|
|
21
|
+
return navItem.navigationPath ?? navItem.name.replace(/\s/g, "-").toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
const nav = (navItem.navigationPath ?? navItem.name).replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
24
|
+
return `package-nav/${packageId}/${nav}`.replace(/\/{2,}/g, "/");
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Every app in the installed packages, then the built-in apps, in that order. A disabled
|
|
28
|
+
* package, or one without app navs, adds nothing.
|
|
29
|
+
*
|
|
30
|
+
* @param packages - Installed packages with the app navs of the version each runs here.
|
|
31
|
+
* @param system - The built-in apps' package.
|
|
32
|
+
*/
|
|
33
|
+
function buildAppCatalog(packages, system = system_apps_1.systemPackage) {
|
|
34
|
+
return [...packages, system]
|
|
35
|
+
.filter((pkg) => !pkg.disabled && (pkg.appNavs?.length ?? 0) > 0)
|
|
36
|
+
.flatMap((pkg) => {
|
|
37
|
+
const isSystem = pkg.packageId === system.packageId;
|
|
38
|
+
return (pkg.appNavs ?? []).map((navItem) => ({
|
|
39
|
+
path: appPath(pkg.packageId, navItem),
|
|
40
|
+
packageId: pkg.packageId,
|
|
41
|
+
packageName: pkg.name,
|
|
42
|
+
packageDescription: pkg.description || undefined,
|
|
43
|
+
navItem,
|
|
44
|
+
name: navItem.name,
|
|
45
|
+
displayName: navItem.displayName || navItem.name,
|
|
46
|
+
iconClassName: navItem.iconClassName || "bi-box-seam",
|
|
47
|
+
color: isSystem ? "system" : (0, peers_sdk_1.resolveAppColor)(pkg.packageId, navItem),
|
|
48
|
+
kind: isSystem ? "system" : "package",
|
|
49
|
+
}));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether an app matches a search: its display name, nav name, package name or package
|
|
54
|
+
* description contains the query, ignoring case. A built-in app matches on its own names only:
|
|
55
|
+
* they all share one package name and description, so those would match every one of them. An
|
|
56
|
+
* empty query matches everything.
|
|
57
|
+
*
|
|
58
|
+
* @param entry - The app.
|
|
59
|
+
* @param query - What the user typed.
|
|
60
|
+
*/
|
|
61
|
+
function appMatchesQuery(entry, query) {
|
|
62
|
+
const needle = query.trim().toLowerCase();
|
|
63
|
+
if (!needle)
|
|
64
|
+
return true;
|
|
65
|
+
const texts = entry.kind === "system"
|
|
66
|
+
? [entry.displayName, entry.name]
|
|
67
|
+
: [entry.displayName, entry.name, entry.packageName, entry.packageDescription];
|
|
68
|
+
return texts.some((text) => !!text && text.toLowerCase().includes(needle));
|
|
69
|
+
}
|
|
70
|
+
/** Every app in the current context, rebuilt when its installed packages change. */
|
|
71
|
+
function useAppCatalog() {
|
|
72
|
+
const [packages] = (0, use_observable_1.useObservable)(routes_loader_1.allPackages);
|
|
73
|
+
return (0, react_1.useMemo)(() => buildAppCatalog(packages), [packages]);
|
|
74
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peers-app/peers-ui",
|
|
3
|
-
"version": "0.33.
|
|
3
|
+
"version": "0.33.11",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/peers-app/peers-ui.git"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"lint:fix": "biome check --write ."
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@peers-app/peers-sdk": "^0.33.
|
|
39
|
+
"@peers-app/peers-sdk": "^0.33.11",
|
|
40
40
|
"bootstrap": "^5.3.3",
|
|
41
41
|
"react": "^18.0.0",
|
|
42
42
|
"react-dom": "^18.0.0"
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@babel/preset-react": "^7.24.1",
|
|
48
48
|
"@babel/preset-typescript": "^7.27.1",
|
|
49
49
|
"@biomejs/biome": "2.3.11",
|
|
50
|
-
"@peers-app/peers-sdk": "0.33.
|
|
50
|
+
"@peers-app/peers-sdk": "0.33.11",
|
|
51
51
|
"@testing-library/dom": "^10.4.0",
|
|
52
52
|
"@testing-library/jest-dom": "^6.6.3",
|
|
53
53
|
"@testing-library/react": "^16.3.0",
|