@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,88 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
4
|
-
|
|
5
|
-
import { FileSpreadsheet, Loader2 } from 'lucide-react';
|
|
6
|
-
import { Card } from '@docyrus/ui-pro-shared/components/card';
|
|
7
|
-
|
|
8
|
-
interface SheetCommandProps {
|
|
9
|
-
commands?: any[];
|
|
10
|
-
state?: string;
|
|
11
|
-
toolCallId?: string;
|
|
12
|
-
workId?: string;
|
|
13
|
-
onAutoRespond?: (commands: any[]) => void;
|
|
14
|
-
onSendSpreadsheetCommands?: (commands: any[]) => void;
|
|
15
|
-
openCanvasView?: (options: any) => void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function SheetCommand({
|
|
19
|
-
commands,
|
|
20
|
-
state,
|
|
21
|
-
toolCallId,
|
|
22
|
-
workId,
|
|
23
|
-
onAutoRespond,
|
|
24
|
-
onSendSpreadsheetCommands: _onSendSpreadsheetCommands,
|
|
25
|
-
openCanvasView
|
|
26
|
-
}: SheetCommandProps) {
|
|
27
|
-
const hasRespondedRef = useRef(false);
|
|
28
|
-
const commandCount = commands?.length ?? 0;
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
if (
|
|
32
|
-
state === 'input-available'
|
|
33
|
-
&& commands && commands.length > 0
|
|
34
|
-
&& toolCallId
|
|
35
|
-
&& !hasRespondedRef.current
|
|
36
|
-
) {
|
|
37
|
-
hasRespondedRef.current = true;
|
|
38
|
-
|
|
39
|
-
// Execute commands on the already-open UniverSheets via postMessage
|
|
40
|
-
for (const cmd of commands) {
|
|
41
|
-
window.postMessage(
|
|
42
|
-
{ type: 'event', eventName: 'api:call', payload: cmd },
|
|
43
|
-
'*'
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Keep canvas visible
|
|
48
|
-
openCanvasView?.({
|
|
49
|
-
type: 'xlsx',
|
|
50
|
-
id: workId,
|
|
51
|
-
workId,
|
|
52
|
-
title: 'Spreadsheet',
|
|
53
|
-
commands
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
onAutoRespond?.(commands);
|
|
57
|
-
}
|
|
58
|
-
}, [
|
|
59
|
-
state,
|
|
60
|
-
commands,
|
|
61
|
-
toolCallId,
|
|
62
|
-
workId,
|
|
63
|
-
openCanvasView,
|
|
64
|
-
onAutoRespond
|
|
65
|
-
]);
|
|
66
|
-
|
|
67
|
-
return (
|
|
68
|
-
<div className="flex flex-row items-center space-x-4">
|
|
69
|
-
<Card className="p-4 flex flex-col space-y-2 w-fit min-w-80 max-w-96 shadow-sm">
|
|
70
|
-
<div className="flex items-start space-x-2">
|
|
71
|
-
<div className="flex-none p-2 bg-slate-50 rounded">
|
|
72
|
-
<FileSpreadsheet className="size-8 text-muted-foreground" />
|
|
73
|
-
</div>
|
|
74
|
-
<div className="grow space-y-1 min-w-0">
|
|
75
|
-
<div className="font-medium text-base">Spreadsheet Commands</div>
|
|
76
|
-
<p className="text-sm text-muted-foreground">
|
|
77
|
-
{commandCount} command{commandCount !== 1 ? 's' : ''} to execute
|
|
78
|
-
</p>
|
|
79
|
-
</div>
|
|
80
|
-
</div>
|
|
81
|
-
</Card>
|
|
82
|
-
|
|
83
|
-
{(state === 'input-streaming' || state === 'input-available') && (
|
|
84
|
-
<Loader2 className="size-8 animate-spin text-primary flex-none" />
|
|
85
|
-
)}
|
|
86
|
-
</div>
|
|
87
|
-
);
|
|
88
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { useEffect, useRef } from 'react';
|
|
4
|
-
|
|
5
|
-
import { useApiClient } from '../lib/api-client';
|
|
6
|
-
|
|
7
|
-
const ALLOWED_ORIGINS = ['https://shell.docy.work', 'https://shell-docyrus.web.app'];
|
|
8
|
-
|
|
9
|
-
interface ShellCanvasUser {
|
|
10
|
-
id?: string;
|
|
11
|
-
email?: string;
|
|
12
|
-
firstname?: string;
|
|
13
|
-
lastname?: string;
|
|
14
|
-
photo?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
interface ShellCanvasProps {
|
|
18
|
-
workId: string;
|
|
19
|
-
versionId?: string | null;
|
|
20
|
-
title?: string;
|
|
21
|
-
user?: ShellCanvasUser;
|
|
22
|
-
onSendToChat?: (message: string) => void;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function ShellCanvas({
|
|
26
|
-
workId, versionId, title, user, onSendToChat
|
|
27
|
-
}: ShellCanvasProps) {
|
|
28
|
-
const src = `https://shell.docy.work?work=${workId}${versionId ? `&versionId=${versionId}` : ''}`;
|
|
29
|
-
const apiClient = useApiClient();
|
|
30
|
-
const onSendToChatRef = useRef(onSendToChat);
|
|
31
|
-
|
|
32
|
-
onSendToChatRef.current = onSendToChat;
|
|
33
|
-
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const api: Record<string, (...args: any[]) => unknown> = {
|
|
36
|
-
getUser: () => user ?? {},
|
|
37
|
-
getTenant: () => ({}),
|
|
38
|
-
getRecord: async (appSlug: string, dataSourceSlug: string, recordId: string, options: any = {}) => {
|
|
39
|
-
const params: Record<string, unknown> = {};
|
|
40
|
-
|
|
41
|
-
if (options.columns) params.columns = options.columns;
|
|
42
|
-
|
|
43
|
-
return apiClient.get(`apps/${appSlug}/data-sources/${dataSourceSlug}/items/${recordId}`, params);
|
|
44
|
-
},
|
|
45
|
-
getRecords: async (appSlug: string, dataSourceSlug: string, options: any = {}) => {
|
|
46
|
-
const params: Record<string, unknown> = {};
|
|
47
|
-
|
|
48
|
-
[
|
|
49
|
-
'columns',
|
|
50
|
-
'limit',
|
|
51
|
-
'offset',
|
|
52
|
-
'orderBy',
|
|
53
|
-
'orderByDirection',
|
|
54
|
-
'filters',
|
|
55
|
-
'pivot'
|
|
56
|
-
].forEach((k) => {
|
|
57
|
-
if (options[k] !== undefined) params[k] = options[k];
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
return apiClient.get(`apps/${appSlug}/data-sources/${dataSourceSlug}/items`, params);
|
|
61
|
-
},
|
|
62
|
-
insertRecord: (appSlug: string, dataSourceSlug: string, data: unknown) => apiClient.post(`apps/${appSlug}/data-sources/${dataSourceSlug}/items`, data),
|
|
63
|
-
updateRecord: (appSlug: string, dataSourceSlug: string, recordId: string, data: unknown) => apiClient.patch(`apps/${appSlug}/data-sources/${dataSourceSlug}/items/${recordId}`, data),
|
|
64
|
-
deleteRecord: (appSlug: string, dataSourceSlug: string, recordId: string) => apiClient.delete(`apps/${appSlug}/data-sources/${dataSourceSlug}/items/${recordId}`),
|
|
65
|
-
viewRecord: async () => {},
|
|
66
|
-
runAggregateQuery: (appSlug: string, dataSourceSlug: string, rows: unknown, calculations: unknown) => apiClient.get(`apps/${appSlug}/data-sources/${dataSourceSlug}/items`, { rows, calculations } as any),
|
|
67
|
-
runCustomQuery: (customQueryId: string, options: unknown) => apiClient.put(`reports/runCustomQuery/${customQueryId}`, options),
|
|
68
|
-
sendToChat: (message: string) => { onSendToChatRef.current?.(message); },
|
|
69
|
-
list: (...args: any[]) => apiClient.get(args[0], args[1]),
|
|
70
|
-
get: (...args: any[]) => apiClient.get(args[0], args[1]),
|
|
71
|
-
post: (...args: any[]) => apiClient.post(args[0], args[1]),
|
|
72
|
-
put: (...args: any[]) => apiClient.put(args[0], args[1]),
|
|
73
|
-
patch: (...args: any[]) => apiClient.patch(args[0], args[1]),
|
|
74
|
-
delete: (...args: any[]) => apiClient.delete(args[0])
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const handleMessage = async (event: MessageEvent) => {
|
|
78
|
-
if (!ALLOWED_ORIGINS.includes(event.origin)) return;
|
|
79
|
-
|
|
80
|
-
const { type, id } = event.data ?? {};
|
|
81
|
-
|
|
82
|
-
if (type === 'handshake') {
|
|
83
|
-
(event.source as Window)?.postMessage(
|
|
84
|
-
{
|
|
85
|
-
type: 'handshake_ack',
|
|
86
|
-
id,
|
|
87
|
-
sessionId: crypto.randomUUID(),
|
|
88
|
-
allowedMethods: Object.keys(api)
|
|
89
|
-
},
|
|
90
|
-
event.origin
|
|
91
|
-
);
|
|
92
|
-
} else if (type === 'rpc') {
|
|
93
|
-
const { method, params = [] } = event.data;
|
|
94
|
-
|
|
95
|
-
if (!Object.prototype.hasOwnProperty.call(api, method)) return;
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
const result = await (api[method] as any)(...params);
|
|
99
|
-
|
|
100
|
-
(event.source as Window)?.postMessage({ type: 'rpc_response', id, result }, event.origin);
|
|
101
|
-
} catch (err: any) {
|
|
102
|
-
(event.source as Window)?.postMessage(
|
|
103
|
-
{ type: 'rpc_response', id, error: err?.message ?? 'Unknown error' },
|
|
104
|
-
event.origin
|
|
105
|
-
);
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
window.addEventListener('message', handleMessage);
|
|
111
|
-
|
|
112
|
-
return () => window.removeEventListener('message', handleMessage);
|
|
113
|
-
}, [apiClient, user]);
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<iframe
|
|
117
|
-
src={src}
|
|
118
|
-
title={title}
|
|
119
|
-
className="w-full h-full border-0"
|
|
120
|
-
sandbox="allow-scripts allow-same-origin allow-downloads allow-modals allow-forms allow-presentation allow-top-navigation-by-user-activation allow-popups" />
|
|
121
|
-
);
|
|
122
|
-
}
|
|
@@ -1,352 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
useCallback, useEffect, useMemo, useRef, useState
|
|
5
|
-
} from 'react';
|
|
6
|
-
|
|
7
|
-
import {
|
|
8
|
-
ChevronDown, Download, FileSpreadsheet, FileText
|
|
9
|
-
} from 'lucide-react';
|
|
10
|
-
|
|
11
|
-
import { Button } from '@docyrus/ui-pro-shared/components/button';
|
|
12
|
-
import {
|
|
13
|
-
DropdownMenu,
|
|
14
|
-
DropdownMenuContent,
|
|
15
|
-
DropdownMenuItem,
|
|
16
|
-
DropdownMenuTrigger
|
|
17
|
-
} from '@docyrus/ui-pro-shared/components/dropdown-menu';
|
|
18
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
19
|
-
|
|
20
|
-
interface ColumnFormat {
|
|
21
|
-
formatter: 'number' | 'percent' | 'currency' | 'date' | 'datetime';
|
|
22
|
-
format?: Record<string, any> | string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface Column {
|
|
26
|
-
name?: string;
|
|
27
|
-
field?: string;
|
|
28
|
-
title?: string;
|
|
29
|
-
label?: string;
|
|
30
|
-
width?: number;
|
|
31
|
-
align?: 'left' | 'center' | 'right';
|
|
32
|
-
format?: ColumnFormat;
|
|
33
|
-
sortable?: boolean;
|
|
34
|
-
minWidth?: number;
|
|
35
|
-
maxWidth?: number;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
interface ShowAdvancedDataTableProps {
|
|
39
|
-
title?: string;
|
|
40
|
-
description?: string;
|
|
41
|
-
additionalComments?: string | null;
|
|
42
|
-
state?: string;
|
|
43
|
-
errorText?: string;
|
|
44
|
-
data?: string;
|
|
45
|
-
columns?: Column[];
|
|
46
|
-
enableTree?: boolean;
|
|
47
|
-
treeChildrenField?: string;
|
|
48
|
-
sortable?: boolean;
|
|
49
|
-
defaultRowHeight?: number;
|
|
50
|
-
defaultHeaderRowHeight?: number;
|
|
51
|
-
defaultColWidth?: number;
|
|
52
|
-
height?: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const formatCellValue = (value: any, formatConfig?: ColumnFormat): string => {
|
|
56
|
-
if (value === null || value === undefined) return '-';
|
|
57
|
-
if (!formatConfig?.formatter) return String(value);
|
|
58
|
-
|
|
59
|
-
const { formatter, format } = formatConfig;
|
|
60
|
-
const fmt = typeof format === 'string' ? JSON.parse(format) : (format ?? {});
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
switch (formatter) {
|
|
64
|
-
case 'number': {
|
|
65
|
-
const num = typeof value === 'string' ? parseFloat(value) : value;
|
|
66
|
-
|
|
67
|
-
if (typeof num !== 'number' || isNaN(num)) return String(value);
|
|
68
|
-
const { thousandsSeparator = ',', decimalsSeparator = '.', decimalPlaces = 2 } = fmt;
|
|
69
|
-
const fixed = num.toFixed(decimalPlaces);
|
|
70
|
-
const [intPart, decPart] = fixed.split('.');
|
|
71
|
-
const formattedInt = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, thousandsSeparator);
|
|
72
|
-
|
|
73
|
-
return decPart ? `${formattedInt}${decimalsSeparator}${decPart}` : formattedInt;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
case 'percent': {
|
|
77
|
-
const num = typeof value === 'string' ? parseFloat(value) : value;
|
|
78
|
-
|
|
79
|
-
if (typeof num !== 'number' || isNaN(num)) return String(value);
|
|
80
|
-
|
|
81
|
-
return `${(num * 100).toFixed(fmt.decimalPlaces ?? 2)}%`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
case 'currency': {
|
|
85
|
-
const num = typeof value === 'string' ? parseFloat(value) : value;
|
|
86
|
-
|
|
87
|
-
if (typeof num !== 'number' || isNaN(num)) return String(value);
|
|
88
|
-
|
|
89
|
-
return `${fmt.symbol ?? '$'}${num.toFixed(2)}`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
case 'date': {
|
|
93
|
-
const d = new Date(value);
|
|
94
|
-
|
|
95
|
-
if (isNaN(d.getTime())) return String(value);
|
|
96
|
-
|
|
97
|
-
return d.toISOString().split('T')[0];
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
case 'datetime': {
|
|
101
|
-
const d = new Date(value);
|
|
102
|
-
|
|
103
|
-
if (isNaN(d.getTime())) return String(value);
|
|
104
|
-
const iso = d.toISOString();
|
|
105
|
-
|
|
106
|
-
return `${iso.split('T')[0]} ${iso.split('T')[1].slice(0, 5)}`;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
default:
|
|
110
|
-
return String(value);
|
|
111
|
-
}
|
|
112
|
-
} catch {
|
|
113
|
-
return String(value);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
export function ShowAdvancedDataTable({
|
|
118
|
-
title = 'Data Table',
|
|
119
|
-
description,
|
|
120
|
-
additionalComments,
|
|
121
|
-
state,
|
|
122
|
-
errorText,
|
|
123
|
-
data,
|
|
124
|
-
columns = [],
|
|
125
|
-
enableTree = false,
|
|
126
|
-
treeChildrenField = 'children',
|
|
127
|
-
sortable = true,
|
|
128
|
-
defaultRowHeight = 40,
|
|
129
|
-
defaultHeaderRowHeight = 40,
|
|
130
|
-
defaultColWidth = 150,
|
|
131
|
-
height = 500
|
|
132
|
-
}: ShowAdvancedDataTableProps) {
|
|
133
|
-
const [open, setOpen] = useState(true);
|
|
134
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
135
|
-
const tableRef = useRef<any>(null);
|
|
136
|
-
|
|
137
|
-
const parsedData = useMemo(() => {
|
|
138
|
-
if (!data) return [];
|
|
139
|
-
try {
|
|
140
|
-
const parsed = JSON.parse(data);
|
|
141
|
-
|
|
142
|
-
return Array.isArray(parsed) ? parsed : [];
|
|
143
|
-
} catch {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
}, [data]);
|
|
147
|
-
|
|
148
|
-
const parseError = useMemo(() => {
|
|
149
|
-
if (!data) return null;
|
|
150
|
-
try {
|
|
151
|
-
JSON.parse(data);
|
|
152
|
-
|
|
153
|
-
return null;
|
|
154
|
-
} catch (e: any) {
|
|
155
|
-
return e.message as string;
|
|
156
|
-
}
|
|
157
|
-
}, [data]);
|
|
158
|
-
|
|
159
|
-
const vtableColumns = useMemo(() => {
|
|
160
|
-
return columns.map((col) => {
|
|
161
|
-
const field = col.field ?? col.name ?? '';
|
|
162
|
-
const column: Record<string, any> = {
|
|
163
|
-
field,
|
|
164
|
-
title: col.title ?? col.label ?? field
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
if (col.width) column.width = typeof col.width === 'string' ? parseInt(col.width) : col.width;
|
|
168
|
-
if (col.minWidth) column.minWidth = col.minWidth;
|
|
169
|
-
if (col.maxWidth) column.maxWidth = col.maxWidth;
|
|
170
|
-
column.sort = col.sortable !== undefined ? col.sortable : sortable;
|
|
171
|
-
if (col.align) {
|
|
172
|
-
column.headerStyle = { textAlign: col.align };
|
|
173
|
-
column.style = { textAlign: col.align };
|
|
174
|
-
}
|
|
175
|
-
if (col.format?.formatter) {
|
|
176
|
-
column.format = (value: any) => formatCellValue(value, col.format);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return column;
|
|
180
|
-
});
|
|
181
|
-
}, [columns, sortable]);
|
|
182
|
-
|
|
183
|
-
const initTable = useCallback(async () => {
|
|
184
|
-
if (!containerRef.current || !parsedData || parsedData.length === 0) return;
|
|
185
|
-
|
|
186
|
-
// Ensure container has dimensions
|
|
187
|
-
const rect = containerRef.current.getBoundingClientRect();
|
|
188
|
-
|
|
189
|
-
if (rect.width === 0) return;
|
|
190
|
-
|
|
191
|
-
try {
|
|
192
|
-
const VTable = await import('@visactor/vtable');
|
|
193
|
-
|
|
194
|
-
if (tableRef.current) {
|
|
195
|
-
tableRef.current.release();
|
|
196
|
-
tableRef.current = null;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const options: Record<string, any> = {
|
|
200
|
-
container: containerRef.current,
|
|
201
|
-
records: parsedData,
|
|
202
|
-
columns: vtableColumns,
|
|
203
|
-
defaultRowHeight,
|
|
204
|
-
defaultHeaderRowHeight,
|
|
205
|
-
defaultColWidth,
|
|
206
|
-
widthMode: 'standard',
|
|
207
|
-
height,
|
|
208
|
-
animationAppear: false
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
if (enableTree) {
|
|
212
|
-
options.tree = { children: treeChildrenField, defaultOpenLevel: 1 };
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
tableRef.current = new VTable.ListTable(options);
|
|
216
|
-
} catch (err) {
|
|
217
|
-
console.error('Failed to initialize VTable:', err);
|
|
218
|
-
}
|
|
219
|
-
}, [
|
|
220
|
-
parsedData,
|
|
221
|
-
vtableColumns,
|
|
222
|
-
defaultRowHeight,
|
|
223
|
-
defaultHeaderRowHeight,
|
|
224
|
-
defaultColWidth,
|
|
225
|
-
height,
|
|
226
|
-
enableTree,
|
|
227
|
-
treeChildrenField
|
|
228
|
-
]);
|
|
229
|
-
|
|
230
|
-
useEffect(() => {
|
|
231
|
-
if (state !== 'output-available' || !open) return;
|
|
232
|
-
|
|
233
|
-
// First attempt after short delay for layout
|
|
234
|
-
const t1 = setTimeout(() => initTable(), 150);
|
|
235
|
-
|
|
236
|
-
// Retry via ResizeObserver in case container has no dimensions yet
|
|
237
|
-
const observer = new ResizeObserver((entries) => {
|
|
238
|
-
const entry = entries[0];
|
|
239
|
-
|
|
240
|
-
if (entry && entry.contentRect.width > 0 && !tableRef.current) {
|
|
241
|
-
initTable();
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
if (containerRef.current) {
|
|
246
|
-
observer.observe(containerRef.current);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
return () => {
|
|
250
|
-
clearTimeout(t1);
|
|
251
|
-
observer.disconnect();
|
|
252
|
-
};
|
|
253
|
-
}, [state, open, initTable]);
|
|
254
|
-
|
|
255
|
-
useEffect(() => {
|
|
256
|
-
return () => {
|
|
257
|
-
if (tableRef.current) {
|
|
258
|
-
tableRef.current.release();
|
|
259
|
-
tableRef.current = null;
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
}, []);
|
|
263
|
-
|
|
264
|
-
const handleDownload = useCallback(async (type: 'csv' | 'xlsx') => {
|
|
265
|
-
if (!tableRef.current) return;
|
|
266
|
-
const fileName = title;
|
|
267
|
-
|
|
268
|
-
if (type === 'csv') {
|
|
269
|
-
tableRef.current.exportToCsv?.({ fileName: `${fileName}.csv`, downloadFile: true, exportAllData: true });
|
|
270
|
-
} else {
|
|
271
|
-
tableRef.current.exportToExcel?.({
|
|
272
|
-
fileName: `${fileName}.xlsx`, downloadFile: true, exportAllData: true, ignoreIcon: true
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
}, [title]);
|
|
276
|
-
|
|
277
|
-
return (
|
|
278
|
-
<div className="rounded-xl shadow bg-card border overflow-hidden">
|
|
279
|
-
{/* Header */}
|
|
280
|
-
<div
|
|
281
|
-
role="button"
|
|
282
|
-
tabIndex={0}
|
|
283
|
-
onClick={() => setOpen(v => !v)}
|
|
284
|
-
onKeyDown={e => (e.key === 'Enter' || e.key === ' ') && setOpen(v => !v)}
|
|
285
|
-
className="flex w-full items-center justify-between gap-1.5 px-4 py-3 text-left bg-muted/50 hover:bg-muted transition-colors cursor-pointer select-none">
|
|
286
|
-
<div className="flex items-center gap-2 grow min-w-0">
|
|
287
|
-
<span className="font-medium text-sm truncate">{title}</span>
|
|
288
|
-
{description && (
|
|
289
|
-
<span className="text-xs text-muted-foreground truncate hidden sm:block">{description}</span>
|
|
290
|
-
)}
|
|
291
|
-
</div>
|
|
292
|
-
<div className="flex items-center gap-1 shrink-0">
|
|
293
|
-
<DropdownMenu>
|
|
294
|
-
<DropdownMenuTrigger asChild>
|
|
295
|
-
<Button
|
|
296
|
-
variant="ghost"
|
|
297
|
-
size="icon"
|
|
298
|
-
className="h-7 w-7"
|
|
299
|
-
onClick={e => e.stopPropagation()}>
|
|
300
|
-
<Download className="size-3.5" />
|
|
301
|
-
</Button>
|
|
302
|
-
</DropdownMenuTrigger>
|
|
303
|
-
<DropdownMenuContent align="end">
|
|
304
|
-
<DropdownMenuItem onClick={() => handleDownload('csv')}>
|
|
305
|
-
<FileText className="size-4 mr-2" />
|
|
306
|
-
Download as CSV
|
|
307
|
-
</DropdownMenuItem>
|
|
308
|
-
<DropdownMenuItem onClick={() => handleDownload('xlsx')}>
|
|
309
|
-
<FileSpreadsheet className="size-4 mr-2" />
|
|
310
|
-
Download as XLSX
|
|
311
|
-
</DropdownMenuItem>
|
|
312
|
-
</DropdownMenuContent>
|
|
313
|
-
</DropdownMenu>
|
|
314
|
-
<ChevronDown className={cn('size-4 text-muted-foreground transition-transform', open && 'rotate-180')} />
|
|
315
|
-
</div>
|
|
316
|
-
</div>
|
|
317
|
-
|
|
318
|
-
{/* Body — always in DOM so VTable container keeps its ref */}
|
|
319
|
-
<div className={cn('p-4', !open && 'hidden')}>
|
|
320
|
-
{state !== 'output-available' && !parseError && (
|
|
321
|
-
<div className="w-full h-[200px] rounded-lg bg-muted/30 animate-pulse" />
|
|
322
|
-
)}
|
|
323
|
-
{parseError && (
|
|
324
|
-
<div className="text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3">
|
|
325
|
-
<div className="font-medium">Error parsing data</div>
|
|
326
|
-
<div className="text-xs mt-1">{parseError}</div>
|
|
327
|
-
</div>
|
|
328
|
-
)}
|
|
329
|
-
{errorText && !parseError && (
|
|
330
|
-
<div className="text-sm text-destructive bg-destructive/10 border border-destructive/20 rounded-lg p-3">
|
|
331
|
-
{errorText}
|
|
332
|
-
</div>
|
|
333
|
-
)}
|
|
334
|
-
{state === 'output-available' && !parseError && parsedData && parsedData.length === 0 && (
|
|
335
|
-
<div className="text-sm text-muted-foreground text-center py-6">No data to display</div>
|
|
336
|
-
)}
|
|
337
|
-
<div ref={containerRef} className="w-full rounded-lg" style={{ height: `${height}px` }} />
|
|
338
|
-
{state === 'output-available' && parsedData && parsedData.length > 0 && (
|
|
339
|
-
<div className="text-xs text-muted-foreground mt-2">
|
|
340
|
-
{parsedData.length} {parsedData.length === 1 ? 'row' : 'rows'}
|
|
341
|
-
</div>
|
|
342
|
-
)}
|
|
343
|
-
{additionalComments && (
|
|
344
|
-
<div className="mt-4 text-sm bg-blue-50 border border-blue-200 rounded-lg p-3 dark:bg-blue-950/30 dark:border-blue-800">
|
|
345
|
-
<div className="font-medium text-blue-900 dark:text-blue-300 mb-1">Note</div>
|
|
346
|
-
<div className="text-blue-800 dark:text-blue-400">{additionalComments}</div>
|
|
347
|
-
</div>
|
|
348
|
-
)}
|
|
349
|
-
</div>
|
|
350
|
-
</div>
|
|
351
|
-
);
|
|
352
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { List, Plus, RefreshCw } from 'lucide-react';
|
|
4
|
-
|
|
5
|
-
import { Button } from '@docyrus/ui-pro-shared/components/button';
|
|
6
|
-
|
|
7
|
-
interface ContentOption {
|
|
8
|
-
title?: string;
|
|
9
|
-
text?: string;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ShowGeneratedContentOptionsProps {
|
|
13
|
-
output?: ContentOption[] | null;
|
|
14
|
-
state: string;
|
|
15
|
-
onInsertText?: (data: { text: string }) => void;
|
|
16
|
-
onReplaceText?: (data: { text: string }) => void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function ShowGeneratedContentOptions({
|
|
20
|
-
output,
|
|
21
|
-
state,
|
|
22
|
-
onInsertText,
|
|
23
|
-
onReplaceText
|
|
24
|
-
}: ShowGeneratedContentOptionsProps) {
|
|
25
|
-
const options: ContentOption[] = Array.isArray(output) ? output : [];
|
|
26
|
-
|
|
27
|
-
if (state === 'output-error') {
|
|
28
|
-
return <div className="text-xs text-destructive py-1">Failed to load options</div>;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (state === 'output-available' && options.length === 0) {
|
|
32
|
-
return <div className="text-xs text-muted-foreground py-1">No options to display</div>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (state !== 'output-available' || options.length === 0) return null;
|
|
36
|
-
|
|
37
|
-
const handleInsert = (option: ContentOption) => {
|
|
38
|
-
onInsertText?.({ text: option.text || option.title || '' });
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const handleReplace = (option: ContentOption) => {
|
|
42
|
-
onReplaceText?.({ text: option.text || option.title || '' });
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<div className="w-full">
|
|
47
|
-
<div className="flex items-center p-1 gap-2 mb-2">
|
|
48
|
-
<List className="w-4 h-4 text-primary" />
|
|
49
|
-
<p className="text-xs font-medium text-primary">
|
|
50
|
-
{`${options.length} options generated:`}
|
|
51
|
-
</p>
|
|
52
|
-
</div>
|
|
53
|
-
<div className="flex flex-col gap-2">
|
|
54
|
-
{options.map((option, index) => (
|
|
55
|
-
<div key={index} className="flex px-4 pt-2 rounded-lg bg-slate-50">
|
|
56
|
-
<div className="flex items-center justify-between mb-4 w-full">
|
|
57
|
-
<div className="flex flex-col w-full">
|
|
58
|
-
<div className="flex mb-2 justify-between items-center">
|
|
59
|
-
{option.title && (
|
|
60
|
-
<h3 className="text-sm ps-2 font-semibold text-foreground w-fit">
|
|
61
|
-
{option.title}
|
|
62
|
-
</h3>
|
|
63
|
-
)}
|
|
64
|
-
<div className="flex justify-end gap-2">
|
|
65
|
-
<Button
|
|
66
|
-
size="sm"
|
|
67
|
-
variant="secondary"
|
|
68
|
-
className="gap-1.5 [&_svg]:size-3.5 text-sky-600 hover:text-sky-700"
|
|
69
|
-
onClick={() => handleInsert(option)}>
|
|
70
|
-
<Plus />
|
|
71
|
-
Insert
|
|
72
|
-
</Button>
|
|
73
|
-
<Button
|
|
74
|
-
size="sm"
|
|
75
|
-
variant="secondary"
|
|
76
|
-
className="gap-1.5 [&_svg]:size-3.5 text-amber-600 hover:text-amber-700"
|
|
77
|
-
onClick={() => handleReplace(option)}>
|
|
78
|
-
<RefreshCw />
|
|
79
|
-
Replace
|
|
80
|
-
</Button>
|
|
81
|
-
</div>
|
|
82
|
-
</div>
|
|
83
|
-
{option.text && (
|
|
84
|
-
<p className="text-xs text-muted-foreground">{option.text}</p>
|
|
85
|
-
)}
|
|
86
|
-
</div>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
))}
|
|
90
|
-
</div>
|
|
91
|
-
</div>
|
|
92
|
-
);
|
|
93
|
-
}
|