aliascss 1.3.9 → 1.4.1
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/classPrinter.js +16 -2
- package/lib/compilers/border.js +23 -1
- package/lib/compilers/color.js +12 -4
- package/lib/compilers/timingFunction.js +5 -2
- package/lib/compilers/transition.js +2 -0
- package/lib/config.d.ts +1 -0
- package/lib/config.js +3 -1
- package/lib/css-properties-all.js +16 -6
- package/lib/custom-css-compilers.js +128 -1
- package/lib/node/compileFile.d.ts +1 -1
- package/lib/node/compileFile.js +21 -2
- 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/extractMediaPrefix.js +5 -2
- 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/prefix/responsive.js +24 -37
- package/lib/returnPropertyAndValue.js +28 -19
- package/lib/returnStatement.js +14 -3
- 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/utils/browser-helper.d.ts +1 -0
- package/lib/utils/browser-helper.js +37 -0
- package/lib/utils/createCompilerObj.js +4 -3
- package/package.json +4 -3
- package/tsconfig.json +1 -0
|
@@ -8,7 +8,7 @@ export default function extractMediaPrefix(className, prefix, match, bool = fals
|
|
|
8
8
|
const prefixMedia = (_a = className.match(match)) === null || _a === void 0 ? void 0 : _a[0];
|
|
9
9
|
if (prefixMedia) {
|
|
10
10
|
if (prefix.hasOwnProperty(prefixMedia)) {
|
|
11
|
-
medias.push(prefix[prefixMedia]);
|
|
11
|
+
medias.push(prefix[prefixMedia] + '::::' + prefixMedia);
|
|
12
12
|
cls = className.replace(prefixMedia, '');
|
|
13
13
|
// return [[], ]
|
|
14
14
|
}
|
|
@@ -22,11 +22,14 @@ export default function extractMediaPrefix(className, prefix, match, bool = fals
|
|
|
22
22
|
const prefixMedia = ((_a = suffixedMatch.match(match)) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = ('@' + suffixedMatch).match(match)) === null || _b === void 0 ? void 0 : _b[0]);
|
|
23
23
|
if (prefixMedia) {
|
|
24
24
|
if (prefix.hasOwnProperty(prefixMedia)) {
|
|
25
|
-
medias.push(prefix[prefixMedia]);
|
|
25
|
+
medias.push(prefix[prefixMedia] + '::::' + prefixMedia);
|
|
26
26
|
// return [[], ]
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
+
else {
|
|
31
|
+
medias.push('@' + e);
|
|
32
|
+
}
|
|
30
33
|
});
|
|
31
34
|
if (medias.length) {
|
|
32
35
|
cls = className.replace(matchNestedMedia, '');
|
|
@@ -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;
|
package/lib/prefix/responsive.js
CHANGED
|
@@ -3,16 +3,16 @@ const media = {
|
|
|
3
3
|
test: new RegExp("^(" + "print|xs|sm|md|lg|xl|xxl|-xs|-sm|-md|-lg|-xl|-xxl|-2xl" + ")(?=[-|_])"),
|
|
4
4
|
target: {
|
|
5
5
|
print: '@media print',
|
|
6
|
-
'@hover': '@media screen and (hover: hover)',
|
|
7
6
|
'@print': '@media print',
|
|
7
|
+
'@hover-capable': '@media screen and (hover: hover)',
|
|
8
8
|
'@landscape': '@media (orientation: landscape)',
|
|
9
9
|
'@portrait': '@media (orientation: portrait)',
|
|
10
|
-
'@container-xs': '@container (max-width
|
|
11
|
-
'@container-sm': '@container (min-width
|
|
12
|
-
'@container-md': '@container (min-width
|
|
13
|
-
'@container-lg': '@container (min-width
|
|
14
|
-
'@container-xl': '@container (min-width
|
|
15
|
-
'@container-
|
|
10
|
+
'@container-xs': '@container (max-width: 576px)',
|
|
11
|
+
'@container-sm': '@container (min-width: 576px)',
|
|
12
|
+
'@container-md': '@container (min-width: 768px)',
|
|
13
|
+
'@container-lg': '@container (min-width: 992px)',
|
|
14
|
+
'@container-xl': '@container (min-width: 1200px)',
|
|
15
|
+
'@container-xxl': '@container (min-width: 1408px)',
|
|
16
16
|
'@forced-color-active': '@media (forced-colors: active)',
|
|
17
17
|
'@fca': '@media (forced-colors: active)',
|
|
18
18
|
'@standalone': '@media (display-mode: standalone)',
|
|
@@ -27,45 +27,32 @@ const media = {
|
|
|
27
27
|
'@resolution-xl': '@media (-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi)',
|
|
28
28
|
'@contrast-more': '@media (prefers-contrast: more)',
|
|
29
29
|
'@data-reduce': '@media (prefers-reduced-data: reduce)',
|
|
30
|
-
xs: '@media (max-width
|
|
31
|
-
'@xs': '@media (max-width
|
|
32
|
-
sm: '@media (min-width
|
|
33
|
-
'@sm': '@media (min-width
|
|
34
|
-
md: '@media (min-width
|
|
35
|
-
'@md': '@media (min-width
|
|
36
|
-
lg: '@media (min-width
|
|
37
|
-
'@lg': '@media (min-width
|
|
38
|
-
xl: '@media (min-width
|
|
39
|
-
'@xl': '@media (min-width
|
|
40
|
-
|
|
41
|
-
'@
|
|
42
|
-
|
|
43
|
-
'-xs': '@media (min-width : 576px)',
|
|
44
|
-
'-@xs': '@media (min-width : 576px)',
|
|
45
|
-
'-@sm': '@media (max-width : 576px)',
|
|
46
|
-
'-sm': '@media (max-width : 576px)',
|
|
47
|
-
'-@md': '@media (max-width : 768px)',
|
|
48
|
-
'-md': '@media (max-width : 768px)',
|
|
49
|
-
'-@lg': '@media (max-width : 992px)',
|
|
50
|
-
'-lg': '@media (max-width : 992px)',
|
|
51
|
-
'-@xl': '@media (max-width : 1200px)',
|
|
52
|
-
'-xl': '@media (max-width : 1200px)',
|
|
53
|
-
// '-@xxl': '@media (max-width : 1408px)',
|
|
54
|
-
// '-xxl': '@media (max-width : 1408px)',
|
|
55
|
-
'-@2xl': '@media (max-width : 1408px)',
|
|
56
|
-
'-2xl': '@media (max-width : 1408px)',
|
|
57
|
-
'dark': '@media (prefers-color-scheme: dark)',
|
|
30
|
+
xs: '@media (max-width: 575.99px)',
|
|
31
|
+
'@xs': '@media (max-width: 575.99px)',
|
|
32
|
+
sm: '@media (min-width: 576px)',
|
|
33
|
+
'@sm': '@media (min-width: 576px)',
|
|
34
|
+
md: '@media (min-width: 768px)',
|
|
35
|
+
'@md': '@media (min-width: 768px)',
|
|
36
|
+
lg: '@media (min-width: 992px)',
|
|
37
|
+
'@lg': '@media (min-width: 992px)',
|
|
38
|
+
xl: '@media (min-width: 1200px)',
|
|
39
|
+
'@xl': '@media (min-width: 1200px)',
|
|
40
|
+
xxl: '@media (min-width: 1408px)',
|
|
41
|
+
'@xxl': '@media (min-width: 1408px)',
|
|
42
|
+
dark: '@media (prefers-color-scheme: dark)',
|
|
58
43
|
'@dark': '@media (prefers-color-scheme: dark)',
|
|
59
|
-
|
|
44
|
+
light: '@media (prefers-color-scheme: light)',
|
|
60
45
|
'@light': '@media (prefers-color-scheme: light)',
|
|
61
46
|
'@theme': '@layer theme',
|
|
62
47
|
'@base': '@layer base',
|
|
48
|
+
'@reset': '@layer reset',
|
|
49
|
+
'@rs': '@layer reset',
|
|
63
50
|
'@components': '@layer components',
|
|
64
51
|
'@comps': '@layer components',
|
|
65
52
|
'@utils': '@layer utilities',
|
|
66
53
|
'@utilities': '@layer utilities',
|
|
67
54
|
'@starting-style': '@starting-style',
|
|
68
|
-
'@ss': '@starting-style'
|
|
55
|
+
'@ss': '@starting-style'
|
|
69
56
|
},
|
|
70
57
|
};
|
|
71
58
|
export function createRegexForMedia(prefix) {
|
|
@@ -9,30 +9,38 @@
|
|
|
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(/_$/)) {
|
|
29
|
-
|
|
36
|
+
// replace --[name] with var(--[name])
|
|
37
|
+
const val = value.replace(/(?<!var\()(--[\w-]+)/g, 'var($1)')
|
|
30
38
|
.replace(/^[(]/, '').replace(/_$/, '').replace(/[)]$/, '')
|
|
31
39
|
.replace(/,/g, ', ');
|
|
32
40
|
value = val.replace(/_/g, ' ');
|
|
33
41
|
}
|
|
34
42
|
else {
|
|
35
|
-
const val = value.replace(/(--[\w-]+)/g, 'var($1)')
|
|
43
|
+
const val = value.replace(/(?<!var\()(--[\w-]+)/g, 'var($1)')
|
|
36
44
|
.replace(/^[(]/, '').replace(/[)]$/, '')
|
|
37
45
|
.replace(/,/g, ' ');
|
|
38
46
|
value = val.replace(/_/g, ' ');
|
|
@@ -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) {
|
|
@@ -128,14 +131,14 @@ bool = false) {
|
|
|
128
131
|
// New Update function value
|
|
129
132
|
if (/^\(.+\)[_]?$/.test(valuePortion)) {
|
|
130
133
|
if (valuePortion.match(/_$/)) {
|
|
131
|
-
const val = valuePortion.replace(/(--[\w-]+)/g, 'var($1)')
|
|
134
|
+
const val = valuePortion.replace(/(?<!var\()(--[\w-]+)/g, 'var($1)')
|
|
132
135
|
.replace(/^[(]/, '').replace(/_$/, '').replace(/[)]$/, '')
|
|
133
136
|
.replace(/,/g, ', ')
|
|
134
137
|
.replace(/[_]/g, ' ');
|
|
135
138
|
return bool ? [prop, val] : prop + ":" + val;
|
|
136
139
|
}
|
|
137
140
|
else {
|
|
138
|
-
const val = valuePortion.replace(/(--[\w-]+)/g, 'var($1)')
|
|
141
|
+
const val = valuePortion.replace(/(?<!var\()(--[\w-]+)/g, 'var($1)')
|
|
139
142
|
.replace(/^[(]/, '').replace(/[)]$/, '')
|
|
140
143
|
.replace(/,/g, ' ')
|
|
141
144
|
.replace(/[_]/g, ' ');
|
|
@@ -154,13 +157,13 @@ bool = false) {
|
|
|
154
157
|
// check if has :()
|
|
155
158
|
if (/^\(.+\)[_]?$/.test(value)) {
|
|
156
159
|
if (value.match(/_$/)) {
|
|
157
|
-
const val = value.replace(/(--[\w-]+)/g, 'var($1)')
|
|
160
|
+
const val = value.replace(/(?<!var\()(--[\w-]+)/g, 'var($1)')
|
|
158
161
|
.replace(/^[(]/, '').replace(/_$/, '').replace(/[)]$/, '')
|
|
159
162
|
.replace(/,/g, ', ');
|
|
160
163
|
value = val;
|
|
161
164
|
}
|
|
162
165
|
else {
|
|
163
|
-
const val = value.replace(/(--[\w-]+)/g, 'var($1)')
|
|
166
|
+
const val = value.replace(/(?<!var\()(--[\w-]+)/g, 'var($1)')
|
|
164
167
|
.replace(/^[(]/, '').replace(/[)]$/, '')
|
|
165
168
|
.replace(/,/g, ' ');
|
|
166
169
|
value = val;
|
|
@@ -177,6 +180,12 @@ bool = false) {
|
|
|
177
180
|
}
|
|
178
181
|
return bool ? [prop, "var(" + cssVar + ',' + value + ')'] : prop + ": var(" + cssVar + ',' + value + ')';
|
|
179
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
|
+
}
|
|
180
189
|
return bool ? [prop, "var(" + valuePortion + ')'] : prop + ": var(" + valuePortion + ')';
|
|
181
190
|
}
|
|
182
191
|
if (property.hasOwnProperty('compiler') && typeof property.compiler === 'function') {
|
package/lib/returnStatement.js
CHANGED
|
@@ -155,15 +155,23 @@ export const compiler = {
|
|
|
155
155
|
// ------------PostCSSParse
|
|
156
156
|
if (result) {
|
|
157
157
|
let stm = '';
|
|
158
|
-
className = (as ? as : className).replace(/([$.&%=\]\[@~,:*#+\(\)
|
|
158
|
+
className = (as ? as : className).replace(/([$.&%=\]\[@~,:*#+\(\)\/^/</>])/g, '\\$1');
|
|
159
159
|
if (bool === true)
|
|
160
160
|
return result;
|
|
161
161
|
this.cache.propertyAndValue[pnv] = result;
|
|
162
162
|
if (mediaEX.length) {
|
|
163
163
|
let [bf, af] = ['', ''];
|
|
164
164
|
mediaEX.map((e) => {
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
const mediaQuery = e.split('::::')[0];
|
|
166
|
+
const mediaPrefix = e.split('::::')[1].replace(/^@/, '');
|
|
167
|
+
if (['xs', 'sm', 'md', 'lg', 'xl', 'xxl'].indexOf(mediaPrefix) !== -1) {
|
|
168
|
+
bf = bf + `@layer ${mediaPrefix}{ ${mediaQuery} {`;
|
|
169
|
+
af = af + "}}";
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
bf = bf + mediaQuery + "{ ";
|
|
173
|
+
af = af + "}";
|
|
174
|
+
}
|
|
167
175
|
});
|
|
168
176
|
stm = `${bf}${beforeClassNameSelector + '.' + className + elementAndPseudo}{${result}${important}}${af}`;
|
|
169
177
|
}
|
|
@@ -182,6 +190,9 @@ export const compiler = {
|
|
|
182
190
|
console.log(`Unable to process ${className} [media:${mediaEX},pseudoSelector:${elementAndPseudo},imp:${important}]`);
|
|
183
191
|
}
|
|
184
192
|
},
|
|
193
|
+
// groupSingle(str:string, as:string){
|
|
194
|
+
// let pnv='';
|
|
195
|
+
// },
|
|
185
196
|
group(str, as) {
|
|
186
197
|
let statement = '';
|
|
187
198
|
[...str.trim().split(/\s+/)].forEach((e) => {
|
|
@@ -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',
|