@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,20 @@
1
+ {
2
+ "name": "heading-scope",
3
+ "changedIn": "2026.10.2",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "HeadingLevel",
7
+ "TAG_BY_LEVEL",
8
+ "HeadingScope",
9
+ "readAmbientLevel",
10
+ "resolveHeadingLevel"
11
+ ],
12
+ "source": {
13
+ "path": "heading-scope.tsx",
14
+ "content": "/**\n * Establishes an ambient heading level read by nested headings and scopes,\n * keeping a document outline sequential without passing a level by hand.\n * Nesting moves one level deeper unless an explicit `level` fixes it, and\n * renders a `display: contents` host so composing it adds no layout box\n * while still exposing the depth via `data-heading-level`.\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 { contents } from \"@sdxc/u/layout\";\n\n/**\n * Semantic depth, from `1` (`<h1>`) through `6` (`<h6>`), shared by every\n * heading-related component's level resolution.\n */\nexport type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;\n\n/**\n * Native tag rendered for each supported {@link HeadingLevel}, as a single\n * level-to-element lookup table.\n */\nexport const TAG_BY_LEVEL: Record<HeadingLevel, \"h1\" | \"h2\" | \"h3\" | \"h4\" | \"h5\" | \"h6\"> = {\n\t1: \"h1\",\n\t2: \"h2\",\n\t3: \"h3\",\n\t4: \"h4\",\n\t5: \"h5\",\n\t6: \"h6\",\n};\n\nconst DEFAULT_LEVEL: HeadingLevel = 1;\n\n/** Deepest semantic depth the native heading elements support; a resolution past this clamps down to it. */\nconst MAX_LEVEL: HeadingLevel = 6;\n\n/**\n * Prop and context types for {@link HeadingScope}.\n */\nexport namespace HeadingScope {\n\t/** Value {@link HeadingScope} provides to descendants through context. */\n\texport interface Context {\n\t\t/** Semantic depth this scope establishes for the headings and nested scopes rendered inside it. */\n\t\tlevel: HeadingLevel;\n\t}\n\n\t/**\n\t * Native `<div>` attributes, plus `mix` and an optional `level` that\n\t * fixes this scope's depth outright, overriding the ambient\n\t * one-level-deeper default.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Explicit semantic depth for this scope. Defaults to one level past\n\t\t * the nearest ancestor scope's depth, or `1` where no scope wraps\n\t\t * this one at all.\n\t\t */\n\t\tlevel?: HeadingLevel;\n\t}\n}\n\n/**\n * Reads the semantic depth from the nearest ancestor {@link HeadingScope},\n * always resolving safely to `undefined` when no ancestor scope exists,\n * regardless of how that absence surfaces.\n *\n * @param handle Runtime handle of the component performing the lookup.\n * @returns The nearest ancestor scope's depth, or `undefined` where nothing wraps the caller.\n * @example\n * let ambient = readAmbientLevel(handle); // 2, nested inside a HeadingScope holding level 2\n */\nexport function readAmbientLevel(handle: Handle<unknown, any>): HeadingLevel | undefined {\n\ttry {\n\t\tlet ambient = handle.context.get(HeadingScope) as HeadingScope.Context | undefined;\n\n\t\treturn ambient?.level;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/**\n * Resolves the semantic depth a heading renders at: an explicit level wins,\n * then the nearest ancestor {@link HeadingScope}'s depth, then `1`, clamped\n * to `6` with a dev-mode warning to flatten or restart the nesting.\n *\n * @param handle Runtime handle of the component resolving its depth.\n * @param explicitLevel A `level` passed directly to the component, if any.\n * @returns The resolved, clamped {@link HeadingLevel}.\n * @example\n * let level = resolveHeadingLevel(handle, handle.props.level); // an explicit level always wins\n */\nexport function resolveHeadingLevel(\n\thandle: Handle<unknown, any>,\n\texplicitLevel?: HeadingLevel,\n): HeadingLevel {\n\tlet resolved: number = explicitLevel ?? readAmbientLevel(handle) ?? DEFAULT_LEVEL;\n\n\tif (resolved > MAX_LEVEL) {\n\t\tif (import.meta.env.DEV) {\n\t\t\tconsole.warn(\n\t\t\t\t`Heading nesting resolved to level ${resolved}, past the native \"h1\"–\"h6\" range. Flatten the nesting, or start a new top-level HeadingScope instead of nesting further.`,\n\t\t\t);\n\t\t}\n\n\t\treturn MAX_LEVEL;\n\t}\n\n\treturn resolved as HeadingLevel;\n}\n\n/**\n * Establishes an ambient heading level for descendants: an explicit `level`\n * fixes it, otherwise one level past the nearest ancestor {@link HeadingScope},\n * read before this scope publishes its own depth, or `1` with no ancestor.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props and providing {@link HeadingScope.Context} to descendants.\n * @returns The render function producing the scope's markup.\n * @example\n * <HeadingScope>\n * \t<Heading>Document title</Heading>\n * \t<HeadingScope>\n * \t\t<Heading>Section title</Heading>\n * \t</HeadingScope>\n * </HeadingScope>\n */\nexport function HeadingScope(handle: Handle<HeadingScope.Props, HeadingScope.Context>) {\n\treturn () => {\n\t\tlet { level, mix, ...rest } = handle.props;\n\t\tlet ambient = readAmbientLevel(handle);\n\t\tlet requested = level ?? (ambient === undefined ? undefined : ((ambient + 1) as HeadingLevel));\n\t\tlet resolved = resolveHeadingLevel(handle, requested);\n\n\t\thandle.context.set({ level: resolved });\n\n\t\treturn <div {...rest} data-heading-level={resolved} mix={[contents(), mix]} />;\n\t};\n}\n"
15
+ },
16
+ "test": {
17
+ "path": "heading-scope.test.ts",
18
+ "content": "/**\n * Unit tests for {@link resolveHeadingLevel} and {@link readAmbientLevel}:\n * pure logic exercised against a minimal `Handle` fixture, with no DOM and\n * no rendered component.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { afterEach, beforeEach, describe, expect, test, vi } from \"vitest\";\n\nimport type { HeadingLevel } from \"@sdxc/ui/heading-scope\";\n\nimport { readAmbientLevel, resolveHeadingLevel } from \"@sdxc/ui/heading-scope\";\n\n/**\n * Minimal `Handle` fixture exposing only `context.get`, matching how this\n * package already unit-tests pure logic without a DOM or a rendered\n * component tree (see `src/behaviors/*.test.ts`).\n */\nfunction stubHandle(get: () => unknown): Handle<unknown> {\n\treturn { context: { set: () => {}, get } } as unknown as Handle<unknown>;\n}\n\nfunction ambientHandle(level: HeadingLevel): Handle<unknown> {\n\treturn stubHandle(() => ({ level }));\n}\n\nfunction unscopedHandle(): Handle<unknown> {\n\treturn stubHandle(() => undefined);\n}\n\n/** Fixture whose `context.get` always throws, simulating a broken lookup. */\nfunction throwingHandle(): Handle<unknown> {\n\treturn stubHandle(() => {\n\t\tthrow new Error(\"lookup failed\");\n\t});\n}\n\ndescribe(resolveHeadingLevel.name, () => {\n\ttest(\"an explicit level always wins, regardless of the ambient value\", () => {\n\t\tlet handle = ambientHandle(5);\n\n\t\texpect(resolveHeadingLevel(handle, 2)).toBe(2);\n\t});\n\n\ttest(\"resolves to 1 when there is no explicit level and no ambient scope\", () => {\n\t\tlet handle = unscopedHandle();\n\n\t\texpect(resolveHeadingLevel(handle, undefined)).toBe(1);\n\t});\n\n\ttest(\"falls back to the ambient level when there is no explicit level\", () => {\n\t\tlet handle = ambientHandle(4);\n\n\t\texpect(resolveHeadingLevel(handle, undefined)).toBe(4);\n\t});\n\n\ttest(\"clamps a resolution past 6 down to 6\", () => {\n\t\tlet handle = ambientHandle(6);\n\n\t\texpect(resolveHeadingLevel(handle, 9 as unknown as HeadingLevel)).toBe(6);\n\t});\n\n\tdescribe(\"dev-only warning\", () => {\n\t\tlet originalDev: string | undefined;\n\t\tlet warnSpy: ReturnType<typeof vi.spyOn>;\n\n\t\tbeforeEach(() => {\n\t\t\toriginalDev = process.env.DEV;\n\t\t\twarnSpy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n\t\t});\n\n\t\tafterEach(() => {\n\t\t\twarnSpy.mockRestore();\n\t\t\tif (originalDev === undefined) delete process.env.DEV;\n\t\t\telse process.env.DEV = originalDev;\n\t\t});\n\n\t\ttest(\"logs once when a resolution clamps past 6 in dev mode\", () => {\n\t\t\tprocess.env.DEV = \"1\";\n\t\t\tlet handle = unscopedHandle();\n\n\t\t\tresolveHeadingLevel(handle, 7 as unknown as HeadingLevel);\n\n\t\t\texpect(warnSpy).toHaveBeenCalledTimes(1);\n\t\t\texpect(String(warnSpy.mock.calls[0]?.[0])).toContain(\"h1\");\n\t\t});\n\n\t\ttest(\"stays silent when a resolution clamps past 6 outside dev mode\", () => {\n\t\t\tdelete process.env.DEV;\n\t\t\tlet handle = unscopedHandle();\n\n\t\t\tresolveHeadingLevel(handle, 7 as unknown as HeadingLevel);\n\n\t\t\texpect(warnSpy).not.toHaveBeenCalled();\n\t\t});\n\n\t\ttest(\"stays silent when a resolution never exceeds 6\", () => {\n\t\t\tprocess.env.DEV = \"1\";\n\t\t\tlet handle = ambientHandle(3);\n\n\t\t\tresolveHeadingLevel(handle, undefined);\n\n\t\t\texpect(warnSpy).not.toHaveBeenCalled();\n\t\t});\n\t});\n});\n\ndescribe(readAmbientLevel.name, () => {\n\ttest(\"returns the ambient level when context.get resolves to a scope value\", () => {\n\t\tlet handle = ambientHandle(3);\n\n\t\texpect(readAmbientLevel(handle)).toBe(3);\n\t});\n\n\ttest(\"returns undefined when context.get resolves to undefined\", () => {\n\t\tlet handle = unscopedHandle();\n\n\t\texpect(readAmbientLevel(handle)).toBeUndefined();\n\t});\n\n\ttest(\"returns undefined, instead of throwing, when context.get throws\", () => {\n\t\tlet handle = throwingHandle();\n\n\t\texpect(() => readAmbientLevel(handle)).not.toThrow();\n\t\texpect(readAmbientLevel(handle)).toBeUndefined();\n\t});\n});\n"
19
+ }
20
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "heading",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [
5
+ "heading-scope"
6
+ ],
7
+ "exports": [
8
+ "Heading"
9
+ ],
10
+ "source": {
11
+ "path": "heading.tsx",
12
+ "content": "/**\n * A section title rendered inside the native heading element matching its\n * semantic depth — `<h1>` through `<h6>` — styled at one fixed emphasis size\n * regardless of which level it renders. An explicit `level` prop fixes the\n * depth outright; otherwise, the nearest ancestor `HeadingScope` supplies\n * it, and a heading with no scope wrapping it at all renders as `<h1>`.\n * Choosing a level changes only the document outline the element contributes to\n * assistive technology; its rendered size stays fixed, so nesting sections\n * correctly never requires a visual trade-off.\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 { balance, fontSize, leading, tracking, weight } from \"@sdxc/u/typography\";\n\nimport type { HeadingLevel } from \"@sdxc/ui/heading-scope\";\n\nimport { resolveHeadingLevel, TAG_BY_LEVEL } from \"@sdxc/ui/heading-scope\";\n\n/**\n * Prop types for {@link Heading}.\n */\nexport namespace Heading {\n\t/**\n\t * Semantic depth, from `1` (`<h1>`) through `6` (`<h6>`), mapped to the\n\t * matching native heading element.\n\t */\n\texport type Level = HeadingLevel;\n\n\t/**\n\t * Every native heading-element attribute, unchanged, plus the `mix`\n\t * passthrough and a `level` prop choosing which native element the\n\t * heading renders as.\n\t */\n\texport interface Props extends TagProps<\"h1\"> {\n\t\t/**\n\t\t * Semantic depth. Defaults to the nearest ancestor `HeadingScope`'s\n\t\t * depth, or `1` where no scope wraps this heading at all.\n\t\t */\n\t\tlevel?: Level;\n\t}\n}\n\n/**\n * Renders its children inside the native heading element matching `level`,\n * styled at one fixed emphasis size — semibold, tight-tracked, and colored for\n * emphasis, with line height collapsed for compact wrapping.\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 * <Heading level={1}>Page title</Heading>\n * @example\n * <Heading>Section title</Heading>\n */\nexport function Heading(handle: Handle<Heading.Props>) {\n\treturn () => {\n\t\tlet { level, mix, ...rest } = handle.props;\n\t\tlet resolved = resolveHeadingLevel(handle, level);\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\tmix={[\n\t\t\t\t\tweight(\"semibold\"),\n\t\t\t\t\ttracking(\"tight\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tfontSize(\"lg\"),\n\t\t\t\t\tleading(\"none\"),\n\t\t\t\t\tbalance(),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
13
+ },
14
+ "test": null
15
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "highlight",
3
+ "changedIn": "2026.10.8",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Highlight"
7
+ ],
8
+ "source": {
9
+ "path": "highlight.tsx",
10
+ "content": "/**\n * Text with the stretches a search matched marked: a run of `{ text, match }` segments\n * rendered as one inline `<span>`, each matched stretch a native `<mark>` tinted through a\n * semantic color role. Segments stay text nodes, so the content is escaped by construction.\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 { bg, fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { raw } from \"@sdxc/u/general\";\nimport { data, when } from \"@sdxc/u/state\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\n/** Semantic color role {@link Highlight} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Highlight.Color = \"brand\";\n\n/**\n * Prop types for {@link Highlight}.\n */\nexport namespace Highlight {\n\t/** Semantic color role the marks are tinted with. */\n\texport type Color = SemanticColor;\n\n\t/** One stretch of the text, and whether the query matched it. */\n\texport interface Segment {\n\t\t/** The stretch exactly as written. */\n\t\ttext: string;\n\t\t/** Whether this stretch is drawn as a `<mark>`. */\n\t\tmatch: boolean;\n\t}\n\n\t/**\n\t * Every native `<span>` attribute except `children`, which the segments replace, plus\n\t * the `mix` passthrough.\n\t */\n\texport interface Props extends Omit<TagProps<\"span\">, \"children\"> {\n\t\t/** The text in order, split where the matches start and end. */\n\t\tsegments: ReadonlyArray<Segment>;\n\t\t/** Semantic color role of the marks. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t}\n}\n\n/**\n * Renders the segments inline, each match as a `<mark>` with a quiet tint behind text\n * that keeps the surrounding color and weight, so a match inside a link still reads as\n * the link. A mark broken across lines keeps its rounded tint on every fragment.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the highlighted text.\n * @example\n * <Highlight segments={[{ text: \"Remix\", match: true }, { text: \" routing\", match: false }]} />\n * @example\n * <Link href={post.href}><Highlight segments={post.title} color=\"warning\" /></Link>\n */\nexport function Highlight(handle: Handle<Highlight.Props>) {\n\treturn () => {\n\t\tlet { color, segments, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-color={color ?? DEFAULT_COLOR}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"& > mark\", [\n\t\t\t\t\t\tfg(\"inherit\"),\n\t\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tfontWeight: \"inherit\",\n\t\t\t\t\t\t\tpaddingInline: \"0.1em\",\n\t\t\t\t\t\t\tmarginInline: \"-0.1em\",\n\t\t\t\t\t\t\tboxDecorationBreak: \"clone\",\n\t\t\t\t\t\t\tWebkitBoxDecorationBreak: \"clone\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"brand\", when(\"& > mark\", bg(\"brand.tint\"))),\n\t\t\t\t\tdata(\"color\", \"neutral\", when(\"& > mark\", bg(\"neutral.tint\"))),\n\t\t\t\t\tdata(\"color\", \"success\", when(\"& > mark\", bg(\"success.tint\"))),\n\t\t\t\t\tdata(\"color\", \"warning\", when(\"& > mark\", bg(\"warning.tint\"))),\n\t\t\t\t\tdata(\"color\", \"danger\", when(\"& > mark\", bg(\"danger.tint\"))),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t{segments.map((segment) => (segment.match ? <mark>{segment.text}</mark> : segment.text))}\n\t\t\t</span>\n\t\t);\n\t};\n}\n"
11
+ },
12
+ "test": {
13
+ "path": "highlight.test.tsx",
14
+ "content": "/**\n * Tests for the markup and tint {@link Highlight} renders: matches become `<mark>`, every\n * stretch stays escaped text, and the tint follows the color role.\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 { Highlight } from \"@sdxc/ui/highlight\";\n\ndescribe(Highlight.name, () => {\n\ttest(\"marks exactly the matched stretches, in order\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Highlight\n\t\t\t\tsegments={[\n\t\t\t\t\t{ text: \"Learn \", match: false },\n\t\t\t\t\t{ text: \"Remix\", match: true },\n\t\t\t\t\t{ text: \" today\", match: false },\n\t\t\t\t]}\n\t\t\t/>,\n\t\t);\n\n\t\texpect(html).toMatch(/<span data-color=\"brand\"[^>]*>Learn <mark>Remix<\\/mark> today<\\/span>/);\n\t});\n\n\ttest(\"escapes the text of every stretch\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Highlight\n\t\t\t\tsegments={[\n\t\t\t\t\t{ text: \"<b>\", match: true },\n\t\t\t\t\t{ text: \" & co\", match: false },\n\t\t\t\t]}\n\t\t\t/>,\n\t\t);\n\n\t\texpect(html).toContain(\"<mark>&lt;b&gt;</mark> &amp; co\");\n\t});\n\n\ttest(\"tints the marks with the color role asked for\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Highlight color=\"warning\" segments={[{ text: \"hit\", match: true }]} />,\n\t\t);\n\n\t\texpect(html).toContain('data-color=\"warning\"');\n\t\texpect(html).toContain(\"--ui-warning-bg-tint\");\n\t});\n});\n"
15
+ }
16
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "hover-card",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "HoverCard"
7
+ ],
8
+ "source": {
9
+ "path": "hover-card.tsx",
10
+ "content": "/**\n * A supplementary detail panel that appears beside a trigger on hover or\n * keyboard focus — a user card beneath an @mention, a definition beneath a\n * term. Its panel shares {@link Popover}'s rounded, bordered, shadowed\n * surface, sized narrower and padded for a compact block of text. Reveal\n * rides `:hover` and `:focus-within` on the compound root, since a\n * hover-revealed surface has no invoker to click — the hover path sits\n * behind `@media (hover: hover)` to avoid a stuck-open panel on coarse\n * pointers, while focus stays unconditional for keyboard and touch users.\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 { fg } from \"@sdxc/u/color\";\nimport { opacity, transition, transitionDuration, visibility } from \"@sdxc/u/effects\";\nimport { pointerEvents, raw } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tcontents,\n\tinlineBlock,\n\tinsBe,\n\tinsBs,\n\tinsIe,\n\tinsIs,\n\trelative,\n} from \"@sdxc/u/layout\";\nimport { media } from \"@sdxc/u/responsive\";\nimport { is, mb, mbe, mbs, marginLeft, marginRight, mi, p } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { text } from \"@sdxc/u/typography\";\n\nimport type { AnchorPlacement } from \"@sdxc/ui/utils\";\n\nimport { floatingSurface } from \"@sdxc/ui/styles\";\n\n/**\n * Side of the trigger {@link HoverCard.Content} renders against when\n * `placement` is left unset.\n */\nconst DEFAULT_PLACEMENT: HoverCard.Placement = \"bottom\";\n\n/**\n * Prop types for {@link HoverCard} and its compound parts.\n */\nexport namespace HoverCard {\n\t/**\n\t * Side of the trigger the panel renders against, and — for corner variants\n\t * — which trigger edge it aligns to on the perpendicular axis. Names a\n\t * physical viewport side, so it keeps attaching under any `dir` value.\n\t */\n\texport type Placement = AnchorPlacement;\n\n\t/**\n\t * Every native `<span>` attribute, plus the `mix` passthrough. This is\n\t * the compound root every part below nests inside — its own hover and\n\t * focus-within state is what reveals {@link HoverCard.Content}.\n\t */\n\texport interface Props extends TagProps<\"span\"> {\n\t\t/** The compound root's parts: {@link HoverCard.Trigger} followed by {@link HoverCard.Content}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link HoverCard.Trigger}.\n\t */\n\texport interface TriggerProps extends TagProps<\"span\"> {\n\t\t/**\n\t\t * The visible trigger — a link, button, or other element. The root\n\t\t * reveals {@link HoverCard.Content} whenever focus or a hover-capable\n\t\t * pointer rests inside it, so pointer users reach the panel even without a focusable child.\n\t\t */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link HoverCard.Content}.\n\t */\n\texport interface ContentProps extends TagProps<\"div\"> {\n\t\t/** Side of the trigger to render against. Defaults to {@link DEFAULT_PLACEMENT}. */\n\t\tplacement?: Placement;\n\t\t/** The panel's content. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the compound root: a `<span>` providing {@link HoverCard.Content}'s\n * anchor and the hover/focus-within scope that reveals it, so hovering or\n * focusing the trigger or panel keeps it open with no script-tracked state.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the compound root's markup.\n * @example\n * <HoverCard>\n * \t<HoverCard.Trigger>\n * \t\t<Link href={`/users/${user.handle}`}>@{user.handle}</Link>\n * \t</HoverCard.Trigger>\n * \t<HoverCard.Content aria-label={t(\"userCard.label\", { name: user.name })}>\n * \t\t<p>{user.bio}</p>\n * \t</HoverCard.Content>\n * </HoverCard>\n */\nexport function HoverCard(handle: Handle<HoverCard.Props>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\tdata-slot=\"hover-card\"\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineBlock(),\n\t\t\t\t\tmedia(\n\t\t\t\t\t\t\"(hover: hover)\",\n\t\t\t\t\t\twhen('&:hover [data-slot=\"hover-card-content\"]', [\n\t\t\t\t\t\t\topacity(100),\n\t\t\t\t\t\t\tvisibility(),\n\t\t\t\t\t\t\t/**\n\t\t\t\t\t\t\t * An open card is something the reader reaches into, so it takes the pointer.\n\t\t\t\t\t\t\t * `!important` settles it: each mix entry gets its own cascade sublayer, and the resting\n\t\t\t\t\t\t\t * state's own rule may land in a later one.\n\t\t\t\t\t\t\t */\n\t\t\t\t\t\t\traw({\n\t\t\t\t\t\t\t\tpointerEvents: \"auto !important\",\n\t\t\t\t\t\t\t\ttransitionDelay: \"var(--ui-hover-card-open-delay, 0.4s)\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\n\t\t\t\t\twhen('&:focus-within [data-slot=\"hover-card-content\"]', [\n\t\t\t\t\t\topacity(100),\n\t\t\t\t\t\tvisibility(),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tpointerEvents: \"auto !important\",\n\t\t\t\t\t\t\ttransitionDelay: \"0s\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\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</span>\n\t\t);\n\t};\n}\n\n/**\n * Renders {@link HoverCard.TriggerProps.children} inside a `<span>` styled\n * `display: contents`, so the trigger keeps the child's own layout and\n * hover/focus-within participation, visible straight through to the root above.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the trigger's markup.\n * @example\n * <HoverCard.Trigger>\n * \t<Link href={`/users/${user.handle}`}>@{user.handle}</Link>\n * </HoverCard.Trigger>\n */\nHoverCard.Trigger = function HoverCardTrigger(handle: Handle<HoverCard.TriggerProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span data-slot=\"hover-card-trigger\" {...rest} mix={[contents(), mix]}>\n\t\t\t\t{children}\n\t\t\t</span>\n\t\t);\n\t};\n};\n\n/**\n * Renders the panel: a `<div>` sharing {@link Popover}'s surface and placement\n * contract, kept in normal stacking order for its CSS-driven hover/focus\n * reveal, with delays tuned for pointer and keyboard users.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the panel's markup.\n * @example\n * <HoverCard.Content placement=\"bottom-start\">\n * \t<OverlayArrow placement=\"bottom-start\">\n * \t\t<svg width={12} height={12} viewBox=\"0 0 12 12\">\n * \t\t\t<path d=\"M0 0 L6 6 L12 0\" />\n * \t\t</svg>\n * \t</OverlayArrow>\n * \t<p>{user.bio}</p>\n * </HoverCard.Content>\n */\nHoverCard.Content = function HoverCardContent(handle: Handle<HoverCard.ContentProps>) {\n\treturn () => {\n\t\tlet { placement, children, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-slot=\"hover-card-content\"\n\t\t\t\tdata-placement={resolvedPlacement}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tfloatingSurface(),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tp(4),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tis(\"18rem\"),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\topacity(0),\n\t\t\t\t\ttransition(\"opacity, visibility, pointer-events\"),\n\t\t\t\t\tvisibility(\"hidden\"),\n\t\t\t\t\tpointerEvents(),\n\t\t\t\t\traw({\n\t\t\t\t\t\tzIndex: \"var(--ui-hover-card-z, 50)\",\n\t\t\t\t\t\ttransitionBehavior: \"allow-discrete\",\n\t\t\t\t\t\ttransitionDelay: \"var(--ui-hover-card-close-delay, 0.2s)\",\n\t\t\t\t\t}),\n\n\t\t\t\t\twhen('&[data-placement^=\"bottom\"]', [\n\t\t\t\t\t\tmbs(\"var(--ui-popover-offset, 0.5rem)\"),\n\t\t\t\t\t\tinsBs(\"100%\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"top\"]', [\n\t\t\t\t\t\tmbe(\"var(--ui-popover-offset, 0.5rem)\"),\n\t\t\t\t\t\tinsBe(\"100%\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"left\"]', [\n\t\t\t\t\t\tmarginRight(\"var(--ui-popover-offset, 0.5rem)\"),\n\t\t\t\t\t\traw({ right: \"100%\" }),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement^=\"right\"]', [\n\t\t\t\t\t\tmarginLeft(\"var(--ui-popover-offset, 0.5rem)\"),\n\t\t\t\t\t\traw({ left: \"100%\" }),\n\t\t\t\t\t]),\n\n\t\t\t\t\t/**\n\t\t\t\t\t * The card rests off its trigger's edge, and a pointer travelling between the\n\t\t\t\t\t * two crosses that space, so the card's own hit area reaches back across it\n\t\t\t\t\t * and the pair reads as one surface for as long as the pointer is on either.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&::before\", raw({ content: '\"\"', position: \"absolute\" })),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t'&[data-placement^=\"bottom\"]::before',\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tinsetBlockEnd: \"100%\",\n\t\t\t\t\t\t\tinsetInlineStart: \"0\",\n\t\t\t\t\t\t\tinsetInlineEnd: \"0\",\n\t\t\t\t\t\t\tblockSize: \"var(--ui-popover-offset, 0.5rem)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t'&[data-placement^=\"top\"]::before',\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tinsetBlockStart: \"100%\",\n\t\t\t\t\t\t\tinsetInlineStart: \"0\",\n\t\t\t\t\t\t\tinsetInlineEnd: \"0\",\n\t\t\t\t\t\t\tblockSize: \"var(--ui-popover-offset, 0.5rem)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t'&[data-placement^=\"left\"]::before',\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tleft: \"100%\",\n\t\t\t\t\t\t\tinsetBlockStart: \"0\",\n\t\t\t\t\t\t\tinsetBlockEnd: \"0\",\n\t\t\t\t\t\t\tinlineSize: \"var(--ui-popover-offset, 0.5rem)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t\twhen(\n\t\t\t\t\t\t'&[data-placement^=\"right\"]::before',\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tright: \"100%\",\n\t\t\t\t\t\t\tinsetBlockStart: \"0\",\n\t\t\t\t\t\t\tinsetBlockEnd: \"0\",\n\t\t\t\t\t\t\tinlineSize: \"var(--ui-popover-offset, 0.5rem)\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\n\t\t\t\t\twhen('&[data-placement=\"bottom\"], &[data-placement=\"top\"]', [\n\t\t\t\t\t\tmi(\"auto\"),\n\t\t\t\t\t\tinsIs(\"0\"),\n\t\t\t\t\t\tinsIe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement=\"bottom-start\"], &[data-placement=\"top-start\"]', insIs(\"0\")),\n\t\t\t\t\twhen('&[data-placement=\"bottom-end\"], &[data-placement=\"top-end\"]', insIe(\"0\")),\n\t\t\t\t\twhen('&[data-placement=\"left\"], &[data-placement=\"right\"]', [\n\t\t\t\t\t\tmb(\"auto\"),\n\t\t\t\t\t\tinsBs(\"0\"),\n\t\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[data-placement=\"left-start\"], &[data-placement=\"right-start\"]', insBs(\"0\")),\n\t\t\t\t\twhen('&[data-placement=\"left-end\"], &[data-placement=\"right-end\"]', insBe(\"0\")),\n\n\t\t\t\t\tmedia(\"(prefers-reduced-motion: reduce)\", [\n\t\t\t\t\t\ttransitionDuration(\"0s\"),\n\t\t\t\t\t\traw({ transitionDelay: \"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\t\t{children}\n\t\t\t</div>\n\t\t);\n\t};\n};\n"
11
+ },
12
+ "test": null
13
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "image-placeholder",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "ImagePlaceholder"
7
+ ],
8
+ "source": {
9
+ "path": "image-placeholder.tsx",
10
+ "content": "/**\n * The shared foundation for a fixed-size image-with-fallback box — a user\n * avatar, a brand logo, or any other picture that needs a graceful stand-in\n * before it loads or when it's missing. It renders a sized, shaped host that\n * an image and a fallback layer both stack into, plus a corner status badge\n * and a group of overlapping instances with a trailing overflow count.\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, border, fg, outline } from \"@sdxc/u/color\";\nimport { ringShadow, rounded, visibility } from \"@sdxc/u/effects\";\nimport { userSelect } from \"@sdxc/u/general\";\nimport {\n\tabsolute,\n\tcenter,\n\tflex,\n\tinlineFlex,\n\tinsBe,\n\tinsIe,\n\tinset,\n\titems,\n\tjustify,\n\trelative,\n\tshrink,\n} from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { bs, fit, is, mis } from \"@sdxc/u/size\";\nimport { data, precededBy, when } from \"@sdxc/u/state\";\nimport { tabularNums, text, textTransform, weight } from \"@sdxc/u/typography\";\n\n/** Size variant {@link ImagePlaceholder} falls back to when `size` is omitted. */\nconst DEFAULT_SIZE: ImagePlaceholder.Size = \"md\";\n\n/**\n * Shape variant {@link ImagePlaceholder} and {@link ImagePlaceholder.GroupCount}\n * fall back to when `shape` is omitted.\n */\nconst DEFAULT_SHAPE: ImagePlaceholder.Shape = \"circle\";\n\n/**\n * The inset hairline {@link ImagePlaceholder.Image} draws over a picture's\n * edge, read from the theme's `--ui-image-outline`, which flips for dark mode.\n */\nconst IMAGE_OUTLINE = \"var(--ui-image-outline, rgb(0 0 0 / 0.1))\";\n\n/**\n * Prop types for {@link ImagePlaceholder} and its compound parts.\n */\nexport namespace ImagePlaceholder {\n\t/**\n\t * Size variant controlling the host's rendered dimensions and, through\n\t * ordinary inheritance, the fallback initials' font size.\n\t */\n\texport type Size = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Shape variant controlling the corner rounding of the host, its image,\n\t * and its fallback layer: `\"circle\"` renders a fully rounded disc, and\n\t * `\"square\"` renders a softly rounded square.\n\t */\n\texport type Shape = \"circle\" | \"square\";\n\n\t/**\n\t * Props accepted by {@link ImagePlaceholder}.\n\t */\n\texport interface Props extends TagProps<\"span\"> {\n\t\t/** Size variant. Defaults to {@link DEFAULT_SIZE}. */\n\t\tsize?: Size;\n\t\t/** Shape variant. Defaults to {@link DEFAULT_SHAPE}. */\n\t\tshape?: Shape;\n\t\t/** The host's compound parts: {@link ImagePlaceholder.Image}, {@link ImagePlaceholder.Fallback}, and an optional {@link ImagePlaceholder.Badge}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link ImagePlaceholder.Image}.\n\t */\n\texport interface ImageProps extends Omit<\n\t\tTagProps<\"img\">,\n\t\t\"src\" | \"alt\" | \"role\" | \"aria-label\" | \"aria-labelledby\" | \"title\"\n\t> {\n\t\t/** Image source URL. */\n\t\tsrc: string;\n\t\t/**\n\t\t * Accessible text description of the image. Required, since a\n\t\t * consumer's own localized description drives what assistive\n\t\t * technology announces.\n\t\t */\n\t\talt: string;\n\t}\n\n\t/**\n\t * Props accepted by {@link ImagePlaceholder.Fallback}.\n\t */\n\texport interface FallbackProps extends TagProps<\"span\"> {\n\t\t/** Fallback content, typically the subject's initials. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link ImagePlaceholder.Badge}.\n\t */\n\texport interface BadgeProps extends TagProps<\"span\"> {}\n\n\t/**\n\t * Props accepted by {@link ImagePlaceholder.Group}.\n\t */\n\texport interface GroupProps extends TagProps<\"div\"> {\n\t\t/** A run of {@link ImagePlaceholder} instances, optionally trailed by {@link ImagePlaceholder.GroupCount}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link ImagePlaceholder.GroupCount}.\n\t */\n\texport interface GroupCountProps extends TagProps<\"span\"> {\n\t\t/** Shape variant, matching the shape of the sibling placeholders it trails. Defaults to {@link DEFAULT_SHAPE}. */\n\t\tshape?: Shape;\n\t\t/** The overflow count text, e.g. `\"+3\"`. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the placeholder host: a fixed-size, centered box whose `data-shape`\n * attribute styles it, its image, and its fallback together, leaving room\n * for {@link ImagePlaceholder.Badge} to sit unclipped on the corner.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the placeholder's markup.\n * @example\n * <ImagePlaceholder>\n * \t<ImagePlaceholder.Image src={user.avatarUrl} alt={user.name} />\n * \t<ImagePlaceholder.Fallback>{initials}</ImagePlaceholder.Fallback>\n * </ImagePlaceholder>\n * @example\n * <ImagePlaceholder size=\"lg\" shape=\"square\">\n * \t<ImagePlaceholder.Image src={org.logoUrl} alt={org.name} />\n * \t<ImagePlaceholder.Badge />\n * </ImagePlaceholder>\n */\nexport function ImagePlaceholder(handle: Handle<ImagePlaceholder.Props>) {\n\treturn () => {\n\t\tlet { size, shape, children, mix, ...rest } = handle.props;\n\t\tlet resolvedSize = size ?? DEFAULT_SIZE;\n\t\tlet resolvedShape = shape ?? DEFAULT_SHAPE;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"image-placeholder\"\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-shape={resolvedShape}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tshrink(),\n\t\t\t\t\tuserSelect(),\n\t\t\t\t\tis(\"var(--ui-image-placeholder-size-md, 2.5rem)\"),\n\t\t\t\t\tbs(\"var(--ui-image-placeholder-size-md, 2.5rem)\"),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\tdata(\"size\", \"sm\", [\n\t\t\t\t\t\tis(\"var(--ui-image-placeholder-size-sm, 2rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-image-placeholder-size-sm, 2rem)\"),\n\t\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"size\", \"lg\", [\n\t\t\t\t\t\tis(\"var(--ui-image-placeholder-size-lg, 3rem)\"),\n\t\t\t\t\t\tbs(\"var(--ui-image-placeholder-size-lg, 3rem)\"),\n\t\t\t\t\t\ttext(\"base\"),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"shape\", \"circle\", [\n\t\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\t\twhen('& > [data-slot=\"image\"]', rounded(\"full\")),\n\t\t\t\t\t\twhen('& > [data-slot=\"fallback\"]', rounded(\"full\")),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"shape\", \"square\", [\n\t\t\t\t\t\trounded(\"lg\"),\n\t\t\t\t\t\twhen('& > [data-slot=\"image\"]', rounded(\"lg\")),\n\t\t\t\t\t\twhen('& > [data-slot=\"fallback\"]', rounded(\"lg\")),\n\t\t\t\t\t]),\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</span>\n\t\t);\n\t};\n}\n\n/**\n * Renders the placeholder's image layer: an `<img>` cropped to cover, clipped to\n * {@link ImagePlaceholder}'s `data-shape`, its inset hairline holding the edge on\n * a same-tone background. Its order against {@link ImagePlaceholder.Fallback} decides what shows.\n *\n * @param handle Runtime handle carrying the host `<img>`'s props.\n * @returns The render function producing the image layer's markup.\n * @example\n * <ImagePlaceholder.Image src={user.avatarUrl} alt={user.name} />\n */\nImagePlaceholder.Image = function ImagePlaceholderImage(\n\thandle: Handle<ImagePlaceholder.ImageProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<img\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"image\"\n\t\t\t\tmix={[\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\tbs(\"full\"),\n\t\t\t\t\tfit(\"cover\"),\n\t\t\t\t\tinset(0, 0, 0, 0),\n\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\toutline({ color: IMAGE_OUTLINE, width: 1, offset: -1 }),\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 the placeholder's fallback layer: a `<span>` centering a consumer's\n * content in uppercase text. Font size inherits {@link ImagePlaceholder}'s\n * `data-size` via CSS, keeping initials proportional at every size.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the fallback layer's markup.\n * @example\n * <ImagePlaceholder.Fallback>{initials}</ImagePlaceholder.Fallback>\n */\nImagePlaceholder.Fallback = function ImagePlaceholderFallback(\n\thandle: Handle<ImagePlaceholder.FallbackProps>,\n) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"fallback\"\n\t\t\t\tmix={[\n\t\t\t\t\t/**\n\t\t\t\t\t * Both layers fill the host and this one follows the image, so it hides while an unbroken\n\t\t\t\t\t * image is present and takes over once the image fails. It hides through `visibility`,\n\t\t\t\t\t * which no other rule here sets, so declaration order keeps it hidden.\n\t\t\t\t\t */\n\t\t\t\t\tprecededBy('img[data-slot=\"image\"]:not([data-image-error])', visibility(\"hidden\")),\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tcenter(),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tbg(\"neutral.bg-tint-pressed\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\tinset(0, 0, 0, 0),\n\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\ttextTransform(\"uppercase\"),\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</span>\n\t\t);\n\t};\n};\n\n/**\n * Renders a small status dot pinned to the host's block-end/inline-end\n * corner, always fully rounded regardless of {@link ImagePlaceholder}'s own\n * shape, and ringed to read as cut from whatever sits beneath it.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the badge's markup.\n * @example\n * <ImagePlaceholder.Badge />\n */\nImagePlaceholder.Badge = function ImagePlaceholderBadge(\n\thandle: Handle<ImagePlaceholder.BadgeProps>,\n) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"badge\"\n\t\t\t\tmix={[\n\t\t\t\t\tabsolute(),\n\t\t\t\t\tis(3),\n\t\t\t\t\tbs(3),\n\t\t\t\t\trounded(\"full\"),\n\t\t\t\t\tborder({ color: \"neutral.tint\", width: 2 }),\n\t\t\t\t\tbg(\"neutral.strong\"),\n\t\t\t\t\tinsBe(\"0\"),\n\t\t\t\t\tinsIe(\"0\"),\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 a row of overlapping placeholders: a flex container that pulls each\n * child back over the previous one and rings each in the neutral tint background,\n * so the overlap reads as stacked cutouts.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <ImagePlaceholder.Group>\n * \t<ImagePlaceholder>…</ImagePlaceholder>\n * \t<ImagePlaceholder>…</ImagePlaceholder>\n * \t<ImagePlaceholder.GroupCount>+3</ImagePlaceholder.GroupCount>\n * </ImagePlaceholder.Group>\n */\nImagePlaceholder.Group = function ImagePlaceholderGroup(\n\thandle: Handle<ImagePlaceholder.GroupProps>,\n) {\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=\"group\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\twhen(\"& > * + *\", mis(-3)),\n\t\t\t\t\twhen('& > [data-slot=\"image-placeholder\"]', ringShadow(\"neutral.tint\")),\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 the \"+N\" overflow indicator trailing {@link ImagePlaceholder.Group}:\n * a medium box matching {@link ImagePlaceholder}'s size, ring and `shape`, its\n * tabular digits keeping a changing count the same width.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the overflow indicator's markup.\n * @example\n * <ImagePlaceholder.GroupCount>+3</ImagePlaceholder.GroupCount>\n */\nImagePlaceholder.GroupCount = function ImagePlaceholderGroupCount(\n\thandle: Handle<ImagePlaceholder.GroupCountProps>,\n) {\n\treturn () => {\n\t\tlet { shape, children, mix, ...rest } = handle.props;\n\t\tlet resolvedShape = shape ?? DEFAULT_SHAPE;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tdata-slot=\"group-count\"\n\t\t\t\tdata-shape={resolvedShape}\n\t\t\t\tmix={[\n\t\t\t\t\trelative(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\toverflow(\"hidden\"),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tbg(\"neutral.bg-tint-hover\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\twhen('&[data-shape=\"circle\"]', rounded(\"full\")),\n\t\t\t\t\twhen('&[data-shape=\"square\"]', rounded(\"lg\")),\n\t\t\t\t\tshrink(),\n\t\t\t\t\tuserSelect(),\n\t\t\t\t\tis(\"var(--ui-image-placeholder-size-md, 2.5rem)\"),\n\t\t\t\t\tbs(\"var(--ui-image-placeholder-size-md, 2.5rem)\"),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\ttabularNums(),\n\t\t\t\t\tringShadow(\"neutral.tint\"),\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</span>\n\t\t);\n\t};\n};\n"
11
+ },
12
+ "test": {
13
+ "path": "image-placeholder.test.tsx",
14
+ "content": "/**\n * Guards the rule that lets a loaded picture show through its fallback, and the inset\n * hairline that edges the picture. Every utility lands in a cascade layer of its own,\n * in first-use order, so a rule sharing a property on the fallback can lose.\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 { Avatar } from \"@sdxc/ui/avatar\";\n\ndescribe(\"an image placeholder's fallback\", () => {\n\t/**\n\t * The fallback is centered with `display: flex`; hiding it with `display: none` left\n\t * the outcome to layer order, and a page that first used the centering utility after\n\t * this rule drew the initials over every loaded picture.\n\t */\n\ttest(\"stands down behind an unbroken image through a property nothing else sets\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Avatar>\n\t\t\t\t<Avatar.Image src=\"https://example.test/ada.png\" alt=\"\" />\n\t\t\t\t<Avatar.Fallback>AD</Avatar.Fallback>\n\t\t\t</Avatar>,\n\t\t);\n\t\tlet rule = html.slice(html.indexOf(':is(img[data-slot=\"image\"]:not([data-image-error])) ~ &'));\n\n\t\texpect(rule.slice(0, rule.indexOf(\"}\"))).toContain(\"visibility: hidden\");\n\t\texpect(rule.slice(0, rule.indexOf(\"}\"))).not.toContain(\"display: none\");\n\t});\n});\n\ndescribe(\"an image placeholder's image\", () => {\n\ttest(\"draws an inset hairline from the theme's image outline token\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Avatar>\n\t\t\t\t<Avatar.Image src=\"https://example.test/ada.png\" alt=\"\" />\n\t\t\t</Avatar>,\n\t\t);\n\n\t\texpect(html).toContain(\"outline-color: var(--ui-image-outline, rgb(0 0 0 / 0.1))\");\n\t\texpect(html).toContain(\"outline-offset: -1px\");\n\t});\n});\n"
15
+ }
16
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "input",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Input"
7
+ ],
8
+ "source": {
9
+ "path": "input.tsx",
10
+ "content": "/**\n * A single-line native form field for free text entry, rendered as a\n * bordered, rounded `<input>` whose border, background, and focus ring read\n * from a semantic color role. It supplies the field's own box styling only,\n * ready to compose alongside a paired label, hint, and validation message,\n * and serves as the shared foundation every other single-line text control\n * in this library builds on.\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 { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor } from \"@sdxc/u/general\";\nimport { block } from \"@sdxc/u/layout\";\nimport { bs, is, pb, pi } from \"@sdxc/u/size\";\nimport { focusVisible, hover, invalid, when } from \"@sdxc/u/state\";\nimport { text } from \"@sdxc/u/typography\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\n\n/** Semantic color role {@link Input} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Input.Color = \"neutral\";\n\n/**\n * Prop types for {@link Input}.\n */\nexport namespace Input {\n\t/**\n\t * Semantic color role for the focus-visible ring, each mapped to its\n\t * matching `--ui-*` variables. A field marked invalid always reads the\n\t * danger tone for its ring regardless of `color`.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Every native `<input>` attribute, unchanged, plus the `mix`\n\t * passthrough. `role` narrows to match whichever `type` is set, the\n\t * same correlation the platform itself defines between the two.\n\t */\n\texport type Props = TagProps<\"input\"> & {\n\t\t/** Semantic color role for the focus-visible ring. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t};\n}\n\n/**\n * Renders a native `<input>` host colored via `data-color`, with hover,\n * focus, and disabled states driven by native pseudo-classes; `[aria-invalid=\"true\"]`\n * together with `:user-invalid` forces the danger tone regardless of `color`.\n *\n * @param handle Runtime handle carrying the host `<input>`'s props.\n * @returns The render function producing the field's markup.\n * @example\n * <Label htmlFor=\"email\">{t(\"form.email.label\")}</Label>\n * <Input id=\"email\" type=\"email\" required />\n * @example\n * <Input\n * \taria-label={t(\"form.search.label\")}\n * \tcolor=\"brand\"\n * \tplaceholder={t(\"form.search.placeholder\")}\n * />\n * @example\n * <Input id=\"username\" aria-describedby=\"username-error\" aria-invalid=\"true\" />\n * <FieldError id=\"username-error\">{t(\"form.username.taken\")}</FieldError>\n */\nexport function Input(handle: Handle<Input.Props>) {\n\treturn () => {\n\t\tlet { color, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<input\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tblock(),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\tbs(10),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\tpi(3),\n\t\t\t\t\tpb(2),\n\t\t\t\t\twhen(\"&::placeholder\", fg(\"neutral.muted\")),\n\t\t\t\t\thover(border(\"neutral.border-hover\")),\n\t\t\t\t\t/**\n\t\t\t\t\t * Focus draws a ring standing off the field, as every button here does, and the border\n\t\t\t\t\t * steps only to its hover weight: a strong border flush with the ring reads as the field\n\t\t\t\t\t * changing shape.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&:focus\", border(\"neutral.border-hover\")),\n\t\t\t\t\t/**\n\t\t\t\t\t * Pointer focus drops the platform outline and keyboard focus keeps the ring below. The\n\t\t\t\t\t * selectors exclude each other because `outline: none` is a shorthand, and from a later\n\t\t\t\t\t * cascade layer it resets the ring's color, width and style at once.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&:focus:not(:focus-visible)\", outline(\"none\")),\n\t\t\t\t\tfocusVisible([\n\t\t\t\t\t\tborder(\"neutral.border-hover\"),\n\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\twhen('&[data-color=\"success\"]', outline(\"success.ring\")),\n\t\t\t\t\t\twhen('&[data-color=\"warning\"]', outline(\"warning.ring\")),\n\t\t\t\t\t\twhen('&[data-color=\"danger\"]', outline(\"danger.ring\")),\n\t\t\t\t\t]),\n\t\t\t\t\tinvalid([border(\"danger\"), outline({ color: \"danger.ring\", offset: 2 })]),\n\t\t\t\t\twhen(\"&:disabled\", [opacity(50), bg(\"neutral.bg-tint-hover\"), cursor(\"not-allowed\")]),\n\t\t\t\t\ttext(\"sm\"),\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
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "item",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Item"
7
+ ],
8
+ "source": {
9
+ "path": "item.tsx",
10
+ "content": "/**\n * A single-line content row composing a leading media slot, a title and\n * description content slot, and a trailing action slot along one\n * horizontally centered line — the shape a settings row, a notification\n * list entry, or a file row all share. Every part lays out through the\n * row's own flex line rather than any part reading a semantic role from its\n * neighbors, so a row renders correctly whichever parts a given list needs:\n * media and content alone, content and actions alone, or all three.\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 { fg } from \"@sdxc/u/color\";\nimport { raw } from \"@sdxc/u/general\";\nimport {\n\tbasis,\n\tcenter,\n\tcontainer,\n\tflex,\n\tflexCol,\n\tflexWrap,\n\tgap,\n\tgrow,\n\titems,\n\tshrink,\n} from \"@sdxc/u/layout\";\nimport { atMax } from \"@sdxc/u/responsive\";\nimport { bs, is, mis, minIs, pb, pi } from \"@sdxc/u/size\";\nimport { when } from \"@sdxc/u/state\";\nimport { fontSize, leading, text, truncate, weight } from \"@sdxc/u/typography\";\n\n/**\n * Named container {@link Item} declares on its own host, so\n * {@link Item.Actions} can adapt to the row's own width instead of the\n * page's, keeping the same row width in a full page or a narrow panel.\n */\nconst CONTAINER_NAME = \"ui-item\";\n\n/**\n * `@container` max-width threshold below which the row can't hold\n * {@link Item.Media}, {@link Item.Content}, and {@link Item.Actions} on one\n * line without crowding {@link Item.Content}'s text out of room.\n */\nconst NARROW_CONTAINER_SIZE = \"20rem\";\n\n/**\n * Prop types for {@link Item} and its compound parts.\n */\nexport namespace Item {\n\t/**\n\t * Props accepted by {@link Item}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** The row's compound parts: {@link Item.Media}, {@link Item.Content}, and {@link Item.Actions}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Item.Media}.\n\t */\n\texport interface MediaProps extends TagProps<\"div\"> {\n\t\t/** The leading graphic — an icon, an image thumbnail, an Avatar instance, or a checkbox. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Item.Content}.\n\t */\n\texport interface ContentProps extends TagProps<\"div\"> {\n\t\t/** {@link Item.Title} and, optionally, {@link Item.Description}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Item.Title}.\n\t */\n\texport interface TitleProps extends TagProps<\"div\"> {\n\t\t/** The row's label text. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Item.Description}.\n\t */\n\texport interface DescriptionProps extends TagProps<\"p\"> {\n\t\t/** Supporting detail below the title — a file size, an email address, a timestamp. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Item.Actions}.\n\t */\n\texport interface ActionsProps extends TagProps<\"div\"> {\n\t\t/** A run of buttons, links, or a switch — whatever control the row offers. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the row's host: a `<div>` laying {@link Item.Media},\n * {@link Item.Content}, and {@link Item.Actions} on one flex line, dropping\n * {@link Item.Actions} to a second line once the row narrows past threshold.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Item>\n * \t<Item.Media><FileTextIcon aria-hidden /></Item.Media>\n * \t<Item.Content>\n * \t\t<Item.Title>quarterly-report.pdf</Item.Title>\n * \t\t<Item.Description>2.4 MB</Item.Description>\n * \t</Item.Content>\n * \t<Item.Actions>\n * \t\t<Button aria-label={t(\"files.download\")}><DownloadIcon /></Button>\n * \t</Item.Actions>\n * </Item>\n * @example\n * <Item>\n * \t<Item.Content>\n * \t\t<Item.Title>{t(\"settings.emailNotifications.title\")}</Item.Title>\n * \t\t<Item.Description>{t(\"settings.emailNotifications.description\")}</Item.Description>\n * \t</Item.Content>\n * \t<Item.Actions>\n * \t\t<Switch name=\"emailNotifications\" />\n * \t</Item.Actions>\n * </Item>\n */\nexport function Item(handle: Handle<Item.Props>) {\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=\"item\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(\"var(--ui-item-gap, 0.75rem)\"),\n\t\t\t\t\tpb(\"var(--ui-item-padding-block, 0.625rem)\"),\n\t\t\t\t\tpi(\"var(--ui-item-padding-inline, 0.75rem)\"),\n\t\t\t\t\tcontainer(CONTAINER_NAME),\n\t\t\t\t\t/**\n\t\t\t\t\t * The row wraps at every width, and {@link Item.Actions} claiming a full line once the\n\t\t\t\t\t * row is narrow decides when it does; a query on this row's own container can only\n\t\t\t\t\t * restyle its descendants, never the row itself.\n\t\t\t\t\t */\n\t\t\t\t\tflexWrap(\"wrap\"),\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 Item.MediaProps.children} as the row's leading slot: a\n * shrink-proof, centered `<div>` colored from the neutral foreground so a\n * nested icon inherits it through `currentcolor`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the media slot's markup.\n * @example\n * <Item.Media><FileTextIcon aria-hidden /></Item.Media>\n * @example\n * <Item.Media>\n * \t<Avatar size=\"sm\">\n * \t\t<Avatar.Image src={member.avatarUrl} alt={member.name} />\n * \t\t<Avatar.Fallback>{member.initials}</Avatar.Fallback>\n * \t</Avatar>\n * </Item.Media>\n */\nItem.Media = function ItemMedia(handle: Handle<Item.MediaProps>) {\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=\"media\"\n\t\t\t\tmix={[\n\t\t\t\t\tcenter(),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\twhen(\"& > svg\", [is(5), bs(5)]),\n\t\t\t\t\tshrink(),\n\t\t\t\t\tis(\"var(--ui-item-media-size, 2rem)\"),\n\t\t\t\t\tbs(\"var(--ui-item-media-size, 2rem)\"),\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 Item.ContentProps.children} as the row's text column: a\n * `<div>` stacking {@link Item.Title} and {@link Item.Description} with its\n * minimum inline size collapsed to `0` so their truncation takes effect.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the text column's markup.\n * @example\n * <Item.Content>\n * \t<Item.Title>quarterly-report.pdf</Item.Title>\n * \t<Item.Description>2.4 MB</Item.Description>\n * </Item.Content>\n */\nItem.Content = function ItemContent(handle: Handle<Item.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={[flex(), flexCol(), minIs(0), gap(0.5), 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 Item.TitleProps.children} as the row's label in a plain\n * `<div>`, since a document outline gains nothing from a heading entry per\n * repeated row, truncated to one line in the foreground's emphasized tone.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the title's markup.\n * @example\n * <Item.Title>quarterly-report.pdf</Item.Title>\n */\nItem.Title = function ItemTitle(handle: Handle<Item.TitleProps>) {\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=\"title\"\n\t\t\t\tmix={[weight(\"medium\"), fg(\"neutral.emphasis\"), truncate(), text(\"sm\"), 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 Item.DescriptionProps.children} as the row's supporting\n * detail in a native `<p>`, truncated to one line to match\n * {@link Item.Title} so the pair reads as one compact two-line block.\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 * <Item.Description>2.4 MB</Item.Description>\n */\nItem.Description = function ItemDescription(handle: Handle<Item.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\tfg(\"neutral.muted\"),\n\t\t\t\t\ttruncate(),\n\t\t\t\t\tfontSize(\"0.8125rem\"),\n\t\t\t\t\tleading(\"calc(1.125 / 0.8125)\"),\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 Item.ActionsProps.children} as the row's trailing slot,\n * pinned to the inline-end edge; once {@link Item} wraps narrow, it drops\n * to its own line, indented past {@link Item.Media} to read as trailing.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the action slot's markup.\n * @example\n * <Item.Actions>\n * \t<Button aria-label={t(\"files.download\")}><DownloadIcon /></Button>\n * \t<Button aria-label={t(\"files.remove\")}><XIcon /></Button>\n * </Item.Actions>\n */\nItem.Actions = function ItemActions(handle: Handle<Item.ActionsProps>) {\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=\"actions\"\n\t\t\t\tmix={[\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tmis(\"auto\"),\n\t\t\t\t\tshrink(),\n\t\t\t\t\tgap(\"var(--ui-item-actions-gap, 0.5rem)\"),\n\t\t\t\t\tatMax(NARROW_CONTAINER_SIZE, CONTAINER_NAME, [\n\t\t\t\t\t\tbasis(\"100%\"),\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\tjustifyContent: \"flex-end\",\n\t\t\t\t\t\t\tmarginInlineStart:\n\t\t\t\t\t\t\t\t\"calc(var(--ui-item-media-size, 2rem) + var(--ui-item-gap, 0.75rem))\",\n\t\t\t\t\t\t}),\n\t\t\t\t\t]),\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"
11
+ },
12
+ "test": null
13
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "keyboard",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Keyboard"
7
+ ],
8
+ "source": {
9
+ "path": "keyboard.tsx",
10
+ "content": "/**\n * A keyboard-shortcut hint rendered inside a native `<kbd>` element, drawn as the key\n * it names: a tinted, bordered cap sized to read beside the row's own text. Its\n * inline-start auto margin pushes it to the trailing edge of whatever row it sits in —\n * a menu item's command, a tooltip's accelerator, a button's shortcut label.\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 { bg, border, fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { inlineFlex, items, justify } from \"@sdxc/u/layout\";\nimport { bs, minIs, mis, pi } from \"@sdxc/u/size\";\nimport { leading, tabularNums, text } from \"@sdxc/u/typography\";\n\n/**\n * Prop types for {@link Keyboard}.\n */\nexport namespace Keyboard {\n\t/**\n\t * Every native `<kbd>` attribute, unchanged, plus the `mix` passthrough.\n\t * Renders as a small, muted, trailing-aligned annotation whose content is\n\t * whatever `children` the consumer supplies — a key, a chord, a glyph.\n\t */\n\texport interface Props extends TagProps<\"kbd\"> {}\n}\n\n/**\n * Renders its children inside a `<kbd>` element drawn as a key cap, whose inline-start\n * auto margin pushes it to the trailing edge of whatever row it sits in — a menu item,\n * a tooltip, a button.\n *\n * @param handle Runtime handle carrying the host `<kbd>`'s props.\n * @returns The render function producing the shortcut hint's markup.\n * @example\n * <Keyboard>⌘K</Keyboard>\n */\nexport function Keyboard(handle: Handle<Keyboard.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<kbd\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tmis(\"auto\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * The cap centers its glyph as an inline box, so a key sits inside the sentence\n\t\t\t\t\t * naming it; `center()` composes `flex()` and would put the key on a line of its own.\n\t\t\t\t\t */\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\t/**\n\t\t\t\t\t * A cap keeps its height and a minimum width whatever it holds, so a single\n\t\t\t\t\t * letter and a two-glyph chord sit on the same line as each other.\n\t\t\t\t\t */\n\t\t\t\t\tbs(\"1.25rem\"),\n\t\t\t\t\tminIs(\"1.25rem\"),\n\t\t\t\t\tpi(1.5),\n\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\ttext(\"xs\"),\n\t\t\t\t\tleading(\"none\"),\n\t\t\t\t\ttabularNums(),\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
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "label",
3
+ "changedIn": "2026.10.2",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Label"
7
+ ],
8
+ "source": {
9
+ "path": "label.tsx",
10
+ "content": "/**\n * A caption for a form control, associated with its field either through\n * the native `for`/`id` relationship (set `htmlFor` to the field's `id`) or\n * by wrapping the control as a child. It renders as a single line of\n * emphasized text at the library's default label size, weight, and color.\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 { fontSize, leading, weight } from \"@sdxc/u/typography\";\n\n/**\n * Prop types for {@link Label}.\n */\nexport namespace Label {\n\t/**\n\t * Every native `<label>` attribute, unchanged, plus the `mix` passthrough.\n\t * Renders at the library's default caption size, medium weight, and\n\t * emphasized neutral foreground; set `htmlFor` or nest the field as a child.\n\t */\n\texport interface Props extends TagProps<\"label\"> {}\n}\n\n/**\n * Renders its children inside a native `<label>` element, sized and colored\n * as a form field caption. Pair it with a field by setting `htmlFor` to the\n * field's `id`, or wrap the field directly so the platform associates them.\n *\n * @param handle Runtime handle carrying the host `<label>`'s props.\n * @returns The render function producing the label's markup.\n * @example\n * <Label htmlFor=\"email\">{t(\"form.email.label\")}</Label>\n * @example\n * <Label>\n * \t{t(\"form.newsletter.label\")}\n * \t<input type=\"checkbox\" name=\"newsletter\" />\n * </Label>\n */\nexport function Label(handle: Handle<Label.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\t{...rest}\n\t\t\t\tmix={[weight(\"medium\"), fg(\"neutral.emphasis\"), fontSize(\"sm\"), leading(\"none\"), mix]}\n\t\t\t/>\n\t\t);\n\t};\n}\n"
11
+ },
12
+ "test": null
13
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "link-button",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "LinkButton"
7
+ ],
8
+ "source": {
9
+ "path": "link-button.tsx",
10
+ "content": "/**\n * A navigation action styled to read as a button rather than inline text —\n * \"View project\", \"Download\", a dialog's \"Cancel\" that also navigates away.\n * Its host renders as a native `<a>`, sharing {@link Button}'s semantic\n * color role, visual weight variant, and size so a link and a button placed\n * side by side render pixel-identical.\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 { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, pointerEvents, userSelect } from \"@sdxc/u/general\";\nimport { gap, inlineFlex, items, justify, shrink } from \"@sdxc/u/layout\";\nimport { bs, is, minBs, pb, pi, pie, pis } from \"@sdxc/u/size\";\nimport { active, data, hover, when } from \"@sdxc/u/state\";\nimport { text, weight } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { hitArea } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { glyphEdges } from \"@sdxc/ui/utils\";\n\n/** Semantic color role {@link LinkButton} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: LinkButton.Color = \"neutral\";\n\n/** Visual weight {@link LinkButton} falls back to when `variant` is omitted. */\nconst DEFAULT_VARIANT: LinkButton.Variant = \"solid\";\n\n/** Size variant {@link LinkButton} falls back to when `size` is omitted. */\nconst DEFAULT_SIZE: LinkButton.Size = \"md\";\n\n/**\n * Prop types for {@link LinkButton}.\n */\nexport namespace LinkButton {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Visual weight the link renders with: a solid fill with an on-solid\n\t * foreground, a transparent fill with a strong colored border, or a fully\n\t * transparent fill with just a colored label.\n\t */\n\texport type Variant = \"solid\" | \"outline\" | \"ghost\";\n\n\t/**\n\t * Size variant controlling the link's padding and font size.\n\t */\n\texport type Size = \"sm\" | \"md\" | \"lg\";\n\n\t/**\n\t * Props accepted by {@link LinkButton}. A type alias rather than an\n\t * interface, since the native anchor props resolve to an intersection\n\t * type that TypeScript can't use in an `extends` clause.\n\t */\n\texport type Props = TagProps<\"a\"> & {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** Visual weight. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Size variant. Defaults to {@link DEFAULT_SIZE}. */\n\t\tsize?: Size;\n\t};\n}\n\n/**\n * Renders a native `<a>` host, colored and shaped through the same color,\n * variant, and size data attributes as {@link Button}. `aria-disabled=\"true\"`\n * keeps it focusable while dimmed, so drop `href` too for full inertness.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the link's markup.\n * @example\n * <LinkButton href=\"/projects/new\">{t(\"actions.createProject\")}</LinkButton>\n * @example\n * <LinkButton href=\"/projects\" color=\"neutral\" variant=\"outline\" size=\"sm\">{t(\"actions.cancel\")}</LinkButton>\n * @example\n * <LinkButton href=\"/export/report.csv\" download aria-disabled={!hasReport || undefined}>{t(\"actions.download\")}</LinkButton>\n */\nexport function LinkButton(handle: Handle<LinkButton.Props>) {\n\treturn () => {\n\t\tlet { color, variant, size, children, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet resolvedSize = size ?? DEFAULT_SIZE;\n\t\tlet edges = glyphEdges(children);\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\t{...rest}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-size={resolvedSize}\n\t\t\t\tdata-glyph-start={edges.start || undefined}\n\t\t\t\tdata-glyph-end={edges.end || undefined}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", outline(\"neutral.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"success\", outline(\"success.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"warning\", outline(\"warning.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"danger\", outline(\"danger.ring\")),\n\t\t\t\t\t]),\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tjustify(\"center\"),\n\t\t\t\t\tgap(2),\n\t\t\t\t\t/**\n\t\t\t\t\t * A glyph inside a link button is measured and held at size by the same rules\n\t\t\t\t\t * `Button` states, for the same reasons: it is sized against the label beside\n\t\t\t\t\t * it so the row keeps the height its text and padding ask for, and it never\n\t\t\t\t\t * shrinks, since the default `flex-shrink: 1` would compress the glyph rather\n\t\t\t\t\t * than the words and a squashed icon reads as a rendering fault.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"& > svg\", [shrink(), is(4), bs(4)]),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\t/** A small control reaches `--ui-target-size` however a consumer positions it. */\n\t\t\t\t\thitArea({ anchor: \"flex-center\" }),\n\t\t\t\t\tpi(4),\n\t\t\t\t\tpb(2),\n\t\t\t\t\t/**\n\t\t\t\t\t * Every variant carries the same border width, colored to match its\n\t\t\t\t\t * own fill (transparent for ghost), so solid, outline, and ghost\n\t\t\t\t\t * render at the same footprint.\n\t\t\t\t\t */\n\t\t\t\t\tborder({ width: 1 }),\n\t\t\t\t\t/**\n\t\t\t\t\t * The row measure is stated, so the control lines up with a field of the same size when\n\t\t\t\t\t * a Group fuses the two, and still grows when a long label wraps.\n\t\t\t\t\t */\n\t\t\t\t\tminBs(\"2.5rem\"),\n\n\t\t\t\t\tdata(\"size\", \"sm\", [pi(3), pb(1.5), minBs(\"2rem\"), when(\"& > svg\", [is(3), bs(3)])]),\n\t\t\t\t\tdata(\"size\", \"lg\", [\n\t\t\t\t\t\tpi(5),\n\t\t\t\t\t\tpb(2.5),\n\t\t\t\t\t\ttext(\"base\"),\n\t\t\t\t\t\tminBs(\"3rem\"),\n\t\t\t\t\t\twhen(\"& > svg\", [is(5), bs(5)]),\n\t\t\t\t\t]),\n\t\t\t\t\t/**\n\t\t\t\t\t * A glyph beside a label carries its own side bearing, so the padding on that\n\t\t\t\t\t * side drops one step and the glyph and the words read as evenly inset.\n\t\t\t\t\t */\n\t\t\t\t\twhen(\"&[data-glyph-start]:has(> svg:first-child)\", [\n\t\t\t\t\t\tpis(3),\n\t\t\t\t\t\tdata(\"size\", \"sm\", pis(2)),\n\t\t\t\t\t\tdata(\"size\", \"lg\", pis(4)),\n\t\t\t\t\t]),\n\t\t\t\t\twhen(\"&[data-glyph-end]:has(> svg:last-child)\", [\n\t\t\t\t\t\tpie(3),\n\t\t\t\t\t\tdata(\"size\", \"sm\", pie(2)),\n\t\t\t\t\t\tdata(\"size\", \"lg\", pie(4)),\n\t\t\t\t\t]),\n\n\t\t\t\t\tdata(\"variant\", \"solid\", [\n\t\t\t\t\t\tdata(\"color\", \"brand\", [\n\t\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\t\tborder(\"brand.solid\"),\n\t\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t\t\thover([bg(\"brand.bg-solid-hover\"), border(\"brand.bg-solid-hover\")]),\n\t\t\t\t\t\t\tactive([bg(\"brand.bg-solid-pressed\"), border(\"brand.bg-solid-pressed\")]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\t\tbg(\"neutral.solid\"),\n\t\t\t\t\t\t\tborder(\"neutral.solid\"),\n\t\t\t\t\t\t\tfg(\"neutral.onSolid\"),\n\t\t\t\t\t\t\thover([bg(\"neutral.bg-solid-hover\"), border(\"neutral.bg-solid-hover\")]),\n\t\t\t\t\t\t\tactive([bg(\"neutral.bg-solid-pressed\"), border(\"neutral.bg-solid-pressed\")]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\t\tbg(\"success.solid\"),\n\t\t\t\t\t\t\tborder(\"success.solid\"),\n\t\t\t\t\t\t\tfg(\"success.onSolid\"),\n\t\t\t\t\t\t\thover([bg(\"success.bg-solid-hover\"), border(\"success.bg-solid-hover\")]),\n\t\t\t\t\t\t\tactive([bg(\"success.bg-solid-pressed\"), border(\"success.bg-solid-pressed\")]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\t\tbg(\"warning.solid\"),\n\t\t\t\t\t\t\tborder(\"warning.solid\"),\n\t\t\t\t\t\t\tfg(\"warning.onSolid\"),\n\t\t\t\t\t\t\thover([bg(\"warning.bg-solid-hover\"), border(\"warning.bg-solid-hover\")]),\n\t\t\t\t\t\t\tactive([bg(\"warning.bg-solid-pressed\"), border(\"warning.bg-solid-pressed\")]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"danger\", [\n\t\t\t\t\t\t\tbg(\"danger.solid\"),\n\t\t\t\t\t\t\tborder(\"danger.solid\"),\n\t\t\t\t\t\t\tfg(\"danger.onSolid\"),\n\t\t\t\t\t\t\thover([bg(\"danger.bg-solid-hover\"), border(\"danger.bg-solid-hover\")]),\n\t\t\t\t\t\t\tactive([bg(\"danger.bg-solid-pressed\"), border(\"danger.bg-solid-pressed\")]),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\n\t\t\t\t\tdata(\"variant\", \"outline\", [\n\t\t\t\t\t\tdata(\"color\", \"brand\", [\n\t\t\t\t\t\t\tborder(\"brand\"),\n\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\thover([bg(\"brand.tint\"), border(\"brand.border-hover\")]),\n\t\t\t\t\t\t\tactive(bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\t\tborder(\"neutral\"),\n\t\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\t\thover([bg(\"neutral.tint\"), border(\"neutral.border-hover\")]),\n\t\t\t\t\t\t\tactive(bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\t\tborder(\"success\"),\n\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\thover([bg(\"success.tint\"), border(\"success.border-hover\")]),\n\t\t\t\t\t\t\tactive(bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\t\tborder(\"warning\"),\n\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\thover([bg(\"warning.tint\"), border(\"warning.border-hover\")]),\n\t\t\t\t\t\t\tactive(bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"danger\", [\n\t\t\t\t\t\t\tborder(\"danger\"),\n\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\thover([bg(\"danger.tint\"), border(\"danger.border-hover\")]),\n\t\t\t\t\t\t\tactive(bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"outline\", bg(\"transparent\")),\n\n\t\t\t\t\tdata(\"variant\", \"ghost\", [\n\t\t\t\t\t\tdata(\"color\", \"brand\", [\n\t\t\t\t\t\t\tfg(\"brand\"),\n\t\t\t\t\t\t\thover(bg(\"brand.tint\")),\n\t\t\t\t\t\t\tactive(bg(\"brand.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\t\tfg(\"success\"),\n\t\t\t\t\t\t\thover(bg(\"success.tint\")),\n\t\t\t\t\t\t\tactive(bg(\"success.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\t\tfg(\"warning\"),\n\t\t\t\t\t\t\thover(bg(\"warning.tint\")),\n\t\t\t\t\t\t\tactive(bg(\"warning.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"danger\", [\n\t\t\t\t\t\t\tfg(\"danger\"),\n\t\t\t\t\t\t\thover(bg(\"danger.tint\")),\n\t\t\t\t\t\t\tactive(bg(\"danger.bg-tint-hover\")),\n\t\t\t\t\t\t]),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"variant\", \"ghost\", [bg(\"transparent\"), border(\"transparent\")]),\n\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', opacity(50)),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), pointerEvents()]),\n\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\tuserSelect(),\n\n\t\t\t\t\ttext(\"sm\"),\n\n\t\t\t\t\tdata(\"size\", \"sm\", text(\"xs\")),\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</a>\n\t\t);\n\t};\n}\n"
11
+ },
12
+ "test": {
13
+ "path": "link-button.test.tsx",
14
+ "content": "/**\n * Tests for {@link LinkButton}: its children still render inside the anchor, a glyph at\n * either edge of a label is marked so that side's padding drops a step, and the anchor\n * carries an inset-free pointer target box.\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 { LinkButton } from \"@sdxc/ui/link-button\";\n\ndescribe(LinkButton.name, () => {\n\ttest(\"renders its label inside the anchor\", async () => {\n\t\tlet html = await renderToString(<LinkButton href=\"/new\">Create</LinkButton>);\n\n\t\texpect(html).toMatch(/<a [^>]*href=\"\\/new\"[^>]*>Create<\\/a>/);\n\t});\n\n\ttest(\"marks a leading glyph and leaves the trailing edge alone\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<LinkButton href=\"/new\">\n\t\t\t\t<svg />\n\t\t\t\tCreate\n\t\t\t</LinkButton>,\n\t\t);\n\n\t\texpect(html).toMatch(/<a [^>]*data-glyph-start/);\n\t\texpect(html).not.toMatch(/<a [^>]*data-glyph-end/);\n\t});\n\n\ttest(\"marks a trailing glyph after a label\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<LinkButton href=\"/next\">\n\t\t\t\tNext\n\t\t\t\t<svg />\n\t\t\t</LinkButton>,\n\t\t);\n\n\t\texpect(html).toMatch(/<a [^>]*data-glyph-end/);\n\t\texpect(html).not.toMatch(/<a [^>]*data-glyph-start/);\n\t});\n\n\ttest(\"draws a target-size box that holds however the anchor is positioned\", async () => {\n\t\tlet html = await renderToString(<LinkButton href=\"/new\">Create</LinkButton>);\n\n\t\texpect(html).toMatch(\n\t\t\t/&::after \\{[^}]*position: absolute;[^}]*inline-size: var\\(--ui-target-size, 1\\.5rem\\);/,\n\t\t);\n\t});\n});\n"
15
+ }
16
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "link",
3
+ "changedIn": "2026.10.2",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Link"
7
+ ],
8
+ "source": {
9
+ "path": "link.tsx",
10
+ "content": "/**\n * A native anchor for inline navigation, always underlined so its\n * affordance never rests on color alone, and colored through a semantic\n * color role that also drives its focus ring and disabled state.\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 { colorMix, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, raw, var as varUtility } from \"@sdxc/u/general\";\nimport { data, when } from \"@sdxc/u/state\";\nimport { textDecoration } from \"@sdxc/u/typography\";\n\nimport type { SemanticColor } from \"@sdxc/ui/utils\";\n\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\n\n/** Semantic color role {@link Link} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Link.Color = \"brand\";\n\n/**\n * Prop types for {@link Link}.\n */\nexport namespace Link {\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = SemanticColor;\n\n\t/**\n\t * Props accepted by {@link Link}. A type alias rather than an interface,\n\t * since the native anchor props resolve through a conditional type that an\n\t * `interface extends` clause can't statically extend.\n\t */\n\texport type Props = TagProps<\"a\"> & {\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t};\n}\n\n/**\n * Renders a native `<a>` host, colored through the `data-color` attribute\n * contract and underlined unconditionally. `aria-disabled=\"true\"` mutes the\n * link, but only removing or neutralizing `href` actually stops navigation.\n *\n * @param handle Runtime handle carrying the host `<a>`'s props.\n * @returns The render function producing the link's markup.\n * @example\n * <Link href=\"/about\">{t(\"nav.about\")}</Link>\n * @example\n * <Link href=\"/delete\" color=\"danger\">{t(\"actions.delete\")}</Link>\n * @example\n * <Link href=\"/settings\" aria-disabled=\"true\">{t(\"nav.settings\")}</Link>\n */\nexport function Link(handle: Handle<Link.Props>) {\n\treturn () => {\n\t\tlet { color, mix, ...rest } = handle.props;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<a\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\twhen(\"&:focus-visible\", [\n\t\t\t\t\t\toutline({ color: \"brand.ring\", offset: 2 }),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", outline(\"neutral.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"success\", outline(\"success.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"warning\", outline(\"warning.ring\")),\n\t\t\t\t\t\tdata(\"color\", \"danger\", outline(\"danger.ring\")),\n\t\t\t\t\t]),\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\tdata(\"color\", \"brand\", fg(\"brand\")),\n\t\t\t\t\tdata(\"color\", \"neutral\", fg(\"neutral\")),\n\t\t\t\t\tdata(\"color\", \"success\", fg(\"success\")),\n\t\t\t\t\tdata(\"color\", \"danger\", fg(\"danger\")),\n\t\t\t\t\tdata(\"color\", \"warning\", fg(\"warning\")),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', opacity(50)),\n\t\t\t\t\ttextDecoration(\"underline\"),\n\t\t\t\t\tcursor(\"pointer\"),\n\t\t\t\t\tdata(\"color\", \"brand\", [\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * `color-mix()`'s color argument needs the raw CSS variable\n\t\t\t\t\t\t * (`var(--ui-brand-fg)`), so the property stays `raw()` while\n\t\t\t\t\t\t * the literal string becomes a builder call.\n\t\t\t\t\t\t */\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\ttextDecorationColor: colorMix(\n\t\t\t\t\t\t\t\t\"srgb\",\n\t\t\t\t\t\t\t\t{ color: varUtility(\"ui-brand-fg\"), weight: 60 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:hover\", raw({ textDecorationColor: varUtility(\"ui-brand-fg\") })),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\ttextDecorationColor: colorMix(\n\t\t\t\t\t\t\t\t\"srgb\",\n\t\t\t\t\t\t\t\t{ color: varUtility(\"ui-neutral-fg\"), weight: 50 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:hover\", raw({ textDecorationColor: varUtility(\"ui-neutral-fg\") })),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\ttextDecorationColor: colorMix(\n\t\t\t\t\t\t\t\t\"srgb\",\n\t\t\t\t\t\t\t\t{ color: varUtility(\"ui-success-fg\"), weight: 60 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:hover\", raw({ textDecorationColor: varUtility(\"ui-success-fg\") })),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"danger\", [\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\ttextDecorationColor: colorMix(\n\t\t\t\t\t\t\t\t\"srgb\",\n\t\t\t\t\t\t\t\t{ color: varUtility(\"ui-danger-fg\"), weight: 60 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:hover\", raw({ textDecorationColor: varUtility(\"ui-danger-fg\") })),\n\t\t\t\t\t]),\n\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\traw({\n\t\t\t\t\t\t\ttextDecorationColor: colorMix(\n\t\t\t\t\t\t\t\t\"srgb\",\n\t\t\t\t\t\t\t\t{ color: varUtility(\"ui-warning-fg\"), weight: 60 },\n\t\t\t\t\t\t\t\t\"transparent\",\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twhen(\"&:hover\", raw({ textDecorationColor: varUtility(\"ui-warning-fg\") })),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&[aria-disabled=\"true\"]', [cursor(\"not-allowed\"), textDecoration(\"none\")]),\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
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "listbox",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [
5
+ "sentinel-row"
6
+ ],
7
+ "exports": [
8
+ "ListBox"
9
+ ],
10
+ "source": {
11
+ "path": "listbox.tsx",
12
+ "content": "/**\n * A run of selectable option rows sharing one native grouping name — each\n * {@link ListBox.Item} pairs a visually hidden `<input type=\"radio\">` or\n * `<input type=\"checkbox\">` with its own visible content, so every focus,\n * keyboard, and form-submission semantic keeps coming from the platform\n * itself. The host renders as a scrollable column reading each option's\n * `:checked` and `:focus` state through a `:has()` selector to color the\n * whole row, with no selection state tracked anywhere in this module.\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 { visuallyHidden } from \"@sdxc/u/a11y\";\nimport { bg, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor } from \"@sdxc/u/general\";\nimport { flex, gap, items } from \"@sdxc/u/layout\";\nimport { overflow } from \"@sdxc/u/overflow\";\nimport { maxBs, pb, pi } from \"@sdxc/u/size\";\nimport { active, hover, when } from \"@sdxc/u/state\";\nimport { text } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { surfaceInset } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { SentinelRow } from \"@sdxc/ui/sentinel-row\";\n\n/**\n * Default {@link ListBox.Props} selection cardinality, applied when\n * `multiple` is omitted, rendering every {@link ListBox.Item} as a native\n * `<input type=\"radio\">` limiting the group to one selected option.\n */\nconst DEFAULT_MULTIPLE = false;\n\n/**\n * Prop types for {@link ListBox} and its {@link ListBox.Item} compound part.\n */\nexport namespace ListBox {\n\t/**\n\t * Value {@link ListBox} stores in component context so every\n\t * {@link ListBox.Item} nested inside shares the same grouping name and\n\t * selection cardinality without repeating them on each option.\n\t */\n\texport interface Context {\n\t\t/** Shared `name` every {@link ListBox.Item} reads unless it sets its own. */\n\t\tname: string;\n\t\t/**\n\t\t * Whether an option's underlying input renders as a checkbox (`true`,\n\t\t * letting several options be selected at once) or a radio (`false`,\n\t\t * limiting the group to a single selected option).\n\t\t */\n\t\tmultiple: boolean;\n\t}\n\n\t/**\n\t * Props accepted by {@link ListBox}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/**\n\t\t * Native grouping name shared by every {@link ListBox.Item} nested inside,\n\t\t * provided through component context. Defaults to the group's own\n\t\t * {@link Handle.id | stable instance id}, so options always group correctly.\n\t\t */\n\t\tname?: string;\n\t\t/**\n\t\t * Renders every option as a checkbox, allowing more than one selected\n\t\t * at once, instead of the default mutually exclusive radio behavior.\n\t\t * Defaults to {@link DEFAULT_MULTIPLE}.\n\t\t */\n\t\tmultiple?: boolean;\n\t}\n\n\t/**\n\t * Props accepted by {@link ListBox.Item}.\n\t */\n\texport interface ItemProps extends Omit<TagProps<\"label\">, \"children\"> {\n\t\t/** Value submitted with the enclosing form when this option is selected. */\n\t\tvalue: string;\n\t\t/**\n\t\t * Native grouping name for this option's underlying input. Defaults to\n\t\t * the name provided by the nearest ancestor {@link ListBox} — set this\n\t\t * only to opt a single option out of its group's shared name.\n\t\t */\n\t\tname?: string;\n\t\t/** Whether this option starts selected, for a form that never tracks selection itself. */\n\t\tdefaultChecked?: boolean;\n\t\t/** Whether this option is selected, for a form that tracks selection itself. */\n\t\tchecked?: boolean;\n\t\t/** Whether this option is inert and excluded from the group's tab order. */\n\t\tdisabled?: boolean;\n\t\t/**\n\t\t * Sets the underlying input's native `required` attribute. On a radio\n\t\t * input this requires at least one option in the group be selected; on\n\t\t * a checkbox input it requires this specific option be checked.\n\t\t */\n\t\trequired?: boolean;\n\t\t/** The option's visible content, associated with the input by native nesting. */\n\t\tchildren?: RemixNode;\n\t\t/**\n\t\t * Per-part styling for the option's hidden `input` element, layered\n\t\t * after its own built-in styling. Use the `mix` prop instead to style\n\t\t * the option's outer `<label>` host.\n\t\t */\n\t\tparts?: {\n\t\t\t/** Additional mixin(s) applied to the hidden native `<input>`. */\n\t\t\tinput?: TagProps<\"input\">[\"mix\"];\n\t\t};\n\t}\n\n\t/**\n\t * Props accepted by {@link ListBox.LoadMoreItem}.\n\t */\n\texport interface LoadMoreItemProps extends TagProps<\"div\"> {}\n}\n\n/**\n * Renders the group host: a `<div>` laying its {@link ListBox.Item} options\n * out as a scrollable column capped at a fixed block size and rounded\n * concentric with its rows, with `role` defaulting to `\"radiogroup\"` for\n * single selection or `\"group\"` for `multiple`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props and providing {@link ListBox.Context}.\n * @returns The render function producing the group's markup.\n * @example\n * <ListBox aria-label={t(\"settings.theme\")}>\n * \t<ListBox.Item value=\"light\" defaultChecked>{t(\"settings.themeLight\")}</ListBox.Item>\n * \t<ListBox.Item value=\"dark\">{t(\"settings.themeDark\")}</ListBox.Item>\n * \t<ListBox.Item value=\"system\">{t(\"settings.themeSystem\")}</ListBox.Item>\n * </ListBox>\n * @example\n * <ListBox aria-label={t(\"settings.notifications\")} multiple>\n * \t<Section aria-labelledby=\"notifications-heading\">\n * \t\t<Header id=\"notifications-heading\">{t(\"settings.channels\")}</Header>\n * \t\t<ListBox.Item value=\"email\" defaultChecked>{t(\"settings.email\")}</ListBox.Item>\n * \t\t<ListBox.Item value=\"sms\">{t(\"settings.sms\")}</ListBox.Item>\n * \t</Section>\n * </ListBox>\n */\nexport function ListBox(handle: Handle<ListBox.Props, ListBox.Context>) {\n\treturn () => {\n\t\tlet { name, multiple, mix, ...rest } = handle.props;\n\t\tlet resolvedName = name ?? handle.id;\n\t\tlet resolvedMultiple = multiple ?? DEFAULT_MULTIPLE;\n\n\t\thandle.context.set({ name: resolvedName, multiple: resolvedMultiple });\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: resolvedMultiple ? \"group\" : \"radiogroup\" }),\n\t\t\t\t\tmaxBs(60),\n\t\t\t\t\toverflow(\"auto\"),\n\t\t\t\t\tsurfaceInset(),\n\t\t\t\t\toutline(\"none\"),\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 a single option: a native `<label>` pairing a visually hidden\n * radio or checkbox input with the option's content. In dev mode, an\n * option with no accessible name logs a `console.warn`.\n *\n * @param handle Runtime handle carrying the host `<label>`'s props.\n * @returns The render function producing the option's markup.\n * @example\n * <ListBox.Item value=\"dog\">{t(\"pet.dog\")}</ListBox.Item>\n * @example\n * <ListBox.Item value=\"cat\" defaultChecked>{t(\"pet.cat\")}</ListBox.Item>\n * @example\n * <ListBox.Item value=\"hamster\" disabled>{t(\"pet.hamster\")}</ListBox.Item>\n */\nListBox.Item = function ListBoxItem(handle: Handle<ListBox.ItemProps>) {\n\treturn () => {\n\t\tlet {\n\t\t\tvalue,\n\t\t\tname,\n\t\t\tchecked,\n\t\t\tdefaultChecked,\n\t\t\tdisabled,\n\t\t\trequired,\n\t\t\tchildren,\n\t\t\tparts,\n\t\t\tmix,\n\t\t\t...rest\n\t\t} = handle.props;\n\t\tlet context = handle.context.get(ListBox);\n\t\tlet resolvedName = name ?? context.name;\n\t\tlet type: \"checkbox\" | \"radio\" = context.multiple ? \"checkbox\" : \"radio\";\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"ListBox.Item: an option with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<label\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(2),\n\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\tpi(3),\n\t\t\t\t\tpb(2),\n\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\twhen(\"&:has(input:focus)\", bg(\"brand.bg-tint-pressed\")),\n\t\t\t\t\t/**\n\t\t\t\t\t * The row the keyboard is on is where the next Enter lands, so it is shown before it is\n\t\t\t\t\t * chosen. The tint stops at the selected row, which keeps its stronger fill while walked past.\n\t\t\t\t\t */\n\t\t\t\t\twhen('&[data-highlighted=\"true\"]:not(:has(input:checked)):not([aria-selected=\"true\"])', [\n\t\t\t\t\t\tbg(\"brand.bg-tint-pressed\"),\n\t\t\t\t\t\tfg(\"brand.emphasis\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&:has(input:checked), &[aria-selected=\"true\"]', [\n\t\t\t\t\t\tbg(\"brand.solid\"),\n\t\t\t\t\t\tfg(\"brand.onSolid\"),\n\t\t\t\t\t]),\n\t\t\t\t\twhen('&:has(input:disabled), &[aria-disabled=\"true\"]', opacity(50)),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\ttext(\"sm\"),\n\t\t\t\t\toutline(\"none\"),\n\t\t\t\t\tmix,\n\t\t\t\t]}\n\t\t\t>\n\t\t\t\t<input\n\t\t\t\t\ttype={type}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tname={resolvedName}\n\t\t\t\t\tchecked={checked}\n\t\t\t\t\tdefaultChecked={defaultChecked}\n\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\trequired={required}\n\t\t\t\t\tmix={[visuallyHidden(), parts?.input]}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</label>\n\t\t);\n\t};\n};\n\n/**\n * Renders a decorative sentinel row: a `<div>` styled as a centered, muted\n * line of small text sized to match {@link ListBox.Item}'s vertical rhythm,\n * ready to hold a loading indicator or \"load more\" trigger as `children`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the sentinel row's markup.\n * @example\n * <ListBox.LoadMoreItem>{t(\"list.loadingMore\")}</ListBox.LoadMoreItem>\n */\nListBox.LoadMoreItem = SentinelRow;\n"
13
+ },
14
+ "test": null
15
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "logo",
3
+ "changedIn": "2026.10.2",
4
+ "dependencies": [
5
+ "image-placeholder"
6
+ ],
7
+ "exports": [
8
+ "Logo"
9
+ ],
10
+ "source": {
11
+ "path": "logo.tsx",
12
+ "content": "/**\n * A brand mark rendered as a fixed-size, softly rounded host stacking an\n * image layer, an initials fallback, and an optional corner status badge,\n * plus a way to overlap several instances into one group with a trailing\n * overflow count.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type { Handle } from \"remix/component\";\n\nimport { ImagePlaceholder } from \"@sdxc/ui/image-placeholder\";\n\n/**\n * Prop types for {@link Logo} and its compound parts, each an alias of\n * {@link ImagePlaceholder}'s matching part since {@link Logo} renders\n * straight through to {@link ImagePlaceholder} fixed to its soft square shape.\n */\nexport namespace Logo {\n\t/**\n\t * Size variant controlling the host's rendered dimensions and, through\n\t * ordinary inheritance, the fallback initials' font size. Re-exports\n\t * {@link ImagePlaceholder.Size}.\n\t */\n\texport type Size = ImagePlaceholder.Size;\n\n\t/**\n\t * Props accepted by {@link Logo}: every prop {@link ImagePlaceholder.Props}\n\t * accepts except `shape`, which stays fixed to a soft square.\n\t */\n\texport interface Props extends Omit<ImagePlaceholder.Props, \"shape\"> {}\n\n\t/**\n\t * Props accepted by {@link Logo.Image}, unchanged from\n\t * {@link ImagePlaceholder.ImageProps}.\n\t */\n\texport interface ImageProps extends ImagePlaceholder.ImageProps {}\n\n\t/**\n\t * Props accepted by {@link Logo.Fallback}, unchanged from\n\t * {@link ImagePlaceholder.FallbackProps}.\n\t */\n\texport interface FallbackProps extends ImagePlaceholder.FallbackProps {}\n\n\t/**\n\t * Props accepted by {@link Logo.Badge}, unchanged from\n\t * {@link ImagePlaceholder.BadgeProps}.\n\t */\n\texport interface BadgeProps extends ImagePlaceholder.BadgeProps {}\n\n\t/**\n\t * Props accepted by {@link Logo.Group}, unchanged from\n\t * {@link ImagePlaceholder.GroupProps}.\n\t */\n\texport interface GroupProps extends ImagePlaceholder.GroupProps {}\n\n\t/**\n\t * Props accepted by {@link Logo.Group.Count}: every prop\n\t * {@link ImagePlaceholder.GroupCountProps} accepts except `shape`, which\n\t * stays fixed to the same soft square the logos it trails render with.\n\t */\n\texport interface GroupCountProps extends Omit<ImagePlaceholder.GroupCountProps, \"shape\"> {}\n}\n\n/**\n * Renders a fixed-size, softly rounded brand-mark host that stacks whichever\n * of {@link Logo.Image}, {@link Logo.Fallback}, and {@link Logo.Badge} a\n * consumer composes as children, with square corner rounding fixed in place.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the brand-mark host's markup.\n * @example\n * <Logo>\n * \t<Logo.Image src={org.logoUrl} alt={org.name} />\n * \t<Logo.Fallback>{initials}</Logo.Fallback>\n * </Logo>\n * @example\n * <Logo size=\"lg\">\n * \t<Logo.Image src={org.logoUrl} alt={org.name} />\n * \t<Logo.Fallback>{initials}</Logo.Fallback>\n * \t<Logo.Badge aria-label={t(\"status.verified\")} />\n * </Logo>\n */\nexport function Logo(handle: Handle<Logo.Props>) {\n\treturn () => <ImagePlaceholder {...handle.props} shape=\"square\" />;\n}\n\n/**\n * Renders the logo's image layer: an absolutely positioned `<img>` filling\n * the host edge to edge, cropped with `object-fit: cover` and clipped to\n * {@link Logo}'s soft-square shape.\n *\n * @param handle Runtime handle carrying the host `<img>`'s props.\n * @returns The render function producing the image layer's markup.\n * @example\n * <Logo.Image src={org.logoUrl} alt={org.name} />\n */\nLogo.Image = ImagePlaceholder.Image;\n\n/**\n * Renders the logo's fallback layer: a `<span>` centering a consumer's\n * initials in uppercase, medium-weight text sized to {@link Logo}'s\n * `data-size` so they stay in proportion at every size.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the fallback layer's markup.\n * @example\n * <Logo.Fallback>{initials}</Logo.Fallback>\n */\nLogo.Fallback = ImagePlaceholder.Fallback;\n\n/**\n * Renders a small status dot pinned to the host's block-end/inline-end\n * corner, fully rounded and ringed with a border matching the surrounding\n * background so it reads as cut out.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the badge's markup.\n * @example\n * <Logo.Badge aria-label={t(\"status.verified\")} />\n */\nLogo.Badge = ImagePlaceholder.Badge;\n\n/**\n * Renders {@link Logo.GroupProps.children} as overlapping logos, pulling\n * every child but the first back over its predecessor and ringing each\n * {@link Logo} child so the overlap reads as stacked cutouts.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the group's markup.\n * @example\n * <Logo.Group>\n * \t<Logo>…</Logo>\n * \t<Logo>…</Logo>\n * \t<Logo.Group.Count>+3</Logo.Group.Count>\n * </Logo.Group>\n */\nfunction LogoGroup(handle: Handle<Logo.GroupProps>) {\n\treturn () => <ImagePlaceholder.Group {...handle.props} />;\n}\n\n/**\n * Renders the \"+N\" overflow indicator that trails {@link Logo.Group}: a\n * fixed medium-size box matching {@link Logo}'s default dimensions, ringed\n * the same way a grouped logo is and fixed to the same soft square shape.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the overflow indicator's markup.\n * @example\n * <Logo.Group.Count>+3</Logo.Group.Count>\n */\nfunction LogoGroupCount(handle: Handle<Logo.GroupCountProps>) {\n\treturn () => <ImagePlaceholder.GroupCount {...handle.props} shape=\"square\" />;\n}\n\nLogoGroup.Count = LogoGroupCount;\nLogo.Group = LogoGroup;\n"
13
+ },
14
+ "test": null
15
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "marker",
3
+ "changedIn": "2026.10.10",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Marker"
7
+ ],
8
+ "source": {
9
+ "path": "marker.tsx",
10
+ "content": "/**\n * An inline row calling out a small event between two message rows — a\n * delivery status, a system note, a highlighted callout, or a labeled\n * divider — colored by a semantic tone and shaped by a variant.\n * {@link Marker.Icon} and {@link Marker.Content} compose beneath it for a\n * glyph-plus-caption row.\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, border, fg } from \"@sdxc/u/color\";\nimport { rounded } from \"@sdxc/u/effects\";\nimport { pseudoContent } from \"@sdxc/u/general\";\nimport { basis, center, gap, grow, inlineFlex, items, shrink } from \"@sdxc/u/layout\";\nimport { bs, is, minIs, pb, pi } from \"@sdxc/u/size\";\nimport { data, when } from \"@sdxc/u/state\";\nimport { fontSize, leading, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\n/** Visual shape {@link Marker} falls back to when `variant` is omitted. */\nconst DEFAULT_VARIANT: Marker.Variant = \"default\";\n\n/** Semantic color role {@link Marker} falls back to when `color` is omitted. */\nconst DEFAULT_COLOR: Marker.Color = \"neutral\";\n\n/**\n * Default `aria-hidden` applied to {@link Marker.Icon} through\n * {@link attrs}, keeping a decorative glyph out of the accessibility tree\n * unless a consumer overrides it for a control with its own name and role.\n */\nconst DEFAULT_ICON_ARIA_HIDDEN = \"true\";\n\n/**\n * `role` applied through {@link attrs} when `variant` is `\"separator\"`,\n * matching the accessibility contract a divider between groups of content\n * carries regardless of whether it's drawn as a bare line or a labeled one.\n */\nconst DEFAULT_SEPARATOR_ROLE = \"separator\";\n\n/**\n * `aria-orientation` applied through {@link attrs} alongside\n * {@link DEFAULT_SEPARATOR_ROLE}, since a labeled separator between message\n * rows always reads as a horizontal divider.\n */\nconst DEFAULT_SEPARATOR_ORIENTATION = \"horizontal\";\n\n/**\n * Prop types for {@link Marker} and its compound parts.\n */\nexport namespace Marker {\n\t/**\n\t * Visual shape the row renders with: `\"default\"` for a plain, centered\n\t * caption, `\"border\"` for a bordered, tinted callout panel, and\n\t * `\"separator\"` for a caption flanked by a hairline divider on either side.\n\t */\n\texport type Variant = \"default\" | \"border\" | \"separator\";\n\n\t/**\n\t * Semantic color role, each mapped to its matching `--ui-*` variables.\n\t */\n\texport type Color = \"brand\" | \"neutral\" | \"success\" | \"warning\" | \"danger\";\n\n\t/**\n\t * Props accepted by {@link Marker}.\n\t */\n\texport interface Props extends TagProps<\"div\"> {\n\t\t/** Visual shape of the row. Defaults to {@link DEFAULT_VARIANT}. */\n\t\tvariant?: Variant;\n\t\t/** Semantic color role. Defaults to {@link DEFAULT_COLOR}. */\n\t\tcolor?: Color;\n\t\t/** The row's compound parts: {@link Marker.Icon} followed by {@link Marker.Content}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Marker.Icon}.\n\t */\n\texport interface IconProps extends TagProps<\"span\"> {\n\t\t/** The icon graphic, typically a single SVG icon, or a nested control such as {@link Spinner}. */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Props accepted by {@link Marker.Content}.\n\t */\n\texport interface ContentProps extends TagProps<\"span\"> {\n\t\t/** The row's caption text. */\n\t\tchildren: RemixNode;\n\t}\n}\n\n/**\n * Renders the row's host element: a centered flex line framed through the\n * `data-variant` and `data-color` attributes, with `variant=\"separator\"`\n * also picking up `role=\"separator\"`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Marker color=\"success\">\n * \t<Marker.Icon><CheckIcon /></Marker.Icon>\n * \t<Marker.Content>{t(\"marker.delivered\")}</Marker.Content>\n * </Marker>\n * @example\n * <Marker>\n * \t<Marker.Content>{t(\"marker.userJoined\", { name: user.name })}</Marker.Content>\n * </Marker>\n * @example\n * <Marker variant=\"border\" color=\"warning\">\n * \t<Marker.Icon><TriangleAlertIcon /></Marker.Icon>\n * \t<Marker.Content>{t(\"marker.reconnecting\")}</Marker.Content>\n * </Marker>\n * @example\n * <Marker variant=\"separator\">\n * \t<Marker.Content>{t(\"marker.today\")}</Marker.Content>\n * </Marker>\n */\nexport function Marker(handle: Handle<Marker.Props>) {\n\treturn () => {\n\t\tlet { variant, color, children, mix, ...rest } = handle.props;\n\t\tlet resolvedVariant = variant ?? DEFAULT_VARIANT;\n\t\tlet resolvedColor = color ?? DEFAULT_COLOR;\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\tdata-variant={resolvedVariant}\n\t\t\t\tdata-color={resolvedColor}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tresolvedVariant === \"separator\"\n\t\t\t\t\t\t? attrs({\n\t\t\t\t\t\t\t\trole: DEFAULT_SEPARATOR_ROLE,\n\t\t\t\t\t\t\t\t\"aria-orientation\": DEFAULT_SEPARATOR_ORIENTATION,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined,\n\t\t\t\t\tcenter(),\n\t\t\t\t\tis(\"full\"),\n\t\t\t\t\tweight(\"medium\"),\n\t\t\t\t\tdata(\"color\", \"brand\", fg(\"brand.muted\")),\n\t\t\t\t\tdata(\"color\", \"neutral\", fg(\"neutral.muted\")),\n\t\t\t\t\tdata(\"color\", \"success\", fg(\"success.muted\")),\n\t\t\t\t\tdata(\"color\", \"warning\", fg(\"warning.muted\")),\n\t\t\t\t\tdata(\"color\", \"danger\", fg(\"danger.muted\")),\n\t\t\t\t\tdata(\"variant\", \"border\", [\n\t\t\t\t\t\trounded(\"md\"),\n\t\t\t\t\t\tborder({ width: 1 }),\n\t\t\t\t\t\tpb(2),\n\t\t\t\t\t\tpi(3.5),\n\t\t\t\t\t\tdata(\"color\", \"brand\", [border(\"brand\"), bg(\"brand.tint\"), fg(\"brand.emphasis\")]),\n\t\t\t\t\t\tdata(\"color\", \"neutral\", [\n\t\t\t\t\t\t\tborder(\"neutral\"),\n\t\t\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\t\t\tfg(\"neutral.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"success\", [\n\t\t\t\t\t\t\tborder(\"success\"),\n\t\t\t\t\t\t\tbg(\"success.tint\"),\n\t\t\t\t\t\t\tfg(\"success.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"warning\", [\n\t\t\t\t\t\t\tborder(\"warning\"),\n\t\t\t\t\t\t\tbg(\"warning.tint\"),\n\t\t\t\t\t\t\tfg(\"warning.emphasis\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t\tdata(\"color\", \"danger\", [border(\"danger\"), bg(\"danger.tint\"), fg(\"danger.emphasis\")]),\n\t\t\t\t\t]),\n\t\t\t\t\tgap(\"var(--ui-marker-gap, 0.375rem)\"),\n\t\t\t\t\tpb(\"0.375rem\"),\n\t\t\t\t\tfontSize(\"0.8125rem\"),\n\t\t\t\t\tleading(\"calc(1.25 / 0.8125)\"),\n\t\t\t\t\tdata(\n\t\t\t\t\t\t\"variant\",\n\t\t\t\t\t\t\"separator\",\n\t\t\t\t\t\twhen(\"&::before, &::after\", [\n\t\t\t\t\t\t\tpseudoContent('\"\"'),\n\t\t\t\t\t\t\tgrow(),\n\t\t\t\t\t\t\tshrink(1),\n\t\t\t\t\t\t\tbasis(\"0%\"),\n\t\t\t\t\t\t\tminIs(\"1.5rem\"),\n\t\t\t\t\t\t\tbs(\"var(--ui-separator-thickness, 1px)\"),\n\t\t\t\t\t\t\tbg(\"neutral.border\"),\n\t\t\t\t\t\t]),\n\t\t\t\t\t),\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 Marker.IconProps.children} as the row's glyph slot,\n * hidden from assistive technology unless a consumer overrides it for a\n * nested accessible control like {@link Spinner}.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the icon slot's markup.\n * @example\n * <Marker.Icon><CheckIcon /></Marker.Icon>\n * @example\n * <Marker.Icon aria-hidden=\"false\">\n * \t<Spinner size=\"sm\" aria-label={t(\"status.generating\")} />\n * </Marker.Icon>\n */\nMarker.Icon = function MarkerIcon(handle: Handle<Marker.IconProps>) {\n\treturn () => {\n\t\tlet { children, mix, ...rest } = handle.props;\n\n\t\treturn (\n\t\t\t<span\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ \"aria-hidden\": DEFAULT_ICON_ARIA_HIDDEN }),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\tshrink(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tfg(\"currentcolor\"),\n\t\t\t\t\twhen(\"& > svg\", [is(\"1em\"), bs(\"1em\")]),\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</span>\n\t\t);\n\t};\n};\n\n/**\n * Renders {@link Marker.ContentProps.children} as the row's caption: a\n * `<span>` inheriting its color, size, and weight from the {@link Marker}\n * root so a single `data-color` drives the icon and caption together.\n *\n * @param handle Runtime handle carrying the host `<span>`'s props.\n * @returns The render function producing the caption's markup.\n * @example\n * <Marker.Content>{t(\"marker.today\")}</Marker.Content>\n * @example\n * <Marker.Content mix={[textShimmer()]}>{t(\"chat.generating\")}</Marker.Content>\n */\nMarker.Content = function MarkerContent(handle: Handle<Marker.ContentProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <span {...rest} mix={[minIs(0), mix]} />;\n\t};\n};\n"
11
+ },
12
+ "test": null
13
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "name": "menu",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [
5
+ "popover",
6
+ "separator"
7
+ ],
8
+ "exports": [
9
+ "Menu"
10
+ ],
11
+ "source": {
12
+ "path": "menu.tsx",
13
+ "content": "/**\n * A menu surface anchored to whatever invoker opens it, riding the same\n * native Popover API {@link Popover} does, sized to its own content and\n * padded around a compact stack of {@link Menu.Item} rows, {@link\n * Menu.Separator} dividers, or a `Section`/`Header` pair grouping related\n * rows together. Every row lands in the page's native Tab order out of the\n * box, since each renders as a real `<a>` or `<button>`.\n *\n * @author [Sergio Xalambrí](https://sergiodxa.com)\n * @copyright Sergio Xalambrí 2026\n */\n\nimport type {\n\tElementProps,\n\tHandle,\n\tMixinDescriptor,\n\tProps as TagProps,\n\tRemixNode,\n} from \"remix/component\";\n\nimport { bg, fg, outline } from \"@sdxc/u/color\";\nimport { rounded, opacity } from \"@sdxc/u/effects\";\nimport { cursor } from \"@sdxc/u/general\";\nimport { flex, gap, items, shrink } from \"@sdxc/u/layout\";\nimport { bs, is, minIs, mb, pb, pi } from \"@sdxc/u/size\";\nimport { active, disabled, focusVisible, hover, when } from \"@sdxc/u/state\";\nimport { text, textAlign, textDecoration, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { surfaceInset } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport { warnIfNoAccessibleName } from \"@sdxc/ui/utils\";\n\nimport { Popover } from \"@sdxc/ui/popover\";\nimport { Separator } from \"@sdxc/ui/separator\";\n\n/**\n * Side of the invoker {@link Menu} renders against when `placement` is left\n * unset, reading down and start-ward the way a dropdown conventionally does.\n */\nconst DEFAULT_PLACEMENT: Popover.Placement = \"bottom-start\";\n\n/**\n * `role` applied to {@link Menu}'s host through {@link attrs} unless a\n * consumer supplies its own, identifying the surface as an ARIA menu.\n */\nconst DEFAULT_ROLE = \"menu\";\n\n/**\n * `role` applied to {@link Menu.Item} through {@link attrs} unless a\n * consumer supplies its own — `\"menuitemcheckbox\"` and `\"menuitemradio\"` are\n * valid overrides for a row that toggles or selects on activation.\n */\nconst DEFAULT_ITEM_ROLE = \"menuitem\";\n\n/**\n * {@link Menu.ItemProps.type} applied to the `<button>` variant when a\n * consumer leaves it unset, keeping a click on the row from submitting a\n * surrounding `<form>` the way a bare `<button>` otherwise would.\n */\nconst DEFAULT_ITEM_TYPE: NonNullable<Menu.ItemProps[\"type\"]> = \"button\";\n\n/**\n * Prop types for {@link Menu} and its compound parts.\n */\nexport namespace Menu {\n\t/**\n\t * Every prop {@link Popover.Props} accepts, since {@link Menu} renders one\n\t * directly as its host.\n\t */\n\texport interface Props extends Popover.Props {\n\t\t/**\n\t\t * The menu's rows: {@link Menu.Item}, {@link Menu.Separator}, or a\n\t\t * `Section`/`Header` pair grouping related items together.\n\t\t */\n\t\tchildren: RemixNode;\n\t}\n\n\t/**\n\t * Every native `<button>` attribute, plus `target`/`rel` for the anchor\n\t * variant `href` enables. Nest a row in a `<form>` for a submit action, or\n\t * compose a `mix`-applied event mixin for click handling.\n\t */\n\texport interface ItemProps extends TagProps<\"button\"> {\n\t\t/** Destination the row navigates to. Renders the row as a native `<a>` instead of a `<button>` when set. */\n\t\thref?: string;\n\t\t/** `target` for the link variant, applied only once `href` is set. */\n\t\ttarget?: TagProps<\"a\">[\"target\"];\n\t\t/** `rel` for the link variant, applied only once `href` is set. */\n\t\trel?: TagProps<\"a\">[\"rel\"];\n\t\t/**\n\t\t * Styles the row in the semantic danger tone, for a destructive action\n\t\t * like deleting a resource.\n\t\t */\n\t\tdanger?: boolean;\n\t\t/**\n\t\t * Extra mixin(s) applied to the row's host element, whichever of\n\t\t * `<a>`/`<button>` it renders as depending on {@link href}.\n\t\t */\n\t\tmix?: MixinDescriptor<HTMLAnchorElement | HTMLButtonElement, any, ElementProps>[];\n\t}\n\n\t/**\n\t * Every prop {@link Separator.Props} accepts, since {@link Menu.Separator}\n\t * renders one directly as its host.\n\t */\n\texport interface SeparatorProps extends Separator.Props {}\n}\n\n/**\n * Renders the menu's own host: a {@link Popover} defaulting to\n * `\"bottom-start\"` placement and `\"menu\"` role, sized to its content. Point a\n * row's `commandfor` at another `<Menu>`'s `id` to open it as a nested menu.\n *\n * @param handle Runtime handle carrying the host's {@link Popover} props.\n * @returns The render function producing the menu's markup.\n * @example\n * <Button commandfor=\"account-menu\" command=\"toggle-popover\">{t(\"nav.account\")}</Button>\n * <Menu id=\"account-menu\" aria-label={t(\"nav.accountMenu\")}>\n * \t<Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * \t<Menu.Item href=\"/settings/billing\">{t(\"nav.billing\")}</Menu.Item>\n * \t<Menu.Separator />\n * \t<Menu.Item danger>{t(\"actions.signOut\")}</Menu.Item>\n * </Menu>\n * @example\n * <Menu id=\"row-menu\" placement=\"left-start\" aria-label={t(\"table.rowActions\")}>\n * \t<Section aria-labelledby=\"row-menu-view-heading\">\n * \t\t<Header id=\"row-menu-view-heading\">{t(\"menu.view\")}</Header>\n * \t\t<Menu.Item href={viewUrl}>{t(\"actions.view\")}</Menu.Item>\n * \t\t<Menu.Item href={editUrl}>{t(\"actions.edit\")}</Menu.Item>\n * \t</Section>\n * \t<Menu.Separator />\n * \t<Menu.Item danger commandfor=\"confirm-delete\" command=\"show-modal\">{t(\"actions.delete\")}</Menu.Item>\n * </Menu>\n */\nexport function Menu(handle: Handle<Menu.Props>) {\n\treturn () => {\n\t\tlet { placement, children, mix, ...rest } = handle.props;\n\t\tlet resolvedPlacement = placement ?? DEFAULT_PLACEMENT;\n\n\t\treturn (\n\t\t\t<Popover\n\t\t\t\t{...rest}\n\t\t\t\tplacement={resolvedPlacement}\n\t\t\t\tmix={[attrs({ role: DEFAULT_ROLE }), minIs(\"10rem\"), surfaceInset(), outline(\"none\"), mix]}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</Popover>\n\t\t);\n\t};\n}\n\n/**\n * Renders a native `<a>` when `href` is set, else a `<button>`, defaulting\n * `role` to `\"menuitem\"`; only omitting or neutralizing `href` stops the\n * `<a>` variant's navigation, since `aria-disabled` mutes it visually only.\n *\n * @param handle Runtime handle carrying the host `<a>`/`<button>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * @example\n * <Menu.Item danger disabled>{t(\"actions.delete\")}</Menu.Item>\n * @example\n * <Menu.Item aria-selected={sort === \"name\" ? \"true\" : undefined}>{t(\"sort.name\")}</Menu.Item>\n */\nMenu.Item = function MenuItem(handle: Handle<Menu.ItemProps>) {\n\treturn () => {\n\t\tlet { href, target, rel, type, danger, children, mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Menu.Item: a row with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\tlet itemMix = [\n\t\t\tinteractiveTransition(),\n\t\t\tattrs({ role: DEFAULT_ITEM_ROLE }),\n\t\t\tflex(),\n\t\t\tis(\"full\"),\n\t\t\titems(\"center\"),\n\t\t\tgap(2),\n\t\t\t/**\n\t\t\t * A glyph in a row reads beside the row's own text, so it is sized against that text\n\t\t\t * and holds that size while a long label wraps.\n\t\t\t */\n\t\t\twhen(\"& > svg, & > [data-slot='icon']\", [is(\"1rem\"), bs(\"1rem\"), shrink()]),\n\t\t\trounded(\"md\"),\n\t\t\tpi(3),\n\t\t\tpb(2),\n\t\t\tfg(\"neutral.emphasis\"),\n\t\t\thover(bg(\"neutral.bg-tint-hover\")),\n\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\twhen(\"&:focus\", bg(\"brand.tint\")),\n\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\twhen('&[aria-selected=\"true\"]', [bg(\"brand.solid\"), fg(\"brand.onSolid\"), weight(500)]),\n\t\t\tdisabled([opacity(50), cursor(\"not-allowed\")]),\n\t\t\twhen(\"&[data-danger]\", [\n\t\t\t\tfg(\"danger\"),\n\t\t\t\thover(bg(\"danger.tint\")),\n\t\t\t\tactive(bg(\"danger.bg-tint-pressed\")),\n\t\t\t\twhen(\"&:focus\", bg(\"danger.tint\")),\n\t\t\t\tfocusVisible(outline(\"danger.ring\")),\n\t\t\t]),\n\t\t\tcursor(\"default\"),\n\t\t\ttextDecoration(\"none\"),\n\t\t\ttext(\"sm\"),\n\t\t\ttextAlign(\"start\"),\n\t\t\tmix,\n\t\t];\n\n\t\tif (href) {\n\t\t\t/**\n\t\t\t * `rest`'s fields (aria-*, data-*, id, event props, …) are all valid\n\t\t\t * on an `<a>` too, so retargeting its type here is safe; `role` is\n\t\t\t * left out since the anchor type narrows it conditionally on `href`.\n\t\t\t */\n\t\t\tlet anchorRest = rest as unknown as Omit<TagProps<\"a\">, \"href\" | \"target\" | \"rel\" | \"role\">;\n\n\t\t\treturn (\n\t\t\t\t<a\n\t\t\t\t\thref={href}\n\t\t\t\t\ttarget={target}\n\t\t\t\t\trel={rel}\n\t\t\t\t\t{...anchorRest}\n\t\t\t\t\tdata-danger={danger || undefined}\n\t\t\t\t\tmix={itemMix}\n\t\t\t\t>\n\t\t\t\t\t{children}\n\t\t\t\t</a>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={type ?? DEFAULT_ITEM_TYPE}\n\t\t\t\t{...rest}\n\t\t\t\tdata-danger={danger || undefined}\n\t\t\t\tmix={itemMix}\n\t\t\t>\n\t\t\t\t{children}\n\t\t\t</button>\n\t\t);\n\t};\n};\n\n/**\n * Renders a hairline divider between two runs of {@link Menu.Item}s: the\n * shared {@link Separator} component with the small block-axis margin a\n * menu's compact rows need on either side of it.\n *\n * @param handle Runtime handle carrying the host's {@link Separator} props.\n * @returns The render function producing the divider's markup.\n * @example\n * <Menu.Item href=\"/settings/profile\">{t(\"nav.profile\")}</Menu.Item>\n * <Menu.Separator />\n * <Menu.Item danger>{t(\"actions.signOut\")}</Menu.Item>\n */\nMenu.Separator = function MenuSeparator(handle: Handle<Menu.SeparatorProps>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\treturn <Separator {...rest} mix={[mb(1), mix]} />;\n\t};\n};\n"
14
+ },
15
+ "test": {
16
+ "path": "menu.test.tsx",
17
+ "content": "/**\n * Covers the menu surface's concentric corners, read from the stylesheet it\n * emits: its padding and radius both derive from `--ui-surface-padding`, so\n * the surface's corners stay concentric with its `--ui-radius-md` rows.\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 { Menu } from \"@sdxc/ui/menu\";\n\ndescribe(\"Menu\", () => {\n\ttest(\"rounds the surface as its rows' radius plus the padding between them\", async () => {\n\t\tlet html = await renderToString(\n\t\t\t<Menu id=\"actions\" aria-label=\"Actions\">\n\t\t\t\t<Menu.Item>Rename</Menu.Item>\n\t\t\t</Menu>,\n\t\t);\n\n\t\texpect(html).toContain(\"padding: var(--ui-surface-padding, 0.25rem)\");\n\t\texpect(html).toContain(\n\t\t\t\"border-radius: calc(var(--ui-radius-md, 0.375rem) + var(--ui-surface-padding, 0.25rem) + 1px)\",\n\t\t);\n\t});\n});\n"
18
+ }
19
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "name": "menubar",
3
+ "changedIn": "2026.10.13",
4
+ "dependencies": [],
5
+ "exports": [
6
+ "Menubar"
7
+ ],
8
+ "source": {
9
+ "path": "menubar.tsx",
10
+ "content": "/**\n * A horizontal row of top-level triggers modeled on a native application's\n * menu bar, where each trigger opens its own dropdown built from the\n * existing {@link Menu} component.\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 { bg, border, fg, outline } from \"@sdxc/u/color\";\nimport { opacity, rounded } from \"@sdxc/u/effects\";\nimport { cursor, raw, userSelect } from \"@sdxc/u/general\";\nimport { flex, gap, inlineFlex, items } from \"@sdxc/u/layout\";\nimport { p, pb, pi } from \"@sdxc/u/size\";\nimport { active, disabled, hover, when } from \"@sdxc/u/state\";\nimport { radius } from \"@sdxc/u/tokens\";\nimport { text, weight } from \"@sdxc/u/typography\";\nimport { attrs } from \"remix/component\";\n\nimport { concentricRadius, surfacePadding } from \"@sdxc/ui/styles\";\nimport { interactiveTransition } from \"@sdxc/ui/styles\";\nimport {\n\twarnIfNoAccessibleLabel,\n\twarnIfNoAccessibleName,\n} from \"@sdxc/ui/utils\";\n\n/**\n * `role=\"menubar\"` applied to {@link Menubar}'s host through {@link attrs}\n * unless a consumer supplies its own `role`, identifying the row as an ARIA\n * menubar.\n */\nconst DEFAULT_ROLE = \"menubar\";\n\n/**\n * `role` applied to {@link Menubar.Trigger} through {@link attrs} unless a\n * consumer supplies its own, identifying each top-level trigger as an ARIA\n * menu-bar item that owns a submenu.\n */\nconst DEFAULT_TRIGGER_ROLE = \"menuitem\";\n\n/**\n * `type` {@link Menubar.TriggerProps} falls back to when a consumer doesn't\n * supply one, keeping a click on the trigger from submitting a surrounding\n * `<form>` the way a bare `<button>`'s default type otherwise would.\n */\nconst DEFAULT_TRIGGER_TYPE: NonNullable<Menubar.TriggerProps[\"type\"]> = \"button\";\n\n/**\n * Invoker Commands verb {@link Menubar.TriggerProps.command} falls back to\n * when omitted: toggles the paired {@link Menu} between shown and hidden,\n * the same default a standalone {@link Menu} trigger uses.\n */\nconst DEFAULT_TRIGGER_COMMAND: NonNullable<Menubar.TriggerProps[\"command\"]> = \"toggle-popover\";\n\n/**\n * Prop types for {@link Menubar} and its compound parts.\n */\nexport namespace Menubar {\n\t/**\n\t * Every native `<div>` attribute, plus the `mix` passthrough.\n\t */\n\texport interface Props extends TagProps<\"div\"> {}\n\n\t/**\n\t * Every native `<button>` attribute, plus the `mix` passthrough, with\n\t * `commandfor` narrowed to required so it always points at the `id` of\n\t * the {@link Menu} this trigger opens.\n\t */\n\texport interface TriggerProps extends Omit<TagProps<\"button\">, \"commandfor\"> {\n\t\t/** `id` of the {@link Menu} this trigger opens. */\n\t\tcommandfor: string;\n\t}\n}\n\n/**\n * Renders the row's host: a native `<div>` carrying the `menubar` role for\n * {@link Menubar.Trigger}s. In dev mode, a root missing an `aria-label` or\n * `aria-labelledby` logs a `console.warn`.\n *\n * @param handle Runtime handle carrying the host `<div>`'s props.\n * @returns The render function producing the row's markup.\n * @example\n * <Menubar aria-label={t(\"app.menubar\")}>\n * \t<Menubar.Trigger commandfor=\"file-menu\">{t(\"menubar.file\")}</Menubar.Trigger>\n * \t<Menu id=\"file-menu\" aria-label={t(\"menubar.fileMenu\")}>\n * \t\t<Menu.Item>{t(\"actions.new\")}</Menu.Item>\n * \t\t<Menu.Item>{t(\"actions.open\")}</Menu.Item>\n * \t</Menu>\n *\n * \t<Menubar.Trigger commandfor=\"edit-menu\">{t(\"menubar.edit\")}</Menubar.Trigger>\n * \t<Menu id=\"edit-menu\" aria-label={t(\"menubar.editMenu\")}>\n * \t\t<Menu.Item>{t(\"actions.undo\")}</Menu.Item>\n * \t\t<Menu.Item>{t(\"actions.redo\")}</Menu.Item>\n * \t</Menu>\n * </Menubar>\n */\nexport function Menubar(handle: Handle<Menubar.Props>) {\n\treturn () => {\n\t\tlet { mix, ...rest } = handle.props;\n\n\t\twarnIfNoAccessibleLabel(\n\t\t\thandle.props,\n\t\t\t'Menubar: needs an \"aria-label\" or \"aria-labelledby\" identifying this menu bar for assistive technology.',\n\t\t);\n\n\t\treturn (\n\t\t\t<div\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tattrs({ role: DEFAULT_ROLE }),\n\t\t\t\t\tflex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(\"0.125rem\"),\n\t\t\t\t\traw({ borderRadius: concentricRadius(surfacePadding(1), radius(\"sm\")) }),\n\t\t\t\t\tborder({ color: \"neutral\", width: 1 }),\n\t\t\t\t\tbg(\"neutral.tint\"),\n\t\t\t\t\tp(surfacePadding(1)),\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 a single top-level trigger: a native `<button>` pointed at the\n * `id` of the {@link Menu} it opens through `commandfor`, with `command`\n * defaulting to `\"toggle-popover\"` and `role` to `\"menuitem\"`.\n *\n * @param handle Runtime handle carrying the host `<button>`'s props.\n * @returns The render function producing the trigger's markup.\n * @example\n * <Menubar.Trigger commandfor=\"file-menu\">{t(\"menubar.file\")}</Menubar.Trigger>\n * @example\n * <Menubar.Trigger commandfor=\"archived-menu\" aria-disabled=\"true\">\n * \t{t(\"menubar.archived\")}\n * </Menubar.Trigger>\n */\nMenubar.Trigger = function MenubarTrigger(handle: Handle<Menubar.TriggerProps>) {\n\treturn () => {\n\t\tlet { type, command, children, mix, ...rest } = handle.props;\n\t\tlet resolvedType = type ?? DEFAULT_TRIGGER_TYPE;\n\t\tlet resolvedCommand = command ?? DEFAULT_TRIGGER_COMMAND;\n\n\t\twarnIfNoAccessibleName(\n\t\t\thandle.props,\n\t\t\tchildren,\n\t\t\t\"Menubar.Trigger: a trigger with no visible text needs an `aria-label` describing it — assistive technology has no accessible name to announce otherwise.\",\n\t\t);\n\n\t\treturn (\n\t\t\t<button\n\t\t\t\ttype={resolvedType}\n\t\t\t\tcommand={resolvedCommand}\n\t\t\t\t{...rest}\n\t\t\t\tmix={[\n\t\t\t\t\tinteractiveTransition(),\n\t\t\t\t\tattrs({ role: DEFAULT_TRIGGER_ROLE, \"aria-haspopup\": \"menu\" }),\n\t\t\t\t\tinlineFlex(),\n\t\t\t\t\titems(\"center\"),\n\t\t\t\t\tgap(2),\n\t\t\t\t\trounded(\"sm\"),\n\t\t\t\t\tpi(3),\n\t\t\t\t\tpb(\"0.375rem\"),\n\t\t\t\t\tfg(\"neutral\"),\n\t\t\t\t\thover([bg(\"neutral.bg-tint-hover\"), fg(\"neutral.emphasis\")]),\n\t\t\t\t\tactive(bg(\"neutral.bg-tint-pressed\")),\n\t\t\t\t\twhen('&[aria-expanded=\"true\"]', [bg(\"brand.solid\"), fg(\"brand.onSolid\")]),\n\t\t\t\t\twhen(\"&:focus-visible\", outline({ color: \"brand.ring\", offset: 2 })),\n\t\t\t\t\tdisabled([opacity(50), cursor(\"not-allowed\")]),\n\t\t\t\t\tcursor(\"default\"),\n\t\t\t\t\tweight(500),\n\t\t\t\t\tuserSelect(),\n\t\t\t\t\ttext(\"sm\"),\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</button>\n\t\t);\n\t};\n};\n"
11
+ },
12
+ "test": null
13
+ }