tailwindcss 0.0.0-insiders.4e21639 → 0.0.0-insiders.4e62334
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 +435 -3
- package/LICENSE +1 -2
- package/README.md +13 -6
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -1
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +460 -259
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +9 -3
- package/lib/corePlugins.js +1840 -1753
- package/lib/css/preflight.css +8 -9
- package/lib/featureFlags.js +29 -20
- package/lib/index.js +22 -11
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +27 -9
- package/lib/lib/collapseDuplicateDeclarations.js +58 -4
- package/lib/lib/defaultExtractor.js +231 -0
- package/lib/lib/detectNesting.js +13 -10
- package/lib/lib/evaluateTailwindFunctions.js +119 -52
- package/lib/lib/expandApplyAtRules.js +440 -161
- package/lib/lib/expandTailwindAtRules.js +130 -128
- package/lib/lib/generateRules.js +410 -171
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +43 -32
- package/lib/lib/offsets.js +199 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/resolveDefaultsAtRules.js +91 -55
- package/lib/lib/setupContextUtils.js +453 -347
- package/lib/lib/setupTrackingContext.js +52 -44
- package/lib/lib/sharedState.js +48 -9
- package/lib/lib/substituteScreenAtRules.js +13 -8
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +36 -25
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +16 -25
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +54 -40
- package/lib/util/configurePlugins.js +4 -1
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +119 -102
- package/lib/util/defaults.js +10 -1
- package/lib/util/escapeClassName.js +7 -4
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +223 -40
- package/lib/util/getAllConfigs.js +27 -8
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isValidArbitraryValue.js +72 -0
- package/lib/util/log.js +22 -12
- package/lib/util/nameClass.js +17 -8
- package/lib/util/negateValue.js +22 -7
- package/lib/util/normalizeConfig.js +99 -54
- package/lib/util/normalizeScreens.js +73 -0
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +30 -23
- package/lib/util/parseDependency.js +18 -15
- package/lib/util/parseObjectStyles.js +10 -7
- package/lib/util/pluginUtils.js +51 -42
- package/lib/util/prefixSelector.js +10 -8
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +91 -66
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +24 -3
- package/lib/util/transformThemeValue.js +37 -29
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +43 -43
- package/peers/index.js +11543 -8114
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +3 -0
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +105 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +293 -36
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +428 -285
- package/src/css/preflight.css +8 -9
- package/src/featureFlags.js +9 -5
- package/src/index.js +14 -6
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +66 -1
- package/src/lib/defaultExtractor.js +208 -0
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +488 -153
- package/src/lib/expandTailwindAtRules.js +82 -80
- package/src/lib/generateRules.js +352 -120
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/offsets.js +239 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +59 -17
- package/src/lib/setupContextUtils.js +337 -174
- package/src/lib/setupTrackingContext.js +13 -8
- package/src/lib/sharedState.js +42 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +12 -2
- package/src/util/buildMediaQuery.js +14 -18
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +31 -14
- package/src/util/dataTypes.js +28 -19
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +237 -23
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isValidArbitraryValue.js +61 -0
- package/src/util/log.js +11 -7
- package/src/util/nameClass.js +1 -1
- package/src/util/negateValue.js +10 -2
- package/src/util/normalizeConfig.js +16 -3
- package/src/util/normalizeScreens.js +45 -0
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/pluginUtils.js +14 -2
- package/src/util/prefixSelector.js +7 -5
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +71 -17
- package/src/util/splitAtTopLevelOnly.js +45 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +24 -3
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +334 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +331 -0
- package/types/index.d.ts +7 -0
- package/lib/lib/setupWatchingContext.js +0 -288
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -311
|
@@ -6,6 +6,11 @@ import colors from '../public/colors'
|
|
|
6
6
|
import { defaults } from './defaults'
|
|
7
7
|
import { toPath } from './toPath'
|
|
8
8
|
import { normalizeConfig } from './normalizeConfig'
|
|
9
|
+
import isPlainObject from './isPlainObject'
|
|
10
|
+
import { cloneDeep } from './cloneDeep'
|
|
11
|
+
import { parseColorFormat } from './pluginUtils'
|
|
12
|
+
import { withAlphaValue } from './withAlphaVariable'
|
|
13
|
+
import toColorValue from './toColorValue'
|
|
9
14
|
|
|
10
15
|
function isFunction(input) {
|
|
11
16
|
return typeof input === 'function'
|
|
@@ -24,7 +29,7 @@ function mergeWith(target, ...sources) {
|
|
|
24
29
|
|
|
25
30
|
if (merged === undefined) {
|
|
26
31
|
if (isObject(target[k]) && isObject(source[k])) {
|
|
27
|
-
target[k] = mergeWith(target[k], source[k], customizer)
|
|
32
|
+
target[k] = mergeWith({}, target[k], source[k], customizer)
|
|
28
33
|
} else {
|
|
29
34
|
target[k] = source[k]
|
|
30
35
|
}
|
|
@@ -132,32 +137,81 @@ function mergeExtensions({ extend, ...theme }) {
|
|
|
132
137
|
})
|
|
133
138
|
}
|
|
134
139
|
|
|
140
|
+
/**
|
|
141
|
+
*
|
|
142
|
+
* @param {string} key
|
|
143
|
+
* @return {Iterable<string[] & {alpha: string | undefined}>}
|
|
144
|
+
*/
|
|
145
|
+
function* toPaths(key) {
|
|
146
|
+
let path = toPath(key)
|
|
147
|
+
|
|
148
|
+
if (path.length === 0) {
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
yield path
|
|
153
|
+
|
|
154
|
+
if (Array.isArray(key)) {
|
|
155
|
+
return
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let pattern = /^(.*?)\s*\/\s*([^/]+)$/
|
|
159
|
+
let matches = key.match(pattern)
|
|
160
|
+
|
|
161
|
+
if (matches !== null) {
|
|
162
|
+
let [, prefix, alpha] = matches
|
|
163
|
+
|
|
164
|
+
let newPath = toPath(prefix)
|
|
165
|
+
newPath.alpha = alpha
|
|
166
|
+
|
|
167
|
+
yield newPath
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
135
171
|
function resolveFunctionKeys(object) {
|
|
172
|
+
// theme('colors.red.500 / 0.5') -> ['colors', 'red', '500 / 0', '5]
|
|
173
|
+
|
|
136
174
|
const resolvePath = (key, defaultValue) => {
|
|
137
|
-
const path
|
|
175
|
+
for (const path of toPaths(key)) {
|
|
176
|
+
let index = 0
|
|
177
|
+
let val = object
|
|
138
178
|
|
|
139
|
-
|
|
140
|
-
|
|
179
|
+
while (val !== undefined && val !== null && index < path.length) {
|
|
180
|
+
val = val[path[index++]]
|
|
141
181
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
val = isFunction(val) ? val(resolvePath, configUtils) : val
|
|
145
|
-
}
|
|
182
|
+
let shouldResolveAsFn =
|
|
183
|
+
isFunction(val) && (path.alpha === undefined || index <= path.length - 1)
|
|
146
184
|
|
|
147
|
-
|
|
148
|
-
|
|
185
|
+
val = shouldResolveAsFn ? val(resolvePath, configUtils) : val
|
|
186
|
+
}
|
|
149
187
|
|
|
150
|
-
|
|
188
|
+
if (val !== undefined) {
|
|
189
|
+
if (path.alpha !== undefined) {
|
|
190
|
+
let normalized = parseColorFormat(val)
|
|
191
|
+
|
|
192
|
+
return withAlphaValue(normalized, path.alpha, toColorValue(normalized))
|
|
193
|
+
}
|
|
151
194
|
|
|
152
|
-
|
|
153
|
-
|
|
195
|
+
if (isPlainObject(val)) {
|
|
196
|
+
return cloneDeep(val)
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return val
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return defaultValue
|
|
154
204
|
}
|
|
155
205
|
|
|
206
|
+
Object.assign(resolvePath, {
|
|
207
|
+
theme: resolvePath,
|
|
208
|
+
...configUtils,
|
|
209
|
+
})
|
|
210
|
+
|
|
156
211
|
return Object.keys(object).reduce((resolved, key) => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
212
|
+
resolved[key] = isFunction(object[key]) ? object[key](resolvePath, configUtils) : object[key]
|
|
213
|
+
|
|
214
|
+
return resolved
|
|
161
215
|
}, {})
|
|
162
216
|
}
|
|
163
217
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This splits a string on a top-level character.
|
|
3
|
+
*
|
|
4
|
+
* Regex doesn't support recursion (at least not the JS-flavored version).
|
|
5
|
+
* So we have to use a tiny state machine to keep track of paren placement.
|
|
6
|
+
*
|
|
7
|
+
* Expected behavior using commas:
|
|
8
|
+
* var(--a, 0 0 1px rgb(0, 0, 0)), 0 0 1px rgb(0, 0, 0)
|
|
9
|
+
* ─┬─ ┬ ┬ ┬
|
|
10
|
+
* x x x ╰──────── Split because top-level
|
|
11
|
+
* ╰──────────────┴──┴───────────── Ignored b/c inside >= 1 levels of parens
|
|
12
|
+
*
|
|
13
|
+
* @param {string} input
|
|
14
|
+
* @param {string} separator
|
|
15
|
+
*/
|
|
16
|
+
export function splitAtTopLevelOnly(input, separator) {
|
|
17
|
+
let stack = []
|
|
18
|
+
let parts = []
|
|
19
|
+
let lastPos = 0
|
|
20
|
+
|
|
21
|
+
for (let idx = 0; idx < input.length; idx++) {
|
|
22
|
+
let char = input[idx]
|
|
23
|
+
|
|
24
|
+
if (stack.length === 0 && char === separator[0]) {
|
|
25
|
+
if (separator.length === 1 || input.slice(idx, idx + separator.length) === separator) {
|
|
26
|
+
parts.push(input.slice(lastPos, idx))
|
|
27
|
+
lastPos = idx + separator.length
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (char === '(' || char === '[' || char === '{') {
|
|
32
|
+
stack.push(char)
|
|
33
|
+
} else if (
|
|
34
|
+
(char === ')' && stack[stack.length - 1] === '(') ||
|
|
35
|
+
(char === ']' && stack[stack.length - 1] === '[') ||
|
|
36
|
+
(char === '}' && stack[stack.length - 1] === '{')
|
|
37
|
+
) {
|
|
38
|
+
stack.pop()
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
parts.push(input.slice(lastPos))
|
|
43
|
+
|
|
44
|
+
return parts
|
|
45
|
+
}
|
package/src/util/toPath.js
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a path string into an array of path segments.
|
|
3
|
+
*
|
|
4
|
+
* Square bracket notation `a[b]` may be used to "escape" dots that would otherwise be interpreted as path separators.
|
|
5
|
+
*
|
|
6
|
+
* Example:
|
|
7
|
+
* a -> ['a']
|
|
8
|
+
* a.b.c -> ['a', 'b', 'c']
|
|
9
|
+
* a[b].c -> ['a', 'b', 'c']
|
|
10
|
+
* a[b.c].e.f -> ['a', 'b.c', 'e', 'f']
|
|
11
|
+
* a[b][c][d] -> ['a', 'b', 'c', 'd']
|
|
12
|
+
*
|
|
13
|
+
* @param {string|string[]} path
|
|
14
|
+
**/
|
|
1
15
|
export function toPath(path) {
|
|
2
16
|
if (Array.isArray(path)) return path
|
|
3
|
-
|
|
17
|
+
|
|
18
|
+
let openBrackets = path.split('[').length - 1
|
|
19
|
+
let closedBrackets = path.split(']').length - 1
|
|
20
|
+
|
|
21
|
+
if (openBrackets !== closedBrackets) {
|
|
22
|
+
throw new Error(`Path is invalid. Has unbalanced brackets: ${path}`)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return path.split(/\.(?![^\[]*\])|[\[\]]/g).filter(Boolean)
|
|
4
26
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import postcss from 'postcss'
|
|
2
|
+
import isPlainObject from './isPlainObject'
|
|
2
3
|
|
|
3
4
|
export default function transformThemeValue(themeSection) {
|
|
4
5
|
if (['fontSize', 'outline'].includes(themeSection)) {
|
|
@@ -10,9 +11,16 @@ export default function transformThemeValue(themeSection) {
|
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
if (themeSection === 'fontFamily') {
|
|
15
|
+
return (value) => {
|
|
16
|
+
if (typeof value === 'function') value = value({})
|
|
17
|
+
let families = Array.isArray(value) && isPlainObject(value[1]) ? value[0] : value
|
|
18
|
+
return Array.isArray(families) ? families.join(', ') : families
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
if (
|
|
14
23
|
[
|
|
15
|
-
'fontFamily',
|
|
16
24
|
'boxShadow',
|
|
17
25
|
'transitionProperty',
|
|
18
26
|
'transitionDuration',
|
|
@@ -44,8 +52,10 @@ export default function transformThemeValue(themeSection) {
|
|
|
44
52
|
}
|
|
45
53
|
}
|
|
46
54
|
|
|
47
|
-
return (value) => {
|
|
48
|
-
if (typeof value === 'function')
|
|
55
|
+
return (value, opts = {}) => {
|
|
56
|
+
if (typeof value === 'function') {
|
|
57
|
+
value = value(opts)
|
|
58
|
+
}
|
|
49
59
|
|
|
50
60
|
return value
|
|
51
61
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import log from './log'
|
|
2
|
+
|
|
3
|
+
export function validateConfig(config) {
|
|
4
|
+
if (config.content.files.length === 0) {
|
|
5
|
+
log.warn('content-problems', [
|
|
6
|
+
'The `content` option in your Tailwind CSS configuration is missing or empty.',
|
|
7
|
+
'Configure your content sources or your generated CSS will be missing styles.',
|
|
8
|
+
'https://tailwindcss.com/docs/content-configuration',
|
|
9
|
+
])
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return config
|
|
13
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
1
2
|
module.exports = {
|
|
2
3
|
content: [],
|
|
3
4
|
presets: [],
|
|
@@ -194,6 +195,9 @@ module.exports = {
|
|
|
194
195
|
'3xl': '1.5rem',
|
|
195
196
|
full: '9999px',
|
|
196
197
|
},
|
|
198
|
+
borderSpacing: ({ theme }) => ({
|
|
199
|
+
...theme('spacing'),
|
|
200
|
+
}),
|
|
197
201
|
borderWidth: {
|
|
198
202
|
DEFAULT: '1px',
|
|
199
203
|
0: '0px',
|
|
@@ -717,7 +721,7 @@ module.exports = {
|
|
|
717
721
|
8: '8px',
|
|
718
722
|
},
|
|
719
723
|
ringColor: ({ theme }) => ({
|
|
720
|
-
DEFAULT: theme(
|
|
724
|
+
DEFAULT: theme(`colors.blue.500`, '#3b82f6'),
|
|
721
725
|
...theme('colors'),
|
|
722
726
|
}),
|
|
723
727
|
ringOffsetColor: ({ theme }) => theme('colors'),
|
|
@@ -797,6 +801,23 @@ module.exports = {
|
|
|
797
801
|
},
|
|
798
802
|
textColor: ({ theme }) => theme('colors'),
|
|
799
803
|
textDecorationColor: ({ theme }) => theme('colors'),
|
|
804
|
+
textDecorationThickness: {
|
|
805
|
+
auto: 'auto',
|
|
806
|
+
'from-font': 'from-font',
|
|
807
|
+
0: '0px',
|
|
808
|
+
1: '1px',
|
|
809
|
+
2: '2px',
|
|
810
|
+
4: '4px',
|
|
811
|
+
8: '8px',
|
|
812
|
+
},
|
|
813
|
+
textUnderlineOffset: {
|
|
814
|
+
auto: 'auto',
|
|
815
|
+
0: '0px',
|
|
816
|
+
1: '1px',
|
|
817
|
+
2: '2px',
|
|
818
|
+
4: '4px',
|
|
819
|
+
8: '8px',
|
|
820
|
+
},
|
|
800
821
|
textIndent: ({ theme }) => ({
|
|
801
822
|
...theme('spacing'),
|
|
802
823
|
}),
|
|
@@ -837,8 +858,8 @@ module.exports = {
|
|
|
837
858
|
none: 'none',
|
|
838
859
|
all: 'all',
|
|
839
860
|
DEFAULT:
|
|
840
|
-
'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
|
|
841
|
-
colors: 'background-color, border-color, color, fill, stroke',
|
|
861
|
+
'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
|
|
862
|
+
colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
|
|
842
863
|
opacity: 'opacity',
|
|
843
864
|
shadow: 'box-shadow',
|
|
844
865
|
transform: 'transform',
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import type { CorePluginList } from './generated/corePluginList'
|
|
2
|
+
import type { DefaultColors } from './generated/colors'
|
|
3
|
+
|
|
4
|
+
// Helpers
|
|
5
|
+
type Expand<T> = T extends object
|
|
6
|
+
? T extends infer O
|
|
7
|
+
? { [K in keyof O]: Expand<O[K]> }
|
|
8
|
+
: never
|
|
9
|
+
: T
|
|
10
|
+
type KeyValuePair<K extends keyof any = string, V = string> = Record<K, V>
|
|
11
|
+
interface RecursiveKeyValuePair<K extends keyof any = string, V = string> {
|
|
12
|
+
[key: string]: V | RecursiveKeyValuePair<K, V>
|
|
13
|
+
}
|
|
14
|
+
type ResolvableTo<T> = T | ((utils: PluginUtils) => T)
|
|
15
|
+
type CSSRuleObject = RecursiveKeyValuePair<string, string | string[]>
|
|
16
|
+
|
|
17
|
+
interface PluginUtils {
|
|
18
|
+
colors: DefaultColors
|
|
19
|
+
theme(path: string, defaultValue?: unknown): any
|
|
20
|
+
breakpoints<I = Record<string, unknown>, O = I>(arg: I): O
|
|
21
|
+
rgb(arg: string): (arg: Partial<{ opacityVariable: string; opacityValue: number }>) => string
|
|
22
|
+
hsl(arg: string): (arg: Partial<{ opacityVariable: string; opacityValue: number }>) => string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Content related config
|
|
26
|
+
type FilePath = string
|
|
27
|
+
type RawFile = { raw: string; extension?: string }
|
|
28
|
+
type ExtractorFn = (content: string) => string[]
|
|
29
|
+
type TransformerFn = (content: string) => string
|
|
30
|
+
type ContentConfig =
|
|
31
|
+
| (FilePath | RawFile)[]
|
|
32
|
+
| {
|
|
33
|
+
files: (FilePath | RawFile)[]
|
|
34
|
+
extract?: ExtractorFn | { [extension: string]: ExtractorFn }
|
|
35
|
+
transform?: TransformerFn | { [extension: string]: TransformerFn }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Important related config
|
|
39
|
+
type ImportantConfig = boolean | string
|
|
40
|
+
|
|
41
|
+
// Prefix related config
|
|
42
|
+
type PrefixConfig = string
|
|
43
|
+
|
|
44
|
+
// Separator related config
|
|
45
|
+
type SeparatorConfig = string
|
|
46
|
+
|
|
47
|
+
// Safelist related config
|
|
48
|
+
type SafelistConfig =
|
|
49
|
+
| string[]
|
|
50
|
+
| {
|
|
51
|
+
pattern: RegExp
|
|
52
|
+
variants?: string[]
|
|
53
|
+
}[]
|
|
54
|
+
|
|
55
|
+
// Presets related config
|
|
56
|
+
type PresetsConfig = Config[]
|
|
57
|
+
|
|
58
|
+
// Future related config
|
|
59
|
+
type FutureConfigValues = never // Replace with 'future-feature-1' | 'future-feature-2'
|
|
60
|
+
type FutureConfig = Expand<'all' | Partial<Record<FutureConfigValues, boolean>>> | []
|
|
61
|
+
|
|
62
|
+
// Experimental related config
|
|
63
|
+
type ExperimentalConfigValues = 'optimizeUniversalDefaults' // Replace with 'experimental-feature-1' | 'experimental-feature-2'
|
|
64
|
+
type ExperimentalConfig = Expand<'all' | Partial<Record<ExperimentalConfigValues, boolean>>> | []
|
|
65
|
+
|
|
66
|
+
// DarkMode related config
|
|
67
|
+
type DarkModeConfig =
|
|
68
|
+
// Use the `media` query strategy.
|
|
69
|
+
| 'media'
|
|
70
|
+
// Use the `class` stategy, which requires a `.dark` class on the `html`.
|
|
71
|
+
| 'class'
|
|
72
|
+
// Use the `class` stategy with a custom class instead of `.dark`.
|
|
73
|
+
| ['class', string]
|
|
74
|
+
|
|
75
|
+
type Screen = { raw: string } | { min: string } | { max: string } | { min: string; max: string }
|
|
76
|
+
type ScreensConfig = string[] | KeyValuePair<string, string | Screen | Screen[]>
|
|
77
|
+
|
|
78
|
+
// Theme related config
|
|
79
|
+
interface ThemeConfig {
|
|
80
|
+
// Responsiveness
|
|
81
|
+
screens: ResolvableTo<ScreensConfig>
|
|
82
|
+
|
|
83
|
+
// Reusable base configs
|
|
84
|
+
colors: ResolvableTo<RecursiveKeyValuePair>
|
|
85
|
+
spacing: ResolvableTo<KeyValuePair>
|
|
86
|
+
|
|
87
|
+
// Components
|
|
88
|
+
container: ResolvableTo<
|
|
89
|
+
Partial<{
|
|
90
|
+
screens: ScreensConfig
|
|
91
|
+
center: boolean
|
|
92
|
+
padding: string | Record<string, string>
|
|
93
|
+
}>
|
|
94
|
+
>
|
|
95
|
+
|
|
96
|
+
// Utilities
|
|
97
|
+
inset: ThemeConfig['spacing']
|
|
98
|
+
zIndex: ResolvableTo<KeyValuePair>
|
|
99
|
+
order: ResolvableTo<KeyValuePair>
|
|
100
|
+
gridColumn: ResolvableTo<KeyValuePair>
|
|
101
|
+
gridColumnStart: ResolvableTo<KeyValuePair>
|
|
102
|
+
gridColumnEnd: ResolvableTo<KeyValuePair>
|
|
103
|
+
gridRow: ResolvableTo<KeyValuePair>
|
|
104
|
+
gridRowStart: ResolvableTo<KeyValuePair>
|
|
105
|
+
gridRowEnd: ResolvableTo<KeyValuePair>
|
|
106
|
+
margin: ThemeConfig['spacing']
|
|
107
|
+
aspectRatio: ResolvableTo<KeyValuePair>
|
|
108
|
+
height: ThemeConfig['spacing']
|
|
109
|
+
maxHeight: ThemeConfig['spacing']
|
|
110
|
+
minHeight: ResolvableTo<KeyValuePair>
|
|
111
|
+
width: ThemeConfig['spacing']
|
|
112
|
+
maxWidth: ResolvableTo<KeyValuePair>
|
|
113
|
+
minWidth: ResolvableTo<KeyValuePair>
|
|
114
|
+
flex: ResolvableTo<KeyValuePair>
|
|
115
|
+
flexShrink: ResolvableTo<KeyValuePair>
|
|
116
|
+
flexGrow: ResolvableTo<KeyValuePair>
|
|
117
|
+
flexBasis: ThemeConfig['spacing']
|
|
118
|
+
borderSpacing: ThemeConfig['spacing']
|
|
119
|
+
transformOrigin: ResolvableTo<KeyValuePair>
|
|
120
|
+
translate: ThemeConfig['spacing']
|
|
121
|
+
rotate: ResolvableTo<KeyValuePair>
|
|
122
|
+
skew: ResolvableTo<KeyValuePair>
|
|
123
|
+
scale: ResolvableTo<KeyValuePair>
|
|
124
|
+
animation: ResolvableTo<KeyValuePair>
|
|
125
|
+
keyframes: ResolvableTo<KeyValuePair<string, KeyValuePair<string, KeyValuePair>>>
|
|
126
|
+
cursor: ResolvableTo<KeyValuePair>
|
|
127
|
+
scrollMargin: ThemeConfig['spacing']
|
|
128
|
+
scrollPadding: ThemeConfig['spacing']
|
|
129
|
+
listStyleType: ResolvableTo<KeyValuePair>
|
|
130
|
+
columns: ResolvableTo<KeyValuePair>
|
|
131
|
+
gridAutoColumns: ResolvableTo<KeyValuePair>
|
|
132
|
+
gridAutoRows: ResolvableTo<KeyValuePair>
|
|
133
|
+
gridTemplateColumns: ResolvableTo<KeyValuePair>
|
|
134
|
+
gridTemplateRows: ResolvableTo<KeyValuePair>
|
|
135
|
+
gap: ThemeConfig['spacing']
|
|
136
|
+
space: ThemeConfig['spacing']
|
|
137
|
+
divideWidth: ThemeConfig['borderWidth']
|
|
138
|
+
divideColor: ThemeConfig['borderColor']
|
|
139
|
+
divideOpacity: ThemeConfig['borderOpacity']
|
|
140
|
+
borderRadius: ResolvableTo<KeyValuePair>
|
|
141
|
+
borderWidth: ResolvableTo<KeyValuePair>
|
|
142
|
+
borderColor: ThemeConfig['colors']
|
|
143
|
+
borderOpacity: ThemeConfig['opacity']
|
|
144
|
+
backgroundColor: ThemeConfig['colors']
|
|
145
|
+
backgroundOpacity: ThemeConfig['opacity']
|
|
146
|
+
backgroundImage: ResolvableTo<KeyValuePair>
|
|
147
|
+
gradientColorStops: ThemeConfig['colors']
|
|
148
|
+
backgroundSize: ResolvableTo<KeyValuePair>
|
|
149
|
+
backgroundPosition: ResolvableTo<KeyValuePair>
|
|
150
|
+
fill: ThemeConfig['colors']
|
|
151
|
+
stroke: ThemeConfig['colors']
|
|
152
|
+
strokeWidth: ResolvableTo<KeyValuePair>
|
|
153
|
+
objectPosition: ResolvableTo<KeyValuePair>
|
|
154
|
+
padding: ThemeConfig['spacing']
|
|
155
|
+
textIndent: ThemeConfig['spacing']
|
|
156
|
+
fontFamily: ResolvableTo<
|
|
157
|
+
KeyValuePair<
|
|
158
|
+
string,
|
|
159
|
+
| string
|
|
160
|
+
| string[]
|
|
161
|
+
| [fontFamily: string | string[], configuration: Partial<{ fontFeatureSettings: string }>]
|
|
162
|
+
>
|
|
163
|
+
>
|
|
164
|
+
fontSize: ResolvableTo<
|
|
165
|
+
KeyValuePair<
|
|
166
|
+
string,
|
|
167
|
+
| string
|
|
168
|
+
| [fontSize: string, lineHeight: string]
|
|
169
|
+
| [
|
|
170
|
+
fontSize: string,
|
|
171
|
+
configuration: Partial<{
|
|
172
|
+
lineHeight: string
|
|
173
|
+
letterSpacing: string
|
|
174
|
+
fontWeight: string | number
|
|
175
|
+
}>
|
|
176
|
+
]
|
|
177
|
+
>
|
|
178
|
+
>
|
|
179
|
+
fontWeight: ResolvableTo<KeyValuePair>
|
|
180
|
+
lineHeight: ResolvableTo<KeyValuePair>
|
|
181
|
+
letterSpacing: ResolvableTo<KeyValuePair>
|
|
182
|
+
textColor: ThemeConfig['colors']
|
|
183
|
+
textOpacity: ThemeConfig['opacity']
|
|
184
|
+
textDecorationColor: ThemeConfig['colors']
|
|
185
|
+
textDecorationThickness: ResolvableTo<KeyValuePair>
|
|
186
|
+
textUnderlineOffset: ResolvableTo<KeyValuePair>
|
|
187
|
+
placeholderColor: ThemeConfig['colors']
|
|
188
|
+
placeholderOpacity: ThemeConfig['opacity']
|
|
189
|
+
caretColor: ThemeConfig['colors']
|
|
190
|
+
accentColor: ThemeConfig['colors']
|
|
191
|
+
opacity: ResolvableTo<KeyValuePair>
|
|
192
|
+
boxShadow: ResolvableTo<KeyValuePair>
|
|
193
|
+
boxShadowColor: ThemeConfig['colors']
|
|
194
|
+
outlineWidth: ResolvableTo<KeyValuePair>
|
|
195
|
+
outlineOffset: ResolvableTo<KeyValuePair>
|
|
196
|
+
outlineColor: ThemeConfig['colors']
|
|
197
|
+
ringWidth: ResolvableTo<KeyValuePair>
|
|
198
|
+
ringColor: ThemeConfig['colors']
|
|
199
|
+
ringOpacity: ThemeConfig['opacity']
|
|
200
|
+
ringOffsetWidth: ResolvableTo<KeyValuePair>
|
|
201
|
+
ringOffsetColor: ThemeConfig['colors']
|
|
202
|
+
blur: ResolvableTo<KeyValuePair>
|
|
203
|
+
brightness: ResolvableTo<KeyValuePair>
|
|
204
|
+
contrast: ResolvableTo<KeyValuePair>
|
|
205
|
+
dropShadow: ResolvableTo<KeyValuePair>
|
|
206
|
+
grayscale: ResolvableTo<KeyValuePair>
|
|
207
|
+
hueRotate: ResolvableTo<KeyValuePair>
|
|
208
|
+
invert: ResolvableTo<KeyValuePair>
|
|
209
|
+
saturate: ResolvableTo<KeyValuePair>
|
|
210
|
+
sepia: ResolvableTo<KeyValuePair>
|
|
211
|
+
backdropBlur: ThemeConfig['blur']
|
|
212
|
+
backdropBrightness: ThemeConfig['brightness']
|
|
213
|
+
backdropContrast: ThemeConfig['contrast']
|
|
214
|
+
backdropGrayscale: ThemeConfig['grayscale']
|
|
215
|
+
backdropHueRotate: ThemeConfig['hueRotate']
|
|
216
|
+
backdropInvert: ThemeConfig['invert']
|
|
217
|
+
backdropOpacity: ThemeConfig['opacity']
|
|
218
|
+
backdropSaturate: ThemeConfig['saturate']
|
|
219
|
+
backdropSepia: ThemeConfig['sepia']
|
|
220
|
+
transitionProperty: ResolvableTo<KeyValuePair>
|
|
221
|
+
transitionTimingFunction: ResolvableTo<KeyValuePair>
|
|
222
|
+
transitionDelay: ResolvableTo<KeyValuePair>
|
|
223
|
+
transitionDuration: ResolvableTo<KeyValuePair>
|
|
224
|
+
willChange: ResolvableTo<KeyValuePair>
|
|
225
|
+
content: ResolvableTo<KeyValuePair>
|
|
226
|
+
|
|
227
|
+
// Custom
|
|
228
|
+
[key: string]: any
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// Core plugins related config
|
|
232
|
+
type CorePluginsConfig = CorePluginList[] | Expand<Partial<Record<CorePluginList, boolean>>>
|
|
233
|
+
|
|
234
|
+
// Plugins related config
|
|
235
|
+
type ValueType =
|
|
236
|
+
| 'any'
|
|
237
|
+
| 'color'
|
|
238
|
+
| 'url'
|
|
239
|
+
| 'image'
|
|
240
|
+
| 'length'
|
|
241
|
+
| 'percentage'
|
|
242
|
+
| 'position'
|
|
243
|
+
| 'lookup'
|
|
244
|
+
| 'generic-name'
|
|
245
|
+
| 'family-name'
|
|
246
|
+
| 'number'
|
|
247
|
+
| 'line-width'
|
|
248
|
+
| 'absolute-size'
|
|
249
|
+
| 'relative-size'
|
|
250
|
+
| 'shadow'
|
|
251
|
+
export interface PluginAPI {
|
|
252
|
+
// for registering new static utility styles
|
|
253
|
+
addUtilities(
|
|
254
|
+
utilities: CSSRuleObject | CSSRuleObject[],
|
|
255
|
+
options?: Partial<{
|
|
256
|
+
respectPrefix: boolean
|
|
257
|
+
respectImportant: boolean
|
|
258
|
+
}>
|
|
259
|
+
): void
|
|
260
|
+
// for registering new dynamic utility styles
|
|
261
|
+
matchUtilities<T>(
|
|
262
|
+
utilities: KeyValuePair<string, (value: T) => CSSRuleObject>,
|
|
263
|
+
options?: Partial<{
|
|
264
|
+
respectPrefix: boolean
|
|
265
|
+
respectImportant: boolean
|
|
266
|
+
type: ValueType | ValueType[]
|
|
267
|
+
values: KeyValuePair<string, T>
|
|
268
|
+
supportsNegativeValues: boolean
|
|
269
|
+
}>
|
|
270
|
+
): void
|
|
271
|
+
// for registering new static component styles
|
|
272
|
+
addComponents(
|
|
273
|
+
components: CSSRuleObject | CSSRuleObject[],
|
|
274
|
+
options?: Partial<{
|
|
275
|
+
respectPrefix: boolean
|
|
276
|
+
respectImportant: boolean
|
|
277
|
+
}>
|
|
278
|
+
): void
|
|
279
|
+
// for registering new dynamic component styles
|
|
280
|
+
matchComponents<T>(
|
|
281
|
+
components: KeyValuePair<string, (value: T) => CSSRuleObject>,
|
|
282
|
+
options?: Partial<{
|
|
283
|
+
respectPrefix: boolean
|
|
284
|
+
respectImportant: boolean
|
|
285
|
+
type: ValueType | ValueType[]
|
|
286
|
+
values: KeyValuePair<string, T>
|
|
287
|
+
supportsNegativeValues: boolean
|
|
288
|
+
}>
|
|
289
|
+
): void
|
|
290
|
+
// for registering new base styles
|
|
291
|
+
addBase(base: CSSRuleObject | CSSRuleObject[]): void
|
|
292
|
+
// for registering custom variants
|
|
293
|
+
addVariant(name: string, definition: string | string[] | (() => string) | (() => string)[]): void
|
|
294
|
+
// for looking up values in the user’s theme configuration
|
|
295
|
+
theme: <TDefaultValue = Config['theme']>(
|
|
296
|
+
path?: string,
|
|
297
|
+
defaultValue?: TDefaultValue
|
|
298
|
+
) => TDefaultValue
|
|
299
|
+
// for looking up values in the user’s Tailwind configuration
|
|
300
|
+
config: <TDefaultValue = Config>(path?: string, defaultValue?: TDefaultValue) => TDefaultValue
|
|
301
|
+
// for checking if a core plugin is enabled
|
|
302
|
+
corePlugins(path: string): boolean
|
|
303
|
+
// for manually escaping strings meant to be used in class names
|
|
304
|
+
e: (className: string) => string
|
|
305
|
+
}
|
|
306
|
+
export type PluginCreator = (api: PluginAPI) => void
|
|
307
|
+
export type PluginsConfig = (
|
|
308
|
+
| PluginCreator
|
|
309
|
+
| { handler: PluginCreator; config?: Config }
|
|
310
|
+
| { (options: any): { handler: PluginCreator; config?: Config }; __isOptionsFunction: true }
|
|
311
|
+
)[]
|
|
312
|
+
|
|
313
|
+
// Top level config related
|
|
314
|
+
interface RequiredConfig {
|
|
315
|
+
content: ContentConfig
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
interface OptionalConfig {
|
|
319
|
+
important: Partial<ImportantConfig>
|
|
320
|
+
prefix: Partial<PrefixConfig>
|
|
321
|
+
separator: Partial<SeparatorConfig>
|
|
322
|
+
safelist: Partial<SafelistConfig>
|
|
323
|
+
presets: Partial<PresetsConfig>
|
|
324
|
+
future: Partial<FutureConfig>
|
|
325
|
+
experimental: Partial<ExperimentalConfig>
|
|
326
|
+
darkMode: Partial<DarkModeConfig>
|
|
327
|
+
theme: Partial<ThemeConfig & { extend: Partial<ThemeConfig> }>
|
|
328
|
+
corePlugins: Partial<CorePluginsConfig>
|
|
329
|
+
plugins: Partial<PluginsConfig>
|
|
330
|
+
// Custom
|
|
331
|
+
[key: string]: any
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export type Config = RequiredConfig & Partial<OptionalConfig>
|
|
File without changes
|