tailwindcss 3.0.2 → 3.0.6

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.
@@ -248,6 +248,21 @@ function parseRules(rule, cache, options = {}) {
248
248
  return [cache.get(rule), options]
249
249
  }
250
250
 
251
+ const IS_VALID_PROPERTY_NAME = /^[a-z_-]/
252
+
253
+ function isValidPropName(name) {
254
+ return IS_VALID_PROPERTY_NAME.test(name)
255
+ }
256
+
257
+ function isParsableCssValue(property, value) {
258
+ try {
259
+ postcss.parse(`a{${property}:${value}}`).toResult()
260
+ return true
261
+ } catch (err) {
262
+ return false
263
+ }
264
+ }
265
+
251
266
  function extractArbitraryProperty(classCandidate, context) {
252
267
  let [, property, value] = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/) ?? []
253
268
 
@@ -255,9 +270,17 @@ function extractArbitraryProperty(classCandidate, context) {
255
270
  return null
256
271
  }
257
272
 
273
+ if (!isValidPropName(property)) {
274
+ return null
275
+ }
276
+
277
+ if (!isValidArbitraryValue(value)) {
278
+ return null
279
+ }
280
+
258
281
  let normalized = normalize(value)
259
282
 
260
- if (!isValidArbitraryValue(normalized)) {
283
+ if (!isParsableCssValue(property, normalized)) {
261
284
  return null
262
285
  }
263
286
 
@@ -302,7 +325,6 @@ function* resolveMatchedPlugins(classCandidate, context) {
302
325
  for (let [prefix, modifier] of candidatePermutations(candidatePrefix)) {
303
326
  if (context.candidateRuleMap.has(prefix)) {
304
327
  yield [context.candidateRuleMap.get(prefix), negative ? `-${modifier}` : modifier]
305
- return
306
328
  }
307
329
  }
308
330
  }
@@ -233,6 +233,28 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
233
233
  .push([{ sort: offset, layer: 'base' }, rule])
234
234
  }
235
235
  },
236
+ /**
237
+ * @param {string} group
238
+ * @param {Record<string, string | string[]>} declarations
239
+ */
240
+ addDefaults(group, declarations) {
241
+ const groups = {
242
+ [`@defaults ${group}`]: declarations,
243
+ }
244
+
245
+ for (let [identifier, rule] of withIdentifiers(groups)) {
246
+ let prefixedIdentifier = prefixIdentifier(identifier, {})
247
+ let offset = offsets.base++
248
+
249
+ if (!context.candidateRuleMap.has(prefixedIdentifier)) {
250
+ context.candidateRuleMap.set(prefixedIdentifier, [])
251
+ }
252
+
253
+ context.candidateRuleMap
254
+ .get(prefixedIdentifier)
255
+ .push([{ sort: offset, layer: 'defaults' }, rule])
256
+ }
257
+ },
236
258
  addComponents(components, options) {
237
259
  let defaultOptions = {
238
260
  respectPrefix: true,
@@ -528,6 +550,7 @@ function registerPlugins(plugins, context) {
528
550
  let variantList = []
529
551
  let variantMap = new Map()
530
552
  let offsets = {
553
+ defaults: 0n,
531
554
  base: 0n,
532
555
  components: 0n,
533
556
  utilities: 0n,
@@ -555,6 +578,7 @@ function registerPlugins(plugins, context) {
555
578
 
556
579
  let highestOffset = ((args) => args.reduce((m, e) => (e > m ? e : m)))([
557
580
  offsets.base,
581
+ offsets.defaults,
558
582
  offsets.components,
559
583
  offsets.utilities,
560
584
  offsets.user,
@@ -566,13 +590,14 @@ function registerPlugins(plugins, context) {
566
590
  context.arbitraryPropertiesSort = ((1n << reservedBits) << 0n) - 1n
567
591
 
568
592
  context.layerOrder = {
569
- base: (1n << reservedBits) << 0n,
570
- components: (1n << reservedBits) << 1n,
571
- utilities: (1n << reservedBits) << 2n,
572
- user: (1n << reservedBits) << 3n,
593
+ defaults: (1n << reservedBits) << 0n,
594
+ base: (1n << reservedBits) << 1n,
595
+ components: (1n << reservedBits) << 2n,
596
+ utilities: (1n << reservedBits) << 3n,
597
+ user: (1n << reservedBits) << 4n,
573
598
  }
574
599
 
575
- reservedBits += 4n
600
+ reservedBits += 5n
576
601
 
577
602
  let offset = 0
578
603
  context.variantOrder = new Map(
@@ -626,7 +651,15 @@ function registerPlugins(plugins, context) {
626
651
  let utils = Array.isArray(util)
627
652
  ? (() => {
628
653
  let [utilName, options] = util
629
- return Object.keys(options?.values ?? {}).map((value) => formatClass(utilName, value))
654
+ let classes = Object.keys(options?.values ?? {}).map((value) =>
655
+ formatClass(utilName, value)
656
+ )
657
+
658
+ if (options?.supportsNegativeValues) {
659
+ classes = [...classes, ...classes.map((cls) => '-' + cls)]
660
+ }
661
+
662
+ return classes
630
663
  })()
631
664
  : [util]
632
665
 
@@ -5,6 +5,12 @@ export function defaults(target, ...sources) {
5
5
  target[k] = source[k]
6
6
  }
7
7
  }
8
+
9
+ for (let k of Object.getOwnPropertySymbols(source)) {
10
+ if (!target?.hasOwnProperty?.(k)) {
11
+ target[k] = source[k]
12
+ }
13
+ }
8
14
  }
9
15
 
10
16
  return target
package/src/util/log.js CHANGED
@@ -12,6 +12,10 @@ function log(chalk, messages, key) {
12
12
  messages.forEach((message) => console.warn(chalk, '-', message))
13
13
  }
14
14
 
15
+ export function dim(input) {
16
+ return chalk.dim(input)
17
+ }
18
+
15
19
  export default {
16
20
  info(key, messages) {
17
21
  log(chalk.bold.cyan('info'), ...(Array.isArray(key) ? [key] : [messages, key]))
@@ -1,4 +1,4 @@
1
- import log from './log'
1
+ import log, { dim } from './log'
2
2
 
3
3
  export function normalizeConfig(config) {
4
4
  // Quick structure validation
@@ -245,5 +245,18 @@ export function normalizeConfig(config) {
245
245
  })(),
246
246
  }
247
247
 
248
+ // Validate globs to prevent bogus globs.
249
+ // E.g.: `./src/*.{html}` is invalid, the `{html}` should just be `html`
250
+ for (let file of config.content.files) {
251
+ if (typeof file === 'string' && /{([^,]*?)}/g.test(file)) {
252
+ log.warn('invalid-glob-braces', [
253
+ `The glob pattern ${dim(file)} in your config is invalid.`,
254
+ ` Update it to ${dim(file.replace(/{([^,]*?)}/g, '$1'))} to silence this warning.`,
255
+ // TODO: Add https://tw.wtf/invalid-glob-braces
256
+ ])
257
+ break
258
+ }
259
+ }
260
+
248
261
  return config
249
262
  }
@@ -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
- return path.split(/[\.\]\[]+/g)
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
  }
@@ -854,8 +854,8 @@ module.exports = {
854
854
  none: 'none',
855
855
  all: 'all',
856
856
  DEFAULT:
857
- 'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
858
- colors: 'background-color, border-color, color, fill, stroke',
857
+ 'color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter',
858
+ colors: 'color, background-color, border-color, text-decoration-color, fill, stroke',
859
859
  opacity: 'opacity',
860
860
  shadow: 'box-shadow',
861
861
  transform: 'transform',
package/peers/.svgo.yml DELETED
@@ -1,75 +0,0 @@
1
- # replace default config
2
-
3
- # multipass: true
4
- # full: true
5
-
6
- plugins:
7
-
8
- # - name
9
- #
10
- # or:
11
- # - name: false
12
- # - name: true
13
- #
14
- # or:
15
- # - name:
16
- # param1: 1
17
- # param2: 2
18
-
19
- - removeDoctype
20
- - removeXMLProcInst
21
- - removeComments
22
- - removeMetadata
23
- - removeXMLNS
24
- - removeEditorsNSData
25
- - cleanupAttrs
26
- - inlineStyles
27
- - minifyStyles
28
- - convertStyleToAttrs
29
- - cleanupIDs
30
- - prefixIds
31
- - removeRasterImages
32
- - removeUselessDefs
33
- - cleanupNumericValues
34
- - cleanupListOfValues
35
- - convertColors
36
- - removeUnknownsAndDefaults
37
- - removeNonInheritableGroupAttrs
38
- - removeUselessStrokeAndFill
39
- - removeViewBox
40
- - cleanupEnableBackground
41
- - removeHiddenElems
42
- - removeEmptyText
43
- - convertShapeToPath
44
- - convertEllipseToCircle
45
- - moveElemsAttrsToGroup
46
- - moveGroupAttrsToElems
47
- - collapseGroups
48
- - convertPathData
49
- - convertTransform
50
- - removeEmptyAttrs
51
- - removeEmptyContainers
52
- - mergePaths
53
- - removeUnusedNS
54
- - sortAttrs
55
- - sortDefsChildren
56
- - removeTitle
57
- - removeDesc
58
- - removeDimensions
59
- - removeAttrs
60
- - removeAttributesBySelector
61
- - removeElementsByAttr
62
- - addClassesToSVGElement
63
- - removeStyleElement
64
- - removeScriptElement
65
- - addAttributesToSVGElement
66
- - removeOffCanvasPaths
67
- - reusePaths
68
-
69
- # configure the indent (default 4 spaces) used by `--pretty` here:
70
- #
71
- # @see https://github.com/svg/svgo/blob/master/lib/svgo/js2svg.js#L6 for more config options
72
- #
73
- # js2svg:
74
- # pretty: true
75
- # indent: ' '
@@ -1,299 +0,0 @@
1
- [
2
- "all",
3
- "display",
4
- "position",
5
- "top",
6
- "right",
7
- "bottom",
8
- "left",
9
- "offset-inline-start",
10
- "offset-inline-end",
11
- "offset-block-start",
12
- "offset-block-end",
13
- "grid",
14
- "grid-area",
15
- "grid-auto-columns",
16
- "grid-auto-flow",
17
- "grid-auto-rows",
18
- "grid-column",
19
- "grid-column-end",
20
- "grid-column-start",
21
- "grid-row",
22
- "grid-row-end",
23
- "grid-row-start",
24
- "grid-template",
25
- "grid-template-areas",
26
- "grid-template-columns",
27
- "grid-template-rows",
28
- "flex",
29
- "flex-basis",
30
- "flex-direction",
31
- "flex-flow",
32
- "flex-grow",
33
- "flex-shrink",
34
- "flex-wrap",
35
- "box-decoration-break",
36
- "place-content",
37
- "place-items",
38
- "place-self",
39
- "align-content",
40
- "align-items",
41
- "align-self",
42
- "justify-content",
43
- "justify-items",
44
- "justify-self",
45
- "vertical-align",
46
- "order",
47
- "float",
48
- "clear",
49
- "shape-margin",
50
- "shape-outside",
51
- "shape-image-threshold",
52
- "orphans",
53
- "columns",
54
- "column-gap",
55
- "column-fill",
56
- "column-rule",
57
- "column-rule-color",
58
- "column-rule-style",
59
- "column-rule-width",
60
- "column-span",
61
- "column-count",
62
- "column-width",
63
- "break-before",
64
- "break-after",
65
- "break-inside",
66
- "page-break-before",
67
- "page-break-after",
68
- "page-break-inside",
69
- "transform",
70
- "transform-box",
71
- "transform-origin",
72
- "transform-style",
73
- "rotate",
74
- "scale",
75
-
76
- "perspective",
77
- "perspective-origin",
78
- "visibility",
79
- "opacity",
80
- "z-index",
81
- "mix-blend-mode",
82
- "backface-visibility",
83
- "backdrop-filter",
84
- "clip-path",
85
- "mask",
86
- "mask-clip",
87
- "mask-image",
88
- "mask-origin",
89
- "mask-position",
90
- "mask-repeat",
91
- "mask-size",
92
- "mask-type",
93
- "filter",
94
- "animation",
95
- "animation-name",
96
- "animation-duration",
97
- "animation-fill-mode",
98
- "animation-play-state",
99
- "animation-timing-function",
100
- "animation-delay",
101
- "animation-iteration-count",
102
- "animation-direction",
103
- "transition",
104
- "transition-delay",
105
- "transition-duration",
106
- "transition-property",
107
- "transition-timing-function",
108
- "will-change",
109
- "counter-increment",
110
- "counter-reset",
111
- "cursor",
112
-
113
- "box-sizing",
114
- "margin",
115
- "margin-top",
116
- "margin-right",
117
- "margin-bottom",
118
- "margin-left",
119
- "margin-inline-start",
120
- "margin-inline-end",
121
- "margin-block-start",
122
- "margin-block-end",
123
- "outline",
124
- "outline-color",
125
- "outline-offset",
126
- "outline-style",
127
- "outline-width",
128
- "box-shadow",
129
- "border",
130
- "border-top",
131
- "border-right",
132
- "border-bottom",
133
- "border-left",
134
- "border-width",
135
- "border-top-width",
136
- "border-right-width",
137
- "border-bottom-width",
138
- "border-left-width",
139
- "border-style",
140
- "border-top-style",
141
- "border-right-style",
142
- "border-bottom-style",
143
- "border-left-style",
144
- "border-radius",
145
- "border-top-right-radius",
146
- "border-top-left-radius",
147
- "border-bottom-right-radius",
148
- "border-bottom-left-radius",
149
- "border-color",
150
- "border-top-color",
151
- "border-right-color",
152
- "border-bottom-color",
153
- "border-left-color",
154
- "border-inline-start",
155
- "border-inline-start-color",
156
- "border-inline-start-style",
157
- "border-inline-start-width",
158
- "border-inline-end",
159
- "border-inline-end-color",
160
- "border-inline-end-style",
161
- "border-inline-end-width",
162
- "border-block-start",
163
- "border-block-start-color",
164
- "border-block-start-style",
165
- "border-block-start-width",
166
- "border-block-end",
167
- "border-block-end-color",
168
- "border-block-end-style",
169
- "border-block-end-width",
170
- "border-image",
171
- "border-image-outset",
172
- "border-image-repeat",
173
- "border-image-slice",
174
- "border-image-source",
175
- "border-image-width",
176
- "border-collapse",
177
- "border-spacing",
178
- "background",
179
- "background-attachment",
180
- "background-blend-mode",
181
- "background-clip",
182
- "background-color",
183
- "background-image",
184
- "background-origin",
185
- "background-position",
186
- "background-position-x",
187
- "background-position-y",
188
- "background-repeat",
189
- "background-size",
190
- "isolation",
191
- "padding",
192
- "padding-top",
193
- "padding-right",
194
- "padding-bottom",
195
- "padding-left",
196
- "padding-inline-start",
197
- "padding-inline-end",
198
- "padding-block-start",
199
- "padding-block-end",
200
- "image-orientation",
201
- "image-rendering",
202
-
203
- "width",
204
- "min-width",
205
- "max-width",
206
- "height",
207
- "min-height",
208
- "max-height",
209
- "inline-size",
210
- "min-inline-size",
211
- "max-inline-size",
212
- "block-size",
213
- "min-block-size",
214
- "max-block-size",
215
- "table-layout",
216
- "caption-side",
217
- "empty-cells",
218
- "overflow",
219
- "overflow-x",
220
- "overflow-y",
221
- "resize",
222
- "object-fit",
223
- "object-position",
224
- "scroll-behavior",
225
- "scroll-snap-coordinate",
226
- "scroll-snap-destination",
227
- "scroll-snap-type",
228
- "touch-action",
229
- "pointer-events",
230
-
231
- "ruby-align",
232
- "ruby-position",
233
- "color",
234
- "caret-color",
235
- "font",
236
- "font-family",
237
- "font-feature-settings",
238
- "font-kerning",
239
- "font-language-override",
240
- "font-size",
241
- "font-optical-sizing",
242
- "font-size-adjust",
243
- "font-stretch",
244
- "font-style",
245
- "font-synthesis",
246
- "font-variant",
247
- "font-variant-alternates",
248
- "font-variant-caps",
249
- "font-variant-east-asian",
250
- "font-variant-ligatures",
251
- "font-variant-numeric",
252
- "font-variant-position",
253
- "font-weight",
254
- "hyphens",
255
- "initial-letter",
256
- "initial-letter-align",
257
- "letter-spacing",
258
- "line-break",
259
- "line-height",
260
- "list-style",
261
- "list-style-image",
262
- "list-style-position",
263
- "list-style-type",
264
- "writing-mode",
265
- "direction",
266
- "unicode-bidi",
267
- "unicode-range",
268
- "user-select",
269
- "text-combine-upright",
270
- "text-align",
271
- "text-align-last",
272
- "text-decoration",
273
- "text-decoration-color",
274
- "text-decoration-line",
275
- "text-decoration-skip",
276
- "text-decoration-style",
277
- "text-decoration-skip-ink",
278
- "text-emphasis",
279
- "text-emphasis-position",
280
- "text-emphasis-color",
281
- "text-emphasis-style",
282
- "text-indent",
283
- "text-justify",
284
- "text-underline-position",
285
- "text-orientation",
286
- "text-overflow",
287
- "text-rendering",
288
- "text-shadow",
289
- "text-size-adjust",
290
- "text-transform",
291
- "white-space",
292
- "word-break",
293
- "word-spacing",
294
- "overflow-wrap",
295
- "quotes",
296
- "tab-size",
297
- "content",
298
- "widows"
299
- ]