@svadmin/ai-elements 0.5.1 → 0.8.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 (303) hide show
  1. package/README.md +18 -53
  2. package/THIRD_PARTY_NOTICES.md +67 -6
  3. package/dist/ai.css +149 -2740
  4. package/dist/ai.theme.css +1 -2771
  5. package/dist/class-properties.generated.d.ts +1 -0
  6. package/dist/class-properties.generated.js +2 -0
  7. package/dist/classnames.d.ts +8 -0
  8. package/dist/classnames.js +26 -0
  9. package/dist/components/AICommandBar.svelte +6 -4
  10. package/dist/components/ChatDialog.svelte +102 -125
  11. package/dist/components/ChatDialog.svelte.d.ts +3 -9
  12. package/dist/components/Conversation.svelte +34 -10
  13. package/dist/components/ConversationContent.svelte +1 -1
  14. package/dist/components/ConversationScrollButton.svelte +0 -1
  15. package/dist/components/CopilotPanel.svelte +8 -6
  16. package/dist/components/Message.svelte +1 -1
  17. package/dist/components/MessageActions.svelte +1 -1
  18. package/dist/components/MessageContent.svelte +1 -1
  19. package/dist/components/MessageToolbar.svelte +1 -1
  20. package/dist/components/Response.svelte +32 -12
  21. package/dist/components/Response.svelte.d.ts +3 -3
  22. package/dist/components/Tool.svelte +13 -13
  23. package/dist/components/Tool.svelte.d.ts +1 -1
  24. package/dist/components/action/Action.svelte +3 -1
  25. package/dist/components/artifact/ArtifactAction.svelte +3 -1
  26. package/dist/components/attachments/Attachment.svelte +4 -2
  27. package/dist/components/attachments/Attachments.svelte +3 -1
  28. package/dist/components/attachments/types.js +3 -2
  29. package/dist/components/audio-player/AudioPlayer.svelte.d.ts +1 -1
  30. package/dist/components/canvas/Canvas.svelte +1 -1
  31. package/dist/components/checkpoint/index.d.ts +2 -2
  32. package/dist/components/code/index.d.ts +9 -1
  33. package/dist/components/code/index.js +8 -1
  34. package/dist/components/code-block/CodeBlockLanguageSelector.svelte.d.ts +1 -1
  35. package/dist/components/code-block/highlight.js +11 -10
  36. package/dist/components/commit/Commit.svelte +23 -2
  37. package/dist/components/commit/CommitActions.svelte +2 -11
  38. package/dist/components/commit/CommitCopyButton.svelte +1 -1
  39. package/dist/components/commit/CommitHeader.svelte +12 -2
  40. package/dist/components/commit/context.svelte.d.ts +6 -0
  41. package/dist/components/commit/context.svelte.js +14 -0
  42. package/dist/components/context/Context.svelte +6 -4
  43. package/dist/components/context/TokensWithCost.svelte +2 -1
  44. package/dist/components/edge/Animated.svelte +6 -6
  45. package/dist/components/edge/Temporary.svelte +6 -5
  46. package/dist/components/file-tree/FileTree.svelte +7 -5
  47. package/dist/components/jsx-preview/parser.js +10 -10
  48. package/dist/components/message/MessageAction.svelte +3 -1
  49. package/dist/components/mic-selector/MicSelector.svelte.d.ts +1 -1
  50. package/dist/components/model-selector/ModelSelectorDialog.svelte +3 -1
  51. package/dist/components/open-in-chat/OpenInChatGPT.svelte +3 -1
  52. package/dist/components/open-in-chat/OpenInClaude.svelte +3 -1
  53. package/dist/components/open-in-chat/OpenInCursor.svelte +3 -1
  54. package/dist/components/open-in-chat/OpenInGitHub.svelte +3 -1
  55. package/dist/components/open-in-chat/OpenInScira.svelte +3 -1
  56. package/dist/components/open-in-chat/OpenInT3.svelte +3 -1
  57. package/dist/components/open-in-chat/OpenInv0.svelte +3 -1
  58. package/dist/components/package-info/PackageInfo.svelte +3 -1
  59. package/dist/components/prompt-input/PromptInput.svelte +8 -18
  60. package/dist/components/prompt-input/PromptInputCommand.svelte +2 -1
  61. package/dist/components/prompt-input/PromptInputSelect.svelte.d.ts +1 -1
  62. package/dist/components/prompt-input/PromptInputSubmit.svelte +5 -18
  63. package/dist/components/prompt-input/PromptInputTextarea.svelte +6 -11
  64. package/dist/components/prompt-input/context.svelte.d.ts +1 -8
  65. package/dist/components/prompt-input/files.js +3 -2
  66. package/dist/components/question/Question.svelte +3 -1
  67. package/dist/components/schema-display/SchemaDisplay.svelte +4 -2
  68. package/dist/components/schema-display/SchemaDisplayParameter.svelte +14 -1
  69. package/dist/components/schema-display/SchemaDisplayProperty.svelte +16 -1
  70. package/dist/components/snippet/index.d.ts +3 -3
  71. package/dist/components/stack-trace/StackTrace.svelte +7 -5
  72. package/dist/components/suggestion/index.d.ts +1 -1
  73. package/dist/components/terminal/Terminal.svelte +4 -2
  74. package/dist/components/terminal/ansi.js +9 -6
  75. package/dist/components/test-results/Test.svelte +1 -1
  76. package/dist/components/test-results/TestResults.svelte +1 -1
  77. package/dist/components/test-results/context.svelte.d.ts +1 -1
  78. package/dist/components/tool/ToolContent.svelte +1 -1
  79. package/dist/components/tool/ToolHeader.svelte +5 -5
  80. package/dist/components/tool/ToolInput.svelte +2 -4
  81. package/dist/components/tool/ToolOutput.svelte +2 -4
  82. package/dist/components/tool/ToolStatusBadge.svelte +2 -3
  83. package/dist/components/voice-selector/VoiceSelector.svelte +2 -1
  84. package/dist/components/voice-selector/VoiceSelector.svelte.d.ts +2 -2
  85. package/dist/components/voice-selector/context.svelte.d.ts +2 -1
  86. package/dist/components/web-preview/WebPreview.svelte +4 -3
  87. package/dist/contracts.d.ts +2 -2
  88. package/dist/generated-components.d.ts +15 -1
  89. package/dist/generated-components.js +20 -1
  90. package/dist/internal/Tooltip.svelte +2 -1
  91. package/dist/parity-manifest.d.ts +0 -1
  92. package/dist/parity-manifest.js +0 -97
  93. package/dist/utilities.css +3172 -0
  94. package/dist/utils.d.ts +1 -1
  95. package/dist/utils.js +1 -1
  96. package/package.json +37 -22
  97. package/vendor/streamdown/AnimatedText.svelte +93 -0
  98. package/vendor/streamdown/AnimatedText.svelte.d.ts +6 -0
  99. package/vendor/streamdown/Block.svelte +96 -0
  100. package/vendor/streamdown/Block.svelte.d.ts +11 -0
  101. package/vendor/streamdown/Elements/Alert.svelte +69 -0
  102. package/vendor/streamdown/Elements/Alert.svelte.d.ts +10 -0
  103. package/vendor/streamdown/Elements/Citation.svelte +260 -0
  104. package/vendor/streamdown/Elements/Citation.svelte.d.ts +7 -0
  105. package/vendor/streamdown/Elements/Code.svelte +226 -0
  106. package/vendor/streamdown/Elements/Code.svelte.d.ts +9 -0
  107. package/vendor/streamdown/Elements/Element.svelte +574 -0
  108. package/vendor/streamdown/Elements/Element.svelte.d.ts +10 -0
  109. package/vendor/streamdown/Elements/FootnoteRef.svelte +30 -0
  110. package/vendor/streamdown/Elements/FootnoteRef.svelte.d.ts +7 -0
  111. package/vendor/streamdown/Elements/Footnotes.svelte +54 -0
  112. package/vendor/streamdown/Elements/Footnotes.svelte.d.ts +7 -0
  113. package/vendor/streamdown/Elements/Image.svelte +200 -0
  114. package/vendor/streamdown/Elements/Image.svelte.d.ts +10 -0
  115. package/vendor/streamdown/Elements/Link.svelte +220 -0
  116. package/vendor/streamdown/Elements/Link.svelte.d.ts +10 -0
  117. package/vendor/streamdown/Elements/LinkSafetyModal.svelte +121 -0
  118. package/vendor/streamdown/Elements/LinkSafetyModal.svelte.d.ts +4 -0
  119. package/vendor/streamdown/Elements/Math.svelte +100 -0
  120. package/vendor/streamdown/Elements/Math.svelte.d.ts +9 -0
  121. package/vendor/streamdown/Elements/Mermaid.svelte +455 -0
  122. package/vendor/streamdown/Elements/Mermaid.svelte.d.ts +9 -0
  123. package/vendor/streamdown/Elements/MermaidDownload.svelte +145 -0
  124. package/vendor/streamdown/Elements/MermaidDownload.svelte.d.ts +8 -0
  125. package/vendor/streamdown/Elements/Slot.svelte +23 -0
  126. package/vendor/streamdown/Elements/Slot.svelte.d.ts +10 -0
  127. package/vendor/streamdown/Elements/Table.svelte +195 -0
  128. package/vendor/streamdown/Elements/Table.svelte.d.ts +9 -0
  129. package/vendor/streamdown/Elements/TableDownload.svelte +221 -0
  130. package/vendor/streamdown/Elements/TableDownload.svelte.d.ts +8 -0
  131. package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte +41 -0
  132. package/vendor/streamdown/Elements/fallbacks/CodeFallback.svelte.d.ts +9 -0
  133. package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte +35 -0
  134. package/vendor/streamdown/Elements/fallbacks/MathFallback.svelte.d.ts +8 -0
  135. package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte +36 -0
  136. package/vendor/streamdown/Elements/fallbacks/MermaidFallback.svelte.d.ts +9 -0
  137. package/vendor/streamdown/Elements/fallbacks/index.d.ts +3 -0
  138. package/vendor/streamdown/Elements/fallbacks/index.js +3 -0
  139. package/vendor/streamdown/Elements/icons.d.ts +31 -0
  140. package/vendor/streamdown/Elements/icons.js +200 -0
  141. package/vendor/streamdown/Elements/index.d.ts +8 -0
  142. package/vendor/streamdown/Elements/index.js +8 -0
  143. package/vendor/streamdown/Elements/popover.svelte.d.ts +8 -0
  144. package/vendor/streamdown/Elements/popover.svelte.js +45 -0
  145. package/vendor/streamdown/Elements/stepperState.svelte.d.ts +36 -0
  146. package/vendor/streamdown/Elements/stepperState.svelte.js +92 -0
  147. package/vendor/streamdown/IconProvider.svelte +11 -0
  148. package/vendor/streamdown/IconProvider.svelte.d.ts +30 -0
  149. package/vendor/streamdown/LICENSE +202 -0
  150. package/vendor/streamdown/PluginProvider.svelte +11 -0
  151. package/vendor/streamdown/PluginProvider.svelte.d.ts +30 -0
  152. package/vendor/streamdown/README.svadmin.md +5 -0
  153. package/vendor/streamdown/Streamdown.svelte +447 -0
  154. package/vendor/streamdown/Streamdown.svelte.d.ts +25 -0
  155. package/vendor/streamdown/block/BlockTokens.svelte +45 -0
  156. package/vendor/streamdown/block/BlockTokens.svelte.d.ts +9 -0
  157. package/vendor/streamdown/block/html.d.ts +14 -0
  158. package/vendor/streamdown/block/html.js +27 -0
  159. package/vendor/streamdown/block/text.d.ts +10 -0
  160. package/vendor/streamdown/block/text.js +31 -0
  161. package/vendor/streamdown/context-key.d.ts +1 -0
  162. package/vendor/streamdown/context-key.js +1 -0
  163. package/vendor/streamdown/context.svelte.d.ts +24 -0
  164. package/vendor/streamdown/context.svelte.js +75 -0
  165. package/vendor/streamdown/contracts/plugins.d.ts +26 -0
  166. package/vendor/streamdown/contracts/plugins.js +1 -0
  167. package/vendor/streamdown/contracts/streamdown.d.ts +374 -0
  168. package/vendor/streamdown/contracts/streamdown.js +29 -0
  169. package/vendor/streamdown/detect-direction.d.ts +1 -0
  170. package/vendor/streamdown/detect-direction.js +1 -0
  171. package/vendor/streamdown/icon-context.d.ts +36 -0
  172. package/vendor/streamdown/icon-context.js +52 -0
  173. package/vendor/streamdown/incomplete-code.d.ts +6 -0
  174. package/vendor/streamdown/incomplete-code.js +23 -0
  175. package/vendor/streamdown/index.d.ts +22 -0
  176. package/vendor/streamdown/index.js +20 -0
  177. package/vendor/streamdown/markdown-parse-cache.d.ts +37 -0
  178. package/vendor/streamdown/markdown-parse-cache.js +109 -0
  179. package/vendor/streamdown/markdown.d.ts +21 -0
  180. package/vendor/streamdown/markdown.js +214 -0
  181. package/vendor/streamdown/marked/index.d.ts +44 -0
  182. package/vendor/streamdown/marked/index.js +228 -0
  183. package/vendor/streamdown/marked/marked-alert.d.ts +13 -0
  184. package/vendor/streamdown/marked/marked-alert.js +47 -0
  185. package/vendor/streamdown/marked/marked-align.d.ts +10 -0
  186. package/vendor/streamdown/marked/marked-align.js +45 -0
  187. package/vendor/streamdown/marked/marked-br.d.ts +6 -0
  188. package/vendor/streamdown/marked/marked-br.js +15 -0
  189. package/vendor/streamdown/marked/marked-citations.d.ts +8 -0
  190. package/vendor/streamdown/marked/marked-citations.js +53 -0
  191. package/vendor/streamdown/marked/marked-cjk.d.ts +2 -0
  192. package/vendor/streamdown/marked/marked-cjk.js +165 -0
  193. package/vendor/streamdown/marked/marked-dl.d.ts +23 -0
  194. package/vendor/streamdown/marked/marked-dl.js +44 -0
  195. package/vendor/streamdown/marked/marked-footnotes.d.ts +26 -0
  196. package/vendor/streamdown/marked/marked-footnotes.js +101 -0
  197. package/vendor/streamdown/marked/marked-hr.d.ts +6 -0
  198. package/vendor/streamdown/marked/marked-hr.js +18 -0
  199. package/vendor/streamdown/marked/marked-list.d.ts +31 -0
  200. package/vendor/streamdown/marked/marked-list.js +330 -0
  201. package/vendor/streamdown/marked/marked-math.d.ts +13 -0
  202. package/vendor/streamdown/marked/marked-math.js +129 -0
  203. package/vendor/streamdown/marked/marked-mdx.d.ts +12 -0
  204. package/vendor/streamdown/marked/marked-mdx.js +124 -0
  205. package/vendor/streamdown/marked/marked-subsup.d.ts +22 -0
  206. package/vendor/streamdown/marked/marked-subsup.js +40 -0
  207. package/vendor/streamdown/marked/marked-table.d.ts +80 -0
  208. package/vendor/streamdown/marked/marked-table.js +527 -0
  209. package/vendor/streamdown/plugin-context.d.ts +19 -0
  210. package/vendor/streamdown/plugin-context.js +40 -0
  211. package/vendor/streamdown/plugins/cjk-shared.d.ts +1 -0
  212. package/vendor/streamdown/plugins/cjk-shared.js +1 -0
  213. package/vendor/streamdown/plugins.d.ts +19 -0
  214. package/vendor/streamdown/plugins.js +107 -0
  215. package/vendor/streamdown/provenance.json +229 -0
  216. package/vendor/streamdown/remend.d.ts +2 -0
  217. package/vendor/streamdown/remend.js +1 -0
  218. package/vendor/streamdown/security/html.d.ts +19 -0
  219. package/vendor/streamdown/security/html.js +329 -0
  220. package/vendor/streamdown/security/preprocess-custom-tags.d.ts +1 -0
  221. package/vendor/streamdown/security/preprocess-custom-tags.js +20 -0
  222. package/vendor/streamdown/security/preprocess-literal-tag-content.d.ts +1 -0
  223. package/vendor/streamdown/security/preprocess-literal-tag-content.js +16 -0
  224. package/vendor/streamdown/security/types.d.ts +1 -0
  225. package/vendor/streamdown/security/types.js +1 -0
  226. package/vendor/streamdown/site/SiteHeader.svelte +94 -0
  227. package/vendor/streamdown/site/SiteHeader.svelte.d.ts +6 -0
  228. package/vendor/streamdown/site/home/HomeDemo.svelte +122 -0
  229. package/vendor/streamdown/site/home/HomeDemo.svelte.d.ts +3 -0
  230. package/vendor/streamdown/site/home/HomePage.svelte +293 -0
  231. package/vendor/streamdown/site/home/HomePage.svelte.d.ts +3 -0
  232. package/vendor/streamdown/site/home/content.d.ts +69 -0
  233. package/vendor/streamdown/site/home/content.js +144 -0
  234. package/vendor/streamdown/site/metadata.d.ts +4 -0
  235. package/vendor/streamdown/site/metadata.js +4 -0
  236. package/vendor/streamdown/site/navigation.d.ts +6 -0
  237. package/vendor/streamdown/site/navigation.js +22 -0
  238. package/vendor/streamdown/streamdown/config.d.ts +41 -0
  239. package/vendor/streamdown/streamdown/config.js +125 -0
  240. package/vendor/streamdown/streamdown/context.d.ts +12 -0
  241. package/vendor/streamdown/streamdown/context.js +2 -0
  242. package/vendor/streamdown/streamdown/incomplete-markdown.d.ts +5 -0
  243. package/vendor/streamdown/streamdown/incomplete-markdown.js +79 -0
  244. package/vendor/streamdown/streamdown/pipeline.d.ts +95 -0
  245. package/vendor/streamdown/streamdown/pipeline.js +138 -0
  246. package/vendor/streamdown/streamdown/runtime.d.ts +59 -0
  247. package/vendor/streamdown/streamdown/runtime.js +112 -0
  248. package/vendor/streamdown/streaming.d.ts +5 -0
  249. package/vendor/streamdown/streaming.js +5 -0
  250. package/vendor/streamdown/theme.d.ts +486 -0
  251. package/vendor/streamdown/theme.js +370 -0
  252. package/vendor/streamdown/translations.d.ts +43 -0
  253. package/vendor/streamdown/translations.js +54 -0
  254. package/vendor/streamdown/url-policy.d.ts +1 -0
  255. package/vendor/streamdown/url-policy.js +1 -0
  256. package/vendor/streamdown/utils/bind.d.ts +8 -0
  257. package/vendor/streamdown/utils/bind.js +26 -0
  258. package/vendor/streamdown/utils/bundledLanguages.d.ts +1 -0
  259. package/vendor/streamdown/utils/bundledLanguages.js +1 -0
  260. package/vendor/streamdown/utils/code-block.d.ts +8 -0
  261. package/vendor/streamdown/utils/code-block.js +38 -0
  262. package/vendor/streamdown/utils/copy.svelte.d.ts +7 -0
  263. package/vendor/streamdown/utils/copy.svelte.js +38 -0
  264. package/vendor/streamdown/utils/darkMode.svelte.d.ts +3 -0
  265. package/vendor/streamdown/utils/darkMode.svelte.js +49 -0
  266. package/vendor/streamdown/utils/detectDirection.d.ts +1 -0
  267. package/vendor/streamdown/utils/detectDirection.js +19 -0
  268. package/vendor/streamdown/utils/get.d.ts +1 -0
  269. package/vendor/streamdown/utils/get.js +25 -0
  270. package/vendor/streamdown/utils/hightlighter.svelte.d.ts +30 -0
  271. package/vendor/streamdown/utils/hightlighter.svelte.js +524 -0
  272. package/vendor/streamdown/utils/index.d.ts +3 -0
  273. package/vendor/streamdown/utils/index.js +3 -0
  274. package/vendor/streamdown/utils/mermaid.d.ts +13 -0
  275. package/vendor/streamdown/utils/mermaid.js +49 -0
  276. package/vendor/streamdown/utils/panzoom.svelte.d.ts +35 -0
  277. package/vendor/streamdown/utils/panzoom.svelte.js +556 -0
  278. package/vendor/streamdown/utils/parse-incomplete-markdown.d.ts +2 -0
  279. package/vendor/streamdown/utils/parse-incomplete-markdown.js +2 -0
  280. package/vendor/streamdown/utils/runtime-env.d.ts +1 -0
  281. package/vendor/streamdown/utils/runtime-env.js +13 -0
  282. package/vendor/streamdown/utils/save.d.ts +1 -0
  283. package/vendor/streamdown/utils/save.js +14 -0
  284. package/vendor/streamdown/utils/scroll-lock.d.ts +2 -0
  285. package/vendor/streamdown/utils/scroll-lock.js +35 -0
  286. package/vendor/streamdown/utils/table.d.ts +8 -0
  287. package/vendor/streamdown/utils/table.js +176 -0
  288. package/vendor/streamdown/utils/url.d.ts +22 -0
  289. package/vendor/streamdown/utils/url.js +98 -0
  290. package/vendor/streamdown/utils/useClickOutside.svelte.d.ts +8 -0
  291. package/vendor/streamdown/utils/useClickOutside.svelte.js +41 -0
  292. package/vendor/streamdown/utils/useKeyDown.svelte.d.ts +5 -0
  293. package/vendor/streamdown/utils/useKeyDown.svelte.js +23 -0
  294. package/UPSTREAM_PARITY.md +0 -69
  295. package/dist/ai-theme.css +0 -28
  296. package/dist/components/code/code-variants.d.ts +0 -25
  297. package/dist/components/code/code-variants.js +0 -20
  298. package/dist/components/conversation/scroll.d.ts +0 -4
  299. package/dist/components/conversation/scroll.js +0 -85
  300. package/dist/components/message/content-polish-html.d.ts +0 -5
  301. package/dist/components/message/content-polish-html.js +0 -75
  302. package/dist/components/tool/content-polish-scroll-region.d.ts +0 -3
  303. package/dist/components/tool/content-polish-scroll-region.js +0 -22
@@ -0,0 +1,176 @@
1
+ const escapeCSV = (value) => {
2
+ let needsEscaping = false;
3
+ let hasQuote = false;
4
+ for (let index = 0; index < value.length; index += 1) {
5
+ const char = value[index];
6
+ if (char === '"') {
7
+ needsEscaping = true;
8
+ hasQuote = true;
9
+ break;
10
+ }
11
+ if (char === ',' || char === '\n') {
12
+ needsEscaping = true;
13
+ }
14
+ }
15
+ if (!needsEscaping) {
16
+ return value;
17
+ }
18
+ if (hasQuote) {
19
+ return `"${value.replace(/"/g, '""')}"`;
20
+ }
21
+ return `"${value}"`;
22
+ };
23
+ const escapeTSV = (value) => {
24
+ let needsEscaping = false;
25
+ for (let index = 0; index < value.length; index += 1) {
26
+ const char = value[index];
27
+ if (char === '\t' || char === '\n' || char === '\r') {
28
+ needsEscaping = true;
29
+ break;
30
+ }
31
+ }
32
+ if (!needsEscaping) {
33
+ return value;
34
+ }
35
+ const parts = new Array(value.length);
36
+ let partIndex = 0;
37
+ for (let index = 0; index < value.length; index += 1) {
38
+ const char = value[index];
39
+ if (char === '\t') {
40
+ parts[partIndex] = '\\t';
41
+ }
42
+ else if (char === '\n') {
43
+ parts[partIndex] = '\\n';
44
+ }
45
+ else if (char === '\r') {
46
+ parts[partIndex] = '\\r';
47
+ }
48
+ else {
49
+ parts[partIndex] = char;
50
+ }
51
+ partIndex += 1;
52
+ }
53
+ return parts.join('');
54
+ };
55
+ const escapeMarkdownTableCell = (cell) => {
56
+ let needsEscaping = false;
57
+ for (let index = 0; index < cell.length; index += 1) {
58
+ const char = cell[index];
59
+ if (char === '\\' || char === '|') {
60
+ needsEscaping = true;
61
+ break;
62
+ }
63
+ }
64
+ if (!needsEscaping) {
65
+ return cell;
66
+ }
67
+ const parts = new Array(cell.length);
68
+ let partIndex = 0;
69
+ for (let index = 0; index < cell.length; index += 1) {
70
+ const char = cell[index];
71
+ if (char === '\\') {
72
+ parts[partIndex] = '\\\\';
73
+ }
74
+ else if (char === '|') {
75
+ parts[partIndex] = '\\|';
76
+ }
77
+ else {
78
+ parts[partIndex] = char;
79
+ }
80
+ partIndex += 1;
81
+ }
82
+ return parts.join('');
83
+ };
84
+ const formatDelimitedRow = (row, delimiter, escapeCell) => {
85
+ if (row.length === 0) {
86
+ return '';
87
+ }
88
+ const formattedCells = new Array(row.length);
89
+ for (let index = 0; index < row.length; index += 1) {
90
+ formattedCells[index] = escapeCell(row[index] ?? '');
91
+ }
92
+ return formattedCells.join(delimiter);
93
+ };
94
+ export const extractTableDataFromElement = (tableElement) => {
95
+ const headers = [];
96
+ const rows = [];
97
+ const headerCells = tableElement.querySelectorAll('thead th');
98
+ for (const cell of headerCells) {
99
+ headers.push(cell.textContent?.trim() || '');
100
+ }
101
+ const bodyRows = tableElement.querySelectorAll('tbody tr');
102
+ for (const row of bodyRows) {
103
+ const rowData = [];
104
+ const cells = row.querySelectorAll('td');
105
+ for (const cell of cells) {
106
+ rowData.push(cell.textContent?.trim() || '');
107
+ }
108
+ rows.push(rowData);
109
+ }
110
+ return { headers, rows };
111
+ };
112
+ export const tableDataToCSV = ({ headers, rows }) => {
113
+ const totalRows = headers.length > 0 ? rows.length + 1 : rows.length;
114
+ const csvRows = new Array(totalRows);
115
+ let rowIndex = 0;
116
+ if (headers.length > 0) {
117
+ csvRows[rowIndex] = formatDelimitedRow(headers, ',', escapeCSV);
118
+ rowIndex += 1;
119
+ }
120
+ for (const row of rows) {
121
+ csvRows[rowIndex] = formatDelimitedRow(row, ',', escapeCSV);
122
+ rowIndex += 1;
123
+ }
124
+ return csvRows.join('\n');
125
+ };
126
+ export const tableDataToTSV = ({ headers, rows }) => {
127
+ const totalRows = headers.length > 0 ? rows.length + 1 : rows.length;
128
+ const tsvRows = new Array(totalRows);
129
+ let rowIndex = 0;
130
+ if (headers.length > 0) {
131
+ tsvRows[rowIndex] = formatDelimitedRow(headers, '\t', escapeTSV);
132
+ rowIndex += 1;
133
+ }
134
+ for (const row of rows) {
135
+ tsvRows[rowIndex] = formatDelimitedRow(row, '\t', escapeTSV);
136
+ rowIndex += 1;
137
+ }
138
+ return tsvRows.join('\n');
139
+ };
140
+ export const tableDataToMarkdown = ({ headers, rows }) => {
141
+ if (headers.length === 0) {
142
+ return '';
143
+ }
144
+ const markdownRows = new Array(rows.length + 2);
145
+ let rowIndex = 0;
146
+ const escapedHeaders = new Array(headers.length);
147
+ for (let index = 0; index < headers.length; index += 1) {
148
+ escapedHeaders[index] = escapeMarkdownTableCell(headers[index]);
149
+ }
150
+ markdownRows[rowIndex] = `| ${escapedHeaders.join(' | ')} |`;
151
+ rowIndex += 1;
152
+ const separatorParts = new Array(headers.length);
153
+ for (let i = 0; i < headers.length; i += 1) {
154
+ separatorParts[i] = '---';
155
+ }
156
+ markdownRows[rowIndex] = `| ${separatorParts.join(' | ')} |`;
157
+ rowIndex += 1;
158
+ for (const row of rows) {
159
+ if (row.length < headers.length) {
160
+ const paddedRow = new Array(headers.length);
161
+ for (let i = 0; i < headers.length; i += 1) {
162
+ paddedRow[i] = i < row.length ? escapeMarkdownTableCell(row[i]) : '';
163
+ }
164
+ markdownRows[rowIndex] = `| ${paddedRow.join(' | ')} |`;
165
+ }
166
+ else {
167
+ const escapedRow = new Array(row.length);
168
+ for (let i = 0; i < row.length; i += 1) {
169
+ escapedRow[i] = escapeMarkdownTableCell(row[i]);
170
+ }
171
+ markdownRows[rowIndex] = `| ${escapedRow.join(' | ')} |`;
172
+ }
173
+ rowIndex += 1;
174
+ }
175
+ return markdownRows.join('\n');
176
+ };
@@ -0,0 +1,22 @@
1
+ export declare const parseUrl: (url: unknown, defaultOrigin?: string) => URL | null;
2
+ export declare const isPathRelativeUrl: (url: unknown) => boolean;
3
+ export type UrlPolicyKind = 'image' | 'link';
4
+ export type TransformUrlOptions = {
5
+ kind?: UrlPolicyKind;
6
+ };
7
+ type WildcardAllowedUrlPrefix = {
8
+ type: 'wildcard';
9
+ };
10
+ type ProtocolAllowedUrlPrefix = {
11
+ type: 'protocol';
12
+ protocol: string;
13
+ };
14
+ type AbsoluteAllowedUrlPrefix = {
15
+ type: 'url';
16
+ url: URL;
17
+ };
18
+ export type AllowedUrlPrefix = WildcardAllowedUrlPrefix | ProtocolAllowedUrlPrefix | AbsoluteAllowedUrlPrefix;
19
+ export declare const parseAllowedUrlPrefixes: (allowedPrefixes: readonly unknown[], defaultOrigin?: string) => AllowedUrlPrefix[];
20
+ export declare const transformParsedUrl: (url: unknown, allowedPrefixes: readonly AllowedUrlPrefix[], defaultOrigin?: string, { kind }?: TransformUrlOptions) => string | null;
21
+ export declare const transformUrl: (url: unknown, allowedPrefixes: string[], defaultOrigin?: string, { kind }?: TransformUrlOptions) => string | null;
22
+ export {};
@@ -0,0 +1,98 @@
1
+ export const parseUrl = (url, defaultOrigin) => {
2
+ if (typeof url !== 'string')
3
+ return null;
4
+ try {
5
+ // Try to parse as absolute URL first
6
+ const urlObject = new URL(url);
7
+ return urlObject;
8
+ }
9
+ catch (error) {
10
+ // If that fails and we have a defaultOrigin, try with it
11
+ if (defaultOrigin) {
12
+ try {
13
+ const urlObject = new URL(url, defaultOrigin);
14
+ return urlObject;
15
+ }
16
+ catch (error) {
17
+ return null;
18
+ }
19
+ }
20
+ return null;
21
+ }
22
+ };
23
+ export const isPathRelativeUrl = (url) => {
24
+ if (typeof url !== 'string')
25
+ return false;
26
+ return ((url.startsWith('/') && !url.startsWith('//')) ||
27
+ url.startsWith('./') ||
28
+ url.startsWith('../') ||
29
+ url.startsWith('#') ||
30
+ url.startsWith('?'));
31
+ };
32
+ const WILDCARD_PROTOCOLS = {
33
+ link: new Set(['http:', 'https:', 'mailto:', 'tel:']),
34
+ image: new Set(['http:', 'https:'])
35
+ };
36
+ const PROTOCOL_ONLY_PREFIX_PATTERN = /^(?<protocol>[A-Za-z][A-Za-z\d+.-]*:)(\/\/)?$/;
37
+ function isAllowedByWildcard(url, kind) {
38
+ if (WILDCARD_PROTOCOLS[kind].has(url.protocol)) {
39
+ return true;
40
+ }
41
+ return kind === 'image' && url.protocol === 'data:' && /^data:image\//i.test(url.href);
42
+ }
43
+ const parseAllowedUrlPrefix = (prefix, defaultOrigin) => {
44
+ if (prefix === '*') {
45
+ return { type: 'wildcard' };
46
+ }
47
+ if (typeof prefix !== 'string') {
48
+ return null;
49
+ }
50
+ const protocolOnlyMatch = prefix.match(PROTOCOL_ONLY_PREFIX_PATTERN);
51
+ if (protocolOnlyMatch?.groups?.protocol) {
52
+ return {
53
+ type: 'protocol',
54
+ protocol: protocolOnlyMatch.groups.protocol.toLowerCase()
55
+ };
56
+ }
57
+ const parsedPrefix = parseUrl(prefix, defaultOrigin);
58
+ if (!parsedPrefix) {
59
+ return null;
60
+ }
61
+ return {
62
+ type: 'url',
63
+ url: parsedPrefix
64
+ };
65
+ };
66
+ export const parseAllowedUrlPrefixes = (allowedPrefixes, defaultOrigin) => allowedPrefixes
67
+ .map((prefix) => parseAllowedUrlPrefix(prefix, defaultOrigin))
68
+ .filter((prefix) => prefix !== null);
69
+ function isAllowedByPrefix(url, prefix, kind) {
70
+ switch (prefix.type) {
71
+ case 'wildcard':
72
+ return isAllowedByWildcard(url, kind);
73
+ case 'protocol':
74
+ return url.protocol.toLowerCase() === prefix.protocol;
75
+ case 'url':
76
+ return prefix.url.origin === url.origin && url.href.startsWith(prefix.url.href);
77
+ }
78
+ }
79
+ export const transformParsedUrl = (url, allowedPrefixes, defaultOrigin, { kind = 'link' } = {}) => {
80
+ if (!url)
81
+ return null;
82
+ if (typeof url !== 'string')
83
+ return null;
84
+ const inputWasRelative = isPathRelativeUrl(url);
85
+ const parsedUrl = parseUrl(url, defaultOrigin);
86
+ if (!parsedUrl)
87
+ return null;
88
+ if (allowedPrefixes.some((prefix) => isAllowedByPrefix(parsedUrl, prefix, kind))) {
89
+ if (inputWasRelative) {
90
+ return url;
91
+ }
92
+ return parsedUrl.href;
93
+ }
94
+ return null;
95
+ };
96
+ export const transformUrl = (url, allowedPrefixes, defaultOrigin, { kind = 'link' } = {}) => transformParsedUrl(url, parseAllowedUrlPrefixes(allowedPrefixes, defaultOrigin), defaultOrigin, {
97
+ kind
98
+ });
@@ -0,0 +1,8 @@
1
+ type ClickOutsideHandlerOptions = {
2
+ isActive: boolean;
3
+ callback: () => void;
4
+ };
5
+ export declare const useClickOutside: (props: ClickOutsideHandlerOptions) => {
6
+ readonly attachment: ((node: HTMLElement) => () => void) | null;
7
+ };
8
+ export {};
@@ -0,0 +1,41 @@
1
+ import { SvelteSet } from 'svelte/reactivity';
2
+ import { on } from 'svelte/events';
3
+ export const useClickOutside = (props) => {
4
+ const refs = new SvelteSet();
5
+ let listener = null;
6
+ const onClickOutside = (e) => {
7
+ let inRef = false;
8
+ if (props.isActive) {
9
+ const path = e.composedPath();
10
+ path.forEach((node) => {
11
+ refs.forEach((ref) => {
12
+ if (ref instanceof Node && node instanceof Node && ref?.isSameNode(node)) {
13
+ inRef = true;
14
+ }
15
+ });
16
+ });
17
+ if (!inRef) {
18
+ props.callback();
19
+ }
20
+ }
21
+ };
22
+ return {
23
+ get attachment() {
24
+ return props.isActive
25
+ ? (node) => {
26
+ refs.add(node);
27
+ if (!listener) {
28
+ listener = on(node.ownerDocument, 'pointerdown', onClickOutside);
29
+ }
30
+ return () => {
31
+ refs.delete(node);
32
+ if (listener && refs.size === 0) {
33
+ listener();
34
+ listener = null;
35
+ }
36
+ };
37
+ }
38
+ : null;
39
+ }
40
+ };
41
+ };
@@ -0,0 +1,5 @@
1
+ export declare const useKeyDown: (opts: {
2
+ isActive: boolean;
3
+ callback: () => void;
4
+ keys: string[];
5
+ }) => void;
@@ -0,0 +1,23 @@
1
+ import { on } from 'svelte/events';
2
+ export const useKeyDown = (opts) => {
3
+ let listener;
4
+ const eventCallback = (event) => {
5
+ if (opts.keys.includes(event.key)) {
6
+ event.preventDefault();
7
+ opts.callback();
8
+ }
9
+ };
10
+ $effect(() => {
11
+ if (opts.isActive && !listener) {
12
+ listener = on(window, 'keydown', eventCallback);
13
+ }
14
+ else {
15
+ listener?.();
16
+ listener = null;
17
+ }
18
+ return () => {
19
+ listener?.();
20
+ listener = null;
21
+ };
22
+ });
23
+ };
@@ -1,69 +0,0 @@
1
- # Upstream architecture and parity assessment
2
-
3
- This package is evaluated against fixed source snapshots so that component
4
- counts and behavior claims remain reproducible:
5
-
6
- - `vercel/ai-elements` at `6a9d5b1822ffb10bba4bd97175f01edd7d8651cd`
7
- - `vuepont/ai-elements-vue` at `ad4818f6081a2fe6e5b7bb53cebc5a66d9a24148`
8
- - `SikandarJODD/ai-elements` at `fa4bc217f84bc571378bc371332a154106772614`
9
-
10
- ## Architecture decision
11
-
12
- SVAdmin keeps its package-first architecture instead of copying the reference
13
- applications wholesale. The current structure is stronger for an admin
14
- framework because it provides:
15
-
16
- - Svelte 5 runes, snippets, bindable state, and scoped context instead of React
17
- compatibility wrappers;
18
- - structured `ChatMessagePart` data for text, reasoning, tools, sources,
19
- attachments, approvals, and generated components;
20
- - TypeBox runtime boundaries for generated component props and agent tool
21
- arguments;
22
- - SSR, package-export, packed-consumer, and workspace integration gates;
23
- - semantic design tokens and tenant/provider ownership inherited from SVAdmin.
24
-
25
- The Sikandar project is stronger as a component-learning reference. Its
26
- co-located examples, registry organization, concise component files, and
27
- Svelte-native compound APIs make individual components easy to inspect. We
28
- adopted the useful parts without importing its application routing or registry
29
- runtime into the package:
30
-
31
- - generic `Action` and `Code` families;
32
- - message and prompt attachment composition;
33
- - workflow subpath aggregation;
34
- - small compound component files and Svelte context APIs;
35
- - explicit `content` props for Markdown responses rather than attempting to
36
- recover text from compiled Svelte snippets.
37
-
38
- ## Component inventory
39
-
40
- The pinned official package exposes 49 component families and 398 runtime
41
- exports. `vuepont/ai-elements-vue` exposes 48 comparable families. The Sikandar
42
- documentation registry lists a smaller application-focused set, while SVAdmin
43
- also includes admin-specific chat surfaces such as `ChatDialog`,
44
- `CopilotPanel`, `AICommandBar`, `InsightCard`, `SmartSuggest`, and `VoiceInput`.
45
-
46
- `AI_ELEMENT_PARITY` is the authoritative machine-readable inventory. Every
47
- official runtime export is mapped to a local Svelte export. Behavior status is
48
- tracked separately and must name an existing test file before a family can be
49
- classified as verified. This prevents an export-only audit from being reported
50
- as functional parity.
51
-
52
- ## Intentional framework differences
53
-
54
- Two official helpers intentionally differ while preserving the user-facing
55
- capability:
56
-
57
- - `JSXPreview` parses a restricted, TypeBox-validated component grammar rather
58
- than executing arbitrary JSX.
59
- - `Tool.getStatusBadge` returns Svelte-renderable status metadata rather than a
60
- React element.
61
-
62
- `MessageResponse` accepts Markdown through `content` or `text`. Plain Svelte
63
- children remain snippets and are rendered as authored UI; they are not mounted
64
- into a hidden DOM node and scraped back into a string. This matches the
65
- Sikandar Svelte implementation and preserves SSR and streaming reactivity.
66
-
67
- Visual evidence remains independent from behavior evidence. A component can
68
- be behavior-verified without claiming pixel identity across React, Vue, and
69
- Svelte rendering stacks.
package/dist/ai-theme.css DELETED
@@ -1,28 +0,0 @@
1
- /* Semantic fallbacks keep this package independent of @svadmin/ui. */
2
- @theme {
3
- --color-background: var(--background, Canvas);
4
- --color-foreground: var(--foreground, CanvasText);
5
- --color-card: var(--card, Canvas);
6
- --color-card-foreground: var(--card-foreground, CanvasText);
7
- --color-popover: var(--popover, Canvas);
8
- --color-popover-foreground: var(--popover-foreground, CanvasText);
9
- --color-primary: var(--primary, Highlight);
10
- --color-primary-foreground: var(--primary-foreground, HighlightText);
11
- --color-secondary: var(--secondary, ButtonFace);
12
- --color-secondary-foreground: var(--secondary-foreground, ButtonText);
13
- --color-muted: var(--muted, ButtonFace);
14
- --color-muted-foreground: var(--muted-foreground, GrayText);
15
- --color-accent: var(--accent, ButtonFace);
16
- --color-accent-foreground: var(--accent-foreground, ButtonText);
17
- --color-destructive: var(--destructive, CanvasText);
18
- --color-destructive-foreground: var(--destructive-foreground, Canvas);
19
- --color-success: var(--success, CanvasText);
20
- --color-success-foreground: var(--success-foreground, Canvas);
21
- --color-warning: var(--warning, CanvasText);
22
- --color-warning-foreground: var(--warning-foreground, Canvas);
23
- --color-info: var(--info, Highlight);
24
- --color-border: var(--border, ButtonBorder);
25
- --color-input: var(--input, ButtonBorder);
26
- --color-ring: var(--ring, Highlight);
27
- --color-sidebar: var(--sidebar, Canvas);
28
- }
@@ -1,25 +0,0 @@
1
- import { type ClassValue } from 'cn';
2
- export type CodeVariant = 'default' | 'secondary' | undefined;
3
- declare function composeCodeVariants({ variant, class: className, className: extraClassName, }?: {
4
- variant?: CodeVariant | null;
5
- class?: ClassValue;
6
- className?: ClassValue;
7
- }): string;
8
- export declare const codeVariants: typeof composeCodeVariants & {
9
- base: string;
10
- variants: {
11
- variant: {
12
- default: string;
13
- secondary: string;
14
- };
15
- };
16
- defaultVariants: {
17
- variant: "default";
18
- };
19
- variantKeys: Array<"variant">;
20
- slots: undefined;
21
- extend: undefined;
22
- compoundVariants: never[];
23
- compoundSlots: never[];
24
- };
25
- export {};
@@ -1,20 +0,0 @@
1
- import { cn } from 'cn';
2
- function composeCodeVariants({ variant = 'default', class: className, className: extraClassName, } = {}) {
3
- return cn('svadmin-ai-code', variant && `svadmin-ai-code--${variant}`, className, extraClassName);
4
- }
5
- // Preserve the metadata read by consumers that extend this public helper.
6
- export const codeVariants = Object.assign(composeCodeVariants, {
7
- base: 'svadmin-ai-code',
8
- variants: {
9
- variant: {
10
- default: 'svadmin-ai-code--default',
11
- secondary: 'svadmin-ai-code--secondary',
12
- },
13
- },
14
- defaultVariants: { variant: 'default' },
15
- variantKeys: ['variant'],
16
- slots: undefined,
17
- extend: undefined,
18
- compoundVariants: [],
19
- compoundSlots: [],
20
- });
@@ -1,4 +0,0 @@
1
- export declare function observeConversationScroll(element: HTMLElement, onAtBottomChange: (atBottom: boolean) => void): {
2
- scrollToBottom(): void;
3
- destroy(): void;
4
- };
@@ -1,85 +0,0 @@
1
- export function observeConversationScroll(element, onAtBottomChange) {
2
- let following = true;
3
- let previousTop = element.scrollTop;
4
- let frame;
5
- let destroyed = false;
6
- const observed = new Set();
7
- const atBottom = () => element.scrollHeight - element.scrollTop - element.clientHeight <= 48;
8
- function scrollToBottom() {
9
- if (destroyed)
10
- return;
11
- following = true;
12
- if (typeof element.scrollTo === 'function') {
13
- element.scrollTo({ top: element.scrollHeight, behavior: 'instant' });
14
- }
15
- else {
16
- element.scrollTop = element.scrollHeight;
17
- }
18
- previousTop = element.scrollTop;
19
- onAtBottomChange(true);
20
- }
21
- function schedule() {
22
- if (destroyed || frame !== undefined)
23
- return;
24
- frame = requestAnimationFrame(() => {
25
- frame = undefined;
26
- if (destroyed)
27
- return;
28
- if (atBottom())
29
- following = true;
30
- if (following)
31
- scrollToBottom();
32
- else
33
- onAtBottomChange(atBottom());
34
- });
35
- }
36
- function onScroll() {
37
- const nextTop = element.scrollTop;
38
- // Layout changes can emit scroll events without a user moving away.
39
- if (atBottom())
40
- following = true;
41
- else if (nextTop !== previousTop)
42
- following = false;
43
- previousTop = nextTop;
44
- onAtBottomChange(atBottom());
45
- }
46
- const resize = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(schedule);
47
- function observeChildren() {
48
- const children = new Set(element.children);
49
- for (const child of observed) {
50
- if (!children.has(child)) {
51
- resize?.unobserve(child);
52
- observed.delete(child);
53
- }
54
- }
55
- for (const child of children) {
56
- if (!observed.has(child)) {
57
- resize?.observe(child);
58
- observed.add(child);
59
- }
60
- }
61
- }
62
- resize?.observe(element);
63
- observeChildren();
64
- const mutation = new MutationObserver((records) => {
65
- if (records.some((record) => record.type === 'childList'))
66
- observeChildren();
67
- schedule();
68
- });
69
- mutation.observe(element, { childList: true, subtree: true, characterData: true });
70
- element.addEventListener('scroll', onScroll, { passive: true });
71
- window.addEventListener('resize', schedule, { passive: true });
72
- schedule();
73
- return {
74
- scrollToBottom,
75
- destroy() {
76
- destroyed = true;
77
- if (frame !== undefined)
78
- cancelAnimationFrame(frame);
79
- resize?.disconnect();
80
- mutation.disconnect();
81
- element.removeEventListener('scroll', onScroll);
82
- window.removeEventListener('resize', schedule);
83
- },
84
- };
85
- }
@@ -1,5 +0,0 @@
1
- import type { Extension } from 'streamdown-svelte';
2
- export declare function createResponseHtmlPreparer(): (markdown: string, extensions?: Extension[]) => {
3
- content: string;
4
- extensions: Extension[];
5
- };