@reqvire-org/ads 0.5.7 → 0.5.8
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/design-foundation.mjs +2 -2
- package/dist/design-inputs.mjs +5 -1
- package/dist/emit/foundation-sheet.mjs +2 -0
- package/dist/foundation-macro.d.mts +5 -0
- package/dist/lowering-emitter.mjs +1 -2
- package/dist/lowering-layer.mjs +2 -3
- package/dist/recipe-model.mjs +2 -1
- package/dist/region-lowering.mjs +16 -7
- package/dist/showcase/client.bundle.js +25 -25
- 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 +4 -3
- package/dist/skills/ads-import/references/recipes.md +4 -3
- package/dist/skills/ads-port/references/recipes.md +4 -3
- package/docs/CHANGELOG.md +32 -18
- package/docs/GUIDE.md +5 -0
- package/docs/LANGUAGE.md +4 -4
- package/package.json +1 -1
|
@@ -217,7 +217,7 @@ function slotArguments(spec, file, declaration) {
|
|
|
217
217
|
}));
|
|
218
218
|
}
|
|
219
219
|
const DOCUMENT_TEXT_FIELDS = ["font-family", "font-size", "line-height"];
|
|
220
|
-
export function documentProfiles(foundation, references) {
|
|
220
|
+
export function documentProfiles(foundation, references, scrollbarGutter = null) {
|
|
221
221
|
const fields = (field) => {
|
|
222
222
|
const reference = references[field], profile = selectedProfile(foundation, reference);
|
|
223
223
|
if (profile.kind === "err")
|
|
@@ -237,7 +237,7 @@ export function documentProfiles(foundation, references) {
|
|
|
237
237
|
const focus = fields("focus");
|
|
238
238
|
if (focus.kind === "err")
|
|
239
239
|
return focus;
|
|
240
|
-
return ok({ text: text.value, surface: surface.value, focus: focus.value, names: { ...references } });
|
|
240
|
+
return ok({ text: text.value, surface: surface.value, focus: focus.value, names: { ...references }, scrollbarGutter });
|
|
241
241
|
}
|
|
242
242
|
export function selectedProfile(foundation, reference, select = {}) {
|
|
243
243
|
const chosen = foundation.model.select(reference, Object.entries(select));
|
package/dist/design-inputs.mjs
CHANGED
|
@@ -40,7 +40,7 @@ export function readDesignInputs(captured, { dsRoot }) {
|
|
|
40
40
|
const contexts = ok(declared.value.contexts), foundation = readFoundation(texts, { kind: "declared", ...contexts.value });
|
|
41
41
|
if (foundation.kind === "err")
|
|
42
42
|
return err({ kind: "foundation", failure: foundation.error });
|
|
43
|
-
const document = documentProfiles(foundation.value, documentReferences(declaration ?? ""));
|
|
43
|
+
const document = documentProfiles(foundation.value, documentReferences(declaration ?? ""), documentGutter(declaration ?? ""));
|
|
44
44
|
if (document.kind === "err")
|
|
45
45
|
return err({ kind: "foundation", failure: document.error });
|
|
46
46
|
const declarations = [];
|
|
@@ -111,6 +111,10 @@ function documentReferences(declaration) {
|
|
|
111
111
|
throw Error("A validated foundation declaration names its text, surface and focus profiles.");
|
|
112
112
|
return { text, surface, focus };
|
|
113
113
|
}
|
|
114
|
+
function documentGutter(declaration) {
|
|
115
|
+
const specs = exampleDeclarations(declaration, FOUNDATION_DECLARATION, "foundation"), spec = specs.kind === "ok" ? specs.value[0] : void 0;
|
|
116
|
+
return isRecordValue(spec) && spec.scrollbarGutter === "stable" ? "stable" : null;
|
|
117
|
+
}
|
|
114
118
|
const isRecordValue = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
115
119
|
export function capturedDesignFiles(dsRoot) {
|
|
116
120
|
const files = [];
|
|
@@ -31,6 +31,8 @@ export function foundationSheet({ foundation, document, themes, fonts, documents
|
|
|
31
31
|
const [base] = themes;
|
|
32
32
|
if (base !== void 0)
|
|
33
33
|
root.append(rule(":root", schemeScope(base.scheme)));
|
|
34
|
+
if (document.scrollbarGutter !== null)
|
|
35
|
+
root.append(rule("html", [["scrollbar-gutter", document.scrollbarGutter]]));
|
|
34
36
|
for (const theme of themes)
|
|
35
37
|
root.append(rule(`:root[data-theme=${JSON.stringify(theme.name)}]`, schemeScope(theme.scheme)));
|
|
36
38
|
if (sectionsDeclared(foundation))
|
|
@@ -42,6 +42,11 @@ export interface FoundationSpec {
|
|
|
42
42
|
* each export) and writes `app-icons.ts` with the links and web manifest entries.
|
|
43
43
|
*/
|
|
44
44
|
readonly appIcon?: AppIconDeclaration;
|
|
45
|
+
/**
|
|
46
|
+
* `"stable"`: the page keeps its scrollbar's room at all times (`scrollbar-gutter: stable` on the document), so a
|
|
47
|
+
* modal's scroll lock, which hides the scrollbar, shifts nothing; omitted, the browser decides.
|
|
48
|
+
*/
|
|
49
|
+
readonly scrollbarGutter?: "stable";
|
|
45
50
|
}
|
|
46
51
|
/** A paint-role token, by name. */
|
|
47
52
|
export type PaintToken = `--${string}`;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { err, ok } from "./result.mjs";
|
|
2
2
|
import { KEYFRAME_PROPERTIES } from "./lowering-properties.mjs";
|
|
3
|
-
const OWNED_DOCUMENT = /^:root:has\(&:[a-z-]+\)$/;
|
|
4
3
|
export function declareRule(registry, request) {
|
|
5
4
|
const { selector, conditions, values, important, origin } = request;
|
|
6
|
-
if (!selector.startsWith("&")
|
|
5
|
+
if (!selector.startsWith("&"))
|
|
7
6
|
return err({ kind: "selector-not-owned", selector, origin });
|
|
8
7
|
const declarations = [];
|
|
9
8
|
for (const [property, value] of values) {
|
package/dist/lowering-layer.mjs
CHANGED
|
@@ -74,14 +74,13 @@ function cardRules(sheet, veil, own, motion, margin) {
|
|
|
74
74
|
"block-size": "fit-content",
|
|
75
75
|
"max-block-size": `calc(100dvh - ${margin.block} * 2)`,
|
|
76
76
|
"max-inline-size": inlineCap(margin.inline, own)
|
|
77
|
-
}, paint = { selector: "&::backdrop", values: veil, condition: null }
|
|
77
|
+
}, paint = { selector: "&::backdrop", values: veil, condition: null };
|
|
78
78
|
if (motion === null || sheet.motion === null)
|
|
79
|
-
return { root: placement, rules: [paint
|
|
79
|
+
return { root: placement, rules: [paint] };
|
|
80
80
|
return {
|
|
81
81
|
root: { ...placement, ...transition("opacity", motion) },
|
|
82
82
|
rules: [
|
|
83
83
|
paint,
|
|
84
|
-
gutter,
|
|
85
84
|
{ selector: "&:not([open])", values: { opacity: "0" }, condition: null },
|
|
86
85
|
{ selector: "&[open]", values: { opacity: "0" }, condition: STARTING },
|
|
87
86
|
{ selector: "&::backdrop", values: transition("opacity", motion), condition: null },
|
package/dist/recipe-model.mjs
CHANGED
|
@@ -217,7 +217,8 @@ export const combineRecipes = (...inputs) => rejecting(() => {
|
|
|
217
217
|
};
|
|
218
218
|
return makeRecipe(inputs.reduce((result, input) => merge(result, input.spec, "recipe"), {}));
|
|
219
219
|
}), foundation = (spec) => rejecting(() => {
|
|
220
|
-
only(spec, ["tokens", "text", "surface", "focus", "reset", "themes", "brands", "palette", "followSystemTheme", "sections", "appIcon"]);
|
|
220
|
+
only(spec, ["tokens", "text", "surface", "focus", "reset", "themes", "brands", "palette", "followSystemTheme", "sections", "appIcon", "scrollbarGutter"]);
|
|
221
|
+
check(spec.scrollbarGutter === void 0 || spec.scrollbarGutter === "stable", `Foundation's scrollbarGutter is "stable", or omitted`);
|
|
221
222
|
check(spec.tokens === "./tokens", "Foundation uses the owned role directory");
|
|
222
223
|
check(typeof spec.text === "string" && typeof spec.surface === "string", "Foundation needs text and surface profiles");
|
|
223
224
|
check(typeof spec.focus === "string", "Foundation needs a focus profile for the document's default focus indicator");
|
package/dist/region-lowering.mjs
CHANGED
|
@@ -544,13 +544,14 @@ function lowerParts(parts, parent, layout, gap, context, parentGrows = !1, overl
|
|
|
544
544
|
context.neighbours.push({ axis, gap: between, first, second });
|
|
545
545
|
});
|
|
546
546
|
}
|
|
547
|
+
function ownSpace(part, side, context) {
|
|
548
|
+
const { profile, slots } = context, binding = side === "before" ? part.spaceBefore : part.spaceAfter;
|
|
549
|
+
if (binding !== null)
|
|
550
|
+
return profile.field(profile.of(slots["spacing-profile"], "spacing", "space"), "spacing", kebab(binding.field));
|
|
551
|
+
return part.spacing === null ? null : profile.of(part.spacing, "spacing", part.name)[`space-${side}`] ?? null;
|
|
552
|
+
}
|
|
547
553
|
function writePartSpace(parts, parent, layout, gap, context, carry = !1) {
|
|
548
|
-
const { out
|
|
549
|
-
const binding = side === "before" ? part.spaceBefore : part.spaceAfter;
|
|
550
|
-
if (binding !== null)
|
|
551
|
-
return profile.field(profile.of(slots["spacing-profile"], "spacing", "space"), "spacing", kebab(binding.field));
|
|
552
|
-
return part.spacing === null ? null : profile.of(part.spacing, "spacing", part.name)[`space-${side}`] ?? null;
|
|
553
|
-
}, spaced = parts.flatMap((part) => {
|
|
554
|
+
const { out } = context, own = (part, side) => ownSpace(part, side, context), spaced = parts.flatMap((part) => {
|
|
554
555
|
const before = own(part, "before"), after = own(part, "after");
|
|
555
556
|
if (part.spacing !== null && before === null && after === null)
|
|
556
557
|
return context.reject({ kind: "profile-field-missing", profile: part.spacing, field: "spaceBefore" });
|
|
@@ -560,6 +561,8 @@ function writePartSpace(parts, parent, layout, gap, context, carry = !1) {
|
|
|
560
561
|
return;
|
|
561
562
|
if (layout !== "stack" && layout !== "native")
|
|
562
563
|
return context.reject({ kind: "space-parent-unsupported", part: first.part.name, layout });
|
|
564
|
+
if (layout === "native")
|
|
565
|
+
return;
|
|
563
566
|
const between = gap ?? "0px", margin = (space) => ({ "margin-block-start": `calc(${space} - ${between})` });
|
|
564
567
|
for (const { part, before, after } of spaced) {
|
|
565
568
|
if (before !== null)
|
|
@@ -694,7 +697,13 @@ function lowerPart(part, parent, parentLayout, context, parentGrows, overlapping
|
|
|
694
697
|
if (twice !== void 0)
|
|
695
698
|
return reject({ kind: "extent-conflict", element: part.name, property: twice[0], providers: ["recipe.normalize.when", "normalize"] });
|
|
696
699
|
add(normalizedDeclarations(part.normalize), "normalize");
|
|
697
|
-
const pathKey = path.split(" > ").slice(1).join(" ")
|
|
700
|
+
const pathKey = path.split(" > ").slice(1).join(" ");
|
|
701
|
+
if (parentLayout === "native") {
|
|
702
|
+
const before = ownSpace(part, "before", context), after = ownSpace(part, "after", context);
|
|
703
|
+
if (before !== null || after !== null)
|
|
704
|
+
add({ "margin-block-start": before ?? "0", "margin-block-end": after ?? "0" }, "space");
|
|
705
|
+
}
|
|
706
|
+
const ownMargin = Object.keys(values).some((property) => property.startsWith("margin")) || (context.rootNormalized.get(path) ?? []).some((property) => property.startsWith("margin"));
|
|
698
707
|
if (context.input.margined?.includes(pathKey) === !0 && !ownMargin)
|
|
699
708
|
out.rule(path, { margin: "0" });
|
|
700
709
|
if (context.input.native?.includes(pathKey) === !0) {
|