tailwindcss 0.0.0-insiders.8259dfd → 0.0.0-insiders.8293c2d

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 (93) hide show
  1. package/CHANGELOG.md +207 -2
  2. package/README.md +8 -4
  3. package/colors.js +2 -1
  4. package/defaultConfig.js +2 -1
  5. package/defaultTheme.js +2 -1
  6. package/lib/cli.js +94 -61
  7. package/lib/constants.js +1 -1
  8. package/lib/corePluginList.js +8 -1
  9. package/lib/corePlugins.js +477 -517
  10. package/lib/css/preflight.css +18 -5
  11. package/lib/featureFlags.js +5 -6
  12. package/lib/index.js +1 -3
  13. package/lib/lib/collapseDuplicateDeclarations.js +80 -0
  14. package/lib/lib/defaultExtractor.js +42 -0
  15. package/lib/lib/detectNesting.js +17 -2
  16. package/lib/lib/evaluateTailwindFunctions.js +10 -6
  17. package/lib/lib/expandApplyAtRules.js +94 -45
  18. package/lib/lib/expandTailwindAtRules.js +32 -33
  19. package/lib/lib/generateRules.js +167 -21
  20. package/lib/lib/normalizeTailwindDirectives.js +8 -1
  21. package/lib/lib/partitionApplyAtRules.js +53 -0
  22. package/lib/lib/resolveDefaultsAtRules.js +28 -14
  23. package/lib/lib/setupContextUtils.js +153 -129
  24. package/lib/lib/setupTrackingContext.js +11 -10
  25. package/lib/lib/sharedState.js +34 -5
  26. package/lib/lib/substituteScreenAtRules.js +7 -4
  27. package/lib/processTailwindFeatures.js +7 -2
  28. package/lib/util/buildMediaQuery.js +13 -24
  29. package/lib/util/color.js +23 -8
  30. package/lib/util/createPlugin.js +1 -2
  31. package/lib/util/createUtilityPlugin.js +6 -10
  32. package/lib/util/dataTypes.js +38 -7
  33. package/lib/util/defaults.js +6 -0
  34. package/lib/util/flattenColorPalette.js +1 -3
  35. package/lib/util/formatVariantSelector.js +186 -0
  36. package/lib/util/isValidArbitraryValue.js +64 -0
  37. package/lib/util/log.js +4 -0
  38. package/lib/util/nameClass.js +1 -0
  39. package/lib/util/normalizeConfig.js +63 -21
  40. package/lib/util/normalizeScreens.js +59 -0
  41. package/lib/util/parseBoxShadowValue.js +77 -0
  42. package/lib/util/pluginUtils.js +27 -158
  43. package/lib/util/prefixSelector.js +1 -3
  44. package/lib/util/resolveConfig.js +30 -31
  45. package/lib/util/resolveConfigPath.js +1 -2
  46. package/lib/util/toColorValue.js +1 -2
  47. package/lib/util/toPath.js +6 -1
  48. package/lib/util/transformThemeValue.js +19 -13
  49. package/nesting/plugin.js +4 -1
  50. package/package.json +19 -21
  51. package/peers/index.js +4621 -5626
  52. package/plugin.js +2 -1
  53. package/resolveConfig.js +2 -1
  54. package/src/cli.js +66 -14
  55. package/src/corePluginList.js +1 -1
  56. package/src/corePlugins.js +406 -518
  57. package/src/css/preflight.css +18 -5
  58. package/src/featureFlags.js +1 -1
  59. package/src/index.js +1 -7
  60. package/src/lib/collapseDuplicateDeclarations.js +93 -0
  61. package/src/lib/defaultExtractor.js +48 -0
  62. package/src/lib/detectNesting.js +22 -3
  63. package/src/lib/evaluateTailwindFunctions.js +6 -3
  64. package/src/lib/expandApplyAtRules.js +101 -45
  65. package/src/lib/expandTailwindAtRules.js +33 -27
  66. package/src/lib/generateRules.js +178 -11
  67. package/src/lib/normalizeTailwindDirectives.js +6 -1
  68. package/src/lib/partitionApplyAtRules.js +52 -0
  69. package/src/lib/resolveDefaultsAtRules.js +31 -10
  70. package/src/lib/setupContextUtils.js +140 -84
  71. package/src/lib/setupTrackingContext.js +11 -10
  72. package/src/lib/sharedState.js +40 -4
  73. package/src/lib/substituteScreenAtRules.js +6 -3
  74. package/src/processTailwindFeatures.js +8 -2
  75. package/src/util/buildMediaQuery.js +14 -18
  76. package/src/util/color.js +20 -7
  77. package/src/util/dataTypes.js +43 -11
  78. package/src/util/defaults.js +6 -0
  79. package/src/util/formatVariantSelector.js +196 -0
  80. package/src/util/isValidArbitraryValue.js +61 -0
  81. package/src/util/log.js +4 -0
  82. package/src/util/nameClass.js +1 -1
  83. package/src/util/normalizeConfig.js +37 -2
  84. package/src/util/normalizeScreens.js +45 -0
  85. package/src/util/parseBoxShadowValue.js +71 -0
  86. package/src/util/pluginUtils.js +15 -138
  87. package/src/util/prefixSelector.js +1 -4
  88. package/src/util/resolveConfig.js +11 -1
  89. package/src/util/toPath.js +23 -1
  90. package/src/util/transformThemeValue.js +22 -7
  91. package/stubs/defaultConfig.stub.js +42 -16
  92. package/lib/lib/setupWatchingContext.js +0 -284
  93. package/src/lib/setupWatchingContext.js +0 -304
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.normalizeScreens = normalizeScreens;
6
+ function normalizeScreens(screens, root = true) {
7
+ if (Array.isArray(screens)) {
8
+ return screens.map((screen)=>{
9
+ if (root && Array.isArray(screen)) {
10
+ throw new Error('The tuple syntax is not supported for `screens`.');
11
+ }
12
+ if (typeof screen === 'string') {
13
+ return {
14
+ name: screen.toString(),
15
+ values: [
16
+ {
17
+ min: screen,
18
+ max: undefined
19
+ }
20
+ ]
21
+ };
22
+ }
23
+ let [name, options] = screen;
24
+ name = name.toString();
25
+ if (typeof options === 'string') {
26
+ return {
27
+ name,
28
+ values: [
29
+ {
30
+ min: options,
31
+ max: undefined
32
+ }
33
+ ]
34
+ };
35
+ }
36
+ if (Array.isArray(options)) {
37
+ return {
38
+ name,
39
+ values: options.map((option)=>resolveValue(option)
40
+ )
41
+ };
42
+ }
43
+ return {
44
+ name,
45
+ values: [
46
+ resolveValue(options)
47
+ ]
48
+ };
49
+ });
50
+ }
51
+ return normalizeScreens(Object.entries(screens !== null && screens !== void 0 ? screens : {}), false);
52
+ }
53
+ function resolveValue({ 'min-width': _minWidth , min =_minWidth , max , raw } = {}) {
54
+ return {
55
+ min,
56
+ max,
57
+ raw
58
+ };
59
+ }
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.parseBoxShadowValue = parseBoxShadowValue;
6
+ exports.formatBoxShadowValue = formatBoxShadowValue;
7
+ let KEYWORDS = new Set([
8
+ 'inset',
9
+ 'inherit',
10
+ 'initial',
11
+ 'revert',
12
+ 'unset'
13
+ ]);
14
+ let COMMA = /\,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
15
+ ;
16
+ let SPACE = /\ +(?![^(]*\))/g // Similar to the one above, but with spaces instead.
17
+ ;
18
+ let LENGTH = /^-?(\d+)(.*?)$/g;
19
+ function parseBoxShadowValue(input) {
20
+ let shadows = input.split(COMMA);
21
+ return shadows.map((shadow)=>{
22
+ let value = shadow.trim();
23
+ let result = {
24
+ raw: value
25
+ };
26
+ let parts = value.split(SPACE);
27
+ let seen = new Set();
28
+ for (let part of parts){
29
+ // Reset index, since the regex is stateful.
30
+ LENGTH.lastIndex = 0;
31
+ // Keyword
32
+ if (!seen.has('KEYWORD') && KEYWORDS.has(part)) {
33
+ result.keyword = part;
34
+ seen.add('KEYWORD');
35
+ } else if (LENGTH.test(part)) {
36
+ if (!seen.has('X')) {
37
+ result.x = part;
38
+ seen.add('X');
39
+ } else if (!seen.has('Y')) {
40
+ result.y = part;
41
+ seen.add('Y');
42
+ } else if (!seen.has('BLUR')) {
43
+ result.blur = part;
44
+ seen.add('BLUR');
45
+ } else if (!seen.has('SPREAD')) {
46
+ result.spread = part;
47
+ seen.add('SPREAD');
48
+ }
49
+ } else {
50
+ if (!result.color) {
51
+ result.color = part;
52
+ } else {
53
+ if (!result.unknown) result.unknown = [];
54
+ result.unknown.push(part);
55
+ }
56
+ }
57
+ }
58
+ // Check if valid
59
+ result.valid = result.x !== undefined && result.y !== undefined;
60
+ return result;
61
+ });
62
+ }
63
+ function formatBoxShadowValue(shadows) {
64
+ return shadows.map((shadow)=>{
65
+ if (!shadow.valid) {
66
+ return shadow.raw;
67
+ }
68
+ return [
69
+ shadow.keyword,
70
+ shadow.x,
71
+ shadow.y,
72
+ shadow.blur,
73
+ shadow.spread,
74
+ shadow.color
75
+ ].filter(Boolean).join(' ');
76
+ }).join(', ');
77
+ }
@@ -2,12 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
- exports.applyStateToMarker = applyStateToMarker;
6
5
  exports.updateAllClasses = updateAllClasses;
7
- exports.updateLastClasses = updateLastClasses;
8
- exports.transformAllSelectors = transformAllSelectors;
9
- exports.transformAllClasses = transformAllClasses;
10
- exports.transformLastClasses = transformLastClasses;
11
6
  exports.asValue = asValue;
12
7
  exports.asColor = asColor;
13
8
  exports.asLookupValue = asLookupValue;
@@ -15,7 +10,6 @@ exports.coerceValue = coerceValue;
15
10
  var _postcssSelectorParser = _interopRequireDefault(require("postcss-selector-parser"));
16
11
  var _escapeCommas = _interopRequireDefault(require("./escapeCommas"));
17
12
  var _withAlphaVariable = require("./withAlphaVariable");
18
- var _isKeyframeRule = _interopRequireDefault(require("./isKeyframeRule"));
19
13
  var _dataTypes = require("./dataTypes");
20
14
  var _negateValue = _interopRequireDefault(require("./negateValue"));
21
15
  function _interopRequireDefault(obj) {
@@ -23,144 +17,19 @@ function _interopRequireDefault(obj) {
23
17
  default: obj
24
18
  };
25
19
  }
26
- function applyStateToMarker(selector, marker, state, join) {
27
- let markerIdx = selector.search(new RegExp(`${marker}[:[]`));
28
- if (markerIdx === -1) {
29
- return join(marker + state, selector);
30
- }
31
- let markerSelector = selector.slice(markerIdx, selector.indexOf(' ', markerIdx));
32
- return join(marker + state + markerSelector.slice(markerIdx + marker.length), selector.replace(markerSelector, ''));
33
- }
34
- function updateAllClasses(selectors, updateClass) {
20
+ function updateAllClasses(selectors1, updateClass) {
35
21
  let parser = (0, _postcssSelectorParser).default((selectors)=>{
36
22
  selectors.walkClasses((sel)=>{
37
- let updatedClass = updateClass(sel.value, {
38
- withAttr (className, attr) {
39
- sel.parent.insertAfter(sel, _postcssSelectorParser.default.attribute({
40
- attribute: attr.slice(1, -1)
41
- }));
42
- return className;
43
- },
44
- withPseudo (className, pseudo) {
45
- sel.parent.insertAfter(sel, _postcssSelectorParser.default.pseudo({
46
- value: pseudo
47
- }));
48
- return className;
49
- }
50
- });
23
+ let updatedClass = updateClass(sel.value);
51
24
  sel.value = updatedClass;
52
25
  if (sel.raws && sel.raws.value) {
53
26
  sel.raws.value = (0, _escapeCommas).default(sel.raws.value);
54
27
  }
55
28
  });
56
29
  });
57
- let result = parser.processSync(selectors);
30
+ let result = parser.processSync(selectors1);
58
31
  return result;
59
32
  }
60
- function updateLastClasses(selectors, updateClass) {
61
- let parser = (0, _postcssSelectorParser).default((selectors)=>{
62
- selectors.each((sel)=>{
63
- let lastClass = sel.filter(({ type })=>type === 'class'
64
- ).pop();
65
- if (lastClass === undefined) {
66
- return;
67
- }
68
- let updatedClass = updateClass(lastClass.value, {
69
- withPseudo (className, pseudo) {
70
- lastClass.parent.insertAfter(lastClass, _postcssSelectorParser.default.pseudo({
71
- value: `${pseudo}`
72
- }));
73
- return className;
74
- }
75
- });
76
- lastClass.value = updatedClass;
77
- if (lastClass.raws && lastClass.raws.value) {
78
- lastClass.raws.value = (0, _escapeCommas).default(lastClass.raws.value);
79
- }
80
- });
81
- });
82
- let result = parser.processSync(selectors);
83
- return result;
84
- }
85
- function splitByNotEscapedCommas(str) {
86
- let chunks = [];
87
- let currentChunk = '';
88
- for(let i = 0; i < str.length; i++){
89
- if (str[i] === ',' && str[i - 1] !== '\\') {
90
- chunks.push(currentChunk);
91
- currentChunk = '';
92
- } else {
93
- currentChunk += str[i];
94
- }
95
- }
96
- chunks.push(currentChunk);
97
- return chunks;
98
- }
99
- function transformAllSelectors(transformSelector, { wrap , withRule } = {
100
- }) {
101
- return ({ container })=>{
102
- container.walkRules((rule)=>{
103
- if ((0, _isKeyframeRule).default(rule)) {
104
- return rule;
105
- }
106
- let transformed = splitByNotEscapedCommas(rule.selector).map(transformSelector).join(',');
107
- rule.selector = transformed;
108
- if (withRule) {
109
- withRule(rule);
110
- }
111
- return rule;
112
- });
113
- if (wrap) {
114
- let wrapper = wrap();
115
- let nodes = container.nodes;
116
- container.removeAll();
117
- wrapper.append(nodes);
118
- container.append(wrapper);
119
- }
120
- };
121
- }
122
- function transformAllClasses(transformClass, { wrap , withRule } = {
123
- }) {
124
- return ({ container })=>{
125
- container.walkRules((rule)=>{
126
- let selector = rule.selector;
127
- let variantSelector = updateAllClasses(selector, transformClass);
128
- rule.selector = variantSelector;
129
- if (withRule) {
130
- withRule(rule);
131
- }
132
- return rule;
133
- });
134
- if (wrap) {
135
- let wrapper = wrap();
136
- let nodes = container.nodes;
137
- container.removeAll();
138
- wrapper.append(nodes);
139
- container.append(wrapper);
140
- }
141
- };
142
- }
143
- function transformLastClasses(transformClass, { wrap , withRule } = {
144
- }) {
145
- return ({ container })=>{
146
- container.walkRules((rule)=>{
147
- let selector = rule.selector;
148
- let variantSelector = updateLastClasses(selector, transformClass);
149
- rule.selector = variantSelector;
150
- if (withRule) {
151
- withRule(rule);
152
- }
153
- return rule;
154
- });
155
- if (wrap) {
156
- let wrapper = wrap();
157
- let nodes = container.nodes;
158
- container.removeAll();
159
- wrapper.append(nodes);
160
- container.append(wrapper);
161
- }
162
- };
163
- }
164
33
  function resolveArbitraryValue(modifier, validate) {
165
34
  if (!isArbitraryValue(modifier)) {
166
35
  return undefined;
@@ -171,8 +40,7 @@ function resolveArbitraryValue(modifier, validate) {
171
40
  }
172
41
  return (0, _dataTypes).normalize(value);
173
42
  }
174
- function asNegativeValue(modifier, lookup = {
175
- }, validate) {
43
+ function asNegativeValue(modifier, lookup = {}, validate) {
176
44
  let positiveValue = lookup[modifier];
177
45
  if (positiveValue !== undefined) {
178
46
  return (0, _negateValue).default(positiveValue);
@@ -185,10 +53,8 @@ function asNegativeValue(modifier, lookup = {
185
53
  return (0, _negateValue).default(resolved);
186
54
  }
187
55
  }
188
- function asValue(modifier, options = {
189
- }, { validate =()=>true
190
- } = {
191
- }) {
56
+ function asValue(modifier, options = {}, { validate =()=>true
57
+ } = {}) {
192
58
  var ref;
193
59
  let value = (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
194
60
  if (value !== undefined) {
@@ -214,27 +80,24 @@ function splitAlpha(modifier) {
214
80
  modifier.slice(slashIdx + 1)
215
81
  ];
216
82
  }
217
- function asColor(modifier, options = {
218
- }, { tailwindConfig ={
219
- } } = {
220
- }) {
221
- var ref7;
222
- if (((ref7 = options.values) === null || ref7 === void 0 ? void 0 : ref7[modifier]) !== undefined) {
223
- var ref;
224
- return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
83
+ function asColor(modifier, options = {}, { tailwindConfig ={} } = {}) {
84
+ var ref;
85
+ if (((ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier]) !== undefined) {
86
+ var ref1;
87
+ return (ref1 = options.values) === null || ref1 === void 0 ? void 0 : ref1[modifier];
225
88
  }
226
89
  let [color, alpha] = splitAlpha(modifier);
227
90
  if (alpha !== undefined) {
228
- var ref, ref1, ref2;
229
- var ref3;
230
- let normalizedColor = (ref3 = (ref = options.values) === null || ref === void 0 ? void 0 : ref[color]) !== null && ref3 !== void 0 ? ref3 : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
91
+ var ref2, ref3, ref4;
92
+ var ref5;
93
+ let normalizedColor = (ref5 = (ref2 = options.values) === null || ref2 === void 0 ? void 0 : ref2[color]) !== null && ref5 !== void 0 ? ref5 : isArbitraryValue(color) ? color.slice(1, -1) : undefined;
231
94
  if (normalizedColor === undefined) {
232
95
  return undefined;
233
96
  }
234
97
  if (isArbitraryValue(alpha)) {
235
98
  return (0, _withAlphaVariable).withAlphaValue(normalizedColor, alpha.slice(1, -1));
236
99
  }
237
- if (((ref1 = tailwindConfig.theme) === null || ref1 === void 0 ? void 0 : (ref2 = ref1.opacity) === null || ref2 === void 0 ? void 0 : ref2[alpha]) === undefined) {
100
+ if (((ref3 = tailwindConfig.theme) === null || ref3 === void 0 ? void 0 : (ref4 = ref3.opacity) === null || ref4 === void 0 ? void 0 : ref4[alpha]) === undefined) {
238
101
  return undefined;
239
102
  }
240
103
  return (0, _withAlphaVariable).withAlphaValue(normalizedColor, tailwindConfig.theme.opacity[alpha]);
@@ -243,8 +106,7 @@ function asColor(modifier, options = {
243
106
  validate: _dataTypes.color
244
107
  });
245
108
  }
246
- function asLookupValue(modifier, options = {
247
- }) {
109
+ function asLookupValue(modifier, options = {}) {
248
110
  var ref;
249
111
  return (ref = options.values) === null || ref === void 0 ? void 0 : ref[modifier];
250
112
  }
@@ -269,7 +131,8 @@ let typeMap = {
269
131
  number: guess(_dataTypes.number),
270
132
  'line-width': guess(_dataTypes.lineWidth),
271
133
  'absolute-size': guess(_dataTypes.absoluteSize),
272
- 'relative-size': guess(_dataTypes.relativeSize)
134
+ 'relative-size': guess(_dataTypes.relativeSize),
135
+ shadow: guess(_dataTypes.shadow)
273
136
  };
274
137
  let supportedTypes = Object.keys(typeMap);
275
138
  function splitAtFirst(input, delim) {
@@ -285,8 +148,14 @@ function splitAtFirst(input, delim) {
285
148
  }
286
149
  function coerceValue(types, modifier, options, tailwindConfig) {
287
150
  if (isArbitraryValue(modifier)) {
288
- let [explicitType, value] = splitAtFirst(modifier.slice(1, -1), ':');
289
- if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
151
+ let arbitraryValue = modifier.slice(1, -1);
152
+ let [explicitType, value] = splitAtFirst(arbitraryValue, ':');
153
+ // It could be that this resolves to `url(https` which is not a valid
154
+ // identifier. We currently only support "simple" words with dashes or
155
+ // underscores. E.g.: family-name
156
+ if (!/^[\w-_]+$/g.test(explicitType)) {
157
+ value = arbitraryValue;
158
+ } else if (explicitType !== undefined && !supportedTypes.includes(explicitType)) {
290
159
  return [];
291
160
  }
292
161
  if (value.length > 0 && supportedTypes.includes(explicitType)) {
@@ -301,7 +170,7 @@ function coerceValue(types, modifier, options, tailwindConfig) {
301
170
  let result = typeMap[type](modifier, options, {
302
171
  tailwindConfig
303
172
  });
304
- if (result) return [
173
+ if (result !== undefined) return [
305
174
  result,
306
175
  type
307
176
  ];
@@ -11,12 +11,10 @@ function _interopRequireDefault(obj) {
11
11
  };
12
12
  }
13
13
  function _default(prefix, selector) {
14
- const getPrefix = typeof prefix === 'function' ? prefix : ()=>prefix === undefined ? '' : prefix
15
- ;
16
14
  return (0, _postcssSelectorParser).default((selectors)=>{
17
15
  selectors.walkClasses((classSelector)=>{
18
16
  (0, _tap).tap(classSelector.value, (baseClass)=>{
19
- classSelector.value = `${getPrefix('.' + baseClass)}${baseClass}`;
17
+ classSelector.value = `${prefix}${baseClass}`;
20
18
  });
21
19
  });
22
20
  }).processSync(selector);
@@ -11,6 +11,8 @@ var _colors = _interopRequireDefault(require("../public/colors"));
11
11
  var _defaults = require("./defaults");
12
12
  var _toPath = require("./toPath");
13
13
  var _normalizeConfig = require("./normalizeConfig");
14
+ var _isPlainObject = _interopRequireDefault(require("./isPlainObject"));
15
+ var _cloneDeep = require("./cloneDeep");
14
16
  function _interopRequireDefault(obj) {
15
17
  return obj && obj.__esModule ? obj : {
16
18
  default: obj
@@ -51,8 +53,7 @@ const configUtils = {
51
53
  negativeScale[`-${key}`] = negativeValue;
52
54
  }
53
55
  return negativeScale;
54
- }, {
55
- });
56
+ }, {});
56
57
  },
57
58
  breakpoints (screens) {
58
59
  return Object.keys(screens).filter((key)=>typeof screens[key] === 'string'
@@ -60,8 +61,7 @@ const configUtils = {
60
61
  ...breakpoints,
61
62
  [`screen-${key}`]: screens[key]
62
63
  })
63
- , {
64
- });
64
+ , {});
65
65
  }
66
66
  };
67
67
  function value(valueToResolve, ...args) {
@@ -86,34 +86,32 @@ function collectExtends(items) {
86
86
  mergedValue
87
87
  ];
88
88
  });
89
- }, {
90
- });
89
+ }, {});
91
90
  }
92
91
  function mergeThemes(themes) {
93
92
  return {
94
93
  ...themes.reduce((merged, theme)=>(0, _defaults).defaults(merged, theme)
95
- , {
96
- }),
94
+ , {}),
97
95
  // In order to resolve n config objects, we combine all of their `extend` properties
98
96
  // into arrays instead of objects so they aren't overridden.
99
97
  extend: collectExtends(themes)
100
98
  };
101
99
  }
102
- function mergeExtensionCustomizer(merged, value) {
100
+ function mergeExtensionCustomizer(merged, value1) {
103
101
  // When we have an array of objects, we do want to merge it
104
102
  if (Array.isArray(merged) && isObject(merged[0])) {
105
- return merged.concat(value);
103
+ return merged.concat(value1);
106
104
  }
107
105
  // When the incoming value is an array, and the existing config is an object, prepend the existing object
108
- if (Array.isArray(value) && isObject(value[0]) && isObject(merged)) {
106
+ if (Array.isArray(value1) && isObject(value1[0]) && isObject(merged)) {
109
107
  return [
110
108
  merged,
111
- ...value
109
+ ...value1
112
110
  ];
113
111
  }
114
112
  // Override arrays (for example for font-families, box-shadows, ...)
115
- if (Array.isArray(value)) {
116
- return value;
113
+ if (Array.isArray(value1)) {
114
+ return value1;
117
115
  }
118
116
  // Execute default behaviour
119
117
  return undefined;
@@ -122,11 +120,9 @@ function mergeExtensions({ extend , ...theme }) {
122
120
  return mergeWith(theme, extend, (themeValue, extensions)=>{
123
121
  // The `extend` property is an array, so we need to check if it contains any functions
124
122
  if (!isFunction(themeValue) && !extensions.some(isFunction)) {
125
- return mergeWith({
126
- }, themeValue, ...extensions, mergeExtensionCustomizer);
123
+ return mergeWith({}, themeValue, ...extensions, mergeExtensionCustomizer);
127
124
  }
128
- return (resolveThemePath, utils)=>mergeWith({
129
- }, ...[
125
+ return (resolveThemePath, utils)=>mergeWith({}, ...[
130
126
  themeValue,
131
127
  ...extensions
132
128
  ].map((e)=>value(e, resolveThemePath, utils)
@@ -143,19 +139,24 @@ function resolveFunctionKeys(object) {
143
139
  val = val[path[index++]];
144
140
  val = isFunction(val) ? val(resolvePath, configUtils) : val;
145
141
  }
146
- return val === undefined ? defaultValue : val;
142
+ if (val === undefined) {
143
+ return defaultValue;
144
+ }
145
+ if ((0, _isPlainObject).default(val)) {
146
+ return (0, _cloneDeep).cloneDeep(val);
147
+ }
148
+ return val;
147
149
  };
148
150
  resolvePath.theme = resolvePath;
149
- for(let key in configUtils){
150
- resolvePath[key] = configUtils[key];
151
+ for(let key1 in configUtils){
152
+ resolvePath[key1] = configUtils[key1];
151
153
  }
152
154
  return Object.keys(object).reduce((resolved, key)=>{
153
155
  return {
154
156
  ...resolved,
155
157
  [key]: isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
156
158
  };
157
- }, {
158
- });
159
+ }, {});
159
160
  }
160
161
  function extractPluginConfigs(configs) {
161
162
  let allConfigs = [];
@@ -164,8 +165,8 @@ function extractPluginConfigs(configs) {
164
165
  ...allConfigs,
165
166
  config
166
167
  ];
167
- var ref;
168
- const plugins = (ref = config === null || config === void 0 ? void 0 : config.plugins) !== null && ref !== void 0 ? ref : [];
168
+ var ref1;
169
+ const plugins = (ref1 = config === null || config === void 0 ? void 0 : config.plugins) !== null && ref1 !== void 0 ? ref1 : [];
169
170
  if (plugins.length === 0) {
170
171
  return;
171
172
  }
@@ -177,8 +178,7 @@ function extractPluginConfigs(configs) {
177
178
  allConfigs = [
178
179
  ...allConfigs,
179
180
  ...extractPluginConfigs([
180
- (ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {
181
- }
181
+ (ref = plugin === null || plugin === void 0 ? void 0 : plugin.config) !== null && ref !== void 0 ? ref : {}
182
182
  ])
183
183
  ];
184
184
  });
@@ -219,16 +219,15 @@ function resolveConfig(configs) {
219
219
  variantOrder: _defaultConfigStub.default.variantOrder
220
220
  },
221
221
  ];
222
- var ref, ref1;
222
+ var ref, ref2;
223
223
  return (0, _normalizeConfig).normalizeConfig((0, _defaults).defaults({
224
224
  theme: resolveFunctionKeys(mergeExtensions(mergeThemes(allConfigs.map((t)=>{
225
- return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {
226
- };
225
+ return (ref = t === null || t === void 0 ? void 0 : t.theme) !== null && ref !== void 0 ? ref : {};
227
226
  })))),
228
227
  corePlugins: resolveCorePlugins(allConfigs.map((c)=>c.corePlugins
229
228
  )),
230
229
  plugins: resolvePluginLists(configs.map((c)=>{
231
- return (ref1 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref1 !== void 0 ? ref1 : [];
230
+ return (ref2 = c === null || c === void 0 ? void 0 : c.plugins) !== null && ref2 !== void 0 ? ref2 : [];
232
231
  }))
233
232
  }, ...allConfigs));
234
233
  }
@@ -45,8 +45,7 @@ function resolveConfigPath(pathOrConfig) {
45
45
  const configPath = _path.default.resolve(configFile);
46
46
  _fs.default.accessSync(configPath);
47
47
  return configPath;
48
- } catch (err) {
49
- }
48
+ } catch (err) {}
50
49
  }
51
50
  return null;
52
51
  }
@@ -4,6 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  });
5
5
  exports.default = toColorValue;
6
6
  function toColorValue(maybeFunction) {
7
- return typeof maybeFunction === 'function' ? maybeFunction({
8
- }) : maybeFunction;
7
+ return typeof maybeFunction === 'function' ? maybeFunction({}) : maybeFunction;
9
8
  }
@@ -5,5 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  exports.toPath = toPath;
6
6
  function toPath(path) {
7
7
  if (Array.isArray(path)) return path;
8
- return path.split(/[\.\]\[]+/g);
8
+ let openBrackets = path.split('[').length - 1;
9
+ let closedBrackets = path.split(']').length - 1;
10
+ if (openBrackets !== closedBrackets) {
11
+ throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`);
12
+ }
13
+ return path.split(/\.(?![^\[]*\])|[\[\]]/g).filter(Boolean);
9
14
  }
@@ -14,8 +14,11 @@ function transformThemeValue(themeSection) {
14
14
  'fontSize',
15
15
  'outline'
16
16
  ].includes(themeSection)) {
17
- return (value)=>Array.isArray(value) ? value[0] : value
18
- ;
17
+ return (value)=>{
18
+ if (typeof value === 'function') value = value({});
19
+ if (Array.isArray(value)) value = value[0];
20
+ return value;
21
+ };
19
22
  }
20
23
  if ([
21
24
  'fontFamily',
@@ -30,8 +33,11 @@ function transformThemeValue(themeSection) {
30
33
  'cursor',
31
34
  'animation',
32
35
  ].includes(themeSection)) {
33
- return (value)=>Array.isArray(value) ? value.join(', ') : value
34
- ;
36
+ return (value)=>{
37
+ if (typeof value === 'function') value = value({});
38
+ if (Array.isArray(value)) value = value.join(', ');
39
+ return value;
40
+ };
35
41
  }
36
42
  // For backwards compatibility reasons, before we switched to underscores
37
43
  // instead of commas for arbitrary values.
@@ -40,14 +46,14 @@ function transformThemeValue(themeSection) {
40
46
  'gridTemplateRows',
41
47
  'objectPosition'
42
48
  ].includes(themeSection)) {
43
- return (value)=>typeof value === 'string' ? _postcss.default.list.comma(value).join(' ') : value
44
- ;
49
+ return (value)=>{
50
+ if (typeof value === 'function') value = value({});
51
+ if (typeof value === 'string') value = _postcss.default.list.comma(value).join(' ');
52
+ return value;
53
+ };
45
54
  }
46
- if (themeSection === 'colors') {
47
- return (value)=>typeof value === 'function' ? value({
48
- }) : value
49
- ;
50
- }
51
- return (value)=>value
52
- ;
55
+ return (value)=>{
56
+ if (typeof value === 'function') value = value({});
57
+ return value;
58
+ };
53
59
  }
package/nesting/plugin.js CHANGED
@@ -14,7 +14,10 @@ module.exports = function nesting(opts = postcssNested) {
14
14
  })
15
15
 
16
16
  let plugin = (() => {
17
- if (typeof opts === 'function') {
17
+ if (
18
+ typeof opts === 'function' ||
19
+ (typeof opts === 'object' && opts?.hasOwnProperty('postcssPlugin'))
20
+ ) {
18
21
  return opts
19
22
  }
20
23