@h-ai/ui 0.1.0-alpha.10 → 0.1.0-alpha.12

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.
@@ -0,0 +1,6 @@
1
+ import type { AiTableEditorProps } from './table-types.js';
2
+ declare const AiTableEditor: import("svelte").Component<AiTableEditorProps, {
3
+ flushPendingTableChange: () => void;
4
+ }, "editorScrollHost">;
5
+ type AiTableEditor = ReturnType<typeof AiTableEditor>;
6
+ export default AiTableEditor;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * 表格列支持的数据类型。
3
+ * - `text`: 普通文本输入
4
+ * - `number`: 数值输入(前端仍按字符串回传,避免输入中间态被强转)
5
+ * - `tag`: 标签样式输入,用于优先级、状态等枚举文本
6
+ */
7
+ export type AiTableColumnType = 'text' | 'number' | 'tag';
8
+ export interface AiTableColumn {
9
+ /** 列唯一键,必须和每行对象中的字段名一一对应。 */
10
+ key: string;
11
+ /** 列头展示文案。 */
12
+ label: string;
13
+ /** 当前列的输入与渲染类型。 */
14
+ type: AiTableColumnType;
15
+ }
16
+ export interface AiTableRow {
17
+ /** 行唯一标识;编辑、删除和流式合并都依赖它做稳定匹配。 */
18
+ row_id: string;
19
+ /**
20
+ * 行内任意单元格值,键名需对应 `table_columns[].key`。
21
+ *
22
+ * @remarks
23
+ * viewer 侧会接历史草稿、structured payload 和流式中间态,值类型不能过早收死。
24
+ * 组件内部会在渲染/复制/下载时统一做字符串化兜底。
25
+ */
26
+ [key: string]: unknown;
27
+ }
28
+ export interface AiTableData {
29
+ /** 列定义,按数组顺序渲染表头和单元格。 */
30
+ table_columns: AiTableColumn[];
31
+ /** 行数据,按数组顺序展示。 */
32
+ table_rows: AiTableRow[];
33
+ }
34
+ /**
35
+ * 表格变更来源,用于上层做埋点或按动作类型分流保存策略。
36
+ */
37
+ export type AiTableEditorChangeAction = 'replace' | 'cell-update' | 'row-add' | 'row-delete' | 'row-reorder';
38
+ export interface AiTableEditorChangePayload {
39
+ /** 本次变更动作类型。 */
40
+ action: AiTableEditorChangeAction;
41
+ /** 变更后的完整表格快照。 */
42
+ nextData: AiTableData;
43
+ /** 命中的行 id;`replace` 动作下可为空,`row-reorder` 下表示被拖动的行。 */
44
+ rowId?: string;
45
+ /** 命中的列 key;仅单元格编辑时存在。 */
46
+ columnKey?: string;
47
+ /** 单元格编辑后的值;仅单元格编辑时存在。 */
48
+ value?: string;
49
+ /** 行重排时命中的参考行 id;用于还原“拖到哪一行附近”的上下文。 */
50
+ targetRowId?: string;
51
+ /** 行重排前的索引;仅 `row-reorder` 时存在。 */
52
+ fromIndex?: number;
53
+ /** 行重排后的索引;仅 `row-reorder` 时存在。 */
54
+ toIndex?: number;
55
+ }
56
+ export interface AiTableCopyPayload {
57
+ /** 当前复制时的结构化表格数据。 */
58
+ data: AiTableData;
59
+ /** 复制到剪贴板的文本内容(TSV)。 */
60
+ text: string;
61
+ }
62
+ export interface AiTableDownloadPayload {
63
+ /** 当前下载时的结构化表格数据。 */
64
+ data: AiTableData;
65
+ /** 下载内容(CSV)。 */
66
+ csv: string;
67
+ /** 推荐文件名(已带 `.csv` 后缀)。 */
68
+ filename: string;
69
+ }
70
+ export interface AiTableEditorProps {
71
+ /** 原始表格内容字符串,通常是 JSON 文本,支持流式残缺片段。 */
72
+ content?: string;
73
+ /** 结构化表格数据;有值时优先于 `content`。 */
74
+ tableData?: AiTableData;
75
+ /** 表格标题。 */
76
+ title?: string;
77
+ /** 外层容器自定义类名。 */
78
+ class?: string;
79
+ /** 暴露给外层的滚动容器引用,便于外层同步滚动行为。 */
80
+ editorScrollHost?: HTMLDivElement | null;
81
+ /** 头部状态文案。 */
82
+ statusText?: string;
83
+ /** 头部辅助文案。 */
84
+ metaText?: string;
85
+ /** 头部保存状态文案。 */
86
+ saveState?: string;
87
+ /** 是否允许编辑单元格与行操作。 */
88
+ editable?: boolean;
89
+ /** 关闭按钮是否禁用。 */
90
+ closeDisabled?: boolean;
91
+ /** 关闭回调。 */
92
+ onclose?: () => void;
93
+ /** 表格变更回调,后续可直接对接保存接口。 */
94
+ ontablechange?: (payload: AiTableEditorChangePayload) => void | Promise<void>;
95
+ /** 表格容器滚动回调,便于外层同步“自动跟随到底部”等策略。 */
96
+ ondocumentscroll?: (event: Event) => void;
97
+ /** 复制回调;不传则走组件内置剪贴板逻辑。 */
98
+ oncopytable?: (payload: AiTableCopyPayload) => void | Promise<void>;
99
+ /** 下载回调;不传则走组件内置浏览器下载逻辑。 */
100
+ ondownloadtable?: (payload: AiTableDownloadPayload) => void | Promise<void>;
101
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -204,6 +204,11 @@
204
204
  "markdown_history": "History",
205
205
  "markdown_view_version": "View version",
206
206
  "markdown_format_heading": "Heading",
207
+ "markdown_format_paragraph": "Paragraph",
208
+ "markdown_format_heading_1": "Heading 1",
209
+ "markdown_format_heading_2": "Heading 2",
210
+ "markdown_format_heading_3": "Heading 3",
211
+ "markdown_format_heading_4": "Heading 4",
207
212
  "markdown_format_bullet": "Bullets",
208
213
  "markdown_format_bold": "Bold",
209
214
  "markdown_format_strike": "Strike",
@@ -212,12 +217,34 @@
212
217
  "markdown_format_link": "Link",
213
218
  "markdown_format_code": "Code",
214
219
  "markdown_format_highlight": "Highlight",
220
+ "markdown_align": "Align",
221
+ "markdown_align_left": "Align left",
222
+ "markdown_align_center": "Align center",
223
+ "markdown_align_right": "Align right",
224
+ "markdown_align_justify": "Justify",
225
+ "markdown_text_color": "Text color",
226
+ "markdown_background_color": "Background color",
227
+ "markdown_reset_default": "Reset default",
228
+ "markdown_color_dialog_label": "Text and background color",
229
+ "markdown_link_dialog_label": "Edit link",
230
+ "markdown_link_input_label": "Link URL",
231
+ "markdown_link_placeholder": "Paste or type a link",
232
+ "markdown_link_apply": "Apply link",
233
+ "markdown_link_remove": "Remove link",
215
234
  "markdown_copy_selection": "Copy",
216
235
  "markdown_annotation": "Annotate",
217
236
  "markdown_run_preview": "Run Preview",
218
237
  "markdown_running": "Running",
219
238
  "markdown_run_failed": "Run failed",
220
239
  "markdown_run_unavailable": "No preview runner is configured for this code block.",
240
+ "markdown_run_unavailable_language": "Local preview for {language} is not supported. Reason: no runtime is configured for this language.",
241
+ "table_editor_eyebrow": "Editable table",
242
+ "table_copy": "Copy table",
243
+ "table_download": "Download table",
244
+ "table_reorder_row": "Drag to reorder this row",
245
+ "table_close": "Close",
246
+ "table_add_row": "Add row",
247
+ "table_delete_row": "Delete row",
221
248
  "crud_create": "Create",
222
249
  "crud_edit": "Edit",
223
250
  "crud_detail": "Detail",
@@ -204,6 +204,11 @@
204
204
  "markdown_history": "历史版本",
205
205
  "markdown_view_version": "查看版本",
206
206
  "markdown_format_heading": "标题",
207
+ "markdown_format_paragraph": "正文",
208
+ "markdown_format_heading_1": "一级标题",
209
+ "markdown_format_heading_2": "二级标题",
210
+ "markdown_format_heading_3": "三级标题",
211
+ "markdown_format_heading_4": "四级标题",
207
212
  "markdown_format_bullet": "列表",
208
213
  "markdown_format_bold": "加粗",
209
214
  "markdown_format_strike": "删除线",
@@ -212,12 +217,34 @@
212
217
  "markdown_format_link": "链接",
213
218
  "markdown_format_code": "代码",
214
219
  "markdown_format_highlight": "高亮",
220
+ "markdown_align": "对齐",
221
+ "markdown_align_left": "左对齐",
222
+ "markdown_align_center": "居中对齐",
223
+ "markdown_align_right": "右对齐",
224
+ "markdown_align_justify": "两端对齐",
225
+ "markdown_text_color": "字体颜色",
226
+ "markdown_background_color": "背景颜色",
227
+ "markdown_reset_default": "恢复默认",
228
+ "markdown_color_dialog_label": "文本和背景颜色",
229
+ "markdown_link_dialog_label": "编辑链接",
230
+ "markdown_link_input_label": "链接地址",
231
+ "markdown_link_placeholder": "输入或粘贴链接地址",
232
+ "markdown_link_apply": "应用链接",
233
+ "markdown_link_remove": "移除链接",
215
234
  "markdown_copy_selection": "复制",
216
235
  "markdown_annotation": "注释",
217
236
  "markdown_run_preview": "运行预览",
218
237
  "markdown_running": "运行中",
219
238
  "markdown_run_failed": "运行失败",
220
239
  "markdown_run_unavailable": "当前代码块未配置运行预览器。",
240
+ "markdown_run_unavailable_language": "暂不支持 {language} 的本地预览。原因:当前环境未配置该语言的运行器。",
241
+ "table_editor_eyebrow": "可编辑表格",
242
+ "table_copy": "复制表格",
243
+ "table_download": "下载表格",
244
+ "table_reorder_row": "拖动调整这一行顺序",
245
+ "table_close": "关闭",
246
+ "table_add_row": "新增一行",
247
+ "table_delete_row": "删除这一行",
221
248
  "crud_create": "新建",
222
249
  "crud_edit": "编辑",
223
250
  "crud_detail": "详情",
package/dist/types.d.ts CHANGED
@@ -29,6 +29,8 @@ export interface ButtonProps {
29
29
  variant?: Variant;
30
30
  /** 尺寸 */
31
31
  size?: Size;
32
+ /** 关联表单 ID */
33
+ form?: string;
32
34
  /** 自定义类名 */
33
35
  class?: string;
34
36
  /** aria-label(无障碍标签) */
@@ -442,6 +444,12 @@ export interface ModalProps {
442
444
  closeOnEscape?: boolean;
443
445
  /** 是否显示关闭按钮 */
444
446
  showClose?: boolean;
447
+ /** 自定义宽度(任意合法 CSS 宽度值) */
448
+ width?: string;
449
+ /** 自定义高度(任意合法 CSS 高度值) */
450
+ height?: string;
451
+ /** 主体区域自定义类名 */
452
+ bodyClass?: string;
445
453
  /** 自定义类名 */
446
454
  class?: string;
447
455
  /** 关闭事件 */
@@ -702,6 +710,8 @@ export interface DropdownProps {
702
710
  * 表单属性
703
711
  */
704
712
  export interface FormProps {
713
+ /** 表单 ID */
714
+ id?: string;
705
715
  /** 自定义类名 */
706
716
  class?: string;
707
717
  /** 加载状态 */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@h-ai/ui",
3
3
  "type": "module",
4
- "version": "0.1.0-alpha.10",
4
+ "version": "0.1.0-alpha.12",
5
5
  "description": "Hai Framework UI component library for Svelte 5 Runes.",
6
6
  "license": "Apache-2.0",
7
7
  "svelte": "./dist/index.js",
@@ -39,10 +39,12 @@
39
39
  "@internationalized/date": "^3.8.0",
40
40
  "@shikijs/langs": "^4.0.2",
41
41
  "bits-ui": "^2.8.0",
42
+ "html2canvas": "^1.4.1",
43
+ "jspdf": "^4.2.1",
42
44
  "marked": "^18.0.0",
43
45
  "shiki": "^4.0.2",
44
46
  "tailwind-merge": "^3.5.0",
45
- "@h-ai/core": "0.1.0-alpha.10"
47
+ "@h-ai/core": "0.1.0-alpha.12"
46
48
  },
47
49
  "devDependencies": {
48
50
  "@sveltejs/package": "^2.5.7",