dowel-ui 0.31.0 → 0.32.0
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.
- package/README.md +2 -2
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +55 -19
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/palettes/atlas.json +1 -1
- package/dist/palettes/austeris.json +1 -1
- package/dist/palettes/dowel.json +1 -1
- package/dist/palettes/efema.json +1 -1
- package/dist/palettes/furca.json +1 -1
- package/dist/palettes/hilvan.json +1 -1
- package/dist/palettes/kasl-server.json +1 -1
- package/dist/palettes/kasl.json +1 -1
- package/dist/palettes/kilna.json +1 -1
- package/dist/palettes/lyrid.json +1 -1
- package/dist/palettes/lyrn.json +1 -1
- package/dist/palettes/midda.json +1 -1
- package/dist/palettes/nitid.json +1 -1
- package/dist/palettes/nooma.json +1 -1
- package/dist/palettes/rhapsod.json +1 -1
- package/dist/palettes/rigger.json +1 -1
- package/dist/palettes/scheda.json +1 -1
- package/dist/palettes/sefy.json +1 -1
- package/dist/palettes/turnout.json +1 -1
- package/dist/registry.json +163 -123
- package/dist/theme.css +39 -0
- package/dist/tokens.json +7 -0
- package/package.json +1 -1
package/dist/registry.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"path": "dowel/theme.css",
|
|
15
15
|
"target": "~/dowel/theme.css",
|
|
16
16
|
"type": "registry:file",
|
|
17
|
-
"content": "/*\n * dowel theme - the token vocabulary every product of the lacodda line shares.\n *\n * The vocabulary comes from the products themselves: kilna and kasl-server\n * already ship the same token names (bg / raise / soft / line / text / dim /\n * accent / good / warn / bad / info) and differ only in values. That is the\n * contract this file freezes. Names are the mockup's own words rather than\n * stock component-library names, so a screen can be checked against a mockup\n * in the mockup's words.\n *\n * Two things are parametric, and everything else is derived from them:\n *\n * --accent-base the product's hue from the brand-line registry\n * --neutral-base the hue the greys are tinted with (the accent, by default)\n *\n * Tinting the neutrals is not decoration - it is what the two live products do\n * by hand: kilna's greys lean magenta, kasl-server's lean gold. Here that lean\n * is one declaration instead of thirty hand-picked hex values.\n *\n * Soft variants are mixed from their own base with `color-mix`, so a product\n * that overrides `--accent-base` gets a matching `--accent-soft` for free and\n * cannot pick one that disagrees with it.\n *\n * Theme selection: no class on the root element follows the operating system,\n * an explicit `light` or `dark` class pins the theme. Components never use\n * `dark:` utilities - every colour goes through a token, and the theme swaps\n * the token underneath.\n */\n\n:root {\n /* The two parameters. `--accent-base` is overridden per product by an accent\n * file; `--neutral-base` follows it unless a product says otherwise. */\n --accent-base: #e8862d;\n --neutral-base: var(--accent-base);\n\n /* Ink and ground of the dark theme, before the neutral tint is mixed in.\n * Kept as their own tokens so the tint amount is the only thing that\n * changes when a product wants greyer or warmer chrome. */\n --ground: #131316;\n --ink: #ece9ef;\n\n /* How much of `--neutral-base` bleeds into the greys. The live products sit\n * at roughly this much: enough that the chrome belongs to the product,\n * little enough that it still reads as grey. */\n --neutral-tint: 6%;\n --neutral-tint-strong: 9%;\n\n color-scheme: dark;\n\n --bg: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ground));\n --raise: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), #1c1c21);\n\n /* Surfaces that lift by translucency rather than by their own colour: they\n * must work over `--bg` and over `--raise` alike. */\n --soft: rgb(255 255 255 / 0.045);\n --softer: rgb(255 255 255 / 0.025);\n --line: rgb(255 255 255 / 0.08);\n --line-2: rgb(255 255 255 / 0.15);\n\n --text: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ink));\n --dim: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #a7a2ad);\n --faint: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #6e6a76);\n\n --accent: var(--accent-base);\n /* The hover/active partner: lighter on dark, where the ground is what the\n * accent has to separate from. */\n --accent-2: color-mix(in oklab, white 22%, var(--accent-base));\n --accent-soft: color-mix(in oklab, var(--accent-base) 16%, transparent);\n\n /* Status hues are the line's own and do not follow the product accent: a\n * green that shifted per product would stop meaning \"good\". Meaning never\n * rests on colour alone - a badge carries an icon and a word - so these\n * exist for emphasis, not as the message. */\n --good: #45d18f;\n --warn: #e8b13f;\n --bad: #ef6a6a;\n --info: #4cc4e0;\n --good-soft: color-mix(in oklab, var(--good) 14%, transparent);\n --warn-soft: color-mix(in oklab, var(--warn) 14%, transparent);\n --bad-soft: color-mix(in oklab, var(--bad) 14%, transparent);\n --info-soft: color-mix(in oklab, var(--info) 15%, transparent);\n\n /* Series colours, for charts.\n *\n * Like the status hues and unlike everything else here, these do NOT follow\n * the product accent - and that is the whole decision. A series is a\n * property of the data, not of the product showing it; a palette derived\n * from the accent would paint the same series differently in kilna and in\n * kasl-server, which is the one thing a series colour must never do.\n *\n * Deriving them from the accent was measured, not guessed: rotating the hue\n * by fixed angles put the best candidate at Delta-E 12.1 from the product's\n * own accent with adjacent pairs at 9.8, and threw 46 of 152 colours outside\n * sRGB. The fixed palette does better on both counts.\n *\n * The cost of fixing them is stated plainly: 13 of the line's 19 accents sit\n * within Delta-E 8 of some slot (lyrid 2.7, atlas 3.1, turnout 3.2). A chart\n * shows one accent, so this is survivable - but it is exactly why identity is\n * carried by the legend and by direct labels, never by hue on its own. The\n * components of this block enforce that; it is not advice.\n *\n * Assigned in order, 1..8, and never cycled: a ninth series folds into\n * \"other\", or the chart becomes small multiples. The order is the\n * colour-blind-safety mechanism - the worst adjacent pair is Delta-E 8.4\n * under simulated protanopia - so re-ordering these breaks a gate.\n *\n * Slot 8 is the line's own value rather than the reference palette's. The\n * reference red sat Delta-E 1.9 from `--bad`, which would have let a series\n * impersonate a status; this one clears every status by 15 and costs\n * nothing, the worst adjacent pair being unchanged.\n *\n * Some slots sit below 3:1 against the surface. That is allowed only because\n * the relief ships with them: visible values, or the table view.\n */\n --series-1: #3987e5;\n --series-2: #d95926;\n --series-3: #199e70;\n --series-4: #c98500;\n --series-5: #d55181;\n --series-6: #008300;\n --series-7: #9085e9;\n --series-8: #a3215a;\n\n /* Magnitude rather than identity: one hue, light to dark. A heatmap cell\n * reads this. The lightest step is allowed to recede toward the surface,\n * because \"near zero\" should; an ordered-but-discrete scale (tiers, funnel\n * stages) starts at 300 instead, where the contrast still holds. */\n --scale-100: #0d366b;\n --scale-200: #184f95;\n --scale-300: #256abf;\n --scale-400: #2a78d6;\n --scale-500: #3987e5;\n --scale-600: #5598e7;\n --scale-700: #86b6ef;\n\n /* The chart's own furniture. A gridline that competes with the data is drawn\n * wrong, so it is quieter than `--line`; the axis is the one that may be\n * seen. */\n --chart-grid: rgb(255 255 255 / 0.06);\n --chart-axis: rgb(255 255 255 / 0.14);\n\n /* Heat, for a grid of cells where colour is the only thing carrying the\n * value - a year of activity, a month of a team's hours.\n *\n * Five discrete steps rather than the seven of `--scale-*`, and a separate\n * set rather than a slice of them, because the two answer different\n * questions. `--scale-*` is sequential: a continuous magnitude, where the\n * lightest step means \"near zero\" and may recede toward the surface.\n * Heat is ordinal: five shades a reader tells apart at a glance and matches\n * against a legend, which needs wider gaps between them (no slice of\n * `--scale-*` clears the 0.06 lightness step - they sit 0.047 apart) and a\n * bottom step that stays distinct from an empty cell.\n *\n * That last one is the whole point. A heatmap cell has more meanings than a\n * number: nothing recorded, a day still running, a day outside the data, and\n * a value. If the faintest value looks like the empty cell, the grid says\n * somebody did nothing on a day nobody reported - and `--heat-1` clears the\n * empty square by 2.1:1 so it cannot.\n *\n * Fixed, like the series and unlike almost everything else here. Derived\n * from the accent - as the first consumer did - the faintest step sat 1.3:1\n * from the empty cell for half the line, and pinning lightness instead ran\n * out of sRGB: the darkest accents cannot reach the top of the ramp at their\n * own chroma.\n */\n --heat-1: #28528e;\n --heat-2: #3a65a3;\n --heat-3: #4d78b7;\n --heat-4: #608ccd;\n --heat-5: #73a0e2;\n\n /* Syntax, for code shown inside a product.\n *\n * Eight kinds rather than the fifty a highlighter's theme names, because\n * these are the distinctions that survive across languages: a keyword, a\n * literal string, a number, a comment, an identifier, a type, punctuation,\n * and the metadata around the code (a decorator, an attribute, a prompt).\n * Anything finer is a grammar's own vocabulary and does not travel.\n *\n * Fixed, like the series and the heat ramps, and for the same reason: code\n * is not a property of the product showing it, and `if` should not be\n * magenta in kilna and cobalt in kasl-server.\n *\n * Chosen against the surface code actually sits on - `--soft` over `--bg`,\n * which is what CodeBlock and `.prose pre` draw - and every slot clears\n * 4.5:1 AS TEXT in both themes. That threshold, not the 3:1 the series are\n * held to, is the whole reason these exist separately: the series palette\n * was measured here first and five of its eight light values sat under 3:1,\n * one at 1.90:1. A filled bar can be pale; a 12px glyph cannot.\n *\n * These are deliberately NOT held to the colour-blind floor the series are.\n * A series colour is the identity of its mark - lose the hue and the data is\n * gone. Syntax colour is a second reading of what the text already says in\n * full: a keyword is a keyword by its spelling, and CodeBlock's default\n * renders no colour at all and stays readable. `syntax.test.ts` says so in\n * place, so the omission is not mistaken for an oversight.\n *\n * `comment` is the quietest on purpose - it is the one kind a reader is\n * meant to be able to skip - and still clears the threshold.\n */\n --syntax-keyword: #c792ea;\n --syntax-string: #9ccc65;\n --syntax-number: #f78c6c;\n --syntax-comment: #9e99a6;\n --syntax-name: #82aaff;\n --syntax-type: #4dd0b1;\n --syntax-punctuation: #c4bfcb;\n --syntax-meta: #f0a868;\n\n /* Elevation, three steps. The products had one shadow and used it for\n * everything that leaves the flow - a toast, a dropdown and a modal all\n * floated by the same amount, so a modal never felt further away than the\n * menu it covered. The three are the steps.\n *\n * Two layers each, and that is what makes them read as depth on a dark\n * surface rather than as a stain. One big soft blur at high opacity is what\n * these were - `0 24px 60px` of 55% black - and against a near-black page\n * the wide skirt never resolves into shade: it just darkens a ring of\n * background around the panel, which a pilot photographed and called an ugly\n * dark contour. Depth is read from the CONTACT shadow, the tight one right\n * under the edge; the ambient layer only has to hint that there is room\n * under the thing. So each step is a tight, slightly stronger layer plus a\n * wider, much weaker one, and the totals come down. */\n --shadow-lift: 0 1px 2px rgb(0 0 0 / 0.4), 0 2px 6px rgb(0 0 0 / 0.22);\n --shadow-raise: 0 2px 4px rgb(0 0 0 / 0.36), 0 8px 20px rgb(0 0 0 / 0.26);\n --shadow-float: 0 4px 8px rgb(0 0 0 / 0.36), 0 18px 44px rgb(0 0 0 / 0.32);\n}\n\n/*\n * Light theme, twice: once for the operating system's preference, once for the\n * explicit `light` class. The declarations are identical - only the selector\n * differs - so that a product can pin a theme against the system setting.\n */\n@media (prefers-color-scheme: light) {\n :root:not(.dark) {\n color-scheme: light;\n\n --ground: #f6f5f7;\n --ink: #232027;\n\n --bg: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ground));\n --raise: #ffffff;\n\n /* Tinted, and translucent - which took two goes to get right.\n *\n * `color-mix` mixes the alpha along with the colour, so mixing 60% of an\n * opaque accent into a 5%-opaque grey gives a surface 62% opaque: twelve\n * times denser than the hairline it was meant to be. It went unnoticed for\n * ten versions because `bg-soft` was only ever used for a hover, where a\n * flash of colour reads as feedback rather than as a mistake. The first\n * component to sit on it permanently - Alert - made it obvious.\n *\n * `oklch(from … / alpha)` keeps the alpha out of the mix: the hue comes\n * from the tinted colour, the transparency is stated. */\n --soft: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.05);\n --softer: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.03);\n --line: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.11);\n --line-2: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.2);\n\n --text: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ink));\n --dim: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #63606b);\n --faint: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #8a8692);\n\n /* On a light ground the accent has to darken to stay legible as text and\n * as a fill. It darkens *to* a lightness rather than *by* an amount: how\n * far a hue has to travel depends on where it starts, and a fixed step\n * that suits magenta leaves lime and gold short. Pinning the lightness and\n * keeping the hue and chroma clears 5:1 for every accent in the line. */\n --accent: oklch(from var(--accent-base) 0.5 c h);\n --accent-2: oklch(from var(--accent-base) 0.4 c h);\n --accent-soft: color-mix(in oklab, var(--accent-base) 12%, transparent);\n\n --good: #0c8554;\n --warn: #9a6b0c;\n --bad: #c93b3b;\n --info: #0d7f9c;\n --good-soft: color-mix(in oklab, var(--good) 12%, transparent);\n --warn-soft: color-mix(in oklab, var(--warn) 14%, transparent);\n --bad-soft: color-mix(in oklab, var(--bad) 12%, transparent);\n --info-soft: color-mix(in oklab, var(--info) 11%, transparent);\n\n /* Series and scale, stepped for the light surface - the same eight hues\n * chosen again against this ground, not the dark values lightened. The dark\n * block says why these do not follow the product accent. */\n --series-1: #2a78d6;\n --series-2: #eb6834;\n --series-3: #1baf7a;\n --series-4: #eda100;\n --series-5: #e87ba4;\n --series-6: #008300;\n --series-7: #4a3aa7;\n --series-8: #85284d;\n\n --scale-100: #cde2fb;\n --scale-200: #9ec5f4;\n --scale-300: #6da7ec;\n --scale-400: #3987e5;\n --scale-500: #2a78d6;\n --scale-600: #1c5cab;\n --scale-700: #104281;\n\n --chart-grid: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.08);\n --chart-axis: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.18);\n\n /* The same five steps chosen again for the light ground, running the other\n * way: here \"more\" is darker. See the dark block for why heat is its own\n * ramp and not a slice of `--scale-*`. */\n --heat-1: #84a8fd;\n --heat-2: #7193e7;\n --heat-3: #5e7fd1;\n --heat-4: #4c6cbb;\n --heat-5: #3b58a6;\n\n /* The same eight kinds chosen again for the light ground - not the dark\n * values darkened. Each clears 4.5:1 as text against `--soft` over this\n * theme's `--bg`; the dark block says why syntax is its own palette and\n * why it is not held to the colour-blind floor. */\n --syntax-keyword: #7c3aad;\n --syntax-string: #276c2b;\n --syntax-number: #b5451b;\n --syntax-comment: #6f6b78;\n --syntax-name: #1a5fb4;\n --syntax-type: #00695c;\n --syntax-punctuation: #4a4753;\n --syntax-meta: #9c4a00;\n\n --shadow-lift: 0 2px 8px rgb(30 24 38 / 0.08);\n --shadow-raise: 0 10px 30px rgb(30 24 38 / 0.14);\n --shadow-float: 0 24px 60px rgb(30 24 38 / 0.18);\n }\n}\n\n:root.light {\n color-scheme: light;\n\n --ground: #f6f5f7;\n --ink: #232027;\n\n --bg: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ground));\n --raise: #ffffff;\n\n /* The same surfaces as above; see the note there. */\n --soft: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.05);\n --softer: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.03);\n --line: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.11);\n --line-2: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.2);\n\n --text: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ink));\n --dim: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #63606b);\n --faint: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #8a8692);\n\n /* Darkened to a lightness, not by an amount - see the note above. */\n --accent: oklch(from var(--accent-base) 0.5 c h);\n --accent-2: oklch(from var(--accent-base) 0.4 c h);\n --accent-soft: color-mix(in oklab, var(--accent-base) 12%, transparent);\n\n --good: #0c8554;\n --warn: #9a6b0c;\n --bad: #c93b3b;\n --info: #0d7f9c;\n --good-soft: color-mix(in oklab, var(--good) 12%, transparent);\n --warn-soft: color-mix(in oklab, var(--warn) 14%, transparent);\n --bad-soft: color-mix(in oklab, var(--bad) 12%, transparent);\n --info-soft: color-mix(in oklab, var(--info) 11%, transparent);\n\n /* Series and scale, stepped for the light surface - the same eight hues\n * chosen again against this ground, not the dark values lightened. The dark\n * block says why these do not follow the product accent. */\n --series-1: #2a78d6;\n --series-2: #eb6834;\n --series-3: #1baf7a;\n --series-4: #eda100;\n --series-5: #e87ba4;\n --series-6: #008300;\n --series-7: #4a3aa7;\n --series-8: #85284d;\n\n --scale-100: #cde2fb;\n --scale-200: #9ec5f4;\n --scale-300: #6da7ec;\n --scale-400: #3987e5;\n --scale-500: #2a78d6;\n --scale-600: #1c5cab;\n --scale-700: #104281;\n\n --chart-grid: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.08);\n --chart-axis: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.18);\n\n /* The same five steps chosen again for the light ground, running the other\n * way: here \"more\" is darker. See the dark block for why heat is its own\n * ramp and not a slice of `--scale-*`. */\n --heat-1: #84a8fd;\n --heat-2: #7193e7;\n --heat-3: #5e7fd1;\n --heat-4: #4c6cbb;\n --heat-5: #3b58a6;\n\n /* The same eight kinds chosen again for the light ground - not the dark\n * values darkened. Each clears 4.5:1 as text against `--soft` over this\n * theme's `--bg`; the dark block says why syntax is its own palette and\n * why it is not held to the colour-blind floor. */\n --syntax-keyword: #7c3aad;\n --syntax-string: #276c2b;\n --syntax-number: #b5451b;\n --syntax-comment: #6f6b78;\n --syntax-name: #1a5fb4;\n --syntax-type: #00695c;\n --syntax-punctuation: #4a4753;\n --syntax-meta: #9c4a00;\n\n --shadow-lift: 0 2px 8px rgb(30 24 38 / 0.08);\n --shadow-raise: 0 10px 30px rgb(30 24 38 / 0.14);\n --shadow-float: 0 24px 60px rgb(30 24 38 / 0.18);\n}\n\n/*\n * `--on-accent` - what sits on top of an accent fill.\n *\n * A light accent (gold, lime, amber) needs dark glyphs; a dark one needs\n * white. The live products picked this by hand and wrote the answer into the\n * theme; here the theme works it out, by the same rule the brand-line S tile\n * uses.\n *\n * `contrast-color()` is the direct way to say it and is used where supported.\n * The fallback covers browsers that lack it. Relative colour syntax exposes\n * the accent's own lightness as `l`; `clamp()` turns that into a hard switch,\n * because the multiplication drives the middle term far past either bound\n * everywhere except within a hair of the threshold. Below it the accent is\n * dark and the result is 1 (white); above it, 0 (black). Chroma is dropped to\n * zero, so what comes out is neutral rather than a tinted grey.\n *\n * The threshold is 0.58, and it is deliberately far below the midpoint an eye\n * would guess. Contrast is not symmetric about it: a mid-lightness colour is\n * still much closer to white than to black in luminance, so black wins well\n * before the colour looks light. Checked against all fourteen accents of the\n * line - every one of them reads better with dark glyphs, the closest being\n * cobalt at 4.86:1 against 4.32:1 for white. A higher threshold is what puts\n * white text on magenta at 3.6:1, which is the defect this rule exists to\n * prevent.\n */\n:root {\n --on-accent: oklch(from var(--accent) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n\n /*\n * The same question for the status fills, and it has to be asked separately:\n * `--on-accent` is derived from the accent, so using it on a `--warn` fill\n * is only ever right by coincidence. The line's first consumer did exactly\n * that - a count on a yellow badge, drawn in white at 1.95:1 - and it read\n * as correct for as long as the product happened to pin white.\n *\n * The status hues do not follow the product accent, so these four are the\n * same for every product; they are still derived rather than written down,\n * because the status colours themselves change between the themes.\n */\n --on-good: oklch(from var(--good) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n --on-warn: oklch(from var(--warn) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n --on-bad: oklch(from var(--bad) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n --on-info: oklch(from var(--info) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n}\n\n@supports (color: contrast-color(red)) {\n :root {\n --on-accent: contrast-color(var(--accent));\n --on-good: contrast-color(var(--good));\n --on-warn: contrast-color(var(--warn));\n --on-bad: contrast-color(var(--bad));\n --on-info: contrast-color(var(--info));\n }\n}\n\n/*\n * The Tailwind 4 surface. `--color-*: initial` drops the stock palette on\n * purpose: a raw `bg-zinc-800` in a product should not compile, because the\n * only colours that exist here are the line's own.\n */\n@theme inline {\n --color-*: initial;\n --color-bg: var(--bg);\n --color-raise: var(--raise);\n --color-soft: var(--soft);\n --color-softer: var(--softer);\n --color-line: var(--line);\n --color-line-2: var(--line-2);\n --color-text: var(--text);\n --color-dim: var(--dim);\n --color-faint: var(--faint);\n --color-accent: var(--accent);\n --color-accent-2: var(--accent-2);\n --color-accent-soft: var(--accent-soft);\n --color-on-accent: var(--on-accent);\n --color-on-good: var(--on-good);\n --color-on-warn: var(--on-warn);\n --color-on-bad: var(--on-bad);\n --color-on-info: var(--on-info);\n --color-good: var(--good);\n --color-good-soft: var(--good-soft);\n --color-warn: var(--warn);\n --color-warn-soft: var(--warn-soft);\n --color-bad: var(--bad);\n --color-bad-soft: var(--bad-soft);\n --color-info: var(--info);\n --color-info-soft: var(--info-soft);\n\n /* Charts. `bg-series-3`, `fill-series-3`, `stroke-scale-500` - the same\n * utilities the rest of the vocabulary gets, so a chart is written in\n * tokens like everything else and `dowel/no-raw-color` can hold it to\n * that. */\n --color-series-1: var(--series-1);\n --color-series-2: var(--series-2);\n --color-series-3: var(--series-3);\n --color-series-4: var(--series-4);\n --color-series-5: var(--series-5);\n --color-series-6: var(--series-6);\n --color-series-7: var(--series-7);\n --color-series-8: var(--series-8);\n --color-scale-100: var(--scale-100);\n --color-scale-200: var(--scale-200);\n --color-scale-300: var(--scale-300);\n --color-scale-400: var(--scale-400);\n --color-scale-500: var(--scale-500);\n --color-scale-600: var(--scale-600);\n --color-scale-700: var(--scale-700);\n --color-chart-grid: var(--chart-grid);\n --color-chart-axis: var(--chart-axis);\n --color-heat-1: var(--heat-1);\n --color-heat-2: var(--heat-2);\n --color-heat-3: var(--heat-3);\n --color-heat-4: var(--heat-4);\n --color-heat-5: var(--heat-5);\n\n /* Syntax, so a highlighted token is written `text-syntax-keyword` like every\n * other colour in the system, and `dowel/no-raw-color` can hold it to that.\n * A highlighter's own stylesheet - which writes hex values into class names\n * of its own choosing - is what this replaces. */\n --color-syntax-keyword: var(--syntax-keyword);\n --color-syntax-string: var(--syntax-string);\n --color-syntax-number: var(--syntax-number);\n --color-syntax-comment: var(--syntax-comment);\n --color-syntax-name: var(--syntax-name);\n --color-syntax-type: var(--syntax-type);\n --color-syntax-punctuation: var(--syntax-punctuation);\n --color-syntax-meta: var(--syntax-meta);\n\n /* Kept because they are not palette choices: a hairline is `transparent`,\n * an SVG follows `currentColor`, and pure black and white are what an\n * overlay scrim and a print sheet are made of. */\n --color-transparent: transparent;\n --color-current: currentColor;\n --color-white: #fff;\n --color-black: #000;\n\n /*\n * Type. System stacks on purpose: a downloaded face costs a network round\n * trip before the first word appears, and the line's products are desktop\n * tools where the operating system's own face is the one the user already\n * reads everything else in.\n */\n --font-sans: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;\n --font-mono: ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, monospace;\n\n /*\n * Radius. Taken from what the products actually draw, not from a ratio:\n * `rounded-[9px]` appears twenty times and `rounded-[10px]` twelve, because\n * a control and the primary button were tuned by eye and then copied. The\n * scale keeps the cluster they landed in and gives it names.\n *\n * `md` is the control radius - inputs, buttons, list rows. That the primary\n * button was one pixel rounder than every other variant is not preserved:\n * the products differ from themselves there, and buttons of the same size\n * sitting side by side should not have mismatched corners.\n */\n --radius-xs: 4px;\n --radius-sm: 6px;\n --radius-md: 9px;\n --radius-lg: 12px;\n --radius-xl: 16px;\n --radius-2xl: 20px;\n\n /*\n * A radius nested inside another has to be smaller by the gap between them,\n * or the inner corner looks wrong against the outer one. The products did\n * this by hand once - 18px outside, 17px inside - and nowhere else.\n */\n --radius-inner: calc(var(--radius-lg) - 1px);\n\n /*\n * Type scale. The products live between 10px and 14px: `text-sm` and\n * `text-xs` together account for nine tenths of every size in both, and the\n * rest scattered across 9, 9.5, 10, 10.5, 11, 11.5, 12.5 and 13 - nine steps\n * inside four pixels, which no eye distinguishes and no reason justifies.\n * This is the same range with the noise removed.\n */\n --text-2xs: 10px;\n --text-2xs--line-height: 14px;\n --text-xs: 11px;\n --text-xs--line-height: 15px;\n --text-sm: 12px;\n --text-sm--line-height: 16px;\n --text-base: 14px;\n --text-base--line-height: 20px;\n --text-lg: 16px;\n --text-lg--line-height: 22px;\n --text-xl: 18px;\n --text-xl--line-height: 24px;\n --text-2xl: 21px;\n --text-2xl--line-height: 28px;\n\n /* Weights. `semibold` is what both products use for anything emphasised;\n * `bold` appears in neither, and the one `font-[650]` in a page title is the\n * kind of value a scale exists to absorb. */\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n\n /* Tracking. The uppercase caption is the only place the products track at\n * all - and they do it at 0.08em in six files and 0.09em in three, a\n * difference nobody can see. One name settles it. */\n --tracking-caption: 0.085em;\n --tracking-tight: -0.01em;\n\n /*\n * A step between the steps.\n *\n * The spacing scale runs in fours - 2, 4, 6, 8 - and four different\n * primitives independently reached past it for three pixels: the gap\n * between segments of a rating and of an axis, the gap between cells of a\n * heatmap, and how far a tooltip's arrow tucks under its popup. Four hands\n * arriving at the same number is not four accidents; it is a step the scale\n * was missing, and each of them wrote `[3px]` because there was nothing to\n * name.\n *\n * It exists for hairline gaps between things that are themselves small -\n * where two pixels reads as touching and four as separate objects. Nothing\n * larger belongs here: this is the bottom of the scale, not a licence to\n * measure by eye.\n */\n --spacing-hair: 3px;\n\n /*\n /* Easing. `out` for anything the user asked for - it arrives fast and\n * settles, which reads as responsive. `in-out` for something moving on its\n * own. `in` is deliberately absent: it starts slowly, which on a control\n * reads as lag. */\n --ease-out: cubic-bezier(0.2, 0, 0, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n /*\n * Elevation. Three steps, because the products had one and used it for a\n * toast, a dropdown and a modal alike - so a modal never sat further from\n * the page than the menu it covered.\n */\n --shadow-lift: var(--shadow-lift);\n --shadow-raise: var(--shadow-raise);\n --shadow-float: var(--shadow-float);\n\n /*\n * The smallest a pointer target may be.\n *\n * 24 CSS pixels, which is WCAG 2.2's 2.5.8 at AA. Not a matter of taste, and\n * measured rather than assumed: a live run of the stand found four different\n * answers to the same question in one set - a chip's cross at 16, Copyable\n * at 19, CopyButton at 21, a search field's clear at 24. Three of the four\n * fail, and the failure is silent. A cross missed by a thumb on a tablet, or\n * by anyone whose hand is not steady, does not delete the tag and does not\n * say anything either.\n *\n * It is a size token rather than a spacing step because it is a floor, not a\n * rhythm: nothing is ever `--target-min` tall on purpose, things are at\n * least that big. `size-target` and `min-size-target` come free from the\n * namespace, but the way a primitive usually reaches it is `target-min`\n * below, which grows the hit area without growing the glyph.\n */\n --size-target: 24px;\n\n /*\n * The window's own chrome: the strip at the top, the rail at the left, and\n * the buttons that close the window.\n *\n * Four products of the line draw their own title bar - the trade is that a\n * system bar over an application bar costs a strip of every laptop screen\n * for nothing - and by the time the fourth one did it, the strip was 40px\n * in one and 2.4rem in another. Neither number is wrong; having two is. A\n * window's chrome is the part of a product that is supposed to look like\n * the operating system rather than like the product, so it is the last\n * place where two of them should differ.\n *\n * 40px is not a taste either. The window buttons have to clear the pointer\n * target floor with room for the hover fill to read as a button, and the\n * strip has to hold a mark, a trail and a search box at one line of text\n * without the trail wrapping. 40 is where both stop being tight.\n *\n * `--spacing-window-button` is 46px because that is what Windows draws, and\n * a bar whose buttons are narrower than the system's has a gap the pointer\n * falls into on the way to the corner. It is deliberately wider than it is\n * tall: the close button is the one that must be hit without aiming, and on\n * a maximised window it is the screen's corner.\n *\n * These are in the spacing namespace rather than beside `--size-target`,\n * and the reason is mechanical rather than tidy. `--size-*` yields exactly\n * one utility, `size-*`, which sets both axes - so `w-window-button` off a\n * `--size-` token compiles to NOTHING, and a button written that way loses\n * its width with no error anywhere. Every measurement here is one axis: the\n * bar has a height, the rail a width, the button a width unequal to its\n * height. `--spacing-*` is the namespace that feeds `w-`, `h-`, `min-h-`\n * and the padding utilities, so it is the one that can say so. Caught by\n * compiling the utility rather than by reading the stylesheet, which is\n * what `tailwind.test.ts` exists for.\n */\n --spacing-titlebar: 40px;\n --spacing-rail: 216px;\n --spacing-window-button: 46px;\n\n /*\n * How much of a frameless window's edge can be grabbed to resize it.\n *\n * The system used to own this and gave about 4 pixels plus whatever the\n * border was; a frameless window has no border, so the whole of it has to\n * be put back by hand. Five is the smallest that can be hit reliably with a\n * mouse and the largest that does not steal a click meant for the first\n * line of text - the strips sit above everything, so anything they cover\n * they cover completely.\n *\n * The corner is double, because a corner is aimed at less precisely than an\n * edge and is the one that resizes both axes at once.\n */\n --spacing-resize-edge: 5px;\n --spacing-resize-corner: 10px;\n}\n\n/*\n * `target-min` - visually smaller, clickably larger.\n *\n * The obvious fix for a 16px cross is to make it 24px, and it is the wrong\n * one: a chip is a small thing by design and a cross a third of its height\n * reads as a button with a chip around it. The set's appearance is a\n * decision, and an accessibility floor should not overturn it.\n *\n * So the target grows and the glyph does not. The pseudo-element is centred on\n * the control, takes its size, and refuses to go under the floor - so a\n * control already large enough is untouched, and a smaller one gains an\n * invisible margin of hit area on every side.\n *\n * `position: relative` comes with it rather than being left to the caller: a\n * target that silently does nothing because its parent forgot to establish a\n * containing block is exactly the failure this exists to prevent.\n *\n * Not `padding`, which was the other candidate: padding moves the glyph inside\n * its box and changes how the control sits in a flex row, so every call site\n * would need a compensating negative margin. This changes nothing about\n * layout.\n */\n@utility target-min {\n position: relative;\n\n &::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n translate: -50% -50%;\n width: 100%;\n height: 100%;\n min-width: var(--size-target);\n min-height: var(--size-target);\n }\n}\n\n/*\n * How tall a control is, and how much room a screen gives each row.\n *\n * `h-9` appeared in nine primitives - every field the set has - each spelling\n * it out, which is why `Input` could not be made compact without editing\n * `Input`. One decision made nine times gets one name.\n *\n * **Not in `@theme`, and that is the whole mechanism.** A token declared there\n * is inlined by the compiler: `h-control` came out as `height: 36px`, the\n * override on a container had nothing to bind to, and the density attribute\n * did exactly nothing. Measured in the browser rather than assumed - the\n * container's `--row-control` read 32px while the field it contained stayed\n * 36. Tailwind also writes a fallback for any `var()` it recognises from the\n * theme, so the name has to live outside the theme's namespaces entirely.\n *\n * Declared here as plain custom properties and turned into utilities by hand\n * below, the reference survives, and an override on an ancestor reaches every\n * control under it - which is what makes density a property of a region\n * rather than of a component.\n */\n:root {\n --row-control: 36px;\n --row-control-sm: 32px;\n --row-control-lg: 40px;\n\n /* The same question for a table, whose rows are sized by what is above and\n * below the text rather than by a height. `Table` had its own `density`\n * prop for this, with its own words - `base` and `dense` - which meant the\n * set used one word for two mechanisms and a product had to set both. */\n --row-cell: 10px;\n}\n\n@utility h-control {\n height: var(--row-control);\n}\n\n@utility py-row {\n padding-block: var(--row-cell);\n}\n\n@utility h-control-sm {\n height: var(--row-control-sm);\n}\n\n@utility h-control-lg {\n height: var(--row-control-lg);\n}\n\n/*\n * Density.\n *\n * Two answers to one question, and the set had neither: a product wanting a\n * tighter table wrote `h-8` at every call site, which is the drift the scale\n * exists to stop, one screen at a time.\n *\n * **It is an attribute on a container, not a prop on a component.** A prop\n * would have to be added to every primitive, threaded through every wrapper a\n * product writes, and passed by hand at each call site - and a primitive\n * written next year would not have it. An attribute is inherited:\n *\n * <form data-density=\"compact\"> …every field inside it…\n *\n * That reaches components which did not exist when the product was built, and\n * a product's own components too, as long as they measure in `h-control` like\n * everything else.\n *\n * The floor does not move with it. `--size-target` stays 24px at every\n * density, because WCAG does not care how tight a table is - which is exactly\n * why `target-min` grows the hit area rather than the control: a compact row\n * is still one a hand can hit.\n */\n[data-density='compact'] {\n --row-control: 32px;\n --row-control-sm: 28px;\n --row-control-lg: 36px;\n --row-cell: 6px;\n}\n\n[data-density='comfortable'] {\n --row-control: 40px;\n --row-control-sm: 36px;\n --row-control-lg: 44px;\n --row-cell: 14px;\n}\n\n/*\n * Stacking order.\n *\n * Not in `@theme`: Tailwind has no z-index namespace, so `z-50` is a literal\n * fifty and a named step would not compile. These are custom properties a\n * component reads directly - `z-index: var(--z-modal)`.\n *\n * The order is the products' own, with the gaps closed. They ran 10 for an\n * in-flow popup, 20 sticky, 30 menu, 40 for a floating button, 50 for modals\n * and drawers, then jumped to 70 and 80 for the command palette - which had to\n * clear the modal layer and had no name to do it with.\n */\n:root {\n /*\n * Motion. One duration existed before this - 160ms on a route change - and\n * everything else rode Tailwind's default. These are the steps around it:\n * `quick` for a colour or an opacity that should feel immediate, `base` for\n * something that moves, `slow` for something arriving from off-screen.\n *\n * Not in `@theme`: Tailwind's `duration-*` utility takes a literal number,\n * not a named step, so these are read directly - `transition-duration:\n * var(--duration-base)`. The easing curves opposite them ARE a namespace,\n * so `ease-out` is a class.\n *\n * Every duration here is for people who want motion: `prefers-reduced-\n * motion` cuts them to nothing further down.\n */\n --duration-quick: 120ms;\n --duration-base: 160ms;\n --duration-slow: 240ms;\n\n --z-popup: 10;\n --z-sticky: 20;\n --z-menu: 30;\n --z-floating: 40;\n --z-overlay: 50;\n --z-modal: 60;\n --z-palette: 70;\n --z-toast: 80;\n}\n\n/*\n * Base layer: what every product would otherwise write again. Scoped to\n * elements and to `:focus-visible`, never to a class, so nothing here can\n * collide with a component.\n */\nbody {\n margin: 0;\n background-color: var(--bg);\n color: var(--text);\n font-family: var(--font-sans);\n -webkit-font-smoothing: antialiased;\n}\n\n/*\n * In `@layer base`, so a component can turn it off.\n *\n * Unlayered, this rule has the same specificity as `focus-visible:outline-none`\n * from Tailwind - both are one pseudo-class - and wins on source order alone,\n * because the theme is imported before the utilities. Every component that\n * draws its own focus ring got this one on top of it: the command palette's\n * field had an accent outline it had explicitly opted out of, and a combobox\n * with chips drew two rings, one around the box and one around the input\n * inside it.\n *\n * A layered rule loses to any unlayered one regardless of specificity, which\n * is the whole point of cascade layers - the base layer states a default and\n * a component overrides it by saying so.\n */\n@layer base {\n :focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n *,\n *::before,\n *::after {\n transition-duration: 0.01ms !important;\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n scroll-behavior: auto !important;\n }\n}\n\n/*\n * Scrollbars. A browser's default bar is a piece of someone else's chrome\n * sitting in the middle of the product - full width, with step arrows. These\n * are the line's own: thin, in the palette, drawn only where something\n * actually scrolls.\n */\n* {\n scrollbar-width: thin;\n scrollbar-color: var(--line-2) transparent;\n}\n\n*::-webkit-scrollbar {\n width: 10px;\n height: 10px;\n}\n\n*::-webkit-scrollbar-track {\n background: transparent;\n}\n\n*::-webkit-scrollbar-thumb {\n border: 3px solid transparent;\n border-radius: 999px;\n background: var(--line-2);\n background-clip: content-box;\n /* The thumb is drawn proportional to how much of the document fits on\n * screen, so a long one collapses it to a few pixels: still visible, no\n * longer catchable by a pointer. This is the floor below which it stops\n * being a control. */\n min-height: 2.5rem;\n}\n\n*::-webkit-scrollbar-thumb:hover {\n background: var(--dim);\n background-clip: content-box;\n}\n\n*::-webkit-scrollbar-corner {\n background: transparent;\n}\n\n*::-webkit-scrollbar-button {\n display: none;\n}\n"
|
|
17
|
+
"content": "/*\n * dowel theme - the token vocabulary every product of the lacodda line shares.\n *\n * The vocabulary comes from the products themselves: kilna and kasl-server\n * already ship the same token names (bg / raise / soft / line / text / dim /\n * accent / good / warn / bad / info) and differ only in values. That is the\n * contract this file freezes. Names are the mockup's own words rather than\n * stock component-library names, so a screen can be checked against a mockup\n * in the mockup's words.\n *\n * Two things are parametric, and everything else is derived from them:\n *\n * --accent-base the product's hue from the brand-line registry\n * --neutral-base the hue the greys are tinted with (the accent, by default)\n *\n * Tinting the neutrals is not decoration - it is what the two live products do\n * by hand: kilna's greys lean magenta, kasl-server's lean gold. Here that lean\n * is one declaration instead of thirty hand-picked hex values.\n *\n * Soft variants are mixed from their own base with `color-mix`, so a product\n * that overrides `--accent-base` gets a matching `--accent-soft` for free and\n * cannot pick one that disagrees with it.\n *\n * Theme selection: no class on the root element follows the operating system,\n * an explicit `light` or `dark` class pins the theme. Components never use\n * `dark:` utilities - every colour goes through a token, and the theme swaps\n * the token underneath.\n */\n\n:root {\n /* The two parameters. `--accent-base` is overridden per product by an accent\n * file; `--neutral-base` follows it unless a product says otherwise. */\n --accent-base: #e8862d;\n --neutral-base: var(--accent-base);\n\n /* Ink and ground of the dark theme, before the neutral tint is mixed in.\n * Kept as their own tokens so the tint amount is the only thing that\n * changes when a product wants greyer or warmer chrome. */\n --ground: #131316;\n --ink: #ece9ef;\n\n /* How much of `--neutral-base` bleeds into the greys. The live products sit\n * at roughly this much: enough that the chrome belongs to the product,\n * little enough that it still reads as grey. */\n --neutral-tint: 6%;\n --neutral-tint-strong: 9%;\n\n color-scheme: dark;\n\n --bg: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ground));\n --raise: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), #1c1c21);\n\n /* Surfaces that lift by translucency rather than by their own colour: they\n * must work over `--bg` and over `--raise` alike. */\n --soft: rgb(255 255 255 / 0.045);\n --softer: rgb(255 255 255 / 0.025);\n --line: rgb(255 255 255 / 0.08);\n --line-2: rgb(255 255 255 / 0.15);\n\n --text: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ink));\n --dim: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #a7a2ad);\n --faint: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #6e6a76);\n\n --accent: var(--accent-base);\n /* The hover/active partner: lighter on dark, where the ground is what the\n * accent has to separate from. */\n --accent-2: color-mix(in oklab, white 22%, var(--accent-base));\n --accent-soft: color-mix(in oklab, var(--accent-base) 16%, transparent);\n\n /* Status hues are the line's own and do not follow the product accent: a\n * green that shifted per product would stop meaning \"good\". Meaning never\n * rests on colour alone - a badge carries an icon and a word - so these\n * exist for emphasis, not as the message. */\n --good: #45d18f;\n --warn: #e8b13f;\n --bad: #ef6a6a;\n --info: #4cc4e0;\n --good-soft: color-mix(in oklab, var(--good) 14%, transparent);\n --warn-soft: color-mix(in oklab, var(--warn) 14%, transparent);\n --bad-soft: color-mix(in oklab, var(--bad) 14%, transparent);\n --info-soft: color-mix(in oklab, var(--info) 15%, transparent);\n\n /* Series colours, for charts.\n *\n * Like the status hues and unlike everything else here, these do NOT follow\n * the product accent - and that is the whole decision. A series is a\n * property of the data, not of the product showing it; a palette derived\n * from the accent would paint the same series differently in kilna and in\n * kasl-server, which is the one thing a series colour must never do.\n *\n * Deriving them from the accent was measured, not guessed: rotating the hue\n * by fixed angles put the best candidate at Delta-E 12.1 from the product's\n * own accent with adjacent pairs at 9.8, and threw 46 of 152 colours outside\n * sRGB. The fixed palette does better on both counts.\n *\n * The cost of fixing them is stated plainly: 13 of the line's 19 accents sit\n * within Delta-E 8 of some slot (lyrid 2.7, atlas 3.1, turnout 3.2). A chart\n * shows one accent, so this is survivable - but it is exactly why identity is\n * carried by the legend and by direct labels, never by hue on its own. The\n * components of this block enforce that; it is not advice.\n *\n * Assigned in order, 1..8, and never cycled: a ninth series folds into\n * \"other\", or the chart becomes small multiples. The order is the\n * colour-blind-safety mechanism - the worst adjacent pair is Delta-E 8.4\n * under simulated protanopia - so re-ordering these breaks a gate.\n *\n * Slot 8 is the line's own value rather than the reference palette's. The\n * reference red sat Delta-E 1.9 from `--bad`, which would have let a series\n * impersonate a status; this one clears every status by 15 and costs\n * nothing, the worst adjacent pair being unchanged.\n *\n * Some slots sit below 3:1 against the surface. That is allowed only because\n * the relief ships with them: visible values, or the table view.\n */\n --series-1: #3987e5;\n --series-2: #d95926;\n --series-3: #199e70;\n --series-4: #c98500;\n --series-5: #d55181;\n --series-6: #008300;\n --series-7: #9085e9;\n --series-8: #a3215a;\n\n /* Magnitude rather than identity: one hue, light to dark. A heatmap cell\n * reads this. The lightest step is allowed to recede toward the surface,\n * because \"near zero\" should; an ordered-but-discrete scale (tiers, funnel\n * stages) starts at 300 instead, where the contrast still holds. */\n --scale-100: #0d366b;\n --scale-200: #184f95;\n --scale-300: #256abf;\n --scale-400: #2a78d6;\n --scale-500: #3987e5;\n --scale-600: #5598e7;\n --scale-700: #86b6ef;\n\n /* The chart's own furniture. A gridline that competes with the data is drawn\n * wrong, so it is quieter than `--line`; the axis is the one that may be\n * seen. */\n --chart-grid: rgb(255 255 255 / 0.06);\n --chart-axis: rgb(255 255 255 / 0.14);\n\n /* Heat, for a grid of cells where colour is the only thing carrying the\n * value - a year of activity, a month of a team's hours.\n *\n * Five discrete steps rather than the seven of `--scale-*`, and a separate\n * set rather than a slice of them, because the two answer different\n * questions. `--scale-*` is sequential: a continuous magnitude, where the\n * lightest step means \"near zero\" and may recede toward the surface.\n * Heat is ordinal: five shades a reader tells apart at a glance and matches\n * against a legend, which needs wider gaps between them (no slice of\n * `--scale-*` clears the 0.06 lightness step - they sit 0.047 apart) and a\n * bottom step that stays distinct from an empty cell.\n *\n * That last one is the whole point. A heatmap cell has more meanings than a\n * number: nothing recorded, a day still running, a day outside the data, and\n * a value. If the faintest value looks like the empty cell, the grid says\n * somebody did nothing on a day nobody reported - and `--heat-1` clears the\n * empty square by 2.1:1 so it cannot.\n *\n * Fixed, like the series and unlike almost everything else here. Derived\n * from the accent - as the first consumer did - the faintest step sat 1.3:1\n * from the empty cell for half the line, and pinning lightness instead ran\n * out of sRGB: the darkest accents cannot reach the top of the ramp at their\n * own chroma.\n */\n --heat-1: #28528e;\n --heat-2: #3a65a3;\n --heat-3: #4d78b7;\n --heat-4: #608ccd;\n --heat-5: #73a0e2;\n\n /* Syntax, for code shown inside a product.\n *\n * Eight kinds rather than the fifty a highlighter's theme names, because\n * these are the distinctions that survive across languages: a keyword, a\n * literal string, a number, a comment, an identifier, a type, punctuation,\n * and the metadata around the code (a decorator, an attribute, a prompt).\n * Anything finer is a grammar's own vocabulary and does not travel.\n *\n * Fixed, like the series and the heat ramps, and for the same reason: code\n * is not a property of the product showing it, and `if` should not be\n * magenta in kilna and cobalt in kasl-server.\n *\n * Chosen against the surface code actually sits on - `--soft` over `--bg`,\n * which is what CodeBlock and `.prose pre` draw - and every slot clears\n * 4.5:1 AS TEXT in both themes. That threshold, not the 3:1 the series are\n * held to, is the whole reason these exist separately: the series palette\n * was measured here first and five of its eight light values sat under 3:1,\n * one at 1.90:1. A filled bar can be pale; a 12px glyph cannot.\n *\n * These are deliberately NOT held to the colour-blind floor the series are.\n * A series colour is the identity of its mark - lose the hue and the data is\n * gone. Syntax colour is a second reading of what the text already says in\n * full: a keyword is a keyword by its spelling, and CodeBlock's default\n * renders no colour at all and stays readable. `syntax.test.ts` says so in\n * place, so the omission is not mistaken for an oversight.\n *\n * `comment` is the quietest on purpose - it is the one kind a reader is\n * meant to be able to skip - and still clears the threshold.\n */\n --syntax-keyword: #c792ea;\n --syntax-string: #9ccc65;\n --syntax-number: #f78c6c;\n --syntax-comment: #9e99a6;\n --syntax-name: #82aaff;\n --syntax-type: #4dd0b1;\n --syntax-punctuation: #c4bfcb;\n --syntax-meta: #f0a868;\n\n /* Elevation, three steps. The products had one shadow and used it for\n * everything that leaves the flow - a toast, a dropdown and a modal all\n * floated by the same amount, so a modal never felt further away than the\n * menu it covered. The three are the steps.\n *\n * Two layers each, and that is what makes them read as depth on a dark\n * surface rather than as a stain. One big soft blur at high opacity is what\n * these were - `0 24px 60px` of 55% black - and against a near-black page\n * the wide skirt never resolves into shade: it just darkens a ring of\n * background around the panel, which a pilot photographed and called an ugly\n * dark contour. Depth is read from the CONTACT shadow, the tight one right\n * under the edge; the ambient layer only has to hint that there is room\n * under the thing. So each step is a tight, slightly stronger layer plus a\n * wider, much weaker one, and the totals come down. */\n --shadow-lift: 0 1px 2px rgb(0 0 0 / 0.4), 0 2px 6px rgb(0 0 0 / 0.22);\n --shadow-raise: 0 2px 4px rgb(0 0 0 / 0.36), 0 8px 20px rgb(0 0 0 / 0.26);\n --shadow-float: 0 4px 8px rgb(0 0 0 / 0.36), 0 18px 44px rgb(0 0 0 / 0.32);\n}\n\n/*\n * Light theme, twice: once for the operating system's preference, once for the\n * explicit `light` class. The declarations are identical - only the selector\n * differs - so that a product can pin a theme against the system setting.\n */\n@media (prefers-color-scheme: light) {\n :root:not(.dark) {\n color-scheme: light;\n\n --ground: #f6f5f7;\n --ink: #232027;\n\n --bg: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ground));\n --raise: #ffffff;\n\n /* Tinted, and translucent - which took two goes to get right.\n *\n * `color-mix` mixes the alpha along with the colour, so mixing 60% of an\n * opaque accent into a 5%-opaque grey gives a surface 62% opaque: twelve\n * times denser than the hairline it was meant to be. It went unnoticed for\n * ten versions because `bg-soft` was only ever used for a hover, where a\n * flash of colour reads as feedback rather than as a mistake. The first\n * component to sit on it permanently - Alert - made it obvious.\n *\n * `oklch(from … / alpha)` keeps the alpha out of the mix: the hue comes\n * from the tinted colour, the transparency is stated. */\n --soft: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.05);\n --softer: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.03);\n --line: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.11);\n --line-2: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.2);\n\n --text: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ink));\n --dim: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #63606b);\n --faint: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #8a8692);\n\n /* On a light ground the accent has to darken to stay legible as text and\n * as a fill. It darkens *to* a lightness rather than *by* an amount: how\n * far a hue has to travel depends on where it starts, and a fixed step\n * that suits magenta leaves lime and gold short. Pinning the lightness and\n * keeping the hue and chroma clears 5:1 for every accent in the line. */\n --accent: oklch(from var(--accent-base) 0.5 c h);\n --accent-2: oklch(from var(--accent-base) 0.4 c h);\n --accent-soft: color-mix(in oklab, var(--accent-base) 12%, transparent);\n\n --good: #0c8554;\n --warn: #9a6b0c;\n --bad: #c93b3b;\n --info: #0d7f9c;\n --good-soft: color-mix(in oklab, var(--good) 12%, transparent);\n --warn-soft: color-mix(in oklab, var(--warn) 14%, transparent);\n --bad-soft: color-mix(in oklab, var(--bad) 12%, transparent);\n --info-soft: color-mix(in oklab, var(--info) 11%, transparent);\n\n /* Series and scale, stepped for the light surface - the same eight hues\n * chosen again against this ground, not the dark values lightened. The dark\n * block says why these do not follow the product accent. */\n --series-1: #2a78d6;\n --series-2: #eb6834;\n --series-3: #1baf7a;\n --series-4: #eda100;\n --series-5: #e87ba4;\n --series-6: #008300;\n --series-7: #4a3aa7;\n --series-8: #85284d;\n\n --scale-100: #cde2fb;\n --scale-200: #9ec5f4;\n --scale-300: #6da7ec;\n --scale-400: #3987e5;\n --scale-500: #2a78d6;\n --scale-600: #1c5cab;\n --scale-700: #104281;\n\n --chart-grid: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.08);\n --chart-axis: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.18);\n\n /* The same five steps chosen again for the light ground, running the other\n * way: here \"more\" is darker. See the dark block for why heat is its own\n * ramp and not a slice of `--scale-*`. */\n --heat-1: #84a8fd;\n --heat-2: #7193e7;\n --heat-3: #5e7fd1;\n --heat-4: #4c6cbb;\n --heat-5: #3b58a6;\n\n /* The same eight kinds chosen again for the light ground - not the dark\n * values darkened. Each clears 4.5:1 as text against `--soft` over this\n * theme's `--bg`; the dark block says why syntax is its own palette and\n * why it is not held to the colour-blind floor. */\n --syntax-keyword: #7c3aad;\n --syntax-string: #276c2b;\n --syntax-number: #b5451b;\n --syntax-comment: #6f6b78;\n --syntax-name: #1a5fb4;\n --syntax-type: #00695c;\n --syntax-punctuation: #4a4753;\n --syntax-meta: #9c4a00;\n\n --shadow-lift: 0 2px 8px rgb(30 24 38 / 0.08);\n --shadow-raise: 0 10px 30px rgb(30 24 38 / 0.14);\n --shadow-float: 0 24px 60px rgb(30 24 38 / 0.18);\n }\n}\n\n:root.light {\n color-scheme: light;\n\n --ground: #f6f5f7;\n --ink: #232027;\n\n --bg: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ground));\n --raise: #ffffff;\n\n /* The same surfaces as above; see the note there. */\n --soft: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.05);\n --softer: oklch(from color-mix(in oklab, var(--neutral-base) 45%, #181420) l c h / 0.03);\n --line: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.11);\n --line-2: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.2);\n\n --text: color-mix(in oklab, var(--neutral-base) var(--neutral-tint), var(--ink));\n --dim: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #63606b);\n --faint: color-mix(in oklab, var(--neutral-base) var(--neutral-tint-strong), #8a8692);\n\n /* Darkened to a lightness, not by an amount - see the note above. */\n --accent: oklch(from var(--accent-base) 0.5 c h);\n --accent-2: oklch(from var(--accent-base) 0.4 c h);\n --accent-soft: color-mix(in oklab, var(--accent-base) 12%, transparent);\n\n --good: #0c8554;\n --warn: #9a6b0c;\n --bad: #c93b3b;\n --info: #0d7f9c;\n --good-soft: color-mix(in oklab, var(--good) 12%, transparent);\n --warn-soft: color-mix(in oklab, var(--warn) 14%, transparent);\n --bad-soft: color-mix(in oklab, var(--bad) 12%, transparent);\n --info-soft: color-mix(in oklab, var(--info) 11%, transparent);\n\n /* Series and scale, stepped for the light surface - the same eight hues\n * chosen again against this ground, not the dark values lightened. The dark\n * block says why these do not follow the product accent. */\n --series-1: #2a78d6;\n --series-2: #eb6834;\n --series-3: #1baf7a;\n --series-4: #eda100;\n --series-5: #e87ba4;\n --series-6: #008300;\n --series-7: #4a3aa7;\n --series-8: #85284d;\n\n --scale-100: #cde2fb;\n --scale-200: #9ec5f4;\n --scale-300: #6da7ec;\n --scale-400: #3987e5;\n --scale-500: #2a78d6;\n --scale-600: #1c5cab;\n --scale-700: #104281;\n\n --chart-grid: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.08);\n --chart-axis: oklch(from color-mix(in oklab, var(--neutral-base) 30%, #181420) l c h / 0.18);\n\n /* The same five steps chosen again for the light ground, running the other\n * way: here \"more\" is darker. See the dark block for why heat is its own\n * ramp and not a slice of `--scale-*`. */\n --heat-1: #84a8fd;\n --heat-2: #7193e7;\n --heat-3: #5e7fd1;\n --heat-4: #4c6cbb;\n --heat-5: #3b58a6;\n\n /* The same eight kinds chosen again for the light ground - not the dark\n * values darkened. Each clears 4.5:1 as text against `--soft` over this\n * theme's `--bg`; the dark block says why syntax is its own palette and\n * why it is not held to the colour-blind floor. */\n --syntax-keyword: #7c3aad;\n --syntax-string: #276c2b;\n --syntax-number: #b5451b;\n --syntax-comment: #6f6b78;\n --syntax-name: #1a5fb4;\n --syntax-type: #00695c;\n --syntax-punctuation: #4a4753;\n --syntax-meta: #9c4a00;\n\n --shadow-lift: 0 2px 8px rgb(30 24 38 / 0.08);\n --shadow-raise: 0 10px 30px rgb(30 24 38 / 0.14);\n --shadow-float: 0 24px 60px rgb(30 24 38 / 0.18);\n}\n\n/*\n * `--on-accent` - what sits on top of an accent fill.\n *\n * A light accent (gold, lime, amber) needs dark glyphs; a dark one needs\n * white. The live products picked this by hand and wrote the answer into the\n * theme; here the theme works it out, by the same rule the brand-line S tile\n * uses.\n *\n * `contrast-color()` is the direct way to say it and is used where supported.\n * The fallback covers browsers that lack it. Relative colour syntax exposes\n * the accent's own lightness as `l`; `clamp()` turns that into a hard switch,\n * because the multiplication drives the middle term far past either bound\n * everywhere except within a hair of the threshold. Below it the accent is\n * dark and the result is 1 (white); above it, 0 (black). Chroma is dropped to\n * zero, so what comes out is neutral rather than a tinted grey.\n *\n * The threshold is 0.58, and it is deliberately far below the midpoint an eye\n * would guess. Contrast is not symmetric about it: a mid-lightness colour is\n * still much closer to white than to black in luminance, so black wins well\n * before the colour looks light. Checked against all fourteen accents of the\n * line - every one of them reads better with dark glyphs, the closest being\n * cobalt at 4.86:1 against 4.32:1 for white. A higher threshold is what puts\n * white text on magenta at 3.6:1, which is the defect this rule exists to\n * prevent.\n */\n:root {\n --on-accent: oklch(from var(--accent) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n\n /*\n * The same question for the status fills, and it has to be asked separately:\n * `--on-accent` is derived from the accent, so using it on a `--warn` fill\n * is only ever right by coincidence. The line's first consumer did exactly\n * that - a count on a yellow badge, drawn in white at 1.95:1 - and it read\n * as correct for as long as the product happened to pin white.\n *\n * The status hues do not follow the product accent, so these four are the\n * same for every product; they are still derived rather than written down,\n * because the status colours themselves change between the themes.\n */\n --on-good: oklch(from var(--good) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n --on-warn: oklch(from var(--warn) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n --on-bad: oklch(from var(--bad) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n --on-info: oklch(from var(--info) clamp(0, (0.58 - l) * 1000, 1) 0 0);\n}\n\n@supports (color: contrast-color(red)) {\n :root {\n --on-accent: contrast-color(var(--accent));\n --on-good: contrast-color(var(--good));\n --on-warn: contrast-color(var(--warn));\n --on-bad: contrast-color(var(--bad));\n --on-info: contrast-color(var(--info));\n }\n}\n\n/*\n * The Tailwind 4 surface. `--color-*: initial` drops the stock palette on\n * purpose: a raw `bg-zinc-800` in a product should not compile, because the\n * only colours that exist here are the line's own.\n */\n@theme inline {\n --color-*: initial;\n --color-bg: var(--bg);\n --color-raise: var(--raise);\n --color-soft: var(--soft);\n --color-softer: var(--softer);\n --color-line: var(--line);\n --color-line-2: var(--line-2);\n --color-text: var(--text);\n --color-dim: var(--dim);\n --color-faint: var(--faint);\n --color-accent: var(--accent);\n --color-accent-2: var(--accent-2);\n --color-accent-soft: var(--accent-soft);\n --color-on-accent: var(--on-accent);\n --color-on-good: var(--on-good);\n --color-on-warn: var(--on-warn);\n --color-on-bad: var(--on-bad);\n --color-on-info: var(--on-info);\n --color-good: var(--good);\n --color-good-soft: var(--good-soft);\n --color-warn: var(--warn);\n --color-warn-soft: var(--warn-soft);\n --color-bad: var(--bad);\n --color-bad-soft: var(--bad-soft);\n --color-info: var(--info);\n --color-info-soft: var(--info-soft);\n\n /* Charts. `bg-series-3`, `fill-series-3`, `stroke-scale-500` - the same\n * utilities the rest of the vocabulary gets, so a chart is written in\n * tokens like everything else and `dowel/no-raw-color` can hold it to\n * that. */\n --color-series-1: var(--series-1);\n --color-series-2: var(--series-2);\n --color-series-3: var(--series-3);\n --color-series-4: var(--series-4);\n --color-series-5: var(--series-5);\n --color-series-6: var(--series-6);\n --color-series-7: var(--series-7);\n --color-series-8: var(--series-8);\n --color-scale-100: var(--scale-100);\n --color-scale-200: var(--scale-200);\n --color-scale-300: var(--scale-300);\n --color-scale-400: var(--scale-400);\n --color-scale-500: var(--scale-500);\n --color-scale-600: var(--scale-600);\n --color-scale-700: var(--scale-700);\n --color-chart-grid: var(--chart-grid);\n --color-chart-axis: var(--chart-axis);\n --color-heat-1: var(--heat-1);\n --color-heat-2: var(--heat-2);\n --color-heat-3: var(--heat-3);\n --color-heat-4: var(--heat-4);\n --color-heat-5: var(--heat-5);\n\n /* Syntax, so a highlighted token is written `text-syntax-keyword` like every\n * other colour in the system, and `dowel/no-raw-color` can hold it to that.\n * A highlighter's own stylesheet - which writes hex values into class names\n * of its own choosing - is what this replaces. */\n --color-syntax-keyword: var(--syntax-keyword);\n --color-syntax-string: var(--syntax-string);\n --color-syntax-number: var(--syntax-number);\n --color-syntax-comment: var(--syntax-comment);\n --color-syntax-name: var(--syntax-name);\n --color-syntax-type: var(--syntax-type);\n --color-syntax-punctuation: var(--syntax-punctuation);\n --color-syntax-meta: var(--syntax-meta);\n\n /* Kept because they are not palette choices: a hairline is `transparent`,\n * an SVG follows `currentColor`, and pure black and white are what an\n * overlay scrim and a print sheet are made of. */\n --color-transparent: transparent;\n --color-current: currentColor;\n --color-white: #fff;\n --color-black: #000;\n\n /*\n * Type. System stacks on purpose: a downloaded face costs a network round\n * trip before the first word appears, and the line's products are desktop\n * tools where the operating system's own face is the one the user already\n * reads everything else in.\n */\n --font-sans: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, sans-serif;\n --font-mono: ui-monospace, 'Cascadia Code', 'SF Mono', Consolas, monospace;\n\n /*\n * Radius. Taken from what the products actually draw, not from a ratio:\n * `rounded-[9px]` appears twenty times and `rounded-[10px]` twelve, because\n * a control and the primary button were tuned by eye and then copied. The\n * scale keeps the cluster they landed in and gives it names.\n *\n * `md` is the control radius - inputs, buttons, list rows. That the primary\n * button was one pixel rounder than every other variant is not preserved:\n * the products differ from themselves there, and buttons of the same size\n * sitting side by side should not have mismatched corners.\n */\n --radius-xs: 4px;\n --radius-sm: 6px;\n --radius-md: 9px;\n --radius-lg: 12px;\n --radius-xl: 16px;\n --radius-2xl: 20px;\n\n /*\n * A radius nested inside another has to be smaller by the gap between them,\n * or the inner corner looks wrong against the outer one. The products did\n * this by hand once - 18px outside, 17px inside - and nowhere else.\n */\n --radius-inner: calc(var(--radius-lg) - 1px);\n\n /*\n * Type scale. The products live between 10px and 14px: `text-sm` and\n * `text-xs` together account for nine tenths of every size in both, and the\n * rest scattered across 9, 9.5, 10, 10.5, 11, 11.5, 12.5 and 13 - nine steps\n * inside four pixels, which no eye distinguishes and no reason justifies.\n * This is the same range with the noise removed.\n */\n --text-2xs: 10px;\n --text-2xs--line-height: 14px;\n --text-xs: 11px;\n --text-xs--line-height: 15px;\n --text-sm: 12px;\n --text-sm--line-height: 16px;\n --text-base: 14px;\n --text-base--line-height: 20px;\n --text-lg: 16px;\n --text-lg--line-height: 22px;\n --text-xl: 18px;\n --text-xl--line-height: 24px;\n --text-2xl: 21px;\n --text-2xl--line-height: 28px;\n\n /* Weights. `semibold` is what both products use for anything emphasised;\n * `bold` appears in neither, and the one `font-[650]` in a page title is the\n * kind of value a scale exists to absorb. */\n --font-weight-normal: 400;\n --font-weight-medium: 500;\n --font-weight-semibold: 600;\n\n /* Tracking. The uppercase caption is the only place the products track at\n * all - and they do it at 0.08em in six files and 0.09em in three, a\n * difference nobody can see. One name settles it. */\n --tracking-caption: 0.085em;\n --tracking-tight: -0.01em;\n\n /*\n * A step between the steps.\n *\n * The spacing scale runs in fours - 2, 4, 6, 8 - and four different\n * primitives independently reached past it for three pixels: the gap\n * between segments of a rating and of an axis, the gap between cells of a\n * heatmap, and how far a tooltip's arrow tucks under its popup. Four hands\n * arriving at the same number is not four accidents; it is a step the scale\n * was missing, and each of them wrote `[3px]` because there was nothing to\n * name.\n *\n * It exists for hairline gaps between things that are themselves small -\n * where two pixels reads as touching and four as separate objects. Nothing\n * larger belongs here: this is the bottom of the scale, not a licence to\n * measure by eye.\n */\n --spacing-hair: 3px;\n\n /*\n /* Easing. `out` for anything the user asked for - it arrives fast and\n * settles, which reads as responsive. `in-out` for something moving on its\n * own. `in` is deliberately absent: it starts slowly, which on a control\n * reads as lag. */\n --ease-out: cubic-bezier(0.2, 0, 0, 1);\n --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);\n\n /*\n * Elevation. Three steps, because the products had one and used it for a\n * toast, a dropdown and a modal alike - so a modal never sat further from\n * the page than the menu it covered.\n */\n --shadow-lift: var(--shadow-lift);\n --shadow-raise: var(--shadow-raise);\n --shadow-float: var(--shadow-float);\n\n /*\n * The smallest a pointer target may be.\n *\n * 24 CSS pixels, which is WCAG 2.2's 2.5.8 at AA. Not a matter of taste, and\n * measured rather than assumed: a live run of the stand found four different\n * answers to the same question in one set - a chip's cross at 16, Copyable\n * at 19, CopyButton at 21, a search field's clear at 24. Three of the four\n * fail, and the failure is silent. A cross missed by a thumb on a tablet, or\n * by anyone whose hand is not steady, does not delete the tag and does not\n * say anything either.\n *\n * It is a size token rather than a spacing step because it is a floor, not a\n * rhythm: nothing is ever `--target-min` tall on purpose, things are at\n * least that big. `size-target` and `min-size-target` come free from the\n * namespace, but the way a primitive usually reaches it is `target-min`\n * below, which grows the hit area without growing the glyph.\n */\n --size-target: 24px;\n\n /*\n * The window's own chrome: the strip at the top, the rail at the left, and\n * the buttons that close the window.\n *\n * Four products of the line draw their own title bar - the trade is that a\n * system bar over an application bar costs a strip of every laptop screen\n * for nothing - and by the time the fourth one did it, the strip was 40px\n * in one and 2.4rem in another. Neither number is wrong; having two is. A\n * window's chrome is the part of a product that is supposed to look like\n * the operating system rather than like the product, so it is the last\n * place where two of them should differ.\n *\n * 40px is not a taste either. The window buttons have to clear the pointer\n * target floor with room for the hover fill to read as a button, and the\n * strip has to hold a mark, a trail and a search box at one line of text\n * without the trail wrapping. 40 is where both stop being tight.\n *\n * `--spacing-window-button` is 46px because that is what Windows draws, and\n * a bar whose buttons are narrower than the system's has a gap the pointer\n * falls into on the way to the corner. It is deliberately wider than it is\n * tall: the close button is the one that must be hit without aiming, and on\n * a maximised window it is the screen's corner.\n *\n * These are in the spacing namespace rather than beside `--size-target`,\n * and the reason is mechanical rather than tidy. `--size-*` yields exactly\n * one utility, `size-*`, which sets both axes - so `w-window-button` off a\n * `--size-` token compiles to NOTHING, and a button written that way loses\n * its width with no error anywhere. Every measurement here is one axis: the\n * bar has a height, the rail a width, the button a width unequal to its\n * height. `--spacing-*` is the namespace that feeds `w-`, `h-`, `min-h-`\n * and the padding utilities, so it is the one that can say so. Caught by\n * compiling the utility rather than by reading the stylesheet, which is\n * what `tailwind.test.ts` exists for.\n */\n --spacing-titlebar: 40px;\n --spacing-rail: 216px;\n --spacing-window-button: 46px;\n\n /*\n * How much of a frameless window's edge can be grabbed to resize it.\n *\n * The system used to own this and gave about 4 pixels plus whatever the\n * border was; a frameless window has no border, so the whole of it has to\n * be put back by hand. Five is the smallest that can be hit reliably with a\n * mouse and the largest that does not steal a click meant for the first\n * line of text - the strips sit above everything, so anything they cover\n * they cover completely.\n *\n * The corner is double, because a corner is aimed at less precisely than an\n * edge and is the one that resizes both axes at once.\n */\n --spacing-resize-edge: 5px;\n --spacing-resize-corner: 10px;\n}\n\n/*\n * `target-min` - visually smaller, clickably larger.\n *\n * The obvious fix for a 16px cross is to make it 24px, and it is the wrong\n * one: a chip is a small thing by design and a cross a third of its height\n * reads as a button with a chip around it. The set's appearance is a\n * decision, and an accessibility floor should not overturn it.\n *\n * So the target grows and the glyph does not. The pseudo-element is centred on\n * the control, takes its size, and refuses to go under the floor - so a\n * control already large enough is untouched, and a smaller one gains an\n * invisible margin of hit area on every side.\n *\n * `position: relative` comes with it rather than being left to the caller: a\n * target that silently does nothing because its parent forgot to establish a\n * containing block is exactly the failure this exists to prevent.\n *\n * Not `padding`, which was the other candidate: padding moves the glyph inside\n * its box and changes how the control sits in a flex row, so every call site\n * would need a compensating negative margin. This changes nothing about\n * layout.\n */\n@utility target-min {\n position: relative;\n\n &::after {\n content: '';\n position: absolute;\n top: 50%;\n left: 50%;\n translate: -50% -50%;\n width: 100%;\n height: 100%;\n min-width: var(--size-target);\n min-height: var(--size-target);\n }\n}\n\n/*\n * How tall a control is, and how much room a screen gives each row.\n *\n * `h-9` appeared in nine primitives - every field the set has - each spelling\n * it out, which is why `Input` could not be made compact without editing\n * `Input`. One decision made nine times gets one name.\n *\n * **Not in `@theme`, and that is the whole mechanism.** A token declared there\n * is inlined by the compiler: `h-control` came out as `height: 36px`, the\n * override on a container had nothing to bind to, and the density attribute\n * did exactly nothing. Measured in the browser rather than assumed - the\n * container's `--row-control` read 32px while the field it contained stayed\n * 36. Tailwind also writes a fallback for any `var()` it recognises from the\n * theme, so the name has to live outside the theme's namespaces entirely.\n *\n * Declared here as plain custom properties and turned into utilities by hand\n * below, the reference survives, and an override on an ancestor reaches every\n * control under it - which is what makes density a property of a region\n * rather than of a component.\n */\n:root {\n --row-control: 36px;\n --row-control-sm: 32px;\n --row-control-lg: 40px;\n\n /* The same question for a table, whose rows are sized by what is above and\n * below the text rather than by a height. `Table` had its own `density`\n * prop for this, with its own words - `base` and `dense` - which meant the\n * set used one word for two mechanisms and a product had to set both. */\n --row-cell: 10px;\n}\n\n@utility h-control {\n height: var(--row-control);\n}\n\n@utility py-row {\n padding-block: var(--row-cell);\n}\n\n@utility h-control-sm {\n height: var(--row-control-sm);\n}\n\n@utility h-control-lg {\n height: var(--row-control-lg);\n}\n\n/*\n * Density.\n *\n * Two answers to one question, and the set had neither: a product wanting a\n * tighter table wrote `h-8` at every call site, which is the drift the scale\n * exists to stop, one screen at a time.\n *\n * **It is an attribute on a container, not a prop on a component.** A prop\n * would have to be added to every primitive, threaded through every wrapper a\n * product writes, and passed by hand at each call site - and a primitive\n * written next year would not have it. An attribute is inherited:\n *\n * <form data-density=\"compact\"> …every field inside it…\n *\n * That reaches components which did not exist when the product was built, and\n * a product's own components too, as long as they measure in `h-control` like\n * everything else.\n *\n * The floor does not move with it. `--size-target` stays 24px at every\n * density, because WCAG does not care how tight a table is - which is exactly\n * why `target-min` grows the hit area rather than the control: a compact row\n * is still one a hand can hit.\n */\n[data-density='compact'] {\n --row-control: 32px;\n --row-control-sm: 28px;\n --row-control-lg: 36px;\n --row-cell: 6px;\n}\n\n[data-density='comfortable'] {\n --row-control: 40px;\n --row-control-sm: 36px;\n --row-control-lg: 44px;\n --row-cell: 14px;\n}\n\n/*\n * Stacking order.\n *\n * Not in `@theme`: Tailwind has no z-index namespace, so `z-50` is a literal\n * fifty and a named step would not compile. These are custom properties a\n * component reads directly - `z-index: var(--z-modal)`.\n *\n * The order is the products' own, with the gaps closed. They ran 10 for an\n * in-flow popup, 20 sticky, 30 menu, 40 for a floating button, 50 for modals\n * and drawers, then jumped to 70 and 80 for the command palette - which had to\n * clear the modal layer and had no name to do it with.\n */\n:root {\n /*\n * Motion. One duration existed before this - 160ms on a route change - and\n * everything else rode Tailwind's default. These are the steps around it:\n * `quick` for a colour or an opacity that should feel immediate, `base` for\n * something that moves, `slow` for something arriving from off-screen.\n *\n * Not in `@theme`: Tailwind's `duration-*` utility takes a literal number,\n * not a named step, so these are read directly - `transition-duration:\n * var(--duration-base)`. The easing curves opposite them ARE a namespace,\n * so `ease-out` is a class.\n *\n * Every duration here is for people who want motion: `prefers-reduced-\n * motion` cuts them to nothing further down.\n */\n --duration-quick: 120ms;\n --duration-base: 160ms;\n --duration-slow: 240ms;\n\n --z-popup: 10;\n --z-sticky: 20;\n --z-menu: 30;\n --z-floating: 40;\n --z-overlay: 50;\n --z-modal: 60;\n --z-palette: 70;\n --z-toast: 80;\n}\n\n/*\n * Base layer: what every product would otherwise write again. Scoped to\n * elements and to `:focus-visible`, never to a class, so nothing here can\n * collide with a component.\n */\nbody {\n margin: 0;\n background-color: var(--bg);\n color: var(--text);\n font-family: var(--font-sans);\n /* The base step, so text nobody gave a class reads at the scale's own body\n * size. Without it that text inherited the browser's 16px - an empty\n * state's heading and a card's name came out a step and a half above the\n * 12px beside them, in every product of the line.\n *\n * The line height is the base step's own 20 over 14, written as a ratio\n * rather than read from `--text-base--line-height`, and that is deliberate.\n * A length is inherited as a length: with 20px here, every element that\n * sets a size of its own without a line height - a 10px chart label -\n * inherited 20px and stood five pixels taller, found in the pictures of\n * the stand. A ratio is inherited as a ratio. The theme test holds the two\n * numbers to the tokens. */\n font-size: var(--text-base);\n line-height: calc(20 / 14);\n -webkit-font-smoothing: antialiased;\n}\n\n/*\n * How heavy an icon's line is.\n *\n * lucide draws at 2 by default, which is tuned for its own 24px; at the 14 and\n * 16 the line actually uses, a 2px stroke reads heavier than the text beside\n * it. 1.75 is the owner's call for the whole line (24.09), made here once\n * rather than as a `strokeWidth` at every one of a few hundred call sites.\n *\n * Only an icon still on lucide's default is changed. `[stroke-width='2']` is\n * how lucide writes the default, and an icon given another width - by a call\n * site, or by `absoluteStrokeWidth`, which computes one - keeps it. In\n * `@layer base` so a `stroke-*` utility on the icon wins too. A product that\n * draws with some other icon set is untouched: the rule keys off lucide's own\n * class.\n */\n:root {\n --icon-stroke: 1.75;\n}\n\n@layer base {\n svg.lucide[stroke-width='2'] {\n stroke-width: var(--icon-stroke);\n }\n}\n\n/*\n * In `@layer base`, so a component can turn it off.\n *\n * Unlayered, this rule has the same specificity as `focus-visible:outline-none`\n * from Tailwind - both are one pseudo-class - and wins on source order alone,\n * because the theme is imported before the utilities. Every component that\n * draws its own focus ring got this one on top of it: the command palette's\n * field had an accent outline it had explicitly opted out of, and a combobox\n * with chips drew two rings, one around the box and one around the input\n * inside it.\n *\n * A layered rule loses to any unlayered one regardless of specificity, which\n * is the whole point of cascade layers - the base layer states a default and\n * a component overrides it by saying so.\n */\n@layer base {\n :focus-visible {\n outline: 2px solid var(--accent);\n outline-offset: 2px;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n *,\n *::before,\n *::after {\n transition-duration: 0.01ms !important;\n animation-duration: 0.01ms !important;\n animation-iteration-count: 1 !important;\n scroll-behavior: auto !important;\n }\n}\n\n/*\n * Scrollbars. A browser's default bar is a piece of someone else's chrome\n * sitting in the middle of the product - full width, with step arrows. These\n * are the line's own: thin, in the palette, drawn only where something\n * actually scrolls.\n */\n* {\n scrollbar-width: thin;\n scrollbar-color: var(--line-2) transparent;\n}\n\n*::-webkit-scrollbar {\n width: 10px;\n height: 10px;\n}\n\n*::-webkit-scrollbar-track {\n background: transparent;\n}\n\n*::-webkit-scrollbar-thumb {\n border: 3px solid transparent;\n border-radius: 999px;\n background: var(--line-2);\n background-clip: content-box;\n /* The thumb is drawn proportional to how much of the document fits on\n * screen, so a long one collapses it to a few pixels: still visible, no\n * longer catchable by a pointer. This is the floor below which it stops\n * being a control. */\n min-height: 2.5rem;\n}\n\n*::-webkit-scrollbar-thumb:hover {\n background: var(--dim);\n background-clip: content-box;\n}\n\n*::-webkit-scrollbar-corner {\n background: transparent;\n}\n\n*::-webkit-scrollbar-button {\n display: none;\n}\n"
|
|
18
18
|
}
|
|
19
19
|
],
|
|
20
20
|
"docs": "Import the theme, then your product accent:\n\n @import './dowel/theme.css';\n @import './dowel/accents/kilna.css';\n\nOutside the line, set the colour directly instead:\n\n :root { --accent-base: #2f7d6b; }"
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
"title": "AboutPlate",
|
|
308
308
|
"description": "The about-plate primitive.",
|
|
309
309
|
"dependencies": [
|
|
310
|
-
"dowel-ui@^0.
|
|
310
|
+
"dowel-ui@^0.32.0"
|
|
311
311
|
],
|
|
312
312
|
"registryDependencies": [
|
|
313
313
|
"https://lacodda.github.io/dowel/r/product-mark.json"
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
"description": "A stack of collapsible sections that share one rule about how many can be open at once - an FAQ, the groups in a long settings page, the filters in a sidebar. Each section is `Collapsible`'s shape (a header, a trigger, a panel) repeated inside a group that also decides `single` or `multiple`, which is the one thing a lone `Collapsible` has no opinion about because it has nothing to be exclusive with.",
|
|
329
329
|
"dependencies": [
|
|
330
330
|
"@base-ui/react",
|
|
331
|
-
"dowel-ui@^0.
|
|
331
|
+
"dowel-ui@^0.32.0"
|
|
332
332
|
],
|
|
333
333
|
"registryDependencies": [
|
|
334
334
|
"https://lacodda.github.io/dowel/r/collapsible.json"
|
|
@@ -350,7 +350,7 @@
|
|
|
350
350
|
"dependencies": [
|
|
351
351
|
"@base-ui/react",
|
|
352
352
|
"class-variance-authority",
|
|
353
|
-
"dowel-ui@^0.
|
|
353
|
+
"dowel-ui@^0.32.0"
|
|
354
354
|
],
|
|
355
355
|
"registryDependencies": [],
|
|
356
356
|
"files": [
|
|
@@ -369,7 +369,7 @@
|
|
|
369
369
|
"description": "The shape everyone recognises: weeks as columns, weekdays as rows, time running left to right, and a value carried by how dark a square is. Two products of the line asked for it by name before it existed.",
|
|
370
370
|
"dependencies": [
|
|
371
371
|
"class-variance-authority",
|
|
372
|
-
"dowel-ui@^0.
|
|
372
|
+
"dowel-ui@^0.32.0"
|
|
373
373
|
],
|
|
374
374
|
"registryDependencies": [
|
|
375
375
|
"https://lacodda.github.io/dowel/r/activity-weeks.json"
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
"title": "ActivityLegend",
|
|
390
390
|
"description": "Separate from the grid because a caller showing three grids on one screen wants one legend, and because the words in it are the product's.",
|
|
391
391
|
"dependencies": [
|
|
392
|
-
"dowel-ui@^0.
|
|
392
|
+
"dowel-ui@^0.32.0"
|
|
393
393
|
],
|
|
394
394
|
"registryDependencies": [
|
|
395
395
|
"https://lacodda.github.io/dowel/r/activity-heatmap.json",
|
|
@@ -427,7 +427,7 @@
|
|
|
427
427
|
"description": "A message that stays on the screen, in the flow of the page, about the thing next to it: this field could not be saved, this profile has no axes yet, this export is out of date.",
|
|
428
428
|
"dependencies": [
|
|
429
429
|
"class-variance-authority",
|
|
430
|
-
"dowel-ui@^0.
|
|
430
|
+
"dowel-ui@^0.32.0"
|
|
431
431
|
],
|
|
432
432
|
"registryDependencies": [],
|
|
433
433
|
"files": [
|
|
@@ -435,7 +435,7 @@
|
|
|
435
435
|
"path": "ui/alert.tsx",
|
|
436
436
|
"target": "@ui/alert.tsx",
|
|
437
437
|
"type": "registry:ui",
|
|
438
|
-
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Alert.\n *\n * A message that stays on the screen, in the flow of the page, about the thing\n * next to it: this field could not be saved, this profile has no axes yet,\n * this export is out of date.\n *\n * Not a Toast, and the difference is worth stating because products keep\n * reaching for the wrong one. A toast is for something that just happened and\n * then goes away; an alert is for a condition that is still true and will\n * still be true after a reload. If dismissing it would be a lie, it is an\n * alert.\n *\n * Not a Banner either: a banner spans the application and speaks about the\n * whole of it. This speaks about what it sits beside.\n *\n * `role` is the caller's decision, and the default is deliberately quiet. An\n * alert that appears in response to something the reader just did should be\n * `role=\"alert\"` so it is announced; one that is simply part of the page\n * should not be, or a screen reader interrupts itself reading the furniture.\n */\n\nexport const alertVariants = cva(\n ['flex gap-2.5 rounded-md border p-3 text-sm', '[&_svg]:mt-0.5 [&_svg]:size-4 [&_svg]:shrink-0'],\n {\n variants: {\n tone: {\n neutral: 'border-line bg-soft text-dim',\n good: 'border-good/40 bg-good-soft text-good',\n warn: 'border-warn/40 bg-warn-soft text-warn',\n bad: 'border-bad/40 bg-bad-soft text-bad',\n info: 'border-info/40 bg-info-soft text-info',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nexport interface AlertProps\n // `title` on a div is the browser's tooltip and is a string; here it is the\n // heading, and can be anything a product wants to draw.\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n VariantProps<typeof alertVariants> {\n /** Drawn before the text. The product's own, because an icon that means\n * \"warning\" here should be the one it means everywhere else in the product. */\n icon?: ReactNode\n /** The heading. Optional: a one-line alert does not need one. */\n title?: ReactNode\n /** Anything that goes at the end - a link to the thing that fixes it, a\n * dismiss button the product owns. */\n action?: ReactNode\n}\n\nexport function Alert({ tone, icon, title, action, className, children, ...props }: AlertProps) {\n return (\n <div className={cn(alertVariants({ tone }), className)} {...props}>\n {icon}\n <div className=\"min-w-0 flex-1\">\n {title !== undefined && <div className=\"font-semibold\">{title}</div>}\n {children !== undefined && (\n <div className={cn('text-xs', title !== undefined && 'mt-0.5')}>{children}</div>\n )}\n </div>\n {action !== undefined && <div className=\"shrink-0\">{action}</div>}\n </div>\n )\n}\n"
|
|
438
|
+
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Alert.\n *\n * A message that stays on the screen, in the flow of the page, about the thing\n * next to it: this field could not be saved, this profile has no axes yet,\n * this export is out of date.\n *\n * Not a Toast, and the difference is worth stating because products keep\n * reaching for the wrong one. A toast is for something that just happened and\n * then goes away; an alert is for a condition that is still true and will\n * still be true after a reload. If dismissing it would be a lie, it is an\n * alert.\n *\n * Not a Banner either: a banner spans the application and speaks about the\n * whole of it. This speaks about what it sits beside.\n *\n * `role` is the caller's decision, and the default is deliberately quiet. An\n * alert that appears in response to something the reader just did should be\n * `role=\"alert\"` so it is announced; one that is simply part of the page\n * should not be, or a screen reader interrupts itself reading the furniture.\n */\n\nexport const alertVariants = cva(\n ['flex gap-2.5 rounded-md border p-3 text-sm', '[&_svg]:mt-0.5 [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0'],\n {\n variants: {\n tone: {\n neutral: 'border-line bg-soft text-dim',\n good: 'border-good/40 bg-good-soft text-good',\n warn: 'border-warn/40 bg-warn-soft text-warn',\n bad: 'border-bad/40 bg-bad-soft text-bad',\n info: 'border-info/40 bg-info-soft text-info',\n },\n },\n defaultVariants: { tone: 'neutral' },\n },\n)\n\nexport interface AlertProps\n // `title` on a div is the browser's tooltip and is a string; here it is the\n // heading, and can be anything a product wants to draw.\n extends Omit<HTMLAttributes<HTMLDivElement>, 'title'>,\n VariantProps<typeof alertVariants> {\n /** Drawn before the text. The product's own, because an icon that means\n * \"warning\" here should be the one it means everywhere else in the product. */\n icon?: ReactNode\n /** The heading. Optional: a one-line alert does not need one. */\n title?: ReactNode\n /** Anything that goes at the end - a link to the thing that fixes it, a\n * dismiss button the product owns. */\n action?: ReactNode\n}\n\nexport function Alert({ tone, icon, title, action, className, children, ...props }: AlertProps) {\n return (\n <div className={cn(alertVariants({ tone }), className)} {...props}>\n {icon}\n <div className=\"min-w-0 flex-1\">\n {title !== undefined && <div className=\"font-semibold\">{title}</div>}\n {children !== undefined && (\n <div className={cn('text-xs', title !== undefined && 'mt-0.5')}>{children}</div>\n )}\n </div>\n {action !== undefined && <div className=\"shrink-0\">{action}</div>}\n </div>\n )\n}\n"
|
|
439
439
|
}
|
|
440
440
|
]
|
|
441
441
|
},
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
"description": "The frame a product draws once and then never thinks about: a bar across the top, a rail down the left, and the screen in the corner they leave. It is three boxes and a grid, which is exactly why every product wrote its own - and why every one of them got the same two things wrong before getting them right.",
|
|
447
447
|
"dependencies": [
|
|
448
448
|
"class-variance-authority",
|
|
449
|
-
"dowel-ui@^0.
|
|
449
|
+
"dowel-ui@^0.32.0"
|
|
450
450
|
],
|
|
451
451
|
"registryDependencies": [],
|
|
452
452
|
"files": [
|
|
@@ -465,7 +465,7 @@
|
|
|
465
465
|
"description": "A person, in the space of a word. Every screen that lists people needs one, and the three things that go wrong with it are always the same:\n * - **The picture fails to load** and a broken-image glyph appears where a face was. The fallback is not a nicety; it is the state this component spends most of its life in, because half the people in any list have no picture at all.",
|
|
466
466
|
"dependencies": [
|
|
467
467
|
"class-variance-authority",
|
|
468
|
-
"dowel-ui@^0.
|
|
468
|
+
"dowel-ui@^0.32.0"
|
|
469
469
|
],
|
|
470
470
|
"registryDependencies": [],
|
|
471
471
|
"files": [
|
|
@@ -484,7 +484,7 @@
|
|
|
484
484
|
"description": "A small piece of state attached to something else: a count, a status, a label. It is not a button and never was - if it can be clicked it is a Chip.",
|
|
485
485
|
"dependencies": [
|
|
486
486
|
"class-variance-authority",
|
|
487
|
-
"dowel-ui@^0.
|
|
487
|
+
"dowel-ui@^0.32.0"
|
|
488
488
|
],
|
|
489
489
|
"registryDependencies": [],
|
|
490
490
|
"files": [
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
"description": "A strip across the top of the application, about the application: you are offline, this build is a preview, your licence expires on Friday, a new version is ready to install.",
|
|
504
504
|
"dependencies": [
|
|
505
505
|
"class-variance-authority",
|
|
506
|
-
"dowel-ui@^0.
|
|
506
|
+
"dowel-ui@^0.32.0"
|
|
507
507
|
],
|
|
508
508
|
"registryDependencies": [],
|
|
509
509
|
"files": [
|
|
@@ -511,7 +511,7 @@
|
|
|
511
511
|
"path": "ui/banner.tsx",
|
|
512
512
|
"target": "@ui/banner.tsx",
|
|
513
513
|
"type": "registry:ui",
|
|
514
|
-
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Banner.\n *\n * A strip across the top of the application, about the application: you are\n * offline, this build is a preview, your licence expires on Friday, a new\n * version is ready to install.\n *\n * The difference from Alert is what it speaks about rather than how it looks.\n * An alert belongs to what it sits beside; a banner belongs to the whole\n * screen and is true no matter which one you are on. That is also why it is\n * not dismissed by the component: whether \"you are offline\" can be dismissed\n * is the product's judgement, not the banner's, so the close button is passed\n * in like any other action.\n *\n * It is a `<div role=\"status\">` by default rather than `role=\"alert\"`: a\n * banner is usually already there when the screen loads, and an alert region\n * that fires on load interrupts whatever a screen reader was saying about the\n * page.\n */\n\nexport const bannerVariants = cva(\n [\n 'flex w-full items-center gap-3 border-b px-4 py-2 text-sm',\n '[&_svg]:size-4 [&_svg]:shrink-0',\n ],\n {\n variants: {\n tone: {\n neutral: 'border-line bg-raise text-dim',\n accent: 'border-accent/30 bg-accent-soft text-accent',\n good: 'border-good/30 bg-good-soft text-good',\n warn: 'border-warn/30 bg-warn-soft text-warn',\n bad: 'border-bad/30 bg-bad-soft text-bad',\n info: 'border-info/30 bg-info-soft text-info',\n },\n /** Pinned to the top of the viewport, above the application's own\n * chrome. For the ones that must not scroll away - offline, expired. */\n sticky: {\n true: 'sticky top-0 [z-index:var(--z-sticky)]',\n false: '',\n },\n },\n defaultVariants: { tone: 'neutral', sticky: false },\n },\n)\n\nexport interface BannerProps\n extends HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof bannerVariants> {\n /** Drawn first. The product's own icon, for the same reason as Alert's. */\n icon?: ReactNode\n /** Anything at the end: a button that fixes it, a link, a dismiss the\n * product decides is allowed. */\n action?: ReactNode\n}\n\nexport function Banner({\n tone,\n sticky,\n icon,\n action,\n role = 'status',\n className,\n children,\n ...props\n}: BannerProps) {\n return (\n <div className={cn(bannerVariants({ tone, sticky }), className)} role={role} {...props}>\n {icon}\n <div className=\"min-w-0 flex-1\">{children}</div>\n {action !== undefined && <div className=\"shrink-0\">{action}</div>}\n </div>\n )\n}\n"
|
|
514
|
+
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Banner.\n *\n * A strip across the top of the application, about the application: you are\n * offline, this build is a preview, your licence expires on Friday, a new\n * version is ready to install.\n *\n * The difference from Alert is what it speaks about rather than how it looks.\n * An alert belongs to what it sits beside; a banner belongs to the whole\n * screen and is true no matter which one you are on. That is also why it is\n * not dismissed by the component: whether \"you are offline\" can be dismissed\n * is the product's judgement, not the banner's, so the close button is passed\n * in like any other action.\n *\n * It is a `<div role=\"status\">` by default rather than `role=\"alert\"`: a\n * banner is usually already there when the screen loads, and an alert region\n * that fires on load interrupts whatever a screen reader was saying about the\n * page.\n */\n\nexport const bannerVariants = cva(\n [\n 'flex w-full items-center gap-3 border-b px-4 py-2 text-sm',\n '[&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0',\n ],\n {\n variants: {\n tone: {\n neutral: 'border-line bg-raise text-dim',\n accent: 'border-accent/30 bg-accent-soft text-accent',\n good: 'border-good/30 bg-good-soft text-good',\n warn: 'border-warn/30 bg-warn-soft text-warn',\n bad: 'border-bad/30 bg-bad-soft text-bad',\n info: 'border-info/30 bg-info-soft text-info',\n },\n /** Pinned to the top of the viewport, above the application's own\n * chrome. For the ones that must not scroll away - offline, expired. */\n sticky: {\n true: 'sticky top-0 [z-index:var(--z-sticky)]',\n false: '',\n },\n },\n defaultVariants: { tone: 'neutral', sticky: false },\n },\n)\n\nexport interface BannerProps\n extends HTMLAttributes<HTMLDivElement>,\n VariantProps<typeof bannerVariants> {\n /** Drawn first. The product's own icon, for the same reason as Alert's. */\n icon?: ReactNode\n /** Anything at the end: a button that fixes it, a link, a dismiss the\n * product decides is allowed. */\n action?: ReactNode\n}\n\nexport function Banner({\n tone,\n sticky,\n icon,\n action,\n role = 'status',\n className,\n children,\n ...props\n}: BannerProps) {\n return (\n <div className={cn(bannerVariants({ tone, sticky }), className)} role={role} {...props}>\n {icon}\n <div className=\"min-w-0 flex-1\">{children}</div>\n {action !== undefined && <div className=\"shrink-0\">{action}</div>}\n </div>\n )\n}\n"
|
|
515
515
|
}
|
|
516
516
|
]
|
|
517
517
|
},
|
|
@@ -522,7 +522,7 @@
|
|
|
522
522
|
"description": "Bars rather than a line, and the distinction is the data's not the drawing's: a line says the value exists between the points, a column says each period is its own sum. Hours worked in a week is a sum - there is no \"Wednesday afternoon\" reading between two weeks - so it is a column.",
|
|
523
523
|
"dependencies": [
|
|
524
524
|
"class-variance-authority",
|
|
525
|
-
"dowel-ui@^0.
|
|
525
|
+
"dowel-ui@^0.32.0"
|
|
526
526
|
],
|
|
527
527
|
"registryDependencies": [],
|
|
528
528
|
"files": [
|
|
@@ -541,7 +541,7 @@
|
|
|
541
541
|
"description": "Where you are, as a trail rather than as a word. On a list screen the screen's own name is enough; on something opened from it, it is not - \"Works\" says nothing about which work, and the way back to the list is otherwise the browser's back button alone, which a desktop window does not visibly have.",
|
|
542
542
|
"dependencies": [
|
|
543
543
|
"@base-ui/react",
|
|
544
|
-
"dowel-ui@^0.
|
|
544
|
+
"dowel-ui@^0.32.0"
|
|
545
545
|
],
|
|
546
546
|
"registryDependencies": [],
|
|
547
547
|
"files": [
|
|
@@ -561,7 +561,7 @@
|
|
|
561
561
|
"dependencies": [
|
|
562
562
|
"@base-ui/react",
|
|
563
563
|
"class-variance-authority",
|
|
564
|
-
"dowel-ui@^0.
|
|
564
|
+
"dowel-ui@^0.32.0"
|
|
565
565
|
],
|
|
566
566
|
"registryDependencies": [],
|
|
567
567
|
"files": [
|
|
@@ -569,7 +569,7 @@
|
|
|
569
569
|
"path": "ui/button.tsx",
|
|
570
570
|
"target": "@ui/button.tsx",
|
|
571
571
|
"type": "registry:ui",
|
|
572
|
-
"content": "import type { ButtonHTMLAttributes } from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { useRender } from '@base-ui/react/use-render'\n// `cn` comes from the package rather than being copied in beside the\n// component (ADR 0002): a helper every primitive shares should update\n// centrally, and a project installing a component already has the package for\n// the theme. shadcn's own components import it from `@/lib/utils`; that is a\n// per-project alias, and a copied file cannot know what it points at.\nimport { cn } from 'dowel-ui'\n\n/*\n * Button.\n *\n * Five variants, because that is what the line's products actually reach for:\n * one primary action per screen, a quiet default, a soft accent for something\n * selected, a destructive one, and an icon-only.\n *\n * Every colour and every size is a token. There are no `dark:` utilities and\n * no raw values - the theme swaps underneath, so the same class list is\n * correct in both themes and in every product's accent.\n */\nexport const buttonVariants = cva(\n [\n 'inline-flex cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap',\n 'font-medium transition-colors',\n // Disabled is a state, not a colour: the button keeps its own hue and\n // loses contact instead, which reads the same whatever the accent is.\n 'disabled:pointer-events-none disabled:opacity-50',\n '[&_svg]:shrink-0',\n ],\n {\n variants: {\n variant: {\n primary: 'rounded-md bg-accent font-semibold text-on-accent hover:bg-accent-2',\n ghost: 'rounded-md border border-line text-dim hover:border-line-2 hover:text-text',\n soft: 'rounded-md bg-accent-soft text-accent hover:bg-accent-soft/60',\n danger: 'rounded-md text-bad hover:bg-bad-soft',\n icon: 'rounded-md text-dim hover:bg-soft hover:text-text',\n },\n size: {\n sm: 'h-
|
|
572
|
+
"content": "import type { ButtonHTMLAttributes } from 'react'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { useRender } from '@base-ui/react/use-render'\n// `cn` comes from the package rather than being copied in beside the\n// component (ADR 0002): a helper every primitive shares should update\n// centrally, and a project installing a component already has the package for\n// the theme. shadcn's own components import it from `@/lib/utils`; that is a\n// per-project alias, and a copied file cannot know what it points at.\nimport { cn } from 'dowel-ui'\n\n/*\n * Button.\n *\n * Five variants, because that is what the line's products actually reach for:\n * one primary action per screen, a quiet default, a soft accent for something\n * selected, a destructive one, and an icon-only.\n *\n * Every colour and every size is a token. There are no `dark:` utilities and\n * no raw values - the theme swaps underneath, so the same class list is\n * correct in both themes and in every product's accent.\n *\n * **Height is a control row, not a number.** `md` and `sm` stand on\n * `h-control` and `h-control-sm`, the rows every field of the set stands on,\n * so a button beside an input of the same size is the same height - and\n * `data-density` on a container reaches the button along with the field. They\n * used to say `h-9` and `h-7` literally, and a compact form came out with 32px\n * fields beside 36px buttons. `xs` is below the rows on purpose: it is for a\n * button inside something - a chat line, a chip, a table cell - and it grows\n * its hit area to the pointer floor rather than its box.\n *\n * **Every size says how big an icon is.** A text button used to size nothing,\n * so a lucide icon inside one drew at its own 24px - taller than the text,\n * across the whole line, and fixed at each call site by a `size-4` that the\n * next call site forgot. Each size now sizes an svg inside it, and only one\n * that has no size of its own: `[&_svg:not([class*=size-])]`. The guard is\n * not a nicety. The unguarded form the icon sizes used to have is a\n * descendant selector, one class and one element, and it outranks the single\n * class `size-5` written on the icon - so an explicit size at a call site was\n * silently overruled, and a `+` meant to be 10px drew at 14. The value is\n * unquoted (`size-` is an identifier) so the class sits in a plain string.\n */\nexport const buttonVariants = cva(\n [\n 'inline-flex cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap',\n 'font-medium transition-colors',\n // Disabled is a state, not a colour: the button keeps its own hue and\n // loses contact instead, which reads the same whatever the accent is.\n 'disabled:pointer-events-none disabled:opacity-50',\n '[&_svg]:shrink-0',\n ],\n {\n variants: {\n variant: {\n primary: 'rounded-md bg-accent font-semibold text-on-accent hover:bg-accent-2',\n ghost: 'rounded-md border border-line text-dim hover:border-line-2 hover:text-text',\n soft: 'rounded-md bg-accent-soft text-accent hover:bg-accent-soft/60',\n danger: 'rounded-md text-bad hover:bg-bad-soft',\n icon: 'rounded-md text-dim hover:bg-soft hover:text-text',\n },\n size: {\n xs: 'target-min h-6 gap-1 px-2 text-xs [&_svg:not([class*=size-])]:size-3',\n sm: 'h-control-sm px-2.5 text-xs [&_svg:not([class*=size-])]:size-3.5',\n md: 'h-control px-3.5 text-sm [&_svg:not([class*=size-])]:size-4',\n 'icon-xs': 'target-min size-5 [&_svg:not([class*=size-])]:size-3',\n 'icon-sm': 'size-7 [&_svg:not([class*=size-])]:size-3.5',\n 'icon-md': 'size-8 [&_svg:not([class*=size-])]:size-4',\n },\n },\n defaultVariants: { variant: 'ghost', size: 'md' },\n },\n)\n\nexport interface ButtonProps\n extends ButtonHTMLAttributes<HTMLButtonElement>,\n VariantProps<typeof buttonVariants> {\n /**\n * Render something else with the button's clothes on - a link, most often.\n *\n * Takes the element itself rather than a boolean: `render={<a href=\"…\" />}`.\n * A function is also accepted, for the rare case that needs the props\n * before deciding what to build with them.\n */\n render?: useRender.RenderProp\n}\n\nexport function Button({ variant, size, render, className, type, ...props }: ButtonProps) {\n return useRender({\n render,\n defaultTagName: 'button',\n props: {\n // A `<button>` inside a form submits it unless told otherwise, which\n // surprises everyone once. When rendering as something else the\n // attribute is meaningless and would land on an `<a>`, so it is only\n // set for the element that has it - `render` is what says which.\n ...(render === undefined && type === undefined ? { type: 'button' } : { type }),\n className: cn(buttonVariants({ variant, size }), className),\n ...props,\n },\n })\n}\n"
|
|
573
573
|
}
|
|
574
574
|
]
|
|
575
575
|
},
|
|
@@ -595,7 +595,7 @@
|
|
|
595
595
|
"title": "Calendar",
|
|
596
596
|
"description": "The sums live next door in `calendar-math`, which has no React in it; this is the grid that draws them and the keyboard that moves around it.",
|
|
597
597
|
"dependencies": [
|
|
598
|
-
"dowel-ui@^0.
|
|
598
|
+
"dowel-ui@^0.32.0"
|
|
599
599
|
],
|
|
600
600
|
"registryDependencies": [
|
|
601
601
|
"https://lacodda.github.io/dowel/r/calendar-math.json"
|
|
@@ -616,7 +616,7 @@
|
|
|
616
616
|
"description": "The interesting part is the words. A checkbox on its own is a nine-pixel target that says nothing; wired to a label it is the whole row, and the row is what a finger and a pointer both aim at. So the label is part of the component rather than something a caller remembers to add - the commonest bug in a hand-rolled checkbox is a `<label>` that is next to the input instead of tied to it, which looks identical and does nothing.",
|
|
617
617
|
"dependencies": [
|
|
618
618
|
"@base-ui/react",
|
|
619
|
-
"dowel-ui@^0.
|
|
619
|
+
"dowel-ui@^0.32.0"
|
|
620
620
|
],
|
|
621
621
|
"registryDependencies": [],
|
|
622
622
|
"files": [
|
|
@@ -635,7 +635,7 @@
|
|
|
635
635
|
"description": "A badge you can act on: a filter that can be removed, a tag with a count, a selected value in a field. The difference from a Badge is entirely about whether something happens when you click it - and if something does, that part is a real `<button>` with a real label, not a decorative cross.",
|
|
636
636
|
"dependencies": [
|
|
637
637
|
"class-variance-authority",
|
|
638
|
-
"dowel-ui@^0.
|
|
638
|
+
"dowel-ui@^0.32.0"
|
|
639
639
|
],
|
|
640
640
|
"registryDependencies": [],
|
|
641
641
|
"files": [
|
|
@@ -654,7 +654,7 @@
|
|
|
654
654
|
"description": "The frame around a piece of code is the same everywhere and is written again in every product: the scroll that must not wrap, the gutter of line numbers that must not be selectable, the copy button, the caption saying which file this is, and the marking of the lines the reader was sent here to look at.",
|
|
655
655
|
"dependencies": [
|
|
656
656
|
"class-variance-authority",
|
|
657
|
-
"dowel-ui@^0.
|
|
657
|
+
"dowel-ui@^0.32.0"
|
|
658
658
|
],
|
|
659
659
|
"registryDependencies": [
|
|
660
660
|
"https://lacodda.github.io/dowel/r/copy-button.json"
|
|
@@ -675,7 +675,7 @@
|
|
|
675
675
|
"description": "One region of a screen that a reader shows or hides by choice - release notes under a version number, a filter panel, the raw payload under a log line. It differs from Accordion in the way a single light switch differs from a panel of them: there is one trigger and one panel, no group holding several and no rule about how many can be open, because there is only ever one to be open or not.",
|
|
676
676
|
"dependencies": [
|
|
677
677
|
"@base-ui/react",
|
|
678
|
-
"dowel-ui@^0.
|
|
678
|
+
"dowel-ui@^0.32.0"
|
|
679
679
|
],
|
|
680
680
|
"registryDependencies": [],
|
|
681
681
|
"files": [
|
|
@@ -693,7 +693,7 @@
|
|
|
693
693
|
"title": "ColorField",
|
|
694
694
|
"description": "Picking a colour for something the product stores: a tag, a project, a calendar. Note what that is *not* - it is not choosing the appearance of the interface. The theme decides that, from one accent, and a field that let a reader repaint the chrome would undo the argument the whole system rests on.",
|
|
695
695
|
"dependencies": [
|
|
696
|
-
"dowel-ui@^0.
|
|
696
|
+
"dowel-ui@^0.32.0"
|
|
697
697
|
],
|
|
698
698
|
"registryDependencies": [
|
|
699
699
|
"https://lacodda.github.io/dowel/r/input.json"
|
|
@@ -713,7 +713,7 @@
|
|
|
713
713
|
"title": "ColumnResizeHandle",
|
|
714
714
|
"description": "The handle, and the hook that keeps the widths it produces. Pointer events rather than HTML5 drag-and-drop: a desktop shell that takes file drops for itself never lets a `dragstart` reach the page, so the native API is a handle that does nothing there; pointer capture on the handle also keeps the drag alive when the pointer runs ahead of the cell, which at any speed above a crawl it does.",
|
|
715
715
|
"dependencies": [
|
|
716
|
-
"dowel-ui@^0.
|
|
716
|
+
"dowel-ui@^0.32.0"
|
|
717
717
|
],
|
|
718
718
|
"registryDependencies": [],
|
|
719
719
|
"files": [
|
|
@@ -733,10 +733,11 @@
|
|
|
733
733
|
"dependencies": [
|
|
734
734
|
"@base-ui/react",
|
|
735
735
|
"class-variance-authority",
|
|
736
|
-
"dowel-ui@^0.
|
|
736
|
+
"dowel-ui@^0.32.0"
|
|
737
737
|
],
|
|
738
738
|
"registryDependencies": [
|
|
739
739
|
"https://lacodda.github.io/dowel/r/input.json",
|
|
740
|
+
"https://lacodda.github.io/dowel/r/layer.json",
|
|
740
741
|
"https://lacodda.github.io/dowel/r/select.json"
|
|
741
742
|
],
|
|
742
743
|
"files": [
|
|
@@ -744,7 +745,7 @@
|
|
|
744
745
|
"path": "ui/combobox.tsx",
|
|
745
746
|
"target": "@ui/combobox.tsx",
|
|
746
747
|
"type": "registry:ui",
|
|
747
|
-
"content": "import type { Ref } from 'react'\nimport { Combobox as Base } from '@base-ui/react/combobox'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { fieldClasses } from './input'\nimport { selectItemVariants, selectPopupVariants } from './select'\n\n/*\n * Combobox.\n *\n * A Select you can type in. The list narrows as the query is typed, which is\n * the only difference that matters and the reason to reach for this one: a\n * Select stops being usable somewhere around thirty options, and a country\n * picker or a tag field is well past that.\n *\n * Everything the Select comment says about the native element applies here\n * too - there is no `<select>` under it, and the input is a real `<input\n * role=\"combobox\">` so autofill, spellcheck and the phone keyboard still\n * work.\n *\n * Filtering is Base UI's: give the root an `items` array and it matches the\n * query against them with `Intl.Collator`, so accents and case behave the way\n * a reader in that language expects rather than the way `toLowerCase` does.\n * `filter` replaces the comparison; `filter={null}` turns it off for a list\n * that is filtered on a server.\n *\n * The chips are Base UI's too - Chips, Chip, ChipRemove - and that is worth\n * saying because inventing them is the obvious move and it goes wrong in one\n * specific way: hand-made chips end up as `<div>`s with an X that only a\n * pointer can reach, and the multi-select becomes keyboard-inaccessible at\n * exactly the point where it holds the most state. Base UI's are focusable,\n * walk with the arrows, and delete with Backspace.\n *\n * `Empty` renders only when nothing matched, and announces itself politely.\n * Its element stays mounted for that announcement to work, so it must not be\n * hidden with `display: none` or removed conditionally - which is why it is a\n * component here rather than a `{items.length === 0 && …}` in the product.\n */\n\n/* Two bases, chosen by `bare`, rather than one base and an override.\n *\n * Inside `ComboboxChips` the container is the field, so the input has no\n * border, no background and no focus ring of its own - a bordered box inside a\n * bordered box reads as two controls, and two focus rings appear as one thick\n * one. The obvious way to write that is `fieldClasses` plus a few `-none`\n * classes, and it does not work: `tailwind-merge` does not treat\n * `focus-visible:outline-none` as conflicting with\n * `focus-visible:outline-2 … outline-accent`, so both survive and the later\n * one in the stylesheet wins. The same trap took `w-full` versus `w-auto`\n * earlier in this file.\n *\n * So the variant picks which set applies instead of trying to subtract from\n * one - nothing is left to a merge that has no opinion. */\nexport const comboboxInputVariants = cva('', {\n variants: {\n size: {\n sm: 'h-control-sm text-xs',\n md: 'h-control',\n lg: 'h-control-lg text-base',\n },\n bare: {\n true: 'h-7 w-auto min-w-24 flex-1 bg-transparent px-1 text-sm text-text placeholder:text-faint outline-none',\n false: fieldClasses,\n },\n },\n defaultVariants: { size: 'md', bare: false },\n})\n\n/** The list, and a row in it, are Select's - imported rather than copied.\n *\n * The two popups are the same object seen twice: a dropdown of options, one\n * of which can be chosen. A reader who uses both on one screen should not be\n * able to tell which is which until they type. Two `cva` calls that started\n * identical do not stay that way - one gets the padding fix - and then the\n * form has two dropdowns that are almost the same. */\nexport const comboboxPopupVariants = selectPopupVariants\nexport const comboboxItemVariants = selectItemVariants\n\n/** The root. `items` is what gets filtered; `multiple` turns the value into an\n * array and makes the chips meaningful. */\nexport const Combobox = Base.Root\n\n/** The wrapper for an input with something beside it - a clear button, an\n * icon, the chips. */\nexport const ComboboxInputGroup = Base.InputGroup\n\n/** The button that opens the list without typing, for a reader who wants to\n * see everything there is. */\nexport const ComboboxTrigger = Base.Trigger\n\n/** The chevron. Decorative. */\nexport const ComboboxIcon = Base.Icon\n\n/** A labelled group of rows. */\nexport const ComboboxGroup = Base.Group\n\n/** The rows of one group, as a render function over that group's items.\n *\n * A `List` is the listbox and there is one per combobox, so a grouped list is\n * a `List` over the groups with a `Collection` inside each - not a `List`\n * inside a `List`. Mapping by hand instead works, but the component then has\n * to be told how to match an item to a value, which is a second place for that\n * knowledge to live. */\nexport const ComboboxCollection = Base.Collection\n\n/** The tick, drawn only on a chosen row. */\nexport const ComboboxItemIndicator = Base.ItemIndicator\n\n/** A polite live region for the state of an asynchronous list. Stays mounted,\n * like `Empty`, so the announcement actually fires. */\nexport const ComboboxStatus = Base.Status\n\n/** The container the chips sit in. Its children are plain nodes, not a render\n * function - the chosen values are mapped by `ComboboxValue` inside it.\n *\n * It wears the field's clothes and lays the chips out in a row that wraps,\n * which is the whole difference between a control and a list: unstyled, the\n * chips stack one per line and the box grows into a column of pills with the\n * input stranded underneath. The input sits on the same line as the last\n * chip and takes the rest of the width, so a half-filled field still looks\n * like a field. */\nexport function ComboboxChips({\n ref,\n className,\n ...props\n}: Base.Chips.Props & { ref?: Ref<HTMLDivElement> }) {\n return (\n <Base.Chips\n // Taken out of `...props` and passed on deliberately: a product needs a\n // handle on this box to anchor the list to it, because the input inside\n // is only as wide as what has been typed.\n ref={ref}\n className={cn(\n fieldClasses,\n 'flex min-h-9 flex-wrap items-center gap-1 py-1',\n 'focus-within:outline-2 focus-within:outline-offset-0 focus-within:outline-accent',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The current value, as a render function of it. This is what turns a\n * `multiple` value into one chip per entry. */\nexport const ComboboxValue = Base.Value\n\n/** `size` is taken from the native `<input size>` - a width in characters,\n * which nothing here wants - and given to the variant instead. */\nexport interface ComboboxInputProps\n extends Omit<Base.Input.Props, 'size'>,\n VariantProps<typeof comboboxInputVariants> {}\n\n/** Where the query is typed. A real `<input role=\"combobox\">`.\n *\n * Inside `ComboboxChips` it drops its own border and background: the\n * container is the field there, and a bordered input inside a bordered box\n * reads as two controls. */\nexport function ComboboxInput({ size, bare, className, ...props }: ComboboxInputProps) {\n // `bare` is pulled out and handed to `cva`. Left in `...props` it would be\n // spread onto the `<input>` as an unknown attribute and change nothing -\n // which is exactly what it did: the variant existed, the prop was passed,\n // and the class list came out without a trace of either.\n return <Base.Input className={cn(comboboxInputVariants({ size, bare }), className)} {...props} />\n}\n\nconst iconButtonClasses = cn(\n 'rounded-sm p-1 text-faint transition-colors hover:text-text',\n 'focus-visible:outline-2 focus-visible:outline-accent',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n)\n\n/** Empties the value. Base UI hides it while there is nothing to clear. */\nexport function ComboboxClear({ className, ...props }: Base.Clear.Props) {\n return <Base.Clear className={cn(iconButtonClasses, className)} {...props} />\n}\n\nexport interface ComboboxPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof comboboxPopupVariants> {\n /** Preferred side of the input. Base UI flips it when it does not fit. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. */\n align?: Base.Positioner.Props['align']\n /** Distance from the input, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /**\n * What to line the list up with. Defaults to the input that owns it.\n *\n * Pass the `ComboboxChips` box when there is one: with chips, the input is\n * only as wide as what has been typed - an empty one measured 214px inside\n * a 288px field - so a list anchored to it hangs short of the box a reader\n * sees. Base UI publishes the anchor's width as `--anchor-width`, which is\n * how the mismatch is visible from outside.\n */\n anchor?: Base.Positioner.Props['anchor']\n /** Where to portal to. Defaults to the document body. */\n container?: Base.Portal.Props['container']\n}\n\n/** The list. Portalled and positioned against the input, or the given anchor. */\nexport function ComboboxPopup({\n size,\n side,\n align,\n sideOffset = 4,\n anchor,\n container,\n className,\n children,\n ...props\n}: ComboboxPopupProps) {\n return (\n <Base.Portal container={container}>\n <Base.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n anchor={anchor}\n className=\"[z-index:var(--z-menu)]\"\n >\n <Base.Popup className={cn(comboboxPopupVariants({ size }), className)} {...props}>\n {children}\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\n/** The rows, as a list. Undressed: it is a wrapper, and the popup around it\n * already carries the border and the padding. */\nexport const ComboboxList = Base.List\n\n/** A row. */\nexport function ComboboxItem({ className, ...props }: Base.Item.Props) {\n return <Base.Item className={cn(comboboxItemVariants(), className)} {...props} />\n}\n\n/** What is shown when nothing matched. The words are the product's. */\nexport function ComboboxEmpty({ className, ...props }: Base.Empty.Props) {\n return <Base.Empty className={cn('px-2 py-3 text-center text-sm text-faint', className)} {...props} />\n}\n\n/** One chosen value, in a multiple combobox. Focusable, so it can be reached\n * and removed without a pointer. */\nexport function ComboboxChip({ className, ...props }: Base.Chip.Props) {\n return (\n <Base.Chip\n className={cn(\n 'flex items-center gap-1 rounded-sm bg-soft px-1.5 py-0.5 text-xs text-text',\n 'outline-none data-[highlighted]:bg-accent-soft data-[highlighted]:text-accent',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The X on a chip. A real button, which is what makes Backspace and Enter\n * both work on it. */\nexport function ComboboxChipRemove({ className, ...props }: Base.ChipRemove.Props) {\n return <Base.ChipRemove className={cn(iconButtonClasses, 'p-0', className)} {...props} />\n}\n\n/** The caption above a group. */\nexport function ComboboxGroupLabel({ className, ...props }: Base.GroupLabel.Props) {\n return (\n <Base.GroupLabel\n className={cn('px-2 py-1.5 text-2xs uppercase tracking-caption text-faint', className)}\n {...props}\n />\n )\n}\n"
|
|
748
|
+
"content": "import type { Ref } from 'react'\nimport { Combobox as Base } from '@base-ui/react/combobox'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { usePopupContainer } from './layer'\nimport { fieldClasses } from './input'\nimport { selectItemVariants, selectPopupVariants } from './select'\n\n/*\n * Combobox.\n *\n * A Select you can type in. The list narrows as the query is typed, which is\n * the only difference that matters and the reason to reach for this one: a\n * Select stops being usable somewhere around thirty options, and a country\n * picker or a tag field is well past that.\n *\n * Everything the Select comment says about the native element applies here\n * too - there is no `<select>` under it, and the input is a real `<input\n * role=\"combobox\">` so autofill, spellcheck and the phone keyboard still\n * work.\n *\n * Filtering is Base UI's: give the root an `items` array and it matches the\n * query against them with `Intl.Collator`, so accents and case behave the way\n * a reader in that language expects rather than the way `toLowerCase` does.\n * `filter` replaces the comparison; `filter={null}` turns it off for a list\n * that is filtered on a server.\n *\n * The chips are Base UI's too - Chips, Chip, ChipRemove - and that is worth\n * saying because inventing them is the obvious move and it goes wrong in one\n * specific way: hand-made chips end up as `<div>`s with an X that only a\n * pointer can reach, and the multi-select becomes keyboard-inaccessible at\n * exactly the point where it holds the most state. Base UI's are focusable,\n * walk with the arrows, and delete with Backspace.\n *\n * `Empty` renders only when nothing matched, and announces itself politely.\n * Its element stays mounted for that announcement to work, so it must not be\n * hidden with `display: none` or removed conditionally - which is why it is a\n * component here rather than a `{items.length === 0 && …}` in the product.\n */\n\n/* Two bases, chosen by `bare`, rather than one base and an override.\n *\n * Inside `ComboboxChips` the container is the field, so the input has no\n * border, no background and no focus ring of its own - a bordered box inside a\n * bordered box reads as two controls, and two focus rings appear as one thick\n * one. The obvious way to write that is `fieldClasses` plus a few `-none`\n * classes, and it does not work: `tailwind-merge` does not treat\n * `focus-visible:outline-none` as conflicting with\n * `focus-visible:outline-2 … outline-accent`, so both survive and the later\n * one in the stylesheet wins. The same trap took `w-full` versus `w-auto`\n * earlier in this file.\n *\n * So the variant picks which set applies instead of trying to subtract from\n * one - nothing is left to a merge that has no opinion. */\nexport const comboboxInputVariants = cva('', {\n variants: {\n size: {\n sm: 'h-control-sm text-xs',\n md: 'h-control',\n lg: 'h-control-lg text-base',\n },\n bare: {\n true: 'h-7 w-auto min-w-24 flex-1 bg-transparent px-1 text-sm text-text placeholder:text-faint outline-none',\n false: fieldClasses,\n },\n },\n defaultVariants: { size: 'md', bare: false },\n})\n\n/** The list, and a row in it, are Select's - imported rather than copied.\n *\n * The two popups are the same object seen twice: a dropdown of options, one\n * of which can be chosen. A reader who uses both on one screen should not be\n * able to tell which is which until they type. Two `cva` calls that started\n * identical do not stay that way - one gets the padding fix - and then the\n * form has two dropdowns that are almost the same. */\nexport const comboboxPopupVariants = selectPopupVariants\nexport const comboboxItemVariants = selectItemVariants\n\n/** The root. `items` is what gets filtered; `multiple` turns the value into an\n * array and makes the chips meaningful. */\nexport const Combobox = Base.Root\n\n/** The wrapper for an input with something beside it - a clear button, an\n * icon, the chips. */\nexport const ComboboxInputGroup = Base.InputGroup\n\n/** The button that opens the list without typing, for a reader who wants to\n * see everything there is. */\nexport const ComboboxTrigger = Base.Trigger\n\n/** The chevron. Decorative. */\nexport const ComboboxIcon = Base.Icon\n\n/** A labelled group of rows. */\nexport const ComboboxGroup = Base.Group\n\n/** The rows of one group, as a render function over that group's items.\n *\n * A `List` is the listbox and there is one per combobox, so a grouped list is\n * a `List` over the groups with a `Collection` inside each - not a `List`\n * inside a `List`. Mapping by hand instead works, but the component then has\n * to be told how to match an item to a value, which is a second place for that\n * knowledge to live. */\nexport const ComboboxCollection = Base.Collection\n\n/** The tick, drawn only on a chosen row. */\nexport const ComboboxItemIndicator = Base.ItemIndicator\n\n/** A polite live region for the state of an asynchronous list. Stays mounted,\n * like `Empty`, so the announcement actually fires. */\nexport const ComboboxStatus = Base.Status\n\n/** The container the chips sit in. Its children are plain nodes, not a render\n * function - the chosen values are mapped by `ComboboxValue` inside it.\n *\n * It wears the field's clothes and lays the chips out in a row that wraps,\n * which is the whole difference between a control and a list: unstyled, the\n * chips stack one per line and the box grows into a column of pills with the\n * input stranded underneath. The input sits on the same line as the last\n * chip and takes the rest of the width, so a half-filled field still looks\n * like a field. */\nexport function ComboboxChips({\n ref,\n className,\n ...props\n}: Base.Chips.Props & { ref?: Ref<HTMLDivElement> }) {\n return (\n <Base.Chips\n // Taken out of `...props` and passed on deliberately: a product needs a\n // handle on this box to anchor the list to it, because the input inside\n // is only as wide as what has been typed.\n ref={ref}\n className={cn(\n fieldClasses,\n 'flex min-h-9 flex-wrap items-center gap-1 py-1',\n 'focus-within:outline-2 focus-within:outline-offset-0 focus-within:outline-accent',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The current value, as a render function of it. This is what turns a\n * `multiple` value into one chip per entry. */\nexport const ComboboxValue = Base.Value\n\n/** `size` is taken from the native `<input size>` - a width in characters,\n * which nothing here wants - and given to the variant instead. */\nexport interface ComboboxInputProps\n extends Omit<Base.Input.Props, 'size'>,\n VariantProps<typeof comboboxInputVariants> {}\n\n/** Where the query is typed. A real `<input role=\"combobox\">`.\n *\n * Inside `ComboboxChips` it drops its own border and background: the\n * container is the field there, and a bordered input inside a bordered box\n * reads as two controls. */\nexport function ComboboxInput({ size, bare, className, ...props }: ComboboxInputProps) {\n // `bare` is pulled out and handed to `cva`. Left in `...props` it would be\n // spread onto the `<input>` as an unknown attribute and change nothing -\n // which is exactly what it did: the variant existed, the prop was passed,\n // and the class list came out without a trace of either.\n return <Base.Input className={cn(comboboxInputVariants({ size, bare }), className)} {...props} />\n}\n\nconst iconButtonClasses = cn(\n 'rounded-sm p-1 text-faint transition-colors hover:text-text',\n 'focus-visible:outline-2 focus-visible:outline-accent',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n)\n\n/** Empties the value. Base UI hides it while there is nothing to clear. */\nexport function ComboboxClear({ className, ...props }: Base.Clear.Props) {\n return <Base.Clear className={cn(iconButtonClasses, className)} {...props} />\n}\n\nexport interface ComboboxPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof comboboxPopupVariants> {\n /** Preferred side of the input. Base UI flips it when it does not fit. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. */\n align?: Base.Positioner.Props['align']\n /** Distance from the input, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /**\n * What to line the list up with. Defaults to the input that owns it.\n *\n * Pass the `ComboboxChips` box when there is one: with chips, the input is\n * only as wide as what has been typed - an empty one measured 214px inside\n * a 288px field - so a list anchored to it hangs short of the box a reader\n * sees. Base UI publishes the anchor's width as `--anchor-width`, which is\n * how the mismatch is visible from outside.\n */\n anchor?: Base.Positioner.Props['anchor']\n /** Where to portal to. Defaults to the raised host of the overlay this is\n * opened inside (`layer.tsx`), and to the document body when there is none -\n * either way not the element it was opened from, whose `overflow` would clip\n * it. Pass an element to put it somewhere else, such as a container being\n * screenshotted. */\n container?: Base.Portal.Props['container']\n}\n\n/** The list. Portalled and positioned against the input, or the given anchor. */\nexport function ComboboxPopup({\n size,\n side,\n align,\n sideOffset = 4,\n anchor,\n container,\n className,\n children,\n ...props\n}: ComboboxPopupProps) {\n // Inside an overlay, the overlay's raised host rather than the body - or\n // this popup draws under the dialog, drawer or popover that opened it. See\n // `layer.tsx`. Outside every overlay the hook gives `undefined`: the body.\n const host = usePopupContainer()\n\n return (\n <Base.Portal container={container ?? host}>\n <Base.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n anchor={anchor}\n className=\"[z-index:var(--z-menu)]\"\n >\n <Base.Popup className={cn(comboboxPopupVariants({ size }), className)} {...props}>\n {children}\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\n/** The rows, as a list. Undressed: it is a wrapper, and the popup around it\n * already carries the border and the padding. */\nexport const ComboboxList = Base.List\n\n/** A row. */\nexport function ComboboxItem({ className, ...props }: Base.Item.Props) {\n return <Base.Item className={cn(comboboxItemVariants(), className)} {...props} />\n}\n\n/** What is shown when nothing matched. The words are the product's. */\nexport function ComboboxEmpty({ className, ...props }: Base.Empty.Props) {\n return <Base.Empty className={cn('px-2 py-3 text-center text-sm text-faint', className)} {...props} />\n}\n\n/** One chosen value, in a multiple combobox. Focusable, so it can be reached\n * and removed without a pointer. */\nexport function ComboboxChip({ className, ...props }: Base.Chip.Props) {\n return (\n <Base.Chip\n className={cn(\n 'flex items-center gap-1 rounded-sm bg-soft px-1.5 py-0.5 text-xs text-text',\n 'outline-none data-[highlighted]:bg-accent-soft data-[highlighted]:text-accent',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The X on a chip. A real button, which is what makes Backspace and Enter\n * both work on it. */\nexport function ComboboxChipRemove({ className, ...props }: Base.ChipRemove.Props) {\n return <Base.ChipRemove className={cn(iconButtonClasses, 'p-0', className)} {...props} />\n}\n\n/** The caption above a group. */\nexport function ComboboxGroupLabel({ className, ...props }: Base.GroupLabel.Props) {\n return (\n <Base.GroupLabel\n className={cn('px-2 py-1.5 text-2xs uppercase tracking-caption text-faint', className)}\n {...props}\n />\n )\n}\n"
|
|
748
749
|
}
|
|
749
750
|
]
|
|
750
751
|
},
|
|
@@ -756,18 +757,19 @@
|
|
|
756
757
|
"dependencies": [
|
|
757
758
|
"@base-ui/react",
|
|
758
759
|
"class-variance-authority",
|
|
759
|
-
"dowel-ui@^0.
|
|
760
|
+
"dowel-ui@^0.32.0"
|
|
760
761
|
],
|
|
761
762
|
"registryDependencies": [
|
|
762
763
|
"https://lacodda.github.io/dowel/r/combobox.json",
|
|
763
|
-
"https://lacodda.github.io/dowel/r/kbd.json"
|
|
764
|
+
"https://lacodda.github.io/dowel/r/kbd.json",
|
|
765
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
764
766
|
],
|
|
765
767
|
"files": [
|
|
766
768
|
{
|
|
767
769
|
"path": "ui/command-palette.tsx",
|
|
768
770
|
"target": "@ui/command-palette.tsx",
|
|
769
771
|
"type": "registry:ui",
|
|
770
|
-
"content": "import type
|
|
772
|
+
"content": "import { useRef, type ReactNode } from 'react'\nimport { Combobox as Base } from '@base-ui/react/combobox'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { comboboxItemVariants } from './combobox'\nimport { Kbd } from './kbd'\nimport { LayerProvider } from './layer'\n\n/*\n * CommandPalette.\n *\n * One box that finds anything: the shortcut opens it, typing narrows a list,\n * Enter runs what is highlighted.\n *\n * It is a Combobox rather than a Dialog with a field in it, and that is Base\n * UI's own arrangement rather than a shortcut taken here: put the input\n * *inside* the popup and the popup becomes `role=\"dialog\"` on its own, with\n * the input still announced as the combobox that owns the list. The filtering,\n * the highlight, the arrow keys and the type-ahead are the ones Combobox\n * already has - there is no second implementation of any of it.\n *\n * What is left for the product is everything that makes a palette that\n * product's: what the items are, how they are grouped, what running one does.\n * `items` is deliberately `unknown[]` - a palette lists commands, works,\n * settings and recent files in the same box, and a type that admitted only\n * strings would push every product into the same stringly-typed workaround.\n */\n\nexport const commandPalettePopupVariants = cva(\n [\n 'flex w-[min(36rem,calc(100vw-2rem))] flex-col overflow-hidden',\n 'rounded-xl border border-line bg-raise text-text shadow-float',\n 'focus-visible:outline-none',\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.98] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0',\n ],\n {\n variants: {\n size: {\n md: 'max-h-[24rem]',\n lg: 'max-h-[32rem]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** The root. Controlled by `open`/`onOpenChange`, because what opens a palette\n * is a shortcut somewhere else in the application. */\nexport const CommandPalette = Base.Root\n\n/** A row. The same clothes as a Combobox row, on purpose: a palette is a list\n * of choices, and two lists of choices in one product should not differ.\n *\n * They did differ, for as long as this was a bare re-export: the comment said\n * \"the same clothes\" and the component wore none, so the rows inherited the\n * popup's 16px and stood a third taller than every other list in the set. A\n * live run caught it - the palette looked like a different product. */\nexport function CommandPaletteItem({ className, ...props }: Base.Item.Props) {\n return <Base.Item className={cn(comboboxItemVariants(), className)} {...props} />\n}\n\n/** The list. Takes a render function over the filtered items. */\nexport function CommandPaletteList({ className, ...props }: Base.List.Props) {\n return <Base.List className={cn('overflow-y-auto p-1', className)} {...props} />\n}\n\n/** Shown when nothing matches. The words are the product's.\n *\n * Base UI keeps it mounted so the announcement fires, which means its padding\n * is spent whether or not it has anything to say - and a palette with six\n * results had a 48px hole under the field. It collapses when empty instead. */\nexport function CommandPaletteEmpty({ className, ...props }: Base.Empty.Props) {\n return (\n <Base.Empty\n className={cn('px-2 py-3 text-center text-sm text-faint empty:hidden empty:p-0', className)}\n {...props}\n />\n )\n}\n\n/** A labelled group, for a palette that lists more than one kind of thing. */\nexport const CommandPaletteGroup = Base.Group\n\n/** The caption above a group. */\nexport const CommandPaletteGroupLabel = Base.GroupLabel\n\n/** The rows of one group, as a render function over that group's items.\n *\n * A palette that lists works, versions and notes together is a `List` over the\n * groups with a `Collection` inside each. Mapping a group's rows by hand also\n * works, but then the palette has to be told how to match an item to a value -\n * and for rows fetched fresh from a server, identity comparison never does. */\nexport const CommandPaletteCollection = Base.Collection\n\nexport interface CommandPalettePopupProps\n extends Omit<Base.Popup.Props, 'aria-label'>,\n VariantProps<typeof commandPalettePopupVariants> {\n /**\n * What the palette is called, for a screen reader. Required, and required\n * for a reason particular to this component: the popup is a dialog, and a\n * dialog is named by its own visible title - which a palette does not have,\n * because the field is the first thing in it.\n *\n * So the name has to come from outside, it has to be the product's word, and\n * nothing else can supply it. A palette without one is announced as \"dialog\"\n * and nothing more; making the prop required is what stops that shipping.\n */\n 'aria-label': string\n /** Where to portal to. Defaults to the document body. */\n container?: Base.Portal.Props['container']\n}\n\n/** The palette itself: a dim over the page, and the box in the upper third of\n * it - where the eye already is, rather than dead centre. */\nexport function CommandPalettePopup({\n size,\n container,\n className,\n children,\n ...props\n}: CommandPalettePopupProps) {\n const portal = useRef<HTMLDivElement>(null)\n\n return (\n <Base.Portal ref={portal} container={container}>\n <Base.Backdrop\n className={cn(\n 'fixed inset-0 bg-black/55 backdrop-blur-[2px]',\n '[z-index:var(--z-overlay)]',\n '[transition:opacity_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:opacity-0 data-[starting-style]:opacity-0',\n )}\n />\n <Base.Positioner\n className=\"[z-index:var(--z-palette)]\"\n /* The anchor is a point at the top of the viewport, given explicitly.\n *\n * A positioner places a popup against an anchor and hides itself with\n * an inline `opacity: 0` until it has measured one. A palette has no\n * trigger to point at - it is opened by a keystroke - so without this\n * the measure never resolves: the popup sits in the DOM at the right\n * size, fully transparent, rendering nothing and reporting no error.\n * Found by reading the computed style off the positioner rather than\n * the popup, which was opaque the whole time.\n *\n * A zero-height rectangle a fifth of the way down puts the palette\n * where the eye already is rather than dead centre. */\n anchor={{\n getBoundingClientRect: () => {\n const width = typeof window === 'undefined' ? 0 : window.innerWidth\n const top = typeof window === 'undefined' ? 0 : window.innerHeight * 0.18\n return new DOMRect(width / 2, top, 0, 0)\n },\n }}\n positionMethod=\"fixed\"\n side=\"bottom\"\n align=\"center\"\n sideOffset={0}\n alignOffset={0}\n >\n <Base.Popup\n className={cn(commandPalettePopupVariants({ size }), className)}\n {...props}\n >\n {/* A tooltip or a menu opened from a result rides above the palette,\n * which stands above every modal. See `layer.tsx`. */}\n <LayerProvider above=\"palette\" mount={portal}>{children}</LayerProvider>\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\nexport interface CommandPaletteInputProps extends Base.Input.Props {\n /** Shown at the right of the field, as `['Esc']`. Decorative. */\n hint?: string[]\n}\n\n/** The field. Sits inside the popup, which is what makes the popup a dialog\n * and the field its combobox. */\nexport function CommandPaletteInput({ hint, className, ...props }: CommandPaletteInputProps) {\n return (\n <div className=\"flex items-center gap-2 border-b border-line px-3\">\n <MagnifierIcon />\n <Base.Input\n className={cn(\n 'h-11 w-full bg-transparent text-sm text-text placeholder:text-faint',\n 'focus-visible:outline-none',\n className,\n )}\n {...props}\n />\n {hint && <Kbd keys={hint} aria-hidden className=\"shrink-0\" />}\n </div>\n )\n}\n\n/** The row's own layout: an icon, what it is, and where it lives. */\nexport function CommandPaletteRow({\n icon,\n hint,\n className,\n children,\n ...props\n}: {\n icon?: ReactNode\n hint?: ReactNode\n className?: string\n children: ReactNode\n} & Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>) {\n return (\n <div className={cn('flex w-full items-center gap-2.5', className)} {...props}>\n {icon}\n <span className=\"min-w-0 flex-1 truncate\">{children}</span>\n {hint !== undefined && <span className=\"shrink-0 text-2xs text-faint\">{hint}</span>}\n </div>\n )\n}\n\nexport { comboboxItemVariants as commandPaletteItemVariants }\n\nfunction MagnifierIcon() {\n return (\n <svg\n viewBox=\"0 0 16 16\"\n width=\"15\"\n height=\"15\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.6\"\n aria-hidden\n className=\"shrink-0 text-faint\"\n >\n <circle cx=\"7\" cy=\"7\" r=\"4.5\" />\n <path d=\"M10.5 10.5L14 14\" strokeLinecap=\"round\" />\n </svg>\n )\n}\n"
|
|
771
773
|
}
|
|
772
774
|
]
|
|
773
775
|
},
|
|
@@ -779,15 +781,18 @@
|
|
|
779
781
|
"dependencies": [
|
|
780
782
|
"@base-ui/react",
|
|
781
783
|
"class-variance-authority",
|
|
782
|
-
"dowel-ui@^0.
|
|
784
|
+
"dowel-ui@^0.32.0"
|
|
785
|
+
],
|
|
786
|
+
"registryDependencies": [
|
|
787
|
+
"https://lacodda.github.io/dowel/r/dialog.json",
|
|
788
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
783
789
|
],
|
|
784
|
-
"registryDependencies": [],
|
|
785
790
|
"files": [
|
|
786
791
|
{
|
|
787
792
|
"path": "ui/confirm-dialog.tsx",
|
|
788
793
|
"target": "@ui/confirm-dialog.tsx",
|
|
789
794
|
"type": "registry:ui",
|
|
790
|
-
"content": "import { AlertDialog as Base } from '@base-ui/react/alert-dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * ConfirmDialog.\n *\n * The dialog for a choice that cannot be taken back - deleting, discarding,\n * revoking. It looks almost exactly like Dialog, and that is deliberate: the\n * difference is not clothes, it is what the popup is allowed to do.\n *\n * A Dialog is dismissed by clicking away, because a Dialog is a place the user\n * wandered into. This one is not: Base UI's `AlertDialog` announces itself as\n * `role=\"alertdialog\"`, which tells a screen reader the popup is interrupting\n * rather than presenting, and it forces `modal` and `disablePointerDismissal`\n * on - `AlertDialog.Root` omits both from Dialog's props, so there is nothing\n * to turn off. A press outside does nothing at all.\n *\n * `Escape` still closes it, and that is deliberate rather than an oversight: a\n * popup with no keyboard way out is a trap. The difference is between a\n * deliberate keypress and clicking absentmindedly beside a dialog.\n *\n * So the rule for choosing between the two is not how important the content\n * feels. It is whether dismissing it by a stray click would be a loss.\n */\n\nexport const confirmDialogPopupVariants = cva(\n [\n 'fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2',\n 'rounded-xl border border-line bg-raise
|
|
795
|
+
"content": "import { useRef } from 'react'\nimport { AlertDialog as Base } from '@base-ui/react/alert-dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { DialogActions, DialogBody, DialogHeader } from './dialog'\nimport { LayerProvider } from './layer'\n\n/*\n * ConfirmDialog.\n *\n * The dialog for a choice that cannot be taken back - deleting, discarding,\n * revoking. It looks almost exactly like Dialog, and that is deliberate: the\n * difference is not clothes, it is what the popup is allowed to do.\n *\n * A Dialog is dismissed by clicking away, because a Dialog is a place the user\n * wandered into. This one is not: Base UI's `AlertDialog` announces itself as\n * `role=\"alertdialog\"`, which tells a screen reader the popup is interrupting\n * rather than presenting, and it forces `modal` and `disablePointerDismissal`\n * on - `AlertDialog.Root` omits both from Dialog's props, so there is nothing\n * to turn off. A press outside does nothing at all.\n *\n * `Escape` still closes it, and that is deliberate rather than an oversight: a\n * popup with no keyboard way out is a trap. The difference is between a\n * deliberate keypress and clicking absentmindedly beside a dialog.\n *\n * So the rule for choosing between the two is not how important the content\n * feels. It is whether dismissing it by a stray click would be a loss.\n *\n * The anatomy is the dialog's, taken from it: a header, a body that scrolls\n * if the consequences run long, and the two answers pinned to the bottom. It\n * has the dialog's small sizes and not its large ones on purpose - a question\n * that needs an editor's width to be asked is an editor, and belongs in a\n * Dialog.\n */\n\nexport const confirmDialogPopupVariants = cva(\n [\n 'fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2',\n 'flex flex-col overflow-hidden',\n 'rounded-xl border border-line bg-raise text-text shadow-float',\n 'focus-visible:outline-none',\n // Never taller than the window, which this one used not to promise: a\n // long list of what a deletion takes with it pushed both answers off\n // the bottom edge.\n 'max-h-[calc(100dvh-2rem)]',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-base)_var(--ease-out),transform_var(--duration-base)_var(--ease-out)]',\n 'data-[closed]:scale-[0.98] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0',\n ],\n {\n variants: {\n size: {\n sm: 'w-[min(22rem,calc(100vw-2rem))]',\n md: 'w-[min(26rem,calc(100vw-2rem))]',\n lg: 'w-[min(34rem,calc(100vw-2rem))]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** The root. Controlled with `open` and `onOpenChange`, or left to manage\n * itself around a `ConfirmDialogTrigger`. */\nexport const ConfirmDialog = Base.Root\n\n/** What opens it. Give it `render` to use your own button. */\nexport const ConfirmDialogTrigger = Base.Trigger\n\n/** What closes it - and the only thing that does, which is why a confirm\n * dialog with no `ConfirmDialogClose` inside it is a trap. */\nexport const ConfirmDialogClose = Base.Close\n\n/** The scrim. Darker than the Dialog's, because what is behind it is not just\n * out of reach for a moment - it is waiting on an answer. */\nexport function ConfirmDialogBackdrop({ className, ...props }: Base.Backdrop.Props) {\n return (\n <Base.Backdrop\n className={cn(\n 'fixed inset-0 bg-black/60 backdrop-blur-[2px]',\n '[z-index:var(--z-overlay)]',\n '[transition:opacity_var(--duration-base)_var(--ease-out)]',\n 'data-[closed]:opacity-0 data-[starting-style]:opacity-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport interface ConfirmDialogPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof confirmDialogPopupVariants> {\n /** Where to portal to. Defaults to the document body, which is what keeps\n * the popup from being clipped by an ancestor. Pass an element to put it\n * somewhere else - inside an overlay that is already open, or into a\n * container being screenshotted. */\n container?: Base.Portal.Props['container']\n /** Whether to draw the scrim. On by default, and it should stay on for\n * anything a person actually uses: the dim is what says the page behind is\n * out of reach. Turn it off where the popup is shown alongside other things\n * on purpose - a component gallery, a screenshot - because a scrim is\n * `position: fixed` and covers everything, not only its own container. */\n backdrop?: boolean\n}\n\n/** The dialog itself, announced as `alertdialog`. Portalled, so it is not\n * clipped by whatever it was opened from. */\nexport function ConfirmDialogPopup({\n size,\n container,\n backdrop = true,\n className,\n children,\n ...props\n}: ConfirmDialogPopupProps) {\n const portal = useRef<HTMLDivElement>(null)\n\n return (\n <Base.Portal ref={portal} container={container}>\n {backdrop && <ConfirmDialogBackdrop />}\n <Base.Popup\n className={cn(\n confirmDialogPopupVariants({ size }),\n '[z-index:var(--z-modal)]',\n className,\n )}\n {...props}\n >\n <LayerProvider above=\"modal\" mount={portal}>{children}</LayerProvider>\n </Base.Popup>\n </Base.Portal>\n )\n}\n\n/** The question. Base UI points the popup's `aria-labelledby` at it, so this\n * is what a screen reader reads out when the dialog interrupts. */\nexport function ConfirmDialogTitle({ className, ...props }: Base.Title.Props) {\n return <Base.Title className={cn('text-base font-semibold', className)} {...props} />\n}\n\n/** What the answer costs, and the popup's `aria-describedby`. On this dialog\n * it is close to required: the title asks, the description says what happens. */\nexport function ConfirmDialogDescription({ className, ...props }: Base.Description.Props) {\n return <Base.Description className={cn('mt-1 text-sm text-dim', className)} {...props} />\n}\n\n/** The top: the question and what it costs. The dialog's part, under this\n * one's name. */\nexport const ConfirmDialogHeader = DialogHeader\n\n/** The part that scrolls, for consequences too long to fit. The dialog's\n * part, under this one's name. */\nexport const ConfirmDialogBody = DialogBody\n\n/** Where the two answers go, pinned to the bottom and right-aligned, because\n * the choice belongs where the eye leaves the sentence. The dialog's part,\n * under this one's name. */\nexport const ConfirmDialogActions = DialogActions\n"
|
|
791
796
|
}
|
|
792
797
|
]
|
|
793
798
|
},
|
|
@@ -798,9 +803,10 @@
|
|
|
798
803
|
"description": "The same list of actions as Menu, opened the other way round: by right click, or by a long press on a touch screen, over an *area* rather than from a button. So the trigger is not a control - it is the region the menu belongs to, a row, a canvas, a file tile - and it renders a `<div>`.",
|
|
799
804
|
"dependencies": [
|
|
800
805
|
"@base-ui/react",
|
|
801
|
-
"dowel-ui@^0.
|
|
806
|
+
"dowel-ui@^0.32.0"
|
|
802
807
|
],
|
|
803
808
|
"registryDependencies": [
|
|
809
|
+
"https://lacodda.github.io/dowel/r/layer.json",
|
|
804
810
|
"https://lacodda.github.io/dowel/r/menu.json"
|
|
805
811
|
],
|
|
806
812
|
"files": [
|
|
@@ -808,7 +814,7 @@
|
|
|
808
814
|
"path": "ui/context-menu.tsx",
|
|
809
815
|
"target": "@ui/context-menu.tsx",
|
|
810
816
|
"type": "registry:ui",
|
|
811
|
-
"content": "import { ContextMenu as Base } from '@base-ui/react/context-menu'\nimport { menuItemVariants, menuPopupVariants } from './menu'\nimport { cn } from 'dowel-ui'\n\n/*\n * ContextMenu.\n *\n * The same list of actions as Menu, opened the other way round: by right\n * click, or by a long press on a touch screen, over an *area* rather than\n * from a button. So the trigger is not a control - it is the region the menu\n * belongs to, a row, a canvas, a file tile - and it renders a `<div>`.\n *\n * That difference is the whole component. Everything below the Root is Menu's\n * own: Base UI re-exports the Portal, Positioner, Popup, Item and the rest\n * from the menu package, so the popup that opens here is literally the same\n * popup, with the same keyboard, the same type-ahead and the same submenus.\n *\n * Which is why the clothes are imported rather than copied. Two `cva` calls\n * that started identical drift within a release - one gets a padding fix, the\n * other does not - and then a product has two menus that are almost the same,\n * which is worse than two that differ on purpose.\n *\n * What Base UI does *not* give this one is `openOnHover`, `modal` or a\n * `handle`: a context menu is opened by a gesture over an anchor point, not\n * by a trigger element it can be attached to from elsewhere.\n */\n\n/** The root. It positions against the pointer, so there is nothing to anchor\n * and nothing to control but `onOpenChange`. */\nexport const ContextMenu = Base.Root\n\n/** The area that opens it. A `<div>`, not a button: give it `render` to make\n * it the row or the canvas it belongs to rather than a wrapper. */\nexport const ContextMenuTrigger = Base.Trigger\n\n/** A labelled group of items, for a menu long enough to need headings. */\nexport const ContextMenuGroup = Base.Group\n\n/** A submenu, opened from a `ContextMenuSubTrigger` inside the parent. */\nexport const ContextMenuSub = Base.SubmenuRoot\n\nexport interface ContextMenuPopupProps extends Base.Popup.Props {\n /** How wide the popup starts. The same three as Menu's. */\n size?: 'sm' | 'md' | 'lg'\n /** Where to portal to. Defaults to the
|
|
817
|
+
"content": "import { ContextMenu as Base } from '@base-ui/react/context-menu'\nimport { menuItemVariants, menuPopupVariants } from './menu'\nimport { cn } from 'dowel-ui'\nimport { usePopupContainer } from './layer'\n\n/*\n * ContextMenu.\n *\n * The same list of actions as Menu, opened the other way round: by right\n * click, or by a long press on a touch screen, over an *area* rather than\n * from a button. So the trigger is not a control - it is the region the menu\n * belongs to, a row, a canvas, a file tile - and it renders a `<div>`.\n *\n * That difference is the whole component. Everything below the Root is Menu's\n * own: Base UI re-exports the Portal, Positioner, Popup, Item and the rest\n * from the menu package, so the popup that opens here is literally the same\n * popup, with the same keyboard, the same type-ahead and the same submenus.\n *\n * Which is why the clothes are imported rather than copied. Two `cva` calls\n * that started identical drift within a release - one gets a padding fix, the\n * other does not - and then a product has two menus that are almost the same,\n * which is worse than two that differ on purpose.\n *\n * What Base UI does *not* give this one is `openOnHover`, `modal` or a\n * `handle`: a context menu is opened by a gesture over an anchor point, not\n * by a trigger element it can be attached to from elsewhere.\n */\n\n/** The root. It positions against the pointer, so there is nothing to anchor\n * and nothing to control but `onOpenChange`. */\nexport const ContextMenu = Base.Root\n\n/** The area that opens it. A `<div>`, not a button: give it `render` to make\n * it the row or the canvas it belongs to rather than a wrapper. */\nexport const ContextMenuTrigger = Base.Trigger\n\n/** A labelled group of items, for a menu long enough to need headings. */\nexport const ContextMenuGroup = Base.Group\n\n/** A submenu, opened from a `ContextMenuSubTrigger` inside the parent. */\nexport const ContextMenuSub = Base.SubmenuRoot\n\nexport interface ContextMenuPopupProps extends Base.Popup.Props {\n /** How wide the popup starts. The same three as Menu's. */\n size?: 'sm' | 'md' | 'lg'\n /** Where to portal to. Defaults to the raised host of the overlay this is\n * opened inside (`layer.tsx`), and to the document body when there is none -\n * either way not the element it was opened from, whose `overflow` would clip\n * it. Pass an element to put it somewhere else, such as a container being\n * screenshotted. */\n container?: Base.Portal.Props['container']\n}\n\n/** The panel. Portalled, and positioned against the point that was clicked\n * rather than against an element. */\nexport function ContextMenuPopup({\n size,\n container,\n className,\n children,\n ...props\n}: ContextMenuPopupProps) {\n // Inside an overlay, the overlay's raised host rather than the body - or\n // this popup draws under the dialog, drawer or popover that opened it. See\n // `layer.tsx`. Outside every overlay the hook gives `undefined`: the body.\n const host = usePopupContainer()\n\n return (\n <Base.Portal container={container ?? host}>\n <Base.Positioner className=\"[z-index:var(--z-menu)]\">\n <Base.Popup className={cn(menuPopupVariants({ size }), className)} {...props}>\n {children}\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\nexport interface ContextMenuItemProps extends Base.Item.Props {\n /** `danger` draws the destructive one apart, in the colour of something\n * that cannot be undone. */\n tone?: 'default' | 'danger'\n}\n\n/** An action. */\nexport function ContextMenuItem({ tone, className, ...props }: ContextMenuItemProps) {\n return <Base.Item className={cn(menuItemVariants({ tone }), className)} {...props} />\n}\n\n/** An item that opens a submenu. Drawn like any other, because it is one. */\nexport function ContextMenuSubTrigger({ tone, className, ...props }: ContextMenuItemProps) {\n return <Base.SubmenuTrigger className={cn(menuItemVariants({ tone }), className)} {...props} />\n}\n\n/** An item that carries a tick. The state is the caller's. */\nexport function ContextMenuCheckboxItem({ tone, className, ...props }: ContextMenuItemProps) {\n return <Base.CheckboxItem className={cn(menuItemVariants({ tone }), className)} {...props} />\n}\n\n/** The tick itself, drawn only when the item is checked. */\nexport const ContextMenuCheckboxIndicator = Base.CheckboxItemIndicator\n\n/** A line between groups of items. Decorative, and marked as such. */\nexport function ContextMenuSeparator({ className, ...props }: Base.Separator.Props) {\n return <Base.Separator className={cn('-mx-1 my-1 h-px bg-line', className)} {...props} />\n}\n\n/** The caption above a group. */\nexport function ContextMenuGroupLabel({ className, ...props }: Base.GroupLabel.Props) {\n return (\n <Base.GroupLabel\n className={cn('px-2 py-1.5 text-2xs uppercase tracking-caption text-faint', className)}\n {...props}\n />\n )\n}\n"
|
|
812
818
|
}
|
|
813
819
|
]
|
|
814
820
|
},
|
|
@@ -818,7 +824,7 @@
|
|
|
818
824
|
"title": "CopyButton",
|
|
819
825
|
"description": "Whatever a product shows in a panel - code, a payload, a log, one side of a comparison - somebody eventually wants to take it away, and the button that lets them is written again every time with the same three things missed.",
|
|
820
826
|
"dependencies": [
|
|
821
|
-
"dowel-ui@^0.
|
|
827
|
+
"dowel-ui@^0.32.0"
|
|
822
828
|
],
|
|
823
829
|
"registryDependencies": [],
|
|
824
830
|
"files": [
|
|
@@ -836,7 +842,7 @@
|
|
|
836
842
|
"title": "Copyable",
|
|
837
843
|
"description": "Any text that someone will eventually want to copy - an id, a path, a hash, a token - copied with one click. The rule comes from nitid: if a value is worth showing, it is worth being able to take away, and selecting a monospaced id by hand is a small daily tax.",
|
|
838
844
|
"dependencies": [
|
|
839
|
-
"dowel-ui@^0.
|
|
845
|
+
"dowel-ui@^0.32.0"
|
|
840
846
|
],
|
|
841
847
|
"registryDependencies": [],
|
|
842
848
|
"files": [
|
|
@@ -854,7 +860,7 @@
|
|
|
854
860
|
"title": "DatePicker",
|
|
855
861
|
"description": "The trigger is a button rather than a text input, and that is the decision worth stating. A typable date field has to answer \"what does `03/04/26` mean\" in a locale it cannot be sure of, and it answers wrong for half the world; a button showing the date spelled out has no such question. Where typing genuinely matters - a birth date, forty years back - the calendar is the wrong control anyway and a product should reach for a plain field.",
|
|
856
862
|
"dependencies": [
|
|
857
|
-
"dowel-ui@^0.
|
|
863
|
+
"dowel-ui@^0.32.0"
|
|
858
864
|
],
|
|
859
865
|
"registryDependencies": [
|
|
860
866
|
"https://lacodda.github.io/dowel/r/calendar.json",
|
|
@@ -877,7 +883,7 @@
|
|
|
877
883
|
"title": "DateRangePicker",
|
|
878
884
|
"description": "The interesting part is the state between them. After the first click there is a start and no end, and that is not an incomplete range to be hidden or a range of one day - it is the normal middle of the interaction, and the calendar has to show it: the first day marked, the days under the pointer shading as the reader moves, the popup staying open. Products that skip it end up with a picker that seems to do nothing until the second click.",
|
|
879
885
|
"dependencies": [
|
|
880
|
-
"dowel-ui@^0.
|
|
886
|
+
"dowel-ui@^0.32.0"
|
|
881
887
|
],
|
|
882
888
|
"registryDependencies": [
|
|
883
889
|
"https://lacodda.github.io/dowel/r/calendar.json",
|
|
@@ -902,15 +908,17 @@
|
|
|
902
908
|
"dependencies": [
|
|
903
909
|
"@base-ui/react",
|
|
904
910
|
"class-variance-authority",
|
|
905
|
-
"dowel-ui@^0.
|
|
911
|
+
"dowel-ui@^0.32.0"
|
|
912
|
+
],
|
|
913
|
+
"registryDependencies": [
|
|
914
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
906
915
|
],
|
|
907
|
-
"registryDependencies": [],
|
|
908
916
|
"files": [
|
|
909
917
|
{
|
|
910
918
|
"path": "ui/dialog.tsx",
|
|
911
919
|
"target": "@ui/dialog.tsx",
|
|
912
920
|
"type": "registry:ui",
|
|
913
|
-
"content": "import { Dialog as Base } from '@base-ui/react/dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Dialog.\n *\n * The parts are exposed rather than wrapped in one component with `title` and\n * `footer` props. The products that did it the other way ended up passing\n * `footer={<>…</>}` within a week, which is a slot with extra steps - and a\n * dialog that owns its own close button owns a word for it, which is a word\n * the product cannot translate.\n *\n * Behaviour is Base UI's: the focus trap, the return of focus to whatever\n * opened it, `Escape`, the scroll lock, and the `aria-labelledby` that ties\n * the popup to its own title. None of that is worth rewriting, and all of it\n * is wrong in the ways nobody notices until someone is navigating by keyboard.\n *\n * What is ours is the clothes,
|
|
921
|
+
"content": "import { useRef, type HTMLAttributes, type ReactNode } from 'react'\nimport { Dialog as Base } from '@base-ui/react/dialog'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { LayerProvider } from './layer'\n\n/*\n * Dialog.\n *\n * The parts are exposed rather than wrapped in one component with `title` and\n * `footer` props. The products that did it the other way ended up passing\n * `footer={<>…</>}` within a week, which is a slot with extra steps - and a\n * dialog that owns its own close button owns a word for it, which is a word\n * the product cannot translate.\n *\n * Behaviour is Base UI's: the focus trap, the return of focus to whatever\n * opened it, `Escape`, the scroll lock, and the `aria-labelledby` that ties\n * the popup to its own title. None of that is worth rewriting, and all of it\n * is wrong in the ways nobody notices until someone is navigating by keyboard.\n *\n * What is ours is the clothes, the enter and leave - the popup arrives with\n * `data-open` and leaves with `data-closed`, both of which Base UI sets, so\n * the animation is a class list rather than a state machine - and the anatomy.\n *\n * **Only the body scrolls.** The popup is a column of three parts: a header\n * that stays at the top, a body that takes what height is left and scrolls\n * inside it, and the actions pinned to the bottom. The popup used to scroll as\n * a whole, and a dialog with more in it than the window is tall took its own\n * buttons with it: in kilna, at a 1280x720 window, \"Save\" on the style editor\n * stood 137px below the bottom edge, and the only way to reach it was to\n * scroll a form to its end to find out whether it had one. The popup carries\n * no padding of its own now - each part does - so the body's scroll runs edge\n * to edge and the header and actions stay whole while it moves.\n *\n * **A popup opened inside rides above it.** The content sits in a layer\n * (`layer.tsx`): a select, a menu or a date picker in a dialog portals into a\n * host raised one rung above the modal, so it is neither clipped by the\n * body's scroll nor drawn underneath the dialog that opened it.\n */\n\nexport const dialogPopupVariants = cva(\n [\n 'fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2',\n 'flex flex-col overflow-hidden',\n 'rounded-xl border border-line bg-raise text-text shadow-float',\n 'focus-visible:outline-none',\n // Never taller than the window. The width was capped from the start and\n // the height was not, so a dialog taller than the window centred itself\n // and hung off both ends. The cap is on the column; the body is what\n // gives way.\n 'max-h-[calc(100dvh-2rem)]',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-base)_var(--ease-out),transform_var(--duration-base)_var(--ease-out)]',\n 'data-[closed]:scale-[0.98] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0',\n ],\n {\n variants: {\n size: {\n sm: 'w-[min(24rem,calc(100vw-2rem))]',\n md: 'w-[min(28rem,calc(100vw-2rem))]',\n lg: 'w-[min(40rem,calc(100vw-2rem))]',\n // An editor: a form wide enough for its fields to sit side by side,\n // or a row of choices to fit on one line rather than three.\n xl: 'w-[min(48rem,calc(100vw-2rem))]',\n // The window, less a margin that says it is still a dialog. The\n // height is set rather than capped, so the body fills it even when\n // there is little in it - a picker or a preview should not jump in\n // size as its content loads.\n full: 'h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** The root. Controlled with `open` and `onOpenChange`, or left to manage\n * itself around a `Dialog.Trigger`. */\nexport const Dialog = Base.Root\n\n/** What opens it. Give it `render` to use your own button. */\nexport const DialogTrigger = Base.Trigger\n\n/** What closes it - the same, for a cancel button or an X. */\nexport const DialogClose = Base.Close\n\n/** The scrim. Dark because a modal is a modal: what is behind it is out of\n * reach, and saying so with contrast is the only thing that reads at a\n * glance. */\nexport function DialogBackdrop({ className, ...props }: Base.Backdrop.Props) {\n return (\n <Base.Backdrop\n className={cn(\n 'fixed inset-0 bg-black/50 backdrop-blur-[2px]',\n '[z-index:var(--z-overlay)]',\n '[transition:opacity_var(--duration-base)_var(--ease-out)]',\n 'data-[closed]:opacity-0 data-[starting-style]:opacity-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport interface DialogPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof dialogPopupVariants> {\n /** Where to portal to. Defaults to the document body, which is what keeps\n * the popup from being clipped by whatever it was opened from. Pass an\n * element to put it somewhere else - inside a dialog that is already open,\n * or into a container being screenshotted. */\n container?: Base.Portal.Props['container']\n /** Whether to draw the scrim. On by default, and it should stay on for\n * anything a person actually uses: the dim is what says the page behind is\n * out of reach. Turn it off where the popup is shown alongside other things\n * on purpose - a component gallery, a screenshot - because a scrim is\n * `position: fixed` and covers everything, not only its own container. */\n backdrop?: boolean\n}\n\n/** The dialog itself. Portalled, so it is not clipped by whatever it was\n * opened from. Put a `DialogHeader`, a `DialogBody` and `DialogActions`\n * inside it. */\nexport function DialogPopup({\n size,\n container,\n backdrop = true,\n className,\n children,\n ...props\n}: DialogPopupProps) {\n const portal = useRef<HTMLDivElement>(null)\n\n return (\n <Base.Portal ref={portal} container={container}>\n {backdrop && <DialogBackdrop />}\n <Base.Popup\n className={cn(dialogPopupVariants({ size }), '[z-index:var(--z-modal)]', className)}\n {...props}\n >\n <LayerProvider above=\"modal\" mount={portal}>{children}</LayerProvider>\n </Base.Popup>\n </Base.Portal>\n )\n}\n\n/*\n * The three parts. Plain elements rather than Base UI parts, because what\n * they do is layout: which one stays and which one scrolls. That is also why\n * the drawer and the confirm dialog take them from here - the anatomy is one\n * decision, and three copies of it would be three answers by the next\n * version.\n */\n\nexport interface DialogHeaderProps extends HTMLAttributes<HTMLDivElement> {\n /** Beside the title, at the end of the line: a close button, a menu. The\n * title and description wrap under themselves rather than under it. */\n action?: ReactNode\n}\n\n/** The top of the popup: the title, the line under it, and an action beside\n * them. It stays put while the body scrolls. */\nexport function DialogHeader({ action, className, children, ...props }: DialogHeaderProps) {\n return (\n <div className={cn('flex shrink-0 items-start gap-3 px-5 pt-5 pb-4', className)} {...props}>\n <div className=\"min-w-0 flex-1\">{children}</div>\n {action !== undefined && <div className=\"-mt-1 -mr-1.5 flex shrink-0 items-center gap-1\">{action}</div>}\n </div>\n )\n}\n\n/** The part that scrolls. It takes the height the header and the actions\n * leave, and only it moves when there is more than fits. */\nexport function DialogBody({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn(\n 'min-h-0 flex-1 overflow-y-auto overscroll-contain px-5',\n // First or last in the popup, it takes the padding the missing part\n // would have given - a dialog with no header still has a top edge.\n 'first:pt-5 last:pb-5',\n // A box that scrolls can be focused, and the popup clips what is\n // outside it: the ring is drawn inside.\n 'focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport interface DialogActionsProps extends HTMLAttributes<HTMLDivElement> {\n /** At the other end of the row from the answer: the action that is not the\n * answer to the dialog's question - \"Delete\" on an editor whose question is\n * \"Save?\". Kept apart so it is not pressed on the way to \"Save\". */\n start?: ReactNode\n}\n\n/** Where the actions go, pinned to the bottom. Right-aligned, because the\n * primary action of a dialog belongs where the eye leaves the sentence. */\nexport function DialogActions({ start, className, children, ...props }: DialogActionsProps) {\n return (\n <div\n className={cn('mt-auto flex shrink-0 items-center justify-end gap-2 px-5 pt-4 pb-5', className)}\n {...props}\n >\n {start !== undefined && <div className=\"mr-auto flex items-center gap-2\">{start}</div>}\n {children}\n </div>\n )\n}\n\n/** The heading. Base UI points the popup's `aria-labelledby` at it, so a\n * dialog with one is named for a screen reader without anyone arranging it. */\nexport function DialogTitle({ className, ...props }: Base.Title.Props) {\n return <Base.Title className={cn('text-base font-semibold', className)} {...props} />\n}\n\n/** The line under the heading, and the popup's `aria-describedby`. */\nexport function DialogDescription({ className, ...props }: Base.Description.Props) {\n return <Base.Description className={cn('mt-1 text-sm text-dim', className)} {...props} />\n}\n"
|
|
914
922
|
}
|
|
915
923
|
]
|
|
916
924
|
},
|
|
@@ -937,7 +945,7 @@
|
|
|
937
945
|
"description": "The question this answers is \"how did this read before, and how does it read now\" - a version against the one before it, a proposal against what is there, a file against what is on disk. Not a code review: there is no staging, no comment, nothing to accept. It is for looking.",
|
|
938
946
|
"dependencies": [
|
|
939
947
|
"class-variance-authority",
|
|
940
|
-
"dowel-ui@^0.
|
|
948
|
+
"dowel-ui@^0.32.0"
|
|
941
949
|
],
|
|
942
950
|
"registryDependencies": [
|
|
943
951
|
"https://lacodda.github.io/dowel/r/copy-button.json",
|
|
@@ -959,7 +967,7 @@
|
|
|
959
967
|
"description": "The line between one part of a screen and the next. The set already had four of them - in the menu, the select, the context menu and the action bar - and each was written inside the thing it divided, so a screen that wanted a rule between two sections had nothing and reached for a bare `<hr>` or a `div` with a background.",
|
|
960
968
|
"dependencies": [
|
|
961
969
|
"class-variance-authority",
|
|
962
|
-
"dowel-ui@^0.
|
|
970
|
+
"dowel-ui@^0.32.0"
|
|
963
971
|
],
|
|
964
972
|
"registryDependencies": [],
|
|
965
973
|
"files": [
|
|
@@ -979,15 +987,18 @@
|
|
|
979
987
|
"dependencies": [
|
|
980
988
|
"@base-ui/react",
|
|
981
989
|
"class-variance-authority",
|
|
982
|
-
"dowel-ui@^0.
|
|
990
|
+
"dowel-ui@^0.32.0"
|
|
991
|
+
],
|
|
992
|
+
"registryDependencies": [
|
|
993
|
+
"https://lacodda.github.io/dowel/r/dialog.json",
|
|
994
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
983
995
|
],
|
|
984
|
-
"registryDependencies": [],
|
|
985
996
|
"files": [
|
|
986
997
|
{
|
|
987
998
|
"path": "ui/drawer.tsx",
|
|
988
999
|
"target": "@ui/drawer.tsx",
|
|
989
1000
|
"type": "registry:ui",
|
|
990
|
-
"content": "import { Drawer as Base } from '@base-ui/react/drawer'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Drawer.\n *\n * A panel that slides in from an edge and holds the screen while it is there -\n * a filter sheet, a detail pane, a form too long to centre. Modal like Dialog,\n * placed like nothing else.\n *\n * Base UI positions none of it. Unlike Popover there is no Positioner and no\n * anchor to measure against; the edge it comes from is entirely CSS, which is\n * what the `side` variant is. It drives three things at once and they have to\n * agree: where the Viewport pushes the panel, which border it grows against,\n * and which way it is translated while opening and closing.\n *\n * `swipeDirection` is the other half and cannot be inferred here: it lives on\n * the root, while `side` lives on the popup, so the two are set together by\n * hand - `side=\"right\"` with `swipeDirection=\"right\"`, `side=\"bottom\"` with\n * `down`, which is Base UI's default. Left unmatched, the drawer slides in\n * from one edge and is flicked away towards another.\n *\n * The transitions key off `data-starting-style` and `data-ending-style` rather\n * than `data-closed`. That is Base UI's own convention for the drawer, and the\n * reason is that a drawer is dragged as well as animated: the popup carries a\n * live `--drawer-swipe-movement-*` while a finger is on it, and the transform\n * has to compose with that rather than replace it.\n */\n\n/** The Viewport: fixed to the whole window, pushing the popup to one edge.\n *\n * It is separate from the popup because a drawer that is its own positioner\n * cannot be scrolled independently of where it sits - and the panel needs to\n * scroll while the edge it is pinned to does not move. */\nconst drawerViewportVariants = cva('fixed inset-0 flex', {\n variants: {\n side: {\n right: 'justify-end',\n left: 'justify-start',\n bottom: 'items-end',\n },\n },\n defaultVariants: { side: 'right' },\n})\n\nexport const drawerPopupVariants = cva(\n [\n 'flex flex-col overflow-
|
|
1001
|
+
"content": "import { useRef } from 'react'\nimport { Drawer as Base } from '@base-ui/react/drawer'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { DialogActions, DialogBody, DialogHeader } from './dialog'\nimport { LayerProvider } from './layer'\n\n/*\n * Drawer.\n *\n * A panel that slides in from an edge and holds the screen while it is there -\n * a filter sheet, a detail pane, a form too long to centre. Modal like Dialog,\n * placed like nothing else.\n *\n * Base UI positions none of it. Unlike Popover there is no Positioner and no\n * anchor to measure against; the edge it comes from is entirely CSS, which is\n * what the `side` variant is. It drives three things at once and they have to\n * agree: where the Viewport pushes the panel, which border it grows against,\n * and which way it is translated while opening and closing.\n *\n * `swipeDirection` is the other half and cannot be inferred here: it lives on\n * the root, while `side` lives on the popup, so the two are set together by\n * hand - `side=\"right\"` with `swipeDirection=\"right\"`, `side=\"bottom\"` with\n * `down`, which is Base UI's default. Left unmatched, the drawer slides in\n * from one edge and is flicked away towards another.\n *\n * The transitions key off `data-starting-style` and `data-ending-style` rather\n * than `data-closed`. That is Base UI's own convention for the drawer, and the\n * reason is that a drawer is dragged as well as animated: the popup carries a\n * live `--drawer-swipe-movement-*` while a finger is on it, and the transform\n * has to compose with that rather than replace it.\n *\n * The anatomy is the dialog's, taken from it rather than copied: a header that\n * stays, a body that scrolls, and the actions pinned to the bottom edge. The\n * panel used to scroll as a whole, which on a tall form took the buttons down\n * with it. A popup opened inside - the menu on a row of the assistant's chat\n * in kilna, which opened underneath the drawer - rides a layer above it.\n */\n\n/** The Viewport: fixed to the whole window, pushing the popup to one edge.\n *\n * It is separate from the popup because a drawer that is its own positioner\n * cannot be scrolled independently of where it sits - and the panel needs to\n * scroll while the edge it is pinned to does not move. */\nconst drawerViewportVariants = cva('fixed inset-0 flex', {\n variants: {\n side: {\n right: 'justify-end',\n left: 'justify-start',\n bottom: 'items-end',\n },\n },\n defaultVariants: { side: 'right' },\n})\n\nexport const drawerPopupVariants = cva(\n [\n 'flex flex-col overflow-hidden',\n 'border-line bg-raise text-text shadow-float',\n 'focus-visible:outline-none',\n // Composed with the live swipe offset rather than replacing it, so a\n // half-dragged drawer animates from where the finger left it.\n '[transition:transform_var(--duration-base)_var(--ease-out)]',\n 'will-change-transform',\n ],\n {\n variants: {\n /* Where it comes from. The three the products of the line reach for:\n * a right-hand pane, its mirror, and a bottom sheet. */\n side: {\n right: [\n 'h-full border-l',\n '[transform:translateX(var(--drawer-swipe-movement-x))]',\n 'data-[starting-style]:[transform:translateX(100%)]',\n 'data-[ending-style]:[transform:translateX(100%)]',\n ],\n left: [\n 'h-full border-r',\n '[transform:translateX(var(--drawer-swipe-movement-x))]',\n 'data-[starting-style]:[transform:translateX(-100%)]',\n 'data-[ending-style]:[transform:translateX(-100%)]',\n ],\n bottom: [\n 'w-full rounded-t-xl border-t',\n '[transform:translateY(var(--drawer-swipe-movement-y))]',\n 'data-[starting-style]:[transform:translateY(100%)]',\n 'data-[ending-style]:[transform:translateY(100%)]',\n ],\n },\n /* How much of the window it takes, across the edge it comes from: the\n * width of a side panel, the height of a bottom sheet. A filter sheet\n * and a detail pane are different sizes of the same thing. */\n size: {\n sm: '',\n md: '',\n lg: '',\n xl: '',\n full: '',\n },\n },\n compoundVariants: [\n { side: ['right', 'left'], size: 'sm', className: 'w-[min(20rem,calc(100vw-3rem))]' },\n { side: ['right', 'left'], size: 'md', className: 'w-[min(24rem,calc(100vw-3rem))]' },\n { side: ['right', 'left'], size: 'lg', className: 'w-[min(32rem,calc(100vw-3rem))]' },\n { side: ['right', 'left'], size: 'xl', className: 'w-[min(48rem,calc(100vw-3rem))]' },\n { side: ['right', 'left'], size: 'full', className: 'w-[calc(100vw-3rem)]' },\n // A sheet is capped rather than sized, so a short one stays short - up\n // to `full`, which is set, so the body fills it while content loads.\n { side: 'bottom', size: 'sm', className: 'max-h-[40vh]' },\n { side: 'bottom', size: 'md', className: 'max-h-[80vh]' },\n { side: 'bottom', size: 'lg', className: 'max-h-[90vh]' },\n { side: 'bottom', size: 'xl', className: 'max-h-[calc(100dvh-3rem)]' },\n { side: 'bottom', size: 'full', className: 'h-[calc(100dvh-3rem)]' },\n ],\n defaultVariants: { side: 'right', size: 'md' },\n },\n)\n\n/** The root. Controlled with `open` and `onOpenChange`, or left to manage\n * itself around a `DrawerTrigger`. */\nexport const Drawer = Base.Root\n\n/** What opens it. Give it `render` to use your own button. */\nexport const DrawerTrigger = Base.Trigger\n\n/** What closes it - the same, for a cancel button or an X. */\nexport const DrawerClose = Base.Close\n\n/** The scrim. Dark because a drawer is modal: what is behind it is out of\n * reach, and saying so with contrast is the only thing that reads at a\n * glance. */\nexport function DrawerBackdrop({ className, ...props }: Base.Backdrop.Props) {\n return (\n <Base.Backdrop\n className={cn(\n 'fixed inset-0 bg-black/50 backdrop-blur-[2px]',\n '[z-index:var(--z-overlay)]',\n '[transition:opacity_var(--duration-base)_var(--ease-out)]',\n 'data-[closed]:opacity-0 data-[starting-style]:opacity-0',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport interface DrawerPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof drawerPopupVariants> {\n /** Where to portal to. Defaults to the document body, which is what keeps\n * the popup from being clipped by an ancestor. Pass an element to put it\n * somewhere else - inside an overlay that is already open, or into a\n * container being screenshotted. */\n container?: Base.Portal.Props['container']\n /** Whether to draw the scrim. On by default, and it should stay on for\n * anything a person actually uses: the dim is what says the page behind is\n * out of reach. Turn it off where the popup is shown alongside other things\n * on purpose - a component gallery, a screenshot - because a scrim is\n * `position: fixed` and covers everything, not only its own container. */\n backdrop?: boolean\n}\n\n/** The panel. Portalled, and wrapped in its own viewport so the edge it is\n * pinned to holds still while the body scrolls. Put a `DrawerHeader`, a\n * `DrawerBody` and `DrawerActions` inside it. */\nexport function DrawerPopup({\n container,\n backdrop = true,\n side,\n size,\n className,\n children,\n ...props\n}: DrawerPopupProps) {\n const portal = useRef<HTMLDivElement>(null)\n\n return (\n <Base.Portal ref={portal} container={container}>\n {backdrop && <DrawerBackdrop />}\n <div className={cn(drawerViewportVariants({ side }), '[z-index:var(--z-modal)]')}>\n <Base.Viewport className=\"flex w-full\">\n <Base.Popup\n className={cn(drawerPopupVariants({ side, size }), className)}\n {...props}\n >\n <LayerProvider above=\"modal\" mount={portal}>{children}</LayerProvider>\n </Base.Popup>\n </Base.Viewport>\n </div>\n </Base.Portal>\n )\n}\n\n/** The heading. Base UI points the popup's `aria-labelledby` at it, so a\n * drawer with one is named for a screen reader without anyone arranging it. */\nexport function DrawerTitle({ className, ...props }: Base.Title.Props) {\n return <Base.Title className={cn('text-base font-semibold', className)} {...props} />\n}\n\n/** The line under the heading, and the popup's `aria-describedby`. */\nexport function DrawerDescription({ className, ...props }: Base.Description.Props) {\n return <Base.Description className={cn('mt-1 text-sm text-dim', className)} {...props} />\n}\n\n/** The top of the panel: the title, the line under it, and an action beside\n * them. The dialog's part, under the drawer's name. */\nexport const DrawerHeader = DialogHeader\n\n/** The part that scrolls. The dialog's part, under the drawer's name. */\nexport const DrawerBody = DialogBody\n\n/** Where the actions go, pinned to the bottom edge of the panel however\n * little is in it - a drawer is tall, and its buttons should not wander up\n * the page. The dialog's part, under the drawer's name. */\nexport const DrawerActions = DialogActions\n"
|
|
991
1002
|
}
|
|
992
1003
|
]
|
|
993
1004
|
},
|
|
@@ -997,7 +1008,7 @@
|
|
|
997
1008
|
"title": "DurationField",
|
|
998
1009
|
"description": "The alternative is what products keep building: two number boxes labelled \"hours\" and \"minutes\", which means two tab stops, two validations, and a reader who has to divide 90 minutes in their head before typing. Here they write `1h 30m`, or `90m`, or `1.5h`, and it means the same thing.",
|
|
999
1010
|
"dependencies": [
|
|
1000
|
-
"dowel-ui@^0.
|
|
1011
|
+
"dowel-ui@^0.32.0"
|
|
1001
1012
|
],
|
|
1002
1013
|
"registryDependencies": [
|
|
1003
1014
|
"https://lacodda.github.io/dowel/r/input.json"
|
|
@@ -1018,7 +1029,7 @@
|
|
|
1018
1029
|
"description": "Three kinds of nothing, and a product that draws the same panel for all three is telling the reader the wrong thing twice:\n * **empty** - there is nothing here yet, and that is normal. The panel says what would be here and offers the one action that makes it appear.",
|
|
1019
1030
|
"dependencies": [
|
|
1020
1031
|
"class-variance-authority",
|
|
1021
|
-
"dowel-ui@^0.
|
|
1032
|
+
"dowel-ui@^0.32.0"
|
|
1022
1033
|
],
|
|
1023
1034
|
"registryDependencies": [],
|
|
1024
1035
|
"files": [
|
|
@@ -1056,7 +1067,7 @@
|
|
|
1056
1067
|
"description": "Every form is the same four parts repeated: a name for the control, the control, sometimes a hint, and sometimes an error. Written by hand each time, they drift - the label loses its `htmlFor`, the hint is a `<div>` no screen reader mentions, the error appears in red and is announced by nothing at all. This is that arrangement, once.",
|
|
1057
1068
|
"dependencies": [
|
|
1058
1069
|
"@base-ui/react",
|
|
1059
|
-
"dowel-ui@^0.
|
|
1070
|
+
"dowel-ui@^0.32.0"
|
|
1060
1071
|
],
|
|
1061
1072
|
"registryDependencies": [],
|
|
1062
1073
|
"files": [
|
|
@@ -1074,7 +1085,7 @@
|
|
|
1074
1085
|
"title": "FileDrop",
|
|
1075
1086
|
"description": "A place to put files: drag them onto it, or press it and pick them. It takes files and hands them over - it does not upload them. Where they go, with which credentials, retried how - that is the product's transport, and a primitive that owned it would be wrong for every product whose upload does not look like the one it guessed.",
|
|
1076
1087
|
"dependencies": [
|
|
1077
|
-
"dowel-ui@^0.
|
|
1088
|
+
"dowel-ui@^0.32.0"
|
|
1078
1089
|
],
|
|
1079
1090
|
"registryDependencies": [],
|
|
1080
1091
|
"files": [
|
|
@@ -1092,7 +1103,7 @@
|
|
|
1092
1103
|
"title": "FilterPopover",
|
|
1093
1104
|
"description": "A text box, a handful of checkboxes - with one way to clear it. The shell only: what goes in the panel is the caller's, since a stage is ticked and a title is typed and the popover has no opinion.",
|
|
1094
1105
|
"dependencies": [
|
|
1095
|
-
"dowel-ui@^0.
|
|
1106
|
+
"dowel-ui@^0.32.0"
|
|
1096
1107
|
],
|
|
1097
1108
|
"registryDependencies": [
|
|
1098
1109
|
"https://lacodda.github.io/dowel/r/button.json",
|
|
@@ -1114,7 +1125,7 @@
|
|
|
1114
1125
|
"description": "The layout jump a loading picture leaves behind is not a styling defect, it is a missing number: the browser has nowhere to put the box until the file arrives and tells it the pixel size, so everything below the picture slides down and back up. `AspectRatio` is that number, given up front by the caller rather than discovered by the browser - a plain box on CSS `aspect-ratio` that reserves its space the instant it is in the tree, and lets any child (an `<img>`, a map, a video) fill it with `size-full`.",
|
|
1115
1126
|
"dependencies": [
|
|
1116
1127
|
"class-variance-authority",
|
|
1117
|
-
"dowel-ui@^0.
|
|
1128
|
+
"dowel-ui@^0.32.0"
|
|
1118
1129
|
],
|
|
1119
1130
|
"registryDependencies": [],
|
|
1120
1131
|
"files": [
|
|
@@ -1132,7 +1143,7 @@
|
|
|
1132
1143
|
"title": "Input",
|
|
1133
1144
|
"description": "A single-line field. It is a plain `<input>` with the line's clothes on, so everything a browser gives an input for free - autofill, spellcheck, the right keyboard on a phone, `type=\"email\"` validation - still works.",
|
|
1134
1145
|
"dependencies": [
|
|
1135
|
-
"dowel-ui@^0.
|
|
1146
|
+
"dowel-ui@^0.32.0"
|
|
1136
1147
|
],
|
|
1137
1148
|
"registryDependencies": [],
|
|
1138
1149
|
"files": [
|
|
@@ -1166,7 +1177,7 @@
|
|
|
1166
1177
|
"title": "JsonViewer",
|
|
1167
1178
|
"description": "What a product reaches for when it has to show a response, a settings file, a webhook payload - data the reader needs to understand, not edit. The alternative it replaces is `JSON.stringify(value, null, 2)` inside a `<pre>`, which is fine for twenty lines and useless for two hundred: nothing folds, nothing is findable, and the shape of the document is somewhere inside the indentation.",
|
|
1168
1179
|
"dependencies": [
|
|
1169
|
-
"dowel-ui@^0.
|
|
1180
|
+
"dowel-ui@^0.32.0"
|
|
1170
1181
|
],
|
|
1171
1182
|
"registryDependencies": [
|
|
1172
1183
|
"https://lacodda.github.io/dowel/r/json-rows.json"
|
|
@@ -1186,7 +1197,7 @@
|
|
|
1186
1197
|
"title": "Kbd",
|
|
1187
1198
|
"description": "A key, as printed in a menu or a hint: `Ctrl` `K`. It is a `<kbd>` element because that is what the element is for - a screen reader announces it as keyboard input rather than reading a stray capital letter.",
|
|
1188
1199
|
"dependencies": [
|
|
1189
|
-
"dowel-ui@^0.
|
|
1200
|
+
"dowel-ui@^0.32.0"
|
|
1190
1201
|
],
|
|
1191
1202
|
"registryDependencies": [],
|
|
1192
1203
|
"files": [
|
|
@@ -1205,7 +1216,7 @@
|
|
|
1205
1216
|
"description": "The shape every product builds out of two `<div>`s in a flex row, and the reason it is worth having once: it is a `<dl>`, and the pairing is what a screen reader announces. Two divs read as four unrelated pieces of text - \"Created\", \"2 hours ago\", \"Owner\", \"Ines\" - and nothing says which value belongs to which name. The right element says it for free.",
|
|
1206
1217
|
"dependencies": [
|
|
1207
1218
|
"class-variance-authority",
|
|
1208
|
-
"dowel-ui@^0.
|
|
1219
|
+
"dowel-ui@^0.32.0"
|
|
1209
1220
|
],
|
|
1210
1221
|
"registryDependencies": [],
|
|
1211
1222
|
"files": [
|
|
@@ -1217,6 +1228,22 @@
|
|
|
1217
1228
|
}
|
|
1218
1229
|
]
|
|
1219
1230
|
},
|
|
1231
|
+
{
|
|
1232
|
+
"name": "layer",
|
|
1233
|
+
"type": "registry:ui",
|
|
1234
|
+
"title": "Layer",
|
|
1235
|
+
"description": "Which layer a popup opened inside an overlay lands on, so that a select in a dialog, a menu in a drawer and a date picker in a popover open above the thing that opened them.",
|
|
1236
|
+
"dependencies": [],
|
|
1237
|
+
"registryDependencies": [],
|
|
1238
|
+
"files": [
|
|
1239
|
+
{
|
|
1240
|
+
"path": "ui/layer.tsx",
|
|
1241
|
+
"target": "@ui/layer.tsx",
|
|
1242
|
+
"type": "registry:ui",
|
|
1243
|
+
"content": "import {\n createContext,\n useContext,\n useLayoutEffect,\n useMemo,\n useState,\n type ReactNode,\n type RefObject,\n} from 'react'\n\n/*\n * Layer.\n *\n * Which layer a popup opened inside an overlay lands on, so that a select in\n * a dialog, a menu in a drawer and a date picker in a popover open above the\n * thing that opened them.\n *\n * The stacking scale is a flat ladder - `--z-menu` 30, `--z-floating` 40,\n * `--z-modal` 60 - and every popup portals to the document body, so the ladder\n * alone decides who covers whom. It answers the common question right and has\n * nothing to say about the one that bites: a popup opened from inside an\n * overlay. A date picker in a dialog is a 40 beside a 60, so the month drew\n * under the dialog that asked for it; a menu in a drawer is a 30 beside a 60;\n * a select in a popover is a 30 beside a 40. Each reads as a control that does\n * nothing.\n *\n * Two other fixes were measured in kilna first, and both look right until the\n * screen is looked at. Portalling the popup INTO the overlay puts it in the\n * overlay's stacking context, where it does paint on top - but a dialog's body\n * scrolls, and a scroll box clips a popup inside it: the month came out with\n * one row of days. Raising the popup's own number works exactly once: it is\n * then above every overlay including the ones it is not inside, and the next\n * pairing arrives with no number left for it.\n *\n * So the popup stays at the body, where nothing clips it, and it is the LAYER\n * that travels. An overlay opens a host of its own on the body and raises the\n * popup rungs inside it; a popup opened anywhere within that overlay portals\n * into the host (`usePopupContainer`) and reads the raised value through\n * ordinary inheritance - its class still says `[z-index:var(--z-floating)]`\n * and has no idea this exists.\n *\n * **The floor is worked out by the stylesheet, not written in numbers.** The\n * donor in kilna kept a mirror of the ladder in TypeScript and a test that the\n * mirror had not drifted. Here the floor is `calc(var(--z-modal) + 1)`, read\n * from the theme where it is declared, so renumbering the ladder moves every\n * floor with it and there is no second copy to forget.\n *\n * **A layer inside a layer keeps climbing.** A popover opened in a dialog is a\n * layer of its own - a select inside it must clear the popover, not only the\n * dialog - so a nested host goes inside its parent's host and inherits the\n * raised rungs. Its floor is one above the larger of its own rung and its\n * parent's floor, which is right for both directions: a popover in a dialog\n * rides above the dialog's floor, and a dialog opened from inside a popover\n * gives its popups a floor above the modal rung rather than the popover's.\n *\n * **Two nodes, not one, and the reason is the cascade.** The floor is computed\n * from the rung the host inherits, and the host then redefines that same rung.\n * On one element that is a cycle - `--z-floating` defined through a floor that\n * is defined through `--z-floating` - and CSS answers a cycle by making both\n * invalid, which sends the z-index back to `auto`. So an outer frame works the\n * floor out from what it inherited, and the host inside it publishes it.\n * Neither node draws anything or makes a stacking context: they stay static,\n * so a popup inside is placed and measured exactly as it would be on the body.\n */\n\n/** The rungs of the stacking scale an overlay stands on. */\nexport type LayerRung = 'popup' | 'menu' | 'floating' | 'overlay' | 'modal' | 'palette'\n\n/** The rungs a popup reads its z-index from. Every one is raised, not only the\n * one a particular popup happens to read: a popover reads floating, a menu and\n * a select read menu, a tooltip reads popup - and for as long as the donor\n * lifted only floating, the select in a dialog stayed on the page's floor. */\nconst POPUP_RUNGS = ['--z-popup', '--z-menu', '--z-floating'] as const\n\ninterface Layer {\n readonly host: RefObject<HTMLElement | null>\n}\n\nconst LayerContext = createContext<Layer | null>(null)\n\n/** Where a popup opened here should portal to, or `undefined` when there is no\n * overlay around it and the body is right. A popup passes it as its portal's\n * `container`, after the caller's own. */\nexport function usePopupContainer(): RefObject<HTMLElement | null> | undefined {\n return useContext(LayerContext)?.host\n}\n\n/** The floor of a layer above `rung`, as the frame declares it: one above the\n * larger of the rung and the floor it is nested in. `--z-layer` is unset\n * outside every layer, and the fallback makes the rung win there. */\nexport function layerFloor(rung: LayerRung): string {\n return `calc(max(var(--z-${rung}), var(--z-layer, 0)) + 1)`\n}\n\nexport interface LayerProviderProps {\n /** The rung the overlay itself stands on: `modal` for a dialog or a drawer,\n * `palette` for the command palette, `floating` for a popover, `overlay`\n * for a product's own full-screen stage. */\n above: LayerRung\n /** Where the layer goes: the overlay's own portal node. Every overlay of\n * the set passes it, and it matters for the modal ones. A modal dialog\n * hides everything outside its portal from assistive technology - Base UI\n * marks the rest of the body `aria-hidden` - and a layer beside the portal\n * rather than in it was hidden with the page: the menu opened in a drawer\n * worked for a pointer and did not exist for a screen reader. Inside the\n * portal the layer counts as the overlay's own. Without it the layer goes\n * into the layer it was opened in, or onto the body. */\n mount?: RefObject<HTMLElement | null>\n children: ReactNode\n}\n\n/** Opens a raised host beside an overlay and offers it to every popup opened\n * inside. Put it inside the overlay's popup, around its content. */\nexport function LayerProvider({ above, mount, children }: LayerProviderProps) {\n const parent = useContext(LayerContext)\n\n // The nodes are made during the first render rather than in the effect. A\n // popup reads its `container` as it mounts, and a host that only appeared\n // on a second pass would let the first paint go to the body - the one frame\n // in which the bug is still there. A lazy state initialiser rather than a\n // ref filled in during render: it runs once, and nothing is read or written\n // through a ref while rendering. The pair never changes, so nothing ever\n // re-renders because of it.\n const [layer] = useState<Layer & { frame: HTMLElement | null }>(() => {\n if (typeof document === 'undefined') return { frame: null, host: { current: null } }\n const frame = document.createElement('div')\n const host = document.createElement('div')\n frame.append(host)\n return { frame, host: { current: host } }\n })\n\n // A layout effect, so the host is in the document before the browser paints\n // anything portalled into it. A child's effect runs before its parent's,\n // which is fine: the parent's host already exists from its render, and the\n // parent attaches the whole branch when its own effect runs.\n useLayoutEffect(() => {\n const outer = layer.frame\n const inner = layer.host.current\n if (outer === null || inner === null) return\n outer.setAttribute('data-dowel-layer', above)\n // Marked as a portal host, which is what it is - and what keeps a reader\n // able to reach it. A modal overlay hides every sibling of its popup from\n // assistive technology when it opens, inside its own portal as much as\n // on the body, and spares only the portal nodes nested in it. The layer\n // is empty at that moment - the select inside is opened later - so\n // without the mark the whole layer was hidden, and every popup opened\n // into it after: a menu that worked for a pointer and was not there for\n // a screen reader.\n outer.setAttribute('data-base-ui-portal', '')\n outer.style.setProperty('--z-layer-next', layerFloor(above))\n inner.style.setProperty('--z-layer', 'var(--z-layer-next)')\n for (const rung of POPUP_RUNGS) inner.style.setProperty(rung, 'var(--z-layer-next)')\n ;(mount?.current ?? parent?.host.current ?? document.body).append(outer)\n return () => outer.remove()\n }, [above, layer, mount, parent])\n\n const value = useMemo<Layer>(() => ({ host: layer.host }), [layer])\n return <LayerContext.Provider value={value}>{children}</LayerContext.Provider>\n}\n"
|
|
1244
|
+
}
|
|
1245
|
+
]
|
|
1246
|
+
},
|
|
1220
1247
|
{
|
|
1221
1248
|
"name": "line-chart",
|
|
1222
1249
|
"type": "registry:ui",
|
|
@@ -1224,7 +1251,7 @@
|
|
|
1224
1251
|
"description": "The distinction against its neighbours is the data's, not the drawing's. A column says each period is its own sum - hours worked in a week, and there is no Wednesday-afternoon figure between two weeks. A line says the value existed the whole time and was sampled: an account balance, a price, a temperature. Drawing a sum as a line claims readings nobody took; drawing a level as columns throws away the thing being watched.",
|
|
1225
1252
|
"dependencies": [
|
|
1226
1253
|
"class-variance-authority",
|
|
1227
|
-
"dowel-ui@^0.
|
|
1254
|
+
"dowel-ui@^0.32.0"
|
|
1228
1255
|
],
|
|
1229
1256
|
"registryDependencies": [
|
|
1230
1257
|
"https://lacodda.github.io/dowel/r/line-scale.json"
|
|
@@ -1260,7 +1287,7 @@
|
|
|
1260
1287
|
"title": "MarkedText",
|
|
1261
1288
|
"description": "A textarea cannot colour a word. The way round it is older than React: draw the same text twice, once as marked-up HTML underneath and once as the textarea on top with its own text transparent, so the caret and the selection are the browser's and the colours are ours. The two have to agree on every metric - font, size, line height, padding, wrapping - or the marks slide off the words they mark. So both take ONE class list, given by the caller, and the textarea adds only what makes it invisible.",
|
|
1262
1289
|
"dependencies": [
|
|
1263
|
-
"dowel-ui@^0.
|
|
1290
|
+
"dowel-ui@^0.32.0"
|
|
1264
1291
|
],
|
|
1265
1292
|
"registryDependencies": [],
|
|
1266
1293
|
"files": [
|
|
@@ -1280,15 +1307,17 @@
|
|
|
1280
1307
|
"dependencies": [
|
|
1281
1308
|
"@base-ui/react",
|
|
1282
1309
|
"class-variance-authority",
|
|
1283
|
-
"dowel-ui@^0.
|
|
1310
|
+
"dowel-ui@^0.32.0"
|
|
1311
|
+
],
|
|
1312
|
+
"registryDependencies": [
|
|
1313
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
1284
1314
|
],
|
|
1285
|
-
"registryDependencies": [],
|
|
1286
1315
|
"files": [
|
|
1287
1316
|
{
|
|
1288
1317
|
"path": "ui/menu.tsx",
|
|
1289
1318
|
"target": "@ui/menu.tsx",
|
|
1290
1319
|
"type": "registry:ui",
|
|
1291
|
-
"content": "import { Menu as Base } from '@base-ui/react/menu'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Menu.\n *\n * A list of actions that opens from a button - the row menu, the overflow\n * menu, the one behind the three dots. The products all wrote this by hand,\n * and all of them wrote the same three hundred lines: a click-outside\n * listener, an Escape handler, and a `stopPropagation` on every item so that\n * choosing an action does not also open the row underneath.\n *\n * None of that is what makes a menu hard. What makes it hard is the keyboard:\n * arrows that wrap, Home and End, type-ahead that finds an item by its first\n * letters, a submenu that opens on the right key and closes when the pointer\n * leaves diagonally. Base UI has all of it.\n *\n * The items are exposed rather than taken as an array of `{ label, onSelect }`.\n * An array is enough until the first separator, the first checkbox item and\n * the first submenu - and each of those arrives as another field on the object\n * rather than as the JSX it obviously is.\n */\n\nexport const menuPopupVariants = cva(\n [\n 'min-w-40 rounded-md border border-line bg-raise p-1 text-text shadow-raise',\n 'focus-visible:outline-none',\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.98] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0',\n ],\n {\n variants: {\n size: {\n sm: 'min-w-32',\n md: 'min-w-40',\n lg: 'min-w-56',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** One row of the menu. `danger` draws the destructive one apart from the\n * rest - in the colour of something that cannot be undone. */\nexport const menuItemVariants = cva(\n [\n 'flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm',\n 'outline-none transition-colors',\n // Base UI marks the item under the pointer or the keyboard the same way,\n // so one rule covers both and they cannot disagree.\n 'data-[highlighted]:bg-soft data-[highlighted]:text-text',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n '[&_svg]:size-3.5 [&_svg]:shrink-0',\n ],\n {\n variants: {\n tone: {\n default: 'text-dim data-[highlighted]:text-text',\n danger: 'text-bad data-[highlighted]:bg-bad-soft data-[highlighted]:text-bad',\n },\n },\n defaultVariants: { tone: 'default' },\n },\n)\n\n/** The root. Uncontrolled by default; `open` and `onOpenChange` make it\n * controlled. */\nexport const Menu = Base.Root\n\n/** What opens it. Give it `render` to use your own button. */\nexport const MenuTrigger = Base.Trigger\n\n/** A labelled group of items, for a menu long enough to need headings. */\nexport const MenuGroup = Base.Group\n\n/** A submenu, opened from a `MenuSubTrigger` inside the parent. */\nexport const MenuSub = Base.SubmenuRoot\n\nexport interface MenuPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof menuPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Where to portal to. Defaults to the
|
|
1320
|
+
"content": "import { Menu as Base } from '@base-ui/react/menu'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { usePopupContainer } from './layer'\n\n/*\n * Menu.\n *\n * A list of actions that opens from a button - the row menu, the overflow\n * menu, the one behind the three dots. The products all wrote this by hand,\n * and all of them wrote the same three hundred lines: a click-outside\n * listener, an Escape handler, and a `stopPropagation` on every item so that\n * choosing an action does not also open the row underneath.\n *\n * None of that is what makes a menu hard. What makes it hard is the keyboard:\n * arrows that wrap, Home and End, type-ahead that finds an item by its first\n * letters, a submenu that opens on the right key and closes when the pointer\n * leaves diagonally. Base UI has all of it.\n *\n * The items are exposed rather than taken as an array of `{ label, onSelect }`.\n * An array is enough until the first separator, the first checkbox item and\n * the first submenu - and each of those arrives as another field on the object\n * rather than as the JSX it obviously is.\n */\n\nexport const menuPopupVariants = cva(\n [\n 'min-w-40 rounded-md border border-line bg-raise p-1 text-text shadow-raise',\n 'focus-visible:outline-none',\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.98] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0',\n ],\n {\n variants: {\n size: {\n sm: 'min-w-32',\n md: 'min-w-40',\n lg: 'min-w-56',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** One row of the menu. `danger` draws the destructive one apart from the\n * rest - in the colour of something that cannot be undone. */\nexport const menuItemVariants = cva(\n [\n 'flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm',\n 'outline-none transition-colors',\n // Base UI marks the item under the pointer or the keyboard the same way,\n // so one rule covers both and they cannot disagree.\n 'data-[highlighted]:bg-soft data-[highlighted]:text-text',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n '[&_svg:not([class*=size-])]:size-3.5 [&_svg]:shrink-0',\n ],\n {\n variants: {\n tone: {\n default: 'text-dim data-[highlighted]:text-text',\n danger: 'text-bad data-[highlighted]:bg-bad-soft data-[highlighted]:text-bad',\n },\n },\n defaultVariants: { tone: 'default' },\n },\n)\n\n/** The root. Uncontrolled by default; `open` and `onOpenChange` make it\n * controlled. */\nexport const Menu = Base.Root\n\n/** What opens it. Give it `render` to use your own button. */\nexport const MenuTrigger = Base.Trigger\n\n/** A labelled group of items, for a menu long enough to need headings. */\nexport const MenuGroup = Base.Group\n\n/** A submenu, opened from a `MenuSubTrigger` inside the parent. */\nexport const MenuSub = Base.SubmenuRoot\n\nexport interface MenuPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof menuPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Where to portal to. Defaults to the raised host of the overlay this is\n * opened inside (`layer.tsx`), and to the document body when there is none -\n * either way not the element it was opened from, whose `overflow` would clip\n * it. Pass an element to put it somewhere else, such as a container being\n * screenshotted. */\n container?: Base.Portal.Props['container']\n}\n\n/** The panel. Portalled and positioned against the trigger. */\nexport function MenuPopup({\n size,\n side,\n align,\n sideOffset = 4,\n container,\n className,\n children,\n ...props\n}: MenuPopupProps) {\n // Inside an overlay, the overlay's raised host rather than the body - or\n // this popup draws under the dialog, drawer or popover that opened it. See\n // `layer.tsx`. Outside every overlay the hook gives `undefined`: the body.\n const host = usePopupContainer()\n\n return (\n <Base.Portal container={container ?? host}>\n <Base.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n className=\"[z-index:var(--z-menu)]\"\n >\n <Base.Popup className={cn(menuPopupVariants({ size }), className)} {...props}>\n {children}\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\nexport interface MenuItemProps extends Base.Item.Props, VariantProps<typeof menuItemVariants> {}\n\n/** An action. Closing the menu afterwards is Base UI's default, which is\n * almost always right - `closeOnClick={false}` is for the one that is not. */\nexport function MenuItem({ tone, className, ...props }: MenuItemProps) {\n return <Base.Item className={cn(menuItemVariants({ tone }), className)} {...props} />\n}\n\n/** An item that opens a submenu. Drawn like any other, because it is one. */\nexport function MenuSubTrigger({ tone, className, ...props }: MenuItemProps) {\n return <Base.SubmenuTrigger className={cn(menuItemVariants({ tone }), className)} {...props} />\n}\n\nexport interface MenuCheckboxItemProps\n extends Base.CheckboxItem.Props,\n VariantProps<typeof menuItemVariants> {}\n\n/** An item that carries a tick. The state is the caller's - a menu does not\n * remember anything.\n *\n * Typed from `CheckboxItem` rather than `Item`: it was declared with the plain\n * item's props while rendering a checkbox, so `checked` and `onCheckedChange` -\n * the two things it exists for - were rejected by the compiler. Nothing had\n * called it until kilna's column picker did. */\nexport function MenuCheckboxItem({ tone, className, ...props }: MenuCheckboxItemProps) {\n return <Base.CheckboxItem className={cn(menuItemVariants({ tone }), className)} {...props} />\n}\n\n/** The tick itself, drawn only when the item is checked. */\nexport const MenuCheckboxIndicator = Base.CheckboxItemIndicator\n\n/** A line between groups of items. Decorative, and marked as such: a screen\n * reader announcing \"separator\" between every pair of actions is noise. */\nexport function MenuSeparator({ className, ...props }: Base.Separator.Props) {\n return <Base.Separator className={cn('-mx-1 my-1 h-px bg-line', className)} {...props} />\n}\n\n/** The caption above a group. */\nexport function MenuGroupLabel({ className, ...props }: Base.GroupLabel.Props) {\n return (\n <Base.GroupLabel\n className={cn('px-2 py-1.5 text-2xs uppercase tracking-caption text-faint', className)}\n {...props}\n />\n )\n}\n"
|
|
1292
1321
|
}
|
|
1293
1322
|
]
|
|
1294
1323
|
},
|
|
@@ -1300,7 +1329,7 @@
|
|
|
1300
1329
|
"dependencies": [
|
|
1301
1330
|
"@base-ui/react",
|
|
1302
1331
|
"class-variance-authority",
|
|
1303
|
-
"dowel-ui@^0.
|
|
1332
|
+
"dowel-ui@^0.32.0"
|
|
1304
1333
|
],
|
|
1305
1334
|
"registryDependencies": [],
|
|
1306
1335
|
"files": [
|
|
@@ -1308,7 +1337,7 @@
|
|
|
1308
1337
|
"path": "ui/nav-rail.tsx",
|
|
1309
1338
|
"target": "@ui/nav-rail.tsx",
|
|
1310
1339
|
"type": "registry:ui",
|
|
1311
|
-
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * NavRail.\n *\n * The product's own destinations: the screens it has, drawn as a column down\n * the left, a row of tabs in a header, or a bar along the bottom of a phone.\n * One list, three shapes, because they are the same list - and when they were\n * three components in two products they drew the current entry three\n * different ways.\n *\n * The entries are the product's links, not this component's. `render` takes\n * an item and answers with the element to draw it as - a router's `NavLink`,\n * a plain `<a>`, whatever the product navigates with - and the rail puts the\n * clothes, the icon and the `aria-current` on it. That keeps the router out\n * of the registry entirely: a set that imported `react-router` would install\n * one in a product that had chosen another, and there is no version of that\n * which is the design system's business.\n *\n * `NavGroup` is the small uppercase caption between runs of entries, and\n * `NavSpacer` pushes what follows to the far end - the settings, the theme\n * switch, the profile, which every rail in the line keeps at its foot.\n */\n\nexport const navRailVariants = cva('flex', {\n variants: {\n /*\n * Which of the three shapes this is.\n *\n * Not a guess from the width: a rail that changed shape when its\n * container narrowed would change shape in the middle of a drag.\n */\n layout: {\n /* Down the left, the desktop shape. `h-full` so the rail runs the\n * height of the window and its foot sits at the bottom because the nav\n * reaches it, not because the content does. */\n column: 'h-full flex-col gap-0.5 overflow-y-auto border-r border-line px-2.5 pt-2.5 pb-3',\n /* A row of tabs, in a header beside the product's name. */\n row: 'flex-row items-center gap-1',\n /* Along the bottom, where a thumb already is. The safe-area inset is\n * the phone's home indicator: without it the last row of entries sits\n * under it with no way to scroll out. */\n bar: 'flex-row border-t border-line bg-raise pb-[env(safe-area-inset-bottom)]',\n },\n },\n defaultVariants: { layout: 'column' },\n})\n\nexport interface NavRailItem {\n id: string\n label: ReactNode\n icon?: ReactNode\n /** A count, a dot, a version chip - whatever sits at the end of the row.\n * Drawn only in `column`, where there is width for it. */\n end?: ReactNode\n /** A destination that exists on the roadmap but not in the build. It is\n * drawn greyed and is not a link: the point is to say the screen is coming,\n * which an entry that navigates nowhere would say by doing nothing. */\n soon?: boolean\n}\n\nexport interface NavRailProps\n extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'onSelect'>,\n VariantProps<typeof navRailVariants> {\n /** What this set of destinations is called. Not drawn - it names the\n * landmark, so a reader meeting two navs on one page can tell which is\n * which. A product with a rail AND a bottom bar has exactly that. */\n label: string\n items: readonly NavRailItem[]\n /** Which destination is the open screen. */\n activeId?: string\n /** The element an entry is drawn as - `render={(item) => <NavLink to={…} />}`. */\n render?: (item: NavRailItem) => useRender.RenderProp\n /** Pressed, whatever the entry is drawn as. */\n onSelect?: (id: string) => void\n}\n\nexport function NavRail({\n layout,\n label,\n items,\n activeId,\n render,\n onSelect,\n className,\n ...props\n}: NavRailProps) {\n return (\n <nav aria-label={label} className={cn(navRailVariants({ layout }), className)} {...props}>\n {items.map((item) => (\n <NavRailEntry\n key={item.id}\n item={item}\n layout={layout ?? 'column'}\n active={item.id === activeId}\n render={item.soon === true ? undefined : render?.(item)}\n onSelect={onSelect}\n />\n ))}\n </nav>\n )\n}\n\n/** The clothes of one entry, by shape.\n *\n * `target-min` on the two narrow shapes rather than on all three: a column\n * entry is already taller than the floor, and the utility establishes a\n * containing block, which is not free on every row of a list. */\nconst entryClasses = {\n column:\n 'flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm no-underline transition-colors',\n /* `flex` here for the same reason as the other two, and it was missing: a\n * tab is an icon beside a word, and without it the entry is a block, the\n * icon and the label stack, and the header grows to twice its height. The\n * class-list tests did not see it - they read the string, not the layout -\n * and the stand did, in the first screenshot. */\n row: 'target-min flex items-center gap-2 rounded-md px-2.5 py-1 text-sm no-underline transition-colors',\n bar: 'target-min flex min-h-14 min-w-0 flex-1 flex-col items-center justify-center gap-1 px-1 py-2 text-2xs no-underline transition-colors',\n} as const\n\nfunction NavRailEntry({\n item,\n layout,\n active,\n render,\n onSelect,\n}: {\n item: NavRailItem\n layout: NonNullable<NavRailProps['layout']>\n active: boolean\n render?: useRender.RenderProp\n onSelect?: (id: string) => void\n}) {\n const soon = item.soon === true\n\n return useRender({\n render,\n // A destination is a link when the product gives it one and a button when\n // it does not; one that is not built yet is neither, and `span` says so -\n // a disabled button is still in the tab order on some browsers, and\n // tabbing onto a screen that does not exist is a dead end.\n defaultTagName: soon ? 'span' : 'button',\n props: {\n ...(render === undefined && !soon ? { type: 'button' } : {}),\n // Named as the current page, which is how a reader learns which of six\n // identical links is where they stand. Colour alone says it to nobody\n // who cannot see it.\n 'aria-current': active ? 'page' : undefined,\n ...(soon ? { 'aria-disabled': true } : {}),\n onClick: soon ? undefined : () => onSelect?.(item.id),\n className: cn(\n entryClasses[layout],\n '[&_svg]:size-4 [&_svg]:shrink-0',\n 'focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent',\n soon\n ? 'cursor-default text-faint'\n : cn(\n 'cursor-pointer text-dim hover:bg-soft hover:text-text',\n // The bottom bar tints the entry itself rather than filling the\n // cell: a filled cell in a four-across bar reads as a pressed\n // button, and it is a location, not an action.\n active &&\n (layout === 'bar'\n ? 'text-accent-2 hover:bg-transparent'\n : 'bg-accent-soft text-text [&_svg]:text-accent'),\n ),\n ),\n children: (\n <>\n {item.icon === undefined ? null : (\n <span aria-hidden className=\"contents\">\n {item.icon}\n </span>\n )}\n {/* Truncated, in one line. A rail is a fixed-width column, and a\n label that wraps onto a second line makes the row taller than\n every other - which in a two-language product happens to one\n entry and not the rest. `min-w-0` because a flex child refuses\n to shrink below its content without it. */}\n <span className={cn('min-w-0 truncate', layout === 'bar' ? 'w-full text-center' : 'flex-1')}>\n {item.label}\n </span>\n {item.end === undefined || layout !== 'column' ? null : (\n <span className=\"ml-auto shrink-0 text-2xs text-faint\">{item.end}</span>\n )}\n </>\n ),\n },\n })\n}\n\n/** The caption over a run of entries: Library, Team, Admin.\n *\n * A `div` rather than a heading: a rail's groups are not the page's outline,\n * and six `h3`s inside a nav put six entries into a reader's document map\n * that lead nowhere. */\nexport function NavGroup({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn(\n 'px-2.5 pt-3 pb-1 text-2xs font-medium uppercase tracking-caption text-faint',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** Pushes everything after it to the far end of the rail. */\nexport function NavSpacer({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('mt-auto flex flex-col gap-0.5', className)} {...props} />\n}\n"
|
|
1340
|
+
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * NavRail.\n *\n * The product's own destinations: the screens it has, drawn as a column down\n * the left, a row of tabs in a header, or a bar along the bottom of a phone.\n * One list, three shapes, because they are the same list - and when they were\n * three components in two products they drew the current entry three\n * different ways.\n *\n * The entries are the product's links, not this component's. `render` takes\n * an item and answers with the element to draw it as - a router's `NavLink`,\n * a plain `<a>`, whatever the product navigates with - and the rail puts the\n * clothes, the icon and the `aria-current` on it. That keeps the router out\n * of the registry entirely: a set that imported `react-router` would install\n * one in a product that had chosen another, and there is no version of that\n * which is the design system's business.\n *\n * `NavGroup` is the small uppercase caption between runs of entries, and\n * `NavSpacer` pushes what follows to the far end - the settings, the theme\n * switch, the profile, which every rail in the line keeps at its foot.\n */\n\nexport const navRailVariants = cva('flex', {\n variants: {\n /*\n * Which of the three shapes this is.\n *\n * Not a guess from the width: a rail that changed shape when its\n * container narrowed would change shape in the middle of a drag.\n */\n layout: {\n /* Down the left, the desktop shape. `h-full` so the rail runs the\n * height of the window and its foot sits at the bottom because the nav\n * reaches it, not because the content does. */\n column: 'h-full flex-col gap-0.5 overflow-y-auto border-r border-line px-2.5 pt-2.5 pb-3',\n /* A row of tabs, in a header beside the product's name. */\n row: 'flex-row items-center gap-1',\n /* Along the bottom, where a thumb already is. The safe-area inset is\n * the phone's home indicator: without it the last row of entries sits\n * under it with no way to scroll out. */\n bar: 'flex-row border-t border-line bg-raise pb-[env(safe-area-inset-bottom)]',\n },\n },\n defaultVariants: { layout: 'column' },\n})\n\nexport interface NavRailItem {\n id: string\n label: ReactNode\n icon?: ReactNode\n /** A count, a dot, a version chip - whatever sits at the end of the row.\n * Drawn only in `column`, where there is width for it. */\n end?: ReactNode\n /** A destination that exists on the roadmap but not in the build. It is\n * drawn greyed and is not a link: the point is to say the screen is coming,\n * which an entry that navigates nowhere would say by doing nothing. */\n soon?: boolean\n}\n\nexport interface NavRailProps\n extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'onSelect'>,\n VariantProps<typeof navRailVariants> {\n /** What this set of destinations is called. Not drawn - it names the\n * landmark, so a reader meeting two navs on one page can tell which is\n * which. A product with a rail AND a bottom bar has exactly that. */\n label: string\n items: readonly NavRailItem[]\n /** Which destination is the open screen. */\n activeId?: string\n /** The element an entry is drawn as - `render={(item) => <NavLink to={…} />}`. */\n render?: (item: NavRailItem) => useRender.RenderProp\n /** Pressed, whatever the entry is drawn as. */\n onSelect?: (id: string) => void\n}\n\nexport function NavRail({\n layout,\n label,\n items,\n activeId,\n render,\n onSelect,\n className,\n ...props\n}: NavRailProps) {\n return (\n <nav aria-label={label} className={cn(navRailVariants({ layout }), className)} {...props}>\n {items.map((item) => (\n <NavRailEntry\n key={item.id}\n item={item}\n layout={layout ?? 'column'}\n active={item.id === activeId}\n render={item.soon === true ? undefined : render?.(item)}\n onSelect={onSelect}\n />\n ))}\n </nav>\n )\n}\n\n/** The clothes of one entry, by shape.\n *\n * `target-min` on the two narrow shapes rather than on all three: a column\n * entry is already taller than the floor, and the utility establishes a\n * containing block, which is not free on every row of a list. */\nconst entryClasses = {\n column:\n 'flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm no-underline transition-colors',\n /* `flex` here for the same reason as the other two, and it was missing: a\n * tab is an icon beside a word, and without it the entry is a block, the\n * icon and the label stack, and the header grows to twice its height. The\n * class-list tests did not see it - they read the string, not the layout -\n * and the stand did, in the first screenshot. */\n row: 'target-min flex items-center gap-2 rounded-md px-2.5 py-1 text-sm no-underline transition-colors',\n bar: 'target-min flex min-h-14 min-w-0 flex-1 flex-col items-center justify-center gap-1 px-1 py-2 text-2xs no-underline transition-colors',\n} as const\n\nfunction NavRailEntry({\n item,\n layout,\n active,\n render,\n onSelect,\n}: {\n item: NavRailItem\n layout: NonNullable<NavRailProps['layout']>\n active: boolean\n render?: useRender.RenderProp\n onSelect?: (id: string) => void\n}) {\n const soon = item.soon === true\n\n return useRender({\n render,\n // A destination is a link when the product gives it one and a button when\n // it does not; one that is not built yet is neither, and `span` says so -\n // a disabled button is still in the tab order on some browsers, and\n // tabbing onto a screen that does not exist is a dead end.\n defaultTagName: soon ? 'span' : 'button',\n props: {\n ...(render === undefined && !soon ? { type: 'button' } : {}),\n // Named as the current page, which is how a reader learns which of six\n // identical links is where they stand. Colour alone says it to nobody\n // who cannot see it.\n 'aria-current': active ? 'page' : undefined,\n ...(soon ? { 'aria-disabled': true } : {}),\n onClick: soon ? undefined : () => onSelect?.(item.id),\n className: cn(\n entryClasses[layout],\n '[&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0',\n 'focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent',\n soon\n ? 'cursor-default text-faint'\n : cn(\n 'cursor-pointer text-dim hover:bg-soft hover:text-text',\n // The bottom bar tints the entry itself rather than filling the\n // cell: a filled cell in a four-across bar reads as a pressed\n // button, and it is a location, not an action.\n active &&\n (layout === 'bar'\n ? 'text-accent-2 hover:bg-transparent'\n : 'bg-accent-soft text-text [&_svg]:text-accent'),\n ),\n ),\n children: (\n <>\n {item.icon === undefined ? null : (\n <span aria-hidden className=\"contents\">\n {item.icon}\n </span>\n )}\n {/* Truncated, in one line. A rail is a fixed-width column, and a\n label that wraps onto a second line makes the row taller than\n every other - which in a two-language product happens to one\n entry and not the rest. `min-w-0` because a flex child refuses\n to shrink below its content without it. */}\n <span className={cn('min-w-0 truncate', layout === 'bar' ? 'w-full text-center' : 'flex-1')}>\n {item.label}\n </span>\n {item.end === undefined || layout !== 'column' ? null : (\n <span className=\"ml-auto shrink-0 text-2xs text-faint\">{item.end}</span>\n )}\n </>\n ),\n },\n })\n}\n\n/** The caption over a run of entries: Library, Team, Admin.\n *\n * A `div` rather than a heading: a rail's groups are not the page's outline,\n * and six `h3`s inside a nav put six entries into a reader's document map\n * that lead nowhere. */\nexport function NavGroup({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return (\n <div\n className={cn(\n 'px-2.5 pt-3 pb-1 text-2xs font-medium uppercase tracking-caption text-faint',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** Pushes everything after it to the far end of the rail. */\nexport function NavSpacer({ className, ...props }: HTMLAttributes<HTMLDivElement>) {\n return <div className={cn('mt-auto flex flex-col gap-0.5', className)} {...props} />\n}\n"
|
|
1312
1341
|
}
|
|
1313
1342
|
]
|
|
1314
1343
|
},
|
|
@@ -1318,7 +1347,7 @@
|
|
|
1318
1347
|
"title": "NotificationBell",
|
|
1319
1348
|
"description": "A bell that is always lit is a bell nobody reads, so the count is the product's decision and this draws it: nothing at zero, the number past that, `9+` past nine. Pressing it does not leave the screen - the last few entries open under it and the whole history is one more click, which is the shape every product converged on once the first one tried a page.",
|
|
1320
1349
|
"dependencies": [
|
|
1321
|
-
"dowel-ui@^0.
|
|
1350
|
+
"dowel-ui@^0.32.0"
|
|
1322
1351
|
],
|
|
1323
1352
|
"registryDependencies": [
|
|
1324
1353
|
"https://lacodda.github.io/dowel/r/button.json",
|
|
@@ -1340,7 +1369,7 @@
|
|
|
1340
1369
|
"description": "A number typed into a text input is a string that happens to look like a number, and every product then writes the same four fixes: strip the letters, clamp to a range, round to a step, and decide what an empty box means. This is those four, once, plus the stepper - because a value with a small range is faster nudged than typed.",
|
|
1341
1370
|
"dependencies": [
|
|
1342
1371
|
"@base-ui/react",
|
|
1343
|
-
"dowel-ui@^0.
|
|
1372
|
+
"dowel-ui@^0.32.0"
|
|
1344
1373
|
],
|
|
1345
1374
|
"registryDependencies": [
|
|
1346
1375
|
"https://lacodda.github.io/dowel/r/input.json"
|
|
@@ -1360,7 +1389,7 @@
|
|
|
1360
1389
|
"title": "NumberFormat",
|
|
1361
1390
|
"description": "Two things, and the second is the reason this is a component rather than a call to `toLocaleString` at each site.",
|
|
1362
1391
|
"dependencies": [
|
|
1363
|
-
"dowel-ui@^0.
|
|
1392
|
+
"dowel-ui@^0.32.0"
|
|
1364
1393
|
],
|
|
1365
1394
|
"registryDependencies": [],
|
|
1366
1395
|
"files": [
|
|
@@ -1379,7 +1408,7 @@
|
|
|
1379
1408
|
"description": "What a screen says it is, and the buttons that act on the whole of it: a title, a line under it, and the actions at the far end of the same row.",
|
|
1380
1409
|
"dependencies": [
|
|
1381
1410
|
"class-variance-authority",
|
|
1382
|
-
"dowel-ui@^0.
|
|
1411
|
+
"dowel-ui@^0.32.0"
|
|
1383
1412
|
],
|
|
1384
1413
|
"registryDependencies": [],
|
|
1385
1414
|
"files": [
|
|
@@ -1397,7 +1426,7 @@
|
|
|
1397
1426
|
"title": "PageSize",
|
|
1398
1427
|
"description": "Its own file rather than a part of `Pagination`, because the two are needed apart often enough: a list that scrolls for ever wants \"how many to load at a time\" and no page buttons, and a table with a fixed page size wants the buttons and no choice. Together they were also over the size gate, which asked the right question.",
|
|
1399
1428
|
"dependencies": [
|
|
1400
|
-
"dowel-ui@^0.
|
|
1429
|
+
"dowel-ui@^0.32.0"
|
|
1401
1430
|
],
|
|
1402
1431
|
"registryDependencies": [
|
|
1403
1432
|
"https://lacodda.github.io/dowel/r/select.json"
|
|
@@ -1417,7 +1446,7 @@
|
|
|
1417
1446
|
"title": "Pagination",
|
|
1418
1447
|
"description": "The arithmetic is exported separately from the component for the same reason `table-sort` is a file of its own: a product that pages on the server needs the page numbers and not the buttons, and computing them a second time in a different place is how the two disagree about where the last page ends.",
|
|
1419
1448
|
"dependencies": [
|
|
1420
|
-
"dowel-ui@^0.
|
|
1449
|
+
"dowel-ui@^0.32.0"
|
|
1421
1450
|
],
|
|
1422
1451
|
"registryDependencies": [
|
|
1423
1452
|
"https://lacodda.github.io/dowel/r/button.json"
|
|
@@ -1438,7 +1467,7 @@
|
|
|
1438
1467
|
"description": "The raised surface everything else sits on. It is the one place a screen gets its structure from, so it stays deliberately plain: a ground, a hairline, a corner.",
|
|
1439
1468
|
"dependencies": [
|
|
1440
1469
|
"class-variance-authority",
|
|
1441
|
-
"dowel-ui@^0.
|
|
1470
|
+
"dowel-ui@^0.32.0"
|
|
1442
1471
|
],
|
|
1443
1472
|
"registryDependencies": [],
|
|
1444
1473
|
"files": [
|
|
@@ -1456,7 +1485,7 @@
|
|
|
1456
1485
|
"title": "PasswordField",
|
|
1457
1486
|
"description": "The reveal is the whole component, and it is not a convenience. A masked field is the only one in a form where a typo cannot be seen, so people either paste (fine) or type slowly and get it wrong anyway; the toggle is what turns an unverifiable field into a checkable one, and it is why long passphrases became usable at all.",
|
|
1458
1487
|
"dependencies": [
|
|
1459
|
-
"dowel-ui@^0.
|
|
1488
|
+
"dowel-ui@^0.32.0"
|
|
1460
1489
|
],
|
|
1461
1490
|
"registryDependencies": [
|
|
1462
1491
|
"https://lacodda.github.io/dowel/r/input.json"
|
|
@@ -1478,15 +1507,17 @@
|
|
|
1478
1507
|
"dependencies": [
|
|
1479
1508
|
"@base-ui/react",
|
|
1480
1509
|
"class-variance-authority",
|
|
1481
|
-
"dowel-ui@^0.
|
|
1510
|
+
"dowel-ui@^0.32.0"
|
|
1511
|
+
],
|
|
1512
|
+
"registryDependencies": [
|
|
1513
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
1482
1514
|
],
|
|
1483
|
-
"registryDependencies": [],
|
|
1484
1515
|
"files": [
|
|
1485
1516
|
{
|
|
1486
1517
|
"path": "ui/popover.tsx",
|
|
1487
1518
|
"target": "@ui/popover.tsx",
|
|
1488
1519
|
"type": "registry:ui",
|
|
1489
|
-
"content": "import { Popover as Base } from '@base-ui/react/popover'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Popover.\n *\n * A panel anchored to the thing that opened it, for content that belongs\n * beside a control rather than in the middle of the screen: a filter, a small\n * form, a menu of settings that is not a menu.\n *\n * Where Dialog is centred and covers the page, this one is placed, and the\n * placing is the part that is easy to get wrong. It goes through a Positioner\n * between the Portal and the Popup - Base UI measures the trigger, measures\n * the popup, and flips or shifts it when the preferred side does not fit. So\n * `side` and `align` are a preference, not an instruction, and a popover near\n * the bottom of the window will come out above its trigger. That is the\n * behaviour worth having; a popover that stays where it was told is a popover\n * half off the screen.\n *\n * `sideOffset` is a distance from the anchor and belongs to the Positioner,\n * not the Popup, so it is taken here and passed inward. The Arrow is optional\n * and sits inside the Popup, where Base UI rotates it to whichever side the\n * popup actually landed on.\n *\n * It is not modal. The page underneath stays live, and focus is not trapped -\n * which is right for a panel beside a control and wrong for a decision.\n */\n\nexport const popoverPopupVariants = cva(\n [\n 'rounded-lg border border-line bg-raise p-4 text-text shadow-raise',\n 'focus-visible:outline-none',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.97] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0',\n // Grow out of the edge it is anchored to rather than out of its own\n // middle, so the motion points back at the trigger.\n 'origin-[var(--transform-origin)]',\n ],\n {\n variants: {\n size: {\n sm: 'w-[min(16rem,calc(100vw-2rem))]',\n md: 'w-[min(20rem,calc(100vw-2rem))]',\n lg: 'w-[min(28rem,calc(100vw-2rem))]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** The root. Controlled with `open` and `onOpenChange`, or left to manage\n * itself around a `PopoverTrigger`. */\nexport const Popover = Base.Root\n\n/** What opens it, and what the popup is measured against. */\nexport const PopoverTrigger = Base.Trigger\n\n/** What closes it, for a button inside the panel. */\nexport const PopoverClose = Base.Close\n\nexport interface PopoverPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof popoverPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit,\n * and defaults it to the bottom. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. Base UI centres it by default. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Whether to draw the arrow pointing back at the trigger. */\n arrow?: boolean\n /** Where to portal to. Defaults to the document body
|
|
1520
|
+
"content": "import { useRef } from 'react'\nimport { Popover as Base } from '@base-ui/react/popover'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { LayerProvider, usePopupContainer } from './layer'\n\n/*\n * Popover.\n *\n * A panel anchored to the thing that opened it, for content that belongs\n * beside a control rather than in the middle of the screen: a filter, a small\n * form, a menu of settings that is not a menu.\n *\n * Where Dialog is centred and covers the page, this one is placed, and the\n * placing is the part that is easy to get wrong. It goes through a Positioner\n * between the Portal and the Popup - Base UI measures the trigger, measures\n * the popup, and flips or shifts it when the preferred side does not fit. So\n * `side` and `align` are a preference, not an instruction, and a popover near\n * the bottom of the window will come out above its trigger. That is the\n * behaviour worth having; a popover that stays where it was told is a popover\n * half off the screen.\n *\n * `sideOffset` is a distance from the anchor and belongs to the Positioner,\n * not the Popup, so it is taken here and passed inward. The Arrow is optional\n * and sits inside the Popup, where Base UI rotates it to whichever side the\n * popup actually landed on.\n *\n * It is not modal. The page underneath stays live, and focus is not trapped -\n * which is right for a panel beside a control and wrong for a decision.\n */\n\nexport const popoverPopupVariants = cva(\n [\n 'rounded-lg border border-line bg-raise p-4 text-text shadow-raise',\n 'focus-visible:outline-none',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.97] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0',\n // Grow out of the edge it is anchored to rather than out of its own\n // middle, so the motion points back at the trigger.\n 'origin-[var(--transform-origin)]',\n ],\n {\n variants: {\n size: {\n sm: 'w-[min(16rem,calc(100vw-2rem))]',\n md: 'w-[min(20rem,calc(100vw-2rem))]',\n lg: 'w-[min(28rem,calc(100vw-2rem))]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** The root. Controlled with `open` and `onOpenChange`, or left to manage\n * itself around a `PopoverTrigger`. */\nexport const Popover = Base.Root\n\n/** What opens it, and what the popup is measured against. */\nexport const PopoverTrigger = Base.Trigger\n\n/** What closes it, for a button inside the panel. */\nexport const PopoverClose = Base.Close\n\nexport interface PopoverPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof popoverPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit,\n * and defaults it to the bottom. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. Base UI centres it by default. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Whether to draw the arrow pointing back at the trigger. */\n arrow?: boolean\n /** Where to portal to. Defaults to the raised host of the overlay this is\n * opened inside (`layer.tsx`), and to the document body when there is none -\n * either way not the element it was opened from, whose `overflow` would clip\n * it. Pass an element to put it somewhere else, such as a container being\n * screenshotted. */\n container?: Base.Portal.Props['container']\n}\n\n/** The panel. Portalled and positioned, so it is not clipped by an ancestor\n * with `overflow: hidden` - which is where most anchored popups go to die.\n *\n * `side` and `align` are passed straight through rather than defaulted here:\n * Base UI's own defaults are already bottom and centre, and writing them out\n * again would be one more place for the two to disagree. */\nexport function PopoverPopup({\n size,\n side,\n align,\n sideOffset = 8,\n arrow = true,\n container,\n className,\n children,\n ...props\n}: PopoverPopupProps) {\n // Inside an overlay, the overlay's raised host rather than the body - or\n // this popup draws under the dialog, drawer or popover that opened it. See\n // `layer.tsx`. Outside every overlay the hook gives `undefined`: the body.\n const host = usePopupContainer()\n\n const portal = useRef<HTMLDivElement>(null)\n\n return (\n <Base.Portal ref={portal} container={container ?? host}>\n <Base.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n className=\"[z-index:var(--z-floating)]\"\n >\n <Base.Popup className={cn(popoverPopupVariants({ size }), className)} {...props}>\n {arrow ? <PopoverArrow /> : null}\n {/* A popover is a layer of its own: a select or a date picker inside it\n * opens above it, not under it. */}\n <LayerProvider above=\"floating\" mount={portal}>{children}</LayerProvider>\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\n/** The notch pointing back at the trigger. Base UI rotates it to whatever side\n * the popup landed on, which is why the rotation is keyed off `data-side`\n * rather than off the `side` that was asked for. */\nexport function PopoverArrow({ className, ...props }: Base.Arrow.Props) {\n return (\n <Base.Arrow\n className={cn(\n 'h-2 w-2 rotate-45 border border-line bg-raise',\n 'data-[side=bottom]:-top-1 data-[side=bottom]:border-r-0 data-[side=bottom]:border-b-0',\n 'data-[side=top]:-bottom-1 data-[side=top]:border-t-0 data-[side=top]:border-l-0',\n 'data-[side=left]:-right-1 data-[side=left]:border-b-0 data-[side=left]:border-l-0',\n 'data-[side=right]:-left-1 data-[side=right]:border-r-0 data-[side=right]:border-t-0',\n className,\n )}\n {...props}\n />\n )\n}\n\n/** The heading. Base UI points the popup's `aria-labelledby` at it, so a\n * popover with one is named for a screen reader without anyone arranging it. */\nexport function PopoverTitle({ className, ...props }: Base.Title.Props) {\n return <Base.Title className={cn('text-sm font-semibold', className)} {...props} />\n}\n\n/** The line under the heading, and the popup's `aria-describedby`. */\nexport function PopoverDescription({ className, ...props }: Base.Description.Props) {\n return <Base.Description className={cn('mt-1 text-sm text-dim', className)} {...props} />\n}\n"
|
|
1490
1521
|
}
|
|
1491
1522
|
]
|
|
1492
1523
|
},
|
|
@@ -1498,15 +1529,17 @@
|
|
|
1498
1529
|
"dependencies": [
|
|
1499
1530
|
"@base-ui/react",
|
|
1500
1531
|
"class-variance-authority",
|
|
1501
|
-
"dowel-ui@^0.
|
|
1532
|
+
"dowel-ui@^0.32.0"
|
|
1533
|
+
],
|
|
1534
|
+
"registryDependencies": [
|
|
1535
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
1502
1536
|
],
|
|
1503
|
-
"registryDependencies": [],
|
|
1504
1537
|
"files": [
|
|
1505
1538
|
{
|
|
1506
1539
|
"path": "ui/preview-card.tsx",
|
|
1507
1540
|
"target": "@ui/preview-card.tsx",
|
|
1508
1541
|
"type": "registry:ui",
|
|
1509
|
-
"content": "import { PreviewCard as Base } from '@base-ui/react/preview-card'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * PreviewCard.\n *\n * The card that appears when a link is hovered: who the author is, what the\n * issue says, what is behind the URL. Rich content - an avatar, a few lines,\n * a figure or two - rather than the phrase a Tooltip holds.\n *\n * Positioned the same way a Popover is, through a Positioner between the\n * Portal and the Popup, so it flips and shifts to stay on screen. What differs\n * is how it opens: hovering the trigger, after a delay, and it stays open\n * while the pointer travels from the link to the card. That last part is the\n * whole trick - a card that vanishes when the pointer leaves the link cannot\n * be read, let alone clicked into.\n *\n * Same warning as Tooltip, and for the same reason. Base UI treats this as a\n * visual enhancement for sighted mouse and keyboard users: it is not reachable\n * on a touch screen and not announced by a screen reader. So NOTHING IN THE\n * CARD MAY BE THE ONLY PLACE IT APPEARS. Everything in it has to also be on\n * the page the link goes to - the card is a shortcut for people who can see\n * it, never the delivery mechanism for the information itself.\n *\n * If the content has to be reachable by everyone, this is the wrong component;\n * a Popover opened from a real button is the right one.\n */\n\nexport const previewCardPopupVariants = cva(\n [\n 'rounded-lg border border-line bg-raise p-4 text-sm text-text shadow-raise',\n 'focus-visible:outline-none',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-base)_var(--ease-out),transform_var(--duration-base)_var(--ease-out)]',\n 'data-[closed]:scale-[0.97] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0',\n // Grow out of the edge it is anchored to rather than out of its own\n // middle, so the motion points back at the link.\n 'origin-[var(--transform-origin)]',\n ],\n {\n variants: {\n size: {\n sm: 'w-[min(18rem,calc(100vw-2rem))]',\n md: 'w-[min(22rem,calc(100vw-2rem))]',\n lg: 'w-[min(28rem,calc(100vw-2rem))]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** The root. Controlled with `open` and `onOpenChange`, or left to manage\n * itself around a `PreviewCardTrigger`. */\nexport const PreviewCard = Base.Root\n\n/** The link the card previews. Usually rendered as the anchor itself, so it\n * stays a real link: it navigates, it opens in a new tab, and a screen reader\n * announces it as one - which is what the card cannot do. Takes `delay`. */\nexport const PreviewCardTrigger = Base.Trigger\n\nexport interface PreviewCardPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof previewCardPopupVariants> {\n /** Preferred side of the link. Base UI flips it when it does not fit, and\n * defaults it to the bottom. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. Base UI centres it by default. */\n align?: Base.Positioner.Props['align']\n /** Distance from the link, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Whether to draw the arrow pointing back at the link. */\n arrow?: boolean\n /** Where to portal to. Defaults to the document body
|
|
1542
|
+
"content": "import { PreviewCard as Base } from '@base-ui/react/preview-card'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { usePopupContainer } from './layer'\n\n/*\n * PreviewCard.\n *\n * The card that appears when a link is hovered: who the author is, what the\n * issue says, what is behind the URL. Rich content - an avatar, a few lines,\n * a figure or two - rather than the phrase a Tooltip holds.\n *\n * Positioned the same way a Popover is, through a Positioner between the\n * Portal and the Popup, so it flips and shifts to stay on screen. What differs\n * is how it opens: hovering the trigger, after a delay, and it stays open\n * while the pointer travels from the link to the card. That last part is the\n * whole trick - a card that vanishes when the pointer leaves the link cannot\n * be read, let alone clicked into.\n *\n * Same warning as Tooltip, and for the same reason. Base UI treats this as a\n * visual enhancement for sighted mouse and keyboard users: it is not reachable\n * on a touch screen and not announced by a screen reader. So NOTHING IN THE\n * CARD MAY BE THE ONLY PLACE IT APPEARS. Everything in it has to also be on\n * the page the link goes to - the card is a shortcut for people who can see\n * it, never the delivery mechanism for the information itself.\n *\n * If the content has to be reachable by everyone, this is the wrong component;\n * a Popover opened from a real button is the right one.\n */\n\nexport const previewCardPopupVariants = cva(\n [\n 'rounded-lg border border-line bg-raise p-4 text-sm text-text shadow-raise',\n 'focus-visible:outline-none',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-base)_var(--ease-out),transform_var(--duration-base)_var(--ease-out)]',\n 'data-[closed]:scale-[0.97] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.97] data-[starting-style]:opacity-0',\n // Grow out of the edge it is anchored to rather than out of its own\n // middle, so the motion points back at the link.\n 'origin-[var(--transform-origin)]',\n ],\n {\n variants: {\n size: {\n sm: 'w-[min(18rem,calc(100vw-2rem))]',\n md: 'w-[min(22rem,calc(100vw-2rem))]',\n lg: 'w-[min(28rem,calc(100vw-2rem))]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** The root. Controlled with `open` and `onOpenChange`, or left to manage\n * itself around a `PreviewCardTrigger`. */\nexport const PreviewCard = Base.Root\n\n/** The link the card previews. Usually rendered as the anchor itself, so it\n * stays a real link: it navigates, it opens in a new tab, and a screen reader\n * announces it as one - which is what the card cannot do. Takes `delay`. */\nexport const PreviewCardTrigger = Base.Trigger\n\nexport interface PreviewCardPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof previewCardPopupVariants> {\n /** Preferred side of the link. Base UI flips it when it does not fit, and\n * defaults it to the bottom. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. Base UI centres it by default. */\n align?: Base.Positioner.Props['align']\n /** Distance from the link, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Whether to draw the arrow pointing back at the link. */\n arrow?: boolean\n /** Where to portal to. Defaults to the raised host of the overlay this is\n * opened inside (`layer.tsx`), and to the document body when there is none -\n * either way not the element it was opened from, whose `overflow` would clip\n * it. Pass an element to put it somewhere else, such as a container being\n * screenshotted. */\n container?: Base.Portal.Props['container']\n}\n\n/** The card. Portalled and positioned, so it is not clipped by the paragraph\n * the link sits in. */\nexport function PreviewCardPopup({\n size,\n side,\n align,\n sideOffset = 8,\n arrow = true,\n container,\n className,\n children,\n ...props\n}: PreviewCardPopupProps) {\n // Inside an overlay, the overlay's raised host rather than the body - or\n // this popup draws under the dialog, drawer or popover that opened it. See\n // `layer.tsx`. Outside every overlay the hook gives `undefined`: the body.\n const host = usePopupContainer()\n\n return (\n <Base.Portal container={container ?? host}>\n <Base.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n className=\"[z-index:var(--z-floating)]\"\n >\n <Base.Popup className={cn(previewCardPopupVariants({ size }), className)} {...props}>\n {arrow ? <PreviewCardArrow /> : null}\n {children}\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\n/** The notch pointing back at the link. Base UI rotates it to whatever side\n * the card landed on, which is why the placement is keyed off `data-side`\n * rather than off the `side` that was asked for. */\nexport function PreviewCardArrow({ className, ...props }: Base.Arrow.Props) {\n return (\n <Base.Arrow\n className={cn(\n 'h-2 w-2 rotate-45 border border-line bg-raise',\n 'data-[side=bottom]:-top-1 data-[side=bottom]:border-r-0 data-[side=bottom]:border-b-0',\n 'data-[side=top]:-bottom-1 data-[side=top]:border-t-0 data-[side=top]:border-l-0',\n 'data-[side=left]:-right-1 data-[side=left]:border-b-0 data-[side=left]:border-l-0',\n 'data-[side=right]:-left-1 data-[side=right]:border-r-0 data-[side=right]:border-t-0',\n className,\n )}\n {...props}\n />\n )\n}\n"
|
|
1510
1543
|
}
|
|
1511
1544
|
]
|
|
1512
1545
|
},
|
|
@@ -1516,7 +1549,7 @@
|
|
|
1516
1549
|
"title": "ProductMark",
|
|
1517
1550
|
"description": "The product-mark primitive.",
|
|
1518
1551
|
"dependencies": [
|
|
1519
|
-
"dowel-ui@^0.
|
|
1552
|
+
"dowel-ui@^0.32.0"
|
|
1520
1553
|
],
|
|
1521
1554
|
"registryDependencies": [],
|
|
1522
1555
|
"files": [
|
|
@@ -1534,7 +1567,7 @@
|
|
|
1534
1567
|
"title": "ProductSwitcher",
|
|
1535
1568
|
"description": "The line's products are meant to be used together: kasl-server reads what kasl records, rigger plans what furca commits, a note in scheda cites a track in lyrid. A person moving between them was typing addresses from memory. This is the one place that knows where the others are - the current product's small tile and name on the trigger, and the others in a menu, each with its own tile, so the colour a person already knows the product by is what they look for.",
|
|
1536
1569
|
"dependencies": [
|
|
1537
|
-
"dowel-ui@^0.
|
|
1570
|
+
"dowel-ui@^0.32.0"
|
|
1538
1571
|
],
|
|
1539
1572
|
"registryDependencies": [
|
|
1540
1573
|
"https://lacodda.github.io/dowel/r/menu.json",
|
|
@@ -1557,7 +1590,7 @@
|
|
|
1557
1590
|
"dependencies": [
|
|
1558
1591
|
"@base-ui/react",
|
|
1559
1592
|
"class-variance-authority",
|
|
1560
|
-
"dowel-ui@^0.
|
|
1593
|
+
"dowel-ui@^0.32.0"
|
|
1561
1594
|
],
|
|
1562
1595
|
"registryDependencies": [],
|
|
1563
1596
|
"files": [
|
|
@@ -1596,7 +1629,7 @@
|
|
|
1596
1629
|
"dependencies": [
|
|
1597
1630
|
"@base-ui/react",
|
|
1598
1631
|
"class-variance-authority",
|
|
1599
|
-
"dowel-ui@^0.
|
|
1632
|
+
"dowel-ui@^0.32.0"
|
|
1600
1633
|
],
|
|
1601
1634
|
"registryDependencies": [],
|
|
1602
1635
|
"files": [
|
|
@@ -1614,7 +1647,7 @@
|
|
|
1614
1647
|
"title": "RatingScale",
|
|
1615
1648
|
"description": "Generalised from kilna, where it is how a work is scored on each of its axes. The shape is a row of marks rather than stars: stars carry a meaning of their own - a review, a public verdict - and this is as often \"how hard was this\" or \"how finished is it\" as it is \"how good\".",
|
|
1616
1649
|
"dependencies": [
|
|
1617
|
-
"dowel-ui@^0.
|
|
1650
|
+
"dowel-ui@^0.32.0"
|
|
1618
1651
|
],
|
|
1619
1652
|
"registryDependencies": [],
|
|
1620
1653
|
"files": [
|
|
@@ -1632,7 +1665,7 @@
|
|
|
1632
1665
|
"title": "RelativeTime",
|
|
1633
1666
|
"description": "The relative-time primitive.",
|
|
1634
1667
|
"dependencies": [
|
|
1635
|
-
"dowel-ui@^0.
|
|
1668
|
+
"dowel-ui@^0.32.0"
|
|
1636
1669
|
],
|
|
1637
1670
|
"registryDependencies": [],
|
|
1638
1671
|
"files": [
|
|
@@ -1650,7 +1683,7 @@
|
|
|
1650
1683
|
"title": "ReorderableList",
|
|
1651
1684
|
"description": "The columns in a column picker, the stops of a dial, the roles of a profile. A hook and a grip rather than a list component: the rows are already something else's - a menu's items, a form's fields - and a component wrapping them would have to reproduce whatever that something else does.",
|
|
1652
1685
|
"dependencies": [
|
|
1653
|
-
"dowel-ui@^0.
|
|
1686
|
+
"dowel-ui@^0.32.0"
|
|
1654
1687
|
],
|
|
1655
1688
|
"registryDependencies": [],
|
|
1656
1689
|
"files": [
|
|
@@ -1658,7 +1691,7 @@
|
|
|
1658
1691
|
"path": "ui/reorderable-list.tsx",
|
|
1659
1692
|
"target": "@ui/reorderable-list.tsx",
|
|
1660
1693
|
"type": "registry:ui",
|
|
1661
|
-
"content": "import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { cn } from 'dowel-ui'\n\n/*\n * Drag a row of a vertical list up or down to put it somewhere else.\n *\n * The columns in a column picker, the stops of a dial, the roles of a\n * profile. A hook and a grip rather than a list component: the rows are\n * already something else's - a menu's items, a form's fields - and a\n * component wrapping them would have to reproduce whatever that something\n * else does.\n *\n * Pointer events, not HTML5 drag-and-drop, for the reason given at\n * ColumnResizeHandle: a desktop shell that takes file drops never lets a\n * `dragstart` reach the page. The grip takes pointer capture on pointerdown,\n * so the rows underneath never see the drag and a menu's own highlighting\n * does not flicker down the list as the pointer crosses it.\n *\n * Nothing moves until the pointer is let go. Live reordering looks better\n * for a second and costs a write per crossed row - to a profile, that is a\n * request per row - and the row being dragged has already been picked up,\n * so the reader is watching the line that says where it lands. The hook\n * reports that line as `slot`, and the caller draws it.\n *\n * The keyboard's way is Alt with an arrow on the focused row. Plain arrows\n * are how a list is walked, and taking them for moving would leave no way\n * to walk it; the modifier is the one screen readers and editors already\n * use for \"move this line\".\n */\n\nexport interface ReorderOptions<K extends string> {\n /** The ids in their current order. Every row carries its id in\n * `data-reorder-id`, which `rowProps` sets. */\n order: readonly K[]\n /** Put `id` at index `to` of the resulting list. Called once per drop or\n * per keypress, never during a drag. */\n onMove: (id: K, to: number) => void\n disabled?: boolean\n}\n\nexport interface Reorder<K extends string> {\n /** Spread on the element holding the rows: the rows are found under it.\n * A callback ref rather than a ref object, so that nothing ref-shaped is\n * handed back and the compiler does not take the whole result for one. */\n listProps: { ref: (element: HTMLElement | null) => void }\n /** The row being dragged, or null. */\n dragging: K | null\n /** Where a drop would go, as an insertion point: between the rows at\n * `slot - 1` and `slot`, in the order as it is. Null while nothing is\n * dragged, or while the drop would change nothing. */\n slot: number | null\n /** The insertion point's distance from the top of the list element, in\n * pixels, for drawing the line. */\n slotOffset: number | null\n /** Spread on the grip: the pointer path. */\n gripProps: (id: K) => (HTMLAttributes<HTMLElement>)\n /** Spread on the row: the id and the keyboard path. The `ref` is a\n * callback that returns its cleanup, as React 19 allows; a host that merges\n * refs and drops the cleanup leaves a listener on a node that is gone,\n * which is harmless. */\n rowProps: (id: K) => {\n 'data-reorder-id': K\n ref: (row: HTMLElement | null) => void | (() => void)\n }\n}\n\nexport function useReorder<K extends string>({ order, onMove, disabled }: ReorderOptions<K>): Reorder<K> {\n const listRef = useRef<HTMLElement | null>(null)\n const [dragging, setDragging] = useState<K | null>(null)\n // The slot and where to draw it, settled together in the move handler: the\n // boxes it is read from are refs, and refs are not for reading in render.\n const [drop, setDrop] = useState<{ slot: number; offset: number } | null>(null)\n // The rows' boxes as they were when the drag began; nothing moves during\n // it, so reading them once is reading them right.\n const boxes = useRef<{ top: number; bottom: number }[]>([])\n const listTop = useRef(0)\n\n // The slot under a pointer: how many rows have their middle above it.\n const slotAt = (y: number): number => {\n let count = 0\n for (const box of boxes.current) if ((box.top + box.bottom) / 2 < y) count += 1\n return count\n }\n\n // A slot is an insertion point in the list as drawn; the move wants the\n // index in the list as it will be, with the row gone from where it was.\n const destination = (from: number, at: number): number => (at > from ? at - 1 : at)\n\n const begin = (id: K, event: ReactPointerEvent<HTMLElement>) => {\n if (disabled || event.button !== 0) return\n const list = listRef.current\n if (list === null) return\n event.preventDefault()\n event.stopPropagation()\n\n listTop.current = list.getBoundingClientRect().top\n // By attribute rather than by selector, so an id needs no escaping.\n const rows = [...list.querySelectorAll<HTMLElement>('[data-reorder-id]')]\n boxes.current = order.map((rowId) => {\n const box = rows.find((row) => row.getAttribute('data-reorder-id') === rowId)?.getBoundingClientRect()\n return box ? { top: box.top, bottom: box.bottom } : { top: 0, bottom: 0 }\n })\n event.currentTarget.setPointerCapture(event.pointerId)\n setDragging(id)\n setDrop(null)\n }\n\n // The insertion point's distance from the top of the list: the top of the\n // row it goes before, or the bottom of the last row.\n const offsetOf = (at: number): number => {\n const rows = boxes.current\n const edge = at < rows.length ? rows[at]?.top : rows[rows.length - 1]?.bottom\n return (edge ?? 0) - listTop.current\n }\n\n const move = (id: K, event: ReactPointerEvent<HTMLElement>) => {\n if (dragging !== id) return\n const from = order.indexOf(id)\n const at = slotAt(event.clientY)\n // Dropping a row back where it is - the slot just above or just below\n // itself - is no move, and drawing a line there would promise one.\n setDrop(destination(from, at) === from ? null : { slot: at, offset: offsetOf(at) })\n }\n\n const end = (id: K, event: ReactPointerEvent<HTMLElement>) => {\n if (dragging !== id) return\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId)\n }\n const from = order.indexOf(id)\n const at = slotAt(event.clientY)\n const to = destination(from, at)\n setDragging(null)\n setDrop(null)\n if (event.type !== 'pointercancel' && to !== from) onMove(id, to)\n }\n\n // Rebuilt every render on purpose: they close over the drag state and the\n // order, and memoising them would mean listing both and getting one wrong.\n const gripProps = (id: K): HTMLAttributes<HTMLElement> => ({\n onPointerDown: (event) => begin(id, event),\n onPointerMove: (event) => move(id, event),\n onPointerUp: (event) => end(id, event),\n onPointerCancel: (event) => end(id, event),\n // The click the drop leaves behind must not reach the row: in a menu it\n // would toggle the item that was only meant to be moved.\n onClick: (event) => event.stopPropagation(),\n })\n\n // The keyboard path is a native listener on the row, not a React one. A\n // menu popup handles the arrow keys itself and stops them on the way up,\n // so a React `onKeyDown` on the item - dispatched from the root, above the\n // popup - never hears them; a listener on the row itself fires at the\n // target first, whatever the ancestors do afterwards. The listener reads\n // the row's id and the latest order off refs rather than closing over\n // them, so one stable callback serves every row and nothing is re-bound\n // on each render.\n const latest = useRef({ order, onMove, disabled })\n useEffect(() => {\n latest.current = { order, onMove, disabled }\n })\n\n const listen = useCallback((row: HTMLElement | null) => {\n if (row === null) return\n const onKeyDown = (event: KeyboardEvent) => {\n const { order: current, onMove: put, disabled: off } = latest.current\n if (off || !event.altKey) return\n const step = event.key === 'ArrowUp' ? -1 : event.key === 'ArrowDown' ? 1 : 0\n if (step === 0) return\n const id = row.getAttribute('data-reorder-id') as K | null\n if (id === null) return\n const to = current.indexOf(id) + step\n if (to < 0 || to >= current.length) return\n // Stopped here so the list's own arrow handling does not also walk the\n // focus off the row that was just moved.\n event.preventDefault()\n event.stopPropagation()\n put(id, to)\n }\n row.addEventListener('keydown', onKeyDown)\n return () => row.removeEventListener('keydown', onKeyDown)\n }, [])\n\n const rowProps = (id: K) => ({\n 'data-reorder-id': id,\n ref: listen,\n })\n\n return {\n listProps: {\n ref: (element) => {\n listRef.current = element\n },\n },\n dragging,\n slot: drop?.slot ?? null,\n slotOffset: drop?.offset ?? null,\n gripProps,\n rowProps,\n }\n}\n\n/** The handle a row is picked up by. Decorative to a screen reader - the\n * keyboard path is on the row itself - so it carries no role and no label. */\nexport function ReorderGrip({ className, ...props }: HTMLAttributes<HTMLElement>) {\n return (\n <span\n aria-hidden\n data-reorder-grip\n className={cn(\n 'inline-flex shrink-0 cursor-grab touch-none select-none text-faint',\n 'active:cursor-grabbing [&_svg]:size-3.5',\n className,\n )}\n {...props}\n >\n <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden>\n <circle cx=\"6\" cy=\"3.5\" r=\"1.2\" />\n <circle cx=\"10\" cy=\"3.5\" r=\"1.2\" />\n <circle cx=\"6\" cy=\"8\" r=\"1.2\" />\n <circle cx=\"10\" cy=\"8\" r=\"1.2\" />\n <circle cx=\"6\" cy=\"12.5\" r=\"1.2\" />\n <circle cx=\"10\" cy=\"12.5\" r=\"1.2\" />\n </svg>\n </span>\n )\n}\n\n/** The line where a dragged row would land. Positioned by the caller from\n * `slotOffset`, inside the element `listProps` is on - which has to be\n * positioned itself. */\nexport function ReorderIndicator({ offset, className }: { offset: number | null; className?: string }) {\n if (offset === null) return null\n return (\n <div\n aria-hidden\n data-reorder-indicator\n className={cn('pointer-events-none absolute inset-x-1 h-0.5 -translate-y-px rounded-full bg-accent', className)}\n style={{ top: offset }}\n />\n )\n}\n"
|
|
1694
|
+
"content": "import {\n useCallback,\n useEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { cn } from 'dowel-ui'\n\n/*\n * Drag a row of a vertical list up or down to put it somewhere else.\n *\n * The columns in a column picker, the stops of a dial, the roles of a\n * profile. A hook and a grip rather than a list component: the rows are\n * already something else's - a menu's items, a form's fields - and a\n * component wrapping them would have to reproduce whatever that something\n * else does.\n *\n * Pointer events, not HTML5 drag-and-drop, for the reason given at\n * ColumnResizeHandle: a desktop shell that takes file drops never lets a\n * `dragstart` reach the page. The grip takes pointer capture on pointerdown,\n * so the rows underneath never see the drag and a menu's own highlighting\n * does not flicker down the list as the pointer crosses it.\n *\n * Nothing moves until the pointer is let go. Live reordering looks better\n * for a second and costs a write per crossed row - to a profile, that is a\n * request per row - and the row being dragged has already been picked up,\n * so the reader is watching the line that says where it lands. The hook\n * reports that line as `slot`, and the caller draws it.\n *\n * The keyboard's way is Alt with an arrow on the focused row. Plain arrows\n * are how a list is walked, and taking them for moving would leave no way\n * to walk it; the modifier is the one screen readers and editors already\n * use for \"move this line\".\n */\n\nexport interface ReorderOptions<K extends string> {\n /** The ids in their current order. Every row carries its id in\n * `data-reorder-id`, which `rowProps` sets. */\n order: readonly K[]\n /** Put `id` at index `to` of the resulting list. Called once per drop or\n * per keypress, never during a drag. */\n onMove: (id: K, to: number) => void\n disabled?: boolean\n}\n\nexport interface Reorder<K extends string> {\n /** Spread on the element holding the rows: the rows are found under it.\n * A callback ref rather than a ref object, so that nothing ref-shaped is\n * handed back and the compiler does not take the whole result for one. */\n listProps: { ref: (element: HTMLElement | null) => void }\n /** The row being dragged, or null. */\n dragging: K | null\n /** Where a drop would go, as an insertion point: between the rows at\n * `slot - 1` and `slot`, in the order as it is. Null while nothing is\n * dragged, or while the drop would change nothing. */\n slot: number | null\n /** The insertion point's distance from the top of the list element, in\n * pixels, for drawing the line. */\n slotOffset: number | null\n /** Spread on the grip: the pointer path. */\n gripProps: (id: K) => (HTMLAttributes<HTMLElement>)\n /** Spread on the row: the id and the keyboard path. The `ref` is a\n * callback that returns its cleanup, as React 19 allows; a host that merges\n * refs and drops the cleanup leaves a listener on a node that is gone,\n * which is harmless. */\n rowProps: (id: K) => {\n 'data-reorder-id': K\n ref: (row: HTMLElement | null) => void | (() => void)\n }\n}\n\nexport function useReorder<K extends string>({ order, onMove, disabled }: ReorderOptions<K>): Reorder<K> {\n const listRef = useRef<HTMLElement | null>(null)\n const [dragging, setDragging] = useState<K | null>(null)\n // The slot and where to draw it, settled together in the move handler: the\n // boxes it is read from are refs, and refs are not for reading in render.\n const [drop, setDrop] = useState<{ slot: number; offset: number } | null>(null)\n // The rows' boxes as they were when the drag began; nothing moves during\n // it, so reading them once is reading them right.\n const boxes = useRef<{ top: number; bottom: number }[]>([])\n const listTop = useRef(0)\n\n // The slot under a pointer: how many rows have their middle above it.\n const slotAt = (y: number): number => {\n let count = 0\n for (const box of boxes.current) if ((box.top + box.bottom) / 2 < y) count += 1\n return count\n }\n\n // A slot is an insertion point in the list as drawn; the move wants the\n // index in the list as it will be, with the row gone from where it was.\n const destination = (from: number, at: number): number => (at > from ? at - 1 : at)\n\n const begin = (id: K, event: ReactPointerEvent<HTMLElement>) => {\n if (disabled || event.button !== 0) return\n const list = listRef.current\n if (list === null) return\n event.preventDefault()\n event.stopPropagation()\n\n listTop.current = list.getBoundingClientRect().top\n // By attribute rather than by selector, so an id needs no escaping.\n const rows = [...list.querySelectorAll<HTMLElement>('[data-reorder-id]')]\n boxes.current = order.map((rowId) => {\n const box = rows.find((row) => row.getAttribute('data-reorder-id') === rowId)?.getBoundingClientRect()\n return box ? { top: box.top, bottom: box.bottom } : { top: 0, bottom: 0 }\n })\n event.currentTarget.setPointerCapture(event.pointerId)\n setDragging(id)\n setDrop(null)\n }\n\n // The insertion point's distance from the top of the list: the top of the\n // row it goes before, or the bottom of the last row.\n const offsetOf = (at: number): number => {\n const rows = boxes.current\n const edge = at < rows.length ? rows[at]?.top : rows[rows.length - 1]?.bottom\n return (edge ?? 0) - listTop.current\n }\n\n const move = (id: K, event: ReactPointerEvent<HTMLElement>) => {\n if (dragging !== id) return\n const from = order.indexOf(id)\n const at = slotAt(event.clientY)\n // Dropping a row back where it is - the slot just above or just below\n // itself - is no move, and drawing a line there would promise one.\n setDrop(destination(from, at) === from ? null : { slot: at, offset: offsetOf(at) })\n }\n\n const end = (id: K, event: ReactPointerEvent<HTMLElement>) => {\n if (dragging !== id) return\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId)\n }\n const from = order.indexOf(id)\n const at = slotAt(event.clientY)\n const to = destination(from, at)\n setDragging(null)\n setDrop(null)\n if (event.type !== 'pointercancel' && to !== from) onMove(id, to)\n }\n\n // Rebuilt every render on purpose: they close over the drag state and the\n // order, and memoising them would mean listing both and getting one wrong.\n const gripProps = (id: K): HTMLAttributes<HTMLElement> => ({\n onPointerDown: (event) => begin(id, event),\n onPointerMove: (event) => move(id, event),\n onPointerUp: (event) => end(id, event),\n onPointerCancel: (event) => end(id, event),\n // The click the drop leaves behind must not reach the row: in a menu it\n // would toggle the item that was only meant to be moved.\n onClick: (event) => event.stopPropagation(),\n })\n\n // The keyboard path is a native listener on the row, not a React one. A\n // menu popup handles the arrow keys itself and stops them on the way up,\n // so a React `onKeyDown` on the item - dispatched from the root, above the\n // popup - never hears them; a listener on the row itself fires at the\n // target first, whatever the ancestors do afterwards. The listener reads\n // the row's id and the latest order off refs rather than closing over\n // them, so one stable callback serves every row and nothing is re-bound\n // on each render.\n const latest = useRef({ order, onMove, disabled })\n useEffect(() => {\n latest.current = { order, onMove, disabled }\n })\n\n const listen = useCallback((row: HTMLElement | null) => {\n if (row === null) return\n const onKeyDown = (event: KeyboardEvent) => {\n const { order: current, onMove: put, disabled: off } = latest.current\n if (off || !event.altKey) return\n const step = event.key === 'ArrowUp' ? -1 : event.key === 'ArrowDown' ? 1 : 0\n if (step === 0) return\n const id = row.getAttribute('data-reorder-id') as K | null\n if (id === null) return\n const to = current.indexOf(id) + step\n if (to < 0 || to >= current.length) return\n // Stopped here so the list's own arrow handling does not also walk the\n // focus off the row that was just moved.\n event.preventDefault()\n event.stopPropagation()\n put(id, to)\n }\n row.addEventListener('keydown', onKeyDown)\n return () => row.removeEventListener('keydown', onKeyDown)\n }, [])\n\n const rowProps = (id: K) => ({\n 'data-reorder-id': id,\n ref: listen,\n })\n\n return {\n listProps: {\n ref: (element) => {\n listRef.current = element\n },\n },\n dragging,\n slot: drop?.slot ?? null,\n slotOffset: drop?.offset ?? null,\n gripProps,\n rowProps,\n }\n}\n\n/** The handle a row is picked up by. Decorative to a screen reader - the\n * keyboard path is on the row itself - so it carries no role and no label. */\nexport function ReorderGrip({ className, ...props }: HTMLAttributes<HTMLElement>) {\n return (\n <span\n aria-hidden\n data-reorder-grip\n className={cn(\n 'inline-flex shrink-0 cursor-grab touch-none select-none text-faint',\n 'active:cursor-grabbing [&_svg:not([class*=size-])]:size-3.5',\n className,\n )}\n {...props}\n >\n <svg viewBox=\"0 0 16 16\" fill=\"currentColor\" aria-hidden>\n <circle cx=\"6\" cy=\"3.5\" r=\"1.2\" />\n <circle cx=\"10\" cy=\"3.5\" r=\"1.2\" />\n <circle cx=\"6\" cy=\"8\" r=\"1.2\" />\n <circle cx=\"10\" cy=\"8\" r=\"1.2\" />\n <circle cx=\"6\" cy=\"12.5\" r=\"1.2\" />\n <circle cx=\"10\" cy=\"12.5\" r=\"1.2\" />\n </svg>\n </span>\n )\n}\n\n/** The line where a dragged row would land. Positioned by the caller from\n * `slotOffset`, inside the element `listProps` is on - which has to be\n * positioned itself. */\nexport function ReorderIndicator({ offset, className }: { offset: number | null; className?: string }) {\n if (offset === null) return null\n return (\n <div\n aria-hidden\n data-reorder-indicator\n className={cn('pointer-events-none absolute inset-x-1 h-0.5 -translate-y-px rounded-full bg-accent', className)}\n style={{ top: offset }}\n />\n )\n}\n"
|
|
1662
1695
|
}
|
|
1663
1696
|
]
|
|
1664
1697
|
},
|
|
@@ -1668,7 +1701,7 @@
|
|
|
1668
1701
|
"title": "SaveState",
|
|
1669
1702
|
"description": "The quiet line beside a field that saves itself: \"saving…\", then a tick that fades. It exists because a form without a Save button has to say what it did anyway - otherwise the reader is left guessing whether their edit survived, and the usual answer to that guess is to press Ctrl+S at a page that has no such thing.",
|
|
1670
1703
|
"dependencies": [
|
|
1671
|
-
"dowel-ui@^0.
|
|
1704
|
+
"dowel-ui@^0.32.0"
|
|
1672
1705
|
],
|
|
1673
1706
|
"registryDependencies": [
|
|
1674
1707
|
"https://lacodda.github.io/dowel/r/spinner.json"
|
|
@@ -1690,7 +1723,7 @@
|
|
|
1690
1723
|
"dependencies": [
|
|
1691
1724
|
"@base-ui/react",
|
|
1692
1725
|
"class-variance-authority",
|
|
1693
|
-
"dowel-ui@^0.
|
|
1726
|
+
"dowel-ui@^0.32.0"
|
|
1694
1727
|
],
|
|
1695
1728
|
"registryDependencies": [],
|
|
1696
1729
|
"files": [
|
|
@@ -1708,7 +1741,7 @@
|
|
|
1708
1741
|
"title": "SearchField",
|
|
1709
1742
|
"description": "An Input that knows it is a search box, which is three small things the products kept not doing:\n * - a magnifier, so the field is recognisable before it is read; - a way to clear it that is not \"select all and delete\" - and one that a keyboard can reach, which a decorative `<span>` cannot; - the shortcut that focuses it, shown in the field rather than learned.",
|
|
1710
1743
|
"dependencies": [
|
|
1711
|
-
"dowel-ui@^0.
|
|
1744
|
+
"dowel-ui@^0.32.0"
|
|
1712
1745
|
],
|
|
1713
1746
|
"registryDependencies": [
|
|
1714
1747
|
"https://lacodda.github.io/dowel/r/input.json",
|
|
@@ -1731,7 +1764,7 @@
|
|
|
1731
1764
|
"description": "A settings screen is the usual case: five or six sections, each its own address so it can be linked to and the back button walks between them, listed down the left with the current one tinted. Every product draws the same column, and every product draws the active row a little differently - which is exactly the drift a shared list exists to stop.",
|
|
1732
1765
|
"dependencies": [
|
|
1733
1766
|
"@base-ui/react",
|
|
1734
|
-
"dowel-ui@^0.
|
|
1767
|
+
"dowel-ui@^0.32.0"
|
|
1735
1768
|
],
|
|
1736
1769
|
"registryDependencies": [],
|
|
1737
1770
|
"files": [
|
|
@@ -1739,7 +1772,7 @@
|
|
|
1739
1772
|
"path": "ui/section-nav.tsx",
|
|
1740
1773
|
"target": "@ui/section-nav.tsx",
|
|
1741
1774
|
"type": "registry:ui",
|
|
1742
|
-
"content": "import { useId, type HTMLAttributes, type ReactNode } from 'react'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cn } from 'dowel-ui'\n\n/*\n * The left-hand list of a screen with sections, and the heading each opens.\n *\n * A settings screen is the usual case: five or six sections, each its own\n * address so it can be linked to and the back button walks between them,\n * listed down the left with the current one tinted. Every product draws the\n * same column, and every product draws the active row a little differently -\n * which is exactly the drift a shared list exists to stop.\n *\n * The rows are the product's links, not the component's. `render` takes the\n * item and answers with the element to draw it as - a router's `NavLink`, an\n * `<a>`, whatever the product navigates with - and the component puts the\n * row's clothes, its icon and its `aria-current` on it. Without `render` a\n * row is a button and `onSelect` says which one was pressed, for a screen\n * whose sections are state rather than routes.\n *\n * `SectionHeading` is the other half: the title and the one-line hint above\n * a section's body, so the column and the page it opens are set in the same\n * type.\n */\n\nexport interface SectionNavItem {\n id: string\n label: ReactNode\n icon?: ReactNode\n}\n\nexport interface SectionNavProps extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'onSelect'> {\n /** What the list is called: the caption above it, and the name a screen\n * reader gives the landmark. */\n label: string\n items: readonly SectionNavItem[]\n /** Which item is the current page. */\n activeId?: string\n /** The element a row is drawn as - `render={(item) => <NavLink to={…} />}`.\n * The row's props are merged onto it, the way Button takes a `render`. */\n render?: (item: SectionNavItem) => useRender.RenderProp\n /** Pressed, whatever the row is drawn as. */\n onSelect?: (id: string) => void\n}\n\nexport function SectionNav({ label, items, activeId, render, onSelect, className, ...props }: SectionNavProps) {\n const captionId = useId()\n return (\n <nav aria-labelledby={captionId} className={cn('flex flex-col gap-0.5', className)} {...props}>\n <h2 id={captionId} className=\"px-2.5 pb-2 text-2xs font-medium uppercase tracking-caption text-faint\">\n {label}\n </h2>\n {items.map((item) => (\n <SectionNavRow\n key={item.id}\n item={item}\n active={item.id === activeId}\n render={render?.(item)}\n onSelect={onSelect}\n />\n ))}\n </nav>\n )\n}\n\nfunction SectionNavRow({\n item,\n active,\n render,\n onSelect,\n}: {\n item: SectionNavItem\n active: boolean\n render?: useRender.RenderProp\n onSelect?: (id: string) => void\n}) {\n return useRender({\n render,\n defaultTagName: 'button',\n props: {\n ...(render === undefined ? { type: 'button' } : {}),\n // Named as the current page for a screen reader, which cannot see that\n // it is the tinted one.\n 'aria-current': active ? 'page' : undefined,\n onClick: () => onSelect?.(item.id),\n className: cn(\n 'flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm text-dim no-underline transition-colors',\n 'hover:bg-soft hover:text-text [&_svg]:size-4 [&_svg]:shrink-0',\n 'focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent',\n active && 'bg-accent-soft text-text [&_svg]:text-accent',\n ),\n children: (\n <>\n {item.icon ? <span aria-hidden className=\"contents\">{item.icon}</span> : null}\n {/* One line, truncated, like a NavRail entry. A section column is a\n fixed width, and a label that wraps makes one row taller than\n every other - which in a two-language product happens to one\n section and not the rest, so the column reads as ragged and the\n line height stops meaning anything. `min-w-0` because a flex\n child will not shrink below its content without it. */}\n <span className=\"min-w-0 flex-1 truncate\">{item.label}</span>\n </>\n ),\n },\n })\n}\n\nexport interface SectionHeadingProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n title: ReactNode\n description?: ReactNode\n}\n\n/** The title of the open section and the line under it. */\nexport function SectionHeading({ title, description, className, ...props }: SectionHeadingProps) {\n return (\n <div className={cn('mb-4 flex flex-col gap-1', className)} {...props}>\n <h2 className=\"text-base font-semibold text-text\">{title}</h2>\n {description ? <p className=\"text-sm text-dim\">{description}</p> : null}\n </div>\n )\n}\n"
|
|
1775
|
+
"content": "import { useId, type HTMLAttributes, type ReactNode } from 'react'\nimport { useRender } from '@base-ui/react/use-render'\nimport { cn } from 'dowel-ui'\n\n/*\n * The left-hand list of a screen with sections, and the heading each opens.\n *\n * A settings screen is the usual case: five or six sections, each its own\n * address so it can be linked to and the back button walks between them,\n * listed down the left with the current one tinted. Every product draws the\n * same column, and every product draws the active row a little differently -\n * which is exactly the drift a shared list exists to stop.\n *\n * The rows are the product's links, not the component's. `render` takes the\n * item and answers with the element to draw it as - a router's `NavLink`, an\n * `<a>`, whatever the product navigates with - and the component puts the\n * row's clothes, its icon and its `aria-current` on it. Without `render` a\n * row is a button and `onSelect` says which one was pressed, for a screen\n * whose sections are state rather than routes.\n *\n * `SectionHeading` is the other half: the title and the one-line hint above\n * a section's body, so the column and the page it opens are set in the same\n * type.\n */\n\nexport interface SectionNavItem {\n id: string\n label: ReactNode\n icon?: ReactNode\n}\n\nexport interface SectionNavProps extends Omit<HTMLAttributes<HTMLElement>, 'children' | 'onSelect'> {\n /** What the list is called: the caption above it, and the name a screen\n * reader gives the landmark. */\n label: string\n items: readonly SectionNavItem[]\n /** Which item is the current page. */\n activeId?: string\n /** The element a row is drawn as - `render={(item) => <NavLink to={…} />}`.\n * The row's props are merged onto it, the way Button takes a `render`. */\n render?: (item: SectionNavItem) => useRender.RenderProp\n /** Pressed, whatever the row is drawn as. */\n onSelect?: (id: string) => void\n}\n\nexport function SectionNav({ label, items, activeId, render, onSelect, className, ...props }: SectionNavProps) {\n const captionId = useId()\n return (\n <nav aria-labelledby={captionId} className={cn('flex flex-col gap-0.5', className)} {...props}>\n <h2 id={captionId} className=\"px-2.5 pb-2 text-2xs font-medium uppercase tracking-caption text-faint\">\n {label}\n </h2>\n {items.map((item) => (\n <SectionNavRow\n key={item.id}\n item={item}\n active={item.id === activeId}\n render={render?.(item)}\n onSelect={onSelect}\n />\n ))}\n </nav>\n )\n}\n\nfunction SectionNavRow({\n item,\n active,\n render,\n onSelect,\n}: {\n item: SectionNavItem\n active: boolean\n render?: useRender.RenderProp\n onSelect?: (id: string) => void\n}) {\n return useRender({\n render,\n defaultTagName: 'button',\n props: {\n ...(render === undefined ? { type: 'button' } : {}),\n // Named as the current page for a screen reader, which cannot see that\n // it is the tinted one.\n 'aria-current': active ? 'page' : undefined,\n onClick: () => onSelect?.(item.id),\n className: cn(\n 'flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-sm text-dim no-underline transition-colors',\n 'hover:bg-soft hover:text-text [&_svg:not([class*=size-])]:size-4 [&_svg]:shrink-0',\n 'focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-accent',\n active && 'bg-accent-soft text-text [&_svg]:text-accent',\n ),\n children: (\n <>\n {item.icon ? <span aria-hidden className=\"contents\">{item.icon}</span> : null}\n {/* One line, truncated, like a NavRail entry. A section column is a\n fixed width, and a label that wraps makes one row taller than\n every other - which in a two-language product happens to one\n section and not the rest, so the column reads as ragged and the\n line height stops meaning anything. `min-w-0` because a flex\n child will not shrink below its content without it. */}\n <span className=\"min-w-0 flex-1 truncate\">{item.label}</span>\n </>\n ),\n },\n })\n}\n\nexport interface SectionHeadingProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n title: ReactNode\n description?: ReactNode\n}\n\n/** The title of the open section and the line under it. */\nexport function SectionHeading({ title, description, className, ...props }: SectionHeadingProps) {\n return (\n <div className={cn('mb-4 flex flex-col gap-1', className)} {...props}>\n <h2 className=\"text-base font-semibold text-text\">{title}</h2>\n {description ? <p className=\"text-sm text-dim\">{description}</p> : null}\n </div>\n )\n}\n"
|
|
1743
1776
|
}
|
|
1744
1777
|
]
|
|
1745
1778
|
},
|
|
@@ -1751,17 +1784,18 @@
|
|
|
1751
1784
|
"dependencies": [
|
|
1752
1785
|
"@base-ui/react",
|
|
1753
1786
|
"class-variance-authority",
|
|
1754
|
-
"dowel-ui@^0.
|
|
1787
|
+
"dowel-ui@^0.32.0"
|
|
1755
1788
|
],
|
|
1756
1789
|
"registryDependencies": [
|
|
1757
|
-
"https://lacodda.github.io/dowel/r/input.json"
|
|
1790
|
+
"https://lacodda.github.io/dowel/r/input.json",
|
|
1791
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
1758
1792
|
],
|
|
1759
1793
|
"files": [
|
|
1760
1794
|
{
|
|
1761
1795
|
"path": "ui/select.tsx",
|
|
1762
1796
|
"target": "@ui/select.tsx",
|
|
1763
1797
|
"type": "registry:ui",
|
|
1764
|
-
"content": "import { Select as Base } from '@base-ui/react/select'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { fieldClasses } from './input'\n\n/*\n * Select.\n *\n * The component the oldest rule in the line is about. A native `<select>`\n * cannot be dressed: the browser draws its popup itself, in the operating\n * system's chrome, and no CSS reaches inside. One native dropdown on a screen\n * of the product's own controls reads as a foreign object, and on Windows it\n * reads as a foreign object from 1998.\n *\n * So this renders `<button role=\"combobox\">` and a portalled list of\n * `role=\"option\"` - zero native elements, which is asserted in the test,\n * because it is the entire reason the component exists.\n *\n * What that costs is everything the browser was doing for free: the keyboard,\n * type-ahead, the announcement of the selected value, the scroll into view,\n * and on a phone the whole native picker. Base UI does all of it, which is\n * the only reason this trade is worth making - a hand-rolled dropdown is how\n * a product ships a control that a screen reader cannot see.\n *\n * The trigger wears Input's `fieldClasses`, imported rather than copied. A\n * select and a text field sit next to each other in every form there has ever\n * been, and two class lists that started the same drift within a release.\n *\n * `multiple` is a prop on the Root: it changes what `value` means - an array\n * rather than a single value - so it belongs where the value lives and not on\n * the trigger.\n */\n\nexport const selectTriggerVariants = cva([fieldClasses, 'flex items-center justify-between gap-2'], {\n variants: {\n size: {\n sm: 'h-control-sm text-xs',\n md: 'h-control',\n lg: 'h-control-lg text-base',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\nexport const selectPopupVariants = cva(\n [\n 'max-h-[min(24rem,var(--available-height))] overflow-y-auto',\n 'rounded-md border border-line bg-raise p-1 text-text shadow-raise',\n 'focus-visible:outline-none',\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.98] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0',\n ],\n {\n variants: {\n size: {\n // The popup matches the trigger's width by default, which is what a\n // dropdown should do; the sizes are a floor for a narrow one.\n sm: 'min-w-[max(8rem,var(--anchor-width))]',\n md: 'min-w-[max(10rem,var(--anchor-width))]',\n lg: 'min-w-[max(14rem,var(--anchor-width))]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** One option. */\nexport const selectItemVariants = cva([\n 'relative flex cursor-pointer select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-7 text-sm',\n 'outline-none transition-colors',\n // Base UI marks the item under the pointer or the keyboard the same way,\n // so one rule covers both and they cannot disagree.\n 'data-[highlighted]:bg-soft data-[highlighted]:text-text',\n // What is already chosen has to be visible in the list, and colour alone\n // will not do it: `text-text` on an item that is already `text-text` says\n // nothing. The tick below is the state; this is the emphasis that goes with\n // it, so the row reads as chosen at a glance and not only under the eye.\n 'data-[selected]:font-medium data-[selected]:text-accent',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n '[&_svg]:size-3.5 [&_svg]:shrink-0',\n])\n\n/** The root. `multiple` turns `value` into an array; otherwise controlled with\n * `value` and `onValueChange`, or left to manage itself. */\nexport const Select = Base.Root\n\n/** What the trigger shows: the selected item's label, and the `placeholder`\n * the product gives it until there is one.\n *\n * Two traps, both Base UI's and both quiet. Its `children` is a *function* of\n * the value, not a node - passing a node pins the trigger to that node\n * forever and the selection never appears, so the placeholder goes in\n * `placeholder`. And what it shows is the raw value, `plum` rather than\n * `Plum`, unless the root is given an `items` map to look the label up in.\n *\n * It truncates, and that matters most for `multiple`: nine chosen fruits are\n * one long string, and without this the trigger either grows into a paragraph\n * or spills its text past its own border. One line, an ellipsis, and the full\n * set is still in the list where the ticks are. */\nexport function SelectValue({ className, ...props }: Base.Value.Props) {\n return <Base.Value className={cn('min-w-0 flex-1 truncate text-left', className)} {...props} />\n}\n\n/** The chevron, or whatever the product puts there. Marked decorative by Base\n * UI, since the button is already named by its value. */\nexport const SelectIcon = Base.Icon\n\n/** A labelled group of options. */\nexport const SelectGroup = Base.Group\n\n/** The text of an option, which is what the trigger echoes when it is chosen. */\nexport const SelectItemText = Base.ItemText\n\n/** The tick, drawn only on the chosen option. */\nexport const SelectItemIndicator = Base.ItemIndicator\n\nexport interface SelectTriggerProps\n extends Base.Trigger.Props,\n VariantProps<typeof selectTriggerVariants> {}\n\n/** The control. A `<button role=\"combobox\">` - never a `<select>`. */\nexport function SelectTrigger({ size, className, ...props }: SelectTriggerProps) {\n return <Base.Trigger className={cn(selectTriggerVariants({ size }), className)} {...props} />\n}\n\nexport interface SelectPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof selectPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Where to portal to. Defaults to the document body
|
|
1798
|
+
"content": "import { Select as Base } from '@base-ui/react/select'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { usePopupContainer } from './layer'\nimport { fieldClasses } from './input'\n\n/*\n * Select.\n *\n * The component the oldest rule in the line is about. A native `<select>`\n * cannot be dressed: the browser draws its popup itself, in the operating\n * system's chrome, and no CSS reaches inside. One native dropdown on a screen\n * of the product's own controls reads as a foreign object, and on Windows it\n * reads as a foreign object from 1998.\n *\n * So this renders `<button role=\"combobox\">` and a portalled list of\n * `role=\"option\"` - zero native elements, which is asserted in the test,\n * because it is the entire reason the component exists.\n *\n * What that costs is everything the browser was doing for free: the keyboard,\n * type-ahead, the announcement of the selected value, the scroll into view,\n * and on a phone the whole native picker. Base UI does all of it, which is\n * the only reason this trade is worth making - a hand-rolled dropdown is how\n * a product ships a control that a screen reader cannot see.\n *\n * The trigger wears Input's `fieldClasses`, imported rather than copied. A\n * select and a text field sit next to each other in every form there has ever\n * been, and two class lists that started the same drift within a release.\n *\n * `multiple` is a prop on the Root: it changes what `value` means - an array\n * rather than a single value - so it belongs where the value lives and not on\n * the trigger.\n */\n\nexport const selectTriggerVariants = cva([fieldClasses, 'flex items-center justify-between gap-2'], {\n variants: {\n size: {\n sm: 'h-control-sm text-xs',\n md: 'h-control',\n lg: 'h-control-lg text-base',\n },\n },\n defaultVariants: { size: 'md' },\n})\n\nexport const selectPopupVariants = cva(\n [\n 'max-h-[min(24rem,var(--available-height))] overflow-y-auto',\n 'rounded-md border border-line bg-raise p-1 text-text shadow-raise',\n 'focus-visible:outline-none',\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.98] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.98] data-[starting-style]:opacity-0',\n ],\n {\n variants: {\n size: {\n // The popup matches the trigger's width by default, which is what a\n // dropdown should do; the sizes are a floor for a narrow one.\n sm: 'min-w-[max(8rem,var(--anchor-width))]',\n md: 'min-w-[max(10rem,var(--anchor-width))]',\n lg: 'min-w-[max(14rem,var(--anchor-width))]',\n },\n },\n defaultVariants: { size: 'md' },\n },\n)\n\n/** One option. */\nexport const selectItemVariants = cva([\n 'relative flex cursor-pointer select-none items-center gap-2 rounded-sm py-1.5 pl-2 pr-7 text-sm',\n 'outline-none transition-colors',\n // Base UI marks the item under the pointer or the keyboard the same way,\n // so one rule covers both and they cannot disagree.\n 'data-[highlighted]:bg-soft data-[highlighted]:text-text',\n // What is already chosen has to be visible in the list, and colour alone\n // will not do it: `text-text` on an item that is already `text-text` says\n // nothing. The tick below is the state; this is the emphasis that goes with\n // it, so the row reads as chosen at a glance and not only under the eye.\n 'data-[selected]:font-medium data-[selected]:text-accent',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50',\n '[&_svg:not([class*=size-])]:size-3.5 [&_svg]:shrink-0',\n])\n\n/** The root. `multiple` turns `value` into an array; otherwise controlled with\n * `value` and `onValueChange`, or left to manage itself. */\nexport const Select = Base.Root\n\n/** What the trigger shows: the selected item's label, and the `placeholder`\n * the product gives it until there is one.\n *\n * Two traps, both Base UI's and both quiet. Its `children` is a *function* of\n * the value, not a node - passing a node pins the trigger to that node\n * forever and the selection never appears, so the placeholder goes in\n * `placeholder`. And what it shows is the raw value, `plum` rather than\n * `Plum`, unless the root is given an `items` map to look the label up in.\n *\n * It truncates, and that matters most for `multiple`: nine chosen fruits are\n * one long string, and without this the trigger either grows into a paragraph\n * or spills its text past its own border. One line, an ellipsis, and the full\n * set is still in the list where the ticks are. */\nexport function SelectValue({ className, ...props }: Base.Value.Props) {\n return <Base.Value className={cn('min-w-0 flex-1 truncate text-left', className)} {...props} />\n}\n\n/** The chevron, or whatever the product puts there. Marked decorative by Base\n * UI, since the button is already named by its value. */\nexport const SelectIcon = Base.Icon\n\n/** A labelled group of options. */\nexport const SelectGroup = Base.Group\n\n/** The text of an option, which is what the trigger echoes when it is chosen. */\nexport const SelectItemText = Base.ItemText\n\n/** The tick, drawn only on the chosen option. */\nexport const SelectItemIndicator = Base.ItemIndicator\n\nexport interface SelectTriggerProps\n extends Base.Trigger.Props,\n VariantProps<typeof selectTriggerVariants> {}\n\n/** The control. A `<button role=\"combobox\">` - never a `<select>`. */\nexport function SelectTrigger({ size, className, ...props }: SelectTriggerProps) {\n return <Base.Trigger className={cn(selectTriggerVariants({ size }), className)} {...props} />\n}\n\nexport interface SelectPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof selectPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Where to portal to. Defaults to the raised host of the overlay this is\n * opened inside (`layer.tsx`), and to the document body when there is none -\n * either way not the element it was opened from, whose `overflow` would clip\n * it. Pass an element to put it somewhere else, such as a container being\n * screenshotted. */\n container?: Base.Portal.Props['container']\n}\n\n/** The list. Portalled and positioned against the trigger.\n *\n * `alignItemWithTrigger` is off: Base UI's default lifts the popup so the\n * selected option sits over the button, which is the native macOS behaviour\n * and is disorienting in a web form - the list jumps to a different place\n * depending on what is already chosen. */\nexport function SelectPopup({\n size,\n side,\n align,\n sideOffset = 4,\n container,\n className,\n children,\n ...props\n}: SelectPopupProps) {\n // Inside an overlay, the overlay's raised host rather than the body - or\n // this popup draws under the dialog, drawer or popover that opened it. See\n // `layer.tsx`. Outside every overlay the hook gives `undefined`: the body.\n const host = usePopupContainer()\n\n return (\n <Base.Portal container={container ?? host}>\n <Base.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n alignItemWithTrigger={false}\n className=\"[z-index:var(--z-menu)]\"\n >\n <Base.Popup className={cn(selectPopupVariants({ size }), className)} {...props}>\n <Base.List>{children}</Base.List>\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\n/** An option, with the tick that says it is the chosen one.\n *\n * The indicator is built in rather than left to the caller. The item already\n * reserves the room for it (`pr-7`), and a dropdown that does not show what is\n * currently selected is the commonest complaint about a styled select: it\n * opens, and the reader has to remember what they picked last time. Passing\n * `indicator={false}` turns it off for a list where the choice is obvious\n * some other way. */\nexport function SelectItem({\n indicator = true,\n className,\n children,\n ...props\n}: Base.Item.Props & { indicator?: boolean }) {\n return (\n <Base.Item className={cn(selectItemVariants(), className)} {...props}>\n {children}\n {indicator && (\n <Base.ItemIndicator className=\"absolute right-2 flex text-accent\">\n <svg viewBox=\"0 0 16 16\" className=\"size-3.5\" aria-hidden>\n <path\n d=\"M3.5 8.5l3 3 6-6.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n </Base.ItemIndicator>\n )}\n </Base.Item>\n )\n}\n\n/** The caption above a group. */\nexport function SelectGroupLabel({ className, ...props }: Base.GroupLabel.Props) {\n return (\n <Base.GroupLabel\n className={cn('px-2 py-1.5 text-2xs uppercase tracking-caption text-faint', className)}\n {...props}\n />\n )\n}\n\n/** A line between groups of options. */\nexport function SelectSeparator({ className, ...props }: Base.Separator.Props) {\n return <Base.Separator className={cn('-mx-1 my-1 h-px bg-line', className)} {...props} />\n}\n"
|
|
1765
1799
|
}
|
|
1766
1800
|
]
|
|
1767
1801
|
},
|
|
@@ -1787,7 +1821,7 @@
|
|
|
1787
1821
|
"title": "SkeletonOf",
|
|
1788
1822
|
"description": "`Skeleton` and its shapes solved half the problem: they gave a product a list, a card and a grid to reach for instead of a spinner. The half left over is the one that actually causes the jump, and it is a human one - somebody has to look at the real thing, judge how many rows it has and how tall they are, and type that in. The judgement is made once, the screen changes a month later, and the placeholder goes on promising the old shape.",
|
|
1789
1823
|
"dependencies": [
|
|
1790
|
-
"dowel-ui@^0.
|
|
1824
|
+
"dowel-ui@^0.32.0"
|
|
1791
1825
|
],
|
|
1792
1826
|
"registryDependencies": [],
|
|
1793
1827
|
"files": [
|
|
@@ -1805,7 +1839,7 @@
|
|
|
1805
1839
|
"title": "Skeleton",
|
|
1806
1840
|
"description": "The rule the component is built on, and the reason it takes a shape rather than filling the space:\n * **A skeleton of the wrong shape is worse than no skeleton.**\n * It promises something the content does not keep, and the promise is paid for in a jump: the page settles, the scrollbar appears, and whatever the reader was about to click has moved. Measured rather than assumed - the line's own calendar showed a list of four short lines where a six-row month grid was about to land, and the skeleton was itself the jump it existed to prevent.",
|
|
1807
1841
|
"dependencies": [
|
|
1808
|
-
"dowel-ui@^0.
|
|
1842
|
+
"dowel-ui@^0.32.0"
|
|
1809
1843
|
],
|
|
1810
1844
|
"registryDependencies": [],
|
|
1811
1845
|
"files": [
|
|
@@ -1824,7 +1858,7 @@
|
|
|
1824
1858
|
"description": "The case for it over a NumberField is that the number does not matter much: a volume, an opacity, a weight in a search filter. Where the exact figure does matter, a slider is a worse field with more pixels - it cannot be typed into, it cannot be pasted into, and it has no state for \"empty\".",
|
|
1825
1859
|
"dependencies": [
|
|
1826
1860
|
"@base-ui/react",
|
|
1827
|
-
"dowel-ui@^0.
|
|
1861
|
+
"dowel-ui@^0.32.0"
|
|
1828
1862
|
],
|
|
1829
1863
|
"registryDependencies": [],
|
|
1830
1864
|
"files": [
|
|
@@ -1843,7 +1877,7 @@
|
|
|
1843
1877
|
"description": "The shape of a history, not a chart of it: no axes, no gridlines, no ticks.",
|
|
1844
1878
|
"dependencies": [
|
|
1845
1879
|
"class-variance-authority",
|
|
1846
|
-
"dowel-ui@^0.
|
|
1880
|
+
"dowel-ui@^0.32.0"
|
|
1847
1881
|
],
|
|
1848
1882
|
"registryDependencies": [],
|
|
1849
1883
|
"files": [
|
|
@@ -1862,7 +1896,7 @@
|
|
|
1862
1896
|
"description": "Something is happening and the answer has not arrived. It carries no text of its own - what is loading is the product's word, not the system's - but it does have to say *something* to a screen reader, or a page that is busy is silently identical to a page that is empty.",
|
|
1863
1897
|
"dependencies": [
|
|
1864
1898
|
"class-variance-authority",
|
|
1865
|
-
"dowel-ui@^0.
|
|
1899
|
+
"dowel-ui@^0.32.0"
|
|
1866
1900
|
],
|
|
1867
1901
|
"registryDependencies": [],
|
|
1868
1902
|
"files": [
|
|
@@ -1880,7 +1914,7 @@
|
|
|
1880
1914
|
"title": "Splash",
|
|
1881
1915
|
"description": "A desktop product has a second or two between the window appearing and the first screen being ready - a workspace to open, a database to migrate, a plugin to start - and a blank window for that long reads as a crash. So the window shows the product instead: the mark, the name, the promise, the version, and a bar that sweeps until there is something to draw.",
|
|
1882
1916
|
"dependencies": [
|
|
1883
|
-
"dowel-ui@^0.
|
|
1917
|
+
"dowel-ui@^0.32.0"
|
|
1884
1918
|
],
|
|
1885
1919
|
"registryDependencies": [],
|
|
1886
1920
|
"files": [
|
|
@@ -1888,7 +1922,7 @@
|
|
|
1888
1922
|
"path": "ui/splash.tsx",
|
|
1889
1923
|
"target": "@ui/splash.tsx",
|
|
1890
1924
|
"type": "registry:ui",
|
|
1891
|
-
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from 'dowel-ui'\n\n/*\n * What the window shows while the application is opening.\n *\n * A desktop product has a second or two between the window appearing and\n * the first screen being ready - a workspace to open, a database to migrate,\n * a plugin to start - and a blank window for that long reads as a crash. So\n * the window shows the product instead: the mark, the name, the promise, the\n * version, and a bar that sweeps until there is something to draw.\n *\n * It is the second half of a pattern, and the first half is not React. The\n * page paints the same picture in inline CSS before the bundle arrives, so\n * that the window is never blank at all; this component takes over from it\n * on the first render, with the same geometry so nothing jumps, and adds the\n * two lines only the application can say - what it is doing, in the person's\n * language, and one thing worth knowing. The static half is in the docs.\n *\n * It is a status region, not a dialog: the reader is told what is happening\n * and cannot act on it. The sweep is a `<style>` of its own rather than a\n * theme keyframe, because a product installs the theme on its first day and\n * this once; and under reduced motion the theme stops every animation dead,\n * which would leave the sweep parked off the end of its track - so the bar\n * is drawn full and still instead.\n */\n\nexport interface SplashProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {\n /** The product's mark, drawn at 56px. */\n mark?: ReactNode\n /** The product's name. */\n name: string\n /** The line under the name. */\n tagline?: string\n /** The version, drawn in the mono face; the `v` is the product's to add. */\n version?: string\n /** What the application is doing right now. */\n status?: string\n /** One thing worth knowing while it does it. */\n tip?: string\n /** Whether the bar is sweeping. Still and full when the application is\n * waiting on something that has no progress, such as a person. */\n busy?: boolean\n}\n\n/** The sweep, named with a prefix so a product's own `sweep` cannot collide\n * with it in the one document both end up in.\n *\n * The class below writes the name out rather than interpolating this\n * constant, and that is not carelessness: Tailwind finds its classes by\n * scanning the source text, and a class assembled from a template is one it\n * never sees - the bar rendered with the right class name and no CSS behind\n * it, and the stand showed an empty track. The test compiles the class to\n * make sure the two spellings agree. */\nconst SWEEP = 'dowel-splash-sweep'\nconst SWEEPING = 'animate-[dowel-splash-sweep_1.1s_ease-in-out_infinite]'\n\nexport function Splash({\n mark,\n name,\n tagline,\n version,\n status,\n tip,\n busy = true,\n className,\n ...props\n}: SplashProps) {\n return (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className={cn(\n 'fixed inset-0 flex flex-col items-center justify-center gap-2.5 bg-bg text-text select-none',\n className,\n )}\n {...props}\n >\n <style>{`@keyframes ${SWEEP} { to { left: 100%; } }`}</style>\n {mark ? <div className=\"mb-1.5 size-14 [&>svg]:size-full\">{mark}</div> : null}\n <div className=\"text-[26px] leading-none font-semibold tracking-[0.02em]\">{name}</div>\n {tagline ? <div className=\"text-sm text-dim\">{tagline}</div> : null}\n {version ? <div className=\"mt-1.5 font-mono text-2xs text-faint\">{version}</div> : null}\n <div className=\"relative mt-4 h-0.5 w-40 overflow-hidden rounded-full bg-line\">\n <div\n data-sweep={busy ? 'on' : 'off'}\n className={cn(\n 'absolute top-0 h-full rounded-full bg-accent',\n busy\n ? cn(\n '-left-2/5 w-2/5',\n SWEEPING,\n 'motion-reduce:left-0 motion-reduce:w-full motion-reduce:animate-none',\n )\n : 'left-0 w-full',\n )}\n />\n </div>\n {status ? <p className=\"mt-3 text-xs text-dim\">{status}</p> : null}\n {tip ? <p className=\"text-2xs text-faint\">{tip}</p> : null}\n </div>\n )\n}\n"
|
|
1925
|
+
"content": "import type { HTMLAttributes, ReactNode } from 'react'\nimport { cn } from 'dowel-ui'\n\n/*\n * What the window shows while the application is opening.\n *\n * A desktop product has a second or two between the window appearing and\n * the first screen being ready - a workspace to open, a database to migrate,\n * a plugin to start - and a blank window for that long reads as a crash. So\n * the window shows the product instead: the mark, the name, the promise, the\n * version, and a bar that sweeps until there is something to draw.\n *\n * It is the second half of a pattern, and the first half is not React. The\n * page paints the same picture in inline CSS before the bundle arrives, so\n * that the window is never blank at all; this component takes over from it\n * on the first render, with the same geometry so nothing jumps, and adds the\n * two lines only the application can say - what it is doing, in the person's\n * language, and one thing worth knowing. The static half is in the docs.\n *\n * It is a status region, not a dialog: the reader is told what is happening\n * and cannot act on it. The sweep is a `<style>` of its own rather than a\n * theme keyframe, because a product installs the theme on its first day and\n * this once; and under reduced motion the theme stops every animation dead,\n * which would leave the sweep parked off the end of its track - so the bar\n * is drawn full and still instead.\n */\n\nexport interface SplashProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {\n /** The product's mark, drawn at 56px. */\n mark?: ReactNode\n /** The product's name. */\n name: string\n /** The line under the name. */\n tagline?: string\n /** The version, drawn in the mono face; the `v` is the product's to add. */\n version?: string\n /** What the application is doing right now. */\n status?: string\n /** One thing worth knowing while it does it. */\n tip?: string\n /** Whether the bar is sweeping. Still and full when the application is\n * waiting on something that has no progress, such as a person. */\n busy?: boolean\n}\n\n/** The sweep, named with a prefix so a product's own `sweep` cannot collide\n * with it in the one document both end up in.\n *\n * The class below writes the name out rather than interpolating this\n * constant, and that is not carelessness: Tailwind finds its classes by\n * scanning the source text, and a class assembled from a template is one it\n * never sees - the bar rendered with the right class name and no CSS behind\n * it, and the stand showed an empty track. The test compiles the class to\n * make sure the two spellings agree. */\nconst SWEEP = 'dowel-splash-sweep'\nconst SWEEPING = 'animate-[dowel-splash-sweep_1.1s_ease-in-out_infinite]'\n\nexport function Splash({\n mark,\n name,\n tagline,\n version,\n status,\n tip,\n busy = true,\n className,\n ...props\n}: SplashProps) {\n return (\n <div\n role=\"status\"\n aria-live=\"polite\"\n className={cn(\n 'fixed inset-0 flex flex-col items-center justify-center gap-2.5 bg-bg text-text select-none',\n className,\n )}\n {...props}\n >\n <style>{`@keyframes ${SWEEP} { to { left: 100%; } }`}</style>\n {mark ? <div className=\"mb-1.5 size-14 [&>svg:not([class*=size-])]:size-full\">{mark}</div> : null}\n <div className=\"text-[26px] leading-none font-semibold tracking-[0.02em]\">{name}</div>\n {tagline ? <div className=\"text-sm text-dim\">{tagline}</div> : null}\n {version ? <div className=\"mt-1.5 font-mono text-2xs text-faint\">{version}</div> : null}\n <div className=\"relative mt-4 h-0.5 w-40 overflow-hidden rounded-full bg-line\">\n <div\n data-sweep={busy ? 'on' : 'off'}\n className={cn(\n 'absolute top-0 h-full rounded-full bg-accent',\n busy\n ? cn(\n '-left-2/5 w-2/5',\n SWEEPING,\n 'motion-reduce:left-0 motion-reduce:w-full motion-reduce:animate-none',\n )\n : 'left-0 w-full',\n )}\n />\n </div>\n {status ? <p className=\"mt-3 text-xs text-dim\">{status}</p> : null}\n {tip ? <p className=\"text-2xs text-faint\">{tip}</p> : null}\n </div>\n )\n}\n"
|
|
1892
1926
|
}
|
|
1893
1927
|
]
|
|
1894
1928
|
},
|
|
@@ -1899,7 +1933,7 @@
|
|
|
1899
1933
|
"description": "The splitter primitive.",
|
|
1900
1934
|
"dependencies": [
|
|
1901
1935
|
"class-variance-authority",
|
|
1902
|
-
"dowel-ui@^0.
|
|
1936
|
+
"dowel-ui@^0.32.0"
|
|
1903
1937
|
],
|
|
1904
1938
|
"registryDependencies": [],
|
|
1905
1939
|
"files": [
|
|
@@ -1918,7 +1952,7 @@
|
|
|
1918
1952
|
"description": "The smallest thing on a dashboard and the one every product writes itself: a label above, a number below, sometimes a word about which way it moved.",
|
|
1919
1953
|
"dependencies": [
|
|
1920
1954
|
"class-variance-authority",
|
|
1921
|
-
"dowel-ui@^0.
|
|
1955
|
+
"dowel-ui@^0.32.0"
|
|
1922
1956
|
],
|
|
1923
1957
|
"registryDependencies": [],
|
|
1924
1958
|
"files": [
|
|
@@ -1937,7 +1971,7 @@
|
|
|
1937
1971
|
"description": "The smallest thing a screen can say about something's condition: a server is up, a job failed, a person is away. Every product of the line drew its own coloured circle, and every one of them drew it the same way - a `<span>` with a background - which means the condition existed for exactly the readers who could see it.",
|
|
1938
1972
|
"dependencies": [
|
|
1939
1973
|
"class-variance-authority",
|
|
1940
|
-
"dowel-ui@^0.
|
|
1974
|
+
"dowel-ui@^0.32.0"
|
|
1941
1975
|
],
|
|
1942
1976
|
"registryDependencies": [],
|
|
1943
1977
|
"files": [
|
|
@@ -1956,7 +1990,7 @@
|
|
|
1956
1990
|
"description": "The steps of a task too long for one screen, and where you stand in them: set up a workspace, import a library, configure a connection. It is a picture of progress on its own, and the top of a Wizard when the steps are a form - a product can show how far along something is without owning the form that moves it, which is why the two are separate components. Base UI has no stepper, so this one is written here rather than wrapped.",
|
|
1957
1991
|
"dependencies": [
|
|
1958
1992
|
"class-variance-authority",
|
|
1959
|
-
"dowel-ui@^0.
|
|
1993
|
+
"dowel-ui@^0.32.0"
|
|
1960
1994
|
],
|
|
1961
1995
|
"registryDependencies": [],
|
|
1962
1996
|
"files": [
|
|
@@ -1975,7 +2009,7 @@
|
|
|
1975
2009
|
"description": "The difference from Checkbox is not how it looks, and getting it wrong is the commonest mistake in the pair. A checkbox is an answer collected now and submitted later, with the rest of the form; a switch is a setting that applies the moment it moves. Put a switch in a form with a Save button and the reader cannot tell whether anything happened - they flipped it, and nothing said so.",
|
|
1976
2010
|
"dependencies": [
|
|
1977
2011
|
"@base-ui/react",
|
|
1978
|
-
"dowel-ui@^0.
|
|
2012
|
+
"dowel-ui@^0.32.0"
|
|
1979
2013
|
],
|
|
1980
2014
|
"registryDependencies": [],
|
|
1981
2015
|
"files": [
|
|
@@ -2010,7 +2044,7 @@
|
|
|
2010
2044
|
"description": "Parts rather than a `columns` prop, and that is the decision worth stating: a `<DataTable columns={…} rows={…} />` is quicker to write for the first table and then owns every cell in the product forever. The moment one column needs a Badge, another a link, and a third the row's own menu, the prop grows a `render` for each - at which point it is JSX with extra steps, spelt in a shape only this component understands.",
|
|
2011
2045
|
"dependencies": [
|
|
2012
2046
|
"class-variance-authority",
|
|
2013
|
-
"dowel-ui@^0.
|
|
2047
|
+
"dowel-ui@^0.32.0"
|
|
2014
2048
|
],
|
|
2015
2049
|
"registryDependencies": [
|
|
2016
2050
|
"https://lacodda.github.io/dowel/r/table-sort.json"
|
|
@@ -2032,7 +2066,7 @@
|
|
|
2032
2066
|
"dependencies": [
|
|
2033
2067
|
"@base-ui/react",
|
|
2034
2068
|
"class-variance-authority",
|
|
2035
|
-
"dowel-ui@^0.
|
|
2069
|
+
"dowel-ui@^0.32.0"
|
|
2036
2070
|
],
|
|
2037
2071
|
"registryDependencies": [],
|
|
2038
2072
|
"files": [
|
|
@@ -2040,7 +2074,7 @@
|
|
|
2040
2074
|
"path": "ui/tabs.tsx",
|
|
2041
2075
|
"target": "@ui/tabs.tsx",
|
|
2042
2076
|
"type": "registry:ui",
|
|
2043
|
-
"content": "import { createContext, useContext, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react'\nimport { Tabs as Base } from '@base-ui/react/tabs'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Tabs - one place on a screen showing one of several views, or a window\n * showing one of several open documents.\n *\n * Two shapes, because the line has two needs and they look nothing alike.\n * `line` is the familiar row of words over a panel, the active one underlined\n * in the accent: settings split into sections, a record's details and its\n * history. `bar` is the strip of open documents that lives *inside* a\n * frameless window's title bar - scheda's trade, where a separate tab row under\n * a system title bar cost about sixty pixels of every laptop screen. A bar tab\n * is as tall as the bar, the active one takes the page's ground so it reads as\n * joined to the document below, and a two-pixel accent rule on its top edge\n * marks it where an underline would sit against the window's edge.\n *\n * Behaviour is Base UI's: arrow keys move between tabs, Home and End go to\n * the ends, the list loops, and the panel is wired to its tab with the ids a\n * reader needs. Nothing here re-implements that.\n *\n * A document tab can close, and that is where the obvious markup is wrong.\n * A close button *inside* a `tab` is an interactive element nested in another,\n * which a screen reader flattens into one control and a keyboard cannot reach\n * separately. So the cross is a sibling drawn over the tab, for the pointer\n * only - taken out of the tab order and the reading - and the keyboard closes\n * the focused tab with Delete, which the tab announces through\n * `aria-keyshortcuts`. A middle click closes too, the way every tabbed thing\n * does. The cross is always drawn, faintly, rather than revealed on hover: a\n * button that appears under the pointer is one the pointer was not aiming for.\n *\n * A document with unsaved changes carries a dot in the accent. The dot is\n * drawing; the words `modifiedLabel` gives are what a reader hears, and the\n * type will not accept one without the other.\n */\n\nexport function Tabs({ className, ...props }: Base.Root.Props) {\n return <Base.Root className={cn('flex min-w-0 flex-col data-[orientation=vertical]:flex-row', className)} {...props} />\n}\n\nexport const tabsListVariants = cva('relative flex min-w-0', {\n variants: {\n variant: {\n line: 'gap-1 border-b border-line data-[orientation=vertical]:flex-col data-[orientation=vertical]:border-r data-[orientation=vertical]:border-b-0',\n // The strip scrolls sideways rather than squeezing: a window with twenty\n // documents open keeps every name legible and lets the bar scroll. The\n // scrollbar itself stays out of a forty-pixel bar.\n bar: 'h-full items-stretch overflow-x-auto [scrollbar-width:none]',\n },\n },\n defaultVariants: { variant: 'line' },\n})\n\nexport interface TabsListProps extends Base.List.Props, VariantProps<typeof tabsListVariants> {\n /** A name for the list, when nothing on the screen already says what the\n * tabs choose between. Documents in a window bar need one. */\n 'aria-label'?: string\n}\n\ntype Variant = NonNullable<TabsListProps['variant']>\n\n/* The list tells its tabs which shape they are, through context rather than a\n * CSS ancestor selector: a panel of `line` tabs inside a `bar` document would\n * match the outer list's selector too. */\nconst VariantContext = createContext<Variant>('line')\n\nexport function TabsList({ variant, className, children, ...props }: TabsListProps) {\n const shape: Variant = variant ?? 'line'\n return (\n <Base.List className={cn(tabsListVariants({ variant: shape }), className)} {...props}>\n <VariantContext.Provider value={shape}>{children}</VariantContext.Provider>\n {shape === 'line' && (\n <Base.Indicator\n className={cn(\n // Base UI measures the active tab and hands its box over as CSS\n // variables, so the rule slides between tabs rather than jumping.\n 'absolute bottom-0 left-(--active-tab-left) h-0.5 w-(--active-tab-width) translate-y-px bg-accent',\n 'transition-[left,width] duration-quick ease-out',\n 'data-[orientation=vertical]:top-(--active-tab-top) data-[orientation=vertical]:right-0 data-[orientation=vertical]:bottom-auto data-[orientation=vertical]:left-auto',\n 'data-[orientation=vertical]:h-(--active-tab-height) data-[orientation=vertical]:w-0.5 data-[orientation=vertical]:translate-x-px data-[orientation=vertical]:translate-y-0',\n 'data-[orientation=vertical]:transition-[top,height]',\n )}\n />\n )}\n </Base.List>\n )\n}\n\nconst tabBase = cn(\n 'flex cursor-default items-center gap-1.5 whitespace-nowrap text-dim outline-none select-none',\n 'transition-colors duration-quick',\n 'hover:text-text data-[active]:text-text',\n 'focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent',\n 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n)\n\n/** The shape of a tab, told by the list it sits in. */\nconst tabShape: Record<Variant, string> = {\n line: 'h-
|
|
2077
|
+
"content": "import { createContext, useContext, type KeyboardEvent, type MouseEvent, type ReactNode } from 'react'\nimport { Tabs as Base } from '@base-ui/react/tabs'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Tabs - one place on a screen showing one of several views, or a window\n * showing one of several open documents.\n *\n * Two shapes, because the line has two needs and they look nothing alike.\n * `line` is the familiar row of words over a panel, the active one underlined\n * in the accent: settings split into sections, a record's details and its\n * history. `bar` is the strip of open documents that lives *inside* a\n * frameless window's title bar - scheda's trade, where a separate tab row under\n * a system title bar cost about sixty pixels of every laptop screen. A bar tab\n * is as tall as the bar, the active one takes the page's ground so it reads as\n * joined to the document below, and a two-pixel accent rule on its top edge\n * marks it where an underline would sit against the window's edge.\n *\n * Behaviour is Base UI's: arrow keys move between tabs, Home and End go to\n * the ends, the list loops, and the panel is wired to its tab with the ids a\n * reader needs. Nothing here re-implements that.\n *\n * A document tab can close, and that is where the obvious markup is wrong.\n * A close button *inside* a `tab` is an interactive element nested in another,\n * which a screen reader flattens into one control and a keyboard cannot reach\n * separately. So the cross is a sibling drawn over the tab, for the pointer\n * only - taken out of the tab order and the reading - and the keyboard closes\n * the focused tab with Delete, which the tab announces through\n * `aria-keyshortcuts`. A middle click closes too, the way every tabbed thing\n * does. The cross is always drawn, faintly, rather than revealed on hover: a\n * button that appears under the pointer is one the pointer was not aiming for.\n *\n * A document with unsaved changes carries a dot in the accent. The dot is\n * drawing; the words `modifiedLabel` gives are what a reader hears, and the\n * type will not accept one without the other.\n */\n\nexport function Tabs({ className, ...props }: Base.Root.Props) {\n return <Base.Root className={cn('flex min-w-0 flex-col data-[orientation=vertical]:flex-row', className)} {...props} />\n}\n\nexport const tabsListVariants = cva('relative flex min-w-0', {\n variants: {\n variant: {\n line: 'gap-1 border-b border-line data-[orientation=vertical]:flex-col data-[orientation=vertical]:border-r data-[orientation=vertical]:border-b-0',\n // The strip scrolls sideways rather than squeezing: a window with twenty\n // documents open keeps every name legible and lets the bar scroll. The\n // scrollbar itself stays out of a forty-pixel bar.\n bar: 'h-full items-stretch overflow-x-auto [scrollbar-width:none]',\n },\n },\n defaultVariants: { variant: 'line' },\n})\n\nexport interface TabsListProps extends Base.List.Props, VariantProps<typeof tabsListVariants> {\n /** A name for the list, when nothing on the screen already says what the\n * tabs choose between. Documents in a window bar need one. */\n 'aria-label'?: string\n}\n\ntype Variant = NonNullable<TabsListProps['variant']>\n\n/* The list tells its tabs which shape they are, through context rather than a\n * CSS ancestor selector: a panel of `line` tabs inside a `bar` document would\n * match the outer list's selector too. */\nconst VariantContext = createContext<Variant>('line')\n\nexport function TabsList({ variant, className, children, ...props }: TabsListProps) {\n const shape: Variant = variant ?? 'line'\n return (\n <Base.List className={cn(tabsListVariants({ variant: shape }), className)} {...props}>\n <VariantContext.Provider value={shape}>{children}</VariantContext.Provider>\n {shape === 'line' && (\n <Base.Indicator\n className={cn(\n // Base UI measures the active tab and hands its box over as CSS\n // variables, so the rule slides between tabs rather than jumping.\n 'absolute bottom-0 left-(--active-tab-left) h-0.5 w-(--active-tab-width) translate-y-px bg-accent',\n 'transition-[left,width] duration-quick ease-out',\n 'data-[orientation=vertical]:top-(--active-tab-top) data-[orientation=vertical]:right-0 data-[orientation=vertical]:bottom-auto data-[orientation=vertical]:left-auto',\n 'data-[orientation=vertical]:h-(--active-tab-height) data-[orientation=vertical]:w-0.5 data-[orientation=vertical]:translate-x-px data-[orientation=vertical]:translate-y-0',\n 'data-[orientation=vertical]:transition-[top,height]',\n )}\n />\n )}\n </Base.List>\n )\n}\n\nconst tabBase = cn(\n 'flex cursor-default items-center gap-1.5 whitespace-nowrap text-dim outline-none select-none',\n // An icon beside a tab's name is sized like one in a small button: at its\n // own 24px it stood taller than the text it labels.\n '[&_svg:not([class*=size-])]:size-3.5 [&_svg]:shrink-0',\n 'transition-colors duration-quick',\n 'hover:text-text data-[active]:text-text',\n 'focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent',\n 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',\n)\n\n/** The shape of a tab, told by the list it sits in. */\nconst tabShape: Record<Variant, string> = {\n line: 'h-control-sm rounded-md px-3 text-sm',\n bar: cn(\n 'h-full border-r border-line pl-3 text-xs',\n 'hover:bg-soft data-[active]:bg-bg data-[active]:shadow-[inset_0_2px_0_var(--accent)]',\n ),\n}\n\ntype Modified =\n | { modified?: false; modifiedLabel?: never }\n | {\n /** The document has changes that are not saved. */\n modified: true\n /** What a reader hears for the dot, e.g. \"unsaved changes\". */\n modifiedLabel: string\n }\n\ntype Closable =\n | { onClose?: never; closeLabel?: never }\n | {\n /** Closes the tab: from the cross, a middle click, or Delete. */\n onClose: () => void\n /** The cross's tooltip, e.g. \"Close notes.md\". */\n closeLabel: string\n }\n\nexport type TabsTabProps = Omit<Base.Tab.Props, 'children'> & {\n children: ReactNode\n} & Modified &\n Closable\n\nexport function TabsTab({\n className,\n children,\n modified,\n modifiedLabel,\n onClose,\n closeLabel,\n onKeyDown,\n onAuxClick,\n ...props\n}: TabsTabProps) {\n const variant = useContext(VariantContext)\n const tab = (\n <Base.Tab\n className={cn(tabBase, tabShape[variant], onClose && (variant === 'bar' ? 'pr-8' : 'pr-9'), className)}\n aria-keyshortcuts={onClose ? 'Delete' : undefined}\n onKeyDown={(event: KeyboardEvent<HTMLElement>) => {\n onKeyDown?.(event as Parameters<NonNullable<typeof onKeyDown>>[0])\n if (onClose && event.key === 'Delete' && !event.defaultPrevented) {\n event.preventDefault()\n onClose()\n }\n }}\n onAuxClick={(event: MouseEvent<HTMLElement>) => {\n onAuxClick?.(event as Parameters<NonNullable<typeof onAuxClick>>[0])\n if (onClose && event.button === 1) {\n event.preventDefault()\n onClose()\n }\n }}\n {...props}\n >\n <span className=\"min-w-0 max-w-56 truncate\">{children}</span>\n {modified && (\n <>\n <span aria-hidden className=\"size-1.5 shrink-0 rounded-full bg-accent\" />\n {/* A space of its own, outside the spans: name computation trims\n each element's text, so a space inside one is lost and the\n reader hears \"plan.mdunsaved changes\". */}\n {' '}\n <span className=\"sr-only\">{modifiedLabel}</span>\n </>\n )}\n </Base.Tab>\n )\n\n if (!onClose) return tab\n\n return (\n <span className=\"relative flex shrink-0\">\n {tab}\n <button\n type=\"button\"\n tabIndex={-1}\n aria-hidden\n title={closeLabel}\n onClick={onClose}\n className={cn(\n 'target-min absolute top-1/2 right-2 flex size-4 -translate-y-1/2 cursor-default items-center justify-center rounded-sm',\n 'text-faint transition-colors duration-quick hover:bg-soft hover:text-text',\n )}\n >\n <svg width=\"8\" height=\"8\" viewBox=\"0 0 8 8\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.2\" aria-hidden>\n <path d=\"M0.5 0.5l7 7M7.5 0.5l-7 7\" />\n </svg>\n </button>\n </span>\n )\n}\n\nexport function TabsPanel({ className, ...props }: Base.Panel.Props) {\n return (\n <Base.Panel\n className={cn(\n 'min-w-0 flex-1 outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-accent',\n className,\n )}\n {...props}\n />\n )\n}\n"
|
|
2044
2078
|
}
|
|
2045
2079
|
]
|
|
2046
2080
|
},
|
|
@@ -2051,7 +2085,7 @@
|
|
|
2051
2085
|
"description": "Free text turned into a list: type a word, press Enter, it becomes a chip.",
|
|
2052
2086
|
"dependencies": [
|
|
2053
2087
|
"class-variance-authority",
|
|
2054
|
-
"dowel-ui@^0.
|
|
2088
|
+
"dowel-ui@^0.32.0"
|
|
2055
2089
|
],
|
|
2056
2090
|
"registryDependencies": [
|
|
2057
2091
|
"https://lacodda.github.io/dowel/r/chip.json",
|
|
@@ -2072,7 +2106,7 @@
|
|
|
2072
2106
|
"title": "Textarea",
|
|
2073
2107
|
"description": "A multi-line field that can grow with what is typed into it, which is the only interesting part: a fixed box makes someone scroll inside a scroll, and a box that grows without limit pushes the button they are trying to reach off the screen. `autoResize` grows it; `maxRows` says when to stop and let it scroll after all.",
|
|
2074
2108
|
"dependencies": [
|
|
2075
|
-
"dowel-ui@^0.
|
|
2109
|
+
"dowel-ui@^0.32.0"
|
|
2076
2110
|
],
|
|
2077
2111
|
"registryDependencies": [
|
|
2078
2112
|
"https://lacodda.github.io/dowel/r/input.json"
|
|
@@ -2093,7 +2127,7 @@
|
|
|
2093
2127
|
"description": "The tier primitive.",
|
|
2094
2128
|
"dependencies": [
|
|
2095
2129
|
"class-variance-authority",
|
|
2096
|
-
"dowel-ui@^0.
|
|
2130
|
+
"dowel-ui@^0.32.0"
|
|
2097
2131
|
],
|
|
2098
2132
|
"registryDependencies": [],
|
|
2099
2133
|
"files": [
|
|
@@ -2111,7 +2145,7 @@
|
|
|
2111
2145
|
"title": "TimeField",
|
|
2112
2146
|
"description": "No donor for this one: neither product of the line had a time field, so this is written from the same shape as DurationField, and for the same reason. Anything a person plausibly types is accepted - `9`, `9:30`, `930`, `9.30`, `9pm`, `21:30` - and what comes back is always `HH:MM`.",
|
|
2113
2147
|
"dependencies": [
|
|
2114
|
-
"dowel-ui@^0.
|
|
2148
|
+
"dowel-ui@^0.32.0"
|
|
2115
2149
|
],
|
|
2116
2150
|
"registryDependencies": [
|
|
2117
2151
|
"https://lacodda.github.io/dowel/r/input.json"
|
|
@@ -2132,7 +2166,7 @@
|
|
|
2132
2166
|
"description": "What happened, in the order it happened: a release history, an audit trail, the steps a job went through. Four products of the line draw one, and all four drew it the same way - a list with a border on the left and a dot positioned over it by hand.",
|
|
2133
2167
|
"dependencies": [
|
|
2134
2168
|
"class-variance-authority",
|
|
2135
|
-
"dowel-ui@^0.
|
|
2169
|
+
"dowel-ui@^0.32.0"
|
|
2136
2170
|
],
|
|
2137
2171
|
"registryDependencies": [],
|
|
2138
2172
|
"files": [
|
|
@@ -2152,7 +2186,7 @@
|
|
|
2152
2186
|
"dependencies": [
|
|
2153
2187
|
"@base-ui/react",
|
|
2154
2188
|
"class-variance-authority",
|
|
2155
|
-
"dowel-ui@^0.
|
|
2189
|
+
"dowel-ui@^0.32.0"
|
|
2156
2190
|
],
|
|
2157
2191
|
"registryDependencies": [],
|
|
2158
2192
|
"files": [
|
|
@@ -2172,15 +2206,17 @@
|
|
|
2172
2206
|
"dependencies": [
|
|
2173
2207
|
"@base-ui/react",
|
|
2174
2208
|
"class-variance-authority",
|
|
2175
|
-
"dowel-ui@^0.
|
|
2209
|
+
"dowel-ui@^0.32.0"
|
|
2210
|
+
],
|
|
2211
|
+
"registryDependencies": [
|
|
2212
|
+
"https://lacodda.github.io/dowel/r/layer.json"
|
|
2176
2213
|
],
|
|
2177
|
-
"registryDependencies": [],
|
|
2178
2214
|
"files": [
|
|
2179
2215
|
{
|
|
2180
2216
|
"path": "ui/tooltip.tsx",
|
|
2181
2217
|
"target": "@ui/tooltip.tsx",
|
|
2182
2218
|
"type": "registry:ui",
|
|
2183
|
-
"content": "import { Tooltip as Base } from '@base-ui/react/tooltip'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\n\n/*\n * Tooltip.\n *\n * A label for a control that has no room for one - an icon button, a truncated\n * cell, a symbol whose meaning is not obvious. A phrase, not a panel.\n *\n * The line between this and Popover is not size, it is whether anything inside\n * can be reached. A tooltip holds no links, no buttons and no fields, because\n * there is no way to get into it: it is tied to a trigger that is hovered or\n * focused, and it disappears the moment attention moves. Content that has to\n * be clicked belongs in a Popover, whatever its length.\n *\n * The half everyone forgets is the keyboard. A tooltip that only opens on\n * hover is invisible to anyone who tabs, which is precisely the person reading\n * an unlabelled icon button. Base UI opens it on focus as well, and `Escape`\n * dismisses it - so it is tested here rather than assumed.\n *\n * The thing to know before using it: this is a VISUAL label, and nothing else.\n * Base UI puts no `role=\"tooltip\"` on the popup and no `aria-describedby` on\n * the trigger, and that is deliberate rather than an oversight - a tooltip is\n * unreachable on a touch screen and unreliable for a screen reader, so\n * pretending otherwise would be worse than not trying. What follows from that\n * is a rule, not a suggestion: THE TRIGGER MUST CARRY ITS OWN `aria-label`,\n * saying roughly what the tooltip says. The tooltip helps a sighted mouse or\n * keyboard user; the `aria-label` is what everybody else gets.\n *\n * So if the words are load-bearing - if not reading them means not\n * understanding the control - this is the wrong component. Put them inline, or\n * in a Popover with `openOnHover` on the trigger, which touch and screen\n * readers can actually reach.\n *\n * `Provider` is optional and shared: once one tooltip in a group has opened,\n * the next opens instantly instead of waiting out its delay again. A toolbar\n * of icon buttons without it feels broken in a way nobody can name.\n */\n\nexport const tooltipPopupVariants = cva(\n [\n 'rounded-md border border-line bg-raise px-2 py-1 text-xs text-text shadow-raise',\n 'select-none',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.96] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0',\n // Grow out of the edge it is anchored to rather than out of its own\n // middle, so the motion points back at the trigger.\n 'origin-[var(--transform-origin)]',\n ],\n {\n variants: {\n /*\n * Two, and no more. A tooltip is a phrase; the only real decision is\n * whether it is allowed to wrap.\n *\n * `wide` exists because the alternative people reach for is a Popover\n * that nothing can be clicked in, which loses the hover and focus\n * behaviour to gain a width.\n */\n size: {\n sm: 'max-w-[16rem]',\n wide: 'max-w-[24rem]',\n },\n },\n defaultVariants: { size: 'sm' },\n },\n)\n\n/** A shared delay for a group of tooltips. Wrap a toolbar in it and the second\n * icon button explains itself instantly rather than making the reader wait\n * again. Optional - a lone tooltip works without one. */\nexport const TooltipProvider = Base.Provider\n\n/** The root. Takes `disabled`, and the controlled `open`/`onOpenChange`.\n *\n * Note that `delay` is NOT here - it is a prop of the trigger, the same as on\n * PreviewCard. Passing it to the root is silently ignored at runtime, which is\n * exactly the kind of mistake only the type checker catches. */\nexport const Tooltip = Base.Root\n\n/** What it labels. Give it `render` to use your own button - and give that\n * button an `aria-label` saying what the tooltip says, because the tooltip\n * itself reaches nobody using a screen reader. */\nexport const TooltipTrigger = Base.Trigger\n\nexport interface TooltipPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof tooltipPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit,\n * and defaults it to the top. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. Base UI centres it by default. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Whether to draw the arrow pointing back at the trigger. */\n arrow?: boolean\n /** Where to portal to. Defaults to the document body
|
|
2219
|
+
"content": "import { Tooltip as Base } from '@base-ui/react/tooltip'\nimport { cva, type VariantProps } from 'class-variance-authority'\nimport { cn } from 'dowel-ui'\nimport { usePopupContainer } from './layer'\n\n/*\n * Tooltip.\n *\n * A label for a control that has no room for one - an icon button, a truncated\n * cell, a symbol whose meaning is not obvious. A phrase, not a panel.\n *\n * The line between this and Popover is not size, it is whether anything inside\n * can be reached. A tooltip holds no links, no buttons and no fields, because\n * there is no way to get into it: it is tied to a trigger that is hovered or\n * focused, and it disappears the moment attention moves. Content that has to\n * be clicked belongs in a Popover, whatever its length.\n *\n * The half everyone forgets is the keyboard. A tooltip that only opens on\n * hover is invisible to anyone who tabs, which is precisely the person reading\n * an unlabelled icon button. Base UI opens it on focus as well, and `Escape`\n * dismisses it - so it is tested here rather than assumed.\n *\n * The thing to know before using it: this is a VISUAL label, and nothing else.\n * Base UI puts no `role=\"tooltip\"` on the popup and no `aria-describedby` on\n * the trigger, and that is deliberate rather than an oversight - a tooltip is\n * unreachable on a touch screen and unreliable for a screen reader, so\n * pretending otherwise would be worse than not trying. What follows from that\n * is a rule, not a suggestion: THE TRIGGER MUST CARRY ITS OWN `aria-label`,\n * saying roughly what the tooltip says. The tooltip helps a sighted mouse or\n * keyboard user; the `aria-label` is what everybody else gets.\n *\n * So if the words are load-bearing - if not reading them means not\n * understanding the control - this is the wrong component. Put them inline, or\n * in a Popover with `openOnHover` on the trigger, which touch and screen\n * readers can actually reach.\n *\n * `Provider` is optional and shared: once one tooltip in a group has opened,\n * the next opens instantly instead of waiting out its delay again. A toolbar\n * of icon buttons without it feels broken in a way nobody can name.\n */\n\nexport const tooltipPopupVariants = cva(\n [\n 'rounded-md border border-line bg-raise px-2 py-1 text-xs text-text shadow-raise',\n 'select-none',\n // The enter and the leave. `duration-*` reads the token directly because\n // Tailwind's own utility takes a literal number.\n '[transition:opacity_var(--duration-quick)_var(--ease-out),transform_var(--duration-quick)_var(--ease-out)]',\n 'data-[closed]:scale-[0.96] data-[closed]:opacity-0',\n 'data-[starting-style]:scale-[0.96] data-[starting-style]:opacity-0',\n // Grow out of the edge it is anchored to rather than out of its own\n // middle, so the motion points back at the trigger.\n 'origin-[var(--transform-origin)]',\n ],\n {\n variants: {\n /*\n * Two, and no more. A tooltip is a phrase; the only real decision is\n * whether it is allowed to wrap.\n *\n * `wide` exists because the alternative people reach for is a Popover\n * that nothing can be clicked in, which loses the hover and focus\n * behaviour to gain a width.\n */\n size: {\n sm: 'max-w-[16rem]',\n wide: 'max-w-[24rem]',\n },\n },\n defaultVariants: { size: 'sm' },\n },\n)\n\n/** A shared delay for a group of tooltips. Wrap a toolbar in it and the second\n * icon button explains itself instantly rather than making the reader wait\n * again. Optional - a lone tooltip works without one. */\nexport const TooltipProvider = Base.Provider\n\n/** The root. Takes `disabled`, and the controlled `open`/`onOpenChange`.\n *\n * Note that `delay` is NOT here - it is a prop of the trigger, the same as on\n * PreviewCard. Passing it to the root is silently ignored at runtime, which is\n * exactly the kind of mistake only the type checker catches. */\nexport const Tooltip = Base.Root\n\n/** What it labels. Give it `render` to use your own button - and give that\n * button an `aria-label` saying what the tooltip says, because the tooltip\n * itself reaches nobody using a screen reader. */\nexport const TooltipTrigger = Base.Trigger\n\nexport interface TooltipPopupProps\n extends Base.Popup.Props,\n VariantProps<typeof tooltipPopupVariants> {\n /** Preferred side of the trigger. Base UI flips it when it does not fit,\n * and defaults it to the top. */\n side?: Base.Positioner.Props['side']\n /** Alignment along that side. Base UI centres it by default. */\n align?: Base.Positioner.Props['align']\n /** Distance from the trigger, in pixels. */\n sideOffset?: Base.Positioner.Props['sideOffset']\n /** Whether to draw the arrow pointing back at the trigger. */\n arrow?: boolean\n /** Where to portal to. Defaults to the raised host of the overlay this is\n * opened inside (`layer.tsx`), and to the document body when there is none -\n * either way not the element it was opened from, whose `overflow` would clip\n * it. Pass an element to put it somewhere else, such as a container being\n * screenshotted. */\n container?: Base.Portal.Props['container']\n}\n\n/** The label itself. Portalled and positioned, so it is not clipped by an\n * ancestor with `overflow: hidden`.\n *\n * `--z-popup` rather than `--z-floating`: a tooltip labels whatever is on top\n * of it, including the contents of a popover or a dialog, so it has to be able\n * to sit above them. */\nexport function TooltipPopup({\n size,\n side,\n align,\n sideOffset = 6,\n arrow = true,\n container,\n className,\n children,\n ...props\n}: TooltipPopupProps) {\n // Inside an overlay, the overlay's raised host rather than the body - or\n // this popup draws under the dialog, drawer or popover that opened it. See\n // `layer.tsx`. Outside every overlay the hook gives `undefined`: the body.\n const host = usePopupContainer()\n\n return (\n <Base.Portal container={container ?? host}>\n <Base.Positioner\n side={side}\n align={align}\n sideOffset={sideOffset}\n className=\"[z-index:var(--z-popup)]\"\n >\n <Base.Popup className={cn(tooltipPopupVariants({ size }), className)} {...props}>\n {arrow ? <TooltipArrow /> : null}\n {children}\n </Base.Popup>\n </Base.Positioner>\n </Base.Portal>\n )\n}\n\n/** The notch pointing back at the trigger. Base UI rotates it to whatever side\n * the tooltip landed on, which is why the placement is keyed off `data-side`\n * rather than off the `side` that was asked for. */\nexport function TooltipArrow({ className, ...props }: Base.Arrow.Props) {\n return (\n <Base.Arrow\n className={cn(\n 'h-1.5 w-1.5 rotate-45 border border-line bg-raise',\n /* Two of the four borders are dropped per side, which Popover has done\n * all along and this did not.\n *\n * A square rotated 45 degrees shows two of its edges outside the\n * popup: the pair facing the trigger, which is the notch, and the\n * pair behind it, which is a stray line hanging off the far side. It\n * reads as a second arrow pointing the wrong way - and it is small\n * enough that it looked like a rendering artefact rather than a rule\n * nobody wrote. */\n 'data-[side=bottom]:-top-hair data-[side=bottom]:border-r-0 data-[side=bottom]:border-b-0',\n 'data-[side=top]:-bottom-hair data-[side=top]:border-t-0 data-[side=top]:border-l-0',\n 'data-[side=left]:-right-hair data-[side=left]:border-b-0 data-[side=left]:border-l-0',\n 'data-[side=right]:-left-hair data-[side=right]:border-r-0 data-[side=right]:border-t-0',\n className,\n )}\n {...props}\n />\n )\n}\n"
|
|
2184
2220
|
}
|
|
2185
2221
|
]
|
|
2186
2222
|
},
|
|
@@ -2207,7 +2243,7 @@
|
|
|
2207
2243
|
"description": "Two products had written this independently and arrived at the same construction - a rounded track, segments positioned absolutely by percent, a floor under the segment width so a short one does not vanish - differing only in what a segment meant. One drew the tiers of a rubric with the score standing among them; the other drew a working day as alternating work and breaks. Neither could be built from the other, and each knew something the other did not: the tiers had the marker and the three-state reading of a segment (passed, standing in, still ahead), the day had the minimum width and the difference between an empty track and an unknown one.",
|
|
2208
2244
|
"dependencies": [
|
|
2209
2245
|
"class-variance-authority",
|
|
2210
|
-
"dowel-ui@^0.
|
|
2246
|
+
"dowel-ui@^0.32.0"
|
|
2211
2247
|
],
|
|
2212
2248
|
"registryDependencies": [
|
|
2213
2249
|
"https://lacodda.github.io/dowel/r/track-segments.json"
|
|
@@ -2243,7 +2279,7 @@
|
|
|
2243
2279
|
"title": "TreeView",
|
|
2244
2280
|
"description": "The shape products reach for and then get wrong in the same place every time. A tree is not a nest of lists with click handlers - it is one control with a cursor in it, and the difference is the whole component:\n * **One tab stop, not one per node.** A tree of four hundred files with a `tabIndex` on each is four hundred stops between the sidebar and the editor. The container is what the keyboard reaches, and the arrows move a cursor inside it - the arrangement a `RadioGroup` has, for the same reason.",
|
|
2245
2281
|
"dependencies": [
|
|
2246
|
-
"dowel-ui@^0.
|
|
2282
|
+
"dowel-ui@^0.32.0"
|
|
2247
2283
|
],
|
|
2248
2284
|
"registryDependencies": [
|
|
2249
2285
|
"https://lacodda.github.io/dowel/r/tree-rows.json"
|
|
@@ -2263,7 +2299,7 @@
|
|
|
2263
2299
|
"title": "Truncate",
|
|
2264
2300
|
"description": "Text that does not fit, cut with an ellipsis - and, importantly, still readable in full: the element carries its own text as a `title`, so hovering shows what was cut. Every product wrote the one-line version of this and none of them remembered the title.",
|
|
2265
2301
|
"dependencies": [
|
|
2266
|
-
"dowel-ui@^0.
|
|
2302
|
+
"dowel-ui@^0.32.0"
|
|
2267
2303
|
],
|
|
2268
2304
|
"registryDependencies": [],
|
|
2269
2305
|
"files": [
|
|
@@ -2281,7 +2317,7 @@
|
|
|
2281
2317
|
"title": "VirtualList",
|
|
2282
2318
|
"description": "The browser is fine with long lists until it is not: a hundred thousand `<div>`s is a layout the machine recomputes on every change, and the page stops responding while it does. What is drawn instead is the window the reader can actually see, held in place by a tall spacer, so the scrollbar still says how much there is.",
|
|
2283
2319
|
"dependencies": [
|
|
2284
|
-
"dowel-ui@^0.
|
|
2320
|
+
"dowel-ui@^0.32.0"
|
|
2285
2321
|
],
|
|
2286
2322
|
"registryDependencies": [],
|
|
2287
2323
|
"files": [
|
|
@@ -2300,7 +2336,7 @@
|
|
|
2300
2336
|
"description": "With `decorations: false` the system draws nothing, so everything it used to do is the page's: dragging the window by its title bar, double-click to maximise, the three buttons, and the edges you grab to resize. Each is small; the reason to take them on at all is that a system title bar over an application title bar costs a strip of every laptop screen for nothing.",
|
|
2301
2337
|
"dependencies": [
|
|
2302
2338
|
"@tauri-apps/api",
|
|
2303
|
-
"dowel-ui@^0.
|
|
2339
|
+
"dowel-ui@^0.32.0"
|
|
2304
2340
|
],
|
|
2305
2341
|
"registryDependencies": [],
|
|
2306
2342
|
"files": [
|
|
@@ -2318,7 +2354,7 @@
|
|
|
2318
2354
|
"title": "Wizard",
|
|
2319
2355
|
"description": "A Stepper with the current step's content under it and the Back / Next / Finish row that walks through the steps - checking each one before it lets the user past. The Stepper alone shows progress; this is the form that makes it, and a product that only needs the picture should not install the form.",
|
|
2320
2356
|
"dependencies": [
|
|
2321
|
-
"dowel-ui@^0.
|
|
2357
|
+
"dowel-ui@^0.32.0"
|
|
2322
2358
|
],
|
|
2323
2359
|
"registryDependencies": [
|
|
2324
2360
|
"https://lacodda.github.io/dowel/r/button.json",
|
|
@@ -2348,6 +2384,7 @@
|
|
|
2348
2384
|
"https://lacodda.github.io/dowel/r/drawer.json",
|
|
2349
2385
|
"https://lacodda.github.io/dowel/r/input.json",
|
|
2350
2386
|
"https://lacodda.github.io/dowel/r/kbd.json",
|
|
2387
|
+
"https://lacodda.github.io/dowel/r/layer.json",
|
|
2351
2388
|
"https://lacodda.github.io/dowel/r/menu.json",
|
|
2352
2389
|
"https://lacodda.github.io/dowel/r/panel.json",
|
|
2353
2390
|
"https://lacodda.github.io/dowel/r/select.json",
|
|
@@ -2373,6 +2410,7 @@
|
|
|
2373
2410
|
"https://lacodda.github.io/dowel/r/field.json",
|
|
2374
2411
|
"https://lacodda.github.io/dowel/r/file-drop.json",
|
|
2375
2412
|
"https://lacodda.github.io/dowel/r/input.json",
|
|
2413
|
+
"https://lacodda.github.io/dowel/r/layer.json",
|
|
2376
2414
|
"https://lacodda.github.io/dowel/r/number-field.json",
|
|
2377
2415
|
"https://lacodda.github.io/dowel/r/password-field.json",
|
|
2378
2416
|
"https://lacodda.github.io/dowel/r/radio-group.json",
|
|
@@ -2395,6 +2433,8 @@
|
|
|
2395
2433
|
"https://lacodda.github.io/dowel/r/alert.json",
|
|
2396
2434
|
"https://lacodda.github.io/dowel/r/banner.json",
|
|
2397
2435
|
"https://lacodda.github.io/dowel/r/confirm-dialog.json",
|
|
2436
|
+
"https://lacodda.github.io/dowel/r/dialog.json",
|
|
2437
|
+
"https://lacodda.github.io/dowel/r/layer.json",
|
|
2398
2438
|
"https://lacodda.github.io/dowel/r/toast.json"
|
|
2399
2439
|
],
|
|
2400
2440
|
"docs": "Which of the four to reach for is the harder question: see https://lacodda.github.io/dowel/guides/overlays/"
|