aliascss 1.4.5 → 1.4.7

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.
Files changed (58) hide show
  1. package/dist/aliascss.js +1 -1
  2. package/lib/compilers/color.js +5 -5
  3. package/lib/compilers/gradient.js +3 -3
  4. package/lib/compilers/stringAndContent.js +2 -1
  5. package/lib/component-elements.d.ts +155 -0
  6. package/lib/component-elements.js +223 -0
  7. package/lib/config.d.ts +1 -0
  8. package/lib/config.js +2 -1
  9. package/lib/css-properties-all.js +337 -202
  10. package/lib/custom-css-compilers.js +54 -54
  11. package/lib/extras-elements.d.ts +87 -0
  12. package/lib/extras-elements.js +184 -0
  13. package/lib/form-elements.d.ts +75 -0
  14. package/lib/form-elements.js +186 -0
  15. package/lib/layout-elements.d.ts +59 -0
  16. package/lib/layout-elements.js +113 -0
  17. package/lib/nav-elements.d.ts +71 -0
  18. package/lib/nav-elements.js +243 -0
  19. package/lib/prebuild.d.ts +520 -12
  20. package/lib/prebuild.js +9 -852
  21. package/lib/prefix/PseudoPrefixNew.js +301 -16
  22. package/lib/prefix/attribute-selector.js +4 -2
  23. package/lib/prefix/pseudoSelectorNew.js +184 -49
  24. package/lib/prefix/responsive.d.ts +13 -9
  25. package/lib/prefix/responsive.js +131 -9
  26. package/lib/returnPropertyAndValue.js +9 -4
  27. package/lib/returnStatement-bk.d.ts +5 -0
  28. package/lib/returnStatement-bk.js +311 -0
  29. package/lib/returnStatement.js +165 -2
  30. package/lib/static/customStaticClassNames.js +35 -35
  31. package/lib/static/staticClassNamesAlias.js +18 -16
  32. package/lib/table-elements.d.ts +39 -0
  33. package/lib/table-elements.js +90 -0
  34. package/lib/utils/helper.d.ts +6 -0
  35. package/lib/utils/helper.js +52 -0
  36. package/lib/x-classes/x-bundle.d.ts +563 -0
  37. package/lib/x-classes/x-bundle.js +11 -0
  38. package/lib/x-classes/x-comps.d.ts +87 -0
  39. package/lib/x-classes/x-comps.js +189 -0
  40. package/lib/x-classes/x-extras.d.ts +155 -0
  41. package/lib/x-classes/x-extras.js +223 -0
  42. package/lib/x-classes/x-form-components.d.ts +75 -0
  43. package/lib/x-classes/x-form-components.js +186 -0
  44. package/lib/x-classes/x-helper-components.d.ts +63 -0
  45. package/lib/x-classes/x-helper-components.js +91 -0
  46. package/lib/x-classes/x-layout-components.d.ts +59 -0
  47. package/lib/x-classes/x-layout-components.js +113 -0
  48. package/lib/x-classes/x-menu.d.ts +23 -0
  49. package/lib/x-classes/x-menu.js +55 -0
  50. package/lib/x-classes/x-navs.d.ts +71 -0
  51. package/lib/x-classes/x-navs.js +243 -0
  52. package/lib/x-classes/x-table.d.ts +39 -0
  53. package/lib/x-classes/x-table.js +90 -0
  54. package/lib/x-classes/x-theme.d.ts +15 -0
  55. package/lib/x-classes/x-theme.js +32 -0
  56. package/lib/x-imports.d.ts +31 -0
  57. package/lib/x-imports.js +748 -0
  58. package/package.json +1 -1
@@ -1,25 +1,27 @@
1
1
  export function createRegexForPseudo(prefix) {
2
- const prefixAlias = Object.keys(prefix).reduce((previous, current) => previous + "|" + current);
3
- return new RegExp("^(" + prefixAlias + ")(?=[-(|_])");
2
+ const keys = Object.keys(prefix)
3
+ .sort((a, b) => b.length - a.length)
4
+ .map(k => k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
5
+ return new RegExp('^(' + keys.join('|') + ')(?=[-(_])');
4
6
  }
5
7
  const prefix = {
6
8
  '--active': ':active', // -a
7
9
  '--a': ':active',
8
10
  '--ac': ':active',
9
- '--after-hover': '::after:hover',
10
- '--afh': '::after:hover',
11
+ '--after-hover': ':hover::after',
12
+ '--afh': ':hover::after',
11
13
  '--after': '::after', // -af
12
14
  '--af': '::after', // -af
13
- '--autofill': ':-webkit-autofill',
14
- '--atf': ':-webkit-autofill',
15
+ '--autofill': ':autofill',
16
+ '--atf': ':autofill',
15
17
  '--any-link': ':any-link',
16
18
  '--al': ':any-link',
17
19
  '--backdrop': '::backdrop',
18
20
  '--bd': '::backdrop',
19
21
  '--blank': ':blank',
20
22
  '--bl': ':blank',
21
- '--before-hover': '::before:hover', // -bfh
22
- '--bfh': '::before:hover', // -bfh
23
+ '--before-hover': ':hover::before', // -bfh
24
+ '--bfh': ':hover::before', // -bfh
23
25
  '--before': '::before', // -bf
24
26
  '--bf': '::before', // -bf
25
27
  '--checked': ':checked', // -ck
@@ -32,6 +34,8 @@ const prefix = {
32
34
  '--de': ':default', // -df
33
35
  '--disabled': ':disabled', // -ds
34
36
  '--di': ':disabled', // -ds
37
+ '--details-content': '::details-content',
38
+ '--dc': '::details-content',
35
39
  '--empty': ':empty', // -em
36
40
  '--em': ':empty', // -em
37
41
  '--enabled': ':enabled', // -en
@@ -75,11 +79,11 @@ const prefix = {
75
79
  '--ind': ':indeterminate', // idt
76
80
  '--invalid': ':invalid', // -in
77
81
  '--inv': ':invalid', // -in
78
- '--is': ' :is',
79
- '--Is': ':is',
82
+ '--is': ':is',
83
+ '--Is': ' :is',
80
84
  // '--is':':is',
81
85
  '--lang': ':lang', // -ln
82
- '--lan': ':lan', // -ln
86
+ '--lan': ':lang', // -ln
83
87
  '--last-child': ':last-child', // -lc
84
88
  '--lc': ':last-child', // -lc
85
89
  '--last-of-type': ':last-of-type', // -lot
@@ -136,22 +140,303 @@ const prefix = {
136
140
  '--webkit-scrollbar-track': '::-webkit-scrollbar-track',
137
141
  '--st': '::-webkit-scrollbar-track',
138
142
  '--scrollbar-thumb': '::-webkit-scrollbar-thumb',
139
- '--web-kit-scrollbar-thumb': '::-webkit-scrollbar-thumb',
143
+ '--webkit-scrollbar-thumb': '::-webkit-scrollbar-thumb',
140
144
  '--stm': '::-webkit-scrollbar-thumb',
145
+ '--webkit-slider-thumb': '::-webkit-slider-thumb',
146
+ '--webkit-slider-runnable-track': '::-webkit-slider-runnable-track',
147
+ '--moz-range-thumb': '::-moz-range-thumb',
148
+ '--moz-range-track': '::-moz-range-track',
149
+ '--moz-range-progress': '::-moz-range-progress',
150
+ '--webkit-progress-bar': '::-webkit-progress-bar',
151
+ '--webkit-progress-value': '::-webkit-progress-value',
152
+ '--webkit-autofill': ':-webkit-autofill',
153
+ '--moz-progress-bar': '::-moz-progress-bar',
141
154
  '--target': ':target', // -tg
142
155
  '--tg': ':target', // -tg
143
156
  '--target-text': '::target-text', // -tg
144
157
  '--tt': '::target-text', // -tg
145
158
  '--user-invalid': ':user-invalid',
146
159
  '--ui': ':user-invalid',
160
+ '--user-valid': ':user-valid',
161
+ '--uv': ':user-valid',
147
162
  '--valid': ':valid', // -vl
148
163
  '--va': ':valid', // -vl
149
164
  '--visited': ':visited', // -vi
150
165
  '--vi': ':visited', // -vi
151
166
  '--v': ':visited', // -vi
152
- '--where': ' :where',
153
- '--w': ' :where',
154
- '--Where': ':where',
155
- '--W': ':where'
167
+ '--where': ':where',
168
+ '--w': ':where',
169
+ '--Where': ' :where',
170
+ '--W': ' :where',
171
+ '--open': ':open',
172
+ '--modal': ':modal',
173
+ '--picker-select': '::picker(select)',
174
+ '--checkmark': '::checkmark',
175
+ '--picker-icon': '::picker-icon'
156
176
  };
157
177
  export default prefix;
178
+ /*
179
+ // export function createRegexForPseudo(prefix:{[key:string]:string
180
+ // }){
181
+ // const prefixAlias= Object.keys(prefix).reduce((previous,current)=>previous+"|"+current);
182
+ // return new RegExp("^("+prefixAlias+")(?=[-(|_])");
183
+ // }
184
+
185
+ export function createRegexForPseudo(prefix: { [key: string]: string }) {
186
+ const keys = Object.keys(prefix)
187
+ .sort((a, b) => b.length - a.length)
188
+ .map(k => k.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'));
189
+ return new RegExp('^(' + keys.join('|') + ')(?=[-(_])');
190
+ }
191
+
192
+ const prefix:{[key:string]:string}={
193
+
194
+ '--active': ':active', // -a
195
+ '--a': ':active',
196
+ '--ac': ':active',
197
+
198
+ '--after-hover': '::after:hover',
199
+ '--afh': '::after:hover',
200
+
201
+
202
+ '--after': '::after', // -af
203
+ '--af': '::after', // -af
204
+ '--autofill':':autofill',
205
+ '--atf':':-webkit-autofill',
206
+ '--any-link':':any-link',
207
+ '--al':':any-link',
208
+
209
+ '--backdrop':'::backdrop',
210
+ '--bd':'::backdrop',
211
+
212
+ '--blank':':blank',
213
+ '--bl':':blank',
214
+
215
+ '--before-hover': '::before:hover', // -bfh
216
+ '--bfh': '::before:hover', // -bfh
217
+
218
+ '--before': '::before', // -bf
219
+ '--bf': '::before', // -bf
220
+
221
+ '--checked': ':checked', // -ck
222
+ '--ch': ':checked', // -ck
223
+
224
+ '--current': ':current', // -ck
225
+ '--cur': ':current',
226
+
227
+ '--cue':'::cue',
228
+ '--cu':'::cue',
229
+
230
+ '--default': ':default', // -df
231
+ '--de': ':default', // -df
232
+
233
+ '--disabled': ':disabled', // -ds
234
+ '--di': ':disabled', // -ds
235
+
236
+ '--details-content':'::details-content',
237
+ '--dc':'::details-content',
238
+
239
+ '--empty': ':empty', // -em
240
+ '--em': ':empty', // -em
241
+
242
+ '--enabled': ':enabled', // -en
243
+ '--en': ':enabled', // -en
244
+
245
+ '--file-selector-button':'::file-selector-button',
246
+ '--fsb':'::file-selector-button',
247
+
248
+ '--first-child': ':first-child', // -fc
249
+ '--fc': ':first-child',
250
+
251
+ '--first-letter': '::first-letter', // -f
252
+ '--fl': '::first-letter', // -fl
253
+
254
+ '--first-line': '::first-line', // -fln
255
+ '--fln': '::first-line', // -fln
256
+
257
+ '--first-of-type': ':first-of-type', // -fot
258
+ '--fot': ':first-of-type',
259
+
260
+ '--focus-within': ':focus-within', // -fo
261
+ '--fw': ':focus-within', // -fo
262
+
263
+ '--focus-visible': ':focus-visible', // -fo
264
+ '--fv': ':focus-visible', // -fo
265
+
266
+ '--focus': ':focus', // -fo
267
+ '--fo': ':focus', // -fo
268
+ '--f': ':focus', // -fo
269
+
270
+ '--fullscreen':':fullscreen',
271
+ '--fs':':fullscreen',
272
+
273
+ '--grammar-error':'::grammar-error',
274
+ '--ge':'::grammar-error',
275
+
276
+ '--has': ':has', // --has
277
+ '--hs': ':has', // -hs
278
+ '--Has': ' :has', // --has
279
+
280
+
281
+
282
+
283
+ '--hover-after': ':hover::after', // -haf
284
+ '--haf': ':hover::after', // -haf
285
+
286
+ '--hover-before': ':hover::before', // -hbf
287
+ '--hbf': ':hover::before', // -hbf
288
+
289
+ '--hover-target': ':hover:target', // -htg
290
+ '--htg': ':hover:target', // -htg
291
+
292
+ '--hover': ':hover', // -h
293
+ '--h': ':hover', // -h
294
+ '--ho': ':hover', // -h
295
+
296
+
297
+
298
+
299
+ '--in-range': ':in-range', // -ir
300
+ '--ir': ':in-range', // -ir
301
+
302
+ '--indeterminate': ':indeterminate', // idt
303
+ '--ind': ':indeterminate', // idt
304
+
305
+ '--invalid': ':invalid', // -in
306
+ '--inv': ':invalid', // -in
307
+ '--is':':is',
308
+ '--Is':' :is',
309
+ // '--is':':is',
310
+
311
+ '--lang': ':lang', // -ln
312
+ '--lan': ':lang', // -ln
313
+
314
+ '--last-child': ':last-child', // -lc
315
+ '--lc': ':last-child', // -lc
316
+
317
+ '--last-of-type': ':last-of-type', // -lot
318
+ '--lot': ':last-of-type', // -lot
319
+
320
+ '--link': ':link', // -l
321
+ '--ln': ':link', // -l
322
+ '--l': ':link', // -l
323
+
324
+ '--marker':'::marker',
325
+ '--m':'::marker',
326
+ '--not': ':not', // -n-
327
+ '--n': ':not', // -n-
328
+
329
+ '--nth-child': ':nth-child', // -nc2n
330
+ '--nc': ':nth-child', // -nc2n
331
+
332
+ '--nth-last-child': ':nth-last-child', // -nlc2n
333
+ '--nlc': ':nth-last-child', // -nlc2n
334
+
335
+ '--nth-last-of-type': ':nth-last-of-type', // -nlot2n
336
+ '--nlot': ':nth-last-of-type', // -nlot2n
337
+
338
+ '--nth-of-type': ':nth-of-type', // -not
339
+ '--nthot': ':nth-of-type', // -not
340
+
341
+ '--only-of-type': ':only-of-type', // -oot
342
+ '--oot': ':only-of-type', // -oot
343
+
344
+ '--only-child': ':only-child', // -oc
345
+ '--oc': ':only-child', // -oc
346
+
347
+ '--optional': ':optional', // -o
348
+ '--op': ':optional', // -o
349
+
350
+ '--out-of-range': ':out-of-range', // -oor
351
+ '--oor': ':out-of-range', // -oor
352
+
353
+ '--placeholder': '::placeholder', // -ph
354
+ '--ph': '::placeholder', // -ph
355
+
356
+ '--placeholder-shown': ':placeholder-shown', // -phs
357
+ '--phs': ':placeholder-shown', // -phs
358
+
359
+ '--popover-open':':popover-open',
360
+ '--po':':popover-open',
361
+
362
+ '--read-only': ':read-only', // -ro
363
+
364
+ '--ro': ':read-only', // -ro
365
+
366
+ '--read-write': ':read-write', // -rw
367
+ '--rw': ':read-write', // -rw
368
+
369
+ '--required': ':required', // -rq
370
+ '--rq': ':required', // -rq
371
+
372
+ '--root': ':root', // -rt
373
+ '--rt': ':root', // -rt
374
+
375
+ '--selection': '::selection', // -sl
376
+ '--s': '::selection', // -sl
377
+
378
+ '--search-cancel-button':'::-webkit-search-cancel-button',
379
+ '--webkit-search-cancel-button':'::-webkit-search-cancel-button',
380
+
381
+ '--search-decoration':'::-webkit-search-decoration',
382
+ '--webkit-search-decoration':'::-webkit-search-decoration',
383
+
384
+ '--spelling-error':'::spelling-error',
385
+ '--se':'::spelling-error',
386
+
387
+ '--scrollbar': '::-webkit-scrollbar',
388
+ '--webkit-scrollbar': '::-webkit-scrollbar',
389
+ '--sb': '::-webkit-scrollbar',
390
+ '--scrollbar-track': '::-webkit-scrollbar-track',
391
+ '--webkit-scrollbar-track': '::-webkit-scrollbar-track',
392
+ '--st': '::-webkit-scrollbar-track',
393
+ '--scrollbar-thumb': '::-webkit-scrollbar-thumb',
394
+ '--webkit-scrollbar-thumb': '::-webkit-scrollbar-thumb',
395
+ '--stm': '::-webkit-scrollbar-thumb',
396
+ '--webkit-slider-thumb':'::-webkit-slider-thumb',
397
+ '--webkit-slider-runnable-track':'::-webkit-slider-runnable-track',
398
+ '--moz-range-thumb':'::-moz-range-thumb',
399
+ '--moz-range-track':'::-moz-range-track',
400
+ '--moz-range-progress':'::-moz-range-progress',
401
+ '--webkit-progress-bar':'::-webkit-progress-bar',
402
+ '--webkit-progress-value':'::-webkit-progress-value',
403
+ '--webkit-autofill':':-webkit-autofill',
404
+ '--moz-progress-bar':'::-moz-progress-bar',
405
+ '--target': ':target', // -tg
406
+ '--tg': ':target', // -tg
407
+
408
+ '--target-text': '::target-text', // -tg
409
+ '--tt': '::target-text', // -tg
410
+
411
+ '--user-invalid':':user-invalid',
412
+ '--ui':':user-invalid',
413
+
414
+
415
+ '--user-valid':':uservalid',
416
+ '--uv':':user-valid',
417
+
418
+ '--valid': ':valid', // -vl
419
+ '--va': ':valid', // -vl
420
+
421
+ '--visited': ':visited', // -vi
422
+ '--vi': ':visited', // -vi
423
+ '--v': ':visited', // -vi
424
+
425
+ '--where':':where',
426
+ '--w':':where',
427
+ '--Where':' :where',
428
+ '--W':' :where',
429
+ '--open':':open',
430
+ '--modal':':modal',
431
+ '--picker-select':'::picker(select)',
432
+ '--checkmark':'::checkmark',
433
+ '--picker-icon':'::picker-icon'
434
+
435
+
436
+
437
+
438
+ }
439
+
440
+ export default prefix;
441
+
442
+ */
@@ -1,5 +1,5 @@
1
1
  const attribute = {
2
- test: /^[-,_]?[\[][a-zA-Z0-9-_:]+([~*$^]?[=][a-zA-Z0-9-_:/.]+)?[\]]/,
2
+ test: /^[-,_]?[\[][a-zA-Z0-9-_:]+([~*$^|]?[=][a-zA-Z0-9-_:/.\\]+)?[\]]/,
3
3
  process(className) {
4
4
  const match = className.match(this.test);
5
5
  if (match) {
@@ -8,7 +8,9 @@ const attribute = {
8
8
  const attrSplit = attr.split("=")[0];
9
9
  const result = attr.replace(attrSplit, attrSplit.replace(/:/g, '\\:'))
10
10
  // .replace(/^([-]?[\[][a-z0-9-_:]+)([~*$^]?[=][a-z0-9-_:/.]+)?[\]]/,(m,s,b)=>s.replace(/\:/g,'\:')+b+']')
11
- .replace(/-(eql|equal)-/, '=').replace(/[=]([a-zA-Z0-9-_:/.]+)[\]]/, '="$1"]').replace(/^[-_]/, ""); // replace(/([\[|\]])/g,'\\$1').replace(/([=])/g,'\\$1');
11
+ .replace(/-(eql|equal)-/, '=').replace(/[=]([a-zA-Z0-9-_:/.\\]+)[\]]/, '="$1"]').replace(/^[-_]/, "")
12
+ .replace(/\\_|_/g, (m) => (m === '_' ? ' ' : '_'));
13
+ ; // replace(/([\[|\]])/g,'\\$1').replace(/([=])/g,'\\$1');
12
14
  return [className.replace(attr, ''), /^[_]/.test(className) ? ' ' + result : result];
13
15
  }
14
16
  }
@@ -1,80 +1,215 @@
1
1
  import prefix, { createRegexForPseudo } from './PseudoPrefixNew.js';
2
2
  import extractPrefix from './extractPrefix.js';
3
+ // ---------------------------------------------------------------------------
4
+ // Built once at module load, not on every call
5
+ // ---------------------------------------------------------------------------
6
+ const pseudoMatch = createRegexForPseudo(prefix);
7
+ // Functional pseudos whose argument is an AliasCSS selector:
8
+ // --not(…) --has(…) --Has(…) --is(…) --Is(…) --where(…) --Where(…) --hs(…) --w(…) --W(…) --n(…)
9
+ const FN_PSEUDO = /^-(-?(?:not|has|Has|is|Is|where|Where|hs|w|W|n))\(/;
10
+ // Functional pseudos whose argument is an nth formula (passed through as is):
11
+ // --nth-child(2n+1) --nth-last-child(…) --nth-of-type(…) --nth-last-of-type(…)
12
+ // --nc(…) --nlc(…) --nthot(…) --nlot(…)
13
+ const NTH_PSEUDO = /^-(-?n(?:th-child|th-last-child|th-last-of-type|th-of-type|c|lc|lot|thot))\(/;
14
+ // nth without parentheses, number or keyword after a dash:
15
+ // --nth-child-3 --nth-last-child-2n --nth-of-type-1 --nth-last-of-type-2
16
+ const NTH_DASH_LONG = /^(--nth-(?:child|last-child|of-type|last-of-type))-([0-9]+n?)(?=[-_])/;
17
+ // --nc-3 --nlc-odd --nthot-2n --nlot-1
18
+ const NTH_DASH_SHORT = /^(--(?:nc|nlc|nthot|nlot))-([a-z0-9]+)(?=[-_])/;
19
+ // Selector pseudos without parentheses, one simple selector after a dash:
20
+ // --not-first-child-… --has_img-… --is-…
21
+ const FN_DASH = /^-(-(?:not|has|Has|is|Is|where|Where|hs|w|W|n))([_-]+[a-zA-Z0-9.,]+)(?=[-_])/;
22
+ // --lang-en-…
23
+ const LANG_DASH = /^--lang-([a-zA-Z0-9]+)(?=[-_])/;
24
+ // Given the index of an opening "(", return [inside, rest after the matching ")"]
25
+ function splitBalanced(str, open) {
26
+ let depth = 0;
27
+ for (let i = open; i < str.length; i++) {
28
+ const ch = str[i];
29
+ if (ch === '\\') {
30
+ i++;
31
+ continue;
32
+ } // skip escaped characters
33
+ if (ch === '(')
34
+ depth++;
35
+ else if (ch === ')' && --depth === 0)
36
+ return [str.slice(open + 1, i), str.slice(i + 1)];
37
+ }
38
+ return null; // unbalanced: not a valid class
39
+ }
40
+ // Returns [rest of the class name, compiled pseudo selector] or null
3
41
  export default function PseudoEleStateNew(data) {
4
- var _a;
5
- // const match=createRegexForPseudo({...prefix,'--KKK':','});
6
- const match = createRegexForPseudo(prefix);
7
- if (!match.test(data))
42
+ if (!pseudoMatch.test(data))
8
43
  return null;
9
- const matchAndFunc = [
44
+ // 1. --not(…) --has(…) --is(…) --where(…): argument is itself an AliasCSS selector
45
+ const fn = data.match(FN_PSEUDO);
46
+ if (fn) {
47
+ const parts = splitBalanced(data, fn[0].length - 1);
48
+ if (!parts)
49
+ return null;
50
+ const [inner, rest] = parts;
51
+ if (!inner)
52
+ return [rest, ''];
53
+ const [result] = extractPrefix(inner + '-display-none');
54
+ return [rest, `${prefix['-' + fn[1]]}(${result})`];
55
+ }
56
+ // 2. --nth-child(…) --nc(…) …: argument passed through as is
57
+ const nth = data.match(NTH_PSEUDO);
58
+ if (nth) {
59
+ const parts = splitBalanced(data, nth[0].length - 1);
60
+ if (!parts)
61
+ return null;
62
+ const [inner, rest] = parts;
63
+ return [rest, `${prefix['-' + nth[1]]}(${inner})`];
64
+ }
65
+ // 3. --nth-child-3 …
66
+ let m = data.match(NTH_DASH_LONG) || data.match(NTH_DASH_SHORT);
67
+ if (m) {
68
+ return [data.slice(m[0].length), `${prefix[m[1]]}(${m[2]})`];
69
+ }
70
+ // 4. --not-first-child-… --has_img-…
71
+ m = data.match(FN_DASH);
72
+ if (m) {
73
+ const [result] = extractPrefix(m[2] + '-display-none');
74
+ return [data.slice(m[0].length), `${prefix['-' + m[1]]}(${result})`];
75
+ }
76
+ // 5. --lang-en-…
77
+ m = data.match(LANG_DASH);
78
+ if (m) {
79
+ return [data.slice(m[0].length), `:lang(${m[1]})`];
80
+ }
81
+ // 6. Plain pseudo from the prefix map: --hover-… --before-…
82
+ m = data.match(pseudoMatch);
83
+ if (m && Object.prototype.hasOwnProperty.call(prefix, m[1])) {
84
+ return [data.slice(m[1].length), prefix[m[1]]];
85
+ }
86
+ return null;
87
+ }
88
+ /*
89
+ import prefix,{createRegexForPseudo} from './PseudoPrefixNew.js';
90
+ import extractPrefix from './extractPrefix.js';
91
+ // Built once, not on every call
92
+ const pseudoMatch = createRegexForPseudo(prefix);
93
+
94
+ // Functional pseudos that take a selector: --not( --has( --is( --where( …
95
+ const FN_PSEUDO = /^-(-?(?:not|has|Has|is|Is|where|Where|hs|w|W|n))\(/;
96
+ // Functional pseudos that take an nth formula: --nth-child( --nc( …
97
+ const NTH_PSEUDO = /^-(-?n(?:th-child|th-last-child|th-last-of-type|th-of-type|c|lc|lot|ot))\(/;
98
+
99
+ // Given the index of an opening "(", return [inside, rest after the matching ")"]
100
+ function splitBalanced(str: string, open: number): [string, string] | null {
101
+ let depth = 0;
102
+ for (let i = open; i < str.length; i++) {
103
+ const ch = str[i];
104
+ if (ch === '\\') { i++; continue; } // skip escaped characters
105
+ if (ch === '(') depth++;
106
+ else if (ch === ')' && --depth === 0) return [str.slice(open + 1, i), str.slice(i + 1)];
107
+ }
108
+ return null; // unbalanced: not a valid class
109
+ }
110
+
111
+ export default function PseudoEleStateNew(data:string):string[]|null{
112
+ if (!pseudoMatch.test(data)) return null;
113
+ // --not(…) --has(…) --is(…) --where(…): the argument is itself an AliasCSS selector
114
+ const fn = data.match(FN_PSEUDO);
115
+ if (fn) {
116
+ const parts = splitBalanced(data, fn[0].length - 1);
117
+ if (!parts) return null;
118
+ const [inner, rest] = parts;
119
+ if (!inner) return [rest, ''];
120
+ const [result] = extractPrefix(inner + '-display-none');
121
+ return [rest, `${prefix['-' + fn[1]]}(${result})`];
122
+ }
123
+
124
+ // --nth-child(…) --nc(…) …: the argument is passed through as is
125
+ const nth = data.match(NTH_PSEUDO);
126
+ if (nth) {
127
+ const parts = splitBalanced(data, nth[0].length - 1);
128
+ if (!parts) return null;
129
+ const [inner, rest] = parts;
130
+ return [rest, `${prefix['-' + nth[1]]}(${inner})`];
131
+ }
132
+
133
+
134
+ const matchAndFunc=[
10
135
  {
11
- match: /^-([-]?(not|has|Has|is|Is|where|Where|n|hs|w|W))\((.+)\)/,
12
- func(value) {
13
- const matched = value.match(this.match);
14
- const newData = matched === null || matched === void 0 ? void 0 : matched[3];
15
- if (newData) {
16
- const [result, className] = extractPrefix(newData + '-display-none');
17
- return [value.replace(matched[0], ''), `${prefix['-' + matched[1]]}(${result})`];
136
+ match:/^-([-]?(not|has|Has|is|Is|where|Where|n|hs|w|W))\((.+)\)/,
137
+ func(value:string){
138
+ const matched=value.match(this.match);
139
+ const newData=matched?.[3];
140
+ if(newData){
141
+ const[result,className]= extractPrefix(newData+'-display-none');
142
+
143
+ return [value.replace(matched[0],''),`${prefix['-'+matched[1]]}(${result})`];
18
144
  }
19
- return [value.replace((matched === null || matched === void 0 ? void 0 : matched[0]) ? matched[0] : '', ''), ''];
145
+ return [value.replace(matched?.[0]?matched[0]:'',''),'']
146
+
20
147
  }
21
148
  },
22
149
  {
23
- match: /^-([-]?n(th(-child|-last-child|-last-of-type|-of-type)|c|lc|lot|ot))\((.+)\)/,
24
- func(value) {
25
- const matched = value.match(this.match);
26
- return [value.replace((matched === null || matched === void 0 ? void 0 : matched[0]) ? matched[0] : '', ''), `${prefix['-' + (matched === null || matched === void 0 ? void 0 : matched[1])]}(${matched === null || matched === void 0 ? void 0 : matched[4]})`];
150
+ match:/^-([-]?n(th(-child|-last-child|-last-of-type|-of-type)|c|lc|lot|ot))\((.+)\)/,
151
+ func(value:string){
152
+ const matched=value.match(this.match);
153
+ return[value.replace(matched?.[0]?matched[0]:'',''),`${prefix['-'+matched?.[1]]}(${matched?.[4]})`]
27
154
  }
28
155
  },
29
156
  ];
157
+
30
158
  // accept (acss-selector)
31
- if (data.match(matchAndFunc[0].match)) {
159
+ if(data.match(matchAndFunc[0].match)){
160
+
32
161
  return matchAndFunc[0].func(data);
33
162
  }
34
- if (data.match(matchAndFunc[1].match)) {
163
+
164
+ if(data.match(matchAndFunc[1].match)){
165
+
35
166
  return matchAndFunc[1].func(data);
36
167
  }
168
+
37
169
  // case 1. nth
38
- if (/(^--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/.test(data)) {
39
- const mch = data.match(/^(--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/);
40
- const cn = (mch === null || mch === void 0 ? void 0 : mch[0]) ? data.replace(mch[0], '') : '';
41
- const alias = (mch === null || mch === void 0 ? void 0 : mch[1]) ? prefix[mch[1].replace(/-$/, '')] : '';
42
- const cont = mch === null || mch === void 0 ? void 0 : mch[3];
43
- return [cn, `${alias}(${cont})`];
170
+ if(/(^--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/.test(data)){
171
+ const mch=data.match(/^(--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/);
172
+ const cn=mch?.[0]?data.replace(mch[0],''):'';
173
+ const alias=mch?.[1]?prefix[mch[1].replace(/-$/,'')]:'';
174
+ const cont=mch?.[3];
175
+ return [cn,`${alias}(${cont})`]
44
176
  // return pseudoHandlerNthChild(data,/(^--nth(-child-|-last-child-|-last-of-type|-of-type-))([0-9]+[n]?)(?=[-|_])/)
45
- }
46
- else if (/^(--(nc|nlc|nlot|nthot)-)([a-z0-9]+)(?=[-|_])/.test(data)) {
47
- const mch = data.match(/^(--(n|nc|nlc|nlot|not)-)([a-z0-9]+)(?=[-|_])/);
48
- const cn = (mch === null || mch === void 0 ? void 0 : mch[0]) ? data.replace(mch[0], '') : '';
49
- const alias = (mch === null || mch === void 0 ? void 0 : mch[1]) ? prefix[mch[1].replace(/-$/, '')] : '';
50
- const cont = mch === null || mch === void 0 ? void 0 : mch[3];
177
+ }else if(/^(--(nc|nlc|nlot|nthot)-)([a-z0-9]+)(?=[-|_])/.test(data)){
178
+ const mch=data.match(/^(--(n|nc|nlc|nlot|not)-)([a-z0-9]+)(?=[-|_])/);
179
+ const cn=mch?.[0]?data.replace(mch[0],''):'';
180
+ const alias=mch?.[1]?prefix[mch[1].replace(/-$/,'')]:'';
181
+ const cont=mch?.[3];
51
182
  // console.log(data,cn,alias,mch)
52
- return [cn, `${alias}(${cont})`];
53
- }
54
- else if (/(^-(-not|-has|-Has|-is|-Is|-where|-Where|-n|-hs|-w|-W|-is)[-_])/.test(data)) {
55
- const mch = data.match(/(^-(-not|-has|-Has|-is|-Is|-where|-Where|-n|-hs|-w|-W|-is)([_-]+[a-zA-Z0-9\.,]+)(?=[-|_]))/);
56
- const cn = (mch === null || mch === void 0 ? void 0 : mch[1]) ? data.replace(mch[1], '') : '';
57
- const alias = (mch === null || mch === void 0 ? void 0 : mch[2]) ? prefix['-' + mch[2].replace(/-$/, '')] : '';
58
- const cont = (_a = PseudoEleStateNew((mch === null || mch === void 0 ? void 0 : mch[3]) + '-dn')) === null || _a === void 0 ? void 0 : _a[1];
59
- const [result, className] = extractPrefix((mch === null || mch === void 0 ? void 0 : mch[3]) + '-display-none');
183
+ return [cn,`${alias}(${cont})`]
184
+ }else if(/(^-(-not|-has|-Has|-is|-Is|-where|-Where|-n|-hs|-w|-W|-is)[-_])/.test(data)){
185
+
186
+ const mch=data.match(/(^-(-not|-has|-Has|-is|-Is|-where|-Where|-n|-hs|-w|-W|-is)([_-]+[a-zA-Z0-9\.,]+)(?=[-|_]))/);
187
+
188
+ const cn=mch?.[1]?data.replace(mch[1],''):'';
189
+ const alias=mch?.[2]?prefix['-'+mch[2].replace(/-$/,'')]:'';
190
+ const cont:string|undefined=PseudoEleStateNew(mch?.[3]+'-dn')?.[1];
191
+ const[result,className]= extractPrefix(mch?.[3]+'-display-none');
60
192
  // console.log('PseudoMatch',result,cont)
61
- return [cn, `${alias}(${result})`];
62
- }
63
- else if (/(^--lang-([a-z]+)(?=[-|_]))/.test(data)) {
64
- const mch = data.match(/(^--lang-([a-z0-9]+)(?=[-|_]))/);
65
- const cn = (mch === null || mch === void 0 ? void 0 : mch[1]) ? data.replace(mch[1], '') : '';
193
+ return [cn,`${alias}(${result})`]
194
+ }else if(/(^--lang-([a-z]+)(?=[-|_]))/.test(data)){
195
+ const mch=data.match(/(^--lang-([a-z0-9]+)(?=[-|_]))/);
196
+ const cn=mch?.[1]?data.replace(mch[1],''):'';
66
197
  // const alias=mch?.[1]?prefix[mch[1].replace(/-$/,'')]:'';
67
- const cont = mch === null || mch === void 0 ? void 0 : mch[2];
68
- return [cn, `:lang(${cont})`];
198
+ const cont=mch?.[2];
199
+ return [cn,`:lang(${cont})`]
69
200
  }
70
- else {
71
- const alias = data.match(match);
201
+ else{
202
+ const alias = data.match(pseudoMatch);
72
203
  if (alias) {
73
204
  if (prefix.hasOwnProperty(alias[0])) {
74
- return [data.replace(alias[0], ''), prefix[alias[0]]];
205
+
206
+ return [data.replace(alias[0], ''), prefix[alias[0]]];
75
207
  }
76
208
  }
209
+
77
210
  // return [data, ''];
78
211
  return null;
79
212
  }
80
213
  }
214
+
215
+ */