@zyro-sec/ui 1.0.2 → 1.0.3

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 (631) hide show
  1. package/AGENTS.md +29 -29
  2. package/LICENSE +21 -21
  3. package/bunfig.toml +2 -2
  4. package/package.json +2 -2
  5. package/perf/motion.bench.ts +14 -14
  6. package/perf/motion.ts +16 -16
  7. package/script/build-oc2-v2-overrides.ts +38 -38
  8. package/script/colors.txt +288 -288
  9. package/script/generate-spinner.ts +121 -121
  10. package/script/pack.ts +5 -5
  11. package/script/tailwind.ts +24 -24
  12. package/src/actions/button/button.css +346 -346
  13. package/src/actions/button/button.stories.tsx +158 -158
  14. package/src/actions/button/button.tsx +56 -56
  15. package/src/actions/icon-button/icon-button.css +128 -128
  16. package/src/actions/icon-button/icon-button.stories.tsx +122 -122
  17. package/src/actions/icon-button/icon-button.tsx +46 -46
  18. package/src/actions/split-button/split-button.css +99 -99
  19. package/src/actions/split-button/split-button.stories.tsx +59 -59
  20. package/src/actions/split-button/split-button.tsx +51 -51
  21. package/src/actions/submit.css +81 -81
  22. package/src/assets/favicon/favicon-v3.svg +6 -6
  23. package/src/assets/favicon/favicon.svg +6 -6
  24. package/src/assets/favicon/site.webmanifest +24 -24
  25. package/src/assets/icons/app/android-studio.svg +369 -369
  26. package/src/assets/icons/app/antigravity.svg +97 -97
  27. package/src/assets/icons/app/cursor.svg +16 -16
  28. package/src/assets/icons/app/file-explorer.svg +20 -20
  29. package/src/assets/icons/app/ghostty.svg +13 -13
  30. package/src/assets/icons/app/iterm2.svg +13 -13
  31. package/src/assets/icons/app/powershell.svg +14 -14
  32. package/src/assets/icons/app/sublimetext.svg +17 -17
  33. package/src/assets/icons/app/vscode.svg +39 -39
  34. package/src/assets/icons/app/windows-terminal.svg +6 -6
  35. package/src/assets/icons/app/zed-dark.svg +15 -15
  36. package/src/assets/icons/app/zed.svg +15 -15
  37. package/src/assets/icons/file-types/auto_light.svg +12 -12
  38. package/src/assets/icons/file-types/cursor.svg +1 -1
  39. package/src/assets/icons/file-types/cursor_light.svg +1 -1
  40. package/src/assets/icons/file-types/drone_light.svg +4 -4
  41. package/src/assets/icons/file-types/folder-admin-open.svg +6 -6
  42. package/src/assets/icons/file-types/folder-admin.svg +6 -6
  43. package/src/assets/icons/file-types/folder-circleci-open.svg +7 -7
  44. package/src/assets/icons/file-types/folder-circleci.svg +7 -7
  45. package/src/assets/icons/file-types/folder-flow-open.svg +6 -6
  46. package/src/assets/icons/file-types/folder-flow.svg +6 -6
  47. package/src/assets/icons/file-types/folder-gh-workflows-open.svg +6 -6
  48. package/src/assets/icons/file-types/folder-gh-workflows.svg +6 -6
  49. package/src/assets/icons/file-types/folder-github-open.svg +6 -6
  50. package/src/assets/icons/file-types/folder-github.svg +6 -6
  51. package/src/assets/icons/file-types/folder-intellij-open.svg +39 -39
  52. package/src/assets/icons/file-types/folder-intellij.svg +39 -39
  53. package/src/assets/icons/file-types/folder-macos-open.svg +6 -6
  54. package/src/assets/icons/file-types/folder-macos.svg +6 -6
  55. package/src/assets/icons/file-types/folder-next-open.svg +6 -6
  56. package/src/assets/icons/file-types/folder-next.svg +6 -6
  57. package/src/assets/icons/file-types/folder-nuxt-open.svg +6 -6
  58. package/src/assets/icons/file-types/folder-nuxt.svg +6 -6
  59. package/src/assets/icons/file-types/folder-open.svg +5 -5
  60. package/src/assets/icons/file-types/folder-scripts-open.svg +6 -6
  61. package/src/assets/icons/file-types/folder-scripts.svg +6 -6
  62. package/src/assets/icons/file-types/folder-target-open.svg +10 -10
  63. package/src/assets/icons/file-types/folder-target.svg +10 -10
  64. package/src/assets/icons/file-types/folder-turborepo-open.svg +15 -15
  65. package/src/assets/icons/file-types/folder-turborepo.svg +15 -15
  66. package/src/assets/icons/file-types/folder-vercel-open.svg +5 -5
  67. package/src/assets/icons/file-types/folder-vercel.svg +5 -5
  68. package/src/assets/icons/file-types/folder.svg +5 -5
  69. package/src/assets/icons/file-types/go_gopher.svg +35 -35
  70. package/src/assets/icons/file-types/nano-staged_light.svg +4 -4
  71. package/src/assets/icons/file-types/opa.svg +9 -9
  72. package/src/assets/icons/file-types/quarto.svg +5 -5
  73. package/src/assets/icons/file-types/rome.svg +6 -6
  74. package/src/assets/icons/file-types/stitches_light.svg +10 -10
  75. package/src/assets/icons/file-types/stylelint_light.svg +13 -13
  76. package/src/assets/icons/file-types/unocss.svg +5 -5
  77. package/src/assets/icons/file-types/vlang.svg +6 -6
  78. package/src/assets/icons/provider/302ai.svg +6 -6
  79. package/src/assets/icons/provider/abacus.svg +14 -14
  80. package/src/assets/icons/provider/aihubmix.svg +3 -3
  81. package/src/assets/icons/provider/alibaba-cn.svg +3 -3
  82. package/src/assets/icons/provider/alibaba-coding-plan-cn.svg +3 -3
  83. package/src/assets/icons/provider/alibaba-coding-plan.svg +3 -3
  84. package/src/assets/icons/provider/alibaba.svg +3 -3
  85. package/src/assets/icons/provider/amazon-bedrock.svg +3 -3
  86. package/src/assets/icons/provider/anthropic.svg +2 -2
  87. package/src/assets/icons/provider/azure-cognitive-services.svg +24 -24
  88. package/src/assets/icons/provider/azure.svg +3 -3
  89. package/src/assets/icons/provider/bailing.svg +3 -3
  90. package/src/assets/icons/provider/baseten.svg +3 -3
  91. package/src/assets/icons/provider/berget.svg +2 -2
  92. package/src/assets/icons/provider/cerebras.svg +4 -4
  93. package/src/assets/icons/provider/chutes.svg +24 -24
  94. package/src/assets/icons/provider/clarifai.svg +24 -24
  95. package/src/assets/icons/provider/claude-agent.svg +3 -3
  96. package/src/assets/icons/provider/cloudferro-sherlock.svg +4 -4
  97. package/src/assets/icons/provider/cloudflare-ai-gateway.svg +4 -4
  98. package/src/assets/icons/provider/cloudflare-workers-ai.svg +4 -4
  99. package/src/assets/icons/provider/cohere.svg +5 -5
  100. package/src/assets/icons/provider/cortecs.svg +24 -24
  101. package/src/assets/icons/provider/deepinfra.svg +4 -4
  102. package/src/assets/icons/provider/deepseek.svg +3 -3
  103. package/src/assets/icons/provider/digitalocean.svg +6 -6
  104. package/src/assets/icons/provider/dinference.svg +1 -1
  105. package/src/assets/icons/provider/drun.svg +8 -8
  106. package/src/assets/icons/provider/evroc.svg +2 -2
  107. package/src/assets/icons/provider/fastrouter.svg +3 -3
  108. package/src/assets/icons/provider/fireworks-ai.svg +3 -3
  109. package/src/assets/icons/provider/firmware.svg +18 -18
  110. package/src/assets/icons/provider/friendli.svg +3 -3
  111. package/src/assets/icons/provider/github-copilot.svg +3 -3
  112. package/src/assets/icons/provider/github-models.svg +3 -3
  113. package/src/assets/icons/provider/gitlab.svg +3 -3
  114. package/src/assets/icons/provider/google-vertex-anthropic.svg +24 -24
  115. package/src/assets/icons/provider/google-vertex.svg +10 -10
  116. package/src/assets/icons/provider/google.svg +3 -3
  117. package/src/assets/icons/provider/groq.svg +3 -3
  118. package/src/assets/icons/provider/helicone.svg +6 -6
  119. package/src/assets/icons/provider/huggingface.svg +3 -3
  120. package/src/assets/icons/provider/iflowcn.svg +3 -3
  121. package/src/assets/icons/provider/inception.svg +4 -4
  122. package/src/assets/icons/provider/inference.svg +3 -3
  123. package/src/assets/icons/provider/io-net.svg +5 -5
  124. package/src/assets/icons/provider/jiekou.svg +4 -4
  125. package/src/assets/icons/provider/kilo.svg +4 -4
  126. package/src/assets/icons/provider/kimi-for-coding.svg +3 -3
  127. package/src/assets/icons/provider/kuae-cloud-coding-plan.svg +3 -3
  128. package/src/assets/icons/provider/llama.svg +3 -3
  129. package/src/assets/icons/provider/lmstudio.svg +24 -24
  130. package/src/assets/icons/provider/lucidquery.svg +3 -3
  131. package/src/assets/icons/provider/meganova.svg +3 -3
  132. package/src/assets/icons/provider/meituan.svg +6 -6
  133. package/src/assets/icons/provider/meta.svg +3 -3
  134. package/src/assets/icons/provider/minimax-cn-coding-plan.svg +24 -24
  135. package/src/assets/icons/provider/minimax-cn.svg +3 -3
  136. package/src/assets/icons/provider/minimax-coding-plan.svg +24 -24
  137. package/src/assets/icons/provider/minimax.svg +3 -3
  138. package/src/assets/icons/provider/mistral.svg +3 -3
  139. package/src/assets/icons/provider/moark.svg +3 -3
  140. package/src/assets/icons/provider/modelscope.svg +5 -5
  141. package/src/assets/icons/provider/moonshotai-cn.svg +3 -3
  142. package/src/assets/icons/provider/moonshotai.svg +3 -3
  143. package/src/assets/icons/provider/morph.svg +24 -24
  144. package/src/assets/icons/provider/nano-gpt.svg +2 -2
  145. package/src/assets/icons/provider/nebius.svg +4 -4
  146. package/src/assets/icons/provider/nova.svg +3 -3
  147. package/src/assets/icons/provider/novita-ai.svg +10 -10
  148. package/src/assets/icons/provider/nvidia.svg +3 -3
  149. package/src/assets/icons/provider/ollama-cloud.svg +7 -7
  150. package/src/assets/icons/provider/openai.svg +3 -3
  151. package/src/assets/icons/provider/opencode-go.svg +3 -3
  152. package/src/assets/icons/provider/opencode.svg +3 -3
  153. package/src/assets/icons/provider/openrouter.svg +3 -3
  154. package/src/assets/icons/provider/ovhcloud.svg +3 -3
  155. package/src/assets/icons/provider/perplexity-agent.svg +3 -3
  156. package/src/assets/icons/provider/perplexity.svg +3 -3
  157. package/src/assets/icons/provider/poe.svg +7 -7
  158. package/src/assets/icons/provider/privatemode-ai.svg +4 -4
  159. package/src/assets/icons/provider/qihang-ai.svg +8 -8
  160. package/src/assets/icons/provider/qiniu-ai.svg +7 -7
  161. package/src/assets/icons/provider/reflection.svg +3 -3
  162. package/src/assets/icons/provider/requesty.svg +24 -24
  163. package/src/assets/icons/provider/sap-ai-core.svg +24 -24
  164. package/src/assets/icons/provider/scaleway.svg +5 -5
  165. package/src/assets/icons/provider/siliconflow-cn.svg +3 -3
  166. package/src/assets/icons/provider/siliconflow.svg +3 -3
  167. package/src/assets/icons/provider/stackit.svg +4 -4
  168. package/src/assets/icons/provider/stepfun.svg +16 -16
  169. package/src/assets/icons/provider/submodel.svg +3 -3
  170. package/src/assets/icons/provider/synthetic.svg +24 -24
  171. package/src/assets/icons/provider/tencent-coding-plan.svg +5 -5
  172. package/src/assets/icons/provider/tencent.svg +3 -3
  173. package/src/assets/icons/provider/thinkingmachines.svg +3 -3
  174. package/src/assets/icons/provider/togetherai.svg +4 -4
  175. package/src/assets/icons/provider/upstage.svg +24 -24
  176. package/src/assets/icons/provider/v0.svg +3 -3
  177. package/src/assets/icons/provider/venice.svg +4 -4
  178. package/src/assets/icons/provider/vercel.svg +3 -3
  179. package/src/assets/icons/provider/vivgrid.svg +4 -4
  180. package/src/assets/icons/provider/vultr.svg +6 -6
  181. package/src/assets/icons/provider/wandb.svg +24 -24
  182. package/src/assets/icons/provider/xai.svg +3 -3
  183. package/src/assets/icons/provider/xiaomi.svg +3 -3
  184. package/src/assets/icons/provider/zai-coding-plan.svg +3 -3
  185. package/src/assets/icons/provider/zai.svg +3 -3
  186. package/src/assets/icons/provider/zenmux.svg +4 -4
  187. package/src/assets/icons/provider/zhipuai-coding-plan.svg +3 -3
  188. package/src/assets/icons/provider/zhipuai.svg +3 -3
  189. package/src/components/animated-number-machine.ts +214 -214
  190. package/src/components/animated-number.css +110 -110
  191. package/src/components/animated-number.stories.tsx +35 -35
  192. package/src/components/animated-number.tsx +202 -202
  193. package/src/components/app-icon.css +5 -5
  194. package/src/components/app-icon.stories.tsx +73 -73
  195. package/src/components/app-icon.tsx +89 -89
  196. package/src/components/app-icons/sprite.svg +114 -114
  197. package/src/components/app-icons/types.ts +22 -22
  198. package/src/components/card.css +94 -94
  199. package/src/components/card.stories.tsx +101 -101
  200. package/src/components/card.tsx +145 -145
  201. package/src/components/collapsible.css +139 -139
  202. package/src/components/collapsible.stories.tsx +76 -76
  203. package/src/components/collapsible.tsx +62 -62
  204. package/src/components/context-menu.css +134 -134
  205. package/src/components/context-menu.stories.tsx +150 -150
  206. package/src/components/context-menu.tsx +342 -342
  207. package/src/components/diagram-preview.css +95 -95
  208. package/src/components/diagram-preview.stories.tsx +62 -62
  209. package/src/components/diagram-preview.tsx +332 -332
  210. package/src/components/dock-surface.css +30 -30
  211. package/src/components/dock-surface.stories.tsx +26 -26
  212. package/src/components/dock-surface.tsx +40 -40
  213. package/src/components/document-surface.css +37 -37
  214. package/src/components/document-surface.stories.tsx +42 -42
  215. package/src/components/document-surface.tsx +6 -6
  216. package/src/components/error-details.css +41 -41
  217. package/src/components/error-details.stories.tsx +72 -72
  218. package/src/components/error-details.tsx +13 -13
  219. package/src/components/favicon.stories.tsx +49 -49
  220. package/src/components/favicon.tsx +13 -13
  221. package/src/components/file-icon-machine.ts +78 -78
  222. package/src/components/file-icon.css +6 -6
  223. package/src/components/file-icon.stories.tsx +93 -93
  224. package/src/components/file-icon.tsx +186 -186
  225. package/src/components/file-icons/choose-icon-name.ts +574 -574
  226. package/src/components/file-icons/sprite.svg +11707 -11707
  227. package/src/components/file-icons/types.ts +1095 -1095
  228. package/src/components/font.stories.tsx +48 -48
  229. package/src/components/font.tsx +1 -1
  230. package/src/components/hover-card.css +61 -61
  231. package/src/components/hover-card.stories.tsx +79 -79
  232. package/src/components/hover-card.tsx +32 -32
  233. package/src/components/image-flight-machine.ts +247 -247
  234. package/src/components/image-flight.ts +161 -161
  235. package/src/components/image-preview.css +202 -202
  236. package/src/components/image-preview.stories.tsx +392 -392
  237. package/src/components/image-preview.tsx +908 -908
  238. package/src/components/image-zoom-machine.ts +191 -191
  239. package/src/components/image-zoom.ts +124 -124
  240. package/src/components/list.css +331 -331
  241. package/src/components/list.stories.tsx +221 -221
  242. package/src/components/list.tsx +322 -322
  243. package/src/components/logo.css +4 -4
  244. package/src/components/logo.stories.tsx +62 -62
  245. package/src/components/logo.tsx +62 -62
  246. package/src/components/menu-scroll.css +70 -70
  247. package/src/components/menu-scroll.stories.tsx +73 -73
  248. package/src/components/menu-scroll.tsx +202 -202
  249. package/src/components/motion-spring.tsx +65 -65
  250. package/src/components/popover-machine.ts +198 -198
  251. package/src/components/popover.css +66 -66
  252. package/src/components/popover.stories.tsx +84 -84
  253. package/src/components/popover.tsx +234 -234
  254. package/src/components/preview-controls.css +28 -28
  255. package/src/components/preview-controls.stories.tsx +40 -40
  256. package/src/components/preview-controls.tsx +53 -53
  257. package/src/components/progress.css +63 -63
  258. package/src/components/progress.stories.tsx +69 -69
  259. package/src/components/progress.tsx +39 -39
  260. package/src/components/provider-icon.css +5 -5
  261. package/src/components/provider-icon.stories.tsx +75 -75
  262. package/src/components/provider-icon.tsx +31 -31
  263. package/src/components/provider-icons/sprite.svg +1131 -1131
  264. package/src/components/provider-icons/types.ts +111 -111
  265. package/src/components/resize-handle-machine.ts +174 -174
  266. package/src/components/resize-handle.css +81 -81
  267. package/src/components/resize-handle.stories.tsx +81 -81
  268. package/src/components/resize-handle.tsx +164 -164
  269. package/src/components/rolling-number.css +24 -24
  270. package/src/components/rolling-number.stories.tsx +23 -23
  271. package/src/components/rolling-number.tsx +135 -135
  272. package/src/components/scroll-view-machine.ts +244 -244
  273. package/src/components/scroll-view.css +99 -99
  274. package/src/components/scroll-view.stories.tsx +68 -68
  275. package/src/components/scroll-view.tsx +653 -653
  276. package/src/components/spinner-frames.css +6 -6
  277. package/src/components/spinner-radar.ts +150 -150
  278. package/src/components/spinner.css +38 -38
  279. package/src/components/spinner.stories.tsx +40 -40
  280. package/src/components/spinner.tsx +43 -43
  281. package/src/components/sticky-accordion-header.css +11 -11
  282. package/src/components/sticky-accordion-header.stories.tsx +64 -64
  283. package/src/components/sticky-accordion-header.tsx +18 -18
  284. package/src/components/text-field-machine.ts +102 -102
  285. package/src/components/text-field.css +134 -134
  286. package/src/components/text-field.stories.tsx +132 -132
  287. package/src/components/text-field.tsx +196 -196
  288. package/src/components/text-reveal-machine.ts +184 -184
  289. package/src/components/text-reveal.css +150 -150
  290. package/src/components/text-reveal.stories.tsx +363 -363
  291. package/src/components/text-reveal.tsx +165 -165
  292. package/src/components/text-strikethrough.css +27 -27
  293. package/src/components/text-strikethrough.stories.tsx +296 -296
  294. package/src/components/text-strikethrough.tsx +92 -92
  295. package/src/components/thinking-heading.stories.tsx +900 -900
  296. package/src/components/truncated-text.css +25 -25
  297. package/src/components/truncated-text.stories.tsx +37 -37
  298. package/src/components/truncated-text.tsx +30 -30
  299. package/src/components/typewriter-machine.ts +134 -134
  300. package/src/components/typewriter.css +14 -14
  301. package/src/components/typewriter.stories.tsx +51 -51
  302. package/src/components/typewriter.tsx +70 -70
  303. package/src/context/dialog-machine.ts +281 -281
  304. package/src/context/dialog.tsx +376 -376
  305. package/src/context/file.tsx +11 -11
  306. package/src/context/focus-rescue.tsx +230 -230
  307. package/src/context/helper.tsx +43 -43
  308. package/src/context/highlight-theme.tsx +66 -66
  309. package/src/context/i18n.tsx +144 -144
  310. package/src/context/index.ts +7 -7
  311. package/src/context/marked-base.tsx +67 -67
  312. package/src/context/marked-parser.tsx +154 -154
  313. package/src/context/overlay-focus.tsx +90 -90
  314. package/src/custom-elements.d.ts +17 -17
  315. package/src/data-display/accordion/accordion.css +130 -130
  316. package/src/data-display/accordion/accordion.stories.tsx +76 -76
  317. package/src/data-display/accordion/accordion.tsx +106 -106
  318. package/src/data-display/avatar/avatar.css +70 -70
  319. package/src/data-display/avatar/avatar.stories.tsx +48 -48
  320. package/src/data-display/avatar/avatar.tsx +63 -63
  321. package/src/data-display/badge/badge.css +63 -63
  322. package/src/data-display/badge/badge.stories.tsx +75 -75
  323. package/src/data-display/badge/badge.tsx +26 -26
  324. package/src/data-display/diff-changes/diff-changes.css +47 -47
  325. package/src/data-display/diff-changes/diff-changes.stories.tsx +63 -63
  326. package/src/data-display/diff-changes/diff-changes.tsx +43 -43
  327. package/src/data-display/keybind/keybind.css +84 -84
  328. package/src/data-display/keybind/keybind.stories.tsx +77 -77
  329. package/src/data-display/keybind/keybind.tsx +31 -31
  330. package/src/data-display/line-comment/line-comment.css +341 -341
  331. package/src/data-display/line-comment/line-comment.stories.tsx +288 -288
  332. package/src/data-display/line-comment/line-comment.tsx +554 -554
  333. package/src/data-display/line-comment/machine.ts +400 -400
  334. package/src/data-display/line-comment/quote-check.svg +3 -3
  335. package/src/data-display/project-avatar/animation-machine.ts +182 -182
  336. package/src/data-display/project-avatar/animation.ts +133 -133
  337. package/src/data-display/project-avatar/generated.ts +225 -225
  338. package/src/data-display/project-avatar/procedural-craft.ts +1079 -1079
  339. package/src/data-display/project-avatar/procedural-kit.ts +244 -244
  340. package/src/data-display/project-avatar/procedural-machine.ts +924 -924
  341. package/src/data-display/project-avatar/procedural-world.ts +1542 -1542
  342. package/src/data-display/project-avatar/procedural.ts +1563 -1563
  343. package/src/data-display/project-avatar/project-avatar.css +189 -189
  344. package/src/data-display/project-avatar/project-avatar.stories.tsx +102 -102
  345. package/src/data-display/project-avatar/project-avatar.tsx +246 -246
  346. package/src/data-display/project-avatar/project-icon-styles.stories.tsx +772 -772
  347. package/src/feedback/activity-ring/activity-ring.css +5 -5
  348. package/src/feedback/activity-ring/activity-ring.stories.tsx +20 -20
  349. package/src/feedback/activity-ring/activity-ring.tsx +15 -15
  350. package/src/feedback/loader/loader.css +32 -32
  351. package/src/feedback/loader/loader.stories.tsx +44 -44
  352. package/src/feedback/loader/loader.tsx +34 -34
  353. package/src/feedback/progress-circle/progress-circle.css +28 -28
  354. package/src/feedback/progress-circle/progress-circle.stories.tsx +56 -56
  355. package/src/feedback/progress-circle/progress-circle.tsx +64 -64
  356. package/src/feedback/toast/description.ts +10 -10
  357. package/src/feedback/toast/machine.ts +115 -115
  358. package/src/feedback/toast/toast.css +234 -234
  359. package/src/feedback/toast/toast.stories.tsx +186 -186
  360. package/src/feedback/toast/toast.tsx +317 -317
  361. package/src/forms/checkbox/checkbox-compact.css +170 -170
  362. package/src/forms/checkbox/checkbox.css +125 -125
  363. package/src/forms/checkbox/checkbox.stories.tsx +104 -104
  364. package/src/forms/checkbox/checkbox.tsx +119 -119
  365. package/src/forms/field/field.css +94 -94
  366. package/src/forms/field/field.stories.tsx +129 -129
  367. package/src/forms/field/field.tsx +271 -271
  368. package/src/forms/inline-input/inline-input.css +16 -16
  369. package/src/forms/inline-input/inline-input.stories.tsx +37 -37
  370. package/src/forms/inline-input/inline-input.tsx +26 -26
  371. package/src/forms/radio/radio.css +218 -218
  372. package/src/forms/radio/radio.stories.tsx +145 -145
  373. package/src/forms/radio/radio.tsx +95 -95
  374. package/src/forms/redirect-paste/redirect-paste.stories.tsx +101 -101
  375. package/src/forms/redirect-paste/redirect-paste.tsx +92 -92
  376. package/src/forms/search-list/navigation.ts +54 -54
  377. package/src/forms/search-list/search-list.css +249 -249
  378. package/src/forms/search-list/search-list.stories.tsx +108 -108
  379. package/src/forms/search-list/search-list.tsx +463 -463
  380. package/src/forms/select/machine.ts +81 -81
  381. package/src/forms/select/select.css +312 -312
  382. package/src/forms/select/select.stories.tsx +208 -208
  383. package/src/forms/select/select.tsx +281 -281
  384. package/src/forms/switch/switch.css +281 -281
  385. package/src/forms/switch/switch.stories.tsx +97 -97
  386. package/src/forms/switch/switch.tsx +35 -35
  387. package/src/forms/text-input/text-input.css +229 -229
  388. package/src/forms/text-input/text-input.stories.tsx +220 -220
  389. package/src/forms/text-input/text-input.tsx +115 -115
  390. package/src/forms/textarea/textarea.css +103 -103
  391. package/src/forms/textarea/textarea.stories.tsx +137 -137
  392. package/src/forms/textarea/textarea.tsx +33 -33
  393. package/src/forms/typeahead/controller.ts +59 -59
  394. package/src/forms/typeahead/machine.ts +253 -253
  395. package/src/forms/typeahead/typeahead.stories.tsx +113 -113
  396. package/src/forms/typeahead/typeahead.tsx +239 -239
  397. package/src/hooks/auto-scroll-machine.ts +261 -261
  398. package/src/hooks/create-auto-scroll.tsx +196 -196
  399. package/src/hooks/index.ts +5 -5
  400. package/src/hooks/list-machine.ts +359 -359
  401. package/src/hooks/spin-phase.ts +116 -116
  402. package/src/hooks/use-filtered-list.tsx +132 -132
  403. package/src/i18n/am.ts +384 -384
  404. package/src/i18n/ar.ts +547 -547
  405. package/src/i18n/az.ts +386 -386
  406. package/src/i18n/bg.ts +386 -386
  407. package/src/i18n/bn.ts +393 -393
  408. package/src/i18n/br.ts +444 -444
  409. package/src/i18n/bs.ts +445 -445
  410. package/src/i18n/ca.ts +423 -423
  411. package/src/i18n/cs.ts +457 -457
  412. package/src/i18n/da.ts +407 -407
  413. package/src/i18n/de.ts +414 -414
  414. package/src/i18n/dv.ts +395 -395
  415. package/src/i18n/dz.ts +393 -393
  416. package/src/i18n/el.ts +388 -388
  417. package/src/i18n/en.ts +433 -433
  418. package/src/i18n/es.ts +443 -443
  419. package/src/i18n/et.ts +386 -386
  420. package/src/i18n/fa.ts +388 -388
  421. package/src/i18n/fi.ts +388 -388
  422. package/src/i18n/fo.ts +388 -388
  423. package/src/i18n/fr.ts +447 -447
  424. package/src/i18n/he.ts +422 -422
  425. package/src/i18n/hi.ts +392 -392
  426. package/src/i18n/hr.ts +422 -422
  427. package/src/i18n/hu.ts +388 -388
  428. package/src/i18n/hy.ts +389 -389
  429. package/src/i18n/id.ts +411 -411
  430. package/src/i18n/is.ts +388 -388
  431. package/src/i18n/it.ts +425 -425
  432. package/src/i18n/ja.ts +406 -406
  433. package/src/i18n/ka.ts +388 -388
  434. package/src/i18n/km.ts +389 -389
  435. package/src/i18n/ko.ts +408 -408
  436. package/src/i18n/lo.ts +387 -387
  437. package/src/i18n/lt.ts +457 -457
  438. package/src/i18n/lv.ts +421 -421
  439. package/src/i18n/mk.ts +387 -387
  440. package/src/i18n/mn.ts +386 -386
  441. package/src/i18n/ms.ts +389 -389
  442. package/src/i18n/my.ts +389 -389
  443. package/src/i18n/ne.ts +393 -393
  444. package/src/i18n/nl.ts +388 -388
  445. package/src/i18n/no.ts +413 -413
  446. package/src/i18n/pa.ts +394 -394
  447. package/src/i18n/pl.ts +476 -476
  448. package/src/i18n/ro.ts +423 -423
  449. package/src/i18n/ru.ts +475 -475
  450. package/src/i18n/si.ts +390 -390
  451. package/src/i18n/sk.ts +457 -457
  452. package/src/i18n/sl.ts +457 -457
  453. package/src/i18n/sq.ts +387 -387
  454. package/src/i18n/sr.ts +422 -422
  455. package/src/i18n/sv.ts +388 -388
  456. package/src/i18n/tg.ts +390 -390
  457. package/src/i18n/th.ts +407 -407
  458. package/src/i18n/tk.ts +386 -386
  459. package/src/i18n/tr.ts +412 -412
  460. package/src/i18n/uk.ts +480 -480
  461. package/src/i18n/ur.ts +394 -394
  462. package/src/i18n/uz.ts +390 -390
  463. package/src/i18n/vi.ts +387 -387
  464. package/src/i18n/zh.ts +408 -408
  465. package/src/i18n/zht.ts +408 -408
  466. package/src/icons/catalog.ts +638 -638
  467. package/src/icons/icon/icon.css +3 -3
  468. package/src/icons/icon/icon.stories.tsx +131 -131
  469. package/src/icons/icon/icon.tsx +106 -106
  470. package/src/icons/registry.ts +217 -217
  471. package/src/layout/divider/divider.css +11 -11
  472. package/src/layout/divider/divider.stories.tsx +38 -38
  473. package/src/layout/divider/divider.tsx +21 -21
  474. package/src/motion/README.md +113 -113
  475. package/src/motion/index.ts +13 -13
  476. package/src/motion/loop.ts +139 -139
  477. package/src/motion/reduced.ts +66 -66
  478. package/src/motion/slider.ts +45 -45
  479. package/src/motion/solid.ts +309 -309
  480. package/src/motion/spring.ts +125 -125
  481. package/src/motion/velocity.ts +46 -46
  482. package/src/motion/waapi.ts +89 -89
  483. package/src/motion-tuning-features.ts +161 -161
  484. package/src/motion-tuning-fields.ts +42 -42
  485. package/src/motion-tuning.ts +323 -323
  486. package/src/navigation/menu/machine.ts +109 -109
  487. package/src/navigation/menu/menu.css +313 -313
  488. package/src/navigation/menu/menu.stories.tsx +328 -328
  489. package/src/navigation/menu/menu.tsx +600 -600
  490. package/src/navigation/menu/submenu-machine.ts +67 -67
  491. package/src/navigation/segmented-control/machine.ts +72 -72
  492. package/src/navigation/segmented-control/segmented-control.css +113 -113
  493. package/src/navigation/segmented-control/segmented-control.stories.tsx +115 -115
  494. package/src/navigation/segmented-control/segmented-control.tsx +396 -396
  495. package/src/navigation/tab-state-indicator.stories.tsx +24 -24
  496. package/src/navigation/tab-state-indicator.tsx +38 -38
  497. package/src/navigation/tabs/tabs-current.css +244 -244
  498. package/src/navigation/tabs/tabs.css +676 -676
  499. package/src/navigation/tabs/tabs.stories.tsx +193 -193
  500. package/src/navigation/tabs/tabs.tsx +212 -212
  501. package/src/overlays/dialog/dialog.css +194 -194
  502. package/src/overlays/dialog/dialog.stories.tsx +365 -365
  503. package/src/overlays/dialog/dialog.tsx +192 -192
  504. package/src/overlays/mcp-sign-in/machine.ts +343 -343
  505. package/src/overlays/mcp-sign-in/mcp-sign-in.ts +159 -159
  506. package/src/overlays/tooltip/machine.ts +312 -312
  507. package/src/overlays/tooltip/tooltip.css +102 -102
  508. package/src/overlays/tooltip/tooltip.stories.tsx +155 -155
  509. package/src/overlays/tooltip/tooltip.tsx +290 -290
  510. package/src/storybook/fixtures.ts +51 -51
  511. package/src/storybook/scaffold.tsx +65 -65
  512. package/src/styles/animations.css +13 -13
  513. package/src/styles/base.css +441 -441
  514. package/src/styles/blue-tokens.stories.tsx +215 -215
  515. package/src/styles/colors.css +772 -772
  516. package/src/styles/file-tree.css +285 -285
  517. package/src/styles/index.css +42 -42
  518. package/src/styles/scrollbar.css +79 -79
  519. package/src/styles/tailwind/colors.css +288 -288
  520. package/src/styles/tailwind/index.css +113 -113
  521. package/src/styles/tailwind/utilities.css +17 -17
  522. package/src/styles/theme.css +640 -640
  523. package/src/styles/tokens/colors.css +172 -172
  524. package/src/styles/tokens/index.css +2 -2
  525. package/src/styles/tokens/theme.css +522 -522
  526. package/src/styles/utilities.css +93 -93
  527. package/src/theme/color.ts +290 -290
  528. package/src/theme/context.tsx +361 -361
  529. package/src/theme/desktop-theme.schema.json +168 -168
  530. package/src/theme/index.ts +35 -35
  531. package/src/theme/machine.ts +508 -508
  532. package/src/theme/resolve.ts +561 -561
  533. package/src/theme/themes/amoled.json +49 -49
  534. package/src/theme/themes/aura.json +51 -51
  535. package/src/theme/themes/ayu.json +51 -51
  536. package/src/theme/themes/carbonfox.json +53 -53
  537. package/src/theme/themes/catppuccin-frappe.json +65 -65
  538. package/src/theme/themes/catppuccin-macchiato.json +65 -65
  539. package/src/theme/themes/catppuccin.json +45 -45
  540. package/src/theme/themes/cobalt2.json +87 -87
  541. package/src/theme/themes/cursor.json +91 -91
  542. package/src/theme/themes/dracula.json +49 -49
  543. package/src/theme/themes/everforest.json +89 -89
  544. package/src/theme/themes/flexoki.json +86 -86
  545. package/src/theme/themes/github.json +85 -85
  546. package/src/theme/themes/gruvbox.json +45 -45
  547. package/src/theme/themes/kanagawa.json +89 -89
  548. package/src/theme/themes/lucent-orng.json +87 -87
  549. package/src/theme/themes/material.json +87 -87
  550. package/src/theme/themes/matrix.json +113 -113
  551. package/src/theme/themes/mercury.json +86 -86
  552. package/src/theme/themes/monokai.json +49 -49
  553. package/src/theme/themes/nightowl.json +46 -46
  554. package/src/theme/themes/nord.json +46 -46
  555. package/src/theme/themes/oc-2.json +509 -509
  556. package/src/theme/themes/one-dark.json +89 -89
  557. package/src/theme/themes/onedarkpro.json +45 -45
  558. package/src/theme/themes/orng.json +87 -87
  559. package/src/theme/themes/osaka-jade.json +88 -88
  560. package/src/theme/themes/palenight.json +85 -85
  561. package/src/theme/themes/rosepine.json +85 -85
  562. package/src/theme/themes/shadesofpurple.json +51 -51
  563. package/src/theme/themes/solarized.json +49 -49
  564. package/src/theme/themes/synthwave84.json +87 -87
  565. package/src/theme/themes/tokyonight.json +47 -47
  566. package/src/theme/themes/vercel.json +90 -90
  567. package/src/theme/themes/vesper.json +51 -51
  568. package/src/theme/themes/zenburn.json +87 -87
  569. package/src/theme/types.ts +75 -75
  570. package/src/theme/v2/avatar.ts +48 -48
  571. package/src/theme/v2/default-primitives.ts +114 -114
  572. package/src/theme/v2/foreground.ts +69 -69
  573. package/src/theme/v2/mapping.ts +180 -180
  574. package/src/theme/v2/resolve.ts +163 -163
  575. package/src/typography/slash/slash.css +14 -14
  576. package/src/typography/slash/slash.stories.tsx +26 -26
  577. package/src/typography/slash/slash.tsx +16 -16
  578. package/src/typography/text-shimmer/machine.ts +90 -90
  579. package/src/typography/text-shimmer/text-shimmer.css +152 -152
  580. package/src/typography/text-shimmer/text-shimmer.stories.tsx +64 -64
  581. package/src/typography/text-shimmer/text-shimmer.tsx +81 -81
  582. package/src/typography/wordmark/wordmark.stories.tsx +19 -19
  583. package/src/typography/wordmark/wordmark.tsx +73 -73
  584. package/test/solid-jsx.ts +20 -20
  585. package/tsconfig.build.json +14 -14
  586. package/tsconfig.json +23 -23
  587. package/vite.config.ts +61 -61
  588. package/src/components/animated-number-machine.test.ts +0 -140
  589. package/src/components/file-icon-machine.test.ts +0 -52
  590. package/src/components/image-flight-machine.test.ts +0 -184
  591. package/src/components/image-flight.test.ts +0 -173
  592. package/src/components/image-zoom-machine.test.ts +0 -154
  593. package/src/components/image-zoom.test.ts +0 -96
  594. package/src/components/popover-machine.test.ts +0 -150
  595. package/src/components/resize-handle-machine.test.ts +0 -164
  596. package/src/components/scroll-view-machine.test.ts +0 -141
  597. package/src/components/scroll-view.test.ts +0 -114
  598. package/src/components/spinner-radar.test.ts +0 -61
  599. package/src/components/text-field-machine.test.ts +0 -99
  600. package/src/components/text-reveal-machine.test.ts +0 -157
  601. package/src/components/typewriter-machine.test.ts +0 -177
  602. package/src/context/dialog-machine.test.ts +0 -295
  603. package/src/context/i18n.test.ts +0 -89
  604. package/src/context/marked-base.test.ts +0 -75
  605. package/src/context/marked-parser.test.ts +0 -167
  606. package/src/context/marked-regression.test.ts +0 -12
  607. package/src/data-display/line-comment/machine.test.ts +0 -385
  608. package/src/data-display/project-avatar/animation-machine.test.ts +0 -134
  609. package/src/data-display/project-avatar/generated.test.ts +0 -50
  610. package/src/data-display/project-avatar/procedural.test.ts +0 -16
  611. package/src/data-display/project-avatar/project-avatar.test.ts +0 -21
  612. package/src/feedback/toast/description.test.ts +0 -20
  613. package/src/feedback/toast/machine.test.ts +0 -106
  614. package/src/forms/search-list/navigation.test.ts +0 -40
  615. package/src/forms/select/machine.test.ts +0 -105
  616. package/src/forms/typeahead/machine.test.ts +0 -143
  617. package/src/hooks/auto-scroll-machine.test.ts +0 -212
  618. package/src/hooks/list-machine.test.ts +0 -263
  619. package/src/hooks/spin-phase.test.ts +0 -32
  620. package/src/hooks/use-filtered-list.test.ts +0 -41
  621. package/src/motion/core.test.ts +0 -328
  622. package/src/motion-tuning-features.test.ts +0 -129
  623. package/src/motion-tuning.test.ts +0 -68
  624. package/src/navigation/menu/machine.test.ts +0 -85
  625. package/src/navigation/menu/submenu-machine.test.ts +0 -71
  626. package/src/navigation/segmented-control/segmented-control.test.ts +0 -123
  627. package/src/overlays/mcp-sign-in/machine.test.ts +0 -215
  628. package/src/overlays/tooltip/machine.test.ts +0 -214
  629. package/src/theme/machine.test.ts +0 -498
  630. package/src/theme/v2/resolve.test.ts +0 -120
  631. package/src/typography/text-shimmer/machine.test.ts +0 -117
@@ -1,463 +1,463 @@
1
- import {
2
- createContext,
3
- createEffect,
4
- createMemo,
5
- createSelector,
6
- For,
7
- type JSX,
8
- on,
9
- onCleanup,
10
- onMount,
11
- Show,
12
- useContext,
13
- } from "solid-js"
14
- import { createResizeObserver } from "@solid-primitives/resize-observer"
15
- import { Icon } from "@zyro-sec/ui/icon"
16
- import { MenuScroll } from "../../components/menu-scroll"
17
- import { TextInput } from "../text-input/text-input"
18
- import { createTypeahead } from "../typeahead/controller"
19
- import { searchListMove, searchListTarget } from "./navigation"
20
- import "./search-list.css"
21
-
22
- /** Attributes for a row's element: spread them, then override a handler to change what the pointer does. */
23
- export type SearchListRow = {
24
- id: string
25
- role: "option"
26
- "aria-selected": boolean
27
- "data-slot": "search-list-row"
28
- "data-active": "" | undefined
29
- onMouseMove: (event: MouseEvent) => void
30
- onMouseDown: (event: MouseEvent) => void
31
- onClick: () => void
32
- }
33
-
34
- /** Attributes for the input of a field passed as `field`: spread them onto it. */
35
- export type SearchListField = {
36
- role: "combobox"
37
- "aria-expanded": boolean
38
- "aria-autocomplete": "list"
39
- "aria-controls": string | undefined
40
- "aria-activedescendant": string | undefined
41
- onInput: (event: InputEvent & { currentTarget: HTMLInputElement }) => void
42
- onKeyDown: (event: KeyboardEvent) => void
43
- }
44
-
45
- export type SearchListHandle<T> = {
46
- active: () => T | undefined
47
- /** `pointer` marks a highlight the pointer took through a row handler of the page's own, as the row's own does. */
48
- setActive: (key: string | undefined, input?: "pointer") => void
49
- }
50
-
51
- const QueryContext = createContext<() => string>(() => "")
52
-
53
- /**
54
- * A search field over sectioned results. Rows that share a `section` key list together under one header, which sticks
55
- * while its rows scroll beneath it until the next header pushes it away. The first row is active until the user picks
56
- * another: ↑/↓ wrap, ⌘ or ⌥ with ↑/↓ jump between sections, Home/End go to the ends, Enter selects and Escape closes.
57
- * A page can keep its own field through `field` and float the results beneath it with `popover`.
58
- */
59
- export function SearchList<T>(props: {
60
- query: string
61
- onQuery: (query: string) => void
62
- placeholder: string
63
- /** The results' accessible name; the placeholder by default. */
64
- label?: string
65
- /** Controls after the field, such as icon buttons. */
66
- trailing?: JSX.Element
67
- /** A search field of the page's own in place of the built-in one. */
68
- field?: (field: SearchListField) => JSX.Element
69
- /** Whether the results show. Closed, only the field remains and the list leaves keys to the page. On by default. */
70
- open?: boolean
71
- /** Float the results beneath the field on a raised surface, over what follows it. */
72
- popover?: boolean
73
- items: T[]
74
- key: (item: T) => string
75
- section?: (item: T) => string
76
- /** Rows that show the same thing in two sections. ↑/↓ step past a copy, so the highlight always lands somewhere new. */
77
- same?: (a: T, b: T) => boolean
78
- /** A section's header, from its first row. */
79
- header?: (item: T) => JSX.Element
80
- /** Shown in place of the rows when there are none. */
81
- empty: JSX.Element
82
- /** A note beneath the rows, such as a hint that more results are hidden. */
83
- footer?: JSX.Element
84
- /** Whether to draw the top edge fade beneath sticky headers. On by default. */
85
- topFade?: boolean
86
- /** Where the results start scrolled each time they mount, such as a position kept from an earlier visit. */
87
- scrollTop?: number
88
- onScroll?: (scrollTop: number) => void
89
- onSelect: (item: T) => void
90
- onActive?: (item: T | undefined) => void
91
- /** Runs before the list's own keys; call `preventDefault` to claim one. */
92
- onKeyDown?: (event: KeyboardEvent, active: T | undefined) => void
93
- onClose?: () => void
94
- ref?: (handle: SearchListHandle<T>) => void
95
- class?: string
96
- /** A row. `item` stays current while results with the same key replace it, so the row keeps its element. */
97
- children: (item: () => T, row: SearchListRow) => JSX.Element
98
- }) {
99
- let viewport: HTMLDivElement | undefined
100
- let results: HTMLDivElement | undefined
101
- let fade: HTMLDivElement | undefined
102
-
103
- const sectionOf = (item: T) => props.section?.(item) ?? ""
104
- const open = () => props.open ?? true
105
- const topFade = () => props.topFade ?? true
106
-
107
- // Sections in the order their first row arrives; rows then list section by section, which is also the arrow order.
108
- const groups = createMemo(() => {
109
- const all = new Map<string, T[]>()
110
-
111
- props.items.forEach((item) => {
112
- const list = all.get(sectionOf(item))
113
-
114
- if (list) list.push(item)
115
- else all.set(sectionOf(item), [item])
116
- })
117
-
118
- return all
119
- })
120
-
121
- const rows = createMemo(() => [...groups().values()].flat())
122
- const byKey = createMemo(() => new Map(rows().map((item) => [props.key(item), item] as const)))
123
- const sectionKeys = createMemo<string[]>((previous) => stable(previous, [...groups().keys()]))
124
-
125
- const typeahead = createTypeahead<T>({
126
- items: rows,
127
- key: (item) => props.key(item),
128
- onSelect: (item) => props.onSelect(item),
129
- onClose: props.onClose && (() => props.onClose?.()),
130
- })
131
-
132
- const activeKey = createMemo(() => {
133
- const item = typeahead.activeItem()
134
-
135
- return item === undefined ? undefined : props.key(item)
136
- })
137
-
138
- // Moving the highlight updates the two rows it leaves and lands on, not every row.
139
- const isActive = createSelector(activeKey)
140
-
141
- // The first row shows from the top, so its header is never hidden; any other row scrolls in only as far as needed.
142
- const reveal = () => {
143
- const item = typeahead.activeItem()
144
-
145
- if (!viewport) return
146
-
147
- if (item === undefined || item === rows()[0]) return viewport.scrollTo({ top: 0 })
148
- document.getElementById(typeahead.optionID(item))?.scrollIntoView({ block: "nearest" })
149
- }
150
-
151
- // Rows fade out where they run under the top header or past the bottom edge. Each fade reaches full strength once
152
- // 15 px is hidden, so it eases in with the scroll. The top fade follows the header over the topmost section and
153
- // measures what that section has hidden, so a header that pushes the last one away starts clear again. Sections and
154
- // scroll extent are measured when the list lays out, so scrolling only does arithmetic.
155
- let sections: { top: number; bottom: number; header: number }[] = []
156
- let maxScroll = 0
157
- const lastFade = { offset: "", top: "", bottom: "" }
158
-
159
- const edges = (scroll: number) => {
160
- if (!viewport) return
161
- const strength = (hidden: number) => String(Math.min(1, Math.max(0, hidden / 15)))
162
-
163
- if (topFade() && fade) {
164
- const current = sections.findLast((section) => section.top - scroll < section.header)
165
-
166
- // A stuck header sits at the top until its section's end pushes it up.
167
- const offset = current?.header
168
- ? Math.min(Math.max(current.top - scroll, 0) + current.header, current.bottom - scroll)
169
- : 0
170
-
171
- const nextOffset = `${Math.max(0, offset)}px`
172
- const nextTop = strength(current ? scroll - current.top : 0)
173
-
174
- if (lastFade.offset !== nextOffset) {
175
- lastFade.offset = nextOffset
176
- fade.style.setProperty("--search-list-fade-offset", nextOffset)
177
- }
178
-
179
- if (lastFade.top !== nextTop) {
180
- lastFade.top = nextTop
181
- fade.style.setProperty("--search-list-fade-top", nextTop)
182
- }
183
- }
184
-
185
- const nextBottom = strength(maxScroll - scroll)
186
-
187
- if (lastFade.bottom !== nextBottom) {
188
- lastFade.bottom = nextBottom
189
- viewport.style.setProperty("--search-list-fade-bottom", nextBottom)
190
- }
191
- }
192
-
193
- const measure = () => {
194
- if (!viewport) return
195
- const scroll = viewport.scrollTop
196
- maxScroll = Math.max(0, viewport.scrollHeight - viewport.clientHeight)
197
-
198
- if (topFade()) {
199
- const origin = viewport.getBoundingClientRect().top - scroll
200
-
201
- sections = [...viewport.querySelectorAll<HTMLElement>('[data-slot="search-list-section"]')].map((section) => {
202
- const rect = section.getBoundingClientRect()
203
-
204
- // A sticky header stays inside its section's content box, so the section's bottom padding is out of its reach.
205
- return {
206
- top: rect.top - origin,
207
- bottom: rect.bottom - origin - parseFloat(getComputedStyle(section).paddingBottom),
208
- header: section.querySelector<HTMLElement>('[data-slot="search-list-header"]')?.offsetHeight ?? 0,
209
- }
210
- })
211
- }
212
-
213
- edges(scroll)
214
- }
215
-
216
- createResizeObserver(() => [viewport, results], measure)
217
- createEffect(
218
- on(
219
- rows,
220
- () => {
221
- if (topFade()) measure()
222
- },
223
- { defer: true },
224
- ),
225
- )
226
-
227
- createEffect(() => props.onActive?.(typeahead.activeItem()))
228
-
229
- // A new query starts from the top. Results that arrive later for the same query bring a chosen row back into view,
230
- // but leave the list where the wheel put it while the first row is still the default or the pointer took the row.
231
- let revealed = props.query
232
- let pointed: string | undefined
233
-
234
- createEffect(
235
- on(
236
- rows,
237
- (all) => {
238
- const fresh = props.query !== revealed
239
- revealed = props.query
240
-
241
- if (!fresh && (typeahead.activeItem() === all[0] || activeKey() === pointed)) return
242
- const frame = requestAnimationFrame(reveal)
243
- onCleanup(() => cancelAnimationFrame(frame))
244
- },
245
- { defer: true },
246
- ),
247
- )
248
-
249
- const choose = (key: string | undefined, input?: "pointer") => {
250
- pointed = input === "pointer" ? key : undefined
251
- typeahead.setActive(key)
252
- }
253
-
254
- props.ref?.({ active: typeahead.activeItem, setActive: choose })
255
-
256
- const onKeyDown = (event: KeyboardEvent) => {
257
- if (event.isComposing) return
258
- props.onKeyDown?.(event, typeahead.activeItem())
259
-
260
- if (event.defaultPrevented || !open()) return
261
- const move = searchListMove(event)
262
-
263
- if (!move) return typeahead.onKeyDown(event)
264
- event.preventDefault()
265
- event.stopPropagation()
266
- const all = rows()
267
- const sections = all.map(sectionOf)
268
- const active = typeahead.activeItem()
269
- const from = active === undefined ? -1 : all.indexOf(active)
270
-
271
- const step = (index: number): number => {
272
- const next = searchListTarget(sections, index, move)
273
- const copy = (move === "next" || move === "previous") && active !== undefined && next !== from
274
-
275
- return copy && props.same?.(all[next]!, active) ? step(next) : next
276
- }
277
-
278
- const target = all[step(from)]
279
-
280
- if (target === undefined) return
281
- choose(props.key(target))
282
- reveal()
283
- }
284
-
285
- onMount(() => {
286
- if (viewport && props.scrollTop) viewport.scrollTop = props.scrollTop
287
- })
288
-
289
- const field: SearchListField = {
290
- role: "combobox",
291
- get "aria-expanded"() {
292
- return open()
293
- },
294
- "aria-autocomplete": "list",
295
- get "aria-controls"() {
296
- return open() ? typeahead.listID : undefined
297
- },
298
- get "aria-activedescendant"() {
299
- return open() ? typeahead.activeID() : undefined
300
- },
301
- onInput: (event) => {
302
- // A new query starts again from its first row.
303
- choose(undefined)
304
- props.onQuery(event.currentTarget.value)
305
- },
306
- onKeyDown,
307
- }
308
-
309
- const row = (key: string, item: () => T): SearchListRow => ({
310
- get id() {
311
- return typeahead.optionID(item())
312
- },
313
- role: "option",
314
- get "aria-selected"() {
315
- return isActive(key)
316
- },
317
- "data-slot": "search-list-row",
318
- get "data-active"() {
319
- return isActive(key) ? ("" as const) : undefined
320
- },
321
- onMouseMove: (event) => {
322
- // A static cursor must not take the active row while the keyboard scrolls rows beneath it.
323
- if (event.movementX === 0 && event.movementY === 0) return
324
- pointed = key
325
- typeahead.setActive(key)
326
- },
327
- // Focus stays in the field.
328
- onMouseDown: (event) => event.preventDefault(),
329
- onClick: () => props.onSelect(item()),
330
- })
331
-
332
- // Every highlighted row reads this, so the query is trimmed and lower-cased once per keystroke, not once per row.
333
- const needle = createMemo(() => props.query.trim().toLowerCase())
334
-
335
- return (
336
- <QueryContext.Provider value={needle}>
337
- <div data-component="search-list" data-popover={props.popover ? "" : undefined} class={props.class}>
338
- <Show
339
- when={props.field}
340
- fallback={
341
- <div data-slot="search-list-search">
342
- <TextInput
343
- {...field}
344
- value={props.query}
345
- autofocus
346
- autocomplete="off"
347
- autocorrect="off"
348
- autocapitalize="off"
349
- spellcheck={false}
350
- appearance="large"
351
- placeholder={props.placeholder}
352
- aria-label={props.placeholder}
353
- leadingIcon={<Icon name="magnifying-glass" />}
354
- trailing={props.trailing}
355
- />
356
- </div>
357
- }
358
- >
359
- {(custom) => custom()(field)}
360
- </Show>
361
- <div data-slot="search-list-body" hidden={!open()}>
362
- <MenuScroll
363
- data-slot="search-list-scroll"
364
- viewportRef={(element) => (viewport = element)}
365
- onScroll={(event) => {
366
- const top = event.currentTarget.scrollTop
367
- // Callers read clean layout before edge-fade properties mutate the viewport.
368
- props.onScroll?.(top)
369
- edges(top)
370
- }}
371
- >
372
- <Show when={topFade()}>
373
- <div ref={fade} data-slot="search-list-fade" aria-hidden="true" />
374
- </Show>
375
- <div
376
- ref={results}
377
- id={typeahead.listID}
378
- data-slot="search-list-results"
379
- role="listbox"
380
- hidden={rows().length === 0}
381
- aria-label={props.label ?? props.placeholder}
382
- >
383
- <For each={sectionKeys()}>
384
- {(section) => {
385
- const keys = createMemo<string[]>((previous) =>
386
- stable(previous, (groups().get(section) ?? []).map(props.key)),
387
- )
388
-
389
- const first = () => byKey().get(keys()[0] ?? "")
390
-
391
- const header = createMemo(() =>
392
- props.header && first() !== undefined ? props.header(first()!) : undefined,
393
- )
394
-
395
- const id = `${typeahead.listID}-section-${encodeURIComponent(section)}`
396
-
397
- return (
398
- <div data-slot="search-list-section" role="group" aria-labelledby={header() ? id : undefined}>
399
- <Show when={header()}>
400
- {(content) => (
401
- <div id={id} data-slot="search-list-header">
402
- {content()}
403
- </div>
404
- )}
405
- </Show>
406
- <For each={keys()}>
407
- {(key) => {
408
- // A row that is leaving keeps its last item until it is removed.
409
- const item = createMemo<T>((previous) => byKey().get(key) ?? previous, byKey().get(key)!)
410
-
411
- return props.children(item, row(key, item))
412
- }}
413
- </For>
414
- </div>
415
- )
416
- }}
417
- </For>
418
- </div>
419
- <Show when={rows().length === 0}>
420
- <div data-slot="search-list-empty">{props.empty}</div>
421
- </Show>
422
- </MenuScroll>
423
- <Show when={props.footer}>
424
- <div data-slot="search-list-footer">{props.footer}</div>
425
- </Show>
426
- </div>
427
- </div>
428
- </QueryContext.Provider>
429
- )
430
- }
431
-
432
- /** Text with its first match for the list's query marked. One mark per row keeps short queries from speckling the list. */
433
- export function SearchHighlight(props: { text: string }) {
434
- const needle = useContext(QueryContext)
435
- const haystack = createMemo(() => props.text.toLowerCase())
436
-
437
- const match = createMemo(() => {
438
- const at = needle() ? haystack().indexOf(needle()) : -1
439
-
440
- // Lower-casing a few scripts changes the length, and then offsets no longer line up with the text.
441
- if (at === -1 || haystack().length !== props.text.length) return
442
-
443
- return { at, end: at + needle().length }
444
- })
445
-
446
- return (
447
- <Show when={match()} fallback={props.text}>
448
- {(range) => (
449
- <>
450
- {props.text.slice(0, range().at)}
451
- <mark data-slot="search-list-match">{props.text.slice(range().at, range().end)}</mark>
452
- {props.text.slice(range().end)}
453
- </>
454
- )}
455
- </Show>
456
- )
457
- }
458
-
459
- function stable(previous: string[] | undefined, next: string[]) {
460
- return previous && previous.length === next.length && previous.every((value, index) => value === next[index])
461
- ? previous
462
- : next
463
- }
1
+ import {
2
+ createContext,
3
+ createEffect,
4
+ createMemo,
5
+ createSelector,
6
+ For,
7
+ type JSX,
8
+ on,
9
+ onCleanup,
10
+ onMount,
11
+ Show,
12
+ useContext,
13
+ } from "solid-js"
14
+ import { createResizeObserver } from "@solid-primitives/resize-observer"
15
+ import { Icon } from "@zyro-sec/ui/icon"
16
+ import { MenuScroll } from "../../components/menu-scroll"
17
+ import { TextInput } from "../text-input/text-input"
18
+ import { createTypeahead } from "../typeahead/controller"
19
+ import { searchListMove, searchListTarget } from "./navigation"
20
+ import "./search-list.css"
21
+
22
+ /** Attributes for a row's element: spread them, then override a handler to change what the pointer does. */
23
+ export type SearchListRow = {
24
+ id: string
25
+ role: "option"
26
+ "aria-selected": boolean
27
+ "data-slot": "search-list-row"
28
+ "data-active": "" | undefined
29
+ onMouseMove: (event: MouseEvent) => void
30
+ onMouseDown: (event: MouseEvent) => void
31
+ onClick: () => void
32
+ }
33
+
34
+ /** Attributes for the input of a field passed as `field`: spread them onto it. */
35
+ export type SearchListField = {
36
+ role: "combobox"
37
+ "aria-expanded": boolean
38
+ "aria-autocomplete": "list"
39
+ "aria-controls": string | undefined
40
+ "aria-activedescendant": string | undefined
41
+ onInput: (event: InputEvent & { currentTarget: HTMLInputElement }) => void
42
+ onKeyDown: (event: KeyboardEvent) => void
43
+ }
44
+
45
+ export type SearchListHandle<T> = {
46
+ active: () => T | undefined
47
+ /** `pointer` marks a highlight the pointer took through a row handler of the page's own, as the row's own does. */
48
+ setActive: (key: string | undefined, input?: "pointer") => void
49
+ }
50
+
51
+ const QueryContext = createContext<() => string>(() => "")
52
+
53
+ /**
54
+ * A search field over sectioned results. Rows that share a `section` key list together under one header, which sticks
55
+ * while its rows scroll beneath it until the next header pushes it away. The first row is active until the user picks
56
+ * another: ↑/↓ wrap, ⌘ or ⌥ with ↑/↓ jump between sections, Home/End go to the ends, Enter selects and Escape closes.
57
+ * A page can keep its own field through `field` and float the results beneath it with `popover`.
58
+ */
59
+ export function SearchList<T>(props: {
60
+ query: string
61
+ onQuery: (query: string) => void
62
+ placeholder: string
63
+ /** The results' accessible name; the placeholder by default. */
64
+ label?: string
65
+ /** Controls after the field, such as icon buttons. */
66
+ trailing?: JSX.Element
67
+ /** A search field of the page's own in place of the built-in one. */
68
+ field?: (field: SearchListField) => JSX.Element
69
+ /** Whether the results show. Closed, only the field remains and the list leaves keys to the page. On by default. */
70
+ open?: boolean
71
+ /** Float the results beneath the field on a raised surface, over what follows it. */
72
+ popover?: boolean
73
+ items: T[]
74
+ key: (item: T) => string
75
+ section?: (item: T) => string
76
+ /** Rows that show the same thing in two sections. ↑/↓ step past a copy, so the highlight always lands somewhere new. */
77
+ same?: (a: T, b: T) => boolean
78
+ /** A section's header, from its first row. */
79
+ header?: (item: T) => JSX.Element
80
+ /** Shown in place of the rows when there are none. */
81
+ empty: JSX.Element
82
+ /** A note beneath the rows, such as a hint that more results are hidden. */
83
+ footer?: JSX.Element
84
+ /** Whether to draw the top edge fade beneath sticky headers. On by default. */
85
+ topFade?: boolean
86
+ /** Where the results start scrolled each time they mount, such as a position kept from an earlier visit. */
87
+ scrollTop?: number
88
+ onScroll?: (scrollTop: number) => void
89
+ onSelect: (item: T) => void
90
+ onActive?: (item: T | undefined) => void
91
+ /** Runs before the list's own keys; call `preventDefault` to claim one. */
92
+ onKeyDown?: (event: KeyboardEvent, active: T | undefined) => void
93
+ onClose?: () => void
94
+ ref?: (handle: SearchListHandle<T>) => void
95
+ class?: string
96
+ /** A row. `item` stays current while results with the same key replace it, so the row keeps its element. */
97
+ children: (item: () => T, row: SearchListRow) => JSX.Element
98
+ }) {
99
+ let viewport: HTMLDivElement | undefined
100
+ let results: HTMLDivElement | undefined
101
+ let fade: HTMLDivElement | undefined
102
+
103
+ const sectionOf = (item: T) => props.section?.(item) ?? ""
104
+ const open = () => props.open ?? true
105
+ const topFade = () => props.topFade ?? true
106
+
107
+ // Sections in the order their first row arrives; rows then list section by section, which is also the arrow order.
108
+ const groups = createMemo(() => {
109
+ const all = new Map<string, T[]>()
110
+
111
+ props.items.forEach((item) => {
112
+ const list = all.get(sectionOf(item))
113
+
114
+ if (list) list.push(item)
115
+ else all.set(sectionOf(item), [item])
116
+ })
117
+
118
+ return all
119
+ })
120
+
121
+ const rows = createMemo(() => [...groups().values()].flat())
122
+ const byKey = createMemo(() => new Map(rows().map((item) => [props.key(item), item] as const)))
123
+ const sectionKeys = createMemo<string[]>((previous) => stable(previous, [...groups().keys()]))
124
+
125
+ const typeahead = createTypeahead<T>({
126
+ items: rows,
127
+ key: (item) => props.key(item),
128
+ onSelect: (item) => props.onSelect(item),
129
+ onClose: props.onClose && (() => props.onClose?.()),
130
+ })
131
+
132
+ const activeKey = createMemo(() => {
133
+ const item = typeahead.activeItem()
134
+
135
+ return item === undefined ? undefined : props.key(item)
136
+ })
137
+
138
+ // Moving the highlight updates the two rows it leaves and lands on, not every row.
139
+ const isActive = createSelector(activeKey)
140
+
141
+ // The first row shows from the top, so its header is never hidden; any other row scrolls in only as far as needed.
142
+ const reveal = () => {
143
+ const item = typeahead.activeItem()
144
+
145
+ if (!viewport) return
146
+
147
+ if (item === undefined || item === rows()[0]) return viewport.scrollTo({ top: 0 })
148
+ document.getElementById(typeahead.optionID(item))?.scrollIntoView({ block: "nearest" })
149
+ }
150
+
151
+ // Rows fade out where they run under the top header or past the bottom edge. Each fade reaches full strength once
152
+ // 15 px is hidden, so it eases in with the scroll. The top fade follows the header over the topmost section and
153
+ // measures what that section has hidden, so a header that pushes the last one away starts clear again. Sections and
154
+ // scroll extent are measured when the list lays out, so scrolling only does arithmetic.
155
+ let sections: { top: number; bottom: number; header: number }[] = []
156
+ let maxScroll = 0
157
+ const lastFade = { offset: "", top: "", bottom: "" }
158
+
159
+ const edges = (scroll: number) => {
160
+ if (!viewport) return
161
+ const strength = (hidden: number) => String(Math.min(1, Math.max(0, hidden / 15)))
162
+
163
+ if (topFade() && fade) {
164
+ const current = sections.findLast((section) => section.top - scroll < section.header)
165
+
166
+ // A stuck header sits at the top until its section's end pushes it up.
167
+ const offset = current?.header
168
+ ? Math.min(Math.max(current.top - scroll, 0) + current.header, current.bottom - scroll)
169
+ : 0
170
+
171
+ const nextOffset = `${Math.max(0, offset)}px`
172
+ const nextTop = strength(current ? scroll - current.top : 0)
173
+
174
+ if (lastFade.offset !== nextOffset) {
175
+ lastFade.offset = nextOffset
176
+ fade.style.setProperty("--search-list-fade-offset", nextOffset)
177
+ }
178
+
179
+ if (lastFade.top !== nextTop) {
180
+ lastFade.top = nextTop
181
+ fade.style.setProperty("--search-list-fade-top", nextTop)
182
+ }
183
+ }
184
+
185
+ const nextBottom = strength(maxScroll - scroll)
186
+
187
+ if (lastFade.bottom !== nextBottom) {
188
+ lastFade.bottom = nextBottom
189
+ viewport.style.setProperty("--search-list-fade-bottom", nextBottom)
190
+ }
191
+ }
192
+
193
+ const measure = () => {
194
+ if (!viewport) return
195
+ const scroll = viewport.scrollTop
196
+ maxScroll = Math.max(0, viewport.scrollHeight - viewport.clientHeight)
197
+
198
+ if (topFade()) {
199
+ const origin = viewport.getBoundingClientRect().top - scroll
200
+
201
+ sections = [...viewport.querySelectorAll<HTMLElement>('[data-slot="search-list-section"]')].map((section) => {
202
+ const rect = section.getBoundingClientRect()
203
+
204
+ // A sticky header stays inside its section's content box, so the section's bottom padding is out of its reach.
205
+ return {
206
+ top: rect.top - origin,
207
+ bottom: rect.bottom - origin - parseFloat(getComputedStyle(section).paddingBottom),
208
+ header: section.querySelector<HTMLElement>('[data-slot="search-list-header"]')?.offsetHeight ?? 0,
209
+ }
210
+ })
211
+ }
212
+
213
+ edges(scroll)
214
+ }
215
+
216
+ createResizeObserver(() => [viewport, results], measure)
217
+ createEffect(
218
+ on(
219
+ rows,
220
+ () => {
221
+ if (topFade()) measure()
222
+ },
223
+ { defer: true },
224
+ ),
225
+ )
226
+
227
+ createEffect(() => props.onActive?.(typeahead.activeItem()))
228
+
229
+ // A new query starts from the top. Results that arrive later for the same query bring a chosen row back into view,
230
+ // but leave the list where the wheel put it while the first row is still the default or the pointer took the row.
231
+ let revealed = props.query
232
+ let pointed: string | undefined
233
+
234
+ createEffect(
235
+ on(
236
+ rows,
237
+ (all) => {
238
+ const fresh = props.query !== revealed
239
+ revealed = props.query
240
+
241
+ if (!fresh && (typeahead.activeItem() === all[0] || activeKey() === pointed)) return
242
+ const frame = requestAnimationFrame(reveal)
243
+ onCleanup(() => cancelAnimationFrame(frame))
244
+ },
245
+ { defer: true },
246
+ ),
247
+ )
248
+
249
+ const choose = (key: string | undefined, input?: "pointer") => {
250
+ pointed = input === "pointer" ? key : undefined
251
+ typeahead.setActive(key)
252
+ }
253
+
254
+ props.ref?.({ active: typeahead.activeItem, setActive: choose })
255
+
256
+ const onKeyDown = (event: KeyboardEvent) => {
257
+ if (event.isComposing) return
258
+ props.onKeyDown?.(event, typeahead.activeItem())
259
+
260
+ if (event.defaultPrevented || !open()) return
261
+ const move = searchListMove(event)
262
+
263
+ if (!move) return typeahead.onKeyDown(event)
264
+ event.preventDefault()
265
+ event.stopPropagation()
266
+ const all = rows()
267
+ const sections = all.map(sectionOf)
268
+ const active = typeahead.activeItem()
269
+ const from = active === undefined ? -1 : all.indexOf(active)
270
+
271
+ const step = (index: number): number => {
272
+ const next = searchListTarget(sections, index, move)
273
+ const copy = (move === "next" || move === "previous") && active !== undefined && next !== from
274
+
275
+ return copy && props.same?.(all[next]!, active) ? step(next) : next
276
+ }
277
+
278
+ const target = all[step(from)]
279
+
280
+ if (target === undefined) return
281
+ choose(props.key(target))
282
+ reveal()
283
+ }
284
+
285
+ onMount(() => {
286
+ if (viewport && props.scrollTop) viewport.scrollTop = props.scrollTop
287
+ })
288
+
289
+ const field: SearchListField = {
290
+ role: "combobox",
291
+ get "aria-expanded"() {
292
+ return open()
293
+ },
294
+ "aria-autocomplete": "list",
295
+ get "aria-controls"() {
296
+ return open() ? typeahead.listID : undefined
297
+ },
298
+ get "aria-activedescendant"() {
299
+ return open() ? typeahead.activeID() : undefined
300
+ },
301
+ onInput: (event) => {
302
+ // A new query starts again from its first row.
303
+ choose(undefined)
304
+ props.onQuery(event.currentTarget.value)
305
+ },
306
+ onKeyDown,
307
+ }
308
+
309
+ const row = (key: string, item: () => T): SearchListRow => ({
310
+ get id() {
311
+ return typeahead.optionID(item())
312
+ },
313
+ role: "option",
314
+ get "aria-selected"() {
315
+ return isActive(key)
316
+ },
317
+ "data-slot": "search-list-row",
318
+ get "data-active"() {
319
+ return isActive(key) ? ("" as const) : undefined
320
+ },
321
+ onMouseMove: (event) => {
322
+ // A static cursor must not take the active row while the keyboard scrolls rows beneath it.
323
+ if (event.movementX === 0 && event.movementY === 0) return
324
+ pointed = key
325
+ typeahead.setActive(key)
326
+ },
327
+ // Focus stays in the field.
328
+ onMouseDown: (event) => event.preventDefault(),
329
+ onClick: () => props.onSelect(item()),
330
+ })
331
+
332
+ // Every highlighted row reads this, so the query is trimmed and lower-cased once per keystroke, not once per row.
333
+ const needle = createMemo(() => props.query.trim().toLowerCase())
334
+
335
+ return (
336
+ <QueryContext.Provider value={needle}>
337
+ <div data-component="search-list" data-popover={props.popover ? "" : undefined} class={props.class}>
338
+ <Show
339
+ when={props.field}
340
+ fallback={
341
+ <div data-slot="search-list-search">
342
+ <TextInput
343
+ {...field}
344
+ value={props.query}
345
+ autofocus
346
+ autocomplete="off"
347
+ autocorrect="off"
348
+ autocapitalize="off"
349
+ spellcheck={false}
350
+ appearance="large"
351
+ placeholder={props.placeholder}
352
+ aria-label={props.placeholder}
353
+ leadingIcon={<Icon name="magnifying-glass" />}
354
+ trailing={props.trailing}
355
+ />
356
+ </div>
357
+ }
358
+ >
359
+ {(custom) => custom()(field)}
360
+ </Show>
361
+ <div data-slot="search-list-body" hidden={!open()}>
362
+ <MenuScroll
363
+ data-slot="search-list-scroll"
364
+ viewportRef={(element) => (viewport = element)}
365
+ onScroll={(event) => {
366
+ const top = event.currentTarget.scrollTop
367
+ // Callers read clean layout before edge-fade properties mutate the viewport.
368
+ props.onScroll?.(top)
369
+ edges(top)
370
+ }}
371
+ >
372
+ <Show when={topFade()}>
373
+ <div ref={fade} data-slot="search-list-fade" aria-hidden="true" />
374
+ </Show>
375
+ <div
376
+ ref={results}
377
+ id={typeahead.listID}
378
+ data-slot="search-list-results"
379
+ role="listbox"
380
+ hidden={rows().length === 0}
381
+ aria-label={props.label ?? props.placeholder}
382
+ >
383
+ <For each={sectionKeys()}>
384
+ {(section) => {
385
+ const keys = createMemo<string[]>((previous) =>
386
+ stable(previous, (groups().get(section) ?? []).map(props.key)),
387
+ )
388
+
389
+ const first = () => byKey().get(keys()[0] ?? "")
390
+
391
+ const header = createMemo(() =>
392
+ props.header && first() !== undefined ? props.header(first()!) : undefined,
393
+ )
394
+
395
+ const id = `${typeahead.listID}-section-${encodeURIComponent(section)}`
396
+
397
+ return (
398
+ <div data-slot="search-list-section" role="group" aria-labelledby={header() ? id : undefined}>
399
+ <Show when={header()}>
400
+ {(content) => (
401
+ <div id={id} data-slot="search-list-header">
402
+ {content()}
403
+ </div>
404
+ )}
405
+ </Show>
406
+ <For each={keys()}>
407
+ {(key) => {
408
+ // A row that is leaving keeps its last item until it is removed.
409
+ const item = createMemo<T>((previous) => byKey().get(key) ?? previous, byKey().get(key)!)
410
+
411
+ return props.children(item, row(key, item))
412
+ }}
413
+ </For>
414
+ </div>
415
+ )
416
+ }}
417
+ </For>
418
+ </div>
419
+ <Show when={rows().length === 0}>
420
+ <div data-slot="search-list-empty">{props.empty}</div>
421
+ </Show>
422
+ </MenuScroll>
423
+ <Show when={props.footer}>
424
+ <div data-slot="search-list-footer">{props.footer}</div>
425
+ </Show>
426
+ </div>
427
+ </div>
428
+ </QueryContext.Provider>
429
+ )
430
+ }
431
+
432
+ /** Text with its first match for the list's query marked. One mark per row keeps short queries from speckling the list. */
433
+ export function SearchHighlight(props: { text: string }) {
434
+ const needle = useContext(QueryContext)
435
+ const haystack = createMemo(() => props.text.toLowerCase())
436
+
437
+ const match = createMemo(() => {
438
+ const at = needle() ? haystack().indexOf(needle()) : -1
439
+
440
+ // Lower-casing a few scripts changes the length, and then offsets no longer line up with the text.
441
+ if (at === -1 || haystack().length !== props.text.length) return
442
+
443
+ return { at, end: at + needle().length }
444
+ })
445
+
446
+ return (
447
+ <Show when={match()} fallback={props.text}>
448
+ {(range) => (
449
+ <>
450
+ {props.text.slice(0, range().at)}
451
+ <mark data-slot="search-list-match">{props.text.slice(range().at, range().end)}</mark>
452
+ {props.text.slice(range().end)}
453
+ </>
454
+ )}
455
+ </Show>
456
+ )
457
+ }
458
+
459
+ function stable(previous: string[] | undefined, next: string[]) {
460
+ return previous && previous.length === next.length && previous.every((value, index) => value === next[index])
461
+ ? previous
462
+ : next
463
+ }