@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.
- package/dist/ads-errors.mjs +24 -3
- package/dist/analysis/owner-source.mjs +18 -0
- package/dist/construction-output.mjs +11 -2
- package/dist/construction-spec.d.mts +43 -6
- package/dist/construction-spec.mjs +21 -11
- package/dist/end-alignment.mjs +4 -4
- package/dist/lowering-layer.mjs +50 -15
- package/dist/lowering-paint.mjs +1 -1
- package/dist/lowering-region-layout.mjs +5 -0
- package/dist/lowering-sequence.mjs +4 -3
- package/dist/measured-geometry.mjs +8 -2
- package/dist/owner-errors.mjs +1 -0
- package/dist/ownership-model.mjs +5 -5
- package/dist/recipe-macro.d.mts +12 -5
- package/dist/recipe-model.mjs +2 -2
- package/dist/region-lowering.mjs +42 -17
- package/dist/showcase/client.bundle.js +1 -1
- package/dist/showcase/http-client.bundle.js +1 -1
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +1 -1
- package/dist/skills/ads-designer/references/recipes.md +2 -1
- package/dist/skills/ads-import/references/recipes.md +2 -1
- package/dist/skills/ads-port/references/recipes.md +2 -1
- package/dist/token-shapes.mjs +42 -1
- package/docs/ADS.md +3 -2
- package/docs/CHANGELOG.md +59 -18
- package/docs/LANGUAGE.md +27 -9
- package/docs/MOTION.md +5 -0
- package/docs/PROFILE-KINDS.md +8 -5
- package/docs/RULES.md +6 -3
- package/docs/TOKEN-ROLES.md +1 -1
- package/package.json +1 -1
package/dist/ads-errors.mjs
CHANGED
|
@@ -677,6 +677,20 @@ export const choiceErrors = {
|
|
|
677
677
|
message: (failure) => `Part "${failure.part}" declares \`resize\` but is rendered as <${failure.element}>.`,
|
|
678
678
|
repair: "Declare `resize` on the part rendered as `<textarea>`, or remove it."
|
|
679
679
|
},
|
|
680
|
+
"drawing-read-unbound": {
|
|
681
|
+
group: "structure-mismatch",
|
|
682
|
+
rule: "A recipe's drawing (`recipe.assets.<part>.source`) is read in the markup of the owner's element that is the part, where ADS inlines the drawing's source. Elsewhere (a helper function that renders markup ADS does not match to the owner) it cannot be inlined, and the emitted owner would read an emptied recipe.",
|
|
683
|
+
guides: [RECIPES],
|
|
684
|
+
message: (failure) => `${failure.name} is read where ADS cannot match it to the element of the part that shows it; the emitted owner would read an emptied recipe.`,
|
|
685
|
+
repair: "Render the element that shows the drawing in the owner's own markup (the function whose markup holds the recipe's root), or give the helper's markup its own recipe root."
|
|
686
|
+
},
|
|
687
|
+
"textarea-element-missing": {
|
|
688
|
+
group: "structure-mismatch",
|
|
689
|
+
rule: 'A control frame centres a single line in its minimum height. A multi-line field declares `element: "textarea"`, so its frame keeps the stated insets around its lines instead.',
|
|
690
|
+
guides: [RECIPES],
|
|
691
|
+
message: (failure) => `Part "${failure.part}" is rendered as <textarea> with a control frame but does not declare element: "textarea"; its first line would be centred in the field.`,
|
|
692
|
+
repair: 'Declare `element: "textarea"` on the part.'
|
|
693
|
+
},
|
|
680
694
|
"decoration-exposed": {
|
|
681
695
|
group: "accessibility-semantics",
|
|
682
696
|
rule: 'A decoration (`kind: "decoration"`) carries no meaning: its element is `aria-hidden="true"` and holds nothing a person can use. ADS writes it behind its parent\'s content and lets the pointer through.',
|
|
@@ -1104,10 +1118,10 @@ export const constructionErrors = {
|
|
|
1104
1118
|
},
|
|
1105
1119
|
"sequence-not-seamless": {
|
|
1106
1120
|
group: "wrong-value",
|
|
1107
|
-
rule: 'A looping sequence ends where it starts: its step at 100 states the same values as its step at 0, so the loop has no jump. A sequence that should run forward then backward declares `repeat: "alternate"`; one that plays one time declares `repeat: "once"`.',
|
|
1121
|
+
rule: 'A looping sequence ends where it starts: its step at 100 states the same values as its step at 0, so the loop has no jump. A sequence that should run forward then backward declares `repeat: "alternate"`; one that starts over from its first step by design (a pulse that grows and fades out) declares `repeat: "restart"`; one that plays one time declares `repeat: "once"`.',
|
|
1108
1122
|
guides: [RECIPES],
|
|
1109
1123
|
message: (failure) => `Sequence ${failure.profile} loops, but its last step differs from its first in ${failure.field}: the loop would jump.`,
|
|
1110
|
-
repair: 'Make the step at 100 state the values of the step at 0, or declare `repeat: "alternate"` or `repeat: "once"` in the profile.'
|
|
1124
|
+
repair: 'Make the step at 100 state the values of the step at 0, or declare `repeat: "restart"` (a pulse that starts over), `repeat: "alternate"` or `repeat: "once"` in the profile.'
|
|
1111
1125
|
},
|
|
1112
1126
|
"sequence-step-field": {
|
|
1113
1127
|
group: "wrong-value",
|
|
@@ -1134,9 +1148,16 @@ export const constructionErrors = {
|
|
|
1134
1148
|
group: "structure-mismatch",
|
|
1135
1149
|
rule: "A text part placed on a drawing (`anchor: { artwork, x, y }`) names a sibling decoration whose artwork is the drawing: their parent is sized to the drawing (its viewBox ratio), so the drawing fills it and a point of the drawing is a share of the parent's box. One parent places labels on one drawing, and states no block size or ratio of its own.",
|
|
1136
1150
|
guides: [RECIPES],
|
|
1137
|
-
message: (failure) => failure.reason === "artwork" ? `Text part ${failure.part} is anchored to a part that is not a sibling decoration with artwork.` : failure.reason === "several" ? `Text part ${failure.part} is anchored to another drawing than its siblings: one parent is sized to one drawing.` : `Text part ${failure.part} is anchored to a drawing, but its parent already states a block size or ratio.`,
|
|
1151
|
+
message: (failure) => failure.reason === "artwork" ? `Text part ${failure.part} is anchored to a part that is not a sibling decoration with artwork.` : failure.reason === "several" ? `Text part ${failure.part} is anchored to another drawing than its siblings: one parent is sized to one drawing.` : failure.reason === "size" ? `Text part ${failure.part} is sized in its drawing's units, but its text profile states no font size to keep as its smallest.` : `Text part ${failure.part} is anchored to a drawing, but its parent already states a block size or ratio.`,
|
|
1138
1152
|
repair: 'Anchor labels to a `kind: "decoration"` sibling that binds the drawing, all to the same one, and leave the parent\'s height to the drawing.'
|
|
1139
1153
|
},
|
|
1154
|
+
"sequence-order-unmeasured": {
|
|
1155
|
+
group: "structure-mismatch",
|
|
1156
|
+
rule: 'A sequence staggered by a measured index (`play: { sequence, orderBy: "<name>" }`, a title\'s words rising in turn) reads a measured value of the recipe of type `index` (`{ type: "index", property: "sequence-order" }`), which the owner writes on each instance at render: 0, 1, 2\u2026',
|
|
1157
|
+
guides: [RECIPES],
|
|
1158
|
+
message: (failure) => `Part ${failure.part} staggers its sequence by ${failure.name}, which is not a measured index of the recipe.`,
|
|
1159
|
+
repair: 'Declare `measured: { <name>: { type: "index", property: "sequence-order" } }` on the recipe and write each instance\'s index with `measured.props({ <name>: i })`.'
|
|
1160
|
+
},
|
|
1140
1161
|
"slider-fill-unsupported": {
|
|
1141
1162
|
group: "structure-mismatch",
|
|
1142
1163
|
rule: 'A slider\'s fill (`pseudo.sliderFill`) is drawn on its track up to the thumb: the element draws its track (`sliderTrack`), whose size and radius the fill takes, and declares a measured share (`{ type: "share", property: "slider-fill" }`) the owner writes as the value\'s place in its range, 0 to 1. Firefox draws the fill natively; other engines paint the track up to the share.',
|
|
@@ -41,6 +41,7 @@ import {
|
|
|
41
41
|
isStringLiteral,
|
|
42
42
|
isVariableDeclaration,
|
|
43
43
|
isVariableDeclarationList,
|
|
44
|
+
isVariableStatement,
|
|
44
45
|
isWhileStatement
|
|
45
46
|
} from "typescript/ast";
|
|
46
47
|
import { JsxEmit, ModuleKind, ModuleResolutionKind } from "typescript/async";
|
|
@@ -1008,6 +1009,8 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
1008
1009
|
const normalized = parsed.value.kind === "region" ? parsed.value.normalizeWhen.find(([selector]) => selector === `& > ${part.selector}`) : void 0;
|
|
1009
1010
|
if (part.pointerTransparent || part.within.length === 0 && normalized?.[1].some(([property, value]) => property === "pointer-events" && value === "none"))
|
|
1010
1011
|
await pointerTransparent(match.opening, part.name, context, resolve);
|
|
1012
|
+
if (element === "textarea" && part.controlFrame === !0 && part.element?.kind !== "textarea")
|
|
1013
|
+
return fail(match.opening, { kind: "textarea-element-missing", part: part.name });
|
|
1011
1014
|
if (part.resizes && element !== "textarea")
|
|
1012
1015
|
return fail(authoredAt(classes.calls, `${part.path}.normalize.resize`) ?? match.opening, { kind: "resize-not-textarea", part: part.name, element });
|
|
1013
1016
|
if (part.scrolls)
|
|
@@ -1567,6 +1570,21 @@ async function analyzeOwner(root, emitted, name, program, options, rowsOf, fail)
|
|
|
1567
1570
|
if (leaf.value.kind === "styled")
|
|
1568
1571
|
for (const { target } of leaf.value.assetSources)
|
|
1569
1572
|
assetEdits.set(target, selection);
|
|
1573
|
+
const macroInitializers = new Set(values.macroCalls.keys());
|
|
1574
|
+
for (const access of nodesOfKind(source, SyntaxKind.PropertyAccessExpression, isPropertyAccessExpression)) {
|
|
1575
|
+
if (access.name.text !== "source" || assetEdits.has(access))
|
|
1576
|
+
continue;
|
|
1577
|
+
const part = access.expression;
|
|
1578
|
+
if (!isPropertyAccessExpression(part) || !isPropertyAccessExpression(part.expression) || part.expression.name.text !== "assets")
|
|
1579
|
+
continue;
|
|
1580
|
+
const holder = part.expression.expression;
|
|
1581
|
+
if (!isIdentifier(holder))
|
|
1582
|
+
continue;
|
|
1583
|
+
const initializer = source.statements.flatMap((statement) => isVariableStatement(statement) ? [...statement.declarationList.declarations] : []).find((node) => isIdentifier(node.name) && node.name.text === holder.text)?.initializer;
|
|
1584
|
+
if (initializer === void 0 || !macroInitializers.has(initializer))
|
|
1585
|
+
continue;
|
|
1586
|
+
return fail(access, { kind: "drawing-read-unbound", name: `${holder.text}.assets.${part.name.text}` });
|
|
1587
|
+
}
|
|
1570
1588
|
for (const statement of source.statements)
|
|
1571
1589
|
if (isImportDeclaration(statement) && isStringLiteral(statement.moduleSpecifier) && statement.moduleSpecifier.text === RECIPE_MODULE)
|
|
1572
1590
|
edits.push({ node: statement, text: "" });
|
|
@@ -6,6 +6,7 @@ import { checkProgressContrast } from "./placeholder-contrast.mjs";
|
|
|
6
6
|
import { BORDER_STYLE, BORDER_STYLES, INACTIVE_STATE, SURFACE_STATE, TEXT_TRANSFORM, TEXT_TRANSFORMS, sequenceStepTokenRoles } from "./role-vocabulary.mjs";
|
|
7
7
|
import { FORCED_FIELDS, FORCED_ONLY, FORCED_PREFIX } from "./forced-colors.mjs";
|
|
8
8
|
import { controlFrameInsets } from "./lowering-region-layout.mjs";
|
|
9
|
+
import { measuredRead } from "./measured-geometry.mjs";
|
|
9
10
|
import { recipeTree } from "./recipe-model.mjs";
|
|
10
11
|
import { profileReference } from "./profile-model.mjs";
|
|
11
12
|
import { inspectMotion } from "./motion-model.mjs";
|
|
@@ -253,7 +254,7 @@ export function writeStateText(out, profile, element, base, texts, selector, rej
|
|
|
253
254
|
out.rule(selector(condition), Object.fromEntries(changed.map((property) => [property, fields[property] ?? STATE_TEXT_INITIAL[property] ?? "normal"])));
|
|
254
255
|
}
|
|
255
256
|
}
|
|
256
|
-
export function writePlays(out, profile, foundation, element, plays, selector, taken, reject) {
|
|
257
|
+
export function writePlays(out, profile, foundation, element, plays, selector, taken, reject, measured = null) {
|
|
257
258
|
for (const play of plays) {
|
|
258
259
|
const selected = profile.select(play.sequence);
|
|
259
260
|
if (selected.kind !== "sequence")
|
|
@@ -279,7 +280,14 @@ export function writePlays(out, profile, foundation, element, plays, selector, t
|
|
|
279
280
|
if (roles === void 0 || role === void 0 || !roles.includes(role))
|
|
280
281
|
return reject({ kind: "sequence-step-field", profile: play.sequence, at: step.at, field });
|
|
281
282
|
}
|
|
282
|
-
const
|
|
283
|
+
const orderVar = (spec) => {
|
|
284
|
+
if (spec.orderBy === null)
|
|
285
|
+
return null;
|
|
286
|
+
const value = measured?.values.find((item) => item.name === spec.orderBy && item.type === "index");
|
|
287
|
+
if (measured === null || value === void 0)
|
|
288
|
+
return reject({ kind: "sequence-order-unmeasured", part: element, name: spec.orderBy });
|
|
289
|
+
return measuredRead(measured.scope, value, "0");
|
|
290
|
+
}, lowered = sequenceRules({
|
|
283
291
|
profile: play.sequence,
|
|
284
292
|
selector,
|
|
285
293
|
condition: play.condition,
|
|
@@ -289,6 +297,7 @@ export function writePlays(out, profile, foundation, element, plays, selector, t
|
|
|
289
297
|
stagger: fields.stagger ?? null,
|
|
290
298
|
repeat,
|
|
291
299
|
order: play.order,
|
|
300
|
+
orderVar: orderVar(play),
|
|
292
301
|
paused: play.paused
|
|
293
302
|
});
|
|
294
303
|
if (lowered.kind === "err")
|
|
@@ -180,6 +180,11 @@ export interface PlaySpec {
|
|
|
180
180
|
readonly condition: string | null;
|
|
181
181
|
readonly sequence: string;
|
|
182
182
|
readonly order: number;
|
|
183
|
+
/**
|
|
184
|
+
* `orderBy`: a measured `index` the owner writes on each instance of a repeated part (a title's words): each starts
|
|
185
|
+
* that many staggers late, however many there are. `null`: `order` alone.
|
|
186
|
+
*/
|
|
187
|
+
readonly orderBy: string | null;
|
|
183
188
|
/** `paused: true`: held at its first step (a diagram armed before it scrolls into view), released by another state. */
|
|
184
189
|
readonly paused: boolean;
|
|
185
190
|
readonly path: string;
|
|
@@ -193,7 +198,14 @@ export interface TextAnchor {
|
|
|
193
198
|
readonly x: number;
|
|
194
199
|
readonly y: number;
|
|
195
200
|
readonly inline: "start" | "center" | "end";
|
|
196
|
-
|
|
201
|
+
/** `baseline`: the label's first baseline sits on `y`, as an SVG `<text>`'s does. */
|
|
202
|
+
readonly block: "start" | "center" | "end" | "baseline";
|
|
203
|
+
/**
|
|
204
|
+
* The label's size in the drawing's units, so it scales with the drawing (11 units on a 540-wide drawing are 11px at
|
|
205
|
+
* 540px, 23px at 1134px); never below its text profile's size, so it stays readable and follows the reader's text
|
|
206
|
+
* size. `null`: its text profile's size.
|
|
207
|
+
*/
|
|
208
|
+
readonly size: number | null;
|
|
197
209
|
readonly path: string;
|
|
198
210
|
}
|
|
199
211
|
/** A named group of a part's drawing (`data-group` in the asset's SVG) and the sequences it plays. */
|
|
@@ -574,11 +586,18 @@ export type Overflow = {
|
|
|
574
586
|
};
|
|
575
587
|
export declare const OVERFLOW_VALUES: readonly ["clip", "scroll-block", "scroll-inline", "scroll-both"];
|
|
576
588
|
/** How a part takes space in its parent's stack or inline arrangement: its content's size, or the free main-axis space (and the cross axis with `both`). */
|
|
589
|
+
/**
|
|
590
|
+
* How a part takes its parent's main-axis space: its content's size; the free space from nothing (`fill`, equal
|
|
591
|
+
* shares); or growing from its own size (`grow`: in a wrapping row the items sit at their own widths where they fit,
|
|
592
|
+
* and each fills its line where they wrap).
|
|
593
|
+
*/
|
|
577
594
|
export type Extent = {
|
|
578
595
|
readonly kind: "content";
|
|
579
596
|
} | {
|
|
580
597
|
readonly kind: "fill";
|
|
581
598
|
readonly axis: "main" | "both";
|
|
599
|
+
} | {
|
|
600
|
+
readonly kind: "grow";
|
|
582
601
|
};
|
|
583
602
|
/** A part shown or hidden while a named condition of the nearest recipe's spatial profile holds (viewport width below its token). */
|
|
584
603
|
export interface PartCondition {
|
|
@@ -606,6 +625,10 @@ export type ElementKind = {
|
|
|
606
625
|
} | {
|
|
607
626
|
readonly kind: "input";
|
|
608
627
|
readonly type: "search" | "text";
|
|
628
|
+
}
|
|
629
|
+
/** A multi-line text field: a control frame keeps its stated insets around the lines (it centres no single line). */
|
|
630
|
+
| {
|
|
631
|
+
readonly kind: "textarea";
|
|
609
632
|
} | {
|
|
610
633
|
readonly kind: "table";
|
|
611
634
|
}
|
|
@@ -626,7 +649,7 @@ export type ElementKind = {
|
|
|
626
649
|
readonly kind: "summary";
|
|
627
650
|
readonly marker: "native" | "none";
|
|
628
651
|
};
|
|
629
|
-
export declare const ELEMENT_NAMES: readonly ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary", "document"];
|
|
652
|
+
export declare const ELEMENT_NAMES: readonly ["iframe", "select", "search-input", "text-input", "textarea", "table", "header-cell", "cell", "list", "summary", "document"];
|
|
630
653
|
export type ElementName = (typeof ELEMENT_NAMES)[number];
|
|
631
654
|
/**
|
|
632
655
|
* How a text part breaks: anywhere (long words wrap), never, truncated with an
|
|
@@ -675,7 +698,7 @@ export type PartContent = {
|
|
|
675
698
|
export type StateTreatment = readonly [condition: string, surface: string];
|
|
676
699
|
export type RegionPartContent = PartContent["kind"];
|
|
677
700
|
/** The kinds of value a measured declaration carries: a px length, a px translation (x, y) or a px grid track length. */
|
|
678
|
-
export declare const MEASURED_TYPES: readonly ["length", "transform", "scale", "size-track", "position", "intrinsic-size", "share"];
|
|
701
|
+
export declare const MEASURED_TYPES: readonly ["length", "transform", "scale", "size-track", "position", "intrinsic-size", "share", "index"];
|
|
679
702
|
export type MeasuredType = (typeof MEASURED_TYPES)[number];
|
|
680
703
|
/**
|
|
681
704
|
* A geometry value the owner measures or computes at runtime and writes through
|
|
@@ -738,6 +761,12 @@ export type MeasuredValue =
|
|
|
738
761
|
readonly type: "share";
|
|
739
762
|
readonly name: string;
|
|
740
763
|
readonly property: string;
|
|
764
|
+
}
|
|
765
|
+
/** An instance's place among its siblings (0, 1, 2…): how many staggers its sequence starts late (`play.orderBy`). */
|
|
766
|
+
| {
|
|
767
|
+
readonly type: "index";
|
|
768
|
+
readonly name: string;
|
|
769
|
+
readonly property: string;
|
|
741
770
|
};
|
|
742
771
|
/**
|
|
743
772
|
* A paint the owner selects at runtime from data (a chart series, a status):
|
|
@@ -895,10 +924,14 @@ export interface ModalSheet {
|
|
|
895
924
|
* Inline edge the sheet is attached to (logical, so it mirrors in RTL), or a card's place: `center` in the
|
|
896
925
|
* viewport, or `block-start` (centred inline, the layer profile's margin below the top).
|
|
897
926
|
*/
|
|
898
|
-
readonly edge: "start" | "end" | "center" | "block-start";
|
|
927
|
+
readonly edge: "start" | "end" | "center" | "block-start" | "fill";
|
|
899
928
|
readonly backdrop: Backdrop;
|
|
900
|
-
/**
|
|
901
|
-
|
|
929
|
+
/**
|
|
930
|
+
* A sheet travels its own extent from `edge`; a card or a whole-viewport modal (`fill`) fades, drops in (`drop`: fades
|
|
931
|
+
* while coming down its motion profile's distance from its scale), or keeps still while only its veil fades (`veil`);
|
|
932
|
+
* `null` opens and closes instantly.
|
|
933
|
+
*/
|
|
934
|
+
readonly motion: "slide" | "fade" | "drop" | "veil" | null;
|
|
902
935
|
/** Breakpoint tier of the selected spatial profile from which the owner shows its inline alternative; `null` = modal at every size. */
|
|
903
936
|
readonly modalBelow: string | null;
|
|
904
937
|
}
|
|
@@ -962,6 +995,8 @@ export interface RegionSpec {
|
|
|
962
995
|
readonly text: TextBinding | null;
|
|
963
996
|
readonly textAlign: TextAlign | null;
|
|
964
997
|
readonly overflow: Overflow;
|
|
998
|
+
/** A layer root's own scroll (its layer makes it scroll) kept to itself: `overscroll: "contain"` with no `overflow`. */
|
|
999
|
+
readonly layerOverscroll?: boolean;
|
|
965
1000
|
readonly element: ElementKind | null;
|
|
966
1001
|
readonly normalize: readonly (readonly [property: string, value: string])[];
|
|
967
1002
|
readonly normalizeWhen: readonly (readonly [selector: string, values: readonly (readonly [property: string, value: string])[]])[];
|
|
@@ -1094,6 +1129,8 @@ export interface DeclaredPart {
|
|
|
1094
1129
|
readonly declaresBoundary: boolean;
|
|
1095
1130
|
/** Whether the part declares `normalize.resize`: its element is a `<textarea>`. */
|
|
1096
1131
|
readonly resizes: boolean;
|
|
1132
|
+
/** Whether the part's frame is a control's (`frame: { kind: "control" }`): on a `<textarea>` it needs `element: "textarea"`. */
|
|
1133
|
+
readonly controlFrame?: boolean;
|
|
1097
1134
|
/** The colour scheme a visual part of a light and dark pair is shown under; `null` for every other part. */
|
|
1098
1135
|
readonly scheme: ColorScheme | null;
|
|
1099
1136
|
}
|
|
@@ -14,12 +14,12 @@ function textAnchor(value, path, read) {
|
|
|
14
14
|
if (value === void 0)
|
|
15
15
|
return null;
|
|
16
16
|
const declared = read.object(value, path);
|
|
17
|
-
read.only(declared, path, ["artwork", "x", "y", "inline", "block"]);
|
|
17
|
+
read.only(declared, path, ["artwork", "x", "y", "inline", "block", "size"]);
|
|
18
18
|
const coordinate = (key) => {
|
|
19
19
|
const item = declared[key];
|
|
20
20
|
return typeof item === "number" && Number.isFinite(item) ? item : read.invalid(`${path}.${key}`, "a number in the drawing's coordinates");
|
|
21
|
-
}, edge = (key) => declared[key] === void 0 ? "start" : read.literal(declared[key], `${path}.${key}`, ["start", "center", "end"]);
|
|
22
|
-
return { artwork: read.string(declared.artwork, `${path}.artwork`), x: coordinate("x"), y: coordinate("y"), inline: edge("inline"), block
|
|
21
|
+
}, edge = (key) => declared[key] === void 0 ? "start" : read.literal(declared[key], `${path}.${key}`, ["start", "center", "end"]), block = declared.block === "baseline" ? "baseline" : edge("block"), size = declared.size === void 0 ? null : typeof declared.size === "number" && Number.isFinite(declared.size) && declared.size > 0 ? declared.size : read.invalid(`${path}.size`, "a positive size in the drawing's units");
|
|
22
|
+
return { artwork: read.string(declared.artwork, `${path}.artwork`), x: coordinate("x"), y: coordinate("y"), inline: edge("inline"), block, size, path };
|
|
23
23
|
}
|
|
24
24
|
export const STICKY_EDGES = ["block-start", "block-end", "inline-start", "inline-end"], ENTER_MOVEMENTS = { translate: "distance", translateInline: "distance", scale: "scale", rotate: "angle" }, PSEUDO_ELEMENTS = ["placeholder", "progressValue", "marker", "before", "sliderTrack", "sliderThumb", "sliderFill"], REPLACED_ELEMENTS = ["img", "input", "select", "textarea", "video", "iframe", "br", "hr", "svg"], PSEUDO_HOSTS = { placeholder: ["input", "textarea"], progressValue: ["progress"], marker: ["li", "summary"], before: "non-replaced", sliderTrack: ["input"], sliderThumb: ["input"], sliderFill: ["input"] }, pseudoHosted = (pseudo, element) => {
|
|
25
25
|
const hosts = PSEUDO_HOSTS[pseudo];
|
|
@@ -47,12 +47,13 @@ function conditionAlignment(fields, path, read) {
|
|
|
47
47
|
};
|
|
48
48
|
}
|
|
49
49
|
const aligns = (alignment) => alignment.align !== null || alignment.justify !== null || alignment.textAlign !== null;
|
|
50
|
-
export const OVERFLOW_VALUES = ["clip", "scroll-block", "scroll-inline", "scroll-both"], ELEMENT_NAMES = ["iframe", "select", "search-input", "text-input", "table", "header-cell", "cell", "list", "summary", "document"], TEXT_WRAPS = ["anywhere", "never", "truncate", "balance", "pretty", "preserve"], TEXT_ALIGNS = ["start", "center", "end"], MEASURED_TYPES = ["length", "transform", "scale", "size-track", "position", "intrinsic-size", "share"], GRID_FIELDS = ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align", "contentFrom"];
|
|
50
|
+
export const OVERFLOW_VALUES = ["clip", "scroll-block", "scroll-inline", "scroll-both"], ELEMENT_NAMES = ["iframe", "select", "search-input", "text-input", "textarea", "table", "header-cell", "cell", "list", "summary", "document"], TEXT_WRAPS = ["anywhere", "never", "truncate", "balance", "pretty", "preserve"], TEXT_ALIGNS = ["start", "center", "end"], MEASURED_TYPES = ["length", "transform", "scale", "size-track", "position", "intrinsic-size", "share", "index"], GRID_FIELDS = ["columns", "weights", "gutter", "margin", "bound", "rows", "context", "align", "contentFrom"];
|
|
51
51
|
export function elementTags(element) {
|
|
52
52
|
switch (element.kind) {
|
|
53
53
|
case "iframe":
|
|
54
54
|
case "select":
|
|
55
55
|
case "input":
|
|
56
|
+
case "textarea":
|
|
56
57
|
case "table":
|
|
57
58
|
case "summary":
|
|
58
59
|
return [element.kind];
|
|
@@ -140,6 +141,7 @@ const regionParts = (parts, within, parent, parentLayout) => parts.flatMap((part
|
|
|
140
141
|
blockText: blockText(part, parentLayout),
|
|
141
142
|
declaresBoundary: part.accessibility !== null,
|
|
142
143
|
resizes: part.normalize.some(([property]) => property === "resize"),
|
|
144
|
+
controlFrame: part.frame?.kind === "control",
|
|
143
145
|
scheme: part.scheme,
|
|
144
146
|
playsAlways: part.plays.flatMap((play) => play.condition === null ? [play.sequence] : [])
|
|
145
147
|
},
|
|
@@ -569,12 +571,15 @@ function paintTransition(value, path, read) {
|
|
|
569
571
|
}
|
|
570
572
|
function playSpec(value, condition, path, read) {
|
|
571
573
|
const declared = read.object(value, path);
|
|
572
|
-
read.only(declared, path, ["sequence", "order", "paused"]);
|
|
574
|
+
read.only(declared, path, ["sequence", "order", "orderBy", "paused"]);
|
|
573
575
|
const order = declared.order === void 0 ? 0 : declared.order;
|
|
574
576
|
if (typeof order !== "number" || !Number.isInteger(order) || order < 0 || order > 32)
|
|
575
577
|
return read.invalid(`${path}.order`, "a whole number from 0 to 32");
|
|
578
|
+
const orderBy = read.optionalString(declared.orderBy, `${path}.orderBy`);
|
|
579
|
+
if (orderBy !== null && declared.order !== void 0)
|
|
580
|
+
return read.invalid(`${path}.orderBy`, "an order by a measured index or a fixed `order`, not both");
|
|
576
581
|
const paused = declared.paused === void 0 ? !1 : read.boolean(declared.paused, `${path}.paused`);
|
|
577
|
-
return { condition, sequence: read.string(declared.sequence, `${path}.sequence`), order, paused, path };
|
|
582
|
+
return { condition, sequence: read.string(declared.sequence, `${path}.sequence`), order, orderBy, paused, path };
|
|
578
583
|
}
|
|
579
584
|
function artworkGroups(value, path, read) {
|
|
580
585
|
if (value === void 0)
|
|
@@ -947,6 +952,7 @@ function elementKind(value, marker, path, read, align) {
|
|
|
947
952
|
switch (name) {
|
|
948
953
|
case "iframe":
|
|
949
954
|
case "select":
|
|
955
|
+
case "textarea":
|
|
950
956
|
case "table":
|
|
951
957
|
case "list":
|
|
952
958
|
return { kind: name };
|
|
@@ -1049,7 +1055,9 @@ function partContent(part, path, read) {
|
|
|
1049
1055
|
function extent(value, path, read) {
|
|
1050
1056
|
if (value === void 0)
|
|
1051
1057
|
return { kind: "content" };
|
|
1052
|
-
switch (read.literal(value, path, ["fill", "fill-both"])) {
|
|
1058
|
+
switch (read.literal(value, path, ["fill", "fill-both", "grow"])) {
|
|
1059
|
+
case "grow":
|
|
1060
|
+
return { kind: "grow" };
|
|
1053
1061
|
case "fill":
|
|
1054
1062
|
return { kind: "fill", axis: "main" };
|
|
1055
1063
|
case "fill-both":
|
|
@@ -1099,6 +1107,7 @@ function measuredValues(value, path, read) {
|
|
|
1099
1107
|
case "position":
|
|
1100
1108
|
case "intrinsic-size":
|
|
1101
1109
|
case "share":
|
|
1110
|
+
case "index":
|
|
1102
1111
|
read.only(fields, at, ["type", "property"]);
|
|
1103
1112
|
return { type, name, property };
|
|
1104
1113
|
}
|
|
@@ -1466,7 +1475,8 @@ function region(authored, read) {
|
|
|
1466
1475
|
surface: read.optionalString(spec.surface, "recipe.surface"),
|
|
1467
1476
|
text: textBinding(spec.text, "recipe.text", read),
|
|
1468
1477
|
textAlign: spec.textAlign === void 0 ? null : read.literal(spec.textAlign, "recipe.textAlign", TEXT_ALIGNS),
|
|
1469
|
-
overflow: overflow(spec.overflow, "recipe.overflow", read, spec.overscroll),
|
|
1478
|
+
overflow: overflow(spec.overflow, "recipe.overflow", read, spec.layer !== void 0 && spec.overflow === void 0 ? void 0 : spec.overscroll),
|
|
1479
|
+
layerOverscroll: spec.layer !== void 0 && spec.overflow === void 0 && spec.overscroll !== void 0 && read.literal(spec.overscroll, "recipe.overscroll", ["contain"]) === "contain",
|
|
1470
1480
|
element: elementKind(spec.element, spec.marker, "recipe", read, spec.element === "cell" || spec.element === "header-cell" ? spec.align : void 0),
|
|
1471
1481
|
normalize: normalized.values,
|
|
1472
1482
|
normalizeWhen: normalized.when,
|
|
@@ -1491,7 +1501,7 @@ function region(authored, read) {
|
|
|
1491
1501
|
paints
|
|
1492
1502
|
};
|
|
1493
1503
|
}
|
|
1494
|
-
const EDGES = ["start", "end"], DIALOG_EDGES = ["start", "end", "center", "block-start"];
|
|
1504
|
+
const EDGES = ["start", "end"], DIALOG_EDGES = ["start", "end", "center", "block-start", "fill"];
|
|
1495
1505
|
function layerSpec(value, read) {
|
|
1496
1506
|
if (value === void 0)
|
|
1497
1507
|
return null;
|
|
@@ -1501,7 +1511,7 @@ function layerSpec(value, read) {
|
|
|
1501
1511
|
read.only(layer, path, ["element", "edge", "backdrop", "motion", "modalBelow"]);
|
|
1502
1512
|
const backdrop = read.object(layer.backdrop, `${path}.backdrop`);
|
|
1503
1513
|
read.only(backdrop, `${path}.backdrop`, ["surface", "dismiss"]);
|
|
1504
|
-
const edge = read.literal(layer.edge, `${path}.edge`, DIALOG_EDGES), card = edge === "center" || edge === "block-start";
|
|
1514
|
+
const edge = read.literal(layer.edge, `${path}.edge`, DIALOG_EDGES), card = edge === "center" || edge === "block-start" || edge === "fill";
|
|
1505
1515
|
return {
|
|
1506
1516
|
kind: "modal-sheet",
|
|
1507
1517
|
element,
|
|
@@ -1510,7 +1520,7 @@ function layerSpec(value, read) {
|
|
|
1510
1520
|
surface: read.string(backdrop.surface, `${path}.backdrop.surface`),
|
|
1511
1521
|
dismiss: backdrop.dismiss === void 0 ? "none" : read.literal(backdrop.dismiss, `${path}.backdrop.dismiss`, ["press", "none"])
|
|
1512
1522
|
},
|
|
1513
|
-
motion: layer.motion === void 0 ? null : card ? read.literal(layer.motion, `${path}.motion`, ["fade"]) : read.literal(layer.motion, `${path}.motion`, ["slide"]),
|
|
1523
|
+
motion: layer.motion === void 0 ? null : card ? read.literal(layer.motion, `${path}.motion`, ["fade", "drop", "veil"]) : read.literal(layer.motion, `${path}.motion`, ["slide"]),
|
|
1514
1524
|
modalBelow: read.optionalString(layer.modalBelow, `${path}.modalBelow`)
|
|
1515
1525
|
};
|
|
1516
1526
|
}
|
package/dist/end-alignment.mjs
CHANGED
|
@@ -12,7 +12,7 @@ function endsRagged(arrangement, parts) {
|
|
|
12
12
|
return !1;
|
|
13
13
|
if (arrangement.justify !== null && /end|space-/.test(arrangement.justify))
|
|
14
14
|
return !1;
|
|
15
|
-
return !parts.some((part) => part.extent.kind
|
|
15
|
+
return !parts.some((part) => part.extent.kind !== "content");
|
|
16
16
|
}
|
|
17
17
|
export function endInsetOf(foundation, spec) {
|
|
18
18
|
switch (spec.kind) {
|
|
@@ -29,7 +29,7 @@ export function endInsetOf(foundation, spec) {
|
|
|
29
29
|
if (frame.kind === "err" || frame.value.kind !== "frame")
|
|
30
30
|
return null;
|
|
31
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);
|
|
32
|
-
if (surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || borderedAtEnd(frame.value.fields, spec.frame?.border ?? null))
|
|
32
|
+
if (surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && (surface.value.fields.has("background") || surface.value.fields.has("background-image")) || borderedAtEnd(frame.value.fields, spec.frame?.border ?? null))
|
|
33
33
|
return [];
|
|
34
34
|
if (endsRagged(spec.arrangement, spec.parts))
|
|
35
35
|
return null;
|
|
@@ -71,7 +71,7 @@ function paintsFlushBox(foundation, spec) {
|
|
|
71
71
|
if (selected.kind === "err")
|
|
72
72
|
return !1;
|
|
73
73
|
const frameName = selected.value.kind === "frame" ? spec.profile : selected.value.kind === "composite" ? selected.value.fields.get("frame-profile") : void 0, frame = frameName === void 0 ? null : frameName === spec.profile ? selected : selectedProfile(foundation, frameName), fields = frame !== null && frame.kind === "ok" && frame.value.kind === "frame" ? frame.value.fields : new Map, surfaceName = spec.surface ?? (selected.value.kind === "composite" ? selected.value.fields.get("surface-profile") : void 0), surface = surfaceName === void 0 ? null : selectedProfile(foundation, surfaceName);
|
|
74
|
-
if (!(surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background")) && !borderedAtEnd(fields, spec.frame?.border ?? null))
|
|
74
|
+
if (!(surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && (surface.value.fields.has("background") || surface.value.fields.has("background-image"))) && !borderedAtEnd(fields, spec.frame?.border ?? null))
|
|
75
75
|
return !1;
|
|
76
76
|
const end = frameInlineInsets(Object.fromEntries(fields)).end;
|
|
77
77
|
return end === void 0 || /^0(px)?$/.test(end.trim());
|
|
@@ -88,7 +88,7 @@ export function stackPartsOf(foundation, spec) {
|
|
|
88
88
|
const frame = selectedProfile(foundation, part.box);
|
|
89
89
|
if (frame.kind === "err" || frame.value.kind !== "frame")
|
|
90
90
|
return [];
|
|
91
|
-
const surface = part.surface === null ? null : selectedProfile(foundation, part.surface), painted = surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && surface.value.fields.has("background") || borderedAtEnd(frame.value.fields, null);
|
|
91
|
+
const surface = part.surface === null ? null : selectedProfile(foundation, part.surface), painted = surface !== null && surface.kind === "ok" && surface.value.kind === "surface" && (surface.value.fields.has("background") || surface.value.fields.has("background-image")) || borderedAtEnd(frame.value.fields, null) || part.overflow.kind === "clip";
|
|
92
92
|
if (painted && banded)
|
|
93
93
|
return [];
|
|
94
94
|
if (painted)
|
package/dist/lowering-layer.mjs
CHANGED
|
@@ -24,13 +24,13 @@ const transition = (property, timing) => ({
|
|
|
24
24
|
"transition-timing-function": timing.easing,
|
|
25
25
|
...timing.delay === null ? {} : { "transition-delay": timing.delay }
|
|
26
26
|
}), REDUCED = { "transition-duration": "0s", "transition-delay": "0s" };
|
|
27
|
-
function sheetRules(sheet, backdrop, own, motion, margin) {
|
|
27
|
+
function sheetRules(sheet, backdrop, own, motion, margin, drop = null) {
|
|
28
28
|
const field = Object.keys(backdrop.fields).find((name) => name !== "background" && name !== "backdrop-blur"), background = backdrop.fields.background;
|
|
29
29
|
if (field !== void 0 || background === void 0)
|
|
30
30
|
return err({ kind: "backdrop-surface-unsupported", surface: backdrop.name, field: field ?? null });
|
|
31
31
|
const blur = backdrop.fields["backdrop-blur"], veil = { background, ...blur === void 0 ? {} : { "-webkit-backdrop-filter": `blur(${blur})`, "backdrop-filter": `blur(${blur})` } };
|
|
32
|
-
if (sheet.edge === "center" || sheet.edge === "block-start")
|
|
33
|
-
return ok(cardRules(sheet, veil, own, motion, margin ?? { inline: "0px", block: "0px" }));
|
|
32
|
+
if (sheet.edge === "center" || sheet.edge === "block-start" || sheet.edge === "fill")
|
|
33
|
+
return ok(cardRules(sheet, veil, own, motion, margin ?? { inline: "0px", block: "0px" }, drop));
|
|
34
34
|
const placement = {
|
|
35
35
|
position: "fixed",
|
|
36
36
|
"inset-block-start": "0",
|
|
@@ -60,8 +60,23 @@ function sheetRules(sheet, backdrop, own, motion, margin) {
|
|
|
60
60
|
]
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
function cardRules(sheet, veil, own, motion, margin) {
|
|
64
|
-
const placement = {
|
|
63
|
+
function cardRules(sheet, veil, own, motion, margin, drop = null) {
|
|
64
|
+
const placement = sheet.edge === "fill" ? {
|
|
65
|
+
position: "fixed",
|
|
66
|
+
"inset-block-start": "0",
|
|
67
|
+
"inset-block-end": "0",
|
|
68
|
+
"inset-inline-start": "0",
|
|
69
|
+
"inset-inline-end": "0",
|
|
70
|
+
"margin-block-start": "0",
|
|
71
|
+
"margin-block-end": "0",
|
|
72
|
+
"margin-inline-start": "0",
|
|
73
|
+
"margin-inline-end": "0",
|
|
74
|
+
"inline-size": "100%",
|
|
75
|
+
"block-size": "100%",
|
|
76
|
+
"max-block-size": "none",
|
|
77
|
+
"max-inline-size": "none",
|
|
78
|
+
"min-inline-size": "0"
|
|
79
|
+
} : {
|
|
65
80
|
position: "fixed",
|
|
66
81
|
"inset-block-start": "0",
|
|
67
82
|
"inset-block-end": "0",
|
|
@@ -73,16 +88,30 @@ function cardRules(sheet, veil, own, motion, margin) {
|
|
|
73
88
|
"margin-inline-end": "auto",
|
|
74
89
|
"block-size": "fit-content",
|
|
75
90
|
"max-block-size": `calc(100dvh - ${margin.block} * 2)`,
|
|
76
|
-
"max-inline-size": inlineCap(margin.inline, own)
|
|
91
|
+
"max-inline-size": inlineCap(margin.inline, own),
|
|
92
|
+
"min-inline-size": "0"
|
|
77
93
|
}, paint = { selector: "&::backdrop", values: veil, condition: null };
|
|
78
94
|
if (motion === null || sheet.motion === null)
|
|
79
95
|
return { root: placement, rules: [paint] };
|
|
96
|
+
if (sheet.motion === "veil")
|
|
97
|
+
return {
|
|
98
|
+
root: { ...placement, "transition-property": DISCRETE, "transition-behavior": "allow-discrete", "transition-duration": motion.duration, ...motion.delay === null ? {} : { "transition-delay": motion.delay } },
|
|
99
|
+
rules: [
|
|
100
|
+
paint,
|
|
101
|
+
{ selector: "&::backdrop", values: transition("opacity", motion), condition: null },
|
|
102
|
+
{ selector: "&:not([open])::backdrop", values: { opacity: "0" }, condition: null },
|
|
103
|
+
{ selector: "&[open]::backdrop", values: { opacity: "0" }, condition: STARTING },
|
|
104
|
+
{ selector: "&", values: REDUCED, condition: REDUCED_MOTION },
|
|
105
|
+
{ selector: "&::backdrop", values: REDUCED, condition: REDUCED_MOTION }
|
|
106
|
+
]
|
|
107
|
+
};
|
|
108
|
+
const away = sheet.motion === "drop" && drop !== null ? { opacity: "0", translate: `0 calc(-1 * ${drop.distance})`, scale: drop.scale } : { opacity: "0" };
|
|
80
109
|
return {
|
|
81
|
-
root: { ...placement, ...transition("opacity", motion) },
|
|
110
|
+
root: { ...placement, ...sheet.motion === "drop" ? { "transform-origin": "top center" } : {}, ...transition(sheet.motion === "drop" ? "opacity, translate, scale" : "opacity", motion) },
|
|
82
111
|
rules: [
|
|
83
112
|
paint,
|
|
84
|
-
{ selector: "&:not([open])", values:
|
|
85
|
-
{ selector: "&[open]", values:
|
|
113
|
+
{ selector: "&:not([open])", values: away, condition: null },
|
|
114
|
+
{ selector: "&[open]", values: away, condition: STARTING },
|
|
86
115
|
{ selector: "&::backdrop", values: transition("opacity", motion), condition: null },
|
|
87
116
|
{ selector: "&:not([open])::backdrop", values: { opacity: "0" }, condition: null },
|
|
88
117
|
{ selector: "&[open]::backdrop", values: { opacity: "0" }, condition: STARTING },
|
|
@@ -91,8 +120,12 @@ function cardRules(sheet, veil, own, motion, margin) {
|
|
|
91
120
|
]
|
|
92
121
|
};
|
|
93
122
|
}
|
|
123
|
+
function blockCap(room, own) {
|
|
124
|
+
const frameCap = own["max-block-size"];
|
|
125
|
+
return frameCap === void 0 ? room : `min(${frameCap}, ${room})`;
|
|
126
|
+
}
|
|
94
127
|
function inlineCap(margin, own) {
|
|
95
|
-
const cap = `calc(
|
|
128
|
+
const cap = `calc(100% - ${margin} * 2)`, frameCap = own["max-inline-size"];
|
|
96
129
|
return frameCap === void 0 ? cap : `min(${frameCap}, ${cap})`;
|
|
97
130
|
}
|
|
98
131
|
function fade(kind, placement, motion, enabled, drop = null) {
|
|
@@ -115,8 +148,9 @@ function measuredPopoverRules(popover, margin, own, motion, drop) {
|
|
|
115
148
|
"inset-block-end": "auto",
|
|
116
149
|
"inset-inline-start": "auto",
|
|
117
150
|
"inset-inline-end": "auto",
|
|
118
|
-
"max-block-size": `calc(100dvh - ${margin} * 2)`,
|
|
119
|
-
"max-inline-size": inlineCap(margin, own)
|
|
151
|
+
"max-block-size": blockCap(`calc(100dvh - ${margin} * 2)`, own),
|
|
152
|
+
"max-inline-size": inlineCap(margin, own),
|
|
153
|
+
"min-inline-size": "0"
|
|
120
154
|
};
|
|
121
155
|
return fade("measured-popover", placement, motion, popover.motion !== null, drop);
|
|
122
156
|
}
|
|
@@ -127,15 +161,16 @@ function popoverRules(popover, layout, own, motion, drop) {
|
|
|
127
161
|
"inset-block-end": popover.corner.block === "end" ? gap : "auto",
|
|
128
162
|
"inset-inline-start": popover.corner.inline === "start" ? margin : "auto",
|
|
129
163
|
"inset-inline-end": popover.corner.inline === "end" ? margin : "auto",
|
|
130
|
-
"max-block-size": clear === null ? `calc(100dvh - ${gap} * 2)` : `calc(100dvh - ${clear} - ${gap} * 2)`,
|
|
131
|
-
"max-inline-size": inlineCap(margin, own)
|
|
164
|
+
"max-block-size": blockCap(clear === null ? `calc(100dvh - ${gap} * 2)` : `calc(100dvh - ${clear} - ${gap} * 2)`, own),
|
|
165
|
+
"max-inline-size": inlineCap(margin, own),
|
|
166
|
+
"min-inline-size": "0"
|
|
132
167
|
};
|
|
133
168
|
return fade("anchored-popover", placement, motion, popover.motion !== null, drop);
|
|
134
169
|
}
|
|
135
170
|
function variantRules(input, own) {
|
|
136
171
|
switch (input.kind) {
|
|
137
172
|
case "modal-sheet":
|
|
138
|
-
return sheetRules(input.sheet, input.backdrop, own, input.motion, input.margin);
|
|
173
|
+
return sheetRules(input.sheet, input.backdrop, own, input.motion, input.margin, input.drop ?? null);
|
|
139
174
|
case "anchored-popover":
|
|
140
175
|
return ok(popoverRules(input.popover, input.placement, own, input.motion, input.drop ?? null));
|
|
141
176
|
case "measured-popover":
|
package/dist/lowering-paint.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { err, ok } from "./result.mjs";
|
|
2
|
-
const SLOT = /^[a-z][a-z0-9-]*$/, TOKEN = /^--[a-z][a-z0-9-]*$/, PART = /^\.[a-z][\w-]*$/i;
|
|
2
|
+
const SLOT = /^[a-z][a-z0-9-]*$/, TOKEN = /^--[a-z][a-z0-9-]*$/, PART = /^\.[a-z][\w-]*(?: > \.[a-z][\w-]*)*$/i;
|
|
3
3
|
export const channelProperty = (slot) => `--asset-${slot}`;
|
|
4
4
|
export function paintChannels(part, slots) {
|
|
5
5
|
if (!PART.test(part))
|
|
@@ -152,6 +152,10 @@ export function extentValues(extent, parent, part, parentGrows = !1, parentWraps
|
|
|
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": {
|
|
156
160
|
if (parent === "native" && arranged && extent.axis !== "both")
|
|
157
161
|
return ok({});
|
|
@@ -207,6 +211,7 @@ export function elementNormalization(element, values) {
|
|
|
207
211
|
}
|
|
208
212
|
case "select":
|
|
209
213
|
case "input":
|
|
214
|
+
case "textarea":
|
|
210
215
|
return plain({ margin: "0" });
|
|
211
216
|
case "table":
|
|
212
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
|
-
|
|
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)) {
|