@reqvire-org/ads 0.5.12 → 0.5.13

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.
@@ -18,9 +18,10 @@ export const MEASURED_PROPERTIES = {
18
18
  "size-track": ["grid-template-columns", "grid-template-rows"],
19
19
  position: ["object-position"],
20
20
  "intrinsic-size": ["inline-size"],
21
- share: ["slider-fill", "slider-step"]
21
+ share: ["slider-fill", "slider-step"],
22
+ index: ["sequence-order"]
22
23
  };
23
- const HOSTS = { length: "region", transform: "region", scale: "region", "size-track": "grid", position: "region", "intrinsic-size": "region", share: "region" }, POSITIONS = ["inset-block-start", "inset-block-end", "inset-inline-start", "inset-inline-end", "translate"];
24
+ const HOSTS = { length: "region", transform: "region", scale: "region", "size-track": "grid", position: "region", "intrinsic-size": "region", share: "region", index: "region" }, POSITIONS = ["inset-block-start", "inset-block-end", "inset-inline-start", "inset-inline-end", "translate"];
24
25
  export const positions = (property) => POSITIONS.includes(property), measuredProperty = (scope, name) => privateProperty(scope, "measured", name);
25
26
  function initialValue(property) {
26
27
  if (property === "translate" || property === "scale")
@@ -44,6 +45,7 @@ export function measuredFallback(value, own) {
44
45
  case "intrinsic-size":
45
46
  return own ?? "auto";
46
47
  case "share":
48
+ case "index":
47
49
  return "0";
48
50
  }
49
51
  }
@@ -64,6 +66,8 @@ export function measuredWrites(scope, values, element, own, supplied, media = nu
64
66
  return checked;
65
67
  if (value.type === "position" && media !== "cover")
66
68
  return err({ kind: "measured-property-unsupported", element, name: value.name, property: value.property, type: value.type, reason: "cover-missing" });
69
+ if (value.type === "index")
70
+ continue;
67
71
  if (value.type === "share") {
68
72
  const reason = value.property === "slider-fill" ? slider.fill ? null : "fill-missing" : slider.steps ? null : "steps-missing";
69
73
  if (reason !== null)
@@ -143,6 +147,7 @@ function valueType(value) {
143
147
  case "length":
144
148
  case "size-track":
145
149
  case "share":
150
+ case "index":
146
151
  return "number";
147
152
  }
148
153
  }
@@ -161,6 +166,7 @@ function written(value) {
161
166
  case "size-track":
162
167
  return `\`\${${read}}px\``;
163
168
  case "share":
169
+ case "index":
164
170
  return `\`\${${read}}\``;
165
171
  }
166
172
  }
@@ -122,6 +122,7 @@ export function constructionError(failure) {
122
122
  case "artwork-group-unknown":
123
123
  case "text-anchor-unsupported":
124
124
  case "artwork-group-draw-length":
125
+ case "sequence-order-unmeasured":
125
126
  case "slider-fill-unsupported":
126
127
  case "slider-steps-unsupported":
127
128
  case "scheme-unsupported":
@@ -70,7 +70,7 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
70
70
  along: (value) => /^[a-z][\w-]*$/i.test(value),
71
71
  lines: oneOf("2", "3"),
72
72
  overflow: OVERFLOW,
73
- extent: oneOf("fill", "fill-both"),
73
+ extent: oneOf("fill", "fill-both", "grow"),
74
74
  element: ELEMENT,
75
75
  marker: oneOf("native", "none"),
76
76
  media: oneOf("inspected-svg"),
@@ -131,19 +131,19 @@ const identifier = /^[a-z][\w-]*$/, profile = /^[a-z][\w-]*(?:\([a-z][\w-]*:\s*[
131
131
  "ads-content": { counter: () => !0, counters: () => !0, style: () => !0, separator: () => !0, prefix: () => !0, suffix: () => !0 },
132
132
  "ads-accessibility": { boundary: () => !0, reason: () => !0 },
133
133
  "ads-focus": { of: () => !0, "shown-by": oneOf("container"), within: (value) => /^\.[A-Za-z_][\w-]*$/.test(value) },
134
- "ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value), paused: oneOf("true", "false") },
134
+ "ads-play": { sequence: binding, order: (value) => /^(?:[0-9]|[12][0-9]|3[0-2])$/.test(value), "order-by": (value) => /^[a-z][A-Za-z0-9]*$/.test(value), paused: oneOf("true", "false") },
135
135
  "ads-group": {},
136
- "ads-anchor": { artwork: (value) => /^[a-z][\w-]*$/i.test(value), x: (value) => /^-?\d+(\.\d+)?$/.test(value), y: (value) => /^-?\d+(\.\d+)?$/.test(value), inline: oneOf("start", "center", "end"), block: oneOf("start", "center", "end") },
136
+ "ads-anchor": { artwork: (value) => /^[a-z][\w-]*$/i.test(value), x: (value) => /^-?\d+(\.\d+)?$/.test(value), y: (value) => /^-?\d+(\.\d+)?$/.test(value), inline: oneOf("start", "center", "end"), block: oneOf("start", "center", "end", "baseline"), size: (value) => /^\d+(\.\d+)?$/.test(value) },
137
137
  "ads-outset": { block: outsetSpacing, inline: outsetSpacing },
138
138
  "ads-sticky": { edge: oneOf("block-start", "block-end", "inline-start", "inline-end"), clear: oneOf("none", "block-start") },
139
139
  "ads-flow": { edges: oneOf("trim") },
140
140
  "ads-snap": { type: oneOf(...SNAP_TYPES), align: oneOf(...SNAP_ALIGNS) },
141
141
  "ads-layer": {
142
142
  element: oneOf("dialog", "popover"),
143
- edge: oneOf("start", "end", "center", "block-start"),
143
+ edge: oneOf("start", "end", "center", "block-start", "fill"),
144
144
  "backdrop-surface": binding,
145
145
  "backdrop-dismiss": oneOf("press", "none"),
146
- motion: oneOf("slide", "fade", "drop"),
146
+ motion: oneOf("slide", "fade", "drop", "veil"),
147
147
  "modal-below": (value) => identifier.test(value),
148
148
  popover: oneOf("auto", "manual"),
149
149
  "corner-block": oneOf("start", "end"),
@@ -99,7 +99,7 @@ export interface SnapDeclaration {
99
99
  /** Content beyond the element's box: clipped, or scrolled on the block axis, the inline axis or both. */
100
100
  export type Overflow = "clip" | "scroll-block" | "scroll-inline" | "scroll-both";
101
101
  /** A native element the region or part renders, for its closed normalization. */
102
- export type NativeElement = "iframe" | "select" | "search-input" | "text-input" | "table" | "header-cell" | "cell" | "list" | "summary" | "document";
102
+ export type NativeElement = "iframe" | "select" | "search-input" | "text-input" | "textarea" | "table" | "header-cell" | "cell" | "list" | "summary" | "document";
103
103
  /** A paint a surface treatment can transition. */
104
104
  export type PaintChannel = "background-color" | "border-color" | "color" | "text-decoration-color" | "box-shadow" | "filter" | "backdrop-filter" | "opacity";
105
105
  /** Paint channels of one element that change between its state surfaces, timed by a motion profile. */
@@ -191,14 +191,14 @@ export type LayerDeclaration = {
191
191
  * A sheet attached to an inline edge (`start`, `end`), or a card: `center` in the viewport, or `block-start`
192
192
  * (centred inline, below the top). A card keeps the layer profile's `viewportMargin` from the viewport edges.
193
193
  */
194
- readonly edge: "start" | "end" | "center" | "block-start";
194
+ readonly edge: "start" | "end" | "center" | "block-start" | "fill";
195
195
  /** The backdrop's surface: its `background`, and optionally its `backdropBlur` (the page behind, blurred). */
196
196
  readonly backdrop: {
197
197
  readonly surface: string;
198
198
  readonly dismiss?: "press" | "none";
199
199
  };
200
200
  /** A sheet slides in from its edge; a card fades in. */
201
- readonly motion?: "slide" | "fade";
201
+ readonly motion?: "slide" | "fade" | "drop" | "veil";
202
202
  /** A breakpoint tier of the recipe's spatial profile; the recipe's `modalQuery` is the range below it. */
203
203
  readonly modalBelow?: string;
204
204
  } | {
@@ -272,6 +272,11 @@ export type MeasuredDeclaration = {
272
272
  | {
273
273
  readonly type: "share";
274
274
  readonly property: "slider-fill" | "slider-step";
275
+ }
276
+ /** An instance's place among its siblings (0, 1, 2…), which a sequence's stagger multiplies (`play.orderBy`). */
277
+ | {
278
+ readonly type: "index";
279
+ readonly property: "sequence-order";
275
280
  };
276
281
  /** Measured values by name: a camelCase name per value, unique within the recipe. */
277
282
  export type MeasuredDeclarations = Readonly<Record<string, MeasuredDeclaration>>;
@@ -327,7 +332,7 @@ export interface RecipeSpec {
327
332
  * part: `"fill"` takes the room an inline control's other content leaves, so a visual after it stands at the far end.
328
333
  * Root of an `inline` row: `"container"` takes the container's width, `"content"` (the default) is as wide as its content.
329
334
  */
330
- readonly extent?: "fill" | "fill-both" | "content" | "container";
335
+ readonly extent?: "fill" | "fill-both" | "grow" | "content" | "container";
331
336
  readonly element?: NativeElement;
332
337
  /** A summary's disclosure marker. */
333
338
  readonly marker?: "native" | "none";
@@ -489,7 +494,9 @@ export interface RecipeSpec {
489
494
  */
490
495
  readonly play?: {
491
496
  readonly sequence: string;
492
- readonly order?: number;
497
+ readonly order?: number; /** A measured `index` the owner writes on each instance: it starts that many staggers late. */
498
+ readonly orderBy?: string;
499
+ readonly paused?: boolean;
493
500
  };
494
501
  /**
495
502
  * The root or part stays at an edge of its scrolling container while the rest scrolls. `clear:
@@ -128,13 +128,13 @@ function body(node, spec) {
128
128
  if (spec.sticky !== void 0)
129
129
  clause(node, "ads-sticky", "", only(spec.sticky, ["edge", "clear"]));
130
130
  if (spec.anchor !== void 0)
131
- clause(node, "ads-anchor", "", only(spec.anchor, ["artwork", "x", "y", "inline", "block"]));
131
+ clause(node, "ads-anchor", "", only(spec.anchor, ["artwork", "x", "y", "inline", "block", "size"]));
132
132
  if (spec.outset !== void 0)
133
133
  clause(node, "ads-outset", "", only(spec.outset, ["block", "inline"]));
134
134
  if (spec.focus !== void 0)
135
135
  clause(node, "ads-focus", "", only(spec.focus, ["of", "shownBy", "within"]));
136
136
  if (spec.play !== void 0)
137
- clause(node, "ads-play", "", only(spec.play, ["sequence", "order", "paused"]));
137
+ clause(node, "ads-play", "", only(spec.play, ["sequence", "order", "orderBy", "paused"]));
138
138
  if (spec.flow !== void 0)
139
139
  clause(node, "ads-flow", "", only(spec.flow, ["edges"]));
140
140
  if (spec.counter !== void 0)
@@ -1,5 +1,5 @@
1
1
  import { BORDER_STYLE, compositeSlot } from "./role-vocabulary.mjs";
2
- import { PART_EFFECTS, normalizedDeclarations, scaleValue } from "./construction-spec.mjs";
2
+ import { PART_EFFECTS, declaredMeasured, normalizedDeclarations, scaleValue } from "./construction-spec.mjs";
3
3
  import {
4
4
  coverArtwork,
5
5
  decorationArtwork,
@@ -322,7 +322,7 @@ const REDUCED_MOTION_QUERY = ["media", "(prefers-reduced-motion: reduce)"];
322
322
  function measuredMotion(measured, profile, reject) {
323
323
  const groups = new Map;
324
324
  for (const value of measured) {
325
- if (value.type === "position" || value.type === "intrinsic-size" || value.type === "share" || value.motion === null)
325
+ if (value.type === "position" || value.type === "intrinsic-size" || value.type === "share" || value.type === "index" || value.motion === null)
326
326
  continue;
327
327
  groups.set(value.motion, [...groups.get(value.motion) ?? [], value.property]);
328
328
  }
@@ -726,17 +726,26 @@ function writePartSpace(parts, parent, layout, gap, context, carry = !1) {
726
726
  return context.reject({ kind: "space-parent-unsupported", part: first.part.name, layout });
727
727
  if (layout === "native")
728
728
  return;
729
- const between = gap ?? "0px", margin = (space) => ({ "margin-block-start": `calc(${space} - ${between})` });
729
+ const between = gap ?? "0px", margin = (space) => ({ "margin-block-start": `calc(${space} - ${between})` }), shownIn = (part) => {
730
+ const [condition] = part.at, spatial = context.slots["spatial-profile"];
731
+ if (condition === void 0 || condition.visible === null || spatial === void 0)
732
+ return;
733
+ const bound = conditionBound(context.foundation, spatial, condition.condition, context.profile, context.reject);
734
+ if (bound === null)
735
+ return;
736
+ const queries = conditionQueries(bound);
737
+ return ["media", condition.visible ? queries.inside : queries.outside];
738
+ };
730
739
  for (const { part, before, after } of spaced) {
731
740
  if (before !== null)
732
741
  out.rule(`${parent} > * + ${part.selector}:not(:first-child)`, margin(before));
733
742
  if (after !== null)
734
- out.rule(`${parent} > ${part.selector} + :not(:first-child):not(:first-child)`, margin(after));
743
+ out.rule(`${parent} > ${part.selector} + :not(:first-child):not(:first-child)`, margin(after), shownIn(part));
735
744
  }
736
745
  for (const previous of spaced)
737
746
  for (const next of spaced)
738
747
  if (previous.after !== null && next.before !== null)
739
- out.rule(`${parent} > ${previous.part.selector} + ${next.part.selector}:not(:first-child):not(:first-child)`, margin(`max(${previous.after}, ${next.before})`));
748
+ out.rule(`${parent} > ${previous.part.selector} + ${next.part.selector}:not(:first-child):not(:first-child)`, margin(`max(${previous.after}, ${next.before})`), shownIn(previous.part));
740
749
  if (carry && parent === "&") {
741
750
  out.own(FLOW_GAP);
742
751
  for (const { part, after } of spaced)
@@ -817,16 +826,20 @@ function stageValues(parts, values, context) {
817
826
  return {};
818
827
  if (values["aspect-ratio"] !== void 0 || values["block-size"] !== void 0)
819
828
  return context.reject({ kind: "text-anchor-unsupported", part: parts.find((part) => part.anchor !== null)?.name ?? "", reason: "sized" });
820
- return { "aspect-ratio": `${box[2]} / ${box[3]}` };
829
+ const sized = parts.some((part) => part.anchor !== null && part.anchor.size !== null);
830
+ return { "aspect-ratio": `${box[2]} / ${box[3]}`, ...sized ? { "container-type": "inline-size" } : {} };
821
831
  }
832
+ const anchoredSizes = new WeakMap;
822
833
  function writeAnchoredLabels(parts, parent, context) {
823
834
  const box = stageOf(parts, context);
824
835
  if (box === null)
825
836
  return;
826
- const [bx, by, bw, bh] = box, shift = { start: "0%", center: "-50%", end: "-100%" };
837
+ const [bx, by, bw, bh] = box, shift = { start: "0%", center: "-50%", end: "-100%", baseline: "-100%" };
827
838
  for (const part of parts) {
828
839
  if (part.anchor === null)
829
840
  continue;
841
+ if (part.anchor.size !== null)
842
+ anchoredSizes.set(part, `calc(100cqi * ${Number((part.anchor.size / bw).toFixed(6))})`);
830
843
  context.out.rule(`${parent} > ${part.selector}`, {
831
844
  position: "absolute",
832
845
  left: `${((part.anchor.x - bx) / bw * 100).toFixed(4)}%`,
@@ -915,7 +928,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
915
928
  if (collapsible) {
916
929
  if (axis === null)
917
930
  return reject({ kind: "state-geometry-unsupported", element: part.name, reason: "collapsed-parent", detail: parentLayout });
918
- const own = part.box !== null || part.frame !== null ? "a frame" : part.arrangement !== null ? "an arrangement" : part.overflow.kind !== "visible" ? "an overflow" : part.extent.kind === "fill" ? "a filling extent" : null;
931
+ const own = part.box !== null || part.frame !== null ? "a frame" : part.arrangement !== null ? "an arrangement" : part.overflow.kind !== "visible" ? "an overflow" : part.extent.kind !== "content" ? "a filling extent" : null;
919
932
  if (own !== null)
920
933
  return reject({ kind: "state-geometry-unsupported", element: part.name, reason: "collapsed-box", detail: own });
921
934
  }
@@ -945,7 +958,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
945
958
  ...overlapping === null || overlapping.group === null || partGeometry.group?.properties.includes(overlapping.property) === !0 ? [] : [overlapping.group]
946
959
  ], 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);
947
960
  transitionRules(path, part.paintTransition, part.surface === null ? null : { name: part.surface, fields: partSurface }, part.when, context, entering === null ? partGroups : [...partGroups, entering.group]);
948
- writePlays(out, profile, context.foundation, part.name, part.plays, path, [...transitioned(part.paintTransition, entering === null ? [] : [entering.group]), ...moved], reject);
961
+ 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 ?? [] });
949
962
  const values = part.arrangement === null ? {} : { "box-sizing": "border-box", "min-inline-size": "0", ...arrangementValues(part.arrangement, slots, profile, part.overflow) };
950
963
  if (parentLayout === "native" && part.arrangement?.layout === "inline" && (Object.keys(flowSpace(part, context)).length > 0 || part.extent.kind === "fill")) {
951
964
  values.display = "flex";
@@ -958,9 +971,18 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
958
971
  checked(checkLayers(part.name, part.parts.length), reject);
959
972
  const text = part.text !== null ? textOf(part.text, slots, profile) : part.content.kind === "text" && slots["text-profile"] !== void 0 ? profile.of(slots["text-profile"], "text") : {};
960
973
  Object.assign(values, text);
974
+ const scaled = anchoredSizes.get(part);
975
+ if (scaled !== void 0) {
976
+ const floor = text["font-size"];
977
+ if (floor === void 0)
978
+ return reject({ kind: "text-anchor-unsupported", part: part.name, reason: "size" });
979
+ values["font-size"] = `max(${floor}, ${scaled})`;
980
+ }
961
981
  writeStateText(out, profile, part.name, text, part.textWhen, (condition) => under(condition, path), reject);
962
982
  if (part.textEdge.length > 0)
963
983
  Object.assign(values, { "text-box-trim": "trim-both", "text-box-edge": part.textEdge.join(" ") });
984
+ if (part.anchor?.block === "baseline")
985
+ Object.assign(values, { "text-box-trim": "trim-end", "text-box-edge": "auto alphabetic" });
964
986
  checkSurfaceEffects(context.foundation, profile, [part.surface, ...part.when.map(([, name]) => name)], part.content.kind === "visual" ? "visual" : part.overflow.kind === "scroll" ? "scroller" : "container", reject);
965
987
  if (part.surface !== null)
966
988
  Object.assign(values, settled(partSurface, entering?.blurred ?? !1));
@@ -981,7 +1003,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
981
1003
  let target = null, frameFields = {};
982
1004
  if (part.frame !== null) {
983
1005
  const lineText = text["line-height"] === void 0 && slots["text-profile"] !== void 0 ? profile.of(slots["text-profile"], "text") : text, lineHeight = profile.field(lineText, "text", "line-height"), frame = profile.of(slots["frame-profile"], "frame", "control"), box = controlBox(frame, LINE_BOX, profile.field, reject);
984
- frameFields = controlBoxValues(box);
1006
+ frameFields = part.element?.kind === "textarea" ? { ...controlBoxValues(box), "min-block-size": frame["min-block-size"] ?? box.minBlockSize, "padding-block-start": box.insets.blockStart, "padding-block-end": box.insets.blockEnd } : controlBoxValues(box);
985
1007
  if (part.frame.border.kind === "rules") {
986
1008
  const paint = part.surface === null ? void 0 : profile.of(part.surface, "surface")["border-color"], rules = checked(frameRules(part.frame.border, frame["border-width"], { surface: part.surface, color: paint }, slots["frame-profile"] ?? null, frame[BORDER_STYLE]), reject);
987
1009
  for (const side of ["top", "right", "bottom", "left"]) {
@@ -1186,7 +1208,7 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
1186
1208
  if (placing !== void 0)
1187
1209
  return reject({ kind: "layer-frame-position", property: placing });
1188
1210
  const motion = layer.motion === null ? null : transitionTiming(profile.of(slots["motion-profile"], "motion", "layer"), profile, reject), drop = () => {
1189
- if (layer.kind === "modal-sheet" || layer.motion !== "drop")
1211
+ if (layer.motion !== "drop")
1190
1212
  return null;
1191
1213
  const fields = profile.of(slots["motion-profile"], "motion", "layer");
1192
1214
  return { distance: profile.field(fields, "motion", "distance"), scale: profile.field(fields, "motion", "scale") };
@@ -1194,8 +1216,11 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
1194
1216
  switch (layer.kind) {
1195
1217
  case "modal-sheet":
1196
1218
  sheetQuery(layer, slots, profile, foundation, reject);
1197
- const layerFields = layer.edge === "center" || layer.edge === "block-start" ? profile.of(slots["layer-profile"], "layer", "layer") : null, inline = layerFields === null ? null : profile.field(layerFields, "layer", "viewport-margin"), margin = inline === null || layerFields === null ? null : { inline, block: layer.edge === "block-start" ? layerFields["edge-gap"] ?? inline : inline };
1198
- return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion, margin };
1219
+ const layerFields = layer.edge === "center" || layer.edge === "block-start" ? profile.of(slots["layer-profile"], "layer", "layer") : null;
1220
+ if (layer.edge === "fill")
1221
+ return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion, margin: { inline: "0px", block: "0px" }, drop: drop() };
1222
+ const inline = layerFields === null ? null : profile.field(layerFields, "layer", "viewport-margin"), margin = inline === null || layerFields === null ? null : { inline, block: layer.edge === "block-start" ? layerFields["edge-gap"] ?? inline : inline };
1223
+ return { kind: "modal-sheet", sheet: layer, backdrop: { name: layer.backdrop.surface, fields: profile.of(layer.backdrop.surface, "surface") }, root, motion, margin, drop: drop() };
1199
1224
  case "measured-popover": {
1200
1225
  const fields = profile.of(slots["layer-profile"], "layer", "layer");
1201
1226
  profile.only(fields, "layer", ["clear-block-start", "edge-gap", "viewport-margin", "anchor-gap", "anchor-overlap", "anchor-outdent", "anchor-indent"]);
@@ -1254,7 +1279,7 @@ export function lowerRegion(spec, foundation, input) {
1254
1279
  out.own(paintProperty(input.scope, paint.name));
1255
1280
  for (const token of paintTokens(paints))
1256
1281
  out.use(`var(${token})`);
1257
- const placedArtwork = [], placedByPart = new Map, targets = [], neighbours = [], rootNormalized = new Map(spec.normalizeWhen.map(([selector, normalized]) => [selector, normalized.map(([property]) => property)])), coverBox = spec.frame !== null && (spec.frame.kind === "fields" && spec.frame.ratio !== null || slots["frame-profile"] !== void 0 && profile.of(slots["frame-profile"], "frame")["block-size"] !== void 0), placed = [], context = { out, profile, slots, input, reject, placedArtwork, placedByPart, foundation, targets, neighbours, placed, carry: spec.carry, rootNormalized, coverBox }, surface = slots["surface-profile"] ?? spec.surface;
1282
+ const placedArtwork = [], placedByPart = new Map, targets = [], neighbours = [], rootNormalized = new Map(spec.normalizeWhen.map(([selector, normalized]) => [selector, normalized.map(([property]) => property)])), coverBox = spec.frame !== null && (spec.frame.kind === "fields" && spec.frame.ratio !== null || slots["frame-profile"] !== void 0 && profile.of(slots["frame-profile"], "frame")["block-size"] !== void 0), placed = [], context = { out, profile, slots, input, reject, placedArtwork, placedByPart, foundation, targets, neighbours, placed, carry: spec.carry, rootNormalized, coverBox, measured: declaredMeasured(spec) }, surface = slots["surface-profile"] ?? spec.surface;
1258
1283
  checkSurfaceEffects(foundation, profile, [slots["surface-profile"], spec.surface, ...spec.when.map(([, name]) => name)], spec.overflow.kind === "scroll" ? "scroller" : "container", reject);
1259
1284
  const press = spec.press.when.length === 0 ? null : writeRootPress(out, spec.press, profile.of(slots["motion-profile"], "motion", spec.profile ?? "recipe"), profile, reject), rootSurface = surface === null ? {} : profile.of(surface, "surface"), restFramed = spec.frame === null || spec.frameAt === null || spec.frameAt.corners === null ? spec.frame : { ...spec.frame, corners: spec.frame.corners ?? FRAME_CORNERS }, rootGeometry = writeStateGeometry("&", "&", {
1260
1285
  frame: restFramed === null ? null : regionFrameValues(restFramed, slots, surface, profile, reject).values,
@@ -1274,7 +1299,7 @@ export function lowerRegion(spec, foundation, input) {
1274
1299
  out.rule(`& ${OVERLAPPED}`, { [rootGeometry.overlap.property]: rootGeometry.overlap.base });
1275
1300
  const rootGroups = [...press === null ? [] : [press], ...measuredMotion(spec.measured, profile, reject), ...rootGeometry.group === null ? [] : [rootGeometry.group]], entering = writeEnter(out, profile, "&", spec.enter, rootSurface, stateSurfaces("&", spec.when, profile), slots, transitioned(spec.paintTransition, rootGroups), reject);
1276
1301
  transitionRules("&", spec.paintTransition, surface === null ? null : { name: surface, fields: rootSurface }, spec.when, context, entering === null ? rootGroups : [...rootGroups, entering.group]);
1277
- writePlays(out, profile, foundation, "&", spec.plays, "&", transitioned(spec.paintTransition, entering === null ? rootGroups : [...rootGroups, entering.group]), reject);
1302
+ writePlays(out, profile, foundation, "&", spec.plays, "&", transitioned(spec.paintTransition, entering === null ? rootGroups : [...rootGroups, entering.group]), reject, { scope: input.scope, values: declaredMeasured(spec) });
1278
1303
  const rootFill = (name) => name === null ? null : profile.of(name, "surface").background ?? null;
1279
1304
  pseudoRules("&", spec.pseudo, "&", [{ condition: null, value: rootFill(surface) }, ...spec.when.map(([condition, name]) => ({ condition, value: rootFill(name) }))], context, spec.frame !== null, spec.measured);
1280
1305
  const rootCounters = counterValues(spec.counter);
@@ -1338,7 +1363,7 @@ export function lowerRegion(spec, foundation, input) {
1338
1363
  } else {
1339
1364
  const cap = values["max-inline-size"];
1340
1365
  values["max-inline-size"] = cap === void 0 ? "100%" : `min(100%, ${cap})`;
1341
- const filling = spec.parts.find((part) => part.extent.kind === "fill");
1366
+ const filling = spec.parts.find((part) => part.extent.kind !== "content");
1342
1367
  if (filling !== void 0 && !fixed)
1343
1368
  return reject({ kind: "extent-row-hugs", part: filling.name });
1344
1369
  }
@@ -1370,7 +1395,7 @@ export function lowerRegion(spec, foundation, input) {
1370
1395
  if (placing !== void 0)
1371
1396
  return reject({ kind: "measured-property-unsupported", element: "&", name: placing.name, property: placing.property, type: placing.type, reason: "layer-placement" });
1372
1397
  const measured = anchorOffsets(layer.kind === "measured-popover" ? slots["layer-profile"] : void 0, checked(measuredWrites(input.scope, spec.measured, "&", layered.value.root, frameSupplied), reject), profile, reject);
1373
- out.rule("&", { ...layered.value.root, ...measured, ...rootPaints });
1398
+ out.rule("&", { ...layered.value.root, ...measured, ...rootPaints, ...spec.layerOverscroll === !0 ? { "overscroll-behavior": "contain" } : {} });
1374
1399
  for (const rule of layered.value.rules)
1375
1400
  out.rule(rule.selector, { ...rule.values }, rule.condition ?? void 0);
1376
1401
  for (const rule of layered.value.documents)