@h-ai/ui 1.0.0-beta.20 → 1.0.0-beta.22
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/README.en.md +24 -0
- package/README.ja.md +24 -0
- package/README.md +24 -0
- package/auto-import.d.ts +1 -0
- package/auto-import.js +1 -0
- package/dist/components/scenes/code/CodeWorkspace.svelte +946 -0
- package/dist/components/scenes/code/CodeWorkspace.svelte.d.ts +21 -0
- package/dist/components/scenes/code/CodeWorkspaceEditor.svelte +737 -0
- package/dist/components/scenes/code/CodeWorkspaceEditor.svelte.d.ts +37 -0
- package/dist/components/scenes/code/CodeWorkspaceGutter.svelte +246 -0
- package/dist/components/scenes/code/CodeWorkspaceGutter.svelte.d.ts +23 -0
- package/dist/components/scenes/code/CodeWorkspaceSearch.svelte +234 -0
- package/dist/components/scenes/code/CodeWorkspaceSearch.svelte.d.ts +23 -0
- package/dist/components/scenes/code/CodeWorkspaceTree.svelte +519 -0
- package/dist/components/scenes/code/CodeWorkspaceTree.svelte.d.ts +26 -0
- package/dist/components/scenes/code/code-editor.d.ts +12 -0
- package/dist/components/scenes/code/code-editor.js +93 -0
- package/dist/components/scenes/code/code-types.d.ts +346 -0
- package/dist/components/scenes/code/code-types.js +1 -0
- package/dist/components/scenes/code/index.d.ts +2 -0
- package/dist/components/scenes/code/index.js +1 -0
- package/dist/components/scenes/code/workers/css.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/css.worker.js +1 -0
- package/dist/components/scenes/code/workers/editor.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/editor.worker.js +1 -0
- package/dist/components/scenes/code/workers/html.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/html.worker.js +1 -0
- package/dist/components/scenes/code/workers/json.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/json.worker.js +1 -0
- package/dist/components/scenes/code/workers/ts.worker.d.ts +1 -0
- package/dist/components/scenes/code/workers/ts.worker.js +1 -0
- package/dist/components/scenes/index.d.ts +1 -0
- package/dist/components/scenes/index.js +2 -0
- package/dist/messages/en-US.json +54 -1
- package/dist/messages/ja-JP.json +54 -1
- package/dist/messages/zh-CN.json +54 -1
- package/dist/toast.svelte.js +13 -4
- package/package.json +8 -2
package/README.en.md
CHANGED
|
@@ -416,6 +416,30 @@ Inside a Modal or Drawer, portal controls participate in the owning dialog's Tab
|
|
|
416
416
|
|
|
417
417
|
#### Scenes
|
|
418
418
|
|
|
419
|
+
##### Code workspace
|
|
420
|
+
|
|
421
|
+
Use `CodeWorkspace` to browse read-only source files. A directory listing and a file reader are enough to get started. The directory callback receives `null` for the root. Opening a file creates or reuses a tab keyed by file ID and version. Switching tabs restores the cursor and scroll position for recently viewed files.
|
|
422
|
+
|
|
423
|
+
```svelte
|
|
424
|
+
<script lang="ts">
|
|
425
|
+
import type { CodeWorkspaceSource } from '@h-ai/ui/components/scenes/code/index'
|
|
426
|
+
import { CodeWorkspace } from '@h-ai/ui/components/scenes/code/index'
|
|
427
|
+
|
|
428
|
+
const source: CodeWorkspaceSource = {
|
|
429
|
+
listChildren: () => [{ kind: 'file', id: 'readme', name: 'README.md' }],
|
|
430
|
+
readFile: () => ({ text: '# Hello', language: 'markdown' }),
|
|
431
|
+
}
|
|
432
|
+
</script>
|
|
433
|
+
|
|
434
|
+
<CodeWorkspace {source} />
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
Supply `source.search` for filename and workspace content search, and return `nextCursor` when another page is available. File and folder `markers` can show risk and Git state. Return `annotations` from `readFile` to mark lines or ranges. Use the `inspector` and `selectionActions` snippets to render the side panel and actions for the selected code. See the [code workspace guide](../../docs/usage/development/ui.md#代码工作区).
|
|
438
|
+
|
|
439
|
+
Vite loads Monaco and its same-origin workers on demand in the browser. The editor follows the Hai theme by default and supports presets and custom palettes. Monaco editors on the same page share a theme. Mobile devices and editor load failures use a plain-text view.
|
|
440
|
+
|
|
441
|
+
Use the `annotationIcon` snippet to render a gutter icon. On hover, `hoverText` displays plain text, or `annotationHover` renders a custom component when `hoverText` is omitted. Press Enter to enter the popup and Escape to close it.
|
|
442
|
+
|
|
419
443
|
##### Guide
|
|
420
444
|
|
|
421
445
|
| Component | Description | Key props |
|
package/README.ja.md
CHANGED
|
@@ -416,6 +416,30 @@ Modal または Drawer 内では、portal の操作要素も所属ダイアロ
|
|
|
416
416
|
|
|
417
417
|
#### Scenes:用途別コンポーネント
|
|
418
418
|
|
|
419
|
+
##### コードワークスペース
|
|
420
|
+
|
|
421
|
+
`CodeWorkspace` は読み取り専用のソース閲覧コンポーネントです。ディレクトリ一覧とファイル内容を返すコールバックだけで利用できます。ルートの一覧を取得する際は、ディレクトリのコールバックに `null` が渡ります。タブはファイル ID とバージョンで識別されます。タブを切り替えると、最近表示したファイルのカーソル位置とスクロール位置が復元されます。
|
|
422
|
+
|
|
423
|
+
```svelte
|
|
424
|
+
<script lang="ts">
|
|
425
|
+
import type { CodeWorkspaceSource } from '@h-ai/ui/components/scenes/code/index'
|
|
426
|
+
import { CodeWorkspace } from '@h-ai/ui/components/scenes/code/index'
|
|
427
|
+
|
|
428
|
+
const source: CodeWorkspaceSource = {
|
|
429
|
+
listChildren: () => [{ kind: 'file', id: 'readme', name: 'README.md' }],
|
|
430
|
+
readFile: () => ({ text: '# Hello', language: 'markdown' }),
|
|
431
|
+
}
|
|
432
|
+
</script>
|
|
433
|
+
|
|
434
|
+
<CodeWorkspace {source} />
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
`source.search` を指定するとファイル名とワークスペース全体の内容を検索できます。続きがある場合は `nextCursor` を返します。ファイルやフォルダーの `markers` でリスクや Git の状態を表示し、`readFile` が返す `annotations` で行や範囲をマークできます。右側のパネルと選択範囲の操作には `inspector` と `selectionActions` の snippet を指定します。[コードワークスペース利用ガイド](../../docs/usage/development/ui.md#代码工作区)を参照してください。
|
|
438
|
+
|
|
439
|
+
Monaco と同一オリジンの worker は、Vite がブラウザーで必要に応じて読み込みます。エディターは既定で Hai のテーマに従い、プリセットとカスタム配色にも対応します。同じページ内の Monaco エディターはテーマを共有します。モバイル端末とエディターの読み込みに失敗した場合は、プレーンテキストで閲覧できます。
|
|
440
|
+
|
|
441
|
+
`annotationIcon` スニペットで行頭アイコンを描画できます。ホバー時は `hoverText` のテキストを優先し、省略時は `annotationHover` で操作可能なコンポーネントを表示できます。Enter でポップアップに移動し、Escape で閉じます。
|
|
442
|
+
|
|
419
443
|
##### Guide:案内・ヘルプ
|
|
420
444
|
|
|
421
445
|
| コンポーネント | 説明 | 主なプロパティ |
|
package/README.md
CHANGED
|
@@ -416,6 +416,30 @@ components/
|
|
|
416
416
|
|
|
417
417
|
#### 场景组件 Scenes
|
|
418
418
|
|
|
419
|
+
##### 代码工作区
|
|
420
|
+
|
|
421
|
+
用 `CodeWorkspace` 浏览只读源码。最小接入只需提供目录列表和文件内容。目录回调收到 `null` 时返回根节点。打开文件即创建标签,标签按文件 ID 和版本复用,切换时恢复近期查看过的文件的光标与滚动位置。
|
|
422
|
+
|
|
423
|
+
```svelte
|
|
424
|
+
<script lang="ts">
|
|
425
|
+
import type { CodeWorkspaceSource } from '@h-ai/ui/components/scenes/code/index'
|
|
426
|
+
import { CodeWorkspace } from '@h-ai/ui/components/scenes/code/index'
|
|
427
|
+
|
|
428
|
+
const source: CodeWorkspaceSource = {
|
|
429
|
+
listChildren: () => [{ kind: 'file', id: 'readme', name: 'README.md' }],
|
|
430
|
+
readFile: () => ({ text: '# Hello', language: 'markdown' }),
|
|
431
|
+
}
|
|
432
|
+
</script>
|
|
433
|
+
|
|
434
|
+
<CodeWorkspace {source} />
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
传入 `source.search` 启用文件名和工作区内容搜索,返回 `nextCursor` 时可继续加载。文件或目录上的 `markers` 展示风险和 Git 状态,`readFile` 返回的 `annotations` 可标记行或范围。传入 `inspector` 和 `selectionActions` snippet 连接右侧检查区及选区浮动操作。更多用法见[代码工作区接入](../../docs/usage/development/ui.md#代码工作区)。
|
|
438
|
+
|
|
439
|
+
Monaco 和同源 worker 由 Vite 在浏览器按需加载。主题默认跟随 Hai,可选预设或传自定义配色。同页 Monaco 编辑器共享主题。移动端和编辑器加载失败时提供纯文本浏览。
|
|
440
|
+
|
|
441
|
+
行前图标由 `annotationIcon` Snippet 自定义。悬停时优先显示标注的 `hoverText`,否则使用 `annotationHover` Snippet,支持交互组件。按 Enter 可进入浮层,按 Escape 关闭。
|
|
442
|
+
|
|
419
443
|
##### Guide 引导与帮助
|
|
420
444
|
|
|
421
445
|
| 组件 | 描述 | 主要属性 |
|
package/auto-import.d.ts
CHANGED
|
@@ -72,6 +72,7 @@ declare global {
|
|
|
72
72
|
const PageHeader: typeof import('@h-ai/ui')['PageHeader']
|
|
73
73
|
const FilterBar: typeof import('@h-ai/ui')['FilterBar']
|
|
74
74
|
const WorkspaceLayout: typeof import('@h-ai/ui')['WorkspaceLayout']
|
|
75
|
+
const CodeWorkspace: typeof import('@h-ai/ui')['CodeWorkspace']
|
|
75
76
|
const Pagination: typeof import('@h-ai/ui')['Pagination']
|
|
76
77
|
const Popover: typeof import('@h-ai/ui')['Popover']
|
|
77
78
|
const PullRefresh: typeof import('@h-ai/ui')['PullRefresh']
|