aliascss 1.1.19 → 1.2.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/dist/aliascss.js +1 -1
- package/lib/classPrinter.js +27 -26
- package/lib/prefix/PseudoPrefix.js +3 -3
- package/lib/prefix/PseudoPrefixNew.js +3 -3
- package/lib/prefix/attribute-selector.js +1 -1
- package/lib/prefix/element-selector.js +1 -1
- package/lib/prefix/pseudoSelectorNew.js +2 -1
- package/lib/returnPropertyAndValue.d.ts +9 -0
- package/lib/returnPropertyAndValue.js +9 -0
- package/lib/returnStatement.js +7 -0
- package/package.json +1 -1
package/lib/classPrinter.js
CHANGED
|
@@ -48,8 +48,7 @@ export let classPrinter = {
|
|
|
48
48
|
if (el.getAttribute('class'))
|
|
49
49
|
attrValue += ' ' + el.getAttribute('class');
|
|
50
50
|
// if acss-class
|
|
51
|
-
if (el.getAttribute('acss-class'))
|
|
52
|
-
attrValue += ' ' + el.getAttribute('acss-class');
|
|
51
|
+
// if (el.getAttribute('acss-class')) attrValue += ' ' + el.getAttribute('acss-class');
|
|
53
52
|
// new Update
|
|
54
53
|
[...el.attributes].map((each) => {
|
|
55
54
|
// ------------
|
|
@@ -98,25 +97,24 @@ export let classPrinter = {
|
|
|
98
97
|
if (!attrValue.trim())
|
|
99
98
|
return;
|
|
100
99
|
// has-test-group(for live update only)
|
|
101
|
-
if (el.getAttribute('acss-group-test')) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
styleTag.appendChild(createNewGroup);
|
|
117
|
-
}
|
|
100
|
+
/* if (el.getAttribute('acss-group-test')) {
|
|
101
|
+
const result = statementMaker.group(attrValue, el.getAttribute('acss-group-test')||'');
|
|
102
|
+
const styleTag = document.querySelector('style#' + el.getAttribute('acss-group-test'));
|
|
103
|
+
if (result) {
|
|
104
|
+
if (styleTag) {
|
|
105
|
+
styleTag.innerHTML = '';
|
|
106
|
+
const createNewGroup = document.createTextNode(result);
|
|
107
|
+
styleTag.appendChild(createNewGroup);
|
|
108
|
+
// return true;
|
|
109
|
+
} else {
|
|
110
|
+
const styleTag: any = document.createElement('style');
|
|
111
|
+
styleTag.id = el.getAttribute('acss-group-test');
|
|
112
|
+
document.getElementsByTagName('head')[0].appendChild(styleTag);
|
|
113
|
+
const createNewGroup = document.createTextNode(result);
|
|
114
|
+
styleTag.appendChild(createNewGroup);
|
|
118
115
|
}
|
|
119
|
-
|
|
116
|
+
}
|
|
117
|
+
} */
|
|
120
118
|
// -----------------------end of for live update
|
|
121
119
|
// get class and trim out white spaces
|
|
122
120
|
const tmpClassList = attrValue.trim().split(/\s+/);
|
|
@@ -169,8 +167,7 @@ export let classPrinter = {
|
|
|
169
167
|
}
|
|
170
168
|
});
|
|
171
169
|
// if acss-class
|
|
172
|
-
if (el.getAttribute('acss-class'))
|
|
173
|
-
attrValue += ' ' + el.getAttribute('acss-class');
|
|
170
|
+
// if (el.getAttribute('acss-class')) attrValue += ' ' + el.getAttribute('acss-class');
|
|
174
171
|
// if has value to process
|
|
175
172
|
if (!attrValue.trim())
|
|
176
173
|
return;
|
|
@@ -204,13 +201,15 @@ export let classPrinter = {
|
|
|
204
201
|
statement += processOuterHtml ? processOuterHtml : '';
|
|
205
202
|
// <template> element
|
|
206
203
|
Array.prototype.forEach.call($el.querySelectorAll('template'), (template) => {
|
|
207
|
-
Array.prototype.forEach.call(template.content.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
204
|
+
// Array.prototype.forEach.call(template.content.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
205
|
+
Array.prototype.forEach.call(template.content.querySelectorAll('[class]'), (e) => {
|
|
208
206
|
const result = this.compileElement(e, classList);
|
|
209
207
|
statement += result ? result : '';
|
|
210
208
|
});
|
|
211
209
|
});
|
|
212
210
|
// <html>
|
|
213
|
-
Array.prototype.forEach.call($el.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
211
|
+
// Array.prototype.forEach.call($el.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
212
|
+
Array.prototype.forEach.call($el.querySelectorAll('[class]'), (e) => {
|
|
214
213
|
const result = this.compileElement(e, classList);
|
|
215
214
|
statement += result ? result : '';
|
|
216
215
|
});
|
|
@@ -223,12 +222,14 @@ export let classPrinter = {
|
|
|
223
222
|
$root.dispatchEvent(new CustomEvent('acss:init', { bubbles: true, detail: { aliascss: this } }));
|
|
224
223
|
// <template> element
|
|
225
224
|
Array.prototype.forEach.call($root.querySelectorAll('template'), (template) => {
|
|
226
|
-
Array.prototype.forEach.call(template.content.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
225
|
+
// Array.prototype.forEach.call(template.content.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
226
|
+
Array.prototype.forEach.call(template.content.querySelectorAll('[class]'), (e) => {
|
|
227
227
|
this.print(e);
|
|
228
228
|
});
|
|
229
229
|
});
|
|
230
230
|
// <html>
|
|
231
|
-
Array.prototype.forEach.call($root.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
231
|
+
// Array.prototype.forEach.call($root.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
232
|
+
Array.prototype.forEach.call($root.querySelectorAll('[class]'), (e) => {
|
|
232
233
|
this.print(e);
|
|
233
234
|
});
|
|
234
235
|
},
|
|
@@ -46,13 +46,13 @@ const prefix = {
|
|
|
46
46
|
'-fln': '::first-line', // -fln
|
|
47
47
|
'--first-of-type': ':first-of-type', // -fot
|
|
48
48
|
'-fot': ':first-of-type',
|
|
49
|
-
'--focus': ':focus', // -fo
|
|
50
|
-
'-fo': ':focus', // -fo
|
|
51
|
-
'-f': ':focus', // -fo
|
|
52
49
|
'--focus-within': ':focus-within', // -fo
|
|
53
50
|
'-fw': ':focus-within', // -fo
|
|
54
51
|
'--focus-visible': ':focus-visible', // -fo
|
|
55
52
|
'-fv': ':focus-visible', // -fo
|
|
53
|
+
'--focus': ':focus', // -fo
|
|
54
|
+
'-fo': ':focus', // -fo
|
|
55
|
+
'-f': ':focus', // -fo
|
|
56
56
|
'--fullscreen': ':fullscreen',
|
|
57
57
|
'-fs': ':fullscreen',
|
|
58
58
|
'--has': ':has', // --has
|
|
@@ -46,13 +46,13 @@ const prefix = {
|
|
|
46
46
|
'--fln': '::first-line', // -fln
|
|
47
47
|
'--first-of-type': ':first-of-type', // -fot
|
|
48
48
|
'--fot': ':first-of-type',
|
|
49
|
-
'--focus': ':focus', // -fo
|
|
50
|
-
'--fo': ':focus', // -fo
|
|
51
|
-
'--f': ':focus', // -fo
|
|
52
49
|
'--focus-within': ':focus-within', // -fo
|
|
53
50
|
'--fw': ':focus-within', // -fo
|
|
54
51
|
'--focus-visible': ':focus-visible', // -fo
|
|
55
52
|
'--fv': ':focus-visible', // -fo
|
|
53
|
+
'--focus': ':focus', // -fo
|
|
54
|
+
'--fo': ':focus', // -fo
|
|
55
|
+
'--f': ':focus', // -fo
|
|
56
56
|
'--fullscreen': ':fullscreen',
|
|
57
57
|
'--fs': ':fullscreen',
|
|
58
58
|
'--has': ':has', // --has
|
|
@@ -2,6 +2,7 @@ import prefix, { createRegexForPseudo } from './PseudoPrefixNew.js';
|
|
|
2
2
|
import extractPrefix from './extractPrefix.js';
|
|
3
3
|
export default function PseudoEleStateNew(data) {
|
|
4
4
|
var _a;
|
|
5
|
+
// const match=createRegexForPseudo({...prefix,'--KKK':','});
|
|
5
6
|
const match = createRegexForPseudo(prefix);
|
|
6
7
|
if (!match.test(data))
|
|
7
8
|
return null;
|
|
@@ -51,7 +52,7 @@ export default function PseudoEleStateNew(data) {
|
|
|
51
52
|
return [cn, `${alias}(${cont})`];
|
|
52
53
|
}
|
|
53
54
|
else if (/(^-(-not|-has|-is|-where|-n|-hs|-w|-is)[-_])/.test(data)) {
|
|
54
|
-
const mch = data.match(/(^-(-not|-has|-is|-where|-n|-hs|-w|-is)([_-]+[a-zA-Z0-9
|
|
55
|
+
const mch = data.match(/(^-(-not|-has|-is|-where|-n|-hs|-w|-is)([_-]+[a-zA-Z0-9\.,]+)(?=[-|_]))/);
|
|
55
56
|
const cn = (mch === null || mch === void 0 ? void 0 : mch[1]) ? data.replace(mch[1], '') : '';
|
|
56
57
|
const alias = (mch === null || mch === void 0 ? void 0 : mch[2]) ? prefix['-' + mch[2].replace(/-$/, '')] : '';
|
|
57
58
|
const cont = (_a = PseudoEleStateNew((mch === null || mch === void 0 ? void 0 : mch[3]) + '-dn')) === null || _a === void 0 ? void 0 : _a[1];
|
|
@@ -8,6 +8,15 @@ type Property = {
|
|
|
8
8
|
};
|
|
9
9
|
compiler?: (...args: any[]) => any;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* @param className : string
|
|
13
|
+
* @param cssPropertiesWithAlias: Compiler Object
|
|
14
|
+
* @param staticClassNames : StaticClassNames
|
|
15
|
+
* @param custom : custom values for color, font, etc
|
|
16
|
+
* @param extractProperty :extractProperty(className:string,cssPropertiesWithAlias:{[key:string]:Property})=>[Property,string]
|
|
17
|
+
* @param bool : return[property,value] or property:value
|
|
18
|
+
* @returns {string[]|null|{}}
|
|
19
|
+
*/
|
|
11
20
|
export default function getPropertyAndValue(className: string, cssPropertiesWithAlias: {
|
|
12
21
|
[key: string]: Property;
|
|
13
22
|
}, staticClassNames: {
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param className : string
|
|
3
|
+
* @param cssPropertiesWithAlias: Compiler Object
|
|
4
|
+
* @param staticClassNames : StaticClassNames
|
|
5
|
+
* @param custom : custom values for color, font, etc
|
|
6
|
+
* @param extractProperty :extractProperty(className:string,cssPropertiesWithAlias:{[key:string]:Property})=>[Property,string]
|
|
7
|
+
* @param bool : return[property,value] or property:value
|
|
8
|
+
* @returns {string[]|null|{}}
|
|
9
|
+
*/
|
|
1
10
|
export default function getPropertyAndValue(className, cssPropertiesWithAlias, staticClassNames, custom, extractProperty, // (a:string,b:{[key:string]:Property})=>[Property,string],
|
|
2
11
|
bool = false) {
|
|
3
12
|
// Case 1 StaticClassNames
|
package/lib/returnStatement.js
CHANGED
|
@@ -44,6 +44,13 @@ export const compiler = {
|
|
|
44
44
|
},
|
|
45
45
|
// className as another-name, bool->only return property and value
|
|
46
46
|
make(className, as, bool) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (/--as-[a-zA-Z0-9-_]+$/.test(className)) {
|
|
49
|
+
const asMatch = (_a = className.match(/--as-([a-zA-Z0-9-_]+)$/)) !== null && _a !== void 0 ? _a : [null, null];
|
|
50
|
+
if (asMatch[0] && asMatch[1]) {
|
|
51
|
+
return this.group(className.replace(asMatch[0], ''), asMatch[1]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
47
54
|
let unPrefixedClassName = className;
|
|
48
55
|
// check for [group-acss,]
|
|
49
56
|
const matchGroupCSS = className.match(/\[([^[]*)\]$/);
|