tailwindcss 0.0.0-insiders.deefbf5 → 0.0.0-insiders.df96ea5

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 (218) hide show
  1. package/README.md +16 -17
  2. package/dist/chunk-GFBUASX3.mjs +1 -0
  3. package/dist/chunk-HTB5LLOP.mjs +1 -0
  4. package/dist/chunk-KV2PFGBW.mjs +38 -0
  5. package/dist/colors-b_6i0Oi7.d.ts +295 -0
  6. package/dist/colors.d.mts +295 -0
  7. package/dist/colors.d.ts +5 -0
  8. package/dist/colors.js +1 -0
  9. package/dist/colors.mjs +1 -0
  10. package/dist/default-theme.d.mts +1147 -0
  11. package/dist/default-theme.d.ts +1147 -0
  12. package/dist/default-theme.js +1 -0
  13. package/dist/default-theme.mjs +1 -0
  14. package/dist/flatten-color-palette.d.mts +6 -0
  15. package/dist/flatten-color-palette.d.ts +6 -0
  16. package/dist/flatten-color-palette.js +3 -0
  17. package/dist/flatten-color-palette.mjs +1 -0
  18. package/dist/lib.d.mts +378 -0
  19. package/dist/lib.d.ts +3 -0
  20. package/dist/lib.js +38 -0
  21. package/dist/lib.mjs +1 -0
  22. package/dist/plugin.d.mts +11 -0
  23. package/dist/plugin.d.ts +134 -0
  24. package/dist/plugin.js +1 -0
  25. package/dist/plugin.mjs +1 -0
  26. package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
  27. package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
  28. package/dist/types-CJYAW1ql.d.mts +128 -0
  29. package/index.css +896 -0
  30. package/package.json +76 -100
  31. package/preflight.css +393 -0
  32. package/theme.css +462 -0
  33. package/CHANGELOG.md +0 -2206
  34. package/base.css +0 -1
  35. package/colors.d.ts +0 -3
  36. package/colors.js +0 -2
  37. package/components.css +0 -1
  38. package/defaultConfig.d.ts +0 -3
  39. package/defaultConfig.js +0 -2
  40. package/defaultTheme.d.ts +0 -4
  41. package/defaultTheme.js +0 -2
  42. package/lib/cli-peer-dependencies.js +0 -20
  43. package/lib/cli.js +0 -805
  44. package/lib/constants.js +0 -37
  45. package/lib/corePluginList.js +0 -179
  46. package/lib/corePlugins.js +0 -3662
  47. package/lib/css/LICENSE +0 -25
  48. package/lib/css/preflight.css +0 -360
  49. package/lib/featureFlags.js +0 -61
  50. package/lib/index.js +0 -40
  51. package/lib/lib/cacheInvalidation.js +0 -87
  52. package/lib/lib/collapseAdjacentRules.js +0 -56
  53. package/lib/lib/collapseDuplicateDeclarations.js +0 -80
  54. package/lib/lib/defaultExtractor.js +0 -228
  55. package/lib/lib/detectNesting.js +0 -34
  56. package/lib/lib/evaluateTailwindFunctions.js +0 -215
  57. package/lib/lib/expandApplyAtRules.js +0 -470
  58. package/lib/lib/expandTailwindAtRules.js +0 -276
  59. package/lib/lib/generateRules.js +0 -722
  60. package/lib/lib/getModuleDependencies.js +0 -48
  61. package/lib/lib/normalizeTailwindDirectives.js +0 -84
  62. package/lib/lib/partitionApplyAtRules.js +0 -53
  63. package/lib/lib/regex.js +0 -52
  64. package/lib/lib/resolveDefaultsAtRules.js +0 -154
  65. package/lib/lib/setupContextUtils.js +0 -932
  66. package/lib/lib/setupTrackingContext.js +0 -169
  67. package/lib/lib/sharedState.js +0 -51
  68. package/lib/lib/substituteScreenAtRules.js +0 -26
  69. package/lib/postcss-plugins/nesting/README.md +0 -42
  70. package/lib/postcss-plugins/nesting/index.js +0 -17
  71. package/lib/postcss-plugins/nesting/plugin.js +0 -84
  72. package/lib/processTailwindFeatures.js +0 -59
  73. package/lib/public/colors.js +0 -329
  74. package/lib/public/create-plugin.js +0 -13
  75. package/lib/public/default-config.js +0 -14
  76. package/lib/public/default-theme.js +0 -14
  77. package/lib/public/resolve-config.js +0 -19
  78. package/lib/util/bigSign.js +0 -8
  79. package/lib/util/buildMediaQuery.js +0 -19
  80. package/lib/util/cloneDeep.js +0 -17
  81. package/lib/util/cloneNodes.js +0 -25
  82. package/lib/util/color.js +0 -90
  83. package/lib/util/configurePlugins.js +0 -18
  84. package/lib/util/createPlugin.js +0 -28
  85. package/lib/util/createUtilityPlugin.js +0 -48
  86. package/lib/util/dataTypes.js +0 -235
  87. package/lib/util/defaults.js +0 -22
  88. package/lib/util/escapeClassName.js +0 -19
  89. package/lib/util/escapeCommas.js +0 -8
  90. package/lib/util/flattenColorPalette.js +0 -14
  91. package/lib/util/formatVariantSelector.js +0 -194
  92. package/lib/util/getAllConfigs.js +0 -34
  93. package/lib/util/hashConfig.js +0 -16
  94. package/lib/util/isKeyframeRule.js +0 -8
  95. package/lib/util/isPlainObject.js +0 -12
  96. package/lib/util/isValidArbitraryValue.js +0 -63
  97. package/lib/util/log.js +0 -50
  98. package/lib/util/nameClass.js +0 -32
  99. package/lib/util/negateValue.js +0 -18
  100. package/lib/util/normalizeConfig.js +0 -250
  101. package/lib/util/normalizeScreens.js +0 -58
  102. package/lib/util/parseAnimationValue.js +0 -88
  103. package/lib/util/parseBoxShadowValue.js +0 -76
  104. package/lib/util/parseDependency.js +0 -63
  105. package/lib/util/parseObjectStyles.js +0 -31
  106. package/lib/util/pluginUtils.js +0 -187
  107. package/lib/util/prefixSelector.js +0 -20
  108. package/lib/util/removeAlphaVariables.js +0 -18
  109. package/lib/util/resolveConfig.js +0 -256
  110. package/lib/util/resolveConfigPath.js +0 -51
  111. package/lib/util/responsive.js +0 -19
  112. package/lib/util/splitAtTopLevelOnly.js +0 -90
  113. package/lib/util/tap.js +0 -9
  114. package/lib/util/toColorValue.js +0 -8
  115. package/lib/util/toPath.js +0 -14
  116. package/lib/util/transformThemeValue.js +0 -61
  117. package/lib/util/validateConfig.js +0 -21
  118. package/lib/util/withAlphaVariable.js +0 -67
  119. package/nesting/index.js +0 -2
  120. package/peers/index.js +0 -77956
  121. package/plugin.d.ts +0 -11
  122. package/plugin.js +0 -2
  123. package/prettier.config.js +0 -19
  124. package/resolveConfig.js +0 -2
  125. package/screens.css +0 -1
  126. package/scripts/create-plugin-list.js +0 -10
  127. package/scripts/generate-types.js +0 -105
  128. package/scripts/install-integrations.js +0 -27
  129. package/scripts/rebuildFixtures.js +0 -68
  130. package/scripts/type-utils.js +0 -27
  131. package/src/cli-peer-dependencies.js +0 -15
  132. package/src/cli.js +0 -915
  133. package/src/constants.js +0 -17
  134. package/src/corePluginList.js +0 -1
  135. package/src/corePlugins.js +0 -2442
  136. package/src/css/LICENSE +0 -25
  137. package/src/css/preflight.css +0 -360
  138. package/src/featureFlags.js +0 -54
  139. package/src/index.js +0 -42
  140. package/src/lib/cacheInvalidation.js +0 -52
  141. package/src/lib/collapseAdjacentRules.js +0 -58
  142. package/src/lib/collapseDuplicateDeclarations.js +0 -93
  143. package/src/lib/defaultExtractor.js +0 -208
  144. package/src/lib/detectNesting.js +0 -39
  145. package/src/lib/evaluateTailwindFunctions.js +0 -248
  146. package/src/lib/expandApplyAtRules.js +0 -539
  147. package/src/lib/expandTailwindAtRules.js +0 -292
  148. package/src/lib/generateRules.js +0 -719
  149. package/src/lib/getModuleDependencies.js +0 -39
  150. package/src/lib/normalizeTailwindDirectives.js +0 -84
  151. package/src/lib/partitionApplyAtRules.js +0 -52
  152. package/src/lib/regex.js +0 -74
  153. package/src/lib/resolveDefaultsAtRules.js +0 -163
  154. package/src/lib/setupContextUtils.js +0 -977
  155. package/src/lib/setupTrackingContext.js +0 -187
  156. package/src/lib/sharedState.js +0 -48
  157. package/src/lib/substituteScreenAtRules.js +0 -19
  158. package/src/postcss-plugins/nesting/README.md +0 -42
  159. package/src/postcss-plugins/nesting/index.js +0 -13
  160. package/src/postcss-plugins/nesting/plugin.js +0 -80
  161. package/src/processTailwindFeatures.js +0 -58
  162. package/src/public/colors.js +0 -300
  163. package/src/public/create-plugin.js +0 -2
  164. package/src/public/default-config.js +0 -4
  165. package/src/public/default-theme.js +0 -4
  166. package/src/public/resolve-config.js +0 -7
  167. package/src/util/bigSign.js +0 -3
  168. package/src/util/buildMediaQuery.js +0 -20
  169. package/src/util/cloneDeep.js +0 -11
  170. package/src/util/cloneNodes.js +0 -24
  171. package/src/util/color.js +0 -73
  172. package/src/util/configurePlugins.js +0 -23
  173. package/src/util/createPlugin.js +0 -27
  174. package/src/util/createUtilityPlugin.js +0 -37
  175. package/src/util/dataTypes.js +0 -254
  176. package/src/util/defaults.js +0 -17
  177. package/src/util/escapeClassName.js +0 -8
  178. package/src/util/escapeCommas.js +0 -3
  179. package/src/util/flattenColorPalette.js +0 -13
  180. package/src/util/formatVariantSelector.js +0 -215
  181. package/src/util/getAllConfigs.js +0 -26
  182. package/src/util/hashConfig.js +0 -5
  183. package/src/util/isKeyframeRule.js +0 -3
  184. package/src/util/isPlainObject.js +0 -8
  185. package/src/util/isValidArbitraryValue.js +0 -61
  186. package/src/util/log.js +0 -29
  187. package/src/util/nameClass.js +0 -26
  188. package/src/util/negateValue.js +0 -16
  189. package/src/util/normalizeConfig.js +0 -262
  190. package/src/util/normalizeScreens.js +0 -45
  191. package/src/util/parseAnimationValue.js +0 -68
  192. package/src/util/parseBoxShadowValue.js +0 -72
  193. package/src/util/parseDependency.js +0 -49
  194. package/src/util/parseObjectStyles.js +0 -19
  195. package/src/util/pluginUtils.js +0 -204
  196. package/src/util/prefixSelector.js +0 -14
  197. package/src/util/removeAlphaVariables.js +0 -24
  198. package/src/util/resolveConfig.js +0 -283
  199. package/src/util/resolveConfigPath.js +0 -55
  200. package/src/util/responsive.js +0 -10
  201. package/src/util/splitAtTopLevelOnly.js +0 -71
  202. package/src/util/tap.js +0 -4
  203. package/src/util/toColorValue.js +0 -3
  204. package/src/util/toPath.js +0 -26
  205. package/src/util/transformThemeValue.js +0 -54
  206. package/src/util/validateConfig.js +0 -13
  207. package/src/util/withAlphaVariable.js +0 -49
  208. package/stubs/defaultConfig.stub.js +0 -954
  209. package/stubs/defaultPostCssConfig.stub.js +0 -6
  210. package/stubs/simpleConfig.stub.js +0 -8
  211. package/tailwind.css +0 -5
  212. package/types/config.d.ts +0 -327
  213. package/types/generated/.gitkeep +0 -0
  214. package/types/generated/colors.d.ts +0 -276
  215. package/types/generated/corePluginList.d.ts +0 -1
  216. package/types/generated/default-theme.d.ts +0 -331
  217. package/types/index.d.ts +0 -7
  218. package/variants.css +0 -1
@@ -1,254 +0,0 @@
1
- import { parseColor } from './color'
2
- import { parseBoxShadowValue } from './parseBoxShadowValue'
3
-
4
- let cssFunctions = ['min', 'max', 'clamp', 'calc']
5
-
6
- // Ref: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Types
7
-
8
- let COMMA = /,(?![^(]*\))/g // Comma separator that is not located between brackets. E.g.: `cubiz-bezier(a, b, c)` these don't count.
9
- let UNDERSCORE = /_(?![^(]*\))/g // Underscore separator that is not located between brackets. E.g.: `rgba(255,_255,_255)_black` these don't count.
10
-
11
- // This is not a data type, but rather a function that can normalize the
12
- // correct values.
13
- export function normalize(value, isRoot = true) {
14
- // Keep raw strings if it starts with `url(`
15
- if (value.includes('url(')) {
16
- return value
17
- .split(/(url\(.*?\))/g)
18
- .filter(Boolean)
19
- .map((part) => {
20
- if (/^url\(.*?\)$/.test(part)) {
21
- return part
22
- }
23
-
24
- return normalize(part, false)
25
- })
26
- .join('')
27
- }
28
-
29
- // Convert `_` to ` `, except for escaped underscores `\_`
30
- value = value
31
- .replace(
32
- /([^\\])_+/g,
33
- (fullMatch, characterBefore) => characterBefore + ' '.repeat(fullMatch.length - 1)
34
- )
35
- .replace(/^_/g, ' ')
36
- .replace(/\\_/g, '_')
37
-
38
- // Remove leftover whitespace
39
- if (isRoot) {
40
- value = value.trim()
41
- }
42
-
43
- // Add spaces around operators inside math functions like calc() that do not follow an operator
44
- // or '('.
45
- value = value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
46
- return match.replace(
47
- /(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g,
48
- '$1 $2 '
49
- )
50
- })
51
-
52
- return value
53
- }
54
-
55
- export function url(value) {
56
- return value.startsWith('url(')
57
- }
58
-
59
- export function number(value) {
60
- return !isNaN(Number(value)) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?`).test(value))
61
- }
62
-
63
- export function percentage(value) {
64
- return value.split(UNDERSCORE).every((part) => {
65
- return /%$/g.test(part) || cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?%`).test(part))
66
- })
67
- }
68
-
69
- let lengthUnits = [
70
- 'cm',
71
- 'mm',
72
- 'Q',
73
- 'in',
74
- 'pc',
75
- 'pt',
76
- 'px',
77
- 'em',
78
- 'ex',
79
- 'ch',
80
- 'rem',
81
- 'lh',
82
- 'vw',
83
- 'vh',
84
- 'vmin',
85
- 'vmax',
86
- ]
87
- let lengthUnitsPattern = `(?:${lengthUnits.join('|')})`
88
- export function length(value) {
89
- return value.split(UNDERSCORE).every((part) => {
90
- return (
91
- part === '0' ||
92
- new RegExp(`${lengthUnitsPattern}$`).test(part) ||
93
- cssFunctions.some((fn) => new RegExp(`^${fn}\\(.+?${lengthUnitsPattern}`).test(part))
94
- )
95
- })
96
- }
97
-
98
- let lineWidths = new Set(['thin', 'medium', 'thick'])
99
- export function lineWidth(value) {
100
- return lineWidths.has(value)
101
- }
102
-
103
- export function shadow(value) {
104
- let parsedShadows = parseBoxShadowValue(normalize(value))
105
-
106
- for (let parsedShadow of parsedShadows) {
107
- if (!parsedShadow.valid) {
108
- return false
109
- }
110
- }
111
-
112
- return true
113
- }
114
-
115
- export function color(value) {
116
- let colors = 0
117
-
118
- let result = value.split(UNDERSCORE).every((part) => {
119
- part = normalize(part)
120
-
121
- if (part.startsWith('var(')) return true
122
- if (parseColor(part, { loose: true }) !== null) return colors++, true
123
-
124
- return false
125
- })
126
-
127
- if (!result) return false
128
- return colors > 0
129
- }
130
-
131
- export function image(value) {
132
- let images = 0
133
- let result = value.split(COMMA).every((part) => {
134
- part = normalize(part)
135
-
136
- if (part.startsWith('var(')) return true
137
- if (
138
- url(part) ||
139
- gradient(part) ||
140
- ['element(', 'image(', 'cross-fade(', 'image-set('].some((fn) => part.startsWith(fn))
141
- ) {
142
- images++
143
- return true
144
- }
145
-
146
- return false
147
- })
148
-
149
- if (!result) return false
150
- return images > 0
151
- }
152
-
153
- let gradientTypes = new Set([
154
- 'linear-gradient',
155
- 'radial-gradient',
156
- 'repeating-linear-gradient',
157
- 'repeating-radial-gradient',
158
- 'conic-gradient',
159
- ])
160
- export function gradient(value) {
161
- value = normalize(value)
162
-
163
- for (let type of gradientTypes) {
164
- if (value.startsWith(`${type}(`)) {
165
- return true
166
- }
167
- }
168
- return false
169
- }
170
-
171
- let validPositions = new Set(['center', 'top', 'right', 'bottom', 'left'])
172
- export function position(value) {
173
- let positions = 0
174
- let result = value.split(UNDERSCORE).every((part) => {
175
- part = normalize(part)
176
-
177
- if (part.startsWith('var(')) return true
178
- if (validPositions.has(part) || length(part) || percentage(part)) {
179
- positions++
180
- return true
181
- }
182
-
183
- return false
184
- })
185
-
186
- if (!result) return false
187
- return positions > 0
188
- }
189
-
190
- export function familyName(value) {
191
- let fonts = 0
192
- let result = value.split(COMMA).every((part) => {
193
- part = normalize(part)
194
-
195
- if (part.startsWith('var(')) return true
196
-
197
- // If it contains spaces, then it should be quoted
198
- if (part.includes(' ')) {
199
- if (!/(['"])([^"']+)\1/g.test(part)) {
200
- return false
201
- }
202
- }
203
-
204
- // If it starts with a number, it's invalid
205
- if (/^\d/g.test(part)) {
206
- return false
207
- }
208
-
209
- fonts++
210
-
211
- return true
212
- })
213
-
214
- if (!result) return false
215
- return fonts > 0
216
- }
217
-
218
- let genericNames = new Set([
219
- 'serif',
220
- 'sans-serif',
221
- 'monospace',
222
- 'cursive',
223
- 'fantasy',
224
- 'system-ui',
225
- 'ui-serif',
226
- 'ui-sans-serif',
227
- 'ui-monospace',
228
- 'ui-rounded',
229
- 'math',
230
- 'emoji',
231
- 'fangsong',
232
- ])
233
- export function genericName(value) {
234
- return genericNames.has(value)
235
- }
236
-
237
- let absoluteSizes = new Set([
238
- 'xx-small',
239
- 'x-small',
240
- 'small',
241
- 'medium',
242
- 'large',
243
- 'x-large',
244
- 'x-large',
245
- 'xxx-large',
246
- ])
247
- export function absoluteSize(value) {
248
- return absoluteSizes.has(value)
249
- }
250
-
251
- let relativeSizes = new Set(['larger', 'smaller'])
252
- export function relativeSize(value) {
253
- return relativeSizes.has(value)
254
- }
@@ -1,17 +0,0 @@
1
- export function defaults(target, ...sources) {
2
- for (let source of sources) {
3
- for (let k in source) {
4
- if (!target?.hasOwnProperty?.(k)) {
5
- target[k] = source[k]
6
- }
7
- }
8
-
9
- for (let k of Object.getOwnPropertySymbols(source)) {
10
- if (!target?.hasOwnProperty?.(k)) {
11
- target[k] = source[k]
12
- }
13
- }
14
- }
15
-
16
- return target
17
- }
@@ -1,8 +0,0 @@
1
- import parser from 'postcss-selector-parser'
2
- import escapeCommas from './escapeCommas'
3
-
4
- export default function escapeClassName(className) {
5
- let node = parser.className()
6
- node.value = className
7
- return escapeCommas(node?.raws?.value ?? node.value)
8
- }
@@ -1,3 +0,0 @@
1
- export default function escapeCommas(className) {
2
- return className.replace(/\\,/g, '\\2c ')
3
- }
@@ -1,13 +0,0 @@
1
- const flattenColorPalette = (colors) =>
2
- Object.assign(
3
- {},
4
- ...Object.entries(colors ?? {}).flatMap(([color, values]) =>
5
- typeof values == 'object'
6
- ? Object.entries(flattenColorPalette(values)).map(([number, hex]) => ({
7
- [color + (number === 'DEFAULT' ? '' : `-${number}`)]: hex,
8
- }))
9
- : [{ [`${color}`]: values }]
10
- )
11
- )
12
-
13
- export default flattenColorPalette
@@ -1,215 +0,0 @@
1
- import selectorParser from 'postcss-selector-parser'
2
- import unescape from 'postcss-selector-parser/dist/util/unesc'
3
- import escapeClassName from '../util/escapeClassName'
4
- import prefixSelector from '../util/prefixSelector'
5
-
6
- let MERGE = ':merge'
7
- let PARENT = '&'
8
-
9
- export let selectorFunctions = new Set([MERGE])
10
-
11
- export function formatVariantSelector(current, ...others) {
12
- for (let other of others) {
13
- let incomingValue = resolveFunctionArgument(other, MERGE)
14
- if (incomingValue !== null) {
15
- let existingValue = resolveFunctionArgument(current, MERGE, incomingValue)
16
- if (existingValue !== null) {
17
- let existingTarget = `${MERGE}(${incomingValue})`
18
- let splitIdx = other.indexOf(existingTarget)
19
- let addition = other.slice(splitIdx + existingTarget.length).split(' ')[0]
20
-
21
- current = current.replace(existingTarget, existingTarget + addition)
22
- continue
23
- }
24
- }
25
-
26
- current = other.replace(PARENT, current)
27
- }
28
-
29
- return current
30
- }
31
-
32
- export function finalizeSelector(
33
- format,
34
- {
35
- selector,
36
- candidate,
37
- context,
38
- isArbitraryVariant,
39
-
40
- // Split by the separator, but ignore the separator inside square brackets:
41
- //
42
- // E.g.: dark:lg:hover:[paint-order:markers]
43
- // ┬ ┬ ┬ ┬
44
- // │ │ │ ╰── We will not split here
45
- // ╰──┴─────┴─────────────── We will split here
46
- //
47
- base = candidate
48
- .split(new RegExp(`\\${context?.tailwindConfig?.separator ?? ':'}(?![^[]*\\])`))
49
- .pop(),
50
- }
51
- ) {
52
- let ast = selectorParser().astSync(selector)
53
-
54
- // We explicitly DO NOT prefix classes in arbitrary variants
55
- if (context?.tailwindConfig?.prefix && !isArbitraryVariant) {
56
- format = prefixSelector(context.tailwindConfig.prefix, format)
57
- }
58
-
59
- format = format.replace(PARENT, `.${escapeClassName(candidate)}`)
60
-
61
- let formatAst = selectorParser().astSync(format)
62
-
63
- // Remove extraneous selectors that do not include the base class/candidate being matched against
64
- // For example if we have a utility defined `.a, .b { color: red}`
65
- // And the formatted variant is sm:b then we want the final selector to be `.sm\:b` and not `.a, .sm\:b`
66
- ast.each((node) => {
67
- let hasClassesMatchingCandidate = node.some((n) => n.type === 'class' && n.value === base)
68
-
69
- if (!hasClassesMatchingCandidate) {
70
- node.remove()
71
- }
72
- })
73
-
74
- // Normalize escaped classes, e.g.:
75
- //
76
- // The idea would be to replace the escaped `base` in the selector with the
77
- // `format`. However, in css you can escape the same selector in a few
78
- // different ways. This would result in different strings and therefore we
79
- // can't replace it properly.
80
- //
81
- // base: bg-[rgb(255,0,0)]
82
- // base in selector: bg-\\[rgb\\(255\\,0\\,0\\)\\]
83
- // escaped base: bg-\\[rgb\\(255\\2c 0\\2c 0\\)\\]
84
- //
85
- ast.walkClasses((node) => {
86
- if (node.raws && node.value.includes(base)) {
87
- node.raws.value = escapeClassName(unescape(node.raws.value))
88
- }
89
- })
90
-
91
- // We can safely replace the escaped base now, since the `base` section is
92
- // now in a normalized escaped value.
93
- ast.walkClasses((node) => {
94
- if (node.value === base) {
95
- node.replaceWith(...formatAst.nodes)
96
- }
97
- })
98
-
99
- // This will make sure to move pseudo's to the correct spot (the end for
100
- // pseudo elements) because otherwise the selector will never work
101
- // anyway.
102
- //
103
- // E.g.:
104
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
105
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
106
- //
107
- // `::before:hover` doesn't work, which means that we can make it work for you by flipping the order.
108
- function collectPseudoElements(selector) {
109
- let nodes = []
110
-
111
- for (let node of selector.nodes) {
112
- if (isPseudoElement(node)) {
113
- nodes.push(node)
114
- selector.removeChild(node)
115
- }
116
-
117
- if (node?.nodes) {
118
- nodes.push(...collectPseudoElements(node))
119
- }
120
- }
121
-
122
- return nodes
123
- }
124
-
125
- // Remove unnecessary pseudo selectors that we used as placeholders
126
- ast.each((selector) => {
127
- selector.walkPseudos((p) => {
128
- if (selectorFunctions.has(p.value)) {
129
- p.replaceWith(p.nodes)
130
- }
131
- })
132
-
133
- let pseudoElements = collectPseudoElements(selector)
134
- if (pseudoElements.length > 0) {
135
- selector.nodes.push(pseudoElements.sort(sortSelector))
136
- }
137
- })
138
-
139
- return ast.toString()
140
- }
141
-
142
- // Note: As a rule, double colons (::) should be used instead of a single colon
143
- // (:). This distinguishes pseudo-classes from pseudo-elements. However, since
144
- // this distinction was not present in older versions of the W3C spec, most
145
- // browsers support both syntaxes for the original pseudo-elements.
146
- let pseudoElementsBC = [':before', ':after', ':first-line', ':first-letter']
147
-
148
- // These pseudo-elements _can_ be combined with other pseudo selectors AND the order does matter.
149
- let pseudoElementExceptions = ['::file-selector-button']
150
-
151
- // This will make sure to move pseudo's to the correct spot (the end for
152
- // pseudo elements) because otherwise the selector will never work
153
- // anyway.
154
- //
155
- // E.g.:
156
- // - `before:hover:text-center` would result in `.before\:hover\:text-center:hover::before`
157
- // - `hover:before:text-center` would result in `.hover\:before\:text-center:hover::before`
158
- //
159
- // `::before:hover` doesn't work, which means that we can make it work
160
- // for you by flipping the order.
161
- function sortSelector(a, z) {
162
- // Both nodes are non-pseudo's so we can safely ignore them and keep
163
- // them in the same order.
164
- if (a.type !== 'pseudo' && z.type !== 'pseudo') {
165
- return 0
166
- }
167
-
168
- // If one of them is a combinator, we need to keep it in the same order
169
- // because that means it will start a new "section" in the selector.
170
- if ((a.type === 'combinator') ^ (z.type === 'combinator')) {
171
- return 0
172
- }
173
-
174
- // One of the items is a pseudo and the other one isn't. Let's move
175
- // the pseudo to the right.
176
- if ((a.type === 'pseudo') ^ (z.type === 'pseudo')) {
177
- return (a.type === 'pseudo') - (z.type === 'pseudo')
178
- }
179
-
180
- // Both are pseudo's, move the pseudo elements (except for
181
- // ::file-selector-button) to the right.
182
- return isPseudoElement(a) - isPseudoElement(z)
183
- }
184
-
185
- function isPseudoElement(node) {
186
- if (node.type !== 'pseudo') return false
187
- if (pseudoElementExceptions.includes(node.value)) return false
188
-
189
- return node.value.startsWith('::') || pseudoElementsBC.includes(node.value)
190
- }
191
-
192
- function resolveFunctionArgument(haystack, needle, arg) {
193
- let startIdx = haystack.indexOf(arg ? `${needle}(${arg})` : needle)
194
- if (startIdx === -1) return null
195
-
196
- // Start inside the `(`
197
- startIdx += needle.length + 1
198
-
199
- let target = ''
200
- let count = 0
201
-
202
- for (let char of haystack.slice(startIdx)) {
203
- if (char !== '(' && char !== ')') {
204
- target += char
205
- } else if (char === '(') {
206
- target += char
207
- count++
208
- } else if (char === ')') {
209
- if (--count < 0) break // unbalanced
210
- target += char
211
- }
212
- }
213
-
214
- return target
215
- }
@@ -1,26 +0,0 @@
1
- import defaultConfig from '../../stubs/defaultConfig.stub.js'
2
- import { flagEnabled } from '../featureFlags'
3
-
4
- export default function getAllConfigs(config) {
5
- const configs = (config?.presets ?? [defaultConfig])
6
- .slice()
7
- .reverse()
8
- .flatMap((preset) => getAllConfigs(preset instanceof Function ? preset() : preset))
9
-
10
- const features = {
11
- // Add experimental configs here...
12
- respectDefaultRingColorOpacity: {
13
- theme: {
14
- ringColor: {
15
- DEFAULT: '#3b82f67f',
16
- },
17
- },
18
- },
19
- }
20
-
21
- const experimentals = Object.keys(features)
22
- .filter((feature) => flagEnabled(config, feature))
23
- .map((feature) => features[feature])
24
-
25
- return [config, ...experimentals, ...configs]
26
- }
@@ -1,5 +0,0 @@
1
- import hash from 'object-hash'
2
-
3
- export default function hashConfig(config) {
4
- return hash(config, { ignoreUnknown: true })
5
- }
@@ -1,3 +0,0 @@
1
- export default function isKeyframeRule(rule) {
2
- return rule.parent && rule.parent.type === 'atrule' && /keyframes$/.test(rule.parent.name)
3
- }
@@ -1,8 +0,0 @@
1
- export default function isPlainObject(value) {
2
- if (Object.prototype.toString.call(value) !== '[object Object]') {
3
- return false
4
- }
5
-
6
- const prototype = Object.getPrototypeOf(value)
7
- return prototype === null || prototype === Object.prototype
8
- }
@@ -1,61 +0,0 @@
1
- let matchingBrackets = new Map([
2
- ['{', '}'],
3
- ['[', ']'],
4
- ['(', ')'],
5
- ])
6
- let inverseMatchingBrackets = new Map(
7
- Array.from(matchingBrackets.entries()).map(([k, v]) => [v, k])
8
- )
9
-
10
- let quotes = new Set(['"', "'", '`'])
11
-
12
- // Arbitrary values must contain balanced brackets (), [] and {}. Escaped
13
- // values don't count, and brackets inside quotes also don't count.
14
- //
15
- // E.g.: w-[this-is]w-[weird-and-invalid]
16
- // E.g.: w-[this-is\\]w-\\[weird-but-valid]
17
- // E.g.: content-['this-is-also-valid]-weirdly-enough']
18
- export default function isValidArbitraryValue(value) {
19
- let stack = []
20
- let inQuotes = false
21
-
22
- for (let i = 0; i < value.length; i++) {
23
- let char = value[i]
24
-
25
- if (char === ':' && !inQuotes && stack.length === 0) {
26
- return false
27
- }
28
-
29
- // Non-escaped quotes allow us to "allow" anything in between
30
- if (quotes.has(char) && value[i - 1] !== '\\') {
31
- inQuotes = !inQuotes
32
- }
33
-
34
- if (inQuotes) continue
35
- if (value[i - 1] === '\\') continue // Escaped
36
-
37
- if (matchingBrackets.has(char)) {
38
- stack.push(char)
39
- } else if (inverseMatchingBrackets.has(char)) {
40
- let inverse = inverseMatchingBrackets.get(char)
41
-
42
- // Nothing to pop from, therefore it is unbalanced
43
- if (stack.length <= 0) {
44
- return false
45
- }
46
-
47
- // Popped value must match the inverse value, otherwise it is unbalanced
48
- if (stack.pop() !== inverse) {
49
- return false
50
- }
51
- }
52
- }
53
-
54
- // If there is still something on the stack, it is also unbalanced
55
- if (stack.length > 0) {
56
- return false
57
- }
58
-
59
- // All good, totally balanced!
60
- return true
61
- }
package/src/util/log.js DELETED
@@ -1,29 +0,0 @@
1
- import colors from 'picocolors'
2
-
3
- let alreadyShown = new Set()
4
-
5
- function log(type, messages, key) {
6
- if (typeof process !== 'undefined' && process.env.JEST_WORKER_ID) return
7
-
8
- if (key && alreadyShown.has(key)) return
9
- if (key) alreadyShown.add(key)
10
-
11
- console.warn('')
12
- messages.forEach((message) => console.warn(type, '-', message))
13
- }
14
-
15
- export function dim(input) {
16
- return colors.dim(input)
17
- }
18
-
19
- export default {
20
- info(key, messages) {
21
- log(colors.bold(colors.cyan('info')), ...(Array.isArray(key) ? [key] : [messages, key]))
22
- },
23
- warn(key, messages) {
24
- log(colors.bold(colors.yellow('warn')), ...(Array.isArray(key) ? [key] : [messages, key]))
25
- },
26
- risk(key, messages) {
27
- log(colors.bold(colors.magenta('risk')), ...(Array.isArray(key) ? [key] : [messages, key]))
28
- },
29
- }
@@ -1,26 +0,0 @@
1
- import escapeClassName from './escapeClassName'
2
- import escapeCommas from './escapeCommas'
3
-
4
- export function asClass(name) {
5
- return escapeCommas(`.${escapeClassName(name)}`)
6
- }
7
-
8
- export default function nameClass(classPrefix, key) {
9
- return asClass(formatClass(classPrefix, key))
10
- }
11
-
12
- export function formatClass(classPrefix, key) {
13
- if (key === 'DEFAULT') {
14
- return classPrefix
15
- }
16
-
17
- if (key === '-' || key === '-DEFAULT') {
18
- return `-${classPrefix}`
19
- }
20
-
21
- if (key.startsWith('-')) {
22
- return `-${classPrefix}${key}`
23
- }
24
-
25
- return `${classPrefix}-${key}`
26
- }
@@ -1,16 +0,0 @@
1
- export default function (value) {
2
- value = `${value}`
3
-
4
- if (value === '0') {
5
- return '0'
6
- }
7
-
8
- // Flip sign of numbers
9
- if (/^[+-]?(\d+|\d*\.\d+)(e[+-]?\d+)?(%|\w+)?$/.test(value)) {
10
- return value.replace(/^[+-]?/, (sign) => (sign === '-' ? '' : '-'))
11
- }
12
-
13
- if (value.includes('var(') || value.includes('calc(')) {
14
- return `calc(${value} * -1)`
15
- }
16
- }