@peers-app/peers-ui 0.34.13 → 0.34.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/apps-home/app-menu.d.ts +1 -2
- package/dist/apps-home/app-menu.js +29 -25
- package/dist/command-palette/command-palette-ui.js +13 -12
- package/dist/components/autocomplete-chips.d.ts +18 -0
- package/dist/components/autocomplete-chips.js +49 -0
- package/dist/components/autocomplete.d.ts +88 -0
- package/dist/components/autocomplete.js +346 -0
- package/dist/components/confirm-button.d.ts +26 -0
- package/dist/components/confirm-button.js +55 -0
- package/dist/components/data-grid/autocomplete.d.ts +1 -31
- package/dist/components/data-grid/autocomplete.js +5 -197
- package/dist/components/empty-state.d.ts +16 -0
- package/dist/components/empty-state.js +16 -0
- package/dist/components/group-switcher.d.ts +3 -3
- package/dist/components/group-switcher.js +22 -17
- package/dist/components/inline-create-form.d.ts +22 -0
- package/dist/components/inline-create-form.js +56 -0
- package/dist/components/list-row.d.ts +33 -0
- package/dist/components/list-row.js +30 -0
- package/dist/components/list-screen.d.ts +31 -3
- package/dist/components/list-screen.js +61 -28
- package/dist/components/markdown-editor/format-bar.js +15 -40
- package/dist/components/markdown-editor/link-plugin.js +38 -9
- package/dist/components/markdown-editor/selection-bar-place.d.ts +37 -0
- package/dist/components/markdown-editor/selection-bar-place.js +107 -0
- package/dist/components/menu-button.d.ts +34 -0
- package/dist/components/menu-button.js +66 -0
- package/dist/components/screen-header.d.ts +35 -0
- package/dist/components/screen-header.js +30 -0
- package/dist/components/search-field.d.ts +22 -0
- package/dist/components/search-field.js +22 -0
- package/dist/components/segmented-control.d.ts +25 -0
- package/dist/components/segmented-control.js +18 -0
- package/dist/components/typeahead.d.ts +9 -0
- package/dist/components/typeahead.js +7 -0
- package/dist/delegates/acts-for-you-panel.d.ts +2 -1
- package/dist/delegates/acts-for-you-panel.js +46 -17
- package/dist/delegates/delegate-request-dialog.d.ts +3 -1
- package/dist/delegates/delegate-request-dialog.js +6 -3
- package/dist/groups/groups-client.d.ts +23 -1
- package/dist/groups/groups-client.js +31 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +14 -1
- package/dist/isolated-screens/config.js +1 -9
- package/dist/isolated-screens/folder-picker-control.d.ts +57 -0
- package/dist/isolated-screens/folder-picker-control.js +217 -0
- package/dist/isolated-screens/folder-picker-host.d.ts +57 -0
- package/dist/isolated-screens/folder-picker-host.js +178 -0
- package/dist/isolated-screens/folder-picker-protocol.d.ts +75 -0
- package/dist/isolated-screens/folder-picker-protocol.js +104 -0
- package/dist/isolated-screens/frame-bridge.js +8 -0
- package/dist/isolated-screens/frame-document.js +2 -1
- package/dist/isolated-screens/frame-microphone.d.ts +55 -0
- package/dist/isolated-screens/frame-microphone.js +265 -0
- package/dist/isolated-screens/frame-permissions.d.ts +19 -0
- package/dist/isolated-screens/frame-permissions.js +32 -0
- package/dist/isolated-screens/frame-protocol.d.ts +26 -0
- package/dist/isolated-screens/frame-protocol.js +9 -0
- package/dist/isolated-screens/frame-pvars.d.ts +27 -0
- package/dist/isolated-screens/frame-pvars.js +101 -14
- package/dist/isolated-screens/global-widgets.d.ts +1 -2
- package/dist/isolated-screens/index.d.ts +2 -0
- package/dist/isolated-screens/index.js +3 -1
- package/dist/isolated-screens/isolated-screen.d.ts +21 -0
- package/dist/isolated-screens/isolated-screen.js +88 -5
- package/dist/isolated-screens/local-folder-picker.d.ts +55 -0
- package/dist/isolated-screens/local-folder-picker.js +143 -0
- package/dist/isolated-screens/microphone-host.d.ts +110 -0
- package/dist/isolated-screens/microphone-host.js +397 -0
- package/dist/isolated-screens/microphone-prompt.d.ts +20 -0
- package/dist/isolated-screens/microphone-prompt.js +60 -0
- package/dist/isolated-screens/piece-frames.js +5 -94
- package/dist/isolated-screens/piece-reach.d.ts +1 -0
- package/dist/isolated-screens/port-channel.d.ts +21 -11
- package/dist/isolated-screens/port-channel.js +15 -5
- package/dist/isolated-screens/slot-rect.d.ts +38 -0
- package/dist/isolated-screens/slot-rect.js +121 -0
- package/dist/isolated-screens/test-ports.d.ts +17 -0
- package/dist/isolated-screens/test-ports.js +25 -3
- package/dist/mentions/mention-chooser.js +1 -1
- package/dist/notifications/notifications-screen.js +1 -1
- package/dist/screens/data-explorer/data-explorer.d.ts +1 -0
- package/dist/screens/data-explorer/data-explorer.js +28 -10
- package/dist/screens/data-explorer/query-executor.d.ts +1 -0
- package/dist/screens/data-explorer/query-executor.js +3 -1
- package/dist/screens/groups/group-list.d.ts +13 -3
- package/dist/screens/groups/group-list.js +88 -11
- package/dist/screens/identity/identity-routes.d.ts +16 -0
- package/dist/screens/identity/identity-routes.js +27 -10
- package/dist/screens/identity/identity-screen.js +4 -1
- package/dist/screens/invites/activity-view.d.ts +3 -1
- package/dist/screens/invites/activity-view.js +7 -3
- package/dist/screens/invites/pending-invites-list.d.ts +8 -4
- package/dist/screens/invites/pending-invites-list.js +44 -45
- package/dist/screens/network-viewer/graph/network-graph-controls.js +3 -3
- package/dist/screens/packages/local-folder-grants-panel.d.ts +2 -0
- package/dist/screens/packages/local-folder-grants-panel.js +1 -1
- package/dist/screens/packages/package-info.js +2 -1
- package/dist/screens/packages/package-list.d.ts +2 -2
- package/dist/screens/packages/package-list.js +89 -105
- package/dist/screens/packages/package-microphone-panel.d.ts +14 -0
- package/dist/screens/packages/package-microphone-panel.js +62 -0
- package/dist/screens/packages/package-runtime-status.d.ts +10 -2
- package/dist/screens/packages/package-runtime-status.js +17 -4
- package/dist/screens/peer-types/peer-type-details.js +3 -2
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -1
- package/dist/screens/peer-types/peer-type-list.js +4 -4
- package/dist/screens/settings/settings-page.js +1 -4
- package/dist/screens/tools/tool-details.js +2 -1
- package/dist/screens/tools/tool-list.d.ts +1 -1
- package/dist/screens/tools/tool-list.js +22 -60
- package/dist/screens/variables/variable-details.js +5 -4
- package/dist/screens/variables/variable-list.d.ts +17 -0
- package/dist/screens/variables/variable-list.js +72 -28
- package/dist/tabs-layout/network-status-details.d.ts +4 -4
- package/dist/tabs-layout/network-status-details.js +6 -5
- package/dist/tabs-layout/network-status-indicator.d.ts +1 -0
- package/dist/tabs-layout/network-status-indicator.js +1 -0
- package/dist/tabs-layout/tab-bar-shortcuts.d.ts +46 -0
- package/dist/tabs-layout/tab-bar-shortcuts.js +140 -0
- package/dist/tabs-layout/tabs-layout.js +11 -9
- package/dist/theme.css +326 -6
- package/dist/ui-contracts/popover-surface.d.ts +3 -0
- package/dist/ui-contracts/popover-surface.js +6 -3
- package/dist/ui-defaults/list-screen.js +10 -4
- package/package.json +3 -3
|
@@ -34,36 +34,50 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.ListScreen = ListScreen;
|
|
37
|
+
exports.firstLineOf = firstLineOf;
|
|
37
38
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
-
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
39
39
|
const _ = __importStar(require("lodash"));
|
|
40
40
|
const react_1 = require("react");
|
|
41
41
|
const globals_1 = require("../globals");
|
|
42
|
-
const
|
|
43
|
-
const
|
|
42
|
+
const empty_state_1 = require("./empty-state");
|
|
43
|
+
const inline_create_form_1 = require("./inline-create-form");
|
|
44
44
|
const lazy_list_1 = require("./lazy-list");
|
|
45
45
|
const loading_indicator_1 = require("./loading-indicator");
|
|
46
|
+
const screen_header_1 = require("./screen-header");
|
|
47
|
+
const search_field_1 = require("./search-field");
|
|
48
|
+
/**
|
|
49
|
+
* A searchable list of a table's records, loaded a page at a time as the user scrolls: a header
|
|
50
|
+
* (with New when the screen can create), a search box, then the rows. Types, Variables and the
|
|
51
|
+
* fallback list for any table use it.
|
|
52
|
+
*/
|
|
46
53
|
function ListScreen(props) {
|
|
47
54
|
const { table, newRecord, sortBy } = props;
|
|
48
|
-
const [
|
|
49
|
-
const [
|
|
50
|
-
|
|
55
|
+
const [searchText, setSearchText] = (0, react_1.useState)("");
|
|
56
|
+
const [creating, setCreating] = (0, react_1.useState)(false);
|
|
57
|
+
// The cursor and the empty mark belong to one search and filter: LazyList (a child) reloads
|
|
58
|
+
// before this component's effects run, so a mark from an older search must not count.
|
|
59
|
+
const [emptyKey, setEmptyKey] = (0, react_1.useState)();
|
|
60
|
+
const cursorRef = (0, react_1.useRef)();
|
|
61
|
+
const what = props.placeholderName || table.metaData.name;
|
|
51
62
|
const newCursor = (0, react_1.useCallback)(async () => {
|
|
52
63
|
const filter = props.getFilter ? props.getFilter(searchText) : null;
|
|
53
64
|
const cursor = await table.cursor(filter || {}, {
|
|
54
65
|
sortBy,
|
|
55
66
|
...(filter ? {} : { textSearch: searchText }),
|
|
56
67
|
});
|
|
57
|
-
cursorObs(cursor);
|
|
58
68
|
return cursor;
|
|
59
|
-
}, [table, searchText, props.getFilter, sortBy
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}, [newCursor]);
|
|
69
|
+
}, [table, searchText, props.getFilter, sortBy]);
|
|
70
|
+
const resetKey = `${searchText}\u0000${props.resetKey ?? ""}`;
|
|
71
|
+
const empty = emptyKey === resetKey;
|
|
63
72
|
const idFieldName = table.metaData.primaryKeyName;
|
|
64
73
|
async function loadMore(existing) {
|
|
65
74
|
let moreMatches = [];
|
|
66
|
-
const
|
|
75
|
+
const key = resetKey;
|
|
76
|
+
let cursor = cursorRef.current?.key === key ? cursorRef.current.cursor : undefined;
|
|
77
|
+
if (!cursor) {
|
|
78
|
+
cursor = await newCursor();
|
|
79
|
+
cursorRef.current = { key, cursor };
|
|
80
|
+
}
|
|
67
81
|
for await (const nextRecord of cursor) {
|
|
68
82
|
if (existing.find((e) => e[idFieldName] === nextRecord[idFieldName]))
|
|
69
83
|
continue;
|
|
@@ -73,8 +87,9 @@ function ListScreen(props) {
|
|
|
73
87
|
if (moreMatches.length >= 10)
|
|
74
88
|
break;
|
|
75
89
|
}
|
|
76
|
-
if (moreMatches.length === 0) {
|
|
77
|
-
|
|
90
|
+
if (moreMatches.length === 0 && cursorRef.current?.cursor === cursor) {
|
|
91
|
+
cursorRef.current = undefined;
|
|
92
|
+
setEmptyKey(existing.length === 0 ? key : undefined);
|
|
78
93
|
}
|
|
79
94
|
// if we're using default textSearch, list items with the most words matched in the name first
|
|
80
95
|
if (!props.getFilter &&
|
|
@@ -90,18 +105,36 @@ function ListScreen(props) {
|
|
|
90
105
|
}
|
|
91
106
|
return moreMatches;
|
|
92
107
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
const newButton = newRecord ? ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "btn btn-outline-primary btn-sm text-nowrap", onClick: () => setCreating(true), children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-plus-lg me-1", "aria-hidden": "true" }), "New ", what] })) : null;
|
|
109
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-xxl p-3", children: [props.title ? ((0, jsx_runtime_1.jsx)(screen_header_1.ScreenHeader, { icon: props.icon, title: props.title, subtitle: props.subtitle, actions: newButton || props.actions ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [newButton, props.actions] })) : undefined })) : (newButton && (0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-end mb-2", children: newButton })), creating && newRecord && ((0, jsx_runtime_1.jsx)(inline_create_form_1.InlineCreateForm, { title: `New ${what}`, initialValue: searchText.trim(), onCancel: () => setCreating(false), onSubmit: async (name) => {
|
|
110
|
+
await newRecord(name);
|
|
111
|
+
setCreating(false);
|
|
112
|
+
setSearchText("");
|
|
113
|
+
} })), (0, jsx_runtime_1.jsx)(search_field_1.SearchField, { value: searchText, onChange: setSearchText, placeholder: `Search ${what}s`, autoFocus: !creating && !!(0, globals_1.isDesktop)() }), props.toolbar, (0, jsx_runtime_1.jsx)("div", { className: "peers-list-container", children: (0, jsx_runtime_1.jsx)(lazy_list_1.LazyList, { resetTrigger: resetKey, loadMore: loadMore, scrollThreshold: 0.6, renderItems: (records) => records.length ? ((0, jsx_runtime_1.jsx)("div", { className: "list-group", children: records.map(props.renderItem) })) : null, loadingIndicator: (0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-center", style: { height: 200 }, children: (0, jsx_runtime_1.jsx)(loading_indicator_1.LoadingIndicator, {}) }), endOfList: empty ? ((0, jsx_runtime_1.jsx)(empty_state_1.EmptyState, { icon: props.emptyIcon ?? props.icon, title: searchText ? `No matching ${what}s` : `No ${what}s yet`, children: searchText
|
|
114
|
+
? "Try a different name or description."
|
|
115
|
+
: newRecord
|
|
116
|
+
? `New ${what} makes one.`
|
|
117
|
+
: undefined })) : ((0, jsx_runtime_1.jsx)("div", { style: { height: 120 } })) }) })] }));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Inline code, or text between two equal runs of `*`, `~` or `_` (`**bold**`, `~~old~~`,
|
|
121
|
+
* `_it_`). A lone mark (`~/.config`, `5 * 3`) or an underscore inside a word (`API_KEY`) is
|
|
122
|
+
* literal text.
|
|
123
|
+
*/
|
|
124
|
+
const INLINE_MARKS = /`([^`]+)`|(?<!\*)(\*{1,3})(?![\s*])(.+?)(?<![\s*])\2(?!\*)|(?<!~)(~{1,2})(?![\s~])(.+?)(?<![\s~])\4(?!~)|(?<![\w_])(_{1,3})(?![\s_])(.+?)(?<![\s_])\6(?![\w_])/g;
|
|
125
|
+
/**
|
|
126
|
+
* The first line of a markdown description as plain text, for a row's one-line description:
|
|
127
|
+
* headings, emphasis, code marks and links' addresses are dropped; code keeps its punctuation.
|
|
128
|
+
*
|
|
129
|
+
* @param markdown - The description.
|
|
130
|
+
*/
|
|
131
|
+
function firstLineOf(markdown) {
|
|
132
|
+
// Bound delimiter matching to the part a row can show, skipping blank lines and indentation.
|
|
133
|
+
// A link whose address runs past that part still shows only its label.
|
|
134
|
+
const line = markdown?.match(/\S[^\n]{0,999}/)?.[0] ?? "";
|
|
135
|
+
return line
|
|
136
|
+
.replace(/^(#+|[-*>]|\d+\.)\s+/, "")
|
|
137
|
+
.replace(/`[^`]+`|!?\[([^\]]*)\]\([^)]*(?:\)|$)/g, (text, label) => label ?? text)
|
|
138
|
+
.replace(INLINE_MARKS, "$1$3$5$7")
|
|
139
|
+
.trim();
|
|
107
140
|
}
|
|
@@ -8,50 +8,13 @@ const LexicalComposerContext_1 = require("@lexical/react/LexicalComposerContext"
|
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const format_1 = require("./format");
|
|
10
10
|
const format_commands_1 = require("./format-commands");
|
|
11
|
+
const selection_bar_place_1 = require("./selection-bar-place");
|
|
11
12
|
/** A press on a bar's button keeps the editor's focus and selection, and a phone's keyboard. */
|
|
12
13
|
const keepFocus = (event) => event.preventDefault();
|
|
13
14
|
/** One button per format, on while the selection has it. */
|
|
14
15
|
function FormatButtons({ formats, state, onFormat, }) {
|
|
15
16
|
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: formats.map((format) => ((0, jsx_runtime_1.jsx)("button", { type: "button", className: `editor-format-button${state[format] ? " active" : ""}`, "aria-label": format_1.FORMAT_BUTTONS[format].label, "aria-pressed": state[format], title: format_1.FORMAT_BUTTONS[format].label, tabIndex: -1, onPointerDown: keepFocus, onMouseDown: keepFocus, onClick: () => onFormat(format), children: (0, jsx_runtime_1.jsx)("i", { className: `bi bi-${format_1.FORMAT_BUTTONS[format].icon}` }) }, format))) }));
|
|
16
17
|
}
|
|
17
|
-
/**
|
|
18
|
-
* The bar's height and the gap to the text, for placing it above the selection or below: 32 px
|
|
19
|
-
* buttons, 3 px padding and a 1 px border make 40, then 16 to the text (theme.css).
|
|
20
|
-
*/
|
|
21
|
-
const BAR_ROOM_PX = 56;
|
|
22
|
-
/**
|
|
23
|
-
* Where the bar over the selection goes, relative to the editor's container: above the selected
|
|
24
|
-
* text, centered on it, or below it when there's no room above in the window.
|
|
25
|
-
*/
|
|
26
|
-
function barPlace(editor) {
|
|
27
|
-
const root = editor.getRootElement();
|
|
28
|
-
const selection = root?.ownerDocument.getSelection();
|
|
29
|
-
// Blink's isCollapsed getter requests layout even for a cached caret. A text control can
|
|
30
|
-
// report "Range" with a collapsed document selection, so keep that check for ranges.
|
|
31
|
-
if (!root || selection?.type !== "Range" || selection.isCollapsed)
|
|
32
|
-
return undefined;
|
|
33
|
-
if (!root.contains(selection.anchorNode) || !root.contains(selection.focusNode))
|
|
34
|
-
return undefined;
|
|
35
|
-
if (!finePointer())
|
|
36
|
-
return undefined;
|
|
37
|
-
const container = root.closest(".editor-container");
|
|
38
|
-
if (!container)
|
|
39
|
-
return undefined;
|
|
40
|
-
const rect = selection.getRangeAt(0).getBoundingClientRect();
|
|
41
|
-
if (!rect.width && !rect.height)
|
|
42
|
-
return undefined;
|
|
43
|
-
const frame = container.getBoundingClientRect();
|
|
44
|
-
const below = rect.top < BAR_ROOM_PX;
|
|
45
|
-
return {
|
|
46
|
-
top: (below ? rect.bottom : rect.top) - frame.top,
|
|
47
|
-
left: rect.left - frame.left + rect.width / 2,
|
|
48
|
-
below,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/** A pointer that can select text precisely: a mouse or trackpad, not a finger. */
|
|
52
|
-
const finePointer = () => typeof window === "undefined" ||
|
|
53
|
-
!window.matchMedia ||
|
|
54
|
-
window.matchMedia("(pointer: fine)").matches;
|
|
55
18
|
/**
|
|
56
19
|
* The bar over selected text: bold, italic, strikethrough, link and code, then the app's own
|
|
57
20
|
* buttons. Only with a mouse or trackpad: on a touch screen the system's own menu takes the
|
|
@@ -62,12 +25,23 @@ function SelectionToolbarPlugin({ actions }) {
|
|
|
62
25
|
const [place, setPlace] = (0, react_1.useState)();
|
|
63
26
|
const [state, setState] = (0, react_1.useState)(format_1.NO_FORMAT);
|
|
64
27
|
const bar = (0, react_1.useRef)(null);
|
|
28
|
+
// Marks the editor, so the link popup keeps clear of the bar (barBottomUnder).
|
|
29
|
+
(0, react_1.useEffect)(() => {
|
|
30
|
+
const stop = editor.registerRootListener((root, previous) => {
|
|
31
|
+
previous?.removeAttribute(selection_bar_place_1.BAR_ATTRIBUTE);
|
|
32
|
+
root?.setAttribute(selection_bar_place_1.BAR_ATTRIBUTE, "");
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
stop();
|
|
36
|
+
editor.getRootElement()?.removeAttribute(selection_bar_place_1.BAR_ATTRIBUTE);
|
|
37
|
+
};
|
|
38
|
+
}, [editor]);
|
|
65
39
|
(0, react_1.useEffect)(() => {
|
|
66
40
|
// While a mouse drag selects text the bar waits, so it doesn't appear under the pointer and
|
|
67
41
|
// catch an upward drag; it shows when the button comes up.
|
|
68
42
|
let dragging = false;
|
|
69
43
|
const update = () => {
|
|
70
|
-
const next = dragging ? undefined : barPlace(editor);
|
|
44
|
+
const next = dragging ? undefined : (0, selection_bar_place_1.barPlace)(editor);
|
|
71
45
|
setPlace(next);
|
|
72
46
|
if (next)
|
|
73
47
|
setState(editor.getEditorState().read(format_commands_1.$formatState));
|
|
@@ -111,7 +85,8 @@ function SelectionToolbarPlugin({ actions }) {
|
|
|
111
85
|
const half = element.offsetWidth / 2;
|
|
112
86
|
const left = Math.min(Math.max(place.left, half), container.clientWidth - half);
|
|
113
87
|
element.style.left = `${left}px`;
|
|
114
|
-
|
|
88
|
+
editor.getRootElement()?.dispatchEvent(new Event(selection_bar_place_1.BAR_PLACED_EVENT));
|
|
89
|
+
}, [editor, place, place && actions]);
|
|
115
90
|
if (!place)
|
|
116
91
|
return null;
|
|
117
92
|
return ((0, jsx_runtime_1.jsxs)("div", { ref: bar, className: `editor-selection-bar${place.below ? " below" : ""}`, role: "toolbar", "aria-label": "Format selected text", style: { top: place.top, left: place.left }, onPointerDown: keepFocus, onMouseDown: keepFocus, children: [(0, jsx_runtime_1.jsx)(FormatButtons, { formats: format_1.INLINE_FORMATS, state: state, onFormat: (format) => (0, format_commands_1.applyFormat)(editor, format) }), actions?.length ? (0, jsx_runtime_1.jsx)("span", { className: "editor-format-divider" }) : null, actions?.map((action) => ((0, jsx_runtime_1.jsxs)("button", { type: "button", className: "editor-format-button editor-format-action", title: action.title, disabled: action.disabled, onClick: action.onClick, children: [(0, jsx_runtime_1.jsx)("i", { className: `bi ${action.iconClass}` }), action.label] }, action.label)))] }));
|
|
@@ -16,6 +16,7 @@ const react_1 = require("react");
|
|
|
16
16
|
const react_dom_1 = require("react-dom");
|
|
17
17
|
const host_shell_consumer_1 = require("../../host-shell/host-shell-consumer");
|
|
18
18
|
const link_schemes_1 = require("../../links/link-schemes");
|
|
19
|
+
const selection_bar_place_1 = require("./selection-bar-place");
|
|
19
20
|
/**
|
|
20
21
|
* Whether `url` is a link the editor keeps and opens: a web or mail link, another app's link
|
|
21
22
|
* (`obsidian://…`), or a `peers://` link. Script, data and file links (`javascript:`, `data:`,
|
|
@@ -116,8 +117,11 @@ function selectionRect(editor, selection) {
|
|
|
116
117
|
editor.getElementByKey(node.getTopLevelElementOrThrow().getKey());
|
|
117
118
|
return element?.getBoundingClientRect();
|
|
118
119
|
}
|
|
119
|
-
/** The popup for the link
|
|
120
|
-
function popupFor(editor,
|
|
120
|
+
/** The popup for the link containing the selection, positioned under its element. */
|
|
121
|
+
function popupFor(editor, selection) {
|
|
122
|
+
const link = $selectedLink(selection);
|
|
123
|
+
if (!link)
|
|
124
|
+
return undefined;
|
|
121
125
|
const rect = editor.getElementByKey(link.getKey())?.getBoundingClientRect();
|
|
122
126
|
if (!rect)
|
|
123
127
|
return undefined;
|
|
@@ -127,6 +131,8 @@ function popupFor(editor, link) {
|
|
|
127
131
|
auto: (0, link_1.$isAutoLinkNode)(link),
|
|
128
132
|
editing: false,
|
|
129
133
|
rect,
|
|
134
|
+
// Edits to a link's text refresh its popup at each keystroke. A caret has no format bar.
|
|
135
|
+
barBottom: selection.isCollapsed() ? undefined : (0, selection_bar_place_1.barBottomUnder)(editor, rect.bottom),
|
|
130
136
|
};
|
|
131
137
|
}
|
|
132
138
|
/**
|
|
@@ -161,8 +167,7 @@ function LinksPlugin() {
|
|
|
161
167
|
const selection = (0, lexical_1.$getSelection)();
|
|
162
168
|
if (!(0, lexical_1.$isRangeSelection)(selection))
|
|
163
169
|
return undefined;
|
|
164
|
-
|
|
165
|
-
return link ? popupFor(editor, link) : undefined;
|
|
170
|
+
return popupFor(editor, selection);
|
|
166
171
|
});
|
|
167
172
|
});
|
|
168
173
|
}, [editor]);
|
|
@@ -184,6 +189,7 @@ function LinksPlugin() {
|
|
|
184
189
|
auto: link ? (0, link_1.$isAutoLinkNode)(link) : false,
|
|
185
190
|
editing: true,
|
|
186
191
|
rect,
|
|
192
|
+
barBottom: (0, selection_bar_place_1.barBottomUnder)(editor, rect.bottom),
|
|
187
193
|
});
|
|
188
194
|
});
|
|
189
195
|
}, [editor]);
|
|
@@ -225,20 +231,42 @@ function LinksPlugin() {
|
|
|
225
231
|
return true;
|
|
226
232
|
}, lexical_1.COMMAND_PRIORITY_LOW));
|
|
227
233
|
}, [editor, refresh, openEditor]);
|
|
228
|
-
// Keep the popup under its link while the page or the editor scrolls
|
|
234
|
+
// Keep the popup under its link while the page or the editor scrolls, and clear of the format
|
|
235
|
+
// bar: after the bar is laid out (it can wrap to two rows), and when the editor's pane changes
|
|
236
|
+
// size (a side panel's divider), which can wrap it too.
|
|
229
237
|
const showing = !!popup;
|
|
230
|
-
|
|
238
|
+
// The bar can first appear in the same commit as the popup after a keyboard selection.
|
|
239
|
+
// Listen during layout, before the toolbar plugin announces its placement.
|
|
240
|
+
(0, react_1.useLayoutEffect)(() => {
|
|
231
241
|
if (!showing)
|
|
232
242
|
return;
|
|
233
243
|
const follow = () => setPopup((current) => {
|
|
234
|
-
|
|
235
|
-
|
|
244
|
+
if (!current)
|
|
245
|
+
return current;
|
|
246
|
+
// A new link isn't in the text yet: its popup stays where it opened, clear of the bar.
|
|
247
|
+
if (!current.linkKey) {
|
|
248
|
+
const barBottom = (0, selection_bar_place_1.barBottomUnder)(editor, current.rect.bottom);
|
|
249
|
+
return barBottom === current.barBottom ? current : { ...current, barBottom };
|
|
250
|
+
}
|
|
251
|
+
const element = editor.getElementByKey(current.linkKey);
|
|
252
|
+
if (!element)
|
|
253
|
+
return current;
|
|
254
|
+
const rect = element.getBoundingClientRect();
|
|
255
|
+
return { ...current, rect, barBottom: (0, selection_bar_place_1.barBottomUnder)(editor, rect.bottom) };
|
|
236
256
|
});
|
|
257
|
+
const root = editor.getRootElement();
|
|
258
|
+
const pane = root?.closest(".editor-container");
|
|
259
|
+
const resized = pane && typeof ResizeObserver !== "undefined" ? new ResizeObserver(follow) : null;
|
|
260
|
+
if (pane)
|
|
261
|
+
resized?.observe(pane);
|
|
237
262
|
window.addEventListener("scroll", follow, true);
|
|
238
263
|
window.addEventListener("resize", follow);
|
|
264
|
+
root?.addEventListener(selection_bar_place_1.BAR_PLACED_EVENT, follow);
|
|
239
265
|
return () => {
|
|
266
|
+
resized?.disconnect();
|
|
240
267
|
window.removeEventListener("scroll", follow, true);
|
|
241
268
|
window.removeEventListener("resize", follow);
|
|
269
|
+
root?.removeEventListener(selection_bar_place_1.BAR_PLACED_EVENT, follow);
|
|
242
270
|
};
|
|
243
271
|
}, [editor, showing]);
|
|
244
272
|
const close = (0, react_1.useCallback)((refocus) => {
|
|
@@ -334,7 +362,8 @@ function LinkPopup(props) {
|
|
|
334
362
|
setInvalid(true);
|
|
335
363
|
};
|
|
336
364
|
const left = Math.max(8, Math.min(popup.rect.left, window.innerWidth - POPUP_WIDTH - 8));
|
|
337
|
-
const
|
|
365
|
+
const top = Math.max(popup.rect.bottom, popup.barBottom ?? popup.rect.bottom) + 4;
|
|
366
|
+
const style = { top, left, maxWidth: POPUP_WIDTH };
|
|
338
367
|
// Buttons keep the editor's focus and selection.
|
|
339
368
|
const keepFocus = (event) => event.preventDefault();
|
|
340
369
|
const follow = (event) => {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { LexicalEditor } from "lexical";
|
|
2
|
+
/** On an editor's root while its selected text gets the format bar (`SelectionToolbarPlugin`). */
|
|
3
|
+
export declare const BAR_ATTRIBUTE = "data-selection-bar";
|
|
4
|
+
/**
|
|
5
|
+
* Fired on the editor's root once the format bar is laid out over a new selection. In a narrow
|
|
6
|
+
* editor the bar can wrap to two rows, taller than planned, so an open link popup moves under it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BAR_PLACED_EVENT = "peers-selection-bar-placed";
|
|
9
|
+
/**
|
|
10
|
+
* Where the bar over the selection goes, relative to the editor's container: above the selected
|
|
11
|
+
* text, centered on it, or below it when there's no room above in the window.
|
|
12
|
+
*/
|
|
13
|
+
export declare function barPlace(editor: LexicalEditor): {
|
|
14
|
+
top: number;
|
|
15
|
+
left: number;
|
|
16
|
+
below: boolean;
|
|
17
|
+
} | undefined;
|
|
18
|
+
/** A pointer that can select text precisely: a mouse or trackpad, not a finger. */
|
|
19
|
+
export declare const finePointer: () => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* The bottom of the format bar, in the window's coordinates, while it shows below the selected
|
|
22
|
+
* text (there's no room above it); undefined while it's above, or the editor has no bar. The link
|
|
23
|
+
* popup opens under it then, rather than over it.
|
|
24
|
+
*
|
|
25
|
+
* @param editor - The editor.
|
|
26
|
+
*/
|
|
27
|
+
export declare function selectionBarBottom(editor: LexicalEditor): number | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Where an open link popup starts so it doesn't cover the format bar: the bottom of the bar on
|
|
30
|
+
* screen when the bar sits where the popup would go under the link (below the text, or above it
|
|
31
|
+
* with the text scrolled up under it), or the bar's planned room while a drag still selects (no
|
|
32
|
+
* bar shows yet). Undefined when the editor has no bar, or the bar is out of the popup's way.
|
|
33
|
+
*
|
|
34
|
+
* @param editor - The editor.
|
|
35
|
+
* @param linkBottom - The bottom of the link the popup is for, in the window's coordinates.
|
|
36
|
+
*/
|
|
37
|
+
export declare function barBottomUnder(editor: LexicalEditor, linkBottom: number): number | undefined;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.finePointer = exports.BAR_PLACED_EVENT = exports.BAR_ATTRIBUTE = void 0;
|
|
4
|
+
exports.barPlace = barPlace;
|
|
5
|
+
exports.selectionBarBottom = selectionBarBottom;
|
|
6
|
+
exports.barBottomUnder = barBottomUnder;
|
|
7
|
+
/** On an editor's root while its selected text gets the format bar (`SelectionToolbarPlugin`). */
|
|
8
|
+
exports.BAR_ATTRIBUTE = "data-selection-bar";
|
|
9
|
+
/**
|
|
10
|
+
* Fired on the editor's root once the format bar is laid out over a new selection. In a narrow
|
|
11
|
+
* editor the bar can wrap to two rows, taller than planned, so an open link popup moves under it.
|
|
12
|
+
*/
|
|
13
|
+
exports.BAR_PLACED_EVENT = "peers-selection-bar-placed";
|
|
14
|
+
/**
|
|
15
|
+
* The bar's height and the gap to the text, for placing it above the selection or below: 32 px
|
|
16
|
+
* buttons, 3 px padding and a 1 px border make 40, then 16 to the text (theme.css).
|
|
17
|
+
*/
|
|
18
|
+
const BAR_ROOM_PX = 56;
|
|
19
|
+
/**
|
|
20
|
+
* Where the bar over the selection goes, relative to the editor's container: above the selected
|
|
21
|
+
* text, centered on it, or below it when there's no room above in the window.
|
|
22
|
+
*/
|
|
23
|
+
function barPlace(editor) {
|
|
24
|
+
const root = editor.getRootElement();
|
|
25
|
+
const selection = root?.ownerDocument.getSelection();
|
|
26
|
+
// Blink's isCollapsed getter requests layout even for a cached caret. A text control can
|
|
27
|
+
// report "Range" with a collapsed document selection, so keep that check for ranges.
|
|
28
|
+
if (!root || selection?.type !== "Range" || selection.isCollapsed)
|
|
29
|
+
return undefined;
|
|
30
|
+
if (!root.contains(selection.anchorNode) || !root.contains(selection.focusNode))
|
|
31
|
+
return undefined;
|
|
32
|
+
if (!(0, exports.finePointer)())
|
|
33
|
+
return undefined;
|
|
34
|
+
const container = root.closest(".editor-container");
|
|
35
|
+
if (!container)
|
|
36
|
+
return undefined;
|
|
37
|
+
const rect = selection.getRangeAt(0).getBoundingClientRect();
|
|
38
|
+
if (!rect.width && !rect.height)
|
|
39
|
+
return undefined;
|
|
40
|
+
const frame = container.getBoundingClientRect();
|
|
41
|
+
const below = rect.top < BAR_ROOM_PX;
|
|
42
|
+
return {
|
|
43
|
+
top: (below ? rect.bottom : rect.top) - frame.top,
|
|
44
|
+
left: rect.left - frame.left + rect.width / 2,
|
|
45
|
+
below,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** A pointer that can select text precisely: a mouse or trackpad, not a finger. */
|
|
49
|
+
const finePointer = () => typeof window === "undefined" ||
|
|
50
|
+
!window.matchMedia ||
|
|
51
|
+
window.matchMedia("(pointer: fine)").matches;
|
|
52
|
+
exports.finePointer = finePointer;
|
|
53
|
+
/**
|
|
54
|
+
* The bottom of the format bar, in the window's coordinates, while it shows below the selected
|
|
55
|
+
* text (there's no room above it); undefined while it's above, or the editor has no bar. The link
|
|
56
|
+
* popup opens under it then, rather than over it.
|
|
57
|
+
*
|
|
58
|
+
* @param editor - The editor.
|
|
59
|
+
*/
|
|
60
|
+
function selectionBarBottom(editor) {
|
|
61
|
+
const root = editor.getRootElement();
|
|
62
|
+
if (!root?.hasAttribute(exports.BAR_ATTRIBUTE))
|
|
63
|
+
return undefined;
|
|
64
|
+
const place = barPlace(editor);
|
|
65
|
+
if (!place?.below)
|
|
66
|
+
return undefined;
|
|
67
|
+
const container = root.closest(".editor-container");
|
|
68
|
+
if (!container)
|
|
69
|
+
return undefined;
|
|
70
|
+
// The bar's room below the text, or more when a narrow editor wraps its buttons.
|
|
71
|
+
const planned = container.getBoundingClientRect().top + place.top + BAR_ROOM_PX;
|
|
72
|
+
const shown = container.querySelector(":scope > .editor-selection-bar.below");
|
|
73
|
+
return Math.max(planned, shown?.getBoundingClientRect().bottom ?? planned);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The room the link popup takes under its link, in rem: its row of buttons and the gap above
|
|
77
|
+
* it, with a little to spare (52 px at a 16 px root). The popup is sized in rem, so the room
|
|
78
|
+
* grows with the text size.
|
|
79
|
+
*/
|
|
80
|
+
const POPUP_ROOM_REM = 3.25;
|
|
81
|
+
/**
|
|
82
|
+
* Where an open link popup starts so it doesn't cover the format bar: the bottom of the bar on
|
|
83
|
+
* screen when the bar sits where the popup would go under the link (below the text, or above it
|
|
84
|
+
* with the text scrolled up under it), or the bar's planned room while a drag still selects (no
|
|
85
|
+
* bar shows yet). Undefined when the editor has no bar, or the bar is out of the popup's way.
|
|
86
|
+
*
|
|
87
|
+
* @param editor - The editor.
|
|
88
|
+
* @param linkBottom - The bottom of the link the popup is for, in the window's coordinates.
|
|
89
|
+
*/
|
|
90
|
+
function barBottomUnder(editor, linkBottom) {
|
|
91
|
+
const root = editor.getRootElement();
|
|
92
|
+
if (!root?.hasAttribute(exports.BAR_ATTRIBUTE))
|
|
93
|
+
return undefined;
|
|
94
|
+
const shown = root.closest(".editor-container")?.querySelector(":scope > .editor-selection-bar");
|
|
95
|
+
if (!shown)
|
|
96
|
+
return selectionBarBottom(editor);
|
|
97
|
+
const bar = shown.getBoundingClientRect();
|
|
98
|
+
// Scrolling often leaves the bar above the link or across its bottom edge. The rectangles
|
|
99
|
+
// alone decide both cases. Only a gap below the link needs the popup's scaled height.
|
|
100
|
+
if (bar.bottom <= linkBottom)
|
|
101
|
+
return undefined;
|
|
102
|
+
if (bar.top <= linkBottom)
|
|
103
|
+
return bar.bottom;
|
|
104
|
+
// The popup is drawn in the window's document (a portal on its body).
|
|
105
|
+
const rem = Number.parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
|
|
106
|
+
return bar.top < linkBottom + POPUP_ROOM_REM * rem ? bar.bottom : undefined;
|
|
107
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/** One command in a {@link MenuButton}'s menu. */
|
|
3
|
+
export interface MenuItem {
|
|
4
|
+
/** What it says. */
|
|
5
|
+
label: string;
|
|
6
|
+
/** A Bootstrap icon class shown before the label, such as `"bi-folder2-open"`. */
|
|
7
|
+
icon?: string;
|
|
8
|
+
/** What it does. The menu closes first. */
|
|
9
|
+
onSelect: () => void;
|
|
10
|
+
/** Shown in red, for a command that removes something. */
|
|
11
|
+
danger?: boolean;
|
|
12
|
+
/** Shown greyed out, and skipped by the arrow keys. */
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A button that opens a menu of commands: a screen's or a row's less common actions, behind ⋯
|
|
17
|
+
* by default. The menu floats above the page, opens below the button (lined up with its right
|
|
18
|
+
* edge unless `align="start"`), and takes the keyboard while open: Up and Down move between
|
|
19
|
+
* commands, Enter picks, Escape or a click outside closes it and focus goes back to the button.
|
|
20
|
+
*
|
|
21
|
+
* @param props.items - The commands, in order; `"divider"` draws a line between groups of them.
|
|
22
|
+
* @param props.label - The button's name for assistive technology, and its tooltip ("More").
|
|
23
|
+
* @param props.children - The button's content; ⋯ when left out.
|
|
24
|
+
* @param props.buttonClassName - The button's classes; a small outlined button by default.
|
|
25
|
+
* @param props.align - Which edge of the button the menu lines up with: `"end"` (its right edge,
|
|
26
|
+
* the default) or `"start"`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function MenuButton(props: {
|
|
29
|
+
items: readonly (MenuItem | "divider")[];
|
|
30
|
+
label?: string;
|
|
31
|
+
children?: React.ReactNode;
|
|
32
|
+
buttonClassName?: string;
|
|
33
|
+
align?: "start" | "end";
|
|
34
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MenuButton = MenuButton;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const hooks_1 = require("../hooks");
|
|
7
|
+
const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
|
|
8
|
+
const popover_surface_1 = require("../ui-contracts/popover-surface");
|
|
9
|
+
const menu_surface_1 = require("./menu-surface");
|
|
10
|
+
/** Focuses the next (`1`) or previous (`-1`) enabled command in a menu, wrapping at the ends. */
|
|
11
|
+
function moveFocus(menu, step) {
|
|
12
|
+
const items = [...menu.querySelectorAll("[role=menuitem]:not(:disabled)")];
|
|
13
|
+
if (!items.length)
|
|
14
|
+
return;
|
|
15
|
+
const at = items.indexOf(document.activeElement);
|
|
16
|
+
items[(at + step + items.length) % items.length].focus();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A button that opens a menu of commands: a screen's or a row's less common actions, behind ⋯
|
|
20
|
+
* by default. The menu floats above the page, opens below the button (lined up with its right
|
|
21
|
+
* edge unless `align="start"`), and takes the keyboard while open: Up and Down move between
|
|
22
|
+
* commands, Enter picks, Escape or a click outside closes it and focus goes back to the button.
|
|
23
|
+
*
|
|
24
|
+
* @param props.items - The commands, in order; `"divider"` draws a line between groups of them.
|
|
25
|
+
* @param props.label - The button's name for assistive technology, and its tooltip ("More").
|
|
26
|
+
* @param props.children - The button's content; ⋯ when left out.
|
|
27
|
+
* @param props.buttonClassName - The button's classes; a small outlined button by default.
|
|
28
|
+
* @param props.align - Which edge of the button the menu lines up with: `"end"` (its right edge,
|
|
29
|
+
* the default) or `"start"`.
|
|
30
|
+
*/
|
|
31
|
+
function MenuButton(props) {
|
|
32
|
+
const [open, setOpen] = (0, react_1.useState)(false);
|
|
33
|
+
const button = (0, react_1.useRef)(null);
|
|
34
|
+
const menu = (0, react_1.useRef)(null);
|
|
35
|
+
const [mode] = (0, hooks_1.useObservable)(color_mode_dropdown_1.colorMode);
|
|
36
|
+
const label = props.label ?? "More";
|
|
37
|
+
// The open menu takes its keys from the window, before anything else sees them: Bootstrap's
|
|
38
|
+
// JavaScript (the desktop app and the PWA load it) handles keys in any `.dropdown-menu` from
|
|
39
|
+
// the document, and throws for a menu without a Bootstrap toggle.
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
if (!open)
|
|
42
|
+
return;
|
|
43
|
+
const onKeyDown = (event) => {
|
|
44
|
+
const box = menu.current;
|
|
45
|
+
if (!box || !(event.target instanceof Node) || !box.contains(event.target))
|
|
46
|
+
return;
|
|
47
|
+
if (event.key === "Escape") {
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
setOpen(false);
|
|
50
|
+
}
|
|
51
|
+
else if (event.key === "ArrowDown" || event.key === "ArrowUp") {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
event.stopPropagation();
|
|
54
|
+
moveFocus(box, event.key === "ArrowDown" ? 1 : -1);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
window.addEventListener("keydown", onKeyDown, true);
|
|
58
|
+
return () => window.removeEventListener("keydown", onKeyDown, true);
|
|
59
|
+
}, [open]);
|
|
60
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("button", { ref: button, type: "button", className: props.buttonClassName ?? "btn btn-outline-secondary btn-sm", title: label, "aria-label": label, "aria-haspopup": "menu", "aria-expanded": open, onClick: () => setOpen((value) => !value), children: props.children ?? (0, jsx_runtime_1.jsx)("i", { className: "bi-three-dots", "aria-hidden": "true" }) }), open && ((0, jsx_runtime_1.jsx)(popover_surface_1.PopoverSurface, { anchor: button, label: label, align: props.align ?? "end", onClose: () => setOpen(false), children: (0, jsx_runtime_1.jsx)("div", { ref: menu, role: "menu", "aria-label": label, className: `${(0, menu_surface_1.menuSurfaceClassName)(mode)} position-static shadow`, children: props.items.map((item, index) => item === "divider" ? (
|
|
61
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: dividers have nothing else to key by
|
|
62
|
+
(0, jsx_runtime_1.jsx)("hr", { className: "dropdown-divider" }, `divider-${index}`)) : ((0, jsx_runtime_1.jsxs)("button", { type: "button", role: "menuitem", className: `dropdown-item${item.danger ? " text-danger" : ""}`, disabled: item.disabled, onClick: () => {
|
|
63
|
+
setOpen(false);
|
|
64
|
+
item.onSelect();
|
|
65
|
+
}, children: [item.icon && (0, jsx_runtime_1.jsx)("i", { className: `${item.icon} me-2`, "aria-hidden": "true" }), item.label] }, item.label))) }) }))] }));
|
|
66
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The top of a screen: its icon and name, a line saying what's in it, and its actions as
|
|
4
|
+
* buttons on the right (they wrap below on a narrow screen). Identity's screens and the list
|
|
5
|
+
* screens (Packages, Tools, Types, Variables) use it, so a screen says what it is the same way
|
|
6
|
+
* everywhere.
|
|
7
|
+
*
|
|
8
|
+
* @param props.icon - A Bootstrap icon class, such as `"bi-box-fill"`.
|
|
9
|
+
* @param props.title - The screen's name.
|
|
10
|
+
* @param props.subtitle - One line on what the screen holds.
|
|
11
|
+
* @param props.actions - Buttons for the screen's actions, such as "New package".
|
|
12
|
+
* @param props.back - A link back to the screen this one was opened from ({@link BackLink}).
|
|
13
|
+
* @param props.className - More classes for the header, such as a margin.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ScreenHeader(props: {
|
|
16
|
+
icon?: string;
|
|
17
|
+
title: React.ReactNode;
|
|
18
|
+
subtitle?: React.ReactNode;
|
|
19
|
+
actions?: React.ReactNode;
|
|
20
|
+
back?: {
|
|
21
|
+
href: string;
|
|
22
|
+
label: string;
|
|
23
|
+
};
|
|
24
|
+
className?: string;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* A small "‹ Packages" link above a detail screen's header, back to the list it was opened from.
|
|
28
|
+
*
|
|
29
|
+
* @param props.href - The list's address, such as `"#packages"`.
|
|
30
|
+
* @param props.label - The list's name.
|
|
31
|
+
*/
|
|
32
|
+
export declare function BackLink(props: {
|
|
33
|
+
href: string;
|
|
34
|
+
label: string;
|
|
35
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScreenHeader = ScreenHeader;
|
|
4
|
+
exports.BackLink = BackLink;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
/**
|
|
7
|
+
* The top of a screen: its icon and name, a line saying what's in it, and its actions as
|
|
8
|
+
* buttons on the right (they wrap below on a narrow screen). Identity's screens and the list
|
|
9
|
+
* screens (Packages, Tools, Types, Variables) use it, so a screen says what it is the same way
|
|
10
|
+
* everywhere.
|
|
11
|
+
*
|
|
12
|
+
* @param props.icon - A Bootstrap icon class, such as `"bi-box-fill"`.
|
|
13
|
+
* @param props.title - The screen's name.
|
|
14
|
+
* @param props.subtitle - One line on what the screen holds.
|
|
15
|
+
* @param props.actions - Buttons for the screen's actions, such as "New package".
|
|
16
|
+
* @param props.back - A link back to the screen this one was opened from ({@link BackLink}).
|
|
17
|
+
* @param props.className - More classes for the header, such as a margin.
|
|
18
|
+
*/
|
|
19
|
+
function ScreenHeader(props) {
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)("header", { className: `peers-screen-header mb-3 ${props.className ?? ""}`, children: [props.back && (0, jsx_runtime_1.jsx)(BackLink, { href: props.back.href, label: props.back.label }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap align-items-start gap-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex-grow-1", style: { minWidth: 0 }, children: [(0, jsx_runtime_1.jsxs)("h4", { className: "mb-1 text-truncate", children: [props.icon && (0, jsx_runtime_1.jsx)("i", { className: `${props.icon} me-2`, "aria-hidden": "true" }), props.title] }), props.subtitle && (0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary", children: props.subtitle })] }), props.actions && (0, jsx_runtime_1.jsx)("div", { className: "d-flex flex-wrap gap-2", children: props.actions })] })] }));
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A small "‹ Packages" link above a detail screen's header, back to the list it was opened from.
|
|
24
|
+
*
|
|
25
|
+
* @param props.href - The list's address, such as `"#packages"`.
|
|
26
|
+
* @param props.label - The list's name.
|
|
27
|
+
*/
|
|
28
|
+
function BackLink(props) {
|
|
29
|
+
return ((0, jsx_runtime_1.jsxs)("a", { href: props.href, className: "peers-back-link small", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi-chevron-left", "aria-hidden": "true" }), props.label] }));
|
|
30
|
+
}
|