@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.3
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/package.json +2 -3
- package/src/components/assistant-animations.tsx +0 -29
- package/src/components/assistant-dialogs.tsx +0 -235
- package/src/components/code-view.tsx +0 -278
- package/src/components/create-agent-task.tsx +0 -104
- package/src/components/create-new-work-version.tsx +0 -30
- package/src/components/extract-web.tsx +0 -160
- package/src/components/forward-to-agent.tsx +0 -90
- package/src/components/generate-chart.tsx +0 -101
- package/src/components/generative-action-button.tsx +0 -122
- package/src/components/generative-tool.tsx +0 -685
- package/src/components/generative-ui-object.tsx +0 -210
- package/src/components/input-area.tsx +0 -1209
- package/src/components/json-schema-layout.tsx +0 -326
- package/src/components/list-item-card.tsx +0 -92
- package/src/components/mermaid-diagram.tsx +0 -192
- package/src/components/preview-image.tsx +0 -47
- package/src/components/request-approval.tsx +0 -48
- package/src/components/request-user-input.tsx +0 -270
- package/src/components/search-web.tsx +0 -319
- package/src/components/sheet-command.tsx +0 -88
- package/src/components/shell-canvas.tsx +0 -122
- package/src/components/show-advanced-data-table.tsx +0 -352
- package/src/components/show-generated-content-options.tsx +0 -93
- package/src/components/show-people-cards.tsx +0 -180
- package/src/components/subagent-tool.tsx +0 -180
- package/src/components/text-editor-tool.tsx +0 -328
- package/src/components/work-canvas.tsx +0 -88
- package/src/components/work-card.tsx +0 -42
- package/src/declarations.d.ts +0 -1
- package/src/docy-assistant.tsx +0 -1962
- package/src/hooks/index.ts +0 -7
- package/src/hooks/use-assistant-api.ts +0 -507
- package/src/hooks/use-deployment-data.ts +0 -162
- package/src/hooks/use-project-state.ts +0 -347
- package/src/hooks/use-session-state.ts +0 -207
- package/src/hooks/use-speech-recognition.ts +0 -137
- package/src/hooks/use-ui-state.ts +0 -185
- package/src/hooks/use-works-state.ts +0 -146
- package/src/i18n/context.tsx +0 -253
- package/src/i18n/index.ts +0 -19
- package/src/i18n/locales/de.json +0 -198
- package/src/i18n/locales/el.json +0 -198
- package/src/i18n/locales/en.json +0 -226
- package/src/i18n/locales/es.json +0 -198
- package/src/i18n/locales/fr.json +0 -198
- package/src/i18n/locales/it.json +0 -198
- package/src/i18n/locales/pt.json +0 -198
- package/src/i18n/locales/sl.json +0 -198
- package/src/i18n/locales/tr.json +0 -211
- package/src/i18n/types.ts +0 -23
- package/src/i18n/use-translation.ts +0 -17
- package/src/index.ts +0 -18
- package/src/internal/plate-editor/editor/auth-context.ts +0 -11
- package/src/internal/plate-editor/editor/editor-base-kit.tsx +0 -39
- package/src/internal/plate-editor/editor/editor-kit.tsx +0 -89
- package/src/internal/plate-editor/editor/plate-editor.tsx +0 -75
- package/src/internal/plate-editor/editor/plate-types.ts +0 -126
- package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +0 -172
- package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +0 -211
- package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +0 -51
- package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +0 -38
- package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +0 -31
- package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +0 -23
- package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +0 -26
- package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/column-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +0 -174
- package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +0 -68
- package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +0 -13
- package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/date-kit.tsx +0 -7
- package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +0 -43
- package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +0 -6
- package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +0 -15
- package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +0 -12
- package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/font-kit.tsx +0 -47
- package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +0 -19
- package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/link-kit.tsx +0 -35
- package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +0 -24
- package/src/internal/plate-editor/editor/plugins/list-kit.tsx +0 -27
- package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +0 -18
- package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +0 -8
- package/src/internal/plate-editor/editor/plugins/math-kit.tsx +0 -10
- package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +0 -37
- package/src/internal/plate-editor/editor/plugins/media-kit.tsx +0 -53
- package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +0 -36
- package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +0 -17
- package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +0 -95
- package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +0 -20
- package/src/internal/plate-editor/editor/plugins/table-kit.tsx +0 -22
- package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +0 -14
- package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +0 -5
- package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +0 -9
- package/src/internal/plate-editor/editor/transforms.ts +0 -165
- package/src/internal/plate-editor/editor/use-chat.ts +0 -152
- package/src/internal/plate-editor/hooks/index.ts +0 -3
- package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +0 -31
- package/src/internal/plate-editor/hooks/use-is-touch-device.ts +0 -26
- package/src/internal/plate-editor/hooks/use-lock-scroll.ts +0 -21
- package/src/internal/plate-editor/hooks/use-media-query.ts +0 -44
- package/src/internal/plate-editor/hooks/use-mounted.ts +0 -18
- package/src/internal/plate-editor/hooks/use-on-click-outside.ts +0 -114
- package/src/internal/plate-editor/hooks/use-upload-file.ts +0 -81
- package/src/internal/plate-editor/i18n/context.tsx +0 -58
- package/src/internal/plate-editor/i18n/index.ts +0 -3
- package/src/internal/plate-editor/i18n/locales/de.json +0 -57
- package/src/internal/plate-editor/i18n/locales/el.json +0 -57
- package/src/internal/plate-editor/i18n/locales/en.json +0 -57
- package/src/internal/plate-editor/i18n/locales/es.json +0 -57
- package/src/internal/plate-editor/i18n/locales/fr.json +0 -57
- package/src/internal/plate-editor/i18n/locales/it.json +0 -57
- package/src/internal/plate-editor/i18n/locales/pt.json +0 -57
- package/src/internal/plate-editor/i18n/locales/sl.json +0 -57
- package/src/internal/plate-editor/i18n/locales/tr.json +0 -57
- package/src/internal/plate-editor/i18n/types.ts +0 -59
- package/src/internal/plate-editor/i18n/use-translation.ts +0 -22
- package/src/internal/plate-editor/index.ts +0 -39
- package/src/internal/plate-editor/lib/ai-output-converter.ts +0 -153
- package/src/internal/plate-editor/lib/download-file.ts +0 -17
- package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/ai-menu.tsx +0 -828
- package/src/internal/plate-editor/plate-ui/ai-node.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +0 -145
- package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +0 -88
- package/src/internal/plate-editor/plate-ui/avatar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +0 -104
- package/src/internal/plate-editor/plate-ui/block-discussion.tsx +0 -364
- package/src/internal/plate-editor/plate-ui/block-draggable.tsx +0 -557
- package/src/internal/plate-editor/plate-ui/block-list-static.tsx +0 -77
- package/src/internal/plate-editor/plate-ui/block-list.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/block-menu.tsx +0 -555
- package/src/internal/plate-editor/plate-ui/block-selection.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +0 -469
- package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +0 -10
- package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/button.tsx +0 -201
- package/src/internal/plate-editor/plate-ui/calendar.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +0 -76
- package/src/internal/plate-editor/plate-ui/callout-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/caption.tsx +0 -47
- package/src/internal/plate-editor/plate-ui/checkbox.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +0 -172
- package/src/internal/plate-editor/plate-ui/code-block-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/code-node-static.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/code-node.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/column-node-static.tsx +0 -65
- package/src/internal/plate-editor/plate-ui/column-node.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/command.tsx +0 -202
- package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +0 -12
- package/src/internal/plate-editor/plate-ui/comment-node.tsx +0 -45
- package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/comment.tsx +0 -619
- package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +0 -85
- package/src/internal/plate-editor/plate-ui/date-node-static.tsx +0 -43
- package/src/internal/plate-editor/plate-ui/date-node.tsx +0 -54
- package/src/internal/plate-editor/plate-ui/dialog.tsx +0 -445
- package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +0 -264
- package/src/internal/plate-editor/plate-ui/editor-static.tsx +0 -40
- package/src/internal/plate-editor/plate-ui/editor.tsx +0 -146
- package/src/internal/plate-editor/plate-ui/emoji-node.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +0 -626
- package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +0 -155
- package/src/internal/plate-editor/plate-ui/equation-node.tsx +0 -226
- package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +0 -26
- package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +0 -206
- package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +0 -157
- package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +0 -25
- package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +0 -1129
- package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +0 -129
- package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +0 -97
- package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +0 -209
- package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +0 -152
- package/src/internal/plate-editor/plate-ui/ghost-text.tsx +0 -20
- package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/heading-node.tsx +0 -56
- package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +0 -9
- package/src/internal/plate-editor/plate-ui/highlight-node.tsx +0 -11
- package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +0 -50
- package/src/internal/plate-editor/plate-ui/hover-card.tsx +0 -7
- package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/hr-node.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +0 -122
- package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +0 -409
- package/src/internal/plate-editor/plate-ui/input.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +0 -258
- package/src/internal/plate-editor/plate-ui/label.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +0 -69
- package/src/internal/plate-editor/plate-ui/link-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/link-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +0 -28
- package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +0 -147
- package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +0 -177
- package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +0 -21
- package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +0 -32
- package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +0 -103
- package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +0 -30
- package/src/internal/plate-editor/plate-ui/media-file-node.tsx +0 -52
- package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +0 -37
- package/src/internal/plate-editor/plate-ui/media-image-node.tsx +0 -183
- package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +0 -441
- package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +0 -127
- package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +0 -227
- package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +0 -214
- package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +0 -73
- package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/media-video-node.tsx +0 -119
- package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +0 -46
- package/src/internal/plate-editor/plate-ui/mention-node.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/menu.tsx +0 -539
- package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +0 -124
- package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +0 -34
- package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +0 -15
- package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +0 -16
- package/src/internal/plate-editor/plate-ui/popover.tsx +0 -75
- package/src/internal/plate-editor/plate-ui/progress.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +0 -79
- package/src/internal/plate-editor/plate-ui/resize-handle.tsx +0 -86
- package/src/internal/plate-editor/plate-ui/separator.tsx +0 -41
- package/src/internal/plate-editor/plate-ui/slash-node.tsx +0 -433
- package/src/internal/plate-editor/plate-ui/spinner.tsx +0 -1
- package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +0 -35
- package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +0 -166
- package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/table-node-static.tsx +0 -84
- package/src/internal/plate-editor/plate-ui/table-node.tsx +0 -283
- package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +0 -252
- package/src/internal/plate-editor/plate-ui/tabs.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/textarea.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +0 -142
- package/src/internal/plate-editor/plate-ui/toc-node.tsx +0 -57
- package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +0 -48
- package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +0 -18
- package/src/internal/plate-editor/plate-ui/toggle-node.tsx +0 -33
- package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +0 -24
- package/src/internal/plate-editor/plate-ui/toggle.tsx +0 -3
- package/src/internal/plate-editor/plate-ui/toolbar.tsx +0 -378
- package/src/internal/plate-editor/plate-ui/tooltip.tsx +0 -148
- package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +0 -175
- package/src/internal/plate-editor/types/index.ts +0 -22
- package/src/internal/plate-editor/vite.ts +0 -284
- package/src/internal/sheets/components/univer-sheets.tsx +0 -1104
- package/src/internal/sheets/i18n/context.tsx +0 -183
- package/src/internal/sheets/i18n/index.ts +0 -19
- package/src/internal/sheets/i18n/locales/de.json +0 -21
- package/src/internal/sheets/i18n/locales/el.json +0 -21
- package/src/internal/sheets/i18n/locales/en.json +0 -21
- package/src/internal/sheets/i18n/locales/es.json +0 -21
- package/src/internal/sheets/i18n/locales/fr.json +0 -21
- package/src/internal/sheets/i18n/locales/it.json +0 -21
- package/src/internal/sheets/i18n/locales/pt.json +0 -21
- package/src/internal/sheets/i18n/locales/sl.json +0 -21
- package/src/internal/sheets/i18n/locales/tr.json +0 -21
- package/src/internal/sheets/i18n/types.ts +0 -23
- package/src/internal/sheets/i18n/use-translation.ts +0 -17
- package/src/internal/sheets/index.ts +0 -14
- package/src/internal/sheets/types/css.d.ts +0 -11
- package/src/internal/sheets/types/index.ts +0 -260
- package/src/internal/sheets/xlsx.ts +0 -1169
- package/src/lib/api-client.ts +0 -77
- package/src/lib/assistant-api-actions.ts +0 -549
- package/src/lib/assistant-config.tsx +0 -75
- package/src/lib/class-utils.ts +0 -40
- package/src/lib/index.ts +0 -7
- package/src/lib/message-utils.ts +0 -131
- package/src/tools/tools-schema.json +0 -512
- package/src/types/index.ts +0 -235
- package/src/views/assistant-view.tsx +0 -1137
- package/src/views/canvas-app.tsx +0 -839
- package/src/views/canvas-code.tsx +0 -93
- package/src/views/canvas-deep-research.tsx +0 -44
- package/src/views/canvas-image.tsx +0 -25
- package/src/views/canvas-record-view.tsx +0 -285
- package/src/views/canvas-spreadsheet.tsx +0 -125
- package/src/views/canvas-text.tsx +0 -52
- package/src/views/canvas.tsx +0 -274
- package/src/views/chat-panel.tsx +0 -149
- package/src/views/index.ts +0 -20
- package/src/views/memories-panel.tsx +0 -365
- package/src/views/message-list.tsx +0 -370
- package/src/views/project-detail.tsx +0 -257
- package/src/views/projects-panel.tsx +0 -131
- package/src/views/sessions-list.tsx +0 -98
- package/src/views/sidebar-content.tsx +0 -256
- package/src/views/work-detail.tsx +0 -98
- package/src/vite.ts +0 -64
- package/src/worker.ts +0 -203
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
|
-
|
|
5
|
-
function getFieldLabel(key: string | number, property: any): string {
|
|
6
|
-
if (property?.title) return property.title;
|
|
7
|
-
|
|
8
|
-
return key
|
|
9
|
-
.toString()
|
|
10
|
-
.replace(/_/g, ' ')
|
|
11
|
-
.replace(/([A-Z])/g, ' $1')
|
|
12
|
-
.split(' ')
|
|
13
|
-
.map(w => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase())
|
|
14
|
-
.join(' ')
|
|
15
|
-
.trim();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function formatLabel(key: string): string {
|
|
19
|
-
return key.replace(/([A-Z])/g, ' $1').replace(/^./, s => s.toUpperCase());
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function inferType(value: any): string {
|
|
23
|
-
if (value === null || value === undefined) return 'string';
|
|
24
|
-
if (Array.isArray(value)) return 'array';
|
|
25
|
-
if (typeof value === 'object') return 'object';
|
|
26
|
-
|
|
27
|
-
return typeof value;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function formatValue(value: any, property: any): string {
|
|
31
|
-
if (value === null || value === undefined) return '—';
|
|
32
|
-
|
|
33
|
-
const type = property?.type;
|
|
34
|
-
|
|
35
|
-
switch (type) {
|
|
36
|
-
case 'boolean':
|
|
37
|
-
return value ? 'Yes' : 'No';
|
|
38
|
-
|
|
39
|
-
case 'number':
|
|
40
|
-
|
|
41
|
-
case 'integer':
|
|
42
|
-
return String(value);
|
|
43
|
-
|
|
44
|
-
case 'string':
|
|
45
|
-
if (property?.format === 'date') return new Date(value).toLocaleDateString();
|
|
46
|
-
if (property?.format === 'date-time') return new Date(value).toLocaleString();
|
|
47
|
-
if (typeof value === 'object') return JSON.stringify(value, null, 2);
|
|
48
|
-
|
|
49
|
-
return String(value);
|
|
50
|
-
|
|
51
|
-
case 'array':
|
|
52
|
-
return Array.isArray(value) ? `${value.length} items` : '—';
|
|
53
|
-
|
|
54
|
-
case 'object':
|
|
55
|
-
return typeof value === 'object' ? JSON.stringify(value, null, 2) : '—';
|
|
56
|
-
|
|
57
|
-
default:
|
|
58
|
-
return String(value);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
function formatNestedObject(value: any): string {
|
|
63
|
-
if (value === null || value === undefined) return '—';
|
|
64
|
-
if (typeof value !== 'object') return String(value);
|
|
65
|
-
|
|
66
|
-
return Object.entries(value)
|
|
67
|
-
.map(([k, v]) => (typeof v === 'object' && v !== null ? `${k}: ${JSON.stringify(v)}` : `${k}: ${v}`))
|
|
68
|
-
.join('\n');
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
function formatNestedArray(value: any): string {
|
|
72
|
-
if (!Array.isArray(value)) return '—';
|
|
73
|
-
if (value.length === 0) return '(empty)';
|
|
74
|
-
if (value.every((item: any) => typeof item !== 'object' || item === null)) return value.join(', ');
|
|
75
|
-
|
|
76
|
-
return `${value.length} items:\n${JSON.stringify(value[0], null, 2)}${value.length > 1 ? '\n...' : ''}`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function formatPrimitive(value: any): string {
|
|
80
|
-
if (value === null || value === undefined) return '—';
|
|
81
|
-
if (typeof value === 'boolean') return value ? 'Yes' : 'No';
|
|
82
|
-
|
|
83
|
-
return String(value);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function getCitationsForField(basis: any[], fieldKey: string | number): any[] {
|
|
87
|
-
if (!Array.isArray(basis) || basis.length === 0) return [];
|
|
88
|
-
const entry = basis.find((item: any) => item.field === fieldKey);
|
|
89
|
-
|
|
90
|
-
return entry?.citations || [];
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
interface JsonSchemaArrayProps {
|
|
94
|
-
schema: any;
|
|
95
|
-
data: any[];
|
|
96
|
-
showHeader?: boolean;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function JsonSchemaArray({ schema, data, showHeader = true }: JsonSchemaArrayProps) {
|
|
100
|
-
const isEmpty = !data || data.length === 0;
|
|
101
|
-
|
|
102
|
-
const isArrayOfObjects = !isEmpty
|
|
103
|
-
&& (schema?.items?.type === 'object'
|
|
104
|
-
|| data.some((item: any) => typeof item === 'object' && item !== null && !Array.isArray(item)));
|
|
105
|
-
|
|
106
|
-
const columns: Record<string, { label: string; property: any }> = useMemo(() => {
|
|
107
|
-
const itemSchema = schema?.items;
|
|
108
|
-
|
|
109
|
-
if (itemSchema?.properties) {
|
|
110
|
-
const cols: Record<string, { label: string; property: any }> = {};
|
|
111
|
-
|
|
112
|
-
Object.keys(itemSchema.properties).forEach((key) => {
|
|
113
|
-
cols[key] = {
|
|
114
|
-
label: itemSchema.properties[key]?.title || formatLabel(key),
|
|
115
|
-
property: itemSchema.properties[key]
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
return cols;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
if (isArrayOfObjects && data.length > 0) {
|
|
123
|
-
const allKeys = new Set<string>();
|
|
124
|
-
|
|
125
|
-
data.forEach((item: any) => {
|
|
126
|
-
if (typeof item === 'object' && item !== null) Object.keys(item).forEach(k => allKeys.add(k));
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
const cols: Record<string, { label: string; property: any }> = {};
|
|
130
|
-
|
|
131
|
-
allKeys.forEach((key) => {
|
|
132
|
-
cols[key] = {
|
|
133
|
-
label: formatLabel(key),
|
|
134
|
-
property: { type: inferType(data[0]?.[key]) }
|
|
135
|
-
};
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
return cols;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return {};
|
|
142
|
-
}, [schema, data, isArrayOfObjects]);
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<div className="w-full not-prose">
|
|
146
|
-
{showHeader && schema?.title && (
|
|
147
|
-
<div className="text-lg font-semibold text-slate-700 mb-3">{schema.title}</div>
|
|
148
|
-
)}
|
|
149
|
-
{showHeader && schema?.description && (
|
|
150
|
-
<div className="text-sm text-slate-600 mb-3">{schema.description}</div>
|
|
151
|
-
)}
|
|
152
|
-
|
|
153
|
-
{isEmpty ? (
|
|
154
|
-
<div className="text-sm text-slate-500 italic py-4">No items</div>
|
|
155
|
-
) : isArrayOfObjects ? (
|
|
156
|
-
<div className="overflow-x-auto overflow-hidden shadow-sm rounded-lg border border-slate-200">
|
|
157
|
-
<table className="min-w-full divide-y divide-slate-200">
|
|
158
|
-
<thead className="bg-slate-50">
|
|
159
|
-
<tr>
|
|
160
|
-
{
|
|
161
|
-
Object.entries(columns).map(([key, col]) => (
|
|
162
|
-
<th
|
|
163
|
-
key={key}
|
|
164
|
-
className="px-4 py-3 text-left text-xs font-medium text-slate-700 uppercase tracking-wider">
|
|
165
|
-
{col.label}
|
|
166
|
-
</th>
|
|
167
|
-
))
|
|
168
|
-
}
|
|
169
|
-
</tr>
|
|
170
|
-
</thead>
|
|
171
|
-
<tbody className="bg-white divide-y divide-slate-200">
|
|
172
|
-
{data.map((item, index) => (
|
|
173
|
-
<tr key={index} className="hover:bg-slate-50">
|
|
174
|
-
{Object.entries(columns).map(([key, col]) => (
|
|
175
|
-
<td key={key} className="px-4 py-3 text-sm text-slate-700">
|
|
176
|
-
{col.property?.type === 'object' ? (
|
|
177
|
-
<div className="text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs">
|
|
178
|
-
{formatNestedObject(item[key])}
|
|
179
|
-
</div>
|
|
180
|
-
) : col.property?.type === 'array' ? (
|
|
181
|
-
<div className="text-xs font-mono bg-slate-100 rounded px-2 py-1 whitespace-pre-wrap break-all max-w-xs">
|
|
182
|
-
{formatNestedArray(item[key])}
|
|
183
|
-
</div>
|
|
184
|
-
) : (
|
|
185
|
-
<span className={col.property?.type === 'number' || col.property?.type === 'integer' ? 'font-mono' : ''}>
|
|
186
|
-
{formatValue(item[key], col.property)}
|
|
187
|
-
</span>
|
|
188
|
-
)}
|
|
189
|
-
</td>
|
|
190
|
-
))}
|
|
191
|
-
</tr>
|
|
192
|
-
))}
|
|
193
|
-
</tbody>
|
|
194
|
-
</table>
|
|
195
|
-
</div>
|
|
196
|
-
) : (
|
|
197
|
-
<div className="space-y-2">
|
|
198
|
-
{data.map((item, index) => (
|
|
199
|
-
<div
|
|
200
|
-
key={index}
|
|
201
|
-
className="px-3 py-2 bg-white border border-slate-200 rounded-md text-sm text-slate-700">
|
|
202
|
-
{formatPrimitive(item)}
|
|
203
|
-
</div>
|
|
204
|
-
))}
|
|
205
|
-
</div>
|
|
206
|
-
)}
|
|
207
|
-
</div>
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
interface JsonSchemaObjectProps {
|
|
212
|
-
schema: any;
|
|
213
|
-
data: any;
|
|
214
|
-
basis?: any[];
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
function JsonSchemaObject({ schema, data, basis = [] }: JsonSchemaObjectProps) {
|
|
218
|
-
const properties: Record<string, any> = schema?.properties || {};
|
|
219
|
-
const required: string[] = schema?.required || [];
|
|
220
|
-
|
|
221
|
-
return (
|
|
222
|
-
<div className="w-full">
|
|
223
|
-
{schema?.title && (
|
|
224
|
-
<div className="text-lg font-semibold text-slate-700 mb-4">{schema.title}</div>
|
|
225
|
-
)}
|
|
226
|
-
{schema?.description && (
|
|
227
|
-
<div className="text-sm text-slate-600 mb-4">{schema.description}</div>
|
|
228
|
-
)}
|
|
229
|
-
|
|
230
|
-
<div className="space-y-4">
|
|
231
|
-
{Object.entries(properties).map(([key, property]: [string, any]) => {
|
|
232
|
-
const isNestedObject = property?.type === 'object' && property?.properties;
|
|
233
|
-
const isArr = property?.type === 'array';
|
|
234
|
-
const citations = getCitationsForField(basis, key);
|
|
235
|
-
const isReq = required.includes(key);
|
|
236
|
-
|
|
237
|
-
if (isNestedObject) {
|
|
238
|
-
return (
|
|
239
|
-
<div key={key} className="border border-slate-200 rounded-lg p-4 bg-slate-50">
|
|
240
|
-
<JsonSchemaObject schema={property} data={data?.[key] || {}} basis={basis} />
|
|
241
|
-
</div>
|
|
242
|
-
);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (isArr) {
|
|
246
|
-
return (
|
|
247
|
-
<div key={key} className="border border-slate-200 rounded-lg p-4 bg-slate-50">
|
|
248
|
-
{property?.title && (
|
|
249
|
-
<div className="text-sm font-medium text-slate-700 mb-2">{property.title}</div>
|
|
250
|
-
)}
|
|
251
|
-
<JsonSchemaArray schema={property} data={data?.[key] || []} showHeader={false} />
|
|
252
|
-
</div>
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
return (
|
|
257
|
-
<div key={key} className="flex flex-col">
|
|
258
|
-
<label className={`text-sm font-medium text-slate-700 mb-1${isReq ? " after:content-['*'] after:ml-0.5 after:text-red-500" : ''}`}>
|
|
259
|
-
{getFieldLabel(key, property)}
|
|
260
|
-
</label>
|
|
261
|
-
|
|
262
|
-
{property?.description && (
|
|
263
|
-
<div className="text-xs text-slate-500 mb-1">{property.description}</div>
|
|
264
|
-
)}
|
|
265
|
-
|
|
266
|
-
<div className={`px-3 py-2 bg-white border border-slate-300 rounded-md text-sm text-slate-700${property?.type === 'number' || property?.type === 'integer' ? ' font-mono' : ''}`}>
|
|
267
|
-
{formatValue(data?.[key], property)}
|
|
268
|
-
</div>
|
|
269
|
-
|
|
270
|
-
{citations.length > 0 && (
|
|
271
|
-
<div className="mt-2 text-xs text-slate-600 bg-slate-50 border border-slate-200 rounded-md p-3">
|
|
272
|
-
<div className="font-medium text-slate-700 mb-2 flex items-center gap-1">
|
|
273
|
-
<svg className="w-3 h-3" fill="currentColor" viewBox="0 0 20 20">
|
|
274
|
-
<path
|
|
275
|
-
fillRule="evenodd"
|
|
276
|
-
d="M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z"
|
|
277
|
-
clipRule="evenodd" />
|
|
278
|
-
</svg>
|
|
279
|
-
Sources ({citations.length})
|
|
280
|
-
</div>
|
|
281
|
-
<div className="space-y-2">
|
|
282
|
-
{citations.map((citation: any, idx: number) => (
|
|
283
|
-
<div key={idx} className="flex gap-2 scroll-mt-4">
|
|
284
|
-
<span className="font-mono text-slate-500">[{idx + 1}]</span>
|
|
285
|
-
<div className="flex-1 min-w-0">
|
|
286
|
-
<a
|
|
287
|
-
href={citation.url}
|
|
288
|
-
target="_blank"
|
|
289
|
-
rel="noopener noreferrer"
|
|
290
|
-
className="text-blue-600 hover:text-blue-800 hover:underline break-all truncate block">
|
|
291
|
-
{citation.url}
|
|
292
|
-
</a>
|
|
293
|
-
{citation.excerpts && citation.excerpts.length > 0 && (
|
|
294
|
-
<div className="mt-1 text-slate-600 italic truncate">
|
|
295
|
-
"{citation.excerpts[0]}"
|
|
296
|
-
</div>
|
|
297
|
-
)}
|
|
298
|
-
</div>
|
|
299
|
-
</div>
|
|
300
|
-
))}
|
|
301
|
-
</div>
|
|
302
|
-
</div>
|
|
303
|
-
)}
|
|
304
|
-
</div>
|
|
305
|
-
);
|
|
306
|
-
})}
|
|
307
|
-
</div>
|
|
308
|
-
</div>
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
export interface JsonSchemaLayoutProps {
|
|
313
|
-
schema: any;
|
|
314
|
-
data: any;
|
|
315
|
-
basis?: any[];
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
export function JsonSchemaLayout({ schema, data, basis = [] }: JsonSchemaLayoutProps) {
|
|
319
|
-
const schemaType = schema?.type || (Array.isArray(data) ? 'array' : 'object');
|
|
320
|
-
|
|
321
|
-
if (schemaType === 'array') {
|
|
322
|
-
return <JsonSchemaArray schema={schema} data={data} />;
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return <JsonSchemaObject schema={schema} data={data} basis={basis} />;
|
|
326
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ElementType, type FC, type ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import { Button } from '@docyrus/ui-pro-shared/components/button';
|
|
6
|
-
import {
|
|
7
|
-
DropdownMenu,
|
|
8
|
-
DropdownMenuContent,
|
|
9
|
-
DropdownMenuItem,
|
|
10
|
-
DropdownMenuTrigger
|
|
11
|
-
} from '@docyrus/ui-pro-shared/components/dropdown-menu';
|
|
12
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
13
|
-
import { Edit, MoreHorizontal, Trash } from 'lucide-react';
|
|
14
|
-
|
|
15
|
-
interface ListItemCardAction {
|
|
16
|
-
label: string;
|
|
17
|
-
icon?: ElementType;
|
|
18
|
-
onClick: () => void;
|
|
19
|
-
variant?: 'default' | 'destructive';
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface ListItemCardProps {
|
|
23
|
-
title: string;
|
|
24
|
-
subtitle?: string;
|
|
25
|
-
onClick?: () => void;
|
|
26
|
-
actions?: ListItemCardAction[];
|
|
27
|
-
className?: string;
|
|
28
|
-
children?: ReactNode;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const ListItemCard: FC<ListItemCardProps> = ({
|
|
32
|
-
title,
|
|
33
|
-
subtitle,
|
|
34
|
-
onClick,
|
|
35
|
-
actions,
|
|
36
|
-
className,
|
|
37
|
-
children
|
|
38
|
-
}) => {
|
|
39
|
-
return (
|
|
40
|
-
<div
|
|
41
|
-
onClick={onClick}
|
|
42
|
-
className={cn(
|
|
43
|
-
'bg-card border border-border rounded-lg p-4 hover:shadow-md transition-shadow',
|
|
44
|
-
onClick && 'cursor-pointer',
|
|
45
|
-
className
|
|
46
|
-
)}>
|
|
47
|
-
<div className="flex items-start justify-between mb-3">
|
|
48
|
-
<h3 className="font-medium text-card-foreground line-clamp-2">{title}</h3>
|
|
49
|
-
{actions && actions.length > 0 && (
|
|
50
|
-
<DropdownMenu>
|
|
51
|
-
<DropdownMenuTrigger asChild>
|
|
52
|
-
<Button
|
|
53
|
-
variant="ghost"
|
|
54
|
-
size="icon"
|
|
55
|
-
className="h-6 w-6 text-muted-foreground hover:text-foreground shrink-0"
|
|
56
|
-
onClick={e => e.stopPropagation()}>
|
|
57
|
-
<MoreHorizontal className="w-4 h-4" />
|
|
58
|
-
</Button>
|
|
59
|
-
</DropdownMenuTrigger>
|
|
60
|
-
<DropdownMenuContent align="end">
|
|
61
|
-
{actions.map((action, index) => {
|
|
62
|
-
const Icon = action.icon || (action.variant === 'destructive' ? Trash : Edit);
|
|
63
|
-
|
|
64
|
-
return (
|
|
65
|
-
<DropdownMenuItem
|
|
66
|
-
key={index}
|
|
67
|
-
onClick={(e) => {
|
|
68
|
-
e.stopPropagation();
|
|
69
|
-
action.onClick();
|
|
70
|
-
}}
|
|
71
|
-
className={cn(
|
|
72
|
-
'cursor-pointer',
|
|
73
|
-
action.variant === 'destructive' && 'text-destructive focus:text-destructive'
|
|
74
|
-
)}>
|
|
75
|
-
<Icon className="w-4 h-4 mr-2" />
|
|
76
|
-
{action.label}
|
|
77
|
-
</DropdownMenuItem>
|
|
78
|
-
);
|
|
79
|
-
})}
|
|
80
|
-
</DropdownMenuContent>
|
|
81
|
-
</DropdownMenu>
|
|
82
|
-
)}
|
|
83
|
-
</div>
|
|
84
|
-
{subtitle && (
|
|
85
|
-
<p className="text-sm text-muted-foreground line-clamp-2">{subtitle}</p>
|
|
86
|
-
)}
|
|
87
|
-
{children}
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
ListItemCard.displayName = 'ListItemCard';
|
|
@@ -1,192 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useCallback, useEffect, useRef, useState, type MouseEvent, type WheelEvent
|
|
5
|
-
} from 'react';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
Maximize2, Minus, Plus, RotateCcw, X
|
|
9
|
-
} from 'lucide-react';
|
|
10
|
-
|
|
11
|
-
import { Button } from '@docyrus/ui-pro-shared/components/button';
|
|
12
|
-
import {
|
|
13
|
-
Dialog, DialogContent, DialogTitle
|
|
14
|
-
} from '@docyrus/ui-pro-shared/components/dialog';
|
|
15
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
16
|
-
|
|
17
|
-
interface MermaidRenderProps {
|
|
18
|
-
content: string;
|
|
19
|
-
className?: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function MermaidRender({ content, className }: MermaidRenderProps) {
|
|
23
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
24
|
-
const svgRef = useRef<HTMLDivElement>(null);
|
|
25
|
-
const [svg, setSvg] = useState('');
|
|
26
|
-
const [zoom, setZoom] = useState(1);
|
|
27
|
-
const [pan, setPan] = useState({ x: 0, y: 0 });
|
|
28
|
-
const isDragging = useRef(false);
|
|
29
|
-
const lastPos = useRef({ x: 0, y: 0 });
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (!content) return;
|
|
33
|
-
|
|
34
|
-
let cancelled = false;
|
|
35
|
-
|
|
36
|
-
const render = async () => {
|
|
37
|
-
try {
|
|
38
|
-
const { default: mermaid } = await import('mermaid');
|
|
39
|
-
|
|
40
|
-
mermaid.initialize({ startOnLoad: false, securityLevel: 'loose' });
|
|
41
|
-
const id = `mermaid-${Math.random().toString(36).slice(2)}`;
|
|
42
|
-
const { svg: rendered } = await mermaid.render(id, content);
|
|
43
|
-
|
|
44
|
-
if (!cancelled) setSvg(rendered);
|
|
45
|
-
} catch (err) {
|
|
46
|
-
console.error('Mermaid render error:', err);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
render();
|
|
51
|
-
|
|
52
|
-
return () => {
|
|
53
|
-
cancelled = true;
|
|
54
|
-
};
|
|
55
|
-
}, [content]);
|
|
56
|
-
|
|
57
|
-
const zoomIn = () => setZoom(z => Math.min(z + 0.15, 4));
|
|
58
|
-
const zoomOut = () => setZoom(z => Math.max(z - 0.15, 0.2));
|
|
59
|
-
const resetView = () => {
|
|
60
|
-
setZoom(1);
|
|
61
|
-
setPan({ x: 0, y: 0 });
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const onWheel = useCallback((e: WheelEvent) => {
|
|
65
|
-
e.preventDefault();
|
|
66
|
-
const delta = e.deltaY > 0 ? -0.1 : 0.1;
|
|
67
|
-
|
|
68
|
-
setZoom(z => Math.min(Math.max(z + delta, 0.2), 4));
|
|
69
|
-
}, []);
|
|
70
|
-
|
|
71
|
-
const onMouseDown = useCallback((e: MouseEvent) => {
|
|
72
|
-
isDragging.current = true;
|
|
73
|
-
lastPos.current = { x: e.clientX, y: e.clientY };
|
|
74
|
-
}, []);
|
|
75
|
-
|
|
76
|
-
const onMouseMove = useCallback((e: MouseEvent) => {
|
|
77
|
-
if (!isDragging.current) return;
|
|
78
|
-
const dx = e.clientX - lastPos.current.x;
|
|
79
|
-
const dy = e.clientY - lastPos.current.y;
|
|
80
|
-
|
|
81
|
-
lastPos.current = { x: e.clientX, y: e.clientY };
|
|
82
|
-
setPan(p => ({ x: p.x + dx, y: p.y + dy }));
|
|
83
|
-
}, []);
|
|
84
|
-
|
|
85
|
-
const onMouseUp = useCallback(() => {
|
|
86
|
-
isDragging.current = false;
|
|
87
|
-
}, []);
|
|
88
|
-
|
|
89
|
-
return (
|
|
90
|
-
<div
|
|
91
|
-
ref={containerRef}
|
|
92
|
-
className={cn(
|
|
93
|
-
'relative w-full h-full overflow-hidden cursor-grab active:cursor-grabbing select-none',
|
|
94
|
-
'bg-[radial-gradient(circle,_#94a3b8_1px,_transparent_1px)] bg-[size:22px_22px] bg-slate-50',
|
|
95
|
-
className
|
|
96
|
-
)}
|
|
97
|
-
onWheel={onWheel}
|
|
98
|
-
onMouseDown={onMouseDown}
|
|
99
|
-
onMouseMove={onMouseMove}
|
|
100
|
-
onMouseUp={onMouseUp}
|
|
101
|
-
onMouseLeave={onMouseUp}>
|
|
102
|
-
<div
|
|
103
|
-
ref={svgRef}
|
|
104
|
-
className="absolute inset-0 flex items-center justify-center"
|
|
105
|
-
style={{ transform: `translate(${pan.x}px, ${pan.y}px) scale(${zoom})`, transformOrigin: 'center' }}
|
|
106
|
-
dangerouslySetInnerHTML={{ __html: svg }} />
|
|
107
|
-
|
|
108
|
-
{/* Zoom controls */}
|
|
109
|
-
<div className="absolute bottom-3 left-3 z-10 flex gap-1">
|
|
110
|
-
<Button variant="secondary" size="icon" className="h-7 w-7 bg-white shadow-sm" onClick={zoomOut}>
|
|
111
|
-
<Minus className="size-3" />
|
|
112
|
-
</Button>
|
|
113
|
-
<Button variant="secondary" size="icon" className="h-7 w-7 bg-white shadow-sm" onClick={zoomIn}>
|
|
114
|
-
<Plus className="size-3" />
|
|
115
|
-
</Button>
|
|
116
|
-
<Button variant="secondary" size="icon" className="h-7 w-7 bg-white shadow-sm" onClick={resetView}>
|
|
117
|
-
<RotateCcw className="size-3" />
|
|
118
|
-
</Button>
|
|
119
|
-
</div>
|
|
120
|
-
</div>
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
interface MermaidDiagramProps {
|
|
125
|
-
title?: string;
|
|
126
|
-
description?: string;
|
|
127
|
-
mermaidNotation: string;
|
|
128
|
-
state?: string;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
export function MermaidDiagram({
|
|
132
|
-
title, description, mermaidNotation, state
|
|
133
|
-
}: MermaidDiagramProps) {
|
|
134
|
-
const [modalOpen, setModalOpen] = useState(false);
|
|
135
|
-
|
|
136
|
-
if (state !== 'output-available') {
|
|
137
|
-
return <div className="w-full h-[400px] rounded-lg border bg-muted/30 animate-pulse" />;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
return (
|
|
141
|
-
<>
|
|
142
|
-
<div className="w-full min-w-96 max-w-2xl h-[400px] border rounded-lg flex flex-col overflow-hidden">
|
|
143
|
-
{/* Header */}
|
|
144
|
-
<div className="flex items-center justify-between bg-muted/50 px-4 py-2 shrink-0">
|
|
145
|
-
<div className="flex items-center gap-3 min-w-0">
|
|
146
|
-
<div className="min-w-0">
|
|
147
|
-
{title && <div className="text-sm font-medium truncate">{title}</div>}
|
|
148
|
-
{description && <div className="text-xs text-muted-foreground truncate">{description}</div>}
|
|
149
|
-
</div>
|
|
150
|
-
</div>
|
|
151
|
-
<Button
|
|
152
|
-
variant="ghost"
|
|
153
|
-
size="icon"
|
|
154
|
-
className="h-7 w-7 shrink-0"
|
|
155
|
-
onClick={() => setModalOpen(true)}>
|
|
156
|
-
<Maximize2 className="size-4" />
|
|
157
|
-
</Button>
|
|
158
|
-
</div>
|
|
159
|
-
|
|
160
|
-
{/* Diagram */}
|
|
161
|
-
<div className="flex-1 overflow-hidden">
|
|
162
|
-
<MermaidRender content={mermaidNotation} />
|
|
163
|
-
</div>
|
|
164
|
-
</div>
|
|
165
|
-
|
|
166
|
-
{/* Fullscreen modal */}
|
|
167
|
-
<Dialog open={modalOpen} onOpenChange={setModalOpen}>
|
|
168
|
-
<DialogContent
|
|
169
|
-
showCloseButton={false}
|
|
170
|
-
className="max-w-[90vw] sm:max-w-[90vw] w-[90vw] h-[90vh] p-0 flex flex-col gap-0 overflow-hidden">
|
|
171
|
-
<DialogTitle className="sr-only">{title ?? 'Diagram'}</DialogTitle>
|
|
172
|
-
<div className="flex items-center justify-between bg-muted/50 px-4 py-2 shrink-0">
|
|
173
|
-
<div className="min-w-0">
|
|
174
|
-
{title && <div className="text-base font-medium truncate">{title}</div>}
|
|
175
|
-
{description && <div className="text-xs text-muted-foreground truncate">{description}</div>}
|
|
176
|
-
</div>
|
|
177
|
-
<Button
|
|
178
|
-
variant="ghost"
|
|
179
|
-
size="icon"
|
|
180
|
-
className="h-7 w-7 shrink-0"
|
|
181
|
-
onClick={() => setModalOpen(false)}>
|
|
182
|
-
<X className="size-4" />
|
|
183
|
-
</Button>
|
|
184
|
-
</div>
|
|
185
|
-
<div className="flex-1 overflow-hidden">
|
|
186
|
-
<MermaidRender content={mermaidNotation} />
|
|
187
|
-
</div>
|
|
188
|
-
</DialogContent>
|
|
189
|
-
</Dialog>
|
|
190
|
-
</>
|
|
191
|
-
);
|
|
192
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type FC, type HTMLAttributes } from 'react';
|
|
2
|
-
|
|
3
|
-
type ImageItem = {
|
|
4
|
-
url: string;
|
|
5
|
-
base64: string;
|
|
6
|
-
mimeType: string;
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
type Props = {
|
|
12
|
-
id?: string;
|
|
13
|
-
title?: string;
|
|
14
|
-
images?: string | (ImageItem | string)[];
|
|
15
|
-
onOpen?: () => void;
|
|
16
|
-
} & HTMLAttributes<HTMLDivElement>;
|
|
17
|
-
|
|
18
|
-
export const PreviewImage: FC<Props> = ({
|
|
19
|
-
title = '', images = '', onOpen, ...rest
|
|
20
|
-
}) => {
|
|
21
|
-
const handleClick = () => {
|
|
22
|
-
if (onOpen) onOpen();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div
|
|
27
|
-
className="rounded-lg shadow-sm hover:shadow-md w-fit min-w-80 max-w-96 border bg-card p-4 flex flex-col items-start justify-stretch space-y-2 cursor-pointer"
|
|
28
|
-
onClick={handleClick}
|
|
29
|
-
{...rest}>
|
|
30
|
-
<div className="truncate text-xs w-full font-medium">{title}</div>
|
|
31
|
-
|
|
32
|
-
{Array.isArray(images) ? (
|
|
33
|
-
images.map((image, index) => (
|
|
34
|
-
<img
|
|
35
|
-
key={index}
|
|
36
|
-
src={typeof image === 'string' ? image : image.url}
|
|
37
|
-
className="w-80"
|
|
38
|
-
alt={`image-${index}`} />
|
|
39
|
-
))
|
|
40
|
-
) : (
|
|
41
|
-
images && <img src={images} className="w-80" alt="image" />
|
|
42
|
-
)}
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default PreviewImage;
|