@zyro-sec/ui 1.0.0 → 1.0.1

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 (256) hide show
  1. package/AGENTS.md +29 -0
  2. package/bunfig.toml +2 -0
  3. package/package.json +21 -114
  4. package/perf/motion.bench.ts +14 -0
  5. package/perf/motion.ts +16 -0
  6. package/script/build-oc2-v2-overrides.ts +38 -0
  7. package/script/colors.txt +288 -0
  8. package/script/generate-spinner.ts +121 -0
  9. package/script/pack.ts +5 -0
  10. package/script/tailwind.ts +24 -0
  11. package/src/actions/button/button.stories.tsx +158 -0
  12. package/src/actions/icon-button/icon-button.stories.tsx +122 -0
  13. package/src/actions/split-button/split-button.stories.tsx +59 -0
  14. package/src/assets/favicon/apple-touch-icon-v3.png +0 -0
  15. package/src/assets/favicon/apple-touch-icon.png +0 -0
  16. package/src/assets/favicon/favicon-96x96-v3.png +0 -0
  17. package/src/assets/favicon/favicon-96x96.png +0 -0
  18. package/src/assets/favicon/favicon-v3.ico +0 -0
  19. package/src/assets/favicon/favicon-v3.svg +7 -0
  20. package/src/assets/favicon/favicon.ico +0 -0
  21. package/src/assets/favicon/favicon.svg +7 -0
  22. package/src/assets/favicon/site.webmanifest +24 -0
  23. package/src/assets/favicon/web-app-manifest-192x192.png +0 -0
  24. package/src/assets/favicon/web-app-manifest-512x512.png +0 -0
  25. package/src/assets/icons/provider/302ai.svg +7 -0
  26. package/src/assets/icons/provider/abacus.svg +14 -0
  27. package/src/assets/icons/provider/aihubmix.svg +3 -0
  28. package/src/assets/icons/provider/alibaba-cn.svg +3 -0
  29. package/src/assets/icons/provider/alibaba-coding-plan-cn.svg +3 -0
  30. package/src/assets/icons/provider/alibaba-coding-plan.svg +3 -0
  31. package/src/assets/icons/provider/alibaba.svg +3 -0
  32. package/src/assets/icons/provider/amazon-bedrock.svg +3 -0
  33. package/src/assets/icons/provider/anthropic.svg +3 -0
  34. package/src/assets/icons/provider/azure-cognitive-services.svg +24 -0
  35. package/src/assets/icons/provider/azure.svg +3 -0
  36. package/src/assets/icons/provider/bailing.svg +3 -0
  37. package/src/assets/icons/provider/baseten.svg +3 -0
  38. package/src/assets/icons/provider/berget.svg +3 -0
  39. package/src/assets/icons/provider/cerebras.svg +4 -0
  40. package/src/assets/icons/provider/chutes.svg +24 -0
  41. package/src/assets/icons/provider/clarifai.svg +24 -0
  42. package/src/assets/icons/provider/claude-agent.svg +3 -0
  43. package/src/assets/icons/provider/cloudferro-sherlock.svg +5 -0
  44. package/src/assets/icons/provider/cloudflare-ai-gateway.svg +4 -0
  45. package/src/assets/icons/provider/cloudflare-workers-ai.svg +4 -0
  46. package/src/assets/icons/provider/cohere.svg +5 -0
  47. package/src/assets/icons/provider/cortecs.svg +24 -0
  48. package/src/assets/icons/provider/deepinfra.svg +4 -0
  49. package/src/assets/icons/provider/deepseek.svg +3 -0
  50. package/src/assets/icons/provider/digitalocean.svg +6 -0
  51. package/src/assets/icons/provider/dinference.svg +1 -0
  52. package/src/assets/icons/provider/drun.svg +8 -0
  53. package/src/assets/icons/provider/evroc.svg +3 -0
  54. package/src/assets/icons/provider/fastrouter.svg +3 -0
  55. package/src/assets/icons/provider/fireworks-ai.svg +3 -0
  56. package/src/assets/icons/provider/firmware.svg +18 -0
  57. package/src/assets/icons/provider/friendli.svg +3 -0
  58. package/src/assets/icons/provider/github-copilot.svg +3 -0
  59. package/src/assets/icons/provider/github-models.svg +3 -0
  60. package/src/assets/icons/provider/gitlab.svg +3 -0
  61. package/src/assets/icons/provider/google-vertex-anthropic.svg +24 -0
  62. package/src/assets/icons/provider/google-vertex.svg +10 -0
  63. package/src/assets/icons/provider/google.svg +3 -0
  64. package/src/assets/icons/provider/groq.svg +3 -0
  65. package/src/assets/icons/provider/helicone.svg +6 -0
  66. package/src/assets/icons/provider/huggingface.svg +3 -0
  67. package/src/assets/icons/provider/iflowcn.svg +3 -0
  68. package/src/assets/icons/provider/inception.svg +4 -0
  69. package/src/assets/icons/provider/inference.svg +3 -0
  70. package/src/assets/icons/provider/io-net.svg +5 -0
  71. package/src/assets/icons/provider/jiekou.svg +4 -0
  72. package/src/assets/icons/provider/kilo.svg +4 -0
  73. package/src/assets/icons/provider/kimi-for-coding.svg +3 -0
  74. package/src/assets/icons/provider/kuae-cloud-coding-plan.svg +3 -0
  75. package/src/assets/icons/provider/llama.svg +3 -0
  76. package/src/assets/icons/provider/lmstudio.svg +24 -0
  77. package/src/assets/icons/provider/lucidquery.svg +3 -0
  78. package/src/assets/icons/provider/meganova.svg +3 -0
  79. package/src/assets/icons/provider/meituan.svg +6 -0
  80. package/src/assets/icons/provider/meta.svg +3 -0
  81. package/src/assets/icons/provider/minimax-cn-coding-plan.svg +24 -0
  82. package/src/assets/icons/provider/minimax-cn.svg +3 -0
  83. package/src/assets/icons/provider/minimax-coding-plan.svg +24 -0
  84. package/src/assets/icons/provider/minimax.svg +3 -0
  85. package/src/assets/icons/provider/mistral.svg +3 -0
  86. package/src/assets/icons/provider/moark.svg +3 -0
  87. package/src/assets/icons/provider/modelscope.svg +5 -0
  88. package/src/assets/icons/provider/moonshotai-cn.svg +3 -0
  89. package/src/assets/icons/provider/moonshotai.svg +3 -0
  90. package/src/assets/icons/provider/morph.svg +24 -0
  91. package/src/assets/icons/provider/nano-gpt.svg +3 -0
  92. package/src/assets/icons/provider/nebius.svg +4 -0
  93. package/src/assets/icons/provider/nova.svg +3 -0
  94. package/src/assets/icons/provider/novita-ai.svg +10 -0
  95. package/src/assets/icons/provider/nvidia.svg +3 -0
  96. package/src/assets/icons/provider/ollama-cloud.svg +7 -0
  97. package/src/assets/icons/provider/openai.svg +3 -0
  98. package/src/assets/icons/provider/opencode-go.svg +3 -0
  99. package/src/assets/icons/provider/opencode.svg +3 -0
  100. package/src/assets/icons/provider/openrouter.svg +3 -0
  101. package/src/assets/icons/provider/ovhcloud.svg +3 -0
  102. package/src/assets/icons/provider/perplexity-agent.svg +3 -0
  103. package/src/assets/icons/provider/perplexity.svg +3 -0
  104. package/src/assets/icons/provider/poe.svg +7 -0
  105. package/src/assets/icons/provider/privatemode-ai.svg +5 -0
  106. package/src/assets/icons/provider/qihang-ai.svg +9 -0
  107. package/src/assets/icons/provider/qiniu-ai.svg +7 -0
  108. package/src/assets/icons/provider/reflection.svg +3 -0
  109. package/src/assets/icons/provider/requesty.svg +24 -0
  110. package/src/assets/icons/provider/sap-ai-core.svg +24 -0
  111. package/src/assets/icons/provider/scaleway.svg +5 -0
  112. package/src/assets/icons/provider/siliconflow-cn.svg +3 -0
  113. package/src/assets/icons/provider/siliconflow.svg +3 -0
  114. package/src/assets/icons/provider/stackit.svg +4 -0
  115. package/src/assets/icons/provider/stepfun.svg +16 -0
  116. package/src/assets/icons/provider/submodel.svg +3 -0
  117. package/src/assets/icons/provider/synthetic.svg +24 -0
  118. package/src/assets/icons/provider/tencent-coding-plan.svg +5 -0
  119. package/src/assets/icons/provider/tencent.svg +3 -0
  120. package/src/assets/icons/provider/thinkingmachines.svg +3 -0
  121. package/src/assets/icons/provider/togetherai.svg +4 -0
  122. package/src/assets/icons/provider/upstage.svg +24 -0
  123. package/src/assets/icons/provider/v0.svg +3 -0
  124. package/src/assets/icons/provider/venice.svg +4 -0
  125. package/src/assets/icons/provider/vercel.svg +3 -0
  126. package/src/assets/icons/provider/vivgrid.svg +4 -0
  127. package/src/assets/icons/provider/vultr.svg +6 -0
  128. package/src/assets/icons/provider/wandb.svg +24 -0
  129. package/src/assets/icons/provider/xai.svg +3 -0
  130. package/src/assets/icons/provider/xiaomi.svg +3 -0
  131. package/src/assets/icons/provider/zai-coding-plan.svg +3 -0
  132. package/src/assets/icons/provider/zai.svg +3 -0
  133. package/src/assets/icons/provider/zenmux.svg +4 -0
  134. package/src/assets/icons/provider/zhipuai-coding-plan.svg +3 -0
  135. package/src/assets/icons/provider/zhipuai.svg +3 -0
  136. package/src/assets/images/social-share-black.png +0 -0
  137. package/src/assets/images/social-share-zen.png +0 -0
  138. package/src/assets/images/social-share.png +0 -0
  139. package/src/components/animated-number-machine.test.ts +140 -0
  140. package/src/components/animated-number.stories.tsx +35 -0
  141. package/src/components/app-icon.stories.tsx +73 -0
  142. package/src/components/card.stories.tsx +101 -0
  143. package/src/components/collapsible.stories.tsx +76 -0
  144. package/src/components/context-menu.stories.tsx +150 -0
  145. package/src/components/diagram-preview.stories.tsx +62 -0
  146. package/src/components/dock-surface.stories.tsx +26 -0
  147. package/src/components/document-surface.stories.tsx +42 -0
  148. package/src/components/error-details.stories.tsx +72 -0
  149. package/src/components/favicon.stories.tsx +49 -0
  150. package/src/components/file-icon-machine.test.ts +52 -0
  151. package/src/components/file-icon.stories.tsx +93 -0
  152. package/src/components/file-icons/sprite.svg +11707 -0
  153. package/src/components/font.stories.tsx +48 -0
  154. package/src/components/hover-card.stories.tsx +79 -0
  155. package/src/components/image-flight-machine.test.ts +184 -0
  156. package/src/components/image-flight.test.ts +173 -0
  157. package/src/components/image-preview.stories.tsx +392 -0
  158. package/src/components/image-zoom-machine.test.ts +154 -0
  159. package/src/components/image-zoom.test.ts +96 -0
  160. package/src/components/list.stories.tsx +221 -0
  161. package/src/components/logo.stories.tsx +62 -0
  162. package/src/components/menu-scroll.stories.tsx +73 -0
  163. package/src/components/popover-machine.test.ts +150 -0
  164. package/src/components/popover.stories.tsx +84 -0
  165. package/src/components/preview-controls.stories.tsx +40 -0
  166. package/src/components/progress.stories.tsx +69 -0
  167. package/src/components/provider-icon.stories.tsx +75 -0
  168. package/src/components/resize-handle-machine.test.ts +164 -0
  169. package/src/components/resize-handle.stories.tsx +81 -0
  170. package/src/components/rolling-number.stories.tsx +23 -0
  171. package/src/components/scroll-view-machine.test.ts +141 -0
  172. package/src/components/scroll-view.stories.tsx +68 -0
  173. package/src/components/scroll-view.test.ts +114 -0
  174. package/src/components/spinner-radar.test.ts +61 -0
  175. package/src/components/spinner.stories.tsx +40 -0
  176. package/src/components/sticky-accordion-header.stories.tsx +64 -0
  177. package/src/components/text-field-machine.test.ts +99 -0
  178. package/src/components/text-field.stories.tsx +132 -0
  179. package/src/components/text-reveal-machine.test.ts +157 -0
  180. package/src/components/text-reveal.stories.tsx +363 -0
  181. package/src/components/text-strikethrough.stories.tsx +296 -0
  182. package/src/components/thinking-heading.stories.tsx +900 -0
  183. package/src/components/truncated-text.stories.tsx +37 -0
  184. package/src/components/typewriter-machine.test.ts +177 -0
  185. package/src/components/typewriter.stories.tsx +51 -0
  186. package/src/context/dialog-machine.test.ts +295 -0
  187. package/src/context/i18n.test.ts +89 -0
  188. package/src/context/marked-base.test.ts +75 -0
  189. package/src/context/marked-parser.test.ts +167 -0
  190. package/src/context/marked-regression.test.ts +12 -0
  191. package/src/data-display/accordion/accordion.stories.tsx +76 -0
  192. package/src/data-display/avatar/avatar.stories.tsx +48 -0
  193. package/src/data-display/badge/badge.stories.tsx +75 -0
  194. package/src/data-display/diff-changes/diff-changes.stories.tsx +63 -0
  195. package/src/data-display/keybind/keybind.stories.tsx +77 -0
  196. package/src/data-display/line-comment/line-comment.stories.tsx +288 -0
  197. package/src/data-display/line-comment/machine.test.ts +385 -0
  198. package/src/data-display/project-avatar/animation-machine.test.ts +134 -0
  199. package/src/data-display/project-avatar/generated.test.ts +50 -0
  200. package/src/data-display/project-avatar/procedural.test.ts +16 -0
  201. package/src/data-display/project-avatar/project-avatar.stories.tsx +102 -0
  202. package/src/data-display/project-avatar/project-avatar.test.ts +21 -0
  203. package/src/data-display/project-avatar/project-icon-styles.stories.tsx +772 -0
  204. package/src/feedback/activity-ring/activity-ring.stories.tsx +20 -0
  205. package/src/feedback/loader/loader.stories.tsx +44 -0
  206. package/src/feedback/progress-circle/progress-circle.stories.tsx +56 -0
  207. package/src/feedback/toast/description.test.ts +20 -0
  208. package/src/feedback/toast/machine.test.ts +106 -0
  209. package/src/feedback/toast/toast.stories.tsx +186 -0
  210. package/src/forms/checkbox/checkbox.stories.tsx +104 -0
  211. package/src/forms/field/field.stories.tsx +129 -0
  212. package/src/forms/inline-input/inline-input.stories.tsx +37 -0
  213. package/src/forms/radio/radio.stories.tsx +145 -0
  214. package/src/forms/redirect-paste/redirect-paste.stories.tsx +101 -0
  215. package/src/forms/search-list/navigation.test.ts +40 -0
  216. package/src/forms/search-list/search-list.stories.tsx +108 -0
  217. package/src/forms/select/machine.test.ts +105 -0
  218. package/src/forms/select/select.stories.tsx +208 -0
  219. package/src/forms/switch/switch.stories.tsx +97 -0
  220. package/src/forms/text-input/text-input.stories.tsx +220 -0
  221. package/src/forms/textarea/textarea.stories.tsx +137 -0
  222. package/src/forms/typeahead/machine.test.ts +143 -0
  223. package/src/forms/typeahead/typeahead.stories.tsx +113 -0
  224. package/src/hooks/auto-scroll-machine.test.ts +212 -0
  225. package/src/hooks/list-machine.test.ts +263 -0
  226. package/src/hooks/spin-phase.test.ts +32 -0
  227. package/src/hooks/use-filtered-list.test.ts +41 -0
  228. package/src/icons/icon/icon.stories.tsx +131 -0
  229. package/src/layout/divider/divider.stories.tsx +38 -0
  230. package/src/motion/README.md +113 -0
  231. package/src/motion/core.test.ts +328 -0
  232. package/src/motion-tuning-features.test.ts +129 -0
  233. package/src/motion-tuning.test.ts +68 -0
  234. package/src/navigation/menu/machine.test.ts +85 -0
  235. package/src/navigation/menu/menu.stories.tsx +328 -0
  236. package/src/navigation/menu/submenu-machine.test.ts +71 -0
  237. package/src/navigation/segmented-control/segmented-control.stories.tsx +115 -0
  238. package/src/navigation/segmented-control/segmented-control.test.ts +123 -0
  239. package/src/navigation/tab-state-indicator.stories.tsx +24 -0
  240. package/src/navigation/tabs/tabs.stories.tsx +193 -0
  241. package/src/overlays/dialog/dialog.stories.tsx +365 -0
  242. package/src/overlays/mcp-sign-in/machine.test.ts +215 -0
  243. package/src/overlays/tooltip/machine.test.ts +214 -0
  244. package/src/overlays/tooltip/tooltip.stories.tsx +155 -0
  245. package/src/styles/blue-tokens.stories.tsx +215 -0
  246. package/src/theme/desktop-theme.schema.json +168 -0
  247. package/src/theme/machine.test.ts +498 -0
  248. package/src/theme/v2/resolve.test.ts +120 -0
  249. package/src/typography/slash/slash.stories.tsx +26 -0
  250. package/src/typography/text-shimmer/machine.test.ts +117 -0
  251. package/src/typography/text-shimmer/text-shimmer.stories.tsx +64 -0
  252. package/src/typography/wordmark/wordmark.stories.tsx +19 -0
  253. package/test/solid-jsx.ts +20 -0
  254. package/tsconfig.build.json +14 -0
  255. package/tsconfig.json +23 -0
  256. package/vite.config.ts +61 -0
@@ -0,0 +1,75 @@
1
+ import { expect, test } from "bun:test"
2
+ import { createMarkdownBase, parseSmallMarkdown } from "./marked-base"
3
+
4
+ test.each([
5
+ "Plain response.",
6
+ "The grade cost $0.5664, and the original run is preserved.",
7
+ "The issue is fixed: all 13 queries succeeded.",
8
+ "Completion is 100%…",
9
+ "https://example.com",
10
+ "Plain response. ",
11
+ "Plain response.\t",
12
+ "\nPlain response.\n",
13
+ "\u00a0Plain response.\u00a0",
14
+ "A paragraph\r---",
15
+ "A paragraph \rwith a hard break.",
16
+ "We can—Code Mode would be useful.\n\nI’ll enable the read-only tools.",
17
+ "A paragraph\nwith a soft break.",
18
+ "A paragraph\r\n\r\nAnother paragraph.",
19
+ "A paragraph\n\n\nAnother paragraph.\n",
20
+ "Quotes: \"yes\" and 'no'.",
21
+ "She said \"yes\" and 'no'.",
22
+ "日本語の文章。",
23
+ "Простой текст.",
24
+ "١. العربية",
25
+ "Hello & goodbye <world>.",
26
+ "A paragraph \nwith a hard break.",
27
+ "Title\n---",
28
+ "- A list\n- Another item",
29
+ "1. A list\n2. Another item",
30
+ "www.example.com",
31
+ "Bold **text** and `code`.",
32
+ "**Done.** The judge made **13 evidence queries**.",
33
+ "The tool is `candidate_evidence`.\n\nIt can query messages.",
34
+ "***Strong emphasis*** and _emphasis_.",
35
+ "A [link](https://example.com) and ![image](./image.png).",
36
+ "A reference [link][id].\n\n[id]: https://example.com",
37
+ "A paragraph\n# Heading",
38
+ "### Heading",
39
+ "####### Paragraph",
40
+ "***",
41
+ "_ _ _",
42
+ "**",
43
+ "*",
44
+ "+ Item",
45
+ "> Quote",
46
+ "A paragraph\n---",
47
+ "A paragraph\n===",
48
+ "a | b\n--- | ---\nc | d",
49
+ "<div>HTML</div>",
50
+ "A paragraph\n with indentation.",
51
+ "~~Struck~~ text and www.example.com.",
52
+ "A **bold\nsoft break**.",
53
+ "An escaped \\*asterisk\\*.",
54
+ " indented code",
55
+ "\n indented code",
56
+ " ",
57
+ ])("preserves the Markdown parser's meaning for %j", (text) => {
58
+ const expected = createMarkdownBase().parse(text, { async: false })
59
+
60
+ if (text.includes("indented code")) {
61
+ expect(parseSmallMarkdown(text)).toBeUndefined()
62
+
63
+ return
64
+ }
65
+
66
+ expect(parseSmallMarkdown(text)).toBe(expected)
67
+ })
68
+
69
+ test("keeps code blocks, math, and large messages on the worker path", () => {
70
+ expect(parseSmallMarkdown("```ts\nconst value = 1\n```")).toBeUndefined()
71
+ expect(parseSmallMarkdown("~~~ts\nconst value = 1\n~~~")).toBeUndefined()
72
+ expect(parseSmallMarkdown("\\(x + y\\)")).toBeUndefined()
73
+ expect(parseSmallMarkdown("$$x + y$$")).toBeUndefined()
74
+ expect(parseSmallMarkdown("a".repeat(1025))).toBeUndefined()
75
+ })
@@ -0,0 +1,167 @@
1
+ import { expect, test } from "bun:test"
2
+ import { createMarkdownParser } from "./marked-parser"
3
+ import { parseSmallMarkdown } from "./marked-base"
4
+
5
+ const parser = createMarkdownParser()
6
+
7
+ test.each([
8
+ ["OpenCode", "OpenCode"],
9
+ ["**`#123`**", "<strong><code>#123</code></strong>"],
10
+ ["*Review* ~~draft~~", "<em>Review</em> <del>draft</del>"],
11
+ ["`<example>`", "<code>&lt;example&gt;</code>"],
12
+ ["\\*literal\\*", "*literal*"],
13
+ ])("renders link label %s with application attributes", async (label, html) => {
14
+ const markdown = `[${label}](https://opencode.ai)`
15
+ const expected = `<p><a href="https://opencode.ai" class="external-link" target="_blank" rel="noopener noreferrer">${html}</a></p>\n`
16
+
17
+ expect(await parser.parse(markdown)).toBe(expected)
18
+ expect(parseSmallMarkdown(markdown)).toBe(expected)
19
+ })
20
+
21
+ test("keeps fragment links in the page", async () => {
22
+ const markdown = "See [Host services](#host-services)"
23
+ const expected = '<p>See <a href="#host-services">Host services</a></p>\n'
24
+
25
+ expect(await parser.parse(markdown)).toBe(expected)
26
+ expect(parseSmallMarkdown(markdown)).toBe(expected)
27
+ })
28
+
29
+ test("renders inline and block math", async () => {
30
+ expect(await parser.parse("\\(x^2\\)")).toContain('<span class="katex">')
31
+ expect(await parser.parse("$$\nx^2\n$$\n")).toContain('<span class="katex-display">')
32
+ })
33
+
34
+ test.each([
35
+ "Energy is $E = mc^2$.",
36
+ "因此 $x^2$ 是正数",
37
+ "因此$x^2$是正数",
38
+ "$a_1$ and $b_1$.",
39
+ "where (i.e. $x$) holds",
40
+ "the $x$-axis",
41
+ "is $x$; y",
42
+ "$x$'s value",
43
+ "ack ($440\\text{ ms}$ IPC p50)",
44
+ ])("renders dollar inline math: %s", async (text) => {
45
+ const html = await parser.parse(text)
46
+ expect(html).toContain('<span class="katex">')
47
+ expect(html).not.toContain("$")
48
+ })
49
+
50
+ test("renders every dollar span in a line", async () => {
51
+ const html = await parser.parse("ack ($440\\text{ ms}$ IPC p50, $413\\text{ MB} \\rightarrow 98\\text{ MB}$)")
52
+ expect(html.match(/<span class="katex">/g)).toHaveLength(2)
53
+ expect(html).not.toContain("$")
54
+ })
55
+
56
+ test("keeps an escaped dollar inside dollar math", async () => {
57
+ const html = await parser.parse("Escaped $a\\$b$ dollar")
58
+ expect(html.match(/<span class="katex">/g)).toHaveLength(1)
59
+ expect(html).toContain('<annotation encoding="application/x-tex">a\\$b</annotation>')
60
+ })
61
+
62
+ test.each(["$$E = mc^2$$", "Inline $$x$$ display", "($$x$$)", "$$\na\n\nb\n$$\n"])(
63
+ "renders dollar display math: %s",
64
+ async (text) => {
65
+ const html = await parser.parse(text)
66
+ expect(html).toContain('<span class="katex-display">')
67
+ expect(html).not.toContain("$$")
68
+ },
69
+ )
70
+
71
+ test.each([
72
+ "It costs $5 and $10.",
73
+ "From $5-$10 a month",
74
+ "It costs $5, originally $10, ranging from $1,000 to $2,000.",
75
+ "It costs $5 (or $6) now",
76
+ "between $5 and $6 dollars",
77
+ "paid $5/$6.",
78
+ "Use $HOME and $PATH",
79
+ "Use $HOME/$USER or $PATH:$HOME",
80
+ "Use `$x$` as a placeholder",
81
+ "An escaped \\$x$ dollar",
82
+ "$ x $ has space inside its delimiters",
83
+ ])("leaves prices, shell variables, and code as text: %s", async (text) => {
84
+ expect(await parser.parse(text)).not.toContain("katex")
85
+ })
86
+
87
+ // Each repeated unit took seconds at this size when `start` retried the dollar regex from every `$` for every text token.
88
+ test("lexes dollar-heavy paragraphs in near-linear time", () => {
89
+ const units = ["`a` $5 ", "$a ", "\\$$a", "$a\\\\\\ ", "It costs $5, ", "with `c` $x_1$ and "]
90
+ const startedAt = performance.now()
91
+ units.forEach((unit) => parser.lexer(unit.repeat(Math.ceil(10_000 / unit.length))))
92
+ expect(performance.now() - startedAt).toBeLessThan(500)
93
+ })
94
+
95
+ test("highlights fenced code with the app theme variables", async () => {
96
+ const html = await parser.parse("```ts\nconst value = 1\n```\n")
97
+
98
+ expect(html).toStartWith('<pre class="highlights" style="background-color:var(--color-background-stronger)')
99
+ expect(html).toContain('<code class="language-ts">')
100
+ expect(html).toContain('<span style="color:var(--syntax-keyword)">const </span>')
101
+ })
102
+
103
+ test.each(["latex", "math", "LaTeX", "latex title=\"Score\""])("renders a %s fence as display math", async (lang) => {
104
+ const html = await parser.parse(
105
+ `\`\`\`${lang}\nS_{\\text{adj}} = \\min\\!\\left(10,\\; S \\cdot \\left(\\frac{T_0}{T}\\right)^{\\alpha}\\right)\n\`\`\`\n`,
106
+ )
107
+
108
+ expect(html).toStartWith('<span class="katex-display">')
109
+ expect(html).not.toContain("<pre")
110
+ })
111
+
112
+ test("renders a math fence inside a list item", async () => {
113
+ expect(await parser.parse("- Score:\n\n ```latex\n x^2\n ```\n")).toContain('<span class="katex-display">')
114
+ })
115
+
116
+ test.each(["\\frac{1}{", "\\notacommand{x}", ""])("keeps a math fence KaTeX cannot parse as code: %p", async (source) => {
117
+ const html = await parser.parse(`\`\`\`latex\n${source}\n\`\`\`\n`)
118
+
119
+ expect(html).toContain('<code class="language-latex">')
120
+ expect(html).not.toContain("katex")
121
+ })
122
+
123
+ test("keeps the fence language for code without a lexer", async () => {
124
+ const html = await parser.parse("```mermaid\ngraph TD; A-->B\n```\n")
125
+
126
+ expect(html).toContain('<code class="language-mermaid">graph TD; A--&gt;B</code>')
127
+ })
128
+
129
+ test.each(["```", "~~~"])("recognizes an empty %s fence at EOF", async (fence) => {
130
+ expect(await parser.parse(`foo\n${fence}`)).toContain('<p>foo</p>\n<pre class="highlights"')
131
+ expect(await parser.parse(`foo\n${fence}`)).toContain('<code class="language-text"></code>')
132
+ })
133
+
134
+ test("preserves emphasis when rejecting an outer reference link", async () => {
135
+ expect(await parser.parse("[foo *bar [baz](/url) qux*][ref]\n\n[ref]: /uri")).toBe(
136
+ '<p>[foo <em>bar <a href="/url" class="external-link" target="_blank" rel="noopener noreferrer">baz</a> qux</em>]<a href="/uri" class="external-link" target="_blank" rel="noopener noreferrer">ref</a></p>\n',
137
+ )
138
+ })
139
+
140
+ test.each([
141
+ "Plain text with **bold**, *emphasis*, ~~deleted~~, and `inline code`.",
142
+ "## Heading\n\n> Quote\n\n- Done\n- Nested\n - item",
143
+ "| A | B |\n| --- | ---: |\n| one | two |",
144
+ '[link](https://example.com "Title") and <https://example.com>',
145
+ "[reference][key]\n\n[key]: https://example.com",
146
+ "[foo *bar [baz](/url) qux*][ref]\n\n[ref]: /uri",
147
+ '<img src="image.png" onerror="alert(1)"><script>alert(2)</script>',
148
+ "hello\r\n\r\nworld",
149
+ ])("small Markdown uses the same rendering rules: %s", async (text) => {
150
+ expect(parseSmallMarkdown(text)).toBe(await parser.parse(text))
151
+ })
152
+
153
+ test.each([
154
+ "```ts\nconst answer = 42\n```",
155
+ "- [x] Done\n- [ ] Pending",
156
+ "~~~\ncode\n~~~",
157
+ " indented code",
158
+ "> ```ts\n> const nested = true\n> ```",
159
+ "- item\n\n nested code",
160
+ "foo\n```",
161
+ "\\(x^2\\)",
162
+ "$$\nx^2\n$$\n",
163
+ "Energy is $E = mc^2$.",
164
+ "a".repeat(1025),
165
+ ])("leaves code, math, and large Markdown to the worker: %s", (text) => {
166
+ expect(parseSmallMarkdown(text)).toBeUndefined()
167
+ })
@@ -0,0 +1,12 @@
1
+ import { expect, test } from "bun:test"
2
+ import { Marked } from "marked"
3
+
4
+ test("preserves code spans adjacent to tildes", async () => {
5
+ const marked = new Marked()
6
+
7
+ expect(await marked.parse("~`0.1576` to measurement-window-only `0.00092`")).toBe(
8
+ "<p>~<code>0.1576</code> to measurement-window-only <code>0.00092</code></p>\n",
9
+ )
10
+ expect(await marked.parse("`before`~`after`")).toBe("<p><code>before</code>~<code>after</code></p>\n")
11
+ expect(await marked.parse("~~`deleted code`~~")).toBe("<p><del><code>deleted code</code></del></p>\n")
12
+ })
@@ -0,0 +1,76 @@
1
+ import { createEffect, createSignal, Show } from "solid-js"
2
+ import { Accordion } from "./accordion"
3
+
4
+ const defaults = {
5
+ value: "first",
6
+ multiple: false,
7
+ collapsible: true,
8
+ secondItem: true,
9
+ disableSecond: false,
10
+ shouldFocusWrap: true,
11
+ }
12
+
13
+ const docs = `### Overview
14
+ Accordion for collapsible content sections with optional multi-open behavior. Use one trigger per item.
15
+
16
+ ### API and behavior
17
+ Compose Accordion.Item, Header, Trigger and Content. The root supports Kobalte's multiple and collapsible modes.
18
+ Control expanded items with a string array and onChange; in this preview the value control sets the starting selection.
19
+
20
+ ### Accessibility and theming
21
+ Kobalte supplies keyboard navigation and ARIA behavior. Use data-component="accordion" and its slot attributes for theming.`
22
+
23
+ export default {
24
+ title: "UI/Accordion",
25
+ id: "ui-accordion",
26
+ component: Accordion,
27
+ tags: ["autodocs"],
28
+ parameters: { docs: { description: { component: docs } } },
29
+ args: defaults,
30
+ argTypes: { value: { control: "select", options: ["none", "first", "second", "both"] } },
31
+ render: (args: typeof defaults) => {
32
+ const [value, setValue] = createSignal<string[]>([])
33
+
34
+ createEffect(() => {
35
+ if (args.value === "both") return setValue(args.multiple ? ["first", "second"] : ["first"])
36
+ setValue(args.value === "none" ? [] : [args.value])
37
+ })
38
+
39
+ return (
40
+ <div style={{ width: "min(420px, 100%)" }}>
41
+ <Accordion
42
+ collapsible={args.collapsible}
43
+ multiple={args.multiple}
44
+ shouldFocusWrap={args.shouldFocusWrap}
45
+ value={args.multiple ? value() : value().slice(0, 1)}
46
+ onChange={setValue}
47
+ >
48
+ <Accordion.Item value="first">
49
+ <Accordion.Header>
50
+ <Accordion.Trigger>First</Accordion.Trigger>
51
+ </Accordion.Header>
52
+ <Accordion.Content>
53
+ <div style={{ color: "var(--text-weak)", padding: "8px 0" }}>Accordion content.</div>
54
+ </Accordion.Content>
55
+ </Accordion.Item>
56
+ <Show when={args.secondItem}>
57
+ <Accordion.Item value="second" disabled={args.disableSecond}>
58
+ <Accordion.Header>
59
+ <Accordion.Trigger>Second</Accordion.Trigger>
60
+ </Accordion.Header>
61
+ <Accordion.Content>
62
+ <div style={{ color: "var(--text-weak)", padding: "8px 0" }}>More content.</div>
63
+ </Accordion.Content>
64
+ </Accordion.Item>
65
+ </Show>
66
+ </Accordion>
67
+ </div>
68
+ )
69
+ },
70
+ }
71
+
72
+ export const Basic = {}
73
+
74
+ export const Multiple = { args: { multiple: true, collapsible: false, value: "both" } }
75
+
76
+ export const NonCollapsible = { args: { collapsible: false, secondItem: false } }
@@ -0,0 +1,48 @@
1
+ import { For } from "solid-js"
2
+ import image from "../../assets/favicon/apple-touch-icon.png"
3
+ import { Avatar, type AvatarProps } from "./avatar"
4
+
5
+ const sizes = ["small", "normal", "large"] satisfies AvatarProps["size"][]
6
+
7
+ const docs = `### Overview
8
+ Avatar matching OpenCode DS variants from Figma, for user lists and headers.
9
+
10
+ ### API and states
11
+ Provide a fallback string. The avatar displays its first grapheme or the image at src. Background and foreground override the fallback colors.
12
+ Sizes are small (16px), normal (20px) and large (28px); user avatars are circular and org avatars have rounded corners.
13
+
14
+ ### Accessibility and theming
15
+ Provide accessible context alongside image avatars. The root uses data-component="avatar-v2" and size, kind and image-state attributes.`
16
+
17
+ // Avatar captures its image source on mount; replace it when the source control changes.
18
+ function Preview(args: AvatarProps) {
19
+ return <For each={[args.src]}>{(src) => <Avatar {...args} src={src} />}</For>
20
+ }
21
+
22
+ export default {
23
+ title: "UI/Avatar",
24
+ id: "ui-avatar",
25
+ component: Avatar,
26
+ tags: ["autodocs"],
27
+ parameters: { docs: { description: { component: docs } } },
28
+ args: { fallback: "WW", size: "large", kind: "user", src: "", background: "", foreground: "" } satisfies AvatarProps,
29
+ argTypes: {
30
+ size: { control: "select", options: sizes },
31
+ kind: { control: "select", options: ["user", "org"] satisfies AvatarProps["kind"][] },
32
+ },
33
+ render: Preview,
34
+ }
35
+
36
+ export const Basic = {}
37
+
38
+ export const WithImage = { args: { src: image } }
39
+
40
+ export const Sizes = {
41
+ render: (args: AvatarProps) => (
42
+ <div class="flex items-center gap-3">
43
+ <For each={sizes}>{(size) => <Preview {...args} size={size} />}</For>
44
+ </div>
45
+ ),
46
+ }
47
+
48
+ export const OrgVariant = { args: { kind: "org" }, render: Sizes.render }
@@ -0,0 +1,75 @@
1
+ import { Badge, type BadgeProps } from "./badge"
2
+
3
+ type Args = Pick<BadgeProps, "appearance" | "variant"> & { children: string; highContrast: boolean }
4
+
5
+ const docs = `### Overview
6
+ Small inline label for metadata and status chips alongside headings or lists. Give it meaningful text as well as a color.
7
+
8
+ ### API and states
9
+ Badge accepts native span props. Compact (16px) uses tabular numeric text; standard (18px) is roomier.
10
+ Choose neutral, accent, subtle (borderless, for counts), or danger. The data-high-contrast attribute strengthens the compact neutral border.
11
+
12
+ ### Theming
13
+ Uses data-component="tag".`
14
+
15
+ function Preview(args: Args) {
16
+ return (
17
+ <Badge appearance={args.appearance} variant={args.variant} data-high-contrast={args.highContrast ? "" : undefined}>
18
+ {args.children}
19
+ </Badge>
20
+ )
21
+ }
22
+
23
+ export default {
24
+ title: "UI/Badge",
25
+ id: "ui-badge",
26
+ component: Badge,
27
+ tags: ["autodocs"],
28
+ parameters: { docs: { description: { component: docs } } },
29
+ args: { children: "Label", appearance: "compact", variant: "neutral", highContrast: false } satisfies Args,
30
+ argTypes: {
31
+ appearance: { control: "select", options: ["compact", "standard"] satisfies BadgeProps["appearance"][] },
32
+ variant: {
33
+ control: "select",
34
+ options: ["neutral", "accent", "subtle", "danger"] satisfies BadgeProps["variant"][],
35
+ },
36
+ },
37
+ render: Preview,
38
+ }
39
+
40
+ export const Basic = {}
41
+
42
+ export const Appearances = {
43
+ render: (args: Args) => (
44
+ <div class="flex items-center gap-2">
45
+ <Preview {...args} appearance="standard">
46
+ Standard
47
+ </Preview>
48
+ <Preview {...args} appearance="compact">
49
+ Compact
50
+ </Preview>
51
+ </div>
52
+ ),
53
+ }
54
+
55
+ export const Subtle = {
56
+ args: { variant: "subtle", children: "12" },
57
+ render: (args: Args) => (
58
+ <div class="flex items-center gap-2">
59
+ <Preview {...args}>1</Preview>
60
+ <Preview {...args} />
61
+ </div>
62
+ ),
63
+ }
64
+
65
+ export const HighContrast = {
66
+ args: { highContrast: true },
67
+ render: (args: Args) => (
68
+ <div class="flex items-center gap-2">
69
+ <Preview {...args} highContrast={false} />
70
+ <Preview {...args} />
71
+ </div>
72
+ ),
73
+ }
74
+
75
+ export const Accent = { args: { variant: "accent", children: "New" } }
@@ -0,0 +1,63 @@
1
+ import type { ComponentProps } from "solid-js"
2
+ import { DiffChanges } from "./diff-changes"
3
+
4
+ type Args = Pick<ComponentProps<typeof DiffChanges>, "appearance" | "markEmpty"> & {
5
+ additions: number
6
+ deletions: number
7
+ multipleFiles: boolean
8
+ }
9
+
10
+ const count = { control: { type: "range", min: 0, max: 100, step: 1 } }
11
+
12
+ const docs = `### Overview
13
+ Summarize additions/deletions as compact text. Pair with Diff or DiffSSR to contextualize a change set.
14
+
15
+ ### API and behavior
16
+ Changes accepts one { additions, deletions } object or an array. Adjust the first file’s counts; Multiple files adds two more changes (+8/−3 and +2/−0).
17
+ The component aggregates totals and renders nothing for zero changes. Marking empty sides lets the caller hide them.
18
+
19
+ ### Appearance and accessibility
20
+ Choose compact or standard. Provide surrounding context for the counts. The component uses data-component="diff-changes" and diff color tokens.`
21
+
22
+ function Preview(args: Args) {
23
+ const file = () => ({ additions: args.additions, deletions: args.deletions })
24
+
25
+ return (
26
+ <DiffChanges
27
+ class="[&_[data-empty]]:hidden"
28
+ appearance={args.appearance}
29
+ markEmpty={args.markEmpty}
30
+ changes={args.multipleFiles ? [file(), { additions: 8, deletions: 3 }, { additions: 2, deletions: 0 }] : file()}
31
+ />
32
+ )
33
+ }
34
+
35
+ export default {
36
+ title: "UI/DiffChanges",
37
+ id: "ui-diff-changes",
38
+ component: DiffChanges,
39
+ tags: ["autodocs"],
40
+ parameters: { docs: { description: { component: docs } } },
41
+ args: { additions: 12, deletions: 5, appearance: "compact", markEmpty: false, multipleFiles: false } satisfies Args,
42
+ argTypes: {
43
+ additions: count,
44
+ deletions: count,
45
+ appearance: { control: "select", options: ["compact", "standard"] },
46
+ },
47
+ render: Preview,
48
+ }
49
+
50
+ export const Default = {}
51
+
52
+ export const Appearances = {
53
+ render: (args: Args) => (
54
+ <div class="flex items-center gap-4">
55
+ <Preview {...args} appearance="standard" />
56
+ <Preview {...args} appearance="compact" />
57
+ </div>
58
+ ),
59
+ }
60
+
61
+ export const MultipleFiles = { args: { multipleFiles: true, additions: 4, deletions: 1 } }
62
+
63
+ export const Zero = { args: { additions: 0, deletions: 0 } }
@@ -0,0 +1,77 @@
1
+ import { For } from "solid-js"
2
+ import { Keybind, type KeybindProps } from "./keybind"
3
+
4
+ const variants = ["neutral", "ghost", "outline"] satisfies KeybindProps["variant"][]
5
+
6
+ type Args = { keys: string; variant: KeybindProps["variant"] }
7
+
8
+ function Preview(args: Args) {
9
+ return <Keybind keys={args.keys.trim().split(/\s+/).filter(Boolean)} variant={args.variant} />
10
+ }
11
+
12
+ const docs = `### Overview
13
+ Inline keybind indicator that renders one or more keyboard keys in a compact row.
14
+
15
+ ### API
16
+ - \`keys\`: Array of key labels to display. Separate labels with spaces in the preview.
17
+ - Inherits native div attributes.
18
+
19
+ ### Variants
20
+ - Neutral — each key sits on a gray pill with darker text.
21
+ - Ghost — keys render without a background, with lighter text.
22
+ - Outline — each key has an inset border and no background, with the dimensions of Neutral.`
23
+
24
+ export default {
25
+ title: "UI/Keybind",
26
+ id: "ui-keybind",
27
+ component: Keybind,
28
+ tags: ["autodocs"],
29
+ parameters: {
30
+ frameHeight: "200px",
31
+ frameBackground: "#fff",
32
+ docs: { description: { component: docs } },
33
+ },
34
+ args: { keys: "⌘", variant: "neutral" },
35
+ argTypes: {
36
+ variant: { control: "select", options: variants },
37
+ },
38
+ render: Preview,
39
+ }
40
+
41
+ export const Playground = {}
42
+
43
+ export const Variants = {
44
+ render: (args: Args) => (
45
+ <div class="flex items-center gap-6">
46
+ <For each={variants}>{(variant) => <Preview {...args} variant={variant} />}</For>
47
+ </div>
48
+ ),
49
+ }
50
+
51
+ export const MultipleKeys = {
52
+ args: { keys: "⌘ K" },
53
+ render: (args: Args) => (
54
+ <div class="flex items-center gap-6">
55
+ <For each={variants}>{(variant) => <Preview {...args} variant={variant} />}</For>
56
+ <Keybind keys={["Ctrl", "B"]} variant="neutral" />
57
+ <Keybind keys={["Ctrl", "B"]} variant="ghost" />
58
+ </div>
59
+ ),
60
+ }
61
+
62
+ export const AllExamples = {
63
+ render: (args: Args) => (
64
+ <div class="grid gap-4">
65
+ <For each={variants}>
66
+ {(variant) => (
67
+ <div class="flex items-center gap-6">
68
+ <span class="w-[50px] text-xs text-text-weak capitalize">{variant}</span>
69
+ <For each={[args.keys, "⌘ K", "⌘ ⇧ P", "Ctrl Shift B"]}>
70
+ {(keys) => <Preview keys={keys} variant={variant} />}
71
+ </For>
72
+ </div>
73
+ )}
74
+ </For>
75
+ </div>
76
+ ),
77
+ }