aliascss 1.1.12 → 1.1.14
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 +270 -181
- package/aliascss.config.js +3 -1
- package/dist/aliascss.js +1 -1
- package/lib/classPrinter.js +3 -2
- package/lib/compilers/shadow.js +1 -1
- package/lib/css-properties-all.js +16 -1
- package/lib/node/compileFile.js +3 -2
- package/lib/prefix/pseudoSelectorNew.js +1 -1
- package/lib/prefix/responsive.js +2 -0
- package/lib/returnPropertyAndValue.js +13 -0
- package/lib/returnStatement.js +16 -4
- package/package.json +1 -1
package/lib/classPrinter.js
CHANGED
|
@@ -79,11 +79,12 @@ export let classPrinter = {
|
|
|
79
79
|
if (testRegExpKF.test(each.name)) {
|
|
80
80
|
const key = each.name.replace(testRegExpKF, '');
|
|
81
81
|
let kfStatement = '@keyframes ' + key + "{\n";
|
|
82
|
+
const returnPnV = (e) => e.map((i) => statementMaker.make(i, undefined, true)).join(";");
|
|
82
83
|
const split = each.value.trim().split(/\s+/);
|
|
83
84
|
split.forEach((each) => {
|
|
84
85
|
try {
|
|
85
|
-
const [at, pNv] = each.replace("-", "=").split("=");
|
|
86
|
-
const result =
|
|
86
|
+
const [at, pNv] = each.replace(/\]\[/, ']-[').replace("-", "=").split("=");
|
|
87
|
+
const result = returnPnV(pNv.replace(/^\[|\]$/g, '').split(','));
|
|
87
88
|
kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${result ? result : ''}}`;
|
|
88
89
|
}
|
|
89
90
|
catch (error) {
|
package/lib/compilers/shadow.js
CHANGED
|
@@ -27,7 +27,7 @@ export default function shadow(data, custom) {
|
|
|
27
27
|
compileValue += eachValue + ",";
|
|
28
28
|
// search for length /()/
|
|
29
29
|
});
|
|
30
|
-
return compileValue.replace(/[,]$/, '').trim();
|
|
30
|
+
return compileValue.replace(/[,]$/, '').replace(/%x/g, '%').trim();
|
|
31
31
|
}
|
|
32
32
|
const ref = `/* Keyword values */
|
|
33
33
|
box-shadow: none;
|
|
@@ -967,7 +967,7 @@ const cssProps = {
|
|
|
967
967
|
values: ['content:c', 'fixed:f'],
|
|
968
968
|
},
|
|
969
969
|
'filter': {
|
|
970
|
-
alias: '',
|
|
970
|
+
alias: 'fl',
|
|
971
971
|
type: 'd',
|
|
972
972
|
compiler: filter,
|
|
973
973
|
values: ['none:n', 'invert():invert:i', 'sepia():sepia:se', 'grayscale():grayscale:gs'],
|
|
@@ -2656,5 +2656,20 @@ const cssProps = {
|
|
|
2656
2656
|
// compiler:'',
|
|
2657
2657
|
values: ['arcs', 'bevel', 'iter', 'miter-clip', 'round'],
|
|
2658
2658
|
},
|
|
2659
|
+
// -------------webkit---
|
|
2660
|
+
'webkit-line-cramp': {
|
|
2661
|
+
alias: '',
|
|
2662
|
+
property: '-webkit-line-clamp',
|
|
2663
|
+
type: 'd',
|
|
2664
|
+
compiler: (value) => value.replace(/^-/, ''),
|
|
2665
|
+
values: ['none:n'],
|
|
2666
|
+
},
|
|
2667
|
+
'webkit-box-orient': {
|
|
2668
|
+
alias: '',
|
|
2669
|
+
property: '-webkit-box-orient',
|
|
2670
|
+
type: 's',
|
|
2671
|
+
// compiler:(value:string)=>value.replace(/^-/,''),
|
|
2672
|
+
values: ['horizontal:h', 'vertical:v', 'inline-axis:ia', 'block-axis:ba'],
|
|
2673
|
+
}
|
|
2659
2674
|
};
|
|
2660
2675
|
export default cssProps;
|
package/lib/node/compileFile.js
CHANGED
|
@@ -120,11 +120,12 @@ export function groupStatement(name, classNames, statementMaker) {
|
|
|
120
120
|
}
|
|
121
121
|
export function keyframesStatement(name, timeLine, statementMaker) {
|
|
122
122
|
let kfStatement = '@keyframes ' + name + "{\n";
|
|
123
|
+
const returnPnV = (e) => e.map((i) => statementMaker.make(i, null, true)).join(";");
|
|
123
124
|
const split = timeLine.split(/\s+/);
|
|
124
125
|
split.forEach((each) => {
|
|
125
126
|
try {
|
|
126
|
-
const [at, pNv] = each.replace("-", "=").split("=");
|
|
127
|
-
kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${
|
|
127
|
+
const [at, pNv] = each.replace(/\]\[/, ']-[').replace("-", "=").split("=");
|
|
128
|
+
kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${returnPnV(pNv.replace(/^\[|\]$/g, '').split(','))}}`;
|
|
128
129
|
}
|
|
129
130
|
catch (error) {
|
|
130
131
|
console.error('Not a valid entry for AliasCSS keyframes processor : ' + each, error);
|
|
@@ -47,7 +47,7 @@ export default function PseudoEleStateNew(data) {
|
|
|
47
47
|
const cn = (mch === null || mch === void 0 ? void 0 : mch[0]) ? data.replace(mch[0], '') : '';
|
|
48
48
|
const alias = (mch === null || mch === void 0 ? void 0 : mch[1]) ? prefix[mch[1].replace(/-$/, '')] : '';
|
|
49
49
|
const cont = mch === null || mch === void 0 ? void 0 : mch[3];
|
|
50
|
-
console.log(data,
|
|
50
|
+
// console.log(data,cn,alias,mch)
|
|
51
51
|
return [cn, `${alias}(${cont})`];
|
|
52
52
|
}
|
|
53
53
|
else if (/(^-(-not|-has|-is|-where|-n|-hs|-w|-is)[-_])/.test(data)) {
|
package/lib/prefix/responsive.js
CHANGED
|
@@ -17,6 +17,8 @@ const media = {
|
|
|
17
17
|
'-xl': '@media (max-width : 1200px)',
|
|
18
18
|
'-xxl': '@media (max-width : 1408px)',
|
|
19
19
|
'-2xl': '@media (max-width : 1408px)',
|
|
20
|
+
'dark': '@media (prefers-color-scheme: dark)',
|
|
21
|
+
'light': '@media (prefers-color-scheme: light)'
|
|
20
22
|
},
|
|
21
23
|
};
|
|
22
24
|
export function createRegexForMedia(prefix) {
|
|
@@ -4,6 +4,19 @@ bool = false) {
|
|
|
4
4
|
if (staticClassNames.hasOwnProperty(className)) {
|
|
5
5
|
return staticClassNames[className];
|
|
6
6
|
}
|
|
7
|
+
// case CSS define var
|
|
8
|
+
if (className.startsWith('--') && className.includes(':')) {
|
|
9
|
+
const value = className.slice(className.indexOf(':')).replace(':', '');
|
|
10
|
+
const property = className.replace(value, '').replace(':', '');
|
|
11
|
+
if (/^--[a-zA-Z]/.test(value)) {
|
|
12
|
+
return bool ? [property, "var(" + value + ')'] : property + ": var(" + value + ')';
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
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, ' / ').replace(/auto flow/g, 'auto-flow')]
|
|
16
|
+
:
|
|
17
|
+
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, ' / ').replace(/auto flow/g, 'auto-flow');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
7
20
|
const [property, propertyKey] = extractProperty(className, cssPropertiesWithAlias);
|
|
8
21
|
// console.log(propertyKey,'ttt',property,className)
|
|
9
22
|
if (property) {
|
package/lib/returnStatement.js
CHANGED
|
@@ -43,6 +43,15 @@ export const compiler = {
|
|
|
43
43
|
// className as another-name, bool->only return property and value
|
|
44
44
|
make(className, as, bool) {
|
|
45
45
|
let unPrefixedClassName = className;
|
|
46
|
+
// check for [group-acss,]
|
|
47
|
+
const matchGroupCSS = className.match(/\[([^[]*)\]$/);
|
|
48
|
+
if (matchGroupCSS) {
|
|
49
|
+
const asString = matchGroupCSS[1]
|
|
50
|
+
.split(',')
|
|
51
|
+
.map(e => (className.replace(matchGroupCSS[0], '') + "-").replace(/--$/, '-') + e)
|
|
52
|
+
.join(' ');
|
|
53
|
+
return this.group(asString, className);
|
|
54
|
+
}
|
|
46
55
|
let beforeClassNameSelector = '';
|
|
47
56
|
if (this.prefix && !className.match(new RegExp('^' + this.prefix + "[-]"))) {
|
|
48
57
|
return null;
|
|
@@ -63,6 +72,9 @@ export const compiler = {
|
|
|
63
72
|
console.error('Not a valid AliasCSS className:' + className, 'Make sure to provide valid css aliascss selector before "&" identifier');
|
|
64
73
|
return null;
|
|
65
74
|
}
|
|
75
|
+
else {
|
|
76
|
+
beforeClassNameSelector = beforeClassNameSelector.replace(/^([\s]?[+~>])(.*)/, "$2$1 ");
|
|
77
|
+
}
|
|
66
78
|
workingClassName = workingClassName.replace(before, '').replace('&', '');
|
|
67
79
|
}
|
|
68
80
|
let [elementAndPseudo, important] = ['', ''];
|
|
@@ -77,7 +89,7 @@ export const compiler = {
|
|
|
77
89
|
workingClassName = prefixPseudoElementAttribute[1];
|
|
78
90
|
elementAndPseudo = prefixPseudoElementAttribute[0];
|
|
79
91
|
// ---------------------------------------------------------------------
|
|
80
|
-
const pnv = workingClassName.replace(
|
|
92
|
+
const pnv = workingClassName.replace(/^-([a-zA-Z])/, '$1');
|
|
81
93
|
let result = '';
|
|
82
94
|
// x-class
|
|
83
95
|
if (/^(x-width|x-height)/.test(pnv)) {
|
|
@@ -117,15 +129,15 @@ export const compiler = {
|
|
|
117
129
|
// ------------PostCSSParse
|
|
118
130
|
if (result) {
|
|
119
131
|
let stm = '';
|
|
120
|
-
className = className.replace(/([$.&%=\]\[
|
|
132
|
+
className = (as ? as : className).replace(/([$.&%=\]\[@~,:*#+\(\)\/^])/g, '\\$1');
|
|
121
133
|
if (bool === true)
|
|
122
134
|
return result;
|
|
123
135
|
this.cache.propertyAndValue[pnv] = result;
|
|
124
136
|
if (media) {
|
|
125
|
-
stm = `${media}{${beforeClassNameSelector + '.' +
|
|
137
|
+
stm = `${media}{${beforeClassNameSelector + '.' + className + elementAndPseudo}{${result}${important}}}`;
|
|
126
138
|
}
|
|
127
139
|
else {
|
|
128
|
-
stm = `${beforeClassNameSelector}.${
|
|
140
|
+
stm = `${beforeClassNameSelector}.${className}${elementAndPseudo}{${result}${important}}`;
|
|
129
141
|
}
|
|
130
142
|
try {
|
|
131
143
|
postcss.parse(stm);
|