@peers-app/peers-ui 0.14.0 → 0.15.0
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/.github/workflows/publish.yml +8 -5
- package/babel.config.js +4 -4
- package/biome.json +191 -0
- package/dist/command-palette/command-palette-ui.d.ts +1 -2
- package/dist/command-palette/command-palette-ui.js +175 -244
- package/dist/command-palette/command-palette.js +65 -64
- package/dist/components/chat-overlay.d.ts +2 -2
- package/dist/components/chat-overlay.js +160 -217
- package/dist/components/checkbox.d.ts +5 -4
- package/dist/components/checkbox.js +4 -7
- package/dist/components/group-switcher.d.ts +1 -2
- package/dist/components/group-switcher.js +119 -159
- package/dist/components/input-date.d.ts +3 -3
- package/dist/components/input-date.js +6 -6
- package/dist/components/input-number.d.ts +7 -6
- package/dist/components/input-number.js +25 -20
- package/dist/components/input.d.ts +5 -4
- package/dist/components/input.js +4 -7
- package/dist/components/inverse-lazy-list.d.ts +3 -3
- package/dist/components/inverse-lazy-list.js +13 -47
- package/dist/components/io-schema-values.d.ts +5 -6
- package/dist/components/io-schema-values.js +28 -65
- package/dist/components/io-schema.d.ts +4 -5
- package/dist/components/io-schema.js +42 -79
- package/dist/components/lazy-list.d.ts +3 -3
- package/dist/components/lazy-list.js +38 -58
- package/dist/components/list-screen.d.ts +3 -8
- package/dist/components/list-screen.js +28 -23
- package/dist/components/loading-indicator.d.ts +1 -2
- package/dist/components/loading-indicator.js +2 -6
- package/dist/components/markdown-editor/autolink-plugin.js +5 -8
- package/dist/components/markdown-editor/editor-inline.d.ts +2 -3
- package/dist/components/markdown-editor/editor-inline.js +2 -6
- package/dist/components/markdown-editor/editor.d.ts +6 -6
- package/dist/components/markdown-editor/editor.js +9 -19
- package/dist/components/markdown-editor/markdown-plugin.d.ts +1 -1
- package/dist/components/markdown-editor/markdown-plugin.js +20 -21
- package/dist/components/markdown-editor/mention-node.d.ts +2 -2
- package/dist/components/markdown-editor/mention-node.js +24 -24
- package/dist/components/markdown-editor/mentions-plugin.d.ts +2 -2
- package/dist/components/markdown-editor/mentions-plugin.js +61 -62
- package/dist/components/markdown-editor/theme.js +28 -28
- package/dist/components/markdown-editor/toolbar.d.ts +2 -3
- package/dist/components/markdown-editor/toolbar.js +32 -49
- package/dist/components/markdown-with-mentions.d.ts +1 -1
- package/dist/components/markdown-with-mentions.js +43 -43
- package/dist/components/message-logs/message-logs.d.ts +1 -2
- package/dist/components/message-logs/message-logs.js +91 -116
- package/dist/components/messages/avatar.d.ts +3 -4
- package/dist/components/messages/avatar.js +37 -46
- package/dist/components/messages/channel-message-list.d.ts +5 -6
- package/dist/components/messages/channel-message-list.js +34 -34
- package/dist/components/messages/channel-view.d.ts +1 -2
- package/dist/components/messages/channel-view.js +23 -57
- package/dist/components/messages/message-compose.d.ts +3 -4
- package/dist/components/messages/message-compose.js +27 -38
- package/dist/components/messages/message-display.d.ts +2 -3
- package/dist/components/messages/message-display.js +42 -95
- package/dist/components/messages/thread-message-list.d.ts +4 -5
- package/dist/components/messages/thread-message-list.js +29 -29
- package/dist/components/router.d.ts +1 -2
- package/dist/components/router.js +58 -66
- package/dist/components/save-button.d.ts +3 -3
- package/dist/components/save-button.js +23 -33
- package/dist/components/sortable-list.d.ts +11 -12
- package/dist/components/sortable-list.js +42 -22
- package/dist/components/tabs.d.ts +3 -3
- package/dist/components/tabs.js +16 -47
- package/dist/components/tooltip.d.ts +4 -4
- package/dist/components/tooltip.js +4 -9
- package/dist/components/trust-level-badge.d.ts +2 -3
- package/dist/components/trust-level-badge.js +16 -16
- package/dist/components/trust-level-dropdown.d.ts +3 -4
- package/dist/components/trust-level-dropdown.js +32 -55
- package/dist/components/typeahead.d.ts +3 -3
- package/dist/components/typeahead.js +48 -89
- package/dist/components/voice-indicator.d.ts +2 -2
- package/dist/components/voice-indicator.js +93 -106
- package/dist/components/voice-subscribe-events.d.ts +32 -0
- package/dist/components/voice-subscribe-events.js +2 -0
- package/dist/globals.d.ts +3 -5
- package/dist/globals.js +22 -33
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +22 -12
- package/dist/hooks.test.js +129 -145
- package/dist/index.d.ts +9 -8
- package/dist/index.js +13 -12
- package/dist/mention-configs.d.ts +2 -2
- package/dist/mention-configs.js +55 -42
- package/dist/screens/assistants/assistant-config.d.ts +2 -3
- package/dist/screens/assistants/assistant-config.js +9 -22
- package/dist/screens/assistants/assistant-details.d.ts +1 -2
- package/dist/screens/assistants/assistant-details.js +13 -28
- package/dist/screens/assistants/assistant-info.d.ts +2 -3
- package/dist/screens/assistants/assistant-info.js +3 -17
- package/dist/screens/assistants/assistant-list.d.ts +1 -2
- package/dist/screens/assistants/assistant-list.js +15 -56
- package/dist/screens/assistants/assistant-tools.d.ts +2 -3
- package/dist/screens/assistants/assistant-tools.js +10 -24
- package/dist/screens/console-logs/console-logs-list.d.ts +1 -2
- package/dist/screens/console-logs/console-logs-list.js +130 -134
- package/dist/screens/console-logs/log-display.d.ts +2 -3
- package/dist/screens/console-logs/log-display.js +40 -42
- package/dist/screens/console-logs/log-filters.d.ts +1 -2
- package/dist/screens/console-logs/log-filters.js +2 -24
- package/dist/screens/console-logs/mobile-log-card.d.ts +2 -3
- package/dist/screens/console-logs/mobile-log-card.js +64 -67
- package/dist/screens/console-logs/resizable-table-header.d.ts +1 -2
- package/dist/screens/console-logs/resizable-table-header.js +31 -67
- package/dist/screens/contacts/contact-details.d.ts +1 -2
- package/dist/screens/contacts/contact-details.js +16 -46
- package/dist/screens/contacts/contact-list.d.ts +1 -2
- package/dist/screens/contacts/contact-list.js +44 -103
- package/dist/screens/contacts/index.d.ts +4 -4
- package/dist/screens/contacts/index.js +1 -1
- package/dist/screens/contacts/user-connect.d.ts +1 -2
- package/dist/screens/contacts/user-connect.js +85 -186
- package/dist/screens/data-explorer/data-explorer.d.ts +1 -2
- package/dist/screens/data-explorer/data-explorer.js +61 -181
- package/dist/screens/data-explorer/index.d.ts +2 -2
- package/dist/screens/data-explorer/query-executor.d.ts +1 -2
- package/dist/screens/data-explorer/query-executor.js +56 -166
- package/dist/screens/groups/group-details.d.ts +1 -2
- package/dist/screens/groups/group-details.js +27 -122
- package/dist/screens/groups/group-invite-listener.d.ts +2 -3
- package/dist/screens/groups/group-invite-listener.js +8 -104
- package/dist/screens/groups/group-list.d.ts +1 -2
- package/dist/screens/groups/group-list.js +56 -133
- package/dist/screens/groups/group-members.d.ts +2 -3
- package/dist/screens/groups/group-members.js +62 -132
- package/dist/screens/groups/index.d.ts +4 -4
- package/dist/screens/groups/index.js +1 -1
- package/dist/screens/join-group/index.d.ts +2 -2
- package/dist/screens/join-group/join-group.d.ts +1 -2
- package/dist/screens/join-group/join-group.js +9 -109
- package/dist/screens/network-viewer/connection-troubleshooter.d.ts +2 -3
- package/dist/screens/network-viewer/connection-troubleshooter.js +89 -193
- package/dist/screens/network-viewer/cpu-usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/cpu-usage-graph.js +60 -99
- package/dist/screens/network-viewer/device-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/device-details-modal.js +25 -177
- package/dist/screens/network-viewer/group-details-modal.d.ts +1 -2
- package/dist/screens/network-viewer/group-details-modal.js +31 -142
- package/dist/screens/network-viewer/index.d.ts +4 -4
- package/dist/screens/network-viewer/index.js +3 -3
- package/dist/screens/network-viewer/network-viewer-ipc.d.ts +22 -0
- package/dist/screens/network-viewer/network-viewer-ipc.js +6 -0
- package/dist/screens/network-viewer/network-viewer.d.ts +1 -2
- package/dist/screens/network-viewer/network-viewer.js +91 -296
- package/dist/screens/network-viewer/usage-graph.d.ts +1 -2
- package/dist/screens/network-viewer/usage-graph.js +78 -110
- package/dist/screens/packages/package-details.d.ts +1 -2
- package/dist/screens/packages/package-details.js +35 -41
- package/dist/screens/packages/package-info.d.ts +2 -2
- package/dist/screens/packages/package-info.js +33 -86
- package/dist/screens/packages/package-list.d.ts +1 -2
- package/dist/screens/packages/package-list.js +42 -106
- package/dist/screens/packages/package-new-local.d.ts +1 -2
- package/dist/screens/packages/package-new-local.js +13 -19
- package/dist/screens/packages/package-versions.d.ts +2 -3
- package/dist/screens/packages/package-versions.js +29 -96
- package/dist/screens/peer-types/peer-type-details.d.ts +3 -4
- package/dist/screens/peer-types/peer-type-details.js +26 -78
- package/dist/screens/peer-types/peer-type-list.d.ts +1 -2
- package/dist/screens/peer-types/peer-type-list.js +13 -24
- package/dist/screens/search/global-search.d.ts +1 -2
- package/dist/screens/search/global-search.js +104 -182
- package/dist/screens/settings/color-mode-dropdown.d.ts +3 -4
- package/dist/screens/settings/color-mode-dropdown.js +18 -37
- package/dist/screens/settings/settings-page.d.ts +1 -1
- package/dist/screens/settings/settings-page.js +86 -213
- package/dist/screens/settings/voice-settings-agent.d.ts +1 -1
- package/dist/screens/settings/voice-settings-agent.js +7 -44
- package/dist/screens/settings/voice-settings-api-keys.d.ts +2 -2
- package/dist/screens/settings/voice-settings-api-keys.js +2 -29
- package/dist/screens/settings/voice-settings-output.d.ts +2 -2
- package/dist/screens/settings/voice-settings-output.js +2 -40
- package/dist/screens/settings/voice-settings-providers.d.ts +2 -2
- package/dist/screens/settings/voice-settings-providers.js +2 -19
- package/dist/screens/settings/voice-settings-types.d.ts +4 -4
- package/dist/screens/settings/voice-settings-types.js +31 -31
- package/dist/screens/settings/voice-settings-wake-word.d.ts +2 -2
- package/dist/screens/settings/voice-settings-wake-word.js +2 -33
- package/dist/screens/settings/voice-settings.d.ts +1 -1
- package/dist/screens/settings/voice-settings.js +35 -112
- package/dist/screens/setup-user.d.ts +1 -2
- package/dist/screens/setup-user.js +38 -116
- package/dist/screens/tools/tool-code.d.ts +2 -3
- package/dist/screens/tools/tool-code.js +9 -13
- package/dist/screens/tools/tool-details.d.ts +1 -2
- package/dist/screens/tools/tool-details.js +26 -39
- package/dist/screens/tools/tool-info.d.ts +2 -3
- package/dist/screens/tools/tool-info.js +9 -48
- package/dist/screens/tools/tool-list.d.ts +1 -2
- package/dist/screens/tools/tool-list.js +33 -65
- package/dist/screens/tools/tool-schema.d.ts +2 -3
- package/dist/screens/tools/tool-schema.js +2 -13
- package/dist/screens/tools/tool-test-details.d.ts +1 -2
- package/dist/screens/tools/tool-test-details.js +12 -28
- package/dist/screens/tools/tool-test-list.d.ts +1 -2
- package/dist/screens/tools/tool-test-list.js +17 -56
- package/dist/screens/variables/variable-details.d.ts +1 -2
- package/dist/screens/variables/variable-details.js +19 -86
- package/dist/screens/variables/variable-list.d.ts +1 -2
- package/dist/screens/variables/variable-list.js +16 -27
- package/dist/screens/welcome-modal.d.ts +1 -2
- package/dist/screens/welcome-modal.js +44 -111
- package/dist/screens/workflows/workflow-details.d.ts +1 -2
- package/dist/screens/workflows/workflow-details.js +17 -31
- package/dist/screens/workflows/workflow-info.d.ts +2 -3
- package/dist/screens/workflows/workflow-info.js +2 -9
- package/dist/screens/workflows/workflow-instructions.d.ts +2 -3
- package/dist/screens/workflows/workflow-instructions.js +23 -55
- package/dist/screens/workflows/workflow-list.d.ts +1 -2
- package/dist/screens/workflows/workflow-list.js +23 -62
- package/dist/setupTests.d.ts +1 -1
- package/dist/setupTests.js +10 -11
- package/dist/system-apps/assistants.app.d.ts +1 -1
- package/dist/system-apps/assistants.app.js +3 -3
- package/dist/system-apps/console-logs.app.d.ts +1 -1
- package/dist/system-apps/console-logs.app.js +3 -3
- package/dist/system-apps/contacts.app.d.ts +1 -1
- package/dist/system-apps/contacts.app.js +4 -4
- package/dist/system-apps/data-explorer.app.d.ts +1 -1
- package/dist/system-apps/data-explorer.app.js +4 -4
- package/dist/system-apps/groups.app.d.ts +1 -1
- package/dist/system-apps/groups.app.js +4 -4
- package/dist/system-apps/index.d.ts +17 -17
- package/dist/system-apps/index.js +52 -52
- package/dist/system-apps/join-group.app.d.ts +1 -1
- package/dist/system-apps/join-group.app.js +4 -4
- package/dist/system-apps/mobile-settings.app.d.ts +1 -1
- package/dist/system-apps/mobile-settings.app.js +3 -3
- package/dist/system-apps/network-viewer.app.d.ts +1 -1
- package/dist/system-apps/network-viewer.app.js +4 -4
- package/dist/system-apps/packages.app.d.ts +1 -1
- package/dist/system-apps/packages.app.js +3 -3
- package/dist/system-apps/search.app.d.ts +1 -1
- package/dist/system-apps/search.app.js +4 -4
- package/dist/system-apps/settings.app.d.ts +1 -1
- package/dist/system-apps/settings.app.js +3 -3
- package/dist/system-apps/threads.app.d.ts +1 -1
- package/dist/system-apps/threads.app.js +3 -3
- package/dist/system-apps/tools.app.d.ts +1 -1
- package/dist/system-apps/tools.app.js +3 -3
- package/dist/system-apps/types.app.d.ts +1 -1
- package/dist/system-apps/types.app.js +3 -3
- package/dist/system-apps/variables.app.d.ts +1 -1
- package/dist/system-apps/variables.app.js +3 -3
- package/dist/system-apps/workflows.app.d.ts +1 -1
- package/dist/system-apps/workflows.app.js +3 -3
- package/dist/tabs-layout/tabs-layout.d.ts +2 -3
- package/dist/tabs-layout/tabs-layout.js +215 -246
- package/dist/tabs-layout/tabs-state.d.ts +2 -2
- package/dist/tabs-layout/tabs-state.js +73 -61
- package/dist/ui-defaults/index.d.ts +2 -2
- package/dist/ui-defaults/list-screen.d.ts +2 -3
- package/dist/ui-defaults/list-screen.js +33 -37
- package/dist/ui-defaults/markdown-field.js +24 -56
- package/dist/ui-router/routes-loader.d.ts +1 -1
- package/dist/ui-router/routes-loader.js +17 -13
- package/dist/ui-router/ui-loader.d.ts +6 -6
- package/dist/ui-router/ui-loader.js +172 -268
- package/dist/utils.js +49 -39
- package/jest.config.js +16 -16
- package/package.json +16 -14
- package/src/command-palette/command-palette-ui.tsx +261 -237
- package/src/command-palette/command-palette.ts +81 -78
- package/src/components/chat-overlay.tsx +366 -261
- package/src/components/checkbox.tsx +15 -12
- package/src/components/group-switcher.tsx +150 -105
- package/src/components/input-date.tsx +17 -16
- package/src/components/input-number.tsx +47 -31
- package/src/components/input.tsx +15 -12
- package/src/components/inverse-lazy-list.tsx +14 -13
- package/src/components/io-schema-values.tsx +51 -69
- package/src/components/io-schema.tsx +94 -69
- package/src/components/lazy-list.tsx +51 -34
- package/src/components/list-screen.tsx +51 -35
- package/src/components/loading-indicator.tsx +2 -4
- package/src/components/markdown-editor/autolink-plugin.tsx +4 -11
- package/src/components/markdown-editor/editor-inline.tsx +3 -4
- package/src/components/markdown-editor/editor.tsx +53 -51
- package/src/components/markdown-editor/markdown-plugin.tsx +48 -40
- package/src/components/markdown-editor/mention-node.ts +39 -38
- package/src/components/markdown-editor/mentions-plugin.tsx +99 -101
- package/src/components/markdown-editor/theme.ts +28 -29
- package/src/components/markdown-editor/toolbar.tsx +53 -47
- package/src/components/markdown-with-mentions.tsx +56 -46
- package/src/components/message-logs/message-logs.tsx +225 -165
- package/src/components/messages/avatar.tsx +70 -52
- package/src/components/messages/channel-message-list.tsx +80 -68
- package/src/components/messages/channel-view.tsx +34 -33
- package/src/components/messages/message-compose.tsx +84 -67
- package/src/components/messages/message-display.tsx +103 -89
- package/src/components/messages/thread-message-list.tsx +53 -44
- package/src/components/router.tsx +42 -43
- package/src/components/save-button.tsx +43 -39
- package/src/components/sortable-list.tsx +77 -49
- package/src/components/tabs.tsx +31 -31
- package/src/components/tooltip.tsx +21 -28
- package/src/components/trust-level-badge.tsx +15 -11
- package/src/components/trust-level-dropdown.tsx +49 -19
- package/src/components/typeahead.tsx +57 -59
- package/src/components/voice-indicator.tsx +158 -141
- package/src/components/voice-subscribe-events.ts +20 -0
- package/src/globals.tsx +42 -40
- package/src/hooks.test.tsx +141 -134
- package/src/hooks.ts +80 -48
- package/src/index.tsx +17 -10
- package/src/mention-configs.ts +122 -68
- package/src/screens/assistants/assistant-config.tsx +28 -18
- package/src/screens/assistants/assistant-details.tsx +35 -36
- package/src/screens/assistants/assistant-info.tsx +16 -11
- package/src/screens/assistants/assistant-list.tsx +37 -34
- package/src/screens/assistants/assistant-tools.tsx +41 -20
- package/src/screens/console-logs/console-logs-list.tsx +173 -140
- package/src/screens/console-logs/log-display.tsx +65 -38
- package/src/screens/console-logs/log-filters.tsx +4 -3
- package/src/screens/console-logs/mobile-log-card.tsx +78 -71
- package/src/screens/console-logs/resizable-table-header.tsx +29 -21
- package/src/screens/contacts/contact-details.tsx +29 -30
- package/src/screens/contacts/contact-list.tsx +71 -60
- package/src/screens/contacts/index.ts +5 -5
- package/src/screens/contacts/user-connect.tsx +177 -171
- package/src/screens/data-explorer/data-explorer.tsx +134 -98
- package/src/screens/data-explorer/index.ts +2 -3
- package/src/screens/data-explorer/query-executor.tsx +90 -80
- package/src/screens/groups/group-details.tsx +120 -101
- package/src/screens/groups/group-invite-listener.tsx +34 -37
- package/src/screens/groups/group-list.tsx +119 -103
- package/src/screens/groups/group-members.tsx +225 -164
- package/src/screens/groups/index.ts +5 -6
- package/src/screens/join-group/index.ts +2 -2
- package/src/screens/join-group/join-group.tsx +41 -39
- package/src/screens/network-viewer/connection-troubleshooter.tsx +145 -104
- package/src/screens/network-viewer/cpu-usage-graph.tsx +39 -43
- package/src/screens/network-viewer/device-details-modal.tsx +46 -59
- package/src/screens/network-viewer/group-details-modal.tsx +68 -49
- package/src/screens/network-viewer/index.ts +4 -5
- package/src/screens/network-viewer/network-viewer-ipc.ts +23 -0
- package/src/screens/network-viewer/network-viewer.tsx +261 -236
- package/src/screens/network-viewer/usage-graph.tsx +57 -49
- package/src/screens/packages/package-details.tsx +43 -35
- package/src/screens/packages/package-info.tsx +107 -66
- package/src/screens/packages/package-list.tsx +175 -98
- package/src/screens/packages/package-new-local.tsx +28 -26
- package/src/screens/packages/package-versions.tsx +102 -77
- package/src/screens/peer-types/peer-type-details.tsx +60 -50
- package/src/screens/peer-types/peer-type-list.tsx +20 -30
- package/src/screens/search/global-search.tsx +153 -137
- package/src/screens/settings/color-mode-dropdown.tsx +52 -35
- package/src/screens/settings/settings-page.tsx +215 -141
- package/src/screens/settings/voice-settings-agent.tsx +13 -12
- package/src/screens/settings/voice-settings-api-keys.tsx +14 -12
- package/src/screens/settings/voice-settings-output.tsx +12 -11
- package/src/screens/settings/voice-settings-providers.tsx +7 -3
- package/src/screens/settings/voice-settings-types.ts +52 -49
- package/src/screens/settings/voice-settings-wake-word.tsx +25 -9
- package/src/screens/settings/voice-settings.tsx +66 -43
- package/src/screens/setup-user.tsx +88 -41
- package/src/screens/tools/tool-code.tsx +12 -17
- package/src/screens/tools/tool-details.tsx +28 -28
- package/src/screens/tools/tool-info.tsx +14 -19
- package/src/screens/tools/tool-list.tsx +58 -40
- package/src/screens/tools/tool-schema.tsx +16 -9
- package/src/screens/tools/tool-test-details.tsx +11 -22
- package/src/screens/tools/tool-test-list.tsx +29 -30
- package/src/screens/variables/variable-details.tsx +63 -51
- package/src/screens/variables/variable-list.tsx +29 -30
- package/src/screens/welcome-modal.tsx +68 -48
- package/src/screens/workflows/workflow-details.tsx +40 -30
- package/src/screens/workflows/workflow-info.tsx +4 -11
- package/src/screens/workflows/workflow-instructions.tsx +35 -28
- package/src/screens/workflows/workflow-list.tsx +50 -40
- package/src/setupTests.ts +14 -13
- package/src/system-apps/assistants.app.ts +5 -5
- package/src/system-apps/console-logs.app.ts +4 -4
- package/src/system-apps/contacts.app.ts +6 -6
- package/src/system-apps/data-explorer.app.ts +5 -5
- package/src/system-apps/groups.app.ts +6 -6
- package/src/system-apps/index.ts +49 -49
- package/src/system-apps/join-group.app.ts +5 -5
- package/src/system-apps/mobile-settings.app.ts +4 -5
- package/src/system-apps/network-viewer.app.ts +5 -5
- package/src/system-apps/packages.app.ts +5 -5
- package/src/system-apps/search.app.ts +6 -6
- package/src/system-apps/settings.app.ts +5 -5
- package/src/system-apps/threads.app.ts +5 -5
- package/src/system-apps/tools.app.ts +5 -5
- package/src/system-apps/types.app.ts +5 -5
- package/src/system-apps/variables.app.ts +5 -5
- package/src/system-apps/workflows.app.ts +5 -5
- package/src/tabs-layout/tabs-layout.tsx +345 -254
- package/src/tabs-layout/tabs-state.ts +100 -81
- package/src/ui-defaults/index.ts +2 -3
- package/src/ui-defaults/list-screen.tsx +45 -40
- package/src/ui-defaults/markdown-field.tsx +22 -26
- package/src/ui-router/routes-loader.ts +40 -24
- package/src/ui-router/ui-loader.tsx +312 -214
- package/src/utils.ts +68 -81
- package/tsconfig.json +5 -10
- package/dist/components/input-datetime.d.ts +0 -7
- package/dist/components/input-datetime.js +0 -35
- package/dist/components/lazy-sortable-list.d.ts +0 -29
- package/dist/components/lazy-sortable-list.js +0 -12
- package/dist/components/left-bar.d.ts +0 -5
- package/dist/components/left-bar.js +0 -207
- package/dist/components/main-content-container.d.ts +0 -2
- package/dist/components/main-content-container.js +0 -92
- package/dist/components/messages/thread-view.d.ts +0 -6
- package/dist/components/messages/thread-view.js +0 -174
- package/dist/components/off-canvas.d.ts +0 -13
- package/dist/components/off-canvas.js +0 -89
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +0 -6
- package/dist/components/text-list-editor.tsx/text-list-editor.js +0 -13
- package/dist/components/top-bar.d.ts +0 -2
- package/dist/components/top-bar.js +0 -51
- package/dist/components/typeahead/mentions-plugin.d.ts +0 -7
- package/dist/components/typeahead/mentions-plugin.js +0 -203
- package/dist/components/typeahead/typeahead-editor.d.ts +0 -15
- package/dist/components/typeahead/typeahead-editor.js +0 -134
- package/dist/components/typeahead/typeahead.d.ts +0 -12
- package/dist/components/typeahead/typeahead.js +0 -94
- package/dist/screens/profile.d.ts +0 -2
- package/dist/screens/profile.js +0 -76
- package/src/components/input-datetime.tsx +0 -41
- package/src/components/lazy-sortable-list.tsx +0 -51
- package/src/components/left-bar.tsx +0 -322
- package/src/components/main-content-container.tsx +0 -79
- package/src/components/messages/thread-view.tsx +0 -214
- package/src/components/off-canvas.tsx +0 -83
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +0 -13
- package/src/components/top-bar.tsx +0 -119
- package/src/components/typeahead/mentions-plugin.tsx +0 -265
- package/src/components/typeahead/typeahead-editor.tsx +0 -140
- package/src/components/typeahead/typeahead.tsx +0 -77
- package/src/screens/profile.tsx +0 -75
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
1
|
+
import { formatMoney, type Observable, unwrapObservable } from "@peers-app/peers-sdk";
|
|
2
|
+
import _, { isNumber } from "lodash";
|
|
3
|
+
import type React from "react";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { useObservable } from "../hooks";
|
|
5
6
|
|
|
6
|
-
interface IProps
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
interface IProps
|
|
8
|
+
extends Omit<
|
|
9
|
+
React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
|
|
10
|
+
"value"
|
|
11
|
+
> {
|
|
12
|
+
value?: number | null | string | Observable<number | null | string | undefined>;
|
|
13
|
+
format?: "money";
|
|
14
|
+
precision?: number;
|
|
15
|
+
refPassthrough?: React.LegacyRef<HTMLInputElement>;
|
|
11
16
|
}
|
|
12
17
|
|
|
13
18
|
export function InputNumber(props: IProps) {
|
|
@@ -16,45 +21,50 @@ export function InputNumber(props: IProps) {
|
|
|
16
21
|
precision = 2;
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
const propsPassthrough = { ...props } as Record<string, unknown> & typeof props;
|
|
25
|
+
for (const name of ["value", "format", "precision", "refPassthrough"] as const) {
|
|
26
|
+
delete propsPassthrough[name];
|
|
27
|
+
}
|
|
22
28
|
|
|
23
29
|
const [value, setValue] = useObservable(props.value);
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
if (isNaN(Number(value)) || value === null || String(value).trim() ===
|
|
27
|
-
return
|
|
31
|
+
const [displayValue, setDisplayValue] = useState<string>(() => {
|
|
32
|
+
if (Number.isNaN(Number(value)) || value === null || String(value).trim() === "") {
|
|
33
|
+
return "";
|
|
28
34
|
}
|
|
29
|
-
if (format ===
|
|
35
|
+
if (format === "money") {
|
|
30
36
|
return formatMoney(Number(unwrapObservable(props.value)), precision);
|
|
31
37
|
}
|
|
32
38
|
return String(value);
|
|
33
39
|
});
|
|
34
|
-
|
|
35
40
|
|
|
36
41
|
function onChange(evt: React.ChangeEvent<HTMLInputElement>) {
|
|
37
|
-
|
|
42
|
+
const _value: string = evt.target.value;
|
|
38
43
|
setDisplayValue(_value);
|
|
39
44
|
// convert blank to null
|
|
40
|
-
if (String(_value).trim() ===
|
|
45
|
+
if (String(_value).trim() === "") {
|
|
41
46
|
setValue(null);
|
|
42
47
|
return;
|
|
43
48
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (isNumber(
|
|
48
|
-
setValue(
|
|
49
|
+
|
|
50
|
+
const stripped = _value.replace(/\$/g, "");
|
|
51
|
+
const parsed = Number(stripped);
|
|
52
|
+
if (isNumber(parsed) && !Number.isNaN(parsed)) {
|
|
53
|
+
setValue(parsed);
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
|
|
52
|
-
function onBlur(
|
|
53
|
-
if (
|
|
54
|
-
|
|
57
|
+
function onBlur(_evt: React.FocusEvent<HTMLInputElement>) {
|
|
58
|
+
if (
|
|
59
|
+
format === "money" &&
|
|
60
|
+
!Number.isNaN(Number(value)) &&
|
|
61
|
+
value !== null &&
|
|
62
|
+
String(value).trim() !== ""
|
|
63
|
+
) {
|
|
64
|
+
const fmtMoney = formatMoney(Number(value), precision);
|
|
55
65
|
setDisplayValue(fmtMoney);
|
|
56
66
|
} else if (value === null) {
|
|
57
|
-
setDisplayValue(
|
|
67
|
+
setDisplayValue("");
|
|
58
68
|
} else {
|
|
59
69
|
setDisplayValue(String(value));
|
|
60
70
|
}
|
|
@@ -62,6 +72,12 @@ export function InputNumber(props: IProps) {
|
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
return (
|
|
65
|
-
<input
|
|
66
|
-
|
|
67
|
-
}
|
|
75
|
+
<input
|
|
76
|
+
{...propsPassthrough}
|
|
77
|
+
ref={refPassthrough}
|
|
78
|
+
value={displayValue}
|
|
79
|
+
onChange={onChange}
|
|
80
|
+
onBlur={onBlur}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
package/src/components/input.tsx
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import type { Observable } from "@peers-app/peers-sdk";
|
|
2
|
+
import type React from "react";
|
|
3
|
+
import { useObservable } from "../hooks";
|
|
3
4
|
|
|
4
|
-
interface IProps
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
interface IProps
|
|
6
|
+
extends Omit<
|
|
7
|
+
React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>,
|
|
8
|
+
"value"
|
|
9
|
+
> {
|
|
10
|
+
value?: string | number | null | Observable<string | number | null | undefined>;
|
|
11
|
+
type?: React.HTMLInputTypeAttribute;
|
|
7
12
|
}
|
|
8
13
|
|
|
9
14
|
export function Input(props: IProps) {
|
|
10
15
|
const [value, setValue] = useObservable(props.value);
|
|
11
|
-
const type = props.type ??
|
|
16
|
+
const type = props.type ?? typeof value;
|
|
12
17
|
function onChange(evt: React.ChangeEvent<HTMLInputElement>) {
|
|
13
|
-
let _value:
|
|
14
|
-
if (type ===
|
|
18
|
+
let _value: string | number = evt.target.value;
|
|
19
|
+
if (type === "number") {
|
|
15
20
|
_value = Number(_value);
|
|
16
21
|
}
|
|
17
22
|
setValue(_value);
|
|
18
23
|
}
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
}
|
|
24
|
+
return <input onChange={onChange} type={type} {...props} value={value ?? ""} />;
|
|
25
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import
|
|
1
|
+
import type React from "react";
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import InfiniteScroll from "react-infinite-scroll-component";
|
|
3
4
|
|
|
4
5
|
interface IInverseLazyListProps<T> {
|
|
5
6
|
/** Unique id for the scroll container — required to avoid id collisions */
|
|
@@ -13,7 +14,7 @@ interface IInverseLazyListProps<T> {
|
|
|
13
14
|
/** Custom loading indicator */
|
|
14
15
|
loadingIndicator?: React.ReactNode;
|
|
15
16
|
/** Change this value to reset the list and reload from scratch */
|
|
16
|
-
resetTrigger?:
|
|
17
|
+
resetTrigger?: unknown;
|
|
17
18
|
/** Style for the outer scroll container */
|
|
18
19
|
style?: React.CSSProperties;
|
|
19
20
|
}
|
|
@@ -38,14 +39,14 @@ export function InverseLazyList<T>(props: IInverseLazyListProps<T>) {
|
|
|
38
39
|
// Expose prepend function via ref so callers can push live updates
|
|
39
40
|
useEffect(() => {
|
|
40
41
|
if (props.prependRef) {
|
|
41
|
-
props.prependRef.current = (item: T) => setItems(prev => [item, ...prev]);
|
|
42
|
+
props.prependRef.current = (item: T) => setItems((prev) => [item, ...prev]);
|
|
42
43
|
}
|
|
43
44
|
return () => {
|
|
44
45
|
if (props.prependRef) props.prependRef.current = null;
|
|
45
46
|
};
|
|
46
47
|
}, [props.prependRef]);
|
|
47
48
|
|
|
48
|
-
|
|
49
|
+
const loadMore = useCallback(async () => {
|
|
49
50
|
if (isLoadingRef.current || allLoaded) return;
|
|
50
51
|
isLoadingRef.current = true;
|
|
51
52
|
try {
|
|
@@ -53,41 +54,41 @@ export function InverseLazyList<T>(props: IInverseLazyListProps<T>) {
|
|
|
53
54
|
if (!moreItems.length) {
|
|
54
55
|
setAllLoaded(true);
|
|
55
56
|
} else {
|
|
56
|
-
setItems(prev => [...prev, ...moreItems]);
|
|
57
|
+
setItems((prev) => [...prev, ...moreItems]);
|
|
57
58
|
}
|
|
58
59
|
} finally {
|
|
59
60
|
isLoadingRef.current = false;
|
|
60
61
|
}
|
|
61
|
-
}
|
|
62
|
+
}, [props.loadMore, allLoaded]);
|
|
62
63
|
|
|
63
64
|
// Auto-preload when items are sparse
|
|
64
65
|
useEffect(() => {
|
|
65
66
|
if (items.length < PRELOAD_THRESHOLD && !allLoaded && !isLoadingRef.current) {
|
|
66
67
|
loadMore();
|
|
67
68
|
}
|
|
68
|
-
}, [items.length, allLoaded]);
|
|
69
|
+
}, [items.length, allLoaded, loadMore]);
|
|
69
70
|
|
|
70
71
|
// Reset when resetTrigger changes
|
|
71
72
|
useEffect(() => {
|
|
72
73
|
setItems([]);
|
|
73
74
|
setAllLoaded(false);
|
|
74
75
|
isLoadingRef.current = false;
|
|
75
|
-
}, [
|
|
76
|
+
}, []);
|
|
76
77
|
|
|
77
78
|
return (
|
|
78
79
|
<div
|
|
79
80
|
id={props.scrollableId}
|
|
80
81
|
style={{
|
|
81
|
-
overflow:
|
|
82
|
-
display:
|
|
83
|
-
flexDirection:
|
|
82
|
+
overflow: "auto",
|
|
83
|
+
display: "flex",
|
|
84
|
+
flexDirection: "column-reverse",
|
|
84
85
|
...props.style,
|
|
85
86
|
}}
|
|
86
87
|
>
|
|
87
88
|
<InfiniteScroll
|
|
88
89
|
dataLength={items.length}
|
|
89
90
|
next={loadMore}
|
|
90
|
-
style={{ display:
|
|
91
|
+
style={{ display: "flex", flexDirection: "column-reverse", overflow: "hidden" }}
|
|
91
92
|
inverse={true}
|
|
92
93
|
hasMore={!allLoaded}
|
|
93
94
|
loader={
|
|
@@ -1,56 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {
|
|
2
|
+
camelCaseToSpaces,
|
|
3
|
+
type IOSchema,
|
|
4
|
+
type Observable,
|
|
5
|
+
observable,
|
|
6
|
+
} from "@peers-app/peers-sdk";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
import { useSubscription } from "../hooks";
|
|
9
|
+
import { Checkbox } from "./checkbox";
|
|
5
10
|
import { Input } from "./input";
|
|
6
11
|
import { InputNumber } from "./input-number";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
12
|
+
import { MarkdownEditorInline } from "./markdown-editor/editor-inline";
|
|
13
|
+
import { Tooltip } from "./tooltip";
|
|
9
14
|
|
|
10
15
|
interface IOSchemaValuesProps {
|
|
11
16
|
ioSchema: IOSchema;
|
|
12
|
-
values: Record<string,
|
|
17
|
+
values: Record<string, unknown>;
|
|
13
18
|
q: Observable<number>;
|
|
14
19
|
excludeFields?: string[];
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
export const IOSchemaValues = (props: IOSchemaValuesProps) => {
|
|
18
|
-
|
|
19
23
|
const { ioSchema, values, q } = props;
|
|
20
24
|
|
|
21
25
|
return (
|
|
22
26
|
<div>
|
|
23
|
-
{ioSchema.fields.map((field
|
|
27
|
+
{ioSchema.fields.map((field) => {
|
|
24
28
|
if (props.excludeFields?.includes(field.name)) {
|
|
25
29
|
return null;
|
|
26
30
|
}
|
|
27
31
|
return (
|
|
28
|
-
<div key={
|
|
32
|
+
<div key={field.name} className="mt-2">
|
|
29
33
|
<small className="text-body-secondary">
|
|
30
34
|
{camelCaseToSpaces(field.name)}:
|
|
31
35
|
<small>
|
|
32
|
-
<Tooltip markdownContent={field.description ??
|
|
36
|
+
<Tooltip markdownContent={field.description ?? ""} />
|
|
33
37
|
</small>
|
|
34
38
|
</small>
|
|
35
39
|
|
|
36
|
-
<IOSchemaValue
|
|
37
|
-
field={field}
|
|
38
|
-
values={values}
|
|
39
|
-
q={q}
|
|
40
|
-
/>
|
|
40
|
+
<IOSchemaValue field={field} values={values} q={q} />
|
|
41
41
|
</div>
|
|
42
|
-
)
|
|
42
|
+
);
|
|
43
43
|
})}
|
|
44
44
|
</div>
|
|
45
|
-
)
|
|
45
|
+
);
|
|
46
|
+
};
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
export const IOSchemaValue = (props: {
|
|
49
|
+
field: IOSchema["fields"][0];
|
|
50
|
+
values: Record<string, unknown>;
|
|
51
|
+
q: Observable<number>;
|
|
52
|
+
}) => {
|
|
50
53
|
const { field, values, q } = props;
|
|
51
54
|
|
|
52
55
|
const [valueObs] = useState(() => {
|
|
53
|
-
|
|
56
|
+
// Field values are heterogeneous (string | number | boolean | Date | …) at runtime.
|
|
57
|
+
// biome-ignore lint/suspicious/noExplicitAny: dynamic IO schema binding
|
|
58
|
+
const obs = observable<any | undefined>(values[field.name] ?? "");
|
|
54
59
|
return obs;
|
|
55
60
|
});
|
|
56
61
|
|
|
@@ -61,12 +66,16 @@ export const IOSchemaValue = (props: { field: IOSchema['fields'][0], values: Rec
|
|
|
61
66
|
});
|
|
62
67
|
return () => {
|
|
63
68
|
sub.dispose();
|
|
64
|
-
}
|
|
69
|
+
};
|
|
65
70
|
});
|
|
66
71
|
|
|
67
|
-
useSubscription(
|
|
68
|
-
|
|
69
|
-
|
|
72
|
+
useSubscription(
|
|
73
|
+
q,
|
|
74
|
+
() => {
|
|
75
|
+
valueObs(values[field.name] ?? "");
|
|
76
|
+
},
|
|
77
|
+
true,
|
|
78
|
+
);
|
|
70
79
|
|
|
71
80
|
const valueType = field.type;
|
|
72
81
|
|
|
@@ -74,49 +83,22 @@ export const IOSchemaValue = (props: { field: IOSchema['fields'][0], values: Rec
|
|
|
74
83
|
|
|
75
84
|
// TODO UI Types - text:secret, date:time, date:date, date:datetime, enum
|
|
76
85
|
|
|
77
|
-
if (valueType ===
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
/>
|
|
84
|
-
);
|
|
86
|
+
if (valueType === "string") {
|
|
87
|
+
if (
|
|
88
|
+
field.subType === "markdown" ||
|
|
89
|
+
(!field.subType && field.name.toLowerCase().includes("body"))
|
|
90
|
+
) {
|
|
91
|
+
return <MarkdownEditorInline value={valueObs} maxHeight={"250px"} />;
|
|
85
92
|
} else {
|
|
86
|
-
return
|
|
87
|
-
<Input
|
|
88
|
-
className='form-control'
|
|
89
|
-
value={valueObs}
|
|
90
|
-
/>
|
|
91
|
-
)
|
|
93
|
+
return <Input className="form-control" value={valueObs} />;
|
|
92
94
|
}
|
|
95
|
+
} else if (valueType === "number") {
|
|
96
|
+
return <InputNumber className="form-control" value={valueObs} />;
|
|
97
|
+
} else if (valueType === "boolean") {
|
|
98
|
+
return <Checkbox className="form-control" checked={valueObs} />;
|
|
99
|
+
} else if (valueType === "Date") {
|
|
100
|
+
return <Input className="form-control" value={valueObs} type="date" />;
|
|
101
|
+
} else {
|
|
102
|
+
return <div>Unknown type: {valueType}</div>;
|
|
93
103
|
}
|
|
94
|
-
|
|
95
|
-
return (
|
|
96
|
-
<InputNumber
|
|
97
|
-
className='form-control'
|
|
98
|
-
value={valueObs}
|
|
99
|
-
/>
|
|
100
|
-
)
|
|
101
|
-
}
|
|
102
|
-
else if (valueType === 'boolean') {
|
|
103
|
-
return (
|
|
104
|
-
<Checkbox
|
|
105
|
-
className='form-control'
|
|
106
|
-
checked={valueObs}
|
|
107
|
-
/>
|
|
108
|
-
)
|
|
109
|
-
}
|
|
110
|
-
else if (valueType === 'Date') {
|
|
111
|
-
return (
|
|
112
|
-
<Input
|
|
113
|
-
className='form-control'
|
|
114
|
-
value={valueObs}
|
|
115
|
-
type='date'
|
|
116
|
-
/>
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
return <div>Unknown type: {valueType}</div>
|
|
121
|
-
}
|
|
122
|
-
}
|
|
104
|
+
};
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
arrayAsTable,
|
|
3
|
+
FieldType,
|
|
4
|
+
type IField,
|
|
5
|
+
type IOSchema,
|
|
6
|
+
IOSchemaType,
|
|
7
|
+
initDoc,
|
|
8
|
+
newid,
|
|
9
|
+
type Observable,
|
|
10
|
+
observable,
|
|
11
|
+
} from "@peers-app/peers-sdk";
|
|
12
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
13
|
import { useObservable, useObservableState } from "../hooks";
|
|
4
14
|
import { MarkdownEditorInline } from "./markdown-editor/editor-inline";
|
|
5
15
|
|
|
6
|
-
export const IOSchemaEditor = (props: {
|
|
16
|
+
export const IOSchemaEditor = (props: {
|
|
17
|
+
ioSchema: Observable<IOSchema>;
|
|
18
|
+
simpleValueName: string;
|
|
19
|
+
}) => {
|
|
7
20
|
const { ioSchema, simpleValueName } = props;
|
|
8
21
|
|
|
9
22
|
if (!ioSchema().type) {
|
|
@@ -13,17 +26,17 @@ export const IOSchemaEditor = (props: { ioSchema: Observable<IOSchema>, simpleVa
|
|
|
13
26
|
ioSchema().fields = [];
|
|
14
27
|
}
|
|
15
28
|
|
|
16
|
-
const q = useObservableState(0)
|
|
29
|
+
const q = useObservableState(0);
|
|
17
30
|
|
|
18
31
|
useEffect(() => {
|
|
19
|
-
|
|
32
|
+
const schemaType = ioSchema().type;
|
|
20
33
|
const sub = ioSchema.subscribe(() => {
|
|
21
34
|
if (schemaType !== ioSchema().type) {
|
|
22
35
|
q(q() + 1);
|
|
23
36
|
}
|
|
24
37
|
});
|
|
25
38
|
return () => sub.dispose();
|
|
26
|
-
}, [ioSchema, q
|
|
39
|
+
}, [ioSchema, q]);
|
|
27
40
|
|
|
28
41
|
return (
|
|
29
42
|
<>
|
|
@@ -31,11 +44,11 @@ export const IOSchemaEditor = (props: { ioSchema: Observable<IOSchema>, simpleVa
|
|
|
31
44
|
className="form-select form-select-sm"
|
|
32
45
|
style={{ width: "150px", display: "inline-block" }}
|
|
33
46
|
defaultValue={ioSchema().type}
|
|
34
|
-
onChange={evt => {
|
|
47
|
+
onChange={(evt) => {
|
|
35
48
|
ioSchema({
|
|
36
49
|
...ioSchema(),
|
|
37
50
|
type: evt.target.value as IOSchemaType,
|
|
38
|
-
})
|
|
51
|
+
});
|
|
39
52
|
}}
|
|
40
53
|
>
|
|
41
54
|
<option value="none">None</option>
|
|
@@ -43,35 +56,39 @@ export const IOSchemaEditor = (props: { ioSchema: Observable<IOSchema>, simpleVa
|
|
|
43
56
|
<option value="complex">Complex Value</option>
|
|
44
57
|
</select>
|
|
45
58
|
|
|
46
|
-
<div
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
<div className="ms-4">
|
|
60
|
+
{ioSchema().type === IOSchemaType.simple && (
|
|
61
|
+
<SimpleInputSchema ioSchema={ioSchema} simpleValueName={simpleValueName} />
|
|
62
|
+
)}
|
|
50
63
|
{ioSchema().type === IOSchemaType.complex && <ComplexInputSchema ioSchema={ioSchema} />}
|
|
51
64
|
</div>
|
|
52
65
|
</>
|
|
53
|
-
)
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const SimpleInputSchema = (props: { ioSchema: Observable<IOSchema>, simpleValueName: string }) => {
|
|
66
|
+
);
|
|
67
|
+
};
|
|
57
68
|
|
|
69
|
+
export const SimpleInputSchema = (props: {
|
|
70
|
+
ioSchema: Observable<IOSchema>;
|
|
71
|
+
simpleValueName: string;
|
|
72
|
+
}) => {
|
|
58
73
|
const { ioSchema, simpleValueName } = props;
|
|
59
74
|
useObservable(ioSchema);
|
|
60
75
|
|
|
61
|
-
const [ioValueType] = useState(() =>
|
|
76
|
+
const [ioValueType] = useState(() =>
|
|
77
|
+
observable(ioSchema()?.fields?.[0]?.type || FieldType.string),
|
|
78
|
+
);
|
|
62
79
|
const [ioValueDesc] = useState(() => observable(ioSchema()?.fields?.[0]?.description || ""));
|
|
63
80
|
|
|
64
|
-
const setSimpleInputSchema = () => {
|
|
65
|
-
const _ioSchema = { ...ioSchema() }
|
|
81
|
+
const setSimpleInputSchema = useCallback(() => {
|
|
82
|
+
const _ioSchema = { ...ioSchema() };
|
|
66
83
|
_ioSchema.type = IOSchemaType.simple;
|
|
67
84
|
_ioSchema.fields = _ioSchema.fields || [];
|
|
68
85
|
_ioSchema.fields[0] = {
|
|
69
86
|
name: simpleValueName,
|
|
70
87
|
description: ioValueDesc(),
|
|
71
88
|
type: ioValueType(),
|
|
72
|
-
}
|
|
89
|
+
};
|
|
73
90
|
ioSchema(_ioSchema);
|
|
74
|
-
}
|
|
91
|
+
}, [ioSchema, simpleValueName, ioValueDesc, ioValueType]);
|
|
75
92
|
|
|
76
93
|
useEffect(() => {
|
|
77
94
|
const sub = ioValueType.subscribe(() => {
|
|
@@ -83,96 +100,104 @@ export const SimpleInputSchema = (props: { ioSchema: Observable<IOSchema>, simpl
|
|
|
83
100
|
return () => {
|
|
84
101
|
sub.dispose();
|
|
85
102
|
sub2.dispose();
|
|
86
|
-
}
|
|
87
|
-
}, [
|
|
103
|
+
};
|
|
104
|
+
}, [ioValueDesc, ioValueType, setSimpleInputSchema]);
|
|
88
105
|
|
|
89
106
|
const simpleValueTypes = Object.values(FieldType);
|
|
90
107
|
|
|
91
108
|
return (
|
|
92
109
|
<div>
|
|
93
|
-
<small>Value Type:</small
|
|
110
|
+
<small>Value Type:</small>
|
|
111
|
+
<br />
|
|
94
112
|
<select
|
|
95
113
|
className="form-select form-select-sm mt-2 mb-2"
|
|
96
114
|
defaultValue={ioValueType()}
|
|
97
|
-
onChange={evt => ioValueType(evt.target.value as FieldType)}
|
|
115
|
+
onChange={(evt) => ioValueType(evt.target.value as FieldType)}
|
|
98
116
|
style={{ width: "150px", display: "inline-block" }}
|
|
99
117
|
>
|
|
100
|
-
{simpleValueTypes.map((type) =>
|
|
101
|
-
<option
|
|
102
|
-
key={type}
|
|
103
|
-
value={type}
|
|
104
|
-
>
|
|
118
|
+
{simpleValueTypes.map((type) => (
|
|
119
|
+
<option key={type} value={type}>
|
|
105
120
|
{type}
|
|
106
121
|
</option>
|
|
107
|
-
)}
|
|
122
|
+
))}
|
|
108
123
|
</select>
|
|
109
124
|
<br />
|
|
110
125
|
<small>Value Description:</small>
|
|
111
|
-
<MarkdownEditorInline
|
|
112
|
-
value={ioValueDesc}
|
|
113
|
-
hideToolbar={true}
|
|
114
|
-
/>
|
|
126
|
+
<MarkdownEditorInline value={ioValueDesc} hideToolbar={true} />
|
|
115
127
|
</div>
|
|
116
|
-
)
|
|
117
|
-
}
|
|
128
|
+
);
|
|
129
|
+
};
|
|
118
130
|
|
|
119
131
|
export const ComplexInputSchema = (props: { ioSchema: Observable<IOSchema> }) => {
|
|
120
132
|
const { ioSchema } = props;
|
|
121
133
|
useObservable(ioSchema);
|
|
122
134
|
|
|
123
|
-
const [[fields,
|
|
135
|
+
const [[fields, _newRow], __setState] = useState(() => {
|
|
124
136
|
const _fields: IField[] = ioSchema().fields || [];
|
|
125
|
-
|
|
126
|
-
|
|
137
|
+
for (const f of _fields) {
|
|
138
|
+
// @ts-expect-error
|
|
139
|
+
f.fakeId = newid();
|
|
140
|
+
}
|
|
127
141
|
const inMemoryTable = arrayAsTable(_fields, {
|
|
128
142
|
primaryKeyName: "fakeId",
|
|
129
143
|
fields: [
|
|
130
|
-
{ name: "fakeId", type: FieldType.string, description:
|
|
131
|
-
{ name: "name", type: FieldType.string, description:
|
|
132
|
-
{ name: "type", type: FieldType.string, description:
|
|
133
|
-
{ name: "description", type: FieldType.string, description:
|
|
134
|
-
{ name: "default", type: FieldType.string, description:
|
|
135
|
-
{ name: "optional", type: FieldType.string, description:
|
|
136
|
-
{ name: "isArray", type: FieldType.string, description:
|
|
137
|
-
]
|
|
144
|
+
{ name: "fakeId", type: FieldType.string, description: "", defaultValue: () => newid() },
|
|
145
|
+
{ name: "name", type: FieldType.string, description: "" },
|
|
146
|
+
{ name: "type", type: FieldType.string, description: "" },
|
|
147
|
+
{ name: "description", type: FieldType.string, description: "" },
|
|
148
|
+
{ name: "default", type: FieldType.string, description: "" },
|
|
149
|
+
{ name: "optional", type: FieldType.string, description: "" },
|
|
150
|
+
{ name: "isArray", type: FieldType.string, description: "" },
|
|
151
|
+
],
|
|
138
152
|
});
|
|
139
|
-
const _fieldsDocs = _fields.map(f => initDoc(f, inMemoryTable));
|
|
153
|
+
const _fieldsDocs = _fields.map((f) => initDoc(f, inMemoryTable));
|
|
140
154
|
const _fieldsDocsObs = observable(_fieldsDocs);
|
|
141
155
|
|
|
142
156
|
const newRow = () => {
|
|
143
|
-
const newField = initDoc(
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
157
|
+
const newField = initDoc(
|
|
158
|
+
{
|
|
159
|
+
// @ts-expect-error
|
|
160
|
+
fakeId: newid(),
|
|
161
|
+
name: "",
|
|
162
|
+
description: "",
|
|
163
|
+
type: FieldType.string,
|
|
164
|
+
optional: false,
|
|
165
|
+
default: "",
|
|
166
|
+
isArray: false,
|
|
167
|
+
},
|
|
168
|
+
inMemoryTable,
|
|
169
|
+
);
|
|
153
170
|
_fieldsDocsObs([..._fieldsDocsObs(), newField]);
|
|
154
171
|
return newField;
|
|
155
|
-
}
|
|
172
|
+
};
|
|
156
173
|
return [_fieldsDocsObs, newRow];
|
|
157
174
|
});
|
|
158
175
|
|
|
159
176
|
useObservable(fields);
|
|
160
177
|
|
|
161
|
-
|
|
178
|
+
const updateSchemaFields = useCallback(() => {
|
|
162
179
|
ioSchema({
|
|
163
180
|
...ioSchema(),
|
|
164
181
|
type: IOSchemaType.complex,
|
|
165
|
-
fields: fields().map(f => f.toJS()),
|
|
182
|
+
fields: fields().map((f) => f.toJS()),
|
|
166
183
|
});
|
|
167
|
-
}
|
|
184
|
+
}, [fields, ioSchema]);
|
|
168
185
|
|
|
169
186
|
useEffect(() => {
|
|
170
|
-
const subs = fields().map(f
|
|
171
|
-
|
|
172
|
-
|
|
187
|
+
const subs = fields().map((f) =>
|
|
188
|
+
f.q.subscribe(() => {
|
|
189
|
+
updateSchemaFields();
|
|
190
|
+
}),
|
|
191
|
+
);
|
|
192
|
+
return () => {
|
|
193
|
+
for (const s of subs) {
|
|
194
|
+
s.dispose();
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
}, [fields, updateSchemaFields]);
|
|
173
198
|
|
|
174
199
|
return (
|
|
175
|
-
<div style={{ fontSize:
|
|
200
|
+
<div style={{ fontSize: "9pt" }} className="mt-2">
|
|
176
201
|
TODO - Move Datagrid over from peers-kore
|
|
177
202
|
{/* <Datagrid<IField>
|
|
178
203
|
primaryKey={{ name: "fakeId", dataType: "string" }}
|
|
@@ -230,5 +255,5 @@ export const ComplexInputSchema = (props: { ioSchema: Observable<IOSchema> }) =>
|
|
|
230
255
|
newRow={newRow}
|
|
231
256
|
/> */}
|
|
232
257
|
</div>
|
|
233
|
-
)
|
|
234
|
-
}
|
|
258
|
+
);
|
|
259
|
+
};
|