@reqvire-org/ads 0.5.6 → 0.5.7
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 +21 -0
- package/dist/analysis/owner-analysis-key.mjs +1 -1
- package/dist/analysis/owner-source.mjs +10 -2
- package/dist/construction-spec.d.mts +15 -0
- package/dist/construction-spec.mjs +39 -5
- package/dist/end-alignment.mjs +11 -0
- package/dist/lowering-region-layout.mjs +4 -2
- package/dist/owner-analysis-check.mjs +22 -0
- package/dist/ownership-model.mjs +1 -1
- package/dist/recipe-macro.d.mts +9 -0
- package/dist/recipe-model.mjs +2 -2
- package/dist/region-lowering.mjs +23 -13
- package/dist/showcase/client.bundle.js +25 -25
- package/dist/showcase/http-client.bundle.js +10 -10
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +3 -3
- package/dist/skills/ads-designer/references/recipes.md +4 -1
- package/dist/skills/ads-import/references/recipes.md +4 -1
- package/dist/skills/ads-port/references/recipes.md +4 -1
- package/dist/token-shapes.mjs +3 -2
- package/docs/CHANGELOG.md +40 -16
- package/docs/LANGUAGE.md +2 -0
- package/docs/RULES.md +6 -3
- package/package.json +1 -1
package/dist/ads-errors.mjs
CHANGED
|
@@ -649,6 +649,13 @@ export const choiceErrors = {
|
|
|
649
649
|
message: (failure) => `Part "${failure.part}" ends its content ${Math.abs(failure.distancePx)}px ${failure.distancePx > 0 ? "past" : "short of"} the line part "${failure.other}" ends on, under ${failure.context}: it is probably not on the same grid or gutter.`,
|
|
650
650
|
repair: "Put the block on the same tracks and gutter as its siblings, or give its frame the inline end padding that ends its content on their line."
|
|
651
651
|
},
|
|
652
|
+
"focus-unshown": {
|
|
653
|
+
group: "accessibility-semantics",
|
|
654
|
+
rule: 'Focus stays visible (WCAG 2.2 2.4.7). A field that shows no outline of its own (`focus: { shownBy: "container" }`) is shown by a container in the same component whose root names it: `focus: { within: ".field" }` draws the focus profile\'s outline around the whole field while it has keyboard focus.',
|
|
655
|
+
guides: [RECIPES, "ads://guides/accessibility"],
|
|
656
|
+
message: (failure) => `${failure.selector} shows no focus outline of its own, and no root in this component shows its focus (\`focus: { within: "${failure.selector}" }\`): its keyboard focus is invisible.`,
|
|
657
|
+
repair: 'Give the box around the field `focus: { within: "<the field\'s class>" }`, or remove `shownBy` so the field draws its own outline.'
|
|
658
|
+
},
|
|
652
659
|
"document-duplicate": {
|
|
653
660
|
group: "conflict",
|
|
654
661
|
rule: 'A design system has at most one document pattern (`element: "document"`): it is the page\'s `<html>`.',
|
|
@@ -3486,6 +3493,20 @@ export const runtimeErrors = {
|
|
|
3486
3493
|
message: (review) => `Summary ${review.part === "&" ? "root" : `part "${review.part}"`} removes its marker and renders no artwork.`,
|
|
3487
3494
|
repair: "Render a chevron (a visual part or a public Icon) chosen by the controlled open state, or keep the native marker."
|
|
3488
3495
|
},
|
|
3496
|
+
"text-layout-inline": {
|
|
3497
|
+
group: "conflict",
|
|
3498
|
+
rule: 'Text alignment and block wrapping (`textAlign`, `wrap: "truncate" | "balance" | "pretty"`) apply to a block of text: on a part rendered as an inline element (a <span>, <a>, <code>) that has no arrangement or box of its own, they change nothing.',
|
|
3499
|
+
guides: [RECIPES],
|
|
3500
|
+
message: (review) => `Part "${review.part}" sets ${review.setting} on an inline <${review.element}>, where it has no effect.`,
|
|
3501
|
+
repair: "Render the part as a block element (a <p> or <div>), give it an arrangement or a box, or set the alignment on the block that holds it."
|
|
3502
|
+
},
|
|
3503
|
+
"text-profile-unreached": {
|
|
3504
|
+
group: "conflict",
|
|
3505
|
+
rule: "A composite's text profile styles its text parts (and a root that binds its own `text`): on a root with neither, it reaches no element.",
|
|
3506
|
+
guides: [RECIPES],
|
|
3507
|
+
message: (review) => `The profile's text profile "${review.profile}" reaches no element: the root binds no \`text\` and has no text parts.`,
|
|
3508
|
+
repair: 'Declare the text as a `kind: "text"` part, bind `text` on the root, or remove the text profile from the composite.'
|
|
3509
|
+
},
|
|
3489
3510
|
"border-paint-missing": {
|
|
3490
3511
|
group: "conflict",
|
|
3491
3512
|
rule: "A frame that draws a border (`borderWidth`) has a paint for it: a surface of the element, at rest or under a state, sets `borderColor` (or a side's colour). Without one CSS paints the border in the text colour, almost always a forgotten paint. Listed for review: the text colour may be meant.",
|
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { SyntaxKind, isExportAssignment, isExportDeclaration, isImportDeclaration } from "typescript/ast";
|
|
3
3
|
import { digest } from "../digest.mjs";
|
|
4
4
|
import { memoProgram } from "./context.mjs";
|
|
5
|
-
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/
|
|
5
|
+
export const OWNER_ANALYSIS_SCHEMA = "ads-owner-analysis/15";
|
|
6
6
|
export function canonical(value) {
|
|
7
7
|
return JSON.stringify(value, (_key, item) => {
|
|
8
8
|
if (item instanceof Map)
|
|
@@ -207,7 +207,7 @@ function insideMap(node, ancestor) {
|
|
|
207
207
|
return !0;
|
|
208
208
|
return !1;
|
|
209
209
|
}
|
|
210
|
-
const isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), NO_CLASSES = { fragments: [], calls: [], markers: [], placement: [], bindings: [] };
|
|
210
|
+
const isLoop = (node) => isForStatement(node) || isForOfStatement(node) || isForInStatement(node) || isWhileStatement(node) || isDoStatement(node), INLINE_TEXT_TAGS = ["span", "a", "code", "strong", "em", "b", "i", "small", "abbr", "cite", "q", "kbd", "mark", "time", "sub", "sup", "s", "u", "label"], NO_CLASSES = { fragments: [], calls: [], markers: [], placement: [], bindings: [] };
|
|
211
211
|
function validateReferences(foundation, spec) {
|
|
212
212
|
if (typeof spec !== "object" || spec === null)
|
|
213
213
|
return null;
|
|
@@ -942,6 +942,11 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
942
942
|
await pointerTransparent(opening, "&", context, resolve);
|
|
943
943
|
if (region.overflow.kind === "scroll")
|
|
944
944
|
scrollReview(opening, "&", node);
|
|
945
|
+
if (region.profile !== null && region.text === null) {
|
|
946
|
+
const selected = selectedProfile(foundation, region.profile, region.select), textProfile = selected.kind === "ok" && selected.value.kind === "composite" ? selected.value.fields.get("text-profile") : void 0, hasText = (list) => list.some((part) => part.content.kind === "text" || part.frame !== null || part.text !== null || hasText(part.parts));
|
|
947
|
+
if (textProfile !== void 0 && !hasText(region.parts))
|
|
948
|
+
review(opening, { kind: "text-profile-unreached", profile: textProfile });
|
|
949
|
+
}
|
|
945
950
|
}
|
|
946
951
|
const matched = new Map([["", opening]]), tinted = new Set(parsed.value.kind === "region" ? surfacedElements(foundation, parsed.value).flatMap((element) => element.visual && (element.surface !== null || element.when.length > 0) ? [element.element] : []) : []), decorative = new Set, margined = new Set;
|
|
947
952
|
let schemed = !1;
|
|
@@ -987,8 +992,11 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
987
992
|
const element = values.tag(match.opening);
|
|
988
993
|
if (UA_MARGIN_TAGS.includes(element))
|
|
989
994
|
margined.add([...part.within, part.selector].join(" "));
|
|
990
|
-
if (UA_CONTROL_TAGS.includes(element))
|
|
995
|
+
if (UA_CONTROL_TAGS.includes(element) && match.classes.fragments.length === 0)
|
|
991
996
|
native.add([...part.within, part.selector].join(" "));
|
|
997
|
+
const domParent = elementOf(match.opening).parent, parentClass = parent === opening ? void 0 : expression(attr(parent, "className")), parentRecipes = parentClass === void 0 ? 0 : split(await resolve(parentClass, context), parentClass).fragments.length;
|
|
998
|
+
if (domParent !== void 0 && openingOf(domParent) === parent && parentRecipes === 0 && INLINE_TEXT_TAGS.includes(element) && part.blockText !== null)
|
|
999
|
+
review(match.opening, { kind: "text-layout-inline", part: part.name, element, setting: part.blockText });
|
|
992
1000
|
const hostless = part.pseudo.find((pseudo) => !pseudoHosted(pseudo, element));
|
|
993
1001
|
if (hostless !== void 0)
|
|
994
1002
|
return fail(match.opening, { kind: "pseudo-host-unsupported", part: part.name, pseudo: hostless, element });
|
|
@@ -707,6 +707,11 @@ export interface RegionPart {
|
|
|
707
707
|
* of a checkbox whose `<input>` is hidden) and shows the focus indicator while that control has keyboard focus.
|
|
708
708
|
*/
|
|
709
709
|
readonly focusOf: string | null;
|
|
710
|
+
/**
|
|
711
|
+
* `focus: { shownBy: "container" }`: this part (a text field inside a composer's box) shows no focus outline of its
|
|
712
|
+
* own; the container that names it with `focus: { within }` draws the indicator around the whole field.
|
|
713
|
+
*/
|
|
714
|
+
readonly focusShownBy: boolean;
|
|
710
715
|
/**
|
|
711
716
|
* `drawnBy: "<sibling part>"`: this part is a native control (a checkbox's `<input>`) that the named part draws.
|
|
712
717
|
* It is invisible and takes no room, laid over that part at its frame's size, so pointer and keyboard still
|
|
@@ -891,6 +896,11 @@ export interface RegionSpec {
|
|
|
891
896
|
/** The root's entrance; never on a top-layer root, whose layer motion is its entrance. */
|
|
892
897
|
readonly enter: EnterSpec | null;
|
|
893
898
|
/** The root stays at an edge of its scrolling container; never on a top-layer root, which the top layer places. */
|
|
899
|
+
/**
|
|
900
|
+
* `focus: { within: ".field" }`: the nearest focus profile's indicator on this root while the named field inside it
|
|
901
|
+
* has keyboard focus (`&:has(.field:focus-visible)`): a composer's box around its text field.
|
|
902
|
+
*/
|
|
903
|
+
readonly focusWithin: string | null;
|
|
894
904
|
readonly sticky: StickySpec | null;
|
|
895
905
|
readonly parts: readonly RegionPart[];
|
|
896
906
|
/** Parts exposed as public rows, in row order, for a parent's `alignRows`. */
|
|
@@ -974,6 +984,11 @@ export interface DeclaredPart {
|
|
|
974
984
|
readonly playsAlways: readonly string[];
|
|
975
985
|
/** A scroll container: it should be reachable by keyboard. */
|
|
976
986
|
readonly scrolls: boolean;
|
|
987
|
+
/**
|
|
988
|
+
* A text part's setting that needs a block of text (`textAlign: "end"`, `wrap: "truncate"`), where the part has no
|
|
989
|
+
* arrangement, box or frame of its own: on an inline element it changes nothing. `null` otherwise.
|
|
990
|
+
*/
|
|
991
|
+
readonly blockText: string | null;
|
|
977
992
|
/** An `accessibility` declaration: its element must be a text-entry control (`<input>` of a text type, `<textarea>`, `<select>`). */
|
|
978
993
|
readonly declaresBoundary: boolean;
|
|
979
994
|
/** Whether the part declares `normalize.resize`: its element is a `<textarea>`. */
|
|
@@ -73,12 +73,23 @@ export function declaredParts(spec) {
|
|
|
73
73
|
case "artwork":
|
|
74
74
|
return [{ ...plainPart, name: spec.part.name, path: `recipe.parts.${spec.part.name}`, selector: spec.part.selector, required: spec.part.required, kind: "visual" }];
|
|
75
75
|
case "region":
|
|
76
|
-
return regionParts(spec.parts, [], "recipe");
|
|
76
|
+
return regionParts(spec.parts, [], "recipe", spec.arrangement.layout);
|
|
77
77
|
case "grid":
|
|
78
78
|
return [];
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
const plainPart = { repeat: !1, within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null }
|
|
81
|
+
const plainPart = { repeat: !1, within: [], pseudo: [], element: null, media: "bound", truncated: !1, clamped: !1, balanced: !1, scrolls: !1, blockText: null, declaresBoundary: !1, resizes: !1, playsAlways: [], scheme: null };
|
|
82
|
+
function blockText(part, parentLayout) {
|
|
83
|
+
if (parentLayout !== null && parentLayout !== "native")
|
|
84
|
+
return null;
|
|
85
|
+
if (part.content.kind !== "text" || part.arrangement !== null || part.box !== null || part.frame !== null)
|
|
86
|
+
return null;
|
|
87
|
+
if (part.textLayout.align !== null)
|
|
88
|
+
return `textAlign: "${part.textLayout.align}"`;
|
|
89
|
+
const wrap = part.textLayout.wrap;
|
|
90
|
+
return wrap === "truncate" || wrap === "balance" || wrap === "pretty" ? `wrap: "${wrap}"` : null;
|
|
91
|
+
}
|
|
92
|
+
const regionParts = (parts, within, parent, parentLayout) => parts.flatMap((part) => [
|
|
82
93
|
{
|
|
83
94
|
name: part.name,
|
|
84
95
|
path: `${parent}.parts.${part.name}`,
|
|
@@ -94,12 +105,13 @@ const plainPart = { repeat: !1, within: [], pseudo: [], element: null, media: "b
|
|
|
94
105
|
clamped: part.textLayout.lines !== null,
|
|
95
106
|
balanced: part.textLayout.wrap === "balance",
|
|
96
107
|
scrolls: part.overflow.kind === "scroll",
|
|
108
|
+
blockText: blockText(part, parentLayout),
|
|
97
109
|
declaresBoundary: part.accessibility !== null,
|
|
98
110
|
resizes: part.normalize.some(([property]) => property === "resize"),
|
|
99
111
|
scheme: part.scheme,
|
|
100
112
|
playsAlways: part.plays.flatMap((play) => play.condition === null ? [play.sequence] : [])
|
|
101
113
|
},
|
|
102
|
-
...regionParts(part.parts, [...within, part.selector], `${parent}.parts.${part.name}
|
|
114
|
+
...regionParts(part.parts, [...within, part.selector], `${parent}.parts.${part.name}`, part.arrangement?.layout ?? null)
|
|
103
115
|
]);
|
|
104
116
|
export function declaredMeasured(spec) {
|
|
105
117
|
switch (spec.kind) {
|
|
@@ -1143,6 +1155,7 @@ function regionPart(name, value, read, path, nested) {
|
|
|
1143
1155
|
sticky: stickySpec(part.sticky, `${path}.sticky`, read),
|
|
1144
1156
|
outset: outsetSpec(part.outset, `${path}.outset`, read),
|
|
1145
1157
|
focusOf: focusSource(part.focus, `${path}.focus`, read),
|
|
1158
|
+
focusShownBy: focusShownBy(part.focus, `${path}.focus`, read),
|
|
1146
1159
|
drawnBy: part.drawnBy === void 0 ? null : read.string(part.drawnBy, `${path}.drawnBy`),
|
|
1147
1160
|
anchorClear: anchorClear(part.anchorClear, `${path}.anchorClear`, read),
|
|
1148
1161
|
scheme: partScheme(part, content, path, read),
|
|
@@ -1168,9 +1181,28 @@ function focusSource(value, path, read) {
|
|
|
1168
1181
|
if (value === void 0)
|
|
1169
1182
|
return null;
|
|
1170
1183
|
const declared = read.object(value, path);
|
|
1171
|
-
read.only(declared, path, ["of"]);
|
|
1184
|
+
read.only(declared, path, ["of", "shownBy"]);
|
|
1185
|
+
if (declared.shownBy !== void 0)
|
|
1186
|
+
return declared.of === void 0 ? null : read.invalid(path, "`of` or `shownBy`, not both");
|
|
1172
1187
|
return read.string(declared.of, `${path}.of`);
|
|
1173
1188
|
}
|
|
1189
|
+
function focusShownBy(value, path, read) {
|
|
1190
|
+
if (value === void 0)
|
|
1191
|
+
return !1;
|
|
1192
|
+
const declared = read.object(value, path);
|
|
1193
|
+
if (declared.shownBy === void 0)
|
|
1194
|
+
return !1;
|
|
1195
|
+
read.literal(declared.shownBy, `${path}.shownBy`, ["container"]);
|
|
1196
|
+
return !0;
|
|
1197
|
+
}
|
|
1198
|
+
function focusWithin(value, read) {
|
|
1199
|
+
if (value === void 0)
|
|
1200
|
+
return null;
|
|
1201
|
+
const declared = read.object(value, "recipe.focus");
|
|
1202
|
+
read.only(declared, "recipe.focus", ["within"]);
|
|
1203
|
+
const selector = read.string(declared.within, "recipe.focus.within");
|
|
1204
|
+
return /^\.[A-Za-z_][\w-]*$/.test(selector) ? selector : read.invalid("recipe.focus.within", 'one class selector (".ds-composer-field")');
|
|
1205
|
+
}
|
|
1174
1206
|
function parseParts(value, read, path, nested) {
|
|
1175
1207
|
if (value === void 0)
|
|
1176
1208
|
return [];
|
|
@@ -1275,7 +1307,8 @@ function region(authored, read) {
|
|
|
1275
1307
|
"extent",
|
|
1276
1308
|
"anchorClear",
|
|
1277
1309
|
"overlap",
|
|
1278
|
-
"geometryTransition"
|
|
1310
|
+
"geometryTransition",
|
|
1311
|
+
"focus"
|
|
1279
1312
|
]);
|
|
1280
1313
|
const layout = spec.layout === void 0 ? "native" : read.literal(spec.layout, "recipe.layout", ROOT_LAYOUTS), normalized = normalization(spec.normalize, "recipe.normalize", REGION_NORMALIZE, REGION_NORMALIZE, "selector", read), parts = parseParts(spec.parts, read, "recipe", !1), measured = measuredValues(spec.measured, "recipe.measured", read);
|
|
1281
1314
|
uniqueMeasured(measured, parts, read);
|
|
@@ -1318,6 +1351,7 @@ function region(authored, read) {
|
|
|
1318
1351
|
frameAt: frameCondition(spec.at, regionFrame(spec.frame, read), read),
|
|
1319
1352
|
plays: layer !== null && rootStates.plays.length > 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.play" }) : rootStates.plays,
|
|
1320
1353
|
sticky: layer !== null && spec.sticky !== void 0 ? read.reject({ kind: "field-unsupported", construction: "region", path: "recipe.sticky" }) : stickySpec(spec.sticky, "recipe.sticky", read),
|
|
1354
|
+
focusWithin: focusWithin(spec.focus, read),
|
|
1321
1355
|
parts,
|
|
1322
1356
|
exposeRows,
|
|
1323
1357
|
layer,
|
package/dist/end-alignment.mjs
CHANGED
|
@@ -7,6 +7,13 @@ function borderedAtEnd(fields, border) {
|
|
|
7
7
|
const width = sideWidth(Object.fromEntries(fields), "inline-end");
|
|
8
8
|
return width !== void 0 && !/^0(px)?$/.test(width.trim());
|
|
9
9
|
}
|
|
10
|
+
function endsRagged(arrangement, parts) {
|
|
11
|
+
if (arrangement === null || arrangement.layout !== "inline")
|
|
12
|
+
return !1;
|
|
13
|
+
if (arrangement.justify !== null && /end|space-/.test(arrangement.justify))
|
|
14
|
+
return !1;
|
|
15
|
+
return !parts.some((part) => part.extent.kind === "fill");
|
|
16
|
+
}
|
|
10
17
|
export function endInsetOf(foundation, spec) {
|
|
11
18
|
switch (spec.kind) {
|
|
12
19
|
case "region": {
|
|
@@ -24,6 +31,8 @@ export function endInsetOf(foundation, spec) {
|
|
|
24
31
|
const surfaceName = spec.surface ?? (selected.value.kind === "composite" ? selected.value.fields.get("surface-profile") : void 0), surface = surfaceName === void 0 ? null : selectedProfile(foundation, surfaceName);
|
|
25
32
|
if (surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || borderedAtEnd(frame.value.fields, spec.frame?.border ?? null))
|
|
26
33
|
return [];
|
|
34
|
+
if (endsRagged(spec.arrangement, spec.parts))
|
|
35
|
+
return null;
|
|
27
36
|
const end = frameInlineInsets(Object.fromEntries(frame.value.fields)).end;
|
|
28
37
|
return end === void 0 ? [] : [end];
|
|
29
38
|
}
|
|
@@ -69,6 +78,8 @@ export function stackPartsOf(foundation, spec) {
|
|
|
69
78
|
const surface = part.surface === null ? null : selectedProfile(foundation, part.surface);
|
|
70
79
|
if (surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || borderedAtEnd(frame.value.fields, null))
|
|
71
80
|
return [{ part: part.name, kind: "box", inset: [] }];
|
|
81
|
+
if (endsRagged(part.arrangement, part.parts))
|
|
82
|
+
return [];
|
|
72
83
|
const end = frameInlineInsets(Object.fromEntries(frame.value.fields)).end;
|
|
73
84
|
return [{ part: part.name, kind: "box", inset: end === void 0 ? [] : [end] }];
|
|
74
85
|
});
|
|
@@ -148,7 +148,7 @@ export function textLayoutValues(layout, part, hasText) {
|
|
|
148
148
|
export function growsWithContent(values) {
|
|
149
149
|
return values["min-block-size"] !== void 0 && values["min-block-size"] !== "0" && values["block-size"] === void 0 && values["max-block-size"] === void 0 && values["aspect-ratio"] === void 0 && values.overflow === void 0;
|
|
150
150
|
}
|
|
151
|
-
export function extentValues(extent, parent, part, parentGrows = !1) {
|
|
151
|
+
export function extentValues(extent, parent, part, parentGrows = !1, parentWraps = !1) {
|
|
152
152
|
switch (extent.kind) {
|
|
153
153
|
case "content":
|
|
154
154
|
return ok({});
|
|
@@ -156,7 +156,9 @@ export function extentValues(extent, parent, part, parentGrows = !1) {
|
|
|
156
156
|
if (parent !== "stack" && parent !== "inline")
|
|
157
157
|
return err({ kind: "extent-parent-unsupported", part, layout: parent });
|
|
158
158
|
const main = parent === "stack" ? "block" : "inline", values = { "flex-grow": "1", "flex-shrink": "1", "flex-basis": parent === "stack" ? "auto" : "0" };
|
|
159
|
-
if (
|
|
159
|
+
if (parent === "inline" && parentWraps)
|
|
160
|
+
values["min-inline-size"] = "min-content";
|
|
161
|
+
else if (!(parent === "stack" && parentGrows))
|
|
160
162
|
values[`min-${main}-size`] = "0";
|
|
161
163
|
if (extent.axis === "both")
|
|
162
164
|
values["align-self"] = "stretch";
|
|
@@ -466,6 +466,7 @@ export function checkFindings(inputs, check, publics = null) {
|
|
|
466
466
|
advisories.push(...counterFindings(inputs, analyzedOwners(check.outcomes)));
|
|
467
467
|
diagnostics.push(...documentFindings(inputs, analyzedOwners(check.outcomes)));
|
|
468
468
|
diagnostics.push(...endAlignmentFindings(inputs, analyzedOwners(check.outcomes), check.foundation));
|
|
469
|
+
diagnostics.push(...focusShownFindings(inputs, analyzedOwners(check.outcomes)));
|
|
469
470
|
return { diagnostics: distinct(diagnostics), advisories };
|
|
470
471
|
}
|
|
471
472
|
function targetFindings(inputs, owners, foundation, spacing) {
|
|
@@ -495,6 +496,27 @@ function targetFindings(inputs, owners, foundation, spacing) {
|
|
|
495
496
|
}
|
|
496
497
|
return { diagnostics, advisories: [...advisories.values()] };
|
|
497
498
|
}
|
|
499
|
+
function focusShownFindings(inputs, owners) {
|
|
500
|
+
const findings = [];
|
|
501
|
+
for (const facts of owners.values()) {
|
|
502
|
+
const shown = new Set;
|
|
503
|
+
for (const style of facts.styles.values())
|
|
504
|
+
for (const match of style.css.matchAll(/:has\((\.[\w-]+):focus-visible\)/g))
|
|
505
|
+
shown.add(match[1] ?? "");
|
|
506
|
+
for (const style of facts.styles.values()) {
|
|
507
|
+
const [first] = style.origins;
|
|
508
|
+
if (first?.kind !== "point")
|
|
509
|
+
continue;
|
|
510
|
+
for (const match of style.css.matchAll(/>\s*(\.[\w-]+):focus-visible\s*\{\s*outline-style:\s*none/g)) {
|
|
511
|
+
const selector = match[1] ?? "";
|
|
512
|
+
if (shown.has(selector))
|
|
513
|
+
continue;
|
|
514
|
+
findings.push(...findingsOf(inputs, { kind: "owner", failure: { kind: "source", origin: { ...first, file: path.join(inputs.dsRoot, first.file) }, problem: { kind: "focus-unshown", selector } } }));
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
return findings;
|
|
519
|
+
}
|
|
498
520
|
function endAlignmentFindings(inputs, owners, foundation) {
|
|
499
521
|
const insets = new Map;
|
|
500
522
|
for (const facts of owners.values())
|
package/dist/ownership-model.mjs
CHANGED
|
@@ -107,7 +107,7 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
|
|
|
107
107
|
"ads-between": { surface: binding, frame: binding },
|
|
108
108
|
"ads-content": { counter: () => !0, counters: () => !0, style: () => !0, separator: () => !0, prefix: () => !0, suffix: () => !0 },
|
|
109
109
|
"ads-accessibility": { boundary: () => !0, reason: () => !0 },
|
|
110
|
-
"ads-focus": { of: () => !0 },
|
|
110
|
+
"ads-focus": { of: () => !0, "shown-by": oneOf("container"), within: (value) => /^\.[A-Za-z_][\w-]*$/.test(value) },
|
|
111
111
|
"ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value) },
|
|
112
112
|
"ads-outset": { block: outsetSpacing, inline: outsetSpacing },
|
|
113
113
|
"ads-sticky": { edge: oneOf("block-start", "block-end"), clear: oneOf("none", "block-start") },
|
package/dist/recipe-macro.d.mts
CHANGED
|
@@ -388,8 +388,17 @@ export interface RecipeSpec {
|
|
|
388
388
|
* This part is the drawn stand-in of a native control beside it (the box of a checkbox whose `<input>`
|
|
389
389
|
* is visually hidden): it shows the focus profile's indicator while the named sibling part has keyboard focus.
|
|
390
390
|
*/
|
|
391
|
+
/**
|
|
392
|
+
* `{ of: "<sibling part>" }`: a drawn stand-in shows a hidden native control's focus. `{ shownBy: "container" }`: a
|
|
393
|
+
* text field whose focus the container around it shows. `{ within: ".field" }` (a root): while that field inside it
|
|
394
|
+
* has keyboard focus, the root draws the nearest focus profile's outline (a composer's box around its textarea).
|
|
395
|
+
*/
|
|
391
396
|
readonly focus?: {
|
|
392
397
|
readonly of: string;
|
|
398
|
+
} | {
|
|
399
|
+
readonly shownBy: "container";
|
|
400
|
+
} | {
|
|
401
|
+
readonly within: string;
|
|
393
402
|
};
|
|
394
403
|
/**
|
|
395
404
|
* A native control (a checkbox's `<input>`) that the named sibling part draws: invisible and taking no room, it
|
package/dist/recipe-model.mjs
CHANGED
|
@@ -103,7 +103,7 @@ const NESTED = new Set(["layout", "parts", "cells", "at", "when", "frame", "sele
|
|
|
103
103
|
"ads-pseudo": ["when", "content"]
|
|
104
104
|
};
|
|
105
105
|
function body(node, spec) {
|
|
106
|
-
const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "play", "pseudo", "counter", "between"] : []] : NESTED_IN[node.name] ?? [], nestedKey = (key) => NESTED.has(key) && !(node.name === "ads-pseudo" && key === "frame");
|
|
106
|
+
const allowed = node.name === "ads-recipe" ? ["layout", "parts", "cells", "at", "when", "frame", "select", "alignRows", "paintTransition", "geometryTransition", "snap", ...node.parent?.type === "root" ? ["normalize", "theme", "layer", "measured", "paints", "enter", "sticky", "play", "pseudo", "counter", "between", "focus"] : []] : NESTED_IN[node.name] ?? [], nestedKey = (key) => NESTED.has(key) && !(node.name === "ads-pseudo" && key === "frame");
|
|
107
107
|
for (const field of Object.keys(spec))
|
|
108
108
|
if (nestedKey(field))
|
|
109
109
|
check(allowed.includes(field), `Unsupported ${field} in ${node.name}`);
|
|
@@ -129,7 +129,7 @@ function body(node, spec) {
|
|
|
129
129
|
if (spec.outset !== void 0)
|
|
130
130
|
clause(node, "ads-outset", "", only(spec.outset, ["block", "inline"]));
|
|
131
131
|
if (spec.focus !== void 0)
|
|
132
|
-
clause(node, "ads-focus", "", only(spec.focus, ["of"]));
|
|
132
|
+
clause(node, "ads-focus", "", only(spec.focus, ["of", "shownBy", "within"]));
|
|
133
133
|
if (spec.play !== void 0)
|
|
134
134
|
clause(node, "ads-play", "", only(spec.play, ["sequence", "order"]));
|
|
135
135
|
if (spec.counter !== void 0)
|
package/dist/region-lowering.mjs
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "./construction-output.mjs";
|
|
29
29
|
import { settled } from "./lowering-enter.mjs";
|
|
30
30
|
import { checkPlaceholderContrast, checkProgressContrast } from "./placeholder-contrast.mjs";
|
|
31
|
-
import { fixedLength, lowerLayer,
|
|
31
|
+
import { fixedLength, lowerLayer, ownsPlacement } from "./lowering-layer.mjs";
|
|
32
32
|
import { RATIO_SUFFIX, focalPosition, intrinsicInlineSize, measuredFallback, measuredProperty, measuredWrites, positions } from "./measured-geometry.mjs";
|
|
33
33
|
import { paintProperty, paintTokens, paintWrites } from "./runtime-paint.mjs";
|
|
34
34
|
import { conditionBound, conditionQueries, geometryOf, tierBelowQuery } from "./spatial-reading.mjs";
|
|
@@ -482,7 +482,7 @@ function lowerVector(part, stroke, path, context) {
|
|
|
482
482
|
out.rule(under(condition, path), { ...checked(vectorStateValues(part.name, surface, profile.of(surface, "surface")), reject) });
|
|
483
483
|
writeConditioned(part, path, {}, context);
|
|
484
484
|
}
|
|
485
|
-
function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overlapping = null, stateGaps = []) {
|
|
485
|
+
function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overlapping = null, stateGaps = [], parentWraps = !1) {
|
|
486
486
|
for (const part of parts) {
|
|
487
487
|
const source = part.focusOf === null ? void 0 : parts.find((other) => other.name === part.focusOf);
|
|
488
488
|
if (source === void 0)
|
|
@@ -495,6 +495,9 @@ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overl
|
|
|
495
495
|
"outline-style": "solid"
|
|
496
496
|
});
|
|
497
497
|
}
|
|
498
|
+
for (const part of parts)
|
|
499
|
+
if (part.focusShownBy)
|
|
500
|
+
context.out.rule(`${parent} > ${part.selector}:focus-visible`, { "outline-style": "none" });
|
|
498
501
|
for (const part of parts) {
|
|
499
502
|
const drawing = part.drawnBy === null ? void 0 : parts.find((other) => other.name === part.drawnBy);
|
|
500
503
|
if (drawing === void 0)
|
|
@@ -505,7 +508,7 @@ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overl
|
|
|
505
508
|
context.out.rule(`${parent} > ${part.selector}`, { position: "absolute", "inline-size": inline, "block-size": block, "margin-block": "0", "margin-inline": "0", opacity: "0", "z-index": "1" });
|
|
506
509
|
}
|
|
507
510
|
writePartSpace(parts, parent, layout, gap, context, context.carry);
|
|
508
|
-
const lowered = parts.map((part) => lowerPart(part, parent, layout, context, parentGrows, overlapping));
|
|
511
|
+
const lowered = parts.map((part) => lowerPart(part, parent, layout, context, parentGrows, overlapping, parentWraps));
|
|
509
512
|
if (layout !== "inline" && layout !== "stack")
|
|
510
513
|
return;
|
|
511
514
|
const axes = layout === "inline" ? ["inline"] : ["block"], pairs = lowered.flatMap((first, index) => {
|
|
@@ -575,15 +578,15 @@ function writePartSpace(parts, parent, layout, gap, context, carry = !1) {
|
|
|
575
578
|
out.rule(`&:not(:last-child):has(> ${part.selector}:last-child)`, { "margin-block-end": `max(0px, calc(${after} - var(${FLOW_GAP}, 0px)))` });
|
|
576
579
|
}
|
|
577
580
|
}
|
|
578
|
-
const FLOW_GAP = "--ads-flow-gap";
|
|
579
|
-
function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping = null) {
|
|
581
|
+
const FLOW_GAP = "--ads-flow-gap", keepsWords = (part) => part.textLayout.wrap !== "truncate" && part.textLayout.wrap !== "anywhere" && part.frame === null && part.box === null;
|
|
582
|
+
function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping = null, parentWraps = !1) {
|
|
580
583
|
const { out, profile, slots, reject } = context, path = `${parent} > ${part.selector}`;
|
|
581
584
|
if (part.content.kind === "vector") {
|
|
582
585
|
lowerVector(part, part.content.stroke, path, context);
|
|
583
586
|
return null;
|
|
584
587
|
}
|
|
585
588
|
if (part.content.kind === "component") {
|
|
586
|
-
writeConditioned(part, path, checked(extentValues(part.extent, parentLayout, part.name, parentGrows), reject), context);
|
|
589
|
+
writeConditioned(part, path, checked(extentValues(part.extent, parentLayout, part.name, parentGrows, parentWraps && keepsWords(part)), reject), context);
|
|
587
590
|
return null;
|
|
588
591
|
}
|
|
589
592
|
const partSurface = part.surface === null ? {} : profile.of(part.surface, "surface"), moving = partMotion(path, part.effects, context), collapsible = part.collapsed || part.geometryWhen.some((state) => state.collapsed !== null), axis = parentLayout === "inline" ? "inline" : parentLayout === "stack" ? "block" : null;
|
|
@@ -677,7 +680,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
|
|
|
677
680
|
const partSnap = part.arrangement?.snap ?? null, snapped = partSnap === null ? null : checked(snapValues(partSnap, part.overflow, part.name), reject);
|
|
678
681
|
if (snapped !== null)
|
|
679
682
|
add(snapped.container, "snap");
|
|
680
|
-
add(checked(extentValues(part.extent, parentLayout, part.name, parentGrows), reject), "extent");
|
|
683
|
+
add(checked(extentValues(part.extent, parentLayout, part.name, parentGrows, parentWraps && keepsWords(part) && values["min-inline-size"] === void 0), reject), "extent");
|
|
681
684
|
if (parentLayout === "layered")
|
|
682
685
|
add(LAYER, "layer");
|
|
683
686
|
if (part.outset !== null) {
|
|
@@ -724,7 +727,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
|
|
|
724
727
|
if (part.presence === "assistive")
|
|
725
728
|
out.rule(path, { ...ASSISTIVE_ONLY });
|
|
726
729
|
}
|
|
727
|
-
lowerParts(part.parts, path, part.arrangement?.layout ?? "native", values.gap ?? values["column-gap"], part.required && context.withinOptional !== !0 ? context : { ...context, withinOptional: !0 }, growsWithContent(values), partGeometry.overlap, partGeometry.gaps);
|
|
730
|
+
lowerParts(part.parts, path, part.arrangement?.layout ?? "native", values.gap ?? values["column-gap"], part.required && context.withinOptional !== !0 ? context : { ...context, withinOptional: !0 }, growsWithContent(values), partGeometry.overlap, partGeometry.gaps, values["flex-wrap"] === "wrap");
|
|
728
731
|
return target;
|
|
729
732
|
}
|
|
730
733
|
const visualOf = (input, part) => input.visuals?.get(part) ?? input.visual;
|
|
@@ -982,14 +985,12 @@ export function lowerRegion(spec, foundation, input) {
|
|
|
982
985
|
const placing = layer.kind === "measured-popover" ? void 0 : spec.measured.find((value) => positions(value.property));
|
|
983
986
|
if (placing !== void 0)
|
|
984
987
|
return reject({ kind: "measured-property-unsupported", element: "&", name: placing.name, property: placing.property, type: placing.type, reason: "layer-placement" });
|
|
985
|
-
|
|
988
|
+
const measured = checked(measuredWrites(input.scope, spec.measured, "&", layered.value.root, frameSupplied), reject);
|
|
989
|
+
out.rule("&", { ...layered.value.root, ...measured, ...rootPaints });
|
|
986
990
|
for (const rule of layered.value.rules)
|
|
987
991
|
out.rule(rule.selector, { ...rule.values }, rule.condition ?? void 0);
|
|
988
992
|
for (const rule of layered.value.documents)
|
|
989
993
|
out.document(rule);
|
|
990
|
-
const measured = checked(measuredWrites(input.scope, spec.measured, "&", layered.value.root, frameSupplied), reject);
|
|
991
|
-
if (Object.keys(measured).length > 0)
|
|
992
|
-
out.rule(openState(layer.kind), measured);
|
|
993
994
|
} else {
|
|
994
995
|
Object.assign(values, stickyValues(spec.sticky, context), anchorClearValues(spec.anchorClear, context), checked(measuredWrites(input.scope, spec.measured, "&", values, frameSupplied), reject), rootPaints);
|
|
995
996
|
if (Object.keys(values).length > 0)
|
|
@@ -1009,7 +1010,16 @@ export function lowerRegion(spec, foundation, input) {
|
|
|
1009
1010
|
out.rule(selector, normalizedDeclarations(normalized));
|
|
1010
1011
|
stateRules(out, "&", spec.when, profile, entering?.blurred ?? !1);
|
|
1011
1012
|
const partLayout = spec.exposeRows.length > 0 ? "grid" : arrangement.layout;
|
|
1012
|
-
lowerParts(spec.parts, "&", partLayout, values.gap ?? values["column-gap"], context, growsWithContent(values), rootGeometry.overlap, rootGeometry.gaps);
|
|
1013
|
+
lowerParts(spec.parts, "&", partLayout, values.gap ?? values["column-gap"], context, growsWithContent(values), rootGeometry.overlap, rootGeometry.gaps, values["flex-wrap"] === "wrap");
|
|
1014
|
+
if (spec.focusWithin !== null) {
|
|
1015
|
+
const focus = context.profile.of(context.slots["focus-profile"], "focus", "recipe.focus");
|
|
1016
|
+
context.out.rule(`&:has(${spec.focusWithin}:focus-visible)`, {
|
|
1017
|
+
"outline-width": context.profile.field(focus, "focus", "width"),
|
|
1018
|
+
"outline-color": context.profile.field(focus, "focus", "color"),
|
|
1019
|
+
"outline-offset": context.profile.field(focus, "focus", "offset"),
|
|
1020
|
+
"outline-style": "solid"
|
|
1021
|
+
});
|
|
1022
|
+
}
|
|
1013
1023
|
if (spec.carry) {
|
|
1014
1024
|
if (partLayout !== "stack")
|
|
1015
1025
|
return reject({ kind: "space-parent-unsupported", part: "&", layout: partLayout });
|