aliascss 1.1.1 → 1.1.3

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.
@@ -53,6 +53,7 @@ export let classPrinter = {
53
53
  // new Update
54
54
  [...el.attributes].map((each) => {
55
55
  // ------------
56
+ // class-group
56
57
  if (testRegExp.test(each.name)) {
57
58
  let value = each.value;
58
59
  let group = each.name.replace(testRegExp, '');
package/lib/config.js CHANGED
@@ -6,8 +6,9 @@ const config = {
6
6
  matchExtractorFunction: new RegExp('(?:' + 'x|@' + ')' + "[\\s*]?(`|\\([" + `"'])` + "([^)`]+)" + "(`|" + `["']` + "\\))"),
7
7
  useCSSModule: false,
8
8
  matchCSSModuleFunction: new RegExp('(?:' + 'x|@' + ')' + "[\\s*]?(`|\\([" + `"'])` + "([^)`]+)" + "(`|" + `["']` + "\\))"),
9
- matchRegExp: /(?:(class|className|class[-_][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
10
- matchRegExpWithColon: /(?:(class|className|class[-_:][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
9
+ // matchRegExp:/(?:(class|className|class[-_][\w-\[\]=_]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
10
+ matchRegExp: /(?:(class|className|class[-_][\w-\[\]=_&:\(\)\~\*\$\^\|]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
11
+ matchRegExpWithColon: /(?:(class|className|class[-_:][\w-\[\]=_&:\(\)\~\*\$\^\|]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
11
12
  matchRegExpKeyFrame: /[\s](?:(keyframes[-_][\w-]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
12
13
  matchRegExpWithColonKeyFrame: /[\s](?:(keyframes[-_:][\w-]+))=[\s*]?(?:["']\W+\s*(?:\w+)\()?["']([^'"]+)['"]/,
13
14
  createExtractorRegex: (fname) => new RegExp('(?:' + fname + ')' + "[\\s*]?(`|\\([" + `"'])` + "([^)`]+)" + "(`|" + `["']` + "\\))"),
@@ -1872,13 +1872,13 @@ const cssProps = {
1872
1872
  alias: 'p',
1873
1873
  type: 'd',
1874
1874
  compiler: length,
1875
- values: [''],
1875
+ values: ['none:n'],
1876
1876
  },
1877
1877
  'padding-block': {
1878
1878
  alias: '',
1879
1879
  type: 's',
1880
1880
  compiler: length,
1881
- values: [''],
1881
+ values: ['none:n'],
1882
1882
  },
1883
1883
  'padding-block-end': {
1884
1884
  alias: 'pbe',
package/lib/index.d.ts CHANGED
@@ -1,3 +1,16 @@
1
+ import styleToAliascss from "./utils/stylesToAliascss.js";
2
+ export declare const getCompiler: (property: string) => {
3
+ alias?: string | undefined;
4
+ property?: string | undefined;
5
+ test?: RegExp | undefined;
6
+ type?: string | undefined;
7
+ values?: string[] | undefined;
8
+ compiler?: ((a: string, b: {
9
+ [key: string]: {
10
+ [key: string]: string;
11
+ };
12
+ }) => any) | undefined;
13
+ } | null;
1
14
  export declare const main: {
2
15
  [key: string]: any;
3
16
  make: (a: string, b?: string | undefined, c?: boolean | undefined) => string;
@@ -6,3 +19,4 @@ export declare const main: {
6
19
  export declare const styleJSX: (str: string, bool?: boolean) => any;
7
20
  export declare const staticClassNames: any;
8
21
  export declare const extend: (object: {}) => any;
22
+ export declare const convert: typeof styleToAliascss;
package/lib/index.js CHANGED
@@ -1,7 +1,11 @@
1
1
  import { compiler } from "./returnStatement.js";
2
+ import cssProps from "./css-properties-all.js";
3
+ import styleToAliascss from "./utils/stylesToAliascss.js";
2
4
  // import { customStaticClassNames } from "./static/customStaticClassNames.js";
5
+ export const getCompiler = (property) => cssProps.hasOwnProperty(property) ? cssProps[property] : null;
3
6
  export const main = compiler;
4
7
  export const styleJSX = (str, bool) => compiler.groupForJs(str, bool);
5
8
  // export const style=()=>{};
6
9
  export const staticClassNames = compiler.staticClassNames;
7
10
  export const extend = (object) => compiler.extend(object);
11
+ export const convert = styleToAliascss;
@@ -82,6 +82,7 @@ export default function extractClassNamesFromFile(file, config) {
82
82
  let classExtracted = each[2];
83
83
  const match = group.match(/\[(.)+\]/);
84
84
  if (match) {
85
+ console.log(match);
85
86
  group = group.replace(match[0], '');
86
87
  classExtracted = classExtracted.trim().split(/\s+/).map(e => match[0].replace(/^\[/, '').replace(/\]$/, '') + (/^[_-]/.test(e) ? '' : '-') + e).join(" ");
87
88
  }
@@ -1,11 +1,14 @@
1
1
  const attribute = {
2
- test: /^[-]?[\[][a-z0-9-_]+([~*$^]?[=][a-z0-9-_:/.]+)?[\]]/,
2
+ test: /^[-]?[\[][a-z0-9-_:]+([~*$^]?[=][a-z0-9-_:/.]+)?[\]]/,
3
3
  process(className) {
4
4
  const match = className.match(this.test);
5
5
  if (match) {
6
6
  const attr = match[0];
7
7
  if (attr) {
8
- const result = attr.replace(/[=]([a-z0-9-_:/.]+)[\]]/, '="$1"]').replace(/^[-_]/, ""); // replace(/([\[|\]])/g,'\\$1').replace(/([=])/g,'\\$1');
8
+ const attrSplit = attr.split("=")[0];
9
+ const result = attr.replace(attrSplit, attrSplit.replace(/:/g, '\\:'))
10
+ // .replace(/^([-]?[\[][a-z0-9-_:]+)([~*$^]?[=][a-z0-9-_:/.]+)?[\]]/,(m,s,b)=>s.replace(/\:/g,'\:')+b+']')
11
+ .replace(/-(eql|equal)-/, '=').replace(/[=]([a-z0-9-_:/.]+)[\]]/, '="$1"]').replace(/^[-_]/, ""); // replace(/([\[|\]])/g,'\\$1').replace(/([=])/g,'\\$1');
9
12
  return [className.replace(attr, ''), result];
10
13
  }
11
14
  }
@@ -166,7 +166,7 @@ export const compiler = {
166
166
  });
167
167
  return jsStyle;
168
168
  },
169
- // for config
169
+ // obj:{'container':'p20px m-12pxx, 'section':'mt16px'}
170
170
  groupObj(obj) {
171
171
  if (typeof obj !== 'object')
172
172
  return false;
@@ -194,7 +194,26 @@ export const compiler = {
194
194
  },
195
195
  addMedia(obj) {
196
196
  this.mediaSelector = Object.assign(Object.assign({}, this.mediaSelector), obj);
197
- }
197
+ },
198
+ // styleToAliascss(value:string,bool:boolean){
199
+ // let classValue='';
200
+ // let styleValue='';
201
+ // value.split(/\s*;\s*/).forEach((each)=>{
202
+ // const [property,value]=each.match(/:/)?each.split(':'):['',''];
203
+ // if(property && value){
204
+ // if(cssProps.hasOwnProperty(property.trim())){
205
+ // classValue+=`${(bool===true && cssProps[property.trim()].alias)?cssProps[property.trim()].alias:property}-${
206
+ // value.trim().replace(/['"]/g, '').replace(/#/g, '').replace(/\((^\()\)/g, (m,s)=>'-'+s.replace(/[\s]*,[\s]*/g,'-'))
207
+ // .replace(/\s/g, '-').replace(/^var---/g,'-').replace(/-var-/g,'')
208
+ // }`
209
+ // }else{
210
+ // styleValue+=each+'; ';
211
+ // }
212
+ // }else {
213
+ // styleValue+=each+'; ';
214
+ // }
215
+ // })
216
+ // }
198
217
  };
199
218
  // compiler.staticClassNames={...helper().generateStaticClassNames(compiler.cssProps,config['css-global-values'])};
200
219
  // compiler.addCustom('color',customColors)
@@ -0,0 +1,5 @@
1
+ export default function styleToAliascss(data: string, options?: {
2
+ 'JSX': true;
3
+ }): string;
4
+ export declare function process(match: string, styleValue: string, isSingleQuote: boolean, JSX?: boolean): string;
5
+ export declare function processJSX(match: string, styleValue: string): string;
@@ -0,0 +1,65 @@
1
+ import cssProps from "../css-properties-all.js";
2
+ export default function styleToAliascss(data, options) {
3
+ const JSX = (options === null || options === void 0 ? void 0 : options.JSX) ? true : false;
4
+ const matchJSXStyle = /(?<=[\s])style=[\{][\{]([^}]*)[\}][\}]/;
5
+ const matchSingleQuotes = /(?<=[\s])style=[']([^']*)[']/;
6
+ const matchDoubleQuotes = /(?<=[\s])style=["]([^']*)["]/;
7
+ if (JSX) {
8
+ return data.replace(new RegExp(matchJSXStyle, 'g'), (m, s) => processJSX(m, s));
9
+ }
10
+ return data.replace(new RegExp(matchSingleQuotes, 'g'), (m, s) => process(m, s, true))
11
+ .replace(new RegExp(matchDoubleQuotes, 'g'), (m, s) => process(m, s, false));
12
+ }
13
+ export function process(match, styleValue, isSingleQuote, JSX) {
14
+ let contentForStyle = '';
15
+ let contentForClass = '';
16
+ styleValue.split(';').forEach((each) => {
17
+ const split = each.split(':');
18
+ if (split && split.length === 2) {
19
+ const [property, value] = split;
20
+ if (cssProps.hasOwnProperty(property.trim())) {
21
+ contentForClass += `${property.trim()}-${value.trim().replace(/#/g, '').replace(/\s/g, '-').replace(/,/g, "__")} `;
22
+ return;
23
+ }
24
+ }
25
+ contentForStyle += each + "; ";
26
+ });
27
+ if (isSingleQuote) {
28
+ return `class="${contentForClass}" style='${contentForStyle}'`;
29
+ }
30
+ return `class="${contentForClass}" style="${contentForStyle}"`;
31
+ }
32
+ export function processJSX(match, styleValue) {
33
+ let contentForStyle = '';
34
+ let contentForClass = '';
35
+ styleValue.replace(/[,]([\s]*[a-zA-z]+\:)/g, "###$1").split("###").forEach((each) => {
36
+ const split = each.split(':');
37
+ if (split && split.length === 2) {
38
+ const [property, value] = split;
39
+ const formatProperty = property.replace(/([a-z])([A-Z])/g, (m, a, b) => a + '-' + b.toLowerCase());
40
+ if (cssProps.hasOwnProperty(formatProperty.trim())) {
41
+ contentForClass += `${formatProperty.trim()}-${value.trim().replace(/['"]/g, '').replace(/#/g, '').replace(/\s/g, '-').replace(/,/g, "__")} `;
42
+ return;
43
+ }
44
+ }
45
+ contentForStyle += each + ", ";
46
+ });
47
+ return `className="${contentForClass}" style={{${contentForStyle}}}`;
48
+ }
49
+ // export function processJSXOld(match:string,styleValue:string){
50
+ // const formatStyleValue=styleValue.replace(/[,]([\s]*[a-zA-z]+\:)/g,"###").split("###");
51
+ // let styleOjb:{[key:string]:string}={};
52
+ // eval(`styleOjb=${styleValue}`);
53
+ // console.log(styleOjb);
54
+ // const contentForStyle:{[key:string]:string}={};
55
+ // let contentForClass=''
56
+ // Object.keys(styleOjb).forEach((key:string)=>{
57
+ // const property=key.replace(/([a-z])([A-Z])/g,(m,a,b)=>a+'-'+b.toLowerCase());
58
+ // if(cssProps.hasOwnProperty(property)){
59
+ // contentForClass+=`${property.trim()}-${(styleOjb[key]+" ").trim().replace(/#/g,'').replace(/\s/g,'-').replace(/,/g,"__")} `
60
+ // return
61
+ // }
62
+ // contentForStyle[key]=styleOjb[key];
63
+ // });
64
+ // return `className="${contentForClass}" style={${JSON.stringify(contentForStyle)}}`
65
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aliascss",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "AliasCSS is a CSS post processor.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -58,7 +58,8 @@
58
58
  "postcss": "^8.4.39",
59
59
  "postcss-discard-duplicates": "^7.0.0",
60
60
  "postcss-sort-media-queries": "^5.2.0",
61
- "postcss-sorting": "^8.0.2"
61
+ "postcss-sorting": "^8.0.2",
62
+ "safe-eval": "^0.4.1"
62
63
  },
63
64
  "homepage": "https://github.com/Rodolopho/acss-lite#readme"
64
65
  }
package/ui/button.html ADDED
@@ -0,0 +1,53 @@
1
+ <div data-size="xxl" data-type="secondary">
2
+ <button
3
+ class="c-fff cp _all-bsbb p8px-12px bg-7F56D9 bxs-0px-1px-2px-0160240400d05 br-8px jcc aic g-4px dif b1px-primary600-solid text-sm fw6 btn-md btn-lg btn-xl btn-2xl btn-xxl btn"
4
+ class-btn='--is-[data-type=secondary]&--hover-bgc-f9fafb --is-[data-type=secondary]&--hover-bc-d0d4dd --is-[data-type=secondary]&bgc-fff --is-[data-type=secondary]&bc-d0d5dd --is-[data-type=secondary]&c-344054 --is-[disabled]&-bgc-F2F4F7 --is-[disabled]&-bc-EAECF0 --is-[disabled]&-c-98A2B3'
5
+ class-btn[--hover]="--is-[disabled]&-bgc-F2F4F7 --is-[disabled]&cna --is-[disabled]&-bc-EAECF0 b-1px-s-6941C6 bgc-6941C6 bxs-0px-1px-2px-0px-0160240400d05"
6
+ class-btn-md="--is-[data-size=md]&-p10px-14px"
7
+ class-btn-lg=" --is-[data-size=lg]&-p10px-16px --is-[data-size=lg]&-text-md"
8
+ class-btn-xl="--is-[data-size=xl]&-p12px-18px --is-[data-size=xl]&-g-6px --is-[data-size=xl]&-text-md"
9
+ class-btn-xxl="--is-[data-size=xxl]&-p16px-22px --is-[data-size=xxl]&-g-10px --is-[data-size=xxl]&-text-lg"
10
+ class-btn-2xl="--is-[data-size=2xl]&-p16px-22px --is-[data-size=2xl]&-g-10px --is-[data-size=2xl]&-text-lg"
11
+ style="">
12
+ <span class="btn-addon"
13
+ class-btn-addon="--is-[data-size=xxl]&-w24px --is-[data-size=xxl]&-h24px --is-[data-size=2xl]&-w24px --is-[data-size=2xl]&-h24px --is-[disabled]&-b-1d67px-solid-98A2B3 --is-[data-type=secondary]&-bc-98A2B3 lt df bsbb w20px h20px br100p b-1d67px-white-solid"
14
+ style=""></span>
15
+ <span class=" ff-Inter ww-break-word ">Button CTA</span>
16
+ <span class="rt btn-addon"></span>
17
+ </button>
18
+ </div>
19
+ <div data-size="xxl" data-type="secondary" [data-type]>
20
+ <div class="
21
+ ac-wrapper
22
+ _button-c-fff _button-cp _all-bsbb _button-p8px-12px _button-bg-7F56D9 _button-bxs-0px-1px-2px-0160240400d05
23
+ _button-br-8px _button-jcc _button-aic _button-g-4px _button-dif _button-b1px-primary600-solid text-sm
24
+ _button-fw6 btn-md btn-lg btn-xl btn-2xl btn-xxl btn
25
+ "
26
+ class-btn="c-fff cp _all-bsbb p8px-12px bg-7F56D9 bxs-0px-1px-2px-0160240400d05 br-8px jcc aic g-4px dif b1px-primary600-solid text-sm fw6"
27
+ class-btn[--hover]="--is-[disabled]&-bgc-F2F4F7 --is-[disabled]&cna --is-[disabled]&-bc-EAECF0 b-1px-s-6941C6 bgc-6941C6 bxs-0px-1px-2px-0px-0160240400d05"
28
+ class-btn-md="--is-[data-size=md]&-p10px-14px"
29
+ class-btn-lg=" --is-[data-size-eql-lg]&-p10px-16px --is-[data-size=lg]&-text-md"
30
+ class-btn-xl="--is-[data-size=xl]&-p12px-18px --is-[data-size=xl]&-g-6px --is-[data-size=xl]&-text-md"
31
+ class-btn-xxl="--is-[data-size=xxl]&-p16px-22px --is-[data-size=xxl]&-g-10px --is-[data-size=xxl]&-text-lg"
32
+ >
33
+
34
+ <!-- Main Content -->
35
+ <button
36
+ class="c-fff cp _all-bsbb p8px-12px bg-7F56D9 bxs-0px-1px-2px-0160240400d05 br-8px jcc aic g-4px dif b1px-primary600-solid text-sm fw6 btn-md btn-lg btn-xl btn-2xl btn-xxl btn"
37
+ class-btn='--is-[data-type=secondary]&--hover-bgc-f9fafb --is-[data-type=secondary]&--hover-bc-d0d4dd --is-[data-type=secondary]&bgc-fff --is-[data-type=secondary]&bc-d0d5dd --is-[data-type=secondary]&c-344054 --is-[disabled]&-bgc-F2F4F7 --is-[disabled]&-bc-EAECF0 --is-[disabled]&-c-98A2B3'
38
+ class-btn[--hover]="--is-[disabled]&-bgc-F2F4F7 --is-[disabled]&cna --is-[disabled]&-bc-EAECF0 b-1px-s-6941C6 bgc-6941C6 bxs-0px-1px-2px-0px-0160240400d05"
39
+ class-btn-md="--is-[data-size=md]&-p10px-14px"
40
+ class-btn-lg=" --is-[data-size=lg]&-p10px-16px --is-[data-size=lg]&-text-md"
41
+ class-btn-xl="--is-[data-size=xl]&-p12px-18px --is-[data-size=xl]&-g-6px --is-[data-size=xl]&-text-md"
42
+ class-btn-xxl="--is-[data-size=xxl]&-p16px-22px --is-[data-size=xxl]&-g-10px --is-[data-size=xxl]&-text-lg"
43
+ class-btn-2xl="--is-[data-size=2xl]&-p16px-22px --is-[data-size=2xl]&-g-10px --is-[data-size=2xl]&-text-lg"
44
+ style="">
45
+ <span class="btn-addon"
46
+ class-btn-addon="--is-[data-size=xxl]&-w24px --is-[data-size=xxl]&-h24px --is-[data-size=2xl]&-w24px --is-[data-size=2xl]&-h24px --is-[disabled]&-b-1d67px-solid-98A2B3 --is-[data-type=secondary]&-bc-98A2B3 lt df bsbb w20px h20px br100p b-1d67px-white-solid"
47
+ style=""></span>
48
+ <span class=" ff-Inter ww-break-word ">Button CTA</span>
49
+ <span class="rt btn-addon"></span>
50
+ </button>
51
+ <!-- End Main Content -->
52
+ </div>
53
+ </div>