aliascss 1.1.13 → 1.1.15

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.
@@ -79,11 +79,12 @@ export let classPrinter = {
79
79
  if (testRegExpKF.test(each.name)) {
80
80
  const key = each.name.replace(testRegExpKF, '');
81
81
  let kfStatement = '@keyframes ' + key + "{\n";
82
+ const returnPnV = (e) => e.map((i) => statementMaker.make(i, undefined, true)).join(";");
82
83
  const split = each.value.trim().split(/\s+/);
83
84
  split.forEach((each) => {
84
85
  try {
85
- const [at, pNv] = each.replace("-", "=").split("=");
86
- const result = statementMaker.make(pNv, undefined, true);
86
+ const [at, pNv] = each.replace(/\]\[/, ']-[').replace("-", "=").split("=");
87
+ const result = returnPnV(pNv.replace(/^\[|\]$/g, '').split(','));
87
88
  kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${result ? result : ''}}`;
88
89
  }
89
90
  catch (error) {
@@ -27,7 +27,7 @@ export default function shadow(data, custom) {
27
27
  compileValue += eachValue + ",";
28
28
  // search for length /()/
29
29
  });
30
- return compileValue.replace(/[,]$/, '').trim();
30
+ return compileValue.replace(/[,]$/, '').replace(/%x/g, '%').trim();
31
31
  }
32
32
  const ref = `/* Keyword values */
33
33
  box-shadow: none;
@@ -120,11 +120,12 @@ export function groupStatement(name, classNames, statementMaker) {
120
120
  }
121
121
  export function keyframesStatement(name, timeLine, statementMaker) {
122
122
  let kfStatement = '@keyframes ' + name + "{\n";
123
+ const returnPnV = (e) => e.map((i) => statementMaker.make(i, null, true)).join(";");
123
124
  const split = timeLine.split(/\s+/);
124
125
  split.forEach((each) => {
125
126
  try {
126
- const [at, pNv] = each.replace("-", "=").split("=");
127
- kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${statementMaker.make(pNv, null, true)}}`;
127
+ const [at, pNv] = each.replace(/\]\[/, ']-[').replace("-", "=").split("=");
128
+ kfStatement += ` ${at.replace('@', '').replace(/:/g, ',').replace(/,/g, "%,").replace(/[\[|\]]/g, '')}% {${returnPnV(pNv.replace(/^\[|\]$/g, '').split(','))}}`;
128
129
  }
129
130
  catch (error) {
130
131
  console.error('Not a valid entry for AliasCSS keyframes processor : ' + each, error);
@@ -47,7 +47,7 @@ export default function PseudoEleStateNew(data) {
47
47
  const cn = (mch === null || mch === void 0 ? void 0 : mch[0]) ? data.replace(mch[0], '') : '';
48
48
  const alias = (mch === null || mch === void 0 ? void 0 : mch[1]) ? prefix[mch[1].replace(/-$/, '')] : '';
49
49
  const cont = mch === null || mch === void 0 ? void 0 : mch[3];
50
- console.log(data, cn, alias, mch);
50
+ // console.log(data,cn,alias,mch)
51
51
  return [cn, `${alias}(${cont})`];
52
52
  }
53
53
  else if (/(^-(-not|-has|-is|-where|-n|-hs|-w|-is)[-_])/.test(data)) {
@@ -1,4 +1,16 @@
1
- export default function getPropertyAndValue(className: string, cssPropertiesWithAlias: {}, staticClassNames: {
1
+ type Property = {
2
+ alias?: string;
3
+ property?: string;
4
+ type?: string;
5
+ values?: string[];
6
+ groups?: {
7
+ [key: string]: string;
8
+ };
9
+ compiler?: (...args: any[]) => any;
10
+ };
11
+ export default function getPropertyAndValue(className: string, cssPropertiesWithAlias: {
12
+ [key: string]: Property;
13
+ }, staticClassNames: {
2
14
  [key: string]: string;
3
15
  }, custom: {
4
16
  [key: string]: {
@@ -6,3 +18,4 @@ export default function getPropertyAndValue(className: string, cssPropertiesWith
6
18
  };
7
19
  }, extractProperty: any, // (a:string,b:{[key:string]:Property})=>[Property,string],
8
20
  bool?: boolean): string[] | null | {};
21
+ export {};
@@ -12,6 +12,16 @@ bool = false) {
12
12
  return bool ? [property, "var(" + value + ')'] : property + ": var(" + value + ')';
13
13
  }
14
14
  else {
15
+ // check for string and color
16
+ if (/color$/.test(property)) {
17
+ console.log(cssPropertiesWithAlias.color);
18
+ const v = cssPropertiesWithAlias.color.compiler ? cssPropertiesWithAlias.color.compiler(value, custom) : value;
19
+ return bool ? [property, v] : property + ":" + v;
20
+ }
21
+ else if (/text$/.test(property)) {
22
+ const v = '"' + value.replace(/([_]?)[_]/g, '$1 ').replace(/_[\s]/g, '_') + '"';
23
+ return bool ? [property, v] : property + ":" + v;
24
+ }
15
25
  return bool ? [property, value.replace(/[-]([-]?[\w])/g, ' $1').replace(/([\d])d([\d])/g, '$1.$2').replace(/([\d])p[\s]/g, "$1% ").replace(/([\d])p$/, "$1%").replace(/[\s]by[\s]/g, ' / ').replace(/auto flow/g, 'auto-flow')]
16
26
  :
17
27
  property + ":" + value.replace(/[-]([-]?[\w])/g, ' $1').replace(/([\d])d([\d])/g, '$1.$2').replace(/([\d])p[\s]/g, "$1% ").replace(/([\d])p$/, "$1%").replace(/[\s]by[\s]/g, ' / ').replace(/auto flow/g, 'auto-flow');
@@ -43,6 +43,15 @@ export const compiler = {
43
43
  // className as another-name, bool->only return property and value
44
44
  make(className, as, bool) {
45
45
  let unPrefixedClassName = className;
46
+ // check for [group-acss,]
47
+ const matchGroupCSS = className.match(/\[([^[]*)\]$/);
48
+ if (matchGroupCSS) {
49
+ const asString = matchGroupCSS[1]
50
+ .split(',')
51
+ .map(e => (className.replace(matchGroupCSS[0], '') + "-").replace(/--$/, '-') + e)
52
+ .join(' ');
53
+ return this.group(asString, className);
54
+ }
46
55
  let beforeClassNameSelector = '';
47
56
  if (this.prefix && !className.match(new RegExp('^' + this.prefix + "[-]"))) {
48
57
  return null;
@@ -63,6 +72,9 @@ export const compiler = {
63
72
  console.error('Not a valid AliasCSS className:' + className, 'Make sure to provide valid css aliascss selector before "&" identifier');
64
73
  return null;
65
74
  }
75
+ else {
76
+ beforeClassNameSelector = beforeClassNameSelector.replace(/^([\s]?[+~>])(.*)/, "$2$1 ");
77
+ }
66
78
  workingClassName = workingClassName.replace(before, '').replace('&', '');
67
79
  }
68
80
  let [elementAndPseudo, important] = ['', ''];
@@ -117,15 +129,15 @@ export const compiler = {
117
129
  // ------------PostCSSParse
118
130
  if (result) {
119
131
  let stm = '';
120
- className = className.replace(/([$.&%=\]\[@~:*#+\(\)\/^])/g, '\\$1');
132
+ className = (as ? as : className).replace(/([$.&%=\]\[@~,:*#+\(\)\/^])/g, '\\$1');
121
133
  if (bool === true)
122
134
  return result;
123
135
  this.cache.propertyAndValue[pnv] = result;
124
136
  if (media) {
125
- stm = `${media}{${beforeClassNameSelector + '.' + (as ? as : className) + elementAndPseudo}{${result}${important}}}`;
137
+ stm = `${media}{${beforeClassNameSelector + '.' + className + elementAndPseudo}{${result}${important}}}`;
126
138
  }
127
139
  else {
128
- stm = `${beforeClassNameSelector}.${(as ? as : className)}${elementAndPseudo}{${result}${important}}`;
140
+ stm = `${beforeClassNameSelector}.${className}${elementAndPseudo}{${result}${important}}`;
129
141
  }
130
142
  try {
131
143
  postcss.parse(stm);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aliascss",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "AliasCSS is a CSS post processor.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",