@peers-app/peers-ui 0.33.12 → 0.33.13

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.
@@ -32,6 +32,8 @@ interface IAppMenuProps {
32
32
  status?: IAppPackageStatus;
33
33
  /** Why it isn't running here, if it failed. */
34
34
  failure?: string;
35
+ /** What it waits for, when its package waits for a contract it requires. */
36
+ waiting?: string;
35
37
  /** The items, in order. */
36
38
  actions: IAppMenuAction[];
37
39
  /** Where to open. */
@@ -51,5 +53,5 @@ export declare function appMenuSubtitle(entry: IAppEntry, status?: IAppPackageSt
51
53
  * actions. Arrow keys move between items, Escape or a click outside closes it, and choosing an
52
54
  * item closes it before running the action.
53
55
  */
54
- export declare function AppMenu({ entry, status, failure, actions, anchor, colorMode, onClose, }: IAppMenuProps): React.ReactPortal;
56
+ export declare function AppMenu({ entry, status, failure, waiting, actions, anchor, colorMode, onClose, }: IAppMenuProps): React.ReactPortal;
55
57
  export {};
@@ -30,7 +30,7 @@ function appMenuSubtitle(entry, status) {
30
30
  * actions. Arrow keys move between items, Escape or a click outside closes it, and choosing an
31
31
  * item closes it before running the action.
32
32
  */
33
- function AppMenu({ entry, status, failure, actions, anchor, colorMode, onClose, }) {
33
+ function AppMenu({ entry, status, failure, waiting, actions, anchor, colorMode, onClose, }) {
34
34
  const menuRef = (0, react_1.useRef)(null);
35
35
  const [position, setPosition] = (0, react_1.useState)();
36
36
  // Place the menu once its size is known, inside the window.
@@ -116,7 +116,7 @@ function AppMenu({ entry, status, failure, actions, anchor, colorMode, onClose,
116
116
  left: position?.left ?? 0,
117
117
  top: position?.top ?? 0,
118
118
  visibility: position ? "visible" : "hidden",
119
- }, onKeyDown: onKeyDown, "data-testid": "app-menu", children: [(0, jsx_runtime_1.jsxs)("div", { className: "px-3 pt-1 pb-2 mb-1 border-bottom", children: [(0, jsx_runtime_1.jsx)("div", { className: "fw-semibold text-truncate", children: entry.displayName }), subtitle && (0, jsx_runtime_1.jsx)("div", { className: "peers-app-menu-detail text-truncate", children: subtitle }), failure && ((0, jsx_runtime_1.jsxs)("div", { className: "small text-danger mt-1", style: { maxWidth: 260 }, children: ["Not running here: ", failure] }))] }), safeActions.map((action) => ((0, jsx_runtime_1.jsx)(MenuItem, { action: action, onClose: onClose }, action.key))), dangerActions.length > 0 && (0, jsx_runtime_1.jsx)("div", { className: "dropdown-divider" }), dangerActions.map((action) => ((0, jsx_runtime_1.jsx)(MenuItem, { action: action, onClose: onClose }, action.key)))] })] }), document.body);
119
+ }, onKeyDown: onKeyDown, "data-testid": "app-menu", children: [(0, jsx_runtime_1.jsxs)("div", { className: "px-3 pt-1 pb-2 mb-1 border-bottom", children: [(0, jsx_runtime_1.jsx)("div", { className: "fw-semibold text-truncate", children: entry.displayName }), subtitle && (0, jsx_runtime_1.jsx)("div", { className: "peers-app-menu-detail text-truncate", children: subtitle }), failure && ((0, jsx_runtime_1.jsxs)("div", { className: "small text-danger mt-1", style: { maxWidth: 260 }, children: ["Not running here: ", failure] })), !failure && waiting && ((0, jsx_runtime_1.jsx)("div", { className: "small peers-app-menu-waiting mt-1", style: { maxWidth: 260 }, children: waiting }))] }), safeActions.map((action) => ((0, jsx_runtime_1.jsx)(MenuItem, { action: action, onClose: onClose }, action.key))), dangerActions.length > 0 && (0, jsx_runtime_1.jsx)("div", { className: "dropdown-divider" }), dangerActions.map((action) => ((0, jsx_runtime_1.jsx)(MenuItem, { action: action, onClose: onClose }, action.key)))] })] }), document.body);
120
120
  }
121
121
  function MenuItem({ action, onClose }) {
122
122
  return ((0, jsx_runtime_1.jsxs)("button", { type: "button", role: "menuitem", className: `dropdown-item ${action.emphasis ? "active" : ""} ${action.danger ? "text-danger" : ""}`, "data-testid": `app-menu-${action.key}`, onClick: () => {
@@ -25,6 +25,13 @@ export declare function usePackageVersionStatus(pkg: IPackage | undefined): IApp
25
25
  * @returns The newer release on the channel it follows, or `undefined` when there's none.
26
26
  */
27
27
  export declare function currentPackageUpdate(pkg: IPackage): Promise<IPackageVersion | undefined>;
28
+ /**
29
+ * What the app menu says about a package that waits for a contract it requires, or `undefined`
30
+ * when it doesn't wait. A package with an older version serving says the update waits.
31
+ *
32
+ * @param runtime - The package's observed runtime state on this device.
33
+ */
34
+ export declare function packageWaitingNote(runtime: Pick<IPackageObservedRuntime, "status" | "running" | "waiting"> | undefined): string | undefined;
28
35
  /**
29
36
  * Why a package isn't running on this device, or `undefined` when nothing failed. A package that
30
37
  * still runs an older version after a failed update isn't counted: it works.
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.usePackageVersionStatus = usePackageVersionStatus;
4
4
  exports.currentPackageUpdate = currentPackageUpdate;
5
+ exports.packageWaitingNote = packageWaitingNote;
5
6
  exports.packageFailure = packageFailure;
6
7
  const peers_sdk_1 = require("@peers-app/peers-sdk");
7
8
  const react_1 = require("react");
@@ -66,6 +67,21 @@ async function currentPackageUpdate(pkg) {
66
67
  return undefined;
67
68
  return status.newestPv ?? undefined;
68
69
  }
70
+ /**
71
+ * What the app menu says about a package that waits for a contract it requires, or `undefined`
72
+ * when it doesn't wait. A package with an older version serving says the update waits.
73
+ *
74
+ * @param runtime - The package's observed runtime state on this device.
75
+ */
76
+ function packageWaitingNote(runtime) {
77
+ if (runtime?.status !== "waiting" || !runtime.waiting)
78
+ return undefined;
79
+ const list = (0, peers_sdk_1.missingContractsLabel)(runtime.waiting.missing);
80
+ if (!runtime.running)
81
+ return `Waiting for ${list}. Open it to see what it needs.`;
82
+ const next = runtime.waiting.version ? `v${runtime.waiting.version}` : "Its update";
83
+ return `${next} is waiting for ${list}; v${runtime.running.version ?? "?"} runs until then.`;
84
+ }
69
85
  /**
70
86
  * Why a package isn't running on this device, or `undefined` when nothing failed. A package that
71
87
  * still runs an older version after a failed update isn't counted: it works.
@@ -17,6 +17,8 @@ interface IAppTileProps {
17
17
  editing: boolean;
18
18
  /** Why its package isn't running here, if it failed. */
19
19
  failure?: string;
20
+ /** Its package waits for a contract it requires, with nothing running. */
21
+ waiting?: boolean;
20
22
  /** Open the app. */
21
23
  onOpen: (entry: IAppEntry) => void;
22
24
  /** Open its menu. `returnFocus` is the tile, when the keyboard opened it. */
@@ -29,5 +31,5 @@ interface IAppTileProps {
29
31
  * A click opens it (in edit mode, its menu). A right-click, a press-and-hold, Shift+F10 or the
30
32
  * context-menu key opens its menu.
31
33
  */
32
- export declare function AppTile({ entry, pkg, size, pinned, editing, failure, onOpen, onMenu, onTogglePin, }: IAppTileProps): import("react/jsx-runtime").JSX.Element;
34
+ export declare function AppTile({ entry, pkg, size, pinned, editing, failure, waiting, onOpen, onMenu, onTogglePin, }: IAppTileProps): import("react/jsx-runtime").JSX.Element;
33
35
  export {};
@@ -13,7 +13,7 @@ const LONG_PRESS_SLOP_PX = 10;
13
13
  * A click opens it (in edit mode, its menu). A right-click, a press-and-hold, Shift+F10 or the
14
14
  * context-menu key opens its menu.
15
15
  */
16
- function AppTile({ entry, pkg, size, pinned, editing, failure, onOpen, onMenu, onTogglePin, }) {
16
+ function AppTile({ entry, pkg, size, pinned, editing, failure, waiting, onOpen, onMenu, onTogglePin, }) {
17
17
  const status = (0, app_status_1.usePackageVersionStatus)(pkg);
18
18
  const buttonRef = (0, react_1.useRef)(null);
19
19
  const press = (0, react_1.useRef)();
@@ -91,16 +91,21 @@ function AppTile({ entry, pkg, size, pinned, editing, failure, onOpen, onMenu, o
91
91
  const states = [
92
92
  status.updatePv && "update ready",
93
93
  failure && "not running",
94
+ !failure && waiting && "waiting to start",
94
95
  status.dev && "dev build",
95
96
  ].filter(Boolean);
96
97
  return ((0, jsx_runtime_1.jsxs)("div", { className: [
97
98
  "peers-app-tile-wrap",
98
99
  `peers-app-tile-${size}`,
99
100
  failure ? "peers-app-tile-failed" : "",
101
+ !failure && waiting ? "peers-app-tile-waiting" : "",
100
102
  status.dev ? "peers-app-tile-dev" : "",
101
- ].join(" "), "data-app-path": entry.path, children: [(0, jsx_runtime_1.jsxs)("button", { ref: buttonRef, type: "button", className: "peers-app-tile", title: entry.displayName, "aria-label": [entry.displayName, ...states].join(", "), "aria-haspopup": editing ? "menu" : undefined, onClick: onClick, onContextMenu: onContextMenu, onKeyDown: onKeyDown, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: cancelPress, onPointerCancel: cancelPress, onPointerLeave: cancelPress, "data-testid": `app-tile-${entry.path}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${entry.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: entry.iconClassName }) }), (0, jsx_runtime_1.jsx)("span", { className: "peers-app-label", children: entry.displayName })] }), !editing && (0, jsx_runtime_1.jsx)(TileStatus, { status: status, failure: failure }), editing && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: `peers-app-edit-badge ${pinned ? "peers-app-edit-badge-unpin" : "peers-app-edit-badge-pin"}`, "aria-label": `${pinned ? "Unpin" : "Pin"} ${entry.displayName}`, title: pinned ? "Unpin" : "Pin", onClick: () => onTogglePin(entry), "data-testid": `app-${pinned ? "unpin" : "pin"}-${entry.path}`, children: pinned ? "−" : "+" }))] }));
103
+ ].join(" "), "data-app-path": entry.path, children: [(0, jsx_runtime_1.jsxs)("button", { ref: buttonRef, type: "button", className: "peers-app-tile", title: entry.displayName, "aria-label": [entry.displayName, ...states].join(", "), "aria-haspopup": editing ? "menu" : undefined, onClick: onClick, onContextMenu: onContextMenu, onKeyDown: onKeyDown, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: cancelPress, onPointerCancel: cancelPress, onPointerLeave: cancelPress, "data-testid": `app-tile-${entry.path}`, children: [(0, jsx_runtime_1.jsx)("span", { className: `peers-app-icon peers-app-color-${entry.color}`, "aria-hidden": "true", children: (0, jsx_runtime_1.jsx)("i", { className: entry.iconClassName }) }), (0, jsx_runtime_1.jsx)("span", { className: "peers-app-label", children: entry.displayName })] }), !editing && (0, jsx_runtime_1.jsx)(TileStatus, { status: status, failure: failure, waiting: waiting }), editing && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: `peers-app-edit-badge ${pinned ? "peers-app-edit-badge-unpin" : "peers-app-edit-badge-pin"}`, "aria-label": `${pinned ? "Unpin" : "Pin"} ${entry.displayName}`, title: pinned ? "Unpin" : "Pin", onClick: () => onTogglePin(entry), "data-testid": `app-${pinned ? "unpin" : "pin"}-${entry.path}`, children: pinned ? "−" : "+" }))] }));
102
104
  }
103
- /** The badge at a tile's corner: not running beats an update; a dev build gets its pill. */
104
- function TileStatus({ status, failure }) {
105
- return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [failure ? ((0, jsx_runtime_1.jsx)("span", { className: "peers-app-status peers-app-status-failed", title: failure, children: "!" })) : status.updatePv ? ((0, jsx_runtime_1.jsx)("span", { className: "peers-app-status peers-app-status-update", title: `v${status.updatePv.version} is ready`, children: (0, jsx_runtime_1.jsx)("i", { className: "bi-arrow-up-circle-fill" }) })) : null, status.dev && (0, jsx_runtime_1.jsx)("span", { className: "peers-app-status peers-app-status-dev", children: "DEV" })] }));
105
+ /**
106
+ * The badge at a tile's corner: not running beats waiting to start, which beats an update; a dev
107
+ * build gets its pill.
108
+ */
109
+ function TileStatus({ status, failure, waiting, }) {
110
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [failure ? ((0, jsx_runtime_1.jsx)("span", { className: "peers-app-status peers-app-status-failed", title: failure, children: "!" })) : waiting ? ((0, jsx_runtime_1.jsx)("span", { className: "peers-app-status peers-app-status-waiting", title: "Waiting to start", children: (0, jsx_runtime_1.jsx)("i", { className: "bi-hourglass-split" }) })) : status.updatePv ? ((0, jsx_runtime_1.jsx)("span", { className: "peers-app-status peers-app-status-update", title: `v${status.updatePv.version} is ready`, children: (0, jsx_runtime_1.jsx)("i", { className: "bi-arrow-up-circle-fill" }) })) : null, status.dev && (0, jsx_runtime_1.jsx)("span", { className: "peers-app-status peers-app-status-dev", children: "DEV" })] }));
106
111
  }
@@ -21,6 +21,7 @@ const routes_loader_1 = require("../ui-router/routes-loader");
21
21
  const app_menu_1 = require("./app-menu");
22
22
  const app_status_1 = require("./app-status");
23
23
  const app_tile_1 = require("./app-tile");
24
+ const current_group_name_1 = require("./current-group-name");
24
25
  const get_apps_sheet_1 = require("./get-apps-sheet");
25
26
  const pinned_apps_1 = require("./pinned-apps");
26
27
  const remove_app_dialog_1 = require("./remove-app-dialog");
@@ -42,7 +43,7 @@ function AppsHome({ isMobile }) {
42
43
  const [storedShowSystem, setShowSystem] = (0, use_observable_1.useObservable)(showSystemAppsVar);
43
44
  const [mode] = (0, use_observable_1.useObservable)(color_mode_dropdown_1.colorMode);
44
45
  const runtimeStates = (0, packages_ipc_1.usePackageRuntimeStates)();
45
- const groupName = useCurrentGroupName();
46
+ const groupName = (0, current_group_name_1.useCurrentGroupName)();
46
47
  const canManage = (0, use_promise_1.usePromise)(package_helpers_1.isGroupAdmin, false, []) ?? false;
47
48
  const [query, setQuery] = (0, react_1.useState)("");
48
49
  const [editing, setEditing] = (0, react_1.useState)(false);
@@ -184,7 +185,7 @@ function AppsHome({ isMobile }) {
184
185
  }
185
186
  return actions;
186
187
  };
187
- const tile = (entry, size) => ((0, jsx_runtime_1.jsx)(app_tile_1.AppTile, { entry: entry, pkg: entry.kind === "package" ? packagesById.get(entry.packageId) : undefined, size: size, pinned: pins.includes(entry.path), editing: editing, failure: entry.kind === "package" ? (0, app_status_1.packageFailure)(runtimeStates?.[entry.packageId]) : undefined, onOpen: openApp, onMenu: (menuEntry, anchor, status, returnFocus) => setMenu({ entry: menuEntry, anchor, status, returnFocus }), onTogglePin: togglePin }, entry.path));
188
+ const tile = (entry, size) => ((0, jsx_runtime_1.jsx)(app_tile_1.AppTile, { entry: entry, pkg: entry.kind === "package" ? packagesById.get(entry.packageId) : undefined, size: size, pinned: pins.includes(entry.path), editing: editing, failure: entry.kind === "package" ? (0, app_status_1.packageFailure)(runtimeStates?.[entry.packageId]) : undefined, waiting: entry.kind === "package" && !!(0, packages_ipc_1.packageWaiting)(runtimeStates?.[entry.packageId]), onOpen: openApp, onMenu: (menuEntry, anchor, status, returnFocus) => setMenu({ entry: menuEntry, anchor, status, returnFocus }), onTogglePin: togglePin }, entry.path));
188
189
  const nothingMatches = searching && !sections.pinned.length && !sections.more.length && !sections.system.length;
189
190
  // Until the pins load, a pinned app would show under More and then jump up.
190
191
  const showSections = pinsLoaded;
@@ -193,6 +194,8 @@ function AppsHome({ isMobile }) {
193
194
  ? "Choose + on an app to pin it here."
194
195
  : "Pin the apps you use most. Choose Edit to start." }))), sections.more.length > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { className: "peers-apps-divider", children: (0, jsx_runtime_1.jsxs)("h2", { children: ["More in ", groupName] }) }), (0, jsx_runtime_1.jsx)("section", { "aria-label": `More in ${groupName}`, className: "peers-apps-grid peers-apps-grid-more", "data-testid": "apps-more", children: sections.more.map((entry) => tile(entry, "more")) })] })), sections.system.length > 0 && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [!searching && ((0, jsx_runtime_1.jsx)("div", { className: "peers-apps-system-toggle", children: (0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn peers-apps-ghost peers-apps-pill", "aria-expanded": showSystem, "aria-controls": "peers-apps-system", onClick: () => setShowSystem(!showSystem), "data-testid": "apps-system-toggle", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-gear-fill", "aria-hidden": "true" }), "System apps", (0, jsx_runtime_1.jsx)("i", { className: showSystem ? "bi-chevron-up" : "bi-chevron-down", "aria-hidden": "true" })] }) })), systemOpen && ((0, jsx_runtime_1.jsx)("section", { id: "peers-apps-system", "aria-label": "System apps", className: "peers-apps-grid-system", "data-testid": "apps-system", children: sections.system.map((entry) => tile(entry, "system")) }))] }))] }))] }), menu && ((0, jsx_runtime_1.jsx)(app_menu_1.AppMenu, { entry: menu.entry, status: menu.status, failure: menu.entry.kind === "package"
195
196
  ? (0, app_status_1.packageFailure)(runtimeStates?.[menu.entry.packageId])
197
+ : undefined, waiting: menu.entry.kind === "package"
198
+ ? (0, app_status_1.packageWaitingNote)(runtimeStates?.[menu.entry.packageId])
196
199
  : undefined, actions: menuActions(menu), anchor: menu.anchor, colorMode: mode, onClose: closeMenu })), removing && ((0, jsx_runtime_1.jsx)(remove_app_dialog_1.RemoveAppDialog, { entry: removing, otherApps: catalog.filter((entry) => entry.packageId === removing.packageId && entry.path !== removing.path), groupName: groupName, onCancel: () => setRemoving(undefined), onConfirm: async () => {
197
200
  await (await (0, packages_ipc_1.packagesTools)()).uninstallPackage({ packageId: removing.packageId });
198
201
  setRemoving(undefined);
@@ -298,14 +301,3 @@ function usePackagesToAdd() {
298
301
  }, [refresh]);
299
302
  return { ...state, refresh };
300
303
  }
301
- /** The current group's name, or "Personal" in the personal context. */
302
- function useCurrentGroupName() {
303
- return ((0, use_promise_1.usePromise)(async () => {
304
- const userContext = await (0, peers_sdk_1.getUserContext)();
305
- const groupId = userContext.currentlyActiveGroupId();
306
- if (!groupId || groupId === userContext.userId)
307
- return "Personal";
308
- const group = await (0, peers_sdk_1.Groups)(userContext.userDataContext).get(groupId);
309
- return group?.name || "this group";
310
- }, "", []) ?? "");
311
- }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * The current group's name, or "Personal" in the personal context; empty until it's read.
3
+ * "this group" stands in for a group whose row has no name.
4
+ */
5
+ export declare function useCurrentGroupName(): string;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useCurrentGroupName = useCurrentGroupName;
4
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
5
+ const use_promise_1 = require("../hooks/use-promise");
6
+ /**
7
+ * The current group's name, or "Personal" in the personal context; empty until it's read.
8
+ * "this group" stands in for a group whose row has no name.
9
+ */
10
+ function useCurrentGroupName() {
11
+ return ((0, use_promise_1.usePromise)(async () => {
12
+ const userContext = await (0, peers_sdk_1.getUserContext)();
13
+ const groupId = userContext.currentlyActiveGroupId();
14
+ if (!groupId || groupId === userContext.userId)
15
+ return "Personal";
16
+ const group = await (0, peers_sdk_1.Groups)(userContext.userDataContext).get(groupId);
17
+ return group?.name || "this group";
18
+ }, "", []) ?? "");
19
+ }
@@ -197,7 +197,7 @@ function CreateGroupModal({ colorMode, userContext, onClose, onGroupCreated, })
197
197
  });
198
198
  await (0, peers_sdk_1.Groups)(groupDataContext).signAndSave(newGroup);
199
199
  // Auto-install peers-core for the new group (copy from another context that
200
- // already has it, else fall back to the remote updateUrl / bundle).
200
+ // already has it, else fall back to the remote updateUrl).
201
201
  await (0, packages_ipc_1.packagesTools)(groupId)
202
202
  .then((tools) => tools.installDefaultPackages())
203
203
  .catch((err) => {
@@ -7,6 +7,10 @@ import { type IToolbarControl } from "./toolbar";
7
7
  * the rest once it's mounted, so the caller can focus it and work with the selection.
8
8
  */
9
9
  export interface IEditorEffects {
10
+ /**
11
+ * Sees each key first, unless the mention picker is open; return true to handle it. Set by
12
+ * the caller.
13
+ */
10
14
  onKeyDown?: (e: React.KeyboardEvent) => boolean | undefined;
11
15
  /** Focus the editor, caret at the end. Set by the editor. */
12
16
  focus?: () => void;
@@ -36,8 +40,9 @@ export interface IMarkdownEditorProps {
36
40
  /** Scroll inside the editor past this height. */
37
41
  maxHeight?: string | number;
38
42
  /**
39
- * The mention picker (`@` or `<`); on unless false. Mentions already in the text show as chips
40
- * either way.
43
+ * The mention picker (`<` for everything, `@` for people, or a trigger a mention source
44
+ * declares, such as `#`); on unless false. Mentions already in the text show as chips either
45
+ * way.
41
46
  */
42
47
  mentions?: boolean;
43
48
  /**
@@ -48,8 +53,9 @@ export interface IMarkdownEditorProps {
48
53
  groupId?: string;
49
54
  }
50
55
  /**
51
- * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`@` or
52
- * `<` finds people and records in every group, and a pasted id becomes its record's chip; a
53
- * mention shows as a chip with the record's live title). Edits are written back to `value`.
56
+ * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`<`
57
+ * finds people and records in every group, `@` people, a trigger a mention source declares, such
58
+ * as `#`, that source's records, and a pasted id becomes its record's chip; a mention shows as a
59
+ * chip with the record's live title). Edits are written back to `value`.
54
60
  */
55
61
  export declare function MarkdownEditor(props: IMarkdownEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -87,9 +87,10 @@ const editorConfig = {
87
87
  theme: theme_1.default,
88
88
  };
89
89
  /**
90
- * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`@` or
91
- * `<` finds people and records in every group, and a pasted id becomes its record's chip; a
92
- * mention shows as a chip with the record's live title). Edits are written back to `value`.
90
+ * A rich-text editor whose value is markdown: lists and checklists, links, and mentions (`<`
91
+ * finds people and records in every group, `@` people, a trigger a mention source declares, such
92
+ * as `#`, that source's records, and a pasted id becomes its record's chip; a mention shows as a
93
+ * chip with the record's live title). Edits are written back to `value`.
93
94
  */
94
95
  function MarkdownEditor(props) {
95
96
  const { effects } = props;
@@ -1,12 +1,25 @@
1
+ import { type MenuTextMatch } from "@lexical/react/LexicalTypeaheadMenuPlugin";
1
2
  import { type IMentionSearchResult, type Observable } from "@peers-app/peers-sdk";
2
3
  /**
3
- * What the user typed after `@` or `<`: words, and a kind when it starts with `kind:`.
4
+ * The query ending at the caret, if the text before it has one: a trigger at the start of a
5
+ * word, then at least one character. A trigger on its own, or one followed by a space, isn't a
6
+ * query, so `# ` at the start of a line stays a heading.
4
7
  *
5
- * @param query - The text from the trigger on, such as `@task:garden`.
8
+ * @param text - The text before the caret, in its text node.
9
+ * @param triggers - The characters that open the picker.
10
+ */
11
+ export declare function findMentionQuery(text: string, triggers: readonly string[]): MenuTextMatch | null;
12
+ /**
13
+ * What the user typed: the trigger, then words, and a kind filter when the words start with one
14
+ * word and a colon (`<tasks:shed`). System Mentions matches the filter loosely, and reads it as
15
+ * words when it names no kind.
16
+ *
17
+ * @param query - The text from the trigger on, such as `<task:garden` or `#work`.
6
18
  */
7
19
  export declare function parseQuery(query: string): {
20
+ trigger: string;
8
21
  text: string;
9
- kinds?: string[];
22
+ kindFilter?: string;
10
23
  };
11
24
  /** A search's answer, with the query it answers, so an older one is never taken for a newer. */
12
25
  interface Found {
@@ -18,9 +31,10 @@ interface Found {
18
31
  * What the picker offers for a query, and whether one result should be taken without asking.
19
32
  *
20
33
  * - Words: the results, as they are.
21
- * - A pasted id (`@<id>` or `<<id>`), once its search has answered: the one record with that id,
22
- * taken at once; nothing found, a link to whatever has the id, taken at once; several records
23
- * (the same id in two kinds), offered to pick from. Before the answer, nothing.
34
+ * - A pasted id (after any trigger, such as `<<id>`), once its search has answered: the one
35
+ * record with that id, taken at once; nothing found, a link to whatever has the id, taken at
36
+ * once; several records (the same id in two kinds), offered to pick from. Before the answer,
37
+ * nothing.
24
38
  *
25
39
  * @param query - The text from the trigger on, or null when the picker is closed.
26
40
  * @param found - The latest search answer.
@@ -33,10 +47,15 @@ export declare function pickerOptions(query: string | null, found: Found, declin
33
47
  /** The kinds that more than one package answers for among these results. */
34
48
  export declare function sharedKinds(results: IMentionSearchResult[]): Set<string>;
35
49
  /**
36
- * The mention picker, opened by `@` or `<`: people first, then records from every group the user
37
- * is in, through System Mentions, with a preview of the highlighted one. Picking one inserts a
38
- * mention chip labeled with the record's title. A pasted id becomes a chip at once: the record's,
39
- * or a dotted `?` chip for an id that matches nothing.
50
+ * The mention picker: `<` finds everything (people, then records from every group the user is
51
+ * in), `@` people only, and a trigger a mention source declares (`#`) that source's records,
52
+ * through System Mentions, with a preview of the highlighted one. `<tasks:` narrows to a kind.
53
+ * Picking one inserts a mention chip labeled with the record's title. A pasted id, after any
54
+ * trigger, becomes a chip at once: the record's, or a dotted `?` chip for an id that matches
55
+ * nothing. It doesn't open in code or in a link's text.
56
+ *
57
+ * The triggers come from System Mentions, which is asked when the editor is first focused, and
58
+ * moves them when packages change.
40
59
  */
41
60
  export declare function MentionsPlugin(props: {
42
61
  mentionsOpen?: Observable<boolean>;