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.
package/dist/prose.mjs ADDED
@@ -0,0 +1,57 @@
1
+ import { f as nest, l as inline, r as compose } from "./styleValue--iQMTcPn.mjs";
2
+ //#region src/prose.ts
3
+ /**
4
+ * `foldkit-mixins/prose`: the longform-content contract. One class carries
5
+ * the rhythm between unlike elements (a heading and the paragraph after it,
6
+ * a list and the paragraph before it); the measure and each rhythm step are
7
+ * `--fk-prose-*` variables, so every prose container shares the class and
8
+ * options only write variables. Belongs in the `components` layer.
9
+ */
10
+ const flow = "var(--fk-prose-paragraph, var(--fk-space-md, 1em))";
11
+ const heading = "var(--fk-prose-heading, var(--fk-space-xl, 1.8em))";
12
+ const list = "var(--fk-prose-list, var(--fk-space-2xs, 0.35em))";
13
+ const rules = compose(nest("> *", { marginBlock: "0" }), nest("> * + *", { marginBlockStart: flow }), nest("> :is(h2, h3, h4, h5, h6)", { marginBlockStart: heading }), nest("> :is(h1, h2, h3, h4, h5, h6) + *", { marginBlockStart: "var(--fk-space-xs, 0.5em)" }), nest("> :is(figure, blockquote, pre, table, hr)", { marginBlock: "var(--fk-prose-figure, var(--fk-space-lg, 1.5em))" }), nest(":is(ul, ol)", { paddingInlineStart: "var(--fk-space-lg, 1.5em)" }), nest("li + li", { marginBlockStart: list }), nest(":is(li > ul, li > ol)", { marginBlockStart: list }), nest("blockquote", {
14
+ paddingInlineStart: "var(--fk-space-md, 1em)",
15
+ borderInlineStart: "var(--fk-border-heavy, 3px) solid var(--fk-outline-default, currentColor)",
16
+ color: "var(--fk-text-subtle, inherit)"
17
+ }), nest("figcaption", {
18
+ marginBlockStart: "var(--fk-space-xs, 0.5em)",
19
+ color: "var(--fk-text-muted, inherit)",
20
+ fontSize: "var(--fk-size-sm, 0.875em)"
21
+ }), nest("hr", {
22
+ border: "0",
23
+ borderBlockStart: "var(--fk-border-thin, 1px) solid var(--fk-outline-subtle, currentColor)"
24
+ }), nest("table", {
25
+ inlineSize: "100%",
26
+ borderCollapse: "collapse",
27
+ fontSize: "var(--fk-size-sm, 0.875em)"
28
+ }), nest(":is(th, td)", {
29
+ padding: "var(--fk-space-xs, 0.5em) var(--fk-space-sm, 0.75em)",
30
+ borderBlockEnd: "var(--fk-border-thin, 1px) solid var(--fk-outline-subtle, currentColor)",
31
+ textAlign: "start"
32
+ }), nest("mark", {
33
+ padding: "0 0.2em",
34
+ background: "var(--fk-accent-subtle, Mark)",
35
+ color: "var(--fk-accent-text, MarkText)"
36
+ }), nest("abbr[title]", {
37
+ textDecorationStyle: "dotted",
38
+ cursor: "help"
39
+ }), nest(":not(pre) > code", { overflowWrap: "anywhere" }), nest("pre", { overflowX: "auto" }), nest("a", { overflowWrap: "anywhere" }));
40
+ const variables = (options) => ({
41
+ ...options.measure === void 0 ? {} : { "--fk-prose-measure": options.measure },
42
+ ...options.rhythm?.paragraph === void 0 ? {} : { "--fk-prose-paragraph": options.rhythm.paragraph },
43
+ ...options.rhythm?.heading === void 0 ? {} : { "--fk-prose-heading": options.rhythm.heading },
44
+ ...options.rhythm?.list === void 0 ? {} : { "--fk-prose-list": options.rhythm.list },
45
+ ...options.rhythm?.figure === void 0 ? {} : { "--fk-prose-figure": options.rhythm.figure }
46
+ });
47
+ /** The prose container: one class for every caller, options as variables on it. */
48
+ const style = (options = {}) => compose(inline({
49
+ maxInlineSize: "var(--fk-prose-measure, 65ch)",
50
+ lineHeight: "var(--fk-leading-relaxed, 1.6)",
51
+ ...variables(options)
52
+ }), rules);
53
+ const Prose = { style };
54
+ //#endregion
55
+ export { Prose, style };
56
+
57
+ //# sourceMappingURL=prose.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prose.mjs","names":[],"sources":["../src/prose.ts"],"sourcesContent":["/**\n * `foldkit-mixins/prose`: the longform-content contract. One class carries\n * the rhythm between unlike elements (a heading and the paragraph after it,\n * a list and the paragraph before it); the measure and each rhythm step are\n * `--fk-prose-*` variables, so every prose container shares the class and\n * options only write variables. Belongs in the `components` layer.\n */\nimport { compose, inline, nest } from './styleValue.js'\nimport type { StyleValue } from './styleValue.js'\n\nexport interface ProseOptions {\n /** The line length, e.g. `'65ch'`. */\n readonly measure?: string\n /** The space before an element, by what it follows. */\n readonly rhythm?: Partial<{\n /** Between flowing blocks: paragraph after paragraph, list after paragraph. */\n readonly paragraph: string\n /** Before a heading; the content after a heading sits tight. */\n readonly heading: string\n /** Between list items and before a nested list. */\n readonly list: string\n /** Around figures, blockquotes, code blocks, tables, and rules. */\n readonly figure: string\n }>\n}\n\nconst flow = 'var(--fk-prose-paragraph, var(--fk-space-md, 1em))'\nconst heading = 'var(--fk-prose-heading, var(--fk-space-xl, 1.8em))'\nconst list = 'var(--fk-prose-list, var(--fk-space-2xs, 0.35em))'\nconst figure = 'var(--fk-prose-figure, var(--fk-space-lg, 1.5em))'\n\nconst rules: StyleValue = compose(\n nest('> *', { marginBlock: '0' }),\n nest('> * + *', { marginBlockStart: flow }),\n nest('> :is(h2, h3, h4, h5, h6)', { marginBlockStart: heading }),\n nest('> :is(h1, h2, h3, h4, h5, h6) + *', { marginBlockStart: 'var(--fk-space-xs, 0.5em)' }),\n nest('> :is(figure, blockquote, pre, table, hr)', { marginBlock: figure }),\n nest(':is(ul, ol)', { paddingInlineStart: 'var(--fk-space-lg, 1.5em)' }),\n nest('li + li', { marginBlockStart: list }),\n nest(':is(li > ul, li > ol)', { marginBlockStart: list }),\n nest('blockquote', {\n paddingInlineStart: 'var(--fk-space-md, 1em)',\n borderInlineStart: 'var(--fk-border-heavy, 3px) solid var(--fk-outline-default, currentColor)',\n color: 'var(--fk-text-subtle, inherit)',\n }),\n nest('figcaption', {\n marginBlockStart: 'var(--fk-space-xs, 0.5em)',\n color: 'var(--fk-text-muted, inherit)',\n fontSize: 'var(--fk-size-sm, 0.875em)',\n }),\n nest('hr', {\n border: '0',\n borderBlockStart: 'var(--fk-border-thin, 1px) solid var(--fk-outline-subtle, currentColor)',\n }),\n nest('table', {\n inlineSize: '100%',\n borderCollapse: 'collapse',\n fontSize: 'var(--fk-size-sm, 0.875em)',\n }),\n nest(':is(th, td)', {\n padding: 'var(--fk-space-xs, 0.5em) var(--fk-space-sm, 0.75em)',\n borderBlockEnd: 'var(--fk-border-thin, 1px) solid var(--fk-outline-subtle, currentColor)',\n textAlign: 'start',\n }),\n nest('mark', {\n padding: '0 0.2em',\n background: 'var(--fk-accent-subtle, Mark)',\n color: 'var(--fk-accent-text, MarkText)',\n }),\n nest('abbr[title]', { textDecorationStyle: 'dotted', cursor: 'help' }),\n nest(':not(pre) > code', { overflowWrap: 'anywhere' }),\n nest('pre', { overflowX: 'auto' }),\n nest('a', { overflowWrap: 'anywhere' }),\n)\n\nconst variables = (options: ProseOptions): Readonly<Record<`--${string}`, string>> => ({\n ...(options.measure === undefined ? {} : { '--fk-prose-measure': options.measure }),\n ...(options.rhythm?.paragraph === undefined\n ? {}\n : { '--fk-prose-paragraph': options.rhythm.paragraph }),\n ...(options.rhythm?.heading === undefined\n ? {}\n : { '--fk-prose-heading': options.rhythm.heading }),\n ...(options.rhythm?.list === undefined ? {} : { '--fk-prose-list': options.rhythm.list }),\n ...(options.rhythm?.figure === undefined ? {} : { '--fk-prose-figure': options.rhythm.figure }),\n})\n\n/** The prose container: one class for every caller, options as variables on it. */\nexport const style = (options: ProseOptions = {}): StyleValue =>\n compose(\n inline({\n maxInlineSize: 'var(--fk-prose-measure, 65ch)',\n lineHeight: 'var(--fk-leading-relaxed, 1.6)',\n ...variables(options),\n }),\n rules,\n )\n\nexport const Prose = { style } as const\n"],"mappings":";;;;;;;;;AA0BA,MAAM,OAAO;AACb,MAAM,UAAU;AAChB,MAAM,OAAO;AAGb,MAAM,QAAoB,QACxB,KAAK,OAAO,EAAE,aAAa,IAAI,CAAC,GAChC,KAAK,WAAW,EAAE,kBAAkB,KAAK,CAAC,GAC1C,KAAK,6BAA6B,EAAE,kBAAkB,QAAQ,CAA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AY,CAAC,IAAI,EAAE,qBAAqB,QAAQ,OAAO,OAAO;AAC/F;;AAGA,MAAa,SAAS,UAAwB,CAAC,MAC7C,QACE,OAAO;CACL,eAAe;CACf,YAAY;CACZ,GAAG,UAAU,OAAO;AACtB,CAAC,GACD,KACF;AAEF,MAAa,QAAQ,EAAE,MAAM"}
@@ -0,0 +1,242 @@
1
+ import { t as DiagnosticError } from "./diagnostics-YJ7991-A.mjs";
2
+ //#region src/styleRules.ts
3
+ const rule = (selector, declarations, at) => Object.freeze({
4
+ selector,
5
+ declarations: Object.freeze({ ...declarations }),
6
+ ...at === void 0 ? {} : { at }
7
+ });
8
+ /**
9
+ * The top-level selectors of a list: split on commas outside `()`, `[]` and
10
+ * strings, so `:is(a, b)` and `[title="a, b"]` stay whole.
11
+ */
12
+ const selectorList = (selector) => {
13
+ const parts = [];
14
+ let depth = 0;
15
+ let quote;
16
+ let start = 0;
17
+ for (let index = 0; index < selector.length; index++) {
18
+ const char = selector[index];
19
+ if (quote !== void 0) {
20
+ if (char === "\\") index++;
21
+ else if (char === quote) quote = void 0;
22
+ } else if (char === "\"" || char === "'") quote = char;
23
+ else if (char === "(" || char === "[") depth++;
24
+ else if (char === ")" || char === "]") depth--;
25
+ else if (char === "," && depth === 0) {
26
+ parts.push(selector.slice(start, index).trim());
27
+ start = index + 1;
28
+ }
29
+ }
30
+ parts.push(selector.slice(start).trim());
31
+ return parts;
32
+ };
33
+ /** Each selector of a list relative to the class: `&` kept where written, else `prefix` added. */
34
+ const relative = (selector, prefix) => selectorList(selector).map((part) => part.includes("&") ? part : prefix(part)).join(", ");
35
+ /** `:hover, :focus-visible` is `&:hover, &:focus-visible`. */
36
+ const pseudo$1 = (suffix, declarations) => rule(relative(suffix, (part) => `&${part}`), declarations);
37
+ const media$1 = (query, declarations) => rule("&", declarations, `@media ${query}`);
38
+ const supports$1 = (condition, declarations) => rule("&", declarations, `@supports ${condition}`);
39
+ const container$1 = (condition, declarations) => rule("&", declarations, `@container ${condition}`);
40
+ /**
41
+ * A nested selector relative to the class, e.g. `> span`, or `[data-open] &`
42
+ * where `&` places the class. Every selector of a list is scoped.
43
+ */
44
+ const nest$1 = (selector, declarations) => rule(relative(selector, (part) => `& ${part}`), declarations);
45
+ /** `gridTemplateColumns` -> `grid-template-columns`; custom properties pass through. */
46
+ const kebab = (property) => property.startsWith("--") ? property : property.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
47
+ const declarationsText = (declarations) => Object.keys(declarations).sort().map((property) => `${kebab(property)}:${declarations[property]}`).join(";");
48
+ /** Canonical, declaration-sorted, authored-rule-order text for a rule list. */
49
+ const inLayerText = (layer, text) => layer === void 0 ? text : `@layer ${layer}{${text}}`;
50
+ const canonical = (rules) => rules.map((entry) => {
51
+ const body = `{${declarationsText(entry.declarations)}}`;
52
+ return inLayerText(entry.layer, entry.at === void 0 ? `${entry.selector}${body}` : `${entry.at}{${entry.selector}${body}}`);
53
+ }).join("");
54
+ const hash = (value) => {
55
+ let state = 2166136261;
56
+ for (let index = 0; index < value.length; index++) {
57
+ state ^= value.charCodeAt(index);
58
+ state = Math.imul(state, 16777619);
59
+ }
60
+ return (state >>> 0).toString(36);
61
+ };
62
+ /** Deterministic `@keyframes`: step order is authored, declarations sorted. */
63
+ const keyframes$1 = (frames) => {
64
+ const body = Object.entries(frames).map(([step, declarations]) => `${step}{${declarationsText(declarations)}}`).join("");
65
+ const name = `kf-${hash(body)}`;
66
+ return Object.freeze({
67
+ name,
68
+ css: `@keyframes ${name}{${body}}`
69
+ });
70
+ };
71
+ const className = (rules) => `style-${hash(canonical(rules))}`;
72
+ const selectorFor = (generated, selector) => selectorList(selector).map((part) => part.includes("&") ? part.replace(/&/g, `.${generated}`) : `.${generated} ${part}`).join(", ");
73
+ const css = (generated, rules) => rules.map((entry) => {
74
+ const body = `{${declarationsText(entry.declarations)}}`;
75
+ const selector = `${selectorFor(generated, entry.selector)}${body}`;
76
+ return inLayerText(entry.layer, entry.at === void 0 ? selector : `${entry.at}{${selector}}`);
77
+ }).join("");
78
+ //#endregion
79
+ //#region src/styleValue.ts
80
+ const tokens = (value) => value.split(/\s+/).filter((token) => token.length > 0);
81
+ const empty = Object.freeze({
82
+ classes: Object.freeze([]),
83
+ style: Object.freeze({})
84
+ });
85
+ const classPiece = (value) => Object.freeze({
86
+ classes: Object.freeze(tokens(value)),
87
+ style: empty.style
88
+ });
89
+ const inline = (value) => Object.freeze({
90
+ classes: empty.classes,
91
+ style: Object.freeze({ ...value })
92
+ });
93
+ /** Concatenate classes; later inline declarations win per property. */
94
+ const compose = (...pieces) => {
95
+ const conditions = pieces.flatMap((piece) => piece.conditions ?? []);
96
+ const items = pieces.flatMap((piece) => piece.items ?? []);
97
+ const rules = pieces.flatMap((piece) => piece.rules ?? []);
98
+ const globalCss = pieces.flatMap((piece) => piece.globalCss ?? []);
99
+ return Object.freeze({
100
+ classes: Object.freeze(pieces.flatMap((piece) => piece.classes)),
101
+ style: Object.freeze(Object.assign(Object.create(null), ...pieces.map((piece) => piece.style))),
102
+ ...conditions.length === 0 ? {} : { conditions: Object.freeze(conditions) },
103
+ ...items.length === 0 ? {} : { items: Object.freeze(items) },
104
+ ...rules.length === 0 ? {} : { rules: Object.freeze(rules) },
105
+ ...globalCss.length === 0 ? {} : { globalCss: Object.freeze(globalCss) }
106
+ });
107
+ };
108
+ /** A pseudo-class/element rule, e.g. `Style.pseudo(':hover', { color: 'red' })`. */
109
+ const pseudo = (suffix, declarations) => Object.freeze({
110
+ classes: empty.classes,
111
+ style: empty.style,
112
+ rules: Object.freeze([pseudo$1(suffix, declarations)])
113
+ });
114
+ /**
115
+ * Declarations on the element itself, as a rule on its generated class
116
+ * (`&{…}`) rather than inline, so `Layers.in` can place them in a layer and a
117
+ * later layer can override them. Inline declarations sit outside every layer.
118
+ */
119
+ const self = (declarations) => Object.freeze({
120
+ classes: empty.classes,
121
+ style: empty.style,
122
+ rules: Object.freeze([rule("&", declarations)])
123
+ });
124
+ /** An at-rule, e.g. `Style.media('(min-width: 40rem)', { color: 'red' })`. */
125
+ const media = (query, declarations) => Object.freeze({
126
+ classes: empty.classes,
127
+ style: empty.style,
128
+ rules: Object.freeze([media$1(query, declarations)])
129
+ });
130
+ /** An at-rule, e.g. `Style.supports('(display: grid)', { display: 'grid' })`. */
131
+ const supports = (condition, declarations) => Object.freeze({
132
+ classes: empty.classes,
133
+ style: empty.style,
134
+ rules: Object.freeze([supports$1(condition, declarations)])
135
+ });
136
+ /** A container query, e.g. `Style.container('(min-width: 30rem)', {...})`. */
137
+ const container = (condition, declarations) => Object.freeze({
138
+ classes: empty.classes,
139
+ style: empty.style,
140
+ rules: Object.freeze([container$1(condition, declarations)])
141
+ });
142
+ /** A nested selector relative to the generated class, e.g. `Style.nest('> span', {...})`. */
143
+ const nest = (selector, declarations) => Object.freeze({
144
+ classes: empty.classes,
145
+ style: empty.style,
146
+ rules: Object.freeze([nest$1(selector, declarations)])
147
+ });
148
+ /**
149
+ * A deterministic `@keyframes` block. Compose `style` where the animation is
150
+ * declared and reference `name` in an `animation` declaration.
151
+ */
152
+ const keyframes = (frames) => {
153
+ const compiled = keyframes$1(frames);
154
+ return Object.freeze({
155
+ name: compiled.name,
156
+ style: Object.freeze({
157
+ classes: empty.classes,
158
+ style: empty.style,
159
+ globalCss: Object.freeze([compiled.css])
160
+ })
161
+ });
162
+ };
163
+ /** Raw class-independent CSS (a layer, a global rule). Prefer typed helpers. */
164
+ const global = (css) => Object.freeze({
165
+ classes: empty.classes,
166
+ style: empty.style,
167
+ globalCss: Object.freeze([css])
168
+ });
169
+ /**
170
+ * Appearance per `data-state` value, e.g. `Style.states({ open: { opacity: '1' } })`
171
+ * compiles to `&[data-state="open"]`. Pairs with Behaviors that write
172
+ * `data-state`, so state is styled with no JavaScript and no `whenInput`:
173
+ * `whenInput` when the view knows, `states` when the DOM does.
174
+ */
175
+ const states = (map, attribute = "data-state") => Object.freeze({
176
+ classes: empty.classes,
177
+ style: empty.style,
178
+ rules: Object.freeze(Object.entries(map).map(([state, declarations]) => pseudo$1(`[${attribute}="${state}"]`, declarations)))
179
+ });
180
+ /**
181
+ * Declarations per named breakpoint, e.g.
182
+ * `Style.responsive({ md: '(min-width: 48rem)' }, { md: { display: 'flex' } })`.
183
+ * The breakpoint names come from the record you pass, typically a theme's, so
184
+ * a misspelled one is a type error.
185
+ */
186
+ const responsive = (breakpoints, map) => Object.freeze({
187
+ classes: empty.classes,
188
+ style: empty.style,
189
+ rules: Object.freeze(Object.entries(map).flatMap(([name, declarations]) => {
190
+ const query = breakpoints[name];
191
+ return query === void 0 || declarations === void 0 ? [] : [media$1(query, declarations)];
192
+ }))
193
+ });
194
+ /** Custom properties on the slot: `Style.vars({ '--gap': '1rem' })`. */
195
+ const vars = (values) => inline(values);
196
+ /**
197
+ * A grid template with typed areas, so a child cannot name an area the
198
+ * parent lacks: `const Page = Style.grid({ areas: [['header', 'header'],
199
+ * ['nav', 'main']] })`, then `Page.area('main')` on the child and
200
+ * `Page.area('footer')` is a type error. A ragged template raises
201
+ * `mixins:ragged-grid-areas`.
202
+ */
203
+ const grid = (config) => {
204
+ const width = config.areas[0]?.length ?? 0;
205
+ if (config.areas.some((row) => row.length !== width)) throw new DiagnosticError({
206
+ source: "mixins",
207
+ code: "mixins:ragged-grid-areas",
208
+ severity: "error",
209
+ message: `Style.grid areas must be rectangular; rows have lengths ${config.areas.map((row) => row.length).join(", ")}`
210
+ });
211
+ const names = [];
212
+ for (const row of config.areas) for (const cell of row) if (cell !== "." && !names.includes(cell)) names.push(cell);
213
+ return Object.freeze({
214
+ style: inline({
215
+ display: "grid",
216
+ gridTemplateAreas: config.areas.map((row) => `"${row.join(" ")}"`).join(" "),
217
+ ...config.columns === void 0 ? {} : { gridTemplateColumns: config.columns },
218
+ ...config.rows === void 0 ? {} : { gridTemplateRows: config.rows },
219
+ ...config.gap === void 0 ? {} : { gap: config.gap }
220
+ }),
221
+ area: (name) => inline({ gridArea: name }),
222
+ areas: Object.freeze(names)
223
+ });
224
+ };
225
+ /**
226
+ * The declarations an element starts from when it enters, as a
227
+ * `@starting-style` rule. With a `transition` on the base, the browser
228
+ * animates from these; pair with `allowDiscrete` when `display` takes part.
229
+ */
230
+ const enter = (declarations) => Object.freeze({
231
+ classes: empty.classes,
232
+ style: empty.style,
233
+ rules: Object.freeze([rule("&", declarations, "@starting-style")])
234
+ });
235
+ /** `transition-behavior: allow-discrete`, so `display` and `overlay` transition too. */
236
+ const allowDiscrete = inline({ transitionBehavior: "allow-discrete" });
237
+ /** Opts the slot into Foldkit's view transitions under `name`. */
238
+ const viewTransitionName = (name) => inline({ viewTransitionName: name });
239
+ //#endregion
240
+ export { supports as _, empty as a, className as b, grid as c, media as d, nest as f, states as g, self as h, container as i, inline as l, responsive as m, classPiece as n, enter as o, pseudo as p, compose as r, global as s, allowDiscrete as t, keyframes as u, vars as v, css as x, viewTransitionName as y };
241
+
242
+ //# sourceMappingURL=styleValue--iQMTcPn.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleValue--iQMTcPn.mjs","names":["pseudo","media","supports","container","nest","keyframes","Rules.pseudo","Rules.rule","Rules.media","Rules.supports","Rules.container","Rules.nest","Rules.keyframes"],"sources":["../src/styleRules.ts","../src/styleValue.ts"],"sourcesContent":["/**\n * Deterministic compilation of rule-based Style. A rule selector is written\n * relative to the generated class with `&` (`&:hover`). The class name is an\n * FNV-1a hash of the canonical rule text, so equal rules share a class and the\n * server and the browser derive the same name. Pure data in, CSS text out: no\n * registry, no DOM, no `Date.now`.\n */\nexport interface StyleRule {\n readonly selector: string\n readonly at?: string\n /** The cascade layer the rule is emitted in; none means the unlayered cascade. */\n readonly layer?: string\n readonly declarations: Readonly<Record<string, string>>\n}\n\nexport const rule = (\n selector: string,\n declarations: Readonly<Record<string, string>>,\n at?: string,\n): StyleRule =>\n Object.freeze({\n selector,\n declarations: Object.freeze({ ...declarations }),\n ...(at === undefined ? {} : { at }),\n })\n\n/**\n * The top-level selectors of a list: split on commas outside `()`, `[]` and\n * strings, so `:is(a, b)` and `[title=\"a, b\"]` stay whole.\n */\nexport const selectorList = (selector: string): ReadonlyArray<string> => {\n const parts: Array<string> = []\n let depth = 0\n let quote: string | undefined\n let start = 0\n for (let index = 0; index < selector.length; index++) {\n const char = selector[index]\n if (quote !== undefined) {\n if (char === '\\\\') index++\n else if (char === quote) quote = undefined\n } else if (char === '\"' || char === \"'\") quote = char\n else if (char === '(' || char === '[') depth++\n else if (char === ')' || char === ']') depth--\n else if (char === ',' && depth === 0) {\n parts.push(selector.slice(start, index).trim())\n start = index + 1\n }\n }\n parts.push(selector.slice(start).trim())\n return parts\n}\n\n/** Each selector of a list relative to the class: `&` kept where written, else `prefix` added. */\nconst relative = (selector: string, prefix: (part: string) => string): string =>\n selectorList(selector)\n .map(part => (part.includes('&') ? part : prefix(part)))\n .join(', ')\n\n/** `:hover, :focus-visible` is `&:hover, &:focus-visible`. */\nexport const pseudo = (suffix: string, declarations: Readonly<Record<string, string>>): StyleRule =>\n rule(\n relative(suffix, part => `&${part}`),\n declarations,\n )\n\nexport const media = (query: string, declarations: Readonly<Record<string, string>>): StyleRule =>\n rule('&', declarations, `@media ${query}`)\n\nexport const supports = (\n condition: string,\n declarations: Readonly<Record<string, string>>,\n): StyleRule => rule('&', declarations, `@supports ${condition}`)\n\nexport const container = (\n condition: string,\n declarations: Readonly<Record<string, string>>,\n): StyleRule => rule('&', declarations, `@container ${condition}`)\n\n/**\n * A nested selector relative to the class, e.g. `> span`, or `[data-open] &`\n * where `&` places the class. Every selector of a list is scoped.\n */\nexport const nest = (selector: string, declarations: Readonly<Record<string, string>>): StyleRule =>\n rule(\n relative(selector, part => `& ${part}`),\n declarations,\n )\n\n/** `gridTemplateColumns` -> `grid-template-columns`; custom properties pass through. */\nconst kebab = (property: string): string =>\n property.startsWith('--')\n ? property\n : property.replace(/[A-Z]/g, match => `-${match.toLowerCase()}`)\n\nconst declarationsText = (declarations: Readonly<Record<string, string>>): string =>\n Object.keys(declarations)\n .sort()\n .map(property => `${kebab(property)}:${declarations[property]}`)\n .join(';')\n\n/** Canonical, declaration-sorted, authored-rule-order text for a rule list. */\nconst inLayerText = (layer: string | undefined, text: string): string =>\n layer === undefined ? text : `@layer ${layer}{${text}}`\n\nexport const canonical = (rules: ReadonlyArray<StyleRule>): string =>\n rules\n .map(entry => {\n const body = `{${declarationsText(entry.declarations)}}`\n return inLayerText(\n entry.layer,\n entry.at === undefined\n ? `${entry.selector}${body}`\n : `${entry.at}{${entry.selector}${body}}`,\n )\n })\n .join('')\n\nconst hash = (value: string): string => {\n let state = 2166136261\n for (let index = 0; index < value.length; index++) {\n state ^= value.charCodeAt(index)\n state = Math.imul(state, 16777619)\n }\n return (state >>> 0).toString(36)\n}\n\nexport interface Keyframes {\n readonly name: string\n readonly css: string\n}\n\n/** Deterministic `@keyframes`: step order is authored, declarations sorted. */\nexport const keyframes = (\n frames: Readonly<Record<string, Readonly<Record<string, string>>>>,\n): Keyframes => {\n const body = Object.entries(frames)\n .map(([step, declarations]) => `${step}{${declarationsText(declarations)}}`)\n .join('')\n const name = `kf-${hash(body)}`\n return Object.freeze({ name, css: `@keyframes ${name}{${body}}` })\n}\n\nexport const className = (rules: ReadonlyArray<StyleRule>): string =>\n `style-${hash(canonical(rules))}`\n\nconst selectorFor = (generated: string, selector: string): string =>\n selectorList(selector)\n .map(part =>\n part.includes('&') ? part.replace(/&/g, `.${generated}`) : `.${generated} ${part}`,\n )\n .join(', ')\n\nexport const css = (generated: string, rules: ReadonlyArray<StyleRule>): string =>\n rules\n .map(entry => {\n const body = `{${declarationsText(entry.declarations)}}`\n const selector = `${selectorFor(generated, entry.selector)}${body}`\n return inLayerText(\n entry.layer,\n entry.at === undefined ? selector : `${entry.at}{${selector}}`,\n )\n })\n .join('')\n","/**\n * The Style kernel: `StyleValue` and the pure builders that make one. A\n * value is class tokens, inline declarations, rule pieces that compile to a\n * deterministic class, and class-independent CSS. Nothing here knows what a\n * slot is; `style.ts` joins this to slots, and the `/theme`, `/layers`,\n * `/layout`, `/defaults`, and `/prose` subpaths build on it alone.\n */\nimport type { Properties } from 'csstype'\nimport { DiagnosticError } from './diagnostics.js'\nimport type { SlotItem } from './slotItem.js'\nimport * as Rules from './styleRules.js'\nimport type { StyleRule } from './styleRules.js'\n\n/**\n * The declarations a piece accepts: camelCase CSS properties, each a string,\n * plus custom properties. A misspelled or kebab-case property is a type error;\n * the compiler writes the kebab-case name. Values stay strings, so `var(...)`,\n * `calc(...)`, and `light-dark(...)` pass through.\n */\nexport type Declarations = { readonly [K in keyof Properties]?: string } & {\n readonly [K: `--${string}`]: string\n}\n\nexport interface StyleValue {\n readonly classes: ReadonlyArray<string>\n readonly style: Readonly<Record<string, string>>\n /** Input-driven pieces resolved at render time; empty for a static style. */\n readonly conditions?: ReadonlyArray<StyleCondition>\n /** Pieces that depend on which repetition of a slot is rendered. */\n readonly items?: ReadonlyArray<(item: SlotItem | undefined) => StyleValue>\n /** Rule-based appearance compiled to a deterministic class plus CSS. */\n readonly rules?: ReadonlyArray<StyleRule>\n /** Class-independent CSS (keyframes, layers, global rules). */\n readonly globalCss?: ReadonlyArray<string>\n}\n\nexport interface StyleCondition {\n readonly predicate: (input: unknown) => boolean\n readonly piece: StyleValue\n}\n\nconst tokens = (value: string): ReadonlyArray<string> =>\n value.split(/\\s+/).filter(token => token.length > 0)\n\nexport const empty: StyleValue = Object.freeze({\n classes: Object.freeze([]) as ReadonlyArray<string>,\n style: Object.freeze({}) as Readonly<Record<string, string>>,\n})\n\nexport const classPiece = (value: string): StyleValue =>\n Object.freeze({ classes: Object.freeze(tokens(value)), style: empty.style })\n\nexport const inline = (value: Declarations): StyleValue =>\n Object.freeze({ classes: empty.classes, style: Object.freeze({ ...value }) })\n\n/** Concatenate classes; later inline declarations win per property. */\nexport const compose = (...pieces: ReadonlyArray<StyleValue>): StyleValue => {\n const conditions = pieces.flatMap(piece => piece.conditions ?? [])\n const items = pieces.flatMap(piece => piece.items ?? [])\n const rules = pieces.flatMap(piece => piece.rules ?? [])\n const globalCss = pieces.flatMap(piece => piece.globalCss ?? [])\n return Object.freeze({\n classes: Object.freeze(pieces.flatMap(piece => piece.classes)),\n style: Object.freeze(Object.assign(Object.create(null), ...pieces.map(piece => piece.style))),\n ...(conditions.length === 0 ? {} : { conditions: Object.freeze(conditions) }),\n ...(items.length === 0 ? {} : { items: Object.freeze(items) }),\n ...(rules.length === 0 ? {} : { rules: Object.freeze(rules) }),\n ...(globalCss.length === 0 ? {} : { globalCss: Object.freeze(globalCss) }),\n })\n}\n\n/** A pseudo-class/element rule, e.g. `Style.pseudo(':hover', { color: 'red' })`. */\nexport const pseudo = (suffix: string, declarations: Declarations): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.pseudo(suffix, declarations)]),\n })\n\n/**\n * Declarations on the element itself, as a rule on its generated class\n * (`&{…}`) rather than inline, so `Layers.in` can place them in a layer and a\n * later layer can override them. Inline declarations sit outside every layer.\n */\nexport const self = (declarations: Declarations): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.rule('&', declarations)]),\n })\n\n/** An at-rule, e.g. `Style.media('(min-width: 40rem)', { color: 'red' })`. */\nexport const media = (query: string, declarations: Declarations): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.media(query, declarations)]),\n })\n\n/** An at-rule, e.g. `Style.supports('(display: grid)', { display: 'grid' })`. */\nexport const supports = (condition: string, declarations: Declarations): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.supports(condition, declarations)]),\n })\n\n/** A container query, e.g. `Style.container('(min-width: 30rem)', {...})`. */\nexport const container = (condition: string, declarations: Declarations): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.container(condition, declarations)]),\n })\n\n/** A nested selector relative to the generated class, e.g. `Style.nest('> span', {...})`. */\nexport const nest = (selector: string, declarations: Declarations): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.nest(selector, declarations)]),\n })\n\n/**\n * A deterministic `@keyframes` block. Compose `style` where the animation is\n * declared and reference `name` in an `animation` declaration.\n */\nexport const keyframes = (\n frames: Readonly<Record<string, Declarations>>,\n): { readonly name: string; readonly style: StyleValue } => {\n const compiled = Rules.keyframes(frames)\n return Object.freeze({\n name: compiled.name,\n style: Object.freeze({\n classes: empty.classes,\n style: empty.style,\n globalCss: Object.freeze([compiled.css]),\n }),\n })\n}\n\n/** Raw class-independent CSS (a layer, a global rule). Prefer typed helpers. */\nexport const global = (css: string): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n globalCss: Object.freeze([css]),\n })\n\n/**\n * Appearance per `data-state` value, e.g. `Style.states({ open: { opacity: '1' } })`\n * compiles to `&[data-state=\"open\"]`. Pairs with Behaviors that write\n * `data-state`, so state is styled with no JavaScript and no `whenInput`:\n * `whenInput` when the view knows, `states` when the DOM does.\n */\nexport const states = (\n map: Readonly<Record<string, Declarations>>,\n attribute = 'data-state',\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze(\n Object.entries(map).map(([state, declarations]) =>\n Rules.pseudo(`[${attribute}=\"${state}\"]`, declarations),\n ),\n ),\n })\n\n/**\n * Declarations per named breakpoint, e.g.\n * `Style.responsive({ md: '(min-width: 48rem)' }, { md: { display: 'flex' } })`.\n * The breakpoint names come from the record you pass, typically a theme's, so\n * a misspelled one is a type error.\n */\nexport const responsive = <Breakpoints extends Readonly<Record<string, string>>>(\n breakpoints: Breakpoints,\n map: Partial<Readonly<Record<keyof Breakpoints & string, Declarations>>>,\n): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze(\n Object.entries(map).flatMap(([name, declarations]) => {\n const query = breakpoints[name]\n return query === undefined || declarations === undefined\n ? []\n : [Rules.media(query, declarations)]\n }),\n ),\n })\n\n/** Custom properties on the slot: `Style.vars({ '--gap': '1rem' })`. */\nexport const vars = (values: Readonly<Record<`--${string}`, string>>): StyleValue => inline(values)\n\nexport interface GridConfig<Area extends string> {\n /** Rows of area names; `'.'` is an empty cell. Every row has the same length. */\n readonly areas: ReadonlyArray<ReadonlyArray<Area>>\n readonly columns?: string\n readonly rows?: string\n readonly gap?: string\n}\n\nexport interface Grid<Area extends string> {\n /** The container's declarations: `display: grid` and the template. */\n readonly style: StyleValue\n /** A child's `grid-area`; only the names the template declares are accepted. */\n readonly area: (name: Area) => StyleValue\n /** The declared names, in first-appearance order. */\n readonly areas: ReadonlyArray<Area>\n}\n\n/**\n * A grid template with typed areas, so a child cannot name an area the\n * parent lacks: `const Page = Style.grid({ areas: [['header', 'header'],\n * ['nav', 'main']] })`, then `Page.area('main')` on the child and\n * `Page.area('footer')` is a type error. A ragged template raises\n * `mixins:ragged-grid-areas`.\n */\nexport const grid = <const Area extends string>(\n config: GridConfig<Area>,\n): Grid<Exclude<Area, '.'>> => {\n const width = config.areas[0]?.length ?? 0\n if (config.areas.some(row => row.length !== width)) {\n throw new DiagnosticError({\n source: 'mixins',\n code: 'mixins:ragged-grid-areas',\n severity: 'error',\n message: `Style.grid areas must be rectangular; rows have lengths ${config.areas.map(row => row.length).join(', ')}`,\n })\n }\n const names: Array<Exclude<Area, '.'>> = []\n for (const row of config.areas) {\n for (const cell of row) {\n if (cell !== '.' && !names.includes(cell as Exclude<Area, '.'>)) {\n names.push(cell as Exclude<Area, '.'>)\n }\n }\n }\n return Object.freeze({\n style: inline({\n display: 'grid',\n gridTemplateAreas: config.areas.map(row => `\"${row.join(' ')}\"`).join(' '),\n ...(config.columns === undefined ? {} : { gridTemplateColumns: config.columns }),\n ...(config.rows === undefined ? {} : { gridTemplateRows: config.rows }),\n ...(config.gap === undefined ? {} : { gap: config.gap }),\n }),\n area: (name: Exclude<Area, '.'>) => inline({ gridArea: name }),\n areas: Object.freeze(names),\n })\n}\n\n/**\n * The declarations an element starts from when it enters, as a\n * `@starting-style` rule. With a `transition` on the base, the browser\n * animates from these; pair with `allowDiscrete` when `display` takes part.\n */\nexport const enter = (declarations: Declarations): StyleValue =>\n Object.freeze({\n classes: empty.classes,\n style: empty.style,\n rules: Object.freeze([Rules.rule('&', declarations, '@starting-style')]),\n })\n\n/** `transition-behavior: allow-discrete`, so `display` and `overlay` transition too. */\nexport const allowDiscrete: StyleValue = inline({ transitionBehavior: 'allow-discrete' })\n\n/** Opts the slot into Foldkit's view transitions under `name`. */\nexport const viewTransitionName = (name: string): StyleValue => inline({ viewTransitionName: name })\n"],"mappings":";;AAeA,MAAa,QACX,UACA,cACA,OAEA,OAAO,OAAO;CACZ;CACA,cAAc,OAAO,OAAO,EAAE,GAAG,aAAa,CAAC;CAC/C,GAAI,OAAO,KAAA,IAAY,CAAC,IAAI,EAAE,GAAG;AACnC,CAAC;;;;;AAMH,MAAa,gBAAgB,aAA4C;CACvE,MAAM,QAAuB,CAAC;CAC9B,IAAI,QAAQ;CACZ,IAAI;CACJ,IAAI,QAAQ;CACZ,KAAK,IAAI,QAAQ,GAAG,QAAQ,SAAS,QAAQ,SAAS;EACpD,MAAM,OAAO,SAAS;EACtB,IAAI,UAAU,KAAA,GAAW;GACvB,IAAI,SAAS,MAAM;QACd,IAAI,SAAS,OAAO,QAAQ,KAAA;EACnC,OAAO,IAAI,SAAS,QAAO,SAAS,KAAK,QAAQ;OAC5C,IAAI,SAAS,OAAO,SAAS,KAAK;OAClC,IAAI,SAAS,OAAO,SAAS,KAAK;OAClC,IAAI,SAAS,OAAO,UAAU,GAAG;GACpC,MAAM,KAAK,SAAS,MAAM,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC;GAC9C,QAAQ,QAAQ;EAClB;CACF;CACA,MAAM,KAAK,SAAS,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC;CACvC,OAAO;AACT;;AAGA,MAAM,YAAY,UAAkB,WAClC,aAAa,QAAQ,CAAC,CACnB,KAAI,SAAS,KAAK,SAAS,GAAG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AAO,OAAO,OAAO,CAACD,KAAW,KAAK,cAAc,iBAAiB,CAAC,CAAC;AACzE,CAAC;;AAGH,MAAa,gBAA4B,OAAO,EAAE,oBAAoB,iBAAiB,CAAC;;AAGxF,MAAa,sBAAsB,SAA6B,OAAO,EAAE,oBAAoB,KAAK,CAAC"}
@@ -0,0 +1,77 @@
1
+ import { Properties } from "csstype";
2
+ //#region src/slotItem.d.ts
3
+ /**
4
+ * Which repetition of a slot is being resolved, when a view renders one slot
5
+ * once per item (rows, tabs, options). The view passes it as the second
6
+ * argument of `slots.x.attrs(base, item)`; a Behavior reads it to write
7
+ * per-item attributes such as `tabindex`, `aria-posinset`, or an id, and a
8
+ * `Style.perItem` piece reads it for appearance.
9
+ */
10
+ interface SlotItem {
11
+ readonly index: number;
12
+ /** The item's stable identity, when it has one: a row id, an option value. */
13
+ readonly id?: string;
14
+ /** How many items the slot renders, when the view knows. */
15
+ readonly count?: number;
16
+ }
17
+ //#endregion
18
+ //#region src/styleRules.d.ts
19
+ /**
20
+ * Deterministic compilation of rule-based Style. A rule selector is written
21
+ * relative to the generated class with `&` (`&:hover`). The class name is an
22
+ * FNV-1a hash of the canonical rule text, so equal rules share a class and the
23
+ * server and the browser derive the same name. Pure data in, CSS text out: no
24
+ * registry, no DOM, no `Date.now`.
25
+ */
26
+ interface StyleRule {
27
+ readonly selector: string;
28
+ readonly at?: string;
29
+ /** The cascade layer the rule is emitted in; none means the unlayered cascade. */
30
+ readonly layer?: string;
31
+ readonly declarations: Readonly<Record<string, string>>;
32
+ }
33
+ //#endregion
34
+ //#region src/styleValue.d.ts
35
+ /**
36
+ * The declarations a piece accepts: camelCase CSS properties, each a string,
37
+ * plus custom properties. A misspelled or kebab-case property is a type error;
38
+ * the compiler writes the kebab-case name. Values stay strings, so `var(...)`,
39
+ * `calc(...)`, and `light-dark(...)` pass through.
40
+ */
41
+ type Declarations = { readonly [K in keyof Properties]?: string; } & {
42
+ readonly [K: `--${string}`]: string;
43
+ };
44
+ interface StyleValue {
45
+ readonly classes: ReadonlyArray<string>;
46
+ readonly style: Readonly<Record<string, string>>;
47
+ /** Input-driven pieces resolved at render time; empty for a static style. */
48
+ readonly conditions?: ReadonlyArray<StyleCondition>;
49
+ /** Pieces that depend on which repetition of a slot is rendered. */
50
+ readonly items?: ReadonlyArray<(item: SlotItem | undefined) => StyleValue>;
51
+ /** Rule-based appearance compiled to a deterministic class plus CSS. */
52
+ readonly rules?: ReadonlyArray<StyleRule>;
53
+ /** Class-independent CSS (keyframes, layers, global rules). */
54
+ readonly globalCss?: ReadonlyArray<string>;
55
+ }
56
+ interface StyleCondition {
57
+ readonly predicate: (input: unknown) => boolean;
58
+ readonly piece: StyleValue;
59
+ }
60
+ interface GridConfig<Area extends string> {
61
+ /** Rows of area names; `'.'` is an empty cell. Every row has the same length. */
62
+ readonly areas: ReadonlyArray<ReadonlyArray<Area>>;
63
+ readonly columns?: string;
64
+ readonly rows?: string;
65
+ readonly gap?: string;
66
+ }
67
+ interface Grid<Area extends string> {
68
+ /** The container's declarations: `display: grid` and the template. */
69
+ readonly style: StyleValue;
70
+ /** A child's `grid-area`; only the names the template declares are accepted. */
71
+ readonly area: (name: Area) => StyleValue;
72
+ /** The declared names, in first-appearance order. */
73
+ readonly areas: ReadonlyArray<Area>;
74
+ }
75
+ //#endregion
76
+ export { StyleValue as a, StyleCondition as i, Grid as n, StyleRule as o, GridConfig as r, SlotItem as s, Declarations as t };
77
+ //# sourceMappingURL=styleValue-C9vAKt7A.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styleValue-C9vAKt7A.d.mts","names":[],"sources":["../src/slotItem.ts","../src/styleRules.ts","../src/styleValue.ts"],"mappings":";;;;;;;;;UAOiB;WACN;;WAEA;;WAEA;;;;;;;;;;;UCLM;WACN;WACA;;WAEA;WACA,cAAc,SAAS;;;;;;;;;;KCOtB,2BAA2B,WAAW;YACtC;;UAGK;WACN,SAAS;WACT,OAAO,SAAS;;WAEhB,aAAa,cAAc;;WAE3B,QAAQ,eAAe,MAAM,yBAAyB;;WAEtD,QAAQ,cAAc;;WAEtB,YAAY;;UAGN;WACN,YAAY;WACZ,OAAO;;UA6JD,WAAW;;WAEjB,OAAO,cAAc,cAAc;WACnC;WACA;WACA;;UAGM,KAAK;;WAEX,OAAO;;WAEP,OAAO,MAAM,SAAS;;WAEtB,OAAO,cAAc"}