tailwindcss 3.1.4 → 3.1.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.
package/CHANGELOG.md CHANGED
@@ -9,6 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
9
9
 
10
10
  - Nothing yet!
11
11
 
12
+ ## [3.1.5] - 2022-07-07
13
+
14
+ ### Added
15
+
16
+ - Support default `font-weight`s in font size utilities ([#8763](https://github.com/tailwindlabs/tailwindcss/pull/8763))
17
+
18
+ ### Fixed
19
+
20
+ - Allows fallback values in plugin API helpers ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))
21
+ - Fix usage of postcss.config.js in standalone CLI ([#8769](https://github.com/tailwindlabs/tailwindcss/pull/8769))
22
+ - Fix usage of special-character prefixes ([#8772](https://github.com/tailwindlabs/tailwindcss/pull/8772))
23
+ - Don’t prefix selectors in arbitrary variants ([#8773](https://github.com/tailwindlabs/tailwindcss/pull/8773))
24
+ - Add support for alpha values in safe list ([#8774](https://github.com/tailwindlabs/tailwindcss/pull/8774))
25
+ - Add more explicit types for the default theme ([#8780](https://github.com/tailwindlabs/tailwindcss/pull/8780))
26
+
12
27
  ## [3.1.4] - 2022-06-21
13
28
 
14
29
  ### Fixed
@@ -1989,7 +2004,8 @@ No release notes
1989
2004
 
1990
2005
  - Everything!
1991
2006
 
1992
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.4...HEAD
2007
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.5...HEAD
2008
+ [3.1.5]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.4...v3.1.5
1993
2009
  [3.1.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...v3.1.4
1994
2010
  [3.1.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.2...v3.1.3
1995
2011
  [3.1.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.1...v3.1.2
package/defaultTheme.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { Config } from './types/config'
2
- declare const theme: Config['theme']
2
+ import { DefaultTheme } from './types/generated/default-theme'
3
+ declare const theme: Config['theme'] & DefaultTheme
3
4
  export = theme
@@ -2657,7 +2657,7 @@ let corePlugins = {
2657
2657
  let [fontSize, options] = Array.isArray(value) ? value : [
2658
2658
  value
2659
2659
  ];
2660
- let { lineHeight , letterSpacing } = (0, _isPlainObject).default(options) ? options : {
2660
+ let { lineHeight , letterSpacing , fontWeight } = (0, _isPlainObject).default(options) ? options : {
2661
2661
  lineHeight: options
2662
2662
  };
2663
2663
  return {
@@ -2667,6 +2667,9 @@ let corePlugins = {
2667
2667
  },
2668
2668
  ...letterSpacing === undefined ? {} : {
2669
2669
  "letter-spacing": letterSpacing
2670
+ },
2671
+ ...fontWeight === undefined ? {} : {
2672
+ "font-weight": fontWeight
2670
2673
  }
2671
2674
  };
2672
2675
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", {
3
3
  value: true
4
4
  });
5
5
  exports.defaultExtractor = defaultExtractor;
6
- var _featureFlagsJs = require("../featureFlags.js");
6
+ var _featureFlags = require("../featureFlags");
7
7
  var regex = _interopRequireWildcard(require("./regex"));
8
8
  function _getRequireWildcardCache() {
9
9
  if (typeof WeakMap !== "function") return null;
@@ -62,7 +62,11 @@ function defaultExtractor(context) {
62
62
  }
63
63
  function* buildRegExps(context) {
64
64
  let separator = context.tailwindConfig.separator;
65
- let variantGroupingEnabled = (0, _featureFlagsJs).flagEnabled(context.tailwindConfig, "variantGrouping");
65
+ let variantGroupingEnabled = (0, _featureFlags).flagEnabled(context.tailwindConfig, "variantGrouping");
66
+ let prefix = context.tailwindConfig.prefix !== "" ? regex.optional(regex.pattern([
67
+ /-?/,
68
+ regex.escape(context.tailwindConfig.prefix)
69
+ ])) : "";
66
70
  let utility = regex.any([
67
71
  // Arbitrary properties
68
72
  /\[[^\s:'"`]+:[^\s\]]+\]/,
@@ -125,6 +129,7 @@ function* buildRegExps(context) {
125
129
  ")+))\\2)?",
126
130
  // Important (optional)
127
131
  /!?/,
132
+ prefix,
128
133
  variantGroupingEnabled ? regex.any([
129
134
  // Or any of those things but grouped separated by commas
130
135
  regex.pattern([
@@ -171,6 +171,7 @@ function applyVariant(variant, matches, context) {
171
171
  return matches;
172
172
  }
173
173
  let args;
174
+ let isArbitraryVariant = false;
174
175
  // Find partial arbitrary variants
175
176
  if (variant.endsWith("]") && !variant.startsWith("[")) {
176
177
  args = variant.slice(variant.lastIndexOf("[") + 1, -1);
@@ -182,6 +183,7 @@ function applyVariant(variant, matches, context) {
182
183
  if (!(0, _setupContextUtils).isValidVariantFormatString(selector)) {
183
184
  return [];
184
185
  }
186
+ isArbitraryVariant = true;
185
187
  let fn = (0, _setupContextUtils).parseVariant(selector);
186
188
  let sort = Array.from(context.variantOrder.values()).pop() << 1n;
187
189
  context.variantMap.set(variant, [
@@ -329,7 +331,8 @@ function applyVariant(variant, matches, context) {
329
331
  {
330
332
  ...meta,
331
333
  sort: variantSort | meta.sort,
332
- collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats)
334
+ collectedFormats: ((_collectedFormats = meta.collectedFormats) !== null && _collectedFormats !== void 0 ? _collectedFormats : []).concat(collectedFormats),
335
+ isArbitraryVariant
333
336
  },
334
337
  clone.nodes[0],
335
338
  ];
@@ -639,6 +642,7 @@ function* resolveMatches(candidate, context, original = candidate) {
639
642
  selector: rule.selector,
640
643
  candidate: original,
641
644
  base: candidate.split(new RegExp(`\\${(ref2 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref2 !== void 0 ? ref2 : ":"}(?![^[]*\\])`)).pop(),
645
+ isArbitraryVariant: match1[0].isArbitraryVariant,
642
646
  context
643
647
  });
644
648
  });
@@ -747,6 +747,12 @@ function registerPlugins(plugins, context) {
747
747
  ...classes.map((cls)=>cls.slice(0, prefixLength) + "-" + cls.slice(prefixLength)),
748
748
  ];
749
749
  }
750
+ if ([].concat(options === null || options === void 0 ? void 0 : options.type).includes("color")) {
751
+ classes = [
752
+ ...classes,
753
+ ...classes.flatMap((cls)=>Object.keys(context.tailwindConfig.theme.opacity).map((opacity)=>`${cls}/${opacity}`)),
754
+ ];
755
+ }
750
756
  return classes;
751
757
  })() : [
752
758
  util
@@ -39,7 +39,7 @@ function formatVariantSelector(current, ...others) {
39
39
  return current;
40
40
  }
41
41
  var ref1;
42
- function finalizeSelector(format, { selector: selector1 , candidate , context , // Split by the separator, but ignore the separator inside square brackets:
42
+ function finalizeSelector(format, { selector: selector1 , candidate , context , isArbitraryVariant , // Split by the separator, but ignore the separator inside square brackets:
43
43
  //
44
44
  // E.g.: dark:lg:hover:[paint-order:markers]
45
45
  // ┬ ┬ ┬ ┬
@@ -49,7 +49,8 @@ function finalizeSelector(format, { selector: selector1 , candidate , context ,
49
49
  base =candidate.split(new RegExp(`\\${(ref1 = context === null || context === void 0 ? void 0 : (ref = context.tailwindConfig) === null || ref === void 0 ? void 0 : ref.separator) !== null && ref1 !== void 0 ? ref1 : ":"}(?![^[]*\\])`)).pop() , }) {
50
50
  var ref2;
51
51
  let ast = (0, _postcssSelectorParser).default().astSync(selector1);
52
- if (context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) {
52
+ // We explicitly DO NOT prefix classes in arbitrary variants
53
+ if ((context === null || context === void 0 ? void 0 : (ref2 = context.tailwindConfig) === null || ref2 === void 0 ? void 0 : ref2.prefix) && !isArbitraryVariant) {
53
54
  format = (0, _prefixSelector).default(context.tailwindConfig.prefix, format);
54
55
  }
55
56
  format = format.replace(PARENT, `.${(0, _escapeClassName).default(candidate)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tailwindcss",
3
- "version": "3.1.4",
3
+ "version": "3.1.5",
4
4
  "description": "A utility-first CSS framework for rapidly building custom user interfaces.",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -47,12 +47,12 @@
47
47
  "@swc/jest": "^0.2.21",
48
48
  "@swc/register": "^0.1.10",
49
49
  "autoprefixer": "^10.4.7",
50
- "cssnano": "^5.1.11",
51
- "esbuild": "^0.14.43",
52
- "eslint": "^8.16.0",
50
+ "cssnano": "^5.1.12",
51
+ "esbuild": "^0.14.48",
52
+ "eslint": "^8.18.0",
53
53
  "eslint-config-prettier": "^8.5.0",
54
- "eslint-plugin-prettier": "^4.0.0",
55
- "jest": "^28.1.1",
54
+ "eslint-plugin-prettier": "^4.2.1",
55
+ "jest": "^28.1.2",
56
56
  "jest-diff": "^28.1.1",
57
57
  "prettier": "^2.7.1",
58
58
  "prettier-plugin-tailwindcss": "^0.1.11",
@@ -79,12 +79,12 @@
79
79
  "postcss": "^8.4.14",
80
80
  "postcss-import": "^14.1.0",
81
81
  "postcss-js": "^4.0.0",
82
- "postcss-load-config": "^3.1.4",
82
+ "postcss-load-config": "^4.0.1",
83
83
  "postcss-nested": "5.0.6",
84
84
  "postcss-selector-parser": "^6.0.10",
85
85
  "postcss-value-parser": "^4.2.0",
86
86
  "quick-lru": "^5.1.1",
87
- "resolve": "^1.22.0"
87
+ "resolve": "^1.22.1"
88
88
  },
89
89
  "browserslist": [
90
90
  "> 1%",
package/peers/index.js CHANGED
@@ -5978,6 +5978,7 @@ var require_core = __commonJS({
5978
5978
  "node:string_decoder": [">= 14.18 && < 15", ">= 16"],
5979
5979
  sys: [">= 0.4 && < 0.7", ">= 0.8"],
5980
5980
  "node:sys": [">= 14.18 && < 15", ">= 16"],
5981
+ "node:test": ">= 18",
5981
5982
  timers: true,
5982
5983
  "node:timers": [">= 14.18 && < 15", ">= 16"],
5983
5984
  "timers/promises": ">= 15",
@@ -6092,7 +6093,7 @@ var require_async = __commonJS({
6092
6093
  var nodeModulesPaths = require_node_modules_paths();
6093
6094
  var normalizeOptions = require_normalize_options();
6094
6095
  var isCore = require_is_core_module();
6095
- var realpathFS = fs.realpath && typeof fs.realpath.native === "function" ? fs.realpath.native : fs.realpath;
6096
+ var realpathFS = process.platform !== "win32" && fs.realpath && typeof fs.realpath.native === "function" ? fs.realpath.native : fs.realpath;
6096
6097
  var homedir = getHomedir();
6097
6098
  var defaultPaths = function() {
6098
6099
  return [
@@ -6525,6 +6526,7 @@ var require_core2 = __commonJS({
6525
6526
  "node:string_decoder": [">= 14.18 && < 15", ">= 16"],
6526
6527
  sys: [">= 0.4 && < 0.7", ">= 0.8"],
6527
6528
  "node:sys": [">= 14.18 && < 15", ">= 16"],
6529
+ "node:test": ">= 18",
6528
6530
  timers: true,
6529
6531
  "node:timers": [">= 14.18 && < 15", ">= 16"],
6530
6532
  "timers/promises": ">= 15",
@@ -6647,7 +6649,7 @@ var require_sync = __commonJS({
6647
6649
  var caller = require_caller();
6648
6650
  var nodeModulesPaths = require_node_modules_paths();
6649
6651
  var normalizeOptions = require_normalize_options();
6650
- var realpathFS = fs.realpathSync && typeof fs.realpathSync.native === "function" ? fs.realpathSync.native : fs.realpathSync;
6652
+ var realpathFS = process.platform !== "win32" && fs.realpathSync && typeof fs.realpathSync.native === "function" ? fs.realpathSync.native : fs.realpathSync;
6651
6653
  var homedir = getHomedir();
6652
6654
  var defaultPaths = function() {
6653
6655
  return [
@@ -73369,11 +73371,12 @@ var require_src11 = __commonJS({
73369
73371
  ...grid,
73370
73372
  ...columnRules
73371
73373
  ]);
73374
+ var variableFunctions = /* @__PURE__ */ new Set(["var", "env", "constant"]);
73372
73375
  function isVariableFunctionNode(node) {
73373
73376
  if (node.type !== "function") {
73374
73377
  return false;
73375
73378
  }
73376
- return ["var", "env", "constant"].includes(node.value.toLowerCase());
73379
+ return variableFunctions.has(node.value.toLowerCase());
73377
73380
  }
73378
73381
  function shouldAbort(parsed) {
73379
73382
  let abort = false;
@@ -75319,7 +75322,7 @@ var require_parseWsc = __commonJS({
75319
75322
  var { list } = require_postcss();
75320
75323
  var { isWidth, isStyle, isColor } = require_validateWsc();
75321
75324
  var none = /^\s*(none|medium)(\s+none(\s+(none|currentcolor))?)?\s*$/i;
75322
- var varRE = /--(\w|[^\x00-\x7F])+/g;
75325
+ var varRE = /--(\w|-|[^\x00-\x7F])+/g;
75323
75326
  var toLower = (v) => {
75324
75327
  let match;
75325
75328
  let lastIndex = 0;
@@ -76402,11 +76405,12 @@ var require_src21 = __commonJS({
76402
76405
  function isCommaNode(node) {
76403
76406
  return node.type === "div" && node.value === ",";
76404
76407
  }
76408
+ var variableFunctions = /* @__PURE__ */ new Set(["var", "env", "constant"]);
76405
76409
  function isVariableFunctionNode(node) {
76406
76410
  if (node.type !== "function") {
76407
76411
  return false;
76408
76412
  }
76409
- return ["var", "env"].includes(node.value.toLowerCase());
76413
+ return variableFunctions.has(node.value.toLowerCase());
76410
76414
  }
76411
76415
  function transform(value) {
76412
76416
  const parsed = valueParser(value);
@@ -77216,6 +77220,7 @@ var require_src26 = __commonJS({
77216
77220
  ["top", "0"]
77217
77221
  ]);
77218
77222
  var mathFunctions = /* @__PURE__ */ new Set(["calc", "min", "max", "clamp"]);
77223
+ var variableFunctions = /* @__PURE__ */ new Set(["var", "env", "constant"]);
77219
77224
  function isCommaNode(node) {
77220
77225
  return node.type === "div" && node.value === ",";
77221
77226
  }
@@ -77223,7 +77228,7 @@ var require_src26 = __commonJS({
77223
77228
  if (node.type !== "function") {
77224
77229
  return false;
77225
77230
  }
77226
- return ["var", "env"].includes(node.value.toLowerCase());
77231
+ return variableFunctions.has(node.value.toLowerCase());
77227
77232
  }
77228
77233
  function isMathFunctionNode(node) {
77229
77234
  if (node.type !== "function") {
@@ -1,8 +1,10 @@
1
1
  import prettier from 'prettier'
2
2
  import { corePlugins } from '../src/corePlugins'
3
3
  import colors from '../src/public/colors'
4
+ import defaultTheme from '../src/public/default-theme'
4
5
  import fs from 'fs'
5
6
  import path from 'path'
7
+ import * as types from './type-utils'
6
8
 
7
9
  fs.writeFileSync(
8
10
  path.join(process.cwd(), 'types', 'generated', 'corePluginList.d.ts'),
@@ -50,3 +52,54 @@ fs.writeFileSync(
50
52
  }
51
53
  )
52
54
  )
55
+
56
+ const defaultThemeTypes = Object.entries(defaultTheme)
57
+ .map(([name, value]) => {
58
+ // Special cases for slightly more accurate types
59
+ if (name === 'keyframes') {
60
+ return [name, `Record<${types.forKeys(value)}, Record<string, CSSDeclarationList>>`]
61
+ }
62
+
63
+ if (name === 'fontSize') {
64
+ return [name, `Record<${types.forKeys(value)}, [string, { lineHeight: string }]>`]
65
+ }
66
+
67
+ // General cases
68
+ if (typeof value === 'string') {
69
+ return [name, `string`]
70
+ }
71
+
72
+ if (typeof value === 'function') {
73
+ return [name, null]
74
+ }
75
+
76
+ if (typeof value === 'object') {
77
+ if (Object.keys(value).length === 0) {
78
+ return [name, null]
79
+ }
80
+
81
+ return [name, types.forValue(value)]
82
+ }
83
+
84
+ return [name, `unknown`]
85
+ })
86
+ .filter(([, type]) => type !== null)
87
+ .map(([name, type]) => `${name}: ${type}`)
88
+ .join('\n')
89
+
90
+ fs.writeFileSync(
91
+ path.join(process.cwd(), 'types', 'generated', 'default-theme.d.ts'),
92
+ prettier.format(
93
+ `
94
+ import { Config } from '../../types'
95
+ type CSSDeclarationList = Record<string, string>
96
+ export type DefaultTheme = Config['theme'] & { ${defaultThemeTypes} }
97
+ `,
98
+ {
99
+ semi: false,
100
+ singleQuote: true,
101
+ printWidth: 100,
102
+ parser: 'typescript',
103
+ }
104
+ )
105
+ )
@@ -0,0 +1,27 @@
1
+ export function union(types) {
2
+ return [...new Set(types)].join(' | ')
3
+ }
4
+
5
+ export function unionValues(values) {
6
+ return union(values.map(forValue))
7
+ }
8
+
9
+ export function forKeys(value) {
10
+ return union(Object.keys(value).map((key) => `'${key}'`))
11
+ }
12
+
13
+ export function forValue(value) {
14
+ if (Array.isArray(value)) {
15
+ return `(${unionValues(value)})[]`
16
+ }
17
+
18
+ if (typeof value === 'object') {
19
+ return `Record<${forKeys(value)}, ${unionValues(Object.values(value))}>`
20
+ }
21
+
22
+ if (typeof value === 'string') {
23
+ return `string`
24
+ }
25
+
26
+ return `any`
27
+ }
@@ -1613,7 +1613,7 @@ export let corePlugins = {
1613
1613
  {
1614
1614
  text: (value) => {
1615
1615
  let [fontSize, options] = Array.isArray(value) ? value : [value]
1616
- let { lineHeight, letterSpacing } = isPlainObject(options)
1616
+ let { lineHeight, letterSpacing, fontWeight } = isPlainObject(options)
1617
1617
  ? options
1618
1618
  : { lineHeight: options }
1619
1619
 
@@ -1621,6 +1621,7 @@ export let corePlugins = {
1621
1621
  'font-size': fontSize,
1622
1622
  ...(lineHeight === undefined ? {} : { 'line-height': lineHeight }),
1623
1623
  ...(letterSpacing === undefined ? {} : { 'letter-spacing': letterSpacing }),
1624
+ ...(fontWeight === undefined ? {} : { 'font-weight': fontWeight }),
1624
1625
  }
1625
1626
  },
1626
1627
  },
@@ -1,4 +1,4 @@
1
- import { flagEnabled } from '../featureFlags.js'
1
+ import { flagEnabled } from '../featureFlags'
2
2
  import * as regex from './regex'
3
3
 
4
4
  export function defaultExtractor(context) {
@@ -22,6 +22,10 @@ export function defaultExtractor(context) {
22
22
  function* buildRegExps(context) {
23
23
  let separator = context.tailwindConfig.separator
24
24
  let variantGroupingEnabled = flagEnabled(context.tailwindConfig, 'variantGrouping')
25
+ let prefix =
26
+ context.tailwindConfig.prefix !== ''
27
+ ? regex.optional(regex.pattern([/-?/, regex.escape(context.tailwindConfig.prefix)]))
28
+ : ''
25
29
 
26
30
  let utility = regex.any([
27
31
  // Arbitrary properties
@@ -88,6 +92,8 @@ function* buildRegExps(context) {
88
92
  // Important (optional)
89
93
  /!?/,
90
94
 
95
+ prefix,
96
+
91
97
  variantGroupingEnabled
92
98
  ? regex.any([
93
99
  // Or any of those things but grouped separated by commas
@@ -129,6 +129,7 @@ function applyVariant(variant, matches, context) {
129
129
  }
130
130
 
131
131
  let args
132
+ let isArbitraryVariant = false
132
133
 
133
134
  // Find partial arbitrary variants
134
135
  if (variant.endsWith(']') && !variant.startsWith('[')) {
@@ -144,6 +145,8 @@ function applyVariant(variant, matches, context) {
144
145
  return []
145
146
  }
146
147
 
148
+ isArbitraryVariant = true
149
+
147
150
  let fn = parseVariant(selector)
148
151
 
149
152
  let sort = Array.from(context.variantOrder.values()).pop() << 1n
@@ -300,6 +303,7 @@ function applyVariant(variant, matches, context) {
300
303
  ...meta,
301
304
  sort: variantSort | meta.sort,
302
305
  collectedFormats: (meta.collectedFormats ?? []).concat(collectedFormats),
306
+ isArbitraryVariant,
303
307
  },
304
308
  clone.nodes[0],
305
309
  ]
@@ -627,6 +631,7 @@ function* resolveMatches(candidate, context, original = candidate) {
627
631
  base: candidate
628
632
  .split(new RegExp(`\\${context?.tailwindConfig?.separator ?? ':'}(?![^[]*\\])`))
629
633
  .pop(),
634
+ isArbitraryVariant: match[0].isArbitraryVariant,
630
635
 
631
636
  context,
632
637
  })
@@ -762,6 +762,17 @@ function registerPlugins(plugins, context) {
762
762
  ]
763
763
  }
764
764
 
765
+ if ([].concat(options?.type).includes('color')) {
766
+ classes = [
767
+ ...classes,
768
+ ...classes.flatMap((cls) =>
769
+ Object.keys(context.tailwindConfig.theme.opacity).map(
770
+ (opacity) => `${cls}/${opacity}`
771
+ )
772
+ ),
773
+ ]
774
+ }
775
+
765
776
  return classes
766
777
  })()
767
778
  : [util]
@@ -35,6 +35,7 @@ export function finalizeSelector(
35
35
  selector,
36
36
  candidate,
37
37
  context,
38
+ isArbitraryVariant,
38
39
 
39
40
  // Split by the separator, but ignore the separator inside square brackets:
40
41
  //
@@ -50,7 +51,8 @@ export function finalizeSelector(
50
51
  ) {
51
52
  let ast = selectorParser().astSync(selector)
52
53
 
53
- if (context?.tailwindConfig?.prefix) {
54
+ // We explicitly DO NOT prefix classes in arbitrary variants
55
+ if (context?.tailwindConfig?.prefix && !isArbitraryVariant) {
54
56
  format = prefixSelector(context.tailwindConfig.prefix, format)
55
57
  }
56
58
 
package/types/config.d.ts CHANGED
@@ -12,6 +12,7 @@ interface RecursiveKeyValuePair<K extends keyof any = string, V = string> {
12
12
  [key: string]: V | RecursiveKeyValuePair<K, V>
13
13
  }
14
14
  type ResolvableTo<T> = T | ((utils: PluginUtils) => T)
15
+ type CSSRuleObject = RecursiveKeyValuePair<string, string | string[]>
15
16
 
16
17
  interface PluginUtils {
17
18
  colors: DefaultColors
@@ -163,6 +164,7 @@ interface ThemeConfig {
163
164
  configuration: Partial<{
164
165
  lineHeight: string
165
166
  letterSpacing: string
167
+ fontWeight: string | number
166
168
  }>
167
169
  ]
168
170
  >
@@ -242,7 +244,7 @@ type ValueType =
242
244
  export interface PluginAPI {
243
245
  // for registering new static utility styles
244
246
  addUtilities(
245
- utilities: RecursiveKeyValuePair | RecursiveKeyValuePair[],
247
+ utilities: CSSRuleObject | CSSRuleObject[],
246
248
  options?: Partial<{
247
249
  respectPrefix: boolean
248
250
  respectImportant: boolean
@@ -250,7 +252,7 @@ export interface PluginAPI {
250
252
  ): void
251
253
  // for registering new dynamic utility styles
252
254
  matchUtilities<T>(
253
- utilities: KeyValuePair<string, (value: T) => RecursiveKeyValuePair>,
255
+ utilities: KeyValuePair<string, (value: T) => CSSRuleObject>,
254
256
  options?: Partial<{
255
257
  respectPrefix: boolean
256
258
  respectImportant: boolean
@@ -261,7 +263,7 @@ export interface PluginAPI {
261
263
  ): void
262
264
  // for registering new static component styles
263
265
  addComponents(
264
- components: RecursiveKeyValuePair | RecursiveKeyValuePair[],
266
+ components: CSSRuleObject | CSSRuleObject[],
265
267
  options?: Partial<{
266
268
  respectPrefix: boolean
267
269
  respectImportant: boolean
@@ -269,7 +271,7 @@ export interface PluginAPI {
269
271
  ): void
270
272
  // for registering new dynamic component styles
271
273
  matchComponents<T>(
272
- components: KeyValuePair<string, (value: T) => RecursiveKeyValuePair>,
274
+ components: KeyValuePair<string, (value: T) => CSSRuleObject>,
273
275
  options?: Partial<{
274
276
  respectPrefix: boolean
275
277
  respectImportant: boolean
@@ -279,7 +281,7 @@ export interface PluginAPI {
279
281
  }>
280
282
  ): void
281
283
  // for registering new base styles
282
- addBase(base: RecursiveKeyValuePair | RecursiveKeyValuePair[]): void
284
+ addBase(base: CSSRuleObject | CSSRuleObject[]): void
283
285
  // for registering custom variants
284
286
  addVariant(name: string, definition: string | string[] | (() => string) | (() => string)[]): void
285
287
  // for looking up values in the user’s theme configuration
@@ -0,0 +1,331 @@
1
+ import { Config } from '../../types'
2
+ type CSSDeclarationList = Record<string, string>
3
+ export type DefaultTheme = Config['theme'] & {
4
+ screens: Record<'sm' | 'md' | 'lg' | 'xl' | '2xl', string>
5
+ columns: Record<
6
+ | '1'
7
+ | '2'
8
+ | '3'
9
+ | '4'
10
+ | '5'
11
+ | '6'
12
+ | '7'
13
+ | '8'
14
+ | '9'
15
+ | '10'
16
+ | '11'
17
+ | '12'
18
+ | 'auto'
19
+ | '3xs'
20
+ | '2xs'
21
+ | 'xs'
22
+ | 'sm'
23
+ | 'md'
24
+ | 'lg'
25
+ | 'xl'
26
+ | '2xl'
27
+ | '3xl'
28
+ | '4xl'
29
+ | '5xl'
30
+ | '6xl'
31
+ | '7xl',
32
+ string
33
+ >
34
+ spacing: Record<
35
+ | '0'
36
+ | '1'
37
+ | '2'
38
+ | '3'
39
+ | '4'
40
+ | '5'
41
+ | '6'
42
+ | '7'
43
+ | '8'
44
+ | '9'
45
+ | '10'
46
+ | '11'
47
+ | '12'
48
+ | '14'
49
+ | '16'
50
+ | '20'
51
+ | '24'
52
+ | '28'
53
+ | '32'
54
+ | '36'
55
+ | '40'
56
+ | '44'
57
+ | '48'
58
+ | '52'
59
+ | '56'
60
+ | '60'
61
+ | '64'
62
+ | '72'
63
+ | '80'
64
+ | '96'
65
+ | 'px'
66
+ | '0.5'
67
+ | '1.5'
68
+ | '2.5'
69
+ | '3.5',
70
+ string
71
+ >
72
+ animation: Record<'none' | 'spin' | 'ping' | 'pulse' | 'bounce', string>
73
+ aspectRatio: Record<'auto' | 'square' | 'video', string>
74
+ backgroundImage: Record<
75
+ | 'none'
76
+ | 'gradient-to-t'
77
+ | 'gradient-to-tr'
78
+ | 'gradient-to-r'
79
+ | 'gradient-to-br'
80
+ | 'gradient-to-b'
81
+ | 'gradient-to-bl'
82
+ | 'gradient-to-l'
83
+ | 'gradient-to-tl',
84
+ string
85
+ >
86
+ backgroundPosition: Record<
87
+ | 'bottom'
88
+ | 'center'
89
+ | 'left'
90
+ | 'left-bottom'
91
+ | 'left-top'
92
+ | 'right'
93
+ | 'right-bottom'
94
+ | 'right-top'
95
+ | 'top',
96
+ string
97
+ >
98
+ backgroundSize: Record<'auto' | 'cover' | 'contain', string>
99
+ blur: Record<'0' | 'none' | 'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | '3xl', string>
100
+ brightness: Record<
101
+ '0' | '50' | '75' | '90' | '95' | '100' | '105' | '110' | '125' | '150' | '200',
102
+ string
103
+ >
104
+ borderRadius: Record<
105
+ 'none' | 'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | 'full',
106
+ string
107
+ >
108
+ borderWidth: Record<'0' | '2' | '4' | '8' | 'DEFAULT', string>
109
+ boxShadow: Record<'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | 'inner' | 'none', string>
110
+ contrast: Record<'0' | '50' | '75' | '100' | '125' | '150' | '200', string>
111
+ content: Record<'none', string>
112
+ cursor: Record<
113
+ | 'auto'
114
+ | 'default'
115
+ | 'pointer'
116
+ | 'wait'
117
+ | 'text'
118
+ | 'move'
119
+ | 'help'
120
+ | 'not-allowed'
121
+ | 'none'
122
+ | 'context-menu'
123
+ | 'progress'
124
+ | 'cell'
125
+ | 'crosshair'
126
+ | 'vertical-text'
127
+ | 'alias'
128
+ | 'copy'
129
+ | 'no-drop'
130
+ | 'grab'
131
+ | 'grabbing'
132
+ | 'all-scroll'
133
+ | 'col-resize'
134
+ | 'row-resize'
135
+ | 'n-resize'
136
+ | 'e-resize'
137
+ | 's-resize'
138
+ | 'w-resize'
139
+ | 'ne-resize'
140
+ | 'nw-resize'
141
+ | 'se-resize'
142
+ | 'sw-resize'
143
+ | 'ew-resize'
144
+ | 'ns-resize'
145
+ | 'nesw-resize'
146
+ | 'nwse-resize'
147
+ | 'zoom-in'
148
+ | 'zoom-out',
149
+ string
150
+ >
151
+ dropShadow: Record<'sm' | 'DEFAULT' | 'md' | 'lg' | 'xl' | '2xl' | 'none', string | string[]>
152
+ grayscale: Record<'0' | 'DEFAULT', string>
153
+ hueRotate: Record<'0' | '15' | '30' | '60' | '90' | '180', string>
154
+ invert: Record<'0' | 'DEFAULT', string>
155
+ flex: Record<'1' | 'auto' | 'initial' | 'none', string>
156
+ flexGrow: Record<'0' | 'DEFAULT', string>
157
+ flexShrink: Record<'0' | 'DEFAULT', string>
158
+ fontFamily: Record<'sans' | 'serif' | 'mono', string[]>
159
+ fontSize: Record<
160
+ | 'xs'
161
+ | 'sm'
162
+ | 'base'
163
+ | 'lg'
164
+ | 'xl'
165
+ | '2xl'
166
+ | '3xl'
167
+ | '4xl'
168
+ | '5xl'
169
+ | '6xl'
170
+ | '7xl'
171
+ | '8xl'
172
+ | '9xl',
173
+ [string, { lineHeight: string }]
174
+ >
175
+ fontWeight: Record<
176
+ | 'thin'
177
+ | 'extralight'
178
+ | 'light'
179
+ | 'normal'
180
+ | 'medium'
181
+ | 'semibold'
182
+ | 'bold'
183
+ | 'extrabold'
184
+ | 'black',
185
+ string
186
+ >
187
+ gridAutoColumns: Record<'auto' | 'min' | 'max' | 'fr', string>
188
+ gridAutoRows: Record<'auto' | 'min' | 'max' | 'fr', string>
189
+ gridColumn: Record<
190
+ | 'auto'
191
+ | 'span-1'
192
+ | 'span-2'
193
+ | 'span-3'
194
+ | 'span-4'
195
+ | 'span-5'
196
+ | 'span-6'
197
+ | 'span-7'
198
+ | 'span-8'
199
+ | 'span-9'
200
+ | 'span-10'
201
+ | 'span-11'
202
+ | 'span-12'
203
+ | 'span-full',
204
+ string
205
+ >
206
+ gridColumnEnd: Record<
207
+ '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '13' | 'auto',
208
+ string
209
+ >
210
+ gridColumnStart: Record<
211
+ '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | '13' | 'auto',
212
+ string
213
+ >
214
+ gridRow: Record<
215
+ 'auto' | 'span-1' | 'span-2' | 'span-3' | 'span-4' | 'span-5' | 'span-6' | 'span-full',
216
+ string
217
+ >
218
+ gridRowStart: Record<'1' | '2' | '3' | '4' | '5' | '6' | '7' | 'auto', string>
219
+ gridRowEnd: Record<'1' | '2' | '3' | '4' | '5' | '6' | '7' | 'auto', string>
220
+ gridTemplateColumns: Record<
221
+ '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12' | 'none',
222
+ string
223
+ >
224
+ gridTemplateRows: Record<'1' | '2' | '3' | '4' | '5' | '6' | 'none', string>
225
+ keyframes: Record<'spin' | 'ping' | 'pulse' | 'bounce', Record<string, CSSDeclarationList>>
226
+ letterSpacing: Record<'tighter' | 'tight' | 'normal' | 'wide' | 'wider' | 'widest', string>
227
+ lineHeight: Record<
228
+ | '3'
229
+ | '4'
230
+ | '5'
231
+ | '6'
232
+ | '7'
233
+ | '8'
234
+ | '9'
235
+ | '10'
236
+ | 'none'
237
+ | 'tight'
238
+ | 'snug'
239
+ | 'normal'
240
+ | 'relaxed'
241
+ | 'loose',
242
+ string
243
+ >
244
+ listStyleType: Record<'none' | 'disc' | 'decimal', string>
245
+ minHeight: Record<'0' | 'full' | 'screen' | 'min' | 'max' | 'fit', string>
246
+ minWidth: Record<'0' | 'full' | 'min' | 'max' | 'fit', string>
247
+ objectPosition: Record<
248
+ | 'bottom'
249
+ | 'center'
250
+ | 'left'
251
+ | 'left-bottom'
252
+ | 'left-top'
253
+ | 'right'
254
+ | 'right-bottom'
255
+ | 'right-top'
256
+ | 'top',
257
+ string
258
+ >
259
+ opacity: Record<
260
+ | '0'
261
+ | '5'
262
+ | '10'
263
+ | '20'
264
+ | '25'
265
+ | '30'
266
+ | '40'
267
+ | '50'
268
+ | '60'
269
+ | '70'
270
+ | '75'
271
+ | '80'
272
+ | '90'
273
+ | '95'
274
+ | '100',
275
+ string
276
+ >
277
+ order: Record<
278
+ | '1'
279
+ | '2'
280
+ | '3'
281
+ | '4'
282
+ | '5'
283
+ | '6'
284
+ | '7'
285
+ | '8'
286
+ | '9'
287
+ | '10'
288
+ | '11'
289
+ | '12'
290
+ | 'first'
291
+ | 'last'
292
+ | 'none',
293
+ string
294
+ >
295
+ outlineOffset: Record<'0' | '1' | '2' | '4' | '8', string>
296
+ outlineWidth: Record<'0' | '1' | '2' | '4' | '8', string>
297
+ ringOffsetWidth: Record<'0' | '1' | '2' | '4' | '8', string>
298
+ ringWidth: Record<'0' | '1' | '2' | '4' | '8' | 'DEFAULT', string>
299
+ rotate: Record<'0' | '1' | '2' | '3' | '6' | '12' | '45' | '90' | '180', string>
300
+ saturate: Record<'0' | '50' | '100' | '150' | '200', string>
301
+ scale: Record<'0' | '50' | '75' | '90' | '95' | '100' | '105' | '110' | '125' | '150', string>
302
+ sepia: Record<'0' | 'DEFAULT', string>
303
+ skew: Record<'0' | '1' | '2' | '3' | '6' | '12', string>
304
+ strokeWidth: Record<'0' | '1' | '2', string>
305
+ textDecorationThickness: Record<'0' | '1' | '2' | '4' | '8' | 'auto' | 'from-font', string>
306
+ textUnderlineOffset: Record<'0' | '1' | '2' | '4' | '8' | 'auto', string>
307
+ transformOrigin: Record<
308
+ | 'center'
309
+ | 'top'
310
+ | 'top-right'
311
+ | 'right'
312
+ | 'bottom-right'
313
+ | 'bottom'
314
+ | 'bottom-left'
315
+ | 'left'
316
+ | 'top-left',
317
+ string
318
+ >
319
+ transitionDelay: Record<'75' | '100' | '150' | '200' | '300' | '500' | '700' | '1000', string>
320
+ transitionDuration: Record<
321
+ '75' | '100' | '150' | '200' | '300' | '500' | '700' | '1000' | 'DEFAULT',
322
+ string
323
+ >
324
+ transitionProperty: Record<
325
+ 'none' | 'all' | 'DEFAULT' | 'colors' | 'opacity' | 'shadow' | 'transform',
326
+ string
327
+ >
328
+ transitionTimingFunction: Record<'DEFAULT' | 'linear' | 'in' | 'out' | 'in-out', string>
329
+ willChange: Record<'auto' | 'scroll' | 'contents' | 'transform', string>
330
+ zIndex: Record<'0' | '10' | '20' | '30' | '40' | '50' | 'auto', string>
331
+ }