@reqvire-org/ads 0.5.13 → 0.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ads-errors.mjs +23 -0
- package/dist/analysis/content-model.mjs +156 -0
- package/dist/analysis/owner-source.mjs +8 -1
- package/dist/check.mjs +1 -0
- package/dist/construction-spec.d.mts +4 -2
- package/dist/construction-spec.mjs +5 -3
- package/dist/end-alignment.mjs +5 -0
- package/dist/owner-analysis-check.mjs +1 -0
- package/dist/recipe-macro.d.mts +1 -1
- package/dist/region-lowering.mjs +15 -4
- package/dist/render-audit/layout-overflow.page.mjs +26 -1
- package/dist/render-audit.mjs +5 -1
- package/dist/showcase/client.bundle.js +46 -46
- package/dist/showcase/http-client.bundle.js +13 -13
- package/dist/showcase/ui/ui.js +3 -3
- package/dist/skills/ads-designer/references/behaviors.md +31 -0
- package/dist/skills/ads-designer/references/recipes.md +5 -4
- package/dist/skills/ads-import/references/behaviors.md +31 -0
- package/dist/skills/ads-import/references/recipes.md +5 -4
- package/dist/skills/ads-port/references/behaviors.md +31 -0
- package/dist/skills/ads-port/references/recipes.md +5 -4
- package/docs/CHANGELOG.md +136 -0
- package/docs/GUIDE.md +16 -1
- package/docs/LANGUAGE.md +2 -2
- package/docs/RULES.md +6 -3
- package/package.json +1 -1
package/dist/ads-errors.mjs
CHANGED
|
@@ -873,6 +873,20 @@ export const choiceErrors = {
|
|
|
873
873
|
message: (failure) => `The ${failure.scheme} image of part "${failure.part}" is not always loading="lazy"; the default theme is ${failure.defaultScheme}, so this file would be downloaded while hidden.`,
|
|
874
874
|
repair: 'Write `loading="lazy"` on that image as a literal and apply any priority (eager loading, `fetchPriority`) to the default scheme\'s image only.'
|
|
875
875
|
},
|
|
876
|
+
"root-margin-unreset": {
|
|
877
|
+
group: "structure-mismatch",
|
|
878
|
+
rule: "A recipe root rendered as an element the browser gives a margin (`figure`, `p`, a list, a heading, `blockquote`, `pre`, `fieldset`) states its margin: its parts are reset by their construction, but a root keeps the browser's (a figure's 40 px sides make it 80 px narrower than its column).",
|
|
879
|
+
guides: [RECIPES],
|
|
880
|
+
message: (failure) => `This recipe root is a <${failure.element}>, which keeps the browser's margin: nothing states its own.`,
|
|
881
|
+
repair: "Add `normalize: { margin: 0 }` to the recipe (its parent's space still applies), or render the root as a <div>."
|
|
882
|
+
},
|
|
883
|
+
"invalid-nesting": {
|
|
884
|
+
group: "accessibility-semantics",
|
|
885
|
+
rule: "An owner's markup follows HTML's content model: an element that takes phrasing content only (a span, a paragraph, a button, a label, a heading) holds no flow content (a div, a list, a paragraph, a heading); a link or a button holds no other link, button or form control; a list item sits in a list, a table row in a table, a cell in a row. A transparent element (a link) takes its parent's model. Browsers repair such markup differently, and assistive technology reads what they repaired.",
|
|
886
|
+
guides: ["ads://guides/accessibility"],
|
|
887
|
+
message: (failure) => failure.rule === "phrasing" ? `<${failure.element}> is flow content inside <${failure.parent}>, which holds phrasing content only.` : failure.rule === "interactive" ? `<${failure.element}> is interactive content inside <${failure.parent}>: one press would reach two targets.` : `<${failure.element}> sits in <${failure.parent}>; it belongs in ${failure.expected.map((name) => `<${name}>`).join(" or ")}.`,
|
|
888
|
+
repair: "Use an element whose content model fits: a <div> (or a list item) for a box that holds blocks, a <span> inside phrasing content; move the second control out of the link or button beside it; put list items in a list and cells in a row."
|
|
889
|
+
},
|
|
876
890
|
"image-alt-missing": {
|
|
877
891
|
group: "accessibility-semantics",
|
|
878
892
|
rule: "Every `<img>` an owner renders states its text alternative (WCAG 2.2 1.1.1): content media and any other image, as artwork images do; decorative images state it as empty.",
|
|
@@ -2189,6 +2203,15 @@ export const runtimeErrors = {
|
|
|
2189
2203
|
emitters: ["src/owner-analysis-check.mts"],
|
|
2190
2204
|
situations: "owner-analysis errors with code source/intrinsic-alt-missing (an artwork image) or source/image-alt-missing (content media and any other image), at the <img>; a spread on owned markup is rejected before."
|
|
2191
2205
|
},
|
|
2206
|
+
"a11y-nesting": {
|
|
2207
|
+
group: "accessibility-semantics",
|
|
2208
|
+
severity: "error",
|
|
2209
|
+
rule: "An owner's markup follows HTML's content model: no flow content inside phrasing-only elements, no press target inside another, and list items, table rows and cells in their list, table and row.",
|
|
2210
|
+
guides: ["ads://guides/accessibility"],
|
|
2211
|
+
repair: "Use an element whose content model fits (a <div> or a list item for a box of blocks), move the inner control beside the outer one, and put items in their list, rows in their table.",
|
|
2212
|
+
emitters: ["src/owner-analysis-check.mts"],
|
|
2213
|
+
situations: "an owner-analysis error with code source/invalid-nesting, at the element that may not sit there."
|
|
2214
|
+
},
|
|
2192
2215
|
"a11y-incomplete": {
|
|
2193
2216
|
group: "rendered-check",
|
|
2194
2217
|
severity: "info",
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isArrayLiteralExpression,
|
|
3
|
+
isArrowFunction,
|
|
4
|
+
isBinaryExpression,
|
|
5
|
+
isBlock,
|
|
6
|
+
isCallExpression,
|
|
7
|
+
isConditionalExpression,
|
|
8
|
+
isFunctionExpression,
|
|
9
|
+
isIfStatement,
|
|
10
|
+
isJsxElement,
|
|
11
|
+
isJsxExpression,
|
|
12
|
+
isJsxFragment,
|
|
13
|
+
isParenthesizedExpression,
|
|
14
|
+
isPropertyAccessExpression,
|
|
15
|
+
isReturnStatement
|
|
16
|
+
} from "typescript/ast";
|
|
17
|
+
const PHRASING_ONLY = new Set(["span", "p", "button", "label", "h1", "h2", "h3", "h4", "h5", "h6", "em", "strong", "small", "b", "i", "u", "s", "code", "kbd", "samp", "var", "abbr", "cite", "q", "sub", "sup", "time", "mark", "dfn", "data", "output", "legend", "summary", "pre"]), TRANSPARENT = new Set(["a", "ins", "del", "map", "object", "canvas", "noscript", "slot"]), PHRASING = new Set([
|
|
18
|
+
"a",
|
|
19
|
+
"abbr",
|
|
20
|
+
"audio",
|
|
21
|
+
"b",
|
|
22
|
+
"bdi",
|
|
23
|
+
"bdo",
|
|
24
|
+
"br",
|
|
25
|
+
"button",
|
|
26
|
+
"canvas",
|
|
27
|
+
"cite",
|
|
28
|
+
"code",
|
|
29
|
+
"data",
|
|
30
|
+
"datalist",
|
|
31
|
+
"del",
|
|
32
|
+
"dfn",
|
|
33
|
+
"em",
|
|
34
|
+
"embed",
|
|
35
|
+
"i",
|
|
36
|
+
"iframe",
|
|
37
|
+
"img",
|
|
38
|
+
"input",
|
|
39
|
+
"ins",
|
|
40
|
+
"kbd",
|
|
41
|
+
"label",
|
|
42
|
+
"map",
|
|
43
|
+
"mark",
|
|
44
|
+
"meter",
|
|
45
|
+
"noscript",
|
|
46
|
+
"object",
|
|
47
|
+
"output",
|
|
48
|
+
"picture",
|
|
49
|
+
"progress",
|
|
50
|
+
"q",
|
|
51
|
+
"ruby",
|
|
52
|
+
"s",
|
|
53
|
+
"samp",
|
|
54
|
+
"select",
|
|
55
|
+
"slot",
|
|
56
|
+
"small",
|
|
57
|
+
"span",
|
|
58
|
+
"strong",
|
|
59
|
+
"sub",
|
|
60
|
+
"sup",
|
|
61
|
+
"svg",
|
|
62
|
+
"template",
|
|
63
|
+
"textarea",
|
|
64
|
+
"time",
|
|
65
|
+
"u",
|
|
66
|
+
"var",
|
|
67
|
+
"video",
|
|
68
|
+
"wbr",
|
|
69
|
+
"math",
|
|
70
|
+
"area",
|
|
71
|
+
"source",
|
|
72
|
+
"track"
|
|
73
|
+
]), INTERACTIVE = new Set(["a", "button", "input", "select", "textarea", "details", "iframe", "embed"]), PLACED_IN = {
|
|
74
|
+
li: ["ul", "ol", "menu"],
|
|
75
|
+
tr: ["table", "thead", "tbody", "tfoot"],
|
|
76
|
+
td: ["tr"],
|
|
77
|
+
th: ["tr"]
|
|
78
|
+
};
|
|
79
|
+
function insideMarkup(fn) {
|
|
80
|
+
let current = fn.parent;
|
|
81
|
+
while (current !== void 0) {
|
|
82
|
+
if (isJsxExpression(current))
|
|
83
|
+
return !0;
|
|
84
|
+
if (isCallExpression(current) || isPropertyAccessExpression(current) || isParenthesizedExpression(current) || isConditionalExpression(current) || isBinaryExpression(current))
|
|
85
|
+
current = current.parent;
|
|
86
|
+
else
|
|
87
|
+
return !1;
|
|
88
|
+
}
|
|
89
|
+
return !1;
|
|
90
|
+
}
|
|
91
|
+
export function enclosingOpening(node) {
|
|
92
|
+
let current = node.parent;
|
|
93
|
+
while (current !== void 0) {
|
|
94
|
+
if (isJsxElement(current))
|
|
95
|
+
return current.openingElement;
|
|
96
|
+
if (isArrowFunction(current) || isFunctionExpression(current)) {
|
|
97
|
+
if (!insideMarkup(current))
|
|
98
|
+
return null;
|
|
99
|
+
current = current.parent;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (!(isJsxFragment(current) || isJsxExpression(current) || isParenthesizedExpression(current) || isConditionalExpression(current) || isBinaryExpression(current) || isCallExpression(current) || isPropertyAccessExpression(current) || isArrayLiteralExpression(current) || isReturnStatement(current) || isBlock(current) || isIfStatement(current)))
|
|
103
|
+
return null;
|
|
104
|
+
if ((isBlock(current) || isReturnStatement(current)) && !inMarkupCallback(current))
|
|
105
|
+
return null;
|
|
106
|
+
current = current.parent;
|
|
107
|
+
}
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
function inMarkupCallback(node) {
|
|
111
|
+
let current = node.parent;
|
|
112
|
+
while (current !== void 0) {
|
|
113
|
+
if (isArrowFunction(current) || isFunctionExpression(current))
|
|
114
|
+
return insideMarkup(current);
|
|
115
|
+
if (isBlock(current) || isReturnStatement(current) || isIfStatement(current)) {
|
|
116
|
+
current = current.parent;
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
return !1;
|
|
120
|
+
}
|
|
121
|
+
return !1;
|
|
122
|
+
}
|
|
123
|
+
export function nestingProblem(opening, elementOf, tagOf) {
|
|
124
|
+
const tag = tagOf(opening);
|
|
125
|
+
if (!/^[a-z]/.test(tag))
|
|
126
|
+
return null;
|
|
127
|
+
const chain = [];
|
|
128
|
+
let at = enclosingOpening(elementOf(opening));
|
|
129
|
+
while (at !== null) {
|
|
130
|
+
const parent = tagOf(at);
|
|
131
|
+
if (!/^[a-z]/.test(parent))
|
|
132
|
+
break;
|
|
133
|
+
if (parent === "svg" || parent === "math" || parent === "foreignObject")
|
|
134
|
+
return null;
|
|
135
|
+
chain.push(parent);
|
|
136
|
+
at = enclosingOpening(elementOf(at));
|
|
137
|
+
}
|
|
138
|
+
const [direct] = chain;
|
|
139
|
+
if (direct === void 0)
|
|
140
|
+
return null;
|
|
141
|
+
const placedIn = PLACED_IN[tag];
|
|
142
|
+
if (placedIn !== void 0 && !placedIn.includes(direct))
|
|
143
|
+
return { rule: "placement", element: tag, parent: direct, expected: placedIn };
|
|
144
|
+
if (INTERACTIVE.has(tag)) {
|
|
145
|
+
const host = chain.find((parent) => parent === "a" || parent === "button");
|
|
146
|
+
if (host !== void 0)
|
|
147
|
+
return { rule: "interactive", element: tag, parent: host };
|
|
148
|
+
}
|
|
149
|
+
const model = chain.find((parent) => !TRANSPARENT.has(parent));
|
|
150
|
+
if (model !== void 0 && PHRASING_ONLY.has(model) && !PHRASING.has(tag)) {
|
|
151
|
+
if ((model === "summary" || model === "legend") && /^h[1-6]$/.test(tag))
|
|
152
|
+
return null;
|
|
153
|
+
return { rule: "phrasing", element: tag, parent: model };
|
|
154
|
+
}
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
@@ -115,6 +115,7 @@ import { appIconEmission, withAppIconsModule } from "../emit/app-icon-emission.m
|
|
|
115
115
|
import { withOutputPackage } from "../emit/output-package.mjs";
|
|
116
116
|
import { analyzedOwners, outcomeCounts, rowsRead } from "./owner-outcomes.mjs";
|
|
117
117
|
import { capturedTreeFiles, findNode, walk } from "./helpers.mjs";
|
|
118
|
+
import { nestingProblem } from "./content-model.mjs";
|
|
118
119
|
import { factorClasses } from "./factored-classes.mjs";
|
|
119
120
|
import { programGlobals } from "./owner-analysis-key.mjs";
|
|
120
121
|
import { memoizedConstruction } from "./construction-memo.mjs";
|
|
@@ -941,6 +942,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
941
942
|
if (rootless !== void 0)
|
|
942
943
|
return fail(opening, { kind: "pseudo-host-unsupported", part: "&", pseudo: rootless.pseudo, element: rootTag });
|
|
943
944
|
await nativeElement(opening, region.element, "&", null, context, resolve);
|
|
945
|
+
const UA_MARGIN_TAGS = ["figure", "p", "ul", "ol", "dl", "dd", "blockquote", "h1", "h2", "h3", "h4", "h5", "h6", "pre", "menu", "fieldset"], statesMargin = region.normalize.some(([property]) => property.startsWith("margin")) || region.element?.kind === "list" || region.layer !== null;
|
|
946
|
+
if (UA_MARGIN_TAGS.includes(rootTag) && !statesMargin)
|
|
947
|
+
return fail(opening, { kind: "root-margin-unreset", element: rootTag });
|
|
944
948
|
if (region.normalize.some(([property, value]) => property === "pointer-events" && value === "none"))
|
|
945
949
|
await pointerTransparent(opening, "&", context, resolve);
|
|
946
950
|
if (region.overflow.kind === "scroll")
|
|
@@ -1526,6 +1530,9 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
1526
1530
|
const tag = values.tag(opening);
|
|
1527
1531
|
if (tag === "img" && attr(opening, "alt") === void 0)
|
|
1528
1532
|
return fail(opening, { kind: "image-alt-missing" });
|
|
1533
|
+
const nesting = nestingProblem(opening, elementOf, values.tag);
|
|
1534
|
+
if (nesting !== null)
|
|
1535
|
+
return fail(opening, { kind: "invalid-nesting", ...nesting, expected: nesting.rule === "placement" ? nesting.expected : [] });
|
|
1529
1536
|
if (clickWithoutKeyboard(opening, tag))
|
|
1530
1537
|
review(opening, { kind: "click-without-keyboard", element: tag });
|
|
1531
1538
|
if (!sections && !artworkThemed.has(opening))
|
|
@@ -1800,7 +1807,7 @@ export async function ownerModuleSource(name, owner, classOf, fail) {
|
|
|
1800
1807
|
}
|
|
1801
1808
|
const runtimeAxes = new Set(selections.flatMap((selection) => selection.result.axes.map((axis) => axis.declaration))), bindings = new Map;
|
|
1802
1809
|
for (const declaration of values.touched)
|
|
1803
|
-
if (declaration.parent.parent
|
|
1810
|
+
if (isVariableStatement(declaration.parent.parent) && isIdentifier(declaration.name))
|
|
1804
1811
|
bindings.set(await values.symbol(declaration.name), declaration);
|
|
1805
1812
|
const references = new Map([...bindings.values()].map((declaration) => [declaration, []]));
|
|
1806
1813
|
for (const identifier of nodesOfKind(source, SyntaxKind.Identifier, isIdentifier)) {
|
package/dist/check.mjs
CHANGED
|
@@ -866,6 +866,8 @@ export interface RegionPart {
|
|
|
866
866
|
/** `frame: { profile, rules, corners }`: the box's one-sided rules and rounded corners, as a root frame's. */
|
|
867
867
|
readonly boxBorder: FrameBorder;
|
|
868
868
|
readonly boxCorners: readonly FrameCorner[] | null;
|
|
869
|
+
/** `frame: { profile, ratio }`: the box's ratio, one its spatial profile permits. */
|
|
870
|
+
readonly boxRatio?: string | null;
|
|
869
871
|
/** A declared, human-approved boundary of this text-entry control (`frame` is a control frame). */
|
|
870
872
|
readonly accessibility: AccessibilityDeclaration | null;
|
|
871
873
|
readonly when: readonly StateTreatment[];
|
|
@@ -1211,7 +1213,7 @@ export interface OutsetSpec {
|
|
|
1211
1213
|
/** Normalization as CSS property → value pairs, in authored order. */
|
|
1212
1214
|
export type Normalized = readonly (readonly [property: string, value: string])[];
|
|
1213
1215
|
/** The pointer cursors an element may show (`normalize.cursor`): a closed set, no image cursors. */
|
|
1214
|
-
export declare const CURSORS: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed"];
|
|
1216
|
+
export declare const CURSORS: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed", "zoom-in", "zoom-out"];
|
|
1215
1217
|
/** The touch gestures an element leaves to the browser (`normalize.touchAction`): none, or panning on one axis. */
|
|
1216
1218
|
export declare const TOUCH_ACTIONS: readonly ["none", "pan-x", "pan-y"];
|
|
1217
1219
|
/** How the user may resize a multi-line text field (`normalize.resize`, on a `<textarea>` part): by its block edge only, or not at all. */
|
|
@@ -1234,7 +1236,7 @@ export declare const NORMALIZE_FIELDS: {
|
|
|
1234
1236
|
};
|
|
1235
1237
|
readonly cursor: {
|
|
1236
1238
|
readonly property: "cursor";
|
|
1237
|
-
readonly values: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed"];
|
|
1239
|
+
readonly values: readonly ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed", "zoom-in", "zoom-out"];
|
|
1238
1240
|
};
|
|
1239
1241
|
readonly textDecoration: {
|
|
1240
1242
|
readonly property: "text-decoration-line";
|
|
@@ -842,7 +842,7 @@ function frameCondition(value, base, read) {
|
|
|
842
842
|
path: `${path}.frame`
|
|
843
843
|
};
|
|
844
844
|
}
|
|
845
|
-
export const CURSORS = ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed"], TOUCH_ACTIONS = ["none", "pan-x", "pan-y"], RESIZES = ["vertical", "none"], USER_SELECTS = ["none"], NORMALIZE_FIELDS = {
|
|
845
|
+
export const CURSORS = ["pointer", "default", "grab", "grabbing", "col-resize", "row-resize", "move", "text", "not-allowed", "zoom-in", "zoom-out"], TOUCH_ACTIONS = ["none", "pan-x", "pan-y"], RESIZES = ["vertical", "none"], USER_SELECTS = ["none"], NORMALIZE_FIELDS = {
|
|
846
846
|
margin: { property: "margin", values: ["0"] },
|
|
847
847
|
borderStyle: { property: "border-style", values: ["solid", "none"] },
|
|
848
848
|
cursor: { property: "cursor", values: CURSORS },
|
|
@@ -1226,9 +1226,10 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1226
1226
|
if (bound.length > 0 && (content.kind !== "visual" || visualBinding(part) === null))
|
|
1227
1227
|
read.reject({ kind: "field-unsupported", construction: "region", path: `${path}.${bound[0] ?? ""}` });
|
|
1228
1228
|
const declaredFrame = part.frame;
|
|
1229
|
-
let boxed = null, safeArea = [], boxBorder = { kind: "profile" }, boxCorners = null;
|
|
1229
|
+
let boxed = null, safeArea = [], boxBorder = { kind: "profile" }, boxCorners = null, boxRatio = null;
|
|
1230
1230
|
if (isRecord(declaredFrame) && declaredFrame.profile !== void 0) {
|
|
1231
|
-
read.only(declaredFrame, `${path}.frame`, ["profile", "safeArea", "rules", "corners"]);
|
|
1231
|
+
read.only(declaredFrame, `${path}.frame`, ["profile", "safeArea", "rules", "corners", "ratio"]);
|
|
1232
|
+
boxRatio = read.optionalString(declaredFrame.ratio, `${path}.frame.ratio`);
|
|
1232
1233
|
boxed = read.string(declaredFrame.profile, `${path}.frame.profile`);
|
|
1233
1234
|
safeArea = safeAreaSides(declaredFrame.safeArea, `${path}.frame.safeArea`, read);
|
|
1234
1235
|
boxBorder = frameBorder(declaredFrame.rules, `${path}.frame.rules`, read);
|
|
@@ -1267,6 +1268,7 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1267
1268
|
safeArea,
|
|
1268
1269
|
boxBorder,
|
|
1269
1270
|
boxCorners,
|
|
1271
|
+
boxRatio,
|
|
1270
1272
|
accessibility: accessibilityDeclaration(part.accessibility, part.frame !== void 0 && boxed === null, `${path}.accessibility`, read),
|
|
1271
1273
|
when: states.treatments,
|
|
1272
1274
|
textWhen: states.texts,
|
package/dist/end-alignment.mjs
CHANGED
|
@@ -76,6 +76,9 @@ function paintsFlushBox(foundation, spec) {
|
|
|
76
76
|
const end = frameInlineInsets(Object.fromEntries(fields)).end;
|
|
77
77
|
return end === void 0 || /^0(px)?$/.test(end.trim());
|
|
78
78
|
}
|
|
79
|
+
function holdsText(part) {
|
|
80
|
+
return part.content.kind === "text" || part.parts.some(holdsText);
|
|
81
|
+
}
|
|
79
82
|
export function stackPartsOf(foundation, spec) {
|
|
80
83
|
if (spec.kind !== "region" || spec.arrangement.layout !== "stack")
|
|
81
84
|
return [];
|
|
@@ -91,6 +94,8 @@ export function stackPartsOf(foundation, spec) {
|
|
|
91
94
|
const surface = part.surface === null ? null : selectedProfile(foundation, part.surface), painted = surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && (surface.value.fields.has("background") || surface.value.fields.has("background-image")) || borderedAtEnd(frame.value.fields, null) || part.overflow.kind === "clip";
|
|
92
95
|
if (painted && banded)
|
|
93
96
|
return [];
|
|
97
|
+
if (painted && !holdsText(part))
|
|
98
|
+
return [];
|
|
94
99
|
if (painted)
|
|
95
100
|
return [{ part: part.name, kind: "box", inset: [] }];
|
|
96
101
|
if (endsRagged(part.arrangement, part.parts))
|
|
@@ -43,6 +43,7 @@ export const OWNER_REVIEW_RULE = "owner-analysis-review";
|
|
|
43
43
|
const ACCESSIBILITY_RULES = new Map([
|
|
44
44
|
["source/intrinsic-alt-missing", "a11y-image-alt"],
|
|
45
45
|
["source/image-alt-missing", "a11y-image-alt"],
|
|
46
|
+
["source/invalid-nesting", "a11y-nesting"],
|
|
46
47
|
["source/control-name-missing", "a11y-icon-label"],
|
|
47
48
|
["construction/target-size-below-minimum", "a11y-target-size"],
|
|
48
49
|
["construction/target-area-overlap", "a11y-target-size"],
|
package/dist/recipe-macro.d.mts
CHANGED
|
@@ -68,7 +68,7 @@ export type Frame = "control" | "container" | {
|
|
|
68
68
|
/** A side of a frame by its logical name. */
|
|
69
69
|
export type SafeAreaSide = "block-start" | "block-end" | "inline-start" | "inline-end";
|
|
70
70
|
/** The pointer cursors an element may show: a closed set, no image cursors. */
|
|
71
|
-
export type Cursor = "pointer" | "default" | "grab" | "grabbing" | "col-resize" | "row-resize" | "move" | "text" | "not-allowed";
|
|
71
|
+
export type Cursor = "pointer" | "default" | "grab" | "grabbing" | "col-resize" | "row-resize" | "move" | "text" | "not-allowed" | "zoom-in" | "zoom-out";
|
|
72
72
|
/** The touch gestures an element leaves to the browser: none (the owner handles them all), or panning on one axis. */
|
|
73
73
|
export type TouchAction = "none" | "pan-x" | "pan-y";
|
|
74
74
|
interface NativeNormalization {
|
package/dist/region-lowering.mjs
CHANGED
|
@@ -217,7 +217,7 @@ function permittedRatio(ratio, slots, profile, reject) {
|
|
|
217
217
|
const ratios = profile.field(Object.fromEntries(profile.select(spatial).fields), spatial, "ratios").split(",").map((item) => item.trim().replace(/\s*\/\s*/, " / ")), normal = ratio.trim().replace(/\s*[/:]\s*/, " / ");
|
|
218
218
|
return ratios.includes(normal) ? normal : reject({ kind: "profile-field-unsupported", profile: spatial, field: "ratio", value: ratio });
|
|
219
219
|
}
|
|
220
|
-
function regionFrameValues(frame, slots, surface, profile, reject) {
|
|
220
|
+
function regionFrameValues(frame, slots, surface, profile, reject, clips = !1) {
|
|
221
221
|
const values = {}, frameReference = slots["frame-profile"];
|
|
222
222
|
let fields = {};
|
|
223
223
|
if (frame.kind === "container") {
|
|
@@ -229,6 +229,8 @@ function regionFrameValues(frame, slots, surface, profile, reject) {
|
|
|
229
229
|
fields = profile.of(frameReference, "frame");
|
|
230
230
|
if (frame.ratio !== null)
|
|
231
231
|
values["aspect-ratio"] = permittedRatio(frame.ratio, slots, profile, reject);
|
|
232
|
+
if (frame.ratio !== null && clips && fields["min-block-size"] === void 0)
|
|
233
|
+
values["min-block-size"] = "0";
|
|
232
234
|
}
|
|
233
235
|
Object.assign(values, frameValues(fields, profile, reject, frame.border));
|
|
234
236
|
if (frame.border.kind === "rules") {
|
|
@@ -592,6 +594,15 @@ function pseudoFill(treatment, surface, profile, reject) {
|
|
|
592
594
|
return reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface, field: other });
|
|
593
595
|
return fields.background ?? reject({ kind: "pseudo-surface-unsupported", pseudo: treatment.pseudo, surface, field: null });
|
|
594
596
|
}
|
|
597
|
+
function yields(part) {
|
|
598
|
+
if (part.content.kind === "text" || part.extent.kind !== "content" || part.overflow.kind !== "visible")
|
|
599
|
+
return !0;
|
|
600
|
+
if (part.arrangement?.wrap === !0)
|
|
601
|
+
return !0;
|
|
602
|
+
if (part.parts.length === 0)
|
|
603
|
+
return !1;
|
|
604
|
+
return part.parts.some(yields);
|
|
605
|
+
}
|
|
595
606
|
const covers = (visual) => visual.fit === "cover", COVER_FILL = { display: "block", "inline-size": "100%", "block-size": "100%", "min-block-size": "0", "object-fit": "cover" };
|
|
596
607
|
function normalizeElement(spec, name, path, values, provided, context) {
|
|
597
608
|
if (spec.element === null)
|
|
@@ -959,7 +970,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
|
|
|
959
970
|
], moved = part.effects === null ? [] : [...new Set(part.effects.when.flatMap(([, names]) => names.map((name) => PART_EFFECTS[name].channel)))], entering = writeEnter(out, profile, path, part.enter, partSurface, stateSurfaces(path, part.when, profile), slots, [...transitioned(part.paintTransition, partGroups), ...moved], reject);
|
|
960
971
|
transitionRules(path, part.paintTransition, part.surface === null ? null : { name: part.surface, fields: partSurface }, part.when, context, entering === null ? partGroups : [...partGroups, entering.group]);
|
|
961
972
|
writePlays(out, profile, context.foundation, part.name, part.plays, path, [...transitioned(part.paintTransition, entering === null ? [] : [entering.group]), ...moved], reject, { scope: context.input.scope, values: context.measured ?? [] });
|
|
962
|
-
const values = part.arrangement === null ? {} : { "box-sizing": "border-box", "min-inline-size": "0", ...arrangementValues(part.arrangement, slots, profile, part.overflow) };
|
|
973
|
+
const values = part.arrangement === null ? {} : { "box-sizing": "border-box", ...yields(part) ? { "min-inline-size": "0" } : {}, ...arrangementValues(part.arrangement, slots, profile, part.overflow) };
|
|
963
974
|
if (parentLayout === "native" && part.arrangement?.layout === "inline" && (Object.keys(flowSpace(part, context)).length > 0 || part.extent.kind === "fill")) {
|
|
964
975
|
values.display = "flex";
|
|
965
976
|
if (part.extent.kind !== "fill")
|
|
@@ -987,7 +998,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
|
|
|
987
998
|
if (part.surface !== null)
|
|
988
999
|
Object.assign(values, settled(partSurface, entering?.blurred ?? !1));
|
|
989
1000
|
Object.assign(values, stickyValues(part.sticky, context), anchorClearValues(part.anchorClear, context));
|
|
990
|
-
const [partCondition] = part.at, boxChange = partCondition?.frame ?? null, boxFrame = (border, corners) => part.box === null ? {} : regionFrameValues({ kind: "fields", container: !1, ratio: null, border, corners, safeArea: [] }, { ...slots, "frame-profile": part.box }, part.surface, profile, reject).values, restCorners = boxChange?.corners === null || boxChange === null ? part.boxCorners : part.boxCorners ?? FRAME_CORNERS, boxFields = boxFrame(part.boxBorder, restCorners);
|
|
1001
|
+
const [partCondition] = part.at, boxChange = partCondition?.frame ?? null, boxFrame = (border, corners) => part.box === null ? {} : regionFrameValues({ kind: "fields", container: !1, ratio: part.boxRatio ?? null, border, corners, safeArea: [] }, { ...slots, "frame-profile": part.box }, part.surface, profile, reject, part.overflow.kind !== "visible").values, restCorners = boxChange?.corners === null || boxChange === null ? part.boxCorners : part.boxCorners ?? FRAME_CORNERS, boxFields = boxFrame(part.boxBorder, restCorners);
|
|
991
1002
|
if (part.box !== null && boxChange !== null && partCondition !== void 0) {
|
|
992
1003
|
const spatial = slots["spatial-profile"], bound = spatial === void 0 ? null : conditionBound(context.foundation, spatial, partCondition.condition, profile, reject);
|
|
993
1004
|
if (bound === null)
|
|
@@ -1328,7 +1339,7 @@ export function lowerRegion(spec, foundation, input) {
|
|
|
1328
1339
|
checked(checkLayers("&", spec.parts.length), reject);
|
|
1329
1340
|
if (slots["surface-profile"] !== void 0)
|
|
1330
1341
|
Object.assign(values, profile.of(slots["surface-profile"], "surface"));
|
|
1331
|
-
const framed = spec.frame === null || spec.frameAt === null || spec.frameAt.corners === null ? spec.frame : { ...spec.frame, corners: spec.frame.corners ?? FRAME_CORNERS }, rootFrame = framed === null ? null : regionFrameValues(framed, slots, surface, profile, reject);
|
|
1342
|
+
const framed = spec.frame === null || spec.frameAt === null || spec.frameAt.corners === null ? spec.frame : { ...spec.frame, corners: spec.frame.corners ?? FRAME_CORNERS }, rootFrame = framed === null ? null : regionFrameValues(framed, slots, surface, profile, reject, spec.overflow.kind !== "visible");
|
|
1332
1343
|
if (rootFrame !== null)
|
|
1333
1344
|
Object.assign(values, rootFrame.values);
|
|
1334
1345
|
if (spec.frameAt !== null) {
|
|
@@ -44,7 +44,7 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
|
|
|
44
44
|
}
|
|
45
45
|
return found;
|
|
46
46
|
function measure() {
|
|
47
|
-
const width = document.documentElement.clientWidth, issues = [], counts = { document: 0, viewport: 0, container: 0, clipped: 0, "broken-word": 0, "collapsed-scroller": 0, "block-clipped": 0, spilled: 0, overlap: 0, "focus-clipped": 0 }, pane = container ? scope.getBoundingClientRect() : { left: 0, right: width }, edge = container ? "container" : "viewport", selector = (element) => {
|
|
47
|
+
const width = document.documentElement.clientWidth, issues = [], counts = { document: 0, viewport: 0, container: 0, clipped: 0, "broken-word": 0, "collapsed-scroller": 0, escaped: 0, "block-clipped": 0, spilled: 0, overlap: 0, "focus-clipped": 0 }, pane = container ? scope.getBoundingClientRect() : { left: 0, right: width }, edge = container ? "container" : "viewport", selector = (element) => {
|
|
48
48
|
const parts = [];
|
|
49
49
|
for (let node = element;node !== scope; ) {
|
|
50
50
|
const parent = node.parentElement;
|
|
@@ -214,9 +214,34 @@ export async function layoutOverflow({ nodeLimit, width: expected, container, sm
|
|
|
214
214
|
report("clipped", element, { overflow: Math.round(cut.reach), cut: cut.cut });
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
+
measureEscapes();
|
|
217
218
|
if (fit)
|
|
218
219
|
measureFit();
|
|
219
220
|
return { issues, counts };
|
|
221
|
+
function measureEscapes() {
|
|
222
|
+
const paints = (style) => ["Left", "Right"].some((side) => Number.parseFloat(style.getPropertyValue(`border-${side.toLowerCase()}-width`)) > 0 && style.getPropertyValue(`border-${side.toLowerCase()}-style`) !== "none") || style.backgroundColor !== "transparent" && !/rgba\([^)]*,\s*0\)$/.test(style.backgroundColor) || style.backgroundImage !== "none", control = (element) => /^(?:button|select|textarea|input)$/.test(element.localName) || element.localName === "a" && element.hasAttribute("href") || element.hasAttribute("tabindex"), text = (element) => [...element.childNodes].some((node) => node.nodeType === Node.TEXT_NODE && (node.textContent ?? "").trim() !== "");
|
|
223
|
+
for (const { element, box } of measured) {
|
|
224
|
+
if (!control(element) && !text(element))
|
|
225
|
+
continue;
|
|
226
|
+
if (element.closest("[inert], [aria-hidden='true']"))
|
|
227
|
+
continue;
|
|
228
|
+
let reach = 0;
|
|
229
|
+
for (let node = element.parentElement;node && node !== scope; node = node.parentElement) {
|
|
230
|
+
const style = getComputedStyle(node);
|
|
231
|
+
if (/^(?:absolute|fixed)$/.test(getComputedStyle(element).position) || /^(?:absolute|fixed)$/.test(style.position))
|
|
232
|
+
break;
|
|
233
|
+
if (style.overflowX !== "visible")
|
|
234
|
+
break;
|
|
235
|
+
if (!paints(style))
|
|
236
|
+
continue;
|
|
237
|
+
const edge = node.getBoundingClientRect();
|
|
238
|
+
reach = Math.max(box.right - edge.right, edge.left - box.left);
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
if (reach > 2)
|
|
242
|
+
report("escaped", element, { overflow: Math.round(reach) });
|
|
243
|
+
}
|
|
244
|
+
}
|
|
220
245
|
function measureFit() {
|
|
221
246
|
const native = (element) => /^(?:input|textarea|select)$/.test(element.localName), intended = (element, style) => native(element) || style.textOverflow === "ellipsis" || style.getPropertyValue("-webkit-line-clamp") !== "none" || style.clip !== "auto" || style.clipPath !== "none" || !!element.closest('[aria-roledescription="carousel"], [role="application"]'), held = (element) => {
|
|
222
247
|
if (!element.computedStyleMap)
|
package/dist/render-audit.mjs
CHANGED
|
@@ -263,6 +263,10 @@ const skipReasons = {
|
|
|
263
263
|
what: "text, a control, or a box's painted edge (a card's border and corners) is cut off by overflow hidden or clip (cropped images, artwork and decorative layers do not count)",
|
|
264
264
|
fix: "Make the content fit, truncate it with text-overflow: ellipsis, or use overflow-x: auto if it should scroll."
|
|
265
265
|
},
|
|
266
|
+
escaped: {
|
|
267
|
+
what: "a control or text reaches past the edge of the painted box around it (a card's border or fill), which does not clip it",
|
|
268
|
+
fix: `Let the box hold it: keep a row of controls from shrinking below its buttons (give the text beside it the room to give way, extent: "fill" or truncation), or let the row wrap; do not let content spill over a card's edge.`
|
|
269
|
+
},
|
|
266
270
|
"collapsed-scroller": {
|
|
267
271
|
what: "a scroll area that holds content is collapsed to nothing: everything in it is out of sight",
|
|
268
272
|
fix: 'Give the scroll area a size: let it fill a parent that has a height (extent: "fill" in a stack given a height), or a minimum block size; check its parents for a height of 0.'
|
|
@@ -321,7 +325,7 @@ export function layoutOverflowFindings(runs, scenarios) {
|
|
|
321
325
|
const { scenario, tag: rule, kind, widths, themes, brands, nodes, nodeCount } = group, container = rule === NARROW_RULE, sorted = [...widths].sort((a, b) => a - b);
|
|
322
326
|
return {
|
|
323
327
|
rule,
|
|
324
|
-
severity: findingSeverity(rule),
|
|
328
|
+
severity: kind === "escaped" ? "review" : findingSeverity(rule),
|
|
325
329
|
file: files.get(scenario) ?? scenario,
|
|
326
330
|
line: 1,
|
|
327
331
|
column: 1,
|