@docyrus/ui-pro-ai-assistant 0.0.2 → 0.0.5

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 (314) hide show
  1. package/dist/components/assistant-animations.d.ts +3 -3
  2. package/dist/docy-assistant.d.ts +1 -1
  3. package/dist/index.js +74 -47
  4. package/dist/index.js.map +1 -1
  5. package/dist/styles.css +5137 -0
  6. package/dist/types/index.d.ts +3 -3
  7. package/dist/views/assistant-view.d.ts +2 -2
  8. package/package.json +38 -36
  9. package/src/components/assistant-animations.tsx +0 -29
  10. package/src/components/assistant-dialogs.tsx +0 -235
  11. package/src/components/code-view.tsx +0 -278
  12. package/src/components/create-agent-task.tsx +0 -104
  13. package/src/components/create-new-work-version.tsx +0 -30
  14. package/src/components/extract-web.tsx +0 -160
  15. package/src/components/forward-to-agent.tsx +0 -90
  16. package/src/components/generate-chart.tsx +0 -101
  17. package/src/components/generative-action-button.tsx +0 -122
  18. package/src/components/generative-tool.tsx +0 -685
  19. package/src/components/generative-ui-object.tsx +0 -210
  20. package/src/components/input-area.tsx +0 -1209
  21. package/src/components/json-schema-layout.tsx +0 -326
  22. package/src/components/list-item-card.tsx +0 -92
  23. package/src/components/mermaid-diagram.tsx +0 -192
  24. package/src/components/preview-image.tsx +0 -47
  25. package/src/components/request-approval.tsx +0 -48
  26. package/src/components/request-user-input.tsx +0 -270
  27. package/src/components/search-web.tsx +0 -319
  28. package/src/components/sheet-command.tsx +0 -88
  29. package/src/components/shell-canvas.tsx +0 -122
  30. package/src/components/show-advanced-data-table.tsx +0 -352
  31. package/src/components/show-generated-content-options.tsx +0 -93
  32. package/src/components/show-people-cards.tsx +0 -180
  33. package/src/components/subagent-tool.tsx +0 -180
  34. package/src/components/text-editor-tool.tsx +0 -328
  35. package/src/components/work-canvas.tsx +0 -88
  36. package/src/components/work-card.tsx +0 -42
  37. package/src/declarations.d.ts +0 -1
  38. package/src/docy-assistant.tsx +0 -1962
  39. package/src/hooks/index.ts +0 -7
  40. package/src/hooks/use-assistant-api.ts +0 -507
  41. package/src/hooks/use-deployment-data.ts +0 -162
  42. package/src/hooks/use-project-state.ts +0 -347
  43. package/src/hooks/use-session-state.ts +0 -207
  44. package/src/hooks/use-speech-recognition.ts +0 -137
  45. package/src/hooks/use-ui-state.ts +0 -185
  46. package/src/hooks/use-works-state.ts +0 -146
  47. package/src/i18n/context.tsx +0 -253
  48. package/src/i18n/index.ts +0 -19
  49. package/src/i18n/locales/de.json +0 -198
  50. package/src/i18n/locales/el.json +0 -198
  51. package/src/i18n/locales/en.json +0 -226
  52. package/src/i18n/locales/es.json +0 -198
  53. package/src/i18n/locales/fr.json +0 -198
  54. package/src/i18n/locales/it.json +0 -198
  55. package/src/i18n/locales/pt.json +0 -198
  56. package/src/i18n/locales/sl.json +0 -198
  57. package/src/i18n/locales/tr.json +0 -211
  58. package/src/i18n/types.ts +0 -23
  59. package/src/i18n/use-translation.ts +0 -17
  60. package/src/index.ts +0 -18
  61. package/src/internal/plate-editor/editor/auth-context.ts +0 -11
  62. package/src/internal/plate-editor/editor/editor-base-kit.tsx +0 -39
  63. package/src/internal/plate-editor/editor/editor-kit.tsx +0 -89
  64. package/src/internal/plate-editor/editor/plate-editor.tsx +0 -75
  65. package/src/internal/plate-editor/editor/plate-types.ts +0 -126
  66. package/src/internal/plate-editor/editor/plugins/ai-kit.tsx +0 -172
  67. package/src/internal/plate-editor/editor/plugins/autoformat-kit.tsx +0 -211
  68. package/src/internal/plate-editor/editor/plugins/basic-blocks-base-kit.tsx +0 -26
  69. package/src/internal/plate-editor/editor/plugins/basic-blocks-kit.tsx +0 -51
  70. package/src/internal/plate-editor/editor/plugins/basic-marks-base-kit.tsx +0 -24
  71. package/src/internal/plate-editor/editor/plugins/basic-marks-kit.tsx +0 -38
  72. package/src/internal/plate-editor/editor/plugins/basic-nodes-kit.tsx +0 -6
  73. package/src/internal/plate-editor/editor/plugins/block-menu-kit.tsx +0 -14
  74. package/src/internal/plate-editor/editor/plugins/block-placeholder-kit.tsx +0 -17
  75. package/src/internal/plate-editor/editor/plugins/block-selection-kit.tsx +0 -31
  76. package/src/internal/plate-editor/editor/plugins/callout-base-kit.tsx +0 -5
  77. package/src/internal/plate-editor/editor/plugins/callout-kit.tsx +0 -7
  78. package/src/internal/plate-editor/editor/plugins/code-block-base-kit.tsx +0 -23
  79. package/src/internal/plate-editor/editor/plugins/code-block-kit.tsx +0 -26
  80. package/src/internal/plate-editor/editor/plugins/column-base-kit.tsx +0 -8
  81. package/src/internal/plate-editor/editor/plugins/column-kit.tsx +0 -7
  82. package/src/internal/plate-editor/editor/plugins/comment-base-kit.tsx +0 -5
  83. package/src/internal/plate-editor/editor/plugins/comment-kit.tsx +0 -174
  84. package/src/internal/plate-editor/editor/plugins/copilot-kit.tsx +0 -68
  85. package/src/internal/plate-editor/editor/plugins/cursor-overlay-kit.tsx +0 -13
  86. package/src/internal/plate-editor/editor/plugins/date-base-kit.tsx +0 -5
  87. package/src/internal/plate-editor/editor/plugins/date-kit.tsx +0 -7
  88. package/src/internal/plate-editor/editor/plugins/discussion-kit.tsx +0 -36
  89. package/src/internal/plate-editor/editor/plugins/dnd-kit.tsx +0 -27
  90. package/src/internal/plate-editor/editor/plugins/docx-export-kit.tsx +0 -43
  91. package/src/internal/plate-editor/editor/plugins/docx-kit.tsx +0 -6
  92. package/src/internal/plate-editor/editor/plugins/emoji-kit.tsx +0 -15
  93. package/src/internal/plate-editor/editor/plugins/exit-break-kit.tsx +0 -12
  94. package/src/internal/plate-editor/editor/plugins/floating-toolbar-kit.tsx +0 -19
  95. package/src/internal/plate-editor/editor/plugins/font-base-kit.tsx +0 -36
  96. package/src/internal/plate-editor/editor/plugins/font-kit.tsx +0 -47
  97. package/src/internal/plate-editor/editor/plugins/indent-base-kit.tsx +0 -19
  98. package/src/internal/plate-editor/editor/plugins/indent-kit.tsx +0 -22
  99. package/src/internal/plate-editor/editor/plugins/link-base-kit.tsx +0 -5
  100. package/src/internal/plate-editor/editor/plugins/link-kit.tsx +0 -35
  101. package/src/internal/plate-editor/editor/plugins/list-base-kit.tsx +0 -24
  102. package/src/internal/plate-editor/editor/plugins/list-kit.tsx +0 -27
  103. package/src/internal/plate-editor/editor/plugins/markdown-kit.tsx +0 -18
  104. package/src/internal/plate-editor/editor/plugins/math-base-kit.tsx +0 -8
  105. package/src/internal/plate-editor/editor/plugins/math-kit.tsx +0 -10
  106. package/src/internal/plate-editor/editor/plugins/media-base-kit.tsx +0 -37
  107. package/src/internal/plate-editor/editor/plugins/media-kit.tsx +0 -53
  108. package/src/internal/plate-editor/editor/plugins/mention-base-kit.tsx +0 -5
  109. package/src/internal/plate-editor/editor/plugins/mention-kit.tsx +0 -36
  110. package/src/internal/plate-editor/editor/plugins/slash-kit.tsx +0 -17
  111. package/src/internal/plate-editor/editor/plugins/suggestion-base-kit.tsx +0 -5
  112. package/src/internal/plate-editor/editor/plugins/suggestion-kit.tsx +0 -95
  113. package/src/internal/plate-editor/editor/plugins/table-base-kit.tsx +0 -20
  114. package/src/internal/plate-editor/editor/plugins/table-kit.tsx +0 -22
  115. package/src/internal/plate-editor/editor/plugins/toc-base-kit.tsx +0 -5
  116. package/src/internal/plate-editor/editor/plugins/toc-kit.tsx +0 -14
  117. package/src/internal/plate-editor/editor/plugins/toggle-base-kit.tsx +0 -5
  118. package/src/internal/plate-editor/editor/plugins/toggle-kit.tsx +0 -9
  119. package/src/internal/plate-editor/editor/transforms.ts +0 -165
  120. package/src/internal/plate-editor/editor/use-chat.ts +0 -152
  121. package/src/internal/plate-editor/hooks/index.ts +0 -3
  122. package/src/internal/plate-editor/hooks/use-copy-to-clipboard.ts +0 -31
  123. package/src/internal/plate-editor/hooks/use-is-touch-device.ts +0 -26
  124. package/src/internal/plate-editor/hooks/use-lock-scroll.ts +0 -21
  125. package/src/internal/plate-editor/hooks/use-media-query.ts +0 -44
  126. package/src/internal/plate-editor/hooks/use-mounted.ts +0 -18
  127. package/src/internal/plate-editor/hooks/use-on-click-outside.ts +0 -114
  128. package/src/internal/plate-editor/hooks/use-upload-file.ts +0 -81
  129. package/src/internal/plate-editor/i18n/context.tsx +0 -58
  130. package/src/internal/plate-editor/i18n/index.ts +0 -3
  131. package/src/internal/plate-editor/i18n/locales/de.json +0 -57
  132. package/src/internal/plate-editor/i18n/locales/el.json +0 -57
  133. package/src/internal/plate-editor/i18n/locales/en.json +0 -57
  134. package/src/internal/plate-editor/i18n/locales/es.json +0 -57
  135. package/src/internal/plate-editor/i18n/locales/fr.json +0 -57
  136. package/src/internal/plate-editor/i18n/locales/it.json +0 -57
  137. package/src/internal/plate-editor/i18n/locales/pt.json +0 -57
  138. package/src/internal/plate-editor/i18n/locales/sl.json +0 -57
  139. package/src/internal/plate-editor/i18n/locales/tr.json +0 -57
  140. package/src/internal/plate-editor/i18n/types.ts +0 -59
  141. package/src/internal/plate-editor/i18n/use-translation.ts +0 -22
  142. package/src/internal/plate-editor/index.ts +0 -39
  143. package/src/internal/plate-editor/lib/ai-output-converter.ts +0 -153
  144. package/src/internal/plate-editor/lib/download-file.ts +0 -17
  145. package/src/internal/plate-editor/plate-ui/ai-chat-editor.tsx +0 -24
  146. package/src/internal/plate-editor/plate-ui/ai-menu.tsx +0 -828
  147. package/src/internal/plate-editor/plate-ui/ai-node.tsx +0 -41
  148. package/src/internal/plate-editor/plate-ui/ai-toolbar-button.tsx +0 -25
  149. package/src/internal/plate-editor/plate-ui/alert-dialog.tsx +0 -145
  150. package/src/internal/plate-editor/plate-ui/align-toolbar-button.tsx +0 -88
  151. package/src/internal/plate-editor/plate-ui/avatar.tsx +0 -3
  152. package/src/internal/plate-editor/plate-ui/block-context-menu.tsx +0 -104
  153. package/src/internal/plate-editor/plate-ui/block-discussion.tsx +0 -364
  154. package/src/internal/plate-editor/plate-ui/block-draggable.tsx +0 -557
  155. package/src/internal/plate-editor/plate-ui/block-list-static.tsx +0 -77
  156. package/src/internal/plate-editor/plate-ui/block-list.tsx +0 -85
  157. package/src/internal/plate-editor/plate-ui/block-menu.tsx +0 -555
  158. package/src/internal/plate-editor/plate-ui/block-selection.tsx +0 -47
  159. package/src/internal/plate-editor/plate-ui/block-suggestion.tsx +0 -469
  160. package/src/internal/plate-editor/plate-ui/blockquote-node-static.tsx +0 -10
  161. package/src/internal/plate-editor/plate-ui/blockquote-node.tsx +0 -11
  162. package/src/internal/plate-editor/plate-ui/button.tsx +0 -201
  163. package/src/internal/plate-editor/plate-ui/calendar.tsx +0 -3
  164. package/src/internal/plate-editor/plate-ui/callout-node-static.tsx +0 -76
  165. package/src/internal/plate-editor/plate-ui/callout-node.tsx +0 -54
  166. package/src/internal/plate-editor/plate-ui/caption.tsx +0 -47
  167. package/src/internal/plate-editor/plate-ui/checkbox.tsx +0 -3
  168. package/src/internal/plate-editor/plate-ui/code-block-node-static.tsx +0 -172
  169. package/src/internal/plate-editor/plate-ui/code-block-node.tsx +0 -226
  170. package/src/internal/plate-editor/plate-ui/code-node-static.tsx +0 -11
  171. package/src/internal/plate-editor/plate-ui/code-node.tsx +0 -12
  172. package/src/internal/plate-editor/plate-ui/column-node-static.tsx +0 -65
  173. package/src/internal/plate-editor/plate-ui/column-node.tsx +0 -24
  174. package/src/internal/plate-editor/plate-ui/command.tsx +0 -202
  175. package/src/internal/plate-editor/plate-ui/comment-node-static.tsx +0 -12
  176. package/src/internal/plate-editor/plate-ui/comment-node.tsx +0 -45
  177. package/src/internal/plate-editor/plate-ui/comment-toolbar-button.tsx +0 -24
  178. package/src/internal/plate-editor/plate-ui/comment.tsx +0 -619
  179. package/src/internal/plate-editor/plate-ui/cursor-overlay.tsx +0 -85
  180. package/src/internal/plate-editor/plate-ui/date-node-static.tsx +0 -43
  181. package/src/internal/plate-editor/plate-ui/date-node.tsx +0 -54
  182. package/src/internal/plate-editor/plate-ui/dialog.tsx +0 -445
  183. package/src/internal/plate-editor/plate-ui/dropdown-menu.tsx +0 -264
  184. package/src/internal/plate-editor/plate-ui/editor-static.tsx +0 -40
  185. package/src/internal/plate-editor/plate-ui/editor.tsx +0 -146
  186. package/src/internal/plate-editor/plate-ui/emoji-node.tsx +0 -48
  187. package/src/internal/plate-editor/plate-ui/emoji-toolbar-button.tsx +0 -626
  188. package/src/internal/plate-editor/plate-ui/equation-node-static.tsx +0 -155
  189. package/src/internal/plate-editor/plate-ui/equation-node.tsx +0 -226
  190. package/src/internal/plate-editor/plate-ui/equation-toolbar-button.tsx +0 -26
  191. package/src/internal/plate-editor/plate-ui/export-toolbar-button.tsx +0 -206
  192. package/src/internal/plate-editor/plate-ui/fixed-toolbar-buttons.tsx +0 -157
  193. package/src/internal/plate-editor/plate-ui/fixed-toolbar.tsx +0 -25
  194. package/src/internal/plate-editor/plate-ui/floating-discussion.tsx +0 -1129
  195. package/src/internal/plate-editor/plate-ui/floating-toolbar-buttons.tsx +0 -129
  196. package/src/internal/plate-editor/plate-ui/floating-toolbar.tsx +0 -97
  197. package/src/internal/plate-editor/plate-ui/font-color-toolbar-button.tsx +0 -209
  198. package/src/internal/plate-editor/plate-ui/font-size-toolbar-button.tsx +0 -152
  199. package/src/internal/plate-editor/plate-ui/ghost-text.tsx +0 -20
  200. package/src/internal/plate-editor/plate-ui/heading-node-static.tsx +0 -52
  201. package/src/internal/plate-editor/plate-ui/heading-node.tsx +0 -56
  202. package/src/internal/plate-editor/plate-ui/highlight-node-static.tsx +0 -9
  203. package/src/internal/plate-editor/plate-ui/highlight-node.tsx +0 -11
  204. package/src/internal/plate-editor/plate-ui/history-toolbar-button.tsx +0 -50
  205. package/src/internal/plate-editor/plate-ui/hover-card.tsx +0 -7
  206. package/src/internal/plate-editor/plate-ui/hr-node-static.tsx +0 -18
  207. package/src/internal/plate-editor/plate-ui/hr-node.tsx +0 -28
  208. package/src/internal/plate-editor/plate-ui/import-toolbar-button.tsx +0 -122
  209. package/src/internal/plate-editor/plate-ui/indent-toolbar-button.tsx +0 -32
  210. package/src/internal/plate-editor/plate-ui/inline-combobox.tsx +0 -409
  211. package/src/internal/plate-editor/plate-ui/input.tsx +0 -37
  212. package/src/internal/plate-editor/plate-ui/insert-toolbar-button.tsx +0 -258
  213. package/src/internal/plate-editor/plate-ui/label.tsx +0 -1
  214. package/src/internal/plate-editor/plate-ui/line-height-toolbar-button.tsx +0 -69
  215. package/src/internal/plate-editor/plate-ui/link-node-static.tsx +0 -15
  216. package/src/internal/plate-editor/plate-ui/link-node.tsx +0 -33
  217. package/src/internal/plate-editor/plate-ui/link-toolbar-button.tsx +0 -28
  218. package/src/internal/plate-editor/plate-ui/link-toolbar.tsx +0 -147
  219. package/src/internal/plate-editor/plate-ui/list-toolbar-button.tsx +0 -177
  220. package/src/internal/plate-editor/plate-ui/mark-toolbar-button.tsx +0 -34
  221. package/src/internal/plate-editor/plate-ui/media-audio-node-static.tsx +0 -21
  222. package/src/internal/plate-editor/plate-ui/media-audio-node.tsx +0 -32
  223. package/src/internal/plate-editor/plate-ui/media-embed-node.tsx +0 -103
  224. package/src/internal/plate-editor/plate-ui/media-file-node-static.tsx +0 -30
  225. package/src/internal/plate-editor/plate-ui/media-file-node.tsx +0 -52
  226. package/src/internal/plate-editor/plate-ui/media-image-node-static.tsx +0 -37
  227. package/src/internal/plate-editor/plate-ui/media-image-node.tsx +0 -183
  228. package/src/internal/plate-editor/plate-ui/media-placeholder-node.tsx +0 -441
  229. package/src/internal/plate-editor/plate-ui/media-preview-dialog.tsx +0 -127
  230. package/src/internal/plate-editor/plate-ui/media-toolbar-button.tsx +0 -227
  231. package/src/internal/plate-editor/plate-ui/media-toolbar.tsx +0 -214
  232. package/src/internal/plate-editor/plate-ui/media-upload-toast.tsx +0 -73
  233. package/src/internal/plate-editor/plate-ui/media-video-node-static.tsx +0 -35
  234. package/src/internal/plate-editor/plate-ui/media-video-node.tsx +0 -119
  235. package/src/internal/plate-editor/plate-ui/mention-node-static.tsx +0 -46
  236. package/src/internal/plate-editor/plate-ui/mention-node.tsx +0 -79
  237. package/src/internal/plate-editor/plate-ui/menu.tsx +0 -539
  238. package/src/internal/plate-editor/plate-ui/mode-toolbar-button.tsx +0 -124
  239. package/src/internal/plate-editor/plate-ui/more-toolbar-button.tsx +0 -34
  240. package/src/internal/plate-editor/plate-ui/paragraph-node-static.tsx +0 -15
  241. package/src/internal/plate-editor/plate-ui/paragraph-node.tsx +0 -16
  242. package/src/internal/plate-editor/plate-ui/popover.tsx +0 -75
  243. package/src/internal/plate-editor/plate-ui/progress.tsx +0 -1
  244. package/src/internal/plate-editor/plate-ui/remote-cursor-overlay.tsx +0 -79
  245. package/src/internal/plate-editor/plate-ui/resize-handle.tsx +0 -86
  246. package/src/internal/plate-editor/plate-ui/separator.tsx +0 -41
  247. package/src/internal/plate-editor/plate-ui/slash-node.tsx +0 -433
  248. package/src/internal/plate-editor/plate-ui/spinner.tsx +0 -1
  249. package/src/internal/plate-editor/plate-ui/suggestion-node-static.tsx +0 -35
  250. package/src/internal/plate-editor/plate-ui/suggestion-node.tsx +0 -166
  251. package/src/internal/plate-editor/plate-ui/suggestion-toolbar-button.tsx +0 -24
  252. package/src/internal/plate-editor/plate-ui/table-node-static.tsx +0 -84
  253. package/src/internal/plate-editor/plate-ui/table-node.tsx +0 -283
  254. package/src/internal/plate-editor/plate-ui/table-toolbar-button.tsx +0 -252
  255. package/src/internal/plate-editor/plate-ui/tabs.tsx +0 -3
  256. package/src/internal/plate-editor/plate-ui/textarea.tsx +0 -57
  257. package/src/internal/plate-editor/plate-ui/toc-node-static.tsx +0 -142
  258. package/src/internal/plate-editor/plate-ui/toc-node.tsx +0 -57
  259. package/src/internal/plate-editor/plate-ui/toc-sidebar.tsx +0 -48
  260. package/src/internal/plate-editor/plate-ui/toggle-node-static.tsx +0 -18
  261. package/src/internal/plate-editor/plate-ui/toggle-node.tsx +0 -33
  262. package/src/internal/plate-editor/plate-ui/toggle-toolbar-button.tsx +0 -24
  263. package/src/internal/plate-editor/plate-ui/toggle.tsx +0 -3
  264. package/src/internal/plate-editor/plate-ui/toolbar.tsx +0 -378
  265. package/src/internal/plate-editor/plate-ui/tooltip.tsx +0 -148
  266. package/src/internal/plate-editor/plate-ui/turn-into-toolbar-button.tsx +0 -175
  267. package/src/internal/plate-editor/types/index.ts +0 -22
  268. package/src/internal/plate-editor/vite.ts +0 -284
  269. package/src/internal/sheets/components/univer-sheets.tsx +0 -1104
  270. package/src/internal/sheets/i18n/context.tsx +0 -183
  271. package/src/internal/sheets/i18n/index.ts +0 -19
  272. package/src/internal/sheets/i18n/locales/de.json +0 -21
  273. package/src/internal/sheets/i18n/locales/el.json +0 -21
  274. package/src/internal/sheets/i18n/locales/en.json +0 -21
  275. package/src/internal/sheets/i18n/locales/es.json +0 -21
  276. package/src/internal/sheets/i18n/locales/fr.json +0 -21
  277. package/src/internal/sheets/i18n/locales/it.json +0 -21
  278. package/src/internal/sheets/i18n/locales/pt.json +0 -21
  279. package/src/internal/sheets/i18n/locales/sl.json +0 -21
  280. package/src/internal/sheets/i18n/locales/tr.json +0 -21
  281. package/src/internal/sheets/i18n/types.ts +0 -23
  282. package/src/internal/sheets/i18n/use-translation.ts +0 -17
  283. package/src/internal/sheets/index.ts +0 -14
  284. package/src/internal/sheets/types/css.d.ts +0 -11
  285. package/src/internal/sheets/types/index.ts +0 -260
  286. package/src/internal/sheets/xlsx.ts +0 -1169
  287. package/src/lib/api-client.ts +0 -77
  288. package/src/lib/assistant-api-actions.ts +0 -549
  289. package/src/lib/assistant-config.tsx +0 -75
  290. package/src/lib/class-utils.ts +0 -40
  291. package/src/lib/index.ts +0 -7
  292. package/src/lib/message-utils.ts +0 -131
  293. package/src/tools/tools-schema.json +0 -512
  294. package/src/types/index.ts +0 -235
  295. package/src/views/assistant-view.tsx +0 -1137
  296. package/src/views/canvas-app.tsx +0 -839
  297. package/src/views/canvas-code.tsx +0 -93
  298. package/src/views/canvas-deep-research.tsx +0 -44
  299. package/src/views/canvas-image.tsx +0 -25
  300. package/src/views/canvas-record-view.tsx +0 -285
  301. package/src/views/canvas-spreadsheet.tsx +0 -125
  302. package/src/views/canvas-text.tsx +0 -52
  303. package/src/views/canvas.tsx +0 -274
  304. package/src/views/chat-panel.tsx +0 -149
  305. package/src/views/index.ts +0 -20
  306. package/src/views/memories-panel.tsx +0 -365
  307. package/src/views/message-list.tsx +0 -370
  308. package/src/views/project-detail.tsx +0 -257
  309. package/src/views/projects-panel.tsx +0 -131
  310. package/src/views/sessions-list.tsx +0 -98
  311. package/src/views/sidebar-content.tsx +0 -256
  312. package/src/views/work-detail.tsx +0 -98
  313. package/src/vite.ts +0 -64
  314. package/src/worker.ts +0 -203
@@ -1,839 +0,0 @@
1
- 'use client';
2
-
3
- import { useState } from 'react';
4
-
5
- import {
6
- ChevronDown, ChevronRight, FolderOpen, LayoutDashboard, Menu, Table2
7
- } from 'lucide-react';
8
-
9
- import {
10
- Bar,
11
- BarChart,
12
- Cell,
13
- Legend,
14
- Line,
15
- LineChart,
16
- Pie,
17
- PieChart,
18
- ResponsiveContainer,
19
- Tooltip,
20
- XAxis,
21
- YAxis
22
- } from 'recharts';
23
-
24
- import { Button } from '@docyrus/ui-pro-shared/components/button';
25
- import { cn } from '@docyrus/ui-pro-shared/lib/utils';
26
-
27
- import { MermaidDiagram } from '../components/mermaid-diagram';
28
-
29
- /*
30
- * ─────────────────────────────────────────────────────────────
31
- * Mermaid generators (ported from mermaid-generator.js)
32
- * ─────────────────────────────────────────────────────────────
33
- */
34
-
35
- function generateLayoutDiagram(app: any): string {
36
- if (!app?.layout) return '';
37
- const { layout } = app;
38
- let d = 'graph LR\n';
39
- const menuArr: any[] = Array.isArray(layout.menu) ? layout.menu : Object.values(layout.menu ?? {});
40
- const widgetsArr: any[] = Array.isArray(layout.widgets) ? layout.widgets : Object.values(layout.widgets ?? {});
41
-
42
- d += ` App["${layout.title || 'App'}"]\n`;
43
- menuArr.forEach((item: any, i: number) => {
44
- const mid = `Menu_${i}`;
45
-
46
- d += ` subgraph cluster_${mid}\n direction TB\n ${mid}["${item.title || item.id}"]\n`;
47
- item.views?.forEach((v: any, j: number) => {
48
- const vid = `View_${i}_${j}`;
49
-
50
- d += ` ${vid}["${v.title || v.id} (${v.type})"]\n ${mid} --> ${vid}\n`;
51
- });
52
- d += ` end\n App --> ${mid}\n`;
53
- });
54
- if (widgetsArr.length > 0) {
55
- d += ` subgraph cluster_Widgets\n direction TB\n Widgets[Widgets]\n`;
56
- widgetsArr.forEach((w: any, i: number) => {
57
- d += ` Widget_${i}["${w.title || w.type}"]\n Widgets --> Widget_${i}\n`;
58
- });
59
- d += ` end\n App -.-> Widgets\n`;
60
- }
61
-
62
- return d;
63
- }
64
-
65
- function generateDataStructureDiagram(app: any): string {
66
- if (!app?.data_sources) return '';
67
-
68
- const dsArr: any[] = Array.isArray(app.data_sources) ? app.data_sources : Object.values(app.data_sources);
69
- let d = 'classDiagram\n direction TB\n';
70
- const idMap: Record<string, string> = {};
71
-
72
- dsArr.forEach((ds: any) => {
73
- const safe = (ds.name || ds.slug || 'DS').replace(/[^a-zA-Z0-9_]/g, '_');
74
- const key = ds.id || ds.slug || ds.name;
75
-
76
- if (key) idMap[key] = safe;
77
- });
78
- dsArr.forEach((ds: any) => {
79
- const safe = (ds.name || ds.slug || 'DS').replace(/[^a-zA-Z0-9_]/g, '_');
80
- const fieldsArr: any[] = Array.isArray(ds.fields) ? ds.fields : Object.values(ds.fields ?? {});
81
-
82
- d += ` class ${safe} {\n`;
83
- fieldsArr.forEach((f: any) => {
84
- d += ` +${f.type || 'string'} ${f.name || f.slug}\n`;
85
- });
86
- d += ' }\n';
87
- fieldsArr.forEach((f: any) => {
88
- if (f.type === 'field-relation' && f.relationDataSourceId) {
89
- const target = idMap[f.relationDataSourceId];
90
-
91
- if (target) d += ` ${safe} --> ${target} : ${f.name || f.slug}\n`;
92
- }
93
- });
94
- });
95
-
96
- return d;
97
- }
98
-
99
- /*
100
- * ─────────────────────────────────────────────────────────────
101
- * AppSidebar
102
- * ─────────────────────────────────────────────────────────────
103
- */
104
-
105
- function AppSidebar({
106
- data, title, onMenuClick
107
- }: {
108
- data: any[];
109
- title?: string;
110
- onMenuClick: (id: string) => void;
111
- }) {
112
- const [collapsed, setCollapsed] = useState(false);
113
- const [expanded, setExpanded] = useState<Set<string>>(new Set());
114
-
115
- const toggleFolder = (id: string) => {
116
- if (collapsed) {
117
- setCollapsed(false);
118
- setExpanded(prev => new Set([...prev, id]));
119
-
120
- return;
121
- }
122
- setExpanded((prev) => {
123
- const next = new Set(prev);
124
-
125
- next.has(id) ? next.delete(id) : next.add(id);
126
-
127
- return next;
128
- });
129
- };
130
-
131
- return (
132
- <aside
133
- className={cn(
134
- 'h-full bg-white border-r border-gray-200 transition-all duration-300 flex flex-col shrink-0',
135
- collapsed ? 'w-12' : 'w-52'
136
- )}>
137
- {/* Header */}
138
- <div className="flex items-center justify-between px-2 py-1.5 border-b border-gray-200 h-9 shrink-0">
139
- {!collapsed && (
140
- <span className="grow text-sm font-semibold text-gray-900 truncate mr-1">{title}</span>
141
- )}
142
- <Button
143
- variant="ghost"
144
- size="icon"
145
- className="h-6 w-6 shrink-0"
146
- onClick={() => setCollapsed(v => !v)}>
147
- <Menu className="size-3.5" />
148
- </Button>
149
- </div>
150
-
151
- {/* Nav */}
152
- <nav className="flex-1 overflow-y-auto p-1.5 space-y-0.5">
153
- {data.map((item: any) => {
154
- if (item.type === 'folder') {
155
- const isExp = expanded.has(item.id);
156
-
157
- return (
158
- <div key={item.id}>
159
- <button
160
- onClick={() => toggleFolder(item.id)}
161
- className="w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-gray-100 text-left text-sm">
162
- <FolderOpen className="size-4 text-gray-500 shrink-0" />
163
- {!collapsed && (
164
- <>
165
- <span className="flex-1 truncate text-gray-900 font-medium">{item.title}</span>
166
- {isExp ? <ChevronDown className="size-3 text-gray-400" /> : <ChevronRight className="size-3 text-gray-400" />}
167
- </>
168
- )}
169
- </button>
170
- {!collapsed && isExp && (
171
- <div className="ml-4 mt-0.5 space-y-0.5">
172
- {item.menu?.map((sub: any) => (
173
- <button
174
- key={sub.id}
175
- onClick={() => { onMenuClick(sub.id); }}
176
- className="w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-gray-100 text-left text-sm text-gray-700">
177
- <span className="truncate">{sub.title}</span>
178
- </button>
179
- ))}
180
- </div>
181
- )}
182
- </div>
183
- );
184
- }
185
-
186
- return (
187
- <button
188
- key={item.id}
189
- onClick={() => { onMenuClick(item.id); }}
190
- title={collapsed ? item.title : undefined}
191
- className="w-full flex items-center gap-2 px-2 py-1.5 rounded-md hover:bg-gray-100 text-left text-sm">
192
- <LayoutDashboard className="size-4 text-gray-500 shrink-0" />
193
- {!collapsed && (
194
- <span className="truncate text-gray-900 font-medium">{item.title}</span>
195
- )}
196
- </button>
197
- );
198
- })}
199
- </nav>
200
- </aside>
201
- );
202
- }
203
-
204
- /*
205
- * ─────────────────────────────────────────────────────────────
206
- * AppBoardView — simplified board (shows columns/fields as table)
207
- * ─────────────────────────────────────────────────────────────
208
- */
209
-
210
- function AppBoardView({ page, dataSources }: { page: any; dataSources: any[] }) {
211
- const [activeViewIdx, setActiveViewIdx] = useState(0);
212
- const views = page?.views ?? [];
213
- const activeView = views[activeViewIdx];
214
- const dsId = activeView?.config?.dataSourceId ?? activeView?.dataSourceId;
215
- const ds = dsId ? dataSources.find(
216
- (d: any) => d.id === dsId
217
- || d.slug === dsId
218
- || d.name === dsId
219
- ) ?? dataSources[0] ?? null : dataSources[0] ?? null;
220
-
221
- // Columns: from view config, falling back to data source fields
222
- const columns: any[] = activeView?.config?.columns ?? activeView?.columns ?? ds?.fields ?? [];
223
-
224
- // DEBUG
225
- console.info('[AppBoardView] dsId', dsId, 'ds.id', ds?.id, 'records', ds?.records?.length);
226
- console.info('[AppBoardView] columns[0]', columns[0], 'record[0] keys', Object.keys(ds?.records?.[0] ?? {}));
227
-
228
- // Records: dummy data from the data source
229
- const records: any[] = ds?.records ?? [];
230
-
231
- const getCellValue = (record: any, col: any): string => {
232
- // column.field is the primary key (from view config), fallback to slug/id/name
233
- const key = col.field || col.slug || col.id || col.name || col;
234
- const val = record[key];
235
-
236
- if (val === null || val === undefined) return '';
237
- // Relation fields: {id, name} → show name
238
- if (typeof val === 'object' && !Array.isArray(val)) return val.name ?? JSON.stringify(val);
239
- if (Array.isArray(val)) return val.map((v: any) => v?.name ?? v).join(', ');
240
-
241
- return String(val);
242
- };
243
-
244
- return (
245
- <div className="flex flex-col h-full w-full overflow-hidden">
246
- <div className="flex items-center gap-2 px-3 py-2 border-b bg-muted/30 shrink-0">
247
- <Table2 className="size-4 text-muted-foreground" />
248
- <span className="text-sm font-medium">{page.title}</span>
249
- </div>
250
- {views.length > 1 && (
251
- <div className="flex gap-1 px-3 py-1 border-b shrink-0">
252
- {views.map((v: any, i: number) => (
253
- <button
254
- key={v.id || i}
255
- onClick={() => setActiveViewIdx(i)}
256
- className={cn(
257
- 'px-2 py-0.5 rounded text-xs',
258
- activeViewIdx === i ? 'bg-primary text-primary-foreground' : 'hover:bg-muted text-muted-foreground'
259
- )}>
260
- {v.title || v.type}
261
- </button>
262
- ))}
263
- </div>
264
- )}
265
- <div className="flex-1 overflow-auto p-3">
266
- {columns.length > 0 ? (
267
- <table className="w-full text-xs border border-gray-200">
268
- <thead className="bg-gray-50">
269
- <tr>
270
- {columns.map((col: any, i: number) => (
271
- <th key={i} className="border border-gray-200 px-2 py-1 text-left font-medium text-gray-700">
272
- {col.name || col.title || col.slug || col}
273
- </th>
274
- ))}
275
- </tr>
276
- </thead>
277
- <tbody>
278
- {records.length > 0 ? records.map((record: any, ri: number) => (
279
- <tr key={ri} className="hover:bg-gray-50">
280
- {columns.map((col: any, ci: number) => (
281
- <td key={ci} className="border border-gray-200 px-2 py-1 max-w-[200px] truncate">
282
- {getCellValue(record, col)}
283
- </td>
284
- ))}
285
- </tr>
286
- )) : (
287
- <tr>
288
- {columns.map((_: any, i: number) => (
289
- <td key={i} className="border border-gray-200 px-2 py-1 text-gray-400 italic">—</td>
290
- ))}
291
- </tr>
292
- )}
293
- </tbody>
294
- </table>
295
- ) : (
296
- <div className="text-sm text-muted-foreground text-center py-8">
297
- {ds ? `Data source: ${ds.title || ds.slug}` : 'No view data available'}
298
- </div>
299
- )}
300
- </div>
301
- </div>
302
- );
303
- }
304
-
305
- /*
306
- * ─────────────────────────────────────────────────────────────
307
- * AppDashboardPreview — widget cards with dot background
308
- * ─────────────────────────────────────────────────────────────
309
- */
310
-
311
- function WidgetSummary({ widget }: { widget: any }) {
312
- const ds = widget.options?.dataSource;
313
- const records: any[] = ds?.records ?? [];
314
- const widgetType: string = widget.options?.type || widget.type || '';
315
- const normType = widgetType.toLowerCase().replace(/_/g, '');
316
-
317
- const dataConfig = widget.options?.dataConfig ?? {};
318
-
319
- // Calculations from dataConfig (each has func + field)
320
- const calculations: any[] = Array.isArray(dataConfig.calculations) ? dataConfig.calculations : [];
321
-
322
- // Group-by rows from dataConfig.fields.rows
323
- const rowFields: string[] = Array.isArray(dataConfig.fields?.rows) ? dataConfig.fields.rows : [];
324
- const groupField: string = rowFields[0] || '';
325
-
326
- // Primary metric: first calculation's field
327
- const primaryCalc = calculations[0];
328
- const metricField: string = primaryCalc?.field || '';
329
-
330
- console.info('[WidgetSummary]', widget.title, {
331
- widgetType, groupField, metricField, records: records.length
332
- });
333
-
334
- const isKpi = normType === 'chartstatistic'
335
- || normType.includes('kpi')
336
- || normType.includes('stat')
337
- || normType.includes('metric');
338
-
339
- // For KPI: sum of primary calc field
340
- const kpiValue = (() => {
341
- if (!metricField || records.length === 0) return null;
342
-
343
- if (primaryCalc?.func === 'count') return records.length;
344
-
345
- const sum = records.reduce((acc: number, r: any) => {
346
- const v = r[metricField];
347
- const num = typeof v === 'object' && v !== null ? Number(v.id ?? 0) : Number(v) || 0;
348
-
349
- return acc + num;
350
- }, 0);
351
-
352
- return sum;
353
- })();
354
-
355
- // For bar/pie charts: group records by rowField, aggregate by calc field
356
- const groups: [string, number][] = (() => {
357
- if (!groupField || records.length === 0) return [];
358
-
359
- const map: Record<string, number> = {};
360
-
361
- records.forEach((r: any) => {
362
- const rawKey = r[groupField];
363
- const label = typeof rawKey === 'object' && rawKey !== null ? (rawKey.name ?? String(rawKey.id ?? '—')) : String(rawKey ?? '—');
364
-
365
- const val = primaryCalc?.func === 'count' ? 1 : metricField ? (() => {
366
- const v = r[metricField];
367
-
368
- return typeof v === 'object' && v !== null ? Number(v.id ?? 0) : Number(v) || 0;
369
- })() : 1;
370
-
371
- map[label] = (map[label] || 0) + val;
372
- });
373
-
374
- return Object.entries(map).sort((a, b) => b[1] - a[1]).slice(0, 6);
375
- })();
376
-
377
- const COLORS = [
378
- '#6366f1',
379
- '#22d3ee',
380
- '#f59e0b',
381
- '#10b981',
382
- '#f43f5e',
383
- '#8b5cf6'
384
- ];
385
- const chartData = groups.map(([name, value]) => ({ name, value }));
386
-
387
- const isPie = normType.includes('pie') || normType.includes('donut');
388
- const isLine = normType.includes('line') || normType.includes('area');
389
- const isColumn = normType.includes('column');
390
-
391
- const metricLabel = primaryCalc?.name || metricField || 'Value';
392
-
393
- return (
394
- <div className="bg-white border border-gray-200 rounded-lg p-3 shadow-sm flex flex-col gap-1 min-h-[140px]">
395
- <div className="text-xs font-semibold text-gray-700 truncate">{widget.title || widget.type}</div>
396
-
397
- {isKpi && kpiValue !== null && (
398
- <div className="mt-auto">
399
- <div className="text-2xl font-bold text-gray-900">
400
- {kpiValue.toLocaleString(undefined, { maximumFractionDigits: 1 })}
401
- </div>
402
- <div className="text-[10px] text-muted-foreground">
403
- {metricLabel} · {records.length} records
404
- </div>
405
- </div>
406
- )}
407
-
408
- {isPie && chartData.length === 0 && records.length > 0 && (
409
- <div className="text-xs text-muted-foreground mt-auto py-2">
410
- {records.length} records · no group field configured
411
- </div>
412
- )}
413
-
414
- {isPie && chartData.length > 0 && (
415
- <div style={{ width: '100%', height: 160 }}>
416
- <ResponsiveContainer width="100%" height="100%">
417
- <PieChart>
418
- <Pie
419
- data={chartData}
420
- dataKey="value"
421
- nameKey="name"
422
- cx="50%"
423
- cy="50%"
424
- innerRadius={normType.includes('donut') ? 35 : 0}
425
- outerRadius={55}
426
- paddingAngle={2}>
427
- {chartData.map((_: any, i: number) => (
428
- <Cell key={i} fill={COLORS[i % COLORS.length]} />
429
- ))}
430
- </Pie>
431
- <Tooltip formatter={(v: any) => v.toLocaleString(undefined, { maximumFractionDigits: 1 })} />
432
- <Legend iconSize={8} wrapperStyle={{ fontSize: 10 }} />
433
- </PieChart>
434
- </ResponsiveContainer>
435
- </div>
436
- )}
437
-
438
- {isLine && chartData.length > 0 && (
439
- <div style={{ width: '100%', height: 110 }}>
440
- <ResponsiveContainer width="100%" height="100%">
441
- <LineChart
442
- data={chartData}
443
- margin={{
444
- top: 4, right: 4, left: -20, bottom: 0
445
- }}>
446
- <XAxis dataKey="name" tick={{ fontSize: 9 }} interval="preserveStartEnd" />
447
- <YAxis tick={{ fontSize: 9 }} />
448
- <Tooltip formatter={(v: any) => v.toLocaleString(undefined, { maximumFractionDigits: 1 })} />
449
- <Line type="monotone" dataKey="value" stroke="#6366f1" strokeWidth={2} dot={{ r: 3 }} name={metricLabel} />
450
- </LineChart>
451
- </ResponsiveContainer>
452
- </div>
453
- )}
454
-
455
- {(isColumn || (!isKpi && !isPie && !isLine)) && chartData.length > 0 && (
456
- <div style={{ width: '100%', height: 110 }}>
457
- <ResponsiveContainer width="100%" height="100%">
458
- <BarChart
459
- data={chartData}
460
- layout={isColumn ? 'vertical' : 'horizontal'}
461
- margin={{
462
- top: 4, right: 4, left: isColumn ? 40 : -20, bottom: 0
463
- }}>
464
- {isColumn ? (
465
- <>
466
- <XAxis type="number" tick={{ fontSize: 9 }} />
467
- <YAxis type="category" dataKey="name" tick={{ fontSize: 9 }} width={36} />
468
- </>
469
- ) : (
470
- <>
471
- <XAxis dataKey="name" tick={{ fontSize: 9 }} interval={0} />
472
- <YAxis tick={{ fontSize: 9 }} />
473
- </>
474
- )}
475
- <Tooltip formatter={(v: any) => v.toLocaleString(undefined, { maximumFractionDigits: 1 })} />
476
- <Bar
477
- dataKey="value"
478
- name={metricLabel}
479
- radius={[
480
- 3,
481
- 3,
482
- 0,
483
- 0
484
- ]}>
485
- {chartData.map((_: any, i: number) => (
486
- <Cell key={i} fill={COLORS[i % COLORS.length]} />
487
- ))}
488
- </Bar>
489
- </BarChart>
490
- </ResponsiveContainer>
491
- </div>
492
- )}
493
-
494
- {!isKpi && chartData.length > 0 && (
495
- <div className="text-[10px] text-muted-foreground">
496
- {metricLabel}{groupField ? ` by ${groupField}` : ''}
497
- </div>
498
- )}
499
-
500
- {kpiValue === null && chartData.length === 0 && (
501
- <div className="text-[10px] text-muted-foreground mt-auto">
502
- {records.length > 0 ? `${records.length} records` : 'No data'}
503
- </div>
504
- )}
505
- </div>
506
- );
507
- }
508
-
509
- function AppDashboardPreview({ page, widgets }: { page: any; widgets: any[] }) {
510
- return (
511
- <div className="flex flex-col h-full w-full overflow-hidden">
512
- <div className="flex items-center gap-2 px-3 py-2 border-b bg-muted/30 shrink-0">
513
- <LayoutDashboard className="size-4 text-muted-foreground" />
514
- <span className="text-sm font-medium">{page.title}</span>
515
- </div>
516
- <div
517
- className="flex-1 overflow-auto p-4"
518
- style={{
519
- background: 'radial-gradient(circle, #94a3b8 1.5px, transparent 1.5px) 0 0 / 22px 22px #f1f5f9'
520
- }}>
521
- <div className="grid grid-cols-2 gap-3">
522
- {widgets.map((widget: any, i: number) => (
523
- <WidgetSummary key={widget.id || i} widget={widget} />
524
- ))}
525
- {widgets.length === 0 && (
526
- <div className="col-span-2 text-sm text-muted-foreground text-center py-8">No widgets configured</div>
527
- )}
528
- </div>
529
- </div>
530
- </div>
531
- );
532
- }
533
-
534
- /*
535
- * ─────────────────────────────────────────────────────────────
536
- * AppPreviewDocument — mermaid diagrams + data structure table
537
- * ─────────────────────────────────────────────────────────────
538
- */
539
-
540
- function AppPreviewDocument({ app }: { app: any }) {
541
- const [tab, setTab] = useState(0);
542
- const tabs = ['Layout Structure', 'Data Structure Table', 'Data Structure Diagram'];
543
- const layoutDiagram = generateLayoutDiagram(app);
544
- const dataDiagram = generateDataStructureDiagram(app);
545
-
546
- return (
547
- <div className="flex flex-col h-full overflow-hidden">
548
- <div className="flex border-b shrink-0">
549
- {tabs.map((t, i) => (
550
- <button
551
- key={i}
552
- onClick={() => setTab(i)}
553
- className={cn(
554
- 'px-3 py-2 text-xs font-medium border-b-2 -mb-px',
555
- tab === i ? 'border-primary text-primary' : 'border-transparent text-muted-foreground hover:text-foreground'
556
- )}>
557
- {t}
558
- </button>
559
- ))}
560
- </div>
561
- <div className="flex-1 overflow-auto p-4">
562
- {tab === 0 && (
563
- <MermaidDiagram
564
- title="Layout Structure"
565
- mermaidNotation={layoutDiagram}
566
- state="output-available" />
567
- )}
568
- {tab === 2 && (
569
- <MermaidDiagram
570
- title="Data Structure Diagram"
571
- mermaidNotation={dataDiagram}
572
- state="output-available" />
573
- )}
574
- {tab === 1 && (
575
- <div className="text-sm space-y-6">
576
- <div>
577
- <h3 className="font-bold border-b pb-2 mb-3">Data Sources</h3>
578
- <table className="w-full border border-gray-200 text-xs">
579
- <thead className="bg-gray-50">
580
- <tr>
581
- {['Title', 'Name', 'Slug'].map(h => (
582
- <th key={h} className="border border-gray-200 px-2 py-1 text-left">{h}</th>
583
- ))}
584
- </tr>
585
- </thead>
586
- <tbody>
587
- {(Array.isArray(app?.data_sources) ? app.data_sources : Object.values(app?.data_sources ?? {})).map((ds: any) => (
588
- <tr key={ds.slug}>
589
- <td className="border border-gray-200 px-2 py-1">{ds.title}</td>
590
- <td className="border border-gray-200 px-2 py-1">{ds.name}</td>
591
- <td className="border border-gray-200 px-2 py-1">{ds.slug}</td>
592
- </tr>
593
- ))}
594
- </tbody>
595
- </table>
596
- </div>
597
-
598
- <div>
599
- <h3 className="font-bold border-b pb-2 mb-3">Fields</h3>
600
- {(Array.isArray(app?.data_sources) ? app.data_sources : Object.values(app?.data_sources ?? {})).map((ds: any) => (
601
- <div key={ds.slug} className="border border-gray-300 bg-gray-50 rounded p-3 mb-3">
602
- <div className="font-bold text-sm mb-2">
603
- {ds.title}
604
- {' '}
605
- <span className="text-muted-foreground font-normal text-xs">{ds.name}</span>
606
- </div>
607
- <table className="w-full border border-gray-200 text-xs bg-white">
608
- <thead className="bg-gray-50">
609
- <tr>
610
- {[
611
- 'Name',
612
- 'Slug',
613
- 'Type',
614
- 'Validations'
615
- ].map(h => (
616
- <th key={h} className="border border-gray-200 px-2 py-1 text-left">{h}</th>
617
- ))}
618
- </tr>
619
- </thead>
620
- <tbody>
621
- {ds.fields?.map((field: any) => (
622
- <tr key={field.id || field.slug}>
623
- <td className="border border-gray-200 px-2 py-1">{field.name}</td>
624
- <td className="border border-gray-200 px-2 py-1">{field.slug}</td>
625
- <td className="border border-gray-200 px-2 py-1">{field.type}</td>
626
- <td className="border border-gray-200 px-2 py-1 max-w-[200px] truncate">
627
- {JSON.stringify(field.validations)}
628
- </td>
629
- </tr>
630
- ))}
631
- </tbody>
632
- </table>
633
- </div>
634
- ))}
635
- </div>
636
- </div>
637
- )}
638
- </div>
639
- </div>
640
- );
641
- }
642
-
643
- /*
644
- * ─────────────────────────────────────────────────────────────
645
- * CanvasAppView — main export (mirrors KvCanvasAppPreview.vue)
646
- * ─────────────────────────────────────────────────────────────
647
- */
648
-
649
- interface CanvasAppViewProps {
650
- app: any;
651
- }
652
-
653
- export function CanvasAppView({ app }: CanvasAppViewProps) {
654
- // DEBUG — runs regardless of app being null
655
- console.info('[CanvasAppView] render, app=', app);
656
-
657
- const [activeTab, setActiveTab] = useState(0);
658
- const [activeMenuId, setActiveMenuId] = useState<string | null>(() => {
659
- const m = app?.layout?.menu;
660
-
661
- if (!m) return null;
662
-
663
- const first = Array.isArray(m) ? m[0] : Object.values(m)[0];
664
-
665
- return (first as any)?.id ?? null;
666
- });
667
-
668
- if (!app) {
669
- return (
670
- <div className="flex h-full items-center justify-center text-sm text-muted-foreground">
671
- No app data available
672
- </div>
673
- );
674
- }
675
-
676
- // Normalize values that may arrive as {0:{...},1:{...}} objects or proper arrays
677
- const toArray = (val: any): any[] => {
678
- if (!val) return [];
679
- if (Array.isArray(val)) return val;
680
- if (typeof val === 'object') return Object.values(val);
681
-
682
- return [];
683
- };
684
-
685
- const rawDataSources = toArray(app.data_sources);
686
- const rawWidgets = toArray(app.layout?.widgets);
687
- const menu = toArray(app.layout?.menu);
688
-
689
- // DEBUG
690
- console.info('[CanvasAppView] app.data_sources', app.data_sources);
691
- console.info('[CanvasAppView] app.layout.dummy_data_json', app.layout?.dummy_data_json);
692
-
693
- /*
694
- * Parse dummy data from layout (mirrors Vue's dummyData parsing)
695
- * Format can be either:
696
- * { "ds_slug": [...records], "other_slug": [...] } — keyed by data source slug
697
- * [...records] — flat array for single data source
698
- * dummy_data_json may be a JSON string or already a parsed object/array.
699
- */
700
- let dummyDataMap: Record<string, any[]> = {};
701
-
702
- try {
703
- const raw = app.layout?.dummy_data_json;
704
-
705
- if (raw) {
706
- const parsed = typeof raw === 'string' ? JSON.parse(raw) : raw;
707
-
708
- if (Array.isArray(parsed)) {
709
- // Flat array — assign to ALL possible keys for every data source
710
- rawDataSources.forEach((ds: any) => {
711
- if (ds.slug) dummyDataMap[ds.slug] = parsed;
712
- if (ds.id) dummyDataMap[ds.id] = parsed;
713
- if (ds.name) dummyDataMap[ds.name] = parsed;
714
- });
715
- dummyDataMap['__all__'] = parsed;
716
- } else if (parsed && typeof parsed === 'object') {
717
- // Keyed object (slug → records[])
718
- dummyDataMap = parsed;
719
- const firstArr = Object.values(parsed).find(v => Array.isArray(v));
720
-
721
- if (firstArr) dummyDataMap['__all__'] = firstArr as any[];
722
- }
723
- }
724
- } catch {
725
- // invalid JSON, skip
726
- }
727
-
728
- const findRecords = (ds: any): any[] => dummyDataMap[ds.slug]
729
- ?? dummyDataMap[ds.id]
730
- ?? dummyDataMap[ds.name]
731
- ?? dummyDataMap['__all__']
732
- ?? [];
733
-
734
- /*
735
- * Prepare data sources with normalized fields + dummy records.
736
- * Vue sets id = slug (useInlineDataSource({ id: ds.slug })), mirror that.
737
- */
738
- const dataSources = rawDataSources.map((ds: any) => ({
739
- ...ds,
740
- _originalId: ds.id, // keep UUID for widget lookup
741
- id: ds.slug || ds.id,
742
- slug: ds.slug || ds.id,
743
- fields: toArray(ds.fields).map((f: any) => ({
744
- ...f,
745
- id: f.id || f.slug,
746
- type: f.type?.replace('field-', '') ?? f.type
747
- })),
748
- records: findRecords(ds)
749
- }));
750
-
751
- const findDataSource = (id: string | undefined) => {
752
- if (!id) return undefined;
753
-
754
- return dataSources.find(
755
- (ds: any) => ds.id === id
756
- || ds.slug === id
757
- || ds.name === id
758
- || ds._originalId === id
759
- );
760
- };
761
-
762
- // Prepare widgets — resolve dataSource, clear dataConfig.meta as Vue does
763
- const widgets = rawWidgets.map((widget: any) => ({
764
- ...widget,
765
- options: {
766
- ...widget.options,
767
- dataConfig: { ...(widget.options?.dataConfig ?? {}), meta: [] },
768
- dataSource: findDataSource(widget.options?.dataSourceId ?? widget.dataSourceId)
769
- }
770
- }));
771
-
772
- const activeMenu = menu.find((m: any) => m.id === activeMenuId) ?? menu[0] ?? null;
773
-
774
- // DEBUG
775
- console.info('[CanvasAppView] dummyDataMap keys', Object.keys(dummyDataMap));
776
- console.info('[CanvasAppView] dataSources', dataSources.map((ds: any) => ({ id: ds.id, slug: ds.slug, records: ds.records?.length })));
777
- console.info('[CanvasAppView] widgets', widgets.map((w: any) => ({ title: w.title, dsId: w.options?.dataSourceId, resolved: !!w.options?.dataSource })));
778
- console.info('[CanvasAppView] menu activeMenu', activeMenu?.type, activeMenu?.id);
779
-
780
- const tabLabels = ['Preview', 'JSON', 'Docs'];
781
-
782
- return (
783
- <div className="flex flex-col h-full w-full overflow-hidden">
784
- {/* Tab bar */}
785
- <div className="flex border-b shrink-0 bg-background">
786
- {tabLabels.map((t, i) => (
787
- <button
788
- key={i}
789
- onClick={() => setActiveTab(i)}
790
- className={cn(
791
- 'px-4 py-2 text-xs font-medium border-b-2 -mb-px transition-colors',
792
- activeTab === i ? 'border-primary text-primary' : 'border-transparent text-muted-foreground hover:text-foreground'
793
- )}>
794
- {t}
795
- </button>
796
- ))}
797
- </div>
798
-
799
- {/* Tab 0: App preview */}
800
- {activeTab === 0 && (
801
- <div className="flex flex-1 overflow-hidden">
802
- <AppSidebar
803
- data={menu}
804
- title={app.layout?.title}
805
- onMenuClick={setActiveMenuId} />
806
- <div className="grow overflow-hidden">
807
- {activeMenu?.type === 'board' && (
808
- <AppBoardView page={activeMenu} dataSources={dataSources} />
809
- )}
810
- {activeMenu?.type === 'dashboard' && (
811
- <AppDashboardPreview page={activeMenu} widgets={widgets} />
812
- )}
813
- {!activeMenu && (
814
- <div className="flex h-full items-center justify-center text-sm text-muted-foreground">
815
- Select a menu item to preview
816
- </div>
817
- )}
818
- </div>
819
- </div>
820
- )}
821
-
822
- {/* Tab 1: JSON editor */}
823
- {activeTab === 1 && (
824
- <div className="flex-1 overflow-auto p-4">
825
- <pre className="text-xs font-mono text-muted-foreground whitespace-pre-wrap break-all">
826
- {JSON.stringify(app, null, 2)}
827
- </pre>
828
- </div>
829
- )}
830
-
831
- {/* Tab 2: Documentation */}
832
- {activeTab === 2 && (
833
- <div className="flex-1 overflow-hidden">
834
- <AppPreviewDocument app={app} />
835
- </div>
836
- )}
837
- </div>
838
- );
839
- }