@peers-app/peers-ui 0.33.18 → 0.33.20
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-tile.js +2 -1
- package/dist/apps-home/get-apps-sheet.js +2 -1
- package/dist/apps-home/remove-app-dialog.js +2 -1
- package/dist/command-palette/command-palette-ui.js +3 -2
- package/dist/command-palette/command-palette.d.ts +47 -0
- package/dist/command-palette/command-palette.js +42 -9
- package/dist/components/color-picker.d.ts +28 -0
- package/dist/components/color-picker.js +97 -0
- package/dist/components/group-switcher.d.ts +3 -2
- package/dist/components/group-switcher.js +74 -101
- package/dist/components/icon-picker.d.ts +20 -0
- package/dist/components/icon-picker.js +98 -0
- package/dist/components/icon-search.d.ts +60 -0
- package/dist/components/icon-search.js +227 -0
- package/dist/components/icon.d.ts +35 -0
- package/dist/components/icon.js +34 -0
- package/dist/components/markdown-editor/mention-preview-card.js +2 -1
- package/dist/components/markdown-editor/mentions-plugin.js +2 -1
- package/dist/groups/group-appearance-dialog.d.ts +45 -0
- package/dist/groups/group-appearance-dialog.js +239 -0
- package/dist/groups/group-look.d.ts +45 -0
- package/dist/groups/group-look.js +47 -0
- package/dist/groups/groups-client.d.ts +29 -0
- package/dist/groups/groups-client.js +81 -0
- package/dist/groups/index.d.ts +3 -0
- package/dist/groups/index.js +15 -0
- package/dist/icon-index/bootstrap-icons.json +1 -0
- package/dist/icon-index/emoji.json +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -1
- package/dist/mentions/mention-chip.js +2 -1
- package/dist/mentions/mention-chooser.js +2 -1
- package/dist/root-layout/layouts/full-screen-layout.js +2 -1
- package/dist/screens/groups/group-details.js +16 -2
- package/dist/screens/groups/group-list.js +37 -43
- package/dist/screens/groups/groups-ipc.d.ts +15 -0
- package/dist/screens/groups/groups-ipc.js +28 -0
- package/dist/screens/packages/package-waiting.js +4 -3
- package/dist/screens/peer-types/peer-type-details.d.ts +9 -1
- package/dist/screens/peer-types/peer-type-details.js +16 -13
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -0
- package/dist/screens/peer-types/peer-type-list.js +3 -1
- package/dist/screens/search/global-search.js +2 -1
- package/dist/tabs-layout/tab-color.d.ts +9 -2
- package/dist/tabs-layout/tab-color.js +14 -4
- package/dist/tabs-layout/tab-order.d.ts +51 -0
- package/dist/tabs-layout/tab-order.js +70 -0
- package/dist/tabs-layout/tab-switcher-overlay.d.ts +16 -0
- package/dist/tabs-layout/tab-switcher-overlay.js +68 -0
- package/dist/tabs-layout/tab-switcher.d.ts +64 -0
- package/dist/tabs-layout/tab-switcher.js +150 -0
- package/dist/tabs-layout/tabs-layout.d.ts +3 -1
- package/dist/tabs-layout/tabs-layout.js +92 -47
- package/dist/tabs-layout/tabs-state.d.ts +34 -13
- package/dist/tabs-layout/tabs-state.js +104 -31
- package/dist/theme.css +327 -0
- package/dist/ui-defaults/list-screen.d.ts +1 -0
- package/dist/ui-defaults/list-screen.js +3 -1
- package/package.json +4 -4
|
@@ -6,21 +6,32 @@ exports.GroupSummaryRow = GroupSummaryRow;
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
+
const color_picker_1 = require("../../components/color-picker");
|
|
10
|
+
const icon_1 = require("../../components/icon");
|
|
9
11
|
const loading_indicator_1 = require("../../components/loading-indicator");
|
|
10
12
|
const globals_1 = require("../../globals");
|
|
13
|
+
const group_appearance_dialog_1 = require("../../groups/group-appearance-dialog");
|
|
14
|
+
const group_look_1 = require("../../groups/group-look");
|
|
15
|
+
const groups_client_1 = require("../../groups/groups-client");
|
|
11
16
|
const hooks_1 = require("../../hooks");
|
|
17
|
+
const use_observable_1 = require("../../hooks/use-observable");
|
|
12
18
|
const identity_routes_1 = require("../identity/identity-routes");
|
|
13
19
|
const activity_view_1 = require("../invites/activity-view");
|
|
14
|
-
const
|
|
20
|
+
const groups_ipc_1 = require("./groups-ipc");
|
|
15
21
|
/** Search, summarize, and create groups owned by the signed-in user. */
|
|
16
22
|
function GroupList(props = {}) {
|
|
17
23
|
const userContext = (0, hooks_1.usePromise)(peers_sdk_1.getUserContext);
|
|
18
|
-
const
|
|
24
|
+
const creating = props.creating ?? false;
|
|
19
25
|
const [draftName, setDraftName] = (0, react_1.useState)("");
|
|
20
26
|
const [searchText, setSearchText] = (0, react_1.useState)("");
|
|
21
27
|
const [summaries, setSummaries] = (0, react_1.useState)();
|
|
22
28
|
const [error, setError] = (0, react_1.useState)("");
|
|
23
29
|
const [creatingBusy, setCreatingBusy] = (0, react_1.useState)(false);
|
|
30
|
+
const [looks] = (0, use_observable_1.useObservable)(creating ? (0, groups_client_1.groupsObservable)() : undefined);
|
|
31
|
+
// A new group starts in the palette color its creator uses least.
|
|
32
|
+
const suggestedColor = (0, react_1.useMemo)(() => looks && (0, peers_sdk_1.leastUsedPaletteColor)(looks.map((look) => look.color)), [looks]);
|
|
33
|
+
const [pickedColor, setPickedColor] = (0, react_1.useState)();
|
|
34
|
+
const draftColor = pickedColor ?? suggestedColor;
|
|
24
35
|
const [groupRevision, setGroupRevision] = (0, react_1.useState)(0);
|
|
25
36
|
(0, react_1.useEffect)(() => {
|
|
26
37
|
if (!userContext) {
|
|
@@ -61,8 +72,9 @@ function GroupList(props = {}) {
|
|
|
61
72
|
};
|
|
62
73
|
}, [groupRevision, userContext]);
|
|
63
74
|
(0, react_1.useEffect)(() => {
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
if (!creating)
|
|
76
|
+
setPickedColor(undefined);
|
|
77
|
+
}, [creating]);
|
|
66
78
|
const filtered = (0, react_1.useMemo)(() => {
|
|
67
79
|
const query = searchText.trim().toLocaleLowerCase();
|
|
68
80
|
if (!query) {
|
|
@@ -83,9 +95,10 @@ function GroupList(props = {}) {
|
|
|
83
95
|
setCreatingBusy(true);
|
|
84
96
|
setError("");
|
|
85
97
|
try {
|
|
98
|
+
await newRecord(name);
|
|
86
99
|
setDraftName("");
|
|
87
100
|
setSearchText("");
|
|
88
|
-
|
|
101
|
+
setPickedColor(undefined);
|
|
89
102
|
}
|
|
90
103
|
catch (err) {
|
|
91
104
|
setError(err.message || "Could not create the group.");
|
|
@@ -95,47 +108,19 @@ function GroupList(props = {}) {
|
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
110
|
async function newRecord(name) {
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
// Generate cryptographic keys for the group
|
|
102
|
-
const groupKeys = (0, peers_sdk_1.newKeys)();
|
|
103
|
-
// NOTE: this is relying on the userContext to be able to create a group context for a group that doesn't yet exist
|
|
104
|
-
// at time of writing, this is supported but is probably unintuitive behavior so we need to watch for this changing in the future
|
|
105
|
-
const groupDataContext = userContext.getDataContext(groupId);
|
|
106
|
-
// Store the validated secret under its deterministic persistent-variable ID.
|
|
107
|
-
await (0, peers_sdk_1.saveGroupSecretKey)(userContext.userDataContext, groupId, groupKeys.secretKey, groupKeys);
|
|
108
|
-
// add me to the group's users table
|
|
109
|
-
const me = await (0, peers_sdk_1.getMe)();
|
|
110
|
-
await (0, peers_sdk_1.Users)(groupDataContext).save(me);
|
|
111
|
-
// Set trust level for current user in the group context
|
|
112
|
-
await (0, peers_sdk_1.setUserTrustLevel)(me.userId, peers_sdk_1.TrustLevel.Trusted, groupDataContext);
|
|
113
|
-
// create group in both the user's and group's context
|
|
114
|
-
const group = await (0, peers_sdk_1.Groups)(userContext.userDataContext).signAndSave({
|
|
115
|
-
groupId,
|
|
116
|
-
name: groupName,
|
|
117
|
-
description: "",
|
|
118
|
-
iconClassName: "bi-people-fill", // Default icon
|
|
119
|
-
founderUserId: me.userId,
|
|
120
|
-
disabled: false,
|
|
121
|
-
publicKey: groupKeys.publicKey,
|
|
122
|
-
publicBoxKey: groupKeys.publicBoxKey,
|
|
123
|
-
signature: "", // will be set via signAndSave
|
|
111
|
+
const { groupId, warning } = await (0, groups_ipc_1.createGroupOnHost)({
|
|
112
|
+
name: name.trim(),
|
|
113
|
+
...(draftColor ? { color: draftColor } : {}),
|
|
124
114
|
});
|
|
125
|
-
|
|
126
|
-
//
|
|
127
|
-
|
|
128
|
-
.
|
|
129
|
-
.catch((err) => {
|
|
130
|
-
console.error("Error auto-installing peers-core for group:", err);
|
|
131
|
-
});
|
|
132
|
-
(0, globals_1.mainContentPath)(`${identity_routes_1.IDENTITY_GROUPS_PATH}/${group.groupId}`);
|
|
133
|
-
return group;
|
|
115
|
+
(0, globals_1.mainContentPath)(`${identity_routes_1.IDENTITY_GROUPS_PATH}/${groupId}`);
|
|
116
|
+
// The group exists, but its look didn't save: say so where it can be picked again.
|
|
117
|
+
if (warning)
|
|
118
|
+
(0, group_appearance_dialog_1.openGroupAppearanceDialog)(groupId, { notice: warning, layer: "everyone" });
|
|
134
119
|
}
|
|
135
120
|
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("h4", { className: "mb-1", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-people-fill me-2" }), "Groups"] }), (0, jsx_runtime_1.jsx)("div", { className: "small text-muted", children: "Shared spaces, membership, and access" })] }), creating ? ((0, jsx_runtime_1.jsx)("div", { className: "card mb-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsx)("h6", { className: "card-title", children: "Create a group" }), (0, jsx_runtime_1.jsxs)("form", { className: "input-group", onSubmit: (event) => {
|
|
136
121
|
event.preventDefault();
|
|
137
122
|
void confirmCreate();
|
|
138
|
-
}, children: [(0, jsx_runtime_1.jsx)("input", { id: "new-group-name", className: "form-control", value: draftName, onChange: (event) => setDraftName(event.target.value), placeholder: "Group name", "aria-label": "Group name" }), (0, jsx_runtime_1.jsx)("button", { type: "submit", className: "btn btn-primary", disabled: !draftName.trim() || creatingBusy, children: creatingBusy ? "Creating…" : "Create" }), (0, jsx_runtime_1.jsx)("a", { href: `#${identity_routes_1.IDENTITY_GROUPS_PATH}`, className: "btn btn-outline-secondary", children: "Cancel" })] })] }) })) : null, (0, jsx_runtime_1.jsx)(activity_view_1.PendingWorkLink, { type: "group" }), (0, jsx_runtime_1.jsxs)("div", { className: "position-relative my-3", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-search position-absolute text-muted", style: { left: 12, top: "50%", transform: "translateY(-50%)" } }), (0, jsx_runtime_1.jsx)("input", { type: "search", className: "form-control ps-5", value: searchText, onChange: (event) => setSearchText(event.target.value), placeholder: "Search groups", "aria-label": "Search groups" })] }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger", children: error }) : null, !summaries && !error ? (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {}) : null, summaries && filtered.length === 0 ? ((0, jsx_runtime_1.jsxs)("div", { className: "border rounded p-4 text-center", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-people fs-2 text-muted" }), (0, jsx_runtime_1.jsx)("h6", { className: "mt-2", children: searchText ? "No matching groups" : "No groups yet" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-muted", children: searchText
|
|
123
|
+
}, children: [(0, jsx_runtime_1.jsx)("input", { id: "new-group-name", className: "form-control", value: draftName, onChange: (event) => setDraftName(event.target.value), placeholder: "Group name", "aria-label": "Group name" }), (0, jsx_runtime_1.jsx)("button", { type: "submit", className: "btn btn-primary", disabled: !draftName.trim() || creatingBusy, children: creatingBusy ? "Creating…" : "Create" }), (0, jsx_runtime_1.jsx)("a", { href: `#${identity_routes_1.IDENTITY_GROUPS_PATH}`, className: "btn btn-outline-secondary", children: "Cancel" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "mt-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary mb-1", children: "Color" }), (0, jsx_runtime_1.jsx)(color_picker_1.ColorPicker, { value: draftColor, onChange: setPickedColor, label: "New group's color", disabled: creatingBusy })] })] }) })) : null, (0, jsx_runtime_1.jsx)(activity_view_1.PendingWorkLink, { type: "group" }), (0, jsx_runtime_1.jsxs)("div", { className: "position-relative my-3", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-search position-absolute text-muted", style: { left: 12, top: "50%", transform: "translateY(-50%)" } }), (0, jsx_runtime_1.jsx)("input", { type: "search", className: "form-control ps-5", value: searchText, onChange: (event) => setSearchText(event.target.value), placeholder: "Search groups", "aria-label": "Search groups" })] }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger", children: error }) : null, userContext && !searchText.trim() ? ((0, jsx_runtime_1.jsx)("div", { className: "list-group mb-3", children: (0, jsx_runtime_1.jsx)(PersonalRow, { userId: userContext.userId }) })) : null, !summaries && !error ? (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {}) : null, summaries && filtered.length === 0 ? ((0, jsx_runtime_1.jsxs)("div", { className: "border rounded p-4 text-center", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-people fs-2 text-muted" }), (0, jsx_runtime_1.jsx)("h6", { className: "mt-2", children: searchText ? "No matching groups" : "No groups yet" }), (0, jsx_runtime_1.jsx)("p", { className: "small text-muted", children: searchText
|
|
139
124
|
? "Try a different name or description."
|
|
140
125
|
: "Create a shared space or use an invite to join one." }), !searchText ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary btn-sm", onClick: startCreate, children: "Create your first group" })) : null] })) : null, filtered.length > 0 ? ((0, jsx_runtime_1.jsx)("div", { className: "list-group", children: filtered.map((summary) => ((0, jsx_runtime_1.jsx)(GroupSummaryRow, { summary: summary }, summary.group.groupId))) })) : null, userContext ? (0, jsx_runtime_1.jsx)(RemovedGroups, { userContext: userContext, revision: groupRevision }) : null] }));
|
|
141
126
|
}
|
|
@@ -182,7 +167,7 @@ function RemovedGroups(props) {
|
|
|
182
167
|
if (!groups.length && !error) {
|
|
183
168
|
return null;
|
|
184
169
|
}
|
|
185
|
-
return ((0, jsx_runtime_1.jsxs)("details", { className: "mt-4", children: [(0, jsx_runtime_1.jsxs)("summary", { className: "small text-muted", children: ["Removed groups (", groups.length, ")"] }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger mt-2", children: error }) : null, (0, jsx_runtime_1.jsx)("div", { className: "list-group mt-2", children: groups.map((group) => ((0, jsx_runtime_1.jsxs)("div", { className: "list-group-item d-flex align-items-center gap-3", children: [(0, jsx_runtime_1.jsx)(
|
|
170
|
+
return ((0, jsx_runtime_1.jsxs)("details", { className: "mt-4", children: [(0, jsx_runtime_1.jsxs)("summary", { className: "small text-muted", children: ["Removed groups (", groups.length, ")"] }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger mt-2", children: error }) : null, (0, jsx_runtime_1.jsx)("div", { className: "list-group mt-2", children: groups.map((group) => ((0, jsx_runtime_1.jsxs)("div", { className: "list-group-item d-flex align-items-center gap-3", children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: group.iconClassName, fallback: "bi:people-fill" }), (0, jsx_runtime_1.jsxs)("span", { className: "flex-grow-1 overflow-hidden", children: [(0, jsx_runtime_1.jsx)("span", { className: "d-block text-truncate", children: group.name || "Unnamed group" }), (0, jsx_runtime_1.jsx)("span", { className: "small text-muted d-block text-truncate font-monospace", children: group.groupId })] }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary btn-sm", disabled: restoringId === group.groupId, onClick: () => void restore(group.groupId), children: restoringId === group.groupId ? "Restoring…" : "Restore" })] }, group.groupId))) })] }));
|
|
186
171
|
}
|
|
187
172
|
async function loadGroupSummaries(userContext) {
|
|
188
173
|
const groups = await (0, peers_sdk_1.Groups)(userContext.userDataContext).list({ disabled: { $ne: true } });
|
|
@@ -201,7 +186,16 @@ async function loadGroupSummaries(userContext) {
|
|
|
201
186
|
/** Compact, fully clickable group summary row. */
|
|
202
187
|
function GroupSummaryRow({ summary }) {
|
|
203
188
|
const { group } = summary;
|
|
204
|
-
|
|
189
|
+
const look = (0, groups_client_1.useGroup)(group.groupId);
|
|
190
|
+
return ((0, jsx_runtime_1.jsxs)("a", { href: `#${identity_routes_1.IDENTITY_GROUPS_PATH}/${group.groupId}`, className: "list-group-item list-group-item-action d-flex align-items-center gap-3 py-3", children: [(0, jsx_runtime_1.jsx)(group_look_1.GroupIcon, { icon: look?.icon ?? group.iconClassName, color: look?.color, variant: "tile", size: "44px" }), (0, jsx_runtime_1.jsxs)("span", { className: "flex-grow-1 overflow-hidden", children: [(0, jsx_runtime_1.jsx)("span", { className: "fw-semibold d-block text-truncate", children: group.name || "Unnamed group" }), (0, jsx_runtime_1.jsx)("span", { className: "small text-muted d-block text-truncate", children: plainDescription(group.description) || "No description yet" })] }), (0, jsx_runtime_1.jsxs)("span", { className: "d-flex align-items-center gap-2 flex-wrap justify-content-end", children: [(0, jsx_runtime_1.jsxs)("span", { className: "badge text-bg-light border", children: [summary.memberCount, " member", summary.memberCount === 1 ? "" : "s"] }), summary.myRole !== undefined ? ((0, jsx_runtime_1.jsx)("span", { className: "badge text-bg-secondary", children: (0, peers_sdk_1.getRoleLabel)(summary.myRole) })) : null] }), (0, jsx_runtime_1.jsx)("i", { className: "bi bi-chevron-right text-muted", "aria-hidden": "true" })] }));
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Personal, at the top of the list. It has no details page (no one else is in it), so the row
|
|
194
|
+
* opens the color-and-icon dialog.
|
|
195
|
+
*/
|
|
196
|
+
function PersonalRow({ userId }) {
|
|
197
|
+
const look = (0, groups_client_1.useGroup)(userId);
|
|
198
|
+
return ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "list-group-item list-group-item-action d-flex align-items-center gap-3 py-3", onClick: () => (0, group_appearance_dialog_1.openGroupAppearanceDialog)(userId), children: [(0, jsx_runtime_1.jsx)(group_look_1.GroupIcon, { icon: look?.icon ?? "bi:person-fill", color: look?.color, variant: "tile", size: "44px" }), (0, jsx_runtime_1.jsxs)("span", { className: "flex-grow-1 overflow-hidden text-start", children: [(0, jsx_runtime_1.jsx)("span", { className: "fw-semibold d-block text-truncate", children: "Personal" }), (0, jsx_runtime_1.jsx)("span", { className: "small text-muted d-block text-truncate", children: "Only you, on all your devices" })] }), (0, jsx_runtime_1.jsx)("span", { className: "small text-body-secondary", children: "Color and icon" }), (0, jsx_runtime_1.jsx)("i", { className: "bi bi-palette text-muted", "aria-hidden": "true" })] }));
|
|
205
199
|
}
|
|
206
200
|
function plainDescription(markdown) {
|
|
207
201
|
return markdown
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ICreateGroupToolInput, type ICreateGroupToolResult, type IHostContractConsumer, type IHostToolsConsumer } from "@peers-app/peers-sdk";
|
|
2
|
+
/**
|
|
3
|
+
* System Host Tools on the local host, bound to Personal. Made on first use: a handle listens for
|
|
4
|
+
* host transport changes, and this module is imported at startup (the group switcher), while
|
|
5
|
+
* groups are created rarely.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hostToolsContract(): IHostContractConsumer<IHostToolsConsumer>;
|
|
8
|
+
/**
|
|
9
|
+
* Create a group through the host, the one way Peers creates one: it signs the record, gives the
|
|
10
|
+
* group its color and icon, and installs the default packages.
|
|
11
|
+
*
|
|
12
|
+
* @param input - Name, and optionally a color and icon reference.
|
|
13
|
+
* @returns The new group's id, and a warning when its look couldn't be saved.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createGroupOnHost(input: ICreateGroupToolInput): Promise<ICreateGroupToolResult>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hostToolsContract = hostToolsContract;
|
|
4
|
+
exports.createGroupOnHost = createGroupOnHost;
|
|
5
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
|
+
let hostTools;
|
|
7
|
+
/**
|
|
8
|
+
* System Host Tools on the local host, bound to Personal. Made on first use: a handle listens for
|
|
9
|
+
* host transport changes, and this module is imported at startup (the group switcher), while
|
|
10
|
+
* groups are created rarely.
|
|
11
|
+
*/
|
|
12
|
+
function hostToolsContract() {
|
|
13
|
+
hostTools ??= (0, peers_sdk_1.hostContractConsumer)((0, peers_sdk_1.getHostToolsContractDefinition)(), {
|
|
14
|
+
dataContextId: async () => (await (0, peers_sdk_1.getUserContext)()).userId,
|
|
15
|
+
});
|
|
16
|
+
return hostTools;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Create a group through the host, the one way Peers creates one: it signs the record, gives the
|
|
20
|
+
* group its color and icon, and installs the default packages.
|
|
21
|
+
*
|
|
22
|
+
* @param input - Name, and optionally a color and icon reference.
|
|
23
|
+
* @returns The new group's id, and a warning when its look couldn't be saved.
|
|
24
|
+
*/
|
|
25
|
+
async function createGroupOnHost(input) {
|
|
26
|
+
const tools = (await hostToolsContract().get()).tools;
|
|
27
|
+
return tools["create-group"](input);
|
|
28
|
+
}
|
|
@@ -8,6 +8,7 @@ const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const current_group_name_1 = require("../../apps-home/current-group-name");
|
|
10
10
|
const get_apps_sheet_1 = require("../../apps-home/get-apps-sheet");
|
|
11
|
+
const icon_1 = require("../../components/icon");
|
|
11
12
|
const delegates_ipc_1 = require("../../delegates/delegates-ipc");
|
|
12
13
|
const use_observable_1 = require("../../hooks/use-observable");
|
|
13
14
|
const use_promise_1 = require("../../hooks/use-promise");
|
|
@@ -32,7 +33,7 @@ function PackageWaitingScreen({ packageId, missing }) {
|
|
|
32
33
|
// The report names contracts other contexts know; the runtime state may not have yet.
|
|
33
34
|
const names = (0, peers_sdk_1.missingContractsLabel)(report?.missing.length ? report.missing : missing);
|
|
34
35
|
const here = groupName || "this group";
|
|
35
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting", "data-testid": "package-waiting", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting-head", children: [(0, jsx_runtime_1.jsxs)("span", { className: `peers-app-icon peers-app-color-${app.color}`, "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)(
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting", "data-testid": "package-waiting", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting-head", children: [(0, jsx_runtime_1.jsxs)("span", { className: `peers-app-icon peers-app-color-${app.color}`, "aria-hidden": "true", children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: app.iconClassName }), (0, jsx_runtime_1.jsx)("span", { className: "peers-waiting-badge", children: (0, jsx_runtime_1.jsx)("i", { className: "bi-hourglass-split" }) })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("h2", { children: [app.name, " is waiting to start"] }), (0, jsx_runtime_1.jsxs)("p", { className: "peers-waiting-lead", children: ["It needs ", names, ", and no package in ", here, " provides ", missing.length > 1 ? "them" : "it", " ", "yet."] })] })] }), (0, jsx_runtime_1.jsxs)("p", { className: "peers-waiting-explain", children: [app.name, " is installed, and its data keeps syncing. It starts by itself as soon as a package that provides ", missing.length > 1 ? "them" : "it", " is running here."] }), admin === false && ((0, jsx_runtime_1.jsxs)("p", { className: "peers-waiting-explain", "data-testid": "package-waiting-admin-only", children: ["Only an admin of ", here, " can add packages here."] })), error ? ((0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2 px-3 small", role: "alert", children: error })) : !report ? ((0, jsx_runtime_1.jsx)("div", { className: "text-center py-3", children: (0, jsx_runtime_1.jsx)("output", { className: "spinner-border spinner-border-sm text-secondary", children: (0, jsx_runtime_1.jsx)("span", { className: "visually-hidden", children: "Loading" }) }) })) : (needs.map((need) => ((0, jsx_runtime_1.jsx)(RequiredContract, { need: need, appName: app.name, groupName: here, canAdd: canAdd, onAdded: refresh }, `${need.contractId}@${need.version}`)))), (0, jsx_runtime_1.jsx)("div", { className: "peers-waiting-foot", children: (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link p-0", onClick: () => (0, tabs_state_1.navigateTo)(`packages/${packageId}`), "data-testid": "package-waiting-details", children: "Details and versions" }) })] }));
|
|
36
37
|
}
|
|
37
38
|
/**
|
|
38
39
|
* The line a waiting package shows where another screen embeds one of its parts: what it waits
|
|
@@ -52,7 +53,7 @@ function InstalledProvider({ provider, appName, groupName, canAdd, onAdded, }) {
|
|
|
52
53
|
const look = useAppLook(provider.packageId, provider.name);
|
|
53
54
|
const [state, add] = useAddAction(onAdded);
|
|
54
55
|
const turnOn = provider.status === "disabled" && canAdd;
|
|
55
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting-provider", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-row", "data-testid": `package-waiting-installed-${provider.packageId}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${look.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)(
|
|
56
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-waiting-provider", children: [(0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-row", "data-testid": `package-waiting-installed-${provider.packageId}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${look.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: look.iconClassName }) }), (0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-text", children: [(0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-name", children: provider.name }), (0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-desc", children: provider.cycle
|
|
56
57
|
? `It needs ${appName} too, so neither can start. One of them has to stop requiring the other: tell their authors.`
|
|
57
58
|
: `Installed in ${groupName}, but ${installedPhrase(provider.status)}.` }), provider.reason && provider.status !== "waiting" && !provider.cycle && ((0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-desc", children: provider.reason })), state.error && ((0, jsx_runtime_1.jsx)("div", { className: "small text-danger mt-1", role: "alert", children: state.error }))] }), (0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-action", "aria-live": "polite", children: turnOn ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn peers-get-apps-add", disabled: state.adding, onClick: () => add([{ packageId: provider.packageId }]), children: state.adding ? "Turning on…" : "Turn on" })) : provider.status !== "waiting" ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0", onClick: () => (0, tabs_state_1.navigateTo)(`packages/${provider.packageId}`), children: "Details" })) : null })] }), provider.missing?.length ? ((0, jsx_runtime_1.jsx)("div", { className: "peers-waiting-chain", children: provider.missing.map((need) => ((0, jsx_runtime_1.jsx)(RequiredContract, { need: need, appName: provider.name, groupName: groupName, canAdd: canAdd, onAdded: onAdded }, `${need.contractId}@${need.version}`))) })) : null] }));
|
|
58
59
|
}
|
|
@@ -62,7 +63,7 @@ function ProviderToAdd({ entry, groupName, canAdd, onAdded, }) {
|
|
|
62
63
|
const [state, add] = useAddAction(onAdded);
|
|
63
64
|
const plan = providersToAdd(entry);
|
|
64
65
|
const also = plan.add.slice(0, -1).map((each) => (0, get_apps_sheet_1.packageToAddDisplay)(each).title);
|
|
65
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-row", "data-testid": `package-waiting-add-row-${entry.packageId}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${display.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)(
|
|
66
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-row", "data-testid": `package-waiting-add-row-${entry.packageId}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${display.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: display.iconClassName }) }), (0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-text", children: [(0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-name", children: display.title }), (0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-desc", children: ["In ", entry.sourceName, entry.version ? ` · v${entry.version}` : "", entry.description ? ` · ${entry.description}` : ""] }), also.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-desc", children: ["Adding it adds ", (0, peers_sdk_1.joinNames)(also), " too, which it needs."] })), plan.unmet.length > 0 && ((0, jsx_runtime_1.jsxs)("div", { className: "peers-get-apps-desc", children: ["It needs ", (0, peers_sdk_1.joinNames)(plan.unmet), " as well, which none of your groups has."] })), state.error && ((0, jsx_runtime_1.jsx)("div", { className: "small text-danger mt-1", role: "alert", children: state.error }))] }), (0, jsx_runtime_1.jsx)("div", { className: "peers-get-apps-action", "aria-live": "polite", children: state.added ? ((0, jsx_runtime_1.jsxs)("span", { className: "peers-get-apps-done", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-check-lg", "aria-hidden": "true" }), "Added"] })) : entry.unsupportedHere ? ((0, jsx_runtime_1.jsx)("span", { className: "peers-get-apps-note", children: "Not on this device" })) : canAdd ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn peers-get-apps-add", disabled: state.adding, onClick: () => add(plan.add.map((each) => ({
|
|
66
67
|
packageId: each.packageId,
|
|
67
68
|
fromDataContextId: each.sourceDataContextId,
|
|
68
69
|
}))), "aria-label": `Add ${display.title} to ${groupName}`, "data-testid": `package-waiting-add-${entry.packageId}`, children: state.adding ? "Adding…" : "Add" })) : null })] }));
|
|
@@ -2,8 +2,16 @@ import { type Observable } from "@peers-app/peers-sdk";
|
|
|
2
2
|
interface IProps {
|
|
3
3
|
peerTypeId: string;
|
|
4
4
|
}
|
|
5
|
+
/** Edit one peer type: its name, icon, description and value schema. */
|
|
5
6
|
export declare const PeerTypeDetails: (props: IProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
|
|
7
|
+
/**
|
|
8
|
+
* A peer type's icon, picked from Bootstrap Icons. Saved as a Bootstrap class (`bi bi-house`),
|
|
9
|
+
* the form older Peers versions draw; emoji aren't offered for the same reason. The icon is
|
|
10
|
+
* optional: "Use the default icon" clears it, so the peer type shows the default again.
|
|
11
|
+
*
|
|
12
|
+
* @param props.icon - The peer type's `iconClass` field.
|
|
13
|
+
*/
|
|
14
|
+
export declare const PeerTypeIconField: (props: {
|
|
7
15
|
icon: Observable<string | undefined>;
|
|
8
16
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
17
|
export {};
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PeerTypeIconField = exports.PeerTypeDetails = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
+
const icon_1 = require("../../components/icon");
|
|
8
|
+
const icon_picker_1 = require("../../components/icon-picker");
|
|
7
9
|
const input_1 = require("../../components/input");
|
|
8
10
|
const io_schema_1 = require("../../components/io-schema");
|
|
9
11
|
const loading_indicator_1 = require("../../components/loading-indicator");
|
|
10
12
|
const editor_inline_1 = require("../../components/markdown-editor/editor-inline");
|
|
11
13
|
const save_button_1 = require("../../components/save-button");
|
|
12
14
|
const tabs_1 = require("../../components/tabs");
|
|
13
|
-
const tooltip_1 = require("../../components/tooltip");
|
|
14
15
|
const hooks_1 = require("../../hooks");
|
|
15
16
|
const tabs_state_1 = require("../../tabs-layout/tabs-state");
|
|
17
|
+
/** Edit one peer type: its name, icon, description and value schema. */
|
|
16
18
|
const PeerTypeDetails = (props) => {
|
|
17
19
|
const valueType = (0, hooks_1.usePromise)(async () => {
|
|
18
20
|
const valueType = await (0, peers_sdk_1.PeerTypes)().get(props.peerTypeId);
|
|
@@ -54,21 +56,22 @@ exports.PeerTypeDetails = PeerTypeDetails;
|
|
|
54
56
|
const VariableInfo = (props) => {
|
|
55
57
|
const { valueType } = props;
|
|
56
58
|
valueType.description = valueType.description || "";
|
|
57
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("small", { className: "text-body-secondary", children: "Name:" }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: valueType.qs.name, className: "form-control mb-3 p-0 ps-2", placeholder: "Variable name", title: "Variable name" }), (0, jsx_runtime_1.
|
|
58
|
-
"Icon classes can be found at:",
|
|
59
|
-
"[Bootstrap Icons](https://icons.getbootstrap.com/)",
|
|
60
|
-
].join(" ") }) })] }), (0, jsx_runtime_1.jsx)(exports.IconPicker, { icon: valueType.qs.iconClass }), (0, jsx_runtime_1.jsx)("small", { className: "mt-2 text-body-secondary", children: "Description:" }), (0, jsx_runtime_1.jsx)(editor_inline_1.MarkdownEditorInline, { value: valueType.qs.description })] }));
|
|
59
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("small", { className: "text-body-secondary", children: "Name:" }), (0, jsx_runtime_1.jsx)(input_1.Input, { value: valueType.qs.name, className: "form-control mb-3 p-0 ps-2", placeholder: "Variable name", title: "Variable name" }), (0, jsx_runtime_1.jsx)("small", { className: "text-body-secondary", children: "Icon:" }), (0, jsx_runtime_1.jsx)(exports.PeerTypeIconField, { icon: valueType.qs.iconClass }), (0, jsx_runtime_1.jsx)("small", { className: "mt-2 text-body-secondary", children: "Description:" }), (0, jsx_runtime_1.jsx)(editor_inline_1.MarkdownEditorInline, { value: valueType.qs.description })] }));
|
|
61
60
|
};
|
|
62
61
|
const VariableSchema = (props) => {
|
|
63
62
|
const { valueType } = props;
|
|
64
63
|
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(io_schema_1.IOSchemaEditor, { ioSchema: valueType.qs.schema, simpleValueName: "value" }) }));
|
|
65
64
|
};
|
|
66
|
-
|
|
65
|
+
/**
|
|
66
|
+
* A peer type's icon, picked from Bootstrap Icons. Saved as a Bootstrap class (`bi bi-house`),
|
|
67
|
+
* the form older Peers versions draw; emoji aren't offered for the same reason. The icon is
|
|
68
|
+
* optional: "Use the default icon" clears it, so the peer type shows the default again.
|
|
69
|
+
*
|
|
70
|
+
* @param props.icon - The peer type's `iconClass` field.
|
|
71
|
+
*/
|
|
72
|
+
const PeerTypeIconField = (props) => {
|
|
67
73
|
const { icon } = props;
|
|
68
|
-
(0, hooks_1.useObservable)(icon);
|
|
69
|
-
|
|
70
|
-
icon("");
|
|
71
|
-
}
|
|
72
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex", children: [(0, jsx_runtime_1.jsx)(input_1.Input, { value: icon, className: "form-control mb-3 p-0 ps-2", placeholder: "icon class", title: "Icon" }), (0, jsx_runtime_1.jsx)("div", { className: "me-2 ms-2", style: { width: "22px" }, children: (0, jsx_runtime_1.jsx)("i", { className: icon() }) })] }));
|
|
74
|
+
const [value] = (0, hooks_1.useObservable)(icon);
|
|
75
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-start gap-2 mb-3", children: [(0, jsx_runtime_1.jsx)("span", { className: "fs-4 px-1", style: { width: "32px" }, children: (0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: value, fallback: "bi:code-square" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "flex-grow-1", children: [value ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0 mb-1 text-decoration-none", onClick: () => icon(undefined), children: "Use the default icon" })) : null, (0, jsx_runtime_1.jsx)(icon_picker_1.IconPicker, { value: (0, peers_sdk_1.parseIcon)(value)?.ref, kinds: ["icons"], onChange: (ref) => icon((0, peers_sdk_1.bootstrapIconClass)(ref) ?? value) })] })] }));
|
|
73
76
|
};
|
|
74
|
-
exports.
|
|
77
|
+
exports.PeerTypeIconField = PeerTypeIconField;
|
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PeerTypeLists = PeerTypeLists;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
|
+
const icon_1 = require("../../components/icon");
|
|
6
7
|
const list_screen_1 = require("../../components/list-screen");
|
|
7
8
|
const markdown_with_mentions_1 = require("../../components/markdown-with-mentions");
|
|
8
9
|
const globals_1 = require("../../globals");
|
|
9
10
|
const ui_loader_1 = require("../../ui-router/ui-loader");
|
|
11
|
+
/** The list of peer types, each with its icon and a link to edit it. */
|
|
10
12
|
function PeerTypeLists() {
|
|
11
13
|
async function newRecord(name) {
|
|
12
14
|
const peerTypeName = name.replace(/\s+/g, "_");
|
|
@@ -29,7 +31,7 @@ function PeerTypeLists() {
|
|
|
29
31
|
};
|
|
30
32
|
}
|
|
31
33
|
function renderItem(item) {
|
|
32
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid pb-4", children: [(0, jsx_runtime_1.jsx)(
|
|
34
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid pb-4", children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: item.iconClass, fallback: "bi:code-square" }), "\u00A0", (0, jsx_runtime_1.jsx)("a", { href: `#peer-types/${item.peerTypeId}`, children: item.name || "<empty-name>" }), (0, jsx_runtime_1.jsx)("div", { style: { paddingLeft: "20px" }, children: (0, jsx_runtime_1.jsx)(markdown_with_mentions_1.MarkdownWithMentions, { content: item.description || "" }) })] }, item.peerTypeId));
|
|
33
35
|
}
|
|
34
36
|
return ((0, jsx_runtime_1.jsx)(list_screen_1.ListScreen, { table: (0, peers_sdk_1.PeerTypes)(), newRecord: newRecord, getFilter: getFilter, sortBy: ["name"], renderItem: renderItem, placeholderName: "value type" }));
|
|
35
37
|
}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GlobalSearch = GlobalSearch;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
+
const icon_1 = require("../../components/icon");
|
|
6
7
|
const hooks_1 = require("../../hooks");
|
|
7
8
|
const mention_configs_1 = require("../../mention-configs");
|
|
8
9
|
const tabs_state_1 = require("../../tabs-layout/tabs-state");
|
|
@@ -124,7 +125,7 @@ function GlobalSearch() {
|
|
|
124
125
|
}, onMouseLeave: (e) => {
|
|
125
126
|
e.currentTarget.style.transform = "translateY(0)";
|
|
126
127
|
e.currentTarget.style.boxShadow = "none";
|
|
127
|
-
}, children: (0, jsx_runtime_1.jsx)("div", { className: "card-body p-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-start", children: [(0, jsx_runtime_1.jsx)(
|
|
128
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { className: "card-body p-3", children: (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-start", children: [(0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: app.iconClassName, className: "me-3 mt-1", style: {
|
|
128
129
|
fontSize: "16px",
|
|
129
130
|
color: isDark ? "#0d6efd" : "#0d6efd",
|
|
130
131
|
minWidth: "16px",
|
|
@@ -10,8 +10,15 @@ import { type TabState } from "./tabs-state";
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function tabAppColor(tab: TabState): AppColor | undefined;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
* A tab's app color ({@link tabAppColor}), kept current as packages load: a tab restored at
|
|
14
|
+
* startup finds its app once the packages are read.
|
|
15
|
+
*
|
|
16
|
+
* @param tab - The tab, or undefined for none.
|
|
17
|
+
* @returns The app's palette color, or undefined for none.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useTabAppColor(tab: TabState | undefined): AppColor | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The classes that draw a tab's icon in its app's color ({@link useTabAppColor}).
|
|
15
22
|
*
|
|
16
23
|
* @param tab - The tab, or undefined for none.
|
|
17
24
|
* @returns `peers-tab-icon peers-app-color-<color>`, or an empty string for no color.
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.tabAppColor = tabAppColor;
|
|
4
|
+
exports.useTabAppColor = useTabAppColor;
|
|
4
5
|
exports.useTabIconColorClass = useTabIconColorClass;
|
|
5
6
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
7
|
const use_observable_1 = require("../hooks/use-observable");
|
|
@@ -25,14 +26,23 @@ function tabAppColor(tab) {
|
|
|
25
26
|
return (0, peers_sdk_1.resolveAppColor)(app.package.packageId, app.navItem);
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
29
|
+
* A tab's app color ({@link tabAppColor}), kept current as packages load: a tab restored at
|
|
30
|
+
* startup finds its app once the packages are read.
|
|
31
|
+
*
|
|
32
|
+
* @param tab - The tab, or undefined for none.
|
|
33
|
+
* @returns The app's palette color, or undefined for none.
|
|
34
|
+
*/
|
|
35
|
+
function useTabAppColor(tab) {
|
|
36
|
+
(0, use_observable_1.useObservable)(routes_loader_1.allPackages);
|
|
37
|
+
return tab ? tabAppColor(tab) : undefined;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The classes that draw a tab's icon in its app's color ({@link useTabAppColor}).
|
|
30
41
|
*
|
|
31
42
|
* @param tab - The tab, or undefined for none.
|
|
32
43
|
* @returns `peers-tab-icon peers-app-color-<color>`, or an empty string for no color.
|
|
33
44
|
*/
|
|
34
45
|
function useTabIconColorClass(tab) {
|
|
35
|
-
|
|
36
|
-
const color = tab ? tabAppColor(tab) : undefined;
|
|
46
|
+
const color = useTabAppColor(tab);
|
|
37
47
|
return color ? `peers-tab-icon peers-app-color-${color}` : "";
|
|
38
48
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tab order with no dependencies, so screens and tests can use it without the package
|
|
3
|
+
* loader: the tab type, the launcher tab, and ordering by recent use. `tabs-state.ts`
|
|
4
|
+
* re-exports all of it.
|
|
5
|
+
*/
|
|
6
|
+
/** One top-level app tab. */
|
|
7
|
+
export interface TabState {
|
|
8
|
+
/** Unique id; `launcher` for the launcher tab. */
|
|
9
|
+
tabId: string;
|
|
10
|
+
/** The package whose app the tab shows: `launcher` for the launcher, `system-apps` for a built-in app. */
|
|
11
|
+
packageId?: string;
|
|
12
|
+
/** The tab's route, with or without a query string. */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Title shown on the tab. */
|
|
15
|
+
title: string;
|
|
16
|
+
/** Bootstrap icon class shown before the title. */
|
|
17
|
+
iconClassName?: string;
|
|
18
|
+
}
|
|
19
|
+
/** The app launcher tab. It is always present and cannot be closed. */
|
|
20
|
+
export declare const launcherApp: TabState;
|
|
21
|
+
/**
|
|
22
|
+
* Repair a recency list against the open tabs.
|
|
23
|
+
*
|
|
24
|
+
* Drops ids that aren't open and duplicates, puts the active tab first, and appends open
|
|
25
|
+
* tabs the list doesn't have, the most recently opened first (the order the phone menu
|
|
26
|
+
* used before it followed recent use).
|
|
27
|
+
*
|
|
28
|
+
* @param history - Tab ids, the most recently active first.
|
|
29
|
+
* @param tabs - Open tabs, in strip order.
|
|
30
|
+
* @param activeId - The active tab's id.
|
|
31
|
+
* @returns The repaired list.
|
|
32
|
+
*/
|
|
33
|
+
export declare function normalizeTabHistory(history: readonly string[], tabs: readonly TabState[], activeId: string): string[];
|
|
34
|
+
/**
|
|
35
|
+
* Order tabs by recent use.
|
|
36
|
+
*
|
|
37
|
+
* @param tabs - Open tabs, in strip order.
|
|
38
|
+
* @param history - Tab ids, the most recently active first.
|
|
39
|
+
* @returns The tabs, the most recently active first; tabs the history lacks come last, the
|
|
40
|
+
* most recently opened first.
|
|
41
|
+
*/
|
|
42
|
+
export declare function tabsByRecentUse(tabs: readonly TabState[], history: readonly string[]): TabState[];
|
|
43
|
+
/**
|
|
44
|
+
* The app tab used before the active one: the first tab in the history that is neither the
|
|
45
|
+
* active tab nor the launcher.
|
|
46
|
+
*
|
|
47
|
+
* @param history - Tab ids, the most recently active first.
|
|
48
|
+
* @param activeId - The active tab's id.
|
|
49
|
+
* @returns That tab's id, or `undefined` when no other app is open.
|
|
50
|
+
*/
|
|
51
|
+
export declare function previousAppTabId(history: readonly string[], activeId: string): string | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tab order with no dependencies, so screens and tests can use it without the package
|
|
4
|
+
* loader: the tab type, the launcher tab, and ordering by recent use. `tabs-state.ts`
|
|
5
|
+
* re-exports all of it.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.launcherApp = void 0;
|
|
9
|
+
exports.normalizeTabHistory = normalizeTabHistory;
|
|
10
|
+
exports.tabsByRecentUse = tabsByRecentUse;
|
|
11
|
+
exports.previousAppTabId = previousAppTabId;
|
|
12
|
+
/** The app launcher tab. It is always present and cannot be closed. */
|
|
13
|
+
exports.launcherApp = {
|
|
14
|
+
tabId: "launcher",
|
|
15
|
+
packageId: "launcher",
|
|
16
|
+
path: "",
|
|
17
|
+
title: "Apps",
|
|
18
|
+
iconClassName: "bi-grid-3x3-gap",
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Repair a recency list against the open tabs.
|
|
22
|
+
*
|
|
23
|
+
* Drops ids that aren't open and duplicates, puts the active tab first, and appends open
|
|
24
|
+
* tabs the list doesn't have, the most recently opened first (the order the phone menu
|
|
25
|
+
* used before it followed recent use).
|
|
26
|
+
*
|
|
27
|
+
* @param history - Tab ids, the most recently active first.
|
|
28
|
+
* @param tabs - Open tabs, in strip order.
|
|
29
|
+
* @param activeId - The active tab's id.
|
|
30
|
+
* @returns The repaired list.
|
|
31
|
+
*/
|
|
32
|
+
function normalizeTabHistory(history, tabs, activeId) {
|
|
33
|
+
const open = new Set(tabs.map((tab) => tab.tabId));
|
|
34
|
+
const result = [];
|
|
35
|
+
const add = (id) => {
|
|
36
|
+
if (open.has(id) && !result.includes(id)) {
|
|
37
|
+
result.push(id);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
add(activeId);
|
|
41
|
+
history.forEach(add);
|
|
42
|
+
[...tabs].reverse().forEach((tab) => {
|
|
43
|
+
add(tab.tabId);
|
|
44
|
+
});
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Order tabs by recent use.
|
|
49
|
+
*
|
|
50
|
+
* @param tabs - Open tabs, in strip order.
|
|
51
|
+
* @param history - Tab ids, the most recently active first.
|
|
52
|
+
* @returns The tabs, the most recently active first; tabs the history lacks come last, the
|
|
53
|
+
* most recently opened first.
|
|
54
|
+
*/
|
|
55
|
+
function tabsByRecentUse(tabs, history) {
|
|
56
|
+
const byId = new Map(tabs.map((tab) => [tab.tabId, tab]));
|
|
57
|
+
const ordered = normalizeTabHistory(history, tabs, "");
|
|
58
|
+
return ordered.flatMap((id) => byId.get(id) ?? []);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The app tab used before the active one: the first tab in the history that is neither the
|
|
62
|
+
* active tab nor the launcher.
|
|
63
|
+
*
|
|
64
|
+
* @param history - Tab ids, the most recently active first.
|
|
65
|
+
* @param activeId - The active tab's id.
|
|
66
|
+
* @returns That tab's id, or `undefined` when no other app is open.
|
|
67
|
+
*/
|
|
68
|
+
function previousAppTabId(history, activeId) {
|
|
69
|
+
return history.find((id) => id !== activeId && id !== exports.launcherApp.tabId);
|
|
70
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The icon size that fits every tab in one row, as the Mac's switcher shrinks its icons. Past
|
|
3
|
+
* the smallest size the row wraps.
|
|
4
|
+
*
|
|
5
|
+
* @param count - Number of tabs.
|
|
6
|
+
* @param viewportWidth - The window's width in px.
|
|
7
|
+
* @returns The tile size in px.
|
|
8
|
+
*/
|
|
9
|
+
export declare function tabSwitcherTileSize(count: number, viewportWidth: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* The Ctrl+Tab switcher's keys, and its row of tabs, the most recently used first (see
|
|
12
|
+
* `tab-switcher.ts`). Like the Mac's app switcher: each tab's app icon, as the Apps screen
|
|
13
|
+
* draws it, on a translucent panel in the middle of the window, with the highlighted tab's
|
|
14
|
+
* name under its icon. Mount it once in a layout with a tab strip.
|
|
15
|
+
*/
|
|
16
|
+
export declare function TabSwitcherOverlay(): import("react/jsx-runtime").JSX.Element | null;
|