@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,469 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Fragment, useMemo, useState } from 'react';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
type TResolvedSuggestion,
|
|
7
|
-
acceptSuggestion,
|
|
8
|
-
getSuggestionKey,
|
|
9
|
-
keyId2SuggestionId,
|
|
10
|
-
rejectSuggestion
|
|
11
|
-
} from '@platejs/suggestion';
|
|
12
|
-
|
|
13
|
-
import { SuggestionPlugin } from '@platejs/suggestion/react';
|
|
14
|
-
import { CheckIcon, XIcon } from 'lucide-react';
|
|
15
|
-
import {
|
|
16
|
-
type NodeEntry,
|
|
17
|
-
type Path,
|
|
18
|
-
type TElement,
|
|
19
|
-
type TSuggestionText,
|
|
20
|
-
ElementApi,
|
|
21
|
-
KEYS,
|
|
22
|
-
PathApi,
|
|
23
|
-
TextApi
|
|
24
|
-
} from 'platejs';
|
|
25
|
-
import { useEditorPlugin, usePluginOption } from 'platejs/react';
|
|
26
|
-
|
|
27
|
-
import { Avatar, AvatarFallback, AvatarImage } from '@docyrus/ui-pro-shared/avatar';
|
|
28
|
-
|
|
29
|
-
import { Button } from './button';
|
|
30
|
-
|
|
31
|
-
import {
|
|
32
|
-
Comment,
|
|
33
|
-
CommentCreateForm,
|
|
34
|
-
formatCommentDate,
|
|
35
|
-
type TComment
|
|
36
|
-
} from './comment';
|
|
37
|
-
|
|
38
|
-
import {
|
|
39
|
-
discussionPlugin,
|
|
40
|
-
type TDiscussion
|
|
41
|
-
} from '../editor/plugins/discussion-kit';
|
|
42
|
-
import { suggestionPlugin } from '../editor/plugins/suggestion-kit';
|
|
43
|
-
|
|
44
|
-
export interface ResolvedSuggestion extends TResolvedSuggestion {
|
|
45
|
-
comments: TComment[];
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const BLOCK_SUGGESTION = '__block__';
|
|
49
|
-
|
|
50
|
-
export const TYPE_TEXT_MAP: Record<string, (node?: TElement) => string> = {
|
|
51
|
-
[KEYS.audio]: () => 'Audio',
|
|
52
|
-
[KEYS.blockquote]: () => 'Blockquote',
|
|
53
|
-
[KEYS.callout]: () => 'Callout',
|
|
54
|
-
[KEYS.codeBlock]: () => 'Code Block',
|
|
55
|
-
[KEYS.column]: () => 'Column',
|
|
56
|
-
[KEYS.equation]: () => 'Equation',
|
|
57
|
-
[KEYS.file]: () => 'File',
|
|
58
|
-
[KEYS.h1]: () => 'Heading 1',
|
|
59
|
-
[KEYS.h2]: () => 'Heading 2',
|
|
60
|
-
[KEYS.h3]: () => 'Heading 3',
|
|
61
|
-
[KEYS.h4]: () => 'Heading 4',
|
|
62
|
-
[KEYS.h5]: () => 'Heading 5',
|
|
63
|
-
[KEYS.h6]: () => 'Heading 6',
|
|
64
|
-
[KEYS.hr]: () => 'Horizontal Rule',
|
|
65
|
-
[KEYS.img]: () => 'Image',
|
|
66
|
-
[KEYS.mediaEmbed]: () => 'Media',
|
|
67
|
-
[KEYS.p]: (node) => {
|
|
68
|
-
if (node?.[KEYS.listType] === KEYS.listTodo) return 'Todo List';
|
|
69
|
-
if (node?.[KEYS.listType] === KEYS.ol) return 'Ordered List';
|
|
70
|
-
if (node?.[KEYS.listType] === KEYS.ul) return 'List';
|
|
71
|
-
|
|
72
|
-
return 'Paragraph';
|
|
73
|
-
},
|
|
74
|
-
[KEYS.table]: () => 'Table',
|
|
75
|
-
[KEYS.toc]: () => 'Table of Contents',
|
|
76
|
-
[KEYS.toggle]: () => 'Toggle',
|
|
77
|
-
[KEYS.video]: () => 'Video'
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
export function BlockSuggestionCard({
|
|
81
|
-
idx,
|
|
82
|
-
isLast,
|
|
83
|
-
suggestion
|
|
84
|
-
}: {
|
|
85
|
-
idx: number;
|
|
86
|
-
isLast: boolean;
|
|
87
|
-
suggestion: ResolvedSuggestion;
|
|
88
|
-
}) {
|
|
89
|
-
const { api, editor } = useEditorPlugin(SuggestionPlugin);
|
|
90
|
-
|
|
91
|
-
const userInfo = usePluginOption(discussionPlugin, 'user', suggestion.userId);
|
|
92
|
-
|
|
93
|
-
const accept = (suggestion: ResolvedSuggestion) => {
|
|
94
|
-
api.suggestion.withoutSuggestions(() => {
|
|
95
|
-
acceptSuggestion(editor, suggestion);
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
const reject = (suggestion: ResolvedSuggestion) => {
|
|
100
|
-
api.suggestion.withoutSuggestions(() => {
|
|
101
|
-
rejectSuggestion(editor, suggestion);
|
|
102
|
-
});
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const [hovering, setHovering] = useState(false);
|
|
106
|
-
|
|
107
|
-
const suggestionText2Array = (text: string) => {
|
|
108
|
-
if (text === BLOCK_SUGGESTION) return ['line breaks'];
|
|
109
|
-
|
|
110
|
-
return text.split(BLOCK_SUGGESTION).filter(Boolean);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const [editingId, setEditingId] = useState<string | null>(null);
|
|
114
|
-
|
|
115
|
-
return (
|
|
116
|
-
<div
|
|
117
|
-
key={`${suggestion.suggestionId}-${idx}`}
|
|
118
|
-
className="relative"
|
|
119
|
-
onMouseEnter={() => setHovering(true)}
|
|
120
|
-
onMouseLeave={() => setHovering(false)}>
|
|
121
|
-
<div className="flex flex-col p-4">
|
|
122
|
-
<div className="relative flex items-center">
|
|
123
|
-
{/* Replace to your own backend or refer to potion */}
|
|
124
|
-
<Avatar className="size-5">
|
|
125
|
-
<AvatarImage alt={userInfo?.name} src={userInfo?.avatarUrl} />
|
|
126
|
-
<AvatarFallback>{userInfo?.name?.[0]}</AvatarFallback>
|
|
127
|
-
</Avatar>
|
|
128
|
-
<h4 className="mx-2 font-semibold text-sm leading-none">
|
|
129
|
-
{userInfo?.name}
|
|
130
|
-
</h4>
|
|
131
|
-
<div className="text-muted-foreground/80 text-xs leading-none">
|
|
132
|
-
<span className="mr-1">
|
|
133
|
-
{formatCommentDate(new Date(suggestion.createdAt))}
|
|
134
|
-
</span>
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
|
|
138
|
-
<div className="relative mt-1 mb-4 pl-[32px]">
|
|
139
|
-
<div className="flex flex-col gap-2">
|
|
140
|
-
{suggestion.type === 'remove'
|
|
141
|
-
&& suggestionText2Array(suggestion.text!).map((text, index) => (
|
|
142
|
-
<div key={index} className="flex items-center gap-2">
|
|
143
|
-
<span className="text-muted-foreground text-sm">Delete:</span>
|
|
144
|
-
|
|
145
|
-
<span key={index} className="text-sm">
|
|
146
|
-
{text}
|
|
147
|
-
</span>
|
|
148
|
-
</div>
|
|
149
|
-
))}
|
|
150
|
-
|
|
151
|
-
{suggestion.type === 'insert'
|
|
152
|
-
&& suggestionText2Array(suggestion.newText!).map((text, index) => (
|
|
153
|
-
<div key={index} className="flex items-center gap-2">
|
|
154
|
-
<span className="text-muted-foreground text-sm">Add:</span>
|
|
155
|
-
|
|
156
|
-
<span key={index} className="text-sm">
|
|
157
|
-
{text || 'line breaks'}
|
|
158
|
-
</span>
|
|
159
|
-
</div>
|
|
160
|
-
))}
|
|
161
|
-
|
|
162
|
-
{suggestion.type === 'replace' && (
|
|
163
|
-
<div className="flex flex-col gap-2">
|
|
164
|
-
{suggestionText2Array(suggestion.newText!).map(
|
|
165
|
-
(text, index) => (
|
|
166
|
-
<Fragment key={index}>
|
|
167
|
-
<div
|
|
168
|
-
key={index}
|
|
169
|
-
className="flex items-start gap-2 text-brand/80">
|
|
170
|
-
<span className="text-sm">with:</span>
|
|
171
|
-
<span className="text-sm">{text || 'line breaks'}</span>
|
|
172
|
-
</div>
|
|
173
|
-
</Fragment>
|
|
174
|
-
)
|
|
175
|
-
)}
|
|
176
|
-
|
|
177
|
-
{suggestionText2Array(suggestion.text!).map((text, index) => (
|
|
178
|
-
<Fragment key={index}>
|
|
179
|
-
<div key={index} className="flex items-start gap-2">
|
|
180
|
-
<span className="text-muted-foreground text-sm">
|
|
181
|
-
{index === 0 ? 'Replace:' : 'Delete:'}
|
|
182
|
-
</span>
|
|
183
|
-
<span className="text-sm">{text || 'line breaks'}</span>
|
|
184
|
-
</div>
|
|
185
|
-
</Fragment>
|
|
186
|
-
))}
|
|
187
|
-
</div>
|
|
188
|
-
)}
|
|
189
|
-
|
|
190
|
-
{suggestion.type === 'update' && (
|
|
191
|
-
<div className="flex items-center gap-2">
|
|
192
|
-
<span className="text-muted-foreground text-sm">
|
|
193
|
-
{Object.keys(suggestion.properties).map(key => (
|
|
194
|
-
<span key={key}>Un{key}</span>
|
|
195
|
-
))}
|
|
196
|
-
|
|
197
|
-
{Object.keys(suggestion.newProperties).map(key => (
|
|
198
|
-
<span key={key}>
|
|
199
|
-
{key.charAt(0).toUpperCase() + key.slice(1)}
|
|
200
|
-
</span>
|
|
201
|
-
))}
|
|
202
|
-
</span>
|
|
203
|
-
<span className="text-sm">{suggestion.newText}</span>
|
|
204
|
-
</div>
|
|
205
|
-
)}
|
|
206
|
-
</div>
|
|
207
|
-
</div>
|
|
208
|
-
|
|
209
|
-
{suggestion.comments.map((comment, index) => (
|
|
210
|
-
<Comment
|
|
211
|
-
key={comment.id ?? index}
|
|
212
|
-
comment={comment}
|
|
213
|
-
discussionLength={suggestion.comments.length}
|
|
214
|
-
documentContent="__suggestion__"
|
|
215
|
-
editingId={editingId}
|
|
216
|
-
index={index}
|
|
217
|
-
setEditingId={setEditingId} />
|
|
218
|
-
))}
|
|
219
|
-
|
|
220
|
-
{hovering && (
|
|
221
|
-
<div className="absolute top-4 right-4 flex gap-2">
|
|
222
|
-
<Button
|
|
223
|
-
variant="ghost"
|
|
224
|
-
className="size-6 p-1 text-muted-foreground"
|
|
225
|
-
onClick={() => accept(suggestion)}>
|
|
226
|
-
<CheckIcon className="size-4" />
|
|
227
|
-
</Button>
|
|
228
|
-
|
|
229
|
-
<Button
|
|
230
|
-
variant="ghost"
|
|
231
|
-
className="size-6 p-1 text-muted-foreground"
|
|
232
|
-
onClick={() => reject(suggestion)}>
|
|
233
|
-
<XIcon className="size-4" />
|
|
234
|
-
</Button>
|
|
235
|
-
</div>
|
|
236
|
-
)}
|
|
237
|
-
|
|
238
|
-
<CommentCreateForm discussionId={suggestion.suggestionId} />
|
|
239
|
-
</div>
|
|
240
|
-
|
|
241
|
-
{!isLast && <div className="h-px w-full bg-muted" />}
|
|
242
|
-
</div>
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
export const useResolveSuggestion = (
|
|
247
|
-
suggestionNodes: NodeEntry<TElement | TSuggestionText>[],
|
|
248
|
-
blockPath: Path
|
|
249
|
-
) => {
|
|
250
|
-
const discussions = usePluginOption(discussionPlugin, 'discussions');
|
|
251
|
-
|
|
252
|
-
const {
|
|
253
|
-
api, editor, getOption, setOption
|
|
254
|
-
}
|
|
255
|
-
= useEditorPlugin(suggestionPlugin);
|
|
256
|
-
|
|
257
|
-
suggestionNodes.forEach(([node]) => {
|
|
258
|
-
const id = api.suggestion.nodeId(node);
|
|
259
|
-
const map = getOption('uniquePathMap');
|
|
260
|
-
|
|
261
|
-
if (!id) return;
|
|
262
|
-
|
|
263
|
-
const previousPath = map.get(id);
|
|
264
|
-
|
|
265
|
-
// If there are no suggestion nodes in the corresponding path in the map, then update it.
|
|
266
|
-
if (PathApi.isPath(previousPath)) {
|
|
267
|
-
const nodes = api.suggestion.node({ id, at: previousPath, isText: true });
|
|
268
|
-
const parentNode = api.node(previousPath);
|
|
269
|
-
let lineBreakId: string | null = null;
|
|
270
|
-
|
|
271
|
-
if (parentNode && ElementApi.isElement(parentNode[0])) {
|
|
272
|
-
lineBreakId = api.suggestion.nodeId(parentNode[0]) ?? null;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
if (!nodes && lineBreakId !== id) {
|
|
276
|
-
setOption('uniquePathMap', new Map(map).set(id, blockPath));
|
|
277
|
-
}
|
|
278
|
-
} else {
|
|
279
|
-
setOption('uniquePathMap', new Map(map).set(id, blockPath));
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
|
|
283
|
-
const resolvedSuggestion: ResolvedSuggestion[] = useMemo(() => {
|
|
284
|
-
const map = getOption('uniquePathMap');
|
|
285
|
-
|
|
286
|
-
if (suggestionNodes.length === 0) return [];
|
|
287
|
-
|
|
288
|
-
const suggestionIds = new Set(
|
|
289
|
-
suggestionNodes
|
|
290
|
-
.flatMap(([node]) => {
|
|
291
|
-
if (TextApi.isText(node)) {
|
|
292
|
-
const dataList = api.suggestion.dataList(node);
|
|
293
|
-
const includeUpdate = dataList.some(
|
|
294
|
-
data => data.type === 'update'
|
|
295
|
-
);
|
|
296
|
-
|
|
297
|
-
if (!includeUpdate) {
|
|
298
|
-
return api.suggestion.nodeId(node) ?? [];
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
return dataList
|
|
302
|
-
.filter(data => data.type === 'update')
|
|
303
|
-
.map(d => d.id);
|
|
304
|
-
}
|
|
305
|
-
if (ElementApi.isElement(node)) {
|
|
306
|
-
return api.suggestion.nodeId(node) ?? [];
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
return [];
|
|
310
|
-
})
|
|
311
|
-
.filter(Boolean)
|
|
312
|
-
);
|
|
313
|
-
|
|
314
|
-
const res: ResolvedSuggestion[] = [];
|
|
315
|
-
|
|
316
|
-
suggestionIds.forEach((id) => {
|
|
317
|
-
if (!id) return;
|
|
318
|
-
|
|
319
|
-
const path = map.get(id);
|
|
320
|
-
|
|
321
|
-
if (!path || !PathApi.isPath(path)) return;
|
|
322
|
-
if (!PathApi.equals(path, blockPath)) return;
|
|
323
|
-
|
|
324
|
-
const entries = [
|
|
325
|
-
...editor.api.nodes({
|
|
326
|
-
at: [],
|
|
327
|
-
mode: 'all',
|
|
328
|
-
match: (n: TElement | TSuggestionText) => (n[KEYS.suggestion] && n[getSuggestionKey(id)])
|
|
329
|
-
|| api.suggestion.nodeId(n as TElement) === id
|
|
330
|
-
})
|
|
331
|
-
] as NodeEntry<TElement | TSuggestionText>[];
|
|
332
|
-
|
|
333
|
-
// move line break to the end
|
|
334
|
-
entries.sort(([, path1], [, path2]) => PathApi.isChild(path1, path2) ? -1 : 1);
|
|
335
|
-
|
|
336
|
-
let newText = '';
|
|
337
|
-
let text = '';
|
|
338
|
-
let properties: any = {};
|
|
339
|
-
let newProperties: any = {};
|
|
340
|
-
|
|
341
|
-
// overlapping suggestion
|
|
342
|
-
entries.forEach(([node]) => {
|
|
343
|
-
if (TextApi.isText(node)) {
|
|
344
|
-
const dataList = api.suggestion.dataList(node);
|
|
345
|
-
|
|
346
|
-
dataList.forEach((data: {
|
|
347
|
-
id: string; type: string; properties?: Record<string, unknown>; newProperties?: Record<string, unknown>;
|
|
348
|
-
}) => {
|
|
349
|
-
if (data.id === id) {
|
|
350
|
-
switch (data.type) {
|
|
351
|
-
case 'insert': {
|
|
352
|
-
newText += node.text;
|
|
353
|
-
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
case 'remove': {
|
|
358
|
-
text += node.text;
|
|
359
|
-
|
|
360
|
-
break;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
case 'update': {
|
|
364
|
-
properties = {
|
|
365
|
-
...properties,
|
|
366
|
-
...data.properties
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
newProperties = {
|
|
370
|
-
...newProperties,
|
|
371
|
-
...data.newProperties
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
newText += node.text;
|
|
375
|
-
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
// No default
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
});
|
|
382
|
-
} else {
|
|
383
|
-
const lineBreakData = api.suggestion.isBlockSuggestion(node) ? node.suggestion : undefined;
|
|
384
|
-
|
|
385
|
-
if (lineBreakData?.id === keyId2SuggestionId(id)) {
|
|
386
|
-
if (lineBreakData.type === 'insert') {
|
|
387
|
-
newText += lineBreakData.isLineBreak ? BLOCK_SUGGESTION : BLOCK_SUGGESTION + TYPE_TEXT_MAP[node.type](node);
|
|
388
|
-
} else if (lineBreakData.type === 'remove') {
|
|
389
|
-
text += lineBreakData.isLineBreak ? BLOCK_SUGGESTION : BLOCK_SUGGESTION + TYPE_TEXT_MAP[node.type](node);
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
});
|
|
394
|
-
|
|
395
|
-
if (entries.length === 0) return;
|
|
396
|
-
|
|
397
|
-
const nodeData = api.suggestion.suggestionData(entries[0][0]);
|
|
398
|
-
|
|
399
|
-
if (!nodeData) return;
|
|
400
|
-
|
|
401
|
-
// const comments = data?.discussions.find((d) => d.id === id)?.comments;
|
|
402
|
-
const comments
|
|
403
|
-
= discussions.find((s: TDiscussion) => s.id === id)?.comments || [];
|
|
404
|
-
const createdAt = new Date(nodeData.createdAt);
|
|
405
|
-
|
|
406
|
-
const keyId = getSuggestionKey(id);
|
|
407
|
-
|
|
408
|
-
if (nodeData.type === 'update') {
|
|
409
|
-
res.push({
|
|
410
|
-
comments,
|
|
411
|
-
createdAt,
|
|
412
|
-
keyId,
|
|
413
|
-
newProperties,
|
|
414
|
-
newText,
|
|
415
|
-
properties,
|
|
416
|
-
suggestionId: keyId2SuggestionId(id),
|
|
417
|
-
type: 'update',
|
|
418
|
-
userId: nodeData.userId
|
|
419
|
-
});
|
|
420
|
-
} else if (newText.length > 0 && text.length > 0) {
|
|
421
|
-
res.push({
|
|
422
|
-
comments,
|
|
423
|
-
createdAt,
|
|
424
|
-
keyId,
|
|
425
|
-
newText,
|
|
426
|
-
suggestionId: keyId2SuggestionId(id),
|
|
427
|
-
text,
|
|
428
|
-
type: 'replace',
|
|
429
|
-
userId: nodeData.userId
|
|
430
|
-
});
|
|
431
|
-
} else if (newText.length > 0) {
|
|
432
|
-
res.push({
|
|
433
|
-
comments,
|
|
434
|
-
createdAt,
|
|
435
|
-
keyId,
|
|
436
|
-
newText,
|
|
437
|
-
suggestionId: keyId2SuggestionId(id),
|
|
438
|
-
type: 'insert',
|
|
439
|
-
userId: nodeData.userId
|
|
440
|
-
});
|
|
441
|
-
} else if (text.length > 0) {
|
|
442
|
-
res.push({
|
|
443
|
-
comments,
|
|
444
|
-
createdAt,
|
|
445
|
-
keyId,
|
|
446
|
-
suggestionId: keyId2SuggestionId(id),
|
|
447
|
-
text,
|
|
448
|
-
type: 'remove',
|
|
449
|
-
userId: nodeData.userId
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
|
|
454
|
-
return res;
|
|
455
|
-
}, [
|
|
456
|
-
api.suggestion,
|
|
457
|
-
blockPath,
|
|
458
|
-
discussions,
|
|
459
|
-
editor.api,
|
|
460
|
-
getOption,
|
|
461
|
-
suggestionNodes
|
|
462
|
-
]);
|
|
463
|
-
|
|
464
|
-
return resolvedSuggestion;
|
|
465
|
-
};
|
|
466
|
-
|
|
467
|
-
export const isResolvedSuggestion = (
|
|
468
|
-
suggestion: ResolvedSuggestion | TDiscussion
|
|
469
|
-
): suggestion is ResolvedSuggestion => 'suggestionId' in suggestion;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { SlateElement, type SlateElementProps } from 'platejs/static';
|
|
3
|
-
|
|
4
|
-
export function BlockquoteElementStatic(props: SlateElementProps) {
|
|
5
|
-
return (
|
|
6
|
-
<SlateElement as="blockquote" className="my-1 px-0.5 py-[3px]" {...props}>
|
|
7
|
-
<div className="border-primary border-l-[3px] px-4">{props.children}</div>
|
|
8
|
-
</SlateElement>
|
|
9
|
-
);
|
|
10
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { PlateElement, type PlateElementProps } from 'platejs/react';
|
|
4
|
-
|
|
5
|
-
export function BlockquoteElement(props: PlateElementProps) {
|
|
6
|
-
return (
|
|
7
|
-
<PlateElement as="blockquote" className="my-1 px-0.5 py-[3px]" {...props}>
|
|
8
|
-
<div className="border-primary border-l-[3px] px-4">{props.children}</div>
|
|
9
|
-
</PlateElement>
|
|
10
|
-
);
|
|
11
|
-
}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { type ComponentProps, type FC, type ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
import { cva, type VariantProps } from 'class-variance-authority';
|
|
6
|
-
import { Slot } from 'radix-ui';
|
|
7
|
-
|
|
8
|
-
import { cn } from '@docyrus/ui-pro-shared/lib/utils';
|
|
9
|
-
|
|
10
|
-
import { Spinner } from './spinner';
|
|
11
|
-
import { withTooltip } from './tooltip';
|
|
12
|
-
|
|
13
|
-
const SlotRoot = Slot.Root;
|
|
14
|
-
|
|
15
|
-
export const buttonVariants = cva(
|
|
16
|
-
'focus-ring inline-flex w-fit cursor-pointer select-none items-center justify-center gap-2 rounded-md text-sm ring-offset-background transition-bg-ease disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
17
|
-
{
|
|
18
|
-
defaultVariants: {
|
|
19
|
-
size: 'default',
|
|
20
|
-
truncate: true,
|
|
21
|
-
variant: 'default'
|
|
22
|
-
},
|
|
23
|
-
variants: {
|
|
24
|
-
active: {
|
|
25
|
-
false: '',
|
|
26
|
-
true: 'border-2 border-primary'
|
|
27
|
-
},
|
|
28
|
-
disabled: {
|
|
29
|
-
true: 'pointer-events-none opacity-50'
|
|
30
|
-
},
|
|
31
|
-
focused: {
|
|
32
|
-
true: 'ring-2 ring-ring ring-offset-2'
|
|
33
|
-
},
|
|
34
|
-
isMenu: {
|
|
35
|
-
true: 'h-auto w-full cursor-pointer justify-start'
|
|
36
|
-
},
|
|
37
|
-
size: {
|
|
38
|
-
blockAction: 'size-[26px] gap-1 px-1.5 text-xs',
|
|
39
|
-
default: 'h-[28px] gap-1.5 px-2',
|
|
40
|
-
icon: 'size-[28px] w-[33px] [&_svg]:size-5',
|
|
41
|
-
iconSm: 'size-[28px]',
|
|
42
|
-
lg: 'h-11 px-4 text-lg',
|
|
43
|
-
md: 'h-8 px-3',
|
|
44
|
-
menuAction: 'size-6',
|
|
45
|
-
navAction: 'size-5',
|
|
46
|
-
none: '',
|
|
47
|
-
xs: 'h-[26px] px-1.5 py-1 text-xs'
|
|
48
|
-
},
|
|
49
|
-
truncate: {
|
|
50
|
-
true: 'truncate whitespace-nowrap'
|
|
51
|
-
},
|
|
52
|
-
variant: {
|
|
53
|
-
blockAction:
|
|
54
|
-
'rounded-sm hover:bg-primary/6 [&_svg]:text-muted-foreground',
|
|
55
|
-
blockActionSecondary:
|
|
56
|
-
'rounded-sm bg-primary/6 [&_svg]:text-muted-foreground',
|
|
57
|
-
brand:
|
|
58
|
-
'bg-brand font-medium text-white hover:bg-brand/80 active:bg-brand-active',
|
|
59
|
-
default:
|
|
60
|
-
'bg-primary font-medium text-primary-foreground hover:bg-primary/90 [&_svg]:text-primary-foreground',
|
|
61
|
-
destructive:
|
|
62
|
-
'bg-destructive text-destructive-foreground hover:bg-destructive/90 [&_svg]:text-destructive-foreground',
|
|
63
|
-
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
64
|
-
ghost2: 'text-muted-foreground hover:bg-accent',
|
|
65
|
-
ghost3: 'text-muted-foreground/80 hover:bg-accent',
|
|
66
|
-
ghostActive: 'bg-accent hover:bg-accent hover:text-accent-foreground',
|
|
67
|
-
menuAction: 'text-muted-foreground/80 hover:bg-primary/6',
|
|
68
|
-
nav: 'rounded-sm text-muted-foreground transition hover:bg-primary/4',
|
|
69
|
-
navAction:
|
|
70
|
-
'rounded-sm text-muted-foreground/80 opacity-0 transition hover:bg-primary/6 group-hover:opacity-100',
|
|
71
|
-
none: '',
|
|
72
|
-
outline:
|
|
73
|
-
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
|
|
74
|
-
primaryOutline:
|
|
75
|
-
'border border-primary-foreground text-primary-foreground hover:bg-accent/15 [&_svg]:text-primary-foreground',
|
|
76
|
-
radio: 'border-2 border-input hover:border-primary',
|
|
77
|
-
secondary:
|
|
78
|
-
'bg-secondary text-secondary-foreground hover:bg-secondary/80'
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
export type ButtonExtendedProps = {
|
|
85
|
-
active?: boolean;
|
|
86
|
-
asChild?: boolean;
|
|
87
|
-
icon?: ReactNode;
|
|
88
|
-
iconPlacement?: 'left' | 'right';
|
|
89
|
-
isPending?: boolean;
|
|
90
|
-
loading?: boolean;
|
|
91
|
-
loadingClassName?: string;
|
|
92
|
-
onToggleClick?: () => void;
|
|
93
|
-
} & {
|
|
94
|
-
children?: ReactNode;
|
|
95
|
-
label?: string;
|
|
96
|
-
} & VariantProps<typeof buttonVariants>;
|
|
97
|
-
|
|
98
|
-
export type ButtonProps = ButtonExtendedProps & ComponentProps<'button'> & {
|
|
99
|
-
shortcut?: ReactNode;
|
|
100
|
-
tooltip?: ReactNode;
|
|
101
|
-
tooltipContentProps?: Record<string, unknown>;
|
|
102
|
-
tooltipProps?: Record<string, unknown>;
|
|
103
|
-
tooltipTriggerProps?: Record<string, unknown>;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
export const Button = withTooltip(({
|
|
107
|
-
active,
|
|
108
|
-
asChild = false,
|
|
109
|
-
children,
|
|
110
|
-
className,
|
|
111
|
-
focused,
|
|
112
|
-
icon,
|
|
113
|
-
iconPlacement = 'left',
|
|
114
|
-
isMenu,
|
|
115
|
-
isPending: _isPending,
|
|
116
|
-
label,
|
|
117
|
-
loading,
|
|
118
|
-
loadingClassName,
|
|
119
|
-
size,
|
|
120
|
-
truncate,
|
|
121
|
-
variant,
|
|
122
|
-
onToggleClick: _onToggleClick,
|
|
123
|
-
...props
|
|
124
|
-
}: ButtonExtendedProps & ComponentProps<'button'>) => {
|
|
125
|
-
const Comp = asChild ? SlotRoot : 'button';
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<Comp
|
|
129
|
-
aria-label={label && label.length > 0 ? label : undefined}
|
|
130
|
-
className={cn(
|
|
131
|
-
buttonVariants({
|
|
132
|
-
disabled: props.disabled,
|
|
133
|
-
focused,
|
|
134
|
-
isMenu,
|
|
135
|
-
size,
|
|
136
|
-
truncate,
|
|
137
|
-
variant
|
|
138
|
-
}),
|
|
139
|
-
active && 'border-2 border-primary',
|
|
140
|
-
className
|
|
141
|
-
)}
|
|
142
|
-
type={Comp === 'button' ? 'button' : undefined}
|
|
143
|
-
{...props}>
|
|
144
|
-
{icon && iconPlacement === 'left' && icon}
|
|
145
|
-
{loading && <Spinner className={loadingClassName} />}
|
|
146
|
-
{children}
|
|
147
|
-
{icon && iconPlacement === 'right' && icon}
|
|
148
|
-
</Comp>
|
|
149
|
-
);
|
|
150
|
-
}) as unknown as FC<ButtonProps>;
|
|
151
|
-
|
|
152
|
-
export type LinkButtonProps = ButtonExtendedProps & ComponentProps<'a'> & {
|
|
153
|
-
shortcut?: ReactNode;
|
|
154
|
-
tooltip?: ReactNode;
|
|
155
|
-
tooltipContentProps?: Record<string, unknown>;
|
|
156
|
-
tooltipProps?: Record<string, unknown>;
|
|
157
|
-
tooltipTriggerProps?: Record<string, unknown>;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export const LinkButton = withTooltip(({
|
|
161
|
-
active,
|
|
162
|
-
children,
|
|
163
|
-
className,
|
|
164
|
-
focused,
|
|
165
|
-
icon,
|
|
166
|
-
iconPlacement = 'left',
|
|
167
|
-
isMenu,
|
|
168
|
-
label,
|
|
169
|
-
loading,
|
|
170
|
-
loadingClassName,
|
|
171
|
-
size,
|
|
172
|
-
truncate,
|
|
173
|
-
variant = 'ghost',
|
|
174
|
-
...props
|
|
175
|
-
}: ButtonExtendedProps & ComponentProps<'a'>) => {
|
|
176
|
-
return (
|
|
177
|
-
<a
|
|
178
|
-
aria-label={label && label.length > 0 ? label : undefined}
|
|
179
|
-
className={cn(
|
|
180
|
-
buttonVariants({
|
|
181
|
-
disabled: props.disabled,
|
|
182
|
-
focused,
|
|
183
|
-
isMenu,
|
|
184
|
-
size,
|
|
185
|
-
truncate,
|
|
186
|
-
variant
|
|
187
|
-
}),
|
|
188
|
-
active && 'border-2 border-primary',
|
|
189
|
-
className
|
|
190
|
-
)}
|
|
191
|
-
role="button"
|
|
192
|
-
{...props}>
|
|
193
|
-
{icon && iconPlacement === 'left' && (
|
|
194
|
-
<div className="shrink-0">{icon}</div>
|
|
195
|
-
)}
|
|
196
|
-
{loading && <Spinner className={loadingClassName} />}
|
|
197
|
-
{children}
|
|
198
|
-
{icon && iconPlacement === 'right' && icon}
|
|
199
|
-
</a>
|
|
200
|
-
);
|
|
201
|
-
}) as unknown as FC<LinkButtonProps>;
|