@peers-app/peers-ui 0.33.14 → 0.33.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/components/markdown-editor/editor.d.ts +10 -4
- package/dist/components/markdown-editor/editor.js +7 -5
- package/dist/components/markdown-editor/markdown-plugin.d.ts +24 -6
- package/dist/components/markdown-editor/markdown-plugin.js +33 -16
- package/dist/tabs-layout/tab-color.d.ts +19 -0
- package/dist/tabs-layout/tab-color.js +38 -0
- package/dist/tabs-layout/tabs-layout.js +11 -3
- package/dist/theme.css +5 -0
- package/package.json +3 -3
|
@@ -51,11 +51,17 @@ export interface IMarkdownEditorProps {
|
|
|
51
51
|
* group as the document's, and mentions resolve wherever they were last found.
|
|
52
52
|
*/
|
|
53
53
|
groupId?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether a line starting with `#` is a heading. True if omitted, for documents such as task
|
|
56
|
+
* bodies and notes. Pass false for short inline text such as messages, where `#` stays text.
|
|
57
|
+
*/
|
|
58
|
+
headings?: boolean;
|
|
54
59
|
}
|
|
55
60
|
/**
|
|
56
|
-
* A rich-text editor whose value is markdown:
|
|
57
|
-
* finds people and records in every group, `@` people, a
|
|
58
|
-
* as `#`, that source's records, and a pasted id becomes
|
|
59
|
-
* chip with the record's live title). Edits are written
|
|
61
|
+
* A rich-text editor whose value is markdown: headings (unless `headings` is false), lists and
|
|
62
|
+
* checklists, links, and mentions (`<` finds people and records in every group, `@` people, a
|
|
63
|
+
* trigger a mention source declares, such as `#`, that source's records, and a pasted id becomes
|
|
64
|
+
* its record's chip; a mention shows as a chip with the record's live title). Edits are written
|
|
65
|
+
* back to `value`.
|
|
60
66
|
*/
|
|
61
67
|
export declare function MarkdownEditor(props: IMarkdownEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -87,10 +87,11 @@ const editorConfig = {
|
|
|
87
87
|
theme: theme_1.default,
|
|
88
88
|
};
|
|
89
89
|
/**
|
|
90
|
-
* A rich-text editor whose value is markdown:
|
|
91
|
-
* finds people and records in every group, `@` people, a
|
|
92
|
-
* as `#`, that source's records, and a pasted id becomes
|
|
93
|
-
* chip with the record's live title). Edits are written
|
|
90
|
+
* A rich-text editor whose value is markdown: headings (unless `headings` is false), lists and
|
|
91
|
+
* checklists, links, and mentions (`<` finds people and records in every group, `@` people, a
|
|
92
|
+
* trigger a mention source declares, such as `#`, that source's records, and a pasted id becomes
|
|
93
|
+
* its record's chip; a mention shows as a chip with the record's live title). Edits are written
|
|
94
|
+
* back to `value`.
|
|
94
95
|
*/
|
|
95
96
|
function MarkdownEditor(props) {
|
|
96
97
|
const { effects } = props;
|
|
@@ -118,7 +119,8 @@ function MarkdownEditor(props) {
|
|
|
118
119
|
}
|
|
119
120
|
};
|
|
120
121
|
}
|
|
121
|
-
|
|
122
|
+
const transformers = props.headings === false ? markdown_plugin_1.inlineMarkdownTransformers : markdown_plugin_1.documentMarkdownTransformers;
|
|
123
|
+
return ((0, jsx_runtime_1.jsx)(mention_chip_1.MentionGroupContext.Provider, { value: props.groupId, children: (0, jsx_runtime_1.jsx)(LexicalComposer_1.LexicalComposer, { initialConfig: { ...editorConfig }, children: (0, jsx_runtime_1.jsxs)("div", { className: "editor-container", children: [props.hideToolbar ? null : (0, jsx_runtime_1.jsx)(toolbar_1.ToolbarPlugin, { topRightControls: props.topRightControls }), (0, jsx_runtime_1.jsxs)("div", { className: "editor-inner", ref: editorRef, style: { maxHeight: props.maxHeight, overflowY: "auto" }, children: [(0, jsx_runtime_1.jsx)(LexicalRichTextPlugin_1.RichTextPlugin, { contentEditable: (0, jsx_runtime_1.jsx)(LexicalContentEditable_1.ContentEditable, { className: "editor-input p-2" }), placeholder: null, ErrorBoundary: LexicalErrorBoundary_1.LexicalErrorBoundary }), (0, jsx_runtime_1.jsx)(LexicalHistoryPlugin_1.HistoryPlugin, {}), props.autoFocus && (0, jsx_runtime_1.jsx)(LexicalAutoFocusPlugin_1.AutoFocusPlugin, { defaultSelection: "rootEnd" }), (0, jsx_runtime_1.jsx)(LexicalListPlugin_1.ListPlugin, {}), props.mentions !== false && ((0, jsx_runtime_1.jsx)(mentions_plugin_1.MentionsPlugin, { mentionsOpen: mentionsOpen, groupId: props.groupId })), (0, jsx_runtime_1.jsx)(autolink_plugin_1.LexicalAutoLinkPlugin, {}), (0, jsx_runtime_1.jsx)(markdown_plugin_1.MarkdownPlugin, { markdownObs: props.value, transformers: transformers }), (0, jsx_runtime_1.jsx)(LexicalMarkdownShortcutPlugin_1.MarkdownShortcutPlugin, { transformers: transformers }), (0, jsx_runtime_1.jsx)(LexicalCheckListPlugin_1.CheckListPlugin, {}), (0, jsx_runtime_1.jsx)(LexicalTabIndentationPlugin_1.TabIndentationPlugin, {}), (0, jsx_runtime_1.jsx)(move_line_plugin_1.MoveLineWithAltArrowsPlugin, { mentionsOpen: mentionsOpen }), (0, jsx_runtime_1.jsx)(select_line_boundary_plugin_1.SelectToLineBoundaryPlugin, {}), (0, jsx_runtime_1.jsx)(OnKeyDownPlugin, { effects: props.effects, mentionsOpen: mentionsOpen }), effects ? (0, jsx_runtime_1.jsx)(selection_effects_plugin_1.SelectionEffectsPlugin, { effects: effects }) : null] })] }) }) }));
|
|
122
124
|
}
|
|
123
125
|
const OnKeyDownPlugin = (props) => {
|
|
124
126
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
@@ -1,15 +1,33 @@
|
|
|
1
|
+
import { type Transformer } from "@lexical/markdown";
|
|
1
2
|
import { type Observable } from "@peers-app/peers-sdk";
|
|
2
3
|
/**
|
|
3
|
-
*
|
|
4
|
-
* otherwise take `peers://` links) and checklists
|
|
4
|
+
* Markdown for documents (task bodies, notes): mentions (ahead of Lexical's link transformer,
|
|
5
|
+
* which would otherwise take `peers://` links) and checklists (ahead of Lexical's lists, or
|
|
6
|
+
* `- [ ]` would read as a plain list item), then Lexical's own, headings included.
|
|
5
7
|
*/
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
+
export declare const documentMarkdownTransformers: Transformer[];
|
|
9
|
+
/**
|
|
10
|
+
* The transformers without the heading one. It's recognized by its node's type, `"heading"`, not
|
|
11
|
+
* the class's name: the app ships Lexical's minified build, which renames classes, so the name
|
|
12
|
+
* check this replaced never matched and headings stayed on.
|
|
13
|
+
*
|
|
14
|
+
* @param transformers - The transformers to filter.
|
|
15
|
+
*/
|
|
16
|
+
export declare function withoutHeadings(transformers: readonly Transformer[]): Transformer[];
|
|
17
|
+
/**
|
|
18
|
+
* Markdown for short inline text such as messages, where a line starting with `#` stays text: the
|
|
19
|
+
* document transformers without headings.
|
|
20
|
+
*/
|
|
21
|
+
export declare const inlineMarkdownTransformers: Transformer[];
|
|
22
|
+
/** {@link MarkdownPlugin}'s props. */
|
|
23
|
+
export interface IMarkdownPluginProps {
|
|
24
|
+
/** The markdown the editor shows, written back as the user edits. */
|
|
8
25
|
markdownObs: Observable<string>;
|
|
26
|
+
/** How markdown is read and written. {@link documentMarkdownTransformers} if omitted. */
|
|
27
|
+
transformers?: Transformer[];
|
|
9
28
|
}
|
|
10
29
|
/**
|
|
11
30
|
* Keeps the editor and a markdown observable in step: the observable's value is loaded into the
|
|
12
31
|
* editor (without moving the caret or taking focus), and edits are written back as markdown.
|
|
13
32
|
*/
|
|
14
|
-
export declare function MarkdownPlugin(props:
|
|
15
|
-
export {};
|
|
33
|
+
export declare function MarkdownPlugin(props: IMarkdownPluginProps): null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.inlineMarkdownTransformers = exports.documentMarkdownTransformers = void 0;
|
|
4
|
+
exports.withoutHeadings = withoutHeadings;
|
|
4
5
|
exports.MarkdownPlugin = MarkdownPlugin;
|
|
5
6
|
const list_1 = require("@lexical/list");
|
|
6
7
|
const markdown_1 = require("@lexical/markdown");
|
|
@@ -10,6 +11,7 @@ const react_1 = require("react");
|
|
|
10
11
|
const mention_node_1 = require("./mention-node");
|
|
11
12
|
// Amount of spaces that define indentation level
|
|
12
13
|
const LIST_INDENT_SIZE = 4;
|
|
14
|
+
/** A list item's indent level, from the tabs and spaces before its marker. */
|
|
13
15
|
function getIndent(whitespaces) {
|
|
14
16
|
const tabs = whitespaces.match(/\t/g);
|
|
15
17
|
const spaces = whitespaces.match(/ /g);
|
|
@@ -61,6 +63,7 @@ const listReplace = (listType) => {
|
|
|
61
63
|
}
|
|
62
64
|
};
|
|
63
65
|
};
|
|
66
|
+
/** A list (and the lists nested in it) as markdown, with `- [ ]`/`- [x]` for checklist items. */
|
|
64
67
|
const listExport = (listNode, exportChildren, depth) => {
|
|
65
68
|
const output = [];
|
|
66
69
|
const children = listNode.getChildren();
|
|
@@ -87,6 +90,7 @@ const listExport = (listNode, exportChildren, depth) => {
|
|
|
87
90
|
}
|
|
88
91
|
return output.join("\n");
|
|
89
92
|
};
|
|
93
|
+
/** `- [ ]` and `- [x]` lines as checklist items, both ways. */
|
|
90
94
|
const CHECK_LIST_TRANSFORMER = {
|
|
91
95
|
dependencies: [list_1.ListNode, list_1.ListItemNode],
|
|
92
96
|
export: (node, exportChildren) => {
|
|
@@ -131,22 +135,34 @@ const OLD_MENTION_TRANSFORMER = {
|
|
|
131
135
|
},
|
|
132
136
|
};
|
|
133
137
|
/**
|
|
134
|
-
*
|
|
135
|
-
* otherwise take `peers://` links) and checklists
|
|
138
|
+
* Markdown for documents (task bodies, notes): mentions (ahead of Lexical's link transformer,
|
|
139
|
+
* which would otherwise take `peers://` links) and checklists (ahead of Lexical's lists, or
|
|
140
|
+
* `- [ ]` would read as a plain list item), then Lexical's own, headings included.
|
|
136
141
|
*/
|
|
137
|
-
exports.
|
|
142
|
+
exports.documentMarkdownTransformers = [
|
|
138
143
|
MENTION_TRANSFORMER,
|
|
139
144
|
OLD_MENTION_TRANSFORMER,
|
|
140
|
-
CHECK_LIST_TRANSFORMER,
|
|
141
|
-
...markdown_1.TRANSFORMERS
|
|
142
|
-
const t = transformer;
|
|
143
|
-
// disable headings for this markdown since these are inline messages
|
|
144
|
-
if (t.dependencies?.[0]?.name === "HeadingNode") {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
return true;
|
|
148
|
-
}),
|
|
145
|
+
CHECK_LIST_TRANSFORMER,
|
|
146
|
+
...markdown_1.TRANSFORMERS,
|
|
149
147
|
];
|
|
148
|
+
/**
|
|
149
|
+
* The transformers without the heading one. It's recognized by its node's type, `"heading"`, not
|
|
150
|
+
* the class's name: the app ships Lexical's minified build, which renames classes, so the name
|
|
151
|
+
* check this replaced never matched and headings stayed on.
|
|
152
|
+
*
|
|
153
|
+
* @param transformers - The transformers to filter.
|
|
154
|
+
*/
|
|
155
|
+
function withoutHeadings(transformers) {
|
|
156
|
+
return transformers.filter((transformer) => {
|
|
157
|
+
const nodes = "dependencies" in transformer ? transformer.dependencies : [];
|
|
158
|
+
return !nodes.some((node) => node.getType() === "heading");
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Markdown for short inline text such as messages, where a line starting with `#` stays text: the
|
|
163
|
+
* document transformers without headings.
|
|
164
|
+
*/
|
|
165
|
+
exports.inlineMarkdownTransformers = withoutHeadings(exports.documentMarkdownTransformers);
|
|
150
166
|
/**
|
|
151
167
|
* Keeps the editor and a markdown observable in step: the observable's value is loaded into the
|
|
152
168
|
* editor (without moving the caret or taking focus), and edits are written back as markdown.
|
|
@@ -154,6 +170,7 @@ exports.customMarkdownTransformers = [
|
|
|
154
170
|
function MarkdownPlugin(props) {
|
|
155
171
|
const [editor] = (0, LexicalComposerContext_1.useLexicalComposerContext)();
|
|
156
172
|
const { markdownObs } = props;
|
|
173
|
+
const transformers = props.transformers ?? exports.documentMarkdownTransformers;
|
|
157
174
|
(0, react_1.useEffect)(() => {
|
|
158
175
|
let markdown = "";
|
|
159
176
|
function setMarkdown() {
|
|
@@ -163,7 +180,7 @@ function MarkdownPlugin(props) {
|
|
|
163
180
|
}
|
|
164
181
|
markdown = newMarkdown;
|
|
165
182
|
editor.update(() => {
|
|
166
|
-
(0, markdown_1.$convertFromMarkdownString)(markdown,
|
|
183
|
+
(0, markdown_1.$convertFromMarkdownString)(markdown, transformers, undefined, true, false);
|
|
167
184
|
});
|
|
168
185
|
}
|
|
169
186
|
setMarkdown();
|
|
@@ -172,7 +189,7 @@ function MarkdownPlugin(props) {
|
|
|
172
189
|
});
|
|
173
190
|
const sub2Dispose = editor.registerUpdateListener(({ editorState }) => {
|
|
174
191
|
editorState.read(() => {
|
|
175
|
-
const newMarkdown = (0, markdown_1.$convertToMarkdownString)(
|
|
192
|
+
const newMarkdown = (0, markdown_1.$convertToMarkdownString)(transformers, undefined, true);
|
|
176
193
|
if (newMarkdown !== markdown) {
|
|
177
194
|
markdown = newMarkdown;
|
|
178
195
|
markdownObs(markdown);
|
|
@@ -183,6 +200,6 @@ function MarkdownPlugin(props) {
|
|
|
183
200
|
sub.dispose();
|
|
184
201
|
sub2Dispose();
|
|
185
202
|
};
|
|
186
|
-
}, [editor, markdownObs]);
|
|
203
|
+
}, [editor, markdownObs, transformers]);
|
|
187
204
|
return null;
|
|
188
205
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type AppColor } from "@peers-app/peers-sdk";
|
|
2
|
+
import { type TabState } from "./tabs-state";
|
|
3
|
+
/**
|
|
4
|
+
* The color of a tab's app on the Apps screen, for its icon in the tab strip: the color its app
|
|
5
|
+
* nav names, else the one Peers picks for it ({@link resolveAppColor}). The Apps tab, built-in
|
|
6
|
+
* apps and a route no package owns have none, and keep the strip's own grey.
|
|
7
|
+
*
|
|
8
|
+
* @param tab - The tab.
|
|
9
|
+
* @returns The app's palette color, or undefined for none.
|
|
10
|
+
*/
|
|
11
|
+
export declare function tabAppColor(tab: TabState): AppColor | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The classes that draw a tab's icon in its app's color ({@link tabAppColor}), kept current as
|
|
14
|
+
* packages load: a tab restored at startup finds its app once the packages are read.
|
|
15
|
+
*
|
|
16
|
+
* @param tab - The tab, or undefined for none.
|
|
17
|
+
* @returns `peers-tab-icon peers-app-color-<color>`, or an empty string for no color.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useTabIconColorClass(tab: TabState | undefined): string;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tabAppColor = tabAppColor;
|
|
4
|
+
exports.useTabIconColorClass = useTabIconColorClass;
|
|
5
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
|
+
const use_observable_1 = require("../hooks/use-observable");
|
|
7
|
+
const system_apps_1 = require("../system-apps");
|
|
8
|
+
const routes_loader_1 = require("../ui-router/routes-loader");
|
|
9
|
+
const tabs_state_1 = require("./tabs-state");
|
|
10
|
+
/**
|
|
11
|
+
* The color of a tab's app on the Apps screen, for its icon in the tab strip: the color its app
|
|
12
|
+
* nav names, else the one Peers picks for it ({@link resolveAppColor}). The Apps tab, built-in
|
|
13
|
+
* apps and a route no package owns have none, and keep the strip's own grey.
|
|
14
|
+
*
|
|
15
|
+
* @param tab - The tab.
|
|
16
|
+
* @returns The app's palette color, or undefined for none.
|
|
17
|
+
*/
|
|
18
|
+
function tabAppColor(tab) {
|
|
19
|
+
if (!tab.packageId || tab.packageId === "launcher" || tab.packageId === system_apps_1.systemPackage.packageId) {
|
|
20
|
+
return undefined;
|
|
21
|
+
}
|
|
22
|
+
const app = (0, tabs_state_1.determineAppFromPath)(tab.path);
|
|
23
|
+
if (!app || app.package.packageId === system_apps_1.systemPackage.packageId)
|
|
24
|
+
return undefined;
|
|
25
|
+
return (0, peers_sdk_1.resolveAppColor)(app.package.packageId, app.navItem);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The classes that draw a tab's icon in its app's color ({@link tabAppColor}), kept current as
|
|
29
|
+
* packages load: a tab restored at startup finds its app once the packages are read.
|
|
30
|
+
*
|
|
31
|
+
* @param tab - The tab, or undefined for none.
|
|
32
|
+
* @returns `peers-tab-icon peers-app-color-<color>`, or an empty string for no color.
|
|
33
|
+
*/
|
|
34
|
+
function useTabIconColorClass(tab) {
|
|
35
|
+
(0, use_observable_1.useObservable)(routes_loader_1.allPackages);
|
|
36
|
+
const color = tab ? tabAppColor(tab) : undefined;
|
|
37
|
+
return color ? `peers-tab-icon peers-app-color-${color}` : "";
|
|
38
|
+
}
|
|
@@ -53,6 +53,7 @@ const identity_routes_1 = require("../screens/identity/identity-routes");
|
|
|
53
53
|
const color_mode_dropdown_1 = require("../screens/settings/color-mode-dropdown");
|
|
54
54
|
const ui_loader_1 = require("../ui-router/ui-loader");
|
|
55
55
|
const network_status_indicator_1 = require("./network-status-indicator");
|
|
56
|
+
const tab_color_1 = require("./tab-color");
|
|
56
57
|
const tabs_state_1 = require("./tabs-state");
|
|
57
58
|
/**
|
|
58
59
|
* Wraps a single tab's content so a crash in one tab doesn't take down the whole app.
|
|
@@ -191,6 +192,7 @@ function MobileTabsHeader({ tabs, activeTab, onSwitch, onClose, colorMode, }) {
|
|
|
191
192
|
const notificationSummary = (0, notifications_client_1.useNotificationSummary)();
|
|
192
193
|
const notificationsLabel = (0, notifications_panel_1.notificationBadgeLabel)(notificationSummary);
|
|
193
194
|
const currentTab = tabs.find((t) => t.tabId === activeTab);
|
|
195
|
+
const currentIconColor = (0, tab_color_1.useTabIconColorClass)(currentTab);
|
|
194
196
|
const nonLauncherTabs = tabs.filter((t) => t.packageId !== "launcher");
|
|
195
197
|
const closeMenu = react_1.default.useCallback(() => {
|
|
196
198
|
setShowMenuDropdown(false);
|
|
@@ -211,7 +213,7 @@ function MobileTabsHeader({ tabs, activeTab, onSwitch, onClose, colorMode, }) {
|
|
|
211
213
|
transform: "translateX(-50%)",
|
|
212
214
|
pointerEvents: "none",
|
|
213
215
|
maxWidth: "calc(100% - 140px)",
|
|
214
|
-
}, children: [currentTab?.iconClassName && currentTab.packageId !== "launcher" && ((0, jsx_runtime_1.jsx)("i", { className: `${currentTab.iconClassName} me-2` })), (0, jsx_runtime_1.jsx)("span", { className: "fw-medium text-truncate small", children: currentTab?.title || "Apps" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-1", children: [(0, jsx_runtime_1.jsx)(network_status_indicator_1.TabsStripIndicators, { compact: true, notifications: false }), (0, jsx_runtime_1.jsxs)("div", { className: "dropdown", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn btn-sm ${colorMode === "light" ? "btn-outline-dark" : "btn-outline-light"}`, onClick: () => (showMenuDropdown ? closeMenu() : setShowMenuDropdown(true)), style: { minWidth: "36px" }, "aria-label": [
|
|
216
|
+
}, children: [currentTab?.iconClassName && currentTab.packageId !== "launcher" && ((0, jsx_runtime_1.jsx)("i", { className: `${currentTab.iconClassName} me-2 ${currentIconColor}` })), (0, jsx_runtime_1.jsx)("span", { className: "fw-medium text-truncate small", children: currentTab?.title || "Apps" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-1", children: [(0, jsx_runtime_1.jsx)(network_status_indicator_1.TabsStripIndicators, { compact: true, notifications: false }), (0, jsx_runtime_1.jsxs)("div", { className: "dropdown", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: `btn btn-sm ${colorMode === "light" ? "btn-outline-dark" : "btn-outline-light"}`, onClick: () => (showMenuDropdown ? closeMenu() : setShowMenuDropdown(true)), style: { minWidth: "36px" }, "aria-label": [
|
|
215
217
|
"Menu",
|
|
216
218
|
nonLauncherTabs.length > 0 &&
|
|
217
219
|
`${nonLauncherTabs.length} tab${nonLauncherTabs.length === 1 ? "" : "s"}`,
|
|
@@ -241,13 +243,19 @@ function MobileTabsHeader({ tabs, activeTab, onSwitch, onClose, colorMode, }) {
|
|
|
241
243
|
.map((tab) => ((0, jsx_runtime_1.jsxs)("div", { className: `dropdown-item d-flex align-items-center justify-content-between ${activeTab === tab.tabId ? "active" : ""}`, style: { cursor: "pointer", padding: "14px 18px", fontSize: "17px" }, onClick: () => {
|
|
242
244
|
onSwitch(tab.tabId);
|
|
243
245
|
closeMenu();
|
|
244
|
-
}, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center", children: [tab.iconClassName && (
|
|
246
|
+
}, children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center", children: [tab.iconClassName && (0, jsx_runtime_1.jsx)(MenuTabIcon, { tab: tab }), (0, jsx_runtime_1.jsx)("span", { children: tab.title })] }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm p-0 ms-3", style: { width: "32px", height: "32px", fontSize: "20px" }, onClick: (e) => {
|
|
245
247
|
e.stopPropagation();
|
|
246
248
|
onClose(tab.tabId);
|
|
247
249
|
}, children: (0, jsx_runtime_1.jsx)("i", { className: "bi-x" }) })] }, tab.tabId)))] })) }))] })] }), showMenuDropdown && ((0, jsx_runtime_1.jsx)("div", { className: "position-fixed w-100 h-100", style: { top: 0, left: 0, zIndex: 999 }, onClick: closeMenu }))] }));
|
|
248
250
|
}
|
|
251
|
+
/** A tab's icon in the phone's tab menu, in its app's color. */
|
|
252
|
+
function MenuTabIcon({ tab }) {
|
|
253
|
+
const color = (0, tab_color_1.useTabIconColorClass)(tab);
|
|
254
|
+
return (0, jsx_runtime_1.jsx)("i", { className: `${tab.iconClassName} me-3 ${color}`, style: { fontSize: "20px" } });
|
|
255
|
+
}
|
|
249
256
|
function TabHeader({ tab, isActive, onSwitch, onClose, colorMode }) {
|
|
250
257
|
const isLight = colorMode === "light";
|
|
258
|
+
const iconColor = (0, tab_color_1.useTabIconColorClass)(tab);
|
|
251
259
|
const activeClass = isLight ? "" : isActive ? "bg-secondary" : "bg-dark";
|
|
252
260
|
return ((0, jsx_runtime_1.jsxs)("div", { className: `peers-tab ${isActive ? "peers-tab-active" : ""} d-flex align-items-center px-2 py-1 user-select-none ${activeClass}`, style: {
|
|
253
261
|
cursor: "pointer",
|
|
@@ -273,7 +281,7 @@ function TabHeader({ tab, isActive, onSwitch, onClose, colorMode }) {
|
|
|
273
281
|
if (!isActive && !isLight) {
|
|
274
282
|
e.currentTarget.style.backgroundColor = "#343a40";
|
|
275
283
|
}
|
|
276
|
-
}, onClick: () => onSwitch(tab.tabId), children: [tab.iconClassName && (0, jsx_runtime_1.jsx)("i", { className: `${tab.iconClassName} me-2` }), (0, jsx_runtime_1.jsx)("span", { className: "text-truncate", style: { maxWidth: "120px", fontSize: "12px" }, children: tab.title }), tab.tabId !== "launcher" && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn p-0 ms-1 opacity-75 hover-opacity-100", style: {
|
|
284
|
+
}, onClick: () => onSwitch(tab.tabId), children: [tab.iconClassName && (0, jsx_runtime_1.jsx)("i", { className: `${tab.iconClassName} me-2 ${iconColor}` }), (0, jsx_runtime_1.jsx)("span", { className: "text-truncate", style: { maxWidth: "120px", fontSize: "12px" }, children: tab.title }), tab.tabId !== "launcher" && ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn p-0 ms-1 opacity-75 hover-opacity-100", style: {
|
|
277
285
|
width: "14px",
|
|
278
286
|
height: "14px",
|
|
279
287
|
fontSize: "11px",
|
package/dist/theme.css
CHANGED
|
@@ -476,6 +476,11 @@
|
|
|
476
476
|
--peers-tile-border: var(--peers-app-system-border);
|
|
477
477
|
}
|
|
478
478
|
|
|
479
|
+
/* A tab's icon in the tab strip: its app's color from the Apps screen (tab-color.ts). */
|
|
480
|
+
.peers-tab-icon {
|
|
481
|
+
color: var(--peers-tile-bg);
|
|
482
|
+
}
|
|
483
|
+
|
|
479
484
|
/* An app's icon: a rounded square in its color. Size it with --peers-tile-size. */
|
|
480
485
|
.peers-app-icon {
|
|
481
486
|
--peers-tile-size: 66px;
|
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.15",
|
|
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.15",
|
|
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.15",
|
|
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",
|