aliascss 1.3.8 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/aliascss.config.bk.js +131 -0
- package/aliascss.config.js +14 -94
- package/dist/aliascss.js +1 -1
- package/docc.md +228 -1
- package/lib/compilers/border.js +23 -1
- package/lib/compilers/clipPath.js +4 -0
- package/lib/compilers/color.js +15 -3
- package/lib/compilers/filter.js +5 -0
- package/lib/compilers/gradient.js +4 -1
- package/lib/compilers/timingFunction.js +5 -2
- package/lib/compilers/transform.js +5 -0
- package/lib/compilers/transition.js +2 -0
- package/lib/compilers/url.js +6 -0
- package/lib/css-properties-all.js +13 -3
- package/lib/custom-css-compilers.js +128 -1
- package/lib/node/compileFile.d.ts +1 -1
- package/lib/node/compileFile.js +10 -1
- package/lib/node/extractClassNamesFromFile.js +1 -1
- package/lib/prebuild.d.ts +19 -75
- package/lib/prebuild.js +573 -96
- package/lib/prefix/element-selector.js +1 -1
- package/lib/prefix/extractPrefix.js +19 -0
- package/lib/prefix/fallback-selector.d.ts +5 -0
- package/lib/prefix/fallback-selector.js +14 -0
- package/lib/returnPropertyAndValue.js +28 -17
- package/lib/static/customStaticClassNames.js +1 -0
- package/lib/static/staticClassNamesAlias-without-global-value.d.ts +3 -0
- package/lib/static/staticClassNamesAlias-without-global-value.js +1290 -0
- package/lib/static/staticClassNamesAlias.bk.d.ts +3 -0
- package/lib/static/staticClassNamesAlias.bk.js +1525 -0
- package/lib/static/staticClassNamesAlias.js +1526 -1298
- package/lib/static/staticClassNamesAliasWithSlashValue.bk.d.ts +3 -0
- package/lib/static/staticClassNamesAliasWithSlashValue.bk.js +1525 -0
- package/lib/static/staticClassNamesAliasWithSlashValue.d.ts +3 -0
- package/lib/static/staticClassNamesAliasWithSlashValue.js +1525 -0
- package/lib/static/staticcn2.d.ts +901 -0
- package/lib/static/staticcn2.js +984 -0
- package/lib/utils/createCompilerObj.js +4 -3
- package/lib/utils/cssFunc.js +3 -0
- package/package.json +4 -3
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import pseudoSelector from './pseudoSelectorNew.js';
|
|
3
3
|
import elementSelector from './element-selector.js';
|
|
4
4
|
import attribute from './attribute-selector.js';
|
|
5
|
+
import fallbackSelector from './fallback-selector.js';
|
|
5
6
|
export default function extractPrefix(className) {
|
|
6
7
|
let workingClassName = className;
|
|
7
8
|
let result = '';
|
|
@@ -58,6 +59,24 @@ export default function extractPrefix(className) {
|
|
|
58
59
|
workingClassName = replacedClassName;
|
|
59
60
|
match = true;
|
|
60
61
|
}
|
|
62
|
+
else if (fallbackSelector.test.test(workingClassName)) {
|
|
63
|
+
console.log('=-=-=-=-=-=--=', workingClassName);
|
|
64
|
+
const [replacedClassName, selector] = fallbackSelector.process(workingClassName);
|
|
65
|
+
if (result.match(/:(not|where|has|is)[)]?$/)) {
|
|
66
|
+
const m = result.match(/:(not|where|has|is)([)])?$/);
|
|
67
|
+
if (m === null || m === void 0 ? void 0 : m[2]) {
|
|
68
|
+
result = result.replace(/\)$/, '') + `(${selector}))`;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
result += `(${selector})`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
result += selector;
|
|
76
|
+
}
|
|
77
|
+
workingClassName = replacedClassName;
|
|
78
|
+
match = true;
|
|
79
|
+
}
|
|
61
80
|
else {
|
|
62
81
|
match = false;
|
|
63
82
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const fallbackSelector = {
|
|
2
|
+
test: /^[-,_]?[_]?@(selector)?\(((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)/, // @(selector)?\(((?:[^()]+|\((?:[^()]+|\([^()]*\))*\))*)\)
|
|
3
|
+
process(className) {
|
|
4
|
+
const match = className.match(this.test);
|
|
5
|
+
if (match) {
|
|
6
|
+
const selector = match[0];
|
|
7
|
+
if (selector) {
|
|
8
|
+
const result = match[2];
|
|
9
|
+
return [className.replace(selector, ''), /^[_]/.test(className) ? ' ' + result : result];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export default fallbackSelector;
|
|
@@ -9,33 +9,41 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export default function getPropertyAndValue(className, cssPropertiesWithAlias, staticClassNames, custom, extractProperty, // (a:string,b:{[key:string]:Property})=>[Property,string],
|
|
11
11
|
bool = false) {
|
|
12
|
+
var _a;
|
|
12
13
|
// Case 1 StaticClassNames
|
|
13
14
|
if (staticClassNames.hasOwnProperty(className)) {
|
|
14
15
|
return staticClassNames[className];
|
|
15
16
|
}
|
|
16
|
-
// case
|
|
17
|
+
// case 2 defining css-variable as className
|
|
17
18
|
if (className.startsWith('--') && className.includes(':')) {
|
|
18
19
|
let value = className.slice(className.indexOf(':')).replace(':', '');
|
|
19
20
|
const property = className.replace(value, '').replace(':', '');
|
|
20
|
-
|
|
21
|
+
let possiblePropsName = '';
|
|
22
|
+
const camelCasePropertyHint = (_a = property.match(/[A-Z][a-z0-9]*$/)) === null || _a === void 0 ? void 0 : _a[0];
|
|
23
|
+
if (camelCasePropertyHint) {
|
|
24
|
+
possiblePropsName = camelCasePropertyHint.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
possiblePropsName = property.slice(property.lastIndexOf('-') + 1);
|
|
28
|
+
}
|
|
21
29
|
let compiler = null;
|
|
22
30
|
if (cssPropertiesWithAlias.hasOwnProperty(possiblePropsName) && cssPropertiesWithAlias[possiblePropsName].hasOwnProperty('compiler') && typeof cssPropertiesWithAlias[possiblePropsName].compiler === 'function') {
|
|
23
31
|
compiler = cssPropertiesWithAlias[possiblePropsName].compiler;
|
|
24
32
|
}
|
|
25
|
-
//
|
|
26
|
-
// check if has :()
|
|
33
|
+
// if value is function i.e --some-var:(12px,red,blue);
|
|
27
34
|
if (/^\(.+\)[_]?$/.test(value)) {
|
|
28
35
|
if (value.match(/_$/)) {
|
|
36
|
+
// replace --[name] with var(--[name])
|
|
29
37
|
const val = value.replace(/(--[\w-]+)/g, 'var($1)')
|
|
30
38
|
.replace(/^[(]/, '').replace(/_$/, '').replace(/[)]$/, '')
|
|
31
39
|
.replace(/,/g, ', ');
|
|
32
|
-
value = val;
|
|
40
|
+
value = val.replace(/_/g, ' ');
|
|
33
41
|
}
|
|
34
42
|
else {
|
|
35
43
|
const val = value.replace(/(--[\w-]+)/g, 'var($1)')
|
|
36
44
|
.replace(/^[(]/, '').replace(/[)]$/, '')
|
|
37
45
|
.replace(/,/g, ' ');
|
|
38
|
-
value = val;
|
|
46
|
+
value = val.replace(/_/g, ' ');
|
|
39
47
|
}
|
|
40
48
|
return bool ? [property, value] : property + ":" + value;
|
|
41
49
|
}
|
|
@@ -55,6 +63,9 @@ bool = false) {
|
|
|
55
63
|
}
|
|
56
64
|
return bool ? [property, "var(" + cssVar + ',' + val + ')'] : property + ": var(" + cssVar + ',' + val + ')';
|
|
57
65
|
}
|
|
66
|
+
else if (compiler && compiler.name === 'color') {
|
|
67
|
+
return bool ? [property, compiler(value)] : property + ":" + compiler(value);
|
|
68
|
+
}
|
|
58
69
|
return bool ? [property, "var(" + value + ')'] : property + ": var(" + value + ')';
|
|
59
70
|
}
|
|
60
71
|
else {
|
|
@@ -81,17 +92,9 @@ bool = false) {
|
|
|
81
92
|
.replace(/[\s](mix|cmyk|set|gradient|bezier|content|shadow|rotate|dark|conic|linear|radial)/g, '-$1');
|
|
82
93
|
}
|
|
83
94
|
return bool ? [property, value] : property + ":" + value;
|
|
84
|
-
// return bool?[property,value.replace(/[-]([-]?[\w])/g,' $1').replace(/([\d])d([\d])/g,'$1.$2').replace(/([\d])p[\s]/g,"$1% ").replace(/([\d])p$/,"$1%").replace(/[\s]by[\s]/g,' / ')
|
|
85
|
-
// .replace(/auto flow/g,'auto-flow').replace(/__/g," ")
|
|
86
|
-
// .replace(/[\s](mix|cmyk|set|gradient|bezier|content|shadow|rotate|dark|conic|linear|radial)/g,'-$1')
|
|
87
|
-
// ]
|
|
88
|
-
// :
|
|
89
|
-
// property+":"+value.replace(/[-]([-]?[\w])/g,' $1').replace(/([\d])d([\d])/g,'$1.$2').replace(/([\d])p[\s]/g,"$1% ").replace(/([\d])p$/,"$1%").replace(/[\s]by[\s]/g,' / ')
|
|
90
|
-
// .replace(/auto flow/g,'auto-flow')
|
|
91
|
-
// .replace(/__/g," ")
|
|
92
|
-
// .replace(/[\s](mix|cmyk|set|gradient|bezier|content|shadow|rotate|dark|conic|linear|radial)/g,'-$1');
|
|
93
95
|
}
|
|
94
96
|
}
|
|
97
|
+
// End of CSS-variable as a className
|
|
95
98
|
const [property, propertyKey] = extractProperty(className, cssPropertiesWithAlias);
|
|
96
99
|
// console.log(propertyKey,'ttt',property,className)
|
|
97
100
|
if (property) {
|
|
@@ -130,13 +133,15 @@ bool = false) {
|
|
|
130
133
|
if (valuePortion.match(/_$/)) {
|
|
131
134
|
const val = valuePortion.replace(/(--[\w-]+)/g, 'var($1)')
|
|
132
135
|
.replace(/^[(]/, '').replace(/_$/, '').replace(/[)]$/, '')
|
|
133
|
-
.replace(/,/g, ', ')
|
|
136
|
+
.replace(/,/g, ', ')
|
|
137
|
+
.replace(/[_]/g, ' ');
|
|
134
138
|
return bool ? [prop, val] : prop + ":" + val;
|
|
135
139
|
}
|
|
136
140
|
else {
|
|
137
141
|
const val = valuePortion.replace(/(--[\w-]+)/g, 'var($1)')
|
|
138
142
|
.replace(/^[(]/, '').replace(/[)]$/, '')
|
|
139
|
-
.replace(/,/g, ' ')
|
|
143
|
+
.replace(/,/g, ' ')
|
|
144
|
+
.replace(/[_]/g, ' ');
|
|
140
145
|
return bool ? [prop, val] : prop + ":" + val;
|
|
141
146
|
}
|
|
142
147
|
}
|
|
@@ -175,6 +180,12 @@ bool = false) {
|
|
|
175
180
|
}
|
|
176
181
|
return bool ? [prop, "var(" + cssVar + ',' + value + ')'] : prop + ": var(" + cssVar + ',' + value + ')';
|
|
177
182
|
}
|
|
183
|
+
if (/(background|color)$/.test(prop)) {
|
|
184
|
+
if (cssPropertiesWithAlias.color.compiler && typeof cssPropertiesWithAlias.color.compiler === 'function') {
|
|
185
|
+
const value = cssPropertiesWithAlias.color.compiler(valuePortion, custom);
|
|
186
|
+
return bool ? [prop, value] : prop + ":" + value;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
178
189
|
return bool ? [prop, "var(" + valuePortion + ')'] : prop + ": var(" + valuePortion + ')';
|
|
179
190
|
}
|
|
180
191
|
if (property.hasOwnProperty('compiler') && typeof property.compiler === 'function') {
|
|
@@ -170,6 +170,7 @@ export const customStaticClassNames = {
|
|
|
170
170
|
'x-absolute-inset-y': "position:absolute;margin:auto;top:0;bottom:0;",
|
|
171
171
|
'x-absolute-inset-x': "position:absolute;left:0;right:0;",
|
|
172
172
|
'x-fixed-center': "position:fixed;margin:auto;top:0;left:0;right:0;bottom:0;",
|
|
173
|
+
'x-isolate': 'isolation:isolate',
|
|
173
174
|
'x-sr-only': 'position:absolute;overflow:hidden;clip-path:rect(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0',
|
|
174
175
|
// 'x-jusitfy-between':'justify-content: space-between',
|
|
175
176
|
// 'x-flex':'display:flex',
|