aliascss 1.1.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/.prettierrc +5 -0
- package/LICENSE +21 -0
- package/README.md +544 -0
- package/READMEEdititng.md +615 -0
- package/aliascss.config.js +201 -0
- package/bin/aliascss.js +101 -0
- package/dist/aliascss.js +1 -0
- package/jestconfig.json +10 -0
- package/lib/build/index.d.ts +1 -0
- package/lib/build/index.js +63 -0
- package/lib/classPrinter.d.ts +6 -0
- package/lib/classPrinter.js +233 -0
- package/lib/compilers/border.d.ts +5 -0
- package/lib/compilers/border.js +50 -0
- package/lib/compilers/clipPath.d.ts +5 -0
- package/lib/compilers/clipPath.js +57 -0
- package/lib/compilers/color.d.ts +5 -0
- package/lib/compilers/color.js +61 -0
- package/lib/compilers/filter.d.ts +7 -0
- package/lib/compilers/filter.js +54 -0
- package/lib/compilers/font.d.ts +5 -0
- package/lib/compilers/font.js +19 -0
- package/lib/compilers/gradient.d.ts +5 -0
- package/lib/compilers/gradient.js +138 -0
- package/lib/compilers/length.d.ts +2 -0
- package/lib/compilers/length.js +10 -0
- package/lib/compilers/shadow.d.ts +5 -0
- package/lib/compilers/shadow.js +55 -0
- package/lib/compilers/stringAndContent.d.ts +6 -0
- package/lib/compilers/stringAndContent.js +23 -0
- package/lib/compilers/timingFunction.d.ts +5 -0
- package/lib/compilers/timingFunction.js +35 -0
- package/lib/compilers/transform.d.ts +2 -0
- package/lib/compilers/transform.js +117 -0
- package/lib/compilers/transition.d.ts +1 -0
- package/lib/compilers/transition.js +35 -0
- package/lib/compilers/url.d.ts +1 -0
- package/lib/compilers/url.js +33 -0
- package/lib/config.d.ts +20 -0
- package/lib/config.js +21 -0
- package/lib/css-properties-all.d.ts +16 -0
- package/lib/css-properties-all.js +2642 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +7 -0
- package/lib/node/compileFile.d.ts +25 -0
- package/lib/node/compileFile.js +337 -0
- package/lib/node/extractClassNamesFromFile.d.ts +18 -0
- package/lib/node/extractClassNamesFromFile.js +105 -0
- package/lib/prefix/PseudoPrefix.d.ts +7 -0
- package/lib/prefix/PseudoPrefix.js +145 -0
- package/lib/prefix/attribute-selector.d.ts +5 -0
- package/lib/prefix/attribute-selector.js +14 -0
- package/lib/prefix/colonToDefaultConversion.d.ts +1 -0
- package/lib/prefix/colonToDefaultConversion.js +3 -0
- package/lib/prefix/element-selector.d.ts +5 -0
- package/lib/prefix/element-selector.js +25 -0
- package/lib/prefix/extractMediaPrefix.d.ts +3 -0
- package/lib/prefix/extractMediaPrefix.js +12 -0
- package/lib/prefix/extractPrefix.d.ts +1 -0
- package/lib/prefix/extractPrefix.js +66 -0
- package/lib/prefix/pseudoSelector.d.ts +1 -0
- package/lib/prefix/pseudoSelector.js +48 -0
- package/lib/prefix/pseudoSelectorNew.d.ts +1 -0
- package/lib/prefix/pseudoSelectorNew.js +78 -0
- package/lib/prefix/responsive.d.ts +10 -0
- package/lib/prefix/responsive.js +26 -0
- package/lib/returnPropertyAndValue.d.ts +8 -0
- package/lib/returnPropertyAndValue.js +42 -0
- package/lib/returnStatement.d.ts +5 -0
- package/lib/returnStatement.js +189 -0
- package/lib/static/customColors.d.ts +3 -0
- package/lib/static/customColors.js +376 -0
- package/lib/static/customStaticClassNames.d.ts +3 -0
- package/lib/static/customStaticClassNames.js +132 -0
- package/lib/static/staticClassNamesAlias.d.ts +3 -0
- package/lib/static/staticClassNamesAlias.js +1300 -0
- package/lib/utils/createCompilerObj.d.ts +35 -0
- package/lib/utils/createCompilerObj.js +97 -0
- package/lib/utils/cssFunc.d.ts +1 -0
- package/lib/utils/cssFunc.js +27 -0
- package/package.json +64 -0
- package/ts.js +5 -0
- package/tsconfig.json +14 -0
- package/tslint.json +9 -0
- package/webpack.config.js +11 -0
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
type Property = {
|
|
2
|
+
alias?: string;
|
|
3
|
+
property?: string;
|
|
4
|
+
type?: string;
|
|
5
|
+
values?: string[];
|
|
6
|
+
compiler?: (a: string, b: {
|
|
7
|
+
[key: string]: {
|
|
8
|
+
[key: string]: string;
|
|
9
|
+
};
|
|
10
|
+
}) => any;
|
|
11
|
+
};
|
|
12
|
+
declare const _default: (key: string, compiler: Property) => ({
|
|
13
|
+
[key: string]: Property;
|
|
14
|
+
} | {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
})[];
|
|
17
|
+
export default _default;
|
|
18
|
+
export declare function staticValueCompiler(property: string, alias: string | boolean | undefined, values: string[]): {
|
|
19
|
+
[key: string]: string;
|
|
20
|
+
};
|
|
21
|
+
export declare function extractProperty(className: string, data: {
|
|
22
|
+
[key: string]: Property;
|
|
23
|
+
}): ({} | null)[];
|
|
24
|
+
export declare function generateStaticClassNames(data: {
|
|
25
|
+
[key: string]: Property;
|
|
26
|
+
}, global?: string[]): {
|
|
27
|
+
[key: string]: string;
|
|
28
|
+
};
|
|
29
|
+
export declare function createCompilerObj(obj: {
|
|
30
|
+
[key: string]: Property;
|
|
31
|
+
}, globalValue?: string[]): [{
|
|
32
|
+
[key: string]: string;
|
|
33
|
+
}, {
|
|
34
|
+
[key: string]: Property;
|
|
35
|
+
}];
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export default (key, compiler) => {
|
|
2
|
+
var _a;
|
|
3
|
+
const dynamicCompilerObj = {};
|
|
4
|
+
let staticCompilerObj = {};
|
|
5
|
+
const property = compiler.property || key;
|
|
6
|
+
const alias = compiler.alias || false;
|
|
7
|
+
// Generate Static ClassNames
|
|
8
|
+
if ((_a = compiler.values) === null || _a === void 0 ? void 0 : _a.length) {
|
|
9
|
+
staticCompilerObj = Object.assign(Object.assign({}, staticValueCompiler(property, alias, compiler.values)), staticCompilerObj);
|
|
10
|
+
}
|
|
11
|
+
// Make Dynamic Class Compiler
|
|
12
|
+
if (compiler.compiler && typeof compiler.compiler === 'function') {
|
|
13
|
+
if (property)
|
|
14
|
+
dynamicCompilerObj[key] = { property, compiler: compiler.compiler };
|
|
15
|
+
if (alias)
|
|
16
|
+
dynamicCompilerObj[alias] = { property, compiler: compiler.compiler };
|
|
17
|
+
}
|
|
18
|
+
return [dynamicCompilerObj, staticCompilerObj];
|
|
19
|
+
};
|
|
20
|
+
export function staticValueCompiler(property, alias = false, values) {
|
|
21
|
+
const result = {};
|
|
22
|
+
if (values.length) {
|
|
23
|
+
values.forEach((value) => {
|
|
24
|
+
const val = value.split(':')[0];
|
|
25
|
+
value.split(':').forEach((each) => {
|
|
26
|
+
result[`${property}-${each}`] = `${property}:${val}`;
|
|
27
|
+
if (alias)
|
|
28
|
+
result[`${alias}-${each}`] = `${property}:${val}`;
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
export function extractProperty(className, data) {
|
|
35
|
+
// we just need parts before '--' or __ as they can't be in property is any;
|
|
36
|
+
const splittedClassName = className.split('--')[0];
|
|
37
|
+
const extractPossiblePropertyPortion = splittedClassName.match(/^[a-z-]+/);
|
|
38
|
+
// Not a valid Aliascss class name
|
|
39
|
+
if (!extractPossiblePropertyPortion)
|
|
40
|
+
return [null, null];
|
|
41
|
+
let propertyPortion = extractPossiblePropertyPortion[0]
|
|
42
|
+
.replace(/-$/, '') // remove last "-"
|
|
43
|
+
.trim();
|
|
44
|
+
let propertyHolder = null;
|
|
45
|
+
// try to match whole portion with property alias
|
|
46
|
+
// From higher to lower i.e border-right-color.......border-right.....border
|
|
47
|
+
if (data.hasOwnProperty(propertyPortion)) {
|
|
48
|
+
propertyHolder = data[propertyPortion];
|
|
49
|
+
// console.log(className,0);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// remove last -[a-z]+ and try again un till ^[a-z]+ means we are at begin ing
|
|
53
|
+
while (/[-][a-z]+$/.test(propertyPortion)) {
|
|
54
|
+
propertyPortion = propertyPortion.replace(/[-][a-z]+$/, '');
|
|
55
|
+
if (data.hasOwnProperty(propertyPortion)) {
|
|
56
|
+
propertyHolder = data[propertyPortion];
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return [propertyHolder, propertyPortion];
|
|
62
|
+
}
|
|
63
|
+
;
|
|
64
|
+
export function generateStaticClassNames(data, global = []) {
|
|
65
|
+
let staticClassNames = {};
|
|
66
|
+
Object.keys(data).map((key) => {
|
|
67
|
+
const [property, alias, values] = [(data[key].property || key), (data[key].property ? key : (data[key].alias || false)), [...(data[key].values || []), ...global]
|
|
68
|
+
];
|
|
69
|
+
staticClassNames = Object.assign(Object.assign({}, staticValueCompiler(property, alias, values)), staticClassNames);
|
|
70
|
+
});
|
|
71
|
+
return staticClassNames;
|
|
72
|
+
}
|
|
73
|
+
;
|
|
74
|
+
// takes compiler as arguments and return compiler obj with alias and staticClassNames with Alias
|
|
75
|
+
export function createCompilerObj(obj, globalValue = []) {
|
|
76
|
+
const [staticClassNames, compilerObj] = [{}, {}];
|
|
77
|
+
Object.keys(obj).map((key) => {
|
|
78
|
+
var _a, _b;
|
|
79
|
+
// createStaticClassNames from Obj
|
|
80
|
+
const [property, alias, values] = [(obj[key].property || key), (obj[key].property ? key : (obj[key].alias || false)), [...(obj[key].values || []), ...globalValue]
|
|
81
|
+
];
|
|
82
|
+
for (const [key, value] of Object.entries(staticValueCompiler(property, alias, values))) {
|
|
83
|
+
staticClassNames[key] = value;
|
|
84
|
+
}
|
|
85
|
+
// staticClassNames={...staticValueCompiler(property,alias,values),...staticClassNames}
|
|
86
|
+
// Dynamic compiler generator for css-Props and Alias
|
|
87
|
+
compilerObj[key] = obj[key];
|
|
88
|
+
if ((_a = obj[key].alias) === null || _a === void 0 ? void 0 : _a.trim()) {
|
|
89
|
+
const alias = ((_b = obj[key].alias) === null || _b === void 0 ? void 0 : _b.trim()) || null;
|
|
90
|
+
if (alias) {
|
|
91
|
+
compilerObj[alias] = obj[key];
|
|
92
|
+
compilerObj[alias].property = key;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return [staticClassNames, compilerObj];
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function repeat(data: string): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// GTC GTR GT left no grid
|
|
2
|
+
export function repeat(data) {
|
|
3
|
+
var _a;
|
|
4
|
+
data = data.replace(/repeat/g, '===');
|
|
5
|
+
const matchRegex = /===-([\d]+|auto-fill|auto-fit)-([a-z0-9-]+)/;
|
|
6
|
+
while (data.match(matchRegex)) {
|
|
7
|
+
const m = (_a = data.match(matchRegex)) === null || _a === void 0 ? void 0 : _a[0].replace(/===/, ' ');
|
|
8
|
+
const match = (m === null || m === void 0 ? void 0 : m.match(/-([\d]+|auto-fill|auto-fit)-([a-z0-9-]+)/)) || ['', '', ''];
|
|
9
|
+
data = data.replace(matchRegex, `repeat(${match[1]}, ${match[2].replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g, " $1($2 , $3 ) ")
|
|
10
|
+
.replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
|
|
11
|
+
.replace(/([\d])d([\d])/g, '$1.$2')
|
|
12
|
+
.replace(/-([\d|a|a])/g, ' $1')
|
|
13
|
+
.replace(/([\d])p([\s])/g, "$1% ").replace(/p$/, "%").replace(/-by[-\s]/g, ' / ')})`);
|
|
14
|
+
}
|
|
15
|
+
// const match=data.match(/-([\d]+|auto-fill|auto-fit)-([a-z0-9-]+)(.*)/)||['','',''];
|
|
16
|
+
// return `repeat(${match[1]}, ${match[2].replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g," $1($2 , $3 ) ")
|
|
17
|
+
// .replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
|
|
18
|
+
// .replace(/([\d])d([\d])/g,'$1.$2')
|
|
19
|
+
// .replace(/-([\d|a|a])/g,' $1')
|
|
20
|
+
// .replace(/([\d])p([\s])/g,"$1% ").replace(/p$/,"%").replace(/-by[-\s]/g,' / ')})`
|
|
21
|
+
// repeat-4-auto-fill-20px-30px-min-max content
|
|
22
|
+
return data.replace(/[-]?(minmax)-(min-content|max-content|auto|\w+)-(min-content|max-content|auto|\w+)/g, " $1($2 , $3 ) ")
|
|
23
|
+
.replace(/[-]?(fit-content)[-]([\w]+)/g, "$1( $2 ) ")
|
|
24
|
+
.replace(/([\d])d([\d])/g, '$1.$2')
|
|
25
|
+
.replace(/-([\d|a|a|m|r])/g, ' $1').replace(/-[)]r/g, ') r')
|
|
26
|
+
.replace(/([\d])p([\s])/g, "$1% ").replace(/p$/, "%").replace(/-by[-\s]/g, ' / ').replace(/_(\d)/g, ' $1');
|
|
27
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aliascss",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "AliasCSS is a CSS post processor.",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"types": "lib/index.d.ts",
|
|
7
|
+
"bin": "bin/aliascss.js",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"typings": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "jest --config jestconfig.json",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"wp": "webpack",
|
|
14
|
+
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
15
|
+
"lint": "tslint -p tsconfig.json",
|
|
16
|
+
"prepare": "npm run build",
|
|
17
|
+
"prepublishOnly": "npm test && npm run lint",
|
|
18
|
+
"preversion": "npm run lint",
|
|
19
|
+
"version": "npm run format && git add -A src",
|
|
20
|
+
"postversion": "git push && git push --tags"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "git+https://github.com/Rodolopho/acss-lite.git"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jest": "^29.5.3",
|
|
28
|
+
"@types/postcss-sorting": "^8.0.2",
|
|
29
|
+
"jest": "^29.6.2",
|
|
30
|
+
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
31
|
+
"ts-jest": "^29.1.1",
|
|
32
|
+
"ts-node": "^10.9.2",
|
|
33
|
+
"tslint": "^6.1.3",
|
|
34
|
+
"tslint-config-prettier": "^1.18.0",
|
|
35
|
+
"webpack": "^5.88.2",
|
|
36
|
+
"webpack-cli": "^5.1.4"
|
|
37
|
+
},
|
|
38
|
+
"keywords": [
|
|
39
|
+
"CSS",
|
|
40
|
+
"Post",
|
|
41
|
+
"processor",
|
|
42
|
+
"AliasCSS",
|
|
43
|
+
"ACSS",
|
|
44
|
+
"ACSS-lite",
|
|
45
|
+
"UI",
|
|
46
|
+
"Design",
|
|
47
|
+
"css"
|
|
48
|
+
],
|
|
49
|
+
"author": "Bikram Thapa",
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"bugs": {
|
|
52
|
+
"url": "https://github.com/Rodolopho/acss-lite/issues"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"chokidar": "^3.6.0",
|
|
56
|
+
"cssnano": "^7.0.4",
|
|
57
|
+
"fast-glob": "^3.3.1",
|
|
58
|
+
"postcss": "^8.4.39",
|
|
59
|
+
"postcss-discard-duplicates": "^7.0.0",
|
|
60
|
+
"postcss-sort-media-queries": "^5.2.0",
|
|
61
|
+
"postcss-sorting": "^8.0.2"
|
|
62
|
+
},
|
|
63
|
+
"homepage": "https://github.com/Rodolopho/acss-lite#readme"
|
|
64
|
+
}
|
package/ts.js
ADDED
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es6",
|
|
4
|
+
"module": "nodenext",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./lib",
|
|
7
|
+
"esModuleInterop": true,
|
|
8
|
+
"strict": true
|
|
9
|
+
},
|
|
10
|
+
"include": ["src", "test.js", "bin"],
|
|
11
|
+
"exclude": ["node_modules", "**/__tests__/*"],
|
|
12
|
+
"esModuleInterop" : true
|
|
13
|
+
}
|
|
14
|
+
|
package/tslint.json
ADDED