@peers-app/peers-ui 0.34.5 → 0.34.7
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/group-switcher.js +30 -2
- package/dist/components/markdown-editor/editor.d.ts +5 -4
- package/dist/components/markdown-editor/editor.js +10 -145
- package/dist/components/markdown-editor/lexical-editor.d.ts +3 -0
- package/dist/components/markdown-editor/lexical-editor.js +153 -0
- package/dist/components/markdown-render.d.ts +8 -0
- package/dist/components/markdown-render.js +143 -0
- package/dist/components/markdown-with-mentions.d.ts +1 -1
- package/dist/components/markdown-with-mentions.js +7 -129
- package/dist/components/trust-level-dropdown.d.ts +6 -1
- package/dist/components/trust-level-dropdown.js +43 -14
- package/dist/components/use-close-on-outside-press.d.ts +19 -0
- package/dist/components/use-close-on-outside-press.js +54 -0
- package/dist/isolated-screens/focus-relay.d.ts +24 -0
- package/dist/isolated-screens/focus-relay.js +104 -0
- package/dist/isolated-screens/frame-document.d.ts +7 -0
- package/dist/isolated-screens/frame-document.js +11 -1
- package/dist/isolated-screens/frame-protocol.d.ts +26 -0
- package/dist/isolated-screens/frame-protocol.js +21 -0
- package/dist/isolated-screens/frame-runtime.js +47 -14
- package/dist/isolated-screens/isolated-screen.d.ts +6 -0
- package/dist/isolated-screens/isolated-screen.js +40 -3
- package/dist/isolated-screens/piece-frames.js +57 -5
- package/dist/isolated-screens/piece-reach.js +17 -6
- package/dist/lazy-module.d.ts +17 -0
- package/dist/lazy-module.js +26 -0
- package/dist/notifications/notification-bell.js +2 -18
- package/dist/operator-console/console-session.js +1 -9
- package/dist/screens/groups/group-members.js +7 -17
- package/dist/screens/invites/accept-invite.js +15 -4
- package/dist/tabs-layout/network-status-indicator.js +2 -21
- package/dist/theme.css +8 -0
- package/dist/ui-contracts/piece-height.d.ts +8 -2
- package/dist/ui-contracts/piece-height.js +6 -1
- package/dist/ui-contracts/piece.js +1 -1
- package/package.json +4 -3
|
@@ -13,6 +13,7 @@ const piece_height_1 = require("../ui-contracts/piece-height");
|
|
|
13
13
|
const piece_resolution_1 = require("../ui-contracts/piece-resolution");
|
|
14
14
|
const popover_surface_1 = require("../ui-contracts/popover-surface");
|
|
15
15
|
const ui_inspection_1 = require("../ui-inspection");
|
|
16
|
+
const focus_relay_1 = require("./focus-relay");
|
|
16
17
|
const frame_bridge_1 = require("./frame-bridge");
|
|
17
18
|
const frame_protocol_1 = require("./frame-protocol");
|
|
18
19
|
const wheel_relay_1 = require("./wheel-relay");
|
|
@@ -24,6 +25,8 @@ const pieces = new Map();
|
|
|
24
25
|
let loadedVersionId;
|
|
25
26
|
/** Whether this frame draws a piece, whose Escape and wheel go to its embedder. */
|
|
26
27
|
let drawsPiece = false;
|
|
28
|
+
/** Whether this frame's piece is drawn over a framed screen's slot, so Tab out goes through the host. */
|
|
29
|
+
let relaysTab = false;
|
|
27
30
|
/**
|
|
28
31
|
* Apply the host's theme. The starting document uses the theme attribute for its color scheme
|
|
29
32
|
* and keeps a piece's background transparent across page color updates.
|
|
@@ -116,6 +119,19 @@ function frameEmitters(host, names) {
|
|
|
116
119
|
function PieceInFrame(props) {
|
|
117
120
|
const { host, piece } = props;
|
|
118
121
|
const emit = (0, react_1.useMemo)(() => frameEmitters(host, piece.emits), [host, piece.emits.join("\n")]);
|
|
122
|
+
// Once the piece's first render is on the page, the embedder's loading view can go.
|
|
123
|
+
(0, react_1.useEffect)(() => {
|
|
124
|
+
host.notify(frame_protocol_1.FrameNotice.pieceDrawn);
|
|
125
|
+
}, [host]);
|
|
126
|
+
// A piece in a popover paints the popover's background, from its first render: over a slot the
|
|
127
|
+
// host leaves the frame clear until then (isolated-screen.tsx), and the slot paints it instead.
|
|
128
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
129
|
+
if (piece.width === undefined)
|
|
130
|
+
return;
|
|
131
|
+
const html = document.documentElement;
|
|
132
|
+
html.classList.add("bg-body");
|
|
133
|
+
return () => html.classList.remove("bg-body");
|
|
134
|
+
}, [piece.width]);
|
|
119
135
|
const Component = piece.component;
|
|
120
136
|
return ((0, jsx_runtime_1.jsx)(PieceRoot, { host: host, height: piece.height, width: piece.width, children: (0, jsx_runtime_1.jsx)(ScreenErrorBoundary, { packageName: props.packageName, onError: (message) => host.notify(frame_protocol_1.FrameNotice.failed, { message }), children: (0, jsx_runtime_1.jsx)(Component, { props: props.props, emit: emit, close: () => host.notify(frame_protocol_1.FrameNotice.pieceClose), groupId: piece.groupId }) }) }));
|
|
121
137
|
}
|
|
@@ -202,6 +218,7 @@ let latestInit = 0;
|
|
|
202
218
|
async function handleInit(host, init) {
|
|
203
219
|
const thisInit = ++latestInit;
|
|
204
220
|
drawsPiece = init.piece !== undefined;
|
|
221
|
+
relaysTab = init.piece?.overSlot === true;
|
|
205
222
|
const firstInit = !root;
|
|
206
223
|
if (firstInit) {
|
|
207
224
|
const bridge = (0, frame_bridge_1.frameBridge)();
|
|
@@ -325,27 +342,43 @@ function isHostShortcut(event) {
|
|
|
325
342
|
* embedder. A popover inside the frame stops its own Escape before it gets here; a listener the
|
|
326
343
|
* piece added after this one can still take it, so it's sent once the event has reached them all.
|
|
327
344
|
* With ⌘ or Ctrl held, Escape is a shortcut like the others (Ctrl+Escape cancels the host's tab
|
|
328
|
-
* switcher).
|
|
345
|
+
* switcher). In a piece drawn over a slot, an unhandled Tab at an edge goes back to the screen.
|
|
329
346
|
*/
|
|
330
347
|
function installKeyForwarding(host) {
|
|
348
|
+
host.onNotify(frame_protocol_1.HostNotice.focusEdge, (payload) => {
|
|
349
|
+
// The host focused this frame as it sent this. Focus the user moved since (a click on a host
|
|
350
|
+
// field) stays where it is: a frame without focus can still take it with `.focus()`.
|
|
351
|
+
if (!relaysTab || !document.hasFocus())
|
|
352
|
+
return;
|
|
353
|
+
const edge = payload?.edge === "last" ? "last" : "first";
|
|
354
|
+
// Nothing to focus: Tab goes straight on past the piece.
|
|
355
|
+
if (!(0, focus_relay_1.focusEdge)(document, edge)) {
|
|
356
|
+
host.notify(frame_protocol_1.FrameNotice.focusLeave, { direction: edge === "first" ? "next" : "previous" });
|
|
357
|
+
}
|
|
358
|
+
});
|
|
331
359
|
const forward = (event) => {
|
|
332
360
|
if (event.defaultPrevented)
|
|
333
361
|
return;
|
|
334
|
-
if (event.key === "Escape" &&
|
|
335
|
-
drawsPiece &&
|
|
336
|
-
event.type === "keydown" &&
|
|
337
|
-
!event.metaKey &&
|
|
338
|
-
!event.ctrlKey) {
|
|
339
|
-
setTimeout(() => {
|
|
340
|
-
if (event.defaultPrevented)
|
|
341
|
-
return;
|
|
342
|
-
host.notify(frame_protocol_1.FrameNotice.key, { type: event.type, key: event.key, code: event.code });
|
|
343
|
-
}, 0);
|
|
344
|
-
return;
|
|
345
|
-
}
|
|
346
362
|
const modifierKey = event.key === "Control" || event.key === "Meta";
|
|
347
|
-
if (!(event.metaKey || event.ctrlKey || modifierKey))
|
|
363
|
+
if (!(event.metaKey || event.ctrlKey || modifierKey)) {
|
|
364
|
+
if (!drawsPiece || event.type !== "keydown")
|
|
365
|
+
return;
|
|
366
|
+
if (event.key === "Escape") {
|
|
367
|
+
setTimeout(() => {
|
|
368
|
+
if (event.defaultPrevented)
|
|
369
|
+
return;
|
|
370
|
+
host.notify(frame_protocol_1.FrameNotice.key, { type: event.type, key: event.key, code: event.code });
|
|
371
|
+
}, 0);
|
|
372
|
+
}
|
|
373
|
+
else if (event.key === "Tab" &&
|
|
374
|
+
relaysTab &&
|
|
375
|
+
!event.altKey &&
|
|
376
|
+
(0, focus_relay_1.tabLeaves)(document, event.shiftKey)) {
|
|
377
|
+
event.preventDefault();
|
|
378
|
+
host.notify(frame_protocol_1.FrameNotice.focusLeave, { direction: event.shiftKey ? "previous" : "next" });
|
|
379
|
+
}
|
|
348
380
|
return;
|
|
381
|
+
}
|
|
349
382
|
if (isHostShortcut(event))
|
|
350
383
|
event.preventDefault();
|
|
351
384
|
host.notify(frame_protocol_1.FrameNotice.key, {
|
|
@@ -53,6 +53,8 @@ export interface IFramePieceEvents {
|
|
|
53
53
|
onSize(height: number, width?: number): void;
|
|
54
54
|
/** It failed to load or threw. */
|
|
55
55
|
onFailed(message: string): void;
|
|
56
|
+
/** It has drawn its piece: the embedder's loading view can go. */
|
|
57
|
+
onDrawn?(): void;
|
|
56
58
|
/** Escape pressed in it that it left alone: for a popover around it. */
|
|
57
59
|
onKey?(key: {
|
|
58
60
|
key: string;
|
|
@@ -148,6 +150,10 @@ declare class FrameSession {
|
|
|
148
150
|
private updateSlot;
|
|
149
151
|
/** Tell a piece slot's frame what happened in its piece. */
|
|
150
152
|
slotNotify(type: string, payload: Record<string, unknown>): void;
|
|
153
|
+
/** Focus came to this piece's frame from its screen's slot: at its first or last control. */
|
|
154
|
+
focusFrom(edge: "first" | "last"): void;
|
|
155
|
+
/** Tab left the piece over one of this screen's slots: focus beside the slot. */
|
|
156
|
+
focusBack(slotId: string, direction: "next" | "previous"): void;
|
|
151
157
|
/** Show a screen or a piece: sends the init now if the frame is ready, or once it says so. */
|
|
152
158
|
show(getContent: () => FrameContent): Promise<void>;
|
|
153
159
|
private frameReady;
|
|
@@ -299,6 +299,28 @@ class FrameSession {
|
|
|
299
299
|
opts.pieceEvents()?.onEmit(name, payload);
|
|
300
300
|
});
|
|
301
301
|
channel.onNotify(frame_protocol_1.FrameNotice.pieceClose, () => opts.pieceEvents()?.onClose());
|
|
302
|
+
channel.onNotify(frame_protocol_1.FrameNotice.pieceDrawn, () => opts.pieceEvents()?.onDrawn?.());
|
|
303
|
+
// Tab across a piece over a slot: in from the screen, and back out to it.
|
|
304
|
+
channel.onNotify(frame_protocol_1.FrameNotice.pieceFocus, (payload) => {
|
|
305
|
+
// The user can move to another frame or a window control before the notice arrives.
|
|
306
|
+
if (document.activeElement !== opts.element)
|
|
307
|
+
return;
|
|
308
|
+
const edge = payload?.edge === "last" ? "last" : "first";
|
|
309
|
+
for (const session of liveSessions) {
|
|
310
|
+
const link = session.opts.slotOf?.();
|
|
311
|
+
if (link?.session === this && link.slotId === payload?.slotId)
|
|
312
|
+
session.focusFrom(edge);
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
channel.onNotify(frame_protocol_1.FrameNotice.focusLeave, (payload) => {
|
|
316
|
+
if (document.activeElement !== opts.element)
|
|
317
|
+
return;
|
|
318
|
+
const link = this.opts.slotOf?.();
|
|
319
|
+
if (!link?.session)
|
|
320
|
+
return;
|
|
321
|
+
const direction = payload?.direction === "previous" ? "previous" : "next";
|
|
322
|
+
link.session.focusBack(link.slotId, direction);
|
|
323
|
+
});
|
|
302
324
|
channel.onNotify(frame_protocol_1.FrameNotice.size, ({ height, width }) => {
|
|
303
325
|
if (typeof height !== "number" || !Number.isFinite(height) || height < 0)
|
|
304
326
|
return;
|
|
@@ -446,6 +468,16 @@ class FrameSession {
|
|
|
446
468
|
slotNotify(type, payload) {
|
|
447
469
|
this.channel.notify(type, payload);
|
|
448
470
|
}
|
|
471
|
+
/** Focus came to this piece's frame from its screen's slot: at its first or last control. */
|
|
472
|
+
focusFrom(edge) {
|
|
473
|
+
this.opts.element.focus();
|
|
474
|
+
this.channel.notify(frame_protocol_1.HostNotice.focusEdge, { edge });
|
|
475
|
+
}
|
|
476
|
+
/** Tab left the piece over one of this screen's slots: focus beside the slot. */
|
|
477
|
+
focusBack(slotId, direction) {
|
|
478
|
+
this.opts.element.focus();
|
|
479
|
+
this.channel.notify(frame_protocol_1.HostNotice.pieceFocusLeave, { slotId, direction });
|
|
480
|
+
}
|
|
449
481
|
/** Show a screen or a piece: sends the init now if the frame is ready, or once it says so. */
|
|
450
482
|
async show(getContent) {
|
|
451
483
|
const userContext = await (0, peers_sdk_1.getUserContext)();
|
|
@@ -470,6 +502,7 @@ class FrameSession {
|
|
|
470
502
|
height: content.height,
|
|
471
503
|
...(content.width !== undefined ? { width: content.width } : {}),
|
|
472
504
|
...(content.emits ? { emits: content.emits } : {}),
|
|
505
|
+
...(this.opts.slotOf?.() ? { overSlot: true } : {}),
|
|
473
506
|
},
|
|
474
507
|
}),
|
|
475
508
|
props: content.props,
|
|
@@ -644,8 +677,11 @@ function PackageFrameElement(props) {
|
|
|
644
677
|
};
|
|
645
678
|
let frameClass = content.kind === "screen" ? "peers-screen-frame" : "peers-piece-frame";
|
|
646
679
|
if (content.kind === "piece" && content.width !== undefined) {
|
|
647
|
-
// PopoverSurface positions the picker over other content and supplies no background.
|
|
648
|
-
|
|
680
|
+
// PopoverSurface positions the picker over other content and supplies no background. Over a
|
|
681
|
+
// slot the frame stays clear until the piece paints its own on its first render, so the
|
|
682
|
+
// embedder's loading view in the slot shows through until then.
|
|
683
|
+
if (!props.slotOf)
|
|
684
|
+
frameClass += " bg-body";
|
|
649
685
|
// Keep the viewport at the cap so vw units and media queries can't feed back into the
|
|
650
686
|
// reported width. The piece draws at (0, 0), regardless of its embedder's writing direction.
|
|
651
687
|
frameStyle.width = content.width;
|
|
@@ -653,7 +689,7 @@ function PackageFrameElement(props) {
|
|
|
653
689
|
frameStyle.top = 0;
|
|
654
690
|
frameStyle.left = 0;
|
|
655
691
|
}
|
|
656
|
-
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-package-frame", style: { position: "relative", width: "100%", height: "100%", overflow: FRAME_OVERFLOW }, children: [(0, jsx_runtime_1.jsx)("iframe", { ref: frameRef, title: props.label, srcDoc: srcDoc, sandbox: "allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads", allow: "clipboard-read; clipboard-write; fullscreen; autoplay", "data-peers-frame": frameId, "data-peers-package": pkg.packageId, className: frameClass, style: frameStyle }), shownSlots.map((slot) => ((0, jsx_runtime_1.jsx)(PieceSlotFrame, { slot: slot, session: sessionRef }, slot.slotId)))] }));
|
|
692
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "peers-package-frame", style: { position: "relative", width: "100%", height: "100%", overflow: FRAME_OVERFLOW }, children: [(0, jsx_runtime_1.jsx)("iframe", { ref: frameRef, title: props.label, tabIndex: props.slotOf ? -1 : undefined, srcDoc: srcDoc, sandbox: "allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-downloads", allow: "clipboard-read; clipboard-write; fullscreen; autoplay", "data-peers-frame": frameId, "data-peers-package": pkg.packageId, className: frameClass, style: frameStyle }), shownSlots.map((slot) => ((0, jsx_runtime_1.jsx)(PieceSlotFrame, { slot: slot, session: sessionRef }, slot.slotId)))] }));
|
|
657
693
|
}
|
|
658
694
|
/**
|
|
659
695
|
* A piece a framed screen embeds, drawn over the slot the screen reports: a frame of its own,
|
|
@@ -671,6 +707,7 @@ function PieceSlotFrame(props) {
|
|
|
671
707
|
session.current?.slotNotify(frame_protocol_1.HostNotice.pieceEmit, { slotId, name, payload });
|
|
672
708
|
},
|
|
673
709
|
onClose: () => session.current?.slotNotify(frame_protocol_1.HostNotice.pieceClose, { slotId }),
|
|
710
|
+
onDrawn: () => session.current?.slotNotify(frame_protocol_1.HostNotice.pieceDrawn, { slotId }),
|
|
674
711
|
onSize: (height, width) => session.current?.slotNotify(frame_protocol_1.HostNotice.pieceSize, width === undefined ? { slotId, height } : { slotId, height, width }),
|
|
675
712
|
onFailed: (message) => session.current?.slotNotify(frame_protocol_1.HostNotice.pieceFailed, { slotId, message }),
|
|
676
713
|
onKey: (key) => session.current?.slotNotify(frame_protocol_1.HostNotice.pieceKey, { slotId, ...key }),
|
|
@@ -11,6 +11,7 @@ const implement_piece_1 = require("../ui-contracts/implement-piece");
|
|
|
11
11
|
const piece_height_1 = require("../ui-contracts/piece-height");
|
|
12
12
|
const piece_host_1 = require("../ui-contracts/piece-host");
|
|
13
13
|
const popover_surface_1 = require("../ui-contracts/popover-surface");
|
|
14
|
+
const focus_relay_1 = require("./focus-relay");
|
|
14
15
|
const frame_component_1 = require("./frame-component");
|
|
15
16
|
const frame_protocol_1 = require("./frame-protocol");
|
|
16
17
|
const frame_realm_1 = require("./frame-realm");
|
|
@@ -72,6 +73,10 @@ function dispatchEscape(target, key) {
|
|
|
72
73
|
}));
|
|
73
74
|
}
|
|
74
75
|
const inlineComponents = new Map();
|
|
76
|
+
/** Keep hooks used by the embedder's loading view on its own mount. */
|
|
77
|
+
function LoadingView({ render }) {
|
|
78
|
+
return render();
|
|
79
|
+
}
|
|
75
80
|
/**
|
|
76
81
|
* In the host's window: the component that draws a piece in a frame for its provider.
|
|
77
82
|
*
|
|
@@ -94,6 +99,9 @@ function inlinePieceComponent(available, name) {
|
|
|
94
99
|
const [bundle, setBundle] = (0, react_1.useState)();
|
|
95
100
|
const [size, setSize] = (0, react_1.useState)();
|
|
96
101
|
const [failed, setFailed] = (0, react_1.useState)();
|
|
102
|
+
// The embedder's loading view shows until the piece's frame has drawn the piece.
|
|
103
|
+
const loading = (0, react_1.useContext)(piece_height_1.PieceLoadingContext);
|
|
104
|
+
const [drawn, setDrawn] = (0, react_1.useState)(false);
|
|
97
105
|
const latest = (0, react_1.useRef)(props);
|
|
98
106
|
latest.current = props;
|
|
99
107
|
(0, react_1.useEffect)(() => {
|
|
@@ -117,6 +125,7 @@ function inlinePieceComponent(available, name) {
|
|
|
117
125
|
onClose: () => latest.current.close(),
|
|
118
126
|
onSize: (height, width) => setSize({ height, width }),
|
|
119
127
|
onFailed: (message) => setFailed(message),
|
|
128
|
+
onDrawn: () => setDrawn(true),
|
|
120
129
|
// On the frame's box, inside any popover around it.
|
|
121
130
|
onKey: (key) => dispatchEscape(box.current, key),
|
|
122
131
|
}), []);
|
|
@@ -125,13 +134,17 @@ function inlinePieceComponent(available, name) {
|
|
|
125
134
|
throw bundle;
|
|
126
135
|
if (failed !== undefined)
|
|
127
136
|
throw new Error(failed);
|
|
128
|
-
if (!bundle)
|
|
137
|
+
if (!bundle) {
|
|
138
|
+
if (loading)
|
|
139
|
+
return (0, jsx_runtime_1.jsx)(LoadingView, { render: loading });
|
|
129
140
|
return ((0, jsx_runtime_1.jsx)("div", { className: "peers-piece-loading", "aria-busy": "true", style: { minHeight: 24, width: inPopover ? popoverStartWidth(maxWidth) : undefined } }));
|
|
141
|
+
}
|
|
130
142
|
const PackageFrame = (0, frame_component_1.packageFrameComponent)();
|
|
131
|
-
return ((0, jsx_runtime_1.
|
|
143
|
+
return ((0, jsx_runtime_1.jsxs)("div", { ref: box, style: {
|
|
144
|
+
position: "relative",
|
|
132
145
|
width: inPopover ? (size?.width ?? popoverStartWidth(maxWidth)) : "100%",
|
|
133
146
|
height: mode === "content" ? (size?.height ?? 24) : "100%",
|
|
134
|
-
}, children: (0, jsx_runtime_1.jsx)(PackageFrame, { pkg: bundle.pkg, bundle: bundle, content: content, pieceEvents: events, label: bundle.pkg.name }) }));
|
|
147
|
+
}, children: [(0, jsx_runtime_1.jsx)(PackageFrame, { pkg: bundle.pkg, bundle: bundle, content: content, pieceEvents: events, label: bundle.pkg.name }), loading && !drawn ? ((0, jsx_runtime_1.jsx)("div", { style: LOADING_OVER_FRAME, children: (0, jsx_runtime_1.jsx)(LoadingView, { render: loading }) })) : null] }));
|
|
135
148
|
}
|
|
136
149
|
const component = InlineFramedPiece;
|
|
137
150
|
inlineComponents.set(key, component);
|
|
@@ -175,6 +188,8 @@ function visibleClip(element, rect) {
|
|
|
175
188
|
*/
|
|
176
189
|
const LAYOUT_EVENTS = ["load", "transitionend", "animationend"];
|
|
177
190
|
const slotComponents = new Map();
|
|
191
|
+
/** The embedder's loading view, over a piece's frame until the frame has drawn the piece. */
|
|
192
|
+
const LOADING_OVER_FRAME = { position: "absolute", inset: 0 };
|
|
178
193
|
/**
|
|
179
194
|
* Inside a framed screen: the component that holds a slot for a piece, which the host draws over
|
|
180
195
|
* it in a frame for the provider.
|
|
@@ -196,6 +211,9 @@ function slotPieceComponent(available, name) {
|
|
|
196
211
|
const slotRef = (0, react_1.useRef)(null);
|
|
197
212
|
const [size, setSize] = (0, react_1.useState)();
|
|
198
213
|
const [failed, setFailed] = (0, react_1.useState)();
|
|
214
|
+
// Keep the embedder's loading view in the slot until the host's frame reports its first draw.
|
|
215
|
+
const loading = (0, react_1.useContext)(piece_height_1.PieceLoadingContext);
|
|
216
|
+
const [drawn, setDrawn] = (0, react_1.useState)(false);
|
|
199
217
|
const latest = (0, react_1.useRef)(props);
|
|
200
218
|
latest.current = props;
|
|
201
219
|
// The slot the host holds for this mount, once its mount request has been answered.
|
|
@@ -207,8 +225,27 @@ function slotPieceComponent(available, name) {
|
|
|
207
225
|
// Each mount is a slot of its own, so a late answer to an earlier one never touches it.
|
|
208
226
|
const slotId = (0, peers_sdk_1.newid)();
|
|
209
227
|
let active = true;
|
|
228
|
+
setDrawn(false);
|
|
210
229
|
const mine = (payload) => payload?.slotId === slotId;
|
|
211
230
|
const stops = [
|
|
231
|
+
host.onNotify(frame_protocol_1.HostNotice.pieceDrawn, (payload) => {
|
|
232
|
+
if (!mine(payload))
|
|
233
|
+
return;
|
|
234
|
+
setDrawn(true);
|
|
235
|
+
// Focus that reached the slot first (Tab while the piece loaded, or a popover focusing
|
|
236
|
+
// it as it opened, whose Tab trap then refocuses it without a focus event) goes in now.
|
|
237
|
+
if (document.hasFocus() && document.activeElement === slotRef.current) {
|
|
238
|
+
host.notify(frame_protocol_1.FrameNotice.pieceFocus, { slotId, edge: "first" });
|
|
239
|
+
}
|
|
240
|
+
}),
|
|
241
|
+
// Tab left the piece drawn over this slot: on to the control after it, or back before it.
|
|
242
|
+
host.onNotify(frame_protocol_1.HostNotice.pieceFocusLeave, (payload) => {
|
|
243
|
+
const slot = slotRef.current;
|
|
244
|
+
// The host focused this screen as it sent this; focus the user moved since stays.
|
|
245
|
+
if (!mine(payload) || !slot || !document.hasFocus())
|
|
246
|
+
return;
|
|
247
|
+
(0, focus_relay_1.focusBeside)(slot, payload.direction === "previous" ? "previous" : "next");
|
|
248
|
+
}),
|
|
212
249
|
host.onNotify(frame_protocol_1.HostNotice.pieceEmit, (payload) => {
|
|
213
250
|
if (mine(payload))
|
|
214
251
|
latest.current.emit[payload.name]?.(payload.payload);
|
|
@@ -336,10 +373,25 @@ function slotPieceComponent(available, name) {
|
|
|
336
373
|
// The piece's error boundary shows the failure, with Retry.
|
|
337
374
|
if (failed !== undefined)
|
|
338
375
|
throw new Error(failed);
|
|
339
|
-
return (
|
|
376
|
+
return (
|
|
377
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: it stands in for the piece's frame, which the host draws over it, in the screen's Tab order.
|
|
378
|
+
(0, jsx_runtime_1.jsx)("div", { ref: slotRef, "data-peers-piece-slot": "",
|
|
379
|
+
// Tab stops here in the piece's place; the host moves focus into the piece's frame.
|
|
380
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: as above; focus moves straight on into the frame.
|
|
381
|
+
tabIndex: 0, onFocus: (event) => {
|
|
382
|
+
const slotId = mounted.current;
|
|
383
|
+
// Until the piece has drawn its frame may have no controls, so focus waits here.
|
|
384
|
+
if (event.target !== event.currentTarget || !slotId || !drawn)
|
|
385
|
+
return;
|
|
386
|
+
const edge = (0, focus_relay_1.edgeEnteredFrom)(event.currentTarget, event.relatedTarget);
|
|
387
|
+
host?.notify(frame_protocol_1.FrameNotice.pieceFocus, { slotId, edge });
|
|
388
|
+
},
|
|
389
|
+
// A popover has no background of its own. The piece's frame paints it once drawn, and is
|
|
390
|
+
// clear before that, so the loading view shows; the slot paints it until then.
|
|
391
|
+
className: inPopover && !drawn ? "bg-body" : undefined, style: {
|
|
340
392
|
width: inPopover ? (size?.width ?? popoverStartWidth(maxWidth)) : "100%",
|
|
341
393
|
height: mode === "content" ? (size?.height ?? 24) : "100%",
|
|
342
|
-
} }));
|
|
394
|
+
}, children: loading && !drawn ? (0, jsx_runtime_1.jsx)(LoadingView, { render: loading }) : null }));
|
|
343
395
|
}
|
|
344
396
|
const component = SlotFramedPiece;
|
|
345
397
|
slotComponents.set(key, component);
|
|
@@ -5,9 +5,12 @@ const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
|
5
5
|
/**
|
|
6
6
|
* Whether a framed screen's package may embed a UI contract's pieces: it consumes that UI
|
|
7
7
|
* contract version (`pkg.consumes`, kept in the manifest's `uiConsumes`), or provides it itself.
|
|
8
|
-
* Read from the manifest this device stored for the screen's version, once per version.
|
|
8
|
+
* Read from the manifest this device stored for the screen's version, once per version. A version
|
|
9
|
+
* with no stored manifest yet (a folder-loaded dev build) is read again next time, since
|
|
10
|
+
* promoting it stores its manifest under the same version id.
|
|
9
11
|
*/
|
|
10
12
|
const known = new Map();
|
|
13
|
+
/** The UI contract versions a manifest declares, or undefined when there's no manifest to read. */
|
|
11
14
|
async function readDeclared(bundle) {
|
|
12
15
|
const user = await (0, peers_sdk_1.getUserContext)();
|
|
13
16
|
const dataContext = bundle.dataContextId === user.userId
|
|
@@ -19,17 +22,17 @@ async function readDeclared(bundle) {
|
|
|
19
22
|
(0, peers_sdk_1.PackageVersions)(dataContext).get(bundle.packageVersionId),
|
|
20
23
|
(0, peers_sdk_1.PackageVersionManifests)(dataContext).get(bundle.packageVersionId),
|
|
21
24
|
]);
|
|
22
|
-
const declared = new Set();
|
|
23
25
|
if (!pv ||
|
|
24
26
|
!row ||
|
|
25
27
|
row.format !== peers_sdk_1.PACKAGE_VERSION_MANIFEST_FORMAT ||
|
|
26
28
|
row.packageId !== pv.packageId ||
|
|
27
29
|
row.packageBundleFileHash !== pv.packageBundleFileHash) {
|
|
28
|
-
return
|
|
30
|
+
return undefined;
|
|
29
31
|
}
|
|
30
32
|
const manifest = JSON.parse(row.manifest);
|
|
31
33
|
if (!manifest || manifest.packageId !== pv.packageId || manifest.version !== pv.version)
|
|
32
|
-
return
|
|
34
|
+
return undefined;
|
|
35
|
+
const declared = new Set();
|
|
33
36
|
for (const entry of manifest.uiConsumes ?? [])
|
|
34
37
|
declared.add(`${entry.contractId}@${entry.version}`);
|
|
35
38
|
for (const entry of (0, peers_sdk_1.providedContracts)(manifest.uiProvides ?? [])) {
|
|
@@ -48,9 +51,17 @@ async function consumesUIContract(bundle, contractId, version) {
|
|
|
48
51
|
const key = `${bundle.dataContextId}:${bundle.packageVersionId}`;
|
|
49
52
|
let declared = known.get(key);
|
|
50
53
|
if (!declared) {
|
|
51
|
-
|
|
54
|
+
const read = readDeclared(bundle);
|
|
55
|
+
declared = read.then((found) => found ?? new Set());
|
|
52
56
|
known.set(key, declared);
|
|
53
|
-
|
|
57
|
+
// Keep only a read that found the manifest; read again after a failure or a missing one.
|
|
58
|
+
read.then((found) => {
|
|
59
|
+
if (!found && known.get(key) === declared)
|
|
60
|
+
known.delete(key);
|
|
61
|
+
}, () => {
|
|
62
|
+
if (known.get(key) === declared)
|
|
63
|
+
known.delete(key);
|
|
64
|
+
});
|
|
54
65
|
}
|
|
55
66
|
return (await declared).has(`${contractId}@${version}`);
|
|
56
67
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defer loading a module until it's first needed, so code most screens never use (the editor,
|
|
3
|
+
* the markdown renderer) isn't compiled and run when peers-ui loads. Every isolated screen and
|
|
4
|
+
* piece is a frame that loads peers-ui on its own, so whatever loads up front, every frame pays.
|
|
5
|
+
*
|
|
6
|
+
* `load` is a `require` inside a function. A bundler then runs that module on the first call:
|
|
7
|
+
* webpack (Electron) and esbuild for any module, Rollup (the PWA) for CommonJS ones only. Rollup
|
|
8
|
+
* runs ES modules (Lexical, react-markdown) up front wherever they're required.
|
|
9
|
+
*
|
|
10
|
+
* A module that throws while loading isn't loaded again: the bundlers keep what it had exported
|
|
11
|
+
* when it threw, so the component fails to draw until the page reloads (the screen's error
|
|
12
|
+
* boundary shows it). Under Jest and Node, the next call tries again.
|
|
13
|
+
*
|
|
14
|
+
* @param load - Loads the module, as `() => require("./x") as typeof import("./x")`.
|
|
15
|
+
* @returns A function that loads the module the first time it's called and returns it after.
|
|
16
|
+
*/
|
|
17
|
+
export declare function lazyModule<T>(load: () => T): () => T;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lazyModule = lazyModule;
|
|
4
|
+
/**
|
|
5
|
+
* Defer loading a module until it's first needed, so code most screens never use (the editor,
|
|
6
|
+
* the markdown renderer) isn't compiled and run when peers-ui loads. Every isolated screen and
|
|
7
|
+
* piece is a frame that loads peers-ui on its own, so whatever loads up front, every frame pays.
|
|
8
|
+
*
|
|
9
|
+
* `load` is a `require` inside a function. A bundler then runs that module on the first call:
|
|
10
|
+
* webpack (Electron) and esbuild for any module, Rollup (the PWA) for CommonJS ones only. Rollup
|
|
11
|
+
* runs ES modules (Lexical, react-markdown) up front wherever they're required.
|
|
12
|
+
*
|
|
13
|
+
* A module that throws while loading isn't loaded again: the bundlers keep what it had exported
|
|
14
|
+
* when it threw, so the component fails to draw until the page reloads (the screen's error
|
|
15
|
+
* boundary shows it). Under Jest and Node, the next call tries again.
|
|
16
|
+
*
|
|
17
|
+
* @param load - Loads the module, as `() => require("./x") as typeof import("./x")`.
|
|
18
|
+
* @returns A function that loads the module the first time it's called and returns it after.
|
|
19
|
+
*/
|
|
20
|
+
function lazyModule(load) {
|
|
21
|
+
let loaded;
|
|
22
|
+
return () => {
|
|
23
|
+
loaded ??= { module: load() };
|
|
24
|
+
return loaded.module;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -5,6 +5,7 @@ exports.NotificationBell = NotificationBell;
|
|
|
5
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const menu_surface_1 = require("../components/menu-surface");
|
|
8
|
+
const use_close_on_outside_press_1 = require("../components/use-close-on-outside-press");
|
|
8
9
|
const hooks_1 = require("../hooks");
|
|
9
10
|
const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
|
|
10
11
|
const notifications_client_1 = require("./notifications-client");
|
|
@@ -22,24 +23,7 @@ function NotificationBell({ compact = false }) {
|
|
|
22
23
|
const [open, setOpen] = (0, react_1.useState)(false);
|
|
23
24
|
const containerRef = (0, react_1.useRef)(null);
|
|
24
25
|
const popoverId = (0, react_1.useId)();
|
|
25
|
-
(0,
|
|
26
|
-
if (!open)
|
|
27
|
-
return;
|
|
28
|
-
const closeOutside = (event) => {
|
|
29
|
-
if (!containerRef.current?.contains(event.target))
|
|
30
|
-
setOpen(false);
|
|
31
|
-
};
|
|
32
|
-
const closeOnEscape = (event) => {
|
|
33
|
-
if (event.key === "Escape")
|
|
34
|
-
setOpen(false);
|
|
35
|
-
};
|
|
36
|
-
document.addEventListener("mousedown", closeOutside);
|
|
37
|
-
document.addEventListener("keydown", closeOnEscape);
|
|
38
|
-
return () => {
|
|
39
|
-
document.removeEventListener("mousedown", closeOutside);
|
|
40
|
-
document.removeEventListener("keydown", closeOnEscape);
|
|
41
|
-
};
|
|
42
|
-
}, [open]);
|
|
26
|
+
(0, use_close_on_outside_press_1.useCloseOnOutsidePress)(containerRef, open, () => setOpen(false));
|
|
43
27
|
const label = (0, notifications_panel_1.notificationBadgeLabel)(summary);
|
|
44
28
|
const toggle = () => setOpen((current) => !current);
|
|
45
29
|
return ((0, jsx_runtime_1.jsxs)("div", { ref: containerRef, className: "position-relative d-flex align-items-center", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm d-flex align-items-center px-2 text-body-secondary", style: {
|
|
@@ -193,15 +193,6 @@ for (const [name, params] of Object.entries(CONSOLE_PARAMS)) {
|
|
|
193
193
|
}
|
|
194
194
|
/** The Console's own helpers, beside the session's, with their argument hints. */
|
|
195
195
|
const consoleHelpers = {
|
|
196
|
-
help: (0, repl_1.withCallInfo)(function help() {
|
|
197
|
-
return CONSOLE_HELP_TEXT;
|
|
198
|
-
}, {
|
|
199
|
-
name: "help",
|
|
200
|
-
kind: "helper",
|
|
201
|
-
params: [],
|
|
202
|
-
objectArgument: false,
|
|
203
|
-
description: "How contracts, these helpers and the Console's keys are used.",
|
|
204
|
-
}),
|
|
205
196
|
print: (0, repl_1.withCallInfo)(function print(...values) {
|
|
206
197
|
consolePrint(...values);
|
|
207
198
|
}, {
|
|
@@ -240,6 +231,7 @@ async function open(transport) {
|
|
|
240
231
|
scope: exports.consoleScope.values,
|
|
241
232
|
print: (value) => printAt("log", [value], undefined),
|
|
242
233
|
reserved: [...console_scope_1.CONSOLE_GLOBAL_NAMES, "print", "console", "clear", "$"],
|
|
234
|
+
helpText: CONSOLE_HELP_TEXT,
|
|
243
235
|
});
|
|
244
236
|
next.onChange = () => {
|
|
245
237
|
(0, exports.consoleContext)(next.contextName);
|
|
@@ -25,9 +25,14 @@ const GroupMembersUI = (props) => {
|
|
|
25
25
|
const members = await groupMembersTable.list({ deleted: { $ne: true } });
|
|
26
26
|
// Get user details for each member using the group context
|
|
27
27
|
const membersWithUsers = await Promise.all(members.map(async (member) => {
|
|
28
|
+
// A member whose profile or trust can't be read is listed by id, as one with no
|
|
29
|
+
// profile is, rather than leaving the whole list unloaded.
|
|
28
30
|
const user = await (0, peers_sdk_1.getUserById)(member.userId, {
|
|
29
31
|
currentDataContext: groupDataContext,
|
|
30
32
|
includeTrustLevel: true,
|
|
33
|
+
}).catch((err) => {
|
|
34
|
+
console.error(`Failed to read group member ${member.userId}:`, err);
|
|
35
|
+
return undefined;
|
|
31
36
|
});
|
|
32
37
|
// If user found from external source, save to current group
|
|
33
38
|
if (user && user.source !== "currentDataContext") {
|
|
@@ -46,22 +51,6 @@ const GroupMembersUI = (props) => {
|
|
|
46
51
|
console.error("Failed to save user to group context:", saveErr);
|
|
47
52
|
}
|
|
48
53
|
}
|
|
49
|
-
// TODO don't do it this way!!! Use group-specific trust level fetching
|
|
50
|
-
if (user && !user.trustLevel) {
|
|
51
|
-
const userCursor = await (0, peers_sdk_1.usersCursor)({ userId: member.userId }, { includeTrustLevel: true });
|
|
52
|
-
const _user = await userCursor.next();
|
|
53
|
-
user.trustLevel = _user?.trustLevel || user.trustLevel || peers_sdk_1.TrustLevel.Unknown;
|
|
54
|
-
}
|
|
55
|
-
// // Fetch trust level for this user in the group context
|
|
56
|
-
// if (user) {
|
|
57
|
-
// try {
|
|
58
|
-
// const trustLevel = await getUserTrustLevel(groupDataContext, user.userId);
|
|
59
|
-
// user.trustLevel = trustLevel;
|
|
60
|
-
// } catch (err) {
|
|
61
|
-
// console.error('Failed to get trust level:', err);
|
|
62
|
-
// user.trustLevel = TrustLevel.Unknown;
|
|
63
|
-
// }
|
|
64
|
-
// }
|
|
65
54
|
return {
|
|
66
55
|
member,
|
|
67
56
|
user: user || null,
|
|
@@ -89,9 +78,10 @@ const GroupMembersUI = (props) => {
|
|
|
89
78
|
if (!group) {
|
|
90
79
|
return null;
|
|
91
80
|
}
|
|
92
|
-
// Try to get founder user details
|
|
81
|
+
// Try to get founder user details. The banner shows only the name, so no trust is read.
|
|
93
82
|
const founderUser = await (0, peers_sdk_1.getUserById)(group.founderUserId, {
|
|
94
83
|
currentDataContext: groupDataContext,
|
|
84
|
+
includeTrustLevel: false,
|
|
95
85
|
});
|
|
96
86
|
return {
|
|
97
87
|
group,
|
|
@@ -8,8 +8,13 @@ const qr_scanner_1 = require("../../components/qr-scanner");
|
|
|
8
8
|
const globals_1 = require("../../globals");
|
|
9
9
|
const invite_capture_1 = require("./invite-capture");
|
|
10
10
|
const invites_ipc_1 = require("./invites-ipc");
|
|
11
|
+
/**
|
|
12
|
+
* The trust choices for a new contact. The first, `""`, sets no level, so they follow the default:
|
|
13
|
+
* New User for their first week, then Known (see `getUserTrust`). The others set a level.
|
|
14
|
+
*/
|
|
11
15
|
const TRUST_OPTIONS = [
|
|
12
|
-
{ value:
|
|
16
|
+
{ value: "", label: "Default: New user for a week, then Known" },
|
|
17
|
+
{ value: peers_sdk_1.TrustLevel.NewUser, label: "New user" },
|
|
13
18
|
{ value: peers_sdk_1.TrustLevel.Known, label: "Known" },
|
|
14
19
|
{ value: peers_sdk_1.TrustLevel.Trusted, label: "Trusted" },
|
|
15
20
|
];
|
|
@@ -42,7 +47,7 @@ function AcceptInvite(props) {
|
|
|
42
47
|
const [scanning, setScanning] = (0, react_1.useState)(false);
|
|
43
48
|
const [preview, setPreview] = (0, react_1.useState)(undefined);
|
|
44
49
|
const [result, setResult] = (0, react_1.useState)(undefined);
|
|
45
|
-
const [trustLevel, setTrustLevel] = (0, react_1.useState)(
|
|
50
|
+
const [trustLevel, setTrustLevel] = (0, react_1.useState)(undefined);
|
|
46
51
|
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
47
52
|
const [error, setError] = (0, react_1.useState)("");
|
|
48
53
|
const runPreview = (0, react_1.useCallback)(async (token) => {
|
|
@@ -51,6 +56,7 @@ function AcceptInvite(props) {
|
|
|
51
56
|
try {
|
|
52
57
|
const tools = await (0, invites_ipc_1.inviteTools)();
|
|
53
58
|
const response = await tools.previewInvite({ token });
|
|
59
|
+
setTrustLevel(undefined);
|
|
54
60
|
setPreview(response.preview);
|
|
55
61
|
setText(token);
|
|
56
62
|
}
|
|
@@ -120,7 +126,10 @@ function AcceptInvite(props) {
|
|
|
120
126
|
setBusy(true);
|
|
121
127
|
try {
|
|
122
128
|
const tools = await (0, invites_ipc_1.inviteTools)();
|
|
123
|
-
const response = await tools.acceptInvite({
|
|
129
|
+
const response = await tools.acceptInvite({
|
|
130
|
+
token: text,
|
|
131
|
+
...(preview?.knownContact || trustLevel === undefined ? {} : { trustLevel }),
|
|
132
|
+
});
|
|
124
133
|
setResult(response.result);
|
|
125
134
|
}
|
|
126
135
|
catch (err) {
|
|
@@ -149,7 +158,9 @@ function AcceptInvite(props) {
|
|
|
149
158
|
setError(message);
|
|
150
159
|
} }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary mt-3", onClick: () => setScanning(false), children: "Cancel" })] }));
|
|
151
160
|
}
|
|
152
|
-
return ((0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 520, margin: "0 auto" }, children: preview ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(PreviewCard, { preview: preview }), !preview.knownContact ? ((0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: "invite-trust", className: "form-label small text-muted mb-1", children: ["Trust level for ", preview.inviter.displayName || "this contact"] }), (0, jsx_runtime_1.jsx)("select", { id: "invite-trust", className: "form-select form-select-sm", value: trustLevel, onChange: (event) => setTrustLevel(
|
|
161
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: { maxWidth: 520, margin: "0 auto" }, children: preview ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(PreviewCard, { preview: preview }), !preview.knownContact ? ((0, jsx_runtime_1.jsxs)("div", { className: "mb-3", children: [(0, jsx_runtime_1.jsxs)("label", { htmlFor: "invite-trust", className: "form-label small text-muted mb-1", children: ["Trust level for ", preview.inviter.displayName || "this contact"] }), (0, jsx_runtime_1.jsx)("select", { id: "invite-trust", className: "form-select form-select-sm", value: trustLevel ?? "", onChange: (event) => setTrustLevel(event.target.value === ""
|
|
162
|
+
? undefined
|
|
163
|
+
: Number(event.target.value)), disabled: busy, children: TRUST_OPTIONS.map((option) => ((0, jsx_runtime_1.jsx)("option", { value: option.value, children: option.label }, option.value))) })] })) : null, error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary", disabled: busy || preview.expired || preview.group?.alreadyMember, onClick: () => void accept(), children: busy ? "Working…" : preview.type === "group" ? "Join" : "Accept" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary", onClick: reset, children: "Back" })] })] })) : ((0, jsx_runtime_1.jsxs)("form", { onSubmit: (event) => {
|
|
153
164
|
event.preventDefault();
|
|
154
165
|
void runPreview(text);
|
|
155
166
|
}, children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: "invite-text", className: "form-label", children: "Paste an invite link or code" }), (0, jsx_runtime_1.jsx)("textarea", { id: "invite-text", className: "form-control font-monospace mb-2", rows: 3, value: text, onChange: (event) => setText(event.target.value), placeholder: "https://peers.app/i#\u2026", disabled: busy, spellCheck: false }), error ? (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }) : null, (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "submit", className: "btn btn-primary", disabled: busy || !text.trim(), children: busy ? "Checking…" : "Continue" }), (0, qr_scanner_1.canScanQr)() ? ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-outline-primary", disabled: busy, onClick: () => setScanning(true), children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-qr-code-scan me-1" }), "Scan QR"] })) : null] })] })) }));
|