@reqvire-org/ads 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/ads-errors.mjs +33 -26
  2. package/dist/analysis/design-usage.mjs +4 -20
  3. package/dist/analysis/mock-check.mjs +4 -5
  4. package/dist/analysis/owner-accessibility.mjs +4 -4
  5. package/dist/analysis/owner-analysis-key.mjs +1 -1
  6. package/dist/analysis/owner-choices.mjs +33 -3
  7. package/dist/analysis/owner-composition.mjs +61 -12
  8. package/dist/analysis/owner-source.mjs +52 -35
  9. package/dist/composed-contrast.mjs +143 -62
  10. package/dist/construction-output.mjs +6 -1
  11. package/dist/construction-spec.d.mts +53 -44
  12. package/dist/construction-spec.mjs +64 -76
  13. package/dist/corner-overpaint.mjs +5 -4
  14. package/dist/design-foundation.mjs +16 -0
  15. package/dist/design-usage.mjs +2 -8
  16. package/dist/emit/emission.mjs +0 -5
  17. package/dist/grid-lowering.mjs +3 -1
  18. package/dist/lowering-enter.mjs +6 -6
  19. package/dist/lowering-session.mjs +10 -0
  20. package/dist/mcp/server-observation.mjs +6 -4
  21. package/dist/mcp/server-project.mjs +4 -1
  22. package/dist/owner-analysis-check.mjs +4 -1
  23. package/dist/owner-errors.mjs +2 -1
  24. package/dist/owner-lowering.mjs +10 -4
  25. package/dist/owner-scenarios.mjs +2 -22
  26. package/dist/ownership-model.mjs +7 -5
  27. package/dist/paint-contrast.mjs +6 -0
  28. package/dist/profile-macro.d.mts +7 -0
  29. package/dist/recipe-macro.d.mts +46 -42
  30. package/dist/recipe-model.mjs +12 -11
  31. package/dist/region-lowering.mjs +54 -109
  32. package/dist/role-vocabulary.d.mts +4 -0
  33. package/dist/role-vocabulary.mjs +4 -0
  34. package/dist/runtime-paint-contrast.mjs +5 -2
  35. package/dist/showcase/client.bundle.js +48 -48
  36. package/dist/showcase/http-client.bundle.js +13 -13
  37. package/dist/showcase/ui/ui.css +1 -1
  38. package/dist/showcase/ui/ui.js +5 -5
  39. package/dist/skills/ads-designer/references/accessibility.md +3 -4
  40. package/dist/skills/ads-designer/references/design-data.md +12 -6
  41. package/dist/skills/ads-designer/references/layout.md +7 -3
  42. package/dist/skills/ads-designer/references/motion.md +2 -1
  43. package/dist/skills/ads-designer/references/recipes.md +28 -18
  44. package/dist/skills/ads-import/references/design-data.md +12 -6
  45. package/dist/skills/ads-import/references/layout.md +7 -3
  46. package/dist/skills/ads-import/references/recipes.md +28 -18
  47. package/dist/skills/ads-migrate/SKILL.md +1 -0
  48. package/dist/skills/ads-migrate/references/0.5.2-to-0.5.3.md +71 -0
  49. package/dist/skills/ads-port/references/design-data.md +12 -6
  50. package/dist/skills/ads-port/references/layout.md +7 -3
  51. package/dist/skills/ads-port/references/recipes.md +28 -18
  52. package/dist/spatial-model.mjs +2 -2
  53. package/dist/surface-contrast.mjs +6 -2
  54. package/dist/target-size.mjs +21 -3
  55. package/docs/ADS.md +9 -3
  56. package/docs/ARCHITECTURE.md +33 -23
  57. package/docs/CACHING.md +1 -1
  58. package/docs/CHANGELOG.md +128 -21
  59. package/docs/GUIDE.md +64 -19
  60. package/docs/LANGUAGE.md +141 -134
  61. package/docs/MCP.md +5 -1
  62. package/docs/MOTION.md +5 -2
  63. package/docs/PROFILE-KINDS.md +46 -4
  64. package/docs/RULES.md +16 -15
  65. package/package.json +1 -1
  66. package/dist/analysis/prose-owners.mjs +0 -57
  67. package/dist/prose-model.d.mts +0 -81
  68. package/dist/prose-model.mjs +0 -101
package/docs/RULES.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <!-- Generated by scripts/sync-rule-reference.mjs from src/ads-errors.mts and src/finding-rules.mts. Do not edit: run `bun run sync:rule-reference`. -->
4
4
 
5
- Every rule ADS reports, under its rule group: 433 rules in 18 groups. A finding names its rule as a code,
5
+ Every rule ADS reports, under its rule group: 434 rules in 18 groups. A finding names its rule as a code,
6
6
  `<domain>/<kind>`; the `check/<rule>` codes are the rules `ads check`, `ads validate`, the render audit and acceptance
7
7
  report by their plain name (`check/a11y-reflow` is the finding `a11y-reflow`).
8
8
 
@@ -18,14 +18,14 @@ Fix findings in group order: earlier groups are often the cause of later ones. T
18
18
  | 1 | [syntax](#syntax) | 11 | violated | The source does not parse or type-check. | Fix these first and accept again: analysis needs a valid program, and later errors may be consequences. |
19
19
  | 2 | [unresolved-reference](#unresolved-reference) | 39 | violated | The source names something that does not exist in this revision. | Correct the name from the existing candidates. Declare a new one only when it is genuinely new design. |
20
20
  | 3 | [boundary](#boundary) | 30 | violated | Code reaches across an ownership or production/development boundary. | Move the code to its owner or pass the value through public props. Do not add an exception or widen the boundary. |
21
- | 4 | [design-bypass](#design-bypass) | 21 | violated | Styling or design values are supplied outside the design language. | Take the value from a profile, token or recipe instead of writing it in place. |
21
+ | 4 | [design-bypass](#design-bypass) | 20 | violated | Styling or design values are supplied outside the design language. | Take the value from a profile, token or recipe instead of writing it in place. |
22
22
  | 5 | [structure-mismatch](#structure-mismatch) | 47 | violated | Rendered markup does not match what its declaration promises. | Make the markup match the declaration: each declared part, cell and binding exactly once, in the declared order. Change the declaration only if it is wrong. |
23
- | 6 | [accessibility-semantics](#accessibility-semantics) | 38 | violated | Owned markup or motion lacks required accessible semantics: a text alternative, an accessible name, keyboard access or reduced motion. | Add the missing semantics in the owning component (alt, aria-label, a native control, a reduced-motion value); do not suppress the check. |
23
+ | 6 | [accessibility-semantics](#accessibility-semantics) | 37 | violated | Owned markup or motion lacks required accessible semantics: a text alternative, an accessible name, keyboard access or reduced motion. | Add the missing semantics in the owning component (alt, aria-label, a native control, a reduced-motion value); do not suppress the check. |
24
24
  | 7 | [project-files](#project-files) | 6 | violated | A required project file or declaration is missing, empty, undocumented or unused. | Add or complete the file the rule names (README, license, theme or brand values), or remove what nothing uses. |
25
25
  | 8 | [wrong-value](#wrong-value) | 72 | violated | A value has the wrong kind, role or range for where it is used. | Choose one of the allowed values the error lists. |
26
- | 9 | [conflict](#conflict) | 38 | violated | Two definitions claim the same thing, or a definition depends on itself. | Keep exactly one source of truth and remove or derive the other. |
26
+ | 9 | [conflict](#conflict) | 40 | violated | Two definitions claim the same thing, or a definition depends on itself. | Keep exactly one source of truth and remove or derive the other. |
27
27
  | 10 | [unanalyzable](#unanalyzable) | 45 | unprovable | ADS cannot prove the rule holds; the design itself may be fine. | Rewrite into a form ADS can follow (literal unions, const records, typed props, JSX) without changing rendered behavior. |
28
- | 11 | [unsupported](#unsupported) | 16 | unprovable | The construct is valid design that ADS does not support yet. | Use a supported alternative. If none fits, report the gap rather than working around the checks. |
28
+ | 11 | [unsupported](#unsupported) | 17 | unprovable | The construct is valid design that ADS does not support yet. | Use a supported alternative. If none fits, report the gap rather than working around the checks. |
29
29
  | 12 | [rendered-check](#rendered-check) | 13 | violated | The rendered result breaks an accessibility, layout, contrast or performance requirement. | Inspect the failing scenario in its audit result or capture, then fix the owning style or markup; do not change the scenario to hide it. |
30
30
  | 13 | [behavior-failed](#behavior-failed) | 4 | violated | A registered behavior guarantee failed or could not run. | Read the failing run with ads_results and ads_investigate, then fix the owner's behavior; keep the guarantee unless it is wrong. |
31
31
  | 14 | [evidence-missing](#evidence-missing) | 12 | rerun | Required evidence is absent or belongs to another revision. | Run the named check (ads_validate, ads_accept dryRun or the preview build) for the current revision; do not edit source to satisfy it. |
@@ -151,7 +151,6 @@ Styling or design values are supplied outside the design language. Take the valu
151
151
  | `mock/hidden-definition` | error | A mock hides no design definitions in strings: no recipe or profile directives and no custom-property references. | Remove the definition; design belongs in owners, profiles and token sheets. | `ads://guides/scenarios`, `ads://guides/tokens` |
152
152
  | `mock/imperative-design` | error | A mock writes no styles and creates no DOM imperatively. | Remove the imperative write; render owners with props. | `ads://guides/scenarios` |
153
153
  | `mock/local-markup` | error | A mock's JSX renders what it imports from the design system (`@ds`), components and patterns alike: no native elements or local components laying out or wrapping them. | Render public owners directly; an arrangement the screen needs belongs in a pattern. | `ads://guides/scenarios`, `ads://guides/layout` |
154
- | `mock/prose-element-undeclared` | error | Plain flow markup inside a prose owner (a component whose recipe has `layout: "prose"`) is that owner's content. Each element used there is one the recipe declares in `elements`; an element it does not declare would be drawn without a design. | Declare the element in the owner's prose recipe (`elements`), or write the content with the elements it declares. | `ads://guides/scenarios`, `ads://guides/recipes` |
155
154
  | `rejection/profile-value-required` | error | Owner design comes from a profile, not from literals or tokens written in place. | Take the value from a profile field. | `ads://guides/recipes`, `ads://guides/tokens` |
156
155
  | `source/class-expression-incomplete` | error | A className is built only from recipe outputs, at most one placement and declared asset bindings. | Remove free class strings and conditions; express the styling in the recipe. | `ads://guides/recipes`, `ads://guides/atomic-styles` |
157
156
  | `source/css-in-js-import` | error | Styling exists only in owners, and owners style only through their recipes: no design-system file imports a CSS-in-JS package. | Remove the import and move the styling into a recipe in an owner. | `ads://guides/recipes`, `ads://guides/layers` |
@@ -183,7 +182,7 @@ Rendered markup does not match what its declaration promises. Make the markup ma
183
182
  | `check/token-selector-invalid` | error | Token sheets declare tokens only in token contexts: :root, :root[data-theme="<name>"], :root[data-brand="<name>"] or both, directly or inside @media, @supports or @layer. A rule under any other selector forms no context: its values would be left out of every check and emitted as written. | Move the declaration into a :root, theme or brand rule (under @media or @supports for a condition); style a selector in a recipe instead. | `ads://guides/tokens` |
184
183
  | `check/token-sheet-property` | error | Token sheets declare tokens only: custom properties (--name). A declaration of an ordinary CSS property (`:root { color: red }`) is no token, belongs to no role and styles outside every recipe; ADS does not read it as a token. | Remove the declaration. Style an element through its recipe, and the document through foundation({ text, surface }); a value meant to be shared is a token (--name) of its role. | `ads://guides/tokens` |
185
184
  | `choice/no-reachable-choice` | error | Every styled selection renders in at least one reachable state. | Check the conditions guarding the element; remove dead branches or the unreachable styling. | `ads://guides/recipes` |
186
- | `construction/artwork-binding-missing` | error | An artwork construction binds its visual part to a declared asset. | Bind the visual part to a declared asset. | `ads://guides/branding`, `ads://guides/pictograms` |
185
+ | `construction/artwork-binding-missing` | error | An artwork construction binds its visual part to a declared asset. | Bind the visual part to a declared asset and name its visual profile in the binding: recipe({ parts: { visual: { kind: "visual", asset: "<asset>", visual: "<visual profile>" } } }). | `ads://guides/branding`, `ads://guides/pictograms` |
187
186
  | `construction/content-missing` | error | A control renders text or artwork in every reachable choice, so it is never empty. | Give every choice a text part or an artwork part. | `ads://guides/recipes`, `ads://guides/accessibility` |
188
187
  | `construction/cover-box-missing` | error | A cropped image (a visual part whose visual profile declares `fit: "cover"`) fills a box of its own: it is a top-level part of a region whose frame declares a `ratio` or whose frame profile fixes its `blockSize`. The frame has the shape; the image is cropped inside it. | Declare `frame: { ratio: "16 / 9" }` (a ratio the spatial profile permits) on the recipe whose top-level visual part crops, or use a visual profile with `fit: "contain"`. | `ads://guides/recipes`, `ads://guides/layout` |
189
188
  | `construction/extent-row-hugs` | error | An inline row is as wide as its content unless its recipe declares `extent: "container"`; a part can fill only a row that takes its container's width. | Declare `extent: "container"` on the row's recipe so it takes its container's width, or remove the part's `extent`. | `ads://guides/recipes`, `ads://guides/layout` |
@@ -198,7 +197,7 @@ Rendered markup does not match what its declaration promises. Make the markup ma
198
197
  | `source/align-rows-mismatch` | error | A grid aligns only the rows a public component exposes, in the order it exposes them. | Align only the rows the component exposes, in its order, or expose the rows from the component. | `ads://guides/layout` |
199
198
  | `source/artwork-mismatch` | error | A visual part renders the drawing its binding selects. | Render the drawing selected by the binding; do not swap in another asset or literal markup. | `ads://guides/branding`, `ads://guides/pictograms` |
200
199
  | `source/artwork-source-undeclared` | error | Inline artwork renders its bound drawing's SVG through a single `dangerouslySetInnerHTML.__html`. | Render the bound drawing's SVG text with a single `__html` property on the visual part. | `ads://guides/branding`, `ads://guides/pictograms` |
201
- | `source/cell-missing-or-repeated` | error | Each declared grid cell renders exactly once. | Render each declared grid cell exactly once. | `ads://guides/layout` |
200
+ | `source/cell-missing-or-repeated` | error | Each declared grid cell renders exactly once; a cell declared `required: false` may be absent, and one declared `repeat: true` (or auto-placed at every tier) renders any number of times. | Render the cell exactly once, declare it `required: false` when it may be absent, or `repeat: true` when it renders once per item of a list. | `ads://guides/layout` |
202
201
  | `source/data-theme-mismatch` | error | An element's data-theme matches the theme its construction declares. | Set data-theme to the theme the construction declares. | `ads://guides/tokens` |
203
202
  | `source/glyph-source-form` | error | A set-bound part renders `dangerouslySetInnerHTML={{ __html: recipe.assets.<part>.source[name] }}`; a reference-bound part renders `{{ __html: glyph.source }}` of the glyph reference it receives. | Render the bound drawing in that exact form; select nothing else with the name or the reference. | `ads://guides/pictograms` |
204
203
  | `source/grid-container-missing` | error | A grid in container context (`context: "container"`) responds to the nearest `ads-region` size container, so an owned ancestor in the same owner starts one: a region framed `container: "region"` (a container is element-owned, never a cell's). Without one its tier rules never match and only the smallest tier applies, wherever the component is placed. | Frame an owned ancestor of the grid with `frame: { container: "region" }` (a wrapper whose width is the region the grid should follow), or use `context: "viewport"`. A container a consumer renders around the component, or one inside a public component it is passed to, does not count. | `ads://guides/recipes`, `ads://guides/layout` |
@@ -209,7 +208,7 @@ Rendered markup does not match what its declaration promises. Make the markup ma
209
208
  | `source/layer-in-grid-cell` | error | A top-layer root is not a grid cell: whenever it is open it leaves the grid for the top layer. | Render the layer root as an uncelled child (or outside the grid), and keep an in-track alternative as its own cell. | `ads://guides/recipes`, `ads://guides/layout` |
210
209
  | `source/markers-shared` | error | One element carries one part or cell marker; distinct markers are lowered as distinct elements. | Use one element per declared part or cell; wrap to separate them. | `ads://guides/recipes`, `ads://guides/layout` |
211
210
  | `source/part-element-mismatch` | error | A region or part that declares a native element renders that element (an input of the declared type), and a vector part is an SVG shape directly under an owned `<svg>`. | Render the declared element for this part, or declare the element it actually renders. | `ads://guides/recipes` |
212
- | `source/part-missing-or-repeated` | error | Each declared part renders exactly once per choice; optional parts are declared as not required. | Render the part exactly once per choice, or mark it as not required in the spec. | `ads://guides/recipes` |
211
+ | `source/part-missing-or-repeated` | error | Each declared part renders exactly once per choice; optional parts are declared as not required, and a part rendered once per item of a list (`items.map(…)`) is declared `repeat: true`. | Render the part exactly once per choice, mark it as not required in the spec, or declare it `repeat: true` when it renders once per item of a list. | `ads://guides/recipes` |
213
212
  | `source/part-selector-unresolved` | error | Every declared part is rendered by an element carrying the part's marker. | Mark the element that renders the part with the part's declared selector. | `ads://guides/recipes`, `ads://guides/contracts` |
214
213
  | `source/placement-repeated` | error | An element has at most one placement. | Give each element exactly one placement; combine positions into one placement value. | `ads://guides/layout` |
215
214
  | `source/placement-without-root` | error | A placement positions a styled root; an element with a placement also carries its own recipe styling. | Add the element's recipe output beside its placement, or move the placement to the styled root. | `ads://guides/layout` |
@@ -232,7 +231,7 @@ Owned markup or motion lacks required accessible semantics: a text alternative,
232
231
  | `check/a11y-keyboard` | review | An onClick on a non-interactive element (div, span, li, img and similar) without role and tabIndex cannot be reached or used from the keyboard (WCAG 2.2 2.1.1), unless a delegated or wrapping control handles it. Composite-widget items and backdrops whose handler reads currentTarget are exempt. | Use a <button> for the action, or add role, tabIndex and a key handler to the element. | `ads://guides/accessibility` |
233
232
  | `check/a11y-motion-endless` | info | A recipe root, a part or an artwork that plays a repeating sequence whenever it is rendered is noted: motion that starts by itself, runs longer than five seconds and is shown beside other content must be pausable, stoppable or hideable (WCAG 2.2 2.2.2), and the owner has no state to stop this one by. Reduced motion stops it only for users who set that preference. | Play the sequence under an owner state the user can end, or render the part only while the work it stands for is in progress. | `ads://guides/accessibility` |
234
233
  | `check/component-contrast` | error | Text meets WCAG 2.2 AA (4.5:1, or 3:1 where its text profile is provably large) against the backdrop it is rendered on: the nearest opaque background of the elements and owners around it, across files, with translucent backgrounds and known gradients composited, in every theme, brand and condition context. A public component is also placed by applications on the document surface foundation.ads.ts declares. | Choose a surface for the text whose colour contrasts with the surface it is rendered on, render the component on another surface, use large text where 3:1 suffices, or adjust the token in the named context. | `ads://guides/accessibility`, `ads://guides/tokens` |
235
- | `check/surface-contrast` | error | A surface profile that sets both color and background meets WCAG 2.2 AA for text, 4.5:1, in every context (theme, brand, brand under theme and condition); its background-image gradient stops count as backgrounds. The minimum follows what the colour paints where the profile is used: a pair below 4.5:1 is accepted when every use of the profile in the design system is artwork (a visual part, or a control that renders no text: 3:1, WCAG 1.4.11), large text (at least 24px, or 18.66px at weight 700: 3:1) or artwork hidden from assistive technology (decoration: no minimum). A profile nothing uses, one a slot supplies, the document surface, and one the recipe also names for a pseudo-element, a prose element, a backdrop or an entrance keep 4.5:1. | Adjust the colour or background token's value in the named context (or point the profile at a pair that contrasts), keeping the pair at 4.5:1 or more; a colour meant for artwork at 3:1 belongs to a surface profile that only visual parts or text-less controls select. A surface that paints a disabled element declares `state: "inactive"` among its fields: it has no minimum (WCAG 1.4.3 exempts inactive components) and may then be selected only under `:disabled` or `[aria-disabled="true"]`. | `ads://guides/accessibility`, `ads://guides/tokens` |
234
+ | `check/surface-contrast` | error | A surface profile that sets both color and background meets WCAG 2.2 AA for text, 4.5:1, in every context (theme, brand, brand under theme and condition); its background-image gradient stops count as backgrounds. The minimum follows what the colour paints where the profile is used: a pair below 4.5:1 is accepted when every use of the profile in the design system is artwork (a visual part, or a control that renders no text: 3:1, WCAG 1.4.11), large text (at least 24px, or 18.66px at weight 700: 3:1) or artwork hidden from assistive technology (decoration: no minimum). A fully transparent colour draws nothing and has no minimum in the contexts where it is transparent (a glyph a control shows only on hover); the states that show it keep theirs. A profile nothing uses, one a slot supplies, the document surface, and one the recipe also names for a pseudo-element, a backdrop or an entrance keep 4.5:1. | Adjust the colour or background token's value in the named context (or point the profile at a pair that contrasts), keeping the pair at 4.5:1 or more; a colour meant for artwork at 3:1 belongs to a surface profile that only visual parts or text-less controls select. A surface that paints a disabled element declares `state: "inactive"` among its fields: it has no minimum (WCAG 1.4.3 exempts inactive components) and may then be selected only under `:disabled` or `[aria-disabled="true"]`. | `ads://guides/accessibility`, `ads://guides/tokens` |
236
235
  | `construction/accessibility-declaration-unmet` | error | An `accessibility` declaration is verified where ADS can: `"boundary-on-interaction"` needs a hover treatment of the control part whose border, drawn at the frame's width, reaches 3:1 against the surroundings in every context (the focus outline is held to 3:1 as always); `"visible-label"` needs a programmatically associated, rendered label (checked by the render audit). | Make the declared identification real (a hover border at 3:1, a visible associated label), or remove the declaration and give the control a 3:1 boundary or fill. | `ads://guides/recipes`, `ads://guides/accessibility` |
237
236
  | `construction/artwork-paint-contrast-insufficient` | error | A control's artwork with paint slots stays recognizable on the control: in every theme, brand and state, at least one of its paints reaches 3:1 against the control's own background (WCAG 1.4.11). A drawing with its own colours (`paint: "intrinsic"`, a product's logo) is not checked. | Give the drawing one paint that reaches 3:1 on that background in that context (an outline or a darker fill), or adjust the token's value there. | `ads://guides/pictograms`, `ads://guides/accessibility`, `ads://guides/tokens` |
238
237
  | `construction/inactive-surface-active` | error | A surface profile declaring `state: "inactive"` paints a disabled control: it has no contrast minimum (WCAG 2.2 1.4.3 exempts inactive components), so a construction selects it only under an inactive owner state (`:disabled`, `[aria-disabled="true"]`), never at rest or under another state. | Select it under `&:disabled` or `&[aria-disabled="true"]`, or use a surface without `state: "inactive"` (which is held to the contrast minimum). | `ads://guides/recipes`, `ads://guides/accessibility` |
@@ -240,10 +239,9 @@ Owned markup or motion lacks required accessible semantics: a text alternative,
240
239
  | `construction/paint-contrast-insufficient` | error | Every declared value of a runtime paint keeps its contrast against the background the construction knows, in every theme, brand and owner state: a `color` paint 4.5:1 (3:1 for provably large text, WCAG 2.2 1.4.3); a `fill`, `stroke` or `border-color` paint, and a `background-color` paint against its enclosing background, 3:1 (1.4.11); text on a painted background its text minimum. The set is finite, so one failing value fails whichever value data selects. | Adjust that token's value in the failing context, remove it from the paint's values, or place the element on a background it contrasts with. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/tokens` |
241
240
  | `construction/placeholder-contrast-insufficient` | error | Placeholder text has at least 4.5:1 contrast against its part's background in every theme, brand and state (WCAG 1.4.3). | Choose a placeholder surface whose colour token contrasts enough with the part's background in that context, or adjust the token's value there. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/tokens` |
242
241
  | `construction/progress-contrast-insufficient` | error | A progress bar's fill has at least 3:1 contrast against its track, the part's own background, in every theme, brand and state (WCAG 1.4.11). | Choose a fill surface whose background token contrasts enough with the part's own background in that context, or adjust the token's value there. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/tokens` |
243
- | `construction/prose-contrast-insufficient` | error | Text in prose reaches the contrast minimum (WCAG 2.2 1.4.3: 4.5:1, or 3:1 for provably large text) on every surface it can sit on, in every theme and brand: each declared element's colour on the prose root's background and on the background of each declared element that can contain it (a link in a quote, text in a table cell or a code block), in its base and state surfaces. | Change the element's colour or the surface it sits on until the pair passes in every theme and brand; give an element inside a tinted container (a quote, a code block) its own colour there by tinting the container's surface, not by a one-off value. | `ads://guides/accessibility`, `ads://guides/recipes` |
244
- | `construction/state-contrast-insufficient` | error | An element's owner states keep it readable (text 4.5:1 or 3:1 when large; a visual part's or a text-less control's artwork 3:1; artwork hidden from assistive technology has no minimum): where a state's colour meets a background from another surface profile (a colour-only state over the base fill, a state fill under the base colour), the pair has at least 4.5:1 contrast in every theme, brand and condition, or 3:1 where the element's text profile makes its text large there (at least 24px, or 18.66px at weight 700); a state that holds only while the element is inactive (:disabled, [aria-disabled="true"]) has no minimum (WCAG 2.2 1.4.3). Two states that cannot hold on one root together (two values of one attribute, a state and its :not(), :disabled and :enabled) are not paired. | Treat the state with a surface that sets both its colour and background, or choose colour and background tokens that contrast in that context. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/tokens` |
242
+ | `construction/state-contrast-insufficient` | error | An element's owner states keep it readable (text 4.5:1 or 3:1 when large; a visual part's or a text-less control's artwork 3:1; artwork hidden from assistive technology has no minimum, nor has a fully transparent colour, which draws nothing): where a state's colour meets a background from another surface profile (a colour-only state over the base fill, a state fill under the base colour), the pair has at least 4.5:1 contrast in every theme, brand and condition, or 3:1 where the element's text profile makes its text large there (at least 24px, or 18.66px at weight 700); a state that holds only while the element is inactive (:disabled, [aria-disabled="true"]) has no minimum (WCAG 2.2 1.4.3). Two states that cannot hold on one root together (two values of one attribute, a state and its :not(), :disabled and :enabled) are not paired. | Treat the state with a surface that sets both its colour and background, or choose colour and background tokens that contrast in that context. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/tokens` |
245
243
  | `construction/target-area-overlap` | error | The enlarged hit areas of neighbouring targets in a stack or inline arrangement do not overlap across their gap in any context: a press there would reach two targets (WCAG 2.2 2.5.8). | Widen the arrangement's gap to at least the hit areas' reach beyond the two boxes, or reduce the min-target sizes. | `ads://guides/recipes`, `ads://guides/accessibility` |
246
- | `construction/target-size-below-minimum` | error | Every control construction and `frame: "control"` part is a pointer target of at least 24 × 24 CSS px in every theme, brand and condition (WCAG 2.2 2.5.8), computed from its lowered box: min block = max(min-block-size, content + 2 (inset + border)), inline = 2 (padding-inline + border) + content; an enlarged hit area (min-target-inline-size, min-target-block-size) counts. Relative lengths are evaluated at the 16px reference root. | Raise the frame profile's min-block-size, padding-inline or the visual size in that context, or give the frame a min-target-inline-size / min-target-block-size hit area of at least 24px. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/tokens` |
244
+ | `construction/target-size-below-minimum` | error | Every control construction and `frame: "control"` part is a pointer target of at least 24 × 24 CSS px in every theme, brand and condition (WCAG 2.2 2.5.8), computed from its lowered box: min block = max(min-block-size, content + 2 (inset + border)), inline = 2 (padding-inline + border) + content; an enlarged hit area (min-target-inline-size, min-target-block-size) counts. Relative lengths are evaluated at the 16px reference root. The spacing exception holds for a smaller part of a stack or inline arrangement: a 24px circle centred on it reaches neither a neighbouring target's box nor, for a smaller neighbour, that neighbour's circle, at every gap the arrangement takes; a root or a part with no neighbouring target keeps the minimum. | Raise the frame profile's min-block-size, padding-inline or the visual size in that context, give the frame a min-target-inline-size / min-target-block-size hit area of at least 24px, or (for a part between targets) widen the arrangement's gap until 24px circles centred on the targets keep clear of each other. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/tokens` |
247
245
  | `review/accessibility-declaration-unnecessary` | review | An `accessibility` declaration covers a control that cannot pass 3:1; on a control whose boundary or fill already passes it is stale. | Remove the declaration. | `ads://guides/recipes`, `ads://guides/accessibility` |
248
246
  | `review/autocomplete-missing` | review | A text control whose name, id or type says what it collects states its autofill token (`autoComplete`, WCAG 1.3.5), so autofill and password managers fill it correctly; `autoComplete="off"` states that it must not be filled. ADS suggests the token from the literal attribute values, a heuristic. | Set `autoComplete` to the field's HTML autofill token (the message suggests one), or `"off"` when it must not be filled; on a public component, pass it through its `autoComplete` prop. Ignore this note when the suggestion is wrong. | `ads://guides/forms`, `ads://guides/accessibility` |
249
247
  | `review/boundary-identified-otherwise` | review | A text-entry control whose boundary is below 3:1 (WCAG 1.4.11) passes only with a human-approved `accessibility` declaration saying how it is identified otherwise; every such control is listed on every run, never silently. | Keep it only if a person approved it and the design still matches the reason. Otherwise make the control pass (a 3:1 fill, or one 3:1 border side such as a soft field's underline) and remove the declaration. | `ads://guides/recipes`, `ads://guides/accessibility`, `ads://guides/forms` |
@@ -287,7 +285,7 @@ A value has the wrong kind, role or range for where it is used. Choose one of th
287
285
  | --- | --- | --- | --- | --- |
288
286
  | `assets/set-member-paint` | error | Glyph set members are foreground artwork (paint "foreground"): the owner's text colour paints every member alike. | Bind slot or intrinsic artwork by name in its own recipe; keep the set to foreground glyphs. | `ads://guides/pictograms` |
289
287
  | `check/a11y-focus` | error | Focus stays visible (WCAG 2.2 2.4.7, 1.4.11). Every focus profile's width resolves to at least 2 CSS px in every context (theme, brand, brand under theme and condition; relative widths at the 16px reference root), and the document's default indicator (foundation({ focus }), which foundation.css paints on every :focus-visible element a construction does not style) has 3:1 contrast with the document surface's background in every context. | Raise the focus profile's width token to 2px or more, or choose a focus colour token that reaches 3:1 on the document surface in the named context. | `ads://guides/accessibility` |
290
- | `check/a11y-target-size` | error | Pointer targets are at least 24 × 24 CSS px (WCAG 2.2 2.5.8): every control construction and every frame: "control" part, computed from its lowered box in every theme, brand and condition (relative lengths at the 16px reference root), its enlarged hit area included; neighbouring hit areas in a stack or inline arrangement do not overlap. | Raise the frame profile's min-block-size, padding-inline or visual size in that context, or declare a min-target-inline-size / min-target-block-size hit area of at least 24px; widen the gap between overlapping hit areas. | `ads://guides/accessibility` |
288
+ | `check/a11y-target-size` | error | Pointer targets are at least 24 × 24 CSS px (WCAG 2.2 2.5.8): every control construction and every frame: "control" part, computed from its lowered box in every theme, brand and condition (relative lengths at the 16px reference root), its enlarged hit area included, or a smaller part spaced from its neighbouring targets so that 24px circles centred on them keep clear (the spacing exception); neighbouring hit areas in a stack or inline arrangement do not overlap. | Raise the frame profile's min-block-size, padding-inline or visual size in that context, or declare a min-target-inline-size / min-target-block-size hit area of at least 24px; widen the gap between overlapping hit areas. | `ads://guides/accessibility` |
291
289
  | `check/a11y-text-resize` | error | Text follows the reader's font size (WCAG 2.2 1.4.4): every font-size token, and every line-height token that is a length, resolves in every context to rem or em (or a calc(), min(), max() or clamp() containing them); a unitless line-height multiplier already scales. | Rewrite the named token in rem (px / 16) or em; for a line height, a unitless multiplier also works. | `ads://guides/accessibility` |
292
290
  | `check/app-icon-asset` | error | The asset foundation({ appIcon }) names is declared, has paint "intrinsic" (browsers, launchers and app stores cannot read CSS variables), is one scalable drawing and has a square viewBox; appIcon.background is a paint-role token that resolves to an opaque colour in the default theme and brand. | Name a declared intrinsic asset with a square viewBox (centre the artwork in it), and give background an opaque paint token. | `ads://guides/branding`, `ads://guides/pictograms` |
293
291
  | `check/app-icon-export` | error | Each appIcon export writes an .svg copy, a .png (size, or width and height), an .ico (sizes up to 256) or an .icns (sizes 16, 32, 64, 128, 256, 512, 1024) of a declared intrinsic asset, at a path inside the output folder that ADS does not write itself and no other export writes; sizes are 16–2048 px, and a background is an opaque paint-role token. | Fix the entry's file, sizing, asset or background as the message says. | `ads://guides/branding`, `ads://guides/pictograms` |
@@ -390,6 +388,7 @@ Two definitions claim the same thing, or a definition depends on itself. Keep ex
390
388
  | `fonts/family-duplicate` | error | Each font family is declared once in the design system, by one font() declaration; family names compare as CSS compares them (ASCII case-insensitively), and two families never share an emitted folder (fonts/<slug>). | Declare every face of the family in one font() declaration, or rename one family. | `ads://guides/performance` |
391
389
  | `foundation/profile-argument-default` | error | A profile's slot reference selects only choices that differ from the referenced profile's defaults: the plain name already selects every default. | Remove the redundant selection (reference the profile by its plain name when no other choice remains). | `ads://guides/recipes` |
392
390
  | `foundation/profile-duplicate` | error | Profile names are unique across the foundation. | Give each profile a unique name, or merge the declarations. | `ads://guides/recipes` |
391
+ | `foundation/provided-role-self` | error | A surface profile's `provides` re-binds tokens for the subtree of the element that takes it, the element itself included: a surface that provides a token its own fields read would repaint itself with the provided value. | Read another token in the surface's own fields, or provide a role the surface itself does not read (a link ink, an icon ink). | `ads://guides/tokens`, `ads://guides/recipes` |
393
392
  | `registration/alias-definition` | error | A registered token is defined by a concrete value, not as an alias of another token. | Define it with a concrete value, or remove the registration. | `ads://guides/tokens` |
394
393
  | `registration/anonymous-layer` | error | Token CSS uses named layers; each anonymous layer is a distinct layer. | Name the @layer, or remove it. | `ads://guides/tokens`, `ads://guides/atomic-styles` |
395
394
  | `registration/definition-mismatch` | error | A registered token's :root definition equals its registered initial value. | Make the :root definition and the @property initial-value equal. | `ads://guides/tokens` |
@@ -397,6 +396,7 @@ Two definitions claim the same thing, or a definition depends on itself. Keep ex
397
396
  | `registration/not-beside-token` | error | A token is registered in the file that defines it, so the definition and its registration change together. | Move the registration into the file that defines the token. | `ads://guides/tokens` |
398
397
  | `rejection/redundant-design-declaration` | error | A declaration states only what its default or input does not already provide. | Remove the declaration. | `ads://guides/recipes` |
399
398
  | `review/hover-geometry-shift` | review | Geometry an element in flow takes under `:hover` (another frame or spacing profile, a part that opens) moves what follows it whenever the pointer passes over it. ADS accepts it as the designer's choice and lists it for review; a layer of a layered parent draws over its neighbours instead and is not listed. | Keep it when the movement is wanted (a pile that spreads and pushes what follows). Otherwise draw the change over its neighbours: a layer of a layered parent, an outset backdrop, or a translate or scale effect, which move nothing else. | `ads://guides/recipes`, `ads://guides/layout` |
399
+ | `review/optional-cell-row` | review | A grid cell that may be absent (`required: false`) and is pinned to a row (`row`) leaves that row empty whenever it is absent: the row's track and the gaps around it stay. ADS accepts it as the designer's choice and lists it for review. | Keep it when the empty row is wanted. Otherwise place the cell in auto rows (omit `row`), so the cells after it move up when it is absent. | `ads://guides/recipes` |
400
400
  | `source/glyph-grid-mixed` | error | Every asset a reference binding can receive shares one grid (viewBox, optical center and minimum drawn height), so one construction draws them all. | Draw the glyphs on one viewBox with one optical center, or accept them through separate props or owners. | `ads://guides/pictograms` |
401
401
  | `source/layer-modal-context` | error | A modal sheet's `modalQuery` is a viewport media query, so the owner's layout swaps at viewport tiers too: no grid of the same owner responds to a container. | Use `context: "viewport"` for the owner's grids, or keep the sheet modal at every size (no `modalBelow`). | `ads://guides/recipes`, `ads://guides/layout` |
402
402
  | `source/local-name-collision` | error | Names of the form compiledClassN are reserved for ADS's emitted output. | Rename the local identifier. | `ads://guides/recipes` |
@@ -424,7 +424,7 @@ ADS cannot prove the rule holds; the design itself may be fine. Rewrite into a f
424
424
  | `choice/binding-written` | error | Values that select design are immutable after declaration, so one declaration describes every use. | Declare it with const and derive new values into new bindings instead of reassigning. | `ads://guides/recipes` |
425
425
  | `choice/branch-limit` | error | Choice analysis is bounded; a selection must stay small enough to be checked completely. | Every listed value multiplies the combinations checked. Make fewer of them select styling or markup together: replace conditional chains with one lookup over a const record keyed by the selecting value, merge props that always change together, or move a part with its own props into its own owner. | `ads://guides/recipes` |
426
426
  | `choice/construction-limit` | error | An owner lowers a bounded number of distinct constructions. | Collapse equivalent combinations, or move independent variation into separate parts so constructions do not multiply. | `ads://guides/recipes`, `ads://guides/performance` |
427
- | `choice/domain-not-finite` | error | Design is selected from a finite set of choices ADS can enumerate, so every rendered combination can be checked. | Type the selecting prop or variable as a literal union (or a const record key) so every choice can be enumerated. An optional object, callback or node prop selects by whether it is given: test a node (or any type that admits text, a number or a boolean) with `!== undefined`, never by truthiness. | `ads://guides/recipes`, `ads://guides/atomic-styles` |
427
+ | `choice/domain-not-finite` | error | Design is selected from a finite set of choices ADS can enumerate, so every rendered combination can be checked. | Type the selecting prop or variable as a literal union (or a const record key) so every choice can be enumerated. A decision made from data (a count, an element, a lookup) is named as design state: `const overflow: "fits" \| "overflows" = members.length > 3 ? …`, or `const fourth: Member \| undefined = members[3]`. An optional object, callback or node prop selects by whether it is given: test a node (or any type that admits text, a number or a boolean) with `!== undefined`, never by truthiness. | `ads://guides/recipes`, `ads://guides/atomic-styles` |
428
428
  | `choice/evidence-not-local` | error | Design evidence comes from the owner's source or the design system's own modules. | Bring the value into the owner's source as a const or prop, or import it from the design system's own modules. | `ads://guides/recipes`, `ads://guides/layers` |
429
429
  | `choice/key-not-literal` | error | Design records are indexed by literal or finite union-typed keys. | Index design records with a literal union-typed value (for example a variant prop), not an arbitrary string. | `ads://guides/recipes` |
430
430
  | `choice/property-unresolved` | error | Design values resolve to literals or const references inside the design system. | Make the property a literal or a const reference ADS can follow within the design system. | `ads://guides/recipes` |
@@ -470,6 +470,7 @@ The construct is valid design that ADS does not support yet. Use a supported alt
470
470
  | `construction/measured-property-unsupported` | error | A measured value sets one geometry property of its type's closed list: a `length` a logical inset or box size (inline/block size and their min/max) on a region root or top-level part, a `transform` `translate`, a `size-track` one track of a grid's own `grid-template-columns`/`-rows`. An `intrinsic-size` sets `inline-size` on a contained application image (`fit: "contain"`). A `position` sets `object-position` on a cropped application image (a visual part whose visual profile declares `fit: "cover"`). Padding, margin, gap, typography, borders, radius and paint are design values; a top-layer root is positioned by measured values only with `placement: "measured"`. | Measure a property of the closed list (`inset-*`, `inline-size`, `block-size` and their min/max, `translate`, a grid track that exists in every tier); declare `placement: "measured"` for an element-anchored popover; move design values to profiles. | `ads://guides/recipes`, `ads://guides/layout` |
471
471
  | `construction/paint-property-unsupported` | error | A runtime paint sets one property of the closed paint list (`fill`, `stroke`, `color`, `background-color`, `border-color`), once per element: backgrounds as images, gradients, outlines and shadows are design values. | Paint `fill`, `stroke`, `color`, `background-color` or `border-color`, one paint per property and element; keep other paint values in surface profiles. | `ads://guides/recipes`, `ads://guides/tokens` |
472
472
  | `construction/paint-transition-effect-unsupported` | error | What changes between a transitioned element's surfaces interpolates. A gradient image never does, so such an element has none. A surface effect does through its own channel: `filter` for `blur`, `shapeShadow` and `groupShadow`, `backdrop-filter` for `backdropBlur` and `backdropSaturate`. An effect that changes between the surfaces without its channel listed would snap while the paints transition. | Add `filter` or `backdrop-filter` to the transition's `channels` for an effect that changes, use surfaces without a gradient image on a transitioned element, or remove its paint transition. | `ads://guides/recipes` |
473
+ | `construction/space-parent-unsupported` | error | A part states its own space before or after (`spaceBefore`, `spaceAfter`) only in a `stack`, where it replaces the stack's gap on that side, or in the block flow of a parent without an arrangement (a list item); the larger of one part's space after and the next part's space before applies. | Arrange the parent as a stack, or remove `spaceBefore` / `spaceAfter` (an inline row or a grid spaces its children evenly). | `ads://guides/recipes`, `ads://guides/layout` |
473
474
  | `construction/spatial-clause-unsupported` | error | Layouts are expressed with the supported spatial clauses. | Express the layout with the supported spatial clauses. | `ads://guides/layout` |
474
475
  | `lowering/tree-unsupported` | error | Owner styling uses CSS constructs ADS can lower. | Rewrite the construct with supported styling, or report the missing support. | `ads://guides/atomic-styles` |
475
476
  | `registration/wrapper-unsupported` | error | @property registrations sit at the top level or inside @media, @supports or @layer. | Move the registration to the top level. | `ads://guides/tokens`, `ads://guides/atomic-styles` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reqvire-org/ads",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "type": "module",
5
5
  "description": "A design system your agent can see and shape. Your components. Your look. Your code.",
6
6
  "repository": {
@@ -1,57 +0,0 @@
1
- import path from "node:path";
2
- import { isCallExpression, isExportDeclaration, isIdentifier, isNamedExports, isObjectLiteralExpression, isPropertyAssignment, isStringLiteral } from "typescript/ast";
3
- import { PROSE_ELEMENT_NAMES, proseContentTags } from "../prose-model.mjs";
4
- import { inRevision, sourceAst } from "./helpers.mjs";
5
- import { PUBLIC_BARREL } from "./owner-source.mjs";
6
- export const NO_PROSE = new Map;
7
- const walk = (node, visit) => {
8
- visit(node);
9
- node.forEachChild((child) => walk(child, visit));
10
- }, propertyName = (node) => isPropertyAssignment(node) ? isIdentifier(node.name) || isStringLiteral(node.name) ? node.name.text : null : null;
11
- export function proseTags(source) {
12
- let names = null;
13
- walk(source, (node) => {
14
- if (!isCallExpression(node) || !isIdentifier(node.expression) || node.expression.text !== "recipe")
15
- return;
16
- const [spec] = node.arguments;
17
- if (spec === void 0 || !isObjectLiteralExpression(spec))
18
- return;
19
- const property = (name) => spec.properties.find((item) => propertyName(item) === name), layout = property("layout");
20
- if (layout === void 0 || !isPropertyAssignment(layout) || !isStringLiteral(layout.initializer) || layout.initializer.text !== "prose")
21
- return;
22
- names ??= new Set;
23
- const elements = property("elements");
24
- if (elements === void 0 || !isPropertyAssignment(elements) || !isObjectLiteralExpression(elements.initializer))
25
- return;
26
- for (const element of elements.initializer.properties) {
27
- const name = propertyName(element);
28
- if (name !== null && PROSE_ELEMENT_NAMES.includes(name))
29
- names.add(name);
30
- }
31
- });
32
- return names === null ? null : proseContentTags(names);
33
- }
34
- const resolved = (from, specifier) => {
35
- const target = path.resolve(path.dirname(from), specifier);
36
- return [`${target}.tsx`, `${target}.ts`, path.join(target, "index.tsx"), path.join(target, "index.ts"), target].find((candidate) => /\.tsx?$/.test(candidate) && inRevision(candidate)) ?? null;
37
- };
38
- export async function publicProse(dsRoot) {
39
- const barrel = path.join(dsRoot, PUBLIC_BARREL);
40
- if (!inRevision(barrel))
41
- return NO_PROSE;
42
- const owners = new Map;
43
- for (const statement of (await sourceAst(barrel)).statements) {
44
- if (!isExportDeclaration(statement) || statement.isTypeOnly || statement.moduleSpecifier === void 0 || !isStringLiteral(statement.moduleSpecifier))
45
- continue;
46
- const clause = statement.exportClause;
47
- if (clause === void 0 || !isNamedExports(clause) || !statement.moduleSpecifier.text.startsWith("."))
48
- continue;
49
- const file = resolved(barrel, statement.moduleSpecifier.text), tags = file === null ? null : proseTags(await sourceAst(file));
50
- if (tags === null)
51
- continue;
52
- for (const element of clause.elements)
53
- if (!element.isTypeOnly && /^[A-Z]/.test(element.name.text))
54
- owners.set(element.name.text, tags);
55
- }
56
- return owners;
57
- }
@@ -1,81 +0,0 @@
1
- /** A prose element's name in a recipe, with the tags it selects. */
2
- export declare const PROSE_ELEMENTS: {
3
- readonly paragraph: readonly ["p"];
4
- readonly heading1: readonly ["h1"];
5
- readonly heading2: readonly ["h2"];
6
- readonly heading3: readonly ["h3"];
7
- readonly heading4: readonly ["h4"];
8
- readonly heading5: readonly ["h5"];
9
- readonly heading6: readonly ["h6"];
10
- readonly list: readonly ["ul", "ol"];
11
- readonly item: readonly ["li"];
12
- readonly quote: readonly ["blockquote"];
13
- readonly rule: readonly ["hr"];
14
- readonly pre: readonly ["pre"];
15
- readonly table: readonly ["table"];
16
- readonly headerCell: readonly ["th"];
17
- readonly cell: readonly ["td"];
18
- readonly figure: readonly ["figure"];
19
- readonly caption: readonly ["figcaption"];
20
- readonly media: readonly ["img", "video", "iframe"];
21
- readonly descriptions: readonly ["dl"];
22
- readonly term: readonly ["dt"];
23
- readonly definition: readonly ["dd"];
24
- readonly link: readonly ["a"];
25
- readonly strong: readonly ["strong", "b"];
26
- readonly emphasis: readonly ["em", "i"];
27
- readonly deleted: readonly ["del", "s"];
28
- readonly code: readonly ["code"];
29
- readonly sub: readonly ["sub"];
30
- readonly sup: readonly ["sup"];
31
- readonly kbd: readonly ["kbd"];
32
- readonly mark: readonly ["mark"];
33
- };
34
- export type ProseElementName = keyof typeof PROSE_ELEMENTS;
35
- export declare const PROSE_ELEMENT_NAMES: readonly ProseElementName[];
36
- /** Every tag prose styles, with the element it belongs to. */
37
- export declare const PROSE_TAGS: ReadonlyMap<string, ProseElementName>;
38
- /**
39
- * Tags that carry no design of their own but are part of content: a table's row groups and rows belong
40
- * to its `table` element, and a line break belongs to any prose. The markup checks accept them as
41
- * content; no rule is written for them.
42
- */
43
- export declare const PROSE_STRUCTURE: ReadonlyMap<string, ProseElementName | null>;
44
- /** Whether a tag can be content of a prose owner: a styled tag or a structural one. */
45
- export declare const isProseTag: (tag: string) => boolean;
46
- /** The content tags a recipe that declares `names` accepts: their own tags, and the structure that comes with them. */
47
- export declare function proseContentTags(names: Iterable<ProseElementName>): ReadonlySet<string>;
48
- /** Elements that stand as blocks in the flow: they take the rhythm before them. */
49
- export declare const PROSE_BLOCKS: readonly ProseElementName[];
50
- /** The elements whose text can sit directly inside `container`: what its background must carry. */
51
- export declare function proseContents(container: ProseElementName): readonly ProseElementName[];
52
- /** The selector of one tag inside the prose root: plain markup only. */
53
- export declare const proseSelector: (tag: string) => string;
54
- /** `&:hover` on an element's selector: the state is the element's own. */
55
- export declare const proseState: (selector: string, condition: string) => string;
56
- /** The first plain element of the root and of a plain container: its start margin is cancelled. */
57
- export declare const PROSE_FIRST: readonly string[];
58
- /**
59
- * A component placed directly in the prose root (it has a class) is a block of the flow like any
60
- * other: it takes the rhythm before it, unless it comes first. Space between siblings is the
61
- * container's to give; the component's own design is untouched. A component inside a paragraph or
62
- * another plain element is inline content and is left alone.
63
- */
64
- export declare const PROSE_COMPONENT = "& > :not(:first-child)[class]";
65
- type Values = Readonly<Record<string, string>>;
66
- /**
67
- * The browser defaults ADS replaces on an element, whatever the recipe declares for it: margins
68
- * (the rhythm owns the space between blocks), a quote's and a figure's indent, a rule's inset border,
69
- * media wider than its column, a table's doubled borders.
70
- */
71
- export declare function proseDefaults(name: ProseElementName): Values;
72
- /**
73
- * The emitted record of a design system's prose owners, beside its public entry: exported name → the
74
- * plain tags its recipe declares. The design-use check of application source reads it, because an
75
- * emitted owner no longer carries its recipe.
76
- */
77
- export declare const PROSE_MANIFEST = "ads-prose.json";
78
- export declare const proseManifestText: (owners: ReadonlyMap<string, ReadonlySet<string>>) => string;
79
- /** The owners a manifest text records; entries that are not a list of prose tags are dropped. */
80
- export declare function parseProseManifest(text: string): ReadonlyMap<string, ReadonlySet<string>>;
81
- export {};
@@ -1,101 +0,0 @@
1
- export const PROSE_ELEMENTS = {
2
- paragraph: ["p"],
3
- heading1: ["h1"],
4
- heading2: ["h2"],
5
- heading3: ["h3"],
6
- heading4: ["h4"],
7
- heading5: ["h5"],
8
- heading6: ["h6"],
9
- list: ["ul", "ol"],
10
- item: ["li"],
11
- quote: ["blockquote"],
12
- rule: ["hr"],
13
- pre: ["pre"],
14
- table: ["table"],
15
- headerCell: ["th"],
16
- cell: ["td"],
17
- figure: ["figure"],
18
- caption: ["figcaption"],
19
- media: ["img", "video", "iframe"],
20
- descriptions: ["dl"],
21
- term: ["dt"],
22
- definition: ["dd"],
23
- link: ["a"],
24
- strong: ["strong", "b"],
25
- emphasis: ["em", "i"],
26
- deleted: ["del", "s"],
27
- code: ["code"],
28
- sub: ["sub"],
29
- sup: ["sup"],
30
- kbd: ["kbd"],
31
- mark: ["mark"]
32
- }, PROSE_ELEMENT_NAMES = Object.keys(PROSE_ELEMENTS), PROSE_TAGS = new Map(PROSE_ELEMENT_NAMES.flatMap((name) => PROSE_ELEMENTS[name].map((tag) => [tag, name]))), PROSE_STRUCTURE = new Map([
33
- ["thead", "table"],
34
- ["tbody", "table"],
35
- ["tfoot", "table"],
36
- ["tr", "table"],
37
- ["br", null]
38
- ]), isProseTag = (tag) => PROSE_TAGS.has(tag) || PROSE_STRUCTURE.has(tag);
39
- export function proseContentTags(names) {
40
- const declared = new Set(names), tags = new Set([...declared].flatMap((name) => PROSE_ELEMENTS[name]));
41
- for (const [tag, owner] of PROSE_STRUCTURE)
42
- if (owner === null || declared.has(owner))
43
- tags.add(tag);
44
- return tags;
45
- }
46
- export const PROSE_BLOCKS = ["paragraph", "heading1", "heading2", "heading3", "heading4", "heading5", "heading6", "list", "quote", "rule", "pre", "table", "figure", "descriptions"];
47
- const INLINE = ["link", "strong", "emphasis", "deleted", "code", "sub", "sup", "kbd", "mark"], FLOW_CONTAINERS = ["item", "quote", "cell", "headerCell", "figure", "definition"];
48
- export function proseContents(container) {
49
- if (FLOW_CONTAINERS.includes(container))
50
- return PROSE_ELEMENT_NAMES.filter((name) => name !== container || container === "item" || container === "quote");
51
- if (container === "list")
52
- return ["item"];
53
- if (container === "table")
54
- return ["headerCell", "cell", "caption"];
55
- if (container === "descriptions")
56
- return ["term", "definition"];
57
- if (container === "rule" || container === "media")
58
- return [];
59
- if (container === "pre")
60
- return ["code"];
61
- if (container === "code")
62
- return [];
63
- return INLINE.filter((name) => name !== container);
64
- }
65
- export const proseSelector = (tag) => `& ${tag}:not([class])`, proseState = (selector, condition) => `${selector}${condition.slice(1)}`, PROSE_FIRST = ["& > :first-child:not([class])", "& :not([class]) > :first-child:not([class])"], PROSE_COMPONENT = "& > :not(:first-child)[class]";
66
- export function proseDefaults(name) {
67
- switch (name) {
68
- case "quote":
69
- case "figure":
70
- return { "margin-inline-start": "0", "margin-inline-end": "0" };
71
- case "definition":
72
- return { "margin-inline-start": "0" };
73
- case "rule":
74
- return { "border-top-width": "0", "border-right-width": "0", "border-bottom-width": "0", "border-left-width": "0" };
75
- case "media":
76
- return { "max-inline-size": "100%", "block-size": "auto" };
77
- case "table":
78
- return { "border-collapse": "collapse" };
79
- case "pre":
80
- return { overflow: "auto hidden" };
81
- default:
82
- return {};
83
- }
84
- }
85
- export const PROSE_MANIFEST = "ads-prose.json", proseManifestText = (owners) => `${JSON.stringify(Object.fromEntries([...owners].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name, tags]) => [name, [...tags].sort()])), null, 2)}
86
- `;
87
- export function parseProseManifest(text) {
88
- const owners = new Map;
89
- let value;
90
- try {
91
- value = JSON.parse(text);
92
- } catch {
93
- return owners;
94
- }
95
- if (typeof value !== "object" || value === null || Array.isArray(value))
96
- return owners;
97
- for (const [name, tags] of Object.entries(value))
98
- if (Array.isArray(tags))
99
- owners.set(name, new Set(tags.filter((tag) => typeof tag === "string" && isProseTag(tag))));
100
- return owners;
101
- }