@master/css 2.0.0-rc.14 → 2.0.0-rc.16

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 (74) hide show
  1. package/dist/_virtual/_commonjsHelpers.cjs +5 -0
  2. package/dist/_virtual/_commonjsHelpers.mjs +3 -0
  3. package/dist/_virtual/css-escape.cjs +5 -0
  4. package/dist/_virtual/css-escape.mjs +3 -0
  5. package/dist/bin/index.cjs +11 -0
  6. package/dist/bin/index.d.ts +1 -11
  7. package/dist/bin/index.mjs +9 -0
  8. package/dist/config/animations.cjs +113 -0
  9. package/dist/config/animations.mjs +111 -0
  10. package/dist/config/functions.cjs +352 -0
  11. package/dist/config/functions.mjs +350 -0
  12. package/dist/config/index.cjs +34 -0
  13. package/dist/config/index.mjs +25 -0
  14. package/dist/config/media-queries.cjs +7 -0
  15. package/dist/config/media-queries.mjs +1 -0
  16. package/dist/config/rules.cjs +2190 -0
  17. package/dist/config/rules.mjs +2184 -0
  18. package/dist/config/selectors.cjs +29 -0
  19. package/dist/config/selectors.mjs +27 -0
  20. package/dist/config/semantics.cjs +194 -0
  21. package/dist/config/semantics.mjs +192 -0
  22. package/dist/config/styles.cjs +2 -0
  23. package/dist/config/styles.mjs +1 -0
  24. package/dist/config/variables.cjs +583 -0
  25. package/dist/config/variables.mjs +581 -0
  26. package/dist/constants/base-unit-regex.cjs +5 -0
  27. package/dist/constants/base-unit-regex.mjs +3 -0
  28. package/dist/constants/start-symbol.cjs +10 -0
  29. package/dist/constants/start-symbol.mjs +8 -0
  30. package/dist/core.cjs +979 -0
  31. package/dist/core.d.ts +2 -3
  32. package/dist/core.mjs +974 -0
  33. package/dist/functions/reorder-for-readable-classes.cjs +68 -0
  34. package/dist/functions/reorder-for-readable-classes.d.ts +1 -1
  35. package/dist/functions/reorder-for-readable-classes.mjs +66 -0
  36. package/dist/functions/transform-color-with-opacity.cjs +9 -0
  37. package/dist/functions/transform-color-with-opacity.mjs +7 -0
  38. package/dist/index.cjs +37 -0
  39. package/dist/index.d.ts +3 -3
  40. package/dist/index.mjs +13 -0
  41. package/dist/layer.cjs +23 -0
  42. package/dist/layer.mjs +23 -0
  43. package/dist/polyfills/css-escape.cjs +8 -0
  44. package/dist/polyfills/css-escape.mjs +2 -0
  45. package/dist/polyfills/css-escape2.cjs +68 -0
  46. package/dist/polyfills/css-escape2.mjs +64 -0
  47. package/dist/rule.cjs +702 -0
  48. package/dist/rule.d.ts +1 -1
  49. package/dist/rule.mjs +700 -0
  50. package/dist/shared/utils/css-escape.cjs +56 -0
  51. package/dist/shared/utils/css-escape.mjs +54 -0
  52. package/dist/tokens/screen-sizes.cjs +17 -0
  53. package/dist/tokens/screen-sizes.mjs +15 -0
  54. package/dist/utils/concat-arrays.cjs +12 -0
  55. package/dist/utils/concat-arrays.mjs +10 -0
  56. package/dist/utils/extend-config.cjs +59 -0
  57. package/dist/utils/extend-config.mjs +57 -0
  58. package/dist/utils/flatten-object.cjs +15 -0
  59. package/dist/utils/flatten-object.mjs +13 -0
  60. package/dist/utils/get-type.cjs +12 -0
  61. package/dist/utils/get-type.mjs +10 -0
  62. package/dist/utils/hex-to-rgb.cjs +30 -0
  63. package/dist/utils/hex-to-rgb.mjs +28 -0
  64. package/dist/utils/is-plain-object.cjs +15 -0
  65. package/dist/utils/is-plain-object.mjs +13 -0
  66. package/dist/utils/is-symbol.cjs +14 -0
  67. package/dist/utils/is-symbol.mjs +12 -0
  68. package/dist/utils/rgb-to-hex.cjs +7 -0
  69. package/dist/utils/rgb-to-hex.mjs +5 -0
  70. package/package.json +1 -1
  71. package/dist/bin/index.bundle.js +0 -33
  72. package/dist/index.bundle.js +0 -1
  73. package/dist/index.bundle.mjs +0 -1
  74. package/dist/types/global.d.ts +0 -5
@@ -0,0 +1,350 @@
1
+ import { BASE_UNIT_REGEX } from '../constants/base-unit-regex.mjs';
2
+
3
+ const functions = {
4
+ $: {
5
+ colored: true,
6
+ transform (value) {
7
+ let name;
8
+ let fallback;
9
+ const firstCommaIndex = value.indexOf(',');
10
+ if (firstCommaIndex !== -1) {
11
+ name = value.slice(0, firstCommaIndex);
12
+ fallback = value.slice(firstCommaIndex + 1);
13
+ } else {
14
+ name = value;
15
+ }
16
+ return [
17
+ {
18
+ type: 'variable',
19
+ name,
20
+ fallback
21
+ }
22
+ ];
23
+ }
24
+ },
25
+ calc: {
26
+ transform (value, bypassVariableNames) {
27
+ const valueComponents = [];
28
+ let i = 0;
29
+ const anaylzeDeeply = (currentValueComponents, bypassHandlingSeparator, parentBypassParsing, parentUnitChecking, isVarFunction)=>{
30
+ const isChildHandler = valueComponents !== currentValueComponents;
31
+ const unparsedValueComponents = [];
32
+ let bypassParsing = false;
33
+ let hasUnit = false;
34
+ let currentHasUnit = false;
35
+ let unitChecking = false;
36
+ let childHasUnit = undefined;
37
+ let current = '';
38
+ const clear = (separator, prefix = '', suffix = '')=>{
39
+ if (childHasUnit === false && separator !== ' ' && this.definition.unit) {
40
+ childHasUnit = undefined;
41
+ if (!unitChecking) {
42
+ pushUnitValueComponents();
43
+ }
44
+ }
45
+ if (current) {
46
+ if (!isVarFunction) {
47
+ const result = BASE_UNIT_REGEX.exec(current);
48
+ if (result) {
49
+ current = (+result[1] * (this.css.config.baseUnit ?? 1)).toString();
50
+ }
51
+ }
52
+ if (!bypassParsing && !parentBypassParsing) {
53
+ const valueComponent = this.parseValueComponent(current);
54
+ if (!hasUnit && isNaN(+current) && valueComponent.type === 'number') {
55
+ hasUnit = true;
56
+ }
57
+ if (unitChecking) {
58
+ if (isNaN(+current)) {
59
+ if (valueComponent.type === 'number') {
60
+ currentValueComponents.push(valueComponent);
61
+ currentHasUnit = true;
62
+ } else {
63
+ currentValueComponents.push(valueComponent);
64
+ }
65
+ } else {
66
+ currentValueComponents.push({
67
+ type: 'number',
68
+ value: +current
69
+ });
70
+ }
71
+ } else {
72
+ if (isChildHandler) {
73
+ const newValueComponent = {
74
+ type: 'string',
75
+ value: current
76
+ };
77
+ unparsedValueComponents.push(newValueComponent);
78
+ currentValueComponents.push(newValueComponent);
79
+ } else {
80
+ currentValueComponents.push(valueComponent);
81
+ }
82
+ }
83
+ } else {
84
+ currentValueComponents.push({
85
+ type: 'string',
86
+ value: current
87
+ });
88
+ }
89
+ current = '';
90
+ }
91
+ if (separator) {
92
+ if (separator === '+' || separator === '-') {
93
+ handleUnitChecking();
94
+ }
95
+ if (prefix && value[i - 1] === ' ') {
96
+ prefix = '';
97
+ }
98
+ if (suffix && value[i + 1] === ' ') {
99
+ suffix = '';
100
+ }
101
+ if (bypassHandlingSeparator) {
102
+ currentValueComponents.push({
103
+ type: 'separator',
104
+ value: separator,
105
+ text: separator
106
+ });
107
+ } else {
108
+ currentValueComponents.push({
109
+ type: 'separator',
110
+ value: separator,
111
+ text: prefix + separator + suffix
112
+ });
113
+ }
114
+ }
115
+ bypassParsing = false;
116
+ };
117
+ const pushUnitValueComponents = ()=>{
118
+ if (this.definition.unit === 'rem' || this.definition.unit === 'em') {
119
+ currentValueComponents.push({
120
+ type: 'separator',
121
+ value: '/',
122
+ text: ' / '
123
+ }, {
124
+ type: 'number',
125
+ value: this.css.config.rootSize
126
+ });
127
+ }
128
+ currentValueComponents.push({
129
+ type: 'separator',
130
+ value: '*',
131
+ text: ' * '
132
+ }, {
133
+ type: 'number',
134
+ value: 1,
135
+ unit: this.definition.unit
136
+ });
137
+ };
138
+ const handleUnitChecking = ()=>{
139
+ if (unitChecking && !currentHasUnit && !parentUnitChecking && (!isChildHandler || hasUnit)) {
140
+ pushUnitValueComponents();
141
+ }
142
+ unitChecking = false;
143
+ currentHasUnit = false;
144
+ };
145
+ for(; i < value.length; i++){
146
+ const char = value[i];
147
+ if (char === '(') {
148
+ const symbolResult = /^([+-])/.exec(current);
149
+ if (symbolResult) {
150
+ currentValueComponents.push({
151
+ type: 'string',
152
+ value: symbolResult[1]
153
+ });
154
+ }
155
+ const functionName = symbolResult ? current.slice(1) : current;
156
+ const newValueComponent = {
157
+ type: 'function',
158
+ name: functionName,
159
+ symbol: char,
160
+ children: [],
161
+ bypassTransform: functionName === 'calc'
162
+ };
163
+ currentValueComponents.push(newValueComponent);
164
+ current = '';
165
+ i++;
166
+ const isVarFunction = functionName === '$' || functionName === 'var';
167
+ childHasUnit = anaylzeDeeply(newValueComponent.children, functionName !== '' && functionName !== 'calc' && (isVarFunction || Object.prototype.hasOwnProperty.call(functions, functionName)), bypassParsing || isVarFunction || unitChecking && currentHasUnit, unitChecking, isVarFunction) || functionName === 'var';
168
+ if (!childHasUnit && functionName === '$') {
169
+ const variableType = this.css.variables[newValueComponent.children[0].value]?.type;
170
+ childHasUnit = !variableType || variableType === 'string';
171
+ }
172
+ if (childHasUnit) {
173
+ hasUnit = true;
174
+ currentHasUnit = true;
175
+ }
176
+ } else if (char === ')') {
177
+ clear('');
178
+ if (hasUnit) {
179
+ for (const eachUnparsedValueComponent of unparsedValueComponents){
180
+ Object.assign(eachUnparsedValueComponent, this.parseValueComponent(eachUnparsedValueComponent.value));
181
+ }
182
+ }
183
+ return hasUnit;
184
+ } else if (char === ',') {
185
+ clear(char, '', ' ');
186
+ } else if (char === ' ') {
187
+ clear(char);
188
+ } else {
189
+ const previousChar = value[i - 1];
190
+ switch(char){
191
+ case '+':
192
+ if (!current && previousChar !== ')') {
193
+ current += char;
194
+ } else {
195
+ clear(char, ' ', ' ');
196
+ }
197
+ break;
198
+ case '-':
199
+ if (!current && previousChar !== ')') {
200
+ current += char;
201
+ } else {
202
+ clear(char, ' ', ' ');
203
+ }
204
+ break;
205
+ case '*':
206
+ if (this.definition.unit) {
207
+ unitChecking = true;
208
+ }
209
+ clear(char, ' ', ' ');
210
+ break;
211
+ case '/':
212
+ if (this.definition.unit) {
213
+ unitChecking = true;
214
+ }
215
+ clear(char, ' ', ' ');
216
+ bypassParsing = true;
217
+ break;
218
+ default:
219
+ current += char;
220
+ break;
221
+ }
222
+ }
223
+ }
224
+ clear('');
225
+ handleUnitChecking();
226
+ };
227
+ anaylzeDeeply(valueComponents, false, false, false, false);
228
+ return 'calc(' + this.resolveValue(valueComponents, functions.calc.unit ?? this.definition.unit, bypassVariableNames, true) + ')';
229
+ }
230
+ },
231
+ translate: {
232
+ unit: 'rem'
233
+ },
234
+ translateX: {
235
+ unit: 'rem'
236
+ },
237
+ translateY: {
238
+ unit: 'rem'
239
+ },
240
+ translateZ: {
241
+ unit: 'rem'
242
+ },
243
+ translate3d: {
244
+ unit: 'rem'
245
+ },
246
+ skew: {
247
+ unit: 'deg'
248
+ },
249
+ skewX: {
250
+ unit: 'deg'
251
+ },
252
+ skewY: {
253
+ unit: 'deg'
254
+ },
255
+ skewZ: {
256
+ unit: 'deg'
257
+ },
258
+ skew3d: {
259
+ unit: 'deg'
260
+ },
261
+ rotate: {
262
+ unit: 'deg'
263
+ },
264
+ rotateX: {
265
+ unit: 'deg'
266
+ },
267
+ rotateY: {
268
+ unit: 'deg'
269
+ },
270
+ rotateZ: {
271
+ unit: 'deg'
272
+ },
273
+ rotate3d: {
274
+ unit: 'deg'
275
+ },
276
+ blur: {
277
+ unit: 'rem'
278
+ },
279
+ 'drop-shadow': {
280
+ unit: 'rem'
281
+ },
282
+ 'hue-rotate': {
283
+ unit: 'deg'
284
+ },
285
+ rgb: {
286
+ unit: ''
287
+ },
288
+ rgba: {
289
+ unit: ''
290
+ },
291
+ hsl: {
292
+ unit: ''
293
+ },
294
+ hsla: {
295
+ unit: ''
296
+ },
297
+ color: {
298
+ unit: '',
299
+ colored: true
300
+ },
301
+ 'color-contrast': {
302
+ unit: '',
303
+ colored: true
304
+ },
305
+ 'color-mix': {
306
+ unit: '',
307
+ colored: true
308
+ },
309
+ hwb: {
310
+ unit: ''
311
+ },
312
+ lab: {
313
+ unit: ''
314
+ },
315
+ lch: {
316
+ unit: ''
317
+ },
318
+ oklab: {
319
+ unit: ''
320
+ },
321
+ oklch: {
322
+ unit: ''
323
+ },
324
+ clamp: {
325
+ unit: ''
326
+ },
327
+ repeat: {
328
+ unit: ''
329
+ },
330
+ 'linear-gradient': {
331
+ colored: true
332
+ },
333
+ 'radial-gradient': {
334
+ colored: true
335
+ },
336
+ 'conic-gradient': {
337
+ colored: true
338
+ },
339
+ 'repeating-linear-gradient': {
340
+ colored: true
341
+ },
342
+ 'repeating-radial-gradient': {
343
+ colored: true
344
+ },
345
+ 'repeating-conic-gradient': {
346
+ colored: true
347
+ }
348
+ };
349
+
350
+ export { functions as default };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ var selectors = require('./selectors.cjs');
4
+ var semantics = require('./semantics.cjs');
5
+ var animations = require('./animations.cjs');
6
+ var variables = require('./variables.cjs');
7
+ var rules = require('./rules.cjs');
8
+ var functions = require('./functions.cjs');
9
+ var screenSizes = require('../tokens/screen-sizes.cjs');
10
+
11
+ const config = {
12
+ mediaQueries: screenSizes,
13
+ selectors,
14
+ semantics,
15
+ rules: rules.default,
16
+ functions,
17
+ animations,
18
+ variables,
19
+ scope: '',
20
+ rootSize: 16,
21
+ baseUnit: 4,
22
+ override: false,
23
+ important: false,
24
+ themeDriver: 'class'
25
+ };
26
+
27
+ exports.selectors = selectors;
28
+ exports.semantics = semantics;
29
+ exports.animations = animations;
30
+ exports.variables = variables;
31
+ exports.rules = rules.default;
32
+ exports.functions = functions;
33
+ exports.mediaQueries = screenSizes;
34
+ exports.config = config;
@@ -0,0 +1,25 @@
1
+ import selectors from './selectors.mjs';
2
+ import semantics from './semantics.mjs';
3
+ import animations from './animations.mjs';
4
+ import variables from './variables.mjs';
5
+ import rules from './rules.mjs';
6
+ import functions from './functions.mjs';
7
+ import mediaQueries from '../tokens/screen-sizes.mjs';
8
+
9
+ const config = {
10
+ mediaQueries,
11
+ selectors,
12
+ semantics,
13
+ rules,
14
+ functions,
15
+ animations,
16
+ variables,
17
+ scope: '',
18
+ rootSize: 16,
19
+ baseUnit: 4,
20
+ override: false,
21
+ important: false,
22
+ themeDriver: 'class'
23
+ };
24
+
25
+ export { animations, config, functions, mediaQueries, rules, selectors, semantics, variables };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ var screenSizes = require('../tokens/screen-sizes.cjs');
4
+
5
+
6
+
7
+ module.exports = screenSizes;
@@ -0,0 +1 @@
1
+ export { default } from '../tokens/screen-sizes.mjs';