@unocss/preset-mini 0.22.5 → 0.24.0

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.
@@ -1,5 +1,5 @@
1
- import { h as handler, c as colorResolver, d as directionMap, p as parseColor, a as cornerMap, i as insetMap, b as directionSize, e as positionMap, x as xyzMap } from './utilities.mjs';
2
- import { CONTROL_SHORTCUT_NO_MERGE, toArray } from '@unocss/core';
1
+ import { h as handler, c as colorResolver, d as directionMap, p as parseColor, a as colorToString, b as cornerMap, e as colorableShadows, i as insetMap, f as directionSize, g as positionMap, x as xyzMap } from './utilities.mjs';
2
+ import { toArray, CONTROL_SHORTCUT_NO_MERGE } from '@unocss/core';
3
3
 
4
4
  const verticalAlignAlias = {
5
5
  mid: "middle",
@@ -17,9 +17,9 @@ const textAligns = [
17
17
  ];
18
18
 
19
19
  const outline = [
20
- [/^outline-(?:width-|size-)?(.+)$/, ([, d]) => ({ "outline-width": handler.bracket.cssvar.fraction.rem(d) })],
20
+ [/^outline-(?:width-|size-)?(.+)$/, ([, d]) => ({ "outline-width": handler.bracket.cssvar.px(d) })],
21
21
  [/^outline-(?:color-)?(.+)$/, colorResolver("outline-color", "outline-color")],
22
- [/^outline-offset-(.+)$/, ([, d]) => ({ "outline-offset": handler.bracket.cssvar.fraction.rem(d) })],
22
+ [/^outline-offset-(.+)$/, ([, d]) => ({ "outline-offset": handler.bracket.cssvar.px(d) })],
23
23
  ["outline", { "outline-style": "solid" }],
24
24
  [/^outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c })],
25
25
  ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
@@ -80,31 +80,28 @@ const borderColorResolver = (direction) => ([, body], { theme }) => {
80
80
  const data = parseColor(body, theme);
81
81
  if (!data)
82
82
  return;
83
- const { alpha, opacity, color, rgba } = data;
84
- if (!color)
85
- return;
86
- if (rgba) {
83
+ const { alpha, color, cssColor } = data;
84
+ if (cssColor) {
87
85
  if (alpha != null) {
88
86
  return {
89
- [`border${direction}-color`]: `rgba(${rgba.join(",")})`
87
+ [`border${direction}-color`]: colorToString(cssColor, alpha)
88
+ };
89
+ }
90
+ if (direction === "") {
91
+ return {
92
+ "--un-border-opacity": cssColor.alpha ?? 1,
93
+ [`border${direction}-color`]: colorToString(cssColor, `var(--un-border${direction}-opacity)`)
90
94
  };
91
95
  } else {
92
- if (direction === "") {
93
- return {
94
- "--un-border-opacity": (opacity && handler.cssvar(opacity)) ?? 1,
95
- [`border${direction}-color`]: `rgba(${rgba.join(",")},var(--un-border${direction}-opacity))`
96
- };
97
- } else {
98
- return {
99
- "--un-border-opacity": (opacity && handler.cssvar(opacity)) ?? 1,
100
- [`--un-border${direction}-opacity`]: "var(--un-border-opacity)",
101
- [`border${direction}-color`]: `rgba(${rgba.join(",")},var(--un-border${direction}-opacity))`
102
- };
103
- }
96
+ return {
97
+ "--un-border-opacity": cssColor.alpha ?? 1,
98
+ [`--un-border${direction}-opacity`]: "var(--un-border-opacity)",
99
+ [`border${direction}-color`]: colorToString(cssColor, `var(--un-border${direction}-opacity)`)
100
+ };
104
101
  }
105
- } else {
102
+ } else if (color) {
106
103
  return {
107
- [`border${direction}-color`]: color.replace("%alpha", `${alpha || 1}`)
104
+ [`border${direction}-color`]: color.replace("%alpha", `${alpha ?? 1}`)
108
105
  };
109
106
  }
110
107
  };
@@ -153,6 +150,7 @@ const bgColors = [
153
150
  const transitionPropertyGroup = {
154
151
  all: "all",
155
152
  colors: ["color", "background-color", "border-color", "text-decoration-color", "fill", "stroke"].join(","),
153
+ none: "none",
156
154
  opacity: "opacity",
157
155
  shadow: "box-shadow",
158
156
  transform: "transform"
@@ -166,22 +164,15 @@ const transitions = [
166
164
  if (p) {
167
165
  return {
168
166
  "transition-property": p,
169
- "transition-timing-function": "cubic-bezier(0.4,0,0.2,1)",
167
+ "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)",
170
168
  "transition-duration": `${duration}ms`
171
169
  };
172
170
  }
173
171
  }],
174
172
  [/^(?:transition-)?duration-(.+)$/, ([, d]) => ({ "transition-duration": handler.bracket.cssvar.time(d) })],
175
173
  [/^(?:transition-)?delay-(.+)$/, ([, d]) => ({ "transition-delay": handler.bracket.cssvar.time(d) })],
176
- [/^ease-(.+)$/, ([, d]) => ({ "transition-timing-function": handler.bracket.cssvar(d) })],
177
- ["ease", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
178
- ["ease-linear", { "transition-timing-function": "linear" }],
179
- ["ease-in", { "transition-timing-function": "cubic-bezier(0.4, 0, 1, 1)" }],
180
- ["ease-out", { "transition-timing-function": "cubic-bezier(0, 0, 0.2, 1)" }],
181
- ["ease-in-out", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
174
+ [/^(?:transition-)?ease(?:-(.+))?$/, ([, d], { theme }) => ({ "transition-timing-function": theme.easing?.[d || "DEFAULT"] ?? handler.bracket.cssvar(d) })],
182
175
  [/^(?:transition-)?property-(.+)$/, ([, v]) => ({ "transition-property": handler.global(v) || transitionProperty(v) })],
183
- ["transition-property-none", { "transition-property": "none" }],
184
- ["property-none", { "transition-property": "none" }],
185
176
  ["transition-none", { transition: "none" }]
186
177
  ];
187
178
 
@@ -208,117 +199,6 @@ const flex = [
208
199
  ["flex-nowrap", { "flex-wrap": "nowrap" }]
209
200
  ];
210
201
 
211
- const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
212
- const displays = [
213
- ["inline", { display: "inline" }],
214
- ["block", { display: "block" }],
215
- ["inline-block", { display: "inline-block" }],
216
- ["contents", { display: "contents" }],
217
- ["flow-root", { display: "flow-root" }],
218
- ["list-item", { display: "list-item" }],
219
- ["hidden", { display: "none" }]
220
- ];
221
- const appearances = [
222
- ["visible", { visibility: "visible" }],
223
- ["invisible", { visibility: "hidden" }],
224
- ["backface-visible", { "backface-visibility": "visible" }],
225
- ["backface-hidden", { "backface-visibility": "hidden" }]
226
- ];
227
- const cursors = [
228
- [/^cursor-(.+)$/, ([, c]) => ({ cursor: handler.bracket.cssvar(c) || c })]
229
- ];
230
- const pointerEvents = [
231
- ["pointer-events-auto", { "pointer-events": "auto" }],
232
- ["pointer-events-none", { "pointer-events": "none" }]
233
- ];
234
- const resizes = [
235
- ["resize-x", { resize: "horizontal" }],
236
- ["resize-y", { resize: "vertical" }],
237
- ["resize", { resize: "both" }],
238
- ["resize-none", { resize: "none" }]
239
- ];
240
- const userSelects = [
241
- ["select-auto", { "user-select": "auto" }],
242
- ["select-all", { "user-select": "all" }],
243
- ["select-text", { "user-select": "text" }],
244
- ["select-none", { "user-select": "none" }]
245
- ];
246
- const whitespaces = [
247
- [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
248
- ];
249
- const contents = [
250
- ["content-empty", { content: '""' }],
251
- ["content-none", { content: '""' }]
252
- ];
253
- const breaks = [
254
- ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
255
- ["break-words", { "overflow-wrap": "break-word" }],
256
- ["break-all", { "word-break": "break-all" }]
257
- ];
258
- const textOverflows = [
259
- ["truncate", { "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }],
260
- ["text-ellipsis", { "text-overflow": "ellipsis" }],
261
- ["text-clip", { "text-overflow": "clip" }]
262
- ];
263
- const textTransforms = [
264
- ["case-upper", { "text-transform": "uppercase" }],
265
- ["case-lower", { "text-transform": "lowercase" }],
266
- ["case-capital", { "text-transform": "capitalize" }],
267
- ["case-normal", { "text-transform": "none" }]
268
- ];
269
- const fontStyles = [
270
- ["italic", { "font-style": "italic" }],
271
- ["not-italic", { "font-style": "normal" }]
272
- ];
273
- const fontSmoothings = [
274
- ["antialiased", {
275
- "-webkit-font-smoothing": "antialiased",
276
- "-moz-osx-font-smoothing": "grayscale",
277
- "font-smoothing": "grayscale"
278
- }],
279
- ["subpixel-antialiased", {
280
- "-webkit-font-smoothing": "auto",
281
- "-moz-osx-font-smoothing": "auto",
282
- "font-smoothing": "auto"
283
- }]
284
- ];
285
-
286
- const shadowBase = {
287
- [CONTROL_SHORTCUT_NO_MERGE]: "",
288
- "--un-ring-offset-shadow": "0 0 #0000",
289
- "--un-ring-shadow": "0 0 #0000",
290
- "--un-shadow-inset": varEmpty,
291
- "--un-shadow": "0 0 #0000"
292
- };
293
- const colorableShadows = (shadows, colorVar) => {
294
- const colored = [];
295
- shadows = toArray(shadows);
296
- for (let i = 0; i < shadows.length; i++) {
297
- const [size, color] = shadows[i].split(/\s(\S+)$/);
298
- if (color.split("(").length !== color.split(")").length)
299
- return shadows;
300
- colored.push(`${size} var(${colorVar}, ${color})`);
301
- }
302
- return colored;
303
- };
304
- const boxShadows = [
305
- [/^shadow(?:-(.+))?$/, ([, d], { theme }) => {
306
- const v = theme.boxShadow?.[d || "DEFAULT"];
307
- if (v) {
308
- return [
309
- shadowBase,
310
- {
311
- "--un-shadow": colorableShadows(v, "--un-shadow-color").join(","),
312
- "box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
313
- }
314
- ];
315
- }
316
- }],
317
- [/^shadow-(.+)$/, colorResolver("--un-shadow-color", "shadow")],
318
- [/^shadow-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-shadow-opacity": handler.bracket.percent(opacity) })],
319
- ["shadow-inset", { "--un-shadow-inset": "inset" }]
320
- ];
321
-
322
202
  const weightMap = {
323
203
  thin: "100",
324
204
  extralight: "200",
@@ -543,14 +423,114 @@ const floats = [
543
423
  ["clear-none", { clear: "none" }]
544
424
  ];
545
425
  const zIndexes = [
546
- [/^z-(.+)$/, ([, v]) => ({ "z-index": handler.bracket.cssvar.number(v) })],
547
- ["z-auto", { "z-index": "auto" }]
426
+ [/^z-(.+)$/, ([, v]) => ({ "z-index": handler.bracket.cssvar.auto.number(v) })]
548
427
  ];
549
428
  const boxSizing = [
550
429
  ["box-border", { "box-sizing": "border-box" }],
551
430
  ["box-content", { "box-sizing": "content-box" }]
552
431
  ];
553
432
 
433
+ const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
434
+ const displays = [
435
+ ["inline", { display: "inline" }],
436
+ ["block", { display: "block" }],
437
+ ["inline-block", { display: "inline-block" }],
438
+ ["contents", { display: "contents" }],
439
+ ["flow-root", { display: "flow-root" }],
440
+ ["list-item", { display: "list-item" }],
441
+ ["hidden", { display: "none" }],
442
+ [/^display-(.+)$/, ([, c]) => ({ display: handler.bracket.cssvar(c) || c })]
443
+ ];
444
+ const appearances = [
445
+ ["visible", { visibility: "visible" }],
446
+ ["invisible", { visibility: "hidden" }],
447
+ ["backface-visible", { "backface-visibility": "visible" }],
448
+ ["backface-hidden", { "backface-visibility": "hidden" }]
449
+ ];
450
+ const cursors = [
451
+ [/^cursor-(.+)$/, ([, c]) => ({ cursor: handler.bracket.cssvar(c) || c })]
452
+ ];
453
+ const pointerEvents = [
454
+ ["pointer-events-auto", { "pointer-events": "auto" }],
455
+ ["pointer-events-none", { "pointer-events": "none" }]
456
+ ];
457
+ const resizes = [
458
+ ["resize-x", { resize: "horizontal" }],
459
+ ["resize-y", { resize: "vertical" }],
460
+ ["resize", { resize: "both" }],
461
+ ["resize-none", { resize: "none" }]
462
+ ];
463
+ const userSelects = [
464
+ ["select-auto", { "user-select": "auto" }],
465
+ ["select-all", { "user-select": "all" }],
466
+ ["select-text", { "user-select": "text" }],
467
+ ["select-none", { "user-select": "none" }]
468
+ ];
469
+ const whitespaces = [
470
+ [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
471
+ ];
472
+ const contents = [
473
+ ["content-empty", { content: '""' }],
474
+ ["content-none", { content: '""' }]
475
+ ];
476
+ const breaks = [
477
+ ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
478
+ ["break-words", { "overflow-wrap": "break-word" }],
479
+ ["break-all", { "word-break": "break-all" }]
480
+ ];
481
+ const textOverflows = [
482
+ ["truncate", { "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }],
483
+ ["text-ellipsis", { "text-overflow": "ellipsis" }],
484
+ ["text-clip", { "text-overflow": "clip" }]
485
+ ];
486
+ const textTransforms = [
487
+ ["case-upper", { "text-transform": "uppercase" }],
488
+ ["case-lower", { "text-transform": "lowercase" }],
489
+ ["case-capital", { "text-transform": "capitalize" }],
490
+ ["case-normal", { "text-transform": "none" }]
491
+ ];
492
+ const fontStyles = [
493
+ ["italic", { "font-style": "italic" }],
494
+ ["not-italic", { "font-style": "normal" }]
495
+ ];
496
+ const fontSmoothings = [
497
+ ["antialiased", {
498
+ "-webkit-font-smoothing": "antialiased",
499
+ "-moz-osx-font-smoothing": "grayscale",
500
+ "font-smoothing": "grayscale"
501
+ }],
502
+ ["subpixel-antialiased", {
503
+ "-webkit-font-smoothing": "auto",
504
+ "-moz-osx-font-smoothing": "auto",
505
+ "font-smoothing": "auto"
506
+ }]
507
+ ];
508
+
509
+ const shadowBase = {
510
+ [CONTROL_SHORTCUT_NO_MERGE]: "",
511
+ "--un-ring-offset-shadow": "0 0 #0000",
512
+ "--un-ring-shadow": "0 0 #0000",
513
+ "--un-shadow-inset": varEmpty,
514
+ "--un-shadow": "0 0 #0000"
515
+ };
516
+ const boxShadows = [
517
+ [/^shadow(?:-(.+))?$/, ([, d], { theme }) => {
518
+ const v = theme.boxShadow?.[d || "DEFAULT"];
519
+ if (v) {
520
+ return [
521
+ shadowBase,
522
+ {
523
+ "--un-shadow": colorableShadows(v, "--un-shadow-color").join(","),
524
+ "box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
525
+ }
526
+ ];
527
+ }
528
+ }],
529
+ [/^shadow-(.+)$/, colorResolver("--un-shadow-color", "shadow")],
530
+ [/^shadow-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-shadow-opacity": handler.bracket.percent(opacity) })],
531
+ ["shadow-inset", { "--un-shadow-inset": "inset" }]
532
+ ];
533
+
554
534
  const ringBase = {
555
535
  ...shadowBase,
556
536
  "--un-ring-inset": varEmpty,
@@ -804,10 +784,10 @@ const variablesAbbrMap = {
804
784
  ws: "white-space"
805
785
  };
806
786
  const cssVariables = [
807
- [/^(.+?)-\$(.+)$/, ([, name, varname]) => {
787
+ [/^(.+?)-(\$.+)$/, ([, name, varname]) => {
808
788
  const prop = variablesAbbrMap[name];
809
789
  if (prop)
810
- return { [prop]: `var(--${varname})` };
790
+ return { [prop]: handler.cssvar(varname) };
811
791
  }]
812
792
  ];
813
793
  const cssProperty = [
@@ -826,11 +806,7 @@ ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
826
806
  ];
827
807
 
828
808
  const textDecorations = [
829
- ["underline", { "text-decoration-line": "underline" }],
830
- ["overline", { "text-decoration-line": "overline" }],
831
- ["line-through", { "text-decoration-line": "line-through" }],
832
- ["decoration-underline", { "text-decoration-line": "underline" }],
833
- ["decoration-line-through", { "text-decoration-line": "line-through" }],
809
+ [/^(?:decoration-)?(underline|overline|line-through)$/, ([, s]) => ({ "text-decoration-line": s })],
834
810
  [/^(?:underline|decoration)-(?:size-)?(.+)$/, ([, s]) => ({ "text-decoration-thickness": handler.bracket.cssvar.px(s) })],
835
811
  [/^(?:underline|decoration)-(auto|from-font)$/, ([, s]) => ({ "text-decoration-thickness": s })],
836
812
  [/^(?:underline|decoration)-(.+)$/, (match, ctx) => {
@@ -926,4 +902,4 @@ const rules = [
926
902
  questionMark
927
903
  ].flat(1);
928
904
 
929
- export { textShadows as $, colorableShadows as A, boxShadows as B, sizes as C, aspectRatio as D, paddings as E, margins as F, varEmpty as G, displays as H, appearances as I, cursors as J, pointerEvents as K, resizes as L, userSelects as M, whitespaces as N, contents as O, breaks as P, textOverflows as Q, textTransforms as R, fontStyles as S, fontSmoothings as T, svgUtilities as U, transforms as V, transitions as W, fonts as X, tabSizes as Y, textIndents as Z, textStrokes as _, appearance as a, cssVariables as a0, cssProperty as a1, textDecorations as a2, borders as b, opacity as c, textColors as d, bgColors as e, flex as f, gaps as g, grids as h, overflows as i, justifies as j, orders as k, alignments as l, placements as m, insets as n, outline as o, positions as p, floats as q, rules as r, boxSizing as s, textAligns as t, questionMark as u, verticalAligns as v, willChange as w, rings as x, shadowBase as y, zIndexes as z };
905
+ export { cssVariables as $, boxShadows as A, sizes as B, aspectRatio as C, paddings as D, margins as E, varEmpty as F, displays as G, appearances as H, cursors as I, pointerEvents as J, resizes as K, userSelects as L, whitespaces as M, contents as N, breaks as O, textOverflows as P, textTransforms as Q, fontStyles as R, fontSmoothings as S, svgUtilities as T, transforms as U, transitions as V, fonts as W, tabSizes as X, textIndents as Y, textStrokes as Z, textShadows as _, appearance as a, cssProperty as a0, textDecorations as a1, borders as b, opacity as c, textColors as d, bgColors as e, flex as f, gaps as g, grids as h, overflows as i, justifies as j, orders as k, alignments as l, placements as m, insets as n, outline as o, positions as p, floats as q, rules as r, boxSizing as s, textAligns as t, questionMark as u, verticalAligns as v, willChange as w, rings as x, shadowBase as y, zIndexes as z };
@@ -37,12 +37,28 @@ const variantBreakpoints = (matcher, { theme }) => {
37
37
  }
38
38
  };
39
39
 
40
+ const scopeMatcher = (strict, name, template) => {
41
+ const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
42
+ return (matcher) => {
43
+ const match = matcher.match(re);
44
+ if (match) {
45
+ return {
46
+ matcher: matcher.slice(match[0].length),
47
+ selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
48
+ };
49
+ }
50
+ };
51
+ };
40
52
  const variantCombinators = [
41
- variants$1.variantMatcher("all", (input) => `${input} *`),
42
- variants$1.variantMatcher("children", (input) => `${input}>*`),
43
- variants$1.variantMatcher("next", (input) => `${input}+*`),
44
- variants$1.variantMatcher("sibling", (input) => `${input}+*`),
45
- variants$1.variantMatcher("siblings", (input) => `${input}~*`),
53
+ scopeMatcher(false, "all", "&&-s &&-c"),
54
+ scopeMatcher(false, "children", "&&-s>&&-c"),
55
+ scopeMatcher(false, "next", "&&-s+&&-c"),
56
+ scopeMatcher(false, "sibling", "&&-s+&&-c"),
57
+ scopeMatcher(false, "siblings", "&&-s~&&-c"),
58
+ scopeMatcher(true, "group", "&&-c &&-s"),
59
+ scopeMatcher(true, "parent", "&&-c>&&-s"),
60
+ scopeMatcher(true, "previous", "&&-c+&&-s"),
61
+ scopeMatcher(true, "peer", "&&-c~&&-s"),
46
62
  variants$1.variantMatcher("svg", (input) => `${input} svg`)
47
63
  ];
48
64
 
@@ -74,6 +90,17 @@ const variantLanguageDirections = [
74
90
  variants$1.variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
75
91
  ];
76
92
 
93
+ const variantLayer = {
94
+ match(matcher) {
95
+ const match = matcher.match(/layer-([\d\w]+)[:-]/);
96
+ if (match) {
97
+ return {
98
+ matcher: matcher.slice(match[0].length),
99
+ layer: match[1]
100
+ };
101
+ }
102
+ }
103
+ };
77
104
  const variantImportant = {
78
105
  match(matcher) {
79
106
  if (matcher.startsWith("!")) {
@@ -180,7 +207,7 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
180
207
  if (match[2])
181
208
  pseudo = `:${match[2]}(${pseudo})`;
182
209
  return {
183
- matcher: input.slice(match[1].length + tag.length + 2),
210
+ matcher: input.slice(match[0].length),
184
211
  selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`
185
212
  };
186
213
  }
@@ -191,7 +218,7 @@ const variantPseudoElements = (input) => {
191
218
  if (match) {
192
219
  const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
193
220
  return {
194
- matcher: input.slice(match[1].length + 1),
221
+ matcher: input.slice(match[0].length),
195
222
  selector: (s) => `${s}${pseudo}`
196
223
  };
197
224
  }
@@ -202,7 +229,7 @@ const variantPseudoClasses = {
202
229
  if (match) {
203
230
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
204
231
  return {
205
- matcher: input.slice(match[1].length + 1),
232
+ matcher: input.slice(match[0].length),
206
233
  selector: (s) => `${s}${pseudo}`
207
234
  };
208
235
  }
@@ -216,7 +243,7 @@ const variantPseudoClassFunctions = {
216
243
  const fn = match[1];
217
244
  const pseudo = PseudoClasses[match[2]] || `:${match[2]}`;
218
245
  return {
219
- matcher: input.slice(match[1].length + match[2].length + 2),
246
+ matcher: input.slice(match[0].length),
220
247
  selector: (s) => `${s}:${fn}(${pseudo})`
221
248
  };
222
249
  }
@@ -233,6 +260,14 @@ const variantTaggedPseudoClasses = (options = {}) => {
233
260
  {
234
261
  match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
235
262
  multiPass: true
263
+ },
264
+ {
265
+ match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
266
+ multiPass: true
267
+ },
268
+ {
269
+ match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
270
+ multiPass: true
236
271
  }
237
272
  ];
238
273
  };
@@ -251,6 +286,7 @@ const partClasses = {
251
286
  };
252
287
 
253
288
  const variants = (options) => [
289
+ variantLayer,
254
290
  variantNegative,
255
291
  variantImportant,
256
292
  variantPrint,
@@ -273,6 +309,7 @@ exports.variantColorsMediaOrClass = variantColorsMediaOrClass;
273
309
  exports.variantCombinators = variantCombinators;
274
310
  exports.variantImportant = variantImportant;
275
311
  exports.variantLanguageDirections = variantLanguageDirections;
312
+ exports.variantLayer = variantLayer;
276
313
  exports.variantMotions = variantMotions;
277
314
  exports.variantNegative = variantNegative;
278
315
  exports.variantOrientations = variantOrientations;
@@ -35,12 +35,28 @@ const variantBreakpoints = (matcher, { theme }) => {
35
35
  }
36
36
  };
37
37
 
38
+ const scopeMatcher = (strict, name, template) => {
39
+ const re = strict ? new RegExp(`^${name}(?:-\\[(.+?)\\])[:-]`) : new RegExp(`^${name}(?:-\\[(.+?)\\])?[:-]`);
40
+ return (matcher) => {
41
+ const match = matcher.match(re);
42
+ if (match) {
43
+ return {
44
+ matcher: matcher.slice(match[0].length),
45
+ selector: (s) => template.replace("&&-s", s).replace("&&-c", match[1] ?? "*")
46
+ };
47
+ }
48
+ };
49
+ };
38
50
  const variantCombinators = [
39
- variantMatcher("all", (input) => `${input} *`),
40
- variantMatcher("children", (input) => `${input}>*`),
41
- variantMatcher("next", (input) => `${input}+*`),
42
- variantMatcher("sibling", (input) => `${input}+*`),
43
- variantMatcher("siblings", (input) => `${input}~*`),
51
+ scopeMatcher(false, "all", "&&-s &&-c"),
52
+ scopeMatcher(false, "children", "&&-s>&&-c"),
53
+ scopeMatcher(false, "next", "&&-s+&&-c"),
54
+ scopeMatcher(false, "sibling", "&&-s+&&-c"),
55
+ scopeMatcher(false, "siblings", "&&-s~&&-c"),
56
+ scopeMatcher(true, "group", "&&-c &&-s"),
57
+ scopeMatcher(true, "parent", "&&-c>&&-s"),
58
+ scopeMatcher(true, "previous", "&&-c+&&-s"),
59
+ scopeMatcher(true, "peer", "&&-c~&&-s"),
44
60
  variantMatcher("svg", (input) => `${input} svg`)
45
61
  ];
46
62
 
@@ -72,6 +88,17 @@ const variantLanguageDirections = [
72
88
  variantMatcher("ltr", (input) => `[dir="ltr"] $$ ${input}`)
73
89
  ];
74
90
 
91
+ const variantLayer = {
92
+ match(matcher) {
93
+ const match = matcher.match(/layer-([\d\w]+)[:-]/);
94
+ if (match) {
95
+ return {
96
+ matcher: matcher.slice(match[0].length),
97
+ layer: match[1]
98
+ };
99
+ }
100
+ }
101
+ };
75
102
  const variantImportant = {
76
103
  match(matcher) {
77
104
  if (matcher.startsWith("!")) {
@@ -178,7 +205,7 @@ const taggedPseudoClassMatcher = (tag, parent, combinator) => {
178
205
  if (match[2])
179
206
  pseudo = `:${match[2]}(${pseudo})`;
180
207
  return {
181
- matcher: input.slice(match[1].length + tag.length + 2),
208
+ matcher: input.slice(match[0].length),
182
209
  selector: (s) => rawRe.test(s) ? s.replace(rawRe, `${parent}${pseudo}:`) : `${parent}${pseudo}${combinator}${s}`
183
210
  };
184
211
  }
@@ -189,7 +216,7 @@ const variantPseudoElements = (input) => {
189
216
  if (match) {
190
217
  const pseudo = PseudoElements[match[1]] || `::${match[1]}`;
191
218
  return {
192
- matcher: input.slice(match[1].length + 1),
219
+ matcher: input.slice(match[0].length),
193
220
  selector: (s) => `${s}${pseudo}`
194
221
  };
195
222
  }
@@ -200,7 +227,7 @@ const variantPseudoClasses = {
200
227
  if (match) {
201
228
  const pseudo = PseudoClasses[match[1]] || `:${match[1]}`;
202
229
  return {
203
- matcher: input.slice(match[1].length + 1),
230
+ matcher: input.slice(match[0].length),
204
231
  selector: (s) => `${s}${pseudo}`
205
232
  };
206
233
  }
@@ -214,7 +241,7 @@ const variantPseudoClassFunctions = {
214
241
  const fn = match[1];
215
242
  const pseudo = PseudoClasses[match[2]] || `:${match[2]}`;
216
243
  return {
217
- matcher: input.slice(match[1].length + match[2].length + 2),
244
+ matcher: input.slice(match[0].length),
218
245
  selector: (s) => `${s}:${fn}(${pseudo})`
219
246
  };
220
247
  }
@@ -231,6 +258,14 @@ const variantTaggedPseudoClasses = (options = {}) => {
231
258
  {
232
259
  match: taggedPseudoClassMatcher("peer", attributify ? '[peer=""]' : ".peer", "~"),
233
260
  multiPass: true
261
+ },
262
+ {
263
+ match: taggedPseudoClassMatcher("parent", attributify ? '[parent=""]' : ".parent", ">"),
264
+ multiPass: true
265
+ },
266
+ {
267
+ match: taggedPseudoClassMatcher("previous", attributify ? '[previous=""]' : ".previous", "+"),
268
+ multiPass: true
234
269
  }
235
270
  ];
236
271
  };
@@ -249,6 +284,7 @@ const partClasses = {
249
284
  };
250
285
 
251
286
  const variants = (options) => [
287
+ variantLayer,
252
288
  variantNegative,
253
289
  variantImportant,
254
290
  variantPrint,
@@ -265,4 +301,4 @@ const variants = (options) => [
265
301
  ...variantLanguageDirections
266
302
  ];
267
303
 
268
- export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g, variantImportant as h, variantNegative as i, variantPseudoElements as j, variantPseudoClasses as k, variantPseudoClassFunctions as l, variantTaggedPseudoClasses as m, partClasses as p, variants as v };
304
+ export { variantBreakpoints as a, variantCombinators as b, variantMotions as c, variantOrientations as d, variantPrint as e, variantColorsMediaOrClass as f, variantLanguageDirections as g, variantLayer as h, variantImportant as i, variantNegative as j, variantPseudoElements as k, variantPseudoClasses as l, variantPseudoClassFunctions as m, variantTaggedPseudoClasses as n, partClasses as p, variants as v };