@peers-app/peers-ui 0.33.22 → 0.33.24
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/components/markdown-editor/markdown-plugin.d.ts +15 -1
- package/dist/components/markdown-editor/markdown-plugin.js +80 -2
- package/dist/components/markdown-editor/mentions-plugin.d.ts +25 -0
- package/dist/components/markdown-editor/mentions-plugin.js +42 -21
- package/dist/root-layout/app-shell-height.d.ts +11 -3
- package/dist/root-layout/app-shell-height.js +12 -4
- package/dist/root-layout/layouts/full-screen-layout.js +5 -1
- package/dist/root-layout/layouts/tabs-with-console-layout.js +1 -1
- package/dist/tabs-layout/tabs-layout.js +1 -0
- package/dist/theme.css +53 -4
- package/dist/ui-router/routes-loader.js +6 -9
- package/dist/ui-router/runnable-version.d.ts +9 -0
- package/dist/ui-router/runnable-version.js +20 -0
- package/dist/ui-router/ui-loader.js +2 -9
- package/package.json +3 -3
|
@@ -22,6 +22,19 @@ export declare function withoutHeadings(transformers: readonly Transformer[]): T
|
|
|
22
22
|
* dividers and callouts, so a line starting with `#`, a `---` line and `[!NOTE]` stay text.
|
|
23
23
|
*/
|
|
24
24
|
export declare const inlineMarkdownTransformers: Transformer[];
|
|
25
|
+
/**
|
|
26
|
+
* Load markdown into the editor in an update, as an outside change. Lexical's import puts the
|
|
27
|
+
* caret at the start whenever the editor has a selection, and an editor that isn't focused then
|
|
28
|
+
* takes the focus, from the editor being typed in (the same note open in two editors, such as a
|
|
29
|
+
* journal day and the panel beside it: on a phone the keyboard closes). So an editor without the
|
|
30
|
+
* focus is left with no selection, and a focused one keeps its caret in the same block, the same
|
|
31
|
+
* distance into its text.
|
|
32
|
+
*
|
|
33
|
+
* @param markdown - The markdown to load.
|
|
34
|
+
* @param transformers - How it's read.
|
|
35
|
+
* @param focused - Whether the editor has the focus.
|
|
36
|
+
*/
|
|
37
|
+
export declare function $importOutsideMarkdown(markdown: string, transformers: Transformer[], focused: boolean): void;
|
|
25
38
|
/** {@link MarkdownPlugin}'s props. */
|
|
26
39
|
export interface IMarkdownPluginProps {
|
|
27
40
|
/** The markdown the editor shows, written back as the user edits. */
|
|
@@ -31,6 +44,7 @@ export interface IMarkdownPluginProps {
|
|
|
31
44
|
}
|
|
32
45
|
/**
|
|
33
46
|
* Keeps the editor and a markdown observable in step: the observable's value is loaded into the
|
|
34
|
-
* editor (without moving the caret or taking focus), and edits
|
|
47
|
+
* editor (without moving the caret or taking focus: {@link $importOutsideMarkdown}), and edits
|
|
48
|
+
* are written back as markdown.
|
|
35
49
|
*/
|
|
36
50
|
export declare function MarkdownPlugin(props: IMarkdownPluginProps): null;
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.inlineMarkdownTransformers = exports.documentMarkdownTransformers = void 0;
|
|
4
4
|
exports.withoutHeadings = withoutHeadings;
|
|
5
|
+
exports.$importOutsideMarkdown = $importOutsideMarkdown;
|
|
5
6
|
exports.MarkdownPlugin = MarkdownPlugin;
|
|
6
7
|
const list_1 = require("@lexical/list");
|
|
7
8
|
const markdown_1 = require("@lexical/markdown");
|
|
8
9
|
const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext");
|
|
9
10
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
11
|
+
const lexical_1 = require("lexical");
|
|
10
12
|
const react_1 = require("react");
|
|
11
13
|
const blocks_1 = require("./blocks");
|
|
12
14
|
const code_plugin_1 = require("./code-plugin");
|
|
@@ -170,9 +172,83 @@ function withoutHeadings(transformers) {
|
|
|
170
172
|
* dividers and callouts, so a line starting with `#`, a `---` line and `[!NOTE]` stay text.
|
|
171
173
|
*/
|
|
172
174
|
exports.inlineMarkdownTransformers = withoutHeadings(exports.documentMarkdownTransformers).filter((transformer) => transformer !== blocks_1.HORIZONTAL_RULE_TRANSFORMER && transformer !== blocks_1.CALLOUT_TRANSFORMER);
|
|
175
|
+
/** The text nodes in `node`, itself included when it's one. */
|
|
176
|
+
function textsIn(node) {
|
|
177
|
+
if ((0, lexical_1.$isTextNode)(node))
|
|
178
|
+
return [node];
|
|
179
|
+
return (0, lexical_1.$isElementNode)(node) ? node.getAllTextNodes() : [];
|
|
180
|
+
}
|
|
181
|
+
/** The caret's block (a child of the root) and its offset in the block's text, if it's in one. */
|
|
182
|
+
function $caretSpot() {
|
|
183
|
+
const selection = (0, lexical_1.$getSelection)();
|
|
184
|
+
if (!(0, lexical_1.$isRangeSelection)(selection))
|
|
185
|
+
return undefined;
|
|
186
|
+
const point = selection.focus;
|
|
187
|
+
const node = point.getNode();
|
|
188
|
+
const block = node.getTopLevelElement();
|
|
189
|
+
if (!block)
|
|
190
|
+
return undefined;
|
|
191
|
+
const size = (texts) => texts.reduce((total, text) => total + text.getTextContentSize(), 0);
|
|
192
|
+
const texts = block.getAllTextNodes();
|
|
193
|
+
if (point.type === "text") {
|
|
194
|
+
const at = texts.findIndex((text) => text.is(node));
|
|
195
|
+
return { block: block.getIndexWithinParent(), offset: size(texts.slice(0, at)) + point.offset };
|
|
196
|
+
}
|
|
197
|
+
// On an element (an empty paragraph, say): the text before it, and in its children before the
|
|
198
|
+
// point.
|
|
199
|
+
const within = new Set(textsIn(node).map((text) => text.getKey()));
|
|
200
|
+
const before = ((0, lexical_1.$isElementNode)(node) ? node.getChildren().slice(0, point.offset) : []).flatMap(textsIn);
|
|
201
|
+
const outside = texts.filter((text) => !within.has(text.getKey()) && text.isBefore(node));
|
|
202
|
+
return { block: block.getIndexWithinParent(), offset: size(outside) + size(before) };
|
|
203
|
+
}
|
|
204
|
+
/** Put the caret back at a {@link CaretSpot}, as near as the new document allows. */
|
|
205
|
+
function $restoreCaret(spot) {
|
|
206
|
+
const root = (0, lexical_1.$getRoot)();
|
|
207
|
+
const block = root.getChildAtIndex(Math.min(spot.block, root.getChildrenSize() - 1));
|
|
208
|
+
if (!(0, lexical_1.$isElementNode)(block)) {
|
|
209
|
+
root.selectEnd();
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
let left = spot.offset;
|
|
213
|
+
const texts = block.getAllTextNodes();
|
|
214
|
+
for (const text of texts) {
|
|
215
|
+
const size = text.getTextContentSize();
|
|
216
|
+
if (left <= size) {
|
|
217
|
+
text.select(left, left);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
left -= size;
|
|
221
|
+
}
|
|
222
|
+
const last = texts.at(-1);
|
|
223
|
+
if (last)
|
|
224
|
+
last.select(last.getTextContentSize(), last.getTextContentSize());
|
|
225
|
+
else
|
|
226
|
+
block.selectStart();
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Load markdown into the editor in an update, as an outside change. Lexical's import puts the
|
|
230
|
+
* caret at the start whenever the editor has a selection, and an editor that isn't focused then
|
|
231
|
+
* takes the focus, from the editor being typed in (the same note open in two editors, such as a
|
|
232
|
+
* journal day and the panel beside it: on a phone the keyboard closes). So an editor without the
|
|
233
|
+
* focus is left with no selection, and a focused one keeps its caret in the same block, the same
|
|
234
|
+
* distance into its text.
|
|
235
|
+
*
|
|
236
|
+
* @param markdown - The markdown to load.
|
|
237
|
+
* @param transformers - How it's read.
|
|
238
|
+
* @param focused - Whether the editor has the focus.
|
|
239
|
+
*/
|
|
240
|
+
function $importOutsideMarkdown(markdown, transformers, focused) {
|
|
241
|
+
const spot = focused ? $caretSpot() : undefined;
|
|
242
|
+
(0, markdown_1.$convertFromMarkdownString)(markdown, transformers, undefined, true, false);
|
|
243
|
+
if (spot)
|
|
244
|
+
$restoreCaret(spot);
|
|
245
|
+
else if (!focused)
|
|
246
|
+
(0, lexical_1.$setSelection)(null);
|
|
247
|
+
}
|
|
173
248
|
/**
|
|
174
249
|
* Keeps the editor and a markdown observable in step: the observable's value is loaded into the
|
|
175
|
-
* editor (without moving the caret or taking focus), and edits
|
|
250
|
+
* editor (without moving the caret or taking focus: {@link $importOutsideMarkdown}), and edits
|
|
251
|
+
* are written back as markdown.
|
|
176
252
|
*/
|
|
177
253
|
function MarkdownPlugin(props) {
|
|
178
254
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
@@ -186,8 +262,10 @@ function MarkdownPlugin(props) {
|
|
|
186
262
|
return;
|
|
187
263
|
}
|
|
188
264
|
markdown = newMarkdown;
|
|
265
|
+
const root = editor.getRootElement();
|
|
266
|
+
const focused = !!root && root.contains(document.activeElement);
|
|
189
267
|
editor.update(() => {
|
|
190
|
-
(
|
|
268
|
+
$importOutsideMarkdown(markdown, transformers, focused);
|
|
191
269
|
});
|
|
192
270
|
}
|
|
193
271
|
setMarkdown();
|
|
@@ -46,6 +46,31 @@ export declare function pickerOptions(query: string | null, found: Found, declin
|
|
|
46
46
|
};
|
|
47
47
|
/** The kinds that more than one package answers for among these results. */
|
|
48
48
|
export declare function sharedKinds(results: IMentionSearchResult[]): Set<string>;
|
|
49
|
+
/** Where the picker's menu sits for one open of it. */
|
|
50
|
+
export interface MenuPlacement {
|
|
51
|
+
/** Above the caret, which is in the lower half of the window; else below it. */
|
|
52
|
+
above: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* The preview card's side: right of the list (""), else left of it, else under it (a window
|
|
55
|
+
* too narrow for either, such as a tablet held upright).
|
|
56
|
+
*/
|
|
57
|
+
preview: "" | "is-preview-left" | "is-preview-below";
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Where the menu goes for a caret at `caret`, in window coordinates. The picker decides it once
|
|
61
|
+
* per open, so the menu holds still while results arrive and change its height, and while the
|
|
62
|
+
* caret moves right as you type.
|
|
63
|
+
*
|
|
64
|
+
* @param caret - The caret's top and left edges in the window.
|
|
65
|
+
* @param view - The window's size.
|
|
66
|
+
*/
|
|
67
|
+
export declare function placeMenu(caret: {
|
|
68
|
+
top: number;
|
|
69
|
+
left: number;
|
|
70
|
+
}, view?: {
|
|
71
|
+
innerWidth: number;
|
|
72
|
+
innerHeight: number;
|
|
73
|
+
}): MenuPlacement;
|
|
49
74
|
/**
|
|
50
75
|
* The mention picker: `<` finds everything (people, then records from every group the user is
|
|
51
76
|
* in), `@` people only, and a trigger a mention source declares (`#`) that source's records,
|
|
@@ -37,6 +37,7 @@ exports.findMentionQuery = findMentionQuery;
|
|
|
37
37
|
exports.parseQuery = parseQuery;
|
|
38
38
|
exports.pickerOptions = pickerOptions;
|
|
39
39
|
exports.sharedKinds = sharedKinds;
|
|
40
|
+
exports.placeMenu = placeMenu;
|
|
40
41
|
exports.MentionsPlugin = MentionsPlugin;
|
|
41
42
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
42
43
|
const code_1 = require("@lexical/code");
|
|
@@ -261,24 +262,35 @@ function AutoPick({ pick }) {
|
|
|
261
262
|
(0, react_1.useEffect)(() => pick(), []);
|
|
262
263
|
return null;
|
|
263
264
|
}
|
|
264
|
-
/** Whether the menu should open above the caret: the caret is in the lower half of the window. */
|
|
265
|
-
function opensAbove(anchor) {
|
|
266
|
-
return anchor.getBoundingClientRect().top > window.innerHeight / 2;
|
|
267
|
-
}
|
|
268
265
|
/** The menu's width and the card's, and the gap between them (`theme.css`). */
|
|
269
266
|
const MENU_WIDTH = 300;
|
|
270
267
|
const PREVIEW_GAP = 8;
|
|
271
268
|
/**
|
|
272
|
-
* Where the
|
|
273
|
-
*
|
|
269
|
+
* Where the menu goes for a caret at `caret`, in window coordinates. The picker decides it once
|
|
270
|
+
* per open, so the menu holds still while results arrive and change its height, and while the
|
|
271
|
+
* caret moves right as you type.
|
|
272
|
+
*
|
|
273
|
+
* @param caret - The caret's top and left edges in the window.
|
|
274
|
+
* @param view - The window's size.
|
|
274
275
|
*/
|
|
275
|
-
function
|
|
276
|
-
const { left } =
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
276
|
+
function placeMenu(caret, view = window) {
|
|
277
|
+
const { left } = caret;
|
|
278
|
+
const preview = left + MENU_WIDTH + PREVIEW_GAP + MENU_WIDTH <= view.innerWidth
|
|
279
|
+
? ""
|
|
280
|
+
: left - PREVIEW_GAP - MENU_WIDTH >= 0
|
|
281
|
+
? "is-preview-left"
|
|
282
|
+
: "is-preview-below";
|
|
283
|
+
return { above: caret.top > view.innerHeight / 2, preview };
|
|
284
|
+
}
|
|
285
|
+
/** The caret in the window: the selection's, which is current while Lexical moves the anchor. */
|
|
286
|
+
function caretRect(anchor) {
|
|
287
|
+
const selection = window.getSelection();
|
|
288
|
+
if (selection && selection.rangeCount > 0) {
|
|
289
|
+
const rect = selection.getRangeAt(0).getBoundingClientRect();
|
|
290
|
+
if (rect.top || rect.left)
|
|
291
|
+
return rect;
|
|
292
|
+
}
|
|
293
|
+
return anchor.getBoundingClientRect();
|
|
282
294
|
}
|
|
283
295
|
/**
|
|
284
296
|
* The mention picker: `<` finds everything (people, then records from every group the user is
|
|
@@ -307,6 +319,8 @@ function MentionsPlugin(props) {
|
|
|
307
319
|
const found = useMentionSearch(queryString, props.groupId);
|
|
308
320
|
const { docGroup } = found;
|
|
309
321
|
const [_mentionsOpen] = (0, react_1.useState)(() => (0, peers_sdk_1.observable)(false));
|
|
322
|
+
// Where the menu goes, decided at its first render each time it opens (see placeMenu).
|
|
323
|
+
const placement = (0, react_1.useRef)(null);
|
|
310
324
|
// The last query taken automatically. An undo brings it back; then it's offered, not retaken.
|
|
311
325
|
const autoPicked = (0, react_1.useRef)(null);
|
|
312
326
|
const { results, autoPick } = (0, react_1.useMemo)(() => pickerOptions(queryString, found, autoPicked.current), [queryString, found]);
|
|
@@ -355,8 +369,10 @@ function MentionsPlugin(props) {
|
|
|
355
369
|
autoPicked.current = null;
|
|
356
370
|
setQueryString(query);
|
|
357
371
|
}, onSelectOption: onSelectOption, triggerFn: checkForMentionMatch, options: options, onOpen: () => {
|
|
372
|
+
placement.current = null;
|
|
358
373
|
_mentionsOpen(true);
|
|
359
374
|
}, onClose: () => {
|
|
375
|
+
placement.current = null;
|
|
360
376
|
_mentionsOpen(false);
|
|
361
377
|
}, menuRenderFn: (anchorElementRef, { selectedIndex, selectOptionAndCleanUp, setHighlightedIndex }) => {
|
|
362
378
|
const anchor = anchorElementRef.current;
|
|
@@ -374,16 +390,21 @@ function MentionsPlugin(props) {
|
|
|
374
390
|
} }, `${queryString}:${option.key}`));
|
|
375
391
|
}
|
|
376
392
|
const highlighted = selectedIndex === null ? undefined : options[selectedIndex];
|
|
393
|
+
placement.current ??= placeMenu(caretRect(anchor));
|
|
377
394
|
const classes = [
|
|
378
395
|
"peers-mention-menu",
|
|
379
|
-
|
|
380
|
-
|
|
396
|
+
placement.current.above ? "is-above" : "",
|
|
397
|
+
placement.current.preview,
|
|
381
398
|
];
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
399
|
+
// Lexical moves its anchor above the caret when the anchor's first child doesn't fit
|
|
400
|
+
// below, measuring it as results change: a zero-height wrapper keeps it from ever doing
|
|
401
|
+
// that, so only the placement above flips the menu. Its width still lets Lexical keep the
|
|
402
|
+
// menu inside the editor's right edge.
|
|
403
|
+
return ReactDOM.createPortal((0, jsx_runtime_1.jsx)("div", { className: "peers-mention-anchor", children: (0, jsx_runtime_1.jsxs)("div", { className: classes.filter(Boolean).join(" "), children: [(0, jsx_runtime_1.jsx)("ul", { className: "peers-mention-menu-list", children: options.map((option, i) => ((0, jsx_runtime_1.jsx)(MentionsTypeaheadMenuItem, { index: i, isSelected: selectedIndex === i, onClick: () => {
|
|
404
|
+
setHighlightedIndex(i);
|
|
405
|
+
selectOptionAndCleanUp(option);
|
|
406
|
+
}, onMouseEnter: () => {
|
|
407
|
+
setHighlightedIndex(i);
|
|
408
|
+
}, option: option, docGroup: docGroup }, option.key))) }), highlighted ? ((0, jsx_runtime_1.jsx)(mention_preview_card_1.MentionPreviewCard, { result: highlighted.result, showPackage: highlighted.showPackage })) : null] }) }), anchor);
|
|
388
409
|
} }));
|
|
389
410
|
}
|
|
@@ -4,7 +4,15 @@
|
|
|
4
4
|
* `100dvh` is the height actually visible. `100vh` in a mobile browser is the height with its
|
|
5
5
|
* toolbars hidden, so a shell sized to it is taller than the screen and the whole page scrolls,
|
|
6
6
|
* header and all. The host sets `--peers-shell-top` and `--peers-shell-bottom`: the PWA uses the
|
|
7
|
-
* device's safe areas (the status bar and home indicator of an installed iOS app)
|
|
8
|
-
*
|
|
7
|
+
* device's safe areas (the status bar and home indicator of an installed iOS app). Both default
|
|
8
|
+
* to none: Electron draws no title bar of its own in the page.
|
|
9
9
|
*/
|
|
10
|
-
export declare const APP_SHELL_HEIGHT = "calc(100dvh - var(--peers-shell-top,
|
|
10
|
+
export declare const APP_SHELL_HEIGHT = "calc(100dvh - var(--peers-shell-top, 0px) - var(--peers-shell-bottom, 0px))";
|
|
11
|
+
/**
|
|
12
|
+
* Room the shell's top strip leaves at its left end for the window's own buttons, which the host
|
|
13
|
+
* draws over the page: macOS's red, yellow and green buttons in Electron, which has no title bar
|
|
14
|
+
* there. The host sets `--peers-window-controls-left` (none in full screen, where the buttons
|
|
15
|
+
* hide), and adds the `peers-window-draggable` class to `<html>` so the strip's empty space moves
|
|
16
|
+
* the window (theme.css). Elsewhere it's none.
|
|
17
|
+
*/
|
|
18
|
+
export declare const WINDOW_CONTROLS_LEFT = "var(--peers-window-controls-left, 0px)";
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APP_SHELL_HEIGHT = void 0;
|
|
3
|
+
exports.WINDOW_CONTROLS_LEFT = exports.APP_SHELL_HEIGHT = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Height of the app shell: the visible viewport less the room the host keeps outside it.
|
|
6
6
|
*
|
|
7
7
|
* `100dvh` is the height actually visible. `100vh` in a mobile browser is the height with its
|
|
8
8
|
* toolbars hidden, so a shell sized to it is taller than the screen and the whole page scrolls,
|
|
9
9
|
* header and all. The host sets `--peers-shell-top` and `--peers-shell-bottom`: the PWA uses the
|
|
10
|
-
* device's safe areas (the status bar and home indicator of an installed iOS app)
|
|
11
|
-
*
|
|
10
|
+
* device's safe areas (the status bar and home indicator of an installed iOS app). Both default
|
|
11
|
+
* to none: Electron draws no title bar of its own in the page.
|
|
12
12
|
*/
|
|
13
|
-
exports.APP_SHELL_HEIGHT = "calc(100dvh - var(--peers-shell-top,
|
|
13
|
+
exports.APP_SHELL_HEIGHT = "calc(100dvh - var(--peers-shell-top, 0px) - var(--peers-shell-bottom, 0px))";
|
|
14
|
+
/**
|
|
15
|
+
* Room the shell's top strip leaves at its left end for the window's own buttons, which the host
|
|
16
|
+
* draws over the page: macOS's red, yellow and green buttons in Electron, which has no title bar
|
|
17
|
+
* there. The host sets `--peers-window-controls-left` (none in full screen, where the buttons
|
|
18
|
+
* hide), and adds the `peers-window-draggable` class to `<html>` so the strip's empty space moves
|
|
19
|
+
* the window (theme.css). Elsewhere it's none.
|
|
20
|
+
*/
|
|
21
|
+
exports.WINDOW_CONTROLS_LEFT = "var(--peers-window-controls-left, 0px)";
|
|
@@ -41,7 +41,11 @@ function FullScreenLayout() {
|
|
|
41
41
|
const isLauncher = activeTab.packageId === "launcher" || activeTab.tabId === "launcher";
|
|
42
42
|
const isLight = mode === "light";
|
|
43
43
|
const title = isLauncher ? "Apps" : activeTab.title;
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column", style: { height: app_shell_height_1.APP_SHELL_HEIGHT, overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: `border-bottom peers-tab-strip d-flex align-items-center
|
|
44
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-column", style: { height: app_shell_height_1.APP_SHELL_HEIGHT, overflow: "hidden" }, children: [(0, jsx_runtime_1.jsxs)("div", { className: `border-bottom peers-tab-strip d-flex align-items-center pe-1 ${isLight ? "" : "bg-dark"}`, style: {
|
|
45
|
+
height: "36px",
|
|
46
|
+
paddingLeft: `calc(${app_shell_height_1.WINDOW_CONTROLS_LEFT} + 0.25rem)`,
|
|
47
|
+
borderBottomColor: isLight ? "var(--peers-tab-edge)" : "#495057",
|
|
48
|
+
}, children: [(0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: mode, isMobile: isMobile }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, active: isLauncher, icon: "bi-grid-3x3-gap", label: "Apps", onClick: () => (0, tabs_state_1.activeTabId)("launcher") }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center flex-grow-1 overflow-hidden px-2", children: [!isLauncher && activeTab.iconClassName && ((0, jsx_runtime_1.jsx)(icon_1.Icon, { icon: activeTab.iconClassName, className: "me-2" })), (0, jsx_runtime_1.jsx)("span", { className: "text-truncate fw-medium", style: { fontSize: "13px" }, children: title })] }), (0, jsx_runtime_1.jsx)(notification_bell_1.NotificationBell, { compact: true }), (0, jsx_runtime_1.jsx)(HeaderButton, { isLight: isLight, icon: "bi-search", label: `Search and navigate (${paletteHint})`, onClick: command_palette_1.openCommandPalette, children: (0, jsx_runtime_1.jsx)("span", { className: "d-none d-md-inline ms-1", style: { fontSize: "11px" }, children: paletteHint }) })] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow-1 overflow-hidden", children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabErrorBoundary, { tabTitle: activeTab.title, tabId: activeTab.tabId, children: (0, jsx_runtime_1.jsx)(tabs_layout_1.TabContent, { tab: activeTab, isMobile: isMobile, isActive: true }) }, activeTab.tabId) })] }));
|
|
45
49
|
}
|
|
46
50
|
/** A small, transparent header button matching the tabs layout's toolbar styling. */
|
|
47
51
|
function HeaderButton({ isLight, icon, label, onClick, active, children }) {
|
|
@@ -15,7 +15,7 @@ const MIN_SIZE = 120;
|
|
|
15
15
|
function clamp(value, min, max) {
|
|
16
16
|
return Math.max(min, Math.min(max, value));
|
|
17
17
|
}
|
|
18
|
-
/** Pixels
|
|
18
|
+
/** Pixels the host keeps above the page (its body's top padding; none in Electron now). */
|
|
19
19
|
function getTopOffset() {
|
|
20
20
|
if (typeof document === "undefined")
|
|
21
21
|
return 0;
|
|
@@ -140,6 +140,7 @@ function TabsLayoutInternal({ fillContainer = false } = {}) {
|
|
|
140
140
|
justifyContent: "center",
|
|
141
141
|
backgroundColor: _colorMode === "light" ? "rgba(var(--bs-body-bg-rgb), 0.85)" : "rgba(0,0,0,0.85)",
|
|
142
142
|
}, children: (0, jsx_runtime_1.jsxs)("div", { className: "text-center", children: [(0, jsx_runtime_1.jsx)("div", { className: "spinner-border text-secondary mb-3", role: "status" }), (0, jsx_runtime_1.jsx)("div", { className: `small ${_colorMode === "light" ? "text-muted" : "text-secondary"}`, children: "Switching group..." })] }) })), (0, jsx_runtime_1.jsx)("div", { className: `border-bottom peers-tab-strip ${_colorMode === "light" ? "" : "bg-dark"}`, style: {
|
|
143
|
+
paddingLeft: app_shell_height_1.WINDOW_CONTROLS_LEFT,
|
|
143
144
|
borderBottomWidth: "1px",
|
|
144
145
|
borderBottomColor: _colorMode === "light" ? "var(--peers-tab-edge)" : "#495057",
|
|
145
146
|
}, children: isMobile ? ((0, jsx_runtime_1.jsx)(MobileTabsHeader, { tabs: tabs, activeTab: activeTab, onSwitch: switchTab, onClose: tabs_state_1.closeTab, colorMode: _colorMode })) : ((0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center px-1", style: { height: "36px" }, children: [(0, jsx_runtime_1.jsx)(group_switcher_1.GroupSwitcher, { colorMode: _colorMode, isMobile: false }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm me-2 d-flex align-items-center", onClick: command_palette_1.openCommandPalette, title: "Search everything (Cmd+K)", style: {
|
package/dist/theme.css
CHANGED
|
@@ -95,6 +95,45 @@
|
|
|
95
95
|
--bs-table-bg: var(--peers-surface-bg);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
/* The host draws the window's own buttons over the strip's left end and has no title bar
|
|
99
|
+
(Electron on macOS: peers-window-draggable on <html>, room in --peers-window-controls-left).
|
|
100
|
+
The strip's empty space moves the window, and what takes a click in it stays clickable. So does
|
|
101
|
+
an overlay that can cover the strip (position-fixed, a modal, or peers-window-no-drag on a
|
|
102
|
+
package's own): the region ignores what's drawn on top, so its top edge would move the window. */
|
|
103
|
+
.peers-window-draggable .peers-tab-strip {
|
|
104
|
+
-webkit-app-region: drag;
|
|
105
|
+
app-region: drag;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.peers-window-draggable
|
|
109
|
+
.peers-tab-strip
|
|
110
|
+
:is(
|
|
111
|
+
button,
|
|
112
|
+
a,
|
|
113
|
+
input,
|
|
114
|
+
select,
|
|
115
|
+
textarea,
|
|
116
|
+
label,
|
|
117
|
+
[role="button"],
|
|
118
|
+
[role="dialog"],
|
|
119
|
+
[role="menu"],
|
|
120
|
+
.peers-tab,
|
|
121
|
+
.dropdown-menu
|
|
122
|
+
),
|
|
123
|
+
.peers-window-draggable
|
|
124
|
+
:is(
|
|
125
|
+
.position-fixed,
|
|
126
|
+
.fixed-top,
|
|
127
|
+
.modal,
|
|
128
|
+
.modal-backdrop,
|
|
129
|
+
.offcanvas,
|
|
130
|
+
.toast-container,
|
|
131
|
+
.peers-window-no-drag
|
|
132
|
+
) {
|
|
133
|
+
-webkit-app-region: no-drag;
|
|
134
|
+
app-region: no-drag;
|
|
135
|
+
}
|
|
136
|
+
|
|
98
137
|
[data-bs-theme="light"] .peers-tab-strip {
|
|
99
138
|
--bs-border-color: var(--peers-tab-edge);
|
|
100
139
|
background-color: var(--peers-tab-strip-bg);
|
|
@@ -316,20 +355,30 @@
|
|
|
316
355
|
card beside the list for the highlighted result. On a narrow screen the card
|
|
317
356
|
sits under the list. */
|
|
318
357
|
|
|
358
|
+
/* Zero height, so Lexical's typeahead never measures the menu and moves its anchor above the
|
|
359
|
+
caret; the menu itself hangs from it. Its width lets Lexical keep it inside the editor. */
|
|
360
|
+
.peers-mention-anchor {
|
|
361
|
+
height: 0;
|
|
362
|
+
position: relative;
|
|
363
|
+
width: 300px;
|
|
364
|
+
}
|
|
365
|
+
|
|
319
366
|
.peers-mention-menu {
|
|
320
367
|
--peers-mention-menu-bg: var(--peers-surface-bg, var(--bs-tertiary-bg));
|
|
321
368
|
--peers-mention-menu-border: var(--peers-surface-border, var(--bs-border-color));
|
|
322
369
|
font-size: 14px;
|
|
370
|
+
left: 0;
|
|
323
371
|
line-height: 1.35;
|
|
324
|
-
position:
|
|
325
|
-
|
|
372
|
+
position: absolute;
|
|
373
|
+
top: 0;
|
|
374
|
+
width: 100%;
|
|
326
375
|
z-index: 1000;
|
|
327
376
|
}
|
|
328
377
|
|
|
329
378
|
.peers-mention-menu.is-above {
|
|
330
379
|
bottom: 100%;
|
|
331
380
|
margin-bottom: 30px;
|
|
332
|
-
|
|
381
|
+
top: auto;
|
|
333
382
|
}
|
|
334
383
|
|
|
335
384
|
.peers-mention-menu-list,
|
|
@@ -449,7 +498,7 @@
|
|
|
449
498
|
}
|
|
450
499
|
|
|
451
500
|
@media (max-width: 640px) {
|
|
452
|
-
.peers-mention-
|
|
501
|
+
.peers-mention-anchor {
|
|
453
502
|
width: min(300px, calc(100vw - 24px));
|
|
454
503
|
}
|
|
455
504
|
|
|
@@ -9,19 +9,16 @@ const runnable_version_1 = require("./runnable-version");
|
|
|
9
9
|
exports.allPackages = (0, peers_sdk_1.observable)([]);
|
|
10
10
|
let allRoutesLoaded = false;
|
|
11
11
|
const prefsSubscribed = new Set();
|
|
12
|
+
/**
|
|
13
|
+
* Follow this device's version selection for a package: a new one, or a cleared one that hands
|
|
14
|
+
* the package back to the group's version, rechecks it, so its app links, icon and routes follow
|
|
15
|
+
* without a UI reload.
|
|
16
|
+
*/
|
|
12
17
|
function subscribeToPrefs(packageId) {
|
|
13
18
|
if (prefsSubscribed.has(packageId))
|
|
14
19
|
return;
|
|
15
20
|
prefsSubscribed.add(packageId);
|
|
16
|
-
|
|
17
|
-
let lastPvId = pvar()?.activePackageVersionId;
|
|
18
|
-
pvar.subscribe(async (prefs) => {
|
|
19
|
-
const newPvId = prefs?.activePackageVersionId;
|
|
20
|
-
if (newPvId && newPvId !== lastPvId) {
|
|
21
|
-
lastPvId = newPvId;
|
|
22
|
-
await recheckPackage(packageId);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
21
|
+
(0, runnable_version_1.onDeviceSelectionChanged)(packageId, () => void recheckPackage(packageId));
|
|
25
22
|
}
|
|
26
23
|
/** Re-check whether a listed package may run here, refresh its app links, and reload its routes. */
|
|
27
24
|
async function recheckPackage(packageId) {
|
|
@@ -31,3 +31,12 @@ export declare function resolveRunnableVersion(pkg: IPackage, servingPackageVers
|
|
|
31
31
|
* @returns The subscription, to stop following.
|
|
32
32
|
*/
|
|
33
33
|
export declare function onSelectedPackageVersionChanged(onChange: (packageId: string) => void): import("@peers-app/peers-sdk").ISubscriptionResult;
|
|
34
|
+
/**
|
|
35
|
+
* Call `onChange` when this device's version selection for a package (its device override)
|
|
36
|
+
* changes: a new selection, or a cleared one that hands the package back to the group's version.
|
|
37
|
+
* A write that keeps the selection (such as pinning it) doesn't count.
|
|
38
|
+
*
|
|
39
|
+
* @param packageId - The package to follow.
|
|
40
|
+
* @param onChange - Called after each change of the selection.
|
|
41
|
+
*/
|
|
42
|
+
export declare function onDeviceSelectionChanged(packageId: string, onChange: () => void): void;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveRunnableVersion = resolveRunnableVersion;
|
|
4
4
|
exports.onSelectedPackageVersionChanged = onSelectedPackageVersionChanged;
|
|
5
|
+
exports.onDeviceSelectionChanged = onDeviceSelectionChanged;
|
|
5
6
|
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
7
|
/**
|
|
7
8
|
* The version of `pkg` this device runs, when it may run here: the device's own selection, else
|
|
@@ -84,3 +85,22 @@ function onSelectedPackageVersionChanged(onChange) {
|
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Call `onChange` when this device's version selection for a package (its device override)
|
|
90
|
+
* changes: a new selection, or a cleared one that hands the package back to the group's version.
|
|
91
|
+
* A write that keeps the selection (such as pinning it) doesn't count.
|
|
92
|
+
*
|
|
93
|
+
* @param packageId - The package to follow.
|
|
94
|
+
* @param onChange - Called after each change of the selection.
|
|
95
|
+
*/
|
|
96
|
+
function onDeviceSelectionChanged(packageId, onChange) {
|
|
97
|
+
const pvar = (0, peers_sdk_1.packagePrefsVar)(packageId);
|
|
98
|
+
let last = pvar()?.activePackageVersionId;
|
|
99
|
+
pvar.subscribe((prefs) => {
|
|
100
|
+
const next = prefs?.activePackageVersionId;
|
|
101
|
+
if (next === last)
|
|
102
|
+
return;
|
|
103
|
+
last = next;
|
|
104
|
+
onChange();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
@@ -415,19 +415,12 @@ const reloadPackage = (0, peers_sdk_1.debounceByArgs)(async (packageId) => {
|
|
|
415
415
|
}
|
|
416
416
|
}, 200);
|
|
417
417
|
const uiPrefsSubscribed = new Set();
|
|
418
|
+
/** Reload a package's screens when this device's selection changes, a cleared one included. */
|
|
418
419
|
function subscribeToPrefs(packageId) {
|
|
419
420
|
if (uiPrefsSubscribed.has(packageId))
|
|
420
421
|
return;
|
|
421
422
|
uiPrefsSubscribed.add(packageId);
|
|
422
|
-
|
|
423
|
-
let lastPvId = pvar()?.activePackageVersionId;
|
|
424
|
-
pvar.subscribe((prefs) => {
|
|
425
|
-
const newPvId = prefs?.activePackageVersionId;
|
|
426
|
-
if (newPvId && newPvId !== lastPvId) {
|
|
427
|
-
lastPvId = newPvId;
|
|
428
|
-
reloadPackage(packageId);
|
|
429
|
-
}
|
|
430
|
-
});
|
|
423
|
+
(0, runnable_version_1.onDeviceSelectionChanged)(packageId, () => reloadPackage(packageId));
|
|
431
424
|
}
|
|
432
425
|
(0, peers_sdk_1.getUserContext)().then((_userContext) => {
|
|
433
426
|
for (const packageId of Object.keys(uiLoads)) {
|
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.24",
|
|
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.24",
|
|
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.24",
|
|
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",
|