@unocss/preset-mini 0.65.0-beta.2 → 0.65.0-beta.3

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.
package/dist/index.d.mts CHANGED
@@ -7,7 +7,7 @@ export { t as theme } from './shared/preset-mini.BSnAbT9I.mjs';
7
7
  export { p as parseColor } from './shared/preset-mini.oF7XTPi1.mjs';
8
8
  import '@unocss/rule-utils';
9
9
 
10
- declare const preflights: Preflight<Theme>[];
10
+ declare function preflights(options: PresetMiniOptions): Preflight<Theme>[] | undefined;
11
11
 
12
12
  interface DarkModeSelectors {
13
13
  /**
@@ -53,7 +53,7 @@ interface PresetMiniOptions extends PresetOptions {
53
53
  *
54
54
  * @default true
55
55
  */
56
- preflight?: boolean;
56
+ preflight?: boolean | 'on-demand';
57
57
  /**
58
58
  * Enable arbitrary variants, for example `<div class="[&>*]:m-1 [&[open]]:p-2"></div>`.
59
59
  *
@@ -71,6 +71,5 @@ interface PresetMiniOptions extends PresetOptions {
71
71
  declare const presetMini: _unocss_core.PresetFactory<Theme, PresetMiniOptions>;
72
72
 
73
73
  declare function VarPrefixPostprocessor(prefix: string): Postprocessor | undefined;
74
- declare function normalizePreflights<Theme extends object>(preflights: Preflight<Theme>[], variablePrefix: string): Preflight<Theme>[];
75
74
 
76
- export { type DarkModeSelectors, type PresetMiniOptions, Theme, VarPrefixPostprocessor, presetMini as default, normalizePreflights, preflights, presetMini };
75
+ export { type DarkModeSelectors, type PresetMiniOptions, Theme, VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
package/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ export { t as theme } from './shared/preset-mini.CoOfBKs_.js';
7
7
  export { p as parseColor } from './shared/preset-mini.CRliz1QB.js';
8
8
  import '@unocss/rule-utils';
9
9
 
10
- declare const preflights: Preflight<Theme>[];
10
+ declare function preflights(options: PresetMiniOptions): Preflight<Theme>[] | undefined;
11
11
 
12
12
  interface DarkModeSelectors {
13
13
  /**
@@ -53,7 +53,7 @@ interface PresetMiniOptions extends PresetOptions {
53
53
  *
54
54
  * @default true
55
55
  */
56
- preflight?: boolean;
56
+ preflight?: boolean | 'on-demand';
57
57
  /**
58
58
  * Enable arbitrary variants, for example `<div class="[&>*]:m-1 [&[open]]:p-2"></div>`.
59
59
  *
@@ -71,6 +71,5 @@ interface PresetMiniOptions extends PresetOptions {
71
71
  declare const presetMini: _unocss_core.PresetFactory<Theme, PresetMiniOptions>;
72
72
 
73
73
  declare function VarPrefixPostprocessor(prefix: string): Postprocessor | undefined;
74
- declare function normalizePreflights<Theme extends object>(preflights: Preflight<Theme>[], variablePrefix: string): Preflight<Theme>[];
75
74
 
76
- export { type DarkModeSelectors, type PresetMiniOptions, Theme, VarPrefixPostprocessor, presetMini as default, normalizePreflights, preflights, presetMini };
75
+ export { type DarkModeSelectors, type PresetMiniOptions, Theme, VarPrefixPostprocessor, presetMini as default, preflights, presetMini };
package/dist/index.mjs CHANGED
@@ -2,25 +2,39 @@ import { entriesToCss, toArray, definePreset } from '@unocss/core';
2
2
  import { extractorArbitraryVariants } from '@unocss/extractor-arbitrary-variants';
3
3
  import { g as globalKeywords } from './shared/preset-mini.Cay6Ue29.mjs';
4
4
  export { k as parseColor } from './shared/preset-mini.Cay6Ue29.mjs';
5
- import { t as theme } from './shared/preset-mini.mgoK7_fk.mjs';
6
- import { r as rules } from './shared/preset-mini.K1rIaInm.mjs';
5
+ import { t as theme } from './shared/preset-mini.ClRt8DkD.mjs';
6
+ import { r as rules } from './shared/preset-mini.BVh-vya-.mjs';
7
7
  import { j as variants } from './shared/preset-mini.CDgj-fgp.mjs';
8
8
  export { colors } from './colors.mjs';
9
9
  import '@unocss/rule-utils';
10
- import './shared/preset-mini.Cw_oISCI.mjs';
10
+ import './shared/preset-mini.C1aTpz3p.mjs';
11
11
 
12
- const preflights = [
13
- {
14
- layer: "preflights",
15
- getCSS(ctx) {
16
- if (ctx.theme.preflightBase) {
17
- const css = entriesToCss(Object.entries(ctx.theme.preflightBase));
18
- const roots = toArray(ctx.theme.preflightRoot ?? ["*,::before,::after", "::backdrop"]);
19
- return roots.map((root) => `${root}{${css}}`).join("");
12
+ function preflights(options) {
13
+ if (options.preflight) {
14
+ return [
15
+ {
16
+ layer: "preflights",
17
+ getCSS({ theme, generator }) {
18
+ if (theme.preflightBase) {
19
+ let entries = Object.entries(theme.preflightBase);
20
+ if (options.preflight === "on-demand") {
21
+ const keys = new Set(Array.from(generator.activatedRules).map((r) => r[2]?.custom?.preflightKeys).filter(Boolean).flat());
22
+ entries = entries.filter(([k]) => keys.has(k));
23
+ }
24
+ if (entries.length > 0) {
25
+ let css = entriesToCss(entries);
26
+ if (options.variablePrefix !== "un-") {
27
+ css = css.replace(/--un-/g, `--${options.variablePrefix}`);
28
+ }
29
+ const roots = toArray(theme.preflightRoot ?? ["*,::before,::after", "::backdrop"]);
30
+ return roots.map((root) => `${root}{${css}}`).join("");
31
+ }
32
+ }
33
+ }
20
34
  }
21
- }
35
+ ];
22
36
  }
23
- ];
37
+ }
24
38
 
25
39
  const shorthands = {
26
40
  position: [
@@ -46,7 +60,7 @@ const presetMini = definePreset((options = {}) => {
46
60
  options,
47
61
  prefix: options.prefix,
48
62
  postprocess: VarPrefixPostprocessor(options.variablePrefix),
49
- preflights: options.preflight ? normalizePreflights(preflights, options.variablePrefix) : [],
63
+ preflights: preflights(options),
50
64
  extractorDefault: options.arbitraryVariants === false ? void 0 : extractorArbitraryVariants(),
51
65
  autocomplete: {
52
66
  shorthands
@@ -64,18 +78,5 @@ function VarPrefixPostprocessor(prefix) {
64
78
  };
65
79
  }
66
80
  }
67
- function normalizePreflights(preflights3, variablePrefix) {
68
- if (variablePrefix !== "un-") {
69
- return preflights3.map((p) => ({
70
- ...p,
71
- getCSS: /* @__PURE__ */ (() => async (ctx) => {
72
- const css = await p.getCSS(ctx);
73
- if (css)
74
- return css.replace(/--un-/g, `--${variablePrefix}`);
75
- })()
76
- }));
77
- }
78
- return preflights3;
79
- }
80
81
 
81
- export { VarPrefixPostprocessor, presetMini as default, normalizePreflights, preflights, presetMini, theme };
82
+ export { VarPrefixPostprocessor, presetMini as default, preflights, presetMini, theme };
package/dist/rules.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { s as alignments, a as appearance, E as aspectRatio, e as bgColors, b as borderStyles, c as borders, B as boxSizing, f as colorScheme, g as containerParent, P as cssProperty, O as cssVariables, j as flex, x as flexGridJustifiesAlignments, z as floats, J as fonts, k as gaps, l as grids, h as handlerBorderStyle, y as insets, n as justifies, G as margins, d as opacity, q as orders, o as outline, m as overflows, F as paddings, u as placements, p as positions, C as questionMark, r as rules, D as sizes, H as svgUtilities, K as tabSizes, t as textAligns, i as textDecorations, L as textIndents, N as textShadows, M as textStrokes, I as transitions, v as verticalAligns, w as willChange, A as zIndexes } from './shared/preset-mini.K1rIaInm.mjs';
2
- export { e as appearances, c as boxShadows, b as boxShadowsBase, k as breaks, g as contains, i as contentVisibility, j as contents, f as cursors, d as displays, o as fontSmoothings, n as fontStyles, p as pointerEvents, h as resizes, r as ringBase, a as rings, l as textOverflows, m as textTransforms, t as textWraps, q as transformBase, s as transforms, u as userSelects, v as varEmpty, w as whitespaces } from './shared/preset-mini.Cw_oISCI.mjs';
1
+ export { s as alignments, a as appearance, E as aspectRatio, e as bgColors, b as borderStyles, c as borders, B as boxSizing, f as colorScheme, g as containerParent, P as cssProperty, O as cssVariables, j as flex, x as flexGridJustifiesAlignments, z as floats, J as fonts, k as gaps, l as grids, h as handlerBorderStyle, y as insets, n as justifies, G as margins, d as opacity, q as orders, o as outline, m as overflows, F as paddings, u as placements, p as positions, C as questionMark, r as rules, D as sizes, H as svgUtilities, K as tabSizes, t as textAligns, i as textDecorations, L as textIndents, N as textShadows, M as textStrokes, I as transitions, v as verticalAligns, w as willChange, A as zIndexes } from './shared/preset-mini.BVh-vya-.mjs';
2
+ export { e as appearances, c as boxShadows, b as boxShadowsBase, k as breaks, g as contains, i as contentVisibility, j as contents, f as cursors, d as displays, o as fontSmoothings, n as fontStyles, p as pointerEvents, h as resizes, r as ringBase, a as rings, l as textOverflows, m as textTransforms, t as textWraps, q as transformBase, s as transforms, u as userSelects, v as varEmpty, w as whitespaces } from './shared/preset-mini.C1aTpz3p.mjs';
3
3
  import './shared/preset-mini.Cay6Ue29.mjs';
4
4
  import '@unocss/core';
5
5
  import '@unocss/rule-utils';
@@ -1,6 +1,6 @@
1
1
  import { g as globalKeywords, a as h, t as isCSSMathFn, l as colorResolver, d as directionMap, n as hasParseableColor, c as cornerMap, k as parseColor, u as isSize, q as makeGlobalStaticRules, i as insetMap, r as resolveBreakpoints, j as directionSize, m as colorableShadows, s as splitShorthand } from './preset-mini.Cay6Ue29.mjs';
2
2
  import { colorToString, colorOpacityToString } from '@unocss/rule-utils';
3
- import { g as contains, p as pointerEvents, e as appearances, d as displays, s as transforms, f as cursors, u as userSelects, h as resizes, l as textOverflows, w as whitespaces, k as breaks, t as textWraps, m as textTransforms, n as fontStyles, o as fontSmoothings, c as boxShadows, a as rings, i as contentVisibility, j as contents } from './preset-mini.Cw_oISCI.mjs';
3
+ import { g as contains, p as pointerEvents, e as appearances, d as displays, s as transforms, f as cursors, u as userSelects, h as resizes, l as textOverflows, w as whitespaces, k as breaks, t as textWraps, m as textTransforms, n as fontStyles, o as fontSmoothings, c as boxShadows, a as rings, i as contentVisibility, j as contents } from './preset-mini.C1aTpz3p.mjs';
4
4
  import { toArray } from '@unocss/core';
5
5
 
6
6
  const verticalAlignAlias = {
@@ -127,6 +127,7 @@ const ringBase = {
127
127
  "--un-ring-color": "rgb(147 197 253 / 0.5)",
128
128
  "--un-shadow": "0 0 rgb(0 0 0 / 0)"
129
129
  };
130
+ const preflightKeys$2 = Object.keys(ringBase);
130
131
  const rings = [
131
132
  // ring
132
133
  [/^ring(?:-(.+))?$/, ([, d], { theme }) => {
@@ -139,7 +140,7 @@ const rings = [
139
140
  "box-shadow": "var(--un-ring-offset-shadow), var(--un-ring-shadow), var(--un-shadow)"
140
141
  };
141
142
  }
142
- }, { autocomplete: "ring-$ringWidth" }],
143
+ }, { custom: { preflightKeys: preflightKeys$2 }, autocomplete: "ring-$ringWidth" }],
143
144
  // size
144
145
  [/^ring-(?:width-|size-)(.+)$/, handleWidth, { autocomplete: "ring-(width|size)-$lineWidth" }],
145
146
  // offset size
@@ -169,6 +170,7 @@ const boxShadowsBase = {
169
170
  "--un-shadow-inset": varEmpty,
170
171
  "--un-shadow": "0 0 rgb(0 0 0 / 0)"
171
172
  };
173
+ const preflightKeys$1 = Object.keys(boxShadowsBase);
172
174
  const boxShadows = [
173
175
  // color
174
176
  [/^shadow(?:-(.+))?$/, (match, context) => {
@@ -183,7 +185,7 @@ const boxShadows = [
183
185
  };
184
186
  }
185
187
  return colorResolver("--un-shadow-color", "shadow", "shadowColor")(match, context);
186
- }, { autocomplete: ["shadow-$colors", "shadow-$boxShadow"] }],
188
+ }, { custom: { preflightKeys: preflightKeys$1 }, autocomplete: ["shadow-$colors", "shadow-$boxShadow"] }],
187
189
  [/^shadow-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-shadow-opacity": h.bracket.percent.cssvar(opacity) }), { autocomplete: "shadow-(op|opacity)-<percent>" }],
188
190
  // inset
189
191
  ["shadow-inset", { "--un-shadow-inset": "inset" }]
@@ -249,9 +251,14 @@ const transformBase = {
249
251
  "--un-translate-y": 0,
250
252
  "--un-translate-z": 0
251
253
  };
254
+ const preflightKeys = Object.keys(transformBase);
252
255
  const transforms = [
253
256
  // origins
254
- [/^(?:transform-)?origin-(.+)$/, ([, s]) => ({ "transform-origin": positionMap[s] ?? h.bracket.cssvar(s) }), { autocomplete: [`transform-origin-(${Object.keys(positionMap).join("|")})`, `origin-(${Object.keys(positionMap).join("|")})`] }],
257
+ [
258
+ /^(?:transform-)?origin-(.+)$/,
259
+ ([, s]) => ({ "transform-origin": positionMap[s] ?? h.bracket.cssvar(s) }),
260
+ { autocomplete: [`transform-origin-(${Object.keys(positionMap).join("|")})`, `origin-(${Object.keys(positionMap).join("|")})`] }
261
+ ],
255
262
  // perspectives
256
263
  [/^(?:transform-)?perspect(?:ive)?-(.+)$/, ([, s]) => {
257
264
  const v = h.bracket.cssvar.px.numberWithUnit(s);
@@ -273,21 +280,23 @@ const transforms = [
273
280
  }
274
281
  }],
275
282
  // modifiers
276
- [/^(?:transform-)?translate-()(.+)$/, handleTranslate],
277
- [/^(?:transform-)?translate-([xyz])-(.+)$/, handleTranslate],
278
- [/^(?:transform-)?rotate-()(.+)$/, handleRotate],
279
- [/^(?:transform-)?rotate-([xyz])-(.+)$/, handleRotate],
280
- [/^(?:transform-)?skew-()(.+)$/, handleSkew],
281
- [/^(?:transform-)?skew-([xy])-(.+)$/, handleSkew, { autocomplete: ["transform-skew-(x|y)-<percent>", "skew-(x|y)-<percent>"] }],
282
- [/^(?:transform-)?scale-()(.+)$/, handleScale],
283
- [/^(?:transform-)?scale-([xyz])-(.+)$/, handleScale, { autocomplete: [`transform-(${transformValues.join("|")})-<percent>`, `transform-(${transformValues.join("|")})-(x|y|z)-<percent>`, `(${transformValues.join("|")})-<percent>`, `(${transformValues.join("|")})-(x|y|z)-<percent>`] }],
283
+ [/^(?:transform-)?translate-()(.+)$/, handleTranslate, { custom: { preflightKeys } }],
284
+ [/^(?:transform-)?translate-([xyz])-(.+)$/, handleTranslate, { custom: { preflightKeys } }],
285
+ [/^(?:transform-)?rotate-()(.+)$/, handleRotate, { custom: { preflightKeys } }],
286
+ [/^(?:transform-)?rotate-([xyz])-(.+)$/, handleRotate, { custom: { preflightKeys } }],
287
+ [/^(?:transform-)?skew-()(.+)$/, handleSkew, { custom: { preflightKeys } }],
288
+ [/^(?:transform-)?skew-([xy])-(.+)$/, handleSkew, { custom: { preflightKeys }, autocomplete: ["transform-skew-(x|y)-<percent>", "skew-(x|y)-<percent>"] }],
289
+ [/^(?:transform-)?scale-()(.+)$/, handleScale, { custom: { preflightKeys } }],
290
+ [/^(?:transform-)?scale-([xyz])-(.+)$/, handleScale, { custom: { preflightKeys }, autocomplete: [`transform-(${transformValues.join("|")})-<percent>`, `transform-(${transformValues.join("|")})-(x|y|z)-<percent>`, `(${transformValues.join("|")})-<percent>`, `(${transformValues.join("|")})-(x|y|z)-<percent>`] }],
284
291
  // style
285
292
  [/^(?:transform-)?preserve-3d$/, () => ({ "transform-style": "preserve-3d" })],
286
293
  [/^(?:transform-)?preserve-flat$/, () => ({ "transform-style": "flat" })],
287
294
  // base
288
- ["transform", { transform }],
289
- ["transform-cpu", { transform: transformCpu }],
290
- ["transform-gpu", { transform: transformGpu }],
295
+ ["transform", { transform }, { custom: { preflightKeys } }],
296
+ ["transform-cpu", { transform: transformCpu }, {
297
+ custom: { preflightKeys: ["--un-translate-x", "--un-translate-y", "--un-rotate", "--un-rotate-z", "--un-skew-x", "--un-skew-y", "--un-scale-x", "--un-scale-y"] }
298
+ }],
299
+ ["transform-gpu", { transform: transformGpu }, { custom: { preflightKeys } }],
291
300
  ["transform-none", { transform: "none" }],
292
301
  ...makeGlobalStaticRules("transform")
293
302
  ];
@@ -1,5 +1,5 @@
1
1
  import { colors } from '../colors.mjs';
2
- import { q as transformBase, b as boxShadowsBase, r as ringBase } from './preset-mini.Cw_oISCI.mjs';
2
+ import { q as transformBase, b as boxShadowsBase, r as ringBase } from './preset-mini.C1aTpz3p.mjs';
3
3
 
4
4
  const blur = {
5
5
  "DEFAULT": "8px",
package/dist/theme.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { colors } from './colors.mjs';
2
- export { u as baseSize, b as blur, n as borderRadius, o as boxShadow, j as breakpoints, C as containers, d as dropShadow, m as duration, f as fontFamily, a as fontSize, i as fontWeight, A as height, h as letterSpacing, l as lineHeight, k as lineWidth, B as maxHeight, y as maxWidth, p as media, q as preflightBase, r as ringWidth, s as spacing, c as textIndent, g as textShadow, e as textStrokeWidth, t as theme, v as verticalBreakpoints, x as width, w as wordSpacing, z as zIndex } from './shared/preset-mini.mgoK7_fk.mjs';
3
- import './shared/preset-mini.Cw_oISCI.mjs';
2
+ export { u as baseSize, b as blur, n as borderRadius, o as boxShadow, j as breakpoints, C as containers, d as dropShadow, m as duration, f as fontFamily, a as fontSize, i as fontWeight, A as height, h as letterSpacing, l as lineHeight, k as lineWidth, B as maxHeight, y as maxWidth, p as media, q as preflightBase, r as ringWidth, s as spacing, c as textIndent, g as textShadow, e as textStrokeWidth, t as theme, v as verticalBreakpoints, x as width, w as wordSpacing, z as zIndex } from './shared/preset-mini.ClRt8DkD.mjs';
3
+ import './shared/preset-mini.C1aTpz3p.mjs';
4
4
  import './shared/preset-mini.Cay6Ue29.mjs';
5
5
  import '@unocss/core';
6
6
  import '@unocss/rule-utils';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
3
  "type": "module",
4
- "version": "0.65.0-beta.2",
4
+ "version": "0.65.0-beta.3",
5
5
  "description": "The minimal preset for UnoCSS",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -56,9 +56,9 @@
56
56
  "dist"
57
57
  ],
58
58
  "dependencies": {
59
- "@unocss/core": "0.65.0-beta.2",
60
- "@unocss/rule-utils": "0.65.0-beta.2",
61
- "@unocss/extractor-arbitrary-variants": "0.65.0-beta.2"
59
+ "@unocss/core": "0.65.0-beta.3",
60
+ "@unocss/extractor-arbitrary-variants": "0.65.0-beta.3",
61
+ "@unocss/rule-utils": "0.65.0-beta.3"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "unbuild",