@unocss/preset-uno 0.11.0 → 0.11.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,10 @@
1
1
  import {
2
- __export
3
- } from "./chunk-5SH5BFJ4.mjs";
2
+ capitalize,
3
+ cornerMap,
4
+ directionMap,
5
+ handler,
6
+ xyzMap
7
+ } from "./chunk-FOQKHXUZ.mjs";
4
8
 
5
9
  // src/rules/transition.ts
6
10
  var transitionBasicProps = [
@@ -93,147 +97,6 @@ var transitions = [
93
97
  }]
94
98
  ];
95
99
 
96
- // src/utils/mappings.ts
97
- var directionMap = {
98
- "l": ["-left"],
99
- "r": ["-right"],
100
- "t": ["-top"],
101
- "b": ["-bottom"],
102
- "s": ["-inline-start"],
103
- "e": ["-inline-end"],
104
- "x": ["-left", "-right"],
105
- "y": ["-top", "-bottom"],
106
- "": [""],
107
- "a": [""]
108
- };
109
- var cornerMap = {
110
- "t": ["-top-left", "-top-right"],
111
- "r": ["-top-right", "-bottom-right"],
112
- "b": ["-bottom-left", "-bottom-right"],
113
- "l": ["-bottom-left", "-top-left"],
114
- "tl": ["-top-left"],
115
- "lt": ["-top-left"],
116
- "tr": ["-top-right"],
117
- "rt": ["-top-right"],
118
- "bl": ["-bottom-left"],
119
- "lb": ["-bottom-left"],
120
- "br": ["-bottom-right"],
121
- "rb": ["-bottom-right"],
122
- "": [""]
123
- };
124
- var xyzMap = {
125
- "x": ["-x"],
126
- "y": ["-y"],
127
- "z": ["-z"],
128
- "": ["-x", "-y"]
129
- };
130
-
131
- // src/utils/handlers/handlers.ts
132
- var handlers_exports = {};
133
- __export(handlers_exports, {
134
- bracket: () => bracket,
135
- cssvar: () => cssvar,
136
- fraction: () => fraction,
137
- number: () => number,
138
- percent: () => percent,
139
- px: () => px,
140
- rem: () => rem,
141
- time: () => time
142
- });
143
- var numberWithUnitRE = /^(-?[0-9.]+)([a-z]*)$/i;
144
- var numberRE = /^(-?[0-9.]+)$/i;
145
- function rem(str) {
146
- if (str === "auto" || str === "a")
147
- return "auto";
148
- const match = str.match(numberWithUnitRE);
149
- if (!match)
150
- return;
151
- const [, n, unit] = match;
152
- if (unit)
153
- return str;
154
- const num = parseFloat(n);
155
- if (!Number.isNaN(num))
156
- return `${num / 4}rem`;
157
- }
158
- function px(str) {
159
- const match = str.match(numberWithUnitRE);
160
- if (!match)
161
- return;
162
- const [, n, unit] = match;
163
- if (unit)
164
- return str;
165
- const num = parseFloat(n);
166
- if (!Number.isNaN(num))
167
- return `${num}px`;
168
- }
169
- function number(str) {
170
- if (!numberRE.test(str))
171
- return;
172
- const num = parseFloat(str);
173
- if (!Number.isNaN(num))
174
- return num;
175
- }
176
- function percent(str) {
177
- if (str.endsWith("%"))
178
- str = str.slice(0, -1);
179
- const num = parseFloat(str);
180
- if (!Number.isNaN(num))
181
- return `${num / 100}`;
182
- }
183
- function fraction(str) {
184
- const [left, right] = str.split("/");
185
- const num = parseFloat(left) / parseFloat(right);
186
- if (!Number.isNaN(num))
187
- return `${num * 100}%`;
188
- }
189
- function bracket(str) {
190
- if (str && str[0] === "[" && str[str.length - 1] === "]")
191
- return str.slice(1, -1).replace(/_/g, " ");
192
- }
193
- function cssvar(str) {
194
- if (str.startsWith("$"))
195
- return `var(--${str.slice(1)})`;
196
- }
197
- function time(str) {
198
- const duration = Number(str.replace(/(s|ms)$/, ""));
199
- if (isNaN(duration))
200
- return;
201
- if (/ms|s$/.test(str))
202
- return str;
203
- return `${str}ms`;
204
- }
205
-
206
- // src/utils/handlers/shorthand.ts
207
- var handlersNames = Object.keys(handlers_exports);
208
- var handler = function(str) {
209
- var _a;
210
- const s = ((_a = this.__options) == null ? void 0 : _a.sequence) || [];
211
- this.__options.sequence = [];
212
- for (const n of s) {
213
- const res = handlers_exports[n](str);
214
- if (res != null)
215
- return res;
216
- }
217
- return void 0;
218
- };
219
- function addProcessor(that, name) {
220
- if (!that.__options) {
221
- that.__options = {
222
- sequence: []
223
- };
224
- }
225
- that.__options.sequence.push(name);
226
- return that;
227
- }
228
- handlersNames.forEach((i) => {
229
- Object.defineProperty(handler, i, {
230
- enumerable: true,
231
- get() {
232
- return addProcessor(this, i);
233
- }
234
- });
235
- });
236
-
237
100
  // src/rules/color.ts
238
101
  import { hex2rgba } from "@unocss/core";
239
102
  var parseColorUtil = (body, theme) => {
@@ -243,11 +106,11 @@ var parseColorUtil = (body, theme) => {
243
106
  if (!name)
244
107
  return;
245
108
  let color;
246
- const bracket2 = handler.bracket(main) || main;
247
- if (bracket2.startsWith("#"))
248
- color = bracket2.slice(1);
249
- if (bracket2.startsWith("hex-"))
250
- color = bracket2.slice(4);
109
+ const bracket = handler.bracket(main) || main;
110
+ if (bracket.startsWith("#"))
111
+ color = bracket.slice(1);
112
+ if (bracket.startsWith("hex-"))
113
+ color = bracket.slice(4);
251
114
  if (!color) {
252
115
  const colorData = (_a = theme.colors) == null ? void 0 : _a[name];
253
116
  if (typeof colorData === "string")
@@ -332,6 +195,11 @@ var divideColors = [
332
195
  [/^divide-(.+)$/, colorResolver("border-color", "divide")],
333
196
  [/^divide-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-divide-opacity": handler.bracket.percent(opacity2) })]
334
197
  ];
198
+ var fillColors = [
199
+ ["fill-none", { fill: "none" }],
200
+ [/^fill-(.+)$/, colorResolver("fill", "fill")],
201
+ [/^fill-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-fill-opacity": handler.bracket.percent(opacity2) })]
202
+ ];
335
203
 
336
204
  // src/rules/border.ts
337
205
  var borderSizes = [
@@ -375,6 +243,43 @@ function handlerRounded([, a, b], { theme }) {
375
243
  return cornerMap[d].map((i) => [`border${i}-radius`, v]);
376
244
  }
377
245
 
246
+ // src/rules/container.ts
247
+ import { toArray } from "@unocss/core";
248
+ var queryMatcher = /@media \(min-width: (.+)\)/;
249
+ var container = [
250
+ [
251
+ /^__container$/,
252
+ (m, { variantHandlers }) => {
253
+ var _a;
254
+ let width = "100%";
255
+ for (const v of variantHandlers) {
256
+ const query = toArray(v.parent || [])[0];
257
+ if (typeof query === "string") {
258
+ const match = (_a = query.match(queryMatcher)) == null ? void 0 : _a[1];
259
+ if (match)
260
+ width = match;
261
+ }
262
+ }
263
+ return { "max-width": width };
264
+ },
265
+ { internal: true }
266
+ ]
267
+ ];
268
+ var containerShortcuts = [
269
+ [/^(?:(\w+)[:-])?container$/, ([, bp], { theme }) => {
270
+ let points = Object.keys(theme.breakpoints || {});
271
+ if (bp) {
272
+ if (!points.includes(bp))
273
+ return;
274
+ points = points.slice(points.indexOf(bp));
275
+ }
276
+ const shortcuts = points.map((p) => `${p}:__container`);
277
+ if (!bp)
278
+ shortcuts.unshift("__container");
279
+ return shortcuts;
280
+ }]
281
+ ];
282
+
378
283
  // src/rules/background.ts
379
284
  var colorResolver2 = (mode) => ([, body], { theme }) => {
380
285
  const data = parseColorUtil(body, theme);
@@ -388,7 +293,7 @@ var colorResolver2 = (mode) => ([, body], { theme }) => {
388
293
  const a = opacity2 ? opacity2[0] === "[" ? handler.bracket.percent(opacity2) : parseFloat(opacity2) / 100 : rgba[3];
389
294
  if (a != null && !Number.isNaN(a)) {
390
295
  rgba[3] = typeof a === "string" && !a.includes("%") ? parseFloat(a) : a;
391
- colorString = `rgba(${rgba.join(",")}, var(--un-${mode}-opacity, 1))`;
296
+ colorString = `rgba(${rgba.join(",")})`;
392
297
  } else {
393
298
  colorString = `rgba(${rgba.slice(0, 3).join(",")}, var(--un-${mode}-opacity, 1))`;
394
299
  }
@@ -441,7 +346,10 @@ var bgClips = [
441
346
  var bgGradients = [
442
347
  [/^from-(.+)$/, colorResolver2("from")],
443
348
  [/^to-(.+)$/, colorResolver2("to")],
444
- [/^via-(.+)$/, colorResolver2("via")]
349
+ [/^via-(.+)$/, colorResolver2("via")],
350
+ [/^from-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-from-opacity": handler.bracket.percent(opacity2) })],
351
+ [/^to-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-to-opacity": handler.bracket.percent(opacity2) })],
352
+ [/^via-op(?:acity)?-?(.+)$/m, ([, opacity2]) => ({ "--un-via-opacity": handler.bracket.percent(opacity2) })]
445
353
  ];
446
354
  var bgImages = [
447
355
  ["bg-none", { "background-image": "none" }],
@@ -501,7 +409,7 @@ var bgSizes = [
501
409
  ];
502
410
 
503
411
  // src/rules/filters.ts
504
- import { toArray } from "@unocss/core";
412
+ import { toArray as toArray2 } from "@unocss/core";
505
413
  var varEmpty = "var(--un-empty,/*!*/ /*!*/)";
506
414
  var percentWithDefault = (defaultValue = "1") => (str) => {
507
415
  const v = str ? handler.bracket.percent(str) : defaultValue;
@@ -556,7 +464,7 @@ var filters = [
556
464
  var _a;
557
465
  const v = handler.bracket(s) || ((_a = theme.dropShadow) == null ? void 0 : _a[s || "DEFAULT"]);
558
466
  if (v)
559
- return toArray(v).map((v2) => `drop-shadow(${v2})`).join(" ");
467
+ return toArray2(v).map((v2) => `drop-shadow(${v2})`).join(" ");
560
468
  })],
561
469
  [/^(backdrop-)?grayscale(?:-(\d+))?$/, toFilter("grayscale", percentWithDefault())],
562
470
  [/^(backdrop-)?hue-rotate-(\d+)$/, toFilter("hue-rotate", (s) => `${handler.bracket.number(s)}deg`)],
@@ -589,7 +497,7 @@ var flex = [
589
497
  ];
590
498
 
591
499
  // src/rules/typography.ts
592
- import { toArray as toArray2 } from "@unocss/core";
500
+ import { toArray as toArray3 } from "@unocss/core";
593
501
  var fontsFamilies = [
594
502
  [/^font-(\w+)$/, ([, d], { theme }) => {
595
503
  var _a;
@@ -615,7 +523,7 @@ var weightMap = {
615
523
  var fontSizes = [
616
524
  [/^text-([^-]+)$/, ([, s = "base"], { theme }) => {
617
525
  var _a;
618
- const result = toArray2(((_a = theme.fontSize) == null ? void 0 : _a[s]) || handler.bracket.rem(s));
526
+ const result = toArray3(((_a = theme.fontSize) == null ? void 0 : _a[s]) || handler.bracket.rem(s));
619
527
  if (result == null ? void 0 : result[0]) {
620
528
  const [size, height = "1"] = result;
621
529
  return {
@@ -734,58 +642,50 @@ var gaps = [
734
642
  ];
735
643
 
736
644
  // src/rules/grid.ts
737
- import { toArray as toArray3 } from "@unocss/core";
645
+ import { toArray as toArray4 } from "@unocss/core";
738
646
  var calSize = (s, theme) => {
739
647
  var _a;
740
- return toArray3(((_a = theme.fontSize) == null ? void 0 : _a[s]) || handler.bracket.rem(s))[0];
648
+ return toArray4(((_a = theme.fontSize) == null ? void 0 : _a[s]) || handler.bracket.rem(s))[0];
741
649
  };
742
- var isNumber = (s) => !isNaN(Number(s));
743
650
  var autoDirection = (selector, theme) => {
744
651
  if (selector === "min")
745
652
  return "min-content";
746
653
  else if (selector === "max")
747
654
  return "max-content";
748
655
  else if (selector === "fr")
749
- return "minmax(0, 1fr)";
656
+ return "minmax(0,1fr)";
750
657
  return calSize(selector, theme);
751
658
  };
752
659
  var grids = [
753
660
  ["grid", { display: "grid" }],
754
661
  ["inline-grid", { display: "inline-grid" }],
755
- [/^grid-cols-(\d+)$/, ([, d]) => ({ "grid-template-columns": `repeat(${d}, minmax(0, 1fr))` })],
756
- [/^grid-rows-(\d+)$/, ([, d]) => ({ "grid-template-rows": `repeat(${d}, minmax(0, 1fr))` })],
662
+ [/^grid-cols-(\d+)$/, ([, d]) => ({ "grid-template-columns": `repeat(${d},minmax(0,1fr))` })],
663
+ [/^grid-rows-(\d+)$/, ([, d]) => ({ "grid-template-rows": `repeat(${d},minmax(0,1fr))` })],
757
664
  [/^grid-cols-\[(.+)\]$/, ([, v]) => ({ "grid-template-columns": v.replace(/,/g, " ") })],
758
665
  [/^grid-rows-\[(.+)\]$/, ([, v]) => ({ "grid-template-rows": v.replace(/,/g, " ") })],
759
- [/^(?:grid-)?auto-flow-(.+)$/, ([, v]) => ({ "grid-auto-flow": `${v.replace("col", "column").split("-").join(" ")}` })],
760
- [/^(?:grid-)?row-start-(.+)$/, ([, v]) => ({ "grid-row-start": `${v}` })],
761
- [/^(?:grid-)?row-end-(.+)$/, ([, v]) => ({ "grid-row-end": `${v}` })],
762
- [/^(?:grid-)?col-start-(.+)$/, ([, v]) => ({ "grid-column-start": `${v}` })],
763
- [/^(?:grid-)?col-end-(.+)$/, ([, v]) => ({ "grid-column-end": `${v}` })],
764
- [/^(?:grid-)?auto-rows-(.+)$/, ([, v], { theme }) => ({ "grid-auto-rows": `${autoDirection(v, theme)}` })],
765
- [/^(?:grid-)?auto-cols-(.+)$/, ([, v], { theme }) => ({ "grid-auto-columns": `${autoDirection(v, theme)}` })],
766
- [/^(?:grid-)?row-((?!(start)|(end)).+)$/, ([, v]) => {
767
- const shortArr = v.split("-");
768
- if (shortArr[0] === "span") {
769
- if (shortArr[1] === "full") {
770
- return {
771
- "grid-row": "1 / -1"
772
- };
773
- }
774
- return isNumber(shortArr[1]) ? { "grid-row": `span ${shortArr[1]} / span ${shortArr[1]}` } : void 0;
775
- }
776
- return { "grid-row": v.split("-").join(" ") };
777
- }],
778
- [/^(?:grid-)?col-((?!(start)|(end)).+)$/, ([, v]) => {
779
- const shortArr = v.split("-");
780
- if (shortArr[0] === "span") {
781
- if (shortArr[1] === "full") {
782
- return {
783
- "grid-column": "1 / -1"
784
- };
785
- }
786
- return isNumber(shortArr[1]) ? { "grid-column": `span ${shortArr[1]} / span ${shortArr[1]}` } : void 0;
666
+ [/^(?:grid-)?auto-flow-([\w.-]+)$/, ([, v]) => ({ "grid-auto-flow": `${v.replace("col", "column").split("-").join(" ")}` })],
667
+ [/^(?:grid-)?row-start-([\w.-]+)$/, ([, v]) => ({ "grid-row-start": `${v}` })],
668
+ [/^(?:grid-)?row-end-([\w.-]+)$/, ([, v]) => ({ "grid-row-end": `${v}` })],
669
+ [/^(?:grid-)?col-start-([\w.-]+)$/, ([, v]) => ({ "grid-column-start": `${v}` })],
670
+ [/^(?:grid-)?col-end-([\w.]+)$/, ([, v]) => ({ "grid-column-end": `${v}` })],
671
+ [/^(?:grid-)?auto-rows-([\w.-]+)$/, ([, v], { theme }) => ({ "grid-auto-rows": `${autoDirection(v, theme)}` })],
672
+ [/^(?:grid-)?auto-cols-([\w.-]+)$/, ([, v], { theme }) => ({ "grid-auto-columns": `${autoDirection(v, theme)}` })],
673
+ [/^(?:grid-)?(row|col)-(.+)$/, ([, d, v]) => {
674
+ var _a;
675
+ const key = d === "row" ? "grid-row" : "grid-column";
676
+ let raw = handler.bracket(v);
677
+ if (raw)
678
+ return { [key]: raw };
679
+ const parts = v.split("-");
680
+ if (parts.length === 1 && parts[0] === "auto")
681
+ return { [key]: parts[0] };
682
+ if (parts[0] === "span") {
683
+ if (parts[1] === "full")
684
+ return { [key]: "1/-1" };
685
+ raw = (_a = handler.number.bracket(parts[1])) == null ? void 0 : _a.toString().replace(/_/g, " ");
686
+ if (raw)
687
+ return { [key]: `span ${raw}/span ${raw}` };
787
688
  }
788
- return { "grid-column": v.split("-").join(" ") };
789
689
  }]
790
690
  ];
791
691
 
@@ -880,6 +780,7 @@ var objectPositions = [
880
780
  ["object-fill", { "object-fit": "fill" }],
881
781
  ["object-scale-down", { "object-fit": "scale-down" }],
882
782
  ["object-none", { "object-fit": "none" }],
783
+ ["object-center", { "object-position": "center" }],
883
784
  ["object-bottom", { "object-position": "bottom" }],
884
785
  ["object-top", { "object-position": "top" }],
885
786
  ["object-right", { "object-position": "right" }],
@@ -887,7 +788,9 @@ var objectPositions = [
887
788
  ["object-lb", { "object-position": "left bottom" }],
888
789
  ["object-lt", { "object-position": "left top" }],
889
790
  ["object-rb", { "object-position": "right bottom" }],
890
- ["object-rt", { "object-position": "right top" }]
791
+ ["object-rt", { "object-position": "right top" }],
792
+ ["object-cb", { "object-position": "center bottom" }],
793
+ ["object-ct", { "object-position": "center top" }]
891
794
  ];
892
795
  var boxSizing = [
893
796
  [
@@ -983,30 +886,21 @@ var boxShadows = [
983
886
 
984
887
  // src/rules/size.ts
985
888
  function getPropName(minmax, hw) {
986
- const minMaxMap = {
987
- w: "width",
988
- h: "height"
989
- };
990
- return `${minmax ? `${minmax}-` : ""}${minMaxMap[hw]}`;
889
+ return `${minmax ? `${minmax}-` : ""}${hw === "h" ? "height" : "width"}`;
890
+ }
891
+ function getThemeValue(minmax, hw, theme, prop) {
892
+ var _a;
893
+ let str = `${hw === "h" ? "height" : "width"}`;
894
+ if (minmax)
895
+ str = `${minmax}${capitalize(str)}`;
896
+ return (_a = theme[str]) == null ? void 0 : _a[prop];
991
897
  }
992
898
  var sizes = [
993
- ["w-full", { width: "100%" }],
994
- ["h-full", { height: "100%" }],
995
- ["w-screen", { width: "100vw" }],
996
- ["h-screen", { height: "100vh" }],
997
- ["max-w-none", { "max-width": "none" }],
998
- ["max-w-full", { "max-width": "100%" }],
999
- ["max-w-screen", { "max-width": "100vw" }],
1000
- ["min-w-none", { "min-width": "none" }],
1001
- ["min-w-full", { "min-width": "100%" }],
1002
- ["min-w-screen", { "min-width": "100vw" }],
1003
- ["max-h-none", { "max-height": "none" }],
1004
- ["max-h-full", { "max-height": "100%" }],
1005
- ["max-h-screen", { "max-height": "100vh" }],
1006
- ["min-h-none", { "min-height": "none" }],
1007
- ["min-h-full", { "min-height": "100%" }],
1008
- ["min-h-screen", { "min-height": "100vh" }],
1009
- [/^(?:(min|max)-)?(w|h)-(.+)$/, ([, m, w, s]) => ({ [getPropName(m, w)]: handler.bracket.cssvar.fraction.rem(s) })],
899
+ [/^(?:(min|max)-)?(w|h)-(.+)$/, ([, m, w, s], { theme }) => {
900
+ const v = getThemeValue(m, w, theme, s) || handler.bracket.cssvar.fraction.rem(s);
901
+ if (v != null)
902
+ return { [getPropName(m, w)]: v };
903
+ }],
1010
904
  [/^(?:(min|max)-)?(w)-screen-(.+)$/, ([, m, w, s], { theme }) => {
1011
905
  var _a;
1012
906
  const v = (_a = theme.breakpoints) == null ? void 0 : _a[s];
@@ -1194,6 +1088,10 @@ var screenReadersAccess = [
1194
1088
  }
1195
1089
  ]
1196
1090
  ];
1091
+ var isolations = [
1092
+ ["isolate", { isolation: "isolate" }],
1093
+ ["isolate-auto", { isolation: "auto" }]
1094
+ ];
1197
1095
 
1198
1096
  // src/rules/table.ts
1199
1097
  var tables = [
@@ -1640,6 +1538,8 @@ var rules = [
1640
1538
  paddings,
1641
1539
  margins,
1642
1540
  lineClamps,
1541
+ isolations,
1542
+ container,
1643
1543
  displays,
1644
1544
  opacity,
1645
1545
  bgAttachments,
@@ -1652,6 +1552,7 @@ var rules = [
1652
1552
  bgPositions,
1653
1553
  bgSizes,
1654
1554
  bgRepeats,
1555
+ fillColors,
1655
1556
  borders,
1656
1557
  divides,
1657
1558
  fonts,
@@ -1728,5 +1629,6 @@ var rules = [
1728
1629
  ].flat(1);
1729
1630
 
1730
1631
  export {
1632
+ containerShortcuts,
1731
1633
  rules
1732
1634
  };
@@ -1,3 +1,7 @@
1
+ import {
2
+ variantMatcher
3
+ } from "./chunk-FOQKHXUZ.mjs";
4
+
1
5
  // src/variants/breakpoints.ts
2
6
  var regexCache = {};
3
7
  var variantBreakpoints = (matcher, _, theme) => {
@@ -14,25 +18,16 @@ var variantBreakpoints = (matcher, _, theme) => {
14
18
  direction = "max";
15
19
  order = -order;
16
20
  }
21
+ const m = matcher.slice(pre.length);
22
+ if (m === "container")
23
+ continue;
17
24
  return {
18
- matcher: matcher.slice(pre.length),
25
+ matcher: m,
19
26
  parent: [`@media (${direction}-width: ${size})`, order]
20
27
  };
21
28
  }
22
29
  };
23
30
 
24
- // src/utils/variants.ts
25
- var variantMatcher = (name, selector) => {
26
- const length = name.length + 1;
27
- const re = new RegExp(`^${name}[:-]`);
28
- return (input) => {
29
- return input.match(re) ? {
30
- matcher: input.slice(length),
31
- selector
32
- } : void 0;
33
- };
34
- };
35
-
36
31
  // src/variants/children.ts
37
32
  var variantChildren = [
38
33
  variantMatcher("children", (input) => `${input} > *`),
@@ -40,30 +35,6 @@ var variantChildren = [
40
35
  variantMatcher("next", (input) => `${input}+*`)
41
36
  ];
42
37
 
43
- // src/variants/dark.ts
44
- var variantColorsClass = [
45
- variantMatcher("dark", (input) => `.dark $$ ${input}`),
46
- variantMatcher("light", (input) => `.light $$ ${input}`)
47
- ];
48
- var variantColorsMedia = [
49
- (v) => {
50
- const dark = variantMatcher("dark")(v);
51
- if (dark) {
52
- return {
53
- ...dark,
54
- parent: "@media (prefers-color-scheme: dark)"
55
- };
56
- }
57
- const light = variantMatcher("light")(v);
58
- if (light) {
59
- return {
60
- ...light,
61
- parent: "@media (prefers-color-scheme: dark)"
62
- };
63
- }
64
- }
65
- ];
66
-
67
38
  // src/variants/pseudo.ts
68
39
  import { toArray } from "@unocss/core";
69
40
  var PseudoClasses = Object.fromEntries([
@@ -150,6 +121,30 @@ var variantPseudoClasses = {
150
121
  multiPass: true
151
122
  };
152
123
 
124
+ // src/variants/dark.ts
125
+ var variantColorsClass = [
126
+ variantMatcher("dark", (input) => `.dark $$ ${input}`),
127
+ variantMatcher("light", (input) => `.light $$ ${input}`)
128
+ ];
129
+ var variantColorsMedia = [
130
+ (v) => {
131
+ const dark = variantMatcher("dark")(v);
132
+ if (dark) {
133
+ return {
134
+ ...dark,
135
+ parent: "@media (prefers-color-scheme: dark)"
136
+ };
137
+ }
138
+ const light = variantMatcher("light")(v);
139
+ if (light) {
140
+ return {
141
+ ...light,
142
+ parent: "@media (prefers-color-scheme: light)"
143
+ };
144
+ }
145
+ }
146
+ ];
147
+
153
148
  // src/variants/index.ts
154
149
  var variantImportant = {
155
150
  match(matcher) {
@@ -199,7 +194,6 @@ var variants = [
199
194
  variantImportant,
200
195
  variantBreakpoints,
201
196
  ...variantChildren,
202
- ...variantColorsClass,
203
197
  variantPseudoClasses,
204
198
  variantPseudoElements
205
199
  ];
@@ -207,11 +201,11 @@ var variants = [
207
201
  export {
208
202
  variantBreakpoints,
209
203
  variantChildren,
210
- variantColorsClass,
211
- variantColorsMedia,
212
204
  PseudoClasses,
213
205
  variantPseudoElements,
214
206
  variantPseudoClasses,
207
+ variantColorsClass,
208
+ variantColorsMedia,
215
209
  variantImportant,
216
210
  variantNegative,
217
211
  variantSpace,
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './index-617c3a40';
1
+ import { T as Theme } from './index-ff2f576a';
2
2
 
3
3
  declare const colors: Theme['colors'];
4
4
 
@@ -1,4 +1,10 @@
1
1
  interface Theme {
2
+ width?: Record<string, string>;
3
+ height?: Record<string, string>;
4
+ maxWidth?: Record<string, string>;
5
+ maxHeight?: Record<string, string>;
6
+ minWidth?: Record<string, string>;
7
+ minHeight?: Record<string, string>;
2
8
  borderRadius?: Record<string, string>;
3
9
  breakpoints?: Record<string, string>;
4
10
  colors?: Record<string, string | Record<string, string>>;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,14 @@
1
1
  import { Preset } from '@unocss/core';
2
- import { T as Theme } from './index-617c3a40';
3
- export { t as theme } from './index-617c3a40';
4
- export { c as colors } from './colors-c48e51c6';
2
+ import { T as Theme } from './index-ff2f576a';
3
+ export { t as theme } from './index-ff2f576a';
4
+ export { c as colors } from './colors-5eb4823c';
5
5
 
6
- declare const preset: () => Preset<Theme>;
6
+ interface UnoOptions {
7
+ /**
8
+ * @default 'class'
9
+ */
10
+ dark?: 'class' | 'media';
11
+ }
12
+ declare const preset: (options?: UnoOptions) => Preset<Theme>;
7
13
 
8
- export { preset as default, preset };
14
+ export { UnoOptions, preset as default, preset };
package/dist/index.js CHANGED
@@ -1,21 +1,31 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkPODFJE44js = require('./chunk-PODFJE44.js');
4
3
 
4
+ var _chunkPCPK4ZRFjs = require('./chunk-PCPK4ZRF.js');
5
5
 
6
6
 
7
- var _chunkCPLQ3FYNjs = require('./chunk-CPLQ3FYN.js');
8
7
 
8
+ var _chunkR5JSOZOBjs = require('./chunk-R5JSOZOB.js');
9
9
 
10
- var _chunk3BHSLSEWjs = require('./chunk-3BHSLSEW.js');
10
+
11
+
12
+
13
+ var _chunkIUVZVO7Hjs = require('./chunk-IUVZVO7H.js');
14
+ require('./chunk-PVS5EBXX.js');
11
15
  require('./chunk-Y6EUTGDC.js');
12
16
 
13
17
  // src/index.ts
14
- var preset = () => ({
18
+ var preset = (options = {}) => ({
15
19
  name: "@unocss/preset-uno",
16
- theme: _chunkCPLQ3FYNjs.theme,
17
- rules: _chunkPODFJE44js.rules,
18
- variants: _chunk3BHSLSEWjs.variants
20
+ theme: _chunkR5JSOZOBjs.theme,
21
+ rules: _chunkPCPK4ZRFjs.rules,
22
+ variants: [
23
+ ..._chunkIUVZVO7Hjs.variants,
24
+ ...options.dark === "media" ? _chunkIUVZVO7Hjs.variantColorsMedia : _chunkIUVZVO7Hjs.variantColorsClass
25
+ ],
26
+ shortcuts: [
27
+ ..._chunkPCPK4ZRFjs.containerShortcuts
28
+ ]
19
29
  });
20
30
  var src_default = preset;
21
31
 
@@ -23,4 +33,4 @@ var src_default = preset;
23
33
 
24
34
 
25
35
 
26
- exports.colors = _chunkCPLQ3FYNjs.colors; exports.default = src_default; exports.preset = preset; exports.theme = _chunkCPLQ3FYNjs.theme;
36
+ exports.colors = _chunkR5JSOZOBjs.colors; exports.default = src_default; exports.preset = preset; exports.theme = _chunkR5JSOZOBjs.theme;