chaincss 1.13.3 → 2.0.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/CHANGELOG.md +81 -0
- package/LICENSE +2 -3
- package/README.md +238 -105
- package/dist/cli/commands/build.d.ts +3 -0
- package/dist/cli/commands/build.d.ts.map +1 -0
- package/dist/cli/commands/compile.d.ts +3 -0
- package/dist/cli/commands/compile.d.ts.map +1 -0
- package/dist/cli/commands/init.d.ts +5 -0
- package/dist/cli/commands/init.d.ts.map +1 -0
- package/dist/cli/commands/timeline.d.ts +2 -0
- package/dist/cli/commands/timeline.d.ts.map +1 -0
- package/dist/cli/commands/watch.d.ts +6 -0
- package/dist/cli/commands/watch.d.ts.map +1 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +5960 -0
- package/dist/cli/types.d.ts +51 -0
- package/dist/cli/types.d.ts.map +1 -0
- package/dist/cli/utils/config-loader.d.ts +8 -0
- package/dist/cli/utils/config-loader.d.ts.map +1 -0
- package/dist/cli/utils/file-utils.d.ts +9 -0
- package/dist/cli/utils/file-utils.d.ts.map +1 -0
- package/dist/cli/utils/logger.d.ts +17 -0
- package/dist/cli/utils/logger.d.ts.map +1 -0
- package/dist/compiler/atomic-optimizer.d.ts +76 -0
- package/dist/compiler/atomic-optimizer.d.ts.map +1 -0
- package/dist/compiler/btt.d.ts +138 -0
- package/dist/compiler/btt.d.ts.map +1 -0
- package/dist/compiler/cache-manager.d.ts +20 -0
- package/dist/compiler/cache-manager.d.ts.map +1 -0
- package/dist/compiler/commonProps.d.ts +2 -0
- package/dist/compiler/commonProps.d.ts.map +1 -0
- package/dist/compiler/index.d.ts +12 -0
- package/dist/compiler/index.d.ts.map +1 -0
- package/dist/compiler/index.js +5177 -0
- package/dist/compiler/prefixer.d.ts +42 -0
- package/dist/compiler/prefixer.d.ts.map +1 -0
- package/dist/compiler/theme-contract.d.ts +61 -0
- package/dist/compiler/theme-contract.d.ts.map +1 -0
- package/dist/compiler/tokens.d.ts +52 -0
- package/dist/compiler/tokens.d.ts.map +1 -0
- package/dist/compiler/types.d.ts +57 -0
- package/dist/compiler/types.d.ts.map +1 -0
- package/dist/core/compiler.d.ts +32 -0
- package/dist/core/compiler.d.ts.map +1 -0
- package/dist/core/constants.d.ts +129 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/types.d.ts +88 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/utils.d.ts +37 -0
- package/dist/core/utils.d.ts.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5667 -0
- package/dist/plugins/vite.d.ts +11 -0
- package/dist/plugins/vite.d.ts.map +1 -0
- package/dist/plugins/vite.js +25839 -0
- package/dist/plugins/webpack.d.ts +45 -0
- package/dist/plugins/webpack.d.ts.map +1 -0
- package/dist/plugins/webpack.js +107 -0
- package/dist/runtime/hmr.d.ts +3 -0
- package/dist/runtime/hmr.d.ts.map +1 -0
- package/dist/runtime/index.d.ts +15 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/index.js +552 -0
- package/dist/runtime/injector.d.ts +85 -0
- package/dist/runtime/injector.d.ts.map +1 -0
- package/dist/runtime/react.d.ts +54 -0
- package/dist/runtime/react.d.ts.map +1 -0
- package/dist/runtime/react.js +270 -0
- package/dist/runtime/types.d.ts +45 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/utils.d.ts +62 -0
- package/dist/runtime/utils.d.ts.map +1 -0
- package/dist/runtime/vue.d.ts +52 -0
- package/dist/runtime/vue.d.ts.map +1 -0
- package/dist/runtime/vue.js +232 -0
- package/package.json +90 -119
- package/browser/commonProps.js +0 -14
- package/browser/index.js +0 -3
- package/browser/react-hooks.js +0 -162
- package/browser/rtt.js +0 -400
- package/browser/vue-composables.js +0 -200
- package/node/atomic-optimizer.js +0 -526
- package/node/btt.js +0 -1009
- package/node/cache-manager.js +0 -56
- package/node/chaincss.js +0 -642
- package/node/index.js +0 -2
- package/node/loaders/chaincss-loader.js +0 -62
- package/node/plugins/next-plugin.js +0 -120
- package/node/plugins/vite-plugin.js +0 -383
- package/node/plugins/webpack-plugin.js +0 -41
- package/node/prefixer.js +0 -237
- package/node/strVal.js +0 -92
- package/node/theme-validator.js +0 -32
- package/shared/theme-contract.js +0 -98
- package/shared/tokens.cjs +0 -256
- package/shared/tokens.mjs +0 -320
- package/types.d.ts +0 -325
package/package.json
CHANGED
|
@@ -1,7 +1,91 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chaincss",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "The JavaScript-native styling engine for the modern web",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"CHANGELOG.md"
|
|
13
|
+
],
|
|
14
|
+
"bin": {
|
|
15
|
+
"chaincss": "./dist/cli/index.js"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"import": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts"
|
|
21
|
+
},
|
|
22
|
+
"./compiler": {
|
|
23
|
+
"import": "./dist/compiler/index.js",
|
|
24
|
+
"types": "./dist/compiler/index.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./runtime": {
|
|
27
|
+
"import": "./dist/runtime/index.js",
|
|
28
|
+
"types": "./dist/runtime/index.d.ts",
|
|
29
|
+
"development": "./dist/runtime/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./plugin/vite": {
|
|
32
|
+
"import": "./dist/plugins/vite.js",
|
|
33
|
+
"types": "./dist/plugins/vite.d.ts"
|
|
34
|
+
},
|
|
35
|
+
"./plugin/webpack": {
|
|
36
|
+
"import": "./dist/plugins/webpack.js",
|
|
37
|
+
"types": "./dist/plugins/webpack.d.ts"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "npm run build:clean && npm run build:types && npm run build:core && npm run build:cli && npm run build:plugins && npm run build:runtime && npm run build:compiler",
|
|
42
|
+
"build:clean": "rm -rf dist",
|
|
43
|
+
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
44
|
+
"build:core": "esbuild src/index.ts --bundle --platform=node --format=esm --outfile=dist/index.js --external:chokidar --external:glob --external:commander --external:chalk --external:autoprefixer --external:postcss --external:clean-css",
|
|
45
|
+
"build:cli": "esbuild src/cli/index.ts --bundle --platform=node --format=esm --outfile=dist/cli/index.js --external:chokidar --external:glob --external:commander --external:chalk --external:autoprefixer --external:postcss --external:clean-css && chmod +x dist/cli/index.js",
|
|
46
|
+
"build:plugins": "esbuild src/plugins/vite.ts --bundle --platform=node --format=esm --outfile=dist/plugins/vite.js --external:vite && esbuild src/plugins/webpack.ts --bundle --platform=node --format=esm --outfile=dist/plugins/webpack.js --external:webpack",
|
|
47
|
+
"build:runtime": "esbuild src/runtime/index.ts --bundle --platform=browser --format=esm --outfile=dist/runtime/index.js --external:react --external:vue && esbuild src/runtime/react.tsx --bundle --platform=browser --format=esm --outfile=dist/runtime/react.js --external:react --external:vue && esbuild src/runtime/vue.ts --bundle --platform=browser --format=esm --outfile=dist/runtime/vue.js --external:vue --external:react",
|
|
48
|
+
"build:compiler": "esbuild src/compiler/index.ts --bundle --platform=node --format=esm --outfile=dist/compiler/index.js --external:chokidar --external:glob --external:commander --external:chalk --external:autoprefixer --external:postcss --external:clean-css",
|
|
49
|
+
"dev": "npm run build:clean && npm run build:types && npm run build:core -- --watch",
|
|
50
|
+
"prepublishOnly": "npm run build",
|
|
51
|
+
"test": "vitest",
|
|
52
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
53
|
+
"preversion": "npm run test && npm run build",
|
|
54
|
+
"version": "git add -A",
|
|
55
|
+
"postversion": "git push && git push --tags"
|
|
56
|
+
},
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"chalk": "^5.3.0",
|
|
59
|
+
"chokidar": "^3.5.3",
|
|
60
|
+
"clean-css": "^5.3.2",
|
|
61
|
+
"commander": "^11.1.0",
|
|
62
|
+
"postcss": "^8.4.31"
|
|
63
|
+
},
|
|
64
|
+
"devDependencies": {
|
|
65
|
+
"@types/clean-css": "^4.2.10",
|
|
66
|
+
"@types/node": "^20.8.10",
|
|
67
|
+
"@types/react": "^18.2.0",
|
|
68
|
+
"autoprefixer": "^10.4.16",
|
|
69
|
+
"browserslist": "^4.22.1",
|
|
70
|
+
"esbuild": "^0.19.12",
|
|
71
|
+
"glob": "^10.3.10",
|
|
72
|
+
"react": "^18.2.0",
|
|
73
|
+
"typescript": "^5.2.2",
|
|
74
|
+
"vite": "^5.0.0",
|
|
75
|
+
"vue": "^3.3.4"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"react": "^18.0.0",
|
|
79
|
+
"vue": "^3.0.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"react": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"vue": {
|
|
86
|
+
"optional": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
5
89
|
"keywords": [
|
|
6
90
|
"css",
|
|
7
91
|
"css-in-js",
|
|
@@ -34,127 +118,14 @@
|
|
|
34
118
|
"license": "MIT",
|
|
35
119
|
"repository": {
|
|
36
120
|
"type": "git",
|
|
37
|
-
"url": "
|
|
121
|
+
"url": "https://github.com/melcanz08/chaincss"
|
|
38
122
|
},
|
|
39
123
|
"homepage": "https://chaincss.dev",
|
|
40
124
|
"bugs": {
|
|
41
125
|
"url": "https://github.com/melcanz08/chaincss/issues"
|
|
42
126
|
},
|
|
43
|
-
"
|
|
44
|
-
".": {
|
|
45
|
-
"types": "./types.d.ts",
|
|
46
|
-
"browser": {
|
|
47
|
-
"import": "./browser/index.js",
|
|
48
|
-
"require": "./browser/index.js"
|
|
49
|
-
},
|
|
50
|
-
"node": {
|
|
51
|
-
"import": "./node/btt.js",
|
|
52
|
-
"require": "./node/btt.js"
|
|
53
|
-
},
|
|
54
|
-
"default": "./browser/index.js"
|
|
55
|
-
},
|
|
56
|
-
"./react": {
|
|
57
|
-
"types": "./types.d.ts",
|
|
58
|
-
"browser": {
|
|
59
|
-
"import": "./browser/react-hooks.js",
|
|
60
|
-
"require": "./browser/react-hooks.js"
|
|
61
|
-
},
|
|
62
|
-
"default": "./browser/react-hooks.js"
|
|
63
|
-
},
|
|
64
|
-
"./vue": {
|
|
65
|
-
"types": "./types.d.ts",
|
|
66
|
-
"browser": {
|
|
67
|
-
"import": "./browser/vue-composables.js",
|
|
68
|
-
"require": "./browser/vue-composables.js"
|
|
69
|
-
},
|
|
70
|
-
"default": "./browser/vue-composables.js"
|
|
71
|
-
},
|
|
72
|
-
"./browser": {
|
|
73
|
-
"browser": {
|
|
74
|
-
"import": "./browser/*",
|
|
75
|
-
"require": "./browser/*"
|
|
76
|
-
},
|
|
77
|
-
"default": "./browser/index.js"
|
|
78
|
-
},
|
|
79
|
-
"./node/*": {
|
|
80
|
-
"node": {
|
|
81
|
-
"import": "./node/*",
|
|
82
|
-
"require": "./node/*"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
"./vite-plugin": {
|
|
86
|
-
"types": "./types.d.ts",
|
|
87
|
-
"import": "./node/plugins/vite-plugin.js",
|
|
88
|
-
"require": "./node/plugins/vite-plugin.js",
|
|
89
|
-
"default": "./node/plugins/vite-plugin.js"
|
|
90
|
-
},
|
|
91
|
-
"./webpack-plugin": {
|
|
92
|
-
"types": "./types.d.ts",
|
|
93
|
-
"import": "./node/plugins/webpack-plugin.js",
|
|
94
|
-
"require": "./node/plugins/webpack-plugin.js",
|
|
95
|
-
"default": "./node/plugins/webpack-plugin.js"
|
|
96
|
-
},
|
|
97
|
-
"./next-plugin": {
|
|
98
|
-
"types": "./types.d.ts",
|
|
99
|
-
"import": "./node/plugins/next-plugin.js",
|
|
100
|
-
"require": "./node/plugins/next-plugin.js",
|
|
101
|
-
"default": "./node/plugins/next-plugin.js"
|
|
102
|
-
},
|
|
103
|
-
"./loader": {
|
|
104
|
-
"types": "./types.d.ts",
|
|
105
|
-
"import": "./node/loaders/chaincss-loader.js",
|
|
106
|
-
"require": "./node/loaders/chaincss-loader.js",
|
|
107
|
-
"default": "./node/loaders/chaincss-loader.js"
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
"types": "types.d.ts",
|
|
111
|
-
"files": [
|
|
112
|
-
"browser/",
|
|
113
|
-
"node/",
|
|
114
|
-
"shared/",
|
|
115
|
-
"types.d.ts",
|
|
116
|
-
"README.md",
|
|
117
|
-
"LICENSE"
|
|
118
|
-
],
|
|
119
|
-
"publishConfig": {
|
|
120
|
-
"access": "public",
|
|
121
|
-
"registry": "https://registry.npmjs.org/",
|
|
122
|
-
"provenance": false
|
|
123
|
-
},
|
|
124
|
-
"bin": {
|
|
125
|
-
"chaincss": "./node/chaincss.js"
|
|
126
|
-
},
|
|
127
|
-
"dependencies": {
|
|
128
|
-
"chokidar": "^3.5.3",
|
|
129
|
-
"clean-css": "^5.3.3"
|
|
130
|
-
},
|
|
131
|
-
"peerDependencies": {
|
|
132
|
-
"vue": "^3.0.0",
|
|
133
|
-
"react": ">=16.8.0",
|
|
134
|
-
"autoprefixer": "^10.0.0",
|
|
135
|
-
"postcss": "^8.5.6",
|
|
136
|
-
"browserslist": "^4.28.1",
|
|
137
|
-
"caniuse-db": "^1.0.30001770"
|
|
138
|
-
},
|
|
139
|
-
"peerDependenciesMeta": {
|
|
140
|
-
"react": {
|
|
141
|
-
"optional": true
|
|
142
|
-
},
|
|
143
|
-
"autoprefixer": {
|
|
144
|
-
"optional": true
|
|
145
|
-
},
|
|
146
|
-
"postcss": {
|
|
147
|
-
"optional": true
|
|
148
|
-
},
|
|
149
|
-
"browserslist": {
|
|
150
|
-
"optional": true
|
|
151
|
-
},
|
|
152
|
-
"caniuse-db": {
|
|
153
|
-
"optional": true
|
|
154
|
-
}
|
|
155
|
-
},
|
|
127
|
+
"sideEffects": false,
|
|
156
128
|
"engines": {
|
|
157
|
-
"node": ">=
|
|
158
|
-
}
|
|
159
|
-
"sideEffects": false
|
|
129
|
+
"node": ">=18.0.0"
|
|
130
|
+
}
|
|
160
131
|
}
|
package/browser/commonProps.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const COMMON_CSS_PROPERTIES = [
|
|
2
|
-
'color', 'background', 'background-color', 'background-image', 'background-size',
|
|
3
|
-
'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
|
|
4
|
-
'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
|
|
5
|
-
'border', 'border-radius', 'border-width', 'border-style', 'border-color',
|
|
6
|
-
'display', 'position', 'top', 'left', 'right', 'bottom',
|
|
7
|
-
'width', 'height', 'max-width', 'min-width', 'max-height', 'min-height',
|
|
8
|
-
'font-size', 'font-weight', 'font-family', 'font-style', 'line-height',
|
|
9
|
-
'text-align', 'text-decoration', 'text-transform', 'letter-spacing',
|
|
10
|
-
'opacity', 'z-index', 'overflow', 'cursor', 'pointer-events',
|
|
11
|
-
'transition', 'transform', 'animation', 'animation-duration', 'animation-timing-function',
|
|
12
|
-
'flex', 'grid', 'gap', 'justify-content', 'align-items', 'flex-direction',
|
|
13
|
-
'box-shadow', 'outline', 'filter', 'backdrop-filter'
|
|
14
|
-
]
|
package/browser/index.js
DELETED
package/browser/react-hooks.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
const { useMemo, useEffect, useRef, useState } = React;
|
|
3
|
-
import { $, compile, chain } from './rtt';
|
|
4
|
-
|
|
5
|
-
const styleCache = new Map();
|
|
6
|
-
let styleSheet = null;
|
|
7
|
-
|
|
8
|
-
const initStyleSheet = () => {
|
|
9
|
-
if (typeof document === 'undefined') return null;
|
|
10
|
-
if (!styleSheet) {
|
|
11
|
-
const existing = document.getElementById('chaincss-styles');
|
|
12
|
-
if (existing) {
|
|
13
|
-
styleSheet = existing;
|
|
14
|
-
return styleSheet;
|
|
15
|
-
}
|
|
16
|
-
const style = document.createElement('style');
|
|
17
|
-
style.id = 'chaincss-styles';
|
|
18
|
-
style.setAttribute('data-chaincss', 'true');
|
|
19
|
-
document.head.appendChild(style);
|
|
20
|
-
styleSheet = style;
|
|
21
|
-
}
|
|
22
|
-
return styleSheet;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const updateStyles = (css) => {
|
|
26
|
-
const sheet = initStyleSheet();
|
|
27
|
-
if (sheet) {
|
|
28
|
-
sheet.textContent = css;
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export function useChainStyles(styles, deps = [], options = {}) {
|
|
33
|
-
const {
|
|
34
|
-
cache = true,
|
|
35
|
-
namespace = 'chain',
|
|
36
|
-
watch = false
|
|
37
|
-
} = options;
|
|
38
|
-
|
|
39
|
-
const id = useRef(`chain-${Math.random().toString(36).substr(2, 9)}`);
|
|
40
|
-
const [classNames, setClassNames] = useState({});
|
|
41
|
-
|
|
42
|
-
const processed = useMemo(() => {
|
|
43
|
-
const resolvedStyles = typeof styles === 'function' ? styles() : styles;
|
|
44
|
-
if (!resolvedStyles || Object.keys(resolvedStyles).length === 0) {
|
|
45
|
-
return { classNames: {}, css: '' };
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const cacheKey = JSON.stringify(resolvedStyles);
|
|
49
|
-
if (cache && styleCache.has(cacheKey)) {
|
|
50
|
-
return styleCache.get(cacheKey);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const newClassNames = {};
|
|
54
|
-
const compiledStyles = {};
|
|
55
|
-
|
|
56
|
-
Object.entries(resolvedStyles).forEach(([key, styleDef]) => {
|
|
57
|
-
const className = `${namespace}-${key}-${id.current}`;
|
|
58
|
-
const styleObj = typeof styleDef === 'function'
|
|
59
|
-
? styleDef()
|
|
60
|
-
: styleDef;
|
|
61
|
-
newClassNames[key] = className;
|
|
62
|
-
compiledStyles[`${key}_${id.current}`] = {
|
|
63
|
-
selectors: [`.${className}`],
|
|
64
|
-
...styleObj
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
compile(compiledStyles);
|
|
69
|
-
const css = chain.cssOutput;
|
|
70
|
-
const result = { classNames: newClassNames, css };
|
|
71
|
-
|
|
72
|
-
if (cache) {
|
|
73
|
-
styleCache.set(cacheKey, result);
|
|
74
|
-
}
|
|
75
|
-
return result;
|
|
76
|
-
}, [styles, namespace, id.current, ...deps]);
|
|
77
|
-
|
|
78
|
-
useEffect(() => {
|
|
79
|
-
if (processed.css) {
|
|
80
|
-
if (!watch) {
|
|
81
|
-
const sheet = initStyleSheet();
|
|
82
|
-
if (sheet) {
|
|
83
|
-
const existingStyles = sheet.textContent || '';
|
|
84
|
-
const styleRegex = new RegExp(`\\.[\\w-]*${id.current}[\\s\\S]*?}`, 'g');
|
|
85
|
-
const cleanedStyles = existingStyles.replace(styleRegex, '');
|
|
86
|
-
sheet.textContent = cleanedStyles + processed.css;
|
|
87
|
-
}
|
|
88
|
-
} else {
|
|
89
|
-
updateStyles(processed.css);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return () => {
|
|
94
|
-
if (!watch && styleSheet) {
|
|
95
|
-
const existingStyles = styleSheet.textContent || '';
|
|
96
|
-
const styleRegex = new RegExp(`\\.[\\w-]*${id.current}[\\s\\S]*?}`, 'g');
|
|
97
|
-
styleSheet.textContent = existingStyles.replace(styleRegex, '');
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
}, [processed.css, watch]);
|
|
101
|
-
|
|
102
|
-
return processed.classNames;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function useDynamicChainStyles(styleFactory, deps = [], options = {}) {
|
|
106
|
-
const styles = useMemo(() => {
|
|
107
|
-
return styleFactory();
|
|
108
|
-
}, deps);
|
|
109
|
-
return useChainStyles(styles, options);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function useThemeChainStyles(styles, theme, options = {}) {
|
|
113
|
-
const themedStyles = useMemo(() => {
|
|
114
|
-
if (typeof styles === 'function') {
|
|
115
|
-
return styles(theme);
|
|
116
|
-
}
|
|
117
|
-
return styles;
|
|
118
|
-
}, [styles, theme]);
|
|
119
|
-
return useChainStyles(themedStyles, options);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function ChainCSSGlobal({ styles }) {
|
|
123
|
-
useChainStyles(styles, { watch: true });
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export function withChainStyles(styles, options = {}) {
|
|
128
|
-
return function WrappedComponent(props) {
|
|
129
|
-
const classNames = useChainStyles(
|
|
130
|
-
typeof styles === 'function' ? styles(props) : styles,
|
|
131
|
-
options
|
|
132
|
-
);
|
|
133
|
-
return React.createElement(WrappedComponent, { ...props, chainStyles: classNames });
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function cx(...classes) {
|
|
138
|
-
return classes.filter(Boolean).join(' ');
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
let debugEnabled = false;
|
|
142
|
-
|
|
143
|
-
export function enableChainCSSDebug() {
|
|
144
|
-
if (typeof window !== 'undefined') {
|
|
145
|
-
debugEnabled = true;
|
|
146
|
-
window.__CHAINCSS_DEBUG__ = true;
|
|
147
|
-
console.log('🔍 ChainCSS Debug Mode Enabled');
|
|
148
|
-
console.log('💡 Tip: Hover over elements to see their atomic classes');
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
export function disableChainCSSDebug() {
|
|
153
|
-
if (typeof window !== 'undefined') {
|
|
154
|
-
debugEnabled = false;
|
|
155
|
-
window.__CHAINCSS_DEBUG__ = false;
|
|
156
|
-
console.log('🔍 ChainCSS Debug Mode Disabled');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export function isDebugEnabled() {
|
|
161
|
-
return debugEnabled || (typeof window !== 'undefined' && window.__CHAINCSS_DEBUG__);
|
|
162
|
-
}
|