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
package/lib/classPrinter.js
CHANGED
|
@@ -4,8 +4,11 @@ import { splitByCommaOutsideParens } from './utils/helper.js';
|
|
|
4
4
|
// import mapRawAttributeNames from './utils/browser-helper.js';
|
|
5
5
|
export default statementMaker;
|
|
6
6
|
export let classPrinter = {
|
|
7
|
-
invalidLists:
|
|
8
|
-
classLists:
|
|
7
|
+
invalidLists: new Set(), // was arrays + indexOf: O(n) per lookup
|
|
8
|
+
classLists: new Set(),
|
|
9
|
+
doneGroups: new Set(), // class:name="…" groups already emitted
|
|
10
|
+
buffer: [], // CSS waiting to be written
|
|
11
|
+
flushQueued: false,
|
|
9
12
|
styleTagExists: false,
|
|
10
13
|
customCheck: false,
|
|
11
14
|
useColon: true,
|
|
@@ -28,9 +31,25 @@ export let classPrinter = {
|
|
|
28
31
|
return styleTag;
|
|
29
32
|
},
|
|
30
33
|
// you can always append a class if you like modify the look here if you want
|
|
34
|
+
// Buffered: every append used to add a text node, and each one makes the browser
|
|
35
|
+
// re-parse the whole <style> (slow on big pages). Now statements are collected and
|
|
36
|
+
// written in one text node per microtask: still before the next paint, so no flash.
|
|
31
37
|
appendToStyleTag(classStatement) {
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
if (!classStatement)
|
|
39
|
+
return;
|
|
40
|
+
this.buffer.push(classStatement);
|
|
41
|
+
if (!this.flushQueued) {
|
|
42
|
+
this.flushQueued = true;
|
|
43
|
+
queueMicrotask(() => this.flush());
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
flush() {
|
|
47
|
+
this.flushQueued = false;
|
|
48
|
+
if (!this.buffer.length)
|
|
49
|
+
return;
|
|
50
|
+
const css = this.buffer.join('\n');
|
|
51
|
+
this.buffer = [];
|
|
52
|
+
this.createStyleTag().appendChild(document.createTextNode(css));
|
|
34
53
|
},
|
|
35
54
|
// compile dom stylesheet
|
|
36
55
|
// show current style statement
|
|
@@ -51,8 +70,8 @@ export let classPrinter = {
|
|
|
51
70
|
print(el) {
|
|
52
71
|
// initialize class or acss-class value container
|
|
53
72
|
let attrValue = '';
|
|
54
|
-
const testRegExp = this.useColon ?
|
|
55
|
-
const testRegExpKF = this.useColon ?
|
|
73
|
+
const testRegExp = this.useColon ? /^class[-_:]/ : /^class[-_]/;
|
|
74
|
+
const testRegExpKF = this.useColon ? /^keyframes[-_:]/ : /^keyframes[-_]/;
|
|
56
75
|
// const rawCSS=/data-raw-css/;
|
|
57
76
|
// if class
|
|
58
77
|
if (el.getAttribute('class'))
|
|
@@ -72,10 +91,12 @@ export let classPrinter = {
|
|
|
72
91
|
group = group.replace(match[0], '');
|
|
73
92
|
value = value.trim().split(/\s+/).map(e => match[0].replace(/^\[/, '').replace(/\]$/, '') + (/^[_-]/.test(e) ? '' : '-') + e).join(" ");
|
|
74
93
|
}
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
this.
|
|
78
|
-
|
|
94
|
+
const key = group + '\u0000' + value;
|
|
95
|
+
if (!this.doneGroups.has(key)) {
|
|
96
|
+
this.doneGroups.add(key);
|
|
97
|
+
const result = statementMaker.group(value, group);
|
|
98
|
+
if (result)
|
|
99
|
+
this.appendToStyleTag(result);
|
|
79
100
|
}
|
|
80
101
|
}
|
|
81
102
|
// -------
|
|
@@ -133,9 +154,9 @@ export let classPrinter = {
|
|
|
133
154
|
// looping class
|
|
134
155
|
tmpClassList.forEach((eachClass) => {
|
|
135
156
|
// escape repeated class name
|
|
136
|
-
if (this.classLists.
|
|
157
|
+
if (!this.classLists.has(eachClass) && !this.invalidLists.has(eachClass)) {
|
|
137
158
|
// add to classlist for reference
|
|
138
|
-
this.classLists.
|
|
159
|
+
this.classLists.add(eachClass);
|
|
139
160
|
// var result=compiler.main(eachClass);
|
|
140
161
|
const result = statementMaker.make(eachClass);
|
|
141
162
|
// console.log(result);
|
|
@@ -144,7 +165,7 @@ export let classPrinter = {
|
|
|
144
165
|
}
|
|
145
166
|
else {
|
|
146
167
|
// not a valid ACSS classNames
|
|
147
|
-
this.invalidLists.
|
|
168
|
+
this.invalidLists.add(eachClass);
|
|
148
169
|
}
|
|
149
170
|
}
|
|
150
171
|
});
|
|
@@ -155,7 +176,7 @@ export let classPrinter = {
|
|
|
155
176
|
let statement = ' ';
|
|
156
177
|
// initialize class or acss-class value container
|
|
157
178
|
let attrValue = '';
|
|
158
|
-
const testRegExp = this.useColon ?
|
|
179
|
+
const testRegExp = this.useColon ? /^class[-_:]/ : /^class[-_]/;
|
|
159
180
|
// matchRegExp:/(?:(class|className|class[-_][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
|
|
160
181
|
// matchRegExpWithColon:/(?:(class|className|class[-_:][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
|
|
161
182
|
// if class
|
|
@@ -197,10 +218,6 @@ export let classPrinter = {
|
|
|
197
218
|
statement += result + ' ';
|
|
198
219
|
// this.appendToStyleTag(result);
|
|
199
220
|
}
|
|
200
|
-
else {
|
|
201
|
-
// not a valid ACSS classNames
|
|
202
|
-
console.log('Not a valid Aliascss class name:' + eachClass);
|
|
203
|
-
}
|
|
204
221
|
}
|
|
205
222
|
});
|
|
206
223
|
return statement;
|
|
@@ -228,7 +245,6 @@ export let classPrinter = {
|
|
|
228
245
|
return statement;
|
|
229
246
|
},
|
|
230
247
|
run(el) {
|
|
231
|
-
var _a;
|
|
232
248
|
const $root = el || document;
|
|
233
249
|
// $root.dispatchEvent(event);
|
|
234
250
|
$root.dispatchEvent(new CustomEvent('acss:init', { bubbles: true, detail: { aliascss: this } }));
|
|
@@ -241,8 +257,16 @@ export let classPrinter = {
|
|
|
241
257
|
// });
|
|
242
258
|
// const event = new Event('acss:init');
|
|
243
259
|
// create a keyframes object to fix case-sensitive issue
|
|
244
|
-
|
|
245
|
-
|
|
260
|
+
// (was: outerHTML of the whole page + regex, which serialises the entire document)
|
|
261
|
+
const kfRoot = (el || document.body);
|
|
262
|
+
const kfNodes = [kfRoot, ...kfRoot.querySelectorAll('*')];
|
|
263
|
+
kfRoot.querySelectorAll('template').forEach((t) => kfNodes.push(...t.content.querySelectorAll('*')));
|
|
264
|
+
kfNodes.forEach((node) => {
|
|
265
|
+
for (const attr of node.attributes) {
|
|
266
|
+
const m = attr.name.match(/^keyframes[-_:](.+)$/i);
|
|
267
|
+
if (m)
|
|
268
|
+
this.kfNames[m[1].toLowerCase()] = m[1];
|
|
269
|
+
}
|
|
246
270
|
});
|
|
247
271
|
// <template> element
|
|
248
272
|
Array.prototype.forEach.call($root.querySelectorAll('template'), (template) => {
|
|
@@ -262,5 +286,307 @@ export let classPrinter = {
|
|
|
262
286
|
Array.prototype.forEach.call($root.querySelectorAll('[data-raw-css]'), (e) => {
|
|
263
287
|
this.appendToStyleTag(e.getAttribute('data-raw-css'));
|
|
264
288
|
});
|
|
289
|
+
this.flush(); // write the whole first pass in one go
|
|
265
290
|
},
|
|
266
291
|
};
|
|
292
|
+
/*
|
|
293
|
+
import { compiler as statementMaker} from './returnStatement.js';
|
|
294
|
+
import config from './config.js';
|
|
295
|
+
import { splitByCommaOutsideParens} from './utils/helper.js';
|
|
296
|
+
// import mapRawAttributeNames from './utils/browser-helper.js';
|
|
297
|
+
export default statementMaker;
|
|
298
|
+
type ClassPrinter = { [key: string]: any };
|
|
299
|
+
export let classPrinter: ClassPrinter = {
|
|
300
|
+
invalidLists: [],
|
|
301
|
+
classLists: [],
|
|
302
|
+
styleTagExists: false,
|
|
303
|
+
customCheck: false,
|
|
304
|
+
useColon:true,
|
|
305
|
+
cls: {},
|
|
306
|
+
kfs: {},
|
|
307
|
+
kfNames:{},
|
|
308
|
+
|
|
309
|
+
styleTag: null,
|
|
310
|
+
createStyleTag() {
|
|
311
|
+
if (this.styleTagExists === true) {
|
|
312
|
+
return this.styleTag;
|
|
313
|
+
}
|
|
314
|
+
const styleTag = document.createElement('style');
|
|
315
|
+
styleTag.id = 'styleAlias';
|
|
316
|
+
document.getElementsByTagName('head')[0].appendChild(styleTag);
|
|
317
|
+
// initialize @layer for reset, base, theme, components and utilities
|
|
318
|
+
const initLayer = document.createTextNode(
|
|
319
|
+
`@layer ${config.layers.join(', ')};`
|
|
320
|
+
);
|
|
321
|
+
styleTag.appendChild(initLayer);
|
|
322
|
+
this.styleTag = styleTag;
|
|
323
|
+
this.styleTagExists = true;
|
|
324
|
+
return styleTag;
|
|
325
|
+
},
|
|
326
|
+
// you can always append a class if you like modify the look here if you want
|
|
327
|
+
appendToStyleTag(classStatement: string) {
|
|
328
|
+
const createNewClass = document.createTextNode(classStatement);
|
|
329
|
+
this.createStyleTag().appendChild(createNewClass);
|
|
330
|
+
},
|
|
331
|
+
// compile dom stylesheet
|
|
332
|
+
// show current style statement
|
|
333
|
+
compile() {
|
|
334
|
+
const classes = document.getElementById('styleAlias');
|
|
335
|
+
if (classes) {
|
|
336
|
+
const prettyPrint = classes.innerHTML
|
|
337
|
+
.replace(/\}/g, '</br>}</br>')
|
|
338
|
+
.replace(/\{/g, '{</br> ');
|
|
339
|
+
document.write(prettyPrint);
|
|
340
|
+
} else {
|
|
341
|
+
console.warn('There is not ACSS used in this document!!');
|
|
342
|
+
alert('Could not found acss statements in this Document!');
|
|
343
|
+
}
|
|
344
|
+
},
|
|
345
|
+
|
|
346
|
+
// print className of el to style tag; gets statement from statementMaker.make(eachClass);
|
|
347
|
+
print(el: HTMLElement) {
|
|
348
|
+
|
|
349
|
+
// initialize class or acss-class value container
|
|
350
|
+
let attrValue = '';
|
|
351
|
+
const testRegExp=this.useColon? /class[-_:]/: /class[-_]/;
|
|
352
|
+
const testRegExpKF=this.useColon? /keyframes[-_:]/: /keyframes[-_]/;
|
|
353
|
+
// const rawCSS=/data-raw-css/;
|
|
354
|
+
|
|
355
|
+
// if class
|
|
356
|
+
if (el.getAttribute('class')) attrValue += ' ' + el.getAttribute('class');
|
|
357
|
+
|
|
358
|
+
// if acss-class
|
|
359
|
+
// if (el.getAttribute('acss-class')) attrValue += ' ' + el.getAttribute('acss-class');
|
|
360
|
+
// new Update
|
|
361
|
+
[...el.attributes].map((each)=>{
|
|
362
|
+
// ------------
|
|
363
|
+
// Raw-CSS Statement
|
|
364
|
+
|
|
365
|
+
// class-group
|
|
366
|
+
if( testRegExp.test(each.name)){
|
|
367
|
+
let value=each.value;
|
|
368
|
+
let group=each.name.replace(testRegExp,'');
|
|
369
|
+
const match=group.match(/\[(.)+\]/);
|
|
370
|
+
if(match){
|
|
371
|
+
group=group.replace(match[0],'');
|
|
372
|
+
value=value.trim().split(/\s+/).map(e=>match[0].replace(/^\[/,'').replace(/\]$/,'')+(/^[_-]/.test(e)?'':'-')+e).join(" ");
|
|
373
|
+
}
|
|
374
|
+
const result = statementMaker.group(value, group);
|
|
375
|
+
if (result) {
|
|
376
|
+
this.appendToStyleTag(result);
|
|
377
|
+
// return true;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// -------
|
|
381
|
+
// if( testRegExp.test(each.name)){
|
|
382
|
+
// const result = statementMaker.group(each.value, each.name.replace(testRegExp,''));
|
|
383
|
+
// if (result) {
|
|
384
|
+
// this.appendToStyleTag(result);
|
|
385
|
+
// // return true;
|
|
386
|
+
// }
|
|
387
|
+
// }
|
|
388
|
+
if( testRegExpKF.test(each.name)){
|
|
389
|
+
const key=each.name.replace(testRegExpKF,'');
|
|
390
|
+
let kfStatement='@keyframes '+ this.kfNames[key] +"{\n";
|
|
391
|
+
const returnPnV=(e:string[])=>e.map((i)=>statementMaker.make(i,undefined,true)).join(";");
|
|
392
|
+
const split=each.value.trim().split(/\s+/);
|
|
393
|
+
split.forEach((each:string) => {
|
|
394
|
+
try {
|
|
395
|
+
const[at,pNv]=each.replace(/\]\[/,']-[').replace("-","=").split("=");
|
|
396
|
+
// const result=returnPnV(pNv.replace(/^\[|\]$/g,'').split(','));
|
|
397
|
+
const result=returnPnV(splitByCommaOutsideParens(pNv.replace(/^\[|\]$/g,'')));
|
|
398
|
+
kfStatement+=` ${at.replace('@','').replace(/:/g,',').replace(/,/g,"%,").replace(/[\[|\]]/g,'')}% {${result?result:''}}`
|
|
399
|
+
} catch (error) {
|
|
400
|
+
console.log('invalid Entry for AliasCSS keyframes processor : '+each,error);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
});
|
|
404
|
+
this.appendToStyleTag(kfStatement+ "\n}");
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
})
|
|
408
|
+
|
|
409
|
+
// if has value to process
|
|
410
|
+
if (!attrValue.trim()) return;
|
|
411
|
+
|
|
412
|
+
// has-test-group(for live update only)
|
|
413
|
+
/* if (el.getAttribute('acss-group-test')) {
|
|
414
|
+
const result = statementMaker.group(attrValue, el.getAttribute('acss-group-test')||'');
|
|
415
|
+
const styleTag = document.querySelector('style#' + el.getAttribute('acss-group-test'));
|
|
416
|
+
if (result) {
|
|
417
|
+
if (styleTag) {
|
|
418
|
+
styleTag.innerHTML = '';
|
|
419
|
+
const createNewGroup = document.createTextNode(result);
|
|
420
|
+
styleTag.appendChild(createNewGroup);
|
|
421
|
+
// return true;
|
|
422
|
+
} else {
|
|
423
|
+
const styleTag: any = document.createElement('style');
|
|
424
|
+
styleTag.id = el.getAttribute('acss-group-test');
|
|
425
|
+
document.getElementsByTagName('head')[0].appendChild(styleTag);
|
|
426
|
+
const createNewGroup = document.createTextNode(result);
|
|
427
|
+
styleTag.appendChild(createNewGroup);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
} */
|
|
431
|
+
// -----------------------end of for live update
|
|
432
|
+
/*
|
|
433
|
+
// get class and trim out white spaces
|
|
434
|
+
const tmpClassList = attrValue.trim().split(/\s+/);
|
|
435
|
+
|
|
436
|
+
// looping class
|
|
437
|
+
tmpClassList.forEach((eachClass: string) => {
|
|
438
|
+
// escape repeated class name
|
|
439
|
+
|
|
440
|
+
if (this.classLists.indexOf(eachClass) === -1 && this.invalidLists.indexOf(eachClass) === -1) {
|
|
441
|
+
// add to classlist for reference
|
|
442
|
+
this.classLists.push(eachClass);
|
|
443
|
+
|
|
444
|
+
// var result=compiler.main(eachClass);
|
|
445
|
+
const result = statementMaker.make(eachClass);
|
|
446
|
+
// console.log(result);
|
|
447
|
+
|
|
448
|
+
if (result) {
|
|
449
|
+
this.appendToStyleTag(result);
|
|
450
|
+
} else {
|
|
451
|
+
// not a valid ACSS classNames
|
|
452
|
+
this.invalidLists.push(eachClass);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
});
|
|
456
|
+
}, // end-of-main
|
|
457
|
+
// returns css statement from current element
|
|
458
|
+
compileElement(el: HTMLElement, list: [] = []) {
|
|
459
|
+
const classList: string[] = list;
|
|
460
|
+
let statement = ' ';
|
|
461
|
+
// initialize class or acss-class value container
|
|
462
|
+
let attrValue = '';
|
|
463
|
+
const testRegExp=this.useColon? /class[-_:]/: /class[-_]/;
|
|
464
|
+
// matchRegExp:/(?:(class|className|class[-_][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
|
|
465
|
+
// matchRegExpWithColon:/(?:(class|className|class[-_:][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
|
|
466
|
+
|
|
467
|
+
// if class
|
|
468
|
+
if (el.getAttribute('class')) attrValue += ' ' + el.getAttribute('class');
|
|
469
|
+
// New update 2023-aug-03
|
|
470
|
+
|
|
471
|
+
[...el.attributes].map((each)=>{
|
|
472
|
+
|
|
473
|
+
if( testRegExp.test(each.name)){
|
|
474
|
+
let value=each.value;
|
|
475
|
+
let group=each.name.replace(testRegExp,'');
|
|
476
|
+
const match=group.match(/\[(.)+\]/);
|
|
477
|
+
if(match){
|
|
478
|
+
group=group.replace(match[0],'');
|
|
479
|
+
value=value.trim().split(/\s+/).map(e=>match[0].replace(/^\[/,'').replace(/\]$/,'')+(/^[_-]/.test(e)?'':'-')+e).join(" ");
|
|
480
|
+
}
|
|
481
|
+
const result = statementMaker.group(value, group);
|
|
482
|
+
if (result) {
|
|
483
|
+
this.appendToStyleTag(result);
|
|
484
|
+
// return true;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
})
|
|
489
|
+
// if acss-class
|
|
490
|
+
// if (el.getAttribute('acss-class')) attrValue += ' ' + el.getAttribute('acss-class');
|
|
491
|
+
|
|
492
|
+
// if has value to process
|
|
493
|
+
if (!attrValue.trim()) return;
|
|
494
|
+
|
|
495
|
+
// get class and trim out whitespace
|
|
496
|
+
const tmpClassList = attrValue.trim().split(/\s+/);
|
|
497
|
+
|
|
498
|
+
// looping class
|
|
499
|
+
tmpClassList.forEach((eachClass) => {
|
|
500
|
+
// escape repeated className
|
|
501
|
+
if (classList.indexOf(eachClass) === -1) {
|
|
502
|
+
classList.push(eachClass);
|
|
503
|
+
// var result=compiler.main(eachClass);
|
|
504
|
+
const result = statementMaker.make(eachClass);
|
|
505
|
+
// console.log(result);
|
|
506
|
+
|
|
507
|
+
if (result) {
|
|
508
|
+
statement += result + ' ';
|
|
509
|
+
// this.appendToStyleTag(result);
|
|
510
|
+
} else {
|
|
511
|
+
// not a valid ACSS classNames
|
|
512
|
+
console.log('Not a valid Aliascss class name:' + eachClass);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
return statement;
|
|
518
|
+
},
|
|
519
|
+
// returns css statement from given element and child
|
|
520
|
+
returnStatement($el: HTMLElement) {
|
|
521
|
+
let statement = '';
|
|
522
|
+
const classList: [] = [];
|
|
523
|
+
const processOuterHtml= this.compileElement($el, classList);
|
|
524
|
+
statement+=processOuterHtml ? processOuterHtml : '';
|
|
525
|
+
|
|
526
|
+
// <template> element
|
|
527
|
+
Array.prototype.forEach.call($el.querySelectorAll('template'), (template) => {
|
|
528
|
+
// Array.prototype.forEach.call(template.content.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
529
|
+
Array.prototype.forEach.call(template.content.querySelectorAll('[class]'), (e) => {
|
|
530
|
+
const result = this.compileElement(e, classList);
|
|
531
|
+
statement += result ? result : '';
|
|
532
|
+
});
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
// <html>
|
|
536
|
+
|
|
537
|
+
// Array.prototype.forEach.call($el.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
538
|
+
Array.prototype.forEach.call($el.querySelectorAll('[class]'), (e) => {
|
|
539
|
+
const result = this.compileElement(e, classList);
|
|
540
|
+
statement += result ? result : '';
|
|
541
|
+
});
|
|
542
|
+
|
|
543
|
+
return statement;
|
|
544
|
+
},
|
|
545
|
+
run(el: HTMLElement) {
|
|
546
|
+
const $root = el || document;
|
|
547
|
+
|
|
548
|
+
// $root.dispatchEvent(event);
|
|
549
|
+
$root.dispatchEvent(new CustomEvent('acss:init', { bubbles: true , detail:{aliascss:this}}));
|
|
550
|
+
// mapRawAttributeNames().then(({ kfs, cls }) => {
|
|
551
|
+
// // Use the variables inside this block
|
|
552
|
+
// this.cls = cls;
|
|
553
|
+
// this.kfs = kfs;
|
|
554
|
+
// }).catch(error => {
|
|
555
|
+
// console.error("cannot initialize keyframes and class-grouping for case free names:", error);
|
|
556
|
+
// });
|
|
557
|
+
|
|
558
|
+
// const event = new Event('acss:init');
|
|
559
|
+
|
|
560
|
+
|
|
561
|
+
|
|
562
|
+
// create a keyframes object to fix case-sensitive issue
|
|
563
|
+
(el||document.body).outerHTML.match(/keyframes-[a-z0-9_-]+(?==)/gi)?.forEach((each)=>{
|
|
564
|
+
this.kfNames[each.replace('keyframes-','').toLowerCase()]=each.replace('keyframes-','');
|
|
565
|
+
|
|
566
|
+
})
|
|
567
|
+
|
|
568
|
+
|
|
569
|
+
|
|
570
|
+
// <template> element
|
|
571
|
+
Array.prototype.forEach.call($root.querySelectorAll('template'), (template) => {
|
|
572
|
+
// Array.prototype.forEach.call(template.content.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
573
|
+
Array.prototype.forEach.call(template.content.querySelectorAll('[class]'), (e) => {
|
|
574
|
+
this.print(e);
|
|
575
|
+
});
|
|
576
|
+
Array.prototype.forEach.call(template.content.querySelectorAll('[data-raw-css]'), (e) => {
|
|
577
|
+
this.appendToStyleTag(e.getAttribute('data-raw-css'));
|
|
578
|
+
});
|
|
579
|
+
});
|
|
580
|
+
|
|
581
|
+
// <html>
|
|
582
|
+
|
|
583
|
+
// Array.prototype.forEach.call($root.querySelectorAll('[class],[acss-class]'), (e) => {
|
|
584
|
+
Array.prototype.forEach.call($root.querySelectorAll('[class]'), (e) => {
|
|
585
|
+
this.print(e);
|
|
586
|
+
});
|
|
587
|
+
Array.prototype.forEach.call($root.querySelectorAll('[data-raw-css]'), (e) => {
|
|
588
|
+
this.appendToStyleTag(e.getAttribute('data-raw-css'));
|
|
589
|
+
});
|
|
590
|
+
},
|
|
591
|
+
|
|
592
|
+
};*/
|
package/lib/compilers/color.js
CHANGED
|
@@ -36,15 +36,15 @@ export default function color(color, custom) {
|
|
|
36
36
|
// custom-color try replacing -
|
|
37
37
|
if (custom.colors.hasOwnProperty(color.replace(/-/g, ''))) {
|
|
38
38
|
if (alpha !== null)
|
|
39
|
-
return `oklch(from ${color.replace(/-/g, '')} l c h/${alpha} )`;
|
|
39
|
+
return `oklch(from ${custom.colors[color.replace(/-/g, '')]} l c h/${alpha} )`;
|
|
40
40
|
return custom.colors[color.replace(/-/g, '')];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
// hexadecimal =+ alpha 00-ff
|
|
44
|
-
if (/^[0-9a-fA-F]{3,8}$/.test(color)) {
|
|
44
|
+
if (/^[#]?[0-9a-fA-F]{3,8}$/.test(color)) {
|
|
45
45
|
if (alpha !== null)
|
|
46
|
-
return `oklch(from #${color} l c h/${alpha} )`;
|
|
47
|
-
return `#${color}`;
|
|
46
|
+
return `oklch(from #${color.replace("#", '')} l c h/${alpha} )`;
|
|
47
|
+
return `#${color.replace("#", '')}`;
|
|
48
48
|
// Name
|
|
49
49
|
}
|
|
50
50
|
else if (/^[a-zA-Z]+$/.test(color)) {
|
|
@@ -94,7 +94,7 @@ export default function color(color, custom) {
|
|
|
94
94
|
}
|
|
95
95
|
else if (/^p3-/.test(color)) {
|
|
96
96
|
if (color.replace(/p3/, '').match(/^--/))
|
|
97
|
-
return `color(display-p3
|
|
97
|
+
return `color(display-p3 var(${color.replace(/p3/, '')})`;
|
|
98
98
|
return replaceLast(`color(display-p3 ${color.replace(/p3/, '').replace(/^-/, '').replace(/-/g, ' ').replace('d', '.')
|
|
99
99
|
.replace(/([0-9])p/g, '$1%')})`, 4, " ", " / ");
|
|
100
100
|
}
|
|
@@ -94,11 +94,11 @@ const alias = {
|
|
|
94
94
|
l: 'left',
|
|
95
95
|
left: 'left',
|
|
96
96
|
'top-left': 'top left',
|
|
97
|
-
'top-right': 'top
|
|
97
|
+
'top-right': 'top right',
|
|
98
98
|
'bottom-right': 'bottom right',
|
|
99
99
|
'bottom-left': 'bottom left',
|
|
100
100
|
'left-top': 'left top',
|
|
101
|
-
'right-top': '
|
|
101
|
+
'right-top': 'right top',
|
|
102
102
|
'right-bottom': 'right bottom',
|
|
103
103
|
'left-bottom': 'left bottom',
|
|
104
104
|
tl: 'top left',
|
|
@@ -106,7 +106,7 @@ const alias = {
|
|
|
106
106
|
br: 'bottom right',
|
|
107
107
|
bl: 'bottom left',
|
|
108
108
|
lt: 'left top',
|
|
109
|
-
rt: '
|
|
109
|
+
rt: 'right top',
|
|
110
110
|
rb: 'right bottom',
|
|
111
111
|
lb: 'left bottom',
|
|
112
112
|
tor: 'to right',
|
|
@@ -5,7 +5,8 @@ export function string(str, custom) {
|
|
|
5
5
|
export default function content(str) {
|
|
6
6
|
// for CSS entities
|
|
7
7
|
if (str.match(/^_/)) {
|
|
8
|
-
return "'
|
|
8
|
+
// return '"' + str.split("_").join(" \\").trim() + '"';
|
|
9
|
+
return '"' + str.slice(1).split('_').map(c => '\\' + c).join('') + '"';
|
|
9
10
|
}
|
|
10
11
|
str = str.replace(/^[-]/, '');
|
|
11
12
|
// attr() or counter()
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
declare const components: {
|
|
2
|
+
'x-card': {
|
|
3
|
+
type: string;
|
|
4
|
+
statement: string;
|
|
5
|
+
};
|
|
6
|
+
'x-card-header': {
|
|
7
|
+
type: string;
|
|
8
|
+
statement: string;
|
|
9
|
+
};
|
|
10
|
+
'x-card-body': {
|
|
11
|
+
type: string;
|
|
12
|
+
statement: string;
|
|
13
|
+
};
|
|
14
|
+
'x-card-footer': {
|
|
15
|
+
type: string;
|
|
16
|
+
statement: string;
|
|
17
|
+
};
|
|
18
|
+
'x-card-media': {
|
|
19
|
+
type: string;
|
|
20
|
+
statement: string;
|
|
21
|
+
};
|
|
22
|
+
'x-card-title': {
|
|
23
|
+
type: string;
|
|
24
|
+
statement: string;
|
|
25
|
+
};
|
|
26
|
+
'x-card-description': {
|
|
27
|
+
type: string;
|
|
28
|
+
statement: string;
|
|
29
|
+
};
|
|
30
|
+
'x-card-elevated': {
|
|
31
|
+
type: string;
|
|
32
|
+
statement: string;
|
|
33
|
+
};
|
|
34
|
+
'x-card-flat': {
|
|
35
|
+
type: string;
|
|
36
|
+
statement: string;
|
|
37
|
+
};
|
|
38
|
+
'x-card-interactive': {
|
|
39
|
+
type: string;
|
|
40
|
+
statement: string;
|
|
41
|
+
};
|
|
42
|
+
'x-badge': {
|
|
43
|
+
type: string;
|
|
44
|
+
statement: string;
|
|
45
|
+
};
|
|
46
|
+
'x-badge-primary': {
|
|
47
|
+
type: string;
|
|
48
|
+
statement: string;
|
|
49
|
+
};
|
|
50
|
+
'x-badge-success': {
|
|
51
|
+
type: string;
|
|
52
|
+
statement: string;
|
|
53
|
+
};
|
|
54
|
+
'x-badge-warning': {
|
|
55
|
+
type: string;
|
|
56
|
+
statement: string;
|
|
57
|
+
};
|
|
58
|
+
'x-badge-error': {
|
|
59
|
+
type: string;
|
|
60
|
+
statement: string;
|
|
61
|
+
};
|
|
62
|
+
'x-badge-info': {
|
|
63
|
+
type: string;
|
|
64
|
+
statement: string;
|
|
65
|
+
};
|
|
66
|
+
'x-badge-dot': {
|
|
67
|
+
type: string;
|
|
68
|
+
statement: string;
|
|
69
|
+
};
|
|
70
|
+
'x-badge-sm': {
|
|
71
|
+
type: string;
|
|
72
|
+
statement: string;
|
|
73
|
+
};
|
|
74
|
+
'x-badge-lg': {
|
|
75
|
+
type: string;
|
|
76
|
+
statement: string;
|
|
77
|
+
};
|
|
78
|
+
'x-badge-square': {
|
|
79
|
+
type: string;
|
|
80
|
+
statement: string;
|
|
81
|
+
};
|
|
82
|
+
'x-alert': {
|
|
83
|
+
type: string;
|
|
84
|
+
statement: string;
|
|
85
|
+
};
|
|
86
|
+
'x-alert-title': {
|
|
87
|
+
type: string;
|
|
88
|
+
statement: string;
|
|
89
|
+
};
|
|
90
|
+
'x-alert-info': {
|
|
91
|
+
type: string;
|
|
92
|
+
statement: string;
|
|
93
|
+
};
|
|
94
|
+
'x-alert-success': {
|
|
95
|
+
type: string;
|
|
96
|
+
statement: string;
|
|
97
|
+
};
|
|
98
|
+
'x-alert-warning': {
|
|
99
|
+
type: string;
|
|
100
|
+
statement: string;
|
|
101
|
+
};
|
|
102
|
+
'x-alert-error': {
|
|
103
|
+
type: string;
|
|
104
|
+
statement: string;
|
|
105
|
+
};
|
|
106
|
+
'x-alert-accent': {
|
|
107
|
+
type: string;
|
|
108
|
+
statement: string;
|
|
109
|
+
};
|
|
110
|
+
'x-dialog': {
|
|
111
|
+
type: string;
|
|
112
|
+
statement: string;
|
|
113
|
+
};
|
|
114
|
+
'x-dialog-header': {
|
|
115
|
+
type: string;
|
|
116
|
+
statement: string;
|
|
117
|
+
};
|
|
118
|
+
'x-dialog-title': {
|
|
119
|
+
type: string;
|
|
120
|
+
statement: string;
|
|
121
|
+
};
|
|
122
|
+
'x-dialog-body': {
|
|
123
|
+
type: string;
|
|
124
|
+
statement: string;
|
|
125
|
+
};
|
|
126
|
+
'x-dialog-footer': {
|
|
127
|
+
type: string;
|
|
128
|
+
statement: string;
|
|
129
|
+
};
|
|
130
|
+
'x-dialog-sm': {
|
|
131
|
+
type: string;
|
|
132
|
+
statement: string;
|
|
133
|
+
};
|
|
134
|
+
'x-dialog-lg': {
|
|
135
|
+
type: string;
|
|
136
|
+
statement: string;
|
|
137
|
+
};
|
|
138
|
+
'x-dialog-sheet': {
|
|
139
|
+
type: string;
|
|
140
|
+
statement: string;
|
|
141
|
+
};
|
|
142
|
+
'x-accordion-group': {
|
|
143
|
+
type: string;
|
|
144
|
+
statement: string;
|
|
145
|
+
};
|
|
146
|
+
'x-accordion': {
|
|
147
|
+
type: string;
|
|
148
|
+
statement: string;
|
|
149
|
+
};
|
|
150
|
+
'x-accordion-content': {
|
|
151
|
+
type: string;
|
|
152
|
+
statement: string;
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
export default components;
|