aliascss 1.5.0 → 1.5.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/CHANGELOG.md +29 -0
- package/dist/aliascss.js +1 -1
- package/jestconfig.json +1 -3
- package/lib/build/index.js +136 -19
- package/lib/classPrinter.d.ts +1 -1
- package/lib/classPrinter.js +4 -2
- package/lib/compilers/border.js +106 -27
- package/lib/compilers/clipPath.js +79 -6
- package/lib/compilers/color.js +150 -21
- package/lib/compilers/filter.js +90 -3
- package/lib/compilers/font.js +39 -11
- package/lib/compilers/gradient.js +43 -27
- package/lib/compilers/length.js +34 -9
- package/lib/compilers/shadow.js +60 -26
- package/lib/compilers/stringAndContent.js +39 -2
- package/lib/compilers/timingFunction.js +57 -6
- package/lib/compilers/transform.js +118 -48
- package/lib/compilers/transition.js +79 -11
- package/lib/compilers/url.js +53 -3
- package/lib/index.d.ts +9 -9
- package/lib/node/compileFile.js +2 -2
- package/lib/returnPropertyAndValue-bk-301026.d.ts +30 -0
- package/lib/returnPropertyAndValue-bk-301026.js +219 -0
- package/lib/returnPropertyAndValue.js +26 -25
- package/lib/returnStatement.js +6 -2
- package/lib/utils/helper.js +16 -2
- package/lib/x-classes/x-form-components.js +2 -1
- package/llms.txt +326 -0
- package/package.json +3 -1
- package/tsconfig.json +1 -0
- package/tsconfig.test.json +10 -0
package/lib/compilers/shadow.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import color from './color.js';
|
|
2
2
|
export default function shadow(data, custom) {
|
|
3
3
|
let compileValue = '';
|
|
4
|
+
if (/^-?none$/.test(data))
|
|
5
|
+
return 'none';
|
|
4
6
|
data.split(/__/).forEach((e) => {
|
|
5
7
|
let eachValue = ' ';
|
|
6
8
|
let len = '';
|
|
@@ -12,15 +14,16 @@ export default function shadow(data, custom) {
|
|
|
12
14
|
if (!e.startsWith('-'))
|
|
13
15
|
e = "-" + e;
|
|
14
16
|
// fix Zero
|
|
15
|
-
|
|
16
|
-
|
|
17
|
+
// a 0 at the end counts too: shadow-0-0 -> 0px 0px
|
|
18
|
+
e = e.replace(/(?<=-)0(?=-|$)/g, '0px').replace(/([-][0-9pd]{6,})/, (a) => a.replace(/p/g, 'xer'));
|
|
19
|
+
const match = e.match(/([-]?[-]?[0-9]{1,3}[d/.]?[0-9]*(px|pt|pc|em|fr|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|p))+/); // pt/pc before p
|
|
17
20
|
if (match) {
|
|
18
21
|
len = match[0];
|
|
19
22
|
e = e.replace(len, '');
|
|
20
23
|
}
|
|
21
24
|
if (len) {
|
|
22
25
|
// eachValue+=len.replace(/-0px-/g,'-0-').replace(/[-]([-]?[\d])/g,' $1').trim()+" ";
|
|
23
|
-
eachValue += len.replace(/[-]([-]?[\d])/g, ' $1').trim() + " ";
|
|
26
|
+
eachValue += len.replace(/[-]([-]?[\d])/g, ' $1').replace(/(\d)d(\d)/g, '$1.$2').trim() + " "; // 1d5px -> 1.5px
|
|
24
27
|
const col = color(e.replace(/xer/g, 'p'), custom);
|
|
25
28
|
if (col) {
|
|
26
29
|
eachValue += col + " ";
|
|
@@ -31,27 +34,58 @@ export default function shadow(data, custom) {
|
|
|
31
34
|
});
|
|
32
35
|
return compileValue.replace(/[,]$/, '').replace(/%x/g, '%').trim();
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
/* A color and two length values */
|
|
38
|
-
/* <color> | <length> | <length> */
|
|
39
|
-
box-shadow: red 60px -16px;
|
|
40
|
-
|
|
41
|
-
/* Three length values and a color */
|
|
42
|
-
/* <length> | <length> | <length> | <color> */
|
|
43
|
-
box-shadow: 10px 5px 5px black;
|
|
44
|
-
|
|
45
|
-
/* Four length values and a color */
|
|
46
|
-
/* <length> | <length> | <length> | <length> | <color> */
|
|
47
|
-
box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 20%);
|
|
48
|
-
|
|
49
|
-
/* inset, length values, and a color */
|
|
50
|
-
/* <inset> | <length> | <length> | <color> */
|
|
51
|
-
box-shadow: inset 5em 1em gold;
|
|
37
|
+
/*
|
|
38
|
+
import color from './color.js';
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
40
|
+
export default function shadow(data: string, custom: { [key: string]: { [key: string]: string } }) {
|
|
41
|
+
let compileValue='';
|
|
42
|
+
data.split(/__/).forEach((e)=>{
|
|
43
|
+
let eachValue=' ';
|
|
44
|
+
let len='';
|
|
45
|
+
const col='';
|
|
46
|
+
if (e.match(/^[-]?(i|inset)/)) {
|
|
47
|
+
eachValue += 'inset ';
|
|
48
|
+
e=e.replace(/^[-]?(inset|i)/,'');
|
|
49
|
+
}
|
|
50
|
+
if(!e.startsWith('-')) e="-"+e;
|
|
51
|
+
// fix Zero
|
|
52
|
+
e=e.replace(/(?<=-)0(?=-)/g,'0px').replace(/([-][0-9pd]{6,})/,(a)=>a.replace(/p/g,'xer'));
|
|
53
|
+
const match=e.match(/([-]?[-]?[0-9]{1,3}[d/.]?[0-9]*(px|em|p|fr|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc))+/);
|
|
54
|
+
if(match){
|
|
55
|
+
len=match[0];
|
|
56
|
+
e=e.replace(len,'')
|
|
57
|
+
}
|
|
58
|
+
if(len){
|
|
59
|
+
// eachValue+=len.replace(/-0px-/g,'-0-').replace(/[-]([-]?[\d])/g,' $1').trim()+" ";
|
|
60
|
+
eachValue+=len.replace(/[-]([-]?[\d])/g,' $1').trim()+" ";
|
|
61
|
+
const col=color(e.replace(/xer/g,'p'),custom);
|
|
62
|
+
if(col) {
|
|
63
|
+
eachValue+=col+" ";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
compileValue+=eachValue + ",";
|
|
67
|
+
|
|
68
|
+
// search for length /()/
|
|
69
|
+
})
|
|
70
|
+
return compileValue.replace(/[,]$/,'').replace(/%x/g,'%').trim();
|
|
71
|
+
}
|
|
72
|
+
*/
|
|
73
|
+
// const ref =`/* Keyword values */
|
|
74
|
+
// box-shadow: none;
|
|
75
|
+
// /* A color and two length values */
|
|
76
|
+
// /* <color> | <length> | <length> */
|
|
77
|
+
// box-shadow: red 60px -16px;
|
|
78
|
+
// /* Three length values and a color */
|
|
79
|
+
// /* <length> | <length> | <length> | <color> */
|
|
80
|
+
// box-shadow: 10px 5px 5px black;
|
|
81
|
+
// /* Four length values and a color */
|
|
82
|
+
// /* <length> | <length> | <length> | <length> | <color> */
|
|
83
|
+
// box-shadow: 2px 2px 2px 1px rgb(0 0 0 / 20%);
|
|
84
|
+
// /* inset, length values, and a color */
|
|
85
|
+
// /* <inset> | <length> | <length> | <color> */
|
|
86
|
+
// box-shadow: inset 5em 1em gold;
|
|
87
|
+
// /* Any number of shadows, separated by commas */
|
|
88
|
+
// box-shadow:
|
|
89
|
+
// 3px 3px red inset,
|
|
90
|
+
// -1em 0 0.4em olive;
|
|
91
|
+
// `
|
|
@@ -3,12 +3,18 @@ export function string(str, custom) {
|
|
|
3
3
|
return str.replace(/^[-]/, '').replace(/__/g, ', ');
|
|
4
4
|
}
|
|
5
5
|
export default function content(str) {
|
|
6
|
-
//
|
|
6
|
+
// the value arrives with its leading "-" (content-_2022 -> "-_2022"): strip it first,
|
|
7
|
+
// otherwise the entity check below never matched and _2022 became the text " 2022"
|
|
8
|
+
str = str.replace(/^[-]/, '');
|
|
9
|
+
// for CSS entities: _2022 -> "\2022", _2014_00a0 -> "\2014\00a0"
|
|
7
10
|
if (str.match(/^_/)) {
|
|
8
11
|
// return '"' + str.split("_").join(" \\").trim() + '"';
|
|
9
12
|
return '"' + str.slice(1).split('_').map(c => '\\' + c).join('') + '"';
|
|
10
13
|
}
|
|
11
|
-
|
|
14
|
+
// raw functions pass through: attr(data-label), counter(item), counters(item,_"."), var(--x)
|
|
15
|
+
if (/^[a-z-]+\(.*\)$/.test(str)) {
|
|
16
|
+
return str.replace(/_/g, ' ');
|
|
17
|
+
}
|
|
12
18
|
// attr() or counter()
|
|
13
19
|
const data = str.match(/^(attr|counter)?[-_]([\w-]+)/);
|
|
14
20
|
if (data) {
|
|
@@ -22,3 +28,34 @@ export default function content(str) {
|
|
|
22
28
|
// return plain string with quotes
|
|
23
29
|
return '"' + str.replace(/[_]/g, ' ') + '"';
|
|
24
30
|
}
|
|
31
|
+
/*
|
|
32
|
+
export function string(str: string, custom: { [key: string]: { [key: string]: string } }) {
|
|
33
|
+
// return string as it is only changes __ to ,
|
|
34
|
+
return str.replace(/^[-]/, '').replace(/__/g,', ');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export default function content(str: string) {
|
|
39
|
+
// for CSS entities
|
|
40
|
+
if (str.match(/^_/)) {
|
|
41
|
+
// return '"' + str.split("_").join(" \\").trim() + '"';
|
|
42
|
+
return '"' + str.slice(1).split('_').map(c => '\\' + c).join('') + '"';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
str = str.replace(/^[-]/, '');
|
|
46
|
+
|
|
47
|
+
// attr() or counter()
|
|
48
|
+
const data = str.match(/^(attr|counter)?[-_]([\w-]+)/);
|
|
49
|
+
if (data) {
|
|
50
|
+
if (data[1] === 'attr') {
|
|
51
|
+
return 'attr(' + data[2] + ')';
|
|
52
|
+
}
|
|
53
|
+
if (data[1] === 'counter') {
|
|
54
|
+
return 'counter(' + data[2] + ')';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// return plain string with quotes
|
|
59
|
+
return '"' + str.replace(/[_]/g, ' ') + '"';
|
|
60
|
+
}
|
|
61
|
+
*/
|
|
@@ -17,17 +17,27 @@ export default function timingFunction(data, custom) {
|
|
|
17
17
|
'step-end': 'step-end',
|
|
18
18
|
};
|
|
19
19
|
let result = '';
|
|
20
|
-
|
|
21
|
-
const
|
|
20
|
+
// any number of decimals: 0d16, 0d175, 1d56 (before: one digit only, so most real curves failed)
|
|
21
|
+
const test1 = /(cubic-bezier|cb)(([-_][-]?[0-9]+(?:[d.][0-9]+)?){4})/;
|
|
22
|
+
// the position is optional: steps-4 -> steps(4)
|
|
23
|
+
const test2 = /(steps|s)[-_]([0-9]+)(?:[-_]((jump)?[-]?(start|end|none|both)))?/;
|
|
22
24
|
data.split('__').forEach((e) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
+
// raw functions pass through: cubic-bezier()/cb(), steps(), linear() ("_" is a space)
|
|
26
|
+
if (/^(cubic-bezier|cb|steps|linear)\(.*\)$/.test(e)) {
|
|
27
|
+
result = result + e.replace('cb(', 'cubic-bezier(').replace(/_/g, ' ') + ", ";
|
|
25
28
|
}
|
|
26
29
|
else if (test1.test(e)) {
|
|
27
|
-
result = result + e.replace(test1, (e, f, g) => 'cubic-bezier' + "(" + g.replace(/-/, "").replace(/--/g, '-Minus').replace(/-/g, ", ").replace(/d/g, ".").replace(/Minus/g, '-') + ")") + ", ";
|
|
30
|
+
result = result + e.replace(test1, (e, f, g) => 'cubic-bezier' + "(" + g.replace(/_/g, '-').replace(/-/, "").replace(/--/g, '-Minus').replace(/-/g, ", ").replace(/d/g, ".").replace(/Minus/g, '-') + ")") + ", ";
|
|
28
31
|
}
|
|
29
32
|
else if (test2.test(e)) {
|
|
30
|
-
result = result + e.replace(test2, (e, f, g, h) =>
|
|
33
|
+
result = result + e.replace(test2, (e, f, g, h) => {
|
|
34
|
+
if (!h)
|
|
35
|
+
return "steps(" + g + ")";
|
|
36
|
+
// jump-* keywords need the dash: jumpstart / none / both -> jump-start / jump-none / jump-both
|
|
37
|
+
const pos = h.replace(/^jump-?/, '');
|
|
38
|
+
const kw = /^(none|both)$/.test(pos) || /^jump/.test(h) ? 'jump-' + pos : pos;
|
|
39
|
+
return "steps" + "(" + g + ", " + kw + ")";
|
|
40
|
+
}) + ", ";
|
|
31
41
|
}
|
|
32
42
|
else if (/^(e|ease|l|linear|ei|ease-in|eo|ease-out|eio|ease-in-out|ss|step-start|se|step-end)$/.test(e)) {
|
|
33
43
|
result = result + func[e] + ", ";
|
|
@@ -36,3 +46,44 @@ export default function timingFunction(data, custom) {
|
|
|
36
46
|
if (result.trim())
|
|
37
47
|
return result.trim().replace(/[,]$/, '');
|
|
38
48
|
}
|
|
49
|
+
/*
|
|
50
|
+
export default function timingFunction(data: string, custom: { [key: string]: { [key: string]: string } }) {
|
|
51
|
+
data = data.replace(/^[-_]/, '');
|
|
52
|
+
|
|
53
|
+
const func: { [key: string]: string } = {
|
|
54
|
+
e: 'ease',
|
|
55
|
+
ease: 'ease',
|
|
56
|
+
linear: 'linear',
|
|
57
|
+
l: 'linear',
|
|
58
|
+
ei: 'ease-in',
|
|
59
|
+
'ease-in': 'ease-in',
|
|
60
|
+
eo: 'ease-out',
|
|
61
|
+
'ease-out': 'ease-out',
|
|
62
|
+
eio: 'ease-in-out',
|
|
63
|
+
'ease-in-out': 'ease-in-out',
|
|
64
|
+
ss: 'step-start',
|
|
65
|
+
'step-start': 'step-start',
|
|
66
|
+
se: 'step-end',
|
|
67
|
+
'step-end': 'step-end',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
let result:string='';
|
|
71
|
+
const test1=/(cubic-bezier|cb)(([-_][-]?[0-9][d.]?[0-9]?){4})/;
|
|
72
|
+
const test2=/(steps|s)[-_]([0-9]+)[-]((jump)?[-]?(start|end|none|both))/;
|
|
73
|
+
data.split('__').forEach((e)=>{
|
|
74
|
+
if(/\b(cubic-bezier|cb)\((-?\d*\.?\d+),(-?\d*\.?\d+),(-?\d*\.?\d+),(-?\d*\.?\d+)\)/.test(e)){
|
|
75
|
+
result=result+ e.replace('cb(','cubic-bezier(') + ", ";
|
|
76
|
+
|
|
77
|
+
}else if(test1.test(e)){
|
|
78
|
+
result= result+ e.replace(test1,(e,f,g)=>'cubic-bezier'+"("+g.replace(/-/,"").replace(/--/g,'-Minus').replace(/-/g,", ").replace(/d/g,".").replace(/Minus/g,'-')+")") +", ";
|
|
79
|
+
}else if(test2.test(e)){
|
|
80
|
+
result=result+e.replace(test2,(e,f,g,h)=>"steps"+"("+g+", " + h+")")+", ";
|
|
81
|
+
}else if(/^(e|ease|l|linear|ei|ease-in|eo|ease-out|eio|ease-in-out|ss|step-start|se|step-end)$/.test(e)){
|
|
82
|
+
result=result+func[e]+", ";
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
if(result.trim()) return result.trim().replace(/[,]$/,'');
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
*/
|
|
@@ -7,7 +7,7 @@ export default (value) => {
|
|
|
7
7
|
value.split(/__(?=[a-z])/).forEach((e) => {
|
|
8
8
|
//
|
|
9
9
|
if (e.match(/[(]/)) {
|
|
10
|
-
compileValue += e + " ";
|
|
10
|
+
compileValue += e.replace(/_/g, ' ') + " "; // raw function: "_" is a space
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
// extract function
|
|
@@ -21,8 +21,11 @@ export default (value) => {
|
|
|
21
21
|
function transformEach(data) {
|
|
22
22
|
if (data.match(/--[a-z]/)) {
|
|
23
23
|
const [func, cssVar] = data.split('--');
|
|
24
|
+
// tx--x:8px -> translateX(var(--x,8px))
|
|
25
|
+
const [name, fallback] = cssVar.split(':');
|
|
26
|
+
const fb = fallback !== undefined ? ',' + fallback.replace(/(?<=[0-9])[d](?=[0-9])/g, '.').replace(/(?<=[0-9])p$/, '%') : '';
|
|
24
27
|
if (tfAlias.hasOwnProperty(func))
|
|
25
|
-
return `${tfAlias[func]}(var(--${
|
|
28
|
+
return `${tfAlias[func]}(var(--${name}${fb}))`;
|
|
26
29
|
return;
|
|
27
30
|
}
|
|
28
31
|
const match = /([a-zA-z]+(3d)?)(([-]?[-]?[0-9]+[d]?[0-9]*[a-z]*))+/;
|
|
@@ -50,51 +53,117 @@ function transformEach(data) {
|
|
|
50
53
|
}
|
|
51
54
|
}
|
|
52
55
|
const tfAlias = {
|
|
53
|
-
m: 'matrix',
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
ty: 'translateY',
|
|
60
|
-
translateY: 'translateY',
|
|
61
|
-
s: 'scale',
|
|
62
|
-
scale: 'scale',
|
|
63
|
-
sx: 'scaleX',
|
|
64
|
-
scaleX: 'scaleX',
|
|
65
|
-
sy: 'scaleY',
|
|
66
|
-
scaleY: 'scaleY',
|
|
67
|
-
r: 'rotate',
|
|
68
|
-
rotate: 'rotate',
|
|
69
|
-
sk: 'skew',
|
|
70
|
-
skew: 'skew',
|
|
71
|
-
skx: 'skewX',
|
|
72
|
-
skewX: 'skewX',
|
|
73
|
-
sky: 'skewY',
|
|
74
|
-
skewY: 'skewY',
|
|
75
|
-
m3d: 'matrix3d',
|
|
76
|
-
matrix3d: 'matrix3d',
|
|
77
|
-
t3d: 'translate3d',
|
|
78
|
-
translate3d: 'translate3d',
|
|
79
|
-
tz: 'translateZ',
|
|
80
|
-
translateZ: 'translateZ',
|
|
81
|
-
s3d: 'scale3d',
|
|
82
|
-
scale3d: 'scale3d',
|
|
83
|
-
sz: 'scaleZ',
|
|
84
|
-
scaleZ: 'scaleZ',
|
|
85
|
-
r3d: 'rotate3d',
|
|
86
|
-
rotate3d: 'rotate3d',
|
|
87
|
-
rx: 'rotateX',
|
|
88
|
-
rotateX: 'rotateX',
|
|
89
|
-
ry: 'rotateY',
|
|
90
|
-
rotateY: 'rotateY',
|
|
91
|
-
rz: 'rotateZ',
|
|
92
|
-
rotateZ: 'rotateZ',
|
|
93
|
-
p: 'perspective',
|
|
94
|
-
perspective: 'perspective',
|
|
56
|
+
m: 'matrix', matrix: 'matrix', t: 'translate', translate: 'translate', tx: 'translateX', translateX: 'translateX',
|
|
57
|
+
ty: 'translateY', translateY: 'translateY', s: 'scale', scale: 'scale', sx: 'scaleX', scaleX: 'scaleX', sy: 'scaleY', scaleY: 'scaleY',
|
|
58
|
+
r: 'rotate', rotate: 'rotate', sk: 'skew', skew: 'skew', skx: 'skewX', skewX: 'skewX', sky: 'skewY', skewY: 'skewY',
|
|
59
|
+
m3d: 'matrix3d', matrix3d: 'matrix3d', t3d: 'translate3d', translate3d: 'translate3d', tz: 'translateZ', translateZ: 'translateZ',
|
|
60
|
+
s3d: 'scale3d', scale3d: 'scale3d', sz: 'scaleZ', scaleZ: 'scaleZ', r3d: 'rotate3d', rotate3d: 'rotate3d',
|
|
61
|
+
rx: 'rotateX', rotateX: 'rotateX', ry: 'rotateY', rotateY: 'rotateY', rz: 'rotateZ', rotateZ: 'rotateZ', p: 'perspective', perspective: 'perspective',
|
|
95
62
|
};
|
|
96
|
-
/*
|
|
97
|
-
|
|
63
|
+
/*
|
|
64
|
+
export default (value:string) => {
|
|
65
|
+
// Remove - before value
|
|
66
|
+
value=value.replace(/^-/,'');
|
|
67
|
+
// initialize compilerValue
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
let compileValue='';
|
|
71
|
+
// check for multiple value
|
|
72
|
+
|
|
73
|
+
value.split(/__(?=[a-z])/).forEach((e)=>{
|
|
74
|
+
//
|
|
75
|
+
if(e.match(/[(]/)){
|
|
76
|
+
compileValue+=e+" ";
|
|
77
|
+
return
|
|
78
|
+
}
|
|
79
|
+
// extract function
|
|
80
|
+
const result=transformEach(e);
|
|
81
|
+
|
|
82
|
+
if(result) compileValue+= result +" ";
|
|
83
|
+
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
if(compileValue.trim()) return compileValue.trim();
|
|
87
|
+
|
|
88
|
+
}
|
|
89
|
+
function transformEach(data: string) {
|
|
90
|
+
if(data.match(/--[a-z]/)){
|
|
91
|
+
const [func, cssVar]=data.split('--');
|
|
92
|
+
if(tfAlias.hasOwnProperty(func)) return `${tfAlias[func]}(var(--${cssVar}))`
|
|
93
|
+
return ;
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
const match = /([a-zA-z]+(3d)?)(([-]?[-]?[0-9]+[d]?[0-9]*[a-z]*))+/;
|
|
97
|
+
const exfunc = data.match(match);
|
|
98
|
+
let func = null;
|
|
99
|
+
if (exfunc) {
|
|
100
|
+
func = exfunc[1];
|
|
101
|
+
}
|
|
102
|
+
if (!func) return;
|
|
103
|
+
let statement = '';
|
|
104
|
+
if (tfAlias.hasOwnProperty(func)) {
|
|
105
|
+
statement += tfAlias[func] + '(';
|
|
106
|
+
statement +=
|
|
107
|
+
data
|
|
108
|
+
.replace(func, '').replace(/--/g,'-Minus').replace(/^-/,'')
|
|
109
|
+
.replace(/-/g, ', ').replace(/Minus/g,'-')
|
|
110
|
+
.replace(/(?<=[0-9])[d](?=[0-9])/g, '.')
|
|
111
|
+
.replace(/(?<=[0-9])[p](?=[\s|,])/g, '%')
|
|
112
|
+
.replace(/p$/, '%') + ')';
|
|
113
|
+
return statement;
|
|
114
|
+
} else {
|
|
115
|
+
return null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const tfAlias: { [key: string]: string } = {
|
|
120
|
+
m: 'matrix',
|
|
121
|
+
matrix: 'matrix',
|
|
122
|
+
t: 'translate',
|
|
123
|
+
translate: 'translate',
|
|
124
|
+
tx: 'translateX',
|
|
125
|
+
translateX: 'translateX',
|
|
126
|
+
ty: 'translateY',
|
|
127
|
+
translateY: 'translateY',
|
|
128
|
+
s: 'scale',
|
|
129
|
+
scale: 'scale',
|
|
130
|
+
sx: 'scaleX',
|
|
131
|
+
scaleX: 'scaleX',
|
|
132
|
+
sy: 'scaleY',
|
|
133
|
+
scaleY: 'scaleY',
|
|
134
|
+
r: 'rotate',
|
|
135
|
+
rotate: 'rotate',
|
|
136
|
+
sk: 'skew',
|
|
137
|
+
skew: 'skew',
|
|
138
|
+
skx: 'skewX',
|
|
139
|
+
skewX: 'skewX',
|
|
140
|
+
sky: 'skewY',
|
|
141
|
+
skewY: 'skewY',
|
|
142
|
+
m3d: 'matrix3d',
|
|
143
|
+
matrix3d: 'matrix3d',
|
|
144
|
+
t3d: 'translate3d',
|
|
145
|
+
translate3d: 'translate3d',
|
|
146
|
+
tz: 'translateZ',
|
|
147
|
+
translateZ: 'translateZ',
|
|
148
|
+
s3d: 'scale3d',
|
|
149
|
+
scale3d: 'scale3d',
|
|
150
|
+
sz: 'scaleZ',
|
|
151
|
+
scaleZ: 'scaleZ',
|
|
152
|
+
r3d: 'rotate3d',
|
|
153
|
+
rotate3d: 'rotate3d',
|
|
154
|
+
rx: 'rotateX',
|
|
155
|
+
rotateX: 'rotateX',
|
|
156
|
+
ry: 'rotateY',
|
|
157
|
+
rotateY: 'rotateY',
|
|
158
|
+
rz: 'rotateZ',
|
|
159
|
+
rotateZ: 'rotateZ',
|
|
160
|
+
p: 'perspective',
|
|
161
|
+
perspective: 'perspective',
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
// Function values
|
|
166
|
+
const ref=`transform-matrix-1-2-3-4-5-6
|
|
98
167
|
transform-matrix3d-1-0-0-0-0-1-0-0-0-0-1-0-0-0-0-1
|
|
99
168
|
transform-perspective-17px
|
|
100
169
|
transform-rotate-0.5turn
|
|
@@ -116,7 +185,8 @@ transform-skew-30deg-20deg
|
|
|
116
185
|
transform-skewX-30deg
|
|
117
186
|
transform-skewY-1.07rad
|
|
118
187
|
|
|
119
|
-
|
|
188
|
+
// Multiple function values
|
|
120
189
|
transform-translateX-10px--rotate-10deg--translateY-5px
|
|
121
190
|
transform-perspective-500px--translate-10px-0-20px--rotateY-3deg
|
|
122
|
-
|
|
191
|
+
`
|
|
192
|
+
*/
|
|
@@ -1,29 +1,48 @@
|
|
|
1
|
+
import timingFunction from './timingFunction.js';
|
|
1
2
|
export default function transition(data) {
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
// a lone duration: 200ms, 0.3s, 0d3s
|
|
4
|
+
if (data.match(/^-?\d*[.d]?\d+(ms|s)$/))
|
|
5
|
+
return data.replace(/^-/, '').replace(/(\d)d(\d)/, '$1.$2');
|
|
4
6
|
let holder = '';
|
|
5
7
|
data
|
|
6
8
|
.replace(/^-/, '')
|
|
7
9
|
.split(/__/)
|
|
8
10
|
.forEach((e) => {
|
|
11
|
+
// a whole layer can be a variable: opacity-200ms__--x
|
|
12
|
+
if (/^--[a-zA-Z]/.test(e)) {
|
|
13
|
+
holder += 'var(' + e + '),';
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
9
16
|
let cssVar = '';
|
|
10
|
-
if (e.match(
|
|
11
|
-
cssVar = '--' + e.split(
|
|
17
|
+
if (e.match(/--[a-zA-Z]/)) {
|
|
18
|
+
cssVar = '--' + e.split(/--(?=[a-zA-Z])/)[1];
|
|
12
19
|
e = e.replace(cssVar, '');
|
|
13
20
|
}
|
|
14
|
-
|
|
21
|
+
// property, duration, then everything else (easing, delay, allow-discrete)
|
|
22
|
+
const m = e.match(/^([a-z-]+)([0-9]+[d.]?[0-9]*m?s)(.*)$/);
|
|
15
23
|
if (!m) {
|
|
16
24
|
if (cssVar)
|
|
17
|
-
|
|
25
|
+
holder += 'var(' + cssVar + '),';
|
|
18
26
|
return;
|
|
19
27
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
28
|
+
let rest = m[3];
|
|
29
|
+
// delay: a time at the end -> opacity-200ms-ease-100ms
|
|
30
|
+
let delay = '';
|
|
31
|
+
const dm = rest.match(/-(-?[0-9]+(?:[d.][0-9]+)?m?s)$/);
|
|
32
|
+
if (dm) {
|
|
33
|
+
delay = dm[1].replace(/(\d)d(\d)/, '$1.$2');
|
|
34
|
+
rest = rest.slice(0, dm.index);
|
|
23
35
|
}
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
// transition-behavior
|
|
37
|
+
let discrete = '';
|
|
38
|
+
if (/-allow-discrete$/.test(rest)) {
|
|
39
|
+
discrete = 'allow-discrete';
|
|
40
|
+
rest = rest.replace(/-allow-discrete$/, '');
|
|
26
41
|
}
|
|
42
|
+
// easing: keywords, cb-…, steps-… (same rules as transition-timing-function)
|
|
43
|
+
const tf = rest.replace(/^-/, '');
|
|
44
|
+
const easing = tf ? (func[tf] || timingFunction(tf, {}) || '') : '';
|
|
45
|
+
holder += [m[1].replace(/-$/, ''), m[2].replace(/d/, '.'), easing, delay, discrete].filter(Boolean).join(' ') + ',';
|
|
27
46
|
if (cssVar)
|
|
28
47
|
holder += ' var(' + cssVar + ')';
|
|
29
48
|
});
|
|
@@ -45,3 +64,52 @@ const func = {
|
|
|
45
64
|
se: 'step-end',
|
|
46
65
|
'step-end': 'step-end',
|
|
47
66
|
};
|
|
67
|
+
/*
|
|
68
|
+
export default function transition(data: string) {
|
|
69
|
+
|
|
70
|
+
if(data.match(/^-?\d*\.?\d+(ms|s)$/)) return data.replace(/^-/,'');
|
|
71
|
+
let holder = '';
|
|
72
|
+
|
|
73
|
+
data
|
|
74
|
+
.replace(/^-/, '')
|
|
75
|
+
.split(/__/)
|
|
76
|
+
.forEach((e) => {
|
|
77
|
+
let cssVar='';
|
|
78
|
+
if(e.match(/--/)){
|
|
79
|
+
cssVar='--'+e.split(/--/)[1];
|
|
80
|
+
e=e.replace(cssVar,'');
|
|
81
|
+
}
|
|
82
|
+
const m = e.match(/^([a-z-]+)([0-9]+[d|/.]?[0-9]*[m]?[s])([\w-_]*)/);
|
|
83
|
+
|
|
84
|
+
if (!m){
|
|
85
|
+
if(cssVar) return e+" var("+cssVar+")";
|
|
86
|
+
return
|
|
87
|
+
}
|
|
88
|
+
const tf = m[3].replace(/^-/, '');
|
|
89
|
+
if (tf && func[tf]) {
|
|
90
|
+
holder += m[1].replace(/-$/, '') + ' ' + m[2].replace(/d/, '.') + ' ' + func[tf] + ',';
|
|
91
|
+
} else {
|
|
92
|
+
holder += m[1].replace(/-$/, '') + ' ' + m[2].replace(/d/, '.') + ',';
|
|
93
|
+
}
|
|
94
|
+
if(cssVar) holder+=' var('+cssVar+')';
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return holder.replace(/[,]$/, '');
|
|
98
|
+
}
|
|
99
|
+
const func: { [key: string]: string } = {
|
|
100
|
+
e: 'ease',
|
|
101
|
+
ease: 'ease',
|
|
102
|
+
linear: 'linear',
|
|
103
|
+
l: 'linear',
|
|
104
|
+
ei: 'ease-in',
|
|
105
|
+
'ease-in': 'ease-in',
|
|
106
|
+
eo: 'ease-out',
|
|
107
|
+
'ease-out': 'ease-out',
|
|
108
|
+
eio: 'ease-in-out',
|
|
109
|
+
'ease-in-out': 'ease-in-out',
|
|
110
|
+
ss: 'step-start',
|
|
111
|
+
'step-start': 'step-start',
|
|
112
|
+
se: 'step-end',
|
|
113
|
+
'step-end': 'step-end',
|
|
114
|
+
};
|
|
115
|
+
*/
|
package/lib/compilers/url.js
CHANGED
|
@@ -9,9 +9,10 @@ export default function url(data) {
|
|
|
9
9
|
holder += 'url' + each + ',';
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
|
-
// css
|
|
12
|
+
// css variable: url() can't contain var(), so the variable holds the whole url(...)
|
|
13
|
+
// (url(var(--x)) is rejected by the browser)
|
|
13
14
|
if (each.match(/^--[a-zA-Z]/)) {
|
|
14
|
-
holder += `
|
|
15
|
+
holder += `var(${each}),`;
|
|
15
16
|
return;
|
|
16
17
|
}
|
|
17
18
|
let dir = '';
|
|
@@ -30,10 +31,59 @@ export default function url(data) {
|
|
|
30
31
|
each = each
|
|
31
32
|
.replace(/^[-_]/, '')
|
|
32
33
|
.replace(new RegExp(divider, 'g'), '/')
|
|
33
|
-
.replace(/[\/]([a-
|
|
34
|
+
.replace(/[\/]([a-zA-Z0-9]+)$/, '.$1'); // PNG, JPG too
|
|
34
35
|
holder += "url('" + dir + each + "'),";
|
|
35
36
|
});
|
|
36
37
|
return holder.replace(/[,]$/, '').trim();
|
|
37
38
|
// note restriction not use folder with name that uses ../../also need to figure out for
|
|
38
39
|
// bg-url_3_path_to_folder-name_name_png--3_
|
|
39
40
|
}
|
|
41
|
+
/*
|
|
42
|
+
export default function url(data: string) {
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// bg-url3-path-to-folder-png
|
|
47
|
+
// bg-url3_path_to-the_folder_name_png
|
|
48
|
+
let holder = '';
|
|
49
|
+
data.split(/__/).forEach((each) => {
|
|
50
|
+
each = each.replace(/^[-]?url/, '');
|
|
51
|
+
// match raw-css function
|
|
52
|
+
if(each.match(/^[(]/)){
|
|
53
|
+
holder+='url'+each+',';
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// css-var inside url
|
|
58
|
+
if(each.match(/^--[a-zA-Z]/)){
|
|
59
|
+
holder+= `url(var(${each})),`;
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
let dir: string = '';
|
|
63
|
+
if (each.match(/^[-]?[\d][-_]/)) {
|
|
64
|
+
const ndir = /^([0-9])[-_]/.exec(each);
|
|
65
|
+
if (ndir)
|
|
66
|
+
for (let i = 0; i < parseInt(ndir[1], 10); i++) {
|
|
67
|
+
dir += '../';
|
|
68
|
+
}
|
|
69
|
+
each = each.replace(/^[\d]/, '');
|
|
70
|
+
}
|
|
71
|
+
if (!/^[-_]/.test(each)) {
|
|
72
|
+
each = '-' + each;
|
|
73
|
+
}
|
|
74
|
+
const divider = each.slice(0, 1);
|
|
75
|
+
|
|
76
|
+
each = each
|
|
77
|
+
.replace(/^[-_]/, '')
|
|
78
|
+
.replace(new RegExp(divider, 'g'), '/')
|
|
79
|
+
.replace(/[\/]([a-z0-9]+)$/, '.$1');
|
|
80
|
+
|
|
81
|
+
holder += "url('" + dir + each + "'),";
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return holder.replace(/[,]$/, '').trim();
|
|
85
|
+
|
|
86
|
+
// note restriction not use folder with name that uses ../../also need to figure out for
|
|
87
|
+
// bg-url_3_path_to_folder-name_name_png--3_
|
|
88
|
+
}
|
|
89
|
+
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import styleToAliascss from "./utils/stylesToAliascss.js";
|
|
2
2
|
export declare const getCompiler: (property: string) => {
|
|
3
|
-
alias?: string
|
|
4
|
-
property?: string
|
|
5
|
-
test?: RegExp
|
|
6
|
-
type?: string
|
|
7
|
-
values?: string[]
|
|
3
|
+
alias?: string;
|
|
4
|
+
property?: string;
|
|
5
|
+
test?: RegExp;
|
|
6
|
+
type?: string;
|
|
7
|
+
values?: string[];
|
|
8
8
|
groups?: {
|
|
9
9
|
[key: string]: string;
|
|
10
|
-
}
|
|
11
|
-
compiler?: (
|
|
10
|
+
};
|
|
11
|
+
compiler?: (a: string, b: {
|
|
12
12
|
[key: string]: {
|
|
13
13
|
[key: string]: string;
|
|
14
14
|
};
|
|
15
|
-
}) => any
|
|
15
|
+
}) => any;
|
|
16
16
|
} | null;
|
|
17
17
|
export declare const main: {
|
|
18
18
|
[key: string]: any;
|
|
19
|
-
make: (a: string, b?: string
|
|
19
|
+
make: (a: string, b?: string, c?: boolean) => string;
|
|
20
20
|
group: (a: string, b: string) => string;
|
|
21
21
|
};
|
|
22
22
|
export declare const styleJSX: (str: string, bool?: boolean) => any;
|