@reqvire-org/ads 0.3.50 → 0.3.51

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 (34) hide show
  1. package/README.md +1 -1
  2. package/dist/browser-audit/first-render.mjs +18 -0
  3. package/dist/browser-audit/layout-overflow.mjs +80 -39
  4. package/dist/browser-audit/worker.mjs +16 -8
  5. package/dist/browser-audit.mjs +52 -11
  6. package/dist/capture/worker.mjs +2 -5
  7. package/dist/check.mjs +5 -3
  8. package/dist/cli.mjs +3 -2
  9. package/dist/config.mjs +2 -2
  10. package/dist/finding-rules.mjs +5 -0
  11. package/dist/layout-widths.mjs +123 -79
  12. package/dist/skills/ads-break-ui/SKILL.md +2 -1
  13. package/dist/skills/ads-break-ui/references/design-data.md +27 -14
  14. package/dist/skills/ads-break-ui/references/validation.md +1 -1
  15. package/dist/skills/ads-designer/SKILL.md +6 -4
  16. package/dist/skills/ads-designer/references/design-data.md +27 -14
  17. package/dist/skills/ads-designer/references/validation.md +1 -1
  18. package/dist/skills/ads-import/references/design-data.md +27 -14
  19. package/dist/skills/ads-import/references/validation.md +1 -1
  20. package/dist/skills/ads-motion/references/design-data.md +27 -14
  21. package/dist/skills/ads-motion/references/validation.md +1 -1
  22. package/dist/skills/ads-port/references/design-data.md +27 -14
  23. package/dist/skills/ads-port/references/validation.md +1 -1
  24. package/dist/starters/preact/ds.config.json +0 -1
  25. package/dist/starters/react/README.md +6 -4
  26. package/dist/starters/react/design-system/components/Content/Image/Image.tsx +7 -4
  27. package/dist/starters/react/design-system/components/Content/Image/README.md +2 -2
  28. package/dist/starters/react/design-system/tokens/spacing.css +1 -1
  29. package/dist/starters/react/ds.config.json +0 -1
  30. package/docs/ADS.md +2 -2
  31. package/docs/ARCHITECTURE.md +9 -6
  32. package/docs/CHANGELOG.md +47 -12
  33. package/docs/GUIDE.md +50 -20
  34. package/package.json +1 -1
@@ -2,30 +2,30 @@ import valueParser from "postcss-value-parser";
2
2
  import { contextValues } from "./themes.mjs";
3
3
  import { findingSeverity } from "./finding-rules.mjs";
4
4
 
5
- /** Widths are fluid on the grid. In component, pattern and composition styles, a width (width,
6
- * min-/max-width, the logical inline sizes, flex-basis or the flex shorthand's basis, and
7
- * grid-template-columns tracks) is a layout-fixed-width error when it resolves to a fixed length
8
- * above 48 px: raw, through tokens, or by arithmetic on spacing tokens. 48 px is the top of the
9
- * control-height and icon range, so anything wider is a layout width rather than a part's size.
10
- * A flex item that both grows and shrinks is fluid whatever its basis.
11
- * Fluid values pass: %, fr, font-relative measures (ch, em, ex, lh), viewport and container
12
- * units, sizing keywords, and min()/max()/clamp()/calc() with a fluid part. Tokens named by
13
- * layout.widthTokens pass; each must be defined fluidly, except a fixed --container-* or
14
- * --content-max token, a cap, which passes as max-width or max-inline-size only. The size families of
15
- * fixed-size parts pass (sizeFamilies). Owners matched by layout.fixedWidthUnits, which is where
16
- * overlays such as dialogs, menus, popovers and tooltips are declared, are not checked: ADS
17
- * knows a unit's layer, not whether it floats. */
5
+ /** In component, pattern and composition styles, a width (width, min-width, the logical inline
6
+ * sizes, flex-basis or the flex shorthand's basis, and grid-template-columns tracks) is a
7
+ * layout-fixed-width error when it cannot shrink below smallPartLimitPx: raw, through tokens, in
8
+ * any length unit, or by arithmetic. Every value is read as what it resolves to in the smallest
9
+ * and the largest container, so max(100%, 280px) is fixed at 280px, and min(100%, 280px) is not.
10
+ * A maximum cannot force overflow, so max-width and max-inline-size are not read at all, except
11
+ * that a fluid one in the same rule lets a width shrink.
12
+ * What the source cannot settle (a variable with no definition) passes; the audit renders it.
13
+ * Tokens named by layout.widthTokens pass when used plainly, and fixed ones are listed for review,
14
+ * as are the fixed widths of owners matched by layout.fixedWidthUnits, which is where overlays
15
+ * such as dialogs, menus, popovers and tooltips are declared: ADS knows a unit's layer, not
16
+ * whether it floats. */
18
17
 
19
- export const fixedWidthLimitPx = 48;
20
- const widthProperties = new Set(["width", "max-width", "min-width", "inline-size", "max-inline-size", "min-inline-size", "flex-basis", "flex", "grid-template-columns"]);
21
- const capProperties = new Set(["max-width", "max-inline-size"]);
22
- const capToken = /^--container-|^--content-max$/;
23
- /** Token families that size a part, not a layout: exempt wherever they are used. */
24
- export const sizeFamilies = /^--(?:icon|control|avatar|border|focus|ring|radius|side-pane|toast)-|^--(?:navigation-rail-width|app-header-height|row-height-compact|compact-column-min)$/;
25
- const fluidUnits = /^(?:%|fr|ch|em|ex|cap|ic|lh|rlh|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))$/i;
26
- const absoluteUnits = { px: 1, rem: 16, pt: 4 / 3, pc: 16, in: 96, cm: 96 / 2.54, mm: 96 / 25.4, q: 96 / 101.6 };
18
+ /** The largest plain size a part may have: see the Layout section of the guide for the evidence. */
19
+ export const smallPartLimitPx = 96;
20
+ const widthProperties = new Set(["width", "min-width", "inline-size", "min-inline-size", "flex-basis", "flex", "grid-template-columns"]);
21
+ const fluidUnits = /^(?:%|fr|[sld]?v(?:w|h|i|b|min|max)|cq(?:w|h|i|b|min|max))$/i;
22
+ /** Lengths in px; a font-relative one at the 16 px root font, as an estimate. It is still fixed. */
23
+ const absoluteUnits = { px: 1, pt: 4 / 3, pc: 16, in: 96, cm: 96 / 2.54, mm: 96 / 25.4, q: 96 / 101.6 };
24
+ const fontUnits = { rem: 16, em: 16, ic: 16, ch: 8, ex: 8, cap: 11, lh: 24, rlh: 24 };
27
25
  const keywords = /^(?:auto|none|min-content|max-content|fit-content|stretch|inherit|initial|unset|revert|revert-layer|content|subgrid)$/i;
28
- const fluid = { fluid: true }, neutral = { neutral: true }, unknown = { unknown: true };
26
+ const fluid = { low: 0, high: Infinity }, neutral = { neutral: true }, unknown = { unknown: true };
27
+ const isLength = part => part.low !== undefined;
28
+ const fixedAt = px => ({ low: px, high: px });
29
29
 
30
30
  /** A regular expression for a token or path glob: * within a path segment, ** across them. */
31
31
  export function globPattern(glob) {
@@ -44,54 +44,72 @@ function splitArguments(nodes) {
44
44
  export function createLayoutWidths(tokens, { themes, layout }) {
45
45
  const values = contextValues(tokens, { theme: themes[0].name, themes });
46
46
  const widthToken = globMatcher(layout.widthTokens);
47
- const isFluid = (name, value) => sequence(valueParser(value).nodes, { seen: new Set([name]), locals: new Map() }).fluid === true;
48
- /** A named width token is allowed; only a fixed --container-* cap is limited to max sizes. */
49
- const cap = name => capToken.test(name) && values.has(name) && !isFluid(name, values.get(name).value);
47
+ const declaredUses = new Map();
50
48
 
51
49
  function variable(node, scope) {
52
50
  const [name, fallback = []] = splitArguments(node.nodes).map(meaningful);
53
51
  const token = name?.find(child => child.type === "word")?.value;
54
52
  if (!token?.startsWith("--")) return unknown;
55
- if (widthToken(token)) return cap(token) ? { cap: token } : neutral;
56
- if (sizeFamilies.test(token)) return neutral;
57
53
  if (scope.seen.has(token)) return unknown;
58
54
  const seen = new Set([...scope.seen, token]);
59
55
  // Component variables declared in the same template are read through, so a width cannot hide in one.
60
56
  const local = scope.locals.get(token);
61
- if (local) return local.map(value => sequence(valueParser(value).nodes, { ...scope, seen })).find(result => result.px !== undefined) ?? unknown;
57
+ if (local) {
58
+ const results = local.map(value => sequence(valueParser(value).nodes, { ...scope, seen })).filter(isLength);
59
+ return results.length ? results.reduce((worst, result) => result.low > worst.low ? result : worst) : unknown;
60
+ }
62
61
  const value = values.get(token)?.value;
63
62
  if (value === undefined) return fallback.length ? sequence(fallback, { ...scope, seen }) : unknown;
64
63
  const result = sequence(valueParser(value).nodes, { ...scope, seen });
65
- return token.startsWith("--space-") && result.px !== undefined ? { ...result, space: true } : result;
64
+ if (!widthToken(token)) return result;
65
+ scope.declared?.add(token);
66
+ return { ...(isLength(result) ? result : neutral), declared: token };
66
67
  }
67
- /** One value part: { fluid } | { neutral } | { unknown } | { cap } | { number } | { px, space?, math? }. */
68
+ /** One value part: { neutral } | { unknown } | { number } | { low, high, declared? }, the length
69
+ * it resolves to in the smallest and the largest container. */
68
70
  function measure(node, scope) {
69
71
  if (node.type === "word") {
70
72
  const parsed = valueParser.unit(node.value);
71
73
  if (!parsed) return keywords.test(node.value) ? neutral : unknown;
72
74
  const number = Number(parsed.number), unit = parsed.unit.toLowerCase();
73
- if (!unit) return { number };
74
- if (number === 0 || fluidUnits.test(unit)) return number === 0 ? neutral : fluid;
75
- return absoluteUnits[unit] ? { px: number * absoluteUnits[unit] } : unknown;
75
+ if (!unit) return number === 0 ? fixedAt(0) : { number };
76
+ if (number === 0) return fixedAt(0);
77
+ if (fluidUnits.test(unit)) return fluid;
78
+ const size = absoluteUnits[unit] ?? fontUnits[unit];
79
+ return size ? fixedAt(number * size) : unknown;
76
80
  }
77
81
  if (node.type !== "function") return unknown;
78
82
  const name = node.value.toLowerCase();
79
83
  if (name === "var") return variable(node, scope);
80
84
  if (name === "calc" || name === "") return calculation(node.nodes, scope);
81
85
  if (name === "fit-content") return neutral;
82
- if (!["min", "max", "clamp"].includes(name)) return unknown;
83
- const parts = splitArguments(node.nodes).map(part => sequence(part, scope));
84
- if (parts.some(part => part.fluid)) return fluid;
85
- if (parts.some(part => part.px === undefined)) return unknown;
86
- const lengths = parts.map(part => part.px);
87
- const px = name === "min" ? Math.min(...lengths) : name === "max" ? Math.max(...lengths) : Math.max(lengths[0], Math.min(lengths[1], lengths[2] ?? Infinity));
88
- return { px, space: parts.some(part => part.space), math: parts.some(part => part.math) };
86
+ if (name === "min") return smallest(splitArguments(node.nodes).map(part => sequence(part, scope)));
87
+ if (name === "max") return largest(splitArguments(node.nodes).map(part => sequence(part, scope)));
88
+ if (name !== "clamp") return unknown;
89
+ const [floor, preferred, ceiling] = splitArguments(node.nodes).map(part => sequence(part, scope));
90
+ if (floor?.neutral) return ceiling?.neutral || !ceiling ? preferred ?? unknown : smallest([preferred, ceiling]);
91
+ return largest([floor, !ceiling || ceiling.neutral ? preferred : smallest([preferred, ceiling])]);
92
+ }
93
+ /** min(): a part that reaches zero lets the whole shrink, whatever the others are. */
94
+ function smallest(parts) {
95
+ const lengths = parts.filter(isLength), open = lengths.length !== parts.length;
96
+ if (!lengths.length || open && !lengths.some(part => part.low === 0)) return unknown;
97
+ return { low: Math.min(...lengths.map(part => part.low)), high: open ? Infinity : Math.min(...lengths.map(part => part.high)) };
98
+ }
99
+ /** max(): it cannot shrink below any part, so a part that cannot be read leaves it unread. */
100
+ function largest(parts) {
101
+ if (!parts.every(isLength)) return unknown;
102
+ return { low: Math.max(...parts.map(part => part.low)), high: Math.max(...parts.map(part => part.high)) };
89
103
  }
90
104
  function sequence(nodes, scope) {
91
105
  const items = meaningful(nodes);
92
106
  return items.length === 1 ? measure(items[0], scope) : unknown;
93
107
  }
94
- /** calc(): fluid when any term is; otherwise its fixed result, marked as arithmetic. */
108
+ const scaled = (length, factor) => {
109
+ const [low, high] = [length.low, length.high].map(size => factor === 0 ? 0 : size * factor);
110
+ return factor < 0 ? { low: high, high: low } : { low, high };
111
+ };
112
+ /** calc(): evaluated at both ends, so 100% - 200px reaches zero and 100% + 200px does not. */
95
113
  function calculation(nodes, scope) {
96
114
  const operands = [], operators = [];
97
115
  for (const item of meaningful(nodes)) {
@@ -101,83 +119,109 @@ export function createLayoutWidths(tokens, { themes, layout }) {
101
119
  // valueParser keeps * and calc()'s / in a word, spaced or not.
102
120
  for (const part of item.value.split(/([*/])/).filter(Boolean)) { if (part === "*" || part === "/") operators.push(part); else operands.push(measure({ type: "word", value: part }, scope)); }
103
121
  }
104
- if (operands.some(operand => operand.fluid)) return fluid;
105
- if (operands.length !== operators.length + 1 || operands.some(operand => operand.px === undefined && operand.number === undefined)) return unknown;
122
+ if (operands.length !== operators.length + 1 || operands.some(operand => !isLength(operand) && operand.number === undefined)) return unknown;
106
123
  // Multiplication and division bind first.
107
124
  const terms = [operands[0]], signs = [];
108
125
  operators.forEach((operator, index) => {
109
126
  const next = operands[index + 1];
110
127
  if (operator !== "*" && operator !== "/") { terms.push(next); signs.push(operator); return; }
111
- const last = terms.pop(), length = last.px ?? next.px, factor = last.px === undefined ? last.number : next.number;
112
- if (length === undefined) terms.push({ number: operator === "*" ? last.number * next.number : last.number / next.number });
113
- else terms.push({ px: operator === "*" ? length * factor : length / factor });
128
+ const last = terms.pop(), length = isLength(last) ? last : next, factor = isLength(last) ? next.number : last.number;
129
+ if (!isLength(length)) terms.push({ number: operator === "*" ? last.number * next.number : last.number / next.number });
130
+ else if (factor === undefined) terms.push(unknown);
131
+ else terms.push(scaled(length, operator === "*" ? factor : 1 / factor));
132
+ });
133
+ if (!terms.every(isLength)) return unknown;
134
+ let { low, high } = terms[0];
135
+ terms.slice(1).forEach((term, index) => {
136
+ if (signs[index] === "+") { low += term.low; high += term.high; } else { low -= term.high; high -= term.low; }
114
137
  });
115
- if (terms.some(term => term.px === undefined)) return unknown;
116
- const px = terms.slice(1).reduce((sum, term, index) => signs[index] === "+" ? sum + term.px : sum - term.px, terms[0].px);
117
- return { px, space: operands.some(operand => operand.space), math: operators.length > 0 };
138
+ return { low: Math.max(low, 0), high: Math.max(high, 0) };
118
139
  }
119
- /** The sizes of a grid-template-columns value, through repeat() and minmax()'s maximum. */
140
+ /** The sizes of a grid-template-columns value. minmax() can shrink to its minimum, and a track
141
+ * repeated with auto-fill or auto-fit wraps instead of forcing overflow. */
120
142
  function tracks(nodes, scope) {
121
143
  const sizes = [];
122
144
  for (const node of meaningful(nodes)) {
123
145
  const name = node.type === "function" ? node.value.toLowerCase() : "";
124
146
  if (node.type === "word" && node.value.startsWith("[")) continue;
125
- if (name === "repeat") sizes.push(...tracks(splitArguments(node.nodes).slice(1).flat(), scope));
126
- else if (name === "minmax") sizes.push(sequence(splitArguments(node.nodes)[1] ?? [], scope));
127
- else sizes.push(measure(node, scope));
147
+ if (name === "repeat") {
148
+ const [count, ...rest] = splitArguments(node.nodes);
149
+ if (!/^auto-(?:fill|fit)$/i.test(meaningful(count)[0]?.value ?? "")) sizes.push(...tracks(rest.flat(), scope));
150
+ } else if (name === "minmax") {
151
+ const floor = sequence(splitArguments(node.nodes)[0] ?? [], scope);
152
+ sizes.push(isLength(floor) ? { ...floor, high: Infinity } : neutral);
153
+ } else sizes.push(measure(node, scope));
128
154
  }
129
155
  return sizes;
130
156
  }
131
- /** Why a width declaration is fixed, or null when it is fluid or allowed. */
132
- function fixed(property, value, scope) {
133
- const verdict = result => {
134
- if (result.cap) return capProperties.has(property) ? null : `${result.cap} is a fixed container cap, valid only as max-width or max-inline-size`;
135
- if (result.px === undefined) return null;
136
- if (result.px <= fixedWidthLimitPx) return null;
137
- return result.space && result.math ? `${Math.round(result.px)}px of arithmetic on spacing tokens` : `a fixed ${Math.round(result.px)}px, above the ${fixedWidthLimitPx}px control and icon range`;
138
- };
157
+ /** What a width that can give way looks like, in the terms of the property it is set on. */
158
+ const fix = (property, value, px) => property === "grid-template-columns" ? `a track of minmax(0, ${px}px)` : property === "flex" || property === "flex-basis" ? `flex: 1 1 ${px}px` : `${property}: min(100%, ${value})`;
159
+ /** What is wrong with a resolved width: { error } | { review } | null when it is fluid or allowed. */
160
+ function verdict(result, property, value) {
161
+ if (!isLength(result) || result.declared) return null;
162
+ if (result.low > smallPartLimitPx) {
163
+ const px = Math.round(result.low);
164
+ return { error: result.low === result.high ? `fixed at about ${px}px` : `unable to shrink below about ${px}px`, fix: fix(property, value, px) };
165
+ }
166
+ return result.low !== result.high && result.high <= smallPartLimitPx ? { review: Math.round(result.high) } : null;
167
+ }
168
+ function judge(property, value, scope) {
139
169
  const nodes = valueParser(value).nodes;
140
170
  if (property === "grid-template-columns") {
141
- for (const track of tracks(nodes, scope)) { const reason = verdict(track); if (reason) return `a fixed track, ${reason}`; }
171
+ for (const track of tracks(nodes, scope)) { const found = verdict(track, property, value); if (found?.error) return { ...found, error: `a track ${found.error}` }; }
142
172
  return null;
143
173
  }
144
174
  if (property === "flex") {
145
175
  const parts = meaningful(nodes);
146
176
  if (parts.length < 2) return null;
147
177
  const basis = parts.at(-1), shrink = parts.length === 3 ? Number(parts[1].value) : 1;
148
- return Number(parts[0].value) > 0 && shrink > 0 ? null : verdict(measure(basis, scope));
178
+ return Number(parts[0].value) > 0 && shrink > 0 ? null : verdict(measure(basis, scope), property, value);
149
179
  }
150
- return verdict(sequence(nodes, scope));
180
+ return verdict(sequence(nodes, scope), property, value);
151
181
  }
152
182
 
153
183
  return {
154
- /** layout-fixed-width findings for one parsed style sheet or Linaria template. */
184
+ /** layout-fixed-width and layout-width-noop findings for one parsed style sheet or Linaria template. */
155
185
  inspect(css, file, offset = { line: 1, column: 1 }) {
156
186
  const findings = [], locals = new Map();
157
187
  css.walkDecls(/^--/, decl => { locals.set(decl.prop, [...(locals.get(decl.prop) ?? []), decl.value]); });
158
188
  css.walkDecls(decl => {
159
189
  const property = decl.prop.toLowerCase();
160
190
  if (!widthProperties.has(property) || decl.value.includes("__ds_expression__")) return;
161
- const reason = fixed(property, decl.value, { seen: new Set(), locals });
162
- if (!reason) return;
163
- const line = offset.line + decl.source.start.line - 1;
164
- findings.push({ rule: "layout-fixed-width", severity: findingSeverity("layout-fixed-width"), file, line, column: decl.source.start.column + (decl.source.start.line === 1 ? offset.column - 1 : 0), guidanceUri: "ads://guides/tokens",
165
- message: `${file}:${line} sets ${property}: ${decl.value}, ${reason}. Widths are fluid on the grid: span columns with a --grid-span-N token in a container query, use % or fr, or cap text with a ch measure (max-inline-size: 65ch).` });
191
+ const declared = new Set(), scope = { seen: new Set(), locals, declared }, found = judge(property, decl.value, scope);
192
+ for (const token of declared) declaredUses.set(token, (declaredUses.get(token) ?? 0) + 1);
193
+ if (!found) return;
194
+ // width: 280px with max-width: 100% in the same rule is min(100%, 280px).
195
+ if (found.error && /^(?:width|inline-size)$/.test(property) && decl.parent.nodes.some(sibling => sibling.type === "decl" && /^max-(?:width|inline-size)$/i.test(sibling.prop) && sequence(valueParser(sibling.value).nodes, scope).low === 0)) return;
196
+ const line = offset.line + decl.source.start.line - 1, column = decl.source.start.column + (decl.source.start.line === 1 ? offset.column - 1 : 0);
197
+ if (found.review !== undefined) {
198
+ findings.push({ rule: "layout-width-noop", severity: findingSeverity("layout-width-noop"), file, line, column, property, value: decl.value, guidanceUri: "ads://guides/tokens",
199
+ message: `${file}:${line} sets ${property}: ${decl.value}. It never exceeds ${found.review}px, within the ${smallPartLimitPx}px a small part may use plainly, so the fluid part does nothing. Write the plain size.` });
200
+ return;
201
+ }
202
+ findings.push({ rule: "layout-fixed-width", severity: findingSeverity("layout-fixed-width"), file, line, column, property, value: decl.value, guidanceUri: "ads://guides/tokens",
203
+ message: `${file}:${line} sets ${property}: ${decl.value}, ${found.error}, above the ${smallPartLimitPx}px a small part may use. The fix depends on what this is. A small part: size it at ${smallPartLimitPx}px or less, plainly, and leave it. A panel, column or anything else that can give way: ${found.fix}. A part that truly stays this wide: give it a token, list the token in layout.widthTokens in ds.config.json, and use the token plainly; ads check lists it for review. These do not fix it: another unit (ch, em and rem are fixed too), max() or a min() that stays under ${smallPartLimitPx}px, or a token name such as --control-*, since no name is exempt.` });
166
204
  });
167
205
  return findings;
168
206
  },
169
- /** Every layout.widthTokens token is defined fluidly, or is a --container-* cap. */
170
- tokenFindings() {
207
+ /** Every fixed width the project declared, for review, so that it stays visible: tokens named by
208
+ * layout.widthTokens with how many widths use them, and what fixedWidthUnits owners set. Call
209
+ * it after inspect has seen every style. */
210
+ declaredWidths(ownerFindings = []) {
171
211
  const findings = [];
172
212
  for (const token of tokens) {
173
- if (!widthToken(token.name) || capToken.test(token.name)) continue;
174
- for (const definition of token.definitions) {
175
- const value = definition.authored ?? definition.value;
176
- if (isFluid(token.name, value)) continue;
177
- findings.push({ rule: "layout-fixed-width", severity: findingSeverity("layout-fixed-width"), file: definition.file, line: definition.line, column: definition.column, tokens: [token.name], guidanceUri: "ads://guides/tokens",
178
- message: `${token.name} is named by layout.widthTokens but is ${value}, not a fluid width. Define it with % or container units, such as calc((100% + var(--grid-gutter)) * 3 / 16 - var(--grid-gutter)); only a --container-* or --content-max token may be a fixed cap.` });
179
- }
213
+ if (!widthToken(token.name)) continue;
214
+ const value = values.get(token.name)?.value;
215
+ const result = value === undefined ? unknown : sequence(valueParser(value).nodes, { seen: new Set([token.name]), locals: new Map() });
216
+ if (!isLength(result) || result.low <= smallPartLimitPx) continue;
217
+ const definition = token.definitions[0], uses = declaredUses.get(token.name) ?? 0;
218
+ findings.push({ rule: "layout-declared-width", severity: findingSeverity("layout-declared-width"), file: definition.file, line: definition.line, column: definition.column, tokens: [token.name], guidanceUri: "ads://guides/tokens",
219
+ message: `${token.name} is ${value}, declared in layout.widthTokens: it cannot shrink below about ${Math.round(result.low)}px. ${uses ? `${uses} width declaration${uses === 1 ? " uses" : "s use"} it. Confirm it must stay fixed.` : "No width uses it, and a maximum needs no declaration: remove it from layout.widthTokens."}` });
180
220
  }
221
+ const owners = new Map();
222
+ for (const finding of ownerFindings) owners.set(finding.file, [...(owners.get(finding.file) ?? []), finding]);
223
+ for (const [file, list] of owners) findings.push({ rule: "layout-declared-width", severity: findingSeverity("layout-declared-width"), file, line: list[0].line, column: list[0].column, guidanceUri: "ads://guides/tokens",
224
+ message: `${file} is in layout.fixedWidthUnits, so its widths are not checked: ${list.map(finding => `${finding.property}: ${finding.value} (line ${finding.line})`).join(", ")}. Confirm it floats above the layout.` });
181
225
  return findings;
182
226
  },
183
227
  };
@@ -41,7 +41,8 @@ request already identifies the target.
41
41
 
42
42
  Run `ads audit` on the stressed scenario. `layout-overflow` fails it when the page overflows
43
43
  horizontally, an element reaches past the viewport or content is clipped at 390, 768 or 1280
44
- px. `overflow-x: auto` scrollers and `text-overflow: ellipsis` are exempt. Fix a failure with
44
+ px, or a set width above 96 px overflows a 240 px container. `overflow-x: auto` scrollers and
45
+ `text-overflow: ellipsis` are exempt. Fix a failure with
45
46
  fluid widths (`%`, `fr`, a `--grid-span-N` token in a container query), `min-width: 0` on flex
46
47
  and grid children, and wrapping, not with `overflow: hidden`.
47
48
 
@@ -134,7 +134,7 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
134
134
  breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
135
135
  widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
136
136
 
137
- ### Widths are fluid on the grid; never a fixed cap
137
+ ### Widths are fluid on the grid
138
138
 
139
139
  `--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
140
140
  Set one inside a container query, under a `Grid` or another `container-type: inline-size`
@@ -155,23 +155,36 @@ Atomic CSS does not keep rule order, so two queries on one property need exclusi
155
155
  Use `%` or `fr` for a share of the parent and a `ch` measure for running text
156
156
  (`max-inline-size: 65ch`).
157
157
 
158
- `layout-fixed-width` is an error for `width`, `min-width`, `max-width`, the logical inline
159
- sizes, `flex-basis`, `flex`'s basis and `grid-template-columns` tracks with a fixed length
160
- above 48 px, the top of the control and icon range: `var(--space-32)`,
161
- `calc(var(--space-32) * 10)`.
158
+ `layout-fixed-width` is an error for `width`, `min-width`, the logical inline sizes, `flex-basis`,
159
+ `flex`'s basis and `grid-template-columns` tracks that cannot shrink below 96 px, in any unit, raw,
160
+ through a token or by arithmetic. `max-width` and `max-inline-size` are not read: a maximum cannot
161
+ force overflow, so cap with them freely.
162
162
 
163
- These pass: `flex: 1 1 <basis>`; `min()`, `max()`, `clamp()` and `calc()` with a fluid part; `minmax()` with a fluid
164
- maximum; the part sizes `--icon-*`, `--control-*`, `--avatar-*`, `--border-*`, `--focus-*`,
165
- `--ring-*`, `--radius-*`, `--side-pane-*`, `--toast-*`, `--navigation-rail-width`,
166
- `--app-header-height`, `--row-height-compact`, `--compact-column-min`; and tokens named by
167
- `layout.widthTokens` in `ds.config.json`, which must be defined with `%` or container units.
168
- A fixed `--container-*` or `--content-max` token named there is a cap, valid only as a maximum.
169
- `layout.fixedWidthUnits` lists owners that may use fixed widths, by unit id or file glob: list
170
- overlays (dialogs, menus, popovers, tooltips) there. There is no per-declaration exception.
163
+ When it fires, pick the fix by what the element is:
164
+
165
+ | The element | Do |
166
+ |---|---|
167
+ | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
+ | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
+ | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
+
172
+ These do not fix it:
173
+
174
+ - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
175
+ - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
+ their fixed part.
177
+ - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
178
+ - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
+
180
+ `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
+ per-declaration exception.
171
182
 
172
183
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
173
184
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
174
- scrollers and `text-overflow: ellipsis` are exempt.
185
+ scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
186
+ 240 px container, and fails when a set width above 96 px overflows it. Make that width fluid, or
187
+ scroll it. Only an overlay's owner, listed in `layout.fixedWidthUnits`, stays out of this render.
175
188
 
176
189
  ## Color roles and states
177
190
 
@@ -43,7 +43,7 @@ implicitly requiring them at acceptance.
43
43
  owners while project scripts and core gates retain full scope.
44
44
  - Both policies run the axe-core audit of every rendered UI scenario in every brand
45
45
  and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
46
- that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
46
+ that policy. An `a11y-incomplete` info item means axe could not decide that rule on those elements: check it by hand, using the reason it names (`bgGradient` is text over a gradient). Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
47
47
  that cannot run (no project Playwright or browser) fails it with a `browser-audit`
48
48
  error naming what to install. Under the acceptance policy, draft
49
49
  acceptance and guarded patches/transactions audit the candidate's affected UI
@@ -327,12 +327,14 @@ brand artwork, icon outputs or glyphs.
327
327
 
328
328
  ## Layout widths
329
329
 
330
- Widths are fluid on the grid; never a fixed cap. Span columns with a `--grid-span-N` token in
331
- a container query, use `%` or `fr`, or cap text with a `ch` measure. `calc(var(--space-32) * 10)`
332
- fails `ads check` (`layout-fixed-width`); list overlays in `layout.fixedWidthUnits`. Atomic CSS
330
+ Widths are fluid on the grid. Span columns with a `--grid-span-N` token in a container query, or
331
+ use `%` or `fr`. `layout-fixed-width` fails a width that cannot shrink below 96 px, in any unit.
332
+ Small parts use plain sizes up to 96 px. A panel takes `width: min(100%, 280px)`. A part that truly
333
+ stays wider takes a token listed in `layout.widthTokens`, and an overlay's owner goes in
334
+ `layout.fixedWidthUnits`. `max-width` is not read. Atomic CSS
333
335
  does not keep rule order: give queries on one property exclusive ranges, such as
334
336
  `(min-width: 768px) and (max-width: 1023.98px)`. `ads audit` fails horizontal overflow at 390,
335
- 768 and 1280 px (`layout-overflow`). See the Grid section of
337
+ 768 and 1280 px, and reports a set width above 96 px that overflows a 240 px container as a review item (`layout-overflow-narrow`). See the Grid section of
336
338
  [design-data.md](references/design-data.md) (`ads://guides/tokens`).
337
339
 
338
340
  ## Web performance
@@ -134,7 +134,7 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
134
134
  breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
135
135
  widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
136
136
 
137
- ### Widths are fluid on the grid; never a fixed cap
137
+ ### Widths are fluid on the grid
138
138
 
139
139
  `--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
140
140
  Set one inside a container query, under a `Grid` or another `container-type: inline-size`
@@ -155,23 +155,36 @@ Atomic CSS does not keep rule order, so two queries on one property need exclusi
155
155
  Use `%` or `fr` for a share of the parent and a `ch` measure for running text
156
156
  (`max-inline-size: 65ch`).
157
157
 
158
- `layout-fixed-width` is an error for `width`, `min-width`, `max-width`, the logical inline
159
- sizes, `flex-basis`, `flex`'s basis and `grid-template-columns` tracks with a fixed length
160
- above 48 px, the top of the control and icon range: `var(--space-32)`,
161
- `calc(var(--space-32) * 10)`.
158
+ `layout-fixed-width` is an error for `width`, `min-width`, the logical inline sizes, `flex-basis`,
159
+ `flex`'s basis and `grid-template-columns` tracks that cannot shrink below 96 px, in any unit, raw,
160
+ through a token or by arithmetic. `max-width` and `max-inline-size` are not read: a maximum cannot
161
+ force overflow, so cap with them freely.
162
162
 
163
- These pass: `flex: 1 1 <basis>`; `min()`, `max()`, `clamp()` and `calc()` with a fluid part; `minmax()` with a fluid
164
- maximum; the part sizes `--icon-*`, `--control-*`, `--avatar-*`, `--border-*`, `--focus-*`,
165
- `--ring-*`, `--radius-*`, `--side-pane-*`, `--toast-*`, `--navigation-rail-width`,
166
- `--app-header-height`, `--row-height-compact`, `--compact-column-min`; and tokens named by
167
- `layout.widthTokens` in `ds.config.json`, which must be defined with `%` or container units.
168
- A fixed `--container-*` or `--content-max` token named there is a cap, valid only as a maximum.
169
- `layout.fixedWidthUnits` lists owners that may use fixed widths, by unit id or file glob: list
170
- overlays (dialogs, menus, popovers, tooltips) there. There is no per-declaration exception.
163
+ When it fires, pick the fix by what the element is:
164
+
165
+ | The element | Do |
166
+ |---|---|
167
+ | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
+ | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
+ | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
+
172
+ These do not fix it:
173
+
174
+ - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
175
+ - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
+ their fixed part.
177
+ - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
178
+ - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
+
180
+ `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
+ per-declaration exception.
171
182
 
172
183
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
173
184
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
174
- scrollers and `text-overflow: ellipsis` are exempt.
185
+ scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
186
+ 240 px container, and fails when a set width above 96 px overflows it. Make that width fluid, or
187
+ scroll it. Only an overlay's owner, listed in `layout.fixedWidthUnits`, stays out of this render.
175
188
 
176
189
  ## Color roles and states
177
190
 
@@ -43,7 +43,7 @@ implicitly requiring them at acceptance.
43
43
  owners while project scripts and core gates retain full scope.
44
44
  - Both policies run the axe-core audit of every rendered UI scenario in every brand
45
45
  and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
46
- that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
46
+ that policy. An `a11y-incomplete` info item means axe could not decide that rule on those elements: check it by hand, using the reason it names (`bgGradient` is text over a gradient). Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
47
47
  that cannot run (no project Playwright or browser) fails it with a `browser-audit`
48
48
  error naming what to install. Under the acceptance policy, draft
49
49
  acceptance and guarded patches/transactions audit the candidate's affected UI
@@ -134,7 +134,7 @@ container width (768 and 1024 px) with container queries, since CSS variables ca
134
134
  breakpoints. The showcase's grid overlay draws these tokens over every preview at the same
135
135
  widths; a project without them shows no overlay. Align text to a cell's edge, not its gutter.
136
136
 
137
- ### Widths are fluid on the grid; never a fixed cap
137
+ ### Widths are fluid on the grid
138
138
 
139
139
  `--grid-span-1` to `--grid-span-16` are widths of N of 16 columns, fluid in their container.
140
140
  Set one inside a container query, under a `Grid` or another `container-type: inline-size`
@@ -155,23 +155,36 @@ Atomic CSS does not keep rule order, so two queries on one property need exclusi
155
155
  Use `%` or `fr` for a share of the parent and a `ch` measure for running text
156
156
  (`max-inline-size: 65ch`).
157
157
 
158
- `layout-fixed-width` is an error for `width`, `min-width`, `max-width`, the logical inline
159
- sizes, `flex-basis`, `flex`'s basis and `grid-template-columns` tracks with a fixed length
160
- above 48 px, the top of the control and icon range: `var(--space-32)`,
161
- `calc(var(--space-32) * 10)`.
158
+ `layout-fixed-width` is an error for `width`, `min-width`, the logical inline sizes, `flex-basis`,
159
+ `flex`'s basis and `grid-template-columns` tracks that cannot shrink below 96 px, in any unit, raw,
160
+ through a token or by arithmetic. `max-width` and `max-inline-size` are not read: a maximum cannot
161
+ force overflow, so cap with them freely.
162
162
 
163
- These pass: `flex: 1 1 <basis>`; `min()`, `max()`, `clamp()` and `calc()` with a fluid part; `minmax()` with a fluid
164
- maximum; the part sizes `--icon-*`, `--control-*`, `--avatar-*`, `--border-*`, `--focus-*`,
165
- `--ring-*`, `--radius-*`, `--side-pane-*`, `--toast-*`, `--navigation-rail-width`,
166
- `--app-header-height`, `--row-height-compact`, `--compact-column-min`; and tokens named by
167
- `layout.widthTokens` in `ds.config.json`, which must be defined with `%` or container units.
168
- A fixed `--container-*` or `--content-max` token named there is a cap, valid only as a maximum.
169
- `layout.fixedWidthUnits` lists owners that may use fixed widths, by unit id or file glob: list
170
- overlays (dialogs, menus, popovers, tooltips) there. There is no per-declaration exception.
163
+ When it fires, pick the fix by what the element is:
164
+
165
+ | The element | Do |
166
+ |---|---|
167
+ | A small part: an icon, control, handle or thumbnail | Size it at 96 px or less, plainly: `width: 64px`, `width: var(--control-height-lg)` |
168
+ | A panel, column or anything that can give way | `width: min(100%, 280px)`, `flex: 1 1 280px` or a `minmax(0, 280px)` track |
169
+ | A part that truly stays that wide | A token listed in `layout.widthTokens` in `ds.config.json`, used plainly: `width: var(--side-pane-width)` |
170
+ | An overlay: dialog, menu, popover, tooltip | Its owner in `layout.fixedWidthUnits`, by unit id or file glob |
171
+
172
+ These do not fix it:
173
+
174
+ - Another unit. `32.5ch`, `20em` and `20rem` are as fixed as `280px`, and depend on the font too.
175
+ - `max(100%, 280px)`, `clamp(200px, 50%, 400px)`, `calc(100% + 200px)`: they cannot shrink below
176
+ their fixed part.
177
+ - `min(100%, 64px)` around a small part: `layout-width-noop` asks for the plain size.
178
+ - A token name. `--control-*`, `--side-pane-*` and every other name are read for their value.
179
+
180
+ `ads check` lists every declared fixed width for review (`layout-declared-width`). There is no
181
+ per-declaration exception.
171
182
 
172
183
  `layout-overflow` (`ads audit`) renders every UI scenario at 390, 768 and 1280 px and fails on
173
184
  horizontal page overflow, elements past the viewport and clipped content. `overflow-x: auto`
174
- scrollers and `text-overflow: ellipsis` are exempt.
185
+ scrollers and `text-overflow: ellipsis` are exempt. It also renders components and patterns in a
186
+ 240 px container, and fails when a set width above 96 px overflows it. Make that width fluid, or
187
+ scroll it. Only an overlay's owner, listed in `layout.fixedWidthUnits`, stays out of this render.
175
188
 
176
189
  ## Color roles and states
177
190
 
@@ -43,7 +43,7 @@ implicitly requiring them at acceptance.
43
43
  owners while project scripts and core gates retain full scope.
44
44
  - Both policies run the axe-core audit of every rendered UI scenario in every brand
45
45
  and theme (`browser-accessibility-audit`); `browserAudit: false` turns it off for
46
- that policy. Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
46
+ that policy. An `a11y-incomplete` info item means axe could not decide that rule on those elements: check it by hand, using the reason it names (`bgGradient` is text over a gradient). Its `a11y-axe`, `a11y-non-text-contrast` and `layout-overflow` findings are errors that fail the policy, and an audit
47
47
  that cannot run (no project Playwright or browser) fails it with a `browser-audit`
48
48
  error naming what to install. Under the acceptance policy, draft
49
49
  acceptance and guarded patches/transactions audit the candidate's affected UI