chaincss 2.1.11 → 2.1.12

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/index.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * @packageDocumentation
4
4
  */
5
5
  export { smartChain, smartChain as chainV3, buildChain, runtimeChain } from './core/smart-chain.js';
6
+ export { injectChainStyles } from './runtime/index.js';
6
7
  export { autoDetector, AutoDetector, type ValueType, type Mode } from './core/auto-detector.js';
7
8
  export { useSmartStyles, createSmartComponent, withSmartStyles } from './runtime/auto-hooks.js';
8
9
  export { ChainCSSCompiler, compileChainCSS } from './core/compiler.js';
package/dist/index.js CHANGED
@@ -3065,9 +3065,6 @@ function smartChain(useTokens = true) {
3065
3065
  var buildChain = (useTokens) => chain(useTokens);
3066
3066
  var runtimeChain = (useTokens) => new RuntimeChain(useTokens || true).proxy;
3067
3067
 
3068
- // src/runtime/auto-hooks.tsx
3069
- import React, { useEffect, useRef, useState } from "react";
3070
-
3071
3068
  // src/core/common-utils.ts
3072
3069
  function kebabCase(str) {
3073
3070
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -3353,7 +3350,40 @@ ${rules}}
3353
3350
  var styleInjector = new StyleInjector();
3354
3351
  var compileRuntime = (s, moduleId) => styleInjector.injectMultiple(s, moduleId);
3355
3352
 
3353
+ // src/runtime/index.ts
3354
+ function injectChainStyles(styles) {
3355
+ let css = "";
3356
+ for (const [key, obj] of Object.entries(styles)) {
3357
+ if (!obj || !obj.selectors) continue;
3358
+ const sel = "." + obj.selectors[0];
3359
+ css += sel + "{";
3360
+ for (const [k, v] of Object.entries(obj)) {
3361
+ if (["selectors", "hover", "atRules", "nestedRules", "_name", "_classes"].includes(k)) continue;
3362
+ css += k.replace(/([A-Z])/g, "-$1").toLowerCase() + ":" + v + ";";
3363
+ }
3364
+ css += "}";
3365
+ if (obj.hover) {
3366
+ css += sel + ":hover{";
3367
+ for (const [k, v] of Object.entries(obj.hover)) css += k.replace(/([A-Z])/g, "-$1").toLowerCase() + ":" + v + ";";
3368
+ css += "}";
3369
+ }
3370
+ if (obj.nestedRules) {
3371
+ for (const rule of obj.nestedRules) {
3372
+ css += rule.selector.replace("&", sel) + "{";
3373
+ for (const [k, v] of Object.entries(rule.styles || {})) css += k.replace(/([A-Z])/g, "-$1").toLowerCase() + ":" + v + ";";
3374
+ css += "}";
3375
+ }
3376
+ }
3377
+ }
3378
+ const el = document.createElement("style");
3379
+ el.setAttribute("data-chaincss", "runtime");
3380
+ el.textContent = css;
3381
+ document.head.appendChild(el);
3382
+ return el;
3383
+ }
3384
+
3356
3385
  // src/runtime/auto-hooks.tsx
3386
+ import React, { useEffect, useRef, useState } from "react";
3357
3387
  function useSmartStyles(styleBuilder, deps = [], options = {}) {
3358
3388
  const moduleId = useRef(options.moduleId || `smart-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`);
3359
3389
  const [classMap, setClassMap] = useState({});
@@ -7001,6 +7031,7 @@ export {
7001
7031
  handleShorthand,
7002
7032
  hasAnimationPreset,
7003
7033
  helpers,
7034
+ injectChainStyles,
7004
7035
  isShorthand,
7005
7036
  macros,
7006
7037
  recipe,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chaincss",
3
- "version": "2.1.11",
3
+ "version": "2.1.12",
4
4
  "description": "ChainCSS v3.0 - 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",
package/src/index.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  // 🆕 NEW: Smart Chain API (Auto-detection mixed mode)
10
10
  // ============================================================================
11
11
  export { smartChain, smartChain as chainV3, buildChain, runtimeChain } from './core/smart-chain.js';
12
+ export { injectChainStyles } from './runtime/index.js';
12
13
  export { autoDetector, AutoDetector, type ValueType, type Mode } from './core/auto-detector.js';
13
14
 
14
15
  // ============================================================================