aliascss 1.4.5 → 1.5.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 +22 -0
- package/bin/aliascss.js +118 -1
- package/dist/aliascss.js +1 -1
- package/lib/classPrinter.js +347 -21
- package/lib/compilers/color.js +5 -5
- package/lib/compilers/gradient.js +3 -3
- package/lib/compilers/stringAndContent.js +2 -1
- package/lib/component-elements.d.ts +155 -0
- package/lib/component-elements.js +223 -0
- package/lib/config.d.ts +2 -0
- package/lib/config.js +3 -1
- package/lib/css-properties-all.js +337 -202
- package/lib/custom-css-compilers.js +49 -116
- package/lib/extras-elements.d.ts +87 -0
- package/lib/extras-elements.js +184 -0
- package/lib/form-elements.d.ts +75 -0
- package/lib/form-elements.js +186 -0
- package/lib/layout-elements.d.ts +59 -0
- package/lib/layout-elements.js +113 -0
- package/lib/nav-elements.d.ts +71 -0
- package/lib/nav-elements.js +243 -0
- package/lib/node/compileFile-BK-291026.d.ts +27 -0
- package/lib/node/compileFile-BK-291026.js +309 -0
- package/lib/node/compileFile-bk.d.ts +14 -12
- package/lib/node/compileFile-bk.js +263 -252
- package/lib/node/compileFile.js +1 -1
- package/lib/node/extractClassNamesFromFile.js +208 -86
- package/lib/prebuild.d.ts +546 -12
- package/lib/prebuild.js +3 -852
- package/lib/prefix/PseudoPrefixNew.js +301 -16
- package/lib/prefix/attribute-selector.js +4 -2
- package/lib/prefix/element-selector.js +93 -20
- package/lib/prefix/extractPrefix.d.ts +1 -1
- package/lib/prefix/extractPrefix.js +113 -70
- package/lib/prefix/pseudoSelectorNew.js +184 -49
- package/lib/prefix/responsive.d.ts +13 -9
- package/lib/prefix/responsive.js +131 -9
- package/lib/returnPropertyAndValue.js +9 -4
- package/lib/returnStatement-bk-291026.d.ts +5 -0
- package/lib/returnStatement-bk-291026.js +470 -0
- package/lib/returnStatement-bk.d.ts +5 -0
- package/lib/returnStatement-bk.js +311 -0
- package/lib/returnStatement.d.ts +1 -0
- package/lib/returnStatement.js +262 -12
- package/lib/static/customStaticClassNames.js +35 -35
- package/lib/static/staticClassNamesAlias.js +18 -16
- package/lib/table-elements.d.ts +39 -0
- package/lib/table-elements.js +90 -0
- package/lib/utils/helper.d.ts +6 -0
- package/lib/utils/helper.js +52 -0
- package/lib/x-classes/x-bundle.d.ts +589 -0
- package/lib/x-classes/x-bundle.js +12 -0
- package/lib/x-classes/x-comps.d.ts +87 -0
- package/lib/x-classes/x-comps.js +189 -0
- package/lib/x-classes/x-extras.d.ts +155 -0
- package/lib/x-classes/x-extras.js +223 -0
- package/lib/x-classes/x-form-components.d.ts +75 -0
- package/lib/x-classes/x-form-components.js +186 -0
- package/lib/x-classes/x-helper-components.d.ts +63 -0
- package/lib/x-classes/x-helper-components.js +91 -0
- package/lib/x-classes/x-layout-components.d.ts +59 -0
- package/lib/x-classes/x-layout-components.js +113 -0
- package/lib/x-classes/x-menu.d.ts +23 -0
- package/lib/x-classes/x-menu.js +55 -0
- package/lib/x-classes/x-navs.d.ts +71 -0
- package/lib/x-classes/x-navs.js +243 -0
- package/lib/x-classes/x-row-col.d.ts +29 -0
- package/lib/x-classes/x-row-col.js +52 -0
- package/lib/x-classes/x-table.d.ts +39 -0
- package/lib/x-classes/x-table.js +90 -0
- package/lib/x-classes/x-theme.d.ts +15 -0
- package/lib/x-classes/x-theme.js +32 -0
- package/lib/x-imports.d.ts +31 -0
- package/lib/x-imports.js +748 -0
- package/package.json +1 -1
|
@@ -3,83 +3,126 @@ import pseudoSelector from './pseudoSelectorNew.js';
|
|
|
3
3
|
import elementSelector from './element-selector.js';
|
|
4
4
|
import attribute from './attribute-selector.js';
|
|
5
5
|
import fallbackSelector from './fallback-selector.js';
|
|
6
|
+
const steps = [
|
|
7
|
+
name => pseudoSelector(name),
|
|
8
|
+
name => elementSelector.process(name),
|
|
9
|
+
name => (attribute.test.test(name) ? attribute.process(name) : null),
|
|
10
|
+
name => (fallbackSelector.test.test(name) ? fallbackSelector.process(name) : null),
|
|
11
|
+
];
|
|
12
|
+
// A bare :not / :has / :is / :where (from forms like --not-[disabled]-…)
|
|
13
|
+
// takes the next selector piece as its argument.
|
|
14
|
+
const OPEN_FN = /:(not|where|has|is)([)])?$/;
|
|
15
|
+
function append(result, selector) {
|
|
16
|
+
const m = result.match(OPEN_FN);
|
|
17
|
+
if (!m)
|
|
18
|
+
return result + selector;
|
|
19
|
+
return m[2]
|
|
20
|
+
? result.replace(/\)$/, '') + `(${selector}))`
|
|
21
|
+
: result + `(${selector})`;
|
|
22
|
+
}
|
|
6
23
|
export default function extractPrefix(className) {
|
|
7
24
|
let workingClassName = className;
|
|
8
25
|
let result = '';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
result += matched[1];
|
|
25
|
-
}
|
|
26
|
-
match = true;
|
|
26
|
+
while (true) {
|
|
27
|
+
let progressed = false;
|
|
28
|
+
for (const step of steps) {
|
|
29
|
+
const matched = step(workingClassName);
|
|
30
|
+
if (!matched)
|
|
31
|
+
continue;
|
|
32
|
+
const [rest, selector] = matched;
|
|
33
|
+
if (rest === workingClassName)
|
|
34
|
+
continue; // no progress: avoid an infinite loop
|
|
35
|
+
result = append(result, selector);
|
|
36
|
+
workingClassName = rest;
|
|
37
|
+
progressed = true;
|
|
38
|
+
break; // restart from the first step, as before
|
|
27
39
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
if (!progressed)
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
return [result, workingClassName];
|
|
44
|
+
}
|
|
45
|
+
/*
|
|
46
|
+
// import pseudoSelector from './selector.js'
|
|
47
|
+
import pseudoSelector from './pseudoSelectorNew.js'
|
|
48
|
+
import elementSelector from './element-selector.js'
|
|
49
|
+
import attribute from './attribute-selector.js';
|
|
50
|
+
import fallbackSelector from './fallback-selector.js';
|
|
51
|
+
|
|
52
|
+
export default function extractPrefix(className:string){
|
|
53
|
+
let workingClassName=className;
|
|
54
|
+
let result='';
|
|
55
|
+
let match=false;
|
|
56
|
+
do {
|
|
57
|
+
const matched=pseudoSelector(workingClassName);
|
|
58
|
+
if(matched){
|
|
59
|
+
workingClassName=matched[0];
|
|
60
|
+
if(result.match(/:(not|where|has|is)[)]?$/)){
|
|
61
|
+
const m=result.match(/:(not|where|has|is)([)])?$/);
|
|
62
|
+
if(m?.[2]){
|
|
63
|
+
result=result.replace(/\)$/,'')+ `(${matched[1]}))`;
|
|
64
|
+
}else{
|
|
65
|
+
result +=`(${matched[1]})`
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
}else{
|
|
69
|
+
result +=matched[1]
|
|
51
70
|
}
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
|
|
72
|
+
match=true;
|
|
73
|
+
|
|
74
|
+
}else if(elementSelector.test.test(workingClassName)){
|
|
75
|
+
const [replacedClassName, selector]=elementSelector.process(workingClassName);
|
|
76
|
+
if(result.match(/:(not|where|has|is)[)]?$/)){
|
|
77
|
+
const m=result.match(/:(not|where|has|is)([)])?$/);
|
|
78
|
+
if(m?.[2]){
|
|
79
|
+
result=result.replace(/\)$/,'')+ `(${selector}))`;
|
|
80
|
+
}else{
|
|
81
|
+
result +=`(${selector})`
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}else{
|
|
85
|
+
result +=selector
|
|
54
86
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
result = result.replace(/\)$/, '') + `(${selector}))`;
|
|
87
|
+
workingClassName=replacedClassName;
|
|
88
|
+
match=true;
|
|
89
|
+
}else if(attribute.test.test(workingClassName)){
|
|
90
|
+
const [replacedClassName, selector]=attribute.process(workingClassName);
|
|
91
|
+
if(result.match(/:(not|where|has|is)[)]?$/)){
|
|
92
|
+
const m=result.match(/:(not|where|has|is)([)])?$/);
|
|
93
|
+
if(m?.[2]){
|
|
94
|
+
result=result.replace(/\)$/,'')+ `(${selector}))`;
|
|
95
|
+
}else{
|
|
96
|
+
result +=`(${selector})`
|
|
97
|
+
}
|
|
98
|
+
}else{
|
|
99
|
+
result +=selector
|
|
69
100
|
}
|
|
70
|
-
|
|
71
|
-
|
|
101
|
+
workingClassName=replacedClassName;
|
|
102
|
+
match=true;
|
|
103
|
+
}else if(fallbackSelector.test.test(workingClassName)){
|
|
104
|
+
// console.log('=-=-=-=-=-=--=',workingClassName);
|
|
105
|
+
const [replacedClassName, selector]=fallbackSelector.process(workingClassName);
|
|
106
|
+
if(result.match(/:(not|where|has|is)[)]?$/)){
|
|
107
|
+
const m=result.match(/:(not|where|has|is)([)])?$/);
|
|
108
|
+
if(m?.[2]){
|
|
109
|
+
result=result.replace(/\)$/,'')+ `(${selector}))`;
|
|
110
|
+
}else{
|
|
111
|
+
result +=`(${selector})`
|
|
112
|
+
}
|
|
113
|
+
}else{
|
|
114
|
+
result +=selector
|
|
72
115
|
}
|
|
116
|
+
workingClassName=replacedClassName;
|
|
117
|
+
match=true;
|
|
118
|
+
}else{
|
|
119
|
+
match=false;
|
|
73
120
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
else {
|
|
81
|
-
match = false;
|
|
82
|
-
}
|
|
83
|
-
} while (match);
|
|
84
|
-
return [result, workingClassName];
|
|
121
|
+
|
|
122
|
+
} while (match);
|
|
123
|
+
|
|
124
|
+
return [result, workingClassName]
|
|
125
|
+
|
|
126
|
+
|
|
85
127
|
}
|
|
128
|
+
*/
|
|
@@ -1,80 +1,215 @@
|
|
|
1
1
|
import prefix, { createRegexForPseudo } from './PseudoPrefixNew.js';
|
|
2
2
|
import extractPrefix from './extractPrefix.js';
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Built once at module load, not on every call
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
const pseudoMatch = createRegexForPseudo(prefix);
|
|
7
|
+
// Functional pseudos whose argument is an AliasCSS selector:
|
|
8
|
+
// --not(…) --has(…) --Has(…) --is(…) --Is(…) --where(…) --Where(…) --hs(…) --w(…) --W(…) --n(…)
|
|
9
|
+
const FN_PSEUDO = /^-(-?(?:not|has|Has|is|Is|where|Where|hs|w|W|n))\(/;
|
|
10
|
+
// Functional pseudos whose argument is an nth formula (passed through as is):
|
|
11
|
+
// --nth-child(2n+1) --nth-last-child(…) --nth-of-type(…) --nth-last-of-type(…)
|
|
12
|
+
// --nc(…) --nlc(…) --nthot(…) --nlot(…)
|
|
13
|
+
const NTH_PSEUDO = /^-(-?n(?:th-child|th-last-child|th-last-of-type|th-of-type|c|lc|lot|thot))\(/;
|
|
14
|
+
// nth without parentheses, number or keyword after a dash:
|
|
15
|
+
// --nth-child-3 --nth-last-child-2n --nth-of-type-1 --nth-last-of-type-2
|
|
16
|
+
const NTH_DASH_LONG = /^(--nth-(?:child|last-child|of-type|last-of-type))-([0-9]+n?)(?=[-_])/;
|
|
17
|
+
// --nc-3 --nlc-odd --nthot-2n --nlot-1
|
|
18
|
+
const NTH_DASH_SHORT = /^(--(?:nc|nlc|nthot|nlot))-([a-z0-9]+)(?=[-_])/;
|
|
19
|
+
// Selector pseudos without parentheses, one simple selector after a dash:
|
|
20
|
+
// --not-first-child-… --has_img-… --is-…
|
|
21
|
+
const FN_DASH = /^-(-(?:not|has|Has|is|Is|where|Where|hs|w|W|n))([_-]+[a-zA-Z0-9.,]+)(?=[-_])/;
|
|
22
|
+
// --lang-en-…
|
|
23
|
+
const LANG_DASH = /^--lang-([a-zA-Z0-9]+)(?=[-_])/;
|
|
24
|
+
// Given the index of an opening "(", return [inside, rest after the matching ")"]
|
|
25
|
+
function splitBalanced(str, open) {
|
|
26
|
+
let depth = 0;
|
|
27
|
+
for (let i = open; i < str.length; i++) {
|
|
28
|
+
const ch = str[i];
|
|
29
|
+
if (ch === '\\') {
|
|
30
|
+
i++;
|
|
31
|
+
continue;
|
|
32
|
+
} // skip escaped characters
|
|
33
|
+
if (ch === '(')
|
|
34
|
+
depth++;
|
|
35
|
+
else if (ch === ')' && --depth === 0)
|
|
36
|
+
return [str.slice(open + 1, i), str.slice(i + 1)];
|
|
37
|
+
}
|
|
38
|
+
return null; // unbalanced: not a valid class
|
|
39
|
+
}
|
|
40
|
+
// Returns [rest of the class name, compiled pseudo selector] or null
|
|
3
41
|
export default function PseudoEleStateNew(data) {
|
|
4
|
-
|
|
5
|
-
// const match=createRegexForPseudo({...prefix,'--KKK':','});
|
|
6
|
-
const match = createRegexForPseudo(prefix);
|
|
7
|
-
if (!match.test(data))
|
|
42
|
+
if (!pseudoMatch.test(data))
|
|
8
43
|
return null;
|
|
9
|
-
|
|
44
|
+
// 1. --not(…) --has(…) --is(…) --where(…): argument is itself an AliasCSS selector
|
|
45
|
+
const fn = data.match(FN_PSEUDO);
|
|
46
|
+
if (fn) {
|
|
47
|
+
const parts = splitBalanced(data, fn[0].length - 1);
|
|
48
|
+
if (!parts)
|
|
49
|
+
return null;
|
|
50
|
+
const [inner, rest] = parts;
|
|
51
|
+
if (!inner)
|
|
52
|
+
return [rest, ''];
|
|
53
|
+
const [result] = extractPrefix(inner + '-display-none');
|
|
54
|
+
return [rest, `${prefix['-' + fn[1]]}(${result})`];
|
|
55
|
+
}
|
|
56
|
+
// 2. --nth-child(…) --nc(…) …: argument passed through as is
|
|
57
|
+
const nth = data.match(NTH_PSEUDO);
|
|
58
|
+
if (nth) {
|
|
59
|
+
const parts = splitBalanced(data, nth[0].length - 1);
|
|
60
|
+
if (!parts)
|
|
61
|
+
return null;
|
|
62
|
+
const [inner, rest] = parts;
|
|
63
|
+
return [rest, `${prefix['-' + nth[1]]}(${inner})`];
|
|
64
|
+
}
|
|
65
|
+
// 3. --nth-child-3 …
|
|
66
|
+
let m = data.match(NTH_DASH_LONG) || data.match(NTH_DASH_SHORT);
|
|
67
|
+
if (m) {
|
|
68
|
+
return [data.slice(m[0].length), `${prefix[m[1]]}(${m[2]})`];
|
|
69
|
+
}
|
|
70
|
+
// 4. --not-first-child-… --has_img-…
|
|
71
|
+
m = data.match(FN_DASH);
|
|
72
|
+
if (m) {
|
|
73
|
+
const [result] = extractPrefix(m[2] + '-display-none');
|
|
74
|
+
return [data.slice(m[0].length), `${prefix['-' + m[1]]}(${result})`];
|
|
75
|
+
}
|
|
76
|
+
// 5. --lang-en-…
|
|
77
|
+
m = data.match(LANG_DASH);
|
|
78
|
+
if (m) {
|
|
79
|
+
return [data.slice(m[0].length), `:lang(${m[1]})`];
|
|
80
|
+
}
|
|
81
|
+
// 6. Plain pseudo from the prefix map: --hover-… --before-…
|
|
82
|
+
m = data.match(pseudoMatch);
|
|
83
|
+
if (m && Object.prototype.hasOwnProperty.call(prefix, m[1])) {
|
|
84
|
+
return [data.slice(m[1].length), prefix[m[1]]];
|
|
85
|
+
}
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
/*
|
|
89
|
+
import prefix,{createRegexForPseudo} from './PseudoPrefixNew.js';
|
|
90
|
+
import extractPrefix from './extractPrefix.js';
|
|
91
|
+
// Built once, not on every call
|
|
92
|
+
const pseudoMatch = createRegexForPseudo(prefix);
|
|
93
|
+
|
|
94
|
+
// Functional pseudos that take a selector: --not( --has( --is( --where( …
|
|
95
|
+
const FN_PSEUDO = /^-(-?(?:not|has|Has|is|Is|where|Where|hs|w|W|n))\(/;
|
|
96
|
+
// Functional pseudos that take an nth formula: --nth-child( --nc( …
|
|
97
|
+
const NTH_PSEUDO = /^-(-?n(?:th-child|th-last-child|th-last-of-type|th-of-type|c|lc|lot|ot))\(/;
|
|
98
|
+
|
|
99
|
+
// Given the index of an opening "(", return [inside, rest after the matching ")"]
|
|
100
|
+
function splitBalanced(str: string, open: number): [string, string] | null {
|
|
101
|
+
let depth = 0;
|
|
102
|
+
for (let i = open; i < str.length; i++) {
|
|
103
|
+
const ch = str[i];
|
|
104
|
+
if (ch === '\\') { i++; continue; } // skip escaped characters
|
|
105
|
+
if (ch === '(') depth++;
|
|
106
|
+
else if (ch === ')' && --depth === 0) return [str.slice(open + 1, i), str.slice(i + 1)];
|
|
107
|
+
}
|
|
108
|
+
return null; // unbalanced: not a valid class
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export default function PseudoEleStateNew(data:string):string[]|null{
|
|
112
|
+
if (!pseudoMatch.test(data)) return null;
|
|
113
|
+
// --not(…) --has(…) --is(…) --where(…): the argument is itself an AliasCSS selector
|
|
114
|
+
const fn = data.match(FN_PSEUDO);
|
|
115
|
+
if (fn) {
|
|
116
|
+
const parts = splitBalanced(data, fn[0].length - 1);
|
|
117
|
+
if (!parts) return null;
|
|
118
|
+
const [inner, rest] = parts;
|
|
119
|
+
if (!inner) return [rest, ''];
|
|
120
|
+
const [result] = extractPrefix(inner + '-display-none');
|
|
121
|
+
return [rest, `${prefix['-' + fn[1]]}(${result})`];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// --nth-child(…) --nc(…) …: the argument is passed through as is
|
|
125
|
+
const nth = data.match(NTH_PSEUDO);
|
|
126
|
+
if (nth) {
|
|
127
|
+
const parts = splitBalanced(data, nth[0].length - 1);
|
|
128
|
+
if (!parts) return null;
|
|
129
|
+
const [inner, rest] = parts;
|
|
130
|
+
return [rest, `${prefix['-' + nth[1]]}(${inner})`];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
const matchAndFunc=[
|
|
10
135
|
{
|
|
11
|
-
match
|
|
12
|
-
func(value)
|
|
13
|
-
const matched
|
|
14
|
-
const newData
|
|
15
|
-
if
|
|
16
|
-
const
|
|
17
|
-
|
|
136
|
+
match:/^-([-]?(not|has|Has|is|Is|where|Where|n|hs|w|W))\((.+)\)/,
|
|
137
|
+
func(value:string){
|
|
138
|
+
const matched=value.match(this.match);
|
|
139
|
+
const newData=matched?.[3];
|
|
140
|
+
if(newData){
|
|
141
|
+
const[result,className]= extractPrefix(newData+'-display-none');
|
|
142
|
+
|
|
143
|
+
return [value.replace(matched[0],''),`${prefix['-'+matched[1]]}(${result})`];
|
|
18
144
|
}
|
|
19
|
-
|
|
145
|
+
return [value.replace(matched?.[0]?matched[0]:'',''),'']
|
|
146
|
+
|
|
20
147
|
}
|
|
21
148
|
},
|
|
22
149
|
{
|
|
23
|
-
match
|
|
24
|
-
func(value)
|
|
25
|
-
const matched
|
|
26
|
-
return
|
|
150
|
+
match:/^-([-]?n(th(-child|-last-child|-last-of-type|-of-type)|c|lc|lot|ot))\((.+)\)/,
|
|
151
|
+
func(value:string){
|
|
152
|
+
const matched=value.match(this.match);
|
|
153
|
+
return[value.replace(matched?.[0]?matched[0]:'',''),`${prefix['-'+matched?.[1]]}(${matched?.[4]})`]
|
|
27
154
|
}
|
|
28
155
|
},
|
|
29
156
|
];
|
|
157
|
+
|
|
30
158
|
// accept (acss-selector)
|
|
31
|
-
if
|
|
159
|
+
if(data.match(matchAndFunc[0].match)){
|
|
160
|
+
|
|
32
161
|
return matchAndFunc[0].func(data);
|
|
33
162
|
}
|
|
34
|
-
|
|
163
|
+
|
|
164
|
+
if(data.match(matchAndFunc[1].match)){
|
|
165
|
+
|
|
35
166
|
return matchAndFunc[1].func(data);
|
|
36
167
|
}
|
|
168
|
+
|
|
37
169
|
// case 1. nth
|
|
38
|
-
if
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
170
|
+
if(/(^--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/.test(data)){
|
|
171
|
+
const mch=data.match(/^(--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/);
|
|
172
|
+
const cn=mch?.[0]?data.replace(mch[0],''):'';
|
|
173
|
+
const alias=mch?.[1]?prefix[mch[1].replace(/-$/,'')]:'';
|
|
174
|
+
const cont=mch?.[3];
|
|
175
|
+
return [cn,`${alias}(${cont})`]
|
|
44
176
|
// return pseudoHandlerNthChild(data,/(^--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const mch
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const cont = mch === null || mch === void 0 ? void 0 : mch[3];
|
|
177
|
+
}else if(/^(--(nc|nlc|nlot|nthot)-)([a-z0-9]+)(?=[-|_])/.test(data)){
|
|
178
|
+
const mch=data.match(/^(--(n|nc|nlc|nlot|not)-)([a-z0-9]+)(?=[-|_])/);
|
|
179
|
+
const cn=mch?.[0]?data.replace(mch[0],''):'';
|
|
180
|
+
const alias=mch?.[1]?prefix[mch[1].replace(/-$/,'')]:'';
|
|
181
|
+
const cont=mch?.[3];
|
|
51
182
|
// console.log(data,cn,alias,mch)
|
|
52
|
-
return [cn
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const mch
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
const
|
|
183
|
+
return [cn,`${alias}(${cont})`]
|
|
184
|
+
}else if(/(^-(-not|-has|-Has|-is|-Is|-where|-Where|-n|-hs|-w|-W|-is)[-_])/.test(data)){
|
|
185
|
+
|
|
186
|
+
const mch=data.match(/(^-(-not|-has|-Has|-is|-Is|-where|-Where|-n|-hs|-w|-W|-is)([_-]+[a-zA-Z0-9\.,]+)(?=[-|_]))/);
|
|
187
|
+
|
|
188
|
+
const cn=mch?.[1]?data.replace(mch[1],''):'';
|
|
189
|
+
const alias=mch?.[2]?prefix['-'+mch[2].replace(/-$/,'')]:'';
|
|
190
|
+
const cont:string|undefined=PseudoEleStateNew(mch?.[3]+'-dn')?.[1];
|
|
191
|
+
const[result,className]= extractPrefix(mch?.[3]+'-display-none');
|
|
60
192
|
// console.log('PseudoMatch',result,cont)
|
|
61
|
-
return [cn
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const mch
|
|
65
|
-
const cn = (mch === null || mch === void 0 ? void 0 : mch[1]) ? data.replace(mch[1], '') : '';
|
|
193
|
+
return [cn,`${alias}(${result})`]
|
|
194
|
+
}else if(/(^--lang-([a-z]+)(?=[-|_]))/.test(data)){
|
|
195
|
+
const mch=data.match(/(^--lang-([a-z0-9]+)(?=[-|_]))/);
|
|
196
|
+
const cn=mch?.[1]?data.replace(mch[1],''):'';
|
|
66
197
|
// const alias=mch?.[1]?prefix[mch[1].replace(/-$/,'')]:'';
|
|
67
|
-
const cont
|
|
68
|
-
return [cn
|
|
198
|
+
const cont=mch?.[2];
|
|
199
|
+
return [cn,`:lang(${cont})`]
|
|
69
200
|
}
|
|
70
|
-
else
|
|
71
|
-
const alias = data.match(
|
|
201
|
+
else{
|
|
202
|
+
const alias = data.match(pseudoMatch);
|
|
72
203
|
if (alias) {
|
|
73
204
|
if (prefix.hasOwnProperty(alias[0])) {
|
|
74
|
-
|
|
205
|
+
|
|
206
|
+
return [data.replace(alias[0], ''), prefix[alias[0]]];
|
|
75
207
|
}
|
|
76
208
|
}
|
|
209
|
+
|
|
77
210
|
// return [data, ''];
|
|
78
211
|
return null;
|
|
79
212
|
}
|
|
80
213
|
}
|
|
214
|
+
|
|
215
|
+
*/
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export type MediaTarget = Record<string, string>;
|
|
2
|
+
export interface MediaConfig {
|
|
3
|
+
test: RegExp;
|
|
4
|
+
target: MediaTarget;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Builds the scope-prefix regex from a prefix map.
|
|
8
|
+
* - Keys are escaped, so custom prefixes may contain regex characters.
|
|
9
|
+
* - Keys are sorted longest first, so matching does not depend on object order.
|
|
10
|
+
* - An empty map returns a regex that never matches instead of throwing.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createRegexForMedia(prefix: MediaTarget): RegExp;
|
|
13
|
+
declare const media: MediaConfig;
|
|
10
14
|
export default media;
|