tailwindcss 0.0.0-insiders.df011dc → 0.0.0-insiders.e2d5f21

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 (120) hide show
  1. package/CHANGELOG.md +106 -1
  2. package/README.md +1 -1
  3. package/colors.js +1 -304
  4. package/defaultConfig.js +1 -4
  5. package/defaultTheme.js +1 -4
  6. package/lib/cli-peer-dependencies.js +4 -9
  7. package/lib/cli.js +646 -705
  8. package/lib/constants.js +15 -15
  9. package/lib/corePluginList.js +174 -4
  10. package/lib/corePlugins.js +3637 -2934
  11. package/lib/css/preflight.css +14 -1
  12. package/lib/featureFlags.js +44 -44
  13. package/lib/index.js +25 -24
  14. package/lib/lib/collapseAdjacentRules.js +33 -35
  15. package/lib/lib/collapseDuplicateDeclarations.js +29 -0
  16. package/lib/lib/detectNesting.js +34 -0
  17. package/lib/lib/evaluateTailwindFunctions.js +134 -155
  18. package/lib/lib/expandApplyAtRules.js +183 -200
  19. package/lib/lib/expandTailwindAtRules.js +219 -232
  20. package/lib/lib/generateRules.js +478 -311
  21. package/lib/lib/getModuleDependencies.js +36 -41
  22. package/lib/lib/normalizeTailwindDirectives.js +66 -58
  23. package/lib/lib/resolveDefaultsAtRules.js +110 -90
  24. package/lib/lib/setupContextUtils.js +740 -580
  25. package/lib/lib/setupTrackingContext.js +142 -162
  26. package/lib/lib/setupWatchingContext.js +235 -278
  27. package/lib/lib/sharedState.js +7 -17
  28. package/lib/lib/substituteScreenAtRules.js +22 -26
  29. package/lib/processTailwindFeatures.js +38 -44
  30. package/lib/public/colors.js +329 -0
  31. package/lib/public/create-plugin.js +13 -0
  32. package/lib/public/default-config.js +14 -0
  33. package/lib/public/default-theme.js +14 -0
  34. package/lib/public/resolve-config.js +19 -0
  35. package/lib/util/bigSign.js +3 -5
  36. package/lib/util/buildMediaQuery.js +15 -31
  37. package/lib/util/cloneDeep.js +14 -13
  38. package/lib/util/cloneNodes.js +9 -13
  39. package/lib/util/color.js +69 -59
  40. package/lib/util/configurePlugins.js +13 -14
  41. package/lib/util/createPlugin.js +21 -24
  42. package/lib/util/createUtilityPlugin.js +47 -45
  43. package/lib/util/dataTypes.js +231 -0
  44. package/lib/util/defaults.js +10 -14
  45. package/lib/util/escapeClassName.js +12 -14
  46. package/lib/util/escapeCommas.js +3 -5
  47. package/lib/util/flattenColorPalette.js +14 -10
  48. package/lib/util/formatVariantSelector.js +186 -0
  49. package/lib/util/getAllConfigs.js +23 -16
  50. package/lib/util/hashConfig.js +10 -10
  51. package/lib/util/isKeyframeRule.js +3 -5
  52. package/lib/util/isPlainObject.js +7 -10
  53. package/lib/util/isValidArbitraryValue.js +64 -0
  54. package/lib/util/log.js +39 -30
  55. package/lib/util/nameClass.js +23 -23
  56. package/lib/util/negateValue.js +14 -15
  57. package/lib/util/normalizeConfig.js +208 -0
  58. package/lib/util/normalizeScreens.js +58 -0
  59. package/lib/util/parseAnimationValue.js +82 -53
  60. package/lib/util/parseBoxShadowValue.js +77 -0
  61. package/lib/util/parseDependency.js +49 -60
  62. package/lib/util/parseObjectStyles.js +23 -20
  63. package/lib/util/pluginUtils.js +153 -285
  64. package/lib/util/prefixSelector.js +14 -16
  65. package/lib/util/resolveConfig.js +194 -249
  66. package/lib/util/resolveConfigPath.js +38 -45
  67. package/lib/util/responsive.js +12 -11
  68. package/lib/util/tap.js +4 -6
  69. package/lib/util/toColorValue.js +4 -5
  70. package/lib/util/toPath.js +4 -6
  71. package/lib/util/transformThemeValue.js +57 -26
  72. package/lib/util/withAlphaVariable.js +56 -54
  73. package/package.json +27 -37
  74. package/peers/index.js +73099 -84294
  75. package/plugin.js +1 -3
  76. package/resolveConfig.js +1 -7
  77. package/scripts/create-plugin-list.js +2 -2
  78. package/src/cli.js +27 -18
  79. package/src/corePluginList.js +1 -1
  80. package/src/corePlugins.js +2124 -1968
  81. package/src/css/preflight.css +14 -1
  82. package/src/featureFlags.js +12 -6
  83. package/src/lib/collapseDuplicateDeclarations.js +28 -0
  84. package/src/lib/detectNesting.js +39 -0
  85. package/src/lib/evaluateTailwindFunctions.js +5 -2
  86. package/src/lib/expandTailwindAtRules.js +24 -32
  87. package/src/lib/generateRules.js +230 -20
  88. package/src/lib/normalizeTailwindDirectives.js +3 -2
  89. package/src/lib/resolveDefaultsAtRules.js +46 -30
  90. package/src/lib/setupContextUtils.js +275 -113
  91. package/src/lib/setupTrackingContext.js +9 -8
  92. package/src/lib/setupWatchingContext.js +12 -7
  93. package/src/lib/sharedState.js +1 -4
  94. package/src/lib/substituteScreenAtRules.js +6 -3
  95. package/src/processTailwindFeatures.js +8 -1
  96. package/src/public/colors.js +300 -0
  97. package/src/public/create-plugin.js +2 -0
  98. package/src/public/default-config.js +4 -0
  99. package/src/public/default-theme.js +4 -0
  100. package/src/public/resolve-config.js +7 -0
  101. package/src/util/buildMediaQuery.js +14 -18
  102. package/src/util/createUtilityPlugin.js +2 -11
  103. package/src/util/dataTypes.js +246 -0
  104. package/src/util/formatVariantSelector.js +196 -0
  105. package/src/util/isValidArbitraryValue.js +61 -0
  106. package/src/util/log.js +18 -21
  107. package/src/util/nameClass.js +10 -6
  108. package/src/util/negateValue.js +4 -2
  109. package/src/util/normalizeConfig.js +249 -0
  110. package/src/util/normalizeScreens.js +42 -0
  111. package/src/util/parseAnimationValue.js +7 -1
  112. package/src/util/parseBoxShadowValue.js +71 -0
  113. package/src/util/parseDependency.js +4 -0
  114. package/src/util/pluginUtils.js +101 -204
  115. package/src/util/prefixSelector.js +1 -4
  116. package/src/util/resolveConfig.js +12 -65
  117. package/src/util/transformThemeValue.js +22 -7
  118. package/src/util/withAlphaVariable.js +13 -8
  119. package/stubs/defaultConfig.stub.js +163 -97
  120. package/stubs/simpleConfig.stub.js +0 -1
@@ -10,7 +10,7 @@ import normalizePath from 'normalize-path'
10
10
  import hash from '../util/hashConfig'
11
11
  import log from '../util/log'
12
12
  import getModuleDependencies from '../lib/getModuleDependencies'
13
- import resolveConfig from '../../resolveConfig'
13
+ import resolveConfig from '../public/resolve-config'
14
14
  import resolveConfigPath from '../util/resolveConfigPath'
15
15
  import { getContext } from './setupContextUtils'
16
16
 
@@ -84,6 +84,13 @@ function rebootWatcher(context, configPath, configDependencies, candidateFiles)
84
84
 
85
85
  watcher = chokidar.watch([...candidateFiles, ...configDependencies], {
86
86
  ignoreInitial: true,
87
+ awaitWriteFinish:
88
+ process.platform === 'win32'
89
+ ? {
90
+ stabilityThreshold: 50,
91
+ pollInterval: 10,
92
+ }
93
+ : false,
87
94
  })
88
95
 
89
96
  setWatcher(context, watcher)
@@ -147,9 +154,9 @@ function getCandidateFiles(context, tailwindConfig) {
147
154
  return candidateFilesCache.get(context)
148
155
  }
149
156
 
150
- let candidateFiles = tailwindConfig.content.content
157
+ let candidateFiles = tailwindConfig.content.files
151
158
  .filter((item) => typeof item === 'string')
152
- .map((contentPath) => normalizePath(path.resolve(contentPath)))
159
+ .map((contentPath) => normalizePath(contentPath))
153
160
 
154
161
  return candidateFilesCache.set(context, candidateFiles).get(context)
155
162
  }
@@ -185,10 +192,9 @@ function getTailwindConfig(configOrPath) {
185
192
  }
186
193
 
187
194
  function resolvedChangedContent(context, candidateFiles) {
188
- let changedContent = context.tailwindConfig.content.content
195
+ let changedContent = context.tailwindConfig.content.files
189
196
  .filter((item) => typeof item.raw === 'string')
190
- .concat(context.tailwindConfig.content.safelist)
191
- .map(({ raw, extension }) => ({ content: raw, extension }))
197
+ .map(({ raw, extension = 'html' }) => ({ content: raw, extension }))
192
198
 
193
199
  for (let changedFile of resolveChangedFiles(context, candidateFiles)) {
194
200
  let content = fs.readFileSync(changedFile, 'utf8')
@@ -248,7 +254,6 @@ export default function setupWatchingContext(configOrPath) {
248
254
  }
249
255
 
250
256
  let [context, isNewContext] = getContext(
251
- tailwindDirectives,
252
257
  root,
253
258
  result,
254
259
  tailwindConfig,
@@ -1,13 +1,10 @@
1
- import LRU from 'quick-lru'
2
-
3
1
  export const env = {
4
2
  TAILWIND_MODE: process.env.TAILWIND_MODE,
5
3
  NODE_ENV: process.env.NODE_ENV,
6
- DEBUG: process.env.DEBUG !== undefined,
4
+ DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== '0',
7
5
  TAILWIND_DISABLE_TOUCH: process.env.TAILWIND_DISABLE_TOUCH !== undefined,
8
6
  TAILWIND_TOUCH_DIR: process.env.TAILWIND_TOUCH_DIR,
9
7
  }
10
8
  export const contextMap = new Map()
11
9
  export const configContextMap = new Map()
12
10
  export const contextSourcesMap = new Map()
13
- export const contentMatchCache = new LRU({ maxSize: 25000 })
@@ -1,16 +1,19 @@
1
+ import { normalizeScreens } from '../util/normalizeScreens'
1
2
  import buildMediaQuery from '../util/buildMediaQuery'
2
3
 
3
4
  export default function ({ tailwindConfig: { theme } }) {
4
5
  return function (css) {
5
6
  css.walkAtRules('screen', (atRule) => {
6
- const screen = atRule.params
7
+ let screen = atRule.params
8
+ let screens = normalizeScreens(theme.screens)
9
+ let screenDefinition = screens.find(({ name }) => name === screen)
7
10
 
8
- if (!theme.screens?.hasOwnProperty?.(screen)) {
11
+ if (!screenDefinition) {
9
12
  throw atRule.error(`No \`${screen}\` screen found.`)
10
13
  }
11
14
 
12
15
  atRule.name = 'media'
13
- atRule.params = buildMediaQuery(theme.screens[screen])
16
+ atRule.params = buildMediaQuery(screenDefinition)
14
17
  })
15
18
  }
16
19
  }
@@ -5,7 +5,10 @@ import evaluateTailwindFunctions from './lib/evaluateTailwindFunctions'
5
5
  import substituteScreenAtRules from './lib/substituteScreenAtRules'
6
6
  import resolveDefaultsAtRules from './lib/resolveDefaultsAtRules'
7
7
  import collapseAdjacentRules from './lib/collapseAdjacentRules'
8
+ import collapseDuplicateDeclarations from './lib/collapseDuplicateDeclarations'
9
+ import detectNesting from './lib/detectNesting'
8
10
  import { createContext } from './lib/setupContextUtils'
11
+ import { issueFlagNotices } from './featureFlags'
9
12
 
10
13
  export default function processTailwindFeatures(setupContext) {
11
14
  return function (root, result) {
@@ -21,7 +24,7 @@ export default function processTailwindFeatures(setupContext) {
21
24
  })
22
25
  },
23
26
  createContext(tailwindConfig, changedContent) {
24
- return createContext(tailwindConfig, changedContent, tailwindDirectives, root)
27
+ return createContext(tailwindConfig, changedContent, root)
25
28
  },
26
29
  })(root, result)
27
30
 
@@ -31,11 +34,15 @@ export default function processTailwindFeatures(setupContext) {
31
34
  )
32
35
  }
33
36
 
37
+ issueFlagNotices(context.tailwindConfig)
38
+
39
+ detectNesting(context)(root, result)
34
40
  expandTailwindAtRules(context)(root, result)
35
41
  expandApplyAtRules(context)(root, result)
36
42
  evaluateTailwindFunctions(context)(root, result)
37
43
  substituteScreenAtRules(context)(root, result)
38
44
  resolveDefaultsAtRules(context)(root, result)
39
45
  collapseAdjacentRules(context)(root, result)
46
+ collapseDuplicateDeclarations(context)(root, result)
40
47
  }
41
48
  }
@@ -0,0 +1,300 @@
1
+ import log from '../util/log'
2
+
3
+ function warn({ version, from, to }) {
4
+ log.warn(`${from}-color-renamed`, [
5
+ `As of Tailwind CSS ${version}, \`${from}\` has been renamed to \`${to}\`.`,
6
+ 'Update your configuration file to silence this warning.',
7
+ ])
8
+ }
9
+
10
+ export default {
11
+ inherit: 'inherit',
12
+ current: 'currentColor',
13
+ transparent: 'transparent',
14
+ black: '#000',
15
+ white: '#fff',
16
+ slate: {
17
+ 50: '#f8fafc',
18
+ 100: '#f1f5f9',
19
+ 200: '#e2e8f0',
20
+ 300: '#cbd5e1',
21
+ 400: '#94a3b8',
22
+ 500: '#64748b',
23
+ 600: '#475569',
24
+ 700: '#334155',
25
+ 800: '#1e293b',
26
+ 900: '#0f172a',
27
+ },
28
+ gray: {
29
+ 50: '#f9fafb',
30
+ 100: '#f3f4f6',
31
+ 200: '#e5e7eb',
32
+ 300: '#d1d5db',
33
+ 400: '#9ca3af',
34
+ 500: '#6b7280',
35
+ 600: '#4b5563',
36
+ 700: '#374151',
37
+ 800: '#1f2937',
38
+ 900: '#111827',
39
+ },
40
+ zinc: {
41
+ 50: '#fafafa',
42
+ 100: '#f4f4f5',
43
+ 200: '#e4e4e7',
44
+ 300: '#d4d4d8',
45
+ 400: '#a1a1aa',
46
+ 500: '#71717a',
47
+ 600: '#52525b',
48
+ 700: '#3f3f46',
49
+ 800: '#27272a',
50
+ 900: '#18181b',
51
+ },
52
+ neutral: {
53
+ 50: '#fafafa',
54
+ 100: '#f5f5f5',
55
+ 200: '#e5e5e5',
56
+ 300: '#d4d4d4',
57
+ 400: '#a3a3a3',
58
+ 500: '#737373',
59
+ 600: '#525252',
60
+ 700: '#404040',
61
+ 800: '#262626',
62
+ 900: '#171717',
63
+ },
64
+ stone: {
65
+ 50: '#fafaf9',
66
+ 100: '#f5f5f4',
67
+ 200: '#e7e5e4',
68
+ 300: '#d6d3d1',
69
+ 400: '#a8a29e',
70
+ 500: '#78716c',
71
+ 600: '#57534e',
72
+ 700: '#44403c',
73
+ 800: '#292524',
74
+ 900: '#1c1917',
75
+ },
76
+ red: {
77
+ 50: '#fef2f2',
78
+ 100: '#fee2e2',
79
+ 200: '#fecaca',
80
+ 300: '#fca5a5',
81
+ 400: '#f87171',
82
+ 500: '#ef4444',
83
+ 600: '#dc2626',
84
+ 700: '#b91c1c',
85
+ 800: '#991b1b',
86
+ 900: '#7f1d1d',
87
+ },
88
+ orange: {
89
+ 50: '#fff7ed',
90
+ 100: '#ffedd5',
91
+ 200: '#fed7aa',
92
+ 300: '#fdba74',
93
+ 400: '#fb923c',
94
+ 500: '#f97316',
95
+ 600: '#ea580c',
96
+ 700: '#c2410c',
97
+ 800: '#9a3412',
98
+ 900: '#7c2d12',
99
+ },
100
+ amber: {
101
+ 50: '#fffbeb',
102
+ 100: '#fef3c7',
103
+ 200: '#fde68a',
104
+ 300: '#fcd34d',
105
+ 400: '#fbbf24',
106
+ 500: '#f59e0b',
107
+ 600: '#d97706',
108
+ 700: '#b45309',
109
+ 800: '#92400e',
110
+ 900: '#78350f',
111
+ },
112
+ yellow: {
113
+ 50: '#fefce8',
114
+ 100: '#fef9c3',
115
+ 200: '#fef08a',
116
+ 300: '#fde047',
117
+ 400: '#facc15',
118
+ 500: '#eab308',
119
+ 600: '#ca8a04',
120
+ 700: '#a16207',
121
+ 800: '#854d0e',
122
+ 900: '#713f12',
123
+ },
124
+ lime: {
125
+ 50: '#f7fee7',
126
+ 100: '#ecfccb',
127
+ 200: '#d9f99d',
128
+ 300: '#bef264',
129
+ 400: '#a3e635',
130
+ 500: '#84cc16',
131
+ 600: '#65a30d',
132
+ 700: '#4d7c0f',
133
+ 800: '#3f6212',
134
+ 900: '#365314',
135
+ },
136
+ green: {
137
+ 50: '#f0fdf4',
138
+ 100: '#dcfce7',
139
+ 200: '#bbf7d0',
140
+ 300: '#86efac',
141
+ 400: '#4ade80',
142
+ 500: '#22c55e',
143
+ 600: '#16a34a',
144
+ 700: '#15803d',
145
+ 800: '#166534',
146
+ 900: '#14532d',
147
+ },
148
+ emerald: {
149
+ 50: '#ecfdf5',
150
+ 100: '#d1fae5',
151
+ 200: '#a7f3d0',
152
+ 300: '#6ee7b7',
153
+ 400: '#34d399',
154
+ 500: '#10b981',
155
+ 600: '#059669',
156
+ 700: '#047857',
157
+ 800: '#065f46',
158
+ 900: '#064e3b',
159
+ },
160
+ teal: {
161
+ 50: '#f0fdfa',
162
+ 100: '#ccfbf1',
163
+ 200: '#99f6e4',
164
+ 300: '#5eead4',
165
+ 400: '#2dd4bf',
166
+ 500: '#14b8a6',
167
+ 600: '#0d9488',
168
+ 700: '#0f766e',
169
+ 800: '#115e59',
170
+ 900: '#134e4a',
171
+ },
172
+ cyan: {
173
+ 50: '#ecfeff',
174
+ 100: '#cffafe',
175
+ 200: '#a5f3fc',
176
+ 300: '#67e8f9',
177
+ 400: '#22d3ee',
178
+ 500: '#06b6d4',
179
+ 600: '#0891b2',
180
+ 700: '#0e7490',
181
+ 800: '#155e75',
182
+ 900: '#164e63',
183
+ },
184
+ sky: {
185
+ 50: '#f0f9ff',
186
+ 100: '#e0f2fe',
187
+ 200: '#bae6fd',
188
+ 300: '#7dd3fc',
189
+ 400: '#38bdf8',
190
+ 500: '#0ea5e9',
191
+ 600: '#0284c7',
192
+ 700: '#0369a1',
193
+ 800: '#075985',
194
+ 900: '#0c4a6e',
195
+ },
196
+ blue: {
197
+ 50: '#eff6ff',
198
+ 100: '#dbeafe',
199
+ 200: '#bfdbfe',
200
+ 300: '#93c5fd',
201
+ 400: '#60a5fa',
202
+ 500: '#3b82f6',
203
+ 600: '#2563eb',
204
+ 700: '#1d4ed8',
205
+ 800: '#1e40af',
206
+ 900: '#1e3a8a',
207
+ },
208
+ indigo: {
209
+ 50: '#eef2ff',
210
+ 100: '#e0e7ff',
211
+ 200: '#c7d2fe',
212
+ 300: '#a5b4fc',
213
+ 400: '#818cf8',
214
+ 500: '#6366f1',
215
+ 600: '#4f46e5',
216
+ 700: '#4338ca',
217
+ 800: '#3730a3',
218
+ 900: '#312e81',
219
+ },
220
+ violet: {
221
+ 50: '#f5f3ff',
222
+ 100: '#ede9fe',
223
+ 200: '#ddd6fe',
224
+ 300: '#c4b5fd',
225
+ 400: '#a78bfa',
226
+ 500: '#8b5cf6',
227
+ 600: '#7c3aed',
228
+ 700: '#6d28d9',
229
+ 800: '#5b21b6',
230
+ 900: '#4c1d95',
231
+ },
232
+ purple: {
233
+ 50: '#faf5ff',
234
+ 100: '#f3e8ff',
235
+ 200: '#e9d5ff',
236
+ 300: '#d8b4fe',
237
+ 400: '#c084fc',
238
+ 500: '#a855f7',
239
+ 600: '#9333ea',
240
+ 700: '#7e22ce',
241
+ 800: '#6b21a8',
242
+ 900: '#581c87',
243
+ },
244
+ fuchsia: {
245
+ 50: '#fdf4ff',
246
+ 100: '#fae8ff',
247
+ 200: '#f5d0fe',
248
+ 300: '#f0abfc',
249
+ 400: '#e879f9',
250
+ 500: '#d946ef',
251
+ 600: '#c026d3',
252
+ 700: '#a21caf',
253
+ 800: '#86198f',
254
+ 900: '#701a75',
255
+ },
256
+ pink: {
257
+ 50: '#fdf2f8',
258
+ 100: '#fce7f3',
259
+ 200: '#fbcfe8',
260
+ 300: '#f9a8d4',
261
+ 400: '#f472b6',
262
+ 500: '#ec4899',
263
+ 600: '#db2777',
264
+ 700: '#be185d',
265
+ 800: '#9d174d',
266
+ 900: '#831843',
267
+ },
268
+ rose: {
269
+ 50: '#fff1f2',
270
+ 100: '#ffe4e6',
271
+ 200: '#fecdd3',
272
+ 300: '#fda4af',
273
+ 400: '#fb7185',
274
+ 500: '#f43f5e',
275
+ 600: '#e11d48',
276
+ 700: '#be123c',
277
+ 800: '#9f1239',
278
+ 900: '#881337',
279
+ },
280
+ get lightBlue() {
281
+ warn({ version: 'v2.2', from: 'lightBlue', to: 'sky' })
282
+ return this.sky
283
+ },
284
+ get warmGray() {
285
+ warn({ version: 'v3.0', from: 'warmGray', to: 'stone' })
286
+ return this.stone
287
+ },
288
+ get trueGray() {
289
+ warn({ version: 'v3.0', from: 'trueGray', to: 'neutral' })
290
+ return this.neutral
291
+ },
292
+ get coolGray() {
293
+ warn({ version: 'v3.0', from: 'coolGray', to: 'gray' })
294
+ return this.gray
295
+ },
296
+ get blueGray() {
297
+ warn({ version: 'v3.0', from: 'blueGray', to: 'slate' })
298
+ return this.slate
299
+ },
300
+ }
@@ -0,0 +1,2 @@
1
+ import createPlugin from '../util/createPlugin'
2
+ export default createPlugin
@@ -0,0 +1,4 @@
1
+ import { cloneDeep } from '../util/cloneDeep'
2
+ import defaultConfig from '../../stubs/defaultConfig.stub'
3
+
4
+ export default cloneDeep(defaultConfig)
@@ -0,0 +1,4 @@
1
+ import { cloneDeep } from '../util/cloneDeep'
2
+ import defaultConfig from '../../stubs/defaultConfig.stub'
3
+
4
+ export default cloneDeep(defaultConfig.theme)
@@ -0,0 +1,7 @@
1
+ import resolveConfigObjects from '../util/resolveConfig'
2
+ import getAllConfigs from '../util/getAllConfigs'
3
+
4
+ export default function resolveConfig(...configs) {
5
+ let [, ...defaultConfigs] = getAllConfigs(configs[0])
6
+ return resolveConfigObjects([...configs, ...defaultConfigs])
7
+ }
@@ -1,24 +1,20 @@
1
1
  export default function buildMediaQuery(screens) {
2
- if (typeof screens === 'string') {
3
- screens = { min: screens }
4
- }
5
-
6
- if (!Array.isArray(screens)) {
7
- screens = [screens]
8
- }
2
+ screens = Array.isArray(screens) ? screens : [screens]
9
3
 
10
4
  return screens
11
- .map((screen) => {
12
- if (screen?.hasOwnProperty?.('raw')) {
13
- return screen.raw
14
- }
5
+ .map((screen) =>
6
+ screen.values.map((screen) => {
7
+ if (screen.raw !== undefined) {
8
+ return screen.raw
9
+ }
15
10
 
16
- return Object.entries(screen)
17
- .map(([feature, value]) => {
18
- feature = { min: 'min-width', max: 'max-width' }[feature] ?? feature
19
- return `(${feature}: ${value})`
20
- })
21
- .join(' and ')
22
- })
11
+ return [
12
+ screen.min && `(min-width: ${screen.min})`,
13
+ screen.max && `(max-width: ${screen.max})`,
14
+ ]
15
+ .filter(Boolean)
16
+ .join(' and ')
17
+ })
18
+ )
23
19
  .join(', ')
24
20
  }
@@ -1,18 +1,9 @@
1
1
  import transformThemeValue from './transformThemeValue'
2
- import { asValue, asColor, asAngle, asLength, asLookupValue } from '../util/pluginUtils'
3
-
4
- let asMap = new Map([
5
- [asValue, 'any'],
6
- [asColor, 'color'],
7
- [asAngle, 'angle'],
8
- [asLength, 'length'],
9
- [asLookupValue, 'lookup'],
10
- ])
11
2
 
12
3
  export default function createUtilityPlugin(
13
4
  themeKey,
14
5
  utilityVariations = [[themeKey, [themeKey]]],
15
- { filterDefault = false, resolveArbitraryValue = asValue } = {}
6
+ { filterDefault = false, ...options } = {}
16
7
  ) {
17
8
  let transformValue = transformThemeValue(themeKey)
18
9
  return function ({ matchUtilities, theme }) {
@@ -33,12 +24,12 @@ export default function createUtilityPlugin(
33
24
  })
34
25
  }, {}),
35
26
  {
27
+ ...options,
36
28
  values: filterDefault
37
29
  ? Object.fromEntries(
38
30
  Object.entries(theme(themeKey) ?? {}).filter(([modifier]) => modifier !== 'DEFAULT')
39
31
  )
40
32
  : theme(themeKey),
41
- type: asMap.get(resolveArbitraryValue) ?? 'any',
42
33
  }
43
34
  )
44
35
  }