chaincss 2.1.31 → 2.1.33
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/README.md +28 -33
- package/dist/cli/index.js +2 -2
- package/dist/compiler/btt.d.ts +2 -8
- package/dist/compiler/recipe.d.ts +1 -6
- package/dist/core/types.d.ts +3 -1
- package/dist/index.js +2 -2
- package/dist/plugins/vite.js +2 -2
- package/dist/runtime/injector.d.ts +4 -4
- package/package.json +4 -4
- package/src/compiler/btt.ts +3 -8
- package/src/compiler/recipe.ts +1 -6
- package/src/core/compiler.ts +2 -2
- package/src/core/types.ts +3 -1
- package/src/runtime/injector.ts +6 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<h1 align="center"
|
|
1
|
+
<h1 align="center">ChainCSS</h1>
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<strong>The first CSS-in-JS library with true auto-detection mixed mode.</strong><br>
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
</a>
|
|
21
21
|
</p>
|
|
22
22
|
|
|
23
|
-
---
|
|
24
23
|
|
|
25
24
|
# What is ChainCSS?
|
|
26
25
|
|
|
@@ -47,7 +46,6 @@ const card = chain()
|
|
|
47
46
|
|
|
48
47
|
**No CSS syntax. No template literals. No object literals. Just JavaScript.**
|
|
49
48
|
|
|
50
|
-
---
|
|
51
49
|
|
|
52
50
|
# Installation
|
|
53
51
|
|
|
@@ -64,6 +62,7 @@ npm install chaincss
|
|
|
64
62
|
| **Browser CDN** | `import { chain } from "https://cdn.jsdelivr.net/npm/chaincss/dist/browser.js"` |
|
|
65
63
|
| **Browser + import map** | Map `"chaincss"` to `./node_modules/chaincss/dist/browser.js` |
|
|
66
64
|
|
|
65
|
+
|
|
67
66
|
## Vite Configuration
|
|
68
67
|
|
|
69
68
|
```ts
|
|
@@ -76,7 +75,6 @@ export default defineConfig({
|
|
|
76
75
|
});
|
|
77
76
|
```
|
|
78
77
|
|
|
79
|
-
---
|
|
80
78
|
|
|
81
79
|
# Core API
|
|
82
80
|
|
|
@@ -121,7 +119,6 @@ const heading = chain()
|
|
|
121
119
|
injectChainStyles({ heading });
|
|
122
120
|
```
|
|
123
121
|
|
|
124
|
-
---
|
|
125
122
|
|
|
126
123
|
# Feature Reference
|
|
127
124
|
|
|
@@ -145,6 +142,7 @@ chain()
|
|
|
145
142
|
.pos("relative");
|
|
146
143
|
```
|
|
147
144
|
|
|
145
|
+
|
|
148
146
|
## Macros (57)
|
|
149
147
|
|
|
150
148
|
### Layout & Display
|
|
@@ -292,7 +290,7 @@ chain()
|
|
|
292
290
|
.$el("responsive");
|
|
293
291
|
```
|
|
294
292
|
|
|
295
|
-
**Built-in breakpoints:** `sm`, `md`, `lg`, `xl`, `2xl`, `mobile`, `tablet`, `desktop`, `portrait`, `landscape`, `dark`, `light`, `reducedMotion`, `highContrast`, `print`, `hover`, `no-hover`, `fine`, `coarse`
|
|
293
|
+
**Built-in breakpoints (20):** `sm`, `md`, `lg`, `xl`, `2xl`, `mobile`, `tablet`, `desktop`, `portrait`, `landscape`, `dark`, `light`, `reducedMotion`, `highContrast`, `print`, `hover`, `no-hover`, `fine`, `coarse`
|
|
296
294
|
|
|
297
295
|
## Transform Methods
|
|
298
296
|
|
|
@@ -306,7 +304,7 @@ chain()
|
|
|
306
304
|
.$el("transformed");
|
|
307
305
|
```
|
|
308
306
|
|
|
309
|
-
### Math Helpers
|
|
307
|
+
### Math Helpers (15)
|
|
310
308
|
|
|
311
309
|
```ts
|
|
312
310
|
chain()
|
|
@@ -358,22 +356,33 @@ const theme = new Theme(light);
|
|
|
358
356
|
theme.toCSSVariables("my-theme"); // -> :root { --my-theme-colors-primary: #3b82f6; ... }
|
|
359
357
|
```
|
|
360
358
|
|
|
361
|
-
## Recipe System
|
|
359
|
+
## Recipe System (Variants)
|
|
362
360
|
|
|
363
361
|
```ts
|
|
364
362
|
import { recipe } from "chaincss";
|
|
365
363
|
|
|
366
364
|
const button = recipe({
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
365
|
+
base: { selectors: ["btn"], display: "inline-flex", borderRadius: "8px", fontWeight: 600 },
|
|
366
|
+
variants: {
|
|
367
|
+
size: {
|
|
368
|
+
sm: { padding: "8px 16px", fontSize: "14px" },
|
|
369
|
+
lg: { padding: "16px 32px", fontSize: "18px" },
|
|
370
|
+
},
|
|
371
|
+
color: {
|
|
372
|
+
primary: { background: "#3b82f6", color: "white" },
|
|
373
|
+
danger: { background: "#ef4444", color: "white" },
|
|
374
|
+
},
|
|
375
|
+
},
|
|
376
|
+
defaultVariants: { size: "md", color: "primary" },
|
|
377
|
+
compoundVariants: [
|
|
378
|
+
{ variants: { size: "lg", color: "primary" }, style: { fontWeight: 800 } },
|
|
379
|
+
],
|
|
373
380
|
});
|
|
381
|
+
|
|
382
|
+
const styles = button({ size: "lg", color: "danger" });
|
|
374
383
|
```
|
|
375
384
|
|
|
376
|
-
### Animations
|
|
385
|
+
### Animations (42 presets)
|
|
377
386
|
|
|
378
387
|
```ts
|
|
379
388
|
chain().fadeIn().$el("el"); chain().slideInUp().$el("el"); chain().slideInUp().$el("el");
|
|
@@ -409,7 +418,6 @@ const diff = getStyleDiff(snapshotId1, snapshotId2);
|
|
|
409
418
|
// -> { added: {...}, removed: {...}, modified: {...} }
|
|
410
419
|
```
|
|
411
420
|
|
|
412
|
-
---
|
|
413
421
|
|
|
414
422
|
# CLI
|
|
415
423
|
|
|
@@ -422,7 +430,6 @@ chaincss cache stats
|
|
|
422
430
|
chaincss timeline list
|
|
423
431
|
```
|
|
424
432
|
|
|
425
|
-
---
|
|
426
433
|
|
|
427
434
|
# Configuration
|
|
428
435
|
|
|
@@ -455,7 +462,6 @@ export default {
|
|
|
455
462
|
};
|
|
456
463
|
```
|
|
457
464
|
|
|
458
|
-
---
|
|
459
465
|
|
|
460
466
|
# Framework Integration
|
|
461
467
|
|
|
@@ -484,11 +490,8 @@ function Card() {
|
|
|
484
490
|
```ts
|
|
485
491
|
import { chain } from "chaincss";
|
|
486
492
|
|
|
487
|
-
const styles = chain()
|
|
488
|
-
|
|
489
|
-
.cols(3)
|
|
490
|
-
.gap(16)
|
|
491
|
-
.$el("grid");
|
|
493
|
+
const styles = chain().display("grid").cols(3).gap(16).$el("grid");
|
|
494
|
+
// <div :class="styles.selectors[0]">
|
|
492
495
|
```
|
|
493
496
|
|
|
494
497
|
## Svelte
|
|
@@ -496,10 +499,8 @@ const styles = chain()
|
|
|
496
499
|
```ts
|
|
497
500
|
import { chain } from "chaincss";
|
|
498
501
|
|
|
499
|
-
const styles = chain()
|
|
500
|
-
|
|
501
|
-
.center()
|
|
502
|
-
.$el("centered");
|
|
502
|
+
const styles = chain().flex().center().$el("centered");
|
|
503
|
+
// <div class={styles.selectors[0]}>
|
|
503
504
|
```
|
|
504
505
|
|
|
505
506
|
### Vanilla JS
|
|
@@ -519,7 +520,6 @@ const styles = chain()
|
|
|
519
520
|
</script>
|
|
520
521
|
```
|
|
521
522
|
|
|
522
|
-
---
|
|
523
523
|
|
|
524
524
|
## Complete Feature List
|
|
525
525
|
|
|
@@ -541,9 +541,6 @@ const styles = chain()
|
|
|
541
541
|
| Dev Tools | 3 | Suggestions Engine, Timeline, Component Generator |
|
|
542
542
|
| Tests | 258 | 18 test files, 0 failures |
|
|
543
543
|
|
|
544
|
-
---
|
|
545
|
-
|
|
546
|
-
---
|
|
547
544
|
|
|
548
545
|
# Performance
|
|
549
546
|
|
|
@@ -553,7 +550,6 @@ const styles = chain()
|
|
|
553
550
|
- LRU persistent caching
|
|
554
551
|
- Shared property deduplication
|
|
555
552
|
|
|
556
|
-
---
|
|
557
553
|
|
|
558
554
|
# Contributing
|
|
559
555
|
|
|
@@ -567,7 +563,6 @@ npm install
|
|
|
567
563
|
npm test
|
|
568
564
|
```
|
|
569
565
|
|
|
570
|
-
---
|
|
571
566
|
|
|
572
567
|
# License
|
|
573
568
|
|
package/dist/cli/index.js
CHANGED
|
@@ -2639,13 +2639,13 @@ var init_compiler = __esm({
|
|
|
2639
2639
|
init_cache_manager();
|
|
2640
2640
|
init_content_addressable_cache();
|
|
2641
2641
|
init_shorthands();
|
|
2642
|
-
__filename = (() => {
|
|
2642
|
+
__filename = typeof import.meta !== "undefined" ? (() => {
|
|
2643
2643
|
try {
|
|
2644
2644
|
return fileURLToPath(import.meta.url);
|
|
2645
2645
|
} catch {
|
|
2646
2646
|
return "";
|
|
2647
2647
|
}
|
|
2648
|
-
})();
|
|
2648
|
+
})() : "";
|
|
2649
2649
|
__dirname = __filename ? path6.dirname(__filename) : "";
|
|
2650
2650
|
ChainCSSCompiler = class {
|
|
2651
2651
|
config;
|
package/dist/compiler/btt.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { DesignTokens } from './tokens.js';
|
|
6
6
|
import type { AtomicOptimizer } from './atomic-optimizer.js';
|
|
7
|
+
import type { StyleDefinition } from '../core/types.js';
|
|
8
|
+
export type { StyleDefinition };
|
|
7
9
|
export { setBreakpoints } from './breakpoints.js';
|
|
8
10
|
export { chain, enableDebug } from './Chain.js';
|
|
9
11
|
export { enableTimeline, getStyleHistory, getStyleChanges, getStyleDiff, exportTimeline, clearTimeline, takeSnapshot, isTimelineEnabled } from './timeline.js';
|
|
@@ -48,14 +50,6 @@ export interface ThemeBlock {
|
|
|
48
50
|
tokens: any;
|
|
49
51
|
fallback: any;
|
|
50
52
|
}
|
|
51
|
-
export interface StyleDefinition {
|
|
52
|
-
selectors: string[];
|
|
53
|
-
hover?: Record<string, string | number>;
|
|
54
|
-
atRules?: AtRule[];
|
|
55
|
-
nestedRules?: NestedRule[];
|
|
56
|
-
themes?: ThemeBlock[];
|
|
57
|
-
[cssProperty: string]: any;
|
|
58
|
-
}
|
|
59
53
|
export declare const run: (...args: any[]) => string;
|
|
60
54
|
export declare const compile: (obj: Record<string, StyleDefinition>) => string;
|
|
61
55
|
export { atomicOptimizer, chains as chainObject };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
selectors: string[];
|
|
3
|
-
hover?: Record<string, string | number>;
|
|
4
|
-
[key: string]: any;
|
|
5
|
-
}
|
|
1
|
+
import type { StyleDefinition } from '../core/types.js';
|
|
6
2
|
export interface RecipeOptions<TVariants extends Record<string, Record<string, any>>> {
|
|
7
3
|
base?: StyleDefinition | (() => StyleDefinition);
|
|
8
4
|
variants?: TVariants;
|
|
@@ -32,4 +28,3 @@ export type Recipe<TVariants extends Record<string, Record<string, any>>> = {
|
|
|
32
28
|
getVariantClassNames: () => Record<string, string>;
|
|
33
29
|
};
|
|
34
30
|
export declare function recipe<TVariants extends Record<string, Record<string, any>>>(options: RecipeOptions<TVariants>): Recipe<TVariants>;
|
|
35
|
-
export {};
|
package/dist/core/types.d.ts
CHANGED
|
@@ -12,8 +12,10 @@ export interface StyleDefinition {
|
|
|
12
12
|
_generateComponent?: boolean;
|
|
13
13
|
_framework?: 'react' | 'vue' | 'svelte' | 'solid' | 'auto';
|
|
14
14
|
_propsDefinition?: Record<string, any>;
|
|
15
|
-
/** Explicit bucket for custom CSS properties
|
|
15
|
+
/** Explicit bucket for custom CSS properties */
|
|
16
16
|
customProperties?: Record<string, string | number>;
|
|
17
|
+
/** Allow arbitrary CSS properties */
|
|
18
|
+
[cssProperty: string]: any;
|
|
17
19
|
}
|
|
18
20
|
export interface AtRule {
|
|
19
21
|
type: 'media' | 'keyframes' | 'font-face' | 'supports' | 'container' | 'layer' | 'counter-style' | 'property';
|
package/dist/index.js
CHANGED
|
@@ -6077,13 +6077,13 @@ var PersistentCache = class {
|
|
|
6077
6077
|
};
|
|
6078
6078
|
|
|
6079
6079
|
// src/core/compiler.ts
|
|
6080
|
-
var __filename = (() => {
|
|
6080
|
+
var __filename = typeof import.meta !== "undefined" ? (() => {
|
|
6081
6081
|
try {
|
|
6082
6082
|
return fileURLToPath(import.meta.url);
|
|
6083
6083
|
} catch {
|
|
6084
6084
|
return "";
|
|
6085
6085
|
}
|
|
6086
|
-
})();
|
|
6086
|
+
})() : "";
|
|
6087
6087
|
var __dirname = __filename ? path5.dirname(__filename) : "";
|
|
6088
6088
|
var ChainCSSCompiler = class {
|
|
6089
6089
|
config;
|
package/dist/plugins/vite.js
CHANGED
|
@@ -2531,13 +2531,13 @@ var PersistentCache = class {
|
|
|
2531
2531
|
};
|
|
2532
2532
|
|
|
2533
2533
|
// src/core/compiler.ts
|
|
2534
|
-
var __filename = (() => {
|
|
2534
|
+
var __filename = typeof import.meta !== "undefined" ? (() => {
|
|
2535
2535
|
try {
|
|
2536
2536
|
return fileURLToPath(import.meta.url);
|
|
2537
2537
|
} catch {
|
|
2538
2538
|
return "";
|
|
2539
2539
|
}
|
|
2540
|
-
})();
|
|
2540
|
+
})() : "";
|
|
2541
2541
|
var __dirname = __filename ? path5.dirname(__filename) : "";
|
|
2542
2542
|
var ChainCSSCompiler = class {
|
|
2543
2543
|
config;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface RuntimeStyleDefinition {
|
|
2
2
|
selectors?: string[];
|
|
3
3
|
hover?: Record<string, string | number>;
|
|
4
4
|
[key: string]: any;
|
|
@@ -33,7 +33,7 @@ declare class StyleInjector {
|
|
|
33
33
|
*/
|
|
34
34
|
resolveToken(value: any): any;
|
|
35
35
|
private generateCSS;
|
|
36
|
-
injectMultiple(styles: Record<string,
|
|
36
|
+
injectMultiple(styles: Record<string, RuntimeStyleDefinition>, moduleId?: string): Record<string, string>;
|
|
37
37
|
writeToDOM(css: string): void;
|
|
38
38
|
removeModule(moduleId: string): void;
|
|
39
39
|
removeAll(): void;
|
|
@@ -45,9 +45,9 @@ declare class StyleInjector {
|
|
|
45
45
|
}
|
|
46
46
|
export declare const styleInjector: StyleInjector;
|
|
47
47
|
export declare const setTokens: (t: TokenStore) => void;
|
|
48
|
-
export declare const compileRuntime: (s: Record<string,
|
|
48
|
+
export declare const compileRuntime: (s: Record<string, RuntimeStyleDefinition>, moduleId?: string) => Record<string, string>;
|
|
49
49
|
export declare const removeRuntimeModule: (moduleId: string) => void;
|
|
50
50
|
export declare const clearRuntimeStyles: () => void;
|
|
51
51
|
export declare const enableRuntimeDebug: (enabled: boolean) => void;
|
|
52
|
-
export declare function runRuntime(...styles:
|
|
52
|
+
export declare function runRuntime(...styles: RuntimeStyleDefinition[]): string;
|
|
53
53
|
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chaincss",
|
|
3
|
-
"version": "2.1.
|
|
4
|
-
"description": "ChainCSS
|
|
3
|
+
"version": "2.1.33",
|
|
4
|
+
"description": "ChainCSS - The first CSS-in-JS library with true auto-detection mixed mode. Zero runtime by default, dynamic when you need it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"build:core": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --packages=external",
|
|
40
40
|
"build:cli": "esbuild src/cli/index.ts --bundle --platform=node --format=esm --outfile=dist/cli/index.js --packages=external && chmod +x dist/cli/index.js",
|
|
41
41
|
"build:plugins": "esbuild src/plugins/vite.ts --bundle --platform=node --format=esm --outfile=dist/plugins/vite.js --packages=external && esbuild src/plugins/webpack.ts --bundle --platform=node --format=esm --outfile=dist/plugins/webpack.js --packages=external",
|
|
42
|
-
"build:runtime": "esbuild src/runtime/index.ts --bundle --platform=browser --format=esm --outfile=dist/runtime/index.js --external:react --external:react-dom --external:vue --external:svelte",
|
|
43
|
-
"build:browser": "esbuild src/browser.ts --bundle --platform=browser --format=esm --outfile=dist/browser.js --external:react --external:react-dom --external:vue --external:svelte",
|
|
42
|
+
"build:runtime": "esbuild src/runtime/index.ts --bundle --platform=browser --format=esm --outfile=dist/runtime/index.js --external:react --external:react-dom --external:vue --external:svelte --external:url",
|
|
43
|
+
"build:browser": "esbuild src/browser.ts --bundle --platform=browser --format=esm --outfile=dist/browser.js --external:react --external:react-dom --external:vue --external:svelte --external:url",
|
|
44
44
|
"build:compiler": "esbuild src/compiler/index.ts --bundle --platform=node --format=esm --outfile=dist/compiler/index.js --packages=external",
|
|
45
45
|
"dev": "tsc -w",
|
|
46
46
|
"prepublishOnly": "npm run build",
|
package/src/compiler/btt.ts
CHANGED
|
@@ -19,6 +19,8 @@ import { animationPresets, createAnimation } from './animations.js';
|
|
|
19
19
|
import { helpers } from './helpers.js';
|
|
20
20
|
import type { AnimationConfig } from './animations.js';
|
|
21
21
|
import { chain, setTokenContext } from './Chain.js';
|
|
22
|
+
import type { StyleDefinition } from '../core/types.js';
|
|
23
|
+
export type { StyleDefinition };
|
|
22
24
|
import { takeSnapshot as ts, isTimelineEnabled as timelineActive } from './timeline.js';
|
|
23
25
|
|
|
24
26
|
// ============================================================================
|
|
@@ -170,14 +172,7 @@ export interface AtRule {
|
|
|
170
172
|
export interface NestedRule { selector: string; styles: Record<string, string | number>; }
|
|
171
173
|
export interface ThemeBlock { name: string; styles: StyleDefinition; tokens: any; fallback: any; }
|
|
172
174
|
|
|
173
|
-
|
|
174
|
-
selectors: string[];
|
|
175
|
-
hover?: Record<string, string | number>;
|
|
176
|
-
atRules?: AtRule[];
|
|
177
|
-
nestedRules?: NestedRule[];
|
|
178
|
-
themes?: ThemeBlock[];
|
|
179
|
-
[cssProperty: string]: any;
|
|
180
|
-
}
|
|
175
|
+
// StyleDefinition imported from core/types.ts
|
|
181
176
|
|
|
182
177
|
// ============================================================================
|
|
183
178
|
// AT-Rule Processing
|
package/src/compiler/recipe.ts
CHANGED
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
* Recipe System - Type-safe component variants
|
|
4
4
|
*/
|
|
5
5
|
import { chain } from './Chain.js';
|
|
6
|
-
|
|
7
|
-
interface StyleDefinition {
|
|
8
|
-
selectors: string[];
|
|
9
|
-
hover?: Record<string, string | number>;
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}
|
|
6
|
+
import type { StyleDefinition } from '../core/types.js';
|
|
12
7
|
import { run } from './btt.js';
|
|
13
8
|
|
|
14
9
|
export interface RecipeOptions<TVariants extends Record<string, Record<string, any>>> {
|
package/src/core/compiler.ts
CHANGED
|
@@ -25,8 +25,8 @@ import { PersistentCache } from '../compiler/content-addressable-cache.js';
|
|
|
25
25
|
import { shorthandMap, macros } from '../compiler/shorthands.js';
|
|
26
26
|
import type { AtomicClass } from '../compiler/atomic-optimizer.js';
|
|
27
27
|
|
|
28
|
-
const __filename = (() => { try { return fileURLToPath(import.meta.url); } catch { return
|
|
29
|
-
const __dirname = __filename ? path.dirname(__filename) :
|
|
28
|
+
const __filename = typeof import.meta !== 'undefined' ? (() => { try { return fileURLToPath(import.meta.url); } catch { return ''; } })() : '';
|
|
29
|
+
const __dirname = __filename ? path.dirname(__filename) : '';
|
|
30
30
|
|
|
31
31
|
interface CachedStyleEntry {
|
|
32
32
|
result: {
|
package/src/core/types.ts
CHANGED
|
@@ -14,8 +14,10 @@ export interface StyleDefinition {
|
|
|
14
14
|
_generateComponent?: boolean;
|
|
15
15
|
_framework?: 'react' | 'vue' | 'svelte' | 'solid' | 'auto';
|
|
16
16
|
_propsDefinition?: Record<string, any>;
|
|
17
|
-
/** Explicit bucket for custom CSS properties
|
|
17
|
+
/** Explicit bucket for custom CSS properties */
|
|
18
18
|
customProperties?: Record<string, string | number>;
|
|
19
|
+
/** Allow arbitrary CSS properties */
|
|
20
|
+
[cssProperty: string]: any;
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
export interface AtRule {
|
package/src/runtime/injector.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { processStyleObject } from '../core/common-utils.js';
|
|
|
5
5
|
|
|
6
6
|
const TOKEN_V2_KEY = '__CHAINCSS_V2_TOKENS__';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
// Runtime-specific style def — selectors optional
|
|
9
|
+
export interface RuntimeStyleDefinition {
|
|
9
10
|
selectors?: string[];
|
|
10
11
|
hover?: Record<string, string | number>;
|
|
11
12
|
[key: string]: any;
|
|
@@ -110,7 +111,7 @@ class StyleInjector {
|
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
private generateCSS(style:
|
|
114
|
+
private generateCSS(style: RuntimeStyleDefinition, className: string): string {
|
|
114
115
|
let css = '';
|
|
115
116
|
const selector = `.${className}`;
|
|
116
117
|
|
|
@@ -139,7 +140,7 @@ class StyleInjector {
|
|
|
139
140
|
return css;
|
|
140
141
|
}
|
|
141
142
|
|
|
142
|
-
injectMultiple(styles: Record<string,
|
|
143
|
+
injectMultiple(styles: Record<string, RuntimeStyleDefinition>, moduleId?: string): Record<string, string> {
|
|
143
144
|
const result: Record<string, string> = {};
|
|
144
145
|
let newCSS = '';
|
|
145
146
|
const moduleClasses = new Set<string>();
|
|
@@ -233,13 +234,13 @@ export const styleInjector = new StyleInjector();
|
|
|
233
234
|
|
|
234
235
|
// --- PUBLIC API ---
|
|
235
236
|
export const setTokens = (t: TokenStore) => styleInjector.setTokens(t);
|
|
236
|
-
export const compileRuntime = (s: Record<string,
|
|
237
|
+
export const compileRuntime = (s: Record<string, RuntimeStyleDefinition>, moduleId?: string) =>
|
|
237
238
|
styleInjector.injectMultiple(s, moduleId);
|
|
238
239
|
export const removeRuntimeModule = (moduleId: string) => styleInjector.removeModule(moduleId);
|
|
239
240
|
export const clearRuntimeStyles = () => styleInjector.removeAll();
|
|
240
241
|
export const enableRuntimeDebug = (enabled: boolean) => styleInjector.enableDebug(enabled);
|
|
241
242
|
|
|
242
|
-
export function runRuntime(...styles:
|
|
243
|
+
export function runRuntime(...styles: RuntimeStyleDefinition[]): string {
|
|
243
244
|
let css = '';
|
|
244
245
|
for (const style of styles) {
|
|
245
246
|
if (style.selectors && style.selectors.length > 0) {
|