foldkit-mixins 0.2.0 → 0.4.0

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.
@@ -0,0 +1,197 @@
1
+ import { t as DiagnosticError } from "./diagnostics-YJ7991-A.mjs";
2
+ //#region src/cssBlocks.ts
3
+ const withoutComments = (text) => text.replace(/\/\*[\s\S]*?\*\//g, "").trim();
4
+ /** Index just past the string starting at `start`, which holds its quote. */
5
+ const endOfString = (css, start) => {
6
+ const quote = css[start];
7
+ let index = start + 1;
8
+ while (index < css.length && css[index] !== quote) index += css[index] === "\\" ? 2 : 1;
9
+ return index + 1;
10
+ };
11
+ const topLevelBlocks = (css) => {
12
+ const blocks = [];
13
+ let start = 0;
14
+ let depth = 0;
15
+ let bodyAt = -1;
16
+ let index = 0;
17
+ while (index < css.length) {
18
+ const char = css[index];
19
+ if (char === "\"" || char === "'") {
20
+ index = endOfString(css, index);
21
+ continue;
22
+ }
23
+ if (char === "/" && css[index + 1] === "*") {
24
+ const end = css.indexOf("*/", index + 2);
25
+ index = end === -1 ? css.length : end + 2;
26
+ continue;
27
+ }
28
+ if (char === "{") {
29
+ if (depth === 0) bodyAt = index;
30
+ depth++;
31
+ } else if (char === "}") {
32
+ depth--;
33
+ if (depth === 0) {
34
+ blocks.push({
35
+ prelude: withoutComments(css.slice(start, bodyAt)),
36
+ text: css.slice(start, index + 1)
37
+ });
38
+ start = index + 1;
39
+ }
40
+ } else if (char === ";" && depth === 0) {
41
+ const text = css.slice(start, index + 1);
42
+ blocks.push({
43
+ prelude: withoutComments(text),
44
+ text
45
+ });
46
+ start = index + 1;
47
+ }
48
+ index++;
49
+ }
50
+ const rest = css.slice(start);
51
+ if (withoutComments(rest) !== "") blocks.push({
52
+ prelude: withoutComments(rest),
53
+ text: rest
54
+ });
55
+ return blocks;
56
+ };
57
+ /** `@layer a, b, c;`: an order statement, not a layered rule. */
58
+ const isLayerStatement = (block) => /^@layer\s[^{}]*;$/.test(block.prelude);
59
+ /** The layer a `@layer name{…}` block is in; undefined for any other block. */
60
+ const layerOf = (block) => /^@layer\s+([^\s{},;]+)$/.exec(block.prelude)?.[1];
61
+ /** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */
62
+ const isUnordered = (block) => isLayerStatement(block) || /^@(?:-webkit-)?keyframes\s|^@font-face\b|^@property\s/.test(block.prelude);
63
+ /** The names a `@layer a, b, c;` statement declares. */
64
+ const declaredNames = (statement) => statement.replace(/^@layer\s+/, "").replace(/;$/, "").split(",").map((name) => name.trim());
65
+ //#endregion
66
+ //#region src/layers.ts
67
+ /**
68
+ * Cascade layers as a value. `define` names an order; the result declares
69
+ * it (`declare`) and places a piece in one of its layers (`in`), typed to
70
+ * those names so a misspelled layer is a type error. `standard` is the
71
+ * order a design system built on the `/theme`, `/layout`, `/defaults`, and
72
+ * `/prose` subpaths expects; the pieces those ship are unlayered until a
73
+ * page wraps them, so a different order needs no different generators.
74
+ */
75
+ const tally = () => ({
76
+ placed: 0,
77
+ kept: /* @__PURE__ */ new Set()
78
+ });
79
+ const placeRule = (name, rule, count) => {
80
+ if (rule.layer !== void 0 && rule.layer !== name) {
81
+ count.kept.add(rule.layer);
82
+ return rule;
83
+ }
84
+ count.placed++;
85
+ return rule.layer === name ? rule : {
86
+ ...rule,
87
+ layer: name
88
+ };
89
+ };
90
+ /** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */
91
+ const placeGlobal = (name, css, count) => {
92
+ const out = [];
93
+ let pending = "";
94
+ const flush = () => {
95
+ if (pending !== "") out.push(`@layer ${name}{${pending}}`);
96
+ pending = "";
97
+ };
98
+ for (const block of topLevelBlocks(css)) {
99
+ const layer = layerOf(block);
100
+ if (isLayerStatement(block)) {
101
+ flush();
102
+ out.push(block.text);
103
+ } else if (layer === void 0) {
104
+ pending += block.text;
105
+ count.placed++;
106
+ } else {
107
+ flush();
108
+ out.push(block.text);
109
+ if (layer === name) count.placed++;
110
+ else count.kept.add(layer);
111
+ }
112
+ }
113
+ flush();
114
+ return out.join("");
115
+ };
116
+ const place = (name, piece, count) => Object.freeze({
117
+ ...piece,
118
+ ...piece.rules === void 0 ? {} : { rules: Object.freeze(piece.rules.map((rule) => placeRule(name, rule, count))) },
119
+ ...piece.globalCss === void 0 ? {} : { globalCss: Object.freeze(piece.globalCss.map((css) => placeGlobal(name, css, count))) },
120
+ ...piece.conditions === void 0 ? {} : { conditions: Object.freeze(piece.conditions.map((condition) => ({
121
+ predicate: condition.predicate,
122
+ piece: place(name, condition.piece, count)
123
+ }))) },
124
+ ...piece.items === void 0 ? {} : { items: Object.freeze(piece.items.map((render) => (item) => place(name, render(item), tally()))) }
125
+ });
126
+ const refuseRelayer = (name, count) => {
127
+ if (count.placed > 0 || count.kept.size === 0) return;
128
+ const layers = [...count.kept];
129
+ throw new DiagnosticError({
130
+ source: "style",
131
+ code: "style:relayered",
132
+ severity: "error",
133
+ message: `Layers.in("${name}", …) was given a piece already in layer ${layers.map((layer) => `"${layer}"`).join(", ")}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,
134
+ details: {
135
+ layer: name,
136
+ kept: layers
137
+ }
138
+ });
139
+ };
140
+ const placeIn = (name, piece) => {
141
+ const count = tally();
142
+ const placed = place(name, piece, count);
143
+ refuseRelayer(name, count);
144
+ return placed;
145
+ };
146
+ const define = (names) => {
147
+ const seen = /* @__PURE__ */ new Set();
148
+ for (const name of names) {
149
+ if (seen.has(name)) throw new DiagnosticError({
150
+ source: "style",
151
+ code: "style:duplicate-layer",
152
+ severity: "error",
153
+ message: `Layers.define names "${name}" twice`
154
+ });
155
+ seen.add(name);
156
+ }
157
+ return Object.freeze({
158
+ names: Object.freeze([...names]),
159
+ declare: Object.freeze({
160
+ classes: Object.freeze([]),
161
+ style: Object.freeze({}),
162
+ globalCss: Object.freeze([`@layer ${names.join(", ")};`])
163
+ }),
164
+ in: placeIn,
165
+ layer: (name) => Object.freeze({
166
+ layer: name,
167
+ place: (piece) => place(name, piece, tally())
168
+ })
169
+ });
170
+ };
171
+ /**
172
+ * The shipped order. `reset` normalizes; `tokens` holds the scales that do
173
+ * not change per theme; `theme` the knobs and what derives from them, plus
174
+ * scoped overrides; `defaults` element defaults; then a design system's
175
+ * `components`, `layouts` (after components, so a wrapper never beats a
176
+ * component's inner rule), a recipe's `variants`, `utilities`, and the
177
+ * application's `app`, always last.
178
+ */
179
+ const standard = define([
180
+ "reset",
181
+ "tokens",
182
+ "theme",
183
+ "defaults",
184
+ "components",
185
+ "layouts",
186
+ "variants",
187
+ "utilities",
188
+ "app"
189
+ ]);
190
+ const Layers = {
191
+ define,
192
+ standard
193
+ };
194
+ //#endregion
195
+ export { isUnordered as a, declaredNames as i, define as n, layerOf as o, standard as r, topLevelBlocks as s, Layers as t };
196
+
197
+ //# sourceMappingURL=layers-CJS5d1i7.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers-CJS5d1i7.mjs","names":[],"sources":["../src/cssBlocks.ts","../src/layers.ts"],"sourcesContent":["/**\n * The top-level blocks of compiled CSS text, and which cascade layer each is\n * in. `Layers.in` reads them to leave an already-layered block where it is,\n * and `Style.stylesheet` to refuse a rule outside the declared order. The\n * text is the compiler's own output or a `Style.global` chunk, so a scanner\n * that respects strings, comments, and brace depth is enough; it is not a\n * CSS parser.\n */\nexport interface Block {\n /** What precedes the body, comments removed: `@layer app`, `.x:hover`, or a whole `@layer a, b;`. */\n readonly prelude: string\n /** The block's full text, as it appeared. */\n readonly text: string\n}\n\nconst withoutComments = (text: string): string => text.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '').trim()\n\n/** Index just past the string starting at `start`, which holds its quote. */\nconst endOfString = (css: string, start: number): number => {\n const quote = css[start]\n let index = start + 1\n while (index < css.length && css[index] !== quote) index += css[index] === '\\\\' ? 2 : 1\n return index + 1\n}\n\nexport const topLevelBlocks = (css: string): ReadonlyArray<Block> => {\n const blocks: Array<Block> = []\n let start = 0\n let depth = 0\n let bodyAt = -1\n let index = 0\n while (index < css.length) {\n const char = css[index]\n if (char === '\"' || char === \"'\") {\n index = endOfString(css, index)\n continue\n }\n if (char === '/' && css[index + 1] === '*') {\n const end = css.indexOf('*/', index + 2)\n index = end === -1 ? css.length : end + 2\n continue\n }\n if (char === '{') {\n if (depth === 0) bodyAt = index\n depth++\n } else if (char === '}') {\n depth--\n if (depth === 0) {\n blocks.push({\n prelude: withoutComments(css.slice(start, bodyAt)),\n text: css.slice(start, index + 1),\n })\n start = index + 1\n }\n } else if (char === ';' && depth === 0) {\n const text = css.slice(start, index + 1)\n blocks.push({ prelude: withoutComments(text), text })\n start = index + 1\n }\n index++\n }\n const rest = css.slice(start)\n if (withoutComments(rest) !== '') blocks.push({ prelude: withoutComments(rest), text: rest })\n return blocks\n}\n\n/** `@layer a, b, c;`: an order statement, not a layered rule. */\nexport const isLayerStatement = (block: Block): boolean => /^@layer\\s[^{}]*;$/.test(block.prelude)\n\n/** The layer a `@layer name{…}` block is in; undefined for any other block. */\nexport const layerOf = (block: Block): string | undefined =>\n /^@layer\\s+([^\\s{},;]+)$/.exec(block.prelude)?.[1]\n\n/** Blocks the cascade does not order: the layer statement, keyframes, font faces, registered properties. */\nexport const isUnordered = (block: Block): boolean =>\n isLayerStatement(block) ||\n /^@(?:-webkit-)?keyframes\\s|^@font-face\\b|^@property\\s/.test(block.prelude)\n\n/** The names a `@layer a, b, c;` statement declares. */\nexport const declaredNames = (statement: string): ReadonlyArray<string> =>\n statement\n .replace(/^@layer\\s+/, '')\n .replace(/;$/, '')\n .split(',')\n .map(name => name.trim())\n","/**\n * Cascade layers as a value. `define` names an order; the result declares\n * it (`declare`) and places a piece in one of its layers (`in`), typed to\n * those names so a misspelled layer is a type error. `standard` is the\n * order a design system built on the `/theme`, `/layout`, `/defaults`, and\n * `/prose` subpaths expects; the pieces those ship are unlayered until a\n * page wraps them, so a different order needs no different generators.\n */\nimport { isLayerStatement, layerOf, topLevelBlocks } from './cssBlocks.js'\nimport { DiagnosticError } from './diagnostics.js'\nimport type { SlotItem } from './slotItem.js'\nimport type { StyleRule } from './styleRules.js'\nimport type { StyleValue } from './styleValue.js'\n\n/**\n * One layer of one order, for `Style.forSlots(S)(pieces, { layer })`: every\n * piece is placed before it is compiled, so the style a view attaches and the\n * style a sheet ships are the same value with the same classes. A piece\n * already in another layer keeps it and is not refused, because a slot piece\n * that is only a layered layout or recipe is ordinary.\n */\nexport interface Placement<Name extends string = string> {\n readonly layer: Name\n readonly place: (piece: StyleValue) => StyleValue\n}\n\nexport interface Layers<Name extends string> {\n readonly names: ReadonlyArray<Name>\n /** The `@layer a, b, c;` statement as a global piece; `Style.stylesheet` hoists it first. */\n readonly declare: StyleValue\n /**\n * The piece's unlayered rules and global CSS emitted inside `@layer name`,\n * including rules under `whenInput` and per-item pieces. A rule or block\n * already in a layer keeps it, so a design system's layered layout composed\n * into an application style stays in `layouts`. A piece with nothing\n * unlayered but something in another layer is refused with\n * `style:relayered`, since the call would move nothing. A slot style is\n * layered where it is defined, with `layer`, not here: placing a finished\n * style would copy it under new classes that no view attaches.\n */\n readonly in: (name: Name, piece: StyleValue) => StyleValue\n /** The placement `Style.forSlots` takes as its `layer` option. */\n readonly layer: (name: Name) => Placement<Name>\n}\n\n/** What one `in` call placed, and which other layers it left in place. */\ninterface Tally {\n placed: number\n readonly kept: Set<string>\n}\n\nconst tally = (): Tally => ({ placed: 0, kept: new Set() })\n\nconst placeRule = (name: string, rule: StyleRule, count: Tally): StyleRule => {\n if (rule.layer !== undefined && rule.layer !== name) {\n count.kept.add(rule.layer)\n return rule\n }\n count.placed++\n return rule.layer === name ? rule : { ...rule, layer: name }\n}\n\n/** Runs of unlayered blocks go into one `@layer name{…}`; layered blocks and statements stay. */\nconst placeGlobal = (name: string, css: string, count: Tally): string => {\n const out: Array<string> = []\n let pending = ''\n const flush = (): void => {\n if (pending !== '') out.push(`@layer ${name}{${pending}}`)\n pending = ''\n }\n for (const block of topLevelBlocks(css)) {\n const layer = layerOf(block)\n if (isLayerStatement(block)) {\n flush()\n out.push(block.text)\n } else if (layer === undefined) {\n pending += block.text\n count.placed++\n } else {\n flush()\n out.push(block.text)\n if (layer === name) count.placed++\n else count.kept.add(layer)\n }\n }\n flush()\n return out.join('')\n}\n\nconst place = (name: string, piece: StyleValue, count: Tally): StyleValue =>\n Object.freeze({\n ...piece,\n ...(piece.rules === undefined\n ? {}\n : { rules: Object.freeze(piece.rules.map(rule => placeRule(name, rule, count))) }),\n ...(piece.globalCss === undefined\n ? {}\n : { globalCss: Object.freeze(piece.globalCss.map(css => placeGlobal(name, css, count))) }),\n ...(piece.conditions === undefined\n ? {}\n : {\n conditions: Object.freeze(\n piece.conditions.map(condition => ({\n predicate: condition.predicate,\n piece: place(name, condition.piece, count),\n })),\n ),\n }),\n ...(piece.items === undefined\n ? {}\n : {\n // Rendered per item, after `in` returned: nothing to refuse by then.\n items: Object.freeze(\n piece.items.map(\n render => (item: SlotItem | undefined) => place(name, render(item), tally()),\n ),\n ),\n }),\n })\n\nconst refuseRelayer = (name: string, count: Tally): void => {\n if (count.placed > 0 || count.kept.size === 0) return\n const layers = [...count.kept]\n throw new DiagnosticError({\n source: 'style',\n code: 'style:relayered',\n severity: 'error',\n message: `Layers.in(\"${name}\", …) was given a piece already in layer ${layers.map(layer => `\"${layer}\"`).join(', ')}; a layered rule keeps its layer, so nothing would move. Place the unlayered piece instead.`,\n details: { layer: name, kept: layers },\n })\n}\n\nconst placeIn = (name: string, piece: StyleValue): StyleValue => {\n const count = tally()\n const placed = place(name, piece, count)\n refuseRelayer(name, count)\n return placed\n}\n\nexport const define = <const Name extends string>(names: ReadonlyArray<Name>): Layers<Name> => {\n const seen = new Set<string>()\n for (const name of names) {\n if (seen.has(name)) {\n throw new DiagnosticError({\n source: 'style',\n code: 'style:duplicate-layer',\n severity: 'error',\n message: `Layers.define names \"${name}\" twice`,\n })\n }\n seen.add(name)\n }\n return Object.freeze({\n names: Object.freeze([...names]),\n declare: Object.freeze({\n classes: Object.freeze([]),\n style: Object.freeze({}),\n globalCss: Object.freeze([`@layer ${names.join(', ')};`]),\n }),\n in: placeIn,\n layer: (name: Name): Placement<Name> =>\n Object.freeze({ layer: name, place: (piece: StyleValue) => place(name, piece, tally()) }),\n })\n}\n\n/**\n * The shipped order. `reset` normalizes; `tokens` holds the scales that do\n * not change per theme; `theme` the knobs and what derives from them, plus\n * scoped overrides; `defaults` element defaults; then a design system's\n * `components`, `layouts` (after components, so a wrapper never beats a\n * component's inner rule), a recipe's `variants`, `utilities`, and the\n * application's `app`, always last.\n */\nexport const standard = define([\n 'reset',\n 'tokens',\n 'theme',\n 'defaults',\n 'components',\n 'layouts',\n 'variants',\n 'utilities',\n 'app',\n])\n\nexport const Layers = { define, standard } as const\n"],"mappings":";;AAeA,MAAM,mBAAmB,SAAyB,KAAK,QAAQ,qBAAqB,EAAE,CAAC,CAAC,KAAK;;AAG7F,MAAM,eAAe,KAAa,UAA0B;CAC1D,MAAM,QAAQ,IAAI;CAClB,IAAI,QAAQ,QAAQ;CACpB,OAAO,QAAQ,IAAI,UAAU,IAAI,WAAW,OAAO,SAAS,IAAI,WAAW,OAAO,IAAI;CACtF,OAAO,QAAQ;AACjB;AAEA,MAAa,kBAAkB,QAAsC;CACnE,MAAM,SAAuB,CAAC;CAC9B,IAAI,QAAQ;CACZ,IAAI,QAAQ;CACZ,IAAI,SAAS;CACb,IAAI,QAAQ;CACZ,OAAO,QAAQ,IAAI,QAAQ;EACzB,MAAM,OAAO,IAAI;EACjB,IAAI,SAAS,QAAO,SAAS,KAAK;GAChC,QAAQ,YAAY,KAAK,KAAK;GAC9B;EACF;EACA,IAAI,SAAS,OAAO,IAAI,QAAQ,OAAO,KAAK;GAC1C,MAAM,MAAM,IAAI,QAAQ,MAAM,QAAQ,CAAC;GACvC,QAAQ,QAAQ,KAAK,IAAI,SAAS,MAAM;GACxC;EACF;EACA,IAAI,SAAS,KAAK;GAChB,IAAI,UAAU,GAAG,SAAS;GAC1B;EACF,OAAO,IAAI,SAAS,KAAK;GACvB;GACA,I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
1
+ import { a as StyleValue } from "./styleValue-C9vAKt7A.mjs";
2
+ //#region src/layers.d.ts
3
+ /**
4
+ * One layer of one order, for `Style.forSlots(S)(pieces, { layer })`: every
5
+ * piece is placed before it is compiled, so the style a view attaches and the
6
+ * style a sheet ships are the same value with the same classes. A piece
7
+ * already in another layer keeps it and is not refused, because a slot piece
8
+ * that is only a layered layout or recipe is ordinary.
9
+ */
10
+ export interface Placement<Name extends string = string> {
11
+ readonly layer: Name;
12
+ readonly place: (piece: StyleValue) => StyleValue;
13
+ }
14
+ export interface Layers<Name extends string> {
15
+ readonly names: ReadonlyArray<Name>;
16
+ /** The `@layer a, b, c;` statement as a global piece; `Style.stylesheet` hoists it first. */
17
+ readonly declare: StyleValue;
18
+ /**
19
+ * The piece's unlayered rules and global CSS emitted inside `@layer name`,
20
+ * including rules under `whenInput` and per-item pieces. A rule or block
21
+ * already in a layer keeps it, so a design system's layered layout composed
22
+ * into an application style stays in `layouts`. A piece with nothing
23
+ * unlayered but something in another layer is refused with
24
+ * `style:relayered`, since the call would move nothing. A slot style is
25
+ * layered where it is defined, with `layer`, not here: placing a finished
26
+ * style would copy it under new classes that no view attaches.
27
+ */
28
+ readonly in: (name: Name, piece: StyleValue) => StyleValue;
29
+ /** The placement `Style.forSlots` takes as its `layer` option. */
30
+ readonly layer: (name: Name) => Placement<Name>;
31
+ }
32
+ export declare const define: <const Name extends string>(names: ReadonlyArray<Name>) => Layers<Name>;
33
+ /**
34
+ * The shipped order. `reset` normalizes; `tokens` holds the scales that do
35
+ * not change per theme; `theme` the knobs and what derives from them, plus
36
+ * scoped overrides; `defaults` element defaults; then a design system's
37
+ * `components`, `layouts` (after components, so a wrapper never beats a
38
+ * component's inner rule), a recipe's `variants`, `utilities`, and the
39
+ * application's `app`, always last.
40
+ */
41
+ export declare const standard: Layers<"reset" | "tokens" | "theme" | "defaults" | "components" | "layouts" | "variants" | "utilities" | "app">;
42
+ export declare const Layers: {
43
+ readonly define: <const Name extends string>(names: ReadonlyArray<Name>) => Layers<Name>;
44
+ readonly standard: Layers<"reset" | "tokens" | "theme" | "defaults" | "components" | "layouts" | "variants" | "utilities" | "app">;
45
+ };
46
+ //#endregion
47
+ //# sourceMappingURL=layers.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layers.d.mts","names":[],"sources":["../src/layers.ts"],"mappings":";;;;;;;;;iBAqBiB,UAAU;WAChB,OAAO;WACP,QAAQ,OAAO,eAAe;;iBAGxB,OAAO;WACb,OAAO,cAAc;;WAErB,SAAS;;;;;;;;;;;WAWT,KAAK,MAAM,MAAM,OAAO,eAAe;;WAEvC,QAAQ,MAAM,SAAS,UAAU;;qBAiG/B,eAAgB,qBAAqB,OAAO,cAAc,UAAQ,OAAO;;;;;;;;;qBAkCzE,UAAQ;qBAYR;WA9CgB,eAAA,qBAAmB,OAAS,cAAc,UAAQ,OAAO"}
@@ -0,0 +1,2 @@
1
+ import { n as define, r as standard, t as Layers } from "./layers-CJS5d1i7.mjs";
2
+ export { Layers, define, standard };
@@ -0,0 +1,114 @@
1
+ import { a as StyleValue } from "./styleValue-C9vAKt7A.mjs";
2
+ //#region src/layout.d.ts
3
+ /**
4
+ * A child of `stack` that keeps its intrinsic width instead of the stack's
5
+ * full-width default. The stack's child rule excludes this piece's class.
6
+ */
7
+ export declare const intrinsic: StyleValue;
8
+ export interface StackOptions {
9
+ readonly gap?: string;
10
+ /** `align-items`; children are full width unless they compose `intrinsic`. */
11
+ readonly align?: string;
12
+ /** Children after this one-based index are pushed to the end (`margin-block-start: auto`). */
13
+ readonly split?: number;
14
+ }
15
+ /** A vertical stack that owns its children's block rhythm. */
16
+ export declare const stack: (options?: StackOptions) => StyleValue;
17
+ export interface ClusterOptions {
18
+ readonly gap?: string;
19
+ readonly justify?: string;
20
+ readonly align?: string;
21
+ }
22
+ /** Items that wrap onto new lines: tags, toolbar buttons, metadata. */
23
+ export declare const cluster: (options?: ClusterOptions) => StyleValue;
24
+ export interface SplitOptions {
25
+ /** The column template above the breakpoint, e.g. `'1fr 2fr'`. */
26
+ readonly fraction?: string;
27
+ /** The container (or, with `contain: false`, viewport) width the columns appear at. */
28
+ readonly breakpoint?: string;
29
+ readonly gap?: string;
30
+ /** `false` adapts on the viewport with `@media` and sets no containment. */
31
+ readonly contain?: boolean;
32
+ }
33
+ /** Two columns above a breakpoint, one below. */
34
+ export declare const split: (options?: SplitOptions) => StyleValue;
35
+ /**
36
+ * The aside of a `sidebar`: composed by the child that is the sidebar. The
37
+ * other children are the content.
38
+ */
39
+ export declare const aside: StyleValue;
40
+ export interface SidebarOptions {
41
+ /** Which side the `aside` child sits on when the row fits. */
42
+ readonly side?: 'start' | 'end';
43
+ /** The aside's preferred width. */
44
+ readonly width?: string;
45
+ /** The content's minimum share; below it the aside wraps under. */
46
+ readonly contentMin?: string;
47
+ readonly gap?: string;
48
+ }
49
+ /**
50
+ * A sidebar beside content that wraps under it when the content would get
51
+ * less than `contentMin`. Flex math, no query, so it needs no containment.
52
+ */
53
+ export declare const sidebar: (options?: SidebarOptions) => StyleValue;
54
+ export interface SwitcherOptions {
55
+ /** The container width below which the items stack. */
56
+ readonly threshold?: string;
57
+ readonly gap?: string;
58
+ }
59
+ /** A row that becomes a stack when narrower than `threshold`. Flex math, no query. */
60
+ export declare const switcher: (options?: SwitcherOptions) => StyleValue;
61
+ export interface ReelOptions {
62
+ /** Each item's inline size; `auto` sizes to content. */
63
+ readonly itemSize?: string;
64
+ readonly gap?: string;
65
+ /** Snap items to the start edge while scrolling. */
66
+ readonly snap?: boolean;
67
+ readonly scrollbar?: 'auto' | 'thin' | 'hidden';
68
+ }
69
+ /** A horizontally scrolling row. */
70
+ export declare const reel: (options?: ReelOptions) => StyleValue;
71
+ export interface CenterOptions {
72
+ /** The measure; default `65ch`. */
73
+ readonly max?: string;
74
+ readonly gutters?: string;
75
+ /** Also center the children by their intrinsic width. */
76
+ readonly intrinsic?: boolean;
77
+ }
78
+ /** Content centered inline with a maximum measure and gutters. */
79
+ export declare const center: (options?: CenterOptions) => StyleValue;
80
+ export interface FrameOptions {
81
+ /** An `aspect-ratio`, e.g. `'16 / 9'`. */
82
+ readonly ratio?: string;
83
+ }
84
+ /** A media frame with a fixed aspect ratio; an `img` or `video` child covers it. */
85
+ export declare const frame: (options?: FrameOptions) => StyleValue;
86
+ export interface PadOptions {
87
+ readonly inline?: string;
88
+ readonly block?: string;
89
+ }
90
+ /** Consistent padding from the space tokens. */
91
+ export declare const pad: (options?: PadOptions) => StyleValue;
92
+ export interface AutoGridOptions {
93
+ /** The narrowest an item may be before the grid drops a column. */
94
+ readonly minItemSize?: string;
95
+ readonly gap?: string;
96
+ }
97
+ /** A grid that fits as many `minItemSize` columns as the width allows. */
98
+ export declare const autoGrid: (options?: AutoGridOptions) => StyleValue;
99
+ export declare const Layout: {
100
+ readonly stack: (options?: StackOptions) => StyleValue;
101
+ readonly intrinsic: StyleValue;
102
+ readonly cluster: (options?: ClusterOptions) => StyleValue;
103
+ readonly split: (options?: SplitOptions) => StyleValue;
104
+ readonly sidebar: (options?: SidebarOptions) => StyleValue;
105
+ readonly aside: StyleValue;
106
+ readonly switcher: (options?: SwitcherOptions) => StyleValue;
107
+ readonly reel: (options?: ReelOptions) => StyleValue;
108
+ readonly center: (options?: CenterOptions) => StyleValue;
109
+ readonly frame: (options?: FrameOptions) => StyleValue;
110
+ readonly pad: (options?: PadOptions) => StyleValue;
111
+ readonly autoGrid: (options?: AutoGridOptions) => StyleValue;
112
+ };
113
+ //#endregion
114
+ //# sourceMappingURL=layout.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.mts","names":[],"sources":["../src/layout.ts"],"mappings":";;;;;;qBAuCa,WAAW;iBAOP;WACN;;WAEA;;WAEA;;;qBAIE,QAAS,UAAS,iBAAoB;iBAgBlC;WACN;WACA;WACA;;;qBAIE,UAAW,UAAS,mBAAsB;iBActC;;WAEN;;WAEA;WACA;;WAEA;;;qBAIE,QAAS,UAAS,iBAAoB;;;;;qBAkBtC,OAAO;iBAKH;;WAEN;;WAEA;;WAEA;WACA;;;;;;qBAOE,UAAW,UAAS,mBAAsB;iBAatC;;WAEN;WACA;;;qBAIE,WAAY,UAAS,oBAAuB;iBAWxC;;WAEN;WACA;;WAEA;WACA;;;qBAaE,OAAQ,UAAS,gBAAmB;iBAwBhC;;WAEN;WACA;;WAEA;;;qBAIE,SAAU,UAAS,kBAAqB;iBAepC;;WAEN;;;qBAIE,QAAS,UAAS,iBAAoB;iBAalC;WACN;WACA;;;qBAIE,MAAO,UAAS,eAAkB;iBAU9B;;WAEN;WACA;;;qBAIE,WAAY,UAAS,oBAAuB;qBAc5C;WA/OkB,QAAA,UAAA,iBAAoB;;WAuBlB,UAAA,UAAA,mBAAsB;WAyBxB,QAAA,UAAA,iBAAoB;WAqClB,UAAA,UAAA,mBAAsB;;WAoBrB,WAAA,UAAA,oBAAuB;WA8B3B,OAAA,UAAA,gBAAmB;WAiCjB,SAAA,UAAA,kBAAqB;WAqBtB,QAAA,UAAA,iBAAoB;WAmBtB,MAAA,UAAA,eAAkB;WAiBb,WAAA,UAAA,oBAAuB"}
@@ -0,0 +1,154 @@
1
+ import { a as empty, b as className, d as media, f as nest, h as self, i as container, p as pseudo, r as compose, v as vars } from "./styleValue--iQMTcPn.mjs";
2
+ //#region src/layout.ts
3
+ /**
4
+ * `foldkit-mixins/layout`: layout pieces (stack, cluster, sidebar, …) as
5
+ * `StyleValue`s. Each entry's rule text is the same for every caller: the
6
+ * rules read `--fk-l-*` custom properties with token fallbacks, and the
7
+ * options only write those properties inline. Ten stacks with ten gaps are
8
+ * one rule and ten inline variables. The pieces are unlayered; a page puts
9
+ * them in `layouts` with `Layers.standard.in`.
10
+ *
11
+ * Two things a query cannot read from a variable are structural instead:
12
+ * `split`'s breakpoint (a `@container` or `@media` query) and `stack`'s
13
+ * `split` index (an `:nth-child`). Those are part of the rule text, so each
14
+ * distinct value is its own class.
15
+ */
16
+ /** The generated class of a rule-only piece, for another piece's selector. */
17
+ const classOf = (piece) => className(piece.rules ?? []);
18
+ const GAP = "var(--fk-l-gap, var(--fk-space-md, 1rem))";
19
+ const gapVar = (gap) => gap === void 0 ? empty : vars({ "--fk-l-gap": gap });
20
+ /**
21
+ * A child of `stack` that keeps its intrinsic width instead of the stack's
22
+ * full-width default. The stack's child rule excludes this piece's class.
23
+ */
24
+ const intrinsic = self({
25
+ flexGrow: "0",
26
+ inlineSize: "fit-content",
27
+ maxInlineSize: "max-content",
28
+ alignSelf: "var(--fk-l-intrinsic-align, flex-start)"
29
+ });
30
+ /** A vertical stack that owns its children's block rhythm. */
31
+ const stack = (options = {}) => compose(self({
32
+ display: "flex",
33
+ flexDirection: "column",
34
+ alignItems: "var(--fk-l-align, stretch)",
35
+ gap: GAP
36
+ }), nest(`> :not(.${classOf(intrinsic)})`, {
37
+ inlineSize: "100%",
38
+ marginBlock: "0"
39
+ }), options.split === void 0 ? empty : nest(`> :nth-child(${options.split})`, { marginBlockEnd: "auto" }), gapVar(options.gap), options.align === void 0 ? empty : vars({ "--fk-l-align": options.align }));
40
+ /** Items that wrap onto new lines: tags, toolbar buttons, metadata. */
41
+ const cluster = (options = {}) => compose(self({
42
+ display: "flex",
43
+ flexWrap: "wrap",
44
+ gap: "var(--fk-l-gap, var(--fk-space-sm, 0.75rem))",
45
+ justifyContent: "var(--fk-l-justify, flex-start)",
46
+ alignItems: "var(--fk-l-align, center)"
47
+ }), gapVar(options.gap), options.justify === void 0 ? empty : vars({ "--fk-l-justify": options.justify }), options.align === void 0 ? empty : vars({ "--fk-l-align": options.align }));
48
+ /** Two columns above a breakpoint, one below. */
49
+ const split = (options = {}) => {
50
+ const query = `(min-width: ${options.breakpoint ?? "30rem"})`;
51
+ const columns = { gridTemplateColumns: "var(--fk-l-fraction, 1fr 1fr)" };
52
+ return compose(self({
53
+ display: "grid",
54
+ gap: GAP,
55
+ gridTemplateColumns: "1fr"
56
+ }), options.contain === false ? media(query, columns) : compose(self({ containerType: "inline-size" }), container(query, columns)), gapVar(options.gap), options.fraction === void 0 ? empty : vars({ "--fk-l-fraction": options.fraction }));
57
+ };
58
+ /**
59
+ * The aside of a `sidebar`: composed by the child that is the sidebar. The
60
+ * other children are the content.
61
+ */
62
+ const aside = self({
63
+ flexGrow: "1",
64
+ flexBasis: "var(--fk-l-side-width, 20rem)"
65
+ });
66
+ /**
67
+ * A sidebar beside content that wraps under it when the content would get
68
+ * less than `contentMin`. Flex math, no query, so it needs no containment.
69
+ */
70
+ const sidebar = (options = {}) => compose(self({
71
+ display: "flex",
72
+ flexWrap: "wrap",
73
+ gap: GAP
74
+ }), nest(`> :not(.${classOf(aside)})`, {
75
+ flexGrow: "9999",
76
+ flexBasis: "var(--fk-l-content-min, 50%)"
77
+ }), options.side === "end" ? nest(`> .${classOf(aside)}`, { order: "1" }) : empty, gapVar(options.gap), options.width === void 0 ? empty : vars({ "--fk-l-side-width": options.width }), options.contentMin === void 0 ? empty : vars({ "--fk-l-content-min": options.contentMin }));
78
+ /** A row that becomes a stack when narrower than `threshold`. Flex math, no query. */
79
+ const switcher = (options = {}) => compose(self({
80
+ display: "flex",
81
+ flexWrap: "wrap",
82
+ gap: GAP
83
+ }), nest("> *", {
84
+ flexGrow: "1",
85
+ flexBasis: "calc((var(--fk-l-threshold, 30rem) - 100%) * 999)"
86
+ }), gapVar(options.gap), options.threshold === void 0 ? empty : vars({ "--fk-l-threshold": options.threshold }));
87
+ const scrollbars = {
88
+ auto: empty,
89
+ thin: self({ scrollbarWidth: "thin" }),
90
+ hidden: compose(self({ scrollbarWidth: "none" }), pseudo("::-webkit-scrollbar", { display: "none" }))
91
+ };
92
+ /** A horizontally scrolling row. */
93
+ const reel = (options = {}) => compose(self({
94
+ display: "flex",
95
+ inlineSize: "100%",
96
+ minInlineSize: "0",
97
+ maxInlineSize: "100%",
98
+ gap: GAP,
99
+ overflowX: "auto",
100
+ overflowY: "hidden",
101
+ overscrollBehaviorInline: "contain"
102
+ }), nest("> *", { flex: "0 0 var(--fk-l-item-size, auto)" }), options.snap === true ? compose(self({ scrollSnapType: "inline proximity" }), nest("> *", { scrollSnapAlign: "start" })) : empty, scrollbars[options.scrollbar ?? "auto"], gapVar(options.gap), options.itemSize === void 0 ? empty : vars({ "--fk-l-item-size": options.itemSize }));
103
+ /** Content centered inline with a maximum measure and gutters. */
104
+ const center = (options = {}) => compose(self({
105
+ boxSizing: "border-box",
106
+ marginInline: "auto",
107
+ maxInlineSize: "var(--fk-l-max, 65ch)",
108
+ paddingInline: "var(--fk-l-gutters, var(--fk-space-md, 1rem))"
109
+ }), options.intrinsic === true ? self({
110
+ display: "flex",
111
+ flexDirection: "column",
112
+ alignItems: "center"
113
+ }) : empty, options.max === void 0 ? empty : vars({ "--fk-l-max": options.max }), options.gutters === void 0 ? empty : vars({ "--fk-l-gutters": options.gutters }));
114
+ /** A media frame with a fixed aspect ratio; an `img` or `video` child covers it. */
115
+ const frame = (options = {}) => compose(self({
116
+ position: "relative",
117
+ overflow: "hidden",
118
+ aspectRatio: "var(--fk-l-ratio, 16 / 9)"
119
+ }), nest("> :is(img, video)", {
120
+ position: "absolute",
121
+ inset: "0",
122
+ inlineSize: "100%",
123
+ blockSize: "100%",
124
+ objectFit: "cover"
125
+ }), options.ratio === void 0 ? empty : vars({ "--fk-l-ratio": options.ratio }));
126
+ /** Consistent padding from the space tokens. */
127
+ const pad = (options = {}) => compose(self({
128
+ paddingInline: "var(--fk-l-pad-inline, var(--fk-space-md, 1rem))",
129
+ paddingBlock: "var(--fk-l-pad-block, var(--fk-space-md, 1rem))"
130
+ }), options.inline === void 0 ? empty : vars({ "--fk-l-pad-inline": options.inline }), options.block === void 0 ? empty : vars({ "--fk-l-pad-block": options.block }));
131
+ /** A grid that fits as many `minItemSize` columns as the width allows. */
132
+ const autoGrid = (options = {}) => compose(self({
133
+ display: "grid",
134
+ gap: GAP,
135
+ gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, var(--fk-l-min-item-size, 16rem)), 1fr))"
136
+ }), gapVar(options.gap), options.minItemSize === void 0 ? empty : vars({ "--fk-l-min-item-size": options.minItemSize }));
137
+ const Layout = {
138
+ stack,
139
+ intrinsic,
140
+ cluster,
141
+ split,
142
+ sidebar,
143
+ aside,
144
+ switcher,
145
+ reel,
146
+ center,
147
+ frame,
148
+ pad,
149
+ autoGrid
150
+ };
151
+ //#endregion
152
+ export { Layout, aside, autoGrid, center, cluster, frame, intrinsic, pad, reel, sidebar, split, stack, switcher };
153
+
154
+ //# sourceMappingURL=layout.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.mjs","names":["Rules.className"],"sources":["../src/layout.ts"],"sourcesContent":["/**\n * `foldkit-mixins/layout`: layout pieces (stack, cluster, sidebar, …) as\n * `StyleValue`s. Each entry's rule text is the same for every caller: the\n * rules read `--fk-l-*` custom properties with token fallbacks, and the\n * options only write those properties inline. Ten stacks with ten gaps are\n * one rule and ten inline variables. The pieces are unlayered; a page puts\n * them in `layouts` with `Layers.standard.in`.\n *\n * Two things a query cannot read from a variable are structural instead:\n * `split`'s breakpoint (a `@container` or `@media` query) and `stack`'s\n * `split` index (an `:nth-child`). Those are part of the rule text, so each\n * distinct value is its own class.\n */\nimport * as Rules from './styleRules.js'\nimport {\n compose,\n container,\n empty,\n media,\n nest,\n pseudo,\n self,\n vars,\n type Declarations,\n type StyleValue,\n} from './styleValue.js'\n\n/** The generated class of a rule-only piece, for another piece's selector. */\nconst classOf = (piece: StyleValue): string => Rules.className(piece.rules ?? [])\n\nconst GAP = 'var(--fk-l-gap, var(--fk-space-md, 1rem))'\n\nconst gapVar = (gap: string | undefined): StyleValue =>\n gap === undefined ? empty : vars({ '--fk-l-gap': gap })\n\n/**\n * A child of `stack` that keeps its intrinsic width instead of the stack's\n * full-width default. The stack's child rule excludes this piece's class.\n */\nexport const intrinsic: StyleValue = self({\n flexGrow: '0',\n inlineSize: 'fit-content',\n maxInlineSize: 'max-content',\n alignSelf: 'var(--fk-l-intrinsic-align, flex-start)',\n})\n\nexport interface StackOptions {\n readonly gap?: string\n /** `align-items`; children are full width unless they compose `intrinsic`. */\n readonly align?: string\n /** Children after this one-based index are pushed to the end (`margin-block-start: auto`). */\n readonly split?: number\n}\n\n/** A vertical stack that owns its children's block rhythm. */\nexport const stack = (options: StackOptions = {}): StyleValue =>\n compose(\n self({\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'var(--fk-l-align, stretch)',\n gap: GAP,\n }),\n nest(`> :not(.${classOf(intrinsic)})`, { inlineSize: '100%', marginBlock: '0' }),\n options.split === undefined\n ? empty\n : nest(`> :nth-child(${options.split})`, { marginBlockEnd: 'auto' }),\n gapVar(options.gap),\n options.align === undefined ? empty : vars({ '--fk-l-align': options.align }),\n )\n\nexport interface ClusterOptions {\n readonly gap?: string\n readonly justify?: string\n readonly align?: string\n}\n\n/** Items that wrap onto new lines: tags, toolbar buttons, metadata. */\nexport const cluster = (options: ClusterOptions = {}): StyleValue =>\n compose(\n self({\n display: 'flex',\n flexWrap: 'wrap',\n gap: 'var(--fk-l-gap, var(--fk-space-sm, 0.75rem))',\n justifyContent: 'var(--fk-l-justify, flex-start)',\n alignItems: 'var(--fk-l-align, center)',\n }),\n gapVar(options.gap),\n options.justify === undefined ? empty : vars({ '--fk-l-justify': options.justify }),\n options.align === undefined ? empty : vars({ '--fk-l-align': options.align }),\n )\n\nexport interface SplitOptions {\n /** The column template above the breakpoint, e.g. `'1fr 2fr'`. */\n readonly fraction?: string\n /** The container (or, with `contain: false`, viewport) width the columns appear at. */\n readonly breakpoint?: string\n readonly gap?: string\n /** `false` adapts on the viewport with `@media` and sets no containment. */\n readonly contain?: boolean\n}\n\n/** Two columns above a breakpoint, one below. */\nexport const split = (options: SplitOptions = {}): StyleValue => {\n const breakpoint = options.breakpoint ?? '30rem'\n const query = `(min-width: ${breakpoint})`\n const columns = { gridTemplateColumns: 'var(--fk-l-fraction, 1fr 1fr)' }\n return compose(\n self({ display: 'grid', gap: GAP, gridTemplateColumns: '1fr' }),\n options.contain === false\n ? media(query, columns)\n : compose(self({ containerType: 'inline-size' }), container(query, columns)),\n gapVar(options.gap),\n options.fraction === undefined ? empty : vars({ '--fk-l-fraction': options.fraction }),\n )\n}\n\n/**\n * The aside of a `sidebar`: composed by the child that is the sidebar. The\n * other children are the content.\n */\nexport const aside: StyleValue = self({\n flexGrow: '1',\n flexBasis: 'var(--fk-l-side-width, 20rem)',\n})\n\nexport interface SidebarOptions {\n /** Which side the `aside` child sits on when the row fits. */\n readonly side?: 'start' | 'end'\n /** The aside's preferred width. */\n readonly width?: string\n /** The content's minimum share; below it the aside wraps under. */\n readonly contentMin?: string\n readonly gap?: string\n}\n\n/**\n * A sidebar beside content that wraps under it when the content would get\n * less than `contentMin`. Flex math, no query, so it needs no containment.\n */\nexport const sidebar = (options: SidebarOptions = {}): StyleValue =>\n compose(\n self({ display: 'flex', flexWrap: 'wrap', gap: GAP }),\n nest(`> :not(.${classOf(aside)})`, {\n flexGrow: '9999',\n flexBasis: 'var(--fk-l-content-min, 50%)',\n }),\n options.side === 'end' ? nest(`> .${classOf(aside)}`, { order: '1' }) : empty,\n gapVar(options.gap),\n options.width === undefined ? empty : vars({ '--fk-l-side-width': options.width }),\n options.contentMin === undefined ? empty : vars({ '--fk-l-content-min': options.contentMin }),\n )\n\nexport interface SwitcherOptions {\n /** The container width below which the items stack. */\n readonly threshold?: string\n readonly gap?: string\n}\n\n/** A row that becomes a stack when narrower than `threshold`. Flex math, no query. */\nexport const switcher = (options: SwitcherOptions = {}): StyleValue =>\n compose(\n self({ display: 'flex', flexWrap: 'wrap', gap: GAP }),\n nest('> *', {\n flexGrow: '1',\n flexBasis: 'calc((var(--fk-l-threshold, 30rem) - 100%) * 999)',\n }),\n gapVar(options.gap),\n options.threshold === undefined ? empty : vars({ '--fk-l-threshold': options.threshold }),\n )\n\nexport interface ReelOptions {\n /** Each item's inline size; `auto` sizes to content. */\n readonly itemSize?: string\n readonly gap?: string\n /** Snap items to the start edge while scrolling. */\n readonly snap?: boolean\n readonly scrollbar?: 'auto' | 'thin' | 'hidden'\n}\n\nconst scrollbars: Readonly<Record<NonNullable<ReelOptions['scrollbar']>, StyleValue>> = {\n auto: empty,\n thin: self({ scrollbarWidth: 'thin' }),\n hidden: compose(\n self({ scrollbarWidth: 'none' }),\n pseudo('::-webkit-scrollbar', { display: 'none' }),\n ),\n}\n\n/** A horizontally scrolling row. */\nexport const reel = (options: ReelOptions = {}): StyleValue =>\n compose(\n self({\n display: 'flex',\n inlineSize: '100%',\n minInlineSize: '0',\n maxInlineSize: '100%',\n gap: GAP,\n overflowX: 'auto',\n overflowY: 'hidden',\n overscrollBehaviorInline: 'contain',\n }),\n nest('> *', { flex: '0 0 var(--fk-l-item-size, auto)' }),\n options.snap === true\n ? compose(\n self({ scrollSnapType: 'inline proximity' }),\n nest('> *', { scrollSnapAlign: 'start' }),\n )\n : empty,\n scrollbars[options.scrollbar ?? 'auto'],\n gapVar(options.gap),\n options.itemSize === undefined ? empty : vars({ '--fk-l-item-size': options.itemSize }),\n )\n\nexport interface CenterOptions {\n /** The measure; default `65ch`. */\n readonly max?: string\n readonly gutters?: string\n /** Also center the children by their intrinsic width. */\n readonly intrinsic?: boolean\n}\n\n/** Content centered inline with a maximum measure and gutters. */\nexport const center = (options: CenterOptions = {}): StyleValue =>\n compose(\n self({\n boxSizing: 'border-box',\n marginInline: 'auto',\n maxInlineSize: 'var(--fk-l-max, 65ch)',\n paddingInline: 'var(--fk-l-gutters, var(--fk-space-md, 1rem))',\n }),\n options.intrinsic === true\n ? self({ display: 'flex', flexDirection: 'column', alignItems: 'center' })\n : empty,\n options.max === undefined ? empty : vars({ '--fk-l-max': options.max }),\n options.gutters === undefined ? empty : vars({ '--fk-l-gutters': options.gutters }),\n )\n\nexport interface FrameOptions {\n /** An `aspect-ratio`, e.g. `'16 / 9'`. */\n readonly ratio?: string\n}\n\n/** A media frame with a fixed aspect ratio; an `img` or `video` child covers it. */\nexport const frame = (options: FrameOptions = {}): StyleValue =>\n compose(\n self({ position: 'relative', overflow: 'hidden', aspectRatio: 'var(--fk-l-ratio, 16 / 9)' }),\n nest('> :is(img, video)', {\n position: 'absolute',\n inset: '0',\n inlineSize: '100%',\n blockSize: '100%',\n objectFit: 'cover',\n }),\n options.ratio === undefined ? empty : vars({ '--fk-l-ratio': options.ratio }),\n )\n\nexport interface PadOptions {\n readonly inline?: string\n readonly block?: string\n}\n\n/** Consistent padding from the space tokens. */\nexport const pad = (options: PadOptions = {}): StyleValue =>\n compose(\n self({\n paddingInline: 'var(--fk-l-pad-inline, var(--fk-space-md, 1rem))',\n paddingBlock: 'var(--fk-l-pad-block, var(--fk-space-md, 1rem))',\n }),\n options.inline === undefined ? empty : vars({ '--fk-l-pad-inline': options.inline }),\n options.block === undefined ? empty : vars({ '--fk-l-pad-block': options.block }),\n )\n\nexport interface AutoGridOptions {\n /** The narrowest an item may be before the grid drops a column. */\n readonly minItemSize?: string\n readonly gap?: string\n}\n\n/** A grid that fits as many `minItemSize` columns as the width allows. */\nexport const autoGrid = (options: AutoGridOptions = {}): StyleValue =>\n compose(\n self({\n display: 'grid',\n gap: GAP,\n gridTemplateColumns:\n 'repeat(auto-fit, minmax(min(100%, var(--fk-l-min-item-size, 16rem)), 1fr))',\n }),\n gapVar(options.gap),\n options.minItemSize === undefined\n ? empty\n : vars({ '--fk-l-min-item-size': options.minItemSize }),\n )\n\nexport const Layout = {\n stack,\n intrinsic,\n cluster,\n split,\n sidebar,\n aside,\n switcher,\n reel,\n center,\n frame,\n pad,\n autoGrid,\n} as const\n"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAM,WAAW,UAA8BA,UAAgB,MAAM,SAAS,CAAC,CAAC;AAEhF,MAAM,MAAM;AAEZ,MAAM,UAAU,QACd,QAAQ,KAAA,IAAY,QAAQ,KAAK,EAAE,cAAc,IAAI,CAAC;;;;;AAMxD,MAAa,YAAwB,KAAK;CACxC,UAAU;CACV,YAAY;CACZ,eAAe;CACf,WAAW;AACb,CAAC;;AAWD,MAAa,SAAS,UAAwB,CAAC,MAC7C,QACE,KA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./styleValue-C9vAKt7A.mjs";
2
+ //#region src/prose.d.ts
3
+ export interface ProseOptions {
4
+ /** The line length, e.g. `'65ch'`. */
5
+ readonly measure?: string;
6
+ /** The space before an element, by what it follows. */
7
+ readonly rhythm?: Partial<{
8
+ /** Between flowing blocks: paragraph after paragraph, list after paragraph. */
9
+ readonly paragraph: string;
10
+ /** Before a heading; the content after a heading sits tight. */
11
+ readonly heading: string;
12
+ /** Between list items and before a nested list. */
13
+ readonly list: string;
14
+ /** Around figures, blockquotes, code blocks, tables, and rules. */
15
+ readonly figure: string;
16
+ }>;
17
+ }
18
+ /** The prose container: one class for every caller, options as variables on it. */
19
+ export declare const style: (options?: ProseOptions) => StyleValue;
20
+ export declare const Prose: {
21
+ readonly style: (options?: ProseOptions) => StyleValue;
22
+ };
23
+ //#endregion
24
+ //# sourceMappingURL=prose.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prose.d.mts","names":[],"sources":["../src/prose.ts"],"mappings":";;iBAUiB;;WAEN;;WAEA,SAAS;;aAEP;;aAEA;;aAEA;;aAEA;;;;qBAkEA,QAAS,UAAS,iBAAoB;qBAUtC;WAVkB,QAAA,UAAA,iBAAoB"}