@openviking/react 0.1.0 → 0.1.2

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.
Files changed (193) hide show
  1. package/README.md +57 -34
  2. package/dist/3~0.js +2117 -0
  3. package/dist/ark-message-list-view~0.js +310 -0
  4. package/dist/a~0.js +21 -0
  5. package/dist/c7~0.js +24 -0
  6. package/dist/client/client.d.ts +12 -0
  7. package/dist/client/errors.d.ts +30 -0
  8. package/dist/client/index.d.ts +4 -0
  9. package/dist/client/options.d.ts +101 -0
  10. package/dist/client/provider.d.ts +52 -0
  11. package/dist/client/types.d.ts +160 -0
  12. package/dist/client.js +239 -0
  13. package/dist/components/agent-connect/agent-connect-copy.d.ts +34 -0
  14. package/dist/components/agent-connect/agent-connect-design.d.ts +1781 -0
  15. package/dist/components/agent-connect/agent-connect-detail.d.ts +13 -0
  16. package/dist/components/agent-connect/agent-connect-installer.d.ts +3 -0
  17. package/dist/components/agent-connect/agent-connect-instructions-view.d.ts +14 -0
  18. package/dist/components/agent-connect/agent-connect-instructions.d.ts +145 -0
  19. package/dist/components/agent-connect/agent-connect-markdown.d.ts +3 -0
  20. package/dist/components/agent-connect/agent-connect.d.ts +4 -1
  21. package/dist/components/agent-connect/content-en.d.ts +137 -0
  22. package/dist/components/agent-connect/content-zh.d.ts +137 -0
  23. package/dist/components/agent-connect/index.d.ts +1 -0
  24. package/dist/components/agent-connect/style.css +503 -0
  25. package/dist/components/agent-connect/types.d.ts +29 -0
  26. package/dist/components/agent-connect.js +1 -0
  27. package/dist/components/file-preview/file-preview-adapters.d.ts +33 -0
  28. package/dist/components/file-preview/file-preview-body.d.ts +27 -0
  29. package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +16 -0
  30. package/dist/components/file-preview/file-preview-breadcrumb.d.ts +21 -0
  31. package/dist/components/file-preview/file-preview-copy-path.d.ts +12 -0
  32. package/dist/components/file-preview/file-preview-editor.d.ts +22 -0
  33. package/dist/components/file-preview/file-preview-handle-adapters.d.ts +26 -0
  34. package/dist/components/file-preview/file-preview-header.d.ts +25 -0
  35. package/dist/components/file-preview/file-preview-labels.d.ts +16 -0
  36. package/dist/components/file-preview/file-preview-lazy-viewer.d.ts +3 -0
  37. package/dist/components/file-preview/file-preview-path.d.ts +30 -0
  38. package/dist/components/file-preview/file-preview-source.d.ts +24 -0
  39. package/dist/components/file-preview/file-preview-state.d.ts +28 -0
  40. package/dist/components/file-preview/file-preview-tab-row.d.ts +16 -0
  41. package/dist/components/file-preview/file-preview-viewer.d.ts +31 -0
  42. package/dist/components/file-preview/file-preview.d.ts +14 -1
  43. package/dist/components/file-preview/index.d.ts +1 -0
  44. package/dist/components/file-preview/style.css +4139 -0
  45. package/dist/components/file-preview/types.d.ts +516 -0
  46. package/dist/components/file-preview/use-file-preview-actions-context.d.ts +23 -0
  47. package/dist/components/file-preview/use-file-preview-actions.d.ts +19 -0
  48. package/dist/components/file-preview/use-file-preview-editing.d.ts +32 -0
  49. package/dist/components/file-preview/use-file-preview-ids.d.ts +24 -0
  50. package/dist/components/file-preview.js +1 -0
  51. package/dist/components/file-tree/file-tree-body.d.ts +18 -0
  52. package/dist/components/file-tree/file-tree-entry-row.d.ts +12 -0
  53. package/dist/components/file-tree/file-tree-icons.d.ts +15 -0
  54. package/dist/components/file-tree/file-tree-info-labels.d.ts +21 -0
  55. package/dist/components/file-tree/file-tree-info-tooltip.d.ts +43 -0
  56. package/dist/components/file-tree/file-tree-info.d.ts +29 -0
  57. package/dist/components/file-tree/file-tree-keyboard.d.ts +14 -0
  58. package/dist/components/file-tree/file-tree-row-context.d.ts +46 -0
  59. package/dist/components/file-tree/file-tree-row-shared.d.ts +11 -0
  60. package/dist/components/file-tree/file-tree-spinner.d.ts +10 -0
  61. package/dist/components/file-tree/file-tree-state-row.d.ts +7 -0
  62. package/dist/components/file-tree/file-tree-tooltip-surface.d.ts +22 -0
  63. package/dist/components/file-tree/file-tree-tooltip.d.ts +17 -0
  64. package/dist/components/file-tree/file-tree.d.ts +15 -1
  65. package/dist/components/file-tree/index.d.ts +1 -0
  66. package/dist/components/file-tree/style.css +410 -0
  67. package/dist/components/file-tree/types.d.ts +589 -0
  68. package/dist/components/file-tree/use-file-tree-actions.d.ts +17 -0
  69. package/dist/components/file-tree.js +1 -0
  70. package/dist/components/scope-switcher/index.d.ts +1 -0
  71. package/dist/components/scope-switcher/scope-keyboard.d.ts +2 -0
  72. package/dist/components/scope-switcher/scope-panel.d.ts +11 -0
  73. package/dist/components/scope-switcher/scope-selector.d.ts +2 -0
  74. package/dist/components/scope-switcher/scope-switcher.d.ts +6 -1
  75. package/dist/components/scope-switcher/style.css +452 -0
  76. package/dist/components/scope-switcher/types.d.ts +489 -0
  77. package/dist/components/scope-switcher.js +3 -0
  78. package/dist/components/style.css +14249 -18
  79. package/dist/components/tui/command-catalog.d.ts +58 -0
  80. package/dist/components/tui/command-completion.d.ts +19 -0
  81. package/dist/components/tui/command-definitions.d.ts +10 -0
  82. package/dist/components/tui/command-input.d.ts +16 -0
  83. package/dist/components/tui/index.d.ts +1 -0
  84. package/dist/components/tui/style.css +1552 -0
  85. package/dist/components/tui/tui-assist.d.ts +15 -0
  86. package/dist/components/tui/tui-code-block.d.ts +8 -0
  87. package/dist/components/tui/tui-command-help.d.ts +9 -0
  88. package/dist/components/tui/tui-command-text.d.ts +6 -0
  89. package/dist/components/tui/tui-composer.d.ts +24 -0
  90. package/dist/components/tui/tui-copy-button.d.ts +9 -0
  91. package/dist/components/tui/tui-input-mirror.d.ts +14 -0
  92. package/dist/components/tui/tui-labels-zh.d.ts +2 -0
  93. package/dist/components/tui/tui-labels.d.ts +5 -0
  94. package/dist/components/tui/tui-markdown-renderers.d.ts +10 -0
  95. package/dist/components/tui/tui-markdown.d.ts +6 -0
  96. package/dist/components/tui/tui-param-hint.d.ts +7 -0
  97. package/dist/components/tui/tui-record-time.d.ts +11 -0
  98. package/dist/components/tui/tui-record.d.ts +13 -0
  99. package/dist/components/tui/tui-resource-preview.d.ts +10 -0
  100. package/dist/components/tui/tui-resource-tree.d.ts +10 -0
  101. package/dist/components/tui/tui-result-header.d.ts +7 -0
  102. package/dist/components/tui/tui-result-text.d.ts +5 -0
  103. package/dist/components/tui/tui-search-list.d.ts +8 -0
  104. package/dist/components/tui/tui-skeleton.d.ts +6 -0
  105. package/dist/components/tui/tui-status-card.d.ts +7 -0
  106. package/dist/components/tui/tui-text.d.ts +10 -0
  107. package/dist/components/tui/tui-uri-text.d.ts +19 -0
  108. package/dist/components/tui/tui-write-result.d.ts +7 -0
  109. package/dist/components/tui/tui.d.ts +11 -1
  110. package/dist/components/tui/types.d.ts +527 -0
  111. package/dist/components/tui/use-tui-assist-position.d.ts +3 -0
  112. package/dist/components/tui/use-tui-completion.d.ts +14 -0
  113. package/dist/components/tui/use-tui-composer-keyboard.d.ts +25 -0
  114. package/dist/components/tui.js +1 -0
  115. package/dist/components/viking-bot/ark-adapter.d.ts +45 -0
  116. package/dist/components/viking-bot/ark-message-body.d.ts +16 -0
  117. package/dist/components/viking-bot/ark-message-list-view.d.ts +7 -0
  118. package/dist/components/viking-bot/ark-message-row.d.ts +19 -0
  119. package/dist/components/viking-bot/index.d.ts +10 -0
  120. package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +10 -0
  121. package/dist/components/viking-bot/interaction/index.d.ts +4 -0
  122. package/dist/components/viking-bot/interaction/labels.d.ts +7 -0
  123. package/dist/components/viking-bot/interaction/lazy-interaction.d.ts +3 -0
  124. package/dist/components/viking-bot/interaction/schedule-input.d.ts +13 -0
  125. package/dist/components/viking-bot/interaction/style.css +189 -0
  126. package/dist/components/viking-bot/interaction/types.d.ts +188 -0
  127. package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +9 -0
  128. package/dist/components/viking-bot/interaction.js +2 -0
  129. package/dist/components/viking-bot/labels.d.ts +2 -0
  130. package/dist/components/viking-bot/lazy-composer.d.ts +3 -0
  131. package/dist/components/viking-bot/message-groups.d.ts +12 -0
  132. package/dist/components/viking-bot/model.d.ts +252 -0
  133. package/dist/components/viking-bot/render-part.d.ts +12 -0
  134. package/dist/components/viking-bot/style.css +7133 -0
  135. package/dist/components/viking-bot/types.d.ts +140 -0
  136. package/dist/components/viking-bot/viking-bot-composer.d.ts +6 -0
  137. package/dist/components/viking-bot/viking-bot-message-list.d.ts +3 -0
  138. package/dist/components/viking-bot/viking-bot.d.ts +16 -1
  139. package/dist/components/viking-bot.js +4 -0
  140. package/dist/c~0.js +201 -0
  141. package/dist/file-preview-viewer~0.js +191 -0
  142. package/dist/f~0.js +356 -0
  143. package/dist/g~0.js +1207 -0
  144. package/dist/h~0.js +58 -0
  145. package/dist/icons/file-type-icon.d.ts +31 -0
  146. package/dist/icons/index.d.ts +33 -23
  147. package/dist/icons/nextjs-icon.d.ts +19 -0
  148. package/dist/icons.js +1 -25
  149. package/dist/index.d.ts +16 -2
  150. package/dist/index.js +8 -1
  151. package/dist/k~0.js +1440 -0
  152. package/dist/lk~0.js +233 -0
  153. package/dist/l~0.js +44 -0
  154. package/dist/modules/console/console.d.ts +4 -0
  155. package/dist/modules/console/index.d.ts +1 -0
  156. package/dist/modules/console/style.css +111 -0
  157. package/dist/modules/console/types.d.ts +101 -0
  158. package/dist/modules/console.js +1 -0
  159. package/dist/modules/file-browser/file-browser-toolbar-button.d.ts +10 -0
  160. package/dist/modules/file-browser/file-browser.d.ts +6 -0
  161. package/dist/modules/file-browser/index.d.ts +1 -0
  162. package/dist/modules/file-browser/style.css +158 -0
  163. package/dist/modules/file-browser/types.d.ts +101 -0
  164. package/dist/modules/file-browser.js +1 -0
  165. package/dist/modules/scope-cascade/controller.d.ts +6 -0
  166. package/dist/modules/scope-cascade/index.d.ts +3 -0
  167. package/dist/modules/scope-cascade/scope-cascade.d.ts +3 -0
  168. package/dist/modules/scope-cascade/style.css +456 -0
  169. package/dist/modules/scope-cascade/style.js +0 -0
  170. package/dist/modules/scope-cascade/types.d.ts +39 -0
  171. package/dist/modules/scope-cascade/use-scope-cascade.d.ts +5 -0
  172. package/dist/modules/scope-cascade.js +1 -0
  173. package/dist/modules/style.css +808 -0
  174. package/dist/modules/style.js +0 -0
  175. package/dist/n~0.js +727 -0
  176. package/dist/shared/components/tooltip/index.d.ts +1 -0
  177. package/dist/shared/components/tooltip/tooltip.d.ts +25 -0
  178. package/dist/shared/components/tooltip/types.d.ts +42 -0
  179. package/dist/shared/components/tooltip/use-tooltip-position.d.ts +38 -0
  180. package/dist/style.css +15138 -18
  181. package/dist/u~0.js +1601 -0
  182. package/dist/viking-bot-composer~0.js +164 -0
  183. package/dist/viking-bot-interaction~0.js +284 -0
  184. package/dist/w~0.js +19 -0
  185. package/package.json +46 -22
  186. package/dist/components/resource-import/resource-import.d.ts +0 -1
  187. package/dist/components/resource-import/style.css +0 -2
  188. package/dist/components/status-badge/status-badge.d.ts +0 -8
  189. package/dist/components/status-badge/style.css +0 -37
  190. package/dist/components/status-badge.js +0 -30
  191. /package/dist/components/{resource-import → viking-bot/interaction}/style.js +0 -0
  192. /package/dist/{components/status-badge → modules/console}/style.js +0 -0
  193. /package/dist/{components/resource-import.js → modules/file-browser/style.js} +0 -0
@@ -0,0 +1,516 @@
1
+ import type { ConfirmSlotProps, DownloadSlotProps, FileViewerResource, ViewerHandle } from '@ark-design/ui/file-viewer/core';
2
+ import type { ComponentType, ForwardRefExoticComponent, HTMLAttributes, PropsWithoutRef, ReactNode, RefAttributes } from 'react';
3
+ /**
4
+ * 要预览的内容及文件信息。提供多个来源时,按 `content`、`file`、`url`
5
+ * 的顺序使用第一个有值的来源。
6
+ * The content and file information to preview. When multiple sources are
7
+ * provided, the first available one is used in the order `content`, `file`, `url`.
8
+ */
9
+ export interface FilePreviewSource {
10
+ /**
11
+ * 文本内容,适用于 Markdown、JSON、代码等可内联的格式。
12
+ * Text content, for formats that can be inlined such as Markdown, JSON and code.
13
+ */
14
+ content?: string;
15
+ /**
16
+ * 二进制文件,适用于 PDF、Office 文档、表格与 3D 模型等。
17
+ * Binary file, for PDF, Office documents, spreadsheets and 3D models.
18
+ */
19
+ file?: File | Blob;
20
+ /**
21
+ * 文件地址。宿主已经能提供可访问链接时使用,组件不自行鉴权。
22
+ * File URL. Used when the host can already provide an accessible link; the
23
+ * component performs no authentication of its own.
24
+ */
25
+ url?: string;
26
+ /**
27
+ * 文件名,用于识别格式与展示标题。无扩展名的文件按文件名匹配,
28
+ * 例如 `Dockerfile` 与 `Makefile`。
29
+ * File name, used for format detection and the header title. Extensionless
30
+ * files match by name, for example `Dockerfile` and `Makefile`.
31
+ */
32
+ fileName: string;
33
+ /**
34
+ * 完整路径,显示为面包屑。省略时面包屑退化为文件名,不渲染祖先按钮。
35
+ * Full path, rendered as the breadcrumb. When omitted the breadcrumb falls
36
+ * back to the file name and renders no ancestor buttons.
37
+ */
38
+ path?: string;
39
+ /**
40
+ * 显式格式提示,优先级高于扩展名与 MIME。
41
+ * Explicit format hint, taking precedence over extension and MIME.
42
+ */
43
+ fileType?: string;
44
+ /**
45
+ * 正文是否被截断。宿主按读取上限取回部分内容时置为 `true`,组件在正文
46
+ * 下方提示,避免把「只读了一部分」当作完整文件。
47
+ * Whether the body was truncated. A host that read only part of the content
48
+ * sets this so the component can say so instead of passing a partial file off
49
+ * as complete.
50
+ */
51
+ truncated?: boolean;
52
+ }
53
+ /**
54
+ * 所有页签的公共配置,包括标识、标题、图标、文案及标题行操作。
55
+ * Configuration shared by every tab, including identity, title, icon, copy and
56
+ * header actions.
57
+ */
58
+ export interface FilePreviewTabBase {
59
+ /**
60
+ * 页签唯一标识。
61
+ * Unique tab key.
62
+ */
63
+ key: string;
64
+ /**
65
+ * 页签行显示的内容。可以是纯文本,也可以是带样式或图标的节点。
66
+ * What the tab row shows. It can be plain text or a node with styling or icons.
67
+ */
68
+ title?: ReactNode;
69
+ /**
70
+ * 页签图标,由宿主提供;省略时该页签只显示标题,不占图标位。
71
+ *
72
+ * 组件不按文件名推断类型:格式识别属于上层职责,内置图标集会把整包图标
73
+ * 拖进产物。需要按格式取图标的宿主可从 `@openviking/react/icons` 引入
74
+ * `getFileTypeIcon`,把结果传进来。
75
+ *
76
+ * The tab icon, supplied by the host. Omit it and the tab shows only its title,
77
+ * with no icon slot.
78
+ *
79
+ * The component does not infer a type from the file name: format detection
80
+ * belongs to the caller, and bundling the icon set would pull every icon into
81
+ * the output. A host that wants a per-format icon can import
82
+ * `getFileTypeIcon` from `@openviking/react/icons` and pass the result in.
83
+ */
84
+ icon?: ReactNode;
85
+ /**
86
+ * 该页签的文案,逐项覆盖外层 `labels`。未提供的项回落到外层。
87
+ * Copy of this tab, overriding the outer `labels` field by field. Fields left
88
+ * out fall back to the outer ones.
89
+ */
90
+ labels?: Partial<FilePreviewLabels>;
91
+ /**
92
+ * 是否禁用该页签。
93
+ * Whether the tab is disabled.
94
+ */
95
+ disabled?: boolean;
96
+ /**
97
+ * 祖先导航成功打开后触发,参数为被点击那一级的完整 URI;失败时不触发。
98
+ * Called after an ancestor opens, with the full URI of the clicked level;
99
+ * not called on failure.
100
+ */
101
+ onOpenParent?: (uri: string) => void;
102
+ /**
103
+ * 路径复制成功后触发,参数为已复制的路径;复制失败时不触发。
104
+ * 省略回调不影响复制。文件页签提供 `source.path` 时显示复制路径按钮。
105
+ * Called after path copying succeeds, with the copied path; not called on
106
+ * failure. Omitting it does not affect copying. File tabs with `source.path`
107
+ * show the copy-path button.
108
+ */
109
+ onCopyPath?: (path: string) => void;
110
+ }
111
+ /**
112
+ * 文件预览页签或宿主自定义内容页签。
113
+ * A file-preview tab or a tab with host-provided content.
114
+ */
115
+ export type FilePreviewTab = FilePreviewFileTab | FilePreviewContentTab;
116
+ /**
117
+ * 按文件格式预览 `source` 的页签。
118
+ * A tab that previews `source` according to its file format.
119
+ */
120
+ export interface FilePreviewFileTab extends FilePreviewTabBase {
121
+ /**
122
+ * 页签类型标记,固定为 `file`。
123
+ * Tab kind discriminator, always `file`.
124
+ */
125
+ kind: 'file';
126
+ /**
127
+ * 要预览的内容及文件信息。
128
+ * The content and file information to preview.
129
+ */
130
+ source: FilePreviewSource;
131
+ /**
132
+ * 文件操作的执行能力;省略对应方法时该操作不可用。
133
+ * File operation capabilities; omitting a method makes its operation unavailable.
134
+ */
135
+ operations?: FilePreviewOperations;
136
+ /**
137
+ * 主文件之外、按 key 读取的伴随资源,例如 3D 模型的贴图。
138
+ * Companion resources read by key alongside the main file, for example
139
+ * textures of a 3D model.
140
+ */
141
+ resources?: readonly FileViewerResource[];
142
+ /**
143
+ * 文件编辑配置;省略时只读。
144
+ * File-editing options; omit them for a read-only preview.
145
+ */
146
+ editing?: FilePreviewEditing;
147
+ /**
148
+ * 文件页签的标题行插槽,在基类之上增加三类状态兜底。
149
+ * Header slots of a file tab, adding the three state fallbacks on top of the base ones.
150
+ */
151
+ slots?: FilePreviewFileTabSlots;
152
+ /**
153
+ * 正文复制成功后触发,参数为已复制的文本;复制失败时不触发。
154
+ * 省略回调不影响复制。仅文件页签提供正文复制,没有可复制文本时按钮禁用。
155
+ * Called after content copying succeeds, with the copied text; not called on
156
+ * failure. Omitting it does not affect copying. Only file tabs provide body
157
+ * copying; the button is disabled when no copyable text is available.
158
+ */
159
+ onCopyContent?: (text: string) => void;
160
+ /**
161
+ * 下载操作成功后触发,失败时不触发。
162
+ * Called after the download operation succeeds; not called on failure.
163
+ */
164
+ onDownload?: () => void;
165
+ /**
166
+ * 正文中的链接成功打开后触发,参数为被点击的 URI;失败时不触发。只有
167
+ * Markdown 正文会触发。
168
+ *
169
+ * Called after a link inside the body opens, with the clicked URI; not called on
170
+ * failure. Only Markdown bodies fire this.
171
+ */
172
+ onOpenUri?: (uri: string) => void;
173
+ }
174
+ /**
175
+ * 展示宿主自定义内容的页签,例如看板或图谱。
176
+ *
177
+ * 这类页签只有页签行由组件负责,正文整块交给宿主——组件不渲染内容区标题行,
178
+ * 也不在中间套任何容器。宿主想加工具栏、标题或状态提示,都写在自己的
179
+ * `content` 里,按需要怎么排就怎么排。
180
+ *
181
+ * A tab with host-provided content, such as a dashboard or graph.
182
+ *
183
+ * The component only renders the tab row for these; the whole body belongs to the
184
+ * host. No content header row is rendered and no wrapper is placed in between, so
185
+ * a host that wants a toolbar, a title or a status line puts it inside `content`
186
+ * and lays it out however it needs.
187
+ */
188
+ export interface FilePreviewContentTab extends FilePreviewTabBase {
189
+ /**
190
+ * 页签类型标记,固定为 `content`。
191
+ * Tab kind discriminator, always `content`.
192
+ */
193
+ kind: 'content';
194
+ /**
195
+ * 页签行显示的内容。内容页签没有 `source.fileName` 可以回落,因此这里是必填。
196
+ * What the tab row shows. A content tab has no `source.fileName` to fall back
197
+ * to, so it is required here.
198
+ */
199
+ title: ReactNode;
200
+ /**
201
+ * 页签正文,由宿主渲染,铺满页签行以下的整个区域。
202
+ * The tab body, rendered by the host and filling everything below the tab row.
203
+ */
204
+ content: ReactNode;
205
+ }
206
+ /**
207
+ * 文件操作的执行能力。方法返回的 Promise 完成后才触发对应的成功通知。
208
+ * File operation capabilities. The matching success notification fires only
209
+ * after the returned promise resolves.
210
+ */
211
+ export interface FilePreviewOperations {
212
+ /**
213
+ * 打开给定的祖先 URI,参数可能指向任意一级目录,不限于当前文件的直接父级。
214
+ * Opens the given ancestor URI. The argument may point at any level, not only
215
+ * the immediate parent of the current file.
216
+ */
217
+ openParent?: (uri: string) => Promise<void>;
218
+ /** 下载当前文件,完成后返回。Downloads the current file and resolves on completion. */
219
+ download?: () => Promise<void>;
220
+ /**
221
+ * 打开正文里被点击的链接,完成后返回。传入后由宿主接管导航,组件阻止默认
222
+ * 跳转;相对路径的解析也归宿主,组件给出的是 Markdown 里的原始目标。
223
+ *
224
+ * 目前只有 Markdown 正文会触发:其它格式的渲染器不提供链接点击回调。
225
+ *
226
+ * Opens a link clicked inside the body and resolves on completion. Supplying it
227
+ * hands navigation to the host — the component prevents the default jump — and
228
+ * resolving relative paths is the host's job too; the component passes the raw
229
+ * target as written in the Markdown.
230
+ *
231
+ * Only Markdown bodies fire this today: the other renderers expose no link-click
232
+ * callback.
233
+ */
234
+ openUri?: (uri: string) => Promise<void>;
235
+ }
236
+ /**
237
+ * 文件编辑配置。省略时只读;可提供编辑所需的完整文本,并处理保存与取消操作。
238
+ * File-editing options. Omit them for a read-only preview. Provide the full text
239
+ * to edit and handle save and cancel actions as needed.
240
+ */
241
+ export interface FilePreviewEditing {
242
+ /**
243
+ * 进入编辑时读取完整文本,适用于截断预览或文件地址。
244
+ * 省略时使用 `content` 或 `file` 中的文本;仅提供 `url` 时需提供此读取函数。
245
+ * 返回 `undefined` 时放弃本次编辑,保持预览态。
246
+ * Provides the full text when editing is requested, for example for a truncated
247
+ * preview or a file URL. When omitted, text from `content` or `file` is used;
248
+ * URL-only sources require this loader. Returning `undefined` cancels the edit
249
+ * request and keeps the preview open.
250
+ */
251
+ loadContent?: (source: FilePreviewSource) => Promise<string | undefined>;
252
+ /**
253
+ * 保存草稿时调用。抛错或 reject 时组件展示失败提示并保留草稿。
254
+ * Invoked when the draft is saved. A thrown error or rejection keeps the draft
255
+ * and shows a failure message.
256
+ */
257
+ save: (value: string) => Promise<void>;
258
+ /**
259
+ * 保存成功后触发,参数为已保存的文本;失败时不触发。
260
+ * Called after saving succeeds, with the saved text; not called on failure.
261
+ */
262
+ onSave?: (value: string) => void;
263
+ /**
264
+ * 取消编辑或切换页签并丢弃草稿后触发,参数为丢弃的文本;保存成功时不触发。
265
+ * Called after cancelling editing or switching tabs discards the draft;
266
+ * receives the discarded text and is not called after a successful save.
267
+ */
268
+ onCancel?: (value: string) => void;
269
+ }
270
+ /**
271
+ * 交给宿主的动作上下文:组件持有的视图与编辑状态,以及改变它们的方法。
272
+ *
273
+ * 组件只渲染外壳与正文,不内置复制、下载、视图切换、编辑这些按钮;宿主在
274
+ * `slots.actions` 里用这份上下文自己拼。状态仍由组件维护,宿主不必接管。
275
+ *
276
+ * The action context handed to the host: the view and editing state the component
277
+ * owns, plus the methods that change it.
278
+ *
279
+ * The component renders only the shell and the body — it ships no copy, download,
280
+ * view-switch or edit buttons. A host composes them in `slots.actions` from this
281
+ * context. The state stays with the component; the host does not take it over.
282
+ */
283
+ export interface FilePreviewActions {
284
+ /** 当前视图模式。The current view mode. */
285
+ viewMode: FilePreviewViewMode;
286
+ /** 切换到指定视图模式。Switches to the given view mode. */
287
+ setViewMode: (mode: FilePreviewViewMode) => void;
288
+ /**
289
+ * 该页签的格式是否同时支持预览与源码。为 `false` 时不该渲染切换控件。
290
+ * Whether the format supports both preview and source. Do not render a switch
291
+ * when it is `false`.
292
+ */
293
+ canSwitchView: boolean;
294
+ /** 是否处于编辑态。Whether the tab is being edited. */
295
+ editing: boolean;
296
+ /** 是否有保存或读取在进行中。Whether a save or load is in flight. */
297
+ busy: boolean;
298
+ /** 该页签是否可编辑,即可提供 `editing`。Whether the tab is editable. */
299
+ canEdit: boolean;
300
+ /** 进入编辑态。Enters editing. */
301
+ startEditing: () => void;
302
+ /** 保存草稿,成功返回 `true`。Saves the draft, resolving to `true` on success. */
303
+ saveEditing: () => Promise<boolean>;
304
+ /** 放弃草稿并退出编辑态。Discards the draft and leaves editing. */
305
+ cancelEditing: () => void;
306
+ /** 该页签是否有可复制的正文。Whether the tab has copyable body text. */
307
+ canCopyContent: boolean;
308
+ /** 复制正文,成功返回 `true`。Copies the body, resolving to `true` on success. */
309
+ copyContent: () => Promise<boolean>;
310
+ /** 该页签是否有可复制的路径。Whether the tab has a copyable path. */
311
+ canCopyPath: boolean;
312
+ /** 复制路径,成功返回 `true`。Copies the path, resolving to `true` on success. */
313
+ copyPath: () => Promise<boolean>;
314
+ /** 该页签是否可下载。Whether the tab can be downloaded. */
315
+ canDownload: boolean;
316
+ /** 下载当前文件。Downloads the current file. */
317
+ download: () => void;
318
+ }
319
+ /**
320
+ * 文件页签内容区标题行的插槽。内容页签不消费这些——它整块正文由宿主渲染,
321
+ * 没有组件提供的标题行可言。
322
+ *
323
+ * Slots of a file tab's content header. Content tabs do not use them: their whole
324
+ * body is the host's, so there is no component-provided header to fill.
325
+ */
326
+ export interface FilePreviewHeaderSlots {
327
+ /**
328
+ * 标题行右侧的动作区。组件不内置任何按钮,复制、下载、视图切换、编辑都由
329
+ * 宿主用上下文里的状态与方法自行渲染。
330
+ *
331
+ * The action area on the right of the header. The component ships no buttons of
332
+ * its own: copy, download, view switch and editing are all rendered by the host
333
+ * from the state and methods in the context.
334
+ */
335
+ actions?: ReactNode | ((actions: FilePreviewActions) => ReactNode);
336
+ /**
337
+ * 标题旁的额外内容,例如权限标记、状态徽标或版本号;不需要时不传。
338
+ * Extra content next to the title, for example a permission tag, a status badge
339
+ * or a version label; omit it when not needed.
340
+ */
341
+ titleExtra?: ReactNode;
342
+ /**
343
+ * 正文下方的补充信息,例如字符数、更新时间或保留策略控件。渲染在正文与
344
+ * 滚动容器之外,不随正文滚动。
345
+ * Supplementary information under the body, for example a character count, an
346
+ * update time or retention controls. Rendered outside the scrolling body.
347
+ */
348
+ footer?: ReactNode;
349
+ }
350
+ /**
351
+ * 文件页签的标题行插槽,以及加载、失败或格式不支持时的替代内容。
352
+ * Header slots of a file tab and replacement content for loading, failure or
353
+ * unsupported formats.
354
+ */
355
+ export interface FilePreviewFileTabSlots extends FilePreviewHeaderSlots {
356
+ /**
357
+ * 内容读取中的兜底内容。不传时使用内置加载态。
358
+ * Fallback while the content is being read. A built-in loading state is used
359
+ * when omitted.
360
+ */
361
+ loadingFallback?: ReactNode;
362
+ /**
363
+ * 读取失败时的兜底内容。不传时使用内置错误态与重试入口。
364
+ * Fallback when reading failed. A built-in error state with a retry entry is
365
+ * used when omitted.
366
+ */
367
+ errorFallback?: ReactNode;
368
+ /**
369
+ * 格式不支持时的兜底内容。格式是否可预览由底座判定,因此这个节点会交给
370
+ * 底座,而不是在组件这边提前判断。传了就由它接管整个不支持态(含底座原本
371
+ * 会给出的下载入口);不传时使用内置提示。
372
+ *
373
+ * Fallback when the format cannot be previewed. Whether a format can be
374
+ * previewed is the base component's call, so this node is handed to it rather
375
+ * than decided here. Supplying it takes over the whole unsupported state,
376
+ * including the download entry the base would otherwise offer; omit it for the
377
+ * built-in message.
378
+ */
379
+ unsupportedFallback?: ReactNode;
380
+ /**
381
+ * 大文件确认态的替代内容。需要拿到确认与取消回调,因此是组件而不是节点。
382
+ * 不传时使用内置确认态与底座文案。
383
+ * Replacement for the large-file confirmation state. It receives the confirm
384
+ * and cancel callbacks, so it is a component rather than a node. A built-in
385
+ * state with base copy is used when omitted.
386
+ */
387
+ confirmFallback?: ComponentType<ConfirmSlotProps>;
388
+ /**
389
+ * 无法内联预览时的替代内容,通常包含下载入口。需要拿到下载与重试回调,
390
+ * 因此是组件而不是节点。不传时使用内置提示与底座文案。
391
+ * Replacement for the state where inline preview is impossible, usually with a
392
+ * download entry. It receives the download and retry callbacks, so it is a
393
+ * component rather than a node. A built-in message with base copy is used when
394
+ * omitted.
395
+ */
396
+ downloadFallback?: ComponentType<DownloadSlotProps>;
397
+ }
398
+ /**
399
+ * 可替换文案,组件内置英文默认值。
400
+ * Replaceable copy; the component ships English defaults.
401
+ */
402
+ export interface FilePreviewLabels {
403
+ /**
404
+ * 复制路径按钮的文案。这是组件自己渲染的唯一按钮——其余动作按钮由宿主在
405
+ * `slots.actions` 里自绘,文案也归宿主。
406
+ *
407
+ * Label of the copy-path button. It is the only button the component renders
408
+ * itself; every other action button belongs to the host's `slots.actions`,
409
+ * copy included.
410
+ */
411
+ copyPath?: string;
412
+ /** 编辑区文本框的无障碍名称。Accessible name of the editor textarea. */
413
+ editor?: string;
414
+ /** 读取失败后退出编辑态的按钮文案。Label of the button that leaves editing after a failed load. */
415
+ leaveEditing?: string;
416
+ /** 重试按钮文案。Retry button label. */
417
+ retry?: string;
418
+ /** 读取失败时的提示。Message shown when reading failed. */
419
+ loadFailed?: string;
420
+ /** 保存失败时的提示。Message shown when saving failed. */
421
+ saveFailed?: string;
422
+ /** 无法预览该格式时的提示。Message shown when the format cannot be previewed. */
423
+ unsupported?: string;
424
+ /** 取回正文时的加载提示。Message shown while the text is being fetched. */
425
+ loading?: string;
426
+ /** 下载按钮文案。Label of the download button. */
427
+ download?: string;
428
+ /** 文件长度为 0 时的提示。Message shown when the file itself is empty. */
429
+ fileEmpty?: string;
430
+ /** 文件非空但没有可展示内容时的提示。Message shown for a non-empty file with nothing to render. */
431
+ noContent?: string;
432
+ /** 正文被截断时的提示。Message shown when the body was truncated. */
433
+ truncated?: string;
434
+ }
435
+ /**
436
+ * 通过组件 ref 切换或查询当前页签,并透传底座的命令式能力。
437
+ * Switches or queries the active tab through the component ref, and exposes the
438
+ * base component's imperative capabilities.
439
+ */
440
+ export interface FilePreviewHandle {
441
+ /**
442
+ * 切到指定 key 的页签。该页签不存在或被禁用时返回 `false`。
443
+ * Switches to the tab with the given key. Returns `false` when the tab does not
444
+ * exist or is disabled.
445
+ */
446
+ setActiveTab: (key: string) => boolean;
447
+ /** 取当前激活页签的 key。Returns the key of the active tab. */
448
+ getActiveTab: () => string;
449
+ /**
450
+ * 取当前文件页签的底座句柄,用于翻页、搜索、缩放等命令式操作。
451
+ * 当前页签不是文件页签、或底座尚未就绪时返回 `null`。
452
+ * Returns the base handle of the active file tab for page, search and zoom
453
+ * commands. Returns `null` when the active tab is a content tab or the base is
454
+ * not ready yet.
455
+ */
456
+ getViewerHandle: () => ViewerHandle | null;
457
+ }
458
+ /**
459
+ * 文件预览配置,支持文件页签与自定义内容页签。
460
+ * 通过页签配置内容与操作,文件页签可提供编辑能力与状态提示。
461
+ * File-preview options supporting file tabs and custom-content tabs. Configure
462
+ * content and actions per tab; file tabs also support editing options and status
463
+ * content.
464
+ */
465
+ export interface FilePreviewProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
466
+ /**
467
+ * 页签列表,至少一个。每个页签用 `source` 交给组件按格式渲染,或用 `content`
468
+ * 完全自定义渲染。
469
+ * The tab list, at least one entry. Each tab either hands `source` to the
470
+ * component for format rendering or renders fully custom `content`.
471
+ */
472
+ tabs: readonly [FilePreviewTab, ...FilePreviewTab[]];
473
+ /**
474
+ * 受控的当前页签 key。传入时由宿主决定当前页签,组件只上报切换意图。
475
+ * The controlled active tab key. When given, the host owns the active tab and
476
+ * the component only reports switch intent.
477
+ */
478
+ activeKey?: string;
479
+ /**
480
+ * 非受控时的初始页签 key,省略时选中第一个。
481
+ * Initial tab key when uncontrolled; the first tab is selected when omitted.
482
+ */
483
+ defaultActiveKey?: string;
484
+ /**
485
+ * 底座内置文案的语言。组件自身文案仍由 `labels` 控制。
486
+ * Language of the base component's built-in copy. The component's own copy is
487
+ * still controlled by `labels`.
488
+ */
489
+ locale?: 'en-US' | 'zh-CN';
490
+ /**
491
+ * 当前页签变化后触发,参数为新的页签 key。
492
+ * Called after the active tab changes, with the new tab key.
493
+ */
494
+ onActiveKeyChange?: (key: string) => void;
495
+ /**
496
+ * 所有页签的默认文案,缺省为英文。页签可以逐项覆盖。
497
+ * Default copy for every tab, English by default. A tab can override it field
498
+ * by field.
499
+ */
500
+ labels?: FilePreviewLabels;
501
+ }
502
+ /**
503
+ * 文件预览组件,可通过 ref 切换或查询当前页签。
504
+ * A file-preview component whose ref supports switching and querying tabs.
505
+ */
506
+ export type FilePreviewComponent = ForwardRefExoticComponent<PropsWithoutRef<FilePreviewProps> & RefAttributes<FilePreviewHandle>>;
507
+ /**
508
+ * 文件页签的视图模式。底座的 `ViewerViewMode` 是不透明的字符串,这里只收
509
+ * 组件自己会切换的两种;其它格式的私有模式(Word 版式/阅读、CAD 2D/3D)
510
+ * 由底座与 Adapter 自行管理,不经过组件。
511
+ *
512
+ * View modes of a file tab. The base `ViewerViewMode` is an opaque string; only
513
+ * the two the component switches between are listed here. Format-private modes
514
+ * (Word layout/reading, CAD 2D/3D) are managed by the base and its adapters.
515
+ */
516
+ export type FilePreviewViewMode = 'preview' | 'source';
@@ -0,0 +1,23 @@
1
+ import type { useFilePreviewActions } from './use-file-preview-actions.js';
2
+ import type { useFilePreviewEditing } from './use-file-preview-editing.js';
3
+ import type { FilePreviewActions, FilePreviewFileTab, FilePreviewTab, FilePreviewViewMode } from './types.js';
4
+ type Operations = ReturnType<typeof useFilePreviewActions>;
5
+ type Editing = ReturnType<typeof useFilePreviewEditing>;
6
+ /**
7
+ * 组装交给宿主的动作上下文:把组件内部的视图、编辑与操作状态,连同改变它们
8
+ * 的方法收成一个对象,供 `slots.actions` 渲染按钮时使用。
9
+ *
10
+ * Assembles the action context handed to the host: the component's view, editing
11
+ * and operation state together with the methods that change them, so a
12
+ * `slots.actions` renderer can build its own buttons.
13
+ */
14
+ export declare function useFilePreviewActionsContext({ activeTab, fileTab, viewMode, canSwitchView, setViewMode, editing, operations, }: {
15
+ activeTab: FilePreviewTab;
16
+ fileTab?: FilePreviewFileTab;
17
+ viewMode: FilePreviewViewMode;
18
+ canSwitchView: boolean;
19
+ setViewMode: (mode: FilePreviewViewMode) => void;
20
+ editing: Editing;
21
+ operations: Operations;
22
+ }): FilePreviewActions;
23
+ export {};
@@ -0,0 +1,19 @@
1
+ import type { FilePreviewFileTab, FilePreviewTab } from './types.js';
2
+ /**
3
+ * 文件页签的操作执行与成功通知。
4
+ *
5
+ * 沿用文件树的约定:`operations` 里的异步方法成功后才触发对应的 `on…`
6
+ * 回调,失败静默;同一操作在飞时忽略重复调用。
7
+ *
8
+ * Executes file-tab operations and reports success. Follows the file-tree
9
+ * convention: the matching `on…` callback fires only after the async operation
10
+ * resolves, failures stay silent, and repeated calls are ignored while one is
11
+ * still in flight.
12
+ */
13
+ export declare function useFilePreviewActions(): {
14
+ openParent: (tab: FilePreviewTab, uri: string) => Promise<void>;
15
+ download: (tab: FilePreviewFileTab) => Promise<void>;
16
+ openUri: (tab: FilePreviewFileTab, uri: string) => Promise<void>;
17
+ copyPath: (tab: FilePreviewTab, path: string) => Promise<boolean>;
18
+ copyContent: (tab: FilePreviewFileTab, text: string) => Promise<boolean>;
19
+ };
@@ -0,0 +1,32 @@
1
+ import type { FilePreviewFileTab, FilePreviewTab } from './types.js';
2
+ /**
3
+ * 文件页签的编辑态:进入编辑时向宿主取完整文本,保存成功才退出编辑。
4
+ *
5
+ * 进入编辑前用请求号作废旧请求,避免快速切换页签时迟到的结果写进新草稿;
6
+ * 保存期间拦住重复提交与页签切换,失败时保留草稿。
7
+ *
8
+ * 受控模式下宿主可以直接改 `activeKey`,不经过 `switchTab`;因此这里比对页签
9
+ * key,变化时在渲染期间就把草稿丢掉,否则会拿上一个页签的草稿去保存新页签。
10
+ *
11
+ * Editing state of a file tab. The full text is requested when editing starts,
12
+ * and the draft only leaves editing after a successful save. A request id
13
+ * invalidates stale loads when the tab changes quickly; duplicate saves and tab
14
+ * switches are blocked while saving, and a failed save keeps the draft.
15
+ *
16
+ * Under a controlled `activeKey` the host can switch tabs without going through
17
+ * `switchTab`, so the hook compares the active key and drops the draft during
18
+ * render when it changes — otherwise the previous tab's draft would be saved to
19
+ * the new one.
20
+ */
21
+ export declare function useFilePreviewEditing(activeTabKey: string): {
22
+ editing: boolean;
23
+ loadingEdit: boolean;
24
+ editFailed: boolean;
25
+ saving: boolean;
26
+ saveFailed: boolean;
27
+ draft: string;
28
+ discard: (tab: FilePreviewTab) => void;
29
+ start: (tab: FilePreviewFileTab) => Promise<void>;
30
+ save: (tab: FilePreviewFileTab) => Promise<boolean>;
31
+ updateDraft: (value: string) => void;
32
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 页签与面板的 DOM id 生成器,带实例前缀。
3
+ *
4
+ * 只用宿主给的 `tab.key` 拼 id,两个预览同时挂载时会产生重复 id,`aria-controls`
5
+ * 与 `aria-labelledby` 因此可能指向另一个实例的元素。`useId` 给出每个实例唯一
6
+ * 的前缀,页签行与面板两侧共用同一份。
7
+ *
8
+ * DOM id generators for tabs and panels, prefixed per instance.
9
+ *
10
+ * Building ids from the host's `tab.key` alone collides when two previews are
11
+ * mounted at once, so `aria-controls` and `aria-labelledby` could point at the
12
+ * other instance's elements. `useId` supplies a unique prefix per instance, shared
13
+ * by the tab row and the panels.
14
+ */
15
+ export declare function useFilePreviewIds(activeKey: string): {
16
+ tabId: (key: string) => string;
17
+ panelId: (key: string) => string;
18
+ /** 面板的公共属性:id、role 与 aria 关联,随当前页签变化。 */
19
+ panelProps: {
20
+ id: string;
21
+ role: 'tabpanel';
22
+ 'aria-labelledby': string;
23
+ };
24
+ };
@@ -0,0 +1 @@
1
+ export { FilePreview } from "../g~0.js";
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { FileTreeRowContext, ResolvedLabels } from './file-tree-row-context.js';
3
+ import type { FileTreeRow } from './types.js';
4
+ export interface FileTreeBodyProps {
5
+ rows: readonly FileTreeRow[];
6
+ isReady: boolean;
7
+ text: ResolvedLabels;
8
+ loadingFallback?: ReactNode;
9
+ errorFallback?: ReactNode;
10
+ emptyFallback?: ReactNode;
11
+ ctx: FileTreeRowContext;
12
+ }
13
+ /**
14
+ * 树内容区:首次加载、整树失败、空态与正常行列表。
15
+ *
16
+ * The tree body: first load, whole-tree failure, empty state, and the row list.
17
+ */
18
+ export declare function FileTreeBody({ rows, isReady, text, loadingFallback, errorFallback, emptyFallback, ctx, }: FileTreeBodyProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { FileTreeRowContext } from './file-tree-row-context.js';
2
+ import type { FileTreeEntryRow } from './types.js';
3
+ /**
4
+ * 一条条目行:展开箭头、图标、名称、行内说明、行尾指示器与悬停浮层。
5
+ *
6
+ * One entry row: chevron, icon, name, inline description, the row-end indicator
7
+ * and the hover tooltip.
8
+ */
9
+ export declare function FileTreeRowView({ row, ctx, }: {
10
+ row: FileTreeEntryRow;
11
+ ctx: FileTreeRowContext;
12
+ }): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 文件夹图标。展开态与收起态叠放在一起交叉淡入,和宿主一致。
3
+ *
4
+ * The folder icon. The open and collapsed states sit stacked and cross-fade,
5
+ * matching the host tree.
6
+ */
7
+ export declare function FileTreeFolderIcon({ open }: {
8
+ open: boolean;
9
+ }): import("react").JSX.Element;
10
+ /** 宿主没有提供 `renderRowIcon` 时的文件图标。Fallback file icon. */
11
+ export declare function FileTreeFileIcon(): import("react").JSX.Element;
12
+ /** 展开箭头,展开时旋转 90°。The expand chevron, rotated when open. */
13
+ export declare function FileTreeChevron({ open }: {
14
+ open: boolean;
15
+ }): import("react").JSX.Element;