aliascss 1.5.3 → 1.5.5

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 (40) hide show
  1. package/dist/aliascss.js +1 -1
  2. package/lib/classPrinter.d.ts +1 -1
  3. package/lib/classPrinter.js +22 -13
  4. package/lib/compilers/dashedIdent.d.ts +49 -0
  5. package/lib/compilers/dashedIdent.js +115 -0
  6. package/lib/compilers/length.js +4 -2
  7. package/lib/css-properties-all-old-full-alias-support.d.ts +19 -0
  8. package/lib/css-properties-all-old-full-alias-support.js +3122 -0
  9. package/lib/css-properties-all.js +184 -169
  10. package/lib/node/compileFile.js +30 -15
  11. package/lib/prefix/pseudoSelectorNew.js +5 -1
  12. package/lib/prefix/responsive.js +7 -7
  13. package/lib/returnPropertyAndValue.js +10 -3
  14. package/lib/returnStatement.js +2 -2
  15. package/lib/static/staticClassNamesAlias.js +8 -8
  16. package/lib/utils/createCompilerObj.d.ts +3 -0
  17. package/lib/utils/createCompilerObj.js +18 -0
  18. package/lib/utils/helper.d.ts +4 -0
  19. package/lib/utils/helper.js +30 -3
  20. package/lib/x-imports.js +135 -68
  21. package/package.json +2 -1
  22. package/.prettierrc +0 -5
  23. package/READMEEdititng.md +0 -615
  24. package/aliascss.config.bk.js +0 -131
  25. package/aliascss.config.js +0 -50
  26. package/custom-compilers.js +0 -61
  27. package/docc.md +0 -486
  28. package/docs/PseudoSelector.js +0 -141
  29. package/docs/colors-tokens.js +0 -3771
  30. package/docs/mediaSelector.js +0 -49
  31. package/docs/staticClassNames.js +0 -15731
  32. package/docs/utilitiesClassName.js +0 -204
  33. package/jestconfig.json +0 -8
  34. package/old-custom-compilers.js +0 -149
  35. package/ts-22.js +0 -2631
  36. package/ts.js +0 -36
  37. package/tsconfig.json +0 -16
  38. package/tsconfig.test.json +0 -10
  39. package/tslint.json +0 -9
  40. package/webpack.config.js +0 -11
@@ -1,4 +1,4 @@
1
- import { compiler as statementMaker } from './returnStatement-bk-291026.js';
1
+ import { compiler as statementMaker } from './returnStatement.js';
2
2
  export default statementMaker;
3
3
  type ClassPrinter = {
4
4
  [key: string]: any;
@@ -1,6 +1,6 @@
1
- import { compiler as statementMaker } from './returnStatement-bk-291026.js';
1
+ import { compiler as statementMaker } from './returnStatement.js';
2
2
  import config from './config.js';
3
- import { splitByCommaOutsideParens } from './utils/helper.js';
3
+ import { parseKeyframeStep } from './utils/helper.js';
4
4
  // import mapRawAttributeNames from './utils/browser-helper.js';
5
5
  export default statementMaker;
6
6
  export let classPrinter = {
@@ -119,19 +119,28 @@ export let classPrinter = {
119
119
  this.doneKeyframes.add(doneKey);
120
120
  const returnPnV = (e) => e.map((i) => statementMaker.make(i, undefined, true)).join(';');
121
121
  let steps = '';
122
- each.value.trim().split(/\s+/).forEach((step) => {
123
- try {
124
- // @0[…] @0-[…] @50%[…] @[0,25,50][…] @[0,25,50]-[…]
125
- const m = step.match(/^@(\[[\d.,%]+\]|[\d.]+%?)-?(\[.*\])$/);
126
- if (!m)
127
- throw new Error('expected @50[...] or @[0,50][...]');
128
- const at = m[1].replace(/[\[\]%]/g, ''); // "0,25,50"
129
- steps += ` ${at.split(',').map((s) => s + '%').join(',')} {${returnPnV(splitByCommaOutsideParens(m[2].replace(/^\[|\]$/g, '')))}}`;
130
- }
131
- catch (error) {
132
- console.log('invalid Entry for AliasCSS keyframes processor : ' + step, error);
122
+ each.value.trim().split(/\s+/).forEach((entry) => {
123
+ // @50[…] @50-[…] @50%[…] @[0,25,50][…] @50-o-0 @[0,25]-o-0
124
+ const step = parseKeyframeStep(entry);
125
+ if (!step) {
126
+ console.log('invalid Entry for AliasCSS keyframes processor : ' + entry + '(expected @50[…], @50class or @[0,50]class)');
127
+ return;
133
128
  }
129
+ steps += ` ${step.at} {${returnPnV(step.classes)}}`;
134
130
  });
131
+ // each.value.trim().split(/\s+/).forEach((step: string) => {
132
+ // try {
133
+ // // @0[…] @0-[…] @50%[…] @[0,25,50][…] @[0,25,50]-[…]
134
+ // const m = step.match(/^@(\[[\d.,%]+\]|[\d.]+%?)-?(\[.*\])$/);
135
+ // if (!m) throw new Error('expected @50[...] or @[0,50][...]');
136
+ // const at = m[1].replace(/[\[\]%]/g, ''); // "0,25,50"
137
+ // steps += ` ${at.split(',').map((s) => s + '%').join(',')} {${returnPnV(
138
+ // splitByCommaOutsideParens(m[2].replace(/^\[|\]$/g, ''))
139
+ // )}}`;
140
+ // } catch (error) {
141
+ // console.log('invalid Entry for AliasCSS keyframes processor : ' + step, error);
142
+ // }
143
+ // });
135
144
  if (steps)
136
145
  this.appendToStyleTag('@keyframes ' + name + '{\n' + steps + '\n}');
137
146
  }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Properties whose values are names written with two leading dashes (CSS
3
+ * "dashed idents"): anchor names, scroll/view timeline names, custom
4
+ * @position-try rules, custom font palettes.
5
+ *
6
+ * In these properties `--name` is a name, never a CSS variable, so the usual
7
+ * `--x` → `var(--x)` rule must not apply. This compiler runs after static class
8
+ * names and before the variable handling in getPropertyAndValue.
9
+ *
10
+ * anchor-name-menu anchor-name: --menu
11
+ * anchor-name--menu anchor-name: --menu (was var(--menu))
12
+ * anchor-name---menu anchor-name: --menu (was ----menu)
13
+ * anchor-name-menu__card anchor-name: --menu, --card
14
+ * anchor-name(--menu,--card) anchor-name: --menu, --card (was var(--menu), var(--card))
15
+ * position-anchor-auto position-anchor: auto (was --auto)
16
+ * timeline-scope-all timeline-scope: all (was --all)
17
+ * animation-timeline(scroll(root_block)) animation-timeline: scroll(root block)
18
+ * scroll-timeline(--hero_y) scroll-timeline: --hero y (was var(--hero y))
19
+ * scroll-timeline-hero_y scroll-timeline: --hero y
20
+ * position-try-fallbacks(--below,flip-block) position-try-fallbacks: --below, flip-block
21
+ *
22
+ * A real variable is still possible with the explicit forms, which this
23
+ * compiler leaves alone: anchor-name--var--x → anchor-name: var(--x),
24
+ * and var(...) written inside a value.
25
+ */
26
+ type Mode =
27
+ /** Every item is one name: bare words get "--" added (anchor-name-menu → --menu) */
28
+ 'name'
29
+ /** Each item is a name followed by other values (scroll-timeline: --hero y) */
30
+ | 'shorthand'
31
+ /** Values are written as they are; "--x" stays a name, nothing is added */
32
+ | 'keep';
33
+ interface Rule {
34
+ mode: Mode;
35
+ /** Words that are keywords, not names */
36
+ keywords: string[];
37
+ }
38
+ export declare const DASHED_IDENT_PROPERTIES: {
39
+ [property: string]: Rule;
40
+ };
41
+ export declare function isDashedIdentProperty(property: string): boolean;
42
+ /**
43
+ * @param property the full CSS property name (after alias lookup), e.g. "anchor-name"
44
+ * @param valuePortion the class name minus the property key, as getPropertyAndValue has it:
45
+ * "-menu", "--menu", "-menu__card", "(--menu,--card)", "(scroll(root_block))"
46
+ * @returns the CSS value, or null to let the normal processing continue
47
+ */
48
+ export default function compileDashedIdent(property: string, valuePortion: string): string | null;
49
+ export {};
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Properties whose values are names written with two leading dashes (CSS
3
+ * "dashed idents"): anchor names, scroll/view timeline names, custom
4
+ * @position-try rules, custom font palettes.
5
+ *
6
+ * In these properties `--name` is a name, never a CSS variable, so the usual
7
+ * `--x` → `var(--x)` rule must not apply. This compiler runs after static class
8
+ * names and before the variable handling in getPropertyAndValue.
9
+ *
10
+ * anchor-name-menu anchor-name: --menu
11
+ * anchor-name--menu anchor-name: --menu (was var(--menu))
12
+ * anchor-name---menu anchor-name: --menu (was ----menu)
13
+ * anchor-name-menu__card anchor-name: --menu, --card
14
+ * anchor-name(--menu,--card) anchor-name: --menu, --card (was var(--menu), var(--card))
15
+ * position-anchor-auto position-anchor: auto (was --auto)
16
+ * timeline-scope-all timeline-scope: all (was --all)
17
+ * animation-timeline(scroll(root_block)) animation-timeline: scroll(root block)
18
+ * scroll-timeline(--hero_y) scroll-timeline: --hero y (was var(--hero y))
19
+ * scroll-timeline-hero_y scroll-timeline: --hero y
20
+ * position-try-fallbacks(--below,flip-block) position-try-fallbacks: --below, flip-block
21
+ *
22
+ * A real variable is still possible with the explicit forms, which this
23
+ * compiler leaves alone: anchor-name--var--x → anchor-name: var(--x),
24
+ * and var(...) written inside a value.
25
+ */
26
+ const GLOBAL = ['inherit', 'initial', 'unset', 'revert', 'revert-layer'];
27
+ export const DASHED_IDENT_PROPERTIES = {
28
+ 'anchor-name': { mode: 'name', keywords: ['none'] },
29
+ 'anchor-scope': { mode: 'name', keywords: ['none', 'all'] },
30
+ 'position-anchor': { mode: 'name', keywords: ['auto', 'none'] },
31
+ 'animation-timeline': { mode: 'name', keywords: ['auto', 'none'] },
32
+ 'scroll-timeline-name': { mode: 'name', keywords: ['none'] },
33
+ 'view-timeline-name': { mode: 'name', keywords: ['none'] },
34
+ 'timeline-scope': { mode: 'name', keywords: ['none', 'all'] },
35
+ 'scroll-timeline': { mode: 'shorthand', keywords: ['none'] },
36
+ 'view-timeline': { mode: 'shorthand', keywords: ['none'] },
37
+ 'position-try-fallbacks': { mode: 'keep', keywords: [] },
38
+ 'position-try': { mode: 'keep', keywords: [] },
39
+ 'font-palette': { mode: 'keep', keywords: [] },
40
+ };
41
+ export function isDashedIdentProperty(property) {
42
+ return Object.prototype.hasOwnProperty.call(DASHED_IDENT_PROPERTIES, property);
43
+ }
44
+ /** `_` is a space; `\_` stays an underscore (same rule as other function values). */
45
+ const spaces = (s) => s.replace(/\\_|_/g, (m) => (m === '_' ? ' ' : '_'));
46
+ /** Splits on commas that aren't inside parentheses. */
47
+ function splitTopLevel(s, sep) {
48
+ const out = [];
49
+ let depth = 0;
50
+ let start = 0;
51
+ for (let i = 0; i < s.length; i++) {
52
+ const ch = s[i];
53
+ if (ch === '(')
54
+ depth++;
55
+ else if (ch === ')')
56
+ depth--;
57
+ else if (depth === 0 && s.startsWith(sep, i)) {
58
+ out.push(s.slice(start, i));
59
+ start = i + sep.length;
60
+ i += sep.length - 1;
61
+ }
62
+ }
63
+ out.push(s.slice(start));
64
+ return out.map((x) => x.trim()).filter(Boolean);
65
+ }
66
+ /** One name: keywords, functions and var() stay as written; anything else gets exactly two leading dashes. */
67
+ function asName(word, rule) {
68
+ if (rule.keywords.indexOf(word) !== -1 || GLOBAL.indexOf(word) !== -1)
69
+ return word;
70
+ if (/^[a-z-]*\(/i.test(word))
71
+ return word; // scroll(), view(), var(), palette-mix()…
72
+ return '--' + word.replace(/^-+/, '');
73
+ }
74
+ function compileItem(item, rule) {
75
+ if (rule.mode === 'keep')
76
+ return item;
77
+ if (rule.mode === 'name')
78
+ return asName(item, rule);
79
+ // shorthand: the first word is the name, the rest (axis, inset) as written
80
+ const [first, ...rest] = splitTopLevel(item, ' ');
81
+ return [asName(first, rule), ...rest].join(' ');
82
+ }
83
+ /**
84
+ * @param property the full CSS property name (after alias lookup), e.g. "anchor-name"
85
+ * @param valuePortion the class name minus the property key, as getPropertyAndValue has it:
86
+ * "-menu", "--menu", "-menu__card", "(--menu,--card)", "(scroll(root_block))"
87
+ * @returns the CSS value, or null to let the normal processing continue
88
+ */
89
+ export default function compileDashedIdent(property, valuePortion) {
90
+ const rule = DASHED_IDENT_PROPERTIES[property];
91
+ if (!rule || !valuePortion)
92
+ return null;
93
+ // Explicit variables keep their existing meaning
94
+ if (/^--var--/.test(valuePortion))
95
+ return null;
96
+ // A fallback-style variable (anchor-name--x:value) is a variable too
97
+ if (/^--[a-zA-Z][\w-]*:/.test(valuePortion))
98
+ return null;
99
+ // Function form: property(value) — commas separate items, _ is a space
100
+ const fn = valuePortion.match(/^\((.+)\)$/);
101
+ if (fn) {
102
+ const items = splitTopLevel(spaces(fn[1]), ',');
103
+ return items.map((item) => compileItem(item, rule)).join(', ') || null;
104
+ }
105
+ // Class form: the leading dash is the separator; __ separates items, _ is a space
106
+ const raw = rule.mode === 'keep' && /^--[a-zA-Z]/.test(valuePortion) ? valuePortion : valuePortion.replace(/^-/, '');
107
+ if (!raw)
108
+ return null;
109
+ const items = raw.split('__').map((x) => spaces(x).trim()).filter(Boolean);
110
+ if (rule.mode === 'keep') {
111
+ // Hyphens belong to the value here (flip-block, --my-try); only __ and _ are separators
112
+ return items.join(', ');
113
+ }
114
+ return items.map((item) => compileItem(item, rule)).join(', ');
115
+ }
@@ -1,3 +1,5 @@
1
+ const POSITION_KEYWORDS = /-(?=(?:top|bottom|left|right|center)(?:-|$))|(?<=(?:^|-)(?:top|bottom|left|right|center))-/g;
2
+ // value = value.replace(/^-/, '').replace(POSITION_KEYWORDS, ' ');
1
3
  export default function length(data) {
2
4
  if (data.match(/^-clamp\(/)) {
3
5
  // Note: [,+-/*] is a RANGE from "+" to "/" (it includes "," "-" "." "/"), so every
@@ -14,12 +16,12 @@ export default function length(data) {
14
16
  }
15
17
  else {
16
18
  // "." between digits works exactly like "d" (12.5rem = 12d5rem)
17
- return data.replace(/(\d)\.(\d)/g, '$1d$2').replace(/[-]?fit-content-([-]?\w+)/g, ' fit-content( $1 )')
19
+ return data.replace(POSITION_KEYWORDS, ' ').replace(/^-(?=[a-zA-Z])/, '').replace(/(\d)\.(\d)/g, '$1d$2').replace(/[-]?fit-content-([-]?\w+)/g, ' fit-content( $1 )')
18
20
  .replace(/[-]([-]?[0-9])/g, ' $1').replace(/([\d])d([\d])/g, '$1.$2').replace(/-auto/g, ' auto')
19
21
  .replace(/([\d])p[\s]/g, "$1% ").replace(/([\d])p$/, "$1%").replace(/([\d])p(?=[,)])/g, "$1%").replace(/-(f|m)/g, '$1'); // 100p inside min()/max()
20
22
  }
21
23
  }
22
- export const lenByNumPer = (value) => 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');
24
+ export const lenByNumPer = (value) => value.replace(POSITION_KEYWORDS, ' ').replace(/^-(?=[a-zA-Z])/, '').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');
23
25
  /*
24
26
  export default function length(data:string){
25
27
  if(data.match(/^-clamp\(/)){
@@ -0,0 +1,19 @@
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
+ compiler?: (a: string, b: {
11
+ [key: string]: {
12
+ [key: string]: string;
13
+ };
14
+ }) => any;
15
+ };
16
+ declare const cssProps: {
17
+ [key: string]: Property;
18
+ };
19
+ export default cssProps;