@unocss/preset-mini 0.16.3 → 0.16.4

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,6 +1,6 @@
1
1
  import { hex2rgba, toArray } from '@unocss/core';
2
- import { h as handler, d as directionMap, c as cornerMap, a as capitalize, x as xyzMap } from './index.mjs';
3
- import { C as CONTROL_BYPASS_PSEUDO } from './pseudo.mjs';
2
+ import { h as handler, d as directionMap, c as cornerMap, a as capitalize, b as directionSize, x as xyzMap } from './utilities.mjs';
3
+ import { C as CONTROL_BYPASS_PSEUDO_CLASS } from './pseudo.mjs';
4
4
 
5
5
  const verticalAlignAlias = {
6
6
  mid: "middle",
@@ -19,7 +19,8 @@ const textAligns = [
19
19
 
20
20
  const parseColorUtil = (body, theme) => {
21
21
  const [main, opacity2] = body.split(/(?:\/|:)/);
22
- const [name, no = "DEFAULT"] = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
22
+ const colors = main.replace(/([a-z])([0-9])/g, "$1-$2").split(/-/g);
23
+ const [name] = colors;
23
24
  if (!name)
24
25
  return;
25
26
  let color;
@@ -30,8 +31,16 @@ const parseColorUtil = (body, theme) => {
30
31
  if (bracketOrMain.startsWith("hex-"))
31
32
  color = bracketOrMain.slice(4);
32
33
  color = color || bracket;
34
+ let no = "DEFAULT";
33
35
  if (!color) {
34
- const colorData = theme.colors?.[name];
36
+ let colorData = theme.colors?.[name];
37
+ if (colorData) {
38
+ [, no = no] = colors;
39
+ } else {
40
+ if (colors.slice(-1)[0].match(/^\d+$/))
41
+ no = colors.pop();
42
+ colorData = theme.colors?.[colors.join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase())];
43
+ }
35
44
  if (typeof colorData === "string")
36
45
  color = colorData;
37
46
  else if (no && colorData)
@@ -94,16 +103,136 @@ const ringOffsetColors = [
94
103
  [/^ring-offset-(.+)$/, colorResolver$1("--un-ring-offset-color", "ring-offset")],
95
104
  [/^ring-offset-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-ring-offset-opacity": handler.bracket.percent(opacity2) })]
96
105
  ];
97
- const fillColors = [
98
- ["fill-none", { fill: "none" }],
99
- [/^fill-(.+)$/, colorResolver$1("fill", "fill")],
100
- [/^fill-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-fill-opacity": handler.bracket.percent(opacity2) })]
106
+
107
+ const cssBasicProps = [
108
+ "color",
109
+ "border-color",
110
+ "background-color",
111
+ "flex-grow",
112
+ "flex",
113
+ "flex-shrink",
114
+ "caret-color",
115
+ "font",
116
+ "gap",
117
+ "opacity",
118
+ "visibility",
119
+ "z-index",
120
+ "font-weight",
121
+ "zoom",
122
+ "text-shadow",
123
+ "transform",
124
+ "box-shadow"
125
+ ];
126
+ const cssPositionProps = [
127
+ "backround-position",
128
+ "left",
129
+ "right",
130
+ "top",
131
+ "bottom",
132
+ "object-position"
133
+ ];
134
+ const cssSizeProps = [
135
+ "max-height",
136
+ "min-height",
137
+ "max-width",
138
+ "min-width",
139
+ "height",
140
+ "width",
141
+ "border-width",
142
+ "margin",
143
+ "padding",
144
+ "outline-width",
145
+ "outline-offset",
146
+ "font-size",
147
+ "line-height",
148
+ "text-indent",
149
+ "vertical-align",
150
+ "border-spacing",
151
+ "letter-spacing",
152
+ "word-spacing"
153
+ ];
154
+ const cssEnhanceProps = ["stroke", "filter", "backdrop-filter", "fill", "mask", "mask-size", "mask-border", "clip-path", "clip"];
155
+ const cssProps = [
156
+ ...cssBasicProps,
157
+ ...cssPositionProps,
158
+ ...cssSizeProps,
159
+ ...cssEnhanceProps
160
+ ];
161
+ const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
162
+ const displays = [
163
+ ["inline", { display: "inline" }],
164
+ ["block", { display: "block" }],
165
+ ["inline-block", { display: "inline-block" }],
166
+ ["contents", { display: "contents" }],
167
+ ["flow-root", { display: "flow-root" }],
168
+ ["list-item", { display: "list-item" }],
169
+ ["hidden", { display: "none" }]
170
+ ];
171
+ const appearances = [
172
+ ["visible", { visibility: "visible" }],
173
+ ["invisible", { visibility: "hidden" }],
174
+ ["backface-visible", { "backface-visibility": "visible" }],
175
+ ["backface-hidden", { "backface-visibility": "hidden" }]
176
+ ];
177
+ const cursors = [
178
+ [/^cursor-(.+)$/, ([, c]) => ({ cursor: c })]
179
+ ];
180
+ const pointerEvents = [
181
+ ["pointer-events-none", { "pointer-events": "none" }],
182
+ ["pointer-events-auto", { "pointer-events": "auto" }]
183
+ ];
184
+ const resizes = [
185
+ ["resize-none", { resize: "none" }],
186
+ ["resize-x", { resize: "horizontal" }],
187
+ ["resize-y", { resize: "vertical" }],
188
+ ["resize", { resize: "both" }]
189
+ ];
190
+ const userSelects = [
191
+ [/^select-(none|text|all|auto)$/, ([, v]) => ({ "user-select": v })]
192
+ ];
193
+ const whitespaces = [
194
+ [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
195
+ ];
196
+ const contents = [
197
+ ["content-empty", { content: '""' }]
198
+ ];
199
+ const breaks = [
200
+ ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
201
+ ["break-word", { "overflow-wrap": "break-word" }],
202
+ ["break-all", { "word-break": "break-all" }]
203
+ ];
204
+ const textOverflows = [
205
+ ["truncate", { "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }],
206
+ ["text-ellipsis", { "text-overflow": "ellipsis" }],
207
+ ["text-clip", { "text-overflow": "clip" }]
208
+ ];
209
+ const textTransforms = [
210
+ ["case-upper", { "text-transform": "uppercase" }],
211
+ ["case-lower", { "text-transform": "lowercase" }],
212
+ ["case-capital", { "text-transform": "capitalize" }],
213
+ ["case-normal", { "text-transform": "none" }]
214
+ ];
215
+ const fontStyles = [
216
+ ["italic", { "font-style": "italic" }],
217
+ ["not-italic", { "font-style": "normal" }]
218
+ ];
219
+ const fontSmoothings = [
220
+ ["antialiased", {
221
+ "-webkit-font-smoothing": "antialiased",
222
+ "-moz-osx-font-smoothing": "grayscale",
223
+ "font-smoothing": "grayscale"
224
+ }],
225
+ ["subpixel-antialiased", {
226
+ "-webkit-font-smoothing": "auto",
227
+ "-moz-osx-font-smoothing": "auto",
228
+ "font-smoothing": "auto"
229
+ }]
101
230
  ];
102
231
 
103
232
  const outlineStyle = ["none", "auto", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset", "inherit", "initial", "revert", "unset"];
104
233
  const parseOutlineSize = (s) => {
105
234
  const propName = ["width", "offset"].find((item) => s.startsWith(item)) || "width";
106
- const size = handler.bracket.fraction.rem(s.replace(/^(offset\-|width\-)/, ""));
235
+ const size = handler.bracket.fraction.rem(s.replace(/^(offset\-|width\-|size\-)/, ""));
107
236
  if (size) {
108
237
  return {
109
238
  [`outline-${propName}`]: size
@@ -128,15 +257,15 @@ const outline = [
128
257
  "outline-style": d
129
258
  };
130
259
  }
131
- const sizeSheet = parseOutlineSize(d);
132
- if (sizeSheet)
133
- return sizeSheet;
134
260
  const colorSheet = colorResolver$1("outline-color", "outline-color")([
135
261
  match[0],
136
262
  match[1].replace(/^color-/, "")
137
263
  ], config);
138
264
  if (colorSheet)
139
265
  return colorSheet;
266
+ const sizeSheet = parseOutlineSize(d);
267
+ if (sizeSheet)
268
+ return sizeSheet;
140
269
  }
141
270
  ]
142
271
  ];
@@ -161,6 +290,19 @@ const placeholder = [
161
290
  }
162
291
  ]
163
292
  ];
293
+ const cssPropsStr = cssProps.join(", ");
294
+ const validateProperty$1 = (prop) => {
295
+ if (prop && !cssProps.includes(prop))
296
+ return;
297
+ return prop || cssPropsStr;
298
+ };
299
+ const willChange = [
300
+ [/^will-change-(.*)/, ([, p]) => {
301
+ const w = validateProperty$1(p) || handler.global(p);
302
+ if (w)
303
+ return { "will-change": w };
304
+ }]
305
+ ];
164
306
 
165
307
  const borders = [
166
308
  [/^border$/, handlerBorder],
@@ -216,64 +358,10 @@ function handlerRounded([, a, b], { theme }) {
216
358
  return cornerMap[d].map((i) => [`border${i}-radius`, v]);
217
359
  }
218
360
 
219
- const transitionBasicProps = [
220
- "color",
221
- "border-color",
222
- "background-color",
223
- "flex-grow",
224
- "flex",
225
- "flex-shrink",
226
- "caret-color",
227
- "font",
228
- "gap",
229
- "opacity",
230
- "visibility",
231
- "z-index",
232
- "font-weight",
233
- "zoom",
234
- "text-shadow",
235
- "transform",
236
- "box-shadow"
237
- ];
238
- const transitionPositionProps = [
239
- "backround-position",
240
- "left",
241
- "right",
242
- "top",
243
- "bottom",
244
- "object-position"
245
- ];
246
- const transitionSizeProps = [
247
- "max-height",
248
- "min-height",
249
- "max-width",
250
- "min-width",
251
- "height",
252
- "width",
253
- "border-width",
254
- "margin",
255
- "padding",
256
- "outline-width",
257
- "outline-offset",
258
- "font-size",
259
- "line-height",
260
- "text-indent",
261
- "vertical-align",
262
- "border-spacing",
263
- "letter-spacing",
264
- "word-spacing"
265
- ];
266
361
  const transitionSwitchProps = ["all", "none"];
267
- const transitionEnhanceProps = ["stroke", "filter", "backdrop-filter", "fill", "mask", "mask-size", "mask-border", "clip-path", "clip"];
268
- const transitionProps = [
269
- ...transitionBasicProps,
270
- ...transitionPositionProps,
271
- ...transitionSizeProps,
272
- ...transitionEnhanceProps
273
- ];
274
- const transitionPropsStr = transitionProps.join(", ");
362
+ const transitionPropsStr = cssProps.join(", ");
275
363
  const validateProperty = (prop) => {
276
- if (prop && ![...transitionProps, ...transitionSwitchProps].includes(prop))
364
+ if (prop && ![...cssProps, ...transitionSwitchProps].includes(prop))
277
365
  return;
278
366
  return prop || transitionPropsStr;
279
367
  };
@@ -598,8 +686,8 @@ const rings = [
598
686
  "--un-ring-color": "rgba(59, 130, 246, .5)",
599
687
  "--un-ring-offset-shadow": "var(--un-ring-inset) 0 0 0 var(--un-ring-offset-width) var(--un-ring-offset-color)",
600
688
  "--un-ring-shadow": `var(--un-ring-inset) 0 0 0 calc(${value} + var(--un-ring-offset-width)) var(--un-ring-color)`,
601
- "-webkit-box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000);",
602
- "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000);"
689
+ "-webkit-box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000)",
690
+ "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow, 0 0 #0000)"
603
691
  };
604
692
  }
605
693
  }],
@@ -679,11 +767,6 @@ const aspectRatio = [
679
767
  }]
680
768
  ];
681
769
 
682
- const directionSize = (prefix) => ([_, direction, size]) => {
683
- const v = handler.bracket.rem.fraction.cssvar(size);
684
- if (v)
685
- return directionMap[direction].map((i) => [prefix + i, v]);
686
- };
687
770
  const paddings = [
688
771
  [/^pa?()-?(-?.+)$/, directionSize("padding")],
689
772
  [/^p-?([xy])-?(-?.+)$/, directionSize("padding")],
@@ -695,84 +778,13 @@ const margins = [
695
778
  [/^m-?([rltbse])-?(-?.+)$/, directionSize("margin")]
696
779
  ];
697
780
 
698
- const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
699
- const displays = [
700
- ["inline", { display: "inline" }],
701
- ["block", { display: "block" }],
702
- ["inline-block", { display: "inline-block" }],
703
- ["contents", { display: "contents" }],
704
- ["flow-root", { display: "flow-root" }],
705
- ["list-item", { display: "list-item" }],
706
- ["hidden", { display: "none" }]
707
- ];
708
- const appearances = [
709
- ["visible", { visibility: "visible" }],
710
- ["invisible", { visibility: "hidden" }],
711
- ["backface-visible", { "backface-visibility": "visible" }],
712
- ["backface-hidden", { "backface-visibility": "hidden" }]
713
- ];
714
- const cursors = [
715
- [/^cursor-(.+)$/, ([, c]) => ({ cursor: c })]
716
- ];
717
- const pointerEvents = [
718
- ["pointer-events-none", { "pointer-events": "none" }],
719
- ["pointer-events-auto", { "pointer-events": "auto" }]
720
- ];
721
- const resizes = [
722
- ["resize-none", { resize: "none" }],
723
- ["resize-x", { resize: "horizontal" }],
724
- ["resize-y", { resize: "vertical" }],
725
- ["resize", { resize: "both" }]
726
- ];
727
- const userSelects = [
728
- [/^select-(none|text|all|auto)$/, ([, v]) => ({ "user-select": v })]
729
- ];
730
- const whitespaces = [
731
- [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
732
- ];
733
- const contents = [
734
- ["content-empty", { content: '""' }]
735
- ];
736
- const breaks = [
737
- ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
738
- ["break-word", { "overflow-wrap": "break-word" }],
739
- ["break-all", { "word-break": "break-all" }]
740
- ];
741
- const textOverflows = [
742
- ["truncate", { "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }],
743
- ["text-ellipsis", { "text-overflow": "ellipsis" }],
744
- ["text-clip", { "text-overflow": "clip" }]
745
- ];
746
- const textTransforms = [
747
- ["case-upper", { "text-transform": "uppercase" }],
748
- ["case-lower", { "text-transform": "lowercase" }],
749
- ["case-capital", { "text-transform": "capitalize" }],
750
- ["case-normal", { "text-transform": "none" }]
751
- ];
752
- const fontStyles = [
753
- ["italic", { "font-style": "italic" }],
754
- ["not-italic", { "font-style": "normal" }]
755
- ];
756
- const fontSmoothings = [
757
- ["antialiased", {
758
- "-webkit-font-smoothing": "antialiased",
759
- "-moz-osx-font-smoothing": "grayscale",
760
- "font-smoothing": "grayscale"
761
- }],
762
- ["subpixel-antialiased", {
763
- "-webkit-font-smoothing": "auto",
764
- "-moz-osx-font-smoothing": "auto",
765
- "font-smoothing": "auto"
766
- }]
767
- ];
768
-
769
781
  const transformGpu = {
770
782
  transform: "rotate(var(--un-rotate)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) translate3d(var(--un-translate-x), var(--un-translate-y), var(--un-translate-z))",
771
- [CONTROL_BYPASS_PSEUDO]: ""
783
+ [CONTROL_BYPASS_PSEUDO_CLASS]: ""
772
784
  };
773
785
  const transformCpu = {
774
786
  transform: "rotate(var(--un-rotate)) scaleX(var(--un-scale-x)) scaleY(var(--un-scale-y)) scaleZ(var(--un-scale-z)) skewX(var(--un-skew-x)) skewY(var(--un-skew-y)) translateX(var(--un-translate-x)) translateY(var(--un-translate-y)) translateZ(var(--un-translate-z))",
775
- [CONTROL_BYPASS_PSEUDO]: ""
787
+ [CONTROL_BYPASS_PSEUDO_CLASS]: ""
776
788
  };
777
789
  const transformBase = {
778
790
  "--un-rotate": 0,
@@ -789,11 +801,12 @@ const transformBase = {
789
801
  const transforms = [
790
802
  ["transform", transformBase],
791
803
  [/^preserve-(3d|flat)$/, ([, value]) => ({ "transform-style": value === "3d" ? `preserve-${value}` : value })],
792
- [/^translate()-([^-]+)$/, handleTranslate],
793
- [/^translate-([xyz])-([^-]+)$/, handleTranslate],
794
- [/^scale()-([^-]+)$/, handleScale],
795
- [/^scale-([xyz])-([^-]+)$/, handleScale],
796
- [/^rotate-([^-]+)(?:deg)?$/, handleRotate],
804
+ [/^translate()-(.+)$/, handleTranslate],
805
+ [/^translate-([xyz])-(.+)$/, handleTranslate],
806
+ [/^scale()-(.+)$/, handleScale],
807
+ [/^scale-([xyz])-(.+)$/, handleScale],
808
+ [/^rotate-(.+)$/, handleRotate],
809
+ [/^rotate-((?!\[)[^-]+?)(?:deg)?$/, handleRotateWithUnit],
797
810
  ["transform-gpu", transformGpu],
798
811
  ["transform-cpu", transformCpu],
799
812
  ["transform-none", { transform: "none" }],
@@ -829,7 +842,7 @@ function handleScale([, d, b]) {
829
842
  ];
830
843
  }
831
844
  }
832
- function handleRotate([, b]) {
845
+ function handleRotateWithUnit([, b]) {
833
846
  const v = handler.bracket.number(b);
834
847
  if (v != null) {
835
848
  return [
@@ -838,6 +851,15 @@ function handleRotate([, b]) {
838
851
  ];
839
852
  }
840
853
  }
854
+ function handleRotate([, b]) {
855
+ const v = handler.bracket(b);
856
+ if (v != null) {
857
+ return [
858
+ transformBase,
859
+ { "--un-rotate": v }
860
+ ];
861
+ }
862
+ }
841
863
 
842
864
  const variablesAbbrMap = {
843
865
  "visible": "visibility",
@@ -921,6 +943,20 @@ const textDecorations = [
921
943
  [/^(?:underline|decoration)-op(?:acity)?-?(.+)$/m, ([, opacity]) => ({ "--un-line-opacity": handler.bracket.percent(opacity) })]
922
944
  ];
923
945
 
946
+ const svgUtilities = [
947
+ [/^fill-(.+)$/, colorResolver$1("fill", "fill")],
948
+ [/^fill-op(?:acity)?-?(.+)$/m, ([, opacity]) => ({ "--un-fill-opacity": handler.bracket.percent(opacity) })],
949
+ ["fill-none", { fill: "none" }],
950
+ [/^stroke-(?:size-|width-)?(.+)$/, ([, s]) => {
951
+ const v = handler.bracket.fraction.px.number(s);
952
+ if (v)
953
+ return { "stroke-width": v };
954
+ }],
955
+ [/^stroke-(.+)$/, colorResolver$1("stroke", "stroke")],
956
+ [/^stroke-op(?:acity)?-?(.+)$/m, ([, opacity]) => ({ "--un-stroke-opacity": handler.bracket.percent(opacity) })],
957
+ ["stroke-none", { stroke: "none" }]
958
+ ];
959
+
924
960
  const rules = [
925
961
  cssVariables,
926
962
  paddings,
@@ -928,7 +964,7 @@ const rules = [
928
964
  displays,
929
965
  opacity,
930
966
  bgColors,
931
- fillColors,
967
+ svgUtilities,
932
968
  borders,
933
969
  contents,
934
970
  fonts,
@@ -974,7 +1010,8 @@ const rules = [
974
1010
  boxSizing,
975
1011
  transitions,
976
1012
  transforms,
1013
+ willChange,
977
1014
  questionMark
978
1015
  ].flat(1);
979
1016
 
980
- export { tabSizes as $, floats as A, zIndexes as B, boxSizing as C, questionMark as D, rings as E, boxShadows as F, sizes as G, aspectRatio as H, paddings as I, margins as J, varEmpty as K, displays as L, appearances as M, cursors as N, pointerEvents as O, resizes as P, userSelects as Q, whitespaces as R, contents as S, breaks as T, textOverflows as U, textTransforms as V, fontStyles as W, fontSmoothings as X, transforms as Y, transitions as Z, fonts as _, appearance as a, textIndents as a0, textStrokes as a1, textShadows as a2, cssVariables as a3, textDecorations as a4, borders as b, parseColorUtil as c, colorResolver$1 as d, opacity as e, textColors as f, bgColors as g, borderColors as h, ringColors as i, ringOffsetColors as j, fillColors as k, flex as l, gaps as m, grids as n, outline as o, placeholder as p, overflows as q, rules as r, positions as s, textAligns as t, justifies as u, verticalAligns as v, orders as w, alignments as x, placements as y, insets as z };
1017
+ export { transitions as $, floats as A, zIndexes as B, boxSizing as C, questionMark as D, rings as E, boxShadows as F, sizes as G, aspectRatio as H, paddings as I, margins as J, cssProps as K, varEmpty as L, displays as M, appearances as N, cursors as O, pointerEvents as P, resizes as Q, userSelects as R, whitespaces as S, contents as T, breaks as U, textOverflows as V, textTransforms as W, fontStyles as X, fontSmoothings as Y, svgUtilities as Z, transforms as _, appearance as a, fonts as a0, tabSizes as a1, textIndents as a2, textStrokes as a3, textShadows as a4, cssVariables as a5, textDecorations as a6, borders as b, parseColorUtil as c, colorResolver$1 as d, opacity as e, textColors as f, bgColors as g, borderColors as h, ringColors as i, ringOffsetColors as j, flex as k, gaps as l, grids as m, overflows as n, outline as o, placeholder as p, positions as q, rules as r, justifies as s, textAligns as t, orders as u, verticalAligns as v, willChange as w, alignments as x, placements as y, insets as z };
@@ -37,10 +37,13 @@ const variantBreakpoints = (matcher, _, theme) => {
37
37
  }
38
38
  };
39
39
 
40
- const variantChildren = [
41
- variants$1.variantMatcher("children", (input) => `${input} > *`),
40
+ const variantCombinators = [
42
41
  variants$1.variantMatcher("all", (input) => `${input} *`),
43
- variants$1.variantMatcher("next", (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}~*`),
46
+ variants$1.variantMatcher("svg", (input) => `${input} svg *`)
44
47
  ];
45
48
 
46
49
  const variantColorsClass = [
@@ -115,15 +118,15 @@ const variants = [
115
118
  variantNegative,
116
119
  variantImportant,
117
120
  variantBreakpoints,
118
- ...variantChildren,
121
+ ...variantCombinators,
119
122
  pseudo.variantPseudoClasses,
120
123
  pseudo.variantPseudoElements
121
124
  ];
122
125
 
123
126
  exports.variantBreakpoints = variantBreakpoints;
124
- exports.variantChildren = variantChildren;
125
127
  exports.variantColorsClass = variantColorsClass;
126
128
  exports.variantColorsMedia = variantColorsMedia;
129
+ exports.variantCombinators = variantCombinators;
127
130
  exports.variantImportant = variantImportant;
128
131
  exports.variantNegative = variantNegative;
129
132
  exports.variantSpace = variantSpace;
@@ -35,10 +35,13 @@ const variantBreakpoints = (matcher, _, theme) => {
35
35
  }
36
36
  };
37
37
 
38
- const variantChildren = [
39
- variantMatcher("children", (input) => `${input} > *`),
38
+ const variantCombinators = [
40
39
  variantMatcher("all", (input) => `${input} *`),
41
- variantMatcher("next", (input) => `${input}+*`)
40
+ variantMatcher("children", (input) => `${input}>*`),
41
+ variantMatcher("next", (input) => `${input}+*`),
42
+ variantMatcher("sibling", (input) => `${input}+*`),
43
+ variantMatcher("siblings", (input) => `${input}~*`),
44
+ variantMatcher("svg", (input) => `${input} svg *`)
42
45
  ];
43
46
 
44
47
  const variantColorsClass = [
@@ -113,9 +116,9 @@ const variants = [
113
116
  variantNegative,
114
117
  variantImportant,
115
118
  variantBreakpoints,
116
- ...variantChildren,
119
+ ...variantCombinators,
117
120
  variantPseudoClasses,
118
121
  variantPseudoElements
119
122
  ];
120
123
 
121
- export { variantColorsMedia as a, variantColorsClass as b, variantBreakpoints as c, variantChildren as d, variantImportant as e, variantNegative as f, variantSpace as g, variants as v };
124
+ export { variantColorsMedia as a, variantColorsClass as b, variantBreakpoints as c, variantCombinators as d, variantImportant as e, variantNegative as f, variantSpace as g, variants as v };
@@ -2,40 +2,42 @@
2
2
 
3
3
  const core = require('@unocss/core');
4
4
 
5
- const CONTROL_BYPASS_PSEUDO = "$$no-pseudo";
5
+ const CONTROL_BYPASS_PSEUDO_CLASS = "$$no-pseudo";
6
6
  const PseudoClasses = Object.fromEntries([
7
+ "any-link",
8
+ "link",
9
+ "visited",
10
+ "target",
11
+ "hover",
7
12
  "active",
8
- "checked",
9
- "default",
10
- "empty",
11
- "enabled",
12
- "disabled",
13
- "first-of-type",
14
- ["first", "first-child"],
15
13
  "focus-visible",
16
14
  "focus-within",
17
15
  "focus",
18
- "hover",
19
- "indeterminate",
20
- "invalid",
21
- "last-of-type",
22
- ["last", "last-child"],
23
- "link",
24
- "only-child",
25
- "only-of-type",
26
- "optional",
27
- "placeholder-shown",
16
+ "autofill",
17
+ "enabled",
18
+ "disabled",
28
19
  "read-only",
29
20
  "read-write",
21
+ "placeholder-shown",
22
+ "default",
23
+ "checked",
24
+ "indeterminate",
25
+ "valid",
26
+ "invalid",
30
27
  "required",
28
+ "optional",
31
29
  "root",
32
- "target",
33
- "valid",
34
- "visited",
30
+ "empty",
35
31
  ["even-of-type", "nth-of-type(even)"],
36
32
  ["even", "nth-child(even)"],
37
33
  ["odd-of-type", "nth-of-type(odd)"],
38
- ["odd", "nth-child(odd)"]
34
+ ["odd", "nth-child(odd)"],
35
+ "first-of-type",
36
+ ["first", "first-child"],
37
+ "last-of-type",
38
+ ["last", "last-child"],
39
+ "only-child",
40
+ "only-of-type"
39
41
  ].map(core.toArray));
40
42
  const PseudoElements = [
41
43
  "before",
@@ -48,19 +50,19 @@ const PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
48
50
  const PseudoClassesStr = Object.keys(PseudoClasses).join("|");
49
51
  const PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
50
52
  const PseudoClassesNotRE = new RegExp(`^not-(${PseudoClassesStr})[:-]`);
51
- const PseudoClassesGroupRE = new RegExp(`^group-(${PseudoClassesStr})[:-]`);
52
- const PseudoClassesPeerRE = new RegExp(`^peer-(${PseudoClassesStr})[:-]`);
53
+ const PseudoClassesGroupRE = new RegExp(`^group-((not-)?(${PseudoClassesStr}))[:-]`);
54
+ const PseudoClassesPeerRE = new RegExp(`^peer-((not-)?(${PseudoClassesStr}))[:-]`);
53
55
  const variantPseudoElements = (input) => {
54
56
  const match = input.match(PseudoElementsRE);
55
57
  if (match) {
56
58
  return {
57
59
  matcher: input.slice(match[1].length + 1),
58
- selector: (s, body) => shouldAdd(body) && `${s}::${match[1]}`
60
+ selector: (s) => `${s}::${match[1]}`
59
61
  };
60
62
  }
61
63
  };
62
64
  function shouldAdd(entires) {
63
- return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO) || void 0;
65
+ return !entires.find((i) => i[0] === CONTROL_BYPASS_PSEUDO_CLASS) || void 0;
64
66
  }
65
67
  const variantPseudoClasses = {
66
68
  match: (input) => {
@@ -82,7 +84,9 @@ const variantPseudoClasses = {
82
84
  }
83
85
  match = input.match(PseudoClassesGroupRE);
84
86
  if (match) {
85
- const pseudo = PseudoClasses[match[1]] || match[1];
87
+ let pseudo = PseudoClasses[match[3]] || match[3];
88
+ if (match[2])
89
+ pseudo = `not(:${pseudo})`;
86
90
  return {
87
91
  matcher: input.slice(match[1].length + 7),
88
92
  selector: (s, body) => shouldAdd(body) && s.includes(".group:") ? s.replace(/\.group:/, `.group:${pseudo}:`) : `.group:${pseudo} ${s}`
@@ -90,17 +94,19 @@ const variantPseudoClasses = {
90
94
  }
91
95
  match = input.match(PseudoClassesPeerRE);
92
96
  if (match) {
93
- const pseudo = PseudoClasses[match[1]] || match[1];
97
+ let pseudo = PseudoClasses[match[3]] || match[3];
98
+ if (match[2])
99
+ pseudo = `not(:${pseudo})`;
94
100
  return {
95
101
  matcher: input.slice(match[1].length + 6),
96
- selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo} ~ ${s}`
102
+ selector: (s, body) => shouldAdd(body) && s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo}~${s}`
97
103
  };
98
104
  }
99
105
  },
100
106
  multiPass: true
101
107
  };
102
108
 
103
- exports.CONTROL_BYPASS_PSEUDO = CONTROL_BYPASS_PSEUDO;
109
+ exports.CONTROL_BYPASS_PSEUDO_CLASS = CONTROL_BYPASS_PSEUDO_CLASS;
104
110
  exports.PseudoClasses = PseudoClasses;
105
111
  exports.variantPseudoClasses = variantPseudoClasses;
106
112
  exports.variantPseudoElements = variantPseudoElements;