@sdxc/kit 0.0.0-stage → 2026.10.17

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 (298) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +93 -2
  3. package/changelog.jsonl +1097 -0
  4. package/config.schema.json +89 -0
  5. package/dist/author.d.ts +36 -0
  6. package/dist/author.js +107 -0
  7. package/dist/bin.d.ts +9 -0
  8. package/dist/bin.js +10 -0
  9. package/dist/cli.d.ts +33 -0
  10. package/dist/cli.js +58 -0
  11. package/dist/commands/create.d.ts +20 -0
  12. package/dist/commands/create.js +169 -0
  13. package/dist/commands/init.d.ts +16 -0
  14. package/dist/commands/init.js +27 -0
  15. package/dist/commands/make.d.ts +335 -0
  16. package/dist/commands/make.js +152 -0
  17. package/dist/commands/run.d.ts +23 -0
  18. package/dist/commands/run.js +53 -0
  19. package/dist/commands/ui/add.d.ts +23 -0
  20. package/dist/commands/ui/add.js +50 -0
  21. package/dist/commands/ui/diff.d.ts +20 -0
  22. package/dist/commands/ui/diff.js +28 -0
  23. package/dist/commands/ui/list.d.ts +24 -0
  24. package/dist/commands/ui/list.js +45 -0
  25. package/dist/commands/ui/remove.d.ts +22 -0
  26. package/dist/commands/ui/remove.js +48 -0
  27. package/dist/commands/ui/update.d.ts +23 -0
  28. package/dist/commands/ui/update.js +37 -0
  29. package/dist/commands/upgrade.d.ts +30 -0
  30. package/dist/commands/upgrade.js +184 -0
  31. package/dist/config.d.ts +81 -0
  32. package/dist/config.js +157 -0
  33. package/dist/contract.d.ts +161 -0
  34. package/dist/contract.js +308 -0
  35. package/dist/create/github.d.ts +63 -0
  36. package/dist/create/github.js +172 -0
  37. package/dist/create/target.d.ts +31 -0
  38. package/dist/create/target.js +56 -0
  39. package/dist/create/templates.d.ts +69 -0
  40. package/dist/create/templates.js +251 -0
  41. package/dist/dependencies.d.ts +34 -0
  42. package/dist/dependencies.js +76 -0
  43. package/dist/diff.d.ts +14 -0
  44. package/dist/diff.js +103 -0
  45. package/dist/format.d.ts +21 -0
  46. package/dist/format.js +40 -0
  47. package/dist/init.d.ts +40 -0
  48. package/dist/init.js +100 -0
  49. package/dist/lock.d.ts +74 -0
  50. package/dist/lock.js +214 -0
  51. package/dist/make/declare.d.ts +54 -0
  52. package/dist/make/declare.js +598 -0
  53. package/dist/make/generate.d.ts +62 -0
  54. package/dist/make/generate.js +160 -0
  55. package/dist/make/imports.d.ts +43 -0
  56. package/dist/make/imports.js +105 -0
  57. package/dist/make/index.d.ts +43 -0
  58. package/dist/make/index.js +140 -0
  59. package/dist/make/kinds.d.ts +40 -0
  60. package/dist/make/kinds.js +96 -0
  61. package/dist/make/migrations.d.ts +41 -0
  62. package/dist/make/migrations.js +116 -0
  63. package/dist/make/names.d.ts +31 -0
  64. package/dist/make/names.js +47 -0
  65. package/dist/make/stubs.d.ts +44 -0
  66. package/dist/make/stubs.js +89 -0
  67. package/dist/middleware.d.ts +44 -0
  68. package/dist/middleware.js +49 -0
  69. package/dist/package-manager.d.ts +41 -0
  70. package/dist/package-manager.js +80 -0
  71. package/dist/project.d.ts +19 -0
  72. package/dist/project.js +42 -0
  73. package/dist/releases.d.ts +40 -0
  74. package/dist/releases.js +110 -0
  75. package/dist/testing.d.ts +60 -0
  76. package/dist/testing.js +148 -0
  77. package/dist/ui/commands.d.ts +114 -0
  78. package/dist/ui/commands.js +432 -0
  79. package/dist/ui/imports.d.ts +46 -0
  80. package/dist/ui/imports.js +160 -0
  81. package/dist/ui/layout.d.ts +48 -0
  82. package/dist/ui/layout.js +138 -0
  83. package/dist/ui/registry.d.ts +58 -0
  84. package/dist/ui/registry.js +82 -0
  85. package/dist/upgrade/changelog.d.ts +50 -0
  86. package/dist/upgrade/changelog.js +69 -0
  87. package/dist/upgrade/project.d.ts +62 -0
  88. package/dist/upgrade/project.js +132 -0
  89. package/dist/upgrade/prompt.d.ts +51 -0
  90. package/dist/upgrade/prompt.js +227 -0
  91. package/dist/upgrade/registry.d.ts +33 -0
  92. package/dist/upgrade/registry.js +50 -0
  93. package/lock.schema.json +60 -0
  94. package/package.json +44 -5
  95. package/registry/ui/accordion.json +15 -0
  96. package/registry/ui/alert-dialog.json +20 -0
  97. package/registry/ui/alert.json +15 -0
  98. package/registry/ui/aspect-ratio.json +13 -0
  99. package/registry/ui/attachment.json +15 -0
  100. package/registry/ui/avatar.json +15 -0
  101. package/registry/ui/badge.json +13 -0
  102. package/registry/ui/breadcrumbs.json +15 -0
  103. package/registry/ui/bubble.json +13 -0
  104. package/registry/ui/button.json +16 -0
  105. package/registry/ui/calendar.json +16 -0
  106. package/registry/ui/card.json +18 -0
  107. package/registry/ui/carousel.json +15 -0
  108. package/registry/ui/chart.json +13 -0
  109. package/registry/ui/checkbox-group.json +13 -0
  110. package/registry/ui/checkbox.json +16 -0
  111. package/registry/ui/color-area.json +13 -0
  112. package/registry/ui/color-field.json +20 -0
  113. package/registry/ui/color-picker.json +17 -0
  114. package/registry/ui/color-slider.json +13 -0
  115. package/registry/ui/color-swatch-picker.json +15 -0
  116. package/registry/ui/color-swatch.json +13 -0
  117. package/registry/ui/color-wheel.json +13 -0
  118. package/registry/ui/combobox.json +15 -0
  119. package/registry/ui/command.json +13 -0
  120. package/registry/ui/confirm.json +19 -0
  121. package/registry/ui/context-menu.json +16 -0
  122. package/registry/ui/date-field.json +19 -0
  123. package/registry/ui/date-picker.json +15 -0
  124. package/registry/ui/date-range-picker.json +16 -0
  125. package/registry/ui/description.json +13 -0
  126. package/registry/ui/dialog.json +19 -0
  127. package/registry/ui/disclosure.json +18 -0
  128. package/registry/ui/drawer.json +18 -0
  129. package/registry/ui/drop-indicator.json +13 -0
  130. package/registry/ui/drop-zone.json +13 -0
  131. package/registry/ui/empty.json +15 -0
  132. package/registry/ui/field-error.json +13 -0
  133. package/registry/ui/file-trigger.json +13 -0
  134. package/registry/ui/form.json +21 -0
  135. package/registry/ui/grid-list.json +18 -0
  136. package/registry/ui/group.json +13 -0
  137. package/registry/ui/header.json +13 -0
  138. package/registry/ui/heading-scope.json +20 -0
  139. package/registry/ui/heading.json +15 -0
  140. package/registry/ui/highlight.json +16 -0
  141. package/registry/ui/hover-card.json +13 -0
  142. package/registry/ui/image-placeholder.json +16 -0
  143. package/registry/ui/input.json +13 -0
  144. package/registry/ui/item.json +13 -0
  145. package/registry/ui/keyboard.json +13 -0
  146. package/registry/ui/label.json +13 -0
  147. package/registry/ui/link-button.json +16 -0
  148. package/registry/ui/link.json +13 -0
  149. package/registry/ui/listbox.json +15 -0
  150. package/registry/ui/logo.json +15 -0
  151. package/registry/ui/marker.json +13 -0
  152. package/registry/ui/menu.json +19 -0
  153. package/registry/ui/menubar.json +13 -0
  154. package/registry/ui/message-scroller.json +16 -0
  155. package/registry/ui/message.json +13 -0
  156. package/registry/ui/meter.json +13 -0
  157. package/registry/ui/modal.json +15 -0
  158. package/registry/ui/nav-link.json +13 -0
  159. package/registry/ui/navigation-menu.json +15 -0
  160. package/registry/ui/number-field.json +15 -0
  161. package/registry/ui/otp-field.json +15 -0
  162. package/registry/ui/overlay-arrow.json +13 -0
  163. package/registry/ui/pagination.json +16 -0
  164. package/registry/ui/popover.json +13 -0
  165. package/registry/ui/progress-bar.json +13 -0
  166. package/registry/ui/radio-group.json +13 -0
  167. package/registry/ui/range-calendar.json +16 -0
  168. package/registry/ui/resizable.json +13 -0
  169. package/registry/ui/scroll-area.json +13 -0
  170. package/registry/ui/search-field.json +16 -0
  171. package/registry/ui/section.json +13 -0
  172. package/registry/ui/select.json +13 -0
  173. package/registry/ui/selection-indicator.json +13 -0
  174. package/registry/ui/sentinel-row.json +16 -0
  175. package/registry/ui/separator.json +13 -0
  176. package/registry/ui/shared-element.json +13 -0
  177. package/registry/ui/sheet.json +15 -0
  178. package/registry/ui/shortcut-list.json +18 -0
  179. package/registry/ui/sidebar.json +20 -0
  180. package/registry/ui/skeleton.json +13 -0
  181. package/registry/ui/slider.json +16 -0
  182. package/registry/ui/spinner.json +13 -0
  183. package/registry/ui/switch.json +16 -0
  184. package/registry/ui/table.json +16 -0
  185. package/registry/ui/tabs.json +17 -0
  186. package/registry/ui/tag-group.json +18 -0
  187. package/registry/ui/text-field.json +19 -0
  188. package/registry/ui/text.json +13 -0
  189. package/registry/ui/textarea.json +13 -0
  190. package/registry/ui/time-field.json +19 -0
  191. package/registry/ui/toast.json +16 -0
  192. package/registry/ui/toggle-button.json +17 -0
  193. package/registry/ui/toolbar.json +13 -0
  194. package/registry/ui/tooltip.json +16 -0
  195. package/registry/ui/tree.json +18 -0
  196. package/registry/ui/typeset.json +16 -0
  197. package/registry/ui/youtube-embed.json +16 -0
  198. package/stubs/command.stub +16 -0
  199. package/stubs/command.test.stub +21 -0
  200. package/stubs/controller.api.stub +21 -0
  201. package/stubs/controller.api.test.stub +18 -0
  202. package/stubs/controller.form.stub +63 -0
  203. package/stubs/controller.form.test.stub +61 -0
  204. package/stubs/controller.stub +24 -0
  205. package/stubs/controller.test.stub +18 -0
  206. package/stubs/email.stub +26 -0
  207. package/stubs/email.test.stub +21 -0
  208. package/stubs/factory.stub +13 -0
  209. package/stubs/initializer.stub +9 -0
  210. package/stubs/initializer.test.stub +16 -0
  211. package/stubs/job.cron.stub +16 -0
  212. package/stubs/job.stub +15 -0
  213. package/stubs/job.test.stub +18 -0
  214. package/stubs/mcp.resource.stub +15 -0
  215. package/stubs/mcp.stub +13 -0
  216. package/stubs/mcp.test.stub +18 -0
  217. package/stubs/middleware.stub +16 -0
  218. package/stubs/middleware.test.stub +16 -0
  219. package/stubs/migration.stub +1 -0
  220. package/stubs/model.stub +33 -0
  221. package/stubs/model.test.stub +18 -0
  222. package/stubs/policy.stub +16 -0
  223. package/stubs/policy.test.stub +20 -0
  224. package/stubs/service.stub +17 -0
  225. package/stubs/service.test.stub +17 -0
  226. package/stubs/validator.stub +17 -0
  227. package/stubs/validator.test.stub +25 -0
  228. package/templates/app/.env.example +16 -0
  229. package/templates/app/README.md +84 -0
  230. package/templates/app/app/commands/about.test.ts +29 -0
  231. package/templates/app/app/commands/about.ts +34 -0
  232. package/templates/app/app/commands/db/console.ts +6 -0
  233. package/templates/app/app/commands/db/migrate.test.ts +30 -0
  234. package/templates/app/app/commands/db/migrate.ts +55 -0
  235. package/templates/app/app/commands/index.ts +31 -0
  236. package/templates/app/app/commands/typegen.test.ts +17 -0
  237. package/templates/app/app/commands/typegen.ts +16 -0
  238. package/templates/app/app/http/controllers/api/health.tsx +15 -0
  239. package/templates/app/app/http/controllers/api/not-found.tsx +16 -0
  240. package/templates/app/app/http/controllers/api/openapi.tsx +17 -0
  241. package/templates/app/app/http/controllers/home.tsx +30 -0
  242. package/templates/app/app/http/controllers/mcp.tsx +16 -0
  243. package/templates/app/app/http/controllers/not-found.tsx +30 -0
  244. package/templates/app/app/http/controllers/robots.test.ts +18 -0
  245. package/templates/app/app/http/controllers/robots.ts +24 -0
  246. package/templates/app/app/http/controllers/sitemap.test.ts +28 -0
  247. package/templates/app/app/http/controllers/sitemap.ts +25 -0
  248. package/templates/app/app/http/middleware/api.ts +10 -0
  249. package/templates/app/app/http/middleware/page.test.ts +40 -0
  250. package/templates/app/app/http/middleware/page.ts +49 -0
  251. package/templates/app/app/http/middleware/server-timing.test.ts +15 -0
  252. package/templates/app/app/http/middleware/server-timing.ts +42 -0
  253. package/templates/app/app/initializers/assets.ts +11 -0
  254. package/templates/app/app/initializers/captcha.ts +11 -0
  255. package/templates/app/app/initializers/cli.ts +75 -0
  256. package/templates/app/app/initializers/database.test.ts +18 -0
  257. package/templates/app/app/initializers/database.ts +18 -0
  258. package/templates/app/app/initializers/dispatcher.ts +36 -0
  259. package/templates/app/app/initializers/honeypot.ts +11 -0
  260. package/templates/app/app/initializers/i18n.test.ts +16 -0
  261. package/templates/app/app/initializers/i18n.ts +28 -0
  262. package/templates/app/app/initializers/local-database.test.ts +33 -0
  263. package/templates/app/app/initializers/local-database.ts +53 -0
  264. package/templates/app/app/initializers/logger.ts +10 -0
  265. package/templates/app/app/initializers/mail.test.ts +27 -0
  266. package/templates/app/app/initializers/mail.ts +11 -0
  267. package/templates/app/app/initializers/mcp.ts +16 -0
  268. package/templates/app/app/initializers/openapi.ts +21 -0
  269. package/templates/app/app/initializers/router.test.ts +61 -0
  270. package/templates/app/app/initializers/router.tsx +111 -0
  271. package/templates/app/app/initializers/seo.ts +15 -0
  272. package/templates/app/app/initializers/session.test.ts +34 -0
  273. package/templates/app/app/initializers/session.ts +29 -0
  274. package/templates/app/app/initializers/spam.ts +10 -0
  275. package/templates/app/app/jobs/index.ts +10 -0
  276. package/templates/app/app/mcp/resources/index.ts +9 -0
  277. package/templates/app/app/mcp/tools/index.ts +10 -0
  278. package/templates/app/app/models/index.ts +10 -0
  279. package/templates/app/app/services/migrations.test.ts +45 -0
  280. package/templates/app/app/services/migrations.ts +60 -0
  281. package/templates/app/app/test/cloudflare-workers.ts +25 -0
  282. package/templates/app/bootstrap/browser.ts +27 -0
  283. package/templates/app/bootstrap/cli.ts +9 -0
  284. package/templates/app/bootstrap/worker.ts +31 -0
  285. package/templates/app/cloudflare.config.ts +56 -0
  286. package/templates/app/config/constants.ts +19 -0
  287. package/templates/app/config/problems.ts +24 -0
  288. package/templates/app/config/security-policy.ts +34 -0
  289. package/templates/app/config/security-txt.ts +28 -0
  290. package/templates/app/database/migrations/.gitkeep +0 -0
  291. package/templates/app/gitignore +9 -0
  292. package/templates/app/package.json +68 -0
  293. package/templates/app/resources/layouts/document.tsx +79 -0
  294. package/templates/app/resources/locales/en.json +10 -0
  295. package/templates/app/routes/api.ts +29 -0
  296. package/templates/app/routes/web.ts +14 -0
  297. package/templates/app/tsconfig.json +40 -0
  298. package/templates/app/vite.config.ts +44 -0
@@ -0,0 +1,227 @@
1
+ /**
2
+ * The prompt `sdxc upgrade` hands an AI agent: the release notes of the packages the project
3
+ * imports, for every release it moved across, breaking changes first, with the components to
4
+ * refresh, the commands that verify the edit, and where each package is documented.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { readFile } from "node:fs/promises";
10
+ import { join } from "node:path";
11
+ import { failure, isFailure, isSuccess, success, wrap } from "@sdxc/result";
12
+ import { compare } from "@sdxc/semver";
13
+ import { loadConfig } from "../config.js";
14
+ import { readLock, uiEntries } from "../lock.js";
15
+ import { lockFileAtOrAbove, packageManager } from "../package-manager.js";
16
+ import { scopedPackageOf } from "../releases.js";
17
+ import { entriesBetween, fullHistoryStart, readChangelog } from "./changelog.js";
18
+ import { projectImports, readManifest } from "./project.js";
19
+ /** Where each release's GitHub Release lives, `<RELEASES>/tag/v<version>`. */
20
+ const RELEASES = "https://github.com/sergiodxa/monorepo/releases";
21
+ /** Each package's reference page, as Markdown an agent reads directly. */
22
+ const DOCUMENTATION = "https://sdxc.dev/api";
23
+ /** Remix's release notes, `<REMIX_RELEASES>/tag/remix@<version>`. */
24
+ const REMIX_RELEASES = "https://github.com/remix-run/remix/releases";
25
+ /** The `package.json` scripts that verify a project, in the order the prompt lists them. */
26
+ const VERIFY_SCRIPTS = ["check", "typecheck", "test"];
27
+ /** Commit types whose notes describe a change to what a consumer receives, besides `feat`. */
28
+ const FIX_TYPES = new Set(["fix", "perf", "revert"]);
29
+ /**
30
+ * The prompt for moving from `input.from` to `input.to`, as Markdown. Only the imported
31
+ * packages' entries appear; notes typed docs, test, refactor, chore, style, ci or build state
32
+ * that a consumer has nothing to do, so they are left to the GitHub Releases.
33
+ */
34
+ export function renderPrompt(input) {
35
+ let imported = new Set(input.packages);
36
+ let relevant = entriesBetween(input.entries, input.from, input.to)
37
+ .filter((entry) => imported.has(entry.package))
38
+ .sort((a, b) => compare(a.release, b.release) || compareText(a.package, b.package));
39
+ let breaking = relevant.filter((entry) => entry.breaking);
40
+ let features = relevant.filter((entry) => !entry.breaking && entry.type === "feat");
41
+ let fixes = relevant.filter((entry) => !entry.breaking && FIX_TYPES.has(entry.type));
42
+ let sections = [
43
+ [
44
+ `# Upgrade the @sdxc packages from ${input.from} to ${input.to}`,
45
+ `This project now depends on the @sdxc packages of release ${input.to}, installed. Update its code for the changes below, which are the release notes of the packages it imports for every release after ${input.from}. Apply each breaking change's migration wherever the code uses what it changed, adopt the features and fixes where they apply, then run the verification commands and fix what they report.`,
46
+ `Packages this project imports: ${[...input.packages].sort(compareText).map(code).join(", ")}.`,
47
+ ].join("\n\n"),
48
+ ];
49
+ if (input.remix !== null) {
50
+ sections.push([
51
+ "## Remix",
52
+ `\`remix\` moved from ${input.remix.from} to ${input.remix.to}, the version release ${input.to} requires. Read its release notes for changes the code needs: ${REMIX_RELEASES}/tag/remix%40${input.remix.to}`,
53
+ ].join("\n\n"));
54
+ }
55
+ if (relevant.length === 0) {
56
+ sections.push("No release in between changed a package this project imports.");
57
+ }
58
+ if (breaking.length > 0)
59
+ sections.push(entrySection("Breaking changes", breaking));
60
+ if (features.length > 0)
61
+ sections.push(entrySection("Features", features));
62
+ if (fixes.length > 0)
63
+ sections.push(entrySection("Fixes", fixes));
64
+ let older = olderReleases(input);
65
+ if (older !== null)
66
+ sections.push(older);
67
+ if (input.components.length > 0) {
68
+ sections.push([
69
+ "## Vendored components",
70
+ "These copied components changed after the release they were copied from. Review each change with `sdxc ui diff`, and take it with `sdxc ui update` (an edited copy is left alone unless `--force`):",
71
+ input.components
72
+ .map((component) => `- \`${component.name}\`, copied from ${component.release}, changed in ${component.changedIn}: \`sdxc ui diff ${component.name}\`, then \`sdxc ui update ${component.name}\``)
73
+ .join("\n"),
74
+ ].join("\n\n"));
75
+ }
76
+ if (input.verify.length > 0) {
77
+ sections.push([
78
+ "## Verify",
79
+ "Run these after editing and fix what they report:",
80
+ input.verify.map((command) => `- \`${command}\``).join("\n"),
81
+ ].join("\n\n"));
82
+ }
83
+ sections.push([
84
+ "## Documentation",
85
+ [...input.packages]
86
+ .sort(compareText)
87
+ .map((name) => `- ${code(name)}: ${DOCUMENTATION}/${documentationSlug(name)}.md`)
88
+ .join("\n"),
89
+ ].join("\n\n"));
90
+ return `${sections.join("\n\n")}\n`;
91
+ }
92
+ /**
93
+ * Gathers the prompt for the project at `root` from the `@sdxc/kit` at `packageRoot`, which is
94
+ * the target release: its version, its changelog, its component registry and its
95
+ * `remix` peer, compared with `remixFrom` when the bump changed `remix`.
96
+ */
97
+ export async function buildPrompt(options) {
98
+ let own = await readOwnManifest(options.packageRoot);
99
+ if (isFailure(own))
100
+ return own;
101
+ let to = own.data.version;
102
+ if (compare(options.from, to) > 0) {
103
+ return failure(new Error(`--from ${options.from} is newer than this @sdxc/kit, ${to}`));
104
+ }
105
+ let entries = await readChangelog(options.packageRoot);
106
+ if (isFailure(entries))
107
+ return entries;
108
+ let project = await readManifest(options.root);
109
+ if (isFailure(project))
110
+ return project;
111
+ let manager = await packageManager({
112
+ declared: project.data.manifest.packageManager,
113
+ findLockFile: lockFileAtOrAbove(options.root),
114
+ });
115
+ let scripts = project.data.manifest.scripts ?? {};
116
+ let imports = await projectImports(options.root);
117
+ let packages = new Set();
118
+ for (let specifier of imports.keys()) {
119
+ let name = scopedPackageOf(specifier);
120
+ if (name !== null)
121
+ packages.add(name);
122
+ }
123
+ let components = await changedComponents(options.root, options.packageRoot);
124
+ if (isFailure(components))
125
+ return components;
126
+ let remixTo = own.data.remix;
127
+ let remix = options.remixFrom !== null && remixTo !== null && options.remixFrom !== remixTo
128
+ ? { from: options.remixFrom, to: remixTo }
129
+ : null;
130
+ return success(renderPrompt({
131
+ from: options.from,
132
+ to,
133
+ entries: entries.data,
134
+ packages: [...packages],
135
+ remix,
136
+ components: components.data,
137
+ verify: VERIFY_SCRIPTS.filter((name) => scripts[name] !== undefined).map((name) => [...manager.run, name].join(" ")),
138
+ }));
139
+ }
140
+ /** The version and `remix` peer of the running kit, which are its release's. */
141
+ async function readOwnManifest(packageRoot) {
142
+ let text = await wrap(() => readFile(join(packageRoot, "package.json"), "utf8"));
143
+ if (isFailure(text))
144
+ return text;
145
+ let parsed = wrap(() => JSON.parse(text.data));
146
+ if (isFailure(parsed) || typeof parsed.data.version !== "string") {
147
+ return failure(new Error(`${packageRoot}/package.json has no version`));
148
+ }
149
+ let remix = parsed.data.peerDependencies?.remix;
150
+ return success({ version: parsed.data.version, remix: typeof remix === "string" ? remix : null });
151
+ }
152
+ /**
153
+ * The components the project's lock file records whose registry entry in the installed
154
+ * release names a later `changedIn` than the release the copy came from. Without a lock file
155
+ * there are none; a component the registry no longer has is left out, and an invalid lock fails.
156
+ */
157
+ async function changedComponents(root, packageRoot) {
158
+ let config = await loadConfig(root);
159
+ if (isFailure(config))
160
+ return config;
161
+ let lock = await readLock(root, config.data.config);
162
+ if (isFailure(lock))
163
+ return lock;
164
+ let changed = [];
165
+ for (let entry of uiEntries(lock.data)) {
166
+ let changedIn = await registryChangedIn(packageRoot, entry.name);
167
+ if (changedIn !== null && compare(changedIn, entry.release) > 0) {
168
+ changed.push({ name: entry.name, release: entry.release, changedIn });
169
+ }
170
+ }
171
+ return success(changed);
172
+ }
173
+ /** The `changedIn` of a component's registry entry, or `null` when the entry is missing or unreadable. */
174
+ async function registryChangedIn(packageRoot, name) {
175
+ let text = await wrap(() => readFile(join(packageRoot, "registry", "ui", `${name}.json`), "utf8"));
176
+ if (!isSuccess(text))
177
+ return null;
178
+ let parsed = wrap(() => JSON.parse(text.data));
179
+ if (!isSuccess(parsed))
180
+ return null;
181
+ return typeof parsed.data.changedIn === "string" ? parsed.data.changedIn : null;
182
+ }
183
+ /**
184
+ * The note on releases older than the changelog's full window, which kept only their breaking
185
+ * entries, with a link to each one's GitHub Release; `null` when the move starts inside it.
186
+ */
187
+ function olderReleases(input) {
188
+ let start = fullHistoryStart(input.to);
189
+ if (compare(input.from, start) >= 0)
190
+ return null;
191
+ let releases = [
192
+ ...new Set(entriesBetween(input.entries, input.from, input.to)
193
+ .map((entry) => entry.release)
194
+ .filter((release) => compare(release, start) < 0)),
195
+ ].sort(compare);
196
+ return [
197
+ "## Older releases",
198
+ `Releases after ${input.from} and before ${start} are summarized by their breaking changes only. Their full notes are on GitHub: ${RELEASES}`,
199
+ ...(releases.length > 0
200
+ ? [releases.map((release) => `- ${release}: ${RELEASES}/tag/v${release}`).join("\n")]
201
+ : []),
202
+ ].join("\n\n");
203
+ }
204
+ /** A heading and each entry under its own sub-heading with its full body. */
205
+ function entrySection(heading, entries) {
206
+ let blocks = entries.map((entry) => {
207
+ let lines = [`### ${entry.package}: ${entry.title}`, `Released in ${entry.release}.`];
208
+ if (entry.body.trim() !== "")
209
+ lines.push(entry.body.trim());
210
+ return lines.join("\n\n");
211
+ });
212
+ return [`## ${heading}`, ...blocks].join("\n\n");
213
+ }
214
+ /** The reference page slug: a scoped package by its bare name. */
215
+ function documentationSlug(name) {
216
+ return name.startsWith("@sdxc/") ? name.slice("@sdxc/".length) : name;
217
+ }
218
+ function code(text) {
219
+ return `\`${text}\``;
220
+ }
221
+ function compareText(a, b) {
222
+ if (a < b)
223
+ return -1;
224
+ if (a > b)
225
+ return 1;
226
+ return 0;
227
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * The npm registry as `sdxc upgrade` reads it: a release is a published `@sdxc/kit` version,
3
+ * which ships in every release, with the `remix` version it declares as its peer and the
4
+ * changelog it carries, so the bump knows all three before anything is installed.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import type { Result } from "@sdxc/result";
10
+ import type { ChangelogEntry } from "./changelog.js";
11
+ /** Where one published file of a version is served, `<PACKAGE_FILES>/<name>@<version>/<file>`. */
12
+ export declare const PACKAGE_FILES = "https://unpkg.com";
13
+ /**
14
+ * The package that marks each release and carries its changelog: every release that ships
15
+ * anything ships it, so its versions are exactly the release dates.
16
+ */
17
+ export declare const RELEASE_PACKAGE = "@sdxc/kit";
18
+ /** A published release. */
19
+ export interface Release {
20
+ version: string;
21
+ /** The exact `remix` version the release pins as its peer, `null` when it declares none. */
22
+ remix: string | null;
23
+ }
24
+ /**
25
+ * The release `version` names, or the latest one when it is `null`. A version npm does not
26
+ * have is a failure naming it.
27
+ */
28
+ export declare function fetchRelease(version: string | null, signal?: AbortSignal): Promise<Result<Release, Error>>;
29
+ /**
30
+ * The changelog of the release `version`, read from its `@sdxc/kit` before anything is
31
+ * installed so the upgrade can say what breaks on the way.
32
+ */
33
+ export declare function fetchChangelog(version: string, signal?: AbortSignal): Promise<Result<ChangelogEntry[], Error>>;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The npm registry as `sdxc upgrade` reads it: a release is a published `@sdxc/kit` version,
3
+ * which ships in every release, with the `remix` version it declares as its peer and the
4
+ * changelog it carries, so the bump knows all three before anything is installed.
5
+ *
6
+ * @author [Sergio Xalambrí](https://sergiodxa.com)
7
+ * @copyright Sergio Xalambrí 2026
8
+ */
9
+ import { failure, isFailure, success, wrap } from "@sdxc/result";
10
+ import { fetchPackument } from "../releases.js";
11
+ import { CHANGELOG_FILE, parseChangelog } from "./changelog.js";
12
+ /** Where one published file of a version is served, `<PACKAGE_FILES>/<name>@<version>/<file>`. */
13
+ export const PACKAGE_FILES = "https://unpkg.com";
14
+ /**
15
+ * The package that marks each release and carries its changelog: every release that ships
16
+ * anything ships it, so its versions are exactly the release dates.
17
+ */
18
+ export const RELEASE_PACKAGE = "@sdxc/kit";
19
+ /**
20
+ * The release `version` names, or the latest one when it is `null`. A version npm does not
21
+ * have is a failure naming it.
22
+ */
23
+ export async function fetchRelease(version, signal) {
24
+ let packument = await fetchPackument(RELEASE_PACKAGE, signal);
25
+ if (isFailure(packument))
26
+ return packument;
27
+ let target = version ?? packument.data.latest;
28
+ let peers = target === null ? undefined : packument.data.versions.get(target);
29
+ if (target === null || peers === undefined) {
30
+ return failure(new Error(`Release ${version ?? "latest"} is not published on npm`));
31
+ }
32
+ return success({ version: target, remix: peers.remix ?? null });
33
+ }
34
+ /**
35
+ * The changelog of the release `version`, read from its `@sdxc/kit` before anything is
36
+ * installed so the upgrade can say what breaks on the way.
37
+ */
38
+ export async function fetchChangelog(version, signal) {
39
+ let url = `${PACKAGE_FILES}/${RELEASE_PACKAGE}@${encodeURIComponent(version)}/${CHANGELOG_FILE}`;
40
+ let response = await wrap(() => fetch(url, { signal }));
41
+ if (isFailure(response))
42
+ return response;
43
+ if (!response.data.ok) {
44
+ return failure(new Error(`${url} answered ${response.data.status}`));
45
+ }
46
+ let text = await wrap(() => response.data.text());
47
+ if (isFailure(text))
48
+ return text;
49
+ return parseChangelog(text.data, url);
50
+ }
@@ -0,0 +1,60 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "description": "One line of the sdxc lock file, which the CLI writes and the project commits",
4
+ "type": "object",
5
+ "properties": {
6
+ "kind": {
7
+ "type": "string",
8
+ "description": "The command group that owns the entry"
9
+ },
10
+ "name": {
11
+ "type": "string",
12
+ "description": "The entry's identity within its kind"
13
+ }
14
+ },
15
+ "required": ["kind", "name"],
16
+ "anyOf": [
17
+ {
18
+ "type": "object",
19
+ "properties": {
20
+ "kind": {
21
+ "type": "string",
22
+ "const": "ui",
23
+ "description": "The command group that owns the entry"
24
+ },
25
+ "name": {
26
+ "type": "string",
27
+ "pattern": "^[a-z0-9][a-z0-9-]*$",
28
+ "description": "The component, as `@sdxc/ui/<name>` imports it"
29
+ },
30
+ "release": {
31
+ "type": "string",
32
+ "description": "The release the copy came from"
33
+ },
34
+ "files": {
35
+ "type": "object",
36
+ "additionalProperties": {
37
+ "type": "string",
38
+ "pattern": "^sha256-[A-Za-z0-9+/]+={0,2}$"
39
+ },
40
+ "propertyNames": {
41
+ "type": "string",
42
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$"
43
+ },
44
+ "description": "Each file written, relative to `ui.directory`, to the hash of its content"
45
+ }
46
+ },
47
+ "required": ["kind", "name", "release", "files"],
48
+ "additionalProperties": false
49
+ },
50
+ {
51
+ "properties": {
52
+ "kind": {
53
+ "type": "string",
54
+ "pattern": "^(?!ui$)"
55
+ }
56
+ },
57
+ "description": "An entry of a kind this release does not define, kept as written"
58
+ }
59
+ ]
60
+ }
package/package.json CHANGED
@@ -1,6 +1,45 @@
1
1
  {
2
- "name": "@sdxc/kit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@sdxc/kit",
3
+ "version": "2026.10.17",
4
+ "description": "The sdxc command line: start a Remix v3 app, generate its files, copy UI components into it and upgrade it",
5
+ "license": "MIT",
6
+ "bin": {
7
+ "sdxc": "dist/bin.js"
8
+ },
9
+ "type": "module",
10
+ "exports": {
11
+ ".": "./dist/cli.js",
12
+ "./config.schema.json": "./config.schema.json",
13
+ "./lock.schema.json": "./lock.schema.json"
14
+ },
15
+ "dependencies": {
16
+ "@sdxc/cli": "2026.10.16",
17
+ "@sdxc/codemod": "2026.10.17",
18
+ "@sdxc/json-schema": "2026.10.16",
19
+ "@sdxc/jsonc": "2026.10.16",
20
+ "@sdxc/jsonl": "2026.10.16",
21
+ "@sdxc/result": "2026.10.13",
22
+ "@sdxc/semver": "2026.10.13"
23
+ },
24
+ "peerDependencies": {
25
+ "remix": "3.0.0"
26
+ },
27
+ "gitHead": "4f4bce453e9afe69f53194368af9e9739d73a876",
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/sergiodxa/monorepo.git",
34
+ "directory": "packages/kit"
35
+ },
36
+ "homepage": "https://sdxc.dev/api/kit",
37
+ "author": {
38
+ "name": "Sergio Xalambrí",
39
+ "url": "https://sergiodxa.com"
40
+ },
41
+ "funding": {
42
+ "type": "github",
43
+ "url": "https://github.com/sponsors/sergiodxa"
44
+ }
45
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "accordion",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [
5
+ "disclosure"
6
+ ],
7
+ "exports": [
8
+ "Accordion"
9
+ ],
10
+ "source": {
11
+ "path": "accordion.tsx",
12
+ "content": "/**\n * A set of expand/collapse sections built on {@link Disclosure}, stacked into\n * one divider-separated list. Each section holds its state on its native\n * `<details>` element; giving sibling {@link Accordion.Item}s the same `name`\n * makes the set exclusive through the platform's `<details name>` behavior,\n * closing whichever section was open as another opens.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { bg, borderEdge, fg } from \"@sdxc/u/color\";\nimport { opacity, rounded, transition, transitionDuration } from \"@sdxc/u/effects\";\nimport { justify, shrink } from \"@sdxc/u/layout\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { bs, is, pb, pbe, pi } from \"@sdxc/u/size\";\nimport { hover, open, when } from \"@sdxc/u/state\";\nimport { rotate } from \"@sdxc/u/transform\";\nimport { pretty, text, textDecoration } from \"@sdxc/u/typography\";\n\nimport { Disclosure } from \"@sdxc/ui/disclosure\";\n\n/**\n * Prop types for {@link Accordion} and its compound parts.\n */\nexport namespace Accordion {\n\t/**\n\t * Props accepted by {@link Accordion}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** One or more {@link Accordion.Item} sections to stack into a list. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every prop {@link Disclosure.Props} accepts, unchanged: the section's\n\t * `open` state and, when set to the same value across siblings, the\n\t * `name` that makes the group exclusive.\n\t */\n\texport interface ItemProps extends Disclosure.Props {}\n\n\t/** Every prop {@link Disclosure.TriggerProps} accepts, unchanged. */\n\texport interface TriggerProps extends Disclosure.TriggerProps {}\n\n\t/** Every prop {@link Disclosure.PanelProps} accepts, unchanged. */\n\texport interface ContentProps extends Disclosure.PanelProps {}\n}\n\n/**\n * Renders the list's root host: a plain `<div>` that stacks\n * {@link Accordion.Item} sections in normal block flow, each drawing its own\n * divider so the whole list reads as one continuous group.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the list's markup.\n * @example\n * <Accordion>\n * \t<Accordion.Item>\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.refunds.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * \t<Accordion.Item>\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.shipping.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.shipping.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * </Accordion>\n * @example\n * <Accordion>\n * \t<Accordion.Item name=\"faq\" open>\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.refunds.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * \t<Accordion.Item name=\"faq\">\n * \t\t<Accordion.Trigger>\n * \t\t\t{t(\"faq.shipping.question\")}\n * \t\t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t\t</Accordion.Trigger>\n * \t\t<Accordion.Content>\n * \t\t\t<p>{t(\"faq.shipping.answer\")}</p>\n * \t\t</Accordion.Content>\n * \t</Accordion.Item>\n * </Accordion>\n */\nexport function Accordion(handle: Handle<Accordion.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div {...rest} mix={[is(\"full\"), mix]}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n}\n\n/**\n * Renders one section as {@link Disclosure} restyled into a flush list row:\n * only a shared block-end divider survives, restored block-start on the first\n * section. A trigger marked `aria-disabled=\"true\"` dims the whole section.\n *\n * @param handle Runtime handle carrying the host `<details>`'s props.\n * @returns The render function producing the section's markup.\n * @example\n * <Accordion.Item>\n * \t<Accordion.Trigger>\n * \t\t{t(\"faq.refunds.question\")}\n * \t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t</Accordion.Trigger>\n * \t<Accordion.Content>\n * \t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t</Accordion.Content>\n * </Accordion.Item>\n * @example\n * <Accordion.Item name=\"faq\" open>\n * \t<Accordion.Trigger>\n * \t\t{t(\"faq.refunds.question\")}\n * \t\t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * \t</Accordion.Trigger>\n * \t<Accordion.Content>\n * \t\t<p>{t(\"faq.refunds.answer\")}</p>\n * \t</Accordion.Content>\n * </Accordion.Item>\n */\nAccordion.Item = function AccordionItem(handle: Handle<Accordion.ItemProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Disclosure\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\tborderEdge(\"inline-start\", { width: \"0\", noStyleDefault: true }),\n\t\t\t\t\tborderEdge(\"inline-end\", { width: \"0\", noStyleDefault: true }),\n\t\t\t\t\tborderEdge(\"block-start\", { width: \"0\", noStyleDefault: true }),\n\t\t\t\t\topen(when('& summary [data-slot=\"icon\"]', rotate(180))),\n\t\t\t\t\twhen(\"&:first-child\", borderEdge(\"block-start\", { width: 1 })),\n\t\t\t\t\twhen('&:has(> summary[aria-disabled=\"true\"])', opacity(50)),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Accordion.TriggerProps.children} as the section's label row,\n * spread to opposite ends and underlined on hover. An icon element carrying\n * `data-slot=\"icon\"` rotates 180 degrees while its section is open.\n *\n * @param handle Runtime handle carrying the host `<summary>`'s props.\n * @returns The render function producing the label row's markup.\n * @example\n * <Accordion.Trigger>\n * \t{t(\"faq.refunds.question\")}\n * \t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * </Accordion.Trigger>\n * @example\n * <Accordion.Trigger aria-disabled=\"true\">\n * \t{t(\"faq.archived.question\")}\n * \t<ChevronDownIcon data-slot=\"icon\" aria-hidden />\n * </Accordion.Trigger>\n */\nAccordion.Trigger = function AccordionTrigger(handle: Handle<Accordion.TriggerProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Disclosure.Trigger\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tjustify(\"between\"),\n\t\t\t\t\tpb(4),\n\t\t\t\t\tpi(0),\n\t\t\t\t\trounded(\"none\"),\n\t\t\t\t\thover([bg(\"transparent\"), textDecoration(\"underline\")]),\n\t\t\t\t\twhen('& [data-slot=\"icon\"]', [\n\t\t\t\t\t\tis(4),\n\t\t\t\t\t\tbs(4),\n\t\t\t\t\t\tshrink(),\n\t\t\t\t\t\ttransition(\"transform\", { duration: \"200ms\" }),\n\t\t\t\t\t]),\n\t\t\t\t\tmedia(\n\t\t\t\t\t\t\"(prefers-reduced-motion: reduce)\",\n\t\t\t\t\t\twhen('& [data-slot=\"icon\"]', transitionDuration(\"0s\")),\n\t\t\t\t\t),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Accordion.ContentProps.children} as the section's revealed body:\n * {@link Disclosure.Panel} running edge to edge like its trigger, with block-end\n * padding and small, muted text sized for supporting copy.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the body's markup.\n * @example\n * <Accordion.Content>\n * \t<p>{t(\"faq.refunds.answer\")}</p>\n * </Accordion.Content>\n */\nAccordion.Content = function AccordionContent(handle: Handle<Accordion.ContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Disclosure.Panel {...rest} mix={[pi(0), pbe(4), fg(\"neutral\"), text(\"sm\"), pretty(), mix]} />\n\t\t);\n\t};\n};\n"
13
+ },
14
+ "test": null
15
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "alert-dialog",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [
5
+ "button",
6
+ "dialog",
7
+ "heading-scope"
8
+ ],
9
+ "exports": [
10
+ "AlertDialog"
11
+ ],
12
+ "source": {
13
+ "path": "alert-dialog.tsx",
14
+ "content": "/**\n * An interruptive modal surface that demands an explicit response before a\n * page continues — confirming a destructive action, surfacing a blocking\n * error — built on the native `<dialog>` host of {@link Dialog}, widened for\n * its two-button layout and sealed against light dismiss. Its compound parts\n * cover a header, title, description, and a two-control footer.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { fg } from \"@sdxc/u/color\";\nimport { flex, gap, justify, vstack } from \"@sdxc/u/layout\";\nimport { mbs } from \"@sdxc/u/size\";\nimport { balance, pretty, text, weight } from \"@sdxc/u/typography\";\n\nimport { Button } from \"@sdxc/ui/button\";\nimport { Dialog } from \"@sdxc/ui/dialog\";\nimport { resolveHeadingLevel, TAG_BY_LEVEL } from \"@sdxc/ui/heading-scope\";\n\n/**\n * Invoker Commands verb {@link AlertDialog.Action} and\n * {@link AlertDialog.Cancel} fall back to when `command` is omitted,\n * dismissing the ancestor AlertDialog named by `commandfor`.\n */\nconst DEFAULT_COMMAND = \"close\";\n\n/**\n * Native `button` `type` {@link AlertDialog.Action} and\n * {@link AlertDialog.Cancel} always spell out, since the platform runs an\n * Invoker Command only from a button typed `\"button\"`, `<form>` or not.\n */\nconst DEFAULT_TYPE: NonNullable<Button.Props[\"type\"]> = \"button\";\n\n/** Semantic color role {@link AlertDialog.Action} falls back to when `color` is omitted. */\nconst DEFAULT_ACTION_COLOR: Button.Color = \"danger\";\n\n/** Visual weight {@link AlertDialog.Cancel} falls back to when `variant` is omitted. */\nconst DEFAULT_CANCEL_VARIANT: Button.Variant = \"outline\";\n\n/** Semantic color role {@link AlertDialog.Cancel} falls back to when `color` is omitted. */\nconst DEFAULT_CANCEL_COLOR: Button.Color = \"neutral\";\n\n/**\n * Prop types for {@link AlertDialog} and its compound parts.\n */\nexport namespace AlertDialog {\n\t/**\n\t * Every prop {@link Dialog} accepts, minus the ones this component fixes:\n\t * `role` is always `\"alertdialog\"` and `closedby`/`closedBy` always\n\t * `\"closerequest\"`, so the panel closes only on an explicit close request.\n\t */\n\texport interface Props extends Omit<Dialog.Props, \"role\" | \"closedby\" | \"closedBy\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Header}.\n\t */\n\texport interface HeaderProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Title}. Every native heading-element\n\t * attribute applies, since the rendered tag follows the nearest ambient\n\t * heading level, falling back to `<h1>`.\n\t */\n\texport interface TitleProps extends TagProps<\"h1\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Description}.\n\t */\n\texport interface DescriptionProps extends TagProps<\"p\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Footer}.\n\t */\n\texport interface FooterProps extends TagProps<\"div\"> {}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Action}: every {@link Button.Props}\n\t * field except `commandfor`/`command`, which this type narrows.\n\t */\n\texport interface ActionProps extends Omit<Button.Props, \"commandfor\" | \"command\"> {\n\t\t/**\n\t\t * `id` of the ancestor {@link AlertDialog} this action dismisses.\n\t\t * Required for the default `type=\"button\"` action; a `type=\"submit\"`\n\t\t * action ends the interruption by submitting its enclosing form.\n\t\t */\n\t\tcommandfor?: string;\n\t\t/**\n\t\t * Invoker Commands verb dispatched to the target AlertDialog. Defaults\n\t\t * to `\"close\"`, and is dropped for a `\"submit\"` or `\"reset\"` action,\n\t\t * which the platform drives as a form control instead of an invoker.\n\t\t */\n\t\tcommand?: \"close\";\n\t}\n\n\t/**\n\t * Props accepted by {@link AlertDialog.Cancel}: every {@link Button.Props}\n\t * field except `commandfor`/`command`/`type`, which this type narrows.\n\t */\n\texport interface CancelProps extends Omit<Button.Props, \"commandfor\" | \"command\" | \"type\"> {\n\t\t/** `id` of the ancestor {@link AlertDialog} this cancel control dismisses. */\n\t\tcommandfor: string;\n\t\t/** Invoker Commands verb dispatched to the target AlertDialog. Defaults to `\"close\"`. */\n\t\tcommand?: \"close\";\n\t\t/**\n\t\t * Narrowed to the only value a cancel control carries, and always\n\t\t * rendered, since the platform runs its close command only from a\n\t\t * button typed `\"button\"`, including inside a `<form>`.\n\t\t */\n\t\ttype?: \"button\";\n\t}\n}\n\n/**\n * Renders the alert panel through {@link Dialog}, widened to fit a two-button\n * footer, with `role` fixed to `\"alertdialog\"` and `closedby` to\n * `\"closerequest\"` so the interruption clears through an explicit response.\n *\n * @param handle Runtime handle carrying the host `<dialog>`'s props.\n * @returns The render function producing the panel's markup.\n * @example\n * <Button commandfor=\"delete-project\" command=\"show-modal\" color=\"danger\">{t(\"project.delete\")}</Button>\n * <AlertDialog id=\"delete-project\" aria-labelledby=\"delete-project-title\">\n * \t<AlertDialog.Header>\n * \t\t<AlertDialog.Title id=\"delete-project-title\">{t(\"project.deleteTitle\")}</AlertDialog.Title>\n * \t\t<AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n * \t</AlertDialog.Header>\n * \t<AlertDialog.Footer>\n * \t\t<AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n * \t\t<AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * \t</AlertDialog.Footer>\n * </AlertDialog>\n */\nexport function AlertDialog(handle: Handle<AlertDialog.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<Dialog {...rest} role=\"alertdialog\" closedby=\"closerequest\" mix={mix}>\n\t\t\t\t{children}\n\t\t\t</Dialog>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link AlertDialog.HeaderProps.children} as the panel's header\n * slot: a column stacking {@link AlertDialog.Title} and\n * {@link AlertDialog.Description} with a small gap between them.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the header slot's markup.\n * @example\n * <AlertDialog.Header>\n * \t<AlertDialog.Title>{t(\"project.deleteTitle\")}</AlertDialog.Title>\n * \t<AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n * </AlertDialog.Header>\n */\nAlertDialog.Header = function AlertDialogHeader(handle: Handle<AlertDialog.HeaderProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"header\" mix={[vstack({ gap: 2 }), mix]} />;\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.TitleProps.children} as the panel's heading,\n * inside the native heading element matching the nearest ancestor\n * `HeadingScope`'s depth, or `<h1>` where no scope wraps it.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the heading's markup.\n * @example\n * <AlertDialog.Title>{t(\"project.deleteTitle\")}</AlertDialog.Title>\n */\nAlertDialog.Title = function AlertDialogTitle(handle: Handle<AlertDialog.TitleProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\t\tlet resolved = resolveHeadingLevel(handle);\n\t\tlet Tag = TAG_BY_LEVEL[resolved];\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"title\"\n\t\t\t\tmix={[fg(\"neutral.emphasis\"), weight(\"semibold\"), text(\"lg\"), balance(), mix]}\n\t\t\t>\n\t\t\t\t{rest.children}\n\t\t\t</Tag>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.DescriptionProps.children} as the panel's\n * supporting copy, in a native `<p>` set to the panel's muted foreground\n * color so it reads as secondary to {@link AlertDialog.Title}.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the description's markup.\n * @example\n * <AlertDialog.Description>{t(\"project.deleteDescription\")}</AlertDialog.Description>\n */\nAlertDialog.Description = function AlertDialogDescription(\n\thandle: Handle<AlertDialog.DescriptionProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<p {...rest} data-slot=\"description\" mix={[fg(\"neutral.muted\"), text(\"sm\"), pretty(), mix]}>\n\t\t\t\t{rest.children}\n\t\t\t</p>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link AlertDialog.FooterProps.children} as an end-aligned action\n * row. Compose {@link AlertDialog.Cancel} before {@link AlertDialog.Action}\n * so the emphasized, potentially destructive control renders last.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the action row's markup.\n * @example\n * <AlertDialog.Footer>\n * \t<AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n * \t<AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * </AlertDialog.Footer>\n */\nAlertDialog.Footer = function AlertDialogFooter(handle: Handle<AlertDialog.FooterProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <div {...rest} data-slot=\"footer\" mix={[gap(2), mbs(6), flex(), justify(\"end\"), mix]} />;\n\t};\n};\n\n/**\n * Renders the panel's emphasized action as a danger-toned {@link Button},\n * typed `\"button\"` so its `command=\"close\"` reaches the {@link AlertDialog}\n * named by `commandfor`; `type=\"submit\"` submits the enclosing form instead.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the action's markup.\n * @example\n * <AlertDialog.Action commandfor=\"delete-project\">{t(\"actions.delete\")}</AlertDialog.Action>\n * @example\n * <AlertDialog.Action commandfor=\"publish-post\" color=\"brand\">{t(\"actions.publish\")}</AlertDialog.Action>\n * @example\n * <AlertDialog.Action type=\"submit\" name=\"intent\" value=\"delete\">{t(\"actions.delete\")}</AlertDialog.Action>\n */\nAlertDialog.Action = function AlertDialogAction(handle: Handle<AlertDialog.ActionProps>) {\n\treturn () => {\n\t\tlet { type, color, command, commandfor, ...rest } = handle.props;\n\t\tlet resolvedType = type ?? DEFAULT_TYPE;\n\t\tlet isInvoker = resolvedType === \"button\";\n\t\tlet resolvedColor = color ?? DEFAULT_ACTION_COLOR;\n\n\t\tif (import.meta.env.DEV && isInvoker && !commandfor) {\n\t\t\tconsole.warn(\n\t\t\t\t'AlertDialog.Action: needs \"commandfor\" naming the panel it dismisses, or type=\"submit\" to submit its enclosing form instead — as rendered, pressing it does nothing.',\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype={resolvedType}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tcommandfor={isInvoker ? commandfor : undefined}\n\t\t\t\tcommand={isInvoker ? (command ?? DEFAULT_COMMAND) : undefined}\n\t\t\t\tdata-slot=\"action\"\n\t\t\t/>\n\t\t);\n\t};\n};\n\n/**\n * Renders the panel's dismiss control as an outline, neutral {@link Button}\n * with `type` fixed to `\"button\"`, so its `command=\"close\"` reaches the\n * {@link AlertDialog} named by `commandfor` from inside a `<form>` too.\n *\n * @param handle Runtime handle carrying the host button's props.\n * @returns The render function producing the cancel control's markup.\n * @example\n * <AlertDialog.Cancel commandfor=\"delete-project\">{t(\"actions.cancel\")}</AlertDialog.Cancel>\n */\nAlertDialog.Cancel = function AlertDialogCancel(handle: Handle<AlertDialog.CancelProps>) {\n\treturn () => {\n\t\tlet { variant, color, command, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_CANCEL_VARIANT;\n\t\tlet resolvedColor = color ?? DEFAULT_CANCEL_COLOR;\n\t\tlet resolvedCommand = command ?? DEFAULT_COMMAND;\n\n\t\treturn (\n\t\t\t<Button\n\t\t\t\t{...rest}\n\t\t\t\ttype={DEFAULT_TYPE}\n\t\t\t\tvariant={resolvedVariant}\n\t\t\t\tcolor={resolvedColor}\n\t\t\t\tcommand={resolvedCommand}\n\t\t\t\tdata-slot=\"cancel\"\n\t\t\t/>\n\t\t);\n\t};\n};\n"
15
+ },
16
+ "test": {
17
+ "path": "alert-dialog.test.tsx",
18
+ "content": "/**\n * Tests for {@link AlertDialog}'s two footer controls: both render an explicit\n * `type=\"button\"` ahead of their command attributes, which is what lets the\n * platform run their Invoker Command inside a `<form>`, and an action asked to\n * submit renders as a plain submit button.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport { renderToString } from \"remix/component/server\";\nimport { describe, expect, test } from \"vitest\";\n\nimport { AlertDialog } from \"@sdxc/ui/alert-dialog\";\n\ndescribe(\"AlertDialog.Cancel\", () => {\n\ttest('renders an explicit type=\"button\" so its close command survives inside a form', async () => {\n\t\tlet html = await renderToString(\n\t\t\t<AlertDialog.Cancel commandfor=\"delete-project\">Cancel</AlertDialog.Cancel>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"button\"');\n\t\texpect(html).toContain('command=\"close\"');\n\t\texpect(html).toContain('commandfor=\"delete-project\"');\n\t});\n\n\ttest(\"writes that type before the command attributes, where the platform reads it\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<AlertDialog.Cancel commandfor=\"delete-project\">Cancel</AlertDialog.Cancel>,\n\t\t);\n\n\t\texpect(html.indexOf('type=\"button\"')).toBeLessThan(html.indexOf(\"commandfor=\"));\n\t\texpect(html.indexOf('type=\"button\"')).toBeLessThan(html.indexOf(\"command=\"));\n\t});\n\n\ttest('keeps type=\"button\" even when a consumer passes it explicitly', async () => {\n\t\tlet html = await renderToString(\n\t\t\t<AlertDialog.Cancel commandfor=\"delete-project\" type=\"button\">\n\t\t\t\tCancel\n\t\t\t</AlertDialog.Cancel>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"button\"');\n\t\texpect(html).not.toContain('type=\"submit\"');\n\t});\n});\n\ndescribe(\"AlertDialog.Action\", () => {\n\ttest('renders an explicit type=\"button\" alongside its close command', async () => {\n\t\tlet html = await renderToString(\n\t\t\t<AlertDialog.Action commandfor=\"delete-project\">Delete</AlertDialog.Action>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"button\"');\n\t\texpect(html).toContain('command=\"close\"');\n\t});\n\n\ttest(\"submits its enclosing form, and renders no command at all, when asked to\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<AlertDialog.Action type=\"submit\" name=\"intent\" value=\"delete\">\n\t\t\t\tDelete\n\t\t\t</AlertDialog.Action>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"submit\"');\n\t\texpect(html).toContain('name=\"intent\"');\n\t\texpect(html).not.toContain(\"command=\");\n\t\texpect(html).not.toContain(\"commandfor=\");\n\t});\n\n\ttest(\"drops a command a submitting action was passed anyway, since the platform would refuse it\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<AlertDialog.Action type=\"submit\" commandfor=\"delete-project\" command=\"close\">\n\t\t\t\tDelete\n\t\t\t</AlertDialog.Action>,\n\t\t);\n\n\t\texpect(html).toContain('type=\"submit\"');\n\t\texpect(html).not.toContain(\"command=\");\n\t\texpect(html).not.toContain(\"commandfor=\");\n\t});\n});\n"
19
+ }
20
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "alert",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [
5
+ "heading-scope"
6
+ ],
7
+ "exports": [
8
+ "Alert"
9
+ ],
10
+ "source": {
11
+ "path": "alert.tsx",
12
+ "content": "/**\n * An inline status message rendered as a bordered, tinted panel, colored by\n * one of five semantic tones and announced to assistive technology through\n * `role=\"alert\"` plus a configurable `aria-live` politeness. Compound parts\n * cover an optional leading icon, a title/description content block, and a\n * trailing action, so a page composes only the parts a given message needs.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps, RemixNode } from \"remix/component\";\n\nimport { border, colorMix, fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { absolute, basis, gap, grow, inset, relative, self, shrink, vstack } from \"@sdxc/u/layout\";\nimport { bs, is, mbe, minIs, p, pis } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { balance, fontSize, leading, pretty, tracking, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { semanticColorPanel } from \"@sdxc/ui/styles\";\nimport { DEFAULT_ICON_ARIA_HIDDEN } from \"@sdxc/ui/utils\";\n\nimport { resolveHeadingLevel, TAG_BY_LEVEL } from \"@sdxc/ui/heading-scope\";\n\n/**\n * `role=\"alert\"` applied through {@link attrs} unless a consumer supplies\n * its own `role`, keeping the panel announced as an ARIA alert by default.\n */\nconst DEFAULT_ROLE = \"alert\";\n\n/**\n * Default {@link Alert.Props.color}, rendering an alert with the neutral\n * tone when a consumer names no semantic color.\n */\nconst DEFAULT_COLOR = \"neutral\";\n\n/**\n * Default {@link Alert.Props.live}, announcing an alert's content politely so\n * assistive technology finishes its current utterance first.\n */\nconst DEFAULT_LIVE = \"polite\";\n\n/**\n * `aria-atomic=\"true\"` applied through {@link attrs} unless a consumer\n * overrides it, so assistive technology re-reads the whole alert on update.\n */\nconst DEFAULT_ARIA_ATOMIC = \"true\";\n\n/**\n * Prop types for {@link Alert} and its compound parts.\n */\nexport namespace Alert {\n\t/**\n\t * Semantic tone driving the host element's border, tint, and foreground\n\t * color through the `--ui-*` variables for that color.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * `aria-live` politeness applied to the host element. `\"off\"` omits the\n\t * `aria-live` attribute, leaving the element's implicit live-region\n\t * behavior in place.\n\t */\n\texport type Live = \"polite\" | \"assertive\" | \"off\";\n\n\t/**\n\t * Props accepted by {@link Alert}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Semantic tone of the alert. Default: `\"neutral\"`. */\n\t\tcolor?: Color;\n\t\t/** `aria-live` politeness for dynamic alerts. Default: `\"polite\"`. */\n\t\tlive?: Live;\n\t\t/** The alert's compound parts: {@link Alert.Icon}, {@link Alert.Content}, {@link Alert.Action}, or any other content. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Alert.Icon}.\n\t */\n\texport interface IconProps extends TagProps<\"div\"> {\n\t\t/** The icon graphic, typically a single SVG icon. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Alert.Content}.\n\t */\n\texport interface ContentProps extends TagProps<\"div\"> {\n\t\t/** The alert's title, description, or other body content. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Alert.Title}. Every native heading-element\n\t * attribute applies, since the rendered tag follows the nearest ambient\n\t * heading level, falling back to `<h1>`.\n\t */\n\texport interface TitleProps extends TagProps<\"h1\"> {\n\t\t/** The alert's heading text. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Alert.Description}.\n\t */\n\texport interface DescriptionProps extends TagProps<\"p\"> {\n\t\t/** The alert's supporting message text. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Alert.Action}.\n\t */\n\texport interface ActionProps extends TagProps<\"div\"> {\n\t\t/** A button, link, or other control the alert offers, e.g. \"Retry\" or \"Dismiss\". */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders an inline status panel tinted by {@link Alert.Props.color}, gaining\n * inline-start padding through `:has()` when a direct {@link Alert.Icon}\n * needs the room. `role`, `aria-atomic`, and `aria-live` stay overridable.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the alert's markup.\n * @example\n * <Alert color=\"danger\">\n * <Alert.Icon><CircleAlertIcon /></Alert.Icon>\n * <Alert.Content>\n * <Alert.Title>{t(\"alerts.paymentFailed.title\")}</Alert.Title>\n * <Alert.Description>{t(\"alerts.paymentFailed.description\")}</Alert.Description>\n * </Alert.Content>\n * <Alert.Action>\n * <Button size=\"sm\">{t(\"alerts.paymentFailed.retry\")}</Button>\n * </Alert.Action>\n * </Alert>\n * @example\n * <Alert color=\"success\" live=\"assertive\">\n * <Alert.Content>\n * <Alert.Title>{t(\"alerts.saved.title\")}</Alert.Title>\n * </Alert.Content>\n * </Alert>\n */\nexport function Alert(handle: Handle<Alert.Props>) {\n\treturn () => {\n\t\tlet {\n\t\t\tcolor = DEFAULT_COLOR,\n\t\t\tlive = DEFAULT_LIVE,\n\t\t\t\"aria-live\": ariaLiveProp,\n\t\t\tchildren,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet ariaLive = ariaLiveProp ?? (live === \"off\" ? undefined : live);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\taria-live={ariaLive}\n\t\t\t\tdata-color={color}\n\t\t\t\tdata-slot=\"alert\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_ROLE, \"aria-atomic\": DEFAULT_ARIA_ATOMIC }),\n\t\t\t\t\tsemanticColorPanel(),\n\t\t\t\t\trelative(),\n\t\t\t\t\tvstack({ align: \"start\" }),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\tgap(3),\n\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\tborder({ width: 1 }),\n\t\t\t\t\tp(4),\n\t\t\t\t\twhen('&:has(> [data-slot=\"icon\"])', pis(10)),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link Alert.IconProps.children} as the alert's leading icon,\n * absolutely positioned at the panel's inline/block-start corner with any\n * direct SVG sized to `1rem`. Decorative, since the text carries the meaning.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the icon's markup.\n */\nAlert.Icon = function AlertIcon(handle: Handle<Alert.IconProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"icon\"\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ICON_ARIA_HIDDEN }),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tinset(4, \"auto\", \"auto\", 4),\n\t\t\t\t\twhen(\"& > svg\", [is(4), bs(4)]),\n\t\t\t\t\tfg(\"currentcolor\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Alert.ContentProps.children} as the alert's body block: a\n * column flex container that shrinks to fit alongside a leading icon or\n * trailing action, holding {@link Alert.Title} and {@link Alert.Description}.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the content block's markup.\n */\nAlert.Content = function AlertContent(handle: Handle<Alert.ContentProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"content\"\n\t\t\t\tmix={[vstack({ gap: 1 }), minIs(0), grow(), shrink(1), basis(\"0%\"), mix]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Alert.TitleProps.children} as the alert's heading, inside\n * the native heading element matching the nearest ancestor `HeadingScope`'s\n * depth — or `<h1>` where no scope wraps it — styled as a small, tight label.\n *\n * @param handle Runtime handle carrying the host heading element's props.\n * @returns The render function producing the title's markup.\n */\nAlert.Title = function AlertTitle(handle: Handle<Alert.TitleProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\t\tlet resolved = resolveHeadingLevel(handle);\n\t\tlet Tag = TAG_BY_LEVEL[resolved];\n\n\t\treturn (\n\t\t\t<Tag\n\t\t\t\t{...rest}\n\t\t\t\tdata-heading-level={resolved}\n\t\t\t\tdata-slot=\"title\"\n\t\t\t\tmix={[\n\t\t\t\t\tmbe(1),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tleading(1),\n\t\t\t\t\ttracking(\"tight\"),\n\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\tbalance(),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</Tag>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Alert.DescriptionProps.children} as the alert's supporting\n * message, slightly translucent against the alert's foreground color so it\n * reads as secondary to the title. Any nested `<p>` keeps its line height.\n *\n * @param handle Runtime handle carrying the host `<p>`'s props.\n * @returns The render function producing the description's markup.\n */\nAlert.Description = function AlertDescription(handle: Handle<Alert.DescriptionProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<p\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"description\"\n\t\t\t\tmix={[\n\t\t\t\t\tleading(\"relaxed\"),\n\t\t\t\t\twhen(\"& p\", leading(\"relaxed\")),\n\t\t\t\t\tpretty(),\n\t\t\t\t\tfontSize(\"sm\"),\n\t\t\t\t\tfg(colorMix(\"oklab\", { color: \"currentcolor\", weight: 70 }, \"transparent\")),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</p>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Alert.ActionProps.children} as the alert's trailing\n * control — a button, link, or dismiss affordance — pinned to the panel's\n * block-start edge at its own natural size.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the action's markup.\n */\nAlert.Action = function AlertAction(handle: Handle<Alert.ActionProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<div {...rest} data-slot=\"action\" mix={[shrink(), self(\"start\"), mix]}>\n\t\t\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n"
13
+ },
14
+ "test": null
15
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "aspect-ratio",
3
+ "changedIn": "2026.10.2",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "AspectRatio"
7
+ ],
8
+ "source": {
9
+ "path": "aspect-ratio.tsx",
10
+ "content": "/**\n * A layout primitive that locks its host to a fixed width-to-height ratio,\n * clipping whatever content it wraps so the box keeps its shape regardless\n * of the content's own intrinsic size. It reserves stable space for media,\n * embeds, and other loading content ahead of time, so nothing around it\n * shifts once that content resolves its own measurements.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle, Props as TagProps } from \"remix/component\";\n\nimport { var as varUtility, raw } from \"@sdxc/u/general\";\nimport { block } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { is } from \"@sdxc/u/size\";\n\nimport { mergeStyle } from \"@sdxc/ui/utils\";\n\nconst DEFAULT_RATIO: AspectRatio.Ratio = \"1 / 1\";\n\n/**\n * Prop types for {@link AspectRatio}.\n */\nexport namespace AspectRatio {\n\t/**\n\t * A CSS `aspect-ratio` value: a bare number of width divided by height\n\t * (`1.7778` for a 16:9 box), or a ratio string CSS accepts directly\n\t * (`\"16 / 9\"`).\n\t */\n\texport type Ratio = number | string;\n\n\t/**\n\t * Props accepted by {@link AspectRatio}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Width-to-height ratio the host maintains. Defaults to a square. */\n\t\tratio?: Ratio;\n\t}\n}\n\n/**\n * Fills its container's inline axis and clips any overflow. The ratio rides on\n * the `--ui-aspect-ratio` custom property, set per instance from the `ratio`\n * prop, so an ancestor's stylesheet can override it on its own.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the ratio-locked box's markup.\n * @example\n * <AspectRatio ratio=\"16 / 9\">\n * \t<img src={coverImageUrl} alt={coverImageAlt} />\n * </AspectRatio>\n * @example\n * <AspectRatio ratio={4 / 3} />\n */\nexport function AspectRatio(handle: Handle<AspectRatio.Props>) {\n\treturn () => {\n\t\tlet { ratio, mix, style, ...rest } = handle.props;\n\t\tlet resolvedRatio = ratio ?? DEFAULT_RATIO;\n\t\tlet resolvedStyle = mergeStyle(style, { \"--ui-aspect-ratio\": resolvedRatio });\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tstyle={resolvedStyle}\n\t\t\t\tmix={[\n\t\t\t\t\tblock(),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\toverflow(),\n\t\t\t\t\traw({ aspectRatio: varUtility(\"ui-aspect-ratio\", \"1\") }),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
11
+ },
12
+ "test": null
13
+ }