@zyro-sec/ui 1.0.0 → 1.0.2

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 -40
  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,20 @@
1
+ import { ActivityRing } from "./activity-ring"
2
+
3
+ export default {
4
+ title: "UI/ActivityRing",
5
+ id: "ui-activity-ring",
6
+ args: { size: 14 },
7
+ argTypes: { size: { control: { type: "range", min: 10, max: 32, step: 1 } } },
8
+ render: (args: { size: number }) => (
9
+ <span class="inline-flex items-center gap-2">
10
+ <ActivityRing width={args.size} height={args.size} />
11
+ Session running
12
+ </span>
13
+ ),
14
+ }
15
+
16
+ export const Inline = {}
17
+
18
+ export const Compact = { args: { size: 12 } }
19
+
20
+ export const Large = { args: { size: 24 } }
@@ -0,0 +1,44 @@
1
+ import { Loader } from "./loader"
2
+
3
+ const docs = `### Overview
4
+ Circular v2 loader for compact loading states.
5
+
6
+ ### API
7
+ - Accepts standard SVG props.
8
+
9
+ ### Behavior
10
+ - The foreground ring covers 33% of the circumference and rotates continuously.
11
+
12
+ ### Accessibility
13
+ - Sets \`aria-hidden="true"\` by default.
14
+ `
15
+
16
+ export default {
17
+ title: "UI/Loader",
18
+ id: "ui-loader",
19
+ component: Loader,
20
+ args: { size: 16 },
21
+ argTypes: { size: { control: { type: "range", min: 8, max: 32, step: 1 } } },
22
+ tags: ["autodocs"],
23
+ parameters: {
24
+ docs: {
25
+ description: {
26
+ component: docs,
27
+ },
28
+ },
29
+ },
30
+ }
31
+
32
+ export const Basic = {
33
+ render: (props: { size: number }) => <Loader width={props.size} height={props.size} />,
34
+ }
35
+
36
+ export const Sizes = {
37
+ render: (props: { size: number }) => (
38
+ <div style={{ display: "flex", gap: "16px", "align-items": "center" }}>
39
+ <Loader width={12} height={12} />
40
+ <Loader width={props.size} height={props.size} />
41
+ <Loader width={24} height={24} />
42
+ </div>
43
+ ),
44
+ }
@@ -0,0 +1,56 @@
1
+ import { For } from "solid-js"
2
+ import { ProgressCircle, type ProgressCircleProps } from "./progress-circle"
3
+
4
+ export default {
5
+ title: "UI/ProgressCircle",
6
+ id: "ui-progress-circle",
7
+ component: ProgressCircle,
8
+ tags: ["autodocs"],
9
+ args: {
10
+ percentage: 60,
11
+ appearance: "compact",
12
+ },
13
+ argTypes: {
14
+ percentage: { control: { type: "range", min: 0, max: 100, step: 1 } },
15
+ appearance: { control: "select", options: ["compact", "indicator"] },
16
+ },
17
+ }
18
+
19
+ export const Playground = {}
20
+
21
+ export const Progress = {
22
+ args: { percentage: 50 },
23
+ render: (props: ProgressCircleProps) => (
24
+ <div style={{ display: "flex", gap: "16px", "align-items": "center" }}>
25
+ <For each={[0, 25, props.percentage, 75, 100]}>
26
+ {(percentage) => <ProgressCircle appearance={props.appearance} percentage={percentage} />}
27
+ </For>
28
+ </div>
29
+ ),
30
+ }
31
+
32
+ export const Sizes = {
33
+ render: (props: ProgressCircleProps) => (
34
+ <div style={{ display: "flex", gap: "16px", "align-items": "center" }}>
35
+ <ProgressCircle {...props} size={12} />
36
+ <ProgressCircle {...props} />
37
+ <ProgressCircle {...props} size={20} strokeWidth={2} />
38
+ </div>
39
+ ),
40
+ }
41
+
42
+ export const Indicator = {
43
+ args: { appearance: "indicator" },
44
+ render: (props: ProgressCircleProps) => (
45
+ <ProgressCircle
46
+ {...props}
47
+ size={16}
48
+ strokeWidth={2}
49
+ style={{
50
+ "--progress-circle-background": "var(--v2-background-bg-layer-04, var(--border-weak-base))",
51
+ "--progress-circle-background-overlay": "var(--v2-overlay-simple-overlay-pressed, transparent)",
52
+ "--progress-circle-progress": "var(--v2-icon-icon-base, var(--icon-base))",
53
+ }}
54
+ />
55
+ ),
56
+ }
@@ -0,0 +1,20 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import { boundToastDescription, toastDescriptionLimit } from "./description"
3
+
4
+ describe("toast description bound", () => {
5
+ test("keeps ordinary descriptions and the options object", () => {
6
+ const options = { title: "Failed", description: "Attachment exceeds the limit" }
7
+ expect(boundToastDescription(options)).toBe(options)
8
+ expect(boundToastDescription({ description: undefined })).toEqual({ description: undefined })
9
+ })
10
+
11
+ test("cuts a description that embeds a whole data URL", () => {
12
+ const description = `Attachment exceeds the limit: data:text/plain;base64,${"Q".repeat(50 * 1024 * 1024)}`
13
+ const bounded = boundToastDescription({ title: "Failed to send prompt", description })
14
+ expect(bounded.description!.length).toBe(toastDescriptionLimit + 1)
15
+ expect(bounded.description!.endsWith("…")).toBe(true)
16
+ expect(bounded.description!.startsWith("Attachment exceeds the limit: data:text/plain;base64,")).toBe(true)
17
+ expect(bounded.title).toBe("Failed to send prompt")
18
+ })
19
+ })
20
+
@@ -0,0 +1,106 @@
1
+ import { describe, expect, test } from "bun:test"
2
+ import {
3
+ createToastRegistryState,
4
+ selectToastOptions,
5
+ transitionToastRegistry,
6
+ type ToastRegistryState,
7
+ } from "./machine"
8
+
9
+ type Options = { readonly label: string }
10
+
11
+ const shown = (key: string, liveIds: (number | string)[], label = key) =>
12
+ ({
13
+ type: "toast.shown",
14
+ key,
15
+ options: { label },
16
+ liveIds: new Set(liveIds),
17
+ topmostLiveId: liveIds.at(-1),
18
+ }) as const
19
+
20
+ function show(state: ToastRegistryState<Options>, key: string, liveIds: (number | string)[], label = key) {
21
+ return transitionToastRegistry(state, shown(key, liveIds, label))
22
+ }
23
+
24
+ describe("toast registry machine", () => {
25
+ test("a toast closed directly in solid-sonner is pruned and shown again as a new toast", () => {
26
+ const first = show(createToastRegistryState(), "saved", [])
27
+ const other = show(first.state, "failed", [first.id])
28
+
29
+ expect(first.id).toBe(-1)
30
+ expect(other.state.entries.map((entry) => entry.key)).toEqual(["saved", "failed"])
31
+
32
+ // Both were dismissed without callbacks (an unmounted region, a direct `toast.dismiss`), so neither is live.
33
+ const again = show(other.state, "saved", [])
34
+
35
+ expect(again.id).toBe(-3)
36
+ expect(again.state.entries).toEqual([{ id: -3, key: "saved", options: { label: "saved" } }])
37
+ expect(again.effects).toEqual([{ type: "sonner.publish", id: -3, options: { label: "saved" } }])
38
+ })
39
+
40
+ test("a released or dismissed toast has no actions left to run", () => {
41
+ const first = show(createToastRegistryState(), "saved", [])
42
+
43
+ expect(selectToastOptions(first.state, first.id)).toEqual({ label: "saved" })
44
+
45
+ const released = transitionToastRegistry(first.state, { type: "toast.released", id: first.id })
46
+
47
+ expect(selectToastOptions(released.state, first.id)).toBeUndefined()
48
+ expect(released.effects).toEqual([])
49
+
50
+ const dismissed = transitionToastRegistry(first.state, { type: "toast.dismissed", id: first.id })
51
+
52
+ expect(selectToastOptions(dismissed.state, first.id)).toBeUndefined()
53
+ expect(dismissed.effects).toEqual([{ type: "sonner.dismiss", id: first.id }])
54
+ })
55
+
56
+ test("a repeat of the front toast updates it in place and pulses it", () => {
57
+ const first = show(createToastRegistryState(), "saved", [])
58
+ const repeat = show(first.state, "saved", [first.id], "saved again")
59
+
60
+ expect(repeat.id).toBe(first.id)
61
+ expect(repeat.state.nextId).toBe(first.state.nextId)
62
+ expect(selectToastOptions(repeat.state, first.id)).toEqual({ label: "saved again" })
63
+ expect(repeat.effects).toEqual([
64
+ { type: "sonner.publish", id: first.id, options: { label: "saved again" } },
65
+ { type: "dom.pulse", id: first.id },
66
+ ])
67
+ })
68
+
69
+ test("a repeat of a buried toast replaces it with a new toast in front", () => {
70
+ const first = show(createToastRegistryState(), "saved", [])
71
+ const other = show(first.state, "failed", [first.id])
72
+ const repeat = show(other.state, "saved", [first.id, other.id])
73
+
74
+ expect(repeat.id).toBe(-3)
75
+ expect(repeat.state.entries.map((entry) => [entry.id, entry.key])).toEqual([
76
+ [-2, "failed"],
77
+ [-3, "saved"],
78
+ ])
79
+ expect(repeat.effects).toEqual([
80
+ { type: "sonner.dismiss", id: first.id },
81
+ { type: "sonner.publish", id: -3, options: { label: "saved" } },
82
+ ])
83
+ })
84
+
85
+ test("custom toasts take ids from the same counter, and dismissing all clears every entry", () => {
86
+ const custom = transitionToastRegistry(createToastRegistryState<Options>(), { type: "custom.shown" })
87
+
88
+ expect(custom.state.nextId).toBe(-1)
89
+ expect(custom.effects).toEqual([])
90
+
91
+ const first = show(custom.state, "saved", [custom.state.nextId])
92
+
93
+ expect(first.id).toBe(-2)
94
+
95
+ const all = transitionToastRegistry(first.state, { type: "toast.dismissed" })
96
+
97
+ expect(all.state).toEqual({ nextId: -2, entries: [] })
98
+ expect(all.effects).toEqual([{ type: "sonner.dismiss", id: undefined }])
99
+ })
100
+
101
+ test("releasing an unknown toast keeps the state", () => {
102
+ const first = show(createToastRegistryState(), "saved", [])
103
+
104
+ expect(transitionToastRegistry(first.state, { type: "toast.released", id: -9 }).state).toBe(first.state)
105
+ })
106
+ })
@@ -0,0 +1,186 @@
1
+ import { onCleanup, onMount } from "solid-js"
2
+ import { Toast, showToast, toaster, type ToastRegionProps } from "./toast"
3
+ import { Button } from "@zyro-sec/ui/button"
4
+
5
+ const docs = `### Overview
6
+ Toast notifications with optional icons, actions, and progress.
7
+
8
+ Use brief titles/descriptions; limit actions to 1-2.
9
+
10
+ ### API
11
+ - Use \`showToast\` to trigger toasts.
12
+ - Render \`Toast.Region\` once per page.
13
+ - \`Toast\` subcomponents compose the structure.
14
+
15
+ ### Styling and states
16
+ - Single toast style; provide any custom icon element via \`icon\`.
17
+ - Optional actions and persistent toasts.
18
+
19
+ ### Behavior
20
+ - Toasts render in a portal and auto-dismiss unless persistent.
21
+
22
+ ### Accessibility
23
+ - The region announces additions through an ARIA live region and expands with Alt+T.
24
+
25
+ ### Theming/tokens
26
+ - Uses \`data-component="toast-v2"\` and slot data attributes.
27
+
28
+ `
29
+
30
+ export default {
31
+ title: "UI/Toast",
32
+ id: "ui-toast",
33
+ component: Toast,
34
+ args: { expand: false, visibleToasts: 3 },
35
+ argTypes: { visibleToasts: { control: { type: "range", min: 1, max: 4, step: 1 } } },
36
+ tags: ["autodocs"],
37
+ parameters: {
38
+ frameHeight: "320px",
39
+ frameBackground: "#fff",
40
+ docs: {
41
+ description: {
42
+ component: docs,
43
+ },
44
+ },
45
+ },
46
+ }
47
+
48
+ export const AllExamples = {
49
+ render: (props: ToastRegionProps) => (
50
+ <div style={{ display: "grid", gap: "12px" }}>
51
+ <Toast.Region {...props} />
52
+ <Button
53
+ class="w-fit"
54
+ variant="neutral"
55
+ onClick={() =>
56
+ showToast({
57
+ title: "Download started...",
58
+ description: "23% · 2 min left",
59
+ icon: (
60
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
61
+ <path
62
+ d="M13.5554 10.4453V13.5564H11.7777H4.22211C3.23989 13.5564 2.44434 13.5564 2.44434 13.5564V10.4453"
63
+ stroke="currentColor"
64
+ />
65
+ <path d="M4.88867 6L7.99978 9.11111L11.1109 6" stroke="currentColor" />
66
+ <path d="M8 9.11198V2.44531" stroke="currentColor" />
67
+ </svg>
68
+ ),
69
+ actions: [
70
+ {
71
+ label: "Run in background",
72
+ variant: "primary",
73
+ onClick: "dismiss",
74
+ },
75
+ { label: "Cancel", variant: "secondary", onClick: "dismiss" },
76
+ ],
77
+ })
78
+ }
79
+ >
80
+ Show download toast
81
+ </Button>
82
+ <Button
83
+ class="w-fit"
84
+ variant="neutral"
85
+ onClick={() =>
86
+ showToast({
87
+ title: "Saved",
88
+ description: "Your changes are stored",
89
+ icon: (
90
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
91
+ <path
92
+ d="M8.00011 14.4436C11.5593 14.4436 14.4446 11.5583 14.4446 7.99913C14.4446 4.43996 11.5593 1.55469 8.00011 1.55469C4.44094 1.55469 1.55566 4.43996 1.55566 7.99913C1.55566 11.5583 4.44094 14.4436 8.00011 14.4436Z"
93
+ stroke="#198B43"
94
+ />
95
+ <path d="M5.11133 8.22135L7.11133 10.4436L10.8891 5.55469" stroke="#198B43" />
96
+ </svg>
97
+ ),
98
+ })
99
+ }
100
+ >
101
+ Show saved toast
102
+ </Button>
103
+ <Button
104
+ class="w-fit"
105
+ variant="neutral"
106
+ onClick={() =>
107
+ showToast({
108
+ title: "Saving...",
109
+ icon: (
110
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
111
+ <rect x="8.75" y="5.25" width="2" height="2" fill="#3A3A3A" />
112
+ <rect x="8.75" y="8.75" width="2" height="2" fill="#3A3A3A" />
113
+ <rect x="8.75" y="12.25" width="2" height="2" fill="#3A3A3A" />
114
+ <rect x="5.25" y="12.25" width="2" height="2" fill="#3A3A3A" />
115
+ <rect opacity="0.3" x="5.25" y="1.75" width="2" height="2" fill="#3A3A3A" />
116
+ <rect opacity="0.3" x="5.25" y="5.25" width="2" height="2" fill="#3A3A3A" />
117
+ <rect opacity="0.3" x="5.25" y="8.75" width="2" height="2" fill="#3A3A3A" />
118
+ <rect opacity="0.3" x="8.75" y="1.75" width="2" height="2" fill="#3A3A3A" />
119
+ </svg>
120
+ ),
121
+ persistent: true,
122
+ })
123
+ }
124
+ >
125
+ Show saving toast
126
+ </Button>
127
+ <Button
128
+ class="w-fit"
129
+ variant="neutral"
130
+ onClick={() =>
131
+ showToast({
132
+ title: "Unsaved changes",
133
+ description: "You have made 4 edits...",
134
+ icon: (
135
+ <svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
136
+ <path
137
+ d="M8 6.33334V8.99392M7.78099 10.9934H8.23448M8 2L1.5 13H14.5L8 2Z"
138
+ stroke="#CB9F34"
139
+ stroke-linecap="square"
140
+ />
141
+ </svg>
142
+ ),
143
+ actions: [
144
+ { label: "Save changes", variant: "primary", onClick: "dismiss" },
145
+ { label: "Cancel", variant: "secondary", onClick: "dismiss" },
146
+ ],
147
+ })
148
+ }
149
+ >
150
+ Show unsaved changes toast
151
+ </Button>
152
+ </div>
153
+ ),
154
+ }
155
+
156
+ function StackButton() {
157
+ const ids = new Set<number>()
158
+
159
+ const show = () => {
160
+ for (const title of ["Download started", "Changes saved", "Upload complete", "Ready to sync"]) {
161
+ ids.add(showToast({ title, persistent: true }))
162
+ }
163
+ }
164
+
165
+ // The region subscribes inside its portal after the surrounding story mounts.
166
+ onMount(() => {
167
+ const frame = requestAnimationFrame(show)
168
+ onCleanup(() => cancelAnimationFrame(frame))
169
+ })
170
+ onCleanup(() => ids.forEach((id) => toaster.dismiss(id)))
171
+
172
+ return (
173
+ <Button variant="neutral" onClick={show}>
174
+ Show stack
175
+ </Button>
176
+ )
177
+ }
178
+
179
+ export const Stacked = {
180
+ render: (props: ToastRegionProps) => (
181
+ <>
182
+ <Toast.Region {...props} />
183
+ <StackButton />
184
+ </>
185
+ ),
186
+ }
@@ -0,0 +1,104 @@
1
+ import { createEffect, createSignal } from "solid-js"
2
+ import { Icon } from "@zyro-sec/ui/icon"
3
+ import { Checkbox, type CheckboxProps } from "./checkbox"
4
+
5
+ const docs = `### Overview
6
+ Checkbox control for multi-select or agreement inputs.
7
+
8
+ ### API
9
+ - Uses Kobalte Checkbox props.
10
+ - Optional: \`hideLabel\`, \`description\`, \`icon\` (standard only).
11
+ - Children render as the label.
12
+ - \`appearance\`: \`standard\` (default, legacy) or \`compact\`, the design system checkbox.
13
+ - \`surface\`: \`base\` (default) or \`layer-1\` for the compact control.
14
+
15
+ ### Theming/tokens
16
+ - Standard uses \`data-component="checkbox"\` and related slots.
17
+ - Compact uses \`data-slot="checkbox-v2"\` with \`--v2-background-bg-accent\`, \`--v2-border-border-strong\` and \`--v2-state-fg-danger\`.
18
+ `
19
+
20
+ function Sample(props: CheckboxProps) {
21
+ const [checked, setChecked] = createSignal(false)
22
+
23
+ createEffect(() => setChecked(!!props.defaultChecked))
24
+
25
+ return <Checkbox {...props} checked={checked()} onChange={setChecked} />
26
+ }
27
+
28
+ export default {
29
+ title: "UI/Checkbox",
30
+ id: "ui-checkbox",
31
+ component: Checkbox,
32
+ render: Sample,
33
+ args: {
34
+ appearance: "standard",
35
+ surface: "base",
36
+ defaultChecked: true,
37
+ indeterminate: false,
38
+ disabled: false,
39
+ readOnly: false,
40
+ required: false,
41
+ validationState: "valid",
42
+ hideLabel: false,
43
+ children: "Checkbox",
44
+ description: "",
45
+ } satisfies CheckboxProps,
46
+ argTypes: {
47
+ appearance: { options: ["standard", "compact"] },
48
+ surface: { options: ["base", "layer-1"] },
49
+ validationState: { options: ["valid", "invalid"] },
50
+ },
51
+ tags: ["autodocs"],
52
+ parameters: { docs: { description: { component: docs } } },
53
+ }
54
+
55
+ export const Basic = {}
56
+
57
+ export const States = {
58
+ args: { children: "Checked" },
59
+ render: (args: CheckboxProps) => (
60
+ <div style={{ display: "grid", gap: "12px" }}>
61
+ <Sample {...args} />
62
+ <Checkbox>Unchecked</Checkbox>
63
+ <Checkbox disabled>Disabled</Checkbox>
64
+ <Checkbox description="Helper text">With description</Checkbox>
65
+ </div>
66
+ ),
67
+ }
68
+
69
+ export const CustomIcon = {
70
+ args: { children: "Custom icon" },
71
+ render: (args: CheckboxProps) => <Sample {...args} icon={<Icon name="check" size="small" />} />,
72
+ }
73
+
74
+ export const HiddenLabel = { args: { children: "Hidden label", defaultChecked: false, hideLabel: true } }
75
+
76
+ export const Compact = {
77
+ args: { appearance: "compact", children: "Default", description: "Suffix", defaultChecked: false },
78
+ render: (args: CheckboxProps) => (
79
+ <div style={{ display: "grid", gap: "16px" }}>
80
+ <Sample {...args} />
81
+ <Checkbox appearance="compact" defaultChecked description="Suffix">
82
+ Checked
83
+ </Checkbox>
84
+ <Checkbox appearance="compact" indeterminate>
85
+ Indeterminate
86
+ </Checkbox>
87
+ <Checkbox appearance="compact" validationState="invalid">
88
+ Invalid
89
+ </Checkbox>
90
+ <Checkbox appearance="compact" disabled description="Suffix">
91
+ Disabled
92
+ </Checkbox>
93
+ <Checkbox appearance="compact" disabled defaultChecked>
94
+ Checked, disabled
95
+ </Checkbox>
96
+ <Checkbox appearance="compact" surface="layer-1">
97
+ Layer 1
98
+ </Checkbox>
99
+ <Checkbox appearance="compact" surface="layer-1" defaultChecked>
100
+ Layer 1, checked
101
+ </Checkbox>
102
+ </div>
103
+ ),
104
+ }
@@ -0,0 +1,129 @@
1
+ import { createSignal, Show, type ParentProps } from "solid-js"
2
+ import { Field } from "./field"
3
+ import { InlineInput } from "@zyro-sec/ui/inline-input"
4
+ import { TextInput } from "@zyro-sec/ui/text-input"
5
+ import { Textarea } from "@zyro-sec/ui/textarea"
6
+
7
+ const docs = `### Overview
8
+ Composable field layout for TextInput, Textarea, and InlineInput.
9
+
10
+ ### Usage
11
+ \`\`\`tsx
12
+ <Field invalid>
13
+ <Field.Label tooltip="Helper">Label</Field.Label>
14
+ <Field.Prefix>Prefix</Field.Prefix>
15
+ <Field.Control>
16
+ <TextInput placeholder="Text" />
17
+ </Field.Control>
18
+ <Field.Suffix>Suffix</Field.Suffix>
19
+ </Field>
20
+ \`\`\`
21
+
22
+ Omit \`Field.Control\` and place the input directly inside \`Field\` — a11y props are merged automatically.
23
+
24
+ ### API
25
+ - \`Field\`: \`invalid\` propagates to the control.
26
+ - \`Field.Label\`: \`tooltip\` shows the info icon with tooltip text.
27
+ - \`Field.Prefix\` / \`Field.Suffix\`: helper copy above / below the control.
28
+ - \`Field.Control\`: optional wrapper (marker only).
29
+ `
30
+
31
+ const args = { invalid: false, label: "Label", tooltip: "", prefix: "Prefix", suffix: "Suffix" }
32
+
33
+ function Example(props: ParentProps<typeof args>) {
34
+ return (
35
+ <div style={{ width: "280px" }}>
36
+ <Field invalid={props.invalid}>
37
+ <Field.Label tooltip={props.tooltip}>{props.label}</Field.Label>
38
+ <Show when={props.prefix}>
39
+ <Field.Prefix>{props.prefix}</Field.Prefix>
40
+ </Show>
41
+ {props.children}
42
+ <Show when={props.suffix}>
43
+ <Field.Suffix>{props.suffix}</Field.Suffix>
44
+ </Show>
45
+ </Field>
46
+ </div>
47
+ )
48
+ }
49
+
50
+ export default {
51
+ title: "UI/Field",
52
+ id: "ui-field",
53
+ args,
54
+ subcomponents: {
55
+ Label: Field.Label,
56
+ Prefix: Field.Prefix,
57
+ Suffix: Field.Suffix,
58
+ Control: Field.Control,
59
+ },
60
+ tags: ["autodocs"],
61
+ parameters: {
62
+ frameHeight: "500px",
63
+ frameBackground: "#fff",
64
+ docs: {
65
+ description: {
66
+ component: docs,
67
+ },
68
+ },
69
+ },
70
+ }
71
+
72
+ export const TextInputExample = {
73
+ args: { tooltip: "Additional context" },
74
+ render: (props: typeof args) => (
75
+ <Example {...props}>
76
+ <Field.Control>
77
+ <TextInput placeholder="Text" showCopyButton />
78
+ </Field.Control>
79
+ </Example>
80
+ ),
81
+ }
82
+
83
+ export const TextInputDirectChild = {
84
+ render: (props: typeof args) => (
85
+ <Example {...props}>
86
+ <TextInput placeholder="Text" />
87
+ </Example>
88
+ ),
89
+ }
90
+
91
+ export const TextareaExample = {
92
+ render: (props: typeof args) => (
93
+ <Example {...props}>
94
+ <Textarea placeholder="Text" />
95
+ </Example>
96
+ ),
97
+ }
98
+
99
+ export const InlineInputExample = {
100
+ render: (props: typeof args) => (
101
+ <Example {...props}>
102
+ <InlineInput placeholder="0.00" width="100%" />
103
+ </Example>
104
+ ),
105
+ }
106
+
107
+ export const Invalid = {
108
+ args: { invalid: true },
109
+ render: (props: typeof args) => (
110
+ <Example {...props}>
111
+ <TextInput placeholder="Text" value="Invalid" showCopyButton />
112
+ </Example>
113
+ ),
114
+ }
115
+
116
+ export const Controlled = {
117
+ args: { label: "Amount", prefix: "" },
118
+ render: (props: typeof args) => {
119
+ const [value, setValue] = createSignal("")
120
+
121
+ return (
122
+ <Example {...props} suffix={value() ? `Entered: ${value()}` : props.suffix}>
123
+ <Field.Control>
124
+ <TextInput placeholder="0.00" value={value()} onInput={(e) => setValue(e.currentTarget.value)} numeric />
125
+ </Field.Control>
126
+ </Example>
127
+ )
128
+ },
129
+ }