@reqvire-org/ads 0.5.11 → 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.
Files changed (37) hide show
  1. package/dist/ads-errors.mjs +29 -8
  2. package/dist/analysis/owner-source.mjs +21 -3
  3. package/dist/construction-output.mjs +16 -2
  4. package/dist/construction-spec.d.mts +43 -6
  5. package/dist/construction-spec.mjs +22 -12
  6. package/dist/end-alignment.mjs +4 -4
  7. package/dist/lowering-layer.mjs +50 -15
  8. package/dist/lowering-paint.mjs +1 -1
  9. package/dist/lowering-region-layout.mjs +8 -1
  10. package/dist/lowering-sequence.mjs +4 -3
  11. package/dist/measured-geometry.mjs +8 -2
  12. package/dist/owner-errors.mjs +1 -0
  13. package/dist/ownership-model.mjs +5 -5
  14. package/dist/recipe-macro.d.mts +12 -5
  15. package/dist/recipe-model.mjs +2 -2
  16. package/dist/region-lowering.mjs +47 -20
  17. package/dist/render-audit/render-states.page.mjs +1 -1
  18. package/dist/showcase/client.bundle.js +2 -2
  19. package/dist/showcase/http-client.bundle.js +2 -2
  20. package/dist/showcase/ui/ui.css +1 -1
  21. package/dist/showcase/ui/ui.js +2 -2
  22. package/dist/skills/ads-designer/references/recipes.md +41 -5
  23. package/dist/skills/ads-import/references/recipes.md +41 -5
  24. package/dist/skills/ads-port/SKILL.md +5 -0
  25. package/dist/skills/ads-port/references/recipes.md +41 -5
  26. package/dist/skills/ads-port/references/testing.md +5 -1
  27. package/dist/state-conditions.d.mts +3 -3
  28. package/dist/state-conditions.mjs +1 -1
  29. package/dist/token-shapes.mjs +42 -1
  30. package/docs/ADS.md +3 -2
  31. package/docs/CHANGELOG.md +75 -18
  32. package/docs/LANGUAGE.md +41 -13
  33. package/docs/MOTION.md +5 -0
  34. package/docs/PROFILE-KINDS.md +8 -5
  35. package/docs/RULES.md +8 -5
  36. package/docs/TOKEN-ROLES.md +1 -1
  37. package/package.json +1 -1
@@ -148,11 +148,17 @@ 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, parentWraps = !1) {
151
+ export function extentValues(extent, parent, part, parentGrows = !1, parentWraps = !1, arranged = !1) {
152
152
  switch (extent.kind) {
153
153
  case "content":
154
154
  return ok({});
155
+ case "grow":
156
+ if (parent !== "stack" && parent !== "inline")
157
+ return err({ kind: "extent-parent-unsupported", part, layout: parent });
158
+ return ok({ "flex-grow": "1", "flex-shrink": "1", "flex-basis": "auto" });
155
159
  case "fill": {
160
+ if (parent === "native" && arranged && extent.axis !== "both")
161
+ return ok({});
156
162
  if (parent !== "stack" && parent !== "inline")
157
163
  return err({ kind: "extent-parent-unsupported", part, layout: parent });
158
164
  const main = parent === "stack" ? "block" : "inline", values = { "flex-grow": "1", "flex-shrink": "1", "flex-basis": parent === "stack" ? "auto" : "0" };
@@ -205,6 +211,7 @@ export function elementNormalization(element, values) {
205
211
  }
206
212
  case "select":
207
213
  case "input":
214
+ case "textarea":
208
215
  return plain({ margin: "0" });
209
216
  case "table":
210
217
  return plain({ "border-collapse": "collapse" });
@@ -1,6 +1,6 @@
1
1
  import { keyframesName } from "./lowering-motion.mjs";
2
2
  import { err, ok } from "./result.mjs";
3
- export const SEQUENCE_REPEATS = ["loop", "alternate", "once"], STEP_FIELDS = {
3
+ export const SEQUENCE_REPEATS = ["loop", "restart", "alternate", "once"], STEP_FIELDS = {
4
4
  opacity: "opacity",
5
5
  "translate-inline": "translate",
6
6
  "translate-block": "translate",
@@ -52,7 +52,8 @@ export function sequenceRules(input) {
52
52
  if (field !== void 0)
53
53
  return err({ kind: "sequence-not-seamless", profile, field });
54
54
  }
55
- if (order > 0 && input.stagger === null)
55
+ const orderVar = input.orderVar ?? null;
56
+ if ((order > 0 || orderVar !== null) && input.stagger === null)
56
57
  return err({ kind: "sequence-stagger-missing", profile });
57
58
  const framesOf = (mirrored) => {
58
59
  const frames = [];
@@ -75,7 +76,7 @@ export function sequenceRules(input) {
75
76
  "animation-iteration-count": repeat === "once" ? "1" : "infinite",
76
77
  ...repeat === "alternate" ? { "animation-direction": "alternate" } : {},
77
78
  "animation-fill-mode": repeat === "once" ? "both" : "backwards",
78
- ...order > 0 && input.stagger !== null ? { "animation-delay": order === 1 ? input.stagger : `calc(${input.stagger} * ${order})` } : {},
79
+ ...orderVar !== null && input.stagger !== null ? { "animation-delay": `calc(${input.stagger} * ${orderVar})` } : order > 0 && input.stagger !== null ? { "animation-delay": order === 1 ? input.stagger : `calc(${input.stagger} * ${order})` } : {},
79
80
  ...input.paused === !0 ? { "animation-play-state": "paused" } : {}
80
81
  }, rules = [{ selector: under(condition, selector), values: animation, condition: null }];
81
82
  if (steps.some((step) => step.values["translate-inline"] !== void 0)) {
@@ -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,9 +958,9 @@ 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
- if (parentLayout === "native" && part.arrangement?.layout === "inline" && Object.keys(flowSpace(part, context)).length > 0) {
963
+ if (parentLayout === "native" && part.arrangement?.layout === "inline" && (Object.keys(flowSpace(part, context)).length > 0 || part.extent.kind === "fill")) {
951
964
  values.display = "flex";
952
965
  if (part.extent.kind !== "fill")
953
966
  values["inline-size"] = "fit-content";
@@ -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,11 +1003,13 @@ 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
- for (const side of ["top", "right", "bottom", "left"])
1009
+ for (const side of ["top", "right", "bottom", "left"]) {
988
1010
  delete frameFields[`border-${side}-width`];
1011
+ delete frameFields[`border-${side}-style`];
1012
+ }
989
1013
  Object.assign(frameFields, rules);
990
1014
  for (const side of ["block-start", "block-end", "inline-start", "inline-end"])
991
1015
  if (!part.frame.border.sides.includes(side))
@@ -1017,7 +1041,7 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
1017
1041
  const partSnap = part.arrangement?.snap ?? null, snapped = partSnap === null ? null : checked(snapValues(partSnap, part.overflow, part.name), reject);
1018
1042
  if (snapped !== null)
1019
1043
  add(snapped.container, "snap");
1020
- add(checked(extentValues(part.extent, parentLayout, part.name, parentGrows, parentWraps && keepsWords(part) && values["min-inline-size"] === void 0), reject), "extent");
1044
+ add(checked(extentValues(part.extent, parentLayout, part.name, parentGrows, parentWraps && keepsWords(part) && values["min-inline-size"] === void 0, part.arrangement !== null && part.arrangement.layout !== "native"), reject), "extent");
1021
1045
  if (parentLayout === "layered" && part.decoration === null)
1022
1046
  add(LAYER, "layer");
1023
1047
  if (part.parts.some((child) => child.decoration !== null))
@@ -1184,7 +1208,7 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
1184
1208
  if (placing !== void 0)
1185
1209
  return reject({ kind: "layer-frame-position", property: placing });
1186
1210
  const motion = layer.motion === null ? null : transitionTiming(profile.of(slots["motion-profile"], "motion", "layer"), profile, reject), drop = () => {
1187
- if (layer.kind === "modal-sheet" || layer.motion !== "drop")
1211
+ if (layer.motion !== "drop")
1188
1212
  return null;
1189
1213
  const fields = profile.of(slots["motion-profile"], "motion", "layer");
1190
1214
  return { distance: profile.field(fields, "motion", "distance"), scale: profile.field(fields, "motion", "scale") };
@@ -1192,8 +1216,11 @@ function layerInput(layer, spec, root, slots, profile, foundation, reject) {
1192
1216
  switch (layer.kind) {
1193
1217
  case "modal-sheet":
1194
1218
  sheetQuery(layer, slots, profile, foundation, reject);
1195
- 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 };
1196
- 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() };
1197
1224
  case "measured-popover": {
1198
1225
  const fields = profile.of(slots["layer-profile"], "layer", "layer");
1199
1226
  profile.only(fields, "layer", ["clear-block-start", "edge-gap", "viewport-margin", "anchor-gap", "anchor-overlap", "anchor-outdent", "anchor-indent"]);
@@ -1252,7 +1279,7 @@ export function lowerRegion(spec, foundation, input) {
1252
1279
  out.own(paintProperty(input.scope, paint.name));
1253
1280
  for (const token of paintTokens(paints))
1254
1281
  out.use(`var(${token})`);
1255
- 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;
1256
1283
  checkSurfaceEffects(foundation, profile, [slots["surface-profile"], spec.surface, ...spec.when.map(([, name]) => name)], spec.overflow.kind === "scroll" ? "scroller" : "container", reject);
1257
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("&", "&", {
1258
1285
  frame: restFramed === null ? null : regionFrameValues(restFramed, slots, surface, profile, reject).values,
@@ -1272,7 +1299,7 @@ export function lowerRegion(spec, foundation, input) {
1272
1299
  out.rule(`& ${OVERLAPPED}`, { [rootGeometry.overlap.property]: rootGeometry.overlap.base });
1273
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);
1274
1301
  transitionRules("&", spec.paintTransition, surface === null ? null : { name: surface, fields: rootSurface }, spec.when, context, entering === null ? rootGroups : [...rootGroups, entering.group]);
1275
- 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) });
1276
1303
  const rootFill = (name) => name === null ? null : profile.of(name, "surface").background ?? null;
1277
1304
  pseudoRules("&", spec.pseudo, "&", [{ condition: null, value: rootFill(surface) }, ...spec.when.map(([condition, name]) => ({ condition, value: rootFill(name) }))], context, spec.frame !== null, spec.measured);
1278
1305
  const rootCounters = counterValues(spec.counter);
@@ -1336,7 +1363,7 @@ export function lowerRegion(spec, foundation, input) {
1336
1363
  } else {
1337
1364
  const cap = values["max-inline-size"];
1338
1365
  values["max-inline-size"] = cap === void 0 ? "100%" : `min(100%, ${cap})`;
1339
- const filling = spec.parts.find((part) => part.extent.kind === "fill");
1366
+ const filling = spec.parts.find((part) => part.extent.kind !== "content");
1340
1367
  if (filling !== void 0 && !fixed)
1341
1368
  return reject({ kind: "extent-row-hugs", part: filling.name });
1342
1369
  }
@@ -1368,7 +1395,7 @@ export function lowerRegion(spec, foundation, input) {
1368
1395
  if (placing !== void 0)
1369
1396
  return reject({ kind: "measured-property-unsupported", element: "&", name: placing.name, property: placing.property, type: placing.type, reason: "layer-placement" });
1370
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);
1371
- out.rule("&", { ...layered.value.root, ...measured, ...rootPaints });
1398
+ out.rule("&", { ...layered.value.root, ...measured, ...rootPaints, ...spec.layerOverscroll === !0 ? { "overscroll-behavior": "contain" } : {} });
1372
1399
  for (const rule of layered.value.rules)
1373
1400
  out.rule(rule.selector, { ...rule.values }, rule.condition ?? void 0);
1374
1401
  for (const rule of layered.value.documents)
@@ -263,7 +263,7 @@ export function applyDerived({ target, condition }) {
263
263
  return { applied: !1, reason: `${part} on <${element.localName}>` };
264
264
  continue;
265
265
  }
266
- const has = /^:has\(>\s*(\.[\w-]+)(?::(checked|indeterminate|disabled))?\)$/.exec(part);
266
+ const has = /^:has\(>\s*(\.[\w-]+(?:\s*>\s*\.[\w-]+)*)(?::(checked|indeterminate|disabled))?\)$/.exec(part);
267
267
  if (has !== null) {
268
268
  const selector = `:scope > ${has[1] ?? ""}`, child = element.querySelector(selector);
269
269
  if (child === null)