@fluixi-css/core 1.0.0-next.1 → 1.0.0-next.2
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/package.json +1 -1
- package/dist/reset.css +174 -152
- package/dist/src/css-parser.cjs +6 -1
- package/dist/src/css-parser.cjs.map +1 -1
- package/dist/src/css-parser.js +6 -2
- package/dist/src/css-parser.js.map +1 -1
- package/dist/src/css-parser.mjs +6 -1
- package/dist/src/css-parser.mjs.map +1 -1
- package/dist/src/engine/apply.d.ts +2 -0
- package/dist/src/engine/apply.js +75 -0
- package/dist/src/engine/apply.js.map +1 -0
- package/dist/src/engine/ast.js +25 -2
- package/dist/src/engine/ast.js.map +1 -1
- package/dist/src/engine/compile.js +48 -10
- package/dist/src/engine/compile.js.map +1 -1
- package/dist/src/engine/directives.js +45 -19
- package/dist/src/engine/directives.js.map +1 -1
- package/dist/src/engine/index.d.ts +4 -0
- package/dist/src/engine/index.js +6 -0
- package/dist/src/engine/index.js.map +1 -1
- package/dist/src/engine/log.d.ts +6 -0
- package/dist/src/engine/log.js +42 -0
- package/dist/src/engine/log.js.map +1 -0
- package/dist/src/engine/registry.d.ts +5 -4
- package/dist/src/engine/registry.js +2 -2
- package/dist/src/engine/registry.js.map +1 -1
- package/dist/src/engine/transform.d.ts +22 -0
- package/dist/src/engine/transform.js +34 -9
- package/dist/src/engine/transform.js.map +1 -1
- package/dist/src/engine/utilities/backgrounds.js +11 -0
- package/dist/src/engine/utilities/backgrounds.js.map +1 -1
- package/dist/src/engine/utilities/borders.js +60 -1
- package/dist/src/engine/utilities/borders.js.map +1 -1
- package/dist/src/engine/utilities/layout.js +25 -0
- package/dist/src/engine/utilities/layout.js.map +1 -1
- package/dist/src/engine/utilities/spacing.js +25 -1
- package/dist/src/engine/utilities/spacing.js.map +1 -1
- package/dist/src/engine/utilities/typography.js +7 -0
- package/dist/src/engine/utilities/typography.js.map +1 -1
- package/dist/src/engine/variants.js +25 -6
- package/dist/src/engine/variants.js.map +1 -1
- package/dist/src/index.cjs +619 -179
- package/dist/src/index.cjs.map +1 -1
- package/dist/src/index.mjs +618 -180
- package/dist/src/index.mjs.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/reset.css +174 -152
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Renders a `transform()` result as a compact, colourised build line for the
|
|
2
|
+
// Vite/PostCSS plugins to print. Pure (returns a string) so css-core stays
|
|
3
|
+
// side-effect free — the plugins own the actual `console.log`.
|
|
4
|
+
const ANSI = {
|
|
5
|
+
reset: '\x1b[0m',
|
|
6
|
+
dim: '\x1b[2m',
|
|
7
|
+
bold: '\x1b[1m',
|
|
8
|
+
cyan: '\x1b[36m',
|
|
9
|
+
green: '\x1b[32m',
|
|
10
|
+
yellow: '\x1b[33m',
|
|
11
|
+
red: '\x1b[31m',
|
|
12
|
+
};
|
|
13
|
+
function paint(code, s, color) {
|
|
14
|
+
return color ? code + s + ANSI.reset : s;
|
|
15
|
+
}
|
|
16
|
+
function humanBytes(n) {
|
|
17
|
+
return n < 1024 ? `${n} B` : `${(n / 1024).toFixed(1)} kB`;
|
|
18
|
+
}
|
|
19
|
+
function humanMs(ms) {
|
|
20
|
+
return ms < 1 ? `${(ms * 1000) | 0} µs` : ms < 1000 ? `${ms.toFixed(1)} ms` : `${(ms / 1000).toFixed(2)} s`;
|
|
21
|
+
}
|
|
22
|
+
// Green under 10 ms, yellow under 50 ms, red beyond — a quick "is it fast?" cue.
|
|
23
|
+
function timeColor(ms) {
|
|
24
|
+
return ms < 10 ? ANSI.green : ms < 50 ? ANSI.yellow : ANSI.red;
|
|
25
|
+
}
|
|
26
|
+
export function formatBuildLog(label, stats, options = {}) {
|
|
27
|
+
var _a;
|
|
28
|
+
const color = (_a = options.color) !== null && _a !== void 0 ? _a : true;
|
|
29
|
+
const head = paint(ANSI.cyan + ANSI.bold, '◆ fluixi', color);
|
|
30
|
+
const name = paint(ANSI.bold, label, color);
|
|
31
|
+
const time = paint(timeColor(stats.ms), humanMs(stats.ms), color);
|
|
32
|
+
const parts = [
|
|
33
|
+
`${stats.utilities} ${stats.utilities === 1 ? 'utility' : 'utilities'}`,
|
|
34
|
+
`${stats.scanned} scanned`,
|
|
35
|
+
humanBytes(stats.bytes),
|
|
36
|
+
];
|
|
37
|
+
if (stats.sources)
|
|
38
|
+
parts.push(`${stats.sources} ${stats.sources === 1 ? 'source' : 'sources'}`);
|
|
39
|
+
const detail = paint(ANSI.dim, parts.join(' · '), color);
|
|
40
|
+
return `${head} ${name} ${time}\n ${detail}`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/engine/log.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,2EAA2E;AAC3E,+DAA+D;AAE/D,MAAM,IAAI,GAAG;IACX,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,GAAG,EAAE,UAAU;CACP,CAAC;AAEX,SAAS,KAAK,CAAC,IAAY,EAAE,CAAS,EAAE,KAAc;IACpD,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;AAC7D,CAAC;AAED,SAAS,OAAO,CAAC,EAAU;IACzB,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAA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C,OAAO;QAAE,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IAEhG,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC;IACzD,OAAO,GAAG,IAAI,IAAI,IAAI,IAAI,IAAI,OAAO,MAAM,EAAE,CAAC;AAChD,CAAC","sourcesContent":["import type { TransformStats } from './transform';\n\n// Renders a `transform()` result as a compact, colourised build line for the\n// Vite/PostCSS plugins to print. Pure (returns a string) so css-core stays\n// side-effect free — the plugins own the actual `console.log`.\n\nconst ANSI = {\n reset: '\\x1b[0m',\n dim: '\\x1b[2m',\n bold: '\\x1b[1m',\n cyan: '\\x1b[36m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n red: '\\x1b[31m',\n} as const;\n\nfunction paint(code: string, s: string, color: boolean): string {\n return color ? code + s + ANSI.reset : s;\n}\n\nfunction humanBytes(n: number): string {\n return n < 1024 ? `${n} B` : `${(n / 1024).toFixed(1)} kB`;\n}\n\nfunction humanMs(ms: number): string {\n return ms < 1 ? `${(ms * 1000) | 0} µs` : ms < 1000 ? `${ms.toFixed(1)} ms` : `${(ms / 1000).toFixed(2)} s`;\n}\n\n// Green under 10 ms, yellow under 50 ms, red beyond — a quick \"is it fast?\" cue.\nfunction timeColor(ms: number): string {\n return ms < 10 ? ANSI.green : ms < 50 ? ANSI.yellow : ANSI.red;\n}\n\nexport interface FormatLogOptions {\n /** Emit ANSI colours. Default true. */\n color?: boolean;\n}\n\nexport function formatBuildLog(label: string, stats: TransformStats, options: FormatLogOptions = {}): string {\n const color = options.color ?? true;\n const head = paint(ANSI.cyan + ANSI.bold, '◆ fluixi', color);\n const name = paint(ANSI.bold, label, color);\n const time = paint(timeColor(stats.ms), humanMs(stats.ms), color);\n\n const parts = [\n `${stats.utilities} ${stats.utilities === 1 ? 'utility' : 'utilities'}`,\n `${stats.scanned} scanned`,\n humanBytes(stats.bytes),\n ];\n if (stats.sources) parts.push(`${stats.sources} ${stats.sources === 1 ? 'source' : 'sources'}`);\n\n const detail = paint(ANSI.dim, parts.join(' · '), color);\n return `${head} ${name} ${time}\\n ${detail}`;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Declaration } from './ast';
|
|
1
|
+
import type { Declaration, StyleRule } from './ast';
|
|
2
2
|
import type { AtomContext, AtomModifier, AtomValue } from './atom';
|
|
3
3
|
import { Theme } from './theme';
|
|
4
4
|
export interface RuleContext {
|
|
@@ -7,7 +7,8 @@ export interface RuleContext {
|
|
|
7
7
|
negative: boolean;
|
|
8
8
|
theme: Theme;
|
|
9
9
|
}
|
|
10
|
-
export type
|
|
10
|
+
export type RuleProduct = Declaration | StyleRule;
|
|
11
|
+
export type DynamicRuleFn = (ctx: RuleContext) => RuleProduct[] | null;
|
|
11
12
|
export interface VariantWrap {
|
|
12
13
|
selector?: string;
|
|
13
14
|
atRule?: {
|
|
@@ -31,7 +32,7 @@ export declare class Registry implements AtomContext {
|
|
|
31
32
|
private variants;
|
|
32
33
|
private dynamicVariants;
|
|
33
34
|
constructor(theme?: Theme);
|
|
34
|
-
rule(name: string,
|
|
35
|
+
rule(name: string, products: RuleProduct[]): this;
|
|
35
36
|
dynamicRule(name: string, handler: DynamicRuleFn): this;
|
|
36
37
|
variant(name: string, wrap: VariantWrap): this;
|
|
37
38
|
dynamicVariant(name: string, handler: DynamicVariantFn): this;
|
|
@@ -39,7 +40,7 @@ export declare class Registry implements AtomContext {
|
|
|
39
40
|
isDynamicRule: (root: string) => boolean;
|
|
40
41
|
isVariant: (root: string) => boolean;
|
|
41
42
|
isDynamicVariant: (root: string) => boolean;
|
|
42
|
-
getRule(root: string):
|
|
43
|
+
getRule(root: string): RuleProduct[] | null;
|
|
43
44
|
getDynamicRule(root: string): DynamicRuleFn | null;
|
|
44
45
|
getVariant(name: string): VariantWrap | null;
|
|
45
46
|
getDynamicVariant(root: string): DynamicVariantFn | null;
|
|
@@ -13,8 +13,8 @@ export class Registry {
|
|
|
13
13
|
this.isDynamicVariant = (root) => this.dynamicVariants.has(root);
|
|
14
14
|
this.theme = theme;
|
|
15
15
|
}
|
|
16
|
-
rule(name,
|
|
17
|
-
this.rules.set(name,
|
|
16
|
+
rule(name, products) {
|
|
17
|
+
this.rules.set(name, products);
|
|
18
18
|
return this;
|
|
19
19
|
}
|
|
20
20
|
dynamicRule(name, handler) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/engine/registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../../src/engine/registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AA6BhC,+EAA+E;AAC/E,+CAA+C;AAC/C,MAAM,OAAO,QAAQ;IAQnB,YAAY,QAAe,IAAI,KAAK,EAAE;QAL9B,UAAK,GAAG,IAAI,GAAG,EAAyB,CAAC;QACzC,iBAAY,GAAG,IAAI,GAAG,EAAyB,CAAC;QAChD,aAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC1C,oBAAe,GAAG,IAAI,GAAG,EAA4B,CAAC;QA0B9D,WAAM,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzD,kBAAa,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACvE,cAAS,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,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I,CAAC;IAChD,CAAC;CACF","sourcesContent":["import type { Declaration, StyleRule } from './ast';\nimport type { AtomContext, AtomModifier, AtomValue } from './atom';\nimport { Theme } from './theme';\n\nexport interface RuleContext {\n value: AtomValue | null;\n modifier: AtomModifier | null;\n negative: boolean;\n theme: Theme;\n}\n\n// A utility produces declarations on its own selector, and/or nested rules whose\n// `&` is woven with that selector — the latter is how child-combinator utilities\n// like `space-x`/`divide-y` reach `& > * + *`.\nexport type RuleProduct = Declaration | StyleRule;\nexport type DynamicRuleFn = (ctx: RuleContext) => RuleProduct[] | null;\n\n// A variant either narrows the selector (`&:hover`, `.group:hover &`) or wraps\n// the rule in an at-rule (`@media`, `@supports`). It may do both.\nexport interface VariantWrap {\n selector?: string;\n atRule?: { name: string; params: string };\n}\n\nexport type VariantValue =\n | { kind: 'named'; value: string }\n | { kind: 'arbitrary'; value: string; dataType: string | null }\n | null;\n\nexport type DynamicVariantFn = (value: VariantValue, modifier: AtomModifier | null) => VariantWrap | null;\n\n// Holds the theme plus the rule and variant tables, and answers the keyword vs\n// value-taking questions the atom parser asks.\nexport class Registry implements AtomContext {\n readonly theme: Theme;\n\n private rules = new Map<string, RuleProduct[]>();\n private dynamicRules = new Map<string, DynamicRuleFn>();\n private variants = new Map<string, VariantWrap>();\n private dynamicVariants = new Map<string, DynamicVariantFn>();\n\n constructor(theme: Theme = new Theme()) {\n this.theme = theme;\n }\n\n rule(name: string, products: RuleProduct[]): this {\n this.rules.set(name, products);\n return this;\n }\n\n dynamicRule(name: string, handler: DynamicRuleFn): this {\n this.dynamicRules.set(name, handler);\n return this;\n }\n\n variant(name: string, wrap: VariantWrap): this {\n this.variants.set(name, wrap);\n return this;\n }\n\n dynamicVariant(name: string, handler: DynamicVariantFn): this {\n this.dynamicVariants.set(name, handler);\n return this;\n }\n\n isRule = (root: string): boolean => this.rules.has(root);\n isDynamicRule = (root: string): boolean => this.dynamicRules.has(root);\n isVariant = (root: string): boolean => this.variants.has(root);\n isDynamicVariant = (root: string): boolean => this.dynamicVariants.has(root);\n\n getRule(root: string): RuleProduct[] | null {\n return this.rules.get(root) ?? null;\n }\n getDynamicRule(root: string): DynamicRuleFn | null {\n return this.dynamicRules.get(root) ?? null;\n }\n getVariant(name: string): VariantWrap | null {\n return this.variants.get(name) ?? null;\n }\n getDynamicVariant(root: string): DynamicVariantFn | null {\n return this.dynamicVariants.get(root) ?? null;\n }\n}\n"]}
|
|
@@ -5,21 +5,43 @@ export interface TransformOptions {
|
|
|
5
5
|
classes?: string[];
|
|
6
6
|
sources?: string[];
|
|
7
7
|
base?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Shared base CSS whose `@theme` / `@utility` / `@custom-variant` are loaded
|
|
10
|
+
* into the registry *before* the input's, so a per-route sheet inherits (and
|
|
11
|
+
* can override) the global theme + custom utilities without redefining them.
|
|
12
|
+
* Only the directives feed the registry — the base CSS itself isn't emitted.
|
|
13
|
+
*/
|
|
14
|
+
theme?: string;
|
|
8
15
|
/** Filename of the input CSS, recorded in the source map. */
|
|
9
16
|
from?: string;
|
|
10
17
|
emitTokens?: boolean;
|
|
11
18
|
emitUiTokens?: boolean;
|
|
12
19
|
/** Reset CSS to prepend at the top of the sheet (baseline, before everything). */
|
|
13
20
|
reset?: string;
|
|
21
|
+
/** Source name recorded for the reset in the map. Default `fluixi:reset.css`. */
|
|
22
|
+
resetFrom?: string;
|
|
14
23
|
/** Produce a source map keyed to the passed-through author CSS. */
|
|
15
24
|
sourceMap?: boolean;
|
|
16
25
|
minify?: boolean;
|
|
17
26
|
}
|
|
27
|
+
export interface TransformStats {
|
|
28
|
+
/** Wall-clock milliseconds for this transform. */
|
|
29
|
+
ms: number;
|
|
30
|
+
/** Class tokens scanned (given + `@source` + inline). */
|
|
31
|
+
scanned: number;
|
|
32
|
+
/** Utility rules generated. */
|
|
33
|
+
utilities: number;
|
|
34
|
+
/** Output CSS byte length. */
|
|
35
|
+
bytes: number;
|
|
36
|
+
/** Files scanned via `@source`. */
|
|
37
|
+
sources: number;
|
|
38
|
+
}
|
|
18
39
|
export interface TransformResult {
|
|
19
40
|
css: string;
|
|
20
41
|
map?: RawSourceMap;
|
|
21
42
|
classes: string[];
|
|
22
43
|
sources: string[];
|
|
44
|
+
stats: TransformStats;
|
|
23
45
|
registry: Registry;
|
|
24
46
|
}
|
|
25
47
|
export declare function transform(input: string, options?: TransformOptions): TransformResult;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseCss } from '../css-parser';
|
|
2
|
+
import { expandApply } from './apply';
|
|
2
3
|
import { raw, stringify, stringifyWithMap } from './ast';
|
|
3
4
|
import { parseAtom } from './atom';
|
|
4
5
|
import { compileAtom } from './compile';
|
|
@@ -18,10 +19,15 @@ const MARKER = 'fluixi';
|
|
|
18
19
|
// directives are consumed, and an `@fluixi;` marker is replaced by the generated
|
|
19
20
|
// token `:root` + utilities. With no marker the generated block is appended.
|
|
20
21
|
export function transform(input, options = {}) {
|
|
21
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
23
|
+
const started = performance.now();
|
|
22
24
|
const reg = (_a = options.registry) !== null && _a !== void 0 ? _a : createRegistry();
|
|
23
|
-
|
|
25
|
+
if (options.theme)
|
|
26
|
+
loadTheme(options.theme, reg.theme);
|
|
27
|
+
loadTheme(input, reg.theme); // the input's own @theme overrides the base
|
|
24
28
|
registerBreakpointVariants(reg); // pick up any @theme breakpoint overrides
|
|
29
|
+
if (options.theme)
|
|
30
|
+
loadDirectives(options.theme, reg);
|
|
25
31
|
loadDirectives(input, reg);
|
|
26
32
|
const classes = new Set((_b = options.classes) !== null && _b !== void 0 ? _b : []);
|
|
27
33
|
for (const s of (_c = options.sources) !== null && _c !== void 0 ? _c : [])
|
|
@@ -74,20 +80,39 @@ export function transform(input, options = {}) {
|
|
|
74
80
|
const start = (_f = node.loc) === null || _f === void 0 ? void 0 : _f.start;
|
|
75
81
|
const end = (_g = node.loc) === null || _g === void 0 ? void 0 : _g.end;
|
|
76
82
|
if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {
|
|
77
|
-
|
|
83
|
+
const text = expandApply(input.slice(start.offset, end.offset), reg);
|
|
84
|
+
nodes.push(raw(text, { source: from, line: start.line, column: Math.max(0, start.column - 1) }));
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
if (!injected)
|
|
81
88
|
nodes.push(...generated);
|
|
89
|
+
const resetFrom = (_h = options.resetFrom) !== null && _h !== void 0 ? _h : 'fluixi:reset.css';
|
|
82
90
|
if (options.reset)
|
|
83
|
-
nodes.unshift(raw(options.reset));
|
|
91
|
+
nodes.unshift(raw(options.reset, { source: resetFrom, line: 1, column: 0 }));
|
|
92
|
+
let css;
|
|
93
|
+
let map;
|
|
84
94
|
if (options.sourceMap) {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
const out = stringifyWithMap(nodes, { minify: options.minify });
|
|
96
|
+
css = out.css;
|
|
97
|
+
out.map.setSourceContent(from, input);
|
|
98
|
+
if (options.reset)
|
|
99
|
+
out.map.setSourceContent(resetFrom, options.reset);
|
|
100
|
+
const json = out.map.toJSON();
|
|
88
101
|
json.file = from;
|
|
89
|
-
|
|
102
|
+
map = json;
|
|
90
103
|
}
|
|
91
|
-
|
|
104
|
+
else {
|
|
105
|
+
css = stringify(nodes, { minify: options.minify });
|
|
106
|
+
}
|
|
107
|
+
const stats = {
|
|
108
|
+
ms: performance.now() - started,
|
|
109
|
+
scanned: classes.size,
|
|
110
|
+
utilities: rules.length,
|
|
111
|
+
bytes: css.length,
|
|
112
|
+
sources: sources.length,
|
|
113
|
+
};
|
|
114
|
+
return map
|
|
115
|
+
? { css, map, classes: [...classes], sources, stats, registry: reg }
|
|
116
|
+
: { css, classes: [...classes], sources, stats, registry: reg };
|
|
92
117
|
}
|
|
93
118
|
//# sourceMappingURL=transform.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"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CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AAC9G,CAAC","sourcesContent":["import type { RawSourceMap } from 'source-map';\nimport { parseCss } from '../css-parser';\nimport { type AstNode, raw, stringify, stringifyWithMap } from './ast';\nimport { parseAtom } from './atom';\nimport { compileAtom } from './compile';\nimport { createRegistry } from './defaults';\nimport { loadDirectives } from './directives';\nimport { Registry } from './registry';\nimport { scanAtoms } from './scanner';\nimport { parseSources, resolveSourceFiles, scanSourceFiles } from './source';\nimport { registerBreakpointVariants } from './variants';\nimport { collectVarRefs, emitTheme, loadTheme } from './theme-source';\nimport { emitUiTheme } from './ui-preset';\n\n// Directives consumed to build the registry — dropped from the output.\nconst CONSUMED = new Set(['theme', 'utility', 'custom-variant', 'source']);\n// The at-rule that marks where generated tokens + utilities are spliced in.\nconst MARKER = 'fluixi';\n\nexport interface TransformOptions {\n registry?: Registry;\n classes?: string[];\n sources?: string[];\n base?: string;\n /** Filename of the input CSS, recorded in the source map. */\n from?: string;\n emitTokens?: boolean;\n emitUiTokens?: boolean;\n /** Reset CSS to prepend at the top of the sheet (baseline, before everything). */\n reset?: string;\n /** Produce a source map keyed to the passed-through author CSS. */\n sourceMap?: boolean;\n minify?: boolean;\n}\n\nexport interface TransformResult {\n css: string;\n map?: RawSourceMap;\n classes: string[];\n sources: string[];\n registry: Registry;\n}\n\n// Processes a whole stylesheet: the author's CSS passes through untouched (and\n// mapped back to source), the `@theme`/`@utility`/`@custom-variant`/`@source`\n// directives are consumed, and an `@fluixi;` marker is replaced by the generated\n// token `:root` + utilities. With no marker the generated block is appended.\nexport function transform(input: string, options: TransformOptions = {}): TransformResult {\n const reg = options.registry ?? createRegistry();\n loadTheme(input, reg.theme);\n registerBreakpointVariants(reg); // pick up any @theme breakpoint overrides\n loadDirectives(input, reg);\n\n const classes = new Set<string>(options.classes ?? []);\n for (const s of options.sources ?? []) for (const c of scanAtoms(s)) classes.add(c);\n const parsed = parseSources(input);\n for (const c of parsed.inline) classes.add(c);\n let sources: string[] = [];\n if (parsed.patterns.length) {\n sources = resolveSourceFiles(parsed, options.base ?? process.cwd());\n for (const c of scanSourceFiles(sources)) classes.add(c);\n }\n\n const rules: AstNode[] = [];\n for (const cls of classes) {\n const atom = parseAtom(cls, reg);\n if (!atom) continue;\n const compiled = compileAtom(atom, reg);\n if (compiled) rules.push(...compiled);\n }\n\n const uiBlock = options.emitUiTokens ? emitUiTheme(reg.theme) : null;\n\n const generated: AstNode[] = [];\n if (options.emitTokens !== false) {\n const used = collectVarRefs(rules);\n if (uiBlock) collectVarRefs([uiBlock], used);\n const tokens = emitTheme(reg.theme, ':root', used);\n if (tokens.nodes.length) generated.push(tokens);\n }\n if (uiBlock && uiBlock.nodes.length) generated.push(uiBlock);\n generated.push(...rules);\n\n const from = options.from ?? '<input>';\n const nodes: AstNode[] = [];\n let injected = false;\n for (const node of parseCss(input).children) {\n if (node.type === 'atrule' && node.name === MARKER) {\n if (!injected) {\n nodes.push(...generated);\n injected = true;\n }\n continue;\n }\n if (node.type === 'atrule' && node.name && CONSUMED.has(node.name)) continue;\n\n const start = node.loc?.start;\n const end = node.loc?.end;\n if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {\n nodes.push(raw(input.slice(start.offset, end.offset), { source: from, line: start.line, column: Math.max(0, start.column - 1) }));\n }\n }\n if (!injected) nodes.push(...generated);\n if (options.reset) nodes.unshift(raw(options.reset));\n\n if (options.sourceMap) {\n const { css, map } = stringifyWithMap(nodes, { minify: options.minify });\n map.setSourceContent(from, input);\n const json = map.toJSON();\n json.file = from;\n return { css, map: json, classes: [...classes], sources, registry: reg };\n }\n return { css: stringify(nodes, { minify: options.minify }), classes: [...classes], sources, registry: reg };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/engine/transform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,C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,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAChE,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;QACd,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACtC,IAAI,OAAO,CAAC,KAAK;YAAE,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACtE,MAAM,IAAI,GAAG,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,KAAK,GAAmB;QAC5B,EAAE,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,OAAO;QAC/B,OAAO,EAAE,OAAO,CAAC,IAAI;QACrB,SAAS,EAAE,KAAK,CAAC,MAAM;QACvB,KAAK,EAAE,GAAG,CAAC,MAAM;QACjB,OAAO,EAAE,OAAO,CAAC,MAAM;KACxB,CAAC;IACF,OAAO,GAAG;QACR,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE;QACpE,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,GAAG,OAAO,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC;AACpE,CAAC","sourcesContent":["import type { RawSourceMap } from 'source-map';\nimport { parseCss } from '../css-parser';\nimport { expandApply } from './apply';\nimport { type AstNode, raw, stringify, stringifyWithMap } from './ast';\nimport { parseAtom } from './atom';\nimport { compileAtom } from './compile';\nimport { createRegistry } from './defaults';\nimport { loadDirectives } from './directives';\nimport { Registry } from './registry';\nimport { scanAtoms } from './scanner';\nimport { parseSources, resolveSourceFiles, scanSourceFiles } from './source';\nimport { registerBreakpointVariants } from './variants';\nimport { collectVarRefs, emitTheme, loadTheme } from './theme-source';\nimport { emitUiTheme } from './ui-preset';\n\n// Directives consumed to build the registry — dropped from the output.\nconst CONSUMED = new Set(['theme', 'utility', 'custom-variant', 'source']);\n// The at-rule that marks where generated tokens + utilities are spliced in.\nconst MARKER = 'fluixi';\n\nexport interface TransformOptions {\n registry?: Registry;\n classes?: string[];\n sources?: string[];\n base?: string;\n /**\n * Shared base CSS whose `@theme` / `@utility` / `@custom-variant` are loaded\n * into the registry *before* the input's, so a per-route sheet inherits (and\n * can override) the global theme + custom utilities without redefining them.\n * Only the directives feed the registry — the base CSS itself isn't emitted.\n */\n theme?: string;\n /** Filename of the input CSS, recorded in the source map. */\n from?: string;\n emitTokens?: boolean;\n emitUiTokens?: boolean;\n /** Reset CSS to prepend at the top of the sheet (baseline, before everything). */\n reset?: string;\n /** Source name recorded for the reset in the map. Default `fluixi:reset.css`. */\n resetFrom?: string;\n /** Produce a source map keyed to the passed-through author CSS. */\n sourceMap?: boolean;\n minify?: boolean;\n}\n\nexport interface TransformStats {\n /** Wall-clock milliseconds for this transform. */\n ms: number;\n /** Class tokens scanned (given + `@source` + inline). */\n scanned: number;\n /** Utility rules generated. */\n utilities: number;\n /** Output CSS byte length. */\n bytes: number;\n /** Files scanned via `@source`. */\n sources: number;\n}\n\nexport interface TransformResult {\n css: string;\n map?: RawSourceMap;\n classes: string[];\n sources: string[];\n stats: TransformStats;\n registry: Registry;\n}\n\n// Processes a whole stylesheet: the author's CSS passes through untouched (and\n// mapped back to source), the `@theme`/`@utility`/`@custom-variant`/`@source`\n// directives are consumed, and an `@fluixi;` marker is replaced by the generated\n// token `:root` + utilities. With no marker the generated block is appended.\nexport function transform(input: string, options: TransformOptions = {}): TransformResult {\n const started = performance.now();\n const reg = options.registry ?? createRegistry();\n if (options.theme) loadTheme(options.theme, reg.theme);\n loadTheme(input, reg.theme); // the input's own @theme overrides the base\n registerBreakpointVariants(reg); // pick up any @theme breakpoint overrides\n if (options.theme) loadDirectives(options.theme, reg);\n loadDirectives(input, reg);\n\n const classes = new Set<string>(options.classes ?? []);\n for (const s of options.sources ?? []) for (const c of scanAtoms(s)) classes.add(c);\n const parsed = parseSources(input);\n for (const c of parsed.inline) classes.add(c);\n let sources: string[] = [];\n if (parsed.patterns.length) {\n sources = resolveSourceFiles(parsed, options.base ?? process.cwd());\n for (const c of scanSourceFiles(sources)) classes.add(c);\n }\n\n const rules: AstNode[] = [];\n for (const cls of classes) {\n const atom = parseAtom(cls, reg);\n if (!atom) continue;\n const compiled = compileAtom(atom, reg);\n if (compiled) rules.push(...compiled);\n }\n\n const uiBlock = options.emitUiTokens ? emitUiTheme(reg.theme) : null;\n\n const generated: AstNode[] = [];\n if (options.emitTokens !== false) {\n const used = collectVarRefs(rules);\n if (uiBlock) collectVarRefs([uiBlock], used);\n const tokens = emitTheme(reg.theme, ':root', used);\n if (tokens.nodes.length) generated.push(tokens);\n }\n if (uiBlock && uiBlock.nodes.length) generated.push(uiBlock);\n generated.push(...rules);\n\n const from = options.from ?? '<input>';\n const nodes: AstNode[] = [];\n let injected = false;\n for (const node of parseCss(input).children) {\n if (node.type === 'atrule' && node.name === MARKER) {\n if (!injected) {\n nodes.push(...generated);\n injected = true;\n }\n continue;\n }\n if (node.type === 'atrule' && node.name && CONSUMED.has(node.name)) continue;\n\n const start = node.loc?.start;\n const end = node.loc?.end;\n if (start && end && typeof start.offset === 'number' && typeof end.offset === 'number') {\n const text = expandApply(input.slice(start.offset, end.offset), reg);\n nodes.push(raw(text, { source: from, line: start.line, column: Math.max(0, start.column - 1) }));\n }\n }\n if (!injected) nodes.push(...generated);\n const resetFrom = options.resetFrom ?? 'fluixi:reset.css';\n if (options.reset) nodes.unshift(raw(options.reset, { source: resetFrom, line: 1, column: 0 }));\n\n let css: string;\n let map: RawSourceMap | undefined;\n if (options.sourceMap) {\n const out = stringifyWithMap(nodes, { minify: options.minify });\n css = out.css;\n out.map.setSourceContent(from, input);\n if (options.reset) out.map.setSourceContent(resetFrom, options.reset);\n const json = out.map.toJSON();\n json.file = from;\n map = json;\n } else {\n css = stringify(nodes, { minify: options.minify });\n }\n\n const stats: TransformStats = {\n ms: performance.now() - started,\n scanned: classes.size,\n utilities: rules.length,\n bytes: css.length,\n sources: sources.length,\n };\n return map\n ? { css, map, classes: [...classes], sources, stats, registry: reg }\n : { css, classes: [...classes], sources, stats, registry: reg };\n}\n"]}
|
|
@@ -28,5 +28,16 @@ export function registerBackgrounds(reg) {
|
|
|
28
28
|
'right-bottom': 'right bottom',
|
|
29
29
|
});
|
|
30
30
|
props(reg, 'background-image', { 'bg-none': 'none' });
|
|
31
|
+
// Form-control colours.
|
|
32
|
+
reg.dynamicRule('accent', ({ value, modifier, theme }) => {
|
|
33
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'auto')
|
|
34
|
+
return [decl('accent-color', 'auto')];
|
|
35
|
+
const c = colorValue(value, modifier, theme);
|
|
36
|
+
return c ? [decl('accent-color', c)] : null;
|
|
37
|
+
});
|
|
38
|
+
reg.dynamicRule('caret', ({ value, modifier, theme }) => {
|
|
39
|
+
const c = colorValue(value, modifier, theme);
|
|
40
|
+
return c ? [decl('caret-color', c)] : null;
|
|
41
|
+
});
|
|
31
42
|
}
|
|
32
43
|
//# sourceMappingURL=backgrounds.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backgrounds.js","sourceRoot":"","sources":["../../../../src/engine/utilities/backgrounds.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEvD,MAAM,UAAU,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AAG,EAAE,KAAK;QACV,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,UAAU;QACtB,WAAW,EAAE,WAAW;QACxB,aAAa,EAAE,aAAa;QAC5B,cAAc,EAAE,cAAc;KAC/B,CAAC,CAAC;IACH,KAAK,CAAC,GAAG,EAAE,kBAAkB,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAC;IAEtD,wBAAwB;IACxB,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACvD,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;YAAE,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7F,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,GAAG,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACtD,MAAM,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { Registry } from '../registry';\nimport { colorValue, keywords, props } from './values';\n\nexport function registerBackgrounds(reg: Registry): void {\n reg.dynamicRule('bg', ({ value, modifier, theme }) => {\n const c = colorValue(value, modifier, theme);\n return c ? [decl('background-color', c)] : null;\n });\n\n // Keyword forms of `bg-*` — these win over the colour root above.\n keywords(reg, 'bg', 'background-repeat', {\n repeat: 'repeat',\n 'no-repeat': 'no-repeat',\n 'repeat-x': 'repeat-x',\n 'repeat-y': 'repeat-y',\n 'repeat-round': 'round',\n 'repeat-space': 'space',\n });\n keywords(reg, 'bg', 'background-size', { auto: 'auto', cover: 'cover', contain: 'contain' });\n keywords(reg, 'bg', 'background-attachment', { fixed: 'fixed', local: 'local', scroll: 'scroll' });\n keywords(reg, 'bg', 'background-position', {\n center: 'center',\n top: 'top',\n bottom: 'bottom',\n left: 'left',\n right: 'right',\n 'left-top': 'left top',\n 'right-top': 'right top',\n 'left-bottom': 'left bottom',\n 'right-bottom': 'right bottom',\n });\n props(reg, 'background-image', { 'bg-none': 'none' });\n\n // Form-control colours.\n reg.dynamicRule('accent', ({ value, modifier, theme }) => {\n if (value?.kind === 'named' && value.value === 'auto') return [decl('accent-color', 'auto')];\n const c = colorValue(value, modifier, theme);\n return c ? [decl('accent-color', c)] : null;\n });\n reg.dynamicRule('caret', ({ value, modifier, theme }) => {\n const c = colorValue(value, modifier, theme);\n return c ? [decl('caret-color', c)] : null;\n });\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { decl } from '../ast';
|
|
1
|
+
import { decl, rule } from '../ast';
|
|
2
2
|
import { colorValue, keywords } from './values';
|
|
3
3
|
export function registerBorders(reg) {
|
|
4
4
|
border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);
|
|
@@ -18,6 +18,8 @@ export function registerBorders(reg) {
|
|
|
18
18
|
hidden: 'hidden',
|
|
19
19
|
none: 'none',
|
|
20
20
|
});
|
|
21
|
+
divide(reg);
|
|
22
|
+
ring(reg);
|
|
21
23
|
rounded(reg, 'rounded', ['']);
|
|
22
24
|
rounded(reg, 'rounded-t', ['-top-left', '-top-right']);
|
|
23
25
|
rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);
|
|
@@ -92,4 +94,61 @@ function outline(reg) {
|
|
|
92
94
|
return color ? [decl('outline-color', color)] : null;
|
|
93
95
|
});
|
|
94
96
|
}
|
|
97
|
+
// Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`
|
|
98
|
+
// set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the
|
|
99
|
+
// edge via a `--flx-divide-*-reverse` toggle.
|
|
100
|
+
const BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
|
|
101
|
+
function divide(reg) {
|
|
102
|
+
divideWidth(reg, 'x', 'border-right-width', 'border-left-width');
|
|
103
|
+
divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');
|
|
104
|
+
reg.dynamicRule('divide', ({ value, modifier, theme }) => {
|
|
105
|
+
if (value === null)
|
|
106
|
+
return null;
|
|
107
|
+
const style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;
|
|
108
|
+
if (style)
|
|
109
|
+
return [rule(BETWEEN, [decl('border-style', style)])];
|
|
110
|
+
const color = colorFor(value, modifier, theme);
|
|
111
|
+
return color ? [rule(BETWEEN, [decl('border-color', color)])] : null;
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
const DIVIDE_STYLES = {
|
|
115
|
+
solid: 'solid',
|
|
116
|
+
dashed: 'dashed',
|
|
117
|
+
dotted: 'dotted',
|
|
118
|
+
double: 'double',
|
|
119
|
+
none: 'none',
|
|
120
|
+
};
|
|
121
|
+
function divideWidth(reg, axis, reverseProp, mainProp) {
|
|
122
|
+
const flag = `--flx-divide-${axis}-reverse`;
|
|
123
|
+
reg.dynamicRule(`divide-${axis}`, ({ value }) => {
|
|
124
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse')
|
|
125
|
+
return [rule(BETWEEN, [decl(flag, '1')])];
|
|
126
|
+
const w = widthValue(value, '1px');
|
|
127
|
+
if (w === null)
|
|
128
|
+
return null;
|
|
129
|
+
return [
|
|
130
|
+
rule(BETWEEN, [
|
|
131
|
+
decl(flag, '0'),
|
|
132
|
+
decl(reverseProp, `calc(${w} * var(${flag}))`),
|
|
133
|
+
decl(mainProp, `calc(${w} * calc(1 - var(${flag})))`),
|
|
134
|
+
]),
|
|
135
|
+
];
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`
|
|
139
|
+
// (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.
|
|
140
|
+
function ring(reg) {
|
|
141
|
+
reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);
|
|
142
|
+
reg.dynamicRule('ring', ({ value, modifier, theme }) => {
|
|
143
|
+
const w = value === null ? '3px' : widthValue(value, null);
|
|
144
|
+
if (w !== null) {
|
|
145
|
+
return [
|
|
146
|
+
decl('--flx-ring-shadow', `var(--flx-ring-inset) 0 0 0 calc(${w} + var(--flx-ring-offset-width)) var(--flx-ring-color)`),
|
|
147
|
+
decl('box-shadow', 'var(--flx-ring-offset-shadow), var(--flx-ring-shadow), var(--flx-shadow, 0 0 #0000)'),
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
const color = colorFor(value, modifier, theme);
|
|
151
|
+
return color ? [decl('--flx-ring-color', color)] : null;
|
|
152
|
+
});
|
|
153
|
+
}
|
|
95
154
|
//# sourceMappingURL=borders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"borders.js","sourceRoot":"","sources":["../../../../src/engine/utilities/borders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,MAAM,QAAQ,CAAC;AAIhD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,UAAU,eAAe,CAAC,GAAa;IAC3C,MAAM,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,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AAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { type Declaration, decl } from '../ast';\nimport type { AtomModifier, AtomValue } from '../atom';\nimport type { Registry } from '../registry';\nimport { Theme } from '../theme';\nimport { colorValue, keywords } from './values';\n\nexport function registerBorders(reg: Registry): void {\n border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);\n border(reg, 'border-x', 'border', ['-left', '-right']);\n border(reg, 'border-y', 'border', ['-top', '-bottom']);\n border(reg, 'border-t', 'border', ['-top']);\n border(reg, 'border-r', 'border', ['-right']);\n border(reg, 'border-b', 'border', ['-bottom']);\n border(reg, 'border-l', 'border', ['-left']);\n border(reg, 'border-s', 'border', ['-inline-start']);\n border(reg, 'border-e', 'border', ['-inline-end']);\n\n keywords(reg, 'border', 'border-style', {\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n hidden: 'hidden',\n none: 'none',\n });\n\n rounded(reg, 'rounded', ['']);\n rounded(reg, 'rounded-t', ['-top-left', '-top-right']);\n rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);\n rounded(reg, 'rounded-b', ['-bottom-right', '-bottom-left']);\n rounded(reg, 'rounded-l', ['-top-left', '-bottom-left']);\n rounded(reg, 'rounded-tl', ['-top-left']);\n rounded(reg, 'rounded-tr', ['-top-right']);\n rounded(reg, 'rounded-br', ['-bottom-right']);\n rounded(reg, 'rounded-bl', ['-bottom-left']);\n\n outline(reg);\n}\n\n// `border`, `border-2`, `border-red-500`, `border-[#fff]`, `border-[2px]` all share\n// one root: a bare value or number is a width, a colour token/arbitrary is a colour.\nfunction border(reg: Registry, root: string, base: string, sides: string[]): void {\n reg.dynamicRule(root, ({ value, modifier, theme }) => {\n const width = widthValue(value, base === 'border' ? '1px' : null);\n if (width !== null) return sides.map((s) => decl(`${base}${s}-width`, width));\n const color = colorFor(value, modifier, theme);\n return color ? sides.map((s) => decl(`${base}${s}-color`, color)) : null;\n });\n}\n\nfunction widthValue(value: AtomValue | null, bare: string | null): string | null {\n if (value === null) return bare;\n if (value.kind === 'arbitrary') {\n if (value.dataType === 'length') return value.value;\n if (value.dataType === null && /^[\\d.]+(px|rem|em|%)$/.test(value.value)) return value.value;\n return null;\n }\n return /^\\d+$/.test(value.value) ? `${value.value}px` : null;\n}\n\nfunction colorFor(value: AtomValue | null, modifier: AtomModifier | null, theme: Theme): string | null {\n if (value?.kind === 'arbitrary' && value.dataType === 'length') return null;\n return colorValue(value, modifier, theme);\n}\n\nfunction rounded(reg: Registry, root: string, corners: string[]): void {\n reg.dynamicRule(root, ({ value, theme }) => {\n const r = radiusValue(value, theme);\n return r ? corners.map((c) => decl(`border${c}-radius`, r)) : null;\n });\n}\n\nfunction radiusValue(value: AtomValue | null, theme: Theme): string | null {\n if (value === null) return theme.resolve('radius', 'DEFAULT');\n if (value.kind === 'arbitrary') return value.value;\n if (value.value === 'none') return '0';\n if (value.value === 'full') return 'calc(infinity * 1px)';\n return theme.resolve('radius', value.value);\n}\n\nfunction outline(reg: Registry): void {\n keywords(reg, 'outline', 'outline-style', {\n none: 'none',\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n });\n reg.dynamicRule('outline', ({ value, modifier, theme }): Declaration[] | null => {\n if (value === null) return [decl('outline-style', 'solid')];\n const width = widthValue(value, null);\n if (width !== null) return [decl('outline-width', width)];\n const color = colorFor(value, modifier, theme);\n return color ? [decl('outline-color', color)] : null;\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"borders.js","sourceRoot":"","sources":["../../../../src/engine/utilities/borders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAItD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEhD,MAAM,UAAU,eAAe,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AAC,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QACrD,MAAM,CAAC,GAAG,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC3D,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;YACf,OAAO;gBACL,IAAI,CACF,mBAAmB,EACnB,oCAAoC,CAAC,wDAAwD,CAC9F;gBACD,IAAI,CACF,YAAY,EACZ,qFAAqF,CACtF;aACF,CAAC;QACJ,CAAC;QACD,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC/C,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { type Declaration, decl, rule } from '../ast';\nimport type { AtomModifier, AtomValue } from '../atom';\nimport type { Registry } from '../registry';\nimport { Theme } from '../theme';\nimport { colorValue, keywords } from './values';\n\nexport function registerBorders(reg: Registry): void {\n border(reg, 'border', 'border', ['-top', '-right', '-bottom', '-left']);\n border(reg, 'border-x', 'border', ['-left', '-right']);\n border(reg, 'border-y', 'border', ['-top', '-bottom']);\n border(reg, 'border-t', 'border', ['-top']);\n border(reg, 'border-r', 'border', ['-right']);\n border(reg, 'border-b', 'border', ['-bottom']);\n border(reg, 'border-l', 'border', ['-left']);\n border(reg, 'border-s', 'border', ['-inline-start']);\n border(reg, 'border-e', 'border', ['-inline-end']);\n\n keywords(reg, 'border', 'border-style', {\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n hidden: 'hidden',\n none: 'none',\n });\n\n divide(reg);\n ring(reg);\n\n rounded(reg, 'rounded', ['']);\n rounded(reg, 'rounded-t', ['-top-left', '-top-right']);\n rounded(reg, 'rounded-r', ['-top-right', '-bottom-right']);\n rounded(reg, 'rounded-b', ['-bottom-right', '-bottom-left']);\n rounded(reg, 'rounded-l', ['-top-left', '-bottom-left']);\n rounded(reg, 'rounded-tl', ['-top-left']);\n rounded(reg, 'rounded-tr', ['-top-right']);\n rounded(reg, 'rounded-br', ['-bottom-right']);\n rounded(reg, 'rounded-bl', ['-bottom-left']);\n\n outline(reg);\n}\n\n// `border`, `border-2`, `border-red-500`, `border-[#fff]`, `border-[2px]` all share\n// one root: a bare value or number is a width, a colour token/arbitrary is a colour.\nfunction border(reg: Registry, root: string, base: string, sides: string[]): void {\n reg.dynamicRule(root, ({ value, modifier, theme }) => {\n const width = widthValue(value, base === 'border' ? '1px' : null);\n if (width !== null) return sides.map((s) => decl(`${base}${s}-width`, width));\n const color = colorFor(value, modifier, theme);\n return color ? sides.map((s) => decl(`${base}${s}-color`, color)) : null;\n });\n}\n\nfunction widthValue(value: AtomValue | null, bare: string | null): string | null {\n if (value === null) return bare;\n if (value.kind === 'arbitrary') {\n if (value.dataType === 'length') return value.value;\n if (value.dataType === null && /^[\\d.]+(px|rem|em|%)$/.test(value.value)) return value.value;\n return null;\n }\n return /^\\d+$/.test(value.value) ? `${value.value}px` : null;\n}\n\nfunction colorFor(value: AtomValue | null, modifier: AtomModifier | null, theme: Theme): string | null {\n if (value?.kind === 'arbitrary' && value.dataType === 'length') return null;\n return colorValue(value, modifier, theme);\n}\n\nfunction rounded(reg: Registry, root: string, corners: string[]): void {\n reg.dynamicRule(root, ({ value, theme }) => {\n const r = radiusValue(value, theme);\n return r ? corners.map((c) => decl(`border${c}-radius`, r)) : null;\n });\n}\n\nfunction radiusValue(value: AtomValue | null, theme: Theme): string | null {\n if (value === null) return theme.resolve('radius', 'DEFAULT');\n if (value.kind === 'arbitrary') return value.value;\n if (value.value === 'none') return '0';\n if (value.value === 'full') return 'calc(infinity * 1px)';\n return theme.resolve('radius', value.value);\n}\n\nfunction outline(reg: Registry): void {\n keywords(reg, 'outline', 'outline-style', {\n none: 'none',\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n });\n reg.dynamicRule('outline', ({ value, modifier, theme }): Declaration[] | null => {\n if (value === null) return [decl('outline-style', 'solid')];\n const width = widthValue(value, null);\n if (width !== null) return [decl('outline-width', width)];\n const color = colorFor(value, modifier, theme);\n return color ? [decl('outline-color', color)] : null;\n });\n}\n\n// Borders *between* children (adjacent-sibling combinator). `divide-x`/`divide-y`\n// set the width, `divide-{color}`/`divide-{style}` the rest; `-reverse` flips the\n// edge via a `--flx-divide-*-reverse` toggle.\nconst BETWEEN = '& > :not([hidden]) ~ :not([hidden])';\n\nfunction divide(reg: Registry): void {\n divideWidth(reg, 'x', 'border-right-width', 'border-left-width');\n divideWidth(reg, 'y', 'border-top-width', 'border-bottom-width');\n\n reg.dynamicRule('divide', ({ value, modifier, theme }) => {\n if (value === null) return null;\n const style = value.kind === 'named' ? DIVIDE_STYLES[value.value] : undefined;\n if (style) return [rule(BETWEEN, [decl('border-style', style)])];\n const color = colorFor(value, modifier, theme);\n return color ? [rule(BETWEEN, [decl('border-color', color)])] : null;\n });\n}\n\nconst DIVIDE_STYLES: Record<string, string> = {\n solid: 'solid',\n dashed: 'dashed',\n dotted: 'dotted',\n double: 'double',\n none: 'none',\n};\n\nfunction divideWidth(reg: Registry, axis: 'x' | 'y', reverseProp: string, mainProp: string): void {\n const flag = `--flx-divide-${axis}-reverse`;\n reg.dynamicRule(`divide-${axis}`, ({ value }) => {\n if (value?.kind === 'named' && value.value === 'reverse') return [rule(BETWEEN, [decl(flag, '1')])];\n const w = widthValue(value, '1px');\n if (w === null) return null;\n return [\n rule(BETWEEN, [\n decl(flag, '0'),\n decl(reverseProp, `calc(${w} * var(${flag}))`),\n decl(mainProp, `calc(${w} * calc(1 - var(${flag})))`),\n ]),\n ];\n });\n}\n\n// A focus/selection ring drawn as a box-shadow, composed through `--flx-ring-*`\n// (declared in reset.css) so `ring`, `ring-{color}` and `ring-inset` stack.\nfunction ring(reg: Registry): void {\n reg.rule('ring-inset', [decl('--flx-ring-inset', 'inset')]);\n reg.dynamicRule('ring', ({ value, modifier, theme }) => {\n const w = value === null ? '3px' : widthValue(value, null);\n if (w !== null) {\n return [\n decl(\n '--flx-ring-shadow',\n `var(--flx-ring-inset) 0 0 0 calc(${w} + var(--flx-ring-offset-width)) var(--flx-ring-color)`,\n ),\n decl(\n 'box-shadow',\n 'var(--flx-ring-offset-shadow), var(--flx-ring-shadow), var(--flx-shadow, 0 0 #0000)',\n ),\n ];\n }\n const color = colorFor(value, modifier, theme);\n return color ? [decl('--flx-ring-color', color)] : null;\n });\n}\n"]}
|
|
@@ -65,6 +65,31 @@ export function registerLayout(reg) {
|
|
|
65
65
|
return [decl('z-index', 'auto')];
|
|
66
66
|
return /^\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;
|
|
67
67
|
});
|
|
68
|
+
reg.dynamicRule('columns', ({ value }) => {
|
|
69
|
+
if (!value)
|
|
70
|
+
return null;
|
|
71
|
+
if (value.kind === 'arbitrary')
|
|
72
|
+
return [decl('columns', value.value)];
|
|
73
|
+
if (value.value === 'auto' || /^\d+$/.test(value.value))
|
|
74
|
+
return [decl('columns', value.value)];
|
|
75
|
+
return null;
|
|
76
|
+
});
|
|
77
|
+
// Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`
|
|
78
|
+
// (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.
|
|
79
|
+
props(reg, 'scroll-snap-type', {
|
|
80
|
+
'snap-none': 'none',
|
|
81
|
+
'snap-x': 'x var(--flx-scroll-snap-strictness)',
|
|
82
|
+
'snap-y': 'y var(--flx-scroll-snap-strictness)',
|
|
83
|
+
'snap-both': 'both var(--flx-scroll-snap-strictness)',
|
|
84
|
+
});
|
|
85
|
+
props(reg, '--flx-scroll-snap-strictness', { 'snap-mandatory': 'mandatory', 'snap-proximity': 'proximity' });
|
|
86
|
+
props(reg, 'scroll-snap-align', {
|
|
87
|
+
'snap-start': 'start',
|
|
88
|
+
'snap-end': 'end',
|
|
89
|
+
'snap-center': 'center',
|
|
90
|
+
'snap-align-none': 'none',
|
|
91
|
+
});
|
|
92
|
+
props(reg, 'scroll-snap-stop', { 'snap-normal': 'normal', 'snap-always': 'always' });
|
|
68
93
|
}
|
|
69
94
|
const OVERFLOW = {
|
|
70
95
|
auto: 'auto',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../../src/engine/utilities/layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAEtD,MAAM,UAAU,cAAc,CAAC,GAAa;IAC1C,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE;QACpB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,cAAc,EAAE,cAAc;QAC9B,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,aAAa;QAC5B,IAAI,EAAE,MAAM;QACZ,aAAa,EAAE,aAAa;QAC5B,KAAK,EAAE,OAAO;QACd,WAAW,EAAE,WAAW;QACxB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IAEH,KAAK,CAAC,GAAG,EAAE,UAAU,EAAE;QACrB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,UAAU;QACpB,QAAQ,EAAE,UAAU;QACpB,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC;IAEH,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAChD,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;IACpD,QAAQ,CAAC,GAAG,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,CAAC,CA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W,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,EAAE;QAC7D,IAAI,CAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,MAAK,OAAO,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAChG,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { decl } from '../ast';\nimport type { Registry } from '../registry';\nimport { keywords, props, sizeValue } from './values';\n\nexport function registerLayout(reg: Registry): void {\n props(reg, 'display', {\n block: 'block',\n inline: 'inline',\n 'inline-block': 'inline-block',\n flex: 'flex',\n 'inline-flex': 'inline-flex',\n grid: 'grid',\n 'inline-grid': 'inline-grid',\n table: 'table',\n 'flow-root': 'flow-root',\n contents: 'contents',\n hidden: 'none',\n });\n\n props(reg, 'position', {\n static: 'static',\n fixed: 'fixed',\n absolute: 'absolute',\n relative: 'relative',\n sticky: 'sticky',\n });\n\n keywords(reg, 'overflow', 'overflow', OVERFLOW);\n keywords(reg, 'overflow-x', 'overflow-x', OVERFLOW);\n keywords(reg, 'overflow-y', 'overflow-y', OVERFLOW);\n\n props(reg, 'visibility', { visible: 'visible', invisible: 'hidden', collapse: 'collapse' });\n keywords(reg, 'box', 'box-sizing', { border: 'border-box', content: 'content-box' });\n props(reg, 'isolation', { isolate: 'isolate', 'isolation-auto': 'auto' });\n\n keywords(reg, 'object', 'object-fit', {\n contain: 'contain',\n cover: 'cover',\n fill: 'fill',\n none: 'none',\n 'scale-down': 'scale-down',\n });\n keywords(reg, 'object', 'object-position', {\n top: 'top',\n bottom: 'bottom',\n center: 'center',\n left: 'left',\n right: 'right',\n 'left-top': 'left top',\n 'right-top': 'right top',\n 'left-bottom': 'left bottom',\n 'right-bottom': 'right bottom',\n });\n\n keywords(reg, 'float', 'float', { start: 'inline-start', end: 'inline-end', left: 'left', right: 'right', none: 'none' });\n keywords(reg, 'clear', 'clear', { start: 'inline-start', end: 'inline-end', left: 'left', right: 'right', both: 'both', none: 'none' });\n\n inset(reg, 'inset', ['top', 'right', 'bottom', 'left']);\n inset(reg, 'inset-x', ['left', 'right']);\n inset(reg, 'inset-y', ['top', 'bottom']);\n inset(reg, 'top', ['top']);\n inset(reg, 'right', ['right']);\n inset(reg, 'bottom', ['bottom']);\n inset(reg, 'left', ['left']);\n inset(reg, 'start', ['inset-inline-start']);\n inset(reg, 'end', ['inset-inline-end']);\n\n reg.dynamicRule('z', ({ value }) => {\n if (!value) return null;\n if (value.kind === 'arbitrary') return [decl('z-index', value.value)];\n if (value.value === 'auto') return [decl('z-index', 'auto')];\n return /^\\d+$/.test(value.value) ? [decl('z-index', value.value)] : null;\n });\n\n reg.dynamicRule('columns', ({ value }) => {\n if (!value) return null;\n if (value.kind === 'arbitrary') return [decl('columns', value.value)];\n if (value.value === 'auto' || /^\\d+$/.test(value.value)) return [decl('columns', value.value)];\n return null;\n });\n\n // Scroll snapping. The axis utilities read `--flx-scroll-snap-strictness`\n // (reset.css defaults it to `proximity`), so `snap-x snap-mandatory` composes.\n props(reg, 'scroll-snap-type', {\n 'snap-none': 'none',\n 'snap-x': 'x var(--flx-scroll-snap-strictness)',\n 'snap-y': 'y var(--flx-scroll-snap-strictness)',\n 'snap-both': 'both var(--flx-scroll-snap-strictness)',\n });\n props(reg, '--flx-scroll-snap-strictness', { 'snap-mandatory': 'mandatory', 'snap-proximity': 'proximity' });\n props(reg, 'scroll-snap-align', {\n 'snap-start': 'start',\n 'snap-end': 'end',\n 'snap-center': 'center',\n 'snap-align-none': 'none',\n });\n props(reg, 'scroll-snap-stop', { 'snap-normal': 'normal', 'snap-always': 'always' });\n}\n\nconst OVERFLOW: Record<string, string> = {\n auto: 'auto',\n hidden: 'hidden',\n clip: 'clip',\n visible: 'visible',\n scroll: 'scroll',\n};\n\nfunction inset(reg: Registry, root: string, props: string[]): void {\n reg.dynamicRule(root, ({ value, negative, modifier, theme }) => {\n if (value?.kind === 'named' && value.value === 'auto') return props.map((p) => decl(p, 'auto'));\n const v = sizeValue(value, theme, { negative, modifier });\n return v ? props.map((p) => decl(p, v)) : null;\n });\n}\n"]}
|
|
@@ -1,8 +1,32 @@
|
|
|
1
|
-
import { decl } from '../ast';
|
|
1
|
+
import { decl, rule } from '../ast';
|
|
2
2
|
import { sizeValue } from './values';
|
|
3
3
|
export function registerSpacing(reg) {
|
|
4
4
|
for (const [root, props] of Object.entries(SPACING))
|
|
5
5
|
spacing(reg, root, props, root[0] === 'm');
|
|
6
|
+
spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');
|
|
7
|
+
spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');
|
|
8
|
+
}
|
|
9
|
+
// Only the space *between* siblings, applied to every child after the first via
|
|
10
|
+
// the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the
|
|
11
|
+
// margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).
|
|
12
|
+
const BETWEEN = '& > :not([hidden]) ~ :not([hidden])';
|
|
13
|
+
function spaceBetween(reg, axis, startProp, endProp) {
|
|
14
|
+
const flag = `--flx-space-${axis}-reverse`;
|
|
15
|
+
reg.dynamicRule(`space-${axis}`, ({ value, negative, theme }) => {
|
|
16
|
+
if ((value === null || value === void 0 ? void 0 : value.kind) === 'named' && value.value === 'reverse') {
|
|
17
|
+
return [rule(BETWEEN, [decl(flag, '1')])];
|
|
18
|
+
}
|
|
19
|
+
const v = sizeValue(value, theme, { negative });
|
|
20
|
+
if (!v)
|
|
21
|
+
return null;
|
|
22
|
+
return [
|
|
23
|
+
rule(BETWEEN, [
|
|
24
|
+
decl(flag, '0'),
|
|
25
|
+
decl(startProp, `calc(${v} * calc(1 - var(${flag})))`),
|
|
26
|
+
decl(endProp, `calc(${v} * var(${flag}))`),
|
|
27
|
+
]),
|
|
28
|
+
];
|
|
29
|
+
});
|
|
6
30
|
}
|
|
7
31
|
// `px`/`py` expand to the physical left/right, top/bottom pair (not the logical
|
|
8
32
|
// `padding-inline`) to match established output; `ps`/`pe` use the logical edges.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spacing.js","sourceRoot":"","sources":["../../../../src/engine/utilities/spacing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"spacing.js","sourceRoot":"","sources":["../../../../src/engine/utilities/spacing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,MAAM,UAAU,eAAe,CAAC,GAAa;IAC3C,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;IAChG,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,qBAAqB,EAAE,mBAAmB,CAAC,CAAC;IACnE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,YAAY,EAAE,eAAe,CAAC,CAAC;AACxD,CAAC;AAED,gFAAgF;AAChF,kFAAkF;AAClF,iFAAiF;AACjF,MAAM,OAAO,GAAG,qCAAqC,CAAC;AAEtD,SAAS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ast';\nimport type { Registry } from '../registry';\nimport { sizeValue } from './values';\n\nexport function registerSpacing(reg: Registry): void {\n for (const [root, props] of Object.entries(SPACING)) spacing(reg, root, props, root[0] === 'm');\n spaceBetween(reg, 'x', 'margin-inline-start', 'margin-inline-end');\n spaceBetween(reg, 'y', 'margin-top', 'margin-bottom');\n}\n\n// Only the space *between* siblings, applied to every child after the first via\n// the adjacent-sibling combinator. `space-x-reverse` flips which edge carries the\n// margin (a `--flx-space-*-reverse` toggle, so it composes with the value util).\nconst BETWEEN = '& > :not([hidden]) ~ :not([hidden])';\n\nfunction spaceBetween(reg: Registry, axis: 'x' | 'y', startProp: string, endProp: string): void {\n const flag = `--flx-space-${axis}-reverse`;\n reg.dynamicRule(`space-${axis}`, ({ value, negative, theme }) => {\n if (value?.kind === 'named' && value.value === 'reverse') {\n return [rule(BETWEEN, [decl(flag, '1')])];\n }\n const v = sizeValue(value, theme, { negative });\n if (!v) return null;\n return [\n rule(BETWEEN, [\n decl(flag, '0'),\n decl(startProp, `calc(${v} * calc(1 - var(${flag})))`),\n decl(endProp, `calc(${v} * var(${flag}))`),\n ]),\n ];\n });\n}\n\n// `px`/`py` expand to the physical left/right, top/bottom pair (not the logical\n// `padding-inline`) to match established output; `ps`/`pe` use the logical edges.\nconst SPACING: Record<string, string[]> = {\n p: ['padding'],\n px: ['padding-left', 'padding-right'],\n py: ['padding-top', 'padding-bottom'],\n ps: ['padding-inline-start'],\n pe: ['padding-inline-end'],\n pt: ['padding-top'],\n pr: ['padding-right'],\n pb: ['padding-bottom'],\n pl: ['padding-left'],\n m: ['margin'],\n mx: ['margin-left', 'margin-right'],\n my: ['margin-top', 'margin-bottom'],\n ms: ['margin-inline-start'],\n me: ['margin-inline-end'],\n mt: ['margin-top'],\n mr: ['margin-right'],\n mb: ['margin-bottom'],\n ml: ['margin-left'],\n 'scroll-m': ['scroll-margin'],\n 'scroll-p': ['scroll-padding'],\n};\n\nfunction spacing(reg: Registry, root: string, props: string[], allowAuto: boolean): void {\n reg.dynamicRule(root, ({ value, negative, theme }) => {\n if (allowAuto && value?.kind === 'named' && value.value === 'auto') return props.map((p) => decl(p, 'auto'));\n const v = sizeValue(value, theme, { negative });\n return v ? props.map((p) => decl(p, v)) : null;\n });\n}\n"]}
|
|
@@ -77,6 +77,13 @@ export function registerTypography(reg) {
|
|
|
77
77
|
const t = (value === null || value === void 0 ? void 0 : value.kind) === 'named' ? TRACKING[value.value] : null;
|
|
78
78
|
return t ? [decl('letter-spacing', t)] : null;
|
|
79
79
|
});
|
|
80
|
+
reg.dynamicRule('content', ({ value }) => {
|
|
81
|
+
if (!value)
|
|
82
|
+
return null;
|
|
83
|
+
if (value.kind === 'arbitrary')
|
|
84
|
+
return [decl('content', value.value)];
|
|
85
|
+
return value.value === 'none' ? [decl('content', 'none')] : null;
|
|
86
|
+
});
|
|
80
87
|
}
|
|
81
88
|
const WEIGHTS = {
|
|
82
89
|
thin: '100',
|