aliascss 1.2.5 → 1.3.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export default function (): string;
@@ -0,0 +1,3 @@
1
+ export default function () {
2
+ return "hello";
3
+ }
@@ -0,0 +1,3 @@
1
+ import statementMaker from'../classPrinter.js';
2
+ XCompiler=statementMaker.make;
3
+
@@ -0,0 +1,20 @@
1
+ type Property = {
2
+ alias?: string;
3
+ property?: string;
4
+ test?: RegExp;
5
+ type?: string;
6
+ values?: string[];
7
+ groups?: {
8
+ [key: string]: string;
9
+ };
10
+ statement?: string;
11
+ compiler?: (a: string, b: {
12
+ [key: string]: {
13
+ [key: string]: string;
14
+ };
15
+ }) => any;
16
+ };
17
+ declare const cssCustomCompilers: {
18
+ [key: string]: Property;
19
+ };
20
+ export default cssCustomCompilers;
@@ -0,0 +1,9 @@
1
+ const cssCustomCompilers = {
2
+ abs: {
3
+ type: 'group',
4
+ compiler: () => {
5
+ return '';
6
+ }
7
+ }
8
+ };
9
+ export default cssCustomCompilers;
package/lib/prebuild.js CHANGED
@@ -189,38 +189,6 @@ export default {
189
189
  [transform-tx--100p,l0,t0,zi-1]--as-x-screen-left
190
190
  [transform-tx-100p,r0,t0,zi-1]--as-x-screen-right `
191
191
  },
192
- // Box-and-button
193
- // 'x-section':{
194
- // type:'statement',
195
- // statement:`w--x-section-width:100p p--x-section-padding:20px [class~=x-section-spacious]--x-section-padding:80px height--x-section-height:auto`,
196
- // },
197
- // 'x-container':{
198
- // type:'statement',
199
- // statement:`width-100p mla mra pl--x-container-padding:15px pl--x-container-padding:15px bsbb xw--x-container-width:initial
200
- // [class~=x-container-fluid][--x-container-width:100%,m-0-auto]
201
- // [class~=x-container-narrow][--x-container-width:800px]`,
202
- // },
203
- // 'x-row':{
204
- // type:'statement',
205
- // statement:`df fww g-16px m--8px __all-margin-8px i__all-flex-1 [class~=x-row-no-wrap]-fwn [class~=x-row-center]-jcc`,
206
- // },
207
- // 'x-col':{
208
- // type:'statement',
209
- // statement:`df fww g-16px m--8px __all-margin-8px i__all-flex-1 [class~=x-col-no-wrap]-fwn [class~=x-col-center]-jcc
210
- // [class~=x-col-full][flex-grow:1]`,
211
- // },
212
- // 'x-box':{
213
- // type:'statement',
214
- // statement:`bgc--x-box-bg:ffffff p--x-box-padding:16px br--x-box-border-radius:8px border--x-box-border:1px-solid-e0e0e0
215
- // [class~=x-box-shadow]-bxs-0px-2px-8px-0000000000d1`,
216
- // },
217
- // 'x-card':{
218
- // type:'statement',
219
- // statement:`bgc--x-card-bg:ffffff padding--x-card-padding:24px br--x-card-border-radius:12px bxs--x-card-shadow:0px-4px-12px-0000000000d1
220
- // [class~=x-card-interactive][--hover-transform-translateY--4px,--hover-bxs-0-8px-24px-0000000000d15]
221
- // transition-transform-0.3s-ease__box-shadow-0.3s-ease
222
- // [class~=x-card-dark][--x-card-bg:1a1a1a,--x-card-shadow:0px-4px-12px-0000000000d3,color--x-card-color:ffffff]`,
223
- // },
224
192
  'x-divider-text': {
225
193
  type: 'statement',
226
194
  statement: `[df,aic,g12px]
@@ -1,3 +1,3 @@
1
1
  export default function extractMediaPrefix(className: string, prefix: {
2
2
  [key: string]: string;
3
- }, match: RegExp, bool?: boolean): [string, string];
3
+ }, match: RegExp, bool?: boolean): [string[], string];
@@ -1,12 +1,36 @@
1
1
  export default function extractMediaPrefix(className, prefix, match, bool = false) {
2
- var _a;
2
+ var _a, _b, _c;
3
+ const medias = [];
4
+ let cls = className;
5
+ const matchNestedMedia = /@\[(.*?)]/;
6
+ // case 1. single media
3
7
  if (className.match(match)) {
4
8
  const prefixMedia = (_a = className.match(match)) === null || _a === void 0 ? void 0 : _a[0];
5
9
  if (prefixMedia) {
6
10
  if (prefix.hasOwnProperty(prefixMedia)) {
7
- return [prefix[prefixMedia], className.replace(prefixMedia, '')];
11
+ medias.push(prefix[prefixMedia]);
12
+ cls = className.replace(prefixMedia, '');
13
+ // return [[], ]
8
14
  }
9
15
  }
10
16
  }
11
- return ['', className];
17
+ else if (className.match(matchNestedMedia)) { // Nested Media Selector
18
+ (_c = (_b = className.match(matchNestedMedia)) === null || _b === void 0 ? void 0 : _b[1]) === null || _c === void 0 ? void 0 : _c.split(',').map((e) => {
19
+ var _a, _b;
20
+ const suffixedMatch = e + "-";
21
+ if (suffixedMatch.match(match) || ("@" + suffixedMatch).match(match)) {
22
+ const prefixMedia = ((_a = suffixedMatch.match(match)) === null || _a === void 0 ? void 0 : _a[0]) || ((_b = ('@' + suffixedMatch).match(match)) === null || _b === void 0 ? void 0 : _b[0]);
23
+ if (prefixMedia) {
24
+ if (prefix.hasOwnProperty(prefixMedia)) {
25
+ medias.push(prefix[prefixMedia]);
26
+ // return [[], ]
27
+ }
28
+ }
29
+ }
30
+ });
31
+ if (medias.length) {
32
+ cls = className.replace(matchNestedMedia, '');
33
+ }
34
+ }
35
+ return [medias, cls];
12
36
  }
@@ -50,6 +50,8 @@ const media = {
50
50
  '@comps': '@layer components',
51
51
  '@utils': '@layer utilities',
52
52
  '@utilities': '@layer utilities',
53
+ '@starting-style': '@starting-style',
54
+ '@ss': '@starting-style',
53
55
  },
54
56
  };
55
57
  export function createRegexForMedia(prefix) {
@@ -107,6 +107,17 @@ bool = false) {
107
107
  }
108
108
  }
109
109
  const valuePortion = className.replace(propertyKey, '');
110
+ // New Update function value
111
+ if (/^\(.*\)[_]?$/.test(valuePortion)) {
112
+ if (valuePortion.match(/_$/)) {
113
+ const val = valuePortion.replace(/[(_)]/g, '').replace(/,/g, ' ');
114
+ return bool ? [prop, val] : prop + ":" + val;
115
+ }
116
+ else {
117
+ const val = valuePortion.replace(/[(_)]/g, '').replace(/,/g, ', ');
118
+ return bool ? [prop, val] : prop + ":" + val;
119
+ }
120
+ }
110
121
  // case 3: calc function
111
122
  if (/^-calc\(/.test(valuePortion)) {
112
123
  return bool ? [prop, valuePortion.replace(/^-/, '').replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2')] : prop + ":" + valuePortion.replace(/^-/, '').replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2');
@@ -84,8 +84,10 @@ export const compiler = {
84
84
  if (!this.mediaTest)
85
85
  this.mediaTest = createRegexForMedia(this.mediaSelector);
86
86
  // 1. check and extract Media prefix and return className with prefix treatment,
87
- let [media, workingClassName] = extractMediaPrefix(unPrefixedClassName, this.mediaSelector, this.mediaTest);
88
- media = media;
87
+ let [extractedMedia, workingClassName] = extractMediaPrefix(unPrefixedClassName, this.mediaSelector, this.mediaTest);
88
+ const mediaEX = extractedMedia;
89
+ // lint escape for const
90
+ extractedMedia = extractedMedia;
89
91
  // 2. search for '&' which tells us to use selector before or after className
90
92
  if (workingClassName.match(/[&]/)) {
91
93
  const [before, after] = workingClassName.split('&');
@@ -155,8 +157,13 @@ export const compiler = {
155
157
  if (bool === true)
156
158
  return result;
157
159
  this.cache.propertyAndValue[pnv] = result;
158
- if (media) {
159
- stm = `${media}{${beforeClassNameSelector + '.' + className + elementAndPseudo}{${result}${important}}}`;
160
+ if (mediaEX.length) {
161
+ let [bf, af] = ['', ''];
162
+ mediaEX.map((e) => {
163
+ bf = bf + e + "{ ";
164
+ af = af + "}";
165
+ });
166
+ stm = `${bf}${beforeClassNameSelector + '.' + className + elementAndPseudo}{${result}${important}}${af}`;
160
167
  }
161
168
  else {
162
169
  stm = `${beforeClassNameSelector}.${className}${elementAndPseudo}{${result}${important}}`;
@@ -170,7 +177,7 @@ export const compiler = {
170
177
  }
171
178
  }
172
179
  else {
173
- console.log(`Unable to process ${className} [media:${media},pseudoSelector:${elementAndPseudo},imp:${important}]`);
180
+ console.log(`Unable to process ${className} [media:${mediaEX},pseudoSelector:${elementAndPseudo},imp:${important}]`);
174
181
  }
175
182
  },
176
183
  group(str, as) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aliascss",
3
- "version": "1.2.5",
3
+ "version": "1.3.0",
4
4
  "description": "AliasCSS is a CSS post processor.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",