@orbit-work/ui 0.1.0

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 (755) hide show
  1. package/README.md +110 -0
  2. package/dist/about-window.cjs +1 -0
  3. package/dist/about-window.d.cts +12 -0
  4. package/dist/about-window.d.ts +12 -0
  5. package/dist/about-window.js +1 -0
  6. package/dist/appearance-D5uQ53j3.d.cts +210 -0
  7. package/dist/appearance-D5uQ53j3.d.ts +210 -0
  8. package/dist/appearance.cjs +1 -0
  9. package/dist/appearance.d.cts +1 -0
  10. package/dist/appearance.d.ts +1 -0
  11. package/dist/appearance.js +1 -0
  12. package/dist/browser-annotation-popup.cjs +1 -0
  13. package/dist/browser-annotation-popup.d.cts +48 -0
  14. package/dist/browser-annotation-popup.d.ts +48 -0
  15. package/dist/browser-annotation-popup.js +1 -0
  16. package/dist/chunk-3KT7IU4X.js +13 -0
  17. package/dist/chunk-5VLBKOG7.cjs +194 -0
  18. package/dist/chunk-7YJY64LZ.js +82 -0
  19. package/dist/chunk-EF2BSN3K.cjs +13 -0
  20. package/dist/chunk-GMMYDILD.cjs +82 -0
  21. package/dist/chunk-VG7FQQ7K.js +194 -0
  22. package/dist/fonts/JetBrainsMono-Medium.ttf +0 -0
  23. package/dist/fonts/JetBrainsMono-Regular.ttf +0 -0
  24. package/dist/fonts/SpaceGrotesk-500-latin-ext.woff2 +0 -0
  25. package/dist/fonts/SpaceGrotesk-500-latin.woff2 +0 -0
  26. package/dist/fonts/SpaceGrotesk-700-latin-ext.woff2 +0 -0
  27. package/dist/fonts/SpaceGrotesk-700-latin.woff2 +0 -0
  28. package/dist/fonts/ibm-plex-mono-latin-400-italic.woff2 +0 -0
  29. package/dist/fonts/ibm-plex-mono-latin-400.woff2 +0 -0
  30. package/dist/fonts/ibm-plex-mono-latin-500.woff2 +0 -0
  31. package/dist/fonts/ibm-plex-mono-latin-ext-400-italic.woff2 +0 -0
  32. package/dist/fonts/ibm-plex-mono-latin-ext-400.woff2 +0 -0
  33. package/dist/fonts/ibm-plex-mono-latin-ext-500.woff2 +0 -0
  34. package/dist/index.cjs +32 -0
  35. package/dist/index.css +1 -0
  36. package/dist/index.d.cts +10345 -0
  37. package/dist/index.d.ts +10345 -0
  38. package/dist/index.js +32 -0
  39. package/dist/orbitwork.css +22134 -0
  40. package/package.json +119 -0
  41. package/src/components/Layout/AppLayout/AppLayout.stories.tsx +246 -0
  42. package/src/components/Layout/AppLayout/AppLayoutSource.test.mjs +37 -0
  43. package/src/components/Layout/AppLayout/index.tsx +122 -0
  44. package/src/components/Layout/Sidebar/index.tsx +13 -0
  45. package/src/components/Layout/SidebarShell/SidebarShell.stories.tsx +676 -0
  46. package/src/components/Layout/SidebarShell/SidebarShellSource.test.mjs +161 -0
  47. package/src/components/Layout/SidebarShell/index.tsx +326 -0
  48. package/src/components/Layout/index.ts +10 -0
  49. package/src/components/composite/ActionBar/ActionBar.stories.tsx +26 -0
  50. package/src/components/composite/ActionBar/index.tsx +31 -0
  51. package/src/components/composite/ActionStatus/ActionStatus.stories.tsx +60 -0
  52. package/src/components/composite/ActionStatus/index.tsx +21 -0
  53. package/src/components/composite/AskQuestionCardView/AskQuestionCardView.stories.tsx +175 -0
  54. package/src/components/composite/AskQuestionCardView/AskQuestionCardViewSource.test.mjs +92 -0
  55. package/src/components/composite/AskQuestionCardView/index.tsx +119 -0
  56. package/src/components/composite/AssistantChannelCard/AssistantChannelCard.stories.tsx +265 -0
  57. package/src/components/composite/AssistantChannelCard/AssistantChannelCardSource.test.mjs +45 -0
  58. package/src/components/composite/AssistantChannelCard/index.tsx +102 -0
  59. package/src/components/composite/AssistantToggleRow/AssistantToggleRow.stories.tsx +197 -0
  60. package/src/components/composite/AssistantToggleRow/index.tsx +35 -0
  61. package/src/components/composite/AttachmentCard/AttachmentCard.stories.tsx +125 -0
  62. package/src/components/composite/AttachmentCard/index.tsx +80 -0
  63. package/src/components/composite/BackButton/BackButton.stories.tsx +93 -0
  64. package/src/components/composite/BackButton/BackButtonSource.test.mjs +29 -0
  65. package/src/components/composite/BackButton/index.tsx +48 -0
  66. package/src/components/composite/Banner/Banner.stories.tsx +180 -0
  67. package/src/components/composite/Banner/BannerSource.test.mjs +67 -0
  68. package/src/components/composite/Banner/index.tsx +125 -0
  69. package/src/components/composite/BeaconIcons/BeaconIcons.stories.tsx +153 -0
  70. package/src/components/composite/BeaconIcons/index.tsx +265 -0
  71. package/src/components/composite/BeaconSpinner/BeaconSpinner.stories.tsx +144 -0
  72. package/src/components/composite/BeaconSpinner/index.tsx +185 -0
  73. package/src/components/composite/CatalogStates/CatalogEmptyState.stories.tsx +108 -0
  74. package/src/components/composite/CatalogStates/CatalogStates.stories.tsx +53 -0
  75. package/src/components/composite/CatalogStates/CatalogStatesSource.test.mjs +149 -0
  76. package/src/components/composite/CatalogStates/index.tsx +113 -0
  77. package/src/components/composite/Charts/Charts.stories.tsx +174 -0
  78. package/src/components/composite/Charts/ChartsSource.test.mjs +111 -0
  79. package/src/components/composite/Charts/index.tsx +385 -0
  80. package/src/components/composite/CodeBlock/CodeBlock.stories.tsx +308 -0
  81. package/src/components/composite/CodeBlock/CodeFaceSource.test.mjs +89 -0
  82. package/src/components/composite/CodeBlock/index.tsx +300 -0
  83. package/src/components/composite/CodeDiff/CodeDiff.stories.tsx +169 -0
  84. package/src/components/composite/CodeDiff/index.tsx +373 -0
  85. package/src/components/composite/CodePreview/CodePreview.stories.tsx +127 -0
  86. package/src/components/composite/CodePreview/CodePreviewSource.test.mjs +43 -0
  87. package/src/components/composite/CodePreview/index.tsx +98 -0
  88. package/src/components/composite/CommandPalette/CommandPalette.stories.tsx +89 -0
  89. package/src/components/composite/CommandPalette/CommandPaletteSource.test.mjs +61 -0
  90. package/src/components/composite/CommandPalette/index.tsx +310 -0
  91. package/src/components/composite/ContentRecommendation/ContentRecommendation.stories.tsx +300 -0
  92. package/src/components/composite/ContentRecommendation/ContentRecommendationSource.test.mjs +48 -0
  93. package/src/components/composite/ContentRecommendation/index.tsx +116 -0
  94. package/src/components/composite/ContextChip/ContextChip.stories.tsx +123 -0
  95. package/src/components/composite/ContextChip/ContextChipSource.test.mjs +24 -0
  96. package/src/components/composite/ContextChip/index.tsx +25 -0
  97. package/src/components/composite/ContextUsageIndicatorView/ContextUsageIndicatorSizeSource.test.mjs +15 -0
  98. package/src/components/composite/ContextUsageIndicatorView/ContextUsageIndicatorView.stories.tsx +110 -0
  99. package/src/components/composite/ContextUsageIndicatorView/ContextUsageLoadingSource.test.mjs +23 -0
  100. package/src/components/composite/ContextUsageIndicatorView/index.tsx +139 -0
  101. package/src/components/composite/Controls/Controls.stories.tsx +227 -0
  102. package/src/components/composite/Controls/index.tsx +15 -0
  103. package/src/components/composite/CreateProjectDialog/CreateProjectDialog.stories.tsx +56 -0
  104. package/src/components/composite/CreateProjectDialog/index.tsx +70 -0
  105. package/src/components/composite/DataManagementSectionView/DataManagementSectionView.stories.tsx +123 -0
  106. package/src/components/composite/DataManagementSectionView/DataManagementSectionViewSource.test.mjs +45 -0
  107. package/src/components/composite/DataManagementSectionView/index.tsx +110 -0
  108. package/src/components/composite/DataTable/DataTable.stories.tsx +159 -0
  109. package/src/components/composite/DataTable/DataTableSource.test.mjs +96 -0
  110. package/src/components/composite/DataTable/index.tsx +373 -0
  111. package/src/components/composite/DetailChrome/DetailChrome.stories.tsx +61 -0
  112. package/src/components/composite/DetailChrome/DetailChromeSource.test.mjs +31 -0
  113. package/src/components/composite/DetailChrome/index.tsx +94 -0
  114. package/src/components/composite/DetailPanel/DetailPanel.stories.tsx +185 -0
  115. package/src/components/composite/DetailPanel/DetailPanelSource.test.mjs +49 -0
  116. package/src/components/composite/DetailPanel/index.tsx +120 -0
  117. package/src/components/composite/DetailScaffold/DetailScaffold.stories.tsx +203 -0
  118. package/src/components/composite/DetailScaffold/DetailScaffoldSource.test.mjs +38 -0
  119. package/src/components/composite/DetailScaffold/index.tsx +114 -0
  120. package/src/components/composite/Dialog/Dialog.stories.tsx +343 -0
  121. package/src/components/composite/Dialog/DialogSource.test.mjs +130 -0
  122. package/src/components/composite/Dialog/index.tsx +333 -0
  123. package/src/components/composite/DropZone/DropZone.stories.tsx +105 -0
  124. package/src/components/composite/DropZone/DropZoneSource.test.mjs +68 -0
  125. package/src/components/composite/DropZone/index.tsx +196 -0
  126. package/src/components/composite/FSelect/FSelect.stories.tsx +64 -0
  127. package/src/components/composite/FSelect/index.tsx +29 -0
  128. package/src/components/composite/FeedbackContextMenuView/FeedbackContextMenuView.stories.tsx +106 -0
  129. package/src/components/composite/FeedbackContextMenuView/index.tsx +51 -0
  130. package/src/components/composite/FeedbackDialogView/FeedbackDialogView.stories.tsx +291 -0
  131. package/src/components/composite/FeedbackDialogView/index.tsx +95 -0
  132. package/src/components/composite/FileReferenceCard/FileReferenceCard.stories.tsx +364 -0
  133. package/src/components/composite/FileReferenceCard/FileReferenceCardSource.test.mjs +48 -0
  134. package/src/components/composite/FileReferenceCard/index.tsx +122 -0
  135. package/src/components/composite/FilterBar/FilterBar.stories.tsx +167 -0
  136. package/src/components/composite/FilterBar/FilterBarSource.test.mjs +75 -0
  137. package/src/components/composite/FilterBar/index.tsx +206 -0
  138. package/src/components/composite/FormField/FormField.stories.tsx +158 -0
  139. package/src/components/composite/FormField/FormFieldSource.test.mjs +56 -0
  140. package/src/components/composite/FormField/index.tsx +219 -0
  141. package/src/components/composite/HomeBackdrop/HomeBackdrop.stories.tsx +54 -0
  142. package/src/components/composite/HomeBackdrop/HomeBackdropSource.test.mjs +50 -0
  143. package/src/components/composite/HomeBackdrop/index.tsx +53 -0
  144. package/src/components/composite/Icons/Icons.stories.tsx +153 -0
  145. package/src/components/composite/Icons/IconsSource.test.mjs +23 -0
  146. package/src/components/composite/Icons/index.tsx +1347 -0
  147. package/src/components/composite/ImageCard/ImageCard.stories.tsx +54 -0
  148. package/src/components/composite/ImageCard/index.tsx +33 -0
  149. package/src/components/composite/ImagePreview/ImagePreview.stories.tsx +172 -0
  150. package/src/components/composite/ImagePreview/ImagePreviewSource.test.mjs +95 -0
  151. package/src/components/composite/ImagePreview/index.tsx +339 -0
  152. package/src/components/composite/ListRow/ListRow.stories.tsx +257 -0
  153. package/src/components/composite/ListRow/ListRowSource.test.mjs +101 -0
  154. package/src/components/composite/ListRow/index.tsx +309 -0
  155. package/src/components/composite/Markdown/Markdown.stories.tsx +192 -0
  156. package/src/components/composite/Markdown/MarkdownSource.test.mjs +126 -0
  157. package/src/components/composite/Markdown/MarkdownStyleSource.test.mjs +152 -0
  158. package/src/components/composite/Markdown/index.tsx +702 -0
  159. package/src/components/composite/MarkdownPreview/MarkdownPreview.stories.tsx +174 -0
  160. package/src/components/composite/MarkdownPreview/MarkdownPreviewTabsSource.test.mjs +31 -0
  161. package/src/components/composite/MarkdownPreview/MarkdownRenderedStyleSource.test.mjs +84 -0
  162. package/src/components/composite/MarkdownPreview/index.tsx +140 -0
  163. package/src/components/composite/MarkdownPreviewModalView/MarkdownPreviewModalView.stories.tsx +104 -0
  164. package/src/components/composite/MarkdownPreviewModalView/index.tsx +85 -0
  165. package/src/components/composite/MessageFeedbackDialog/MessageFeedbackDialog.stories.tsx +66 -0
  166. package/src/components/composite/MessageFeedbackDialog/index.tsx +115 -0
  167. package/src/components/composite/ModelCatalogErrorState/ModelCatalogErrorState.stories.tsx +101 -0
  168. package/src/components/composite/ModelCatalogErrorState/ModelCatalogRetrySource.test.mjs +86 -0
  169. package/src/components/composite/ModelCatalogErrorState/index.tsx +59 -0
  170. package/src/components/composite/ModelModalityFlow/ModelModalityFlow.stories.tsx +224 -0
  171. package/src/components/composite/ModelModalityFlow/ModelModalityFlowSource.test.mjs +56 -0
  172. package/src/components/composite/ModelModalityFlow/index.tsx +113 -0
  173. package/src/components/composite/ModelPickerList/ModelPickerList.stories.tsx +313 -0
  174. package/src/components/composite/ModelPickerList/index.tsx +142 -0
  175. package/src/components/composite/ModelSelect/ModelSelect.stories.tsx +90 -0
  176. package/src/components/composite/ModelSelect/index.tsx +148 -0
  177. package/src/components/composite/ModelsSettingsSectionView/ModelsSettingsSectionView.stories.tsx +170 -0
  178. package/src/components/composite/ModelsSettingsSectionView/index.tsx +139 -0
  179. package/src/components/composite/NativeControls/NativeControls.stories.tsx +386 -0
  180. package/src/components/composite/NativeControls/NativeControlsStyleSource.test.mjs +63 -0
  181. package/src/components/composite/NativeControls/index.tsx +97 -0
  182. package/src/components/composite/NavMenu/NavMenu.stories.tsx +383 -0
  183. package/src/components/composite/NavMenu/NavMenuSource.test.mjs +56 -0
  184. package/src/components/composite/NavMenu/index.tsx +142 -0
  185. package/src/components/composite/NoPlanPanelView/NoPlanPanelView.stories.tsx +344 -0
  186. package/src/components/composite/NoPlanPanelView/NoPlanPanelViewSource.test.mjs +34 -0
  187. package/src/components/composite/NoPlanPanelView/index.tsx +97 -0
  188. package/src/components/composite/OpenWithButton/OpenWithButton.stories.tsx +78 -0
  189. package/src/components/composite/OpenWithButton/index.tsx +46 -0
  190. package/src/components/composite/OrbitworkLogo/OrbitworkLogo.stories.tsx +192 -0
  191. package/src/components/composite/OrbitworkLogo/index.tsx +207 -0
  192. package/src/components/composite/OrbitworkModal/OrbitworkModal.stories.tsx +58 -0
  193. package/src/components/composite/OrbitworkModal/index.tsx +31 -0
  194. package/src/components/composite/PageHead/PageHead.stories.tsx +235 -0
  195. package/src/components/composite/PageHead/PageHeadSource.test.mjs +76 -0
  196. package/src/components/composite/PageHead/index.tsx +128 -0
  197. package/src/components/composite/PlanFeatureIcon/PlanFeatureIcon.stories.tsx +205 -0
  198. package/src/components/composite/PlanFeatureIcon/PlanFeatureIconSource.test.mjs +38 -0
  199. package/src/components/composite/PlanFeatureIcon/index.tsx +48 -0
  200. package/src/components/composite/PlanSettingsSectionView/PlanSettingsSectionView.stories.tsx +231 -0
  201. package/src/components/composite/PlanSettingsSectionView/PlanSettingsSectionViewSource.test.mjs +85 -0
  202. package/src/components/composite/PlanSettingsSectionView/index.tsx +264 -0
  203. package/src/components/composite/Popover/Popover.stories.tsx +175 -0
  204. package/src/components/composite/Popover/PopoverSource.test.mjs +59 -0
  205. package/src/components/composite/Popover/index.tsx +176 -0
  206. package/src/components/composite/PptxRenderer/ElementDispatcher/index.tsx +70 -0
  207. package/src/components/composite/PptxRenderer/PptxChromeStyleSource.test.mjs +36 -0
  208. package/src/components/composite/PptxRenderer/PptxRenderer.stories.tsx +128 -0
  209. package/src/components/composite/PptxRenderer/PptxSlide/index.tsx +48 -0
  210. package/src/components/composite/PptxRenderer/constants.ts +2 -0
  211. package/src/components/composite/PptxRenderer/elements/AudioElement/index.tsx +48 -0
  212. package/src/components/composite/PptxRenderer/elements/ChartElement/index.tsx +172 -0
  213. package/src/components/composite/PptxRenderer/elements/DiagramElement/index.tsx +46 -0
  214. package/src/components/composite/PptxRenderer/elements/GroupElement/index.tsx +28 -0
  215. package/src/components/composite/PptxRenderer/elements/ImageElement/index.tsx +61 -0
  216. package/src/components/composite/PptxRenderer/elements/MathElement/index.tsx +57 -0
  217. package/src/components/composite/PptxRenderer/elements/ShapeElement/index.tsx +327 -0
  218. package/src/components/composite/PptxRenderer/elements/TableElement/index.tsx +90 -0
  219. package/src/components/composite/PptxRenderer/elements/TextElement/index.tsx +57 -0
  220. package/src/components/composite/PptxRenderer/elements/VideoElement/index.tsx +43 -0
  221. package/src/components/composite/PptxRenderer/index.ts +24 -0
  222. package/src/components/composite/PptxRenderer/types.ts +326 -0
  223. package/src/components/composite/PptxRenderer/utils.ts +129 -0
  224. package/src/components/composite/ProjectSelect/ProjectSelect.stories.tsx +112 -0
  225. package/src/components/composite/ProjectSelect/ProjectSelectSource.test.mjs +34 -0
  226. package/src/components/composite/ProjectSelect/index.tsx +155 -0
  227. package/src/components/composite/RadioCard/RadioCard.stories.tsx +130 -0
  228. package/src/components/composite/RadioCard/RadioCardSource.test.mjs +42 -0
  229. package/src/components/composite/RadioCard/index.tsx +171 -0
  230. package/src/components/composite/RowOverflowMenu/RowOverflowMenu.stories.tsx +113 -0
  231. package/src/components/composite/RowOverflowMenu/RowOverflowMenuSource.test.mjs +59 -0
  232. package/src/components/composite/RowOverflowMenu/index.tsx +101 -0
  233. package/src/components/composite/SandboxPermissionPrompt/SandboxPermissionPrompt.stories.tsx +159 -0
  234. package/src/components/composite/SandboxPermissionPrompt/SandboxPermissionPromptSource.test.mjs +71 -0
  235. package/src/components/composite/SandboxPermissionPrompt/index.tsx +157 -0
  236. package/src/components/composite/SearchInput/SearchInput.stories.tsx +127 -0
  237. package/src/components/composite/SearchInput/index.tsx +91 -0
  238. package/src/components/composite/SearchResult/SearchResult.stories.tsx +305 -0
  239. package/src/components/composite/SearchResult/SearchResultSource.test.mjs +45 -0
  240. package/src/components/composite/SearchResult/index.tsx +148 -0
  241. package/src/components/composite/Section/Section.stories.tsx +148 -0
  242. package/src/components/composite/Section/SectionSource.test.mjs +59 -0
  243. package/src/components/composite/Section/index.tsx +105 -0
  244. package/src/components/composite/SelectionBulkBar/SelectionBulkBar.stories.tsx +111 -0
  245. package/src/components/composite/SelectionBulkBar/SelectionBulkBarSource.test.mjs +44 -0
  246. package/src/components/composite/SelectionBulkBar/index.tsx +99 -0
  247. package/src/components/composite/ShareStrip/ShareStrip.stories.tsx +123 -0
  248. package/src/components/composite/ShareStrip/index.tsx +83 -0
  249. package/src/components/composite/ShortcutSheet/ShortcutSheet.stories.tsx +90 -0
  250. package/src/components/composite/ShortcutSheet/ShortcutSheetSource.test.mjs +49 -0
  251. package/src/components/composite/ShortcutSheet/index.tsx +163 -0
  252. package/src/components/composite/SitesArtifactCardView/SitesArtifactCardView.stories.tsx +328 -0
  253. package/src/components/composite/SitesArtifactCardView/SitesArtifactCardViewSource.test.mjs +45 -0
  254. package/src/components/composite/SitesArtifactCardView/index.tsx +100 -0
  255. package/src/components/composite/Skeleton/Skeleton.stories.tsx +188 -0
  256. package/src/components/composite/Skeleton/SkeletonSource.test.mjs +25 -0
  257. package/src/components/composite/Skeleton/index.tsx +152 -0
  258. package/src/components/composite/Splash/Splash.stories.tsx +150 -0
  259. package/src/components/composite/Splash/index.tsx +229 -0
  260. package/src/components/composite/StatusTag/StatusTag.stories.tsx +66 -0
  261. package/src/components/composite/StatusTag/StatusTagSource.test.mjs +64 -0
  262. package/src/components/composite/StatusTag/index.tsx +78 -0
  263. package/src/components/composite/StepList/StepList.stories.tsx +352 -0
  264. package/src/components/composite/StepList/index.tsx +23 -0
  265. package/src/components/composite/Tag/Tag.stories.tsx +279 -0
  266. package/src/components/composite/Tag/TagSource.test.mjs +67 -0
  267. package/src/components/composite/Tag/index.tsx +229 -0
  268. package/src/components/composite/TimePicker/TimePicker.stories.tsx +91 -0
  269. package/src/components/composite/TimePicker/TimePickerSource.test.mjs +98 -0
  270. package/src/components/composite/TimePicker/index.tsx +208 -0
  271. package/src/components/composite/TitleBar/TitleBar.stories.tsx +329 -0
  272. package/src/components/composite/TitleBar/TitleBarSource.test.mjs +140 -0
  273. package/src/components/composite/TitleBar/index.tsx +350 -0
  274. package/src/components/composite/Toast/Toast.stories.tsx +304 -0
  275. package/src/components/composite/Toast/ToastSource.test.mjs +63 -0
  276. package/src/components/composite/Toast/index.tsx +135 -0
  277. package/src/components/composite/Tooltip/Tooltip.stories.tsx +304 -0
  278. package/src/components/composite/Tooltip/TooltipSource.test.mjs +34 -0
  279. package/src/components/composite/Tooltip/index.tsx +204 -0
  280. package/src/components/composite/TranscriptDividers/TranscriptDividers.stories.tsx +160 -0
  281. package/src/components/composite/TranscriptDividers/TranscriptDividersSource.test.mjs +90 -0
  282. package/src/components/composite/TranscriptDividers/index.tsx +352 -0
  283. package/src/components/composite/WCardShell/WCardShell.stories.tsx +228 -0
  284. package/src/components/composite/WCardShell/index.tsx +101 -0
  285. package/src/components/composite/index.ts +81 -0
  286. package/src/components/domain/artifacts/ArtifactPreviewSidebarView/ArtifactPreviewSidebarView.stories.tsx +128 -0
  287. package/src/components/domain/artifacts/ArtifactPreviewSidebarView/ArtifactPreviewSidebarViewSource.test.mjs +69 -0
  288. package/src/components/domain/artifacts/ArtifactPreviewSidebarView/index.tsx +212 -0
  289. package/src/components/domain/artifacts/index.ts +1 -0
  290. package/src/components/domain/browser/BrowserAnnotationPopupView/BrowserAnnotationPopupView.stories.tsx +211 -0
  291. package/src/components/domain/browser/BrowserAnnotationPopupView/BrowserAnnotationPopupViewSource.test.mjs +82 -0
  292. package/src/components/domain/browser/BrowserAnnotationPopupView/index.tsx +235 -0
  293. package/src/components/domain/browser/BrowserDeviceToolbarView/BrowserDeviceToolbarView.stories.tsx +260 -0
  294. package/src/components/domain/browser/BrowserDeviceToolbarView/BrowserDeviceToolbarViewSource.test.mjs +12 -0
  295. package/src/components/domain/browser/BrowserDeviceToolbarView/index.tsx +154 -0
  296. package/src/components/domain/browser/BrowserFindBarView/BrowserFindBarView.stories.tsx +52 -0
  297. package/src/components/domain/browser/BrowserFindBarView/index.tsx +111 -0
  298. package/src/components/domain/browser/BrowserImportDialogView/BrowserImportDialogView.stories.tsx +89 -0
  299. package/src/components/domain/browser/BrowserImportDialogView/index.tsx +155 -0
  300. package/src/components/domain/browser/BrowserLoadErrorView/BrowserLoadErrorView.stories.tsx +197 -0
  301. package/src/components/domain/browser/BrowserLoadErrorView/BrowserLoadErrorViewSource.test.mjs +29 -0
  302. package/src/components/domain/browser/BrowserLoadErrorView/index.tsx +45 -0
  303. package/src/components/domain/browser/BrowserMoreMenuView/BrowserMoreMenuView.stories.tsx +66 -0
  304. package/src/components/domain/browser/BrowserMoreMenuView/index.tsx +268 -0
  305. package/src/components/domain/browser/BrowserNavBarView/BrowserNavBarView.stories.tsx +149 -0
  306. package/src/components/domain/browser/BrowserNavBarView/index.tsx +156 -0
  307. package/src/components/domain/browser/BrowserTabBarView/index.tsx +18 -0
  308. package/src/components/domain/browser/SubAgentPane/SubAgentPane.stories.tsx +96 -0
  309. package/src/components/domain/browser/SubAgentPane/SubAgentPaneSource.test.mjs +48 -0
  310. package/src/components/domain/browser/SubAgentPane/index.tsx +121 -0
  311. package/src/components/domain/browser/TerminalPane/TerminalPane.stories.tsx +95 -0
  312. package/src/components/domain/browser/TerminalPane/TerminalPaneSource.test.mjs +52 -0
  313. package/src/components/domain/browser/TerminalPane/index.tsx +75 -0
  314. package/src/components/domain/browser/WebPreview/WebPreview.stories.tsx +71 -0
  315. package/src/components/domain/browser/WebPreview/index.tsx +141 -0
  316. package/src/components/domain/browser/WebPreviewConsole/WebPreviewConsole.stories.tsx +61 -0
  317. package/src/components/domain/browser/WebPreviewConsole/WebPreviewConsoleSource.test.mjs +66 -0
  318. package/src/components/domain/browser/WebPreviewConsole/index.tsx +239 -0
  319. package/src/components/domain/browser/WebPreviewDialog/WebPreviewDialog.stories.tsx +288 -0
  320. package/src/components/domain/browser/WebPreviewDialog/WebPreviewDialogSource.test.mjs +62 -0
  321. package/src/components/domain/browser/WebPreviewDialog/index.tsx +82 -0
  322. package/src/components/domain/browser/WebPreviewNav/WebPreviewNav.stories.tsx +462 -0
  323. package/src/components/domain/browser/WebPreviewNav/WebPreviewNavSource.test.mjs +353 -0
  324. package/src/components/domain/browser/WebPreviewNav/index.tsx +351 -0
  325. package/src/components/domain/browser/WebPreviewShell/WebPreviewShell.stories.tsx +226 -0
  326. package/src/components/domain/browser/WebPreviewShell/WebPreviewShellSource.test.mjs +172 -0
  327. package/src/components/domain/browser/WebPreviewShell/index.tsx +324 -0
  328. package/src/components/domain/browser/index.ts +45 -0
  329. package/src/components/domain/chat/AgentLoopSegment/AgentLoopSegment.stories.tsx +107 -0
  330. package/src/components/domain/chat/AgentLoopSegment/AgentLoopSegmentSource.test.mjs +45 -0
  331. package/src/components/domain/chat/AgentLoopSegment/index.tsx +29 -0
  332. package/src/components/domain/chat/AgentTurn/AgentTurn.stories.tsx +162 -0
  333. package/src/components/domain/chat/AgentTurn/AgentTurnSource.test.mjs +98 -0
  334. package/src/components/domain/chat/AgentTurn/beaconContext.ts +37 -0
  335. package/src/components/domain/chat/AgentTurn/index.tsx +226 -0
  336. package/src/components/domain/chat/ArtifactCard/ArtifactCard.stories.tsx +127 -0
  337. package/src/components/domain/chat/ArtifactCard/index.tsx +249 -0
  338. package/src/components/domain/chat/Attachment/Attachment.stories.tsx +235 -0
  339. package/src/components/domain/chat/Attachment/AttachmentSource.test.mjs +160 -0
  340. package/src/components/domain/chat/Attachment/index.tsx +857 -0
  341. package/src/components/domain/chat/AuthorizationCard/AuthorizationCard.stories.tsx +53 -0
  342. package/src/components/domain/chat/AuthorizationCard/AuthorizationCardSource.test.mjs +80 -0
  343. package/src/components/domain/chat/AuthorizationCard/index.tsx +89 -0
  344. package/src/components/domain/chat/ChatBubble/ChatBubble.stories.tsx +32 -0
  345. package/src/components/domain/chat/ChatBubble/index.tsx +24 -0
  346. package/src/components/domain/chat/ChatMessage/ChatMessage.stories.tsx +31 -0
  347. package/src/components/domain/chat/ChatMessage/index.tsx +23 -0
  348. package/src/components/domain/chat/ChatR2ReviewSource.test.mjs +98 -0
  349. package/src/components/domain/chat/ChatThinking/ChatThinking.stories.tsx +125 -0
  350. package/src/components/domain/chat/ChatThinking/index.tsx +55 -0
  351. package/src/components/domain/chat/Chatbot/Chatbot.stories.tsx +49 -0
  352. package/src/components/domain/chat/Chatbot/index.tsx +37 -0
  353. package/src/components/domain/chat/Composer/Composer.stories.tsx +227 -0
  354. package/src/components/domain/chat/Composer/ComposerSource.test.mjs +175 -0
  355. package/src/components/domain/chat/Composer/index.tsx +450 -0
  356. package/src/components/domain/chat/Composer/parts/ComposerAudioSpectrum.stories.tsx +203 -0
  357. package/src/components/domain/chat/Composer/parts/ComposerAudioSpectrum.tsx +110 -0
  358. package/src/components/domain/chat/Composer/parts/ComposerAudioSpectrumSource.test.mjs +54 -0
  359. package/src/components/domain/chat/Composer/parts/ComposerAuthorization.stories.tsx +155 -0
  360. package/src/components/domain/chat/Composer/parts/ComposerAuthorization.tsx +108 -0
  361. package/src/components/domain/chat/Composer/parts/ComposerMentions.stories.tsx +76 -0
  362. package/src/components/domain/chat/Composer/parts/ComposerMentions.tsx +83 -0
  363. package/src/components/domain/chat/Composer/parts/ComposerMentionsSource.test.mjs +85 -0
  364. package/src/components/domain/chat/Composer/parts/ComposerMenu.stories.tsx +266 -0
  365. package/src/components/domain/chat/Composer/parts/ComposerMenu.tsx +232 -0
  366. package/src/components/domain/chat/Composer/parts/ComposerMenuPopover.stories.tsx +166 -0
  367. package/src/components/domain/chat/Composer/parts/ComposerMenuPopover.tsx +87 -0
  368. package/src/components/domain/chat/Composer/parts/ComposerMenuPopoverSource.test.mjs +56 -0
  369. package/src/components/domain/chat/Composer/parts/ComposerPopover.stories.tsx +257 -0
  370. package/src/components/domain/chat/Composer/parts/ComposerPopover.tsx +221 -0
  371. package/src/components/domain/chat/Composer/parts/ComposerPopoverSource.test.mjs +71 -0
  372. package/src/components/domain/chat/Composer/parts/ComposerProjectPicker.stories.tsx +260 -0
  373. package/src/components/domain/chat/Composer/parts/ComposerProjectPicker.tsx +246 -0
  374. package/src/components/domain/chat/Composer/parts/ComposerProjectPickerSource.test.mjs +46 -0
  375. package/src/components/domain/chat/Composer/parts/ComposerQueue.stories.tsx +275 -0
  376. package/src/components/domain/chat/Composer/parts/ComposerQueue.tsx +155 -0
  377. package/src/components/domain/chat/Composer/parts/ComposerQueueSource.test.mjs +95 -0
  378. package/src/components/domain/chat/Composer/parts/ComposerVoiceInput.stories.tsx +77 -0
  379. package/src/components/domain/chat/Composer/parts/ComposerVoiceInput.tsx +70 -0
  380. package/src/components/domain/chat/Composer/parts/mountChip.ts +21 -0
  381. package/src/components/domain/chat/ContextUsage/ContextUsage.stories.tsx +62 -0
  382. package/src/components/domain/chat/ContextUsage/index.tsx +69 -0
  383. package/src/components/domain/chat/ExecutionSummary/ExecutionSummary.stories.tsx +238 -0
  384. package/src/components/domain/chat/ExecutionSummary/ExecutionSummarySource.test.mjs +210 -0
  385. package/src/components/domain/chat/ExecutionSummary/index.tsx +487 -0
  386. package/src/components/domain/chat/Message/Message.stories.tsx +264 -0
  387. package/src/components/domain/chat/Message/index.tsx +44 -0
  388. package/src/components/domain/chat/MessageActions/MessageActions.stories.tsx +132 -0
  389. package/src/components/domain/chat/MessageActions/MessageActionsSource.test.mjs +79 -0
  390. package/src/components/domain/chat/MessageActions/index.tsx +186 -0
  391. package/src/components/domain/chat/PlanCard/PlanCard.stories.tsx +87 -0
  392. package/src/components/domain/chat/PlanCard/index.tsx +170 -0
  393. package/src/components/domain/chat/RichContent/RichContent.stories.tsx +102 -0
  394. package/src/components/domain/chat/RichContent/RichContentSource.test.mjs +82 -0
  395. package/src/components/domain/chat/RichContent/index.tsx +465 -0
  396. package/src/components/domain/chat/SubAgentThread/SubAgentThread.stories.tsx +119 -0
  397. package/src/components/domain/chat/SubAgentThread/index.tsx +104 -0
  398. package/src/components/domain/chat/Thinking/Thinking.stories.tsx +196 -0
  399. package/src/components/domain/chat/Thinking/ThinkingInlineSource.test.mjs +154 -0
  400. package/src/components/domain/chat/Thinking/index.tsx +237 -0
  401. package/src/components/domain/chat/ToolCallRow/ToolCallRow.stories.tsx +105 -0
  402. package/src/components/domain/chat/ToolCallRow/ToolCallRowSource.test.mjs +83 -0
  403. package/src/components/domain/chat/ToolCallRow/index.tsx +113 -0
  404. package/src/components/domain/chat/Transcript/Transcript.stories.tsx +296 -0
  405. package/src/components/domain/chat/Transcript/TranscriptSource.test.mjs +189 -0
  406. package/src/components/domain/chat/Transcript/index.tsx +187 -0
  407. package/src/components/domain/chat/TranscriptSpine/TranscriptSpine.stories.tsx +124 -0
  408. package/src/components/domain/chat/TranscriptSpine/index.tsx +245 -0
  409. package/src/components/domain/chat/UserTurn/UserTurn.stories.tsx +176 -0
  410. package/src/components/domain/chat/UserTurn/UserTurnSource.test.mjs +150 -0
  411. package/src/components/domain/chat/UserTurn/index.tsx +194 -0
  412. package/src/components/domain/chat/index.ts +22 -0
  413. package/src/components/domain/desktop/DesktopAccountMenuView/DesktopAccountMenuView.stories.tsx +116 -0
  414. package/src/components/domain/desktop/DesktopAccountMenuView/DesktopAccountMenuViewSource.test.mjs +80 -0
  415. package/src/components/domain/desktop/DesktopAccountMenuView/index.tsx +355 -0
  416. package/src/components/domain/desktop/DesktopAppearanceSettings/DesktopAppearanceSettings.stories.tsx +96 -0
  417. package/src/components/domain/desktop/DesktopAppearanceSettings/DesktopAppearanceSettingsSource.test.mjs +89 -0
  418. package/src/components/domain/desktop/DesktopAppearanceSettings/index.tsx +155 -0
  419. package/src/components/domain/desktop/DesktopAssistantConfigView/DesktopAssistantConfigView.stories.tsx +275 -0
  420. package/src/components/domain/desktop/DesktopAssistantConfigView/DesktopAssistantConfigViewSource.test.mjs +37 -0
  421. package/src/components/domain/desktop/DesktopAssistantConfigView/index.tsx +221 -0
  422. package/src/components/domain/desktop/DesktopCatalogView/DesktopCatalogView.stories.tsx +537 -0
  423. package/src/components/domain/desktop/DesktopCatalogView/DesktopCatalogViewSource.test.mjs +339 -0
  424. package/src/components/domain/desktop/DesktopCatalogView/index.tsx +1074 -0
  425. package/src/components/domain/desktop/DesktopChatBranchDivider/DesktopChatBranchDivider.stories.tsx +58 -0
  426. package/src/components/domain/desktop/DesktopChatBranchDivider/index.tsx +33 -0
  427. package/src/components/domain/desktop/DesktopChatEmptyStateView/DesktopChatEmptyStateView.stories.tsx +75 -0
  428. package/src/components/domain/desktop/DesktopChatEmptyStateView/DesktopChatEmptyStateViewSource.test.mjs +54 -0
  429. package/src/components/domain/desktop/DesktopChatEmptyStateView/index.tsx +64 -0
  430. package/src/components/domain/desktop/DesktopChatHeaderView/DesktopChatHeaderView.stories.tsx +83 -0
  431. package/src/components/domain/desktop/DesktopChatHeaderView/DesktopChatHeaderViewSource.test.mjs +126 -0
  432. package/src/components/domain/desktop/DesktopChatHeaderView/index.tsx +169 -0
  433. package/src/components/domain/desktop/DesktopChatMessageView/DesktopChatMessageView.stories.tsx +170 -0
  434. package/src/components/domain/desktop/DesktopChatMessageView/DesktopChatMessageViewSource.test.mjs +47 -0
  435. package/src/components/domain/desktop/DesktopChatMessageView/index.tsx +213 -0
  436. package/src/components/domain/desktop/DesktopChatTurnView/DesktopChatTurnView.stories.tsx +498 -0
  437. package/src/components/domain/desktop/DesktopChatTurnView/DesktopChatTurnViewSource.test.mjs +187 -0
  438. package/src/components/domain/desktop/DesktopChatTurnView/index.tsx +490 -0
  439. package/src/components/domain/desktop/DesktopComposer/DesktopComposer.stories.tsx +195 -0
  440. package/src/components/domain/desktop/DesktopComposer/DesktopComposerModelPickerSource.test.mjs +132 -0
  441. package/src/components/domain/desktop/DesktopComposer/DesktopComposerMountChipSource.test.mjs +43 -0
  442. package/src/components/domain/desktop/DesktopComposer/DesktopComposerResponsiveSource.test.mjs +44 -0
  443. package/src/components/domain/desktop/DesktopComposer/DesktopMcpFormThemeSource.test.mjs +30 -0
  444. package/src/components/domain/desktop/DesktopComposer/index.tsx +206 -0
  445. package/src/components/domain/desktop/DesktopConnectorDetailView/DesktopConnectorDetailView.stories.tsx +72 -0
  446. package/src/components/domain/desktop/DesktopConnectorDetailView/DesktopConnectorDetailViewSource.test.mjs +81 -0
  447. package/src/components/domain/desktop/DesktopConnectorDetailView/index.tsx +301 -0
  448. package/src/components/domain/desktop/DesktopHomeView/DesktopHomeView.stories.tsx +103 -0
  449. package/src/components/domain/desktop/DesktopHomeView/DesktopHomeViewSource.test.mjs +51 -0
  450. package/src/components/domain/desktop/DesktopHomeView/index.tsx +122 -0
  451. package/src/components/domain/desktop/DesktopLibraryAuthorizationDialog/DesktopLibraryAuthorizationDialog.stories.tsx +55 -0
  452. package/src/components/domain/desktop/DesktopLibraryAuthorizationDialog/index.tsx +156 -0
  453. package/src/components/domain/desktop/DesktopLibraryPageView/DesktopLibraryPageView.stories.tsx +42 -0
  454. package/src/components/domain/desktop/DesktopLibraryPageView/index.tsx +35 -0
  455. package/src/components/domain/desktop/DesktopLoginView/DesktopLoginView.css +75 -0
  456. package/src/components/domain/desktop/DesktopLoginView/DesktopLoginView.stories.tsx +230 -0
  457. package/src/components/domain/desktop/DesktopLoginView/DesktopLoginViewSource.test.mjs +149 -0
  458. package/src/components/domain/desktop/DesktopLoginView/index.tsx +418 -0
  459. package/src/components/domain/desktop/DesktopOnboardingTourView/DesktopOnboardingTourView.stories.tsx +103 -0
  460. package/src/components/domain/desktop/DesktopOnboardingTourView/DesktopOnboardingTourViewSource.test.mjs +57 -0
  461. package/src/components/domain/desktop/DesktopOnboardingTourView/index.tsx +189 -0
  462. package/src/components/domain/desktop/DesktopPet/DesktopPet.fixture.ts +243 -0
  463. package/src/components/domain/desktop/DesktopPet/DesktopPet.stories.tsx +337 -0
  464. package/src/components/domain/desktop/DesktopPet/DesktopPetSource.test.mjs +191 -0
  465. package/src/components/domain/desktop/DesktopPet/index.tsx +591 -0
  466. package/src/components/domain/desktop/DesktopPetSettings/DesktopPetSettings.stories.tsx +159 -0
  467. package/src/components/domain/desktop/DesktopPetSettings/DesktopPetSettingsSource.test.mjs +76 -0
  468. package/src/components/domain/desktop/DesktopPetSettings/index.tsx +140 -0
  469. package/src/components/domain/desktop/DesktopRunStatusView/DesktopRunStatusView.stories.tsx +166 -0
  470. package/src/components/domain/desktop/DesktopRunStatusView/DesktopRunStatusViewSource.test.mjs +51 -0
  471. package/src/components/domain/desktop/DesktopRunStatusView/index.tsx +34 -0
  472. package/src/components/domain/desktop/DesktopSelectionCard/DesktopSelectionCard.stories.tsx +122 -0
  473. package/src/components/domain/desktop/DesktopSelectionCard/DesktopSelectionCardSource.test.mjs +42 -0
  474. package/src/components/domain/desktop/DesktopSelectionCard/index.tsx +75 -0
  475. package/src/components/domain/desktop/DesktopSettingsMemorySection/DesktopSettingsMemorySection.stories.tsx +225 -0
  476. package/src/components/domain/desktop/DesktopSettingsMemorySection/DesktopSettingsMemorySectionSource.test.mjs +105 -0
  477. package/src/components/domain/desktop/DesktopSettingsMemorySection/index.tsx +340 -0
  478. package/src/components/domain/desktop/DesktopSettingsView/DesktopSettingsView.stories.tsx +177 -0
  479. package/src/components/domain/desktop/DesktopSettingsView/DesktopSettingsViewSource.test.mjs +195 -0
  480. package/src/components/domain/desktop/DesktopSettingsView/index.tsx +176 -0
  481. package/src/components/domain/desktop/DesktopShareSelectionBarView/DesktopShareSelectionBarView.stories.tsx +77 -0
  482. package/src/components/domain/desktop/DesktopShareSelectionBarView/DesktopShareSelectionBarViewSource.test.mjs +76 -0
  483. package/src/components/domain/desktop/DesktopShareSelectionBarView/index.tsx +55 -0
  484. package/src/components/domain/desktop/DesktopSidebarView/DesktopSidebarView.stories.tsx +454 -0
  485. package/src/components/domain/desktop/DesktopSidebarView/DesktopSidebarViewSource.test.mjs +386 -0
  486. package/src/components/domain/desktop/DesktopSidebarView/index.tsx +1072 -0
  487. package/src/components/domain/desktop/DesktopSiteReleasesView/DesktopSiteReleasesView.stories.tsx +369 -0
  488. package/src/components/domain/desktop/DesktopSiteReleasesView/DesktopSiteReleasesViewSource.test.mjs +123 -0
  489. package/src/components/domain/desktop/DesktopSiteReleasesView/index.tsx +392 -0
  490. package/src/components/domain/desktop/DesktopSitesListView/DesktopSitesListView.stories.tsx +244 -0
  491. package/src/components/domain/desktop/DesktopSitesListView/DesktopSitesListViewSource.test.mjs +198 -0
  492. package/src/components/domain/desktop/DesktopSitesListView/index.tsx +417 -0
  493. package/src/components/domain/desktop/DesktopSkillsPageView/DesktopSkillsPageView.stories.tsx +230 -0
  494. package/src/components/domain/desktop/DesktopSkillsPageView/DesktopSkillsPageViewSource.test.mjs +149 -0
  495. package/src/components/domain/desktop/DesktopSkillsPageView/index.tsx +235 -0
  496. package/src/components/domain/desktop/DesktopTaskDetailView/index.tsx +111 -0
  497. package/src/components/domain/desktop/DesktopToolCallView/DesktopToolCallListViewSource.test.mjs +302 -0
  498. package/src/components/domain/desktop/DesktopToolCallView/DesktopToolCallView.stories.tsx +409 -0
  499. package/src/components/domain/desktop/DesktopToolCallView/index.tsx +388 -0
  500. package/src/components/domain/desktop/DesktopWorkbenchShell/DesktopWorkbenchShell.stories.tsx +418 -0
  501. package/src/components/domain/desktop/DesktopWorkbenchShell/DesktopWorkbenchShellSource.test.mjs +151 -0
  502. package/src/components/domain/desktop/DesktopWorkbenchShell/index.tsx +167 -0
  503. package/src/components/domain/desktop/DesktopWorkspacePageView/DesktopWorkspacePageView.stories.tsx +135 -0
  504. package/src/components/domain/desktop/DesktopWorkspacePageView/DesktopWorkspacePageViewSource.test.mjs +57 -0
  505. package/src/components/domain/desktop/DesktopWorkspacePageView/index.tsx +114 -0
  506. package/src/components/domain/desktop/DesktopWorkspaceView/DesktopWorkspaceView.stories.tsx +227 -0
  507. package/src/components/domain/desktop/DesktopWorkspaceView/DesktopWorkspaceViewSource.test.mjs +175 -0
  508. package/src/components/domain/desktop/DesktopWorkspaceView/index.tsx +580 -0
  509. package/src/components/domain/desktop/ResourceManagement/ResourceManagement.stories.tsx +19 -0
  510. package/src/components/domain/desktop/ResourceManagement/ResourceManagementSource.test.mjs +54 -0
  511. package/src/components/domain/desktop/ResourceManagement/SharesList.tsx +323 -0
  512. package/src/components/domain/desktop/ResourceManagement/SnapshotViews.tsx +92 -0
  513. package/src/components/domain/desktop/ResourceManagement/SnapshotViewsSource.test.mjs +15 -0
  514. package/src/components/domain/desktop/ResourceManagement/index.tsx +246 -0
  515. package/src/components/domain/desktop/ShareSettingsDialogView/index.tsx +234 -0
  516. package/src/components/domain/desktop/SidePanelEmpty/SidePanelEmpty.stories.tsx +100 -0
  517. package/src/components/domain/desktop/SidePanelEmpty/SidePanelEmptySource.test.mjs +67 -0
  518. package/src/components/domain/desktop/SidePanelEmpty/index.tsx +113 -0
  519. package/src/components/domain/desktop/StarterCapsules/StarterCapsules.stories.tsx +65 -0
  520. package/src/components/domain/desktop/StarterCapsules/StarterCapsulesSource.test.mjs +43 -0
  521. package/src/components/domain/desktop/StarterCapsules/index.tsx +90 -0
  522. package/src/components/domain/desktop/WorkbenchSidePanel/WorkbenchSidePanel.stories.tsx +59 -0
  523. package/src/components/domain/desktop/WorkbenchSidePanel/WorkbenchSidePanelSource.test.mjs +51 -0
  524. package/src/components/domain/desktop/WorkbenchSidePanel/index.tsx +74 -0
  525. package/src/components/domain/desktop/WorkspaceMigrateConfirm/WorkspaceMigrateConfirm.stories.tsx +79 -0
  526. package/src/components/domain/desktop/WorkspaceMigrateConfirm/WorkspaceMigrateConfirmSource.test.mjs +34 -0
  527. package/src/components/domain/desktop/WorkspaceMigrateConfirm/index.tsx +92 -0
  528. package/src/components/domain/desktop/index.ts +64 -0
  529. package/src/components/domain/files/FileBrowser/FileBrowser.stories.tsx +397 -0
  530. package/src/components/domain/files/FileBrowser/FileBrowserSource.test.mjs +75 -0
  531. package/src/components/domain/files/FileBrowser/index.tsx +221 -0
  532. package/src/components/domain/files/FileIcon/FileIcon.stories.tsx +207 -0
  533. package/src/components/domain/files/FileIcon/FileIconSource.test.mjs +39 -0
  534. package/src/components/domain/files/FileIcon/index.tsx +133 -0
  535. package/src/components/domain/files/FilePreviewContentView/FilePreviewContentView.stories.tsx +242 -0
  536. package/src/components/domain/files/FilePreviewContentView/FilePreviewContentViewSource.test.mjs +44 -0
  537. package/src/components/domain/files/FilePreviewContentView/index.tsx +125 -0
  538. package/src/components/domain/files/FileTree/FileTree.stories.tsx +204 -0
  539. package/src/components/domain/files/FileTree/FileTreeSource.test.mjs +18 -0
  540. package/src/components/domain/files/FileTree/index.tsx +106 -0
  541. package/src/components/domain/files/PreviewDialog/PreviewDialog.stories.tsx +178 -0
  542. package/src/components/domain/files/PreviewDialog/PreviewDialogSource.test.mjs +92 -0
  543. package/src/components/domain/files/PreviewDialog/index.tsx +294 -0
  544. package/src/components/domain/files/index.ts +5 -0
  545. package/src/components/domain/index.ts +8 -0
  546. package/src/components/domain/office/CsvPreview/CsvPreview.stories.tsx +264 -0
  547. package/src/components/domain/office/CsvPreview/CsvPreviewSource.test.mjs +77 -0
  548. package/src/components/domain/office/CsvPreview/index.tsx +224 -0
  549. package/src/components/domain/office/OfficePreview/OfficePreview.stories.tsx +265 -0
  550. package/src/components/domain/office/OfficePreview/OfficePreviewDialog.stories.tsx +71 -0
  551. package/src/components/domain/office/OfficePreview/OfficePreviewDialog.tsx +43 -0
  552. package/src/components/domain/office/OfficePreview/OfficePreviewSource.test.mjs +126 -0
  553. package/src/components/domain/office/OfficePreview/index.tsx +782 -0
  554. package/src/components/domain/office/PdfPreview/PdfPreview.stories.tsx +280 -0
  555. package/src/components/domain/office/PdfPreview/PdfPreviewDialog.stories.tsx +61 -0
  556. package/src/components/domain/office/PdfPreview/PdfPreviewDialog.tsx +61 -0
  557. package/src/components/domain/office/PdfPreview/PdfPreviewSource.test.mjs +70 -0
  558. package/src/components/domain/office/PdfPreview/index.tsx +217 -0
  559. package/src/components/domain/office/index.ts +5 -0
  560. package/src/components/domain/skills/McpServerListView/McpServerListView.stories.tsx +510 -0
  561. package/src/components/domain/skills/McpServerListView/McpServerListViewSource.test.mjs +101 -0
  562. package/src/components/domain/skills/McpServerListView/index.tsx +250 -0
  563. package/src/components/domain/skills/SkillAvatarView/SkillAvatarView.stories.tsx +121 -0
  564. package/src/components/domain/skills/SkillAvatarView/SkillAvatarViewSource.test.mjs +67 -0
  565. package/src/components/domain/skills/SkillAvatarView/index.tsx +112 -0
  566. package/src/components/domain/skills/SkillCardView/SkillCardView.stories.tsx +374 -0
  567. package/src/components/domain/skills/SkillCardView/SkillCardViewSource.test.mjs +35 -0
  568. package/src/components/domain/skills/SkillCardView/index.tsx +88 -0
  569. package/src/components/domain/skills/SkillDetailPanelView/SkillDetailPanelView.stories.tsx +113 -0
  570. package/src/components/domain/skills/SkillDetailPanelView/index.tsx +115 -0
  571. package/src/components/domain/skills/SkillDetailView/SkillDetailView.stories.tsx +274 -0
  572. package/src/components/domain/skills/SkillDetailView/index.tsx +121 -0
  573. package/src/components/domain/skills/SkillImportDialogView/SkillImportDialogView.stories.tsx +128 -0
  574. package/src/components/domain/skills/SkillImportDialogView/SkillImportDialogViewSource.test.mjs +11 -0
  575. package/src/components/domain/skills/SkillImportDialogView/index.tsx +147 -0
  576. package/src/components/domain/skills/ToolDetailModalView/ToolDetailModalView.stories.tsx +160 -0
  577. package/src/components/domain/skills/ToolDetailModalView/ToolDetailModalViewSource.test.mjs +99 -0
  578. package/src/components/domain/skills/ToolDetailModalView/index.tsx +160 -0
  579. package/src/components/domain/skills/index.ts +7 -0
  580. package/src/components/domain/tasks/ScheduledTaskCardView/ScheduledTaskCardView.stories.tsx +120 -0
  581. package/src/components/domain/tasks/ScheduledTaskCardView/ScheduledTaskCardViewSource.test.mjs +40 -0
  582. package/src/components/domain/tasks/ScheduledTaskCardView/index.tsx +135 -0
  583. package/src/components/domain/tasks/ScheduledTaskDeleteDialog/ScheduledTaskDeleteDialog.stories.tsx +56 -0
  584. package/src/components/domain/tasks/ScheduledTaskDeleteDialog/ScheduledTaskDeleteDialogSource.test.mjs +35 -0
  585. package/src/components/domain/tasks/ScheduledTaskDeleteDialog/index.tsx +73 -0
  586. package/src/components/domain/tasks/ScheduledTaskDetailView/ScheduledTaskDetailView.stories.tsx +121 -0
  587. package/src/components/domain/tasks/ScheduledTaskDetailView/ScheduledTaskDetailViewSource.test.mjs +115 -0
  588. package/src/components/domain/tasks/ScheduledTaskDetailView/index.tsx +223 -0
  589. package/src/components/domain/tasks/ScheduledTasksSpaceView/ScheduledTasksSpaceView.stories.tsx +526 -0
  590. package/src/components/domain/tasks/ScheduledTasksSpaceView/ScheduledTasksSpaceViewSource.test.mjs +85 -0
  591. package/src/components/domain/tasks/ScheduledTasksSpaceView/index.tsx +118 -0
  592. package/src/components/domain/tasks/index.ts +4 -0
  593. package/src/components/domain/theme/SkinManager.stories.tsx +43 -0
  594. package/src/components/domain/theme/SkinManagerUI.tsx +382 -0
  595. package/src/components/domain/theme/ThemeDemo.stories.tsx +12 -0
  596. package/src/components/domain/theme/ThemeDemo.tsx +224 -0
  597. package/src/components/index.ts +11 -0
  598. package/src/components/primitives/Avatar/Avatar.stories.tsx +170 -0
  599. package/src/components/primitives/Avatar/AvatarSource.test.mjs +37 -0
  600. package/src/components/primitives/Avatar/index.tsx +180 -0
  601. package/src/components/primitives/BackTop/BackTop.stories.tsx +122 -0
  602. package/src/components/primitives/BackTop/BackTopSource.test.mjs +61 -0
  603. package/src/components/primitives/BackTop/index.tsx +93 -0
  604. package/src/components/primitives/Badge/Badge.stories.tsx +376 -0
  605. package/src/components/primitives/Badge/BadgeSource.test.mjs +27 -0
  606. package/src/components/primitives/Badge/index.tsx +65 -0
  607. package/src/components/primitives/Button/Button.stories.tsx +287 -0
  608. package/src/components/primitives/Button/ButtonSource.test.mjs +84 -0
  609. package/src/components/primitives/Button/index.tsx +216 -0
  610. package/src/components/primitives/Card/Card.stories.tsx +186 -0
  611. package/src/components/primitives/Card/CardSource.test.mjs +73 -0
  612. package/src/components/primitives/Card/index.tsx +137 -0
  613. package/src/components/primitives/Checkbox/Checkbox.stories.tsx +79 -0
  614. package/src/components/primitives/Checkbox/CheckboxSource.test.mjs +43 -0
  615. package/src/components/primitives/Checkbox/index.tsx +87 -0
  616. package/src/components/primitives/Chip/Chip.stories.tsx +149 -0
  617. package/src/components/primitives/Chip/ChipSource.test.mjs +73 -0
  618. package/src/components/primitives/Chip/index.tsx +252 -0
  619. package/src/components/primitives/Divider/Divider.stories.tsx +68 -0
  620. package/src/components/primitives/Divider/DividerSource.test.mjs +26 -0
  621. package/src/components/primitives/Divider/index.tsx +65 -0
  622. package/src/components/primitives/Dropdown/Dropdown.stories.tsx +38 -0
  623. package/src/components/primitives/Dropdown/DropdownSource.test.mjs +23 -0
  624. package/src/components/primitives/Dropdown/index.tsx +29 -0
  625. package/src/components/primitives/EmptyState/EmptyState.stories.tsx +159 -0
  626. package/src/components/primitives/EmptyState/EmptyStateSource.test.mjs +169 -0
  627. package/src/components/primitives/EmptyState/index.tsx +185 -0
  628. package/src/components/primitives/ErrorCard/ErrorCard.stories.tsx +50 -0
  629. package/src/components/primitives/ErrorCard/index.tsx +78 -0
  630. package/src/components/primitives/Field/Field.stories.tsx +208 -0
  631. package/src/components/primitives/Field/FieldSource.test.mjs +70 -0
  632. package/src/components/primitives/Field/index.tsx +297 -0
  633. package/src/components/primitives/InlineMessage/InlineMessage.stories.tsx +137 -0
  634. package/src/components/primitives/InlineMessage/InlineMessageSource.test.mjs +50 -0
  635. package/src/components/primitives/InlineMessage/index.tsx +141 -0
  636. package/src/components/primitives/Input/Input.stories.tsx +30 -0
  637. package/src/components/primitives/Input/index.tsx +12 -0
  638. package/src/components/primitives/Keycap/Keycap.stories.tsx +93 -0
  639. package/src/components/primitives/Keycap/KeycapSource.test.mjs +30 -0
  640. package/src/components/primitives/Keycap/index.tsx +67 -0
  641. package/src/components/primitives/Menu/Menu.stories.tsx +416 -0
  642. package/src/components/primitives/Menu/MenuEmptySource.test.mjs +23 -0
  643. package/src/components/primitives/Menu/MenuSource.test.mjs +207 -0
  644. package/src/components/primitives/Menu/index.tsx +922 -0
  645. package/src/components/primitives/Pagination/Pagination.stories.tsx +77 -0
  646. package/src/components/primitives/Pagination/PaginationSource.test.mjs +24 -0
  647. package/src/components/primitives/Pagination/index.tsx +85 -0
  648. package/src/components/primitives/Pagination/pagination.ts +25 -0
  649. package/src/components/primitives/Pagination/paginationModel.test.mjs +18 -0
  650. package/src/components/primitives/ProgressBar/ProgressBar.stories.tsx +103 -0
  651. package/src/components/primitives/ProgressBar/ProgressBarSource.test.mjs +44 -0
  652. package/src/components/primitives/ProgressBar/index.tsx +68 -0
  653. package/src/components/primitives/Radio/Radio.stories.tsx +84 -0
  654. package/src/components/primitives/Radio/RadioSource.test.mjs +38 -0
  655. package/src/components/primitives/Radio/index.tsx +161 -0
  656. package/src/components/primitives/SegmentedControl/SegmentedControl.stories.tsx +110 -0
  657. package/src/components/primitives/SegmentedControl/SegmentedControlSource.test.mjs +75 -0
  658. package/src/components/primitives/SegmentedControl/index.tsx +188 -0
  659. package/src/components/primitives/Select/Select.stories.tsx +158 -0
  660. package/src/components/primitives/Select/SelectSource.test.mjs +94 -0
  661. package/src/components/primitives/Select/index.tsx +364 -0
  662. package/src/components/primitives/Spinner/index.tsx +58 -0
  663. package/src/components/primitives/Switch/Switch.stories.tsx +64 -0
  664. package/src/components/primitives/Switch/SwitchSource.test.mjs +38 -0
  665. package/src/components/primitives/Switch/index.tsx +84 -0
  666. package/src/components/primitives/Tabs/Tabs.stories.tsx +230 -0
  667. package/src/components/primitives/Tabs/TabsSource.test.mjs +91 -0
  668. package/src/components/primitives/Tabs/index.tsx +183 -0
  669. package/src/components/primitives/index.ts +24 -0
  670. package/src/examples/ResourceManagementExample.tsx +119 -0
  671. package/src/examples/SiteWorkbenchExample.tsx +96 -0
  672. package/src/hooks/index.ts +7 -0
  673. package/src/hooks/useClickOutside.ts +20 -0
  674. package/src/hooks/useDragReorder.ts +29 -0
  675. package/src/hooks/useImeAwareEnter.ts +59 -0
  676. package/src/hooks/useImeAwareEnterSource.test.mjs +65 -0
  677. package/src/hooks/useKeyboard.ts +16 -0
  678. package/src/hooks/usePopover.ts +67 -0
  679. package/src/hooks/useSelectedOptionLocator.ts +33 -0
  680. package/src/hooks/useSidebarResize.ts +107 -0
  681. package/src/hooks/useTenantTheme.ts +53 -0
  682. package/src/hooks/useUnifiedTheme.ts +85 -0
  683. package/src/index.ts +6 -0
  684. package/src/lib/InjectedStyleTokenMirrorSource.test.mjs +67 -0
  685. package/src/lib/about-window.test.mjs +46 -0
  686. package/src/lib/about-window.ts +218 -0
  687. package/src/lib/appearance.test.mjs +283 -0
  688. package/src/lib/appearance.ts +46 -0
  689. package/src/lib/browser-annotation-popup.ts +151 -0
  690. package/src/lib/focusTrap.ts +51 -0
  691. package/src/lib/index.ts +5 -0
  692. package/src/lib/shortcut.test.mjs +100 -0
  693. package/src/lib/shortcut.ts +97 -0
  694. package/src/lib/twMergeOw.ts +18 -0
  695. package/src/lib/utils.ts +6 -0
  696. package/src/screens/Browser.stories.tsx +353 -0
  697. package/src/screens/Chat.stories.tsx +808 -0
  698. package/src/screens/Home.stories.tsx +253 -0
  699. package/src/screens/Login.stories.tsx +134 -0
  700. package/src/screens/McpManager.stories.tsx +159 -0
  701. package/src/screens/Onboarding.stories.tsx +155 -0
  702. package/src/screens/ScheduledTasks.stories.tsx +134 -0
  703. package/src/screens/ScreenFrameSource.test.mjs +77 -0
  704. package/src/screens/SettingsAppearance.stories.tsx +117 -0
  705. package/src/screens/SettingsMemory.stories.tsx +128 -0
  706. package/src/screens/SettingsModels.stories.tsx +228 -0
  707. package/src/screens/SettingsSections.stories.tsx +164 -0
  708. package/src/screens/Share.stories.tsx +202 -0
  709. package/src/screens/SharePage.stories.tsx +29 -0
  710. package/src/screens/Sites.stories.tsx +183 -0
  711. package/src/screens/Skills.stories.tsx +83 -0
  712. package/src/screens/Workspace.stories.tsx +191 -0
  713. package/src/screens/_home.tsx +46 -0
  714. package/src/screens/_screen.tsx +355 -0
  715. package/src/screens/_settingsNav.ts +27 -0
  716. package/src/screens/_skillsCatalog.tsx +372 -0
  717. package/src/theme/SkinDenylistSyncSource.test.mjs +124 -0
  718. package/src/theme/__tests__/skins.test.mjs +84 -0
  719. package/src/theme/core/semanticAdapter.ts +116 -0
  720. package/src/theme/core/skin.ts +605 -0
  721. package/src/theme/core/skinScoped.ts +289 -0
  722. package/src/theme/core/tenantTheme.test.mjs +127 -0
  723. package/src/theme/core/tenantTheme.ts +124 -0
  724. package/src/theme/core/types.ts +60 -0
  725. package/src/theme/core/unifiedTheme.ts +157 -0
  726. package/src/theme/index.ts +33 -0
  727. package/src/theme/providers/BrandingProvider.tsx +57 -0
  728. package/src/theme/providers/ThemeProvider.tsx +221 -0
  729. package/src/theme/skinDs2PropertyGate.test.mjs +109 -0
  730. package/src/theme/skins/index.ts +107 -0
  731. package/src/theme/utils/cssSafety.ts +92 -0
  732. package/src/theme/utils/skinManager.ts +159 -0
  733. package/src/theme/utils/themeApplier.ts +75 -0
  734. package/src/tokens/DesktopSurfacesSweep15Source.test.mjs +77 -0
  735. package/src/tokens/SharedStyleSheetsSource.test.mjs +90 -0
  736. package/src/tokens/TailwindThemeSupplySource.test.mjs +129 -0
  737. package/src/tokens/base.ts +199 -0
  738. package/src/tokens/dark.ts +288 -0
  739. package/src/tokens/index.ts +4 -0
  740. package/src/tokens/light.ts +320 -0
  741. package/src/tokens/tailwind.ts +216 -0
  742. package/src/types/desktop-pet.ts +100 -0
  743. package/src/types/file-browser.ts +51 -0
  744. package/src/types/file-tree.ts +34 -0
  745. package/src/types/index.ts +3 -0
  746. package/src/types/xspreadsheet.d.ts +4 -0
  747. package/src/utils/cn.ts +6 -0
  748. package/src/utils/glyphColor.ts +32 -0
  749. package/src/utils/index.ts +4 -0
  750. package/src/utils/localPathInline.test.mjs +45 -0
  751. package/src/utils/localPathInline.ts +49 -0
  752. package/src/utils/markdownFileRefs.test.mjs +88 -0
  753. package/src/utils/markdownFileRefs.ts +140 -0
  754. package/src/utils/office-excel.ts +452 -0
  755. package/src/utils/shiki.ts +156 -0
@@ -0,0 +1,782 @@
1
+ "use client"
2
+
3
+ import {
4
+ type CSSProperties,
5
+ type ComponentProps,
6
+ type KeyboardEvent as ReactKeyboardEvent,
7
+ type ReactNode,
8
+ type PointerEvent as ReactPointerEvent,
9
+ memo,
10
+ useCallback,
11
+ useEffect,
12
+ useRef,
13
+ useState,
14
+ } from "react"
15
+ import { cn } from "../../../../lib/utils"
16
+ import { createSpreadsheet, readOnlyInput, transferExcelToSpreadSheet } from "../../../../utils/office-excel"
17
+ import { ZoomIn, ZoomOut } from "../../../composite/Icons"
18
+ import { PptxSlide } from "../../../composite/PptxRenderer/PptxSlide"
19
+ import { PT_TO_PX } from "../../../composite/PptxRenderer/constants"
20
+ import type { PptxParseResult } from "../../../composite/PptxRenderer/types"
21
+ import { Skeleton } from "../../../composite/Skeleton"
22
+ import { Button, EmptyState, InlineMessage } from "../../../primitives"
23
+ import { type AttachmentMenuOption, OpenWithMenu } from "../../chat/Attachment"
24
+
25
+ // ─── OfficePreview ───
26
+
27
+ /**
28
+ * OfficePreview —— 04 预览域的 Office 适配器(Word / Excel / PowerPoint)。
29
+ *
30
+ * 归口口径(蓝图批次④「PreviewDialog 壳 + 各适配器」):适配器只负责**内容**,
31
+ * 壳(标题栏读数、下载/打开方式动作组、模态立面、载/错/空三态)一律交给
32
+ * `FilePreviewDialog`。`chrome={false}` 就是「我坐在壳里」的开关:关掉自绘的
33
+ * 卡片边框与圆角,让内容铺满壳的内容区。开箱即用的组合见同目录 `OfficePreviewDialog`。
34
+ *
35
+ * 衬底制式:Office 走壳的 `plain` 而非 `paper`——三种渲染器各自带纸
36
+ * (docx-preview 的白页衬灰底、pptx 的幻灯片底、x-spreadsheet 的 canvas 恒亮网格,
37
+ * 见 styles/xspreadsheet.css 头注释的两域划分),壳再叠一层纸会出现纸中纸。
38
+ *
39
+ * R3 中性件:无信标/荧黄元素;缩放读数按 §7 走 mono+tabular-nums。
40
+ */
41
+ export type OfficeFileType = "word" | "excel" | "powerpoint" | "unknown"
42
+
43
+ export type OfficePreviewProps = ComponentProps<"div"> & {
44
+ /** 文件 URL(http、blob、或本地文件协议) */
45
+ src?: string
46
+ /** 文件类型提示 */
47
+ fileType?: OfficeFileType
48
+ /**
49
+ * 自定义加载指示器。没有 `src` 时传它即视为**调用方自述载中**(取文件的那一层
50
+ * 知道自己在载),此时出载态而不是空态——载态优先于空态。
51
+ */
52
+ loading?: ReactNode
53
+ /** 自定义错误内容 */
54
+ error?: ReactNode
55
+ /**
56
+ * 自绘卡片立面(边框+圆角)。坐进 `FilePreviewDialog` 壳时传 `false`:
57
+ * 壳已经给了模态立面,适配器再画一圈边就成了双层框。默认 `true` 保持独立可用。
58
+ */
59
+ chrome?: boolean
60
+ /** 用系统默认应用打开文件的回调(简单模式) */
61
+ onOpen?: () => void
62
+ /** "打开方式"菜单选项列表加载器(和 Attachment 卡一致) */
63
+ onRequestOpenWithOptions?: () => Promise<AttachmentMenuOption[]> | AttachmentMenuOption[]
64
+ /** "打开方式"菜单选中回调 */
65
+ onOpenWith?: (option: AttachmentMenuOption) => void
66
+ }
67
+
68
+ const FILE_TYPE_LABELS: Record<OfficeFileType, string> = {
69
+ word: "Word 文档",
70
+ excel: "Excel 表格",
71
+ powerpoint: "PowerPoint 演示",
72
+ unknown: "Office 文档",
73
+ }
74
+
75
+ type RenderState = "idle" | "loading" | "ready" | "empty" | "error"
76
+
77
+ /**
78
+ * 带中文人话的解析错误。第三方解析库(docx-preview / exceljs / pptxtojson)与 fetch
79
+ * 抛的都是裸英文,直接甩给用户就是 V1 的「把 stack 当文案」。§6 错误态口径=
80
+ * **人话一句 + mono ≤2 行详情**:`human` 出正文,原文降级进折叠的 mono 详情。
81
+ */
82
+ class OfficeLoadError extends Error {
83
+ human: string
84
+ detail: string
85
+ constructor(human: string, detail = "") {
86
+ super(human)
87
+ this.name = "OfficeLoadError"
88
+ this.human = human
89
+ this.detail = detail
90
+ }
91
+ }
92
+
93
+ /** 把第三方库/网络层的裸英文归成一句中文人话;归不上的落通用句,原文仍留在 mono 详情里。 */
94
+ function localizeOfficeError(raw: string, fileType: OfficeFileType): string {
95
+ const label = FILE_TYPE_LABELS[fileType]
96
+ if (/network|failed to fetch|load failed|err_|dns/i.test(raw)) return `${label}没取到,检查一下文件地址还在不在。`
97
+ if (/password|encrypt/i.test(raw)) return `${label}设了密码,先解除保护再预览。`
98
+ if (/corrupt|invalid|malformed|zip|central directory|unexpected end/i.test(raw))
99
+ return `${label}读不出来,文件可能已经损坏。`
100
+ return `${label}没解析出来。`
101
+ }
102
+
103
+ export function OfficePreview({
104
+ className = "",
105
+ src,
106
+ fileType = "unknown",
107
+ loading: loadingNode,
108
+ error: errorNode,
109
+ chrome = true,
110
+ onOpen,
111
+ onRequestOpenWithOptions,
112
+ onOpenWith,
113
+ children,
114
+ ...props
115
+ }: OfficePreviewProps) {
116
+ const containerRef = useRef<HTMLDivElement>(null)
117
+ const bodyRef = useRef<HTMLDivElement>(null)
118
+ const renderIdRef = useRef(0)
119
+ const bufferRef = useRef<ArrayBuffer | null>(null)
120
+ const [state, setState] = useState<RenderState>("idle")
121
+ const [errorMsg, setErrorMsg] = useState("")
122
+ // 裸英文原文只进 mono 详情行,不当正文(§6 人话一句 + mono ≤2 行)
123
+ const [errorDetail, setErrorDetail] = useState("")
124
+ // x-spreadsheet 自带 ResizeObserver 与实例,卸载时要一起收掉
125
+ const excelDisposeRef = useRef<(() => void) | null>(null)
126
+
127
+ // PowerPoint state
128
+ const [pptxData, setPptxData] = useState<PptxParseResult | null>(null)
129
+ const [slideCount, setSlideCount] = useState(0)
130
+ const [activeSlide, setActiveSlide] = useState(0)
131
+ const [pptZoom, setPptZoom] = useState(1)
132
+ const [slideFitScale, setSlideFitScale] = useState(0)
133
+ const mainSlideRef = useRef<HTMLDivElement>(null)
134
+ const pptxBodyRef = useRef<HTMLDivElement>(null)
135
+
136
+ useEffect(() => {
137
+ const container = containerRef.current
138
+ if (!src || !container) {
139
+ setState("idle")
140
+ return
141
+ }
142
+
143
+ const renderId = renderIdRef.current + 1
144
+ renderIdRef.current = renderId
145
+ const superseded = () => renderIdRef.current !== renderId
146
+
147
+ setState("loading")
148
+ setErrorMsg("")
149
+ setErrorDetail("")
150
+
151
+ void (async () => {
152
+ try {
153
+ let buffer: ArrayBuffer
154
+ if (bufferRef.current) {
155
+ buffer = bufferRef.current
156
+ } else {
157
+ const response = await fetch(src)
158
+ if (!response.ok)
159
+ throw new OfficeLoadError(
160
+ `${FILE_TYPE_LABELS[fileType]}没取到,检查一下文件地址还在不在。`,
161
+ `HTTP ${response.status} ${response.statusText}`.trim(),
162
+ )
163
+ buffer = await response.arrayBuffer()
164
+ if (superseded()) return
165
+ bufferRef.current = buffer
166
+ }
167
+
168
+ container.replaceChildren()
169
+ switch (fileType) {
170
+ case "word":
171
+ await renderWord(buffer, container)
172
+ break
173
+ case "excel": {
174
+ excelDisposeRef.current?.()
175
+ const dispose = await renderExcel(buffer, container, () => ({
176
+ width: bodyRef.current?.clientWidth ?? 0,
177
+ height: bodyRef.current?.clientHeight ?? 0,
178
+ }))
179
+ excelDisposeRef.current = dispose
180
+ if (superseded()) return
181
+ // 空工作簿:没有实例可挂,落 empty 档由 React 渲 EmptyState。
182
+ if (!dispose) {
183
+ setState("empty")
184
+ return
185
+ }
186
+ break
187
+ }
188
+ case "powerpoint": {
189
+ const { parse } = await import("pptxtojson")
190
+ const result = await parse(buffer, {
191
+ imageMode: "base64",
192
+ videoMode: "blob",
193
+ audioMode: "blob",
194
+ })
195
+ if (superseded()) return
196
+ setPptxData(result as PptxParseResult)
197
+ setSlideCount(result.slides.length)
198
+ setActiveSlide(0)
199
+ break
200
+ }
201
+ default:
202
+ throw new OfficeLoadError("这种文件暂时打不开。", `unsupported fileType: ${fileType}`)
203
+ }
204
+ if (superseded()) return
205
+ setState("ready")
206
+ } catch (err) {
207
+ if (superseded()) return
208
+ const raw = err instanceof Error ? err.message : String(err ?? "")
209
+ setState("error")
210
+ setErrorMsg(err instanceof OfficeLoadError ? err.human : localizeOfficeError(raw, fileType))
211
+ setErrorDetail(err instanceof OfficeLoadError ? err.detail : raw)
212
+ }
213
+ })()
214
+
215
+ return () => {
216
+ renderIdRef.current += 1
217
+ }
218
+ }, [src, fileType])
219
+
220
+ // 组件卸载时收掉 x-spreadsheet 实例与它的 ResizeObserver
221
+ useEffect(
222
+ () => () => {
223
+ excelDisposeRef.current?.()
224
+ excelDisposeRef.current = null
225
+ },
226
+ [],
227
+ )
228
+
229
+ useEffect(() => {
230
+ bufferRef.current = null
231
+ setPptxData(null)
232
+ setSlideCount(0)
233
+ setActiveSlide(0)
234
+ }, [src])
235
+
236
+ // Zoom & pan interaction on main panel
237
+ useEffect(() => {
238
+ if (fileType !== "powerpoint" || !slideCount) return
239
+ const slide = mainSlideRef.current
240
+ const panel = slide?.parentElement
241
+ if (!panel || !slide) return
242
+
243
+ const baseZoom = pptxBodyRef.current?.dataset.owState === "collapsed" ? 0.9 : 1
244
+ let zoom = baseZoom
245
+ let panX = 0
246
+ let panY = 0
247
+ let dragging = false
248
+ let startX = 0
249
+ let startY = 0
250
+ let startPanX = 0
251
+ let startPanY = 0
252
+
253
+ const applyTransform = () => {
254
+ slide.style.transform = `scale(${zoom}) translate(${panX}px, ${panY}px)`
255
+ setPptZoom(zoom)
256
+ panel.style.cursor = zoom > 1.01 ? "grab" : ""
257
+ }
258
+
259
+ const onWheel = (e: WheelEvent) => {
260
+ if (e.ctrlKey || e.metaKey) {
261
+ e.preventDefault()
262
+ const delta = -e.deltaY * 0.01
263
+ zoom = Math.min(5, Math.max(0.25, zoom + delta))
264
+ if (zoom <= 1) {
265
+ panX = 0
266
+ panY = 0
267
+ }
268
+ applyTransform()
269
+ } else if (zoom > 1.01) {
270
+ e.preventDefault()
271
+ panX -= e.deltaX / zoom
272
+ panY -= e.deltaY / zoom
273
+ applyTransform()
274
+ }
275
+ }
276
+
277
+ const onPointerDown = (e: PointerEvent) => {
278
+ if (zoom <= 1.01) return
279
+ e.preventDefault()
280
+ dragging = true
281
+ startX = e.clientX
282
+ startY = e.clientY
283
+ startPanX = panX
284
+ startPanY = panY
285
+ panel.style.cursor = "grabbing"
286
+ panel.setPointerCapture(e.pointerId)
287
+ }
288
+
289
+ const onPointerMove = (e: PointerEvent) => {
290
+ if (!dragging) return
291
+ panX = startPanX + (e.clientX - startX) / zoom
292
+ panY = startPanY + (e.clientY - startY) / zoom
293
+ applyTransform()
294
+ }
295
+
296
+ const onPointerUp = (e: PointerEvent) => {
297
+ if (!dragging) return
298
+ dragging = false
299
+ panel.style.cursor = zoom > 1.01 ? "grab" : ""
300
+ panel.releasePointerCapture(e.pointerId)
301
+ }
302
+
303
+ const onDblClick = () => {
304
+ zoom = baseZoom
305
+ panX = 0
306
+ panY = 0
307
+ applyTransform()
308
+ }
309
+
310
+ const setZoomFromToolbar = (newZoom: number) => {
311
+ zoom = Math.min(5, Math.max(0.25, newZoom))
312
+ if (zoom <= 1) {
313
+ panX = 0
314
+ panY = 0
315
+ }
316
+ applyTransform()
317
+ }
318
+ ;(panel as any).__pptxSetZoom = setZoomFromToolbar
319
+
320
+ panel.addEventListener("wheel", onWheel, { passive: false })
321
+ panel.addEventListener("pointerdown", onPointerDown)
322
+ panel.addEventListener("pointermove", onPointerMove)
323
+ panel.addEventListener("pointerup", onPointerUp)
324
+ panel.addEventListener("dblclick", onDblClick)
325
+
326
+ return () => {
327
+ panel.removeEventListener("wheel", onWheel)
328
+ panel.removeEventListener("pointerdown", onPointerDown)
329
+ panel.removeEventListener("pointermove", onPointerMove)
330
+ panel.removeEventListener("pointerup", onPointerUp)
331
+ panel.removeEventListener("dblclick", onDblClick)
332
+ delete (panel as any).__pptxSetZoom
333
+ }
334
+ }, [fileType, slideCount, activeSlide])
335
+
336
+ const handleZoomChange = (newZoom: number) => {
337
+ const panel = mainSlideRef.current?.parentElement
338
+ if (panel && (panel as any).__pptxSetZoom) {
339
+ ;(panel as any).__pptxSetZoom(newZoom)
340
+ }
341
+ }
342
+
343
+ const handlePptxKeyDown = useCallback(
344
+ (event: ReactKeyboardEvent<HTMLDivElement>) => {
345
+ if (event.key !== "ArrowUp" && event.key !== "ArrowDown") return
346
+
347
+ const target = event.target as HTMLElement
348
+ if (target.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(target.tagName)) return
349
+
350
+ event.preventDefault()
351
+ const offset = event.key === "ArrowUp" ? -1 : 1
352
+ setActiveSlide((current) => Math.min(Math.max(current + offset, 0), slideCount - 1))
353
+ },
354
+ [slideCount],
355
+ )
356
+
357
+ const handlePptxPointerDown = useCallback((event: ReactPointerEvent<HTMLDivElement>) => {
358
+ const target = event.target as HTMLElement
359
+ if (target.closest('button, a, input, textarea, select, [contenteditable="true"]')) return
360
+ event.currentTarget.focus({ preventScroll: true })
361
+ }, [])
362
+
363
+ useEffect(() => {
364
+ if (!slideCount) return
365
+ const activeThumbnail = pptxBodyRef.current?.querySelector<HTMLElement>(
366
+ "[data-slot='pptx-thumb'][data-ow-state='active']",
367
+ )
368
+ activeThumbnail?.scrollIntoView({ block: "nearest" })
369
+ }, [activeSlide, slideCount])
370
+
371
+ // Toggle collapsed class based on panel width
372
+ useEffect(() => {
373
+ if (fileType !== "powerpoint" || !pptxBodyRef.current) return
374
+ const body = pptxBodyRef.current
375
+ const check = () => {
376
+ if (body.clientWidth < 750) {
377
+ body.dataset.owState = "collapsed"
378
+ } else {
379
+ delete body.dataset.owState
380
+ }
381
+ }
382
+ check()
383
+ const observer = new ResizeObserver(check)
384
+ observer.observe(body)
385
+ return () => observer.disconnect()
386
+ }, [fileType, slideCount])
387
+
388
+ // Compute fit scale for main slide based on panel size
389
+ useEffect(() => {
390
+ if (fileType !== "powerpoint" || !pptxData || !slideCount) return
391
+ const slide = mainSlideRef.current
392
+ const panel = slide?.parentElement
393
+ if (!panel) return
394
+
395
+ const refit = () => {
396
+ const panelWidth = panel.clientWidth
397
+ const panelHeight = panel.clientHeight
398
+ if (!panelWidth || !panelHeight) return
399
+ const nativeW = pptxData.size.width * PT_TO_PX
400
+ const nativeH = pptxData.size.height * PT_TO_PX
401
+ const collapsed = pptxBodyRef.current?.dataset.owState === "collapsed"
402
+ const fitRatio = collapsed ? 0.81 : 0.9
403
+ const scale = Math.min((panelWidth * fitRatio) / nativeW, (panelHeight * fitRatio) / nativeH)
404
+ setSlideFitScale(scale)
405
+ }
406
+ refit()
407
+ const observer = new ResizeObserver(refit)
408
+ observer.observe(panel)
409
+ return () => observer.disconnect()
410
+ }, [fileType, slideCount, pptxData])
411
+
412
+ const isPptx = fileType === "powerpoint" && state === "ready" && slideCount > 0
413
+ // 调用方给了自定义 loading 节点却还没有 src = 它自己在取文件,自述「载中」。
414
+ // 原来 `!src` 分支排在 `state === "loading"` 前面,state 恒为 idle,loadingNode 永不可达
415
+ // ——WordLoading 那类 story 渲出来是空态不是载态。载态优先于空态。
416
+ const selfDeclaredLoading = !src && loadingNode != null
417
+
418
+ return (
419
+ <div
420
+ data-slot="office-preview"
421
+ data-ow-chrome={chrome ? undefined : "none"}
422
+ className={cn(
423
+ "flex flex-col w-full h-full bg-ow-bg overflow-hidden",
424
+ // 坐进 PreviewDialog 壳时不再自绘立面(§5 一件事只有一层边)
425
+ chrome && "[border-radius:var(--ow-radius-card)] border border-ow-border-strong",
426
+ className,
427
+ )}
428
+ {...props}
429
+ >
430
+ {/* Body */}
431
+ <div
432
+ data-ow-part="body"
433
+ className="flex-1 min-h-0 relative flex flex-col items-center justify-center pl-0.5"
434
+ ref={bodyRef}
435
+ >
436
+ {/* §6 容器三态:空=EmptyState 信标母题(G5)· 载=Skeleton 呼吸(禁 shimmer)·
437
+ 错=InlineMessage error tint 三件套(人话一句 + 折叠 mono 详情)。
438
+ 原来三态共用一个 text-3 灰字居中的 div,空态还自画了一套彩色文件类型图标
439
+ ——判断表「空态:灰字居中 → G5」,且母题唯一语汇是信标。 */}
440
+ {state === "loading" || selfDeclaredLoading ? (
441
+ <div
442
+ data-ow-part="loading"
443
+ role="status"
444
+ aria-live="polite"
445
+ aria-label={`正在打开${FILE_TYPE_LABELS[fileType]}`}
446
+ className="flex w-full max-w-[560px] flex-col gap-3 p-8"
447
+ >
448
+ {loadingNode ?? (
449
+ <>
450
+ <Skeleton variant="line" height={18} width="46%" />
451
+ <Skeleton variant="line" height={13} />
452
+ <Skeleton variant="line" height={13} />
453
+ <Skeleton variant="line" height={13} width="78%" />
454
+ <Skeleton variant="block" height={180} />
455
+ </>
456
+ )}
457
+ </div>
458
+ ) : !src ? (
459
+ <div data-ow-part="empty" className="flex w-full items-center justify-center p-8">
460
+ <EmptyState message={`暂无 ${FILE_TYPE_LABELS[fileType]}`} />
461
+ </div>
462
+ ) : state === "empty" ? (
463
+ <div data-ow-part="empty" className="flex w-full items-center justify-center p-8">
464
+ <EmptyState message="这个表格里没有工作表。" />
465
+ </div>
466
+ ) : state === "error" ? (
467
+ <div data-ow-part="error" className="flex w-full max-w-[560px] flex-col p-8">
468
+ {errorNode ?? (
469
+ <InlineMessage variant="error" detail={errorDetail}>
470
+ {errorMsg || `${FILE_TYPE_LABELS[fileType]}没解析出来。`}
471
+ </InlineMessage>
472
+ )}
473
+ </div>
474
+ ) : null}
475
+
476
+ {/* PowerPoint dual-panel layout */}
477
+ {isPptx && pptxData && (
478
+ <div data-ow-part="pptx-panels" className="flex flex-col w-full flex-1 min-h-0 overflow-hidden self-stretch">
479
+ {/* Toolbar */}
480
+ <div
481
+ data-ow-part="pptx-toolbar"
482
+ /* §7 控件高:条高钉 --ow-h-lg(40),不再用 py-1.5 靠 6+28+6 凑(同簇 PdfPreview header 同口径)。 */
483
+ className="flex items-center gap-1 px-3 border-b border-ow-border flex-shrink-0 bg-ow-bg"
484
+ style={{ height: "var(--ow-h-lg)" }}
485
+ >
486
+ <span data-ow-part="spacer" className="flex-1" />
487
+ <Button
488
+ type="button"
489
+ data-ow-part="toolbar-btn"
490
+ variant="ghost"
491
+ size="sm"
492
+ className="w-7 h-7 p-0 text-ow-text-2 hover:bg-ow-surface"
493
+ onClick={() => handleZoomChange(pptZoom - 0.25)}
494
+ title="缩小"
495
+ >
496
+ <ZoomOut width={14} height={14} />
497
+ </Button>
498
+ <span
499
+ data-ow-part="toolbar-zoom"
500
+ // §7 读数(百分比)一律 mono + tabular-nums,缩放时数字不跳宽
501
+ className="min-w-10 text-center font-medium text-ow-fs-caption leading-none font-[family-name:var(--ow-font-mono)] [font-variant-numeric:tabular-nums] text-ow-text-2 select-none"
502
+ >
503
+ {Math.round(pptZoom * 100)}%
504
+ </span>
505
+ <Button
506
+ type="button"
507
+ data-ow-part="toolbar-btn"
508
+ variant="ghost"
509
+ size="sm"
510
+ className="w-7 h-7 p-0 text-ow-text-2 hover:bg-ow-surface"
511
+ onClick={() => handleZoomChange(pptZoom + 0.25)}
512
+ title="放大"
513
+ >
514
+ <ZoomIn width={14} height={14} />
515
+ </Button>
516
+ {(onOpen || onRequestOpenWithOptions) && (
517
+ <OpenWithMenu
518
+ label="打开方式"
519
+ onOpen={onOpen}
520
+ onRequestOptions={onRequestOpenWithOptions}
521
+ onSelect={onOpenWith}
522
+ />
523
+ )}
524
+ </div>
525
+ <div
526
+ data-ow-part="pptx-body"
527
+ /* 焦点环三件套(§6 既定态):环宽/环色/缝全走 token。这一格铺满壳的内容区且父级
528
+ overflow-hidden,正 offset 会被裁掉,所以缝取负值内收(同 xspreadsheet.css / assistant-settings.css)。 */
529
+ className="grid grid-cols-[200px_minmax(0,1fr)] grid-rows-[1fr] flex-1 min-h-0 overflow-hidden relative focus:outline-none focus-visible:[outline:var(--ow-focus-ring-w)_solid_var(--ow-focus-ring)] focus-visible:[outline-offset:calc(var(--ow-focus-ring-offset)*-1)]"
530
+ ref={pptxBodyRef}
531
+ tabIndex={0}
532
+ role="region"
533
+ aria-label={`PowerPoint 预览,第 ${activeSlide + 1} 页,共 ${slideCount} 页`}
534
+ onKeyDown={handlePptxKeyDown}
535
+ onPointerDown={handlePptxPointerDown}
536
+ >
537
+ {/* Thumbnails */}
538
+ <div
539
+ data-ow-part="pptx-thumbs"
540
+ /* §5 表面三档:贴地侧栏取实心面档 --ow-surface,不做半透明毛玻璃
541
+ (bg-ow-bg/72 + backdrop-blur 是 V1 的「玻璃层」语汇,2.0 只有地/面/井三档)。 */
542
+ className="flex flex-col gap-2 py-4 px-3 overflow-y-auto overflow-x-hidden min-h-0 border-r border-ow-border bg-ow-surface scrollbar-thin"
543
+ >
544
+ {pptxData.slides.map((slide, i) => (
545
+ <PptxThumbnail
546
+ key={i}
547
+ slide={slide}
548
+ index={i}
549
+ isActive={i === activeSlide}
550
+ slideWidth={pptxData.size.width}
551
+ slideHeight={pptxData.size.height}
552
+ onClick={setActiveSlide}
553
+ />
554
+ ))}
555
+ </div>
556
+ {/* Main slide panel */}
557
+ <div
558
+ data-ow-part="pptx-main"
559
+ className="relative overflow-hidden bg-ow-surface flex items-center justify-center min-h-0 h-full"
560
+ >
561
+ <div
562
+ data-ow-part="pptx-slide"
563
+ /* §5 贴地零影:幻灯片坐在 pptx-main 面板里是贴地内容不是弹层,
564
+ 纸面立边靠 1px --ow-border 表达(同文件 renderWord 也在 strip
565
+ docx-preview 注入的 box-shadow,口径就此一致)。 */
566
+ className="relative overflow-hidden [border-radius:var(--ow-radius-md)] border border-ow-border origin-center flex-shrink-0"
567
+ ref={mainSlideRef}
568
+ style={{
569
+ width: pptxData.size.width * PT_TO_PX * slideFitScale,
570
+ height: pptxData.size.height * PT_TO_PX * slideFitScale,
571
+ }}
572
+ >
573
+ <div
574
+ style={{
575
+ transform: `scale(${slideFitScale})`,
576
+ transformOrigin: "top left",
577
+ }}
578
+ >
579
+ {pptxData.slides[activeSlide] && (
580
+ <PptxSlide
581
+ slide={pptxData.slides[activeSlide]}
582
+ slideWidth={pptxData.size.width}
583
+ slideHeight={pptxData.size.height}
584
+ />
585
+ )}
586
+ </div>
587
+ </div>
588
+ </div>
589
+ </div>
590
+ </div>
591
+ )}
592
+
593
+ {/* Non-pptx content container */}
594
+ <div
595
+ ref={containerRef}
596
+ data-ow-part="content"
597
+ className="w-full h-full overflow-auto box-border"
598
+ style={{ display: state === "ready" && !isPptx ? undefined : "none" }}
599
+ />
600
+ {children}
601
+ </div>
602
+ </div>
603
+ )
604
+ }
605
+
606
+ // ─── Thumbnail ───
607
+
608
+ interface PptxThumbnailProps {
609
+ slide: PptxParseResult["slides"][number]
610
+ index: number
611
+ isActive: boolean
612
+ slideWidth: number
613
+ slideHeight: number
614
+ onClick: (index: number) => void
615
+ }
616
+
617
+ const PptxThumbnail = memo(function PptxThumbnail({
618
+ slide,
619
+ index,
620
+ isActive,
621
+ slideWidth,
622
+ slideHeight,
623
+ onClick,
624
+ }: PptxThumbnailProps) {
625
+ const nativeWidthPx = slideWidth * PT_TO_PX
626
+ const nativeHeightPx = slideHeight * PT_TO_PX
627
+ const thumbRef = useRef<HTMLSpanElement>(null)
628
+ const [thumbScale, setThumbScale] = useState(0)
629
+
630
+ useEffect(() => {
631
+ const el = thumbRef.current
632
+ if (!el) return
633
+ const compute = () => {
634
+ const w = el.clientWidth
635
+ if (w > 0) setThumbScale(w / nativeWidthPx)
636
+ }
637
+ compute()
638
+ const observer = new ResizeObserver(compute)
639
+ observer.observe(el)
640
+ return () => observer.disconnect()
641
+ }, [nativeWidthPx])
642
+
643
+ const handleClick = useCallback(() => onClick(index), [onClick, index])
644
+
645
+ return (
646
+ <Button
647
+ type="button"
648
+ data-slot="pptx-thumb"
649
+ data-ow-state={isActive ? "active" : undefined}
650
+ variant="unstyled"
651
+ /* R2/§15:选中态不能用 --ow-primary tint —— 暗档 primary 就是荧黄,一列缩略图
652
+ 全成状态极。改中性底(hover→selected-bg)+当前页边框加粗+页码提色,
653
+ R1 双编码里形状与文字各占一样,颜色只做第二编码。§9 动效走 ease-beacon 120ms。 */
654
+ className="group grid grid-cols-[32px_minmax(0,1fr)] items-center gap-2 p-2 border-0 [border-radius:var(--ow-radius-sm)] bg-transparent cursor-pointer text-left [transition:background-color_var(--ow-dur-1)_var(--ow-ease-beacon)] hover:bg-ow-hover active:bg-ow-press data-[ow-state=active]:bg-ow-selected-bg"
655
+ onClick={handleClick}
656
+ >
657
+ <span
658
+ data-ow-part="num"
659
+ // §7 读数:页码 mono + tabular-nums,页数进两位时不跳宽
660
+ className="font-medium text-ow-fs-body leading-none font-[family-name:var(--ow-font-mono)] [font-variant-numeric:tabular-nums] text-ow-text-3 text-center group-data-[ow-state=active]:text-ow-text"
661
+ >
662
+ {index + 1}
663
+ </span>
664
+ <span
665
+ data-ow-part="slide"
666
+ className="block relative w-full [border-radius:var(--ow-radius-2xs)] border border-ow-border group-data-[ow-state=active]:border-ow-border-strong bg-ow-bg overflow-hidden pointer-events-none [transition:border-color_var(--ow-dur-1)_var(--ow-ease-beacon)]"
667
+ ref={thumbRef}
668
+ style={{ aspectRatio: `${slideWidth} / ${slideHeight}` }}
669
+ >
670
+ {thumbScale > 0 && (
671
+ <span
672
+ style={{
673
+ display: "block",
674
+ transform: `scale(${thumbScale})`,
675
+ transformOrigin: "top left",
676
+ position: "absolute",
677
+ top: 0,
678
+ left: 0,
679
+ width: nativeWidthPx,
680
+ height: nativeHeightPx,
681
+ }}
682
+ >
683
+ <PptxSlide slide={slide} slideWidth={slideWidth} slideHeight={slideHeight} />
684
+ </span>
685
+ )}
686
+ </span>
687
+ </Button>
688
+ )
689
+ })
690
+
691
+ // ─── Renderers (Word / Excel) ───
692
+
693
+ async function renderWord(buffer: ArrayBuffer, container: HTMLElement): Promise<void> {
694
+ const { renderAsync } = await import("docx-preview")
695
+ await renderAsync(buffer, container, undefined, {
696
+ className: "ow-docx-body",
697
+ inWrapper: true,
698
+ })
699
+ // docx-preview injects a <style> with box-shadow on the page sections — strip it.
700
+ container.querySelectorAll<HTMLStyleElement>("style").forEach((style) => {
701
+ style.textContent = (style.textContent || "").replace(/box-shadow:[^;]+;/g, "")
702
+ })
703
+ // §14 白底浅字坑:纸面恒白(styles/components.css 把 section 的 background 定在
704
+ // --ow-paper),所以纸上任何**继承语义色**的节点必须走浅档墨色,否则暗主题下会出现
705
+ // 白纸浅字。docx-preview 的页节点是它自己建的 DOM,React 侧挂不上属性,只能渲完补打
706
+ // ——与 PreviewDialog 的 paper 制式(纸页 data-theme="light")同一口径。
707
+ // 文档自带的墨色(docx-preview 从主题解析出的内联 color)不受影响,仍是文档自己的黑。
708
+ container.querySelectorAll<HTMLElement>("section.ow-docx-body, section.docx").forEach((page) => {
709
+ page.dataset.theme = "light"
710
+ })
711
+ }
712
+
713
+ // exceljs 4.4 throws "Cannot read properties of undefined (reading 'anchors')"
714
+ // while reconciling drawings: `xlsx.js` does `(drawing.anchors || [])` over every
715
+ // entry of the parsed drawings map, which guards `.anchors` being falsy but not
716
+ // `drawing` itself being undefined. A drawing part that fails to parse (wrong
717
+ // root tag, truncated XML) lands in that map as undefined and takes the whole
718
+ // load down, even though we only ever render cell text.
719
+ //
720
+ // `ignoreNodes` alone is not enough — it suppresses the worksheet's own drawing
721
+ // node, but that reconcile loop iterates the drawings map independently. Removing
722
+ // the drawing parts alone is worse than nothing: it leaves the sheet's dangling
723
+ // relationship behind and *causes* this same failure. Only both together cover
724
+ // every case, so the zip rewrite runs strictly as a fallback and healthy files
725
+ // never pay for it.
726
+ async function loadWorkbookIgnoringDrawings(buffer: ArrayBuffer) {
727
+ const ExcelJS = await import("exceljs")
728
+ const loadOptions = { ignoreNodes: ["drawing", "picture"] }
729
+ try {
730
+ const workbook = new ExcelJS.Workbook()
731
+ await workbook.xlsx.load(buffer, loadOptions)
732
+ return workbook
733
+ } catch {
734
+ const JSZip = (await import("jszip")).default
735
+ const zip = await JSZip.loadAsync(buffer)
736
+ for (const entry of Object.keys(zip.files)) {
737
+ if (entry.replace(/^\//, "").startsWith("xl/drawings/")) zip.remove(entry)
738
+ }
739
+ const sanitized = await zip.generateAsync({ type: "arraybuffer" })
740
+ const workbook = new ExcelJS.Workbook()
741
+ await workbook.xlsx.load(sanitized, loadOptions)
742
+ return workbook
743
+ }
744
+ }
745
+
746
+ /**
747
+ * 用 x-spreadsheet 渲染工作簿,转换层与实例参数移植自 vue-office。
748
+ *
749
+ * 多 Sheet 切换交给 x-spreadsheet 自己的 bottombar,所以这里不再需要外层
750
+ * sheet tabs。返回值是清理函数:实例把自己挂在 container 上,还额外注册了
751
+ * 一个 window resize 监听。
752
+ */
753
+ async function renderExcel(
754
+ buffer: ArrayBuffer,
755
+ container: HTMLElement,
756
+ measure: () => { width: number; height: number },
757
+ ): Promise<(() => void) | null> {
758
+ const workbook = await loadWorkbookIgnoringDrawings(buffer)
759
+ // 空工作簿返回 null=「没挂任何实例」,空态交回 React(state="empty" → EmptyState 母题)。
760
+ // 原来这里直接 innerHTML 写一段灰字 <p>,节点不在 React 树里,G5 母题进不去。
761
+ if (!workbook.worksheets.length) return null
762
+
763
+ const mount = document.createElement("div")
764
+ mount.className = "ow-excel-sheet"
765
+ mount.setAttribute("data-slot", "excel-sheet")
766
+ container.appendChild(mount)
767
+
768
+ const sheet = await createSpreadsheet(mount, measure)
769
+ sheet.loadData(transferExcelToSpreadSheet(workbook, { minColLength: 20 }))
770
+ // 只读模式下 x-spreadsheet 仍渲染可编辑的隐藏 input,双击单元格会进编辑态
771
+ readOnlyInput(mount)
772
+
773
+ // x-spreadsheet 只监听 window resize,面板内部的尺寸变化(侧栏折叠、
774
+ // 分割条拖动)不会触发重排,所以补一个 ResizeObserver 走它的 reload。
775
+ const observer = new ResizeObserver(() => sheet.sheet.reload?.())
776
+ observer.observe(container)
777
+
778
+ return () => {
779
+ observer.disconnect()
780
+ mount.remove()
781
+ }
782
+ }