@peers-app/peers-ui 0.27.3 → 0.27.5
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/screens/network-viewer/group-details-modal.d.ts +4 -0
- package/dist/screens/network-viewer/group-details-modal.js +6 -46
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +3 -2
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/sync-recovery.js +103 -1
- package/dist/screens/variables/variable-details.js +2 -1
- package/dist/tabs-layout/network-status-indicator.js +26 -12
- package/dist/tabs-layout/use-network-status.d.ts +6 -1
- package/dist/tabs-layout/use-network-status.js +27 -4
- package/package.json +9 -3
- package/.claude/settings.local.json +0 -34
- package/.github/README.md +0 -52
- package/.github/workflows/delete-all-artifacts.yml +0 -49
- package/.github/workflows/publish.yml +0 -51
- package/babel.config.js +0 -7
- package/biome.json +0 -198
- package/dist/app-updates/app-updates-consumer.test.d.ts +0 -1
- package/dist/app-updates/app-updates-consumer.test.js +0 -56
- package/dist/app-updates/app-updates-settings.test.d.ts +0 -1
- package/dist/app-updates/app-updates-settings.test.js +0 -93
- package/dist/app-updates/remote-app-update-panel.test.d.ts +0 -1
- package/dist/app-updates/remote-app-update-panel.test.js +0 -165
- package/dist/components/access-level-field.test.d.ts +0 -1
- package/dist/components/access-level-field.test.js +0 -28
- package/dist/components/message-logs/tool-access-approval-card.test.d.ts +0 -1
- package/dist/components/message-logs/tool-access-approval-card.test.js +0 -102
- package/dist/components/responsive-section-nav.test.d.ts +0 -1
- package/dist/components/responsive-section-nav.test.js +0 -45
- package/dist/globals-hash.test.d.ts +0 -1
- package/dist/globals-hash.test.js +0 -16
- package/dist/hooks/use-observable-state.test.d.ts +0 -1
- package/dist/hooks/use-observable-state.test.js +0 -64
- package/dist/hooks/use-observable.test.d.ts +0 -1
- package/dist/hooks/use-observable.test.js +0 -191
- package/dist/hooks/use-rows.test.d.ts +0 -1
- package/dist/hooks/use-rows.test.js +0 -175
- package/dist/hooks/use-tool.test.d.ts +0 -1
- package/dist/hooks/use-tool.test.js +0 -190
- package/dist/host-shell/host-shell-consumer.test.d.ts +0 -1
- package/dist/host-shell/host-shell-consumer.test.js +0 -28
- package/dist/root-layout/root-layout-host.test.d.ts +0 -1
- package/dist/root-layout/root-layout-host.test.js +0 -86
- package/dist/screens/account/account-screen.test.d.ts +0 -1
- package/dist/screens/account/account-screen.test.js +0 -51
- package/dist/screens/assistants/assistant-config.test.d.ts +0 -1
- package/dist/screens/assistants/assistant-config.test.js +0 -57
- package/dist/screens/contacts/contact-list.test.d.ts +0 -1
- package/dist/screens/contacts/contact-list.test.js +0 -48
- package/dist/screens/device-pairing/device-pairing.test.d.ts +0 -1
- package/dist/screens/device-pairing/device-pairing.test.js +0 -119
- package/dist/screens/devices/devices-list.test.d.ts +0 -1
- package/dist/screens/devices/devices-list.test.js +0 -53
- package/dist/screens/groups/group-list.test.d.ts +0 -1
- package/dist/screens/groups/group-list.test.js +0 -38
- package/dist/screens/identity/identity-routes.test.d.ts +0 -1
- package/dist/screens/identity/identity-routes.test.js +0 -51
- package/dist/screens/identity/identity-screen.test.d.ts +0 -1
- package/dist/screens/identity/identity-screen.test.js +0 -103
- package/dist/screens/invites/accept-invite.test.d.ts +0 -1
- package/dist/screens/invites/accept-invite.test.js +0 -103
- package/dist/screens/invites/activity-view.test.d.ts +0 -1
- package/dist/screens/invites/activity-view.test.js +0 -108
- package/dist/screens/invites/invite-classify.test.d.ts +0 -1
- package/dist/screens/invites/invite-classify.test.js +0 -115
- package/dist/screens/network-viewer/network-viewer-ipc.test.d.ts +0 -1
- package/dist/screens/network-viewer/network-viewer-ipc.test.js +0 -61
- package/dist/screens/network-viewer/network-viewer.section.test.d.ts +0 -1
- package/dist/screens/network-viewer/network-viewer.section.test.js +0 -63
- package/dist/screens/network-viewer/sync-recovery.test.d.ts +0 -1
- package/dist/screens/network-viewer/sync-recovery.test.js +0 -104
- package/dist/screens/packages/package-helpers.test.d.ts +0 -1
- package/dist/screens/packages/package-helpers.test.js +0 -53
- package/dist/screens/packages/package-runtime-status.test.d.ts +0 -1
- package/dist/screens/packages/package-runtime-status.test.js +0 -50
- package/dist/screens/packages/packages-ipc.test.d.ts +0 -1
- package/dist/screens/packages/packages-ipc.test.js +0 -43
- package/dist/screens/settings/settings-page.test.d.ts +0 -1
- package/dist/screens/settings/settings-page.test.js +0 -19
- package/dist/screens/tools/tool-access-ipc.test.d.ts +0 -1
- package/dist/screens/tools/tool-access-ipc.test.js +0 -40
- package/dist/screens/tools/tool-catalog-ipc.test.d.ts +0 -1
- package/dist/screens/tools/tool-catalog-ipc.test.js +0 -52
- package/dist/tabs-layout/network-status-indicator.test.d.ts +0 -1
- package/dist/tabs-layout/network-status-indicator.test.js +0 -665
- package/dist/tabs-layout/tabs-state.test.d.ts +0 -1
- package/dist/tabs-layout/tabs-state.test.js +0 -110
- package/dist/tabs-layout/use-network-status.test.d.ts +0 -1
- package/dist/tabs-layout/use-network-status.test.js +0 -45
- package/dist/ui-router/ui-loader.test.d.ts +0 -1
- package/dist/ui-router/ui-loader.test.js +0 -91
- package/jest.config.js +0 -25
- package/release-guard.js +0 -10
- package/src/app-updates/app-update-controls.tsx +0 -73
- package/src/app-updates/app-updates-consumer.test.ts +0 -83
- package/src/app-updates/app-updates-consumer.ts +0 -121
- package/src/app-updates/app-updates-settings.test.tsx +0 -109
- package/src/app-updates/app-updates-settings.tsx +0 -136
- package/src/app-updates/remote-app-update-panel.test.tsx +0 -205
- package/src/app-updates/remote-app-update-panel.tsx +0 -210
- package/src/app-updates/use-app-update-status.ts +0 -16
- package/src/command-palette/command-palette-ui.tsx +0 -564
- package/src/command-palette/command-palette.ts +0 -242
- package/src/components/access-level-field.test.tsx +0 -32
- package/src/components/access-level-field.tsx +0 -68
- package/src/components/checkbox.tsx +0 -25
- package/src/components/group-switcher.tsx +0 -526
- package/src/components/input-date.tsx +0 -29
- package/src/components/input-number.tsx +0 -83
- package/src/components/input.tsx +0 -25
- package/src/components/inverse-lazy-list.tsx +0 -107
- package/src/components/io-schema-values.tsx +0 -103
- package/src/components/io-schema.tsx +0 -259
- package/src/components/lazy-list.tsx +0 -115
- package/src/components/list-screen.tsx +0 -126
- package/src/components/loading-indicator.tsx +0 -7
- package/src/components/markdown-editor/autolink-plugin.tsx +0 -29
- package/src/components/markdown-editor/editor-inline.tsx +0 -9
- package/src/components/markdown-editor/editor.tsx +0 -158
- package/src/components/markdown-editor/markdown-plugin.tsx +0 -202
- package/src/components/markdown-editor/mention-node.ts +0 -204
- package/src/components/markdown-editor/mentions-plugin.tsx +0 -354
- package/src/components/markdown-editor/move-line-plugin.tsx +0 -186
- package/src/components/markdown-editor/select-line-boundary-plugin.tsx +0 -95
- package/src/components/markdown-editor/theme.ts +0 -46
- package/src/components/markdown-editor/toolbar.tsx +0 -269
- package/src/components/markdown-with-mentions.tsx +0 -198
- package/src/components/message-logs/message-logs.tsx +0 -523
- package/src/components/message-logs/tool-access-approval-card.test.tsx +0 -127
- package/src/components/message-logs/tool-access-approval-card.tsx +0 -178
- package/src/components/messages/avatar.tsx +0 -171
- package/src/components/messages/channel-message-list.tsx +0 -189
- package/src/components/messages/channel-view.tsx +0 -92
- package/src/components/messages/message-compose.tsx +0 -192
- package/src/components/messages/message-display.tsx +0 -231
- package/src/components/messages/thread-message-list.tsx +0 -135
- package/src/components/qr-scanner.tsx +0 -180
- package/src/components/responsive-section-nav.test.tsx +0 -88
- package/src/components/responsive-section-nav.tsx +0 -92
- package/src/components/router.tsx +0 -175
- package/src/components/save-button.tsx +0 -134
- package/src/components/sortable-list.tsx +0 -130
- package/src/components/tabs.tsx +0 -76
- package/src/components/tooltip.tsx +0 -43
- package/src/components/trust-level-badge.tsx +0 -44
- package/src/components/trust-level-dropdown.tsx +0 -136
- package/src/components/typeahead.tsx +0 -357
- package/src/globals-hash.test.ts +0 -19
- package/src/globals.tsx +0 -226
- package/src/hooks/index.ts +0 -8
- package/src/hooks/use-host-contract.ts +0 -75
- package/src/hooks/use-observable-state.test.tsx +0 -101
- package/src/hooks/use-observable-state.ts +0 -29
- package/src/hooks/use-observable.test.tsx +0 -258
- package/src/hooks/use-observable.ts +0 -67
- package/src/hooks/use-on-screen.ts +0 -24
- package/src/hooks/use-promise.ts +0 -34
- package/src/hooks/use-rows.test.tsx +0 -196
- package/src/hooks/use-rows.ts +0 -120
- package/src/hooks/use-subscription.ts +0 -24
- package/src/hooks/use-tool.test.tsx +0 -225
- package/src/hooks/use-tool.ts +0 -116
- package/src/host-shell/host-shell-consumer.test.ts +0 -32
- package/src/host-shell/host-shell-consumer.ts +0 -53
- package/src/index.tsx +0 -42
- package/src/mention-configs.ts +0 -185
- package/src/operator-console/operator-console-state.ts +0 -119
- package/src/operator-console/operator-console.tsx +0 -233
- package/src/peers-services-registration.ts +0 -6
- package/src/root-layout/global-overlays.ts +0 -50
- package/src/root-layout/layout-picker.tsx +0 -47
- package/src/root-layout/layouts/full-screen-layout.tsx +0 -144
- package/src/root-layout/layouts/tabs-with-console-layout.tsx +0 -260
- package/src/root-layout/root-layout-host.test.tsx +0 -108
- package/src/root-layout/root-layout-host.tsx +0 -147
- package/src/root-layout/root-layout-registry.ts +0 -51
- package/src/root-layout/root-layout-state.ts +0 -55
- package/src/root-layout/root-layout.ts +0 -32
- package/src/screens/account/account-screen.test.tsx +0 -65
- package/src/screens/account/account-screen.tsx +0 -942
- package/src/screens/assistants/assistant-config.test.tsx +0 -54
- package/src/screens/assistants/assistant-config.tsx +0 -121
- package/src/screens/assistants/assistant-details.tsx +0 -89
- package/src/screens/assistants/assistant-info.tsx +0 -66
- package/src/screens/assistants/assistant-list.tsx +0 -145
- package/src/screens/assistants/assistant-tools.tsx +0 -82
- package/src/screens/console-logs/console-logs-list.tsx +0 -374
- package/src/screens/console-logs/log-display.tsx +0 -137
- package/src/screens/console-logs/log-filters.tsx +0 -64
- package/src/screens/console-logs/mobile-log-card.tsx +0 -161
- package/src/screens/console-logs/resizable-table-header.tsx +0 -110
- package/src/screens/contacts/contact-details.tsx +0 -123
- package/src/screens/contacts/contact-list.test.tsx +0 -59
- package/src/screens/contacts/contact-list.tsx +0 -286
- package/src/screens/contacts/index.ts +0 -2
- package/src/screens/data-explorer/data-explorer.tsx +0 -633
- package/src/screens/data-explorer/index.ts +0 -6
- package/src/screens/data-explorer/query-executor.tsx +0 -520
- package/src/screens/device-pairing/device-pairing.test.tsx +0 -143
- package/src/screens/device-pairing/device-pairing.tsx +0 -461
- package/src/screens/device-pairing/identity-ipc.ts +0 -25
- package/src/screens/device-pairing/index.ts +0 -2
- package/src/screens/device-pairing/use-device-pairing-state.ts +0 -15
- package/src/screens/devices/devices-list.test.tsx +0 -68
- package/src/screens/devices/devices-list.tsx +0 -365
- package/src/screens/devices/index.ts +0 -1
- package/src/screens/groups/group-details.tsx +0 -160
- package/src/screens/groups/group-invite-panel.tsx +0 -311
- package/src/screens/groups/group-list.test.tsx +0 -44
- package/src/screens/groups/group-list.tsx +0 -317
- package/src/screens/groups/group-members.tsx +0 -343
- package/src/screens/groups/index.ts +0 -3
- package/src/screens/identity/identity-routes.test.ts +0 -70
- package/src/screens/identity/identity-routes.ts +0 -301
- package/src/screens/identity/identity-screen.test.tsx +0 -138
- package/src/screens/identity/identity-screen.tsx +0 -282
- package/src/screens/identity/index.ts +0 -2
- package/src/screens/identity/invite-contact-panel.tsx +0 -45
- package/src/screens/identity/profile-invite.tsx +0 -93
- package/src/screens/invites/accept-invite.test.tsx +0 -115
- package/src/screens/invites/accept-invite.tsx +0 -318
- package/src/screens/invites/activity-view.test.tsx +0 -127
- package/src/screens/invites/activity-view.tsx +0 -162
- package/src/screens/invites/index.ts +0 -6
- package/src/screens/invites/invite-capture.ts +0 -104
- package/src/screens/invites/invite-classify.test.ts +0 -129
- package/src/screens/invites/invite-share.tsx +0 -104
- package/src/screens/invites/invites-ipc.ts +0 -25
- package/src/screens/invites/pending-invites-list.tsx +0 -256
- package/src/screens/network-viewer/connection-troubleshooter.tsx +0 -395
- package/src/screens/network-viewer/cpu-usage-graph.tsx +0 -294
- package/src/screens/network-viewer/device-details-modal.tsx +0 -339
- package/src/screens/network-viewer/group-details-modal.tsx +0 -421
- package/src/screens/network-viewer/index.ts +0 -8
- package/src/screens/network-viewer/network-viewer-ipc.test.ts +0 -72
- package/src/screens/network-viewer/network-viewer-ipc.ts +0 -39
- package/src/screens/network-viewer/network-viewer-section.ts +0 -12
- package/src/screens/network-viewer/network-viewer.section.test.tsx +0 -68
- package/src/screens/network-viewer/network-viewer.tsx +0 -708
- package/src/screens/network-viewer/remote-logs-panel.tsx +0 -190
- package/src/screens/network-viewer/sync-recovery.test.tsx +0 -114
- package/src/screens/network-viewer/sync-recovery.tsx +0 -461
- package/src/screens/network-viewer/usage-graph.tsx +0 -455
- package/src/screens/packages/local-folder-grants-panel.tsx +0 -290
- package/src/screens/packages/local-folders-ipc.ts +0 -28
- package/src/screens/packages/package-details.tsx +0 -166
- package/src/screens/packages/package-helpers.test.ts +0 -57
- package/src/screens/packages/package-helpers.ts +0 -137
- package/src/screens/packages/package-info.tsx +0 -354
- package/src/screens/packages/package-list.tsx +0 -519
- package/src/screens/packages/package-network-panel.tsx +0 -82
- package/src/screens/packages/package-new-local.tsx +0 -100
- package/src/screens/packages/package-runtime-status.test.tsx +0 -58
- package/src/screens/packages/package-runtime-status.tsx +0 -68
- package/src/screens/packages/package-versions.tsx +0 -298
- package/src/screens/packages/packages-ipc.test.ts +0 -47
- package/src/screens/packages/packages-ipc.ts +0 -125
- package/src/screens/peer-types/peer-type-details.tsx +0 -172
- package/src/screens/peer-types/peer-type-list.tsx +0 -64
- package/src/screens/search/global-search.tsx +0 -406
- package/src/screens/settings/color-mode-dropdown.tsx +0 -82
- package/src/screens/settings/settings-page.test.tsx +0 -24
- package/src/screens/settings/settings-page.tsx +0 -426
- package/src/screens/setup-user.tsx +0 -355
- package/src/screens/tools/tool-access-ipc.test.ts +0 -55
- package/src/screens/tools/tool-access-ipc.ts +0 -27
- package/src/screens/tools/tool-catalog-ipc.test.ts +0 -52
- package/src/screens/tools/tool-catalog-ipc.ts +0 -51
- package/src/screens/tools/tool-details.tsx +0 -52
- package/src/screens/tools/tool-info.tsx +0 -45
- package/src/screens/tools/tool-list.tsx +0 -106
- package/src/screens/tools/tool-schema.tsx +0 -44
- package/src/screens/tools/tool-test-details.tsx +0 -89
- package/src/screens/tools/tool-test-list.tsx +0 -73
- package/src/screens/variables/variable-details.tsx +0 -289
- package/src/screens/variables/variable-list.tsx +0 -110
- package/src/screens/welcome-modal.tsx +0 -294
- package/src/screens/workflows/workflow-details.tsx +0 -115
- package/src/screens/workflows/workflow-info.tsx +0 -22
- package/src/screens/workflows/workflow-instructions.tsx +0 -134
- package/src/screens/workflows/workflow-list.tsx +0 -117
- package/src/setupTests.ts +0 -38
- package/src/system-apps/assistants.app.ts +0 -7
- package/src/system-apps/console-logs.app.ts +0 -7
- package/src/system-apps/data-explorer.app.ts +0 -8
- package/src/system-apps/identity.app.ts +0 -9
- package/src/system-apps/index.ts +0 -77
- package/src/system-apps/mobile-settings.app.ts +0 -7
- package/src/system-apps/network-viewer.app.ts +0 -8
- package/src/system-apps/packages.app.ts +0 -7
- package/src/system-apps/search.app.ts +0 -8
- package/src/system-apps/settings.app.ts +0 -7
- package/src/system-apps/threads.app.ts +0 -7
- package/src/system-apps/tools.app.ts +0 -7
- package/src/system-apps/types.app.ts +0 -7
- package/src/system-apps/variables.app.ts +0 -7
- package/src/system-apps/workflows.app.ts +0 -7
- package/src/tabs-layout/network-status-indicator.test.tsx +0 -799
- package/src/tabs-layout/network-status-indicator.tsx +0 -756
- package/src/tabs-layout/tabs-layout.tsx +0 -857
- package/src/tabs-layout/tabs-state.test.ts +0 -152
- package/src/tabs-layout/tabs-state.ts +0 -587
- package/src/tabs-layout/use-network-status.test.tsx +0 -58
- package/src/tabs-layout/use-network-status.ts +0 -68
- package/src/ui-defaults/index.ts +0 -2
- package/src/ui-defaults/list-screen.tsx +0 -94
- package/src/ui-defaults/markdown-field.tsx +0 -87
- package/src/ui-router/routes-loader.ts +0 -193
- package/src/ui-router/ui-loader.test.tsx +0 -108
- package/src/ui-router/ui-loader.tsx +0 -606
- package/src/utils.ts +0 -95
- package/tsconfig.json +0 -18
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type DataFilter,
|
|
3
|
-
type ICursorIterable,
|
|
4
|
-
observable,
|
|
5
|
-
type SortBy,
|
|
6
|
-
type Table,
|
|
7
|
-
} from "@peers-app/peers-sdk";
|
|
8
|
-
import * as _ from "lodash";
|
|
9
|
-
import type React from "react";
|
|
10
|
-
import { useCallback, useEffect, useState } from "react";
|
|
11
|
-
import { isDesktop } from "../globals";
|
|
12
|
-
import { useObservable } from "../hooks";
|
|
13
|
-
import { Input } from "./input";
|
|
14
|
-
import { LazyList } from "./lazy-list";
|
|
15
|
-
import { LoadingIndicator } from "./loading-indicator";
|
|
16
|
-
|
|
17
|
-
interface IProps<T extends Record<string, unknown>> {
|
|
18
|
-
table: Table<T>;
|
|
19
|
-
/**
|
|
20
|
-
* Creates a new record from the search text when the user presses Enter. When omitted,
|
|
21
|
-
* the list is browse/search only (no create) and the placeholder drops "or create".
|
|
22
|
-
*/
|
|
23
|
-
newRecord?: (text: string) => Promise<T>;
|
|
24
|
-
getFilter?: (text: string) => DataFilter<T>;
|
|
25
|
-
sortBy?: SortBy<T>;
|
|
26
|
-
renderItem: (record: T) => JSX.Element;
|
|
27
|
-
placeholderName?: string;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function ListScreen<T extends Record<string, unknown>>(props: IProps<T>) {
|
|
31
|
-
const { table, newRecord, sortBy } = props;
|
|
32
|
-
|
|
33
|
-
const [searchTextObs] = useState(() => observable(""));
|
|
34
|
-
const [searchText] = useObservable(searchTextObs);
|
|
35
|
-
|
|
36
|
-
const [cursorObs] = useState(() => observable<ICursorIterable<T> | undefined>());
|
|
37
|
-
|
|
38
|
-
const newCursor = useCallback(async () => {
|
|
39
|
-
const filter = props.getFilter ? props.getFilter(searchText) : null;
|
|
40
|
-
const cursor = await table.cursor(filter || {}, {
|
|
41
|
-
sortBy,
|
|
42
|
-
...(filter ? {} : { textSearch: searchText }),
|
|
43
|
-
});
|
|
44
|
-
cursorObs(cursor);
|
|
45
|
-
return cursor;
|
|
46
|
-
}, [table, searchText, props.getFilter, sortBy, cursorObs]);
|
|
47
|
-
|
|
48
|
-
useEffect(() => {
|
|
49
|
-
void newCursor();
|
|
50
|
-
}, [newCursor]);
|
|
51
|
-
|
|
52
|
-
const idFieldName = table.metaData.primaryKeyName;
|
|
53
|
-
|
|
54
|
-
async function loadMore(existing: T[]): Promise<T[]> {
|
|
55
|
-
let moreMatches: T[] = [];
|
|
56
|
-
const cursor = cursorObs() || (await newCursor());
|
|
57
|
-
for await (const nextRecord of cursor) {
|
|
58
|
-
if (existing.find((e) => e[idFieldName] === nextRecord[idFieldName])) continue;
|
|
59
|
-
moreMatches.push(nextRecord);
|
|
60
|
-
if (searchText.length && moreMatches.length > 5) break;
|
|
61
|
-
if (moreMatches.length >= 10) break;
|
|
62
|
-
}
|
|
63
|
-
if (moreMatches.length === 0) {
|
|
64
|
-
cursorObs(undefined);
|
|
65
|
-
}
|
|
66
|
-
// if we're using default textSearch, list items with the most words matched in the name first
|
|
67
|
-
if (
|
|
68
|
-
!props.getFilter &&
|
|
69
|
-
moreMatches &&
|
|
70
|
-
searchText &&
|
|
71
|
-
table.metaData.fields.find((f) => f.name === "name")
|
|
72
|
-
) {
|
|
73
|
-
const words = searchText.toLowerCase().split(" ");
|
|
74
|
-
moreMatches = _.sortBy(moreMatches, (r) => {
|
|
75
|
-
const nameVal = r.name;
|
|
76
|
-
const nameStr = typeof nameVal === "string" ? nameVal : String(nameVal ?? "");
|
|
77
|
-
return words.filter((w) => nameStr.toLowerCase().includes(w)).length;
|
|
78
|
-
}).reverse();
|
|
79
|
-
}
|
|
80
|
-
return moreMatches;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async function searchSubmit(evt: React.KeyboardEvent<HTMLInputElement>) {
|
|
84
|
-
if (evt.key !== "Enter") return;
|
|
85
|
-
if (!newRecord) return;
|
|
86
|
-
const name = searchText.trim();
|
|
87
|
-
if (!name) return;
|
|
88
|
-
searchTextObs("");
|
|
89
|
-
await newRecord(name);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<div className="container-fluid">
|
|
94
|
-
<div className="input-group mt-3 mb-3">
|
|
95
|
-
<Input
|
|
96
|
-
value={searchTextObs}
|
|
97
|
-
className="form-control"
|
|
98
|
-
placeholder={`${newRecord ? "Search or create" : "Search"} ${props.placeholderName || table.metaData.name}`}
|
|
99
|
-
autoFocus={!!isDesktop()}
|
|
100
|
-
onKeyUp={(evt) => searchSubmit(evt)}
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
<div className="peers-list-container">
|
|
105
|
-
<LazyList
|
|
106
|
-
resetTrigger={searchText}
|
|
107
|
-
loadMore={loadMore}
|
|
108
|
-
scrollThreshold={0.6}
|
|
109
|
-
renderItems={(notes) => {
|
|
110
|
-
return notes.map(props.renderItem);
|
|
111
|
-
}}
|
|
112
|
-
loadingIndicator={
|
|
113
|
-
<div className="d-flex justify-content-center" style={{ height: 200 }}>
|
|
114
|
-
<LoadingIndicator />
|
|
115
|
-
</div>
|
|
116
|
-
}
|
|
117
|
-
endOfList={
|
|
118
|
-
<div className="d-flex justify-content-center" style={{ height: 200 }}>
|
|
119
|
-
{/* <span className="h3">End of List</span> */}
|
|
120
|
-
</div>
|
|
121
|
-
}
|
|
122
|
-
/>
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
);
|
|
126
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { AutoLinkPlugin, createLinkMatcherWithRegExp } from "@lexical/react/LexicalAutoLinkPlugin";
|
|
2
|
-
|
|
3
|
-
const URL_REGEX =
|
|
4
|
-
/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)(?<![-.+():%])/;
|
|
5
|
-
|
|
6
|
-
const EMAIL_REGEX =
|
|
7
|
-
/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/;
|
|
8
|
-
|
|
9
|
-
const MATCHERS = [
|
|
10
|
-
createLinkMatcherWithRegExp(URL_REGEX, (text) => {
|
|
11
|
-
return text.startsWith("http") ? text : `https://${text}`;
|
|
12
|
-
}),
|
|
13
|
-
createLinkMatcherWithRegExp(EMAIL_REGEX, (text) => {
|
|
14
|
-
return `mailto:${text}`;
|
|
15
|
-
}),
|
|
16
|
-
];
|
|
17
|
-
|
|
18
|
-
export function LexicalAutoLinkPlugin(): JSX.Element {
|
|
19
|
-
return <AutoLinkPlugin matchers={MATCHERS} />;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
import { LinkPlugin as LexicalLinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
23
|
-
|
|
24
|
-
export default function LinkPlugin(): JSX.Element {
|
|
25
|
-
const validateUrl = (url: string) => {
|
|
26
|
-
return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("mailto:");
|
|
27
|
-
};
|
|
28
|
-
return <LexicalLinkPlugin validateUrl={validateUrl} />;
|
|
29
|
-
}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { CodeNode } from "@lexical/code";
|
|
2
|
-
import { AutoLinkNode, LinkNode } from "@lexical/link";
|
|
3
|
-
import { ListItemNode, ListNode } from "@lexical/list";
|
|
4
|
-
import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
|
|
5
|
-
import { CheckListPlugin } from "@lexical/react/LexicalCheckListPlugin";
|
|
6
|
-
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
7
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
8
|
-
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
9
|
-
import { LexicalErrorBoundary } from "@lexical/react/LexicalErrorBoundary";
|
|
10
|
-
import { HistoryPlugin } from "@lexical/react/LexicalHistoryPlugin";
|
|
11
|
-
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
12
|
-
import { MarkdownShortcutPlugin } from "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
13
|
-
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
14
|
-
import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin";
|
|
15
|
-
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
16
|
-
import { type Observable, observable } from "@peers-app/peers-sdk";
|
|
17
|
-
import { COMMAND_PRIORITY_LOW, KEY_DOWN_COMMAND } from "lexical";
|
|
18
|
-
import React, { useEffect, useState } from "react";
|
|
19
|
-
import { type IMentionConfig, mentionConfigs } from "../../mention-configs";
|
|
20
|
-
import { LexicalAutoLinkPlugin } from "./autolink-plugin";
|
|
21
|
-
import { customMarkdownTransformers, MarkdownPlugin } from "./markdown-plugin";
|
|
22
|
-
import { MentionNode } from "./mention-node";
|
|
23
|
-
import { MentionsPlugin } from "./mentions-plugin";
|
|
24
|
-
import { MoveLineWithAltArrowsPlugin } from "./move-line-plugin";
|
|
25
|
-
import { SelectToLineBoundaryPlugin } from "./select-line-boundary-plugin";
|
|
26
|
-
import theme from "./theme";
|
|
27
|
-
import { type IToolbarControl, ToolbarPlugin } from "./toolbar";
|
|
28
|
-
|
|
29
|
-
const editorConfig = {
|
|
30
|
-
namespace: "PeersEditor",
|
|
31
|
-
nodes: [
|
|
32
|
-
HeadingNode,
|
|
33
|
-
QuoteNode,
|
|
34
|
-
CodeNode,
|
|
35
|
-
ListNode,
|
|
36
|
-
ListItemNode,
|
|
37
|
-
MentionNode,
|
|
38
|
-
// Lexical node registry typing is narrower than runtime; AutoLinkNode is required for links.
|
|
39
|
-
AutoLinkNode as any,
|
|
40
|
-
LinkNode,
|
|
41
|
-
],
|
|
42
|
-
// Handling of errors during update
|
|
43
|
-
onError(error: Error) {
|
|
44
|
-
throw error;
|
|
45
|
-
},
|
|
46
|
-
// The editor theme
|
|
47
|
-
theme,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export interface IEditorEffects {
|
|
51
|
-
onKeyDown?: (e: React.KeyboardEvent) => boolean | undefined;
|
|
52
|
-
focus?: () => void;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export interface IMarkdownEditorProps {
|
|
56
|
-
value: Observable<string>;
|
|
57
|
-
effects?: IEditorEffects;
|
|
58
|
-
topRightControls?: IToolbarControl[];
|
|
59
|
-
autoFocus?: boolean;
|
|
60
|
-
hideToolbar?: boolean;
|
|
61
|
-
maxHeight?: string | number;
|
|
62
|
-
mentionConfigs?: IMentionConfig[];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export function MarkdownEditor(props: IMarkdownEditorProps) {
|
|
66
|
-
const { effects } = props;
|
|
67
|
-
const editorRef = React.useRef<HTMLDivElement>(null);
|
|
68
|
-
|
|
69
|
-
const [mentionsOpen] = useState(() => {
|
|
70
|
-
const obs = observable(false);
|
|
71
|
-
return obs;
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
if (effects) {
|
|
75
|
-
effects.focus = () => {
|
|
76
|
-
if (editorRef.current?.children[0]) {
|
|
77
|
-
const div = editorRef.current.children[0] as HTMLDivElement;
|
|
78
|
-
setTimeout(() => {
|
|
79
|
-
div.focus();
|
|
80
|
-
// Set the selection to the end of the div content
|
|
81
|
-
const range = document.createRange();
|
|
82
|
-
range.selectNodeContents(div);
|
|
83
|
-
range.collapse(false);
|
|
84
|
-
const selection = window.getSelection();
|
|
85
|
-
if (selection) {
|
|
86
|
-
selection.removeAllRanges();
|
|
87
|
-
selection.addRange(range);
|
|
88
|
-
}
|
|
89
|
-
}, 10);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const _mentionConfigs = props.mentionConfigs ?? mentionConfigs;
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<LexicalComposer initialConfig={{ ...editorConfig }}>
|
|
98
|
-
<div className="editor-container">
|
|
99
|
-
{props.hideToolbar ? null : <ToolbarPlugin topRightControls={props.topRightControls} />}
|
|
100
|
-
|
|
101
|
-
<div
|
|
102
|
-
className="editor-inner"
|
|
103
|
-
ref={editorRef}
|
|
104
|
-
style={{ maxHeight: props.maxHeight, overflowY: "auto" }}
|
|
105
|
-
>
|
|
106
|
-
<RichTextPlugin
|
|
107
|
-
contentEditable={<ContentEditable className="editor-input p-2" />}
|
|
108
|
-
placeholder={null}
|
|
109
|
-
ErrorBoundary={LexicalErrorBoundary}
|
|
110
|
-
/>
|
|
111
|
-
<HistoryPlugin />
|
|
112
|
-
{props.autoFocus && <AutoFocusPlugin defaultSelection="rootEnd" />}
|
|
113
|
-
<ListPlugin />
|
|
114
|
-
|
|
115
|
-
{_mentionConfigs.length > 0 && (
|
|
116
|
-
<MentionsPlugin mentionConfigs={_mentionConfigs} mentionsOpen={mentionsOpen} />
|
|
117
|
-
)}
|
|
118
|
-
|
|
119
|
-
<LexicalAutoLinkPlugin />
|
|
120
|
-
<MarkdownPlugin markdownObs={props.value} />
|
|
121
|
-
<MarkdownShortcutPlugin transformers={customMarkdownTransformers} />
|
|
122
|
-
<CheckListPlugin />
|
|
123
|
-
<TabIndentationPlugin />
|
|
124
|
-
<MoveLineWithAltArrowsPlugin mentionsOpen={mentionsOpen} />
|
|
125
|
-
<SelectToLineBoundaryPlugin />
|
|
126
|
-
<OnKeyDownPlugin effects={props.effects} mentionsOpen={mentionsOpen} />
|
|
127
|
-
</div>
|
|
128
|
-
</div>
|
|
129
|
-
</LexicalComposer>
|
|
130
|
-
);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const OnKeyDownPlugin = (props: {
|
|
134
|
-
effects?: IEditorEffects;
|
|
135
|
-
mentionsOpen: Observable<boolean>;
|
|
136
|
-
}) => {
|
|
137
|
-
const [editor] = useLexicalComposerContext();
|
|
138
|
-
// Intentionally `[editor]` only: `props.effects` is a stable object ref whose `onKeyDown` is
|
|
139
|
-
// imperatively reassigned by callers each render; the closure reads the latest value at event time.
|
|
140
|
-
useEffect(() => {
|
|
141
|
-
const removeListener = editor.registerCommand(
|
|
142
|
-
KEY_DOWN_COMMAND,
|
|
143
|
-
(event: KeyboardEvent) => {
|
|
144
|
-
if (props.mentionsOpen()) {
|
|
145
|
-
return false;
|
|
146
|
-
}
|
|
147
|
-
if (props.effects?.onKeyDown) {
|
|
148
|
-
const result = props.effects.onKeyDown(event as unknown as React.KeyboardEvent);
|
|
149
|
-
return !!result;
|
|
150
|
-
}
|
|
151
|
-
return false;
|
|
152
|
-
},
|
|
153
|
-
COMMAND_PRIORITY_LOW,
|
|
154
|
-
);
|
|
155
|
-
return removeListener;
|
|
156
|
-
}, [editor]);
|
|
157
|
-
return null;
|
|
158
|
-
};
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
$createListItemNode,
|
|
3
|
-
$createListNode,
|
|
4
|
-
$isListItemNode,
|
|
5
|
-
$isListNode,
|
|
6
|
-
ListItemNode,
|
|
7
|
-
ListNode,
|
|
8
|
-
type ListType,
|
|
9
|
-
} from "@lexical/list";
|
|
10
|
-
import {
|
|
11
|
-
$convertFromMarkdownString,
|
|
12
|
-
$convertToMarkdownString,
|
|
13
|
-
type ElementTransformer,
|
|
14
|
-
type TextMatchTransformer,
|
|
15
|
-
TRANSFORMERS,
|
|
16
|
-
} from "@lexical/markdown";
|
|
17
|
-
import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
|
|
18
|
-
import {
|
|
19
|
-
formatMention,
|
|
20
|
-
type IMentionData,
|
|
21
|
-
mentionRegex,
|
|
22
|
-
type Observable,
|
|
23
|
-
} from "@peers-app/peers-sdk";
|
|
24
|
-
import { useEffect } from "react";
|
|
25
|
-
import { $createMentionNode, $isMentionNode, MentionNode } from "./mention-node";
|
|
26
|
-
|
|
27
|
-
// Amount of spaces that define indentation level
|
|
28
|
-
const LIST_INDENT_SIZE = 4;
|
|
29
|
-
|
|
30
|
-
function getIndent(whitespaces: string): number {
|
|
31
|
-
const tabs = whitespaces.match(/\t/g);
|
|
32
|
-
const spaces = whitespaces.match(/ /g);
|
|
33
|
-
let indent = 0;
|
|
34
|
-
if (tabs) {
|
|
35
|
-
indent += tabs.length;
|
|
36
|
-
}
|
|
37
|
-
if (spaces) {
|
|
38
|
-
indent += Math.floor(spaces.length / LIST_INDENT_SIZE);
|
|
39
|
-
}
|
|
40
|
-
return indent;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const listReplace = (listType: ListType): ElementTransformer["replace"] => {
|
|
44
|
-
return (parentNode, children, match) => {
|
|
45
|
-
const previousNode = parentNode.getPreviousSibling();
|
|
46
|
-
const nextNode = parentNode.getNextSibling();
|
|
47
|
-
const listItem = $createListItemNode(listType === "check" ? match[3] === "x" : undefined);
|
|
48
|
-
if ($isListNode(nextNode) && nextNode.getListType() === listType) {
|
|
49
|
-
const firstChild = nextNode.getFirstChild();
|
|
50
|
-
if (firstChild !== null) {
|
|
51
|
-
firstChild.insertBefore(listItem);
|
|
52
|
-
} else {
|
|
53
|
-
// should never happen, but let's handle gracefully, just in case.
|
|
54
|
-
nextNode.append(listItem);
|
|
55
|
-
}
|
|
56
|
-
parentNode.remove();
|
|
57
|
-
} else if ($isListNode(previousNode) && previousNode.getListType() === listType) {
|
|
58
|
-
previousNode.append(listItem);
|
|
59
|
-
parentNode.remove();
|
|
60
|
-
} else {
|
|
61
|
-
const list = $createListNode(listType, listType === "number" ? Number(match[2]) : undefined);
|
|
62
|
-
list.append(listItem);
|
|
63
|
-
parentNode.replace(list);
|
|
64
|
-
}
|
|
65
|
-
listItem.append(...children);
|
|
66
|
-
listItem.select(0, 0);
|
|
67
|
-
const indent = getIndent(match[1]);
|
|
68
|
-
if (indent) {
|
|
69
|
-
listItem.setIndent(indent);
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const listExport = (
|
|
75
|
-
listNode: ListNode,
|
|
76
|
-
exportChildren: (node: ListItemNode) => string,
|
|
77
|
-
depth: number,
|
|
78
|
-
): string => {
|
|
79
|
-
const output = [];
|
|
80
|
-
const children = listNode.getChildren();
|
|
81
|
-
let index = 0;
|
|
82
|
-
for (const listItemNode of children) {
|
|
83
|
-
if ($isListItemNode(listItemNode)) {
|
|
84
|
-
if (listItemNode.getChildrenSize() === 1) {
|
|
85
|
-
const firstChild = listItemNode.getFirstChild();
|
|
86
|
-
if ($isListNode(firstChild)) {
|
|
87
|
-
output.push(listExport(firstChild, exportChildren, depth + 1));
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
const indent = " ".repeat(depth * LIST_INDENT_SIZE);
|
|
92
|
-
const listType = listNode.getListType();
|
|
93
|
-
const prefix =
|
|
94
|
-
listType === "number"
|
|
95
|
-
? `${listNode.getStart() + index}. `
|
|
96
|
-
: listType === "check"
|
|
97
|
-
? `- [${listItemNode.getChecked() ? "x" : " "}] `
|
|
98
|
-
: "- ";
|
|
99
|
-
output.push(indent + prefix + exportChildren(listItemNode));
|
|
100
|
-
index++;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return output.join("\n");
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const CHECK_LIST_TRANSFORMER: ElementTransformer = {
|
|
108
|
-
dependencies: [ListNode, ListItemNode],
|
|
109
|
-
export: (node, exportChildren) => {
|
|
110
|
-
return $isListNode(node) ? listExport(node, exportChildren, 0) : null;
|
|
111
|
-
},
|
|
112
|
-
regExp: /^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,
|
|
113
|
-
replace: listReplace("check"),
|
|
114
|
-
type: "element",
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
const MENTION_TRANSFORMER: TextMatchTransformer = {
|
|
118
|
-
type: "text-match",
|
|
119
|
-
trigger: "<",
|
|
120
|
-
dependencies: [MentionNode],
|
|
121
|
-
importRegExp: mentionRegex(),
|
|
122
|
-
regExp: mentionRegex(),
|
|
123
|
-
export: (node) => {
|
|
124
|
-
if ($isMentionNode(node)) {
|
|
125
|
-
return formatMention(node.data);
|
|
126
|
-
}
|
|
127
|
-
return null;
|
|
128
|
-
},
|
|
129
|
-
replace: (textNode, match) => {
|
|
130
|
-
const kind = match[2];
|
|
131
|
-
const name = match[3].replace(/_/g, " ");
|
|
132
|
-
const id = match[4];
|
|
133
|
-
const data: IMentionData = {
|
|
134
|
-
kind,
|
|
135
|
-
name,
|
|
136
|
-
id,
|
|
137
|
-
clickable: false,
|
|
138
|
-
};
|
|
139
|
-
const node = $createMentionNode(data);
|
|
140
|
-
textNode.replace(node);
|
|
141
|
-
},
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
export const customMarkdownTransformers = [
|
|
145
|
-
MENTION_TRANSFORMER,
|
|
146
|
-
CHECK_LIST_TRANSFORMER, // This needs to be first or checklists will be treated as unordered lists
|
|
147
|
-
...TRANSFORMERS.filter((transformer) => {
|
|
148
|
-
const t = transformer as { dependencies?: { name?: string }[] };
|
|
149
|
-
// disable headings for this markdown since these are inline messages
|
|
150
|
-
if (t.dependencies?.[0]?.name === "HeadingNode") {
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
return true;
|
|
154
|
-
}),
|
|
155
|
-
];
|
|
156
|
-
|
|
157
|
-
interface IProps {
|
|
158
|
-
markdownObs: Observable<string>;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
export function MarkdownPlugin(props: IProps) {
|
|
162
|
-
const [editor] = useLexicalComposerContext();
|
|
163
|
-
const { markdownObs } = props;
|
|
164
|
-
|
|
165
|
-
useEffect(() => {
|
|
166
|
-
let markdown = "";
|
|
167
|
-
|
|
168
|
-
function setMarkdown() {
|
|
169
|
-
const newMarkdown = markdownObs() || "";
|
|
170
|
-
if (newMarkdown === markdown) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
markdown = newMarkdown;
|
|
174
|
-
editor.update(() => {
|
|
175
|
-
$convertFromMarkdownString(markdown, customMarkdownTransformers, undefined, true, false);
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
setMarkdown();
|
|
180
|
-
|
|
181
|
-
const sub = markdownObs.subscribe(() => {
|
|
182
|
-
setMarkdown();
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
const sub2Dispose = editor.registerUpdateListener(({ editorState }) => {
|
|
186
|
-
editorState.read(() => {
|
|
187
|
-
const newMarkdown = $convertToMarkdownString(customMarkdownTransformers, undefined, true);
|
|
188
|
-
if (newMarkdown !== markdown) {
|
|
189
|
-
markdown = newMarkdown;
|
|
190
|
-
markdownObs(markdown);
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
return () => {
|
|
196
|
-
sub.dispose();
|
|
197
|
-
sub2Dispose();
|
|
198
|
-
};
|
|
199
|
-
}, [editor, markdownObs]);
|
|
200
|
-
|
|
201
|
-
return null;
|
|
202
|
-
}
|