aliascss 1.5.2 → 1.5.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.
- package/CHANGELOG.md +9 -0
- package/README.md +408 -553
- package/dist/aliascss.js +1 -1
- package/lib/classPrinter.js +1 -0
- package/lib/css-properties-all.js +26 -1
- package/lib/returnPropertyAndValue.js +17 -6
- package/package.json +1 -1
package/lib/classPrinter.js
CHANGED
|
@@ -7,6 +7,7 @@ export let classPrinter = {
|
|
|
7
7
|
invalidLists: new Set(), // was arrays + indexOf: O(n) per lookup
|
|
8
8
|
classLists: new Set(),
|
|
9
9
|
doneGroups: new Set(), // class:name="…" groups already emitted
|
|
10
|
+
doneKeyframes: new Set(), // add this
|
|
10
11
|
buffer: [], // CSS waiting to be written
|
|
11
12
|
flushQueued: false,
|
|
12
13
|
styleTagExists: false,
|
|
@@ -970,7 +970,7 @@ const cssProps = {
|
|
|
970
970
|
alias: 'd',
|
|
971
971
|
type: 's',
|
|
972
972
|
// compiler:'',
|
|
973
|
-
values: ['block:b', 'compact:cp', 'container:c', 'contents:cont', 'flex:f', 'grid:g', 'inline:i', 'inline-block:ib',
|
|
973
|
+
values: ['-webkit-box:webkit-box:wb:box', 'block:b', 'compact:cp', 'container:c', 'contents:cont', 'flex:f', 'grid:g', 'inline:i', 'inline-block:ib',
|
|
974
974
|
'inline-flex:if', 'inline-grid:ig', 'inline-table:it',
|
|
975
975
|
'list-item:li', 'none:n', 'run-in:ri', 'table:t', 'table-caption:tcap', 'table-cell:tcl', 'table-column:tc',
|
|
976
976
|
'table-column-group:tcg', 'table-footer-group:tfg', 'table-header-group:thg', 'table-row:tr', 'table-row-group:trg'],
|
|
@@ -3093,5 +3093,30 @@ const cssProps = {
|
|
|
3093
3093
|
compiler: (value) => url(value),
|
|
3094
3094
|
values: ['none:n'],
|
|
3095
3095
|
},
|
|
3096
|
+
// ---------------some Custom Aliases compiler----------------
|
|
3097
|
+
'max-h': {
|
|
3098
|
+
property: 'max-height',
|
|
3099
|
+
type: 'd',
|
|
3100
|
+
compiler: length,
|
|
3101
|
+
values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
|
|
3102
|
+
},
|
|
3103
|
+
'min-h': {
|
|
3104
|
+
property: 'min-height',
|
|
3105
|
+
type: 'd',
|
|
3106
|
+
compiler: length,
|
|
3107
|
+
values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
|
|
3108
|
+
},
|
|
3109
|
+
'max-w': {
|
|
3110
|
+
property: 'max-width',
|
|
3111
|
+
type: 'd',
|
|
3112
|
+
compiler: length,
|
|
3113
|
+
values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
|
|
3114
|
+
},
|
|
3115
|
+
'min-w': {
|
|
3116
|
+
property: 'min-width',
|
|
3117
|
+
type: 'd',
|
|
3118
|
+
compiler: length,
|
|
3119
|
+
values: ['max-content:xc', 'min-content:mc', 'none:n', 'fit-content:fc'],
|
|
3120
|
+
},
|
|
3096
3121
|
};
|
|
3097
3122
|
export default cssProps;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* ":--8px" is accepted as negative too.
|
|
6
6
|
*/
|
|
7
7
|
const asClassValue = (value) => '-' + value.replace(/^--(?=[\d.])/, '-');
|
|
8
|
+
const calcValue = (value) => value.replace(/([-+/*])([\d]|var\(|calc\()/g, ' $1 $2').replace(/_/g, ' ');
|
|
8
9
|
/** Value clean-up used when no compiler handles the value (same rules as before, sign-safe). */
|
|
9
10
|
const fallbackValue = (value) => asClassValue(value)
|
|
10
11
|
.replace(/[-]([-]?[\w])/g, ' $1')
|
|
@@ -29,6 +30,9 @@ bool = false) {
|
|
|
29
30
|
if (staticClassNames.hasOwnProperty(className)) {
|
|
30
31
|
return staticClassNames[className];
|
|
31
32
|
}
|
|
33
|
+
// Leading-dot decimals: ".5" → "0.5" (o-.5, m-.5rem, --x-o:.5, scale(.5)). 0.5 is the documented form.
|
|
34
|
+
// Only a dot after a non-word character changes, so "1.5", "0d5", "x.5" and "_.5" stay as written.
|
|
35
|
+
className = className.replace(/(^|[^\w.])\.(\d)/g, '$10.$2');
|
|
32
36
|
// case 2 defining css-variable as className
|
|
33
37
|
if (className.startsWith('--') && className.includes(':')) {
|
|
34
38
|
let value = className.slice(className.indexOf(':')).replace(':', '');
|
|
@@ -68,7 +72,8 @@ bool = false) {
|
|
|
68
72
|
//
|
|
69
73
|
// case 1: CSS Variable inside css variable
|
|
70
74
|
if (/^calc/.test(value)) {
|
|
71
|
-
|
|
75
|
+
const v = calcValue(value);
|
|
76
|
+
return bool ? [property, v] : property + ":" + v;
|
|
72
77
|
}
|
|
73
78
|
// case 2: CSS variable in side css variable
|
|
74
79
|
if (/^--[a-zA-Z]/.test(value)) {
|
|
@@ -120,7 +125,7 @@ bool = false) {
|
|
|
120
125
|
let value = splits[1].slice(splits[1].indexOf(':')).replace(':', '');
|
|
121
126
|
const cssVar = splits[1].replace(value, '').replace(':', '');
|
|
122
127
|
if (/^calc\(/.test(value)) {
|
|
123
|
-
return bool ? [prop, "var(--" + cssVar + ',' + value
|
|
128
|
+
return bool ? [prop, "var(--" + cssVar + ',' + calcValue(value) + ')'] : prop + ": var(--" + cssVar + ',' + calcValue(value) + ')';
|
|
124
129
|
}
|
|
125
130
|
if (property.hasOwnProperty('compiler') && typeof property.compiler === 'function') {
|
|
126
131
|
const val = property.compiler(asClassValue(value), custom);
|
|
@@ -151,11 +156,17 @@ bool = false) {
|
|
|
151
156
|
return bool ? [prop, val] : prop + ":" + val;
|
|
152
157
|
}
|
|
153
158
|
}
|
|
154
|
-
// case 3:
|
|
159
|
+
// case 3: rew var function
|
|
160
|
+
if (/^-var\(/.test(valuePortion)) {
|
|
161
|
+
return bool ? [prop, valuePortion.replace(/^-/, '')] : prop + ":" + valuePortion.replace(/^-/, '');
|
|
162
|
+
}
|
|
163
|
+
// case 4: calc function
|
|
155
164
|
if (/^-calc\(/.test(valuePortion)) {
|
|
156
|
-
|
|
165
|
+
const v = calcValue(valuePortion.replace(/^-/, ''));
|
|
166
|
+
return bool ? [prop, v] : prop + ":" + v;
|
|
167
|
+
// return bool?[prop,valuePortion.replace(/^-/,'').replace(/([-+/*])([\d]|var\(|calc\()/g,' $1 $2')]:prop+":"+valuePortion.replace(/^-/,'').replace(/([-+/*])([\d]|var\(|calc\()/g,' $1 $2');
|
|
157
168
|
}
|
|
158
|
-
// case
|
|
169
|
+
// case 5: CSS variable without --var keyword
|
|
159
170
|
if (/^--[a-zA-Z]/.test(valuePortion)) {
|
|
160
171
|
if (valuePortion.includes(':')) {
|
|
161
172
|
let value = valuePortion.slice(valuePortion.indexOf(':')).replace(':', '');
|
|
@@ -178,7 +189,7 @@ bool = false) {
|
|
|
178
189
|
}
|
|
179
190
|
//
|
|
180
191
|
if (/^calc\(/.test(value)) {
|
|
181
|
-
return bool ? [prop, "var(" + cssVar + ',' + value
|
|
192
|
+
return bool ? [prop, "var(" + cssVar + ',' + calcValue(value) + ')'] : prop + ": var(" + cssVar + ',' + calcValue(value) + ')';
|
|
182
193
|
}
|
|
183
194
|
if (property.hasOwnProperty('compiler') && typeof property.compiler === 'function') {
|
|
184
195
|
const val = property.compiler(asClassValue(value), custom);
|