@h-ai/ui 1.0.0-beta.3 → 1.0.0-beta.31

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 (200) hide show
  1. package/README.en.md +14 -1007
  2. package/README.ja.md +13 -1006
  3. package/README.md +15 -1007
  4. package/auto-import.d.ts +9 -0
  5. package/auto-import.js +246 -65
  6. package/dist/components/compounds/Accordion.svelte +6 -2
  7. package/dist/components/compounds/BottomNav.svelte +14 -2
  8. package/dist/components/compounds/Card.svelte +3 -1
  9. package/dist/components/compounds/Combobox.svelte +41 -5
  10. package/dist/components/compounds/DataTable.svelte +28 -8
  11. package/dist/components/compounds/DatePicker.svelte +6 -1
  12. package/dist/components/compounds/Drawer.svelte +12 -4
  13. package/dist/components/compounds/Dropdown.svelte +135 -59
  14. package/dist/components/compounds/Empty.svelte +10 -2
  15. package/dist/components/compounds/FormField.svelte +10 -2
  16. package/dist/components/compounds/JsonViewer.svelte +18 -6
  17. package/dist/components/compounds/Modal.svelte +8 -2
  18. package/dist/components/compounds/Pagination.svelte +22 -7
  19. package/dist/components/compounds/Popover.svelte +94 -12
  20. package/dist/components/compounds/Steps.svelte +24 -8
  21. package/dist/components/compounds/SwipeCell.svelte +3 -1
  22. package/dist/components/compounds/TableToolbar.svelte +32 -9
  23. package/dist/components/compounds/Tabs.svelte +25 -5
  24. package/dist/components/compounds/TagInput.svelte +2 -0
  25. package/dist/components/compounds/Timeline.svelte +6 -2
  26. package/dist/components/compounds/ToastContainer.svelte +41 -10
  27. package/dist/components/compounds/Tooltip.svelte +1 -1
  28. package/dist/components/compounds/Tooltip.svelte.d.ts +1 -1
  29. package/dist/components/control-size.js +48 -8
  30. package/dist/components/primitives/Avatar.svelte +9 -3
  31. package/dist/components/primitives/BareInput.svelte +3 -1
  32. package/dist/components/primitives/Button.svelte +6 -2
  33. package/dist/components/primitives/Checkbox.svelte +5 -0
  34. package/dist/components/primitives/IconButton.svelte +3 -1
  35. package/dist/components/primitives/Input.svelte +19 -3
  36. package/dist/components/primitives/Radio.svelte +4 -1
  37. package/dist/components/primitives/Range.svelte +3 -1
  38. package/dist/components/primitives/Rating.svelte +9 -3
  39. package/dist/components/primitives/Select.svelte +21 -5
  40. package/dist/components/primitives/Tag.svelte +6 -10
  41. package/dist/components/primitives/Textarea.svelte +14 -2
  42. package/dist/components/scenes/ai/AiDocumentEditor.svelte +118 -76
  43. package/dist/components/scenes/ai/document-download.js +55 -88
  44. package/dist/components/scenes/ai/document-parse.js +27 -33
  45. package/dist/components/scenes/ai/document-pdf-pages.d.ts +26 -0
  46. package/dist/components/scenes/ai/document-pdf-pages.js +111 -0
  47. package/dist/components/scenes/ai/document-pdf-worker.d.ts +11 -0
  48. package/dist/components/scenes/ai/document-pdf-worker.js +29 -0
  49. package/dist/components/scenes/ai/document-render-pool.d.ts +19 -0
  50. package/dist/components/scenes/ai/document-render-pool.js +20 -0
  51. package/dist/components/scenes/ai/document-render-worker.d.ts +13 -0
  52. package/dist/components/scenes/ai/document-render-worker.js +7 -0
  53. package/dist/components/scenes/ai/document-types.d.ts +2 -12
  54. package/dist/components/scenes/ai/editor-markdown-extensions.js +9 -3
  55. package/dist/components/scenes/ai/highlight.js +3 -1
  56. package/dist/components/scenes/ai/index.d.ts +4 -1
  57. package/dist/components/scenes/ai/index.js +2 -0
  58. package/dist/components/scenes/ai/markdown-parse.js +36 -10
  59. package/dist/components/scenes/ai/mermaid-render.js +13 -1
  60. package/dist/components/scenes/ai/mind/AiMindMapEditor.svelte +519 -0
  61. package/dist/components/scenes/ai/mind/AiMindMapEditor.svelte.d.ts +8 -0
  62. package/dist/components/scenes/ai/mind/mind-adapter.d.ts +38 -0
  63. package/dist/components/scenes/ai/mind/mind-adapter.js +59 -0
  64. package/dist/components/scenes/ai/mind/mind-types.d.ts +116 -0
  65. package/dist/components/scenes/ai/mind/mind-types.js +1 -0
  66. package/dist/components/scenes/ai/safe-html.js +9 -3
  67. package/dist/components/scenes/ai/table/AiTableEditor.svelte +28 -16
  68. package/dist/components/scenes/app/FeedbackDetail.svelte +102 -24
  69. package/dist/components/scenes/app/FeedbackForm.svelte +70 -16
  70. package/dist/components/scenes/app/FeedbackList.svelte +138 -21
  71. package/dist/components/scenes/app/FeedbackRecorder.svelte +18 -5
  72. package/dist/components/scenes/app/FeedbackReplay.svelte +15 -3
  73. package/dist/components/scenes/app/FeedbackScreenshot.svelte +64 -13
  74. package/dist/components/scenes/app/LanguageSwitch.svelte +6 -2
  75. package/dist/components/scenes/app/SettingsLayout.svelte +3 -1
  76. package/dist/components/scenes/app/ThemeSelector.svelte +29 -5
  77. package/dist/components/scenes/app/ThemeToggle.svelte +6 -2
  78. package/dist/components/scenes/app/WorkspaceLayout.svelte +1 -1
  79. package/dist/components/scenes/app/feedback-functions.js +6 -2
  80. package/dist/components/scenes/charts/Chart.svelte +55 -21
  81. package/dist/components/scenes/charts/Chart.svelte.d.ts +0 -1
  82. package/dist/components/scenes/charts/ChartLoadError.svelte +13 -0
  83. package/dist/components/scenes/charts/ChartLoadError.svelte.d.ts +6 -0
  84. package/dist/components/scenes/charts/DashboardGrid.svelte +34 -0
  85. package/dist/components/scenes/charts/DashboardGrid.svelte.d.ts +15 -0
  86. package/dist/components/scenes/charts/MetricCard.svelte +69 -0
  87. package/dist/components/scenes/charts/MetricCard.svelte.d.ts +15 -0
  88. package/dist/components/scenes/charts/ReportCard.svelte +48 -0
  89. package/dist/components/scenes/charts/ReportCard.svelte.d.ts +15 -0
  90. package/dist/components/scenes/charts/chart-presets.d.ts +15 -0
  91. package/dist/components/scenes/charts/chart-presets.js +56 -0
  92. package/dist/components/scenes/charts/chart-types.d.ts +13 -2
  93. package/dist/components/scenes/charts/dashboard-types.d.ts +79 -0
  94. package/dist/components/scenes/charts/dashboard-types.js +1 -0
  95. package/dist/components/scenes/charts/index.d.ts +6 -2
  96. package/dist/components/scenes/charts/index.js +4 -1
  97. package/dist/components/scenes/charts/renderers/AreaChart.svelte +1 -0
  98. package/dist/components/scenes/charts/renderers/AreaChart.svelte.d.ts +1 -0
  99. package/dist/components/scenes/charts/renderers/BarChart.svelte +1 -0
  100. package/dist/components/scenes/charts/renderers/BarChart.svelte.d.ts +1 -0
  101. package/dist/components/scenes/charts/renderers/LineChart.svelte +39 -12
  102. package/dist/components/scenes/charts/renderers/LineChart.svelte.d.ts +1 -0
  103. package/dist/components/scenes/charts/renderers/PieChart.svelte +1 -0
  104. package/dist/components/scenes/charts/renderers/PieChart.svelte.d.ts +1 -0
  105. package/dist/components/scenes/charts/renderers/ScatterChart.svelte +1 -0
  106. package/dist/components/scenes/charts/renderers/ScatterChart.svelte.d.ts +1 -0
  107. package/dist/components/scenes/code/CodeWorkspace.svelte +946 -0
  108. package/dist/components/scenes/code/CodeWorkspace.svelte.d.ts +21 -0
  109. package/dist/components/scenes/code/CodeWorkspaceEditor.svelte +737 -0
  110. package/dist/components/scenes/code/CodeWorkspaceEditor.svelte.d.ts +37 -0
  111. package/dist/components/scenes/code/CodeWorkspaceGutter.svelte +246 -0
  112. package/dist/components/scenes/code/CodeWorkspaceGutter.svelte.d.ts +23 -0
  113. package/dist/components/scenes/code/CodeWorkspaceSearch.svelte +234 -0
  114. package/dist/components/scenes/code/CodeWorkspaceSearch.svelte.d.ts +23 -0
  115. package/dist/components/scenes/code/CodeWorkspaceTree.svelte +519 -0
  116. package/dist/components/scenes/code/CodeWorkspaceTree.svelte.d.ts +26 -0
  117. package/dist/components/scenes/code/code-editor.d.ts +12 -0
  118. package/dist/components/scenes/code/code-editor.js +93 -0
  119. package/dist/components/scenes/code/code-types.d.ts +346 -0
  120. package/dist/components/scenes/code/code-types.js +1 -0
  121. package/dist/components/scenes/code/index.d.ts +2 -0
  122. package/dist/components/scenes/code/index.js +1 -0
  123. package/dist/components/scenes/code/workers/css.worker.d.ts +1 -0
  124. package/dist/components/scenes/code/workers/css.worker.js +1 -0
  125. package/dist/components/scenes/code/workers/editor.worker.d.ts +1 -0
  126. package/dist/components/scenes/code/workers/editor.worker.js +1 -0
  127. package/dist/components/scenes/code/workers/html.worker.d.ts +1 -0
  128. package/dist/components/scenes/code/workers/html.worker.js +1 -0
  129. package/dist/components/scenes/code/workers/json.worker.d.ts +1 -0
  130. package/dist/components/scenes/code/workers/json.worker.js +1 -0
  131. package/dist/components/scenes/code/workers/ts.worker.d.ts +1 -0
  132. package/dist/components/scenes/code/workers/ts.worker.js +1 -0
  133. package/dist/components/scenes/crud/CrudDetailDrawer.svelte +6 -2
  134. package/dist/components/scenes/crud/CrudDetailPanel.svelte +6 -2
  135. package/dist/components/scenes/crud/CrudEditPanel.svelte +41 -12
  136. package/dist/components/scenes/crud/CrudPage.svelte +34 -9
  137. package/dist/components/scenes/crud/crud-controller.svelte.js +23 -8
  138. package/dist/components/scenes/crud/crud-form-validation.js +27 -9
  139. package/dist/components/scenes/crypto/EncryptedInput.svelte +9 -3
  140. package/dist/components/scenes/error/error-presets.js +30 -5
  141. package/dist/components/scenes/guide/GuideHostContent.svelte +7 -1
  142. package/dist/components/scenes/guide/HelpCenter.svelte +23 -4
  143. package/dist/components/scenes/iam/AgreementNotice.svelte +9 -3
  144. package/dist/components/scenes/iam/AuthPanel.svelte +74 -16
  145. package/dist/components/scenes/iam/ChangePasswordForm.svelte +6 -2
  146. package/dist/components/scenes/iam/ForgotPasswordForm.svelte +9 -3
  147. package/dist/components/scenes/iam/LoginForm.svelte +32 -8
  148. package/dist/components/scenes/iam/PasswordInput.svelte +50 -12
  149. package/dist/components/scenes/iam/RegisterForm.svelte +11 -3
  150. package/dist/components/scenes/iam/ResetPasswordForm.svelte +6 -2
  151. package/dist/components/scenes/iam/SensitiveOperationsForm.svelte +3 -1
  152. package/dist/components/scenes/iam/SessionRecoveryDialog.svelte +4 -1
  153. package/dist/components/scenes/iam/UserProfile.svelte +41 -14
  154. package/dist/components/scenes/iam/auth-captcha.js +9 -2
  155. package/dist/components/scenes/iam/auth-error-message.d.ts +2 -2
  156. package/dist/components/scenes/iam/auth-error-message.js +16 -3
  157. package/dist/components/scenes/iam/password-utils.js +9 -2
  158. package/dist/components/scenes/iam/sensitive-actions.svelte.js +4 -1
  159. package/dist/components/scenes/index.d.ts +2 -0
  160. package/dist/components/scenes/index.js +4 -0
  161. package/dist/components/scenes/storage/FileList.svelte +3 -1
  162. package/dist/components/scenes/storage/FileUpload.svelte +7 -2
  163. package/dist/components/scenes/tools/ArtifactWorkspace.svelte +561 -0
  164. package/dist/components/scenes/tools/ArtifactWorkspace.svelte.d.ts +17 -0
  165. package/dist/components/scenes/tools/ToolWorkspace.svelte +435 -0
  166. package/dist/components/scenes/tools/ToolWorkspace.svelte.d.ts +17 -0
  167. package/dist/components/scenes/tools/artifact-data.d.ts +35 -0
  168. package/dist/components/scenes/tools/artifact-data.js +127 -0
  169. package/dist/components/scenes/tools/artifact-markdown.d.ts +58 -0
  170. package/dist/components/scenes/tools/artifact-markdown.js +308 -0
  171. package/dist/components/scenes/tools/artifact-preview.d.ts +9 -0
  172. package/dist/components/scenes/tools/artifact-preview.js +31 -0
  173. package/dist/components/scenes/tools/index.d.ts +4 -0
  174. package/dist/components/scenes/tools/index.js +3 -0
  175. package/dist/components/scenes/tools/tool-form.d.ts +74 -0
  176. package/dist/components/scenes/tools/tool-form.js +179 -0
  177. package/dist/components/scenes/tools/workspace-types.d.ts +221 -0
  178. package/dist/components/scenes/tools/workspace-types.js +1 -0
  179. package/dist/components/scenes/types.d.ts +2 -2
  180. package/dist/guide-storage.js +12 -4
  181. package/dist/guide.svelte.js +59 -16
  182. package/dist/i18n.svelte.js +9 -3
  183. package/dist/internal/dialog-focus.d.ts +19 -0
  184. package/dist/internal/dialog-focus.js +104 -4
  185. package/dist/internal/form-validation.svelte.js +46 -15
  186. package/dist/internal/icon-safety.js +6 -2
  187. package/dist/message.svelte.js +6 -2
  188. package/dist/messagebox.svelte.js +6 -2
  189. package/dist/messages/en-US.json +158 -2
  190. package/dist/messages/ja-JP.json +158 -2
  191. package/dist/messages/zh-CN.json +158 -2
  192. package/dist/styles/eye-care.css +55 -0
  193. package/dist/styles/global.css +16 -0
  194. package/dist/styles/theme.css +1 -0
  195. package/dist/theme-config.d.ts +1 -3
  196. package/dist/theme-config.js +137 -22
  197. package/dist/toast.svelte.js +27 -7
  198. package/dist/types.d.ts +3 -3
  199. package/dist/utils.js +6 -2
  200. package/package.json +31 -19
@@ -0,0 +1,116 @@
1
+ import type { DataAttributes } from '../../../../types.js';
2
+ /**
3
+ * 项目脑图持久化协议,不暴露 Mind Elixir 的内部数据形状。
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import type { AiMindMapNode } from '@h-ai/ui'
8
+ * const node: AiMindMapNode = { id: 'root', text: '中心主题', children: [] }
9
+ * ```
10
+ */
11
+ export interface AiMindMapNode {
12
+ /** 在同一脑图生命周期内稳定且全图唯一的节点 ID。 */
13
+ id: string;
14
+ /** 用户可见的纯文本节点内容。 */
15
+ text: string;
16
+ /** 按兄弟节点展示顺序排列的子节点。 */
17
+ children: AiMindMapNode[];
18
+ }
19
+ /**
20
+ * 由 Mate 领域校验后交给框架编辑器的 mind/v1 数据。
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import type { AiMindMapData } from '@h-ai/ui'
25
+ * const data: AiMindMapData = { kind: 'mind/v1', layout: 'right', root: { id: 'root', text: '中心主题', children: [] } }
26
+ * ```
27
+ */
28
+ export interface AiMindMapData {
29
+ /** 固定协议标识,未知协议不会交给引擎编辑。 */
30
+ kind: 'mind/v1';
31
+ /** 首版支持的根分支布局。 */
32
+ layout: 'right' | 'left' | 'both';
33
+ /** 脑图唯一根节点。 */
34
+ root: AiMindMapNode;
35
+ }
36
+ /**
37
+ * 编辑器发出的完整数据快照及变更来源。
38
+ *
39
+ * @example
40
+ * ```ts
41
+ * import type { AiMindMapChangePayload } from '@h-ai/ui'
42
+ * const payload: AiMindMapChangePayload = { data: { kind: 'mind/v1', layout: 'right', root: { id: 'root', text: '中心主题', children: [] } }, reason: 'edit' }
43
+ * ```
44
+ */
45
+ export interface AiMindMapChangePayload {
46
+ /** 可直接持久化的项目协议快照。 */
47
+ data: AiMindMapData;
48
+ /** 编辑器观察到的引擎操作类型,仅作诊断信息,不保证标识具体用户操作来源。 */
49
+ reason: string;
50
+ }
51
+ /**
52
+ * 编辑器导出动作使用的格式标识。
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * import type { AiMindMapExportFormat } from '@h-ai/ui'
57
+ * const format: AiMindMapExportFormat = 'json'
58
+ * ```
59
+ */
60
+ export type AiMindMapExportFormat = 'json' | 'csv' | 'xlsx' | 'xmind';
61
+ /**
62
+ * 当前画布的稳定节点选择及其改写范围。
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * import type { AiMindMapSelection } from '@h-ai/ui'
67
+ * const selection: AiMindMapSelection = { nodeIds: ['root'], scope: 'subtree', text: '中心主题' }
68
+ * ```
69
+ */
70
+ export interface AiMindMapSelection {
71
+ /** 按画布选择顺序去重后的稳定节点 ID。 */
72
+ nodeIds: string[];
73
+ /** 当前编辑首版按选中节点及后代改写。 */
74
+ scope: 'subtree';
75
+ /** 供用户识别引用目标的简短摘要。 */
76
+ text: string;
77
+ }
78
+ /**
79
+ * AiMindMapEditor 受控属性。
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * import type { AiMindMapEditorProps } from '@h-ai/ui'
84
+ * const props: AiMindMapEditorProps = { data: { kind: 'mind/v1', layout: 'right', root: { id: 'root', text: '中心主题', children: [] } }, artifactKey: 'mind-1' }
85
+ * ```
86
+ */
87
+ export interface AiMindMapEditorProps extends DataAttributes {
88
+ /** 宿主追加到编辑器根节点的布局类名。 */
89
+ class?: string;
90
+ /** 经 mind/v1 校验的完整脑图;同一 artifactKey 下替换时重置引擎历史。 */
91
+ data: AiMindMapData;
92
+ /** 产物身份变化时清理上一个实例的本地编辑历史。 */
93
+ artifactKey: string;
94
+ /** 面板标题,由宿主 Artifact 元数据提供。 */
95
+ title?: string;
96
+ /** false 时禁用编辑和写入操作,同时保留导航能力。 */
97
+ editable?: boolean;
98
+ /** 是否为深色主题,用于与宿主工作区保持一致。 */
99
+ dark?: boolean;
100
+ /** 宿主提供的保存状态;空值时不占用工具栏空间。 */
101
+ saveState?: string;
102
+ /** 真实内容变化后通知宿主保存;视口变化不会触发此回调。 */
103
+ onchange?: (payload: AiMindMapChangePayload) => void;
104
+ /** 初始化或数据适配失败时报告错误,避免显示可编辑的空白画布。 */
105
+ onerror?: (error: Error) => void;
106
+ /** 请求宿主先冲刷保存,再从传入的同一快照生成文件。 */
107
+ onexport?: (format: AiMindMapExportFormat, data: AiMindMapData) => void | Promise<void>;
108
+ /** 关闭当前产物查看器;调用前编辑器会先提交活动中的节点输入。 */
109
+ onclose?: () => void;
110
+ /** 把选中的项目 JSON 正文交给宿主校验并写入当前脑图草稿。 */
111
+ onimportjson?: (content: string) => void | Promise<void>;
112
+ /** 选择变化时回传节点 ID;不触发数据保存。 */
113
+ onselectionchange?: (selection: AiMindMapSelection | null) => void;
114
+ /** 请求宿主把当前节点/分支放入原聊天输入框,不直接调用模型。 */
115
+ onrewrite?: (selection: AiMindMapSelection) => void;
116
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -99,7 +99,9 @@ function escapeHtmlText(text) {
99
99
  */
100
100
  export function sanitizeLinkHref(href) {
101
101
  const normalized = href?.trim() ?? '';
102
- return SAFE_LINK_HREF_REGEX.test(normalized) ? normalized : '';
102
+ return SAFE_LINK_HREF_REGEX.test(normalized)
103
+ ? normalized
104
+ : '';
103
105
  }
104
106
  /**
105
107
  * 识别外部链接,供渲染器添加相应的 rel/target 安全属性。
@@ -126,7 +128,9 @@ export function isExternalLinkHref(href) {
126
128
  */
127
129
  export function sanitizeImageSrc(src) {
128
130
  const normalized = src?.trim() ?? '';
129
- return SAFE_IMAGE_SRC_REGEX.test(normalized) ? normalized : '';
131
+ return SAFE_IMAGE_SRC_REGEX.test(normalized)
132
+ ? normalized
133
+ : '';
130
134
  }
131
135
  function sanitizeAlignValue(value) {
132
136
  const normalized = value?.trim().toLowerCase();
@@ -276,7 +280,9 @@ function sanitizeHtmlTag(rawTag) {
276
280
  return escapeHtml(rawTag);
277
281
  }
278
282
  if (isClosingTag) {
279
- return VOID_HTML_TAGS.has(tagName) ? '' : `</${tagName}>`;
283
+ return VOID_HTML_TAGS.has(tagName)
284
+ ? ''
285
+ : `</${tagName}>`;
280
286
  }
281
287
  const attributes = readSanitizedAttributes(tagName, rawAttributes);
282
288
  const renderedAttributes = [];
@@ -230,7 +230,9 @@
230
230
  }
231
231
 
232
232
  function normalizeColumnType(value: unknown): AiTableColumnType {
233
- return value === 'number' || value === 'tag' ? value : 'text'
233
+ return value === 'number' || value === 'tag'
234
+ ? value
235
+ : 'text'
234
236
  }
235
237
 
236
238
  function serializeTableDataForComparison(
@@ -265,7 +267,9 @@
265
267
 
266
268
  const key = typeof item.key === 'string' && item.key.trim()
267
269
  ? item.key.trim()
268
- : (typeof item.name === 'string' ? item.name.trim() : '')
270
+ : (typeof item.name === 'string'
271
+ ? item.name.trim()
272
+ : '')
269
273
  if (!key || usedKeys.has(key)) {
270
274
  continue
271
275
  }
@@ -515,10 +519,14 @@
515
519
  if (isRecord(parsedWhole)) {
516
520
  const columns = Array.isArray(parsedWhole.table_columns)
517
521
  ? normalizeTableColumns(parsedWhole.table_columns)
518
- : (Array.isArray(parsedWhole.columns) ? normalizeTableColumns(parsedWhole.columns) : [])
522
+ : (Array.isArray(parsedWhole.columns)
523
+ ? normalizeTableColumns(parsedWhole.columns)
524
+ : [])
519
525
  const rows = Array.isArray(parsedWhole.table_rows)
520
526
  ? normalizeTableRows(parsedWhole.table_rows)
521
- : (Array.isArray(parsedWhole.rows) ? normalizeTableRows(parsedWhole.rows) : [])
527
+ : (Array.isArray(parsedWhole.rows)
528
+ ? normalizeTableRows(parsedWhole.rows)
529
+ : [])
522
530
 
523
531
  if (columns.length > 0 || rows.length > 0) {
524
532
  return {
@@ -540,8 +548,12 @@
540
548
  return null
541
549
  }
542
550
 
543
- const columns = columnsChunk ? parseTableColumnsFromChunk(columnsChunk) : []
544
- const rows = rowsChunk ? parseTableRowsFromChunk(rowsChunk) : []
551
+ const columns = columnsChunk
552
+ ? parseTableColumnsFromChunk(columnsChunk)
553
+ : []
554
+ const rows = rowsChunk
555
+ ? parseTableRowsFromChunk(rowsChunk)
556
+ : []
545
557
  if (columns.length === 0 && rows.length === 0) {
546
558
  return null
547
559
  }
@@ -781,7 +793,9 @@
781
793
  }
782
794
 
783
795
  const rowBounds = currentTarget.getBoundingClientRect()
784
- return event.clientY < rowBounds.top + rowBounds.height / 2 ? 'before' : 'after'
796
+ return event.clientY < rowBounds.top + rowBounds.height / 2
797
+ ? 'before'
798
+ : 'after'
785
799
  }
786
800
 
787
801
  function updateRowDropHint(rowId: string, event: DragEvent): void {
@@ -1067,7 +1081,9 @@
1067
1081
  function resolveBodyRowClass(rowId: string): string {
1068
1082
  return cn(
1069
1083
  'hai-ai-table-body-row',
1070
- draggingRowId === rowId ? 'hai-ai-table-body-row--dragging' : '',
1084
+ draggingRowId === rowId
1085
+ ? 'hai-ai-table-body-row--dragging'
1086
+ : '',
1071
1087
  isDropIndicatorVisible(rowId, 'before')
1072
1088
  ? 'hai-ai-table-body-row--drop-before'
1073
1089
  : '',
@@ -1175,7 +1191,9 @@
1175
1191
  <td>
1176
1192
  <input
1177
1193
  class={resolveCellInputClass(column.type)}
1178
- type={column.type === 'number' ? 'number' : 'text'}
1194
+ type={column.type === 'number'
1195
+ ? 'number'
1196
+ : 'text'}
1179
1197
  value={cellInputValue}
1180
1198
  title={cellInputValue}
1181
1199
  disabled={!editable}
@@ -1242,13 +1260,7 @@
1242
1260
 
1243
1261
  <style>
1244
1262
  .hai-ai-table-pane {
1245
- /*
1246
- 主题变量兼容层:
1247
- - hai-mate Web 端主要使用 daisyUI v5 的 `--color-*` 语义变量;
1248
- - 组件库内部分场景仍可能提供旧版 `--b1/--bc/--p` 通道变量;
1249
- - 这里统一抽象为 AiTableEditor 私有变量,确保在两套主题体系下都能稳定着色。
1250
- */
1251
- --hai-ai-table-bg: var(--color-base-100, var(--color-base-100, oklch(1 0 0)));
1263
+ --hai-ai-table-bg: var(--color-base-100, oklch(1 0 0));
1252
1264
  --hai-ai-table-bg-soft: var(--color-base-200, var(--color-base-200, oklch(0.97 0 0)));
1253
1265
  --hai-ai-table-fg: var(--color-base-content, var(--color-base-content, oklch(0.22 0 0)));
1254
1266
  --hai-ai-table-primary: var(--color-primary, var(--color-primary, oklch(0.62 0.2 258)));
@@ -27,7 +27,12 @@
27
27
 
28
28
  let {
29
29
  report,
30
- evidence = { items: [], total: 0, page: 1, pageSize: 20 },
30
+ evidence = {
31
+ items: [],
32
+ total: 0,
33
+ page: 1,
34
+ pageSize: 20,
35
+ },
31
36
  attachments = [],
32
37
  history = [],
33
38
  webhook,
@@ -78,13 +83,34 @@
78
83
  let errorId = $derived(evidenceQuery.errorId ?? '')
79
84
  let kind = $derived(evidenceQuery.kind ?? '')
80
85
  const tabs = $derived([
81
- { key: 'overview', label: uiM('feedback_overview') },
82
- { key: 'scene', label: uiM('feedback_scene') },
83
- { key: 'replay', label: uiM('feedback_replay') },
84
- { key: 'logs', label: uiM('feedback_logs') },
85
- { key: 'business', label: uiM('feedback_business') },
86
- { key: 'environment', label: uiM('feedback_environment') },
87
- { key: 'history', label: uiM('feedback_history') },
86
+ {
87
+ key: 'overview',
88
+ label: uiM('feedback_overview'),
89
+ },
90
+ {
91
+ key: 'scene',
92
+ label: uiM('feedback_scene'),
93
+ },
94
+ {
95
+ key: 'replay',
96
+ label: uiM('feedback_replay'),
97
+ },
98
+ {
99
+ key: 'logs',
100
+ label: uiM('feedback_logs'),
101
+ },
102
+ {
103
+ key: 'business',
104
+ label: uiM('feedback_business'),
105
+ },
106
+ {
107
+ key: 'environment',
108
+ label: uiM('feedback_environment'),
109
+ },
110
+ {
111
+ key: 'history',
112
+ label: uiM('feedback_history'),
113
+ },
88
114
  ])
89
115
 
90
116
  async function run(action: (() => void | Promise<void>) | undefined) {
@@ -103,7 +129,10 @@
103
129
  }
104
130
  }
105
131
  async function query(next: Partial<FeedbackEvidenceQuery>) {
106
- evidenceQuery = { ...evidenceQuery, ...next }
132
+ evidenceQuery = {
133
+ ...evidenceQuery,
134
+ ...next,
135
+ }
107
136
  const generation = ++queryGeneration
108
137
  querying = true
109
138
  actionError = ''
@@ -120,18 +149,41 @@
120
149
  }
121
150
  }
122
151
  function changeTab(tab: string) {
123
- if (tab === 'environment')
124
- void query({ page: 1, kind: 'environment', requestId: undefined, errorId: undefined })
125
- else if (tab === 'scene')
126
- void query({ page: 1, kind: 'interaction', requestId: undefined, errorId: undefined })
127
- else if (tab === 'logs')
152
+ if (tab === 'environment') {
153
+ void query({
154
+ page: 1,
155
+ kind: 'environment',
156
+ requestId: undefined,
157
+ errorId: undefined,
158
+ })
159
+ }
160
+ else if (tab === 'scene') {
161
+ void query({
162
+ page: 1,
163
+ kind: 'interaction',
164
+ requestId: undefined,
165
+ errorId: undefined,
166
+ })
167
+ }
168
+ else if (tab === 'logs') {
128
169
  void query({ page: 1, kind: undefined })
129
- else if (tab === 'business')
130
- void query({ page: 1, kind: 'business', requestId: undefined, errorId: undefined })
170
+ }
171
+ else if (tab === 'business') {
172
+ void query({
173
+ page: 1,
174
+ kind: 'business',
175
+ requestId: undefined,
176
+ errorId: undefined,
177
+ })
178
+ }
131
179
  }
132
180
  useToastFeedback(() => error || actionError)
133
- useToastFeedback(() => permissions.read === false ? uiM('feedback_permission_denied') : '', 'warning')
134
- useToastFeedback(() => failedPreviews.length ? uiM('feedback_preview_failed') : '', 'warning')
181
+ useToastFeedback(() => permissions.read === false
182
+ ? uiM('feedback_permission_denied')
183
+ : '', 'warning')
184
+ useToastFeedback(() => failedPreviews.length
185
+ ? uiM('feedback_preview_failed')
186
+ : '', 'warning')
135
187
  </script>
136
188
 
137
189
  <section {...dataAttributes} class={`feedback-detail min-w-0 space-y-4 ${className}`} aria-label={uiM('feedback_details')}>
@@ -139,7 +191,11 @@
139
191
  <header class='flex flex-wrap items-center justify-between gap-3'>
140
192
  <div class='min-w-0'><h2 class='text-xl font-semibold break-all'>{report.number}</h2><p class='text-sm text-base-content/65'>{report.appId} · {report.appVersion || '—'} · {feedbackTime(report.createdAt)}</p></div>
141
193
  <div class='flex flex-wrap items-center gap-2'>
142
- <Badge variant={report.status === 'handled' ? 'success' : 'ghost'}>{uiM(report.status === 'handled' ? 'feedback_handled' : 'feedback_pending')}</Badge>
194
+ <Badge variant={report.status === 'handled'
195
+ ? 'success'
196
+ : 'ghost'}>{uiM(report.status === 'handled'
197
+ ? 'feedback_handled'
198
+ : 'feedback_pending')}</Badge>
143
199
  {#if permissions.export && onexport}<Button size='sm' disabled={busy} onclick={() => run(() => onexport(report!))}>{uiM('feedback_export')}</Button>{/if}
144
200
  {#if onclose}<Button size='sm' variant='ghost' onclick={onclose}>{uiM('feedback_close')}</Button>{/if}
145
201
  </div>
@@ -154,7 +210,11 @@
154
210
  <div><dt class='text-base-content/55'>{uiM('feedback_collection')}</dt><dd>{collectionLabel(report.collectionStatus)}</dd></div>
155
211
  <div><dt class='text-base-content/55'>{uiM('feedback_notification')}</dt><dd>{notificationLabel(report.notificationStatus)}</dd></div>
156
212
  {#if webhook}
157
- <div><dt class='text-base-content/55'>{uiM('feedback_webhook')}</dt><dd>{notificationLabel(webhook.status === 'succeeded' ? 'sent' : webhook.status === 'running' ? 'sending' : webhook.status)} · {uiM('feedback_attempts')}: {webhook.attempts}</dd>{#if webhook.lastError}<dd><Button variant='ghost' size='sm' onclick={() => toast.error(webhook!.lastError!)}>{uiM('toast_diagnostics')}</Button></dd>{/if}</div>
213
+ <div><dt class='text-base-content/55'>{uiM('feedback_webhook')}</dt><dd>{notificationLabel(webhook.status === 'succeeded'
214
+ ? 'sent'
215
+ : webhook.status === 'running'
216
+ ? 'sending'
217
+ : webhook.status)} · {uiM('feedback_attempts')}: {webhook.attempts}</dd>{#if webhook.lastError}<dd><Button variant='ghost' size='sm' onclick={() => toast.error(webhook!.lastError!)}>{uiM('toast_diagnostics')}</Button></dd>{/if}</div>
158
218
  {/if}
159
219
  <div><dt class='text-base-content/55'>{uiM('feedback_submitter')}</dt><dd class='break-all'>{report.userId || '—'}</dd></div>
160
220
  <div><dt class='text-base-content/55'>{uiM('feedback_revision')}</dt><dd>{report.evidenceRevision}</dd></div>
@@ -186,7 +246,12 @@
186
246
  {#if tab === 'logs'}
187
247
  <form onsubmit={(event) => {
188
248
  event.preventDefault()
189
- void query({ page: 1, kind: kind || undefined, requestId: requestId || undefined, errorId: errorId || undefined })
249
+ void query({
250
+ page: 1,
251
+ kind: kind || undefined,
252
+ requestId: requestId || undefined,
253
+ errorId: errorId || undefined,
254
+ })
190
255
  }}>
191
256
  <FormLayout columns={2}>
192
257
  <FormField label={uiM('feedback_kind')}><Input bind:value={kind} /></FormField>
@@ -212,16 +277,29 @@
212
277
  {#if onstatus && ((report.status === 'pending' && permissions.process) || (report.status === 'handled' && permissions.reopen))}
213
278
  <form class='space-y-3' onsubmit={(event) => {
214
279
  event.preventDefault()
215
- void run(() => onstatus({ id: report!.id, status: report!.status === 'pending' ? 'handled' : 'pending', expectedVersion: report!.version, note: note.trim() || undefined }))
280
+ void run(() => onstatus({
281
+ id: report!.id,
282
+ status: report!.status === 'pending'
283
+ ? 'handled'
284
+ : 'pending',
285
+ expectedVersion: report!.version,
286
+ note: note.trim() || undefined,
287
+ }))
216
288
  }}>
217
289
  <FormLayout><FormField label={uiM('feedback_note')}><Textarea bind:value={note} maxlength={4000} disabled={busy} /></FormField></FormLayout>
218
- <Button type='submit' variant='primary' loading={busy}>{uiM(report.status === 'pending' ? 'feedback_handle' : 'feedback_reopen')}</Button>
290
+ <Button type='submit' variant='primary' loading={busy}>{uiM(report.status === 'pending'
291
+ ? 'feedback_handle'
292
+ : 'feedback_reopen')}</Button>
219
293
  </form>
220
294
  {/if}
221
295
  {#if permissions.retry && onretry && (report.notificationStatus === 'failed' || report.collectionStatus === 'partial' || report.collectionStatus === 'failed')}<Button size='sm' disabled={busy} onclick={() => run(() => onretry(report!))}>{uiM('feedback_retry')}</Button>{/if}
222
296
  <ol class='space-y-3'>
223
297
  {#each history as change (change.id)}
224
- <li class='rounded-lg border border-base-content/10 p-3 text-sm'><p class='text-base-content/60'>{feedbackTime(change.createdAt)} · {change.actorId}</p><p>{uiM(change.fromStatus === 'handled' ? 'feedback_handled' : 'feedback_pending')} → {uiM(change.toStatus === 'handled' ? 'feedback_handled' : 'feedback_pending')}</p>{#if change.note}<p class='mt-1 whitespace-pre-wrap break-words'>{change.note}</p>{/if}</li>
298
+ <li class='rounded-lg border border-base-content/10 p-3 text-sm'><p class='text-base-content/60'>{feedbackTime(change.createdAt)} · {change.actorId}</p><p>{uiM(change.fromStatus === 'handled'
299
+ ? 'feedback_handled'
300
+ : 'feedback_pending')} → {uiM(change.toStatus === 'handled'
301
+ ? 'feedback_handled'
302
+ : 'feedback_pending')}</p>{#if change.note}<p class='mt-1 whitespace-pre-wrap break-words'>{change.note}</p>{/if}</li>
225
303
  {/each}
226
304
  </ol>
227
305
  </div>
@@ -115,15 +115,37 @@
115
115
  let previousKey = $state(untrack(() => resetKey))
116
116
  const visibleAttachments = $derived(attachments.filter(item => !removedAttachmentIds.includes(item.id)))
117
117
  const attachmentBytes = $derived(visibleAttachments.reduce((total, file) => total + (file.size ?? 0), 0))
118
- const recordingBytes = $derived(budget ? Math.max(0, Math.min(budget.maxAttachmentBytes, budget.maxAttachmentsBytes - attachmentBytes)) : undefined)
119
- const attachmentLimitReached = $derived(budget ? visibleAttachments.length >= budget.maxAttachmentCount || attachmentBytes >= budget.maxAttachmentsBytes : false)
118
+ const recordingBytes = $derived(budget
119
+ ? Math.max(0, Math.min(budget.maxAttachmentBytes, budget.maxAttachmentsBytes - attachmentBytes))
120
+ : undefined)
121
+ const attachmentLimitReached = $derived(budget
122
+ ? visibleAttachments.length >= budget.maxAttachmentCount || attachmentBytes >= budget.maxAttachmentsBytes
123
+ : false)
120
124
  const materialGroups = $derived([
121
- { label: uiM('feedback_environment'), kinds: ['environment'] },
122
- { label: uiM('feedback_logs'), kinds: ['log', 'error', 'request'] },
123
- { label: uiM('feedback_scene'), kinds: ['interaction', 'snapshot', 'business'] },
124
- { label: uiM('feedback_replay'), kinds: ['replay'] },
125
- { label: uiM('feedback_missing'), kinds: ['missing'] },
126
- ].map(group => ({ ...group, items: evidence.filter(item => group.kinds.includes(item.kind)) })).filter(group => group.items.length))
125
+ {
126
+ label: uiM('feedback_environment'),
127
+ kinds: ['environment'],
128
+ },
129
+ {
130
+ label: uiM('feedback_logs'),
131
+ kinds: ['log', 'error', 'request'],
132
+ },
133
+ {
134
+ label: uiM('feedback_scene'),
135
+ kinds: ['interaction', 'snapshot', 'business'],
136
+ },
137
+ {
138
+ label: uiM('feedback_replay'),
139
+ kinds: ['replay'],
140
+ },
141
+ {
142
+ label: uiM('feedback_missing'),
143
+ kinds: ['missing'],
144
+ },
145
+ ].map(group => ({
146
+ ...group,
147
+ items: evidence.filter(item => group.kinds.includes(item.kind)),
148
+ })).filter(group => group.items.length))
127
149
  const typeOptions = $derived([
128
150
  { value: 'bug', label: labels.types?.bug ?? uiM('feedback_type_bug') },
129
151
  { value: 'feature', label: labels.types?.feature ?? uiM('feedback_type_feature') },
@@ -145,7 +167,13 @@
145
167
  })
146
168
 
147
169
  function values(): FeedbackFormData {
148
- return { description: description.trim(), type: feedbackType, contact: contact.trim() || undefined, files: [...files], removedAttachmentIds: [...removedAttachmentIds] }
170
+ return {
171
+ description: description.trim(),
172
+ type: feedbackType,
173
+ contact: contact.trim() || undefined,
174
+ files: [...files],
175
+ removedAttachmentIds: [...removedAttachmentIds],
176
+ }
149
177
  }
150
178
 
151
179
  async function submit(event: SubmitEvent) {
@@ -222,7 +250,10 @@
222
250
  }
223
251
 
224
252
  function selectFiles(event: Event & { currentTarget: HTMLInputElement }) {
225
- files = [...files, ...Array.from(event.currentTarget.files ?? [])]
253
+ files = [
254
+ ...files,
255
+ ...Array.from(event.currentTarget.files ?? []),
256
+ ]
226
257
  // 清空原生选择值允许再次选择同名文件,不绑定浏览器的文件路径。
227
258
  event.currentTarget.value = ''
228
259
  if (onfileschange)
@@ -243,13 +274,20 @@
243
274
  await stageFiles()
244
275
  }
245
276
  useToastFeedback(() => error)
246
- useToastFeedback(() => receipt ? uiM('feedback_accepted', { number: receipt.number }) : '', 'success')
277
+ useToastFeedback(() => receipt
278
+ ? uiM('feedback_accepted', { number: receipt.number })
279
+ : '', 'success')
247
280
  </script>
248
281
 
249
282
  <form {...dataAttributes} class={`feedback-form flex min-h-0 min-w-0 flex-1 flex-col gap-4 ${className}`} onsubmit={submit} data-feedback-ui='true' data-feedback-ignore='true'>
250
283
  <div class='min-h-0 flex-1 space-y-4 overflow-y-auto'>
251
284
  {#if budget}
252
- <p class='text-xs text-base-content/60'>{uiM('feedback_capacity_hint', { used: (attachments.filter(item => !removedAttachmentIds.includes(item.id)).reduce((sum, item) => sum + (item.size ?? 0), 0) / 1048576).toFixed(1), total: (budget.maxAttachmentsBytes / 1048576).toFixed(1), single: (budget.maxAttachmentBytes / 1048576).toFixed(1), count: budget.maxAttachmentCount })}</p>
285
+ <p class='text-xs text-base-content/60'>{uiM('feedback_capacity_hint', {
286
+ used: (attachments.filter(item => !removedAttachmentIds.includes(item.id)).reduce((sum, item) => sum + (item.size ?? 0), 0) / 1048576).toFixed(1),
287
+ total: (budget.maxAttachmentsBytes / 1048576).toFixed(1),
288
+ single: (budget.maxAttachmentBytes / 1048576).toFixed(1),
289
+ count: budget.maxAttachmentCount,
290
+ })}</p>
253
291
  {/if}
254
292
  {#if receipt}
255
293
  <div data-testid='feedback-receipt' class='rounded-lg border border-base-content/10 bg-base-200/50 p-4 space-y-2 break-words'>
@@ -287,7 +325,9 @@
287
325
  <Button size='xs' variant='ghost' disabled={loading || annotating || exporting} ariaLabel={`${uiM('feedback_remove')} ${attachment.name}`} onclick={() => removedAttachmentIds = [...removedAttachmentIds, attachment.id]}>{uiM('feedback_remove')}</Button>
288
326
  </div>
289
327
  </div>
290
- {#if attachment.mimeType?.startsWith('image/') && attachment.url}<FeedbackScreenshot {attachment} onannotate={!loading && !exporting && !staging && onannotate ? annotate : undefined} />{/if}
328
+ {#if attachment.mimeType?.startsWith('image/') && attachment.url}<FeedbackScreenshot {attachment} onannotate={!loading && !exporting && !staging && onannotate
329
+ ? annotate
330
+ : undefined} />{/if}
291
331
  {#if attachment.mimeType?.startsWith('video/') && attachment.url}<!-- svelte-ignore a11y_media_has_caption (用户上传的无声录屏) -->
292
332
  <video src={attachment.url} controls preload='metadata' class='max-w-full rounded' aria-label={attachment.name}></video>{/if}
293
333
  {#if attachment.missingReason}<Button size='sm' variant='ghost' onclick={() => toast.warning(`${uiM('feedback_missing')}: ${attachment.missingReason}`)}>{uiM('feedback_missing')}</Button>{/if}
@@ -313,7 +353,9 @@
313
353
  <dt class='font-medium'>{group.label} · {group.items.length}</dt>
314
354
  <dd class='space-y-2 pt-2'>
315
355
  {#each group.items as item (item.id)}
316
- <details class='rounded bg-base-200 p-2' ontoggle={event => expandedMaterials = event.currentTarget.open ? [...expandedMaterials, item.id] : expandedMaterials.filter(id => id !== item.id)}>
356
+ <details class='rounded bg-base-200 p-2' ontoggle={event => expandedMaterials = event.currentTarget.open
357
+ ? [...expandedMaterials, item.id]
358
+ : expandedMaterials.filter(id => id !== item.id)}>
317
359
  <summary class='cursor-pointer break-all text-xs'>{feedbackTime(item.timestamp)} · {item.kind} · {item.source} #{item.sequence}</summary>
318
360
  {#if expandedMaterials.includes(item.id)}<pre class='mt-2 max-h-64 max-w-full overflow-auto whitespace-pre-wrap break-all text-xs'>{evidenceText(item.data)}</pre>{/if}
319
361
  </details>
@@ -322,7 +364,17 @@
322
364
  </div>
323
365
  {/each}
324
366
  {#each evidenceSummary as item, index (`${item.label}:${index}`)}
325
- <div class='min-w-0'><dt class='font-medium'>{item.label}{item.count === undefined ? '' : ` · ${item.count}`}</dt><dd class='text-base-content/65 break-words'>{item.status === 'missing' ? uiM('feedback_missing') : item.status === 'not-applicable' ? uiM('feedback_not_applicable') : item.status === 'partial' ? uiM('feedback_partial') : uiM('feedback_complete')}{item.detail ? ` · ${item.detail}` : ''}</dd></div>
367
+ <div class='min-w-0'><dt class='font-medium'>{item.label}{item.count === undefined
368
+ ? ''
369
+ : ` · ${item.count}`}</dt><dd class='text-base-content/65 break-words'>{item.status === 'missing'
370
+ ? uiM('feedback_missing')
371
+ : item.status === 'not-applicable'
372
+ ? uiM('feedback_not_applicable')
373
+ : item.status === 'partial'
374
+ ? uiM('feedback_partial')
375
+ : uiM('feedback_complete')}{item.detail
376
+ ? ` · ${item.detail}`
377
+ : ''}</dd></div>
326
378
  {/each}
327
379
  </dl>
328
380
  </details>
@@ -331,7 +383,9 @@
331
383
  </div>
332
384
  <div class='shrink-0 flex flex-wrap justify-end gap-2 border-t border-base-content/10 bg-base-100 pt-4 pb-2'>
333
385
  {#if onexport}<Button variant='ghost' loading={exporting} disabled={annotating || staging} onclick={saveLocal}>{uiM('feedback_local_export')}</Button>{/if}
334
- {#if oncancel}<Button variant='ghost' onclick={oncancel}>{receipt ? uiM('feedback_close') : labels.cancel ?? uiM('feedback_cancel')}</Button>{/if}
386
+ {#if oncancel}<Button variant='ghost' onclick={oncancel}>{receipt
387
+ ? uiM('feedback_close')
388
+ : labels.cancel ?? uiM('feedback_cancel')}</Button>{/if}
335
389
  {#if !receipt}<Button type='submit' variant='primary' loading={loading || staging} disabled={annotating || exporting || recording || Boolean(onfileschange && filesError)}>{labels.submit ?? uiM('feedback_submit')}</Button>{/if}
336
390
  </div>
337
391
  </form>