@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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @unocss/preset-mini
2
2
 
3
- The minimal preset for [UnoCSS](https://github.com/antfu/unocss).
3
+ The minimal preset for [UnoCSS](https://github.com/unocss/unocss).
4
4
 
5
5
  ## Installation
6
6
 
@@ -124,6 +124,13 @@ const boxShadow = {
124
124
  "inner": "inset 0 2px 4px 0 rgba(0,0,0,0.05)",
125
125
  "none": "0 0 #0000"
126
126
  };
127
+ const easing = {
128
+ "DEFAULT": "cubic-bezier(0.4, 0, 0.2, 1)",
129
+ "linear": "linear",
130
+ "in": "cubic-bezier(0.4, 0, 1, 1)",
131
+ "out": "cubic-bezier(0, 0, 0.2, 1)",
132
+ "in-out": "cubic-bezier(0.4, 0, 0.2, 1)"
133
+ };
127
134
 
128
135
  const blur = {
129
136
  "DEFAULT": "8px",
@@ -206,7 +213,8 @@ const theme = {
206
213
  textShadow,
207
214
  textStrokeWidth,
208
215
  blur,
209
- dropShadow
216
+ dropShadow,
217
+ easing
210
218
  };
211
219
 
212
220
  exports.baseSize = baseSize;
@@ -215,6 +223,7 @@ exports.borderRadius = borderRadius;
215
223
  exports.boxShadow = boxShadow;
216
224
  exports.breakpoints = breakpoints;
217
225
  exports.dropShadow = dropShadow;
226
+ exports.easing = easing;
218
227
  exports.fontFamily = fontFamily;
219
228
  exports.fontSize = fontSize;
220
229
  exports.height = height;
@@ -122,6 +122,13 @@ const boxShadow = {
122
122
  "inner": "inset 0 2px 4px 0 rgba(0,0,0,0.05)",
123
123
  "none": "0 0 #0000"
124
124
  };
125
+ const easing = {
126
+ "DEFAULT": "cubic-bezier(0.4, 0, 0.2, 1)",
127
+ "linear": "linear",
128
+ "in": "cubic-bezier(0.4, 0, 1, 1)",
129
+ "out": "cubic-bezier(0, 0, 0.2, 1)",
130
+ "in-out": "cubic-bezier(0.4, 0, 0.2, 1)"
131
+ };
125
132
 
126
133
  const blur = {
127
134
  "DEFAULT": "8px",
@@ -204,7 +211,8 @@ const theme = {
204
211
  textShadow,
205
212
  textStrokeWidth,
206
213
  blur,
207
- dropShadow
214
+ dropShadow,
215
+ easing
208
216
  };
209
217
 
210
- export { fontSize as a, blur as b, textIndent as c, dropShadow as d, textStrokeWidth as e, fontFamily as f, textShadow as g, letterSpacing as h, breakpoints as i, borderRadius as j, boxShadow as k, lineHeight as l, baseSize as m, width as n, maxWidth as o, height as p, maxHeight as q, theme as t, wordSpacing as w };
218
+ export { fontSize as a, blur as b, textIndent as c, dropShadow as d, textStrokeWidth as e, fontFamily as f, textShadow as g, letterSpacing as h, breakpoints as i, borderRadius as j, boxShadow as k, lineHeight as l, easing as m, baseSize as n, width as o, maxWidth as p, height as q, maxHeight as r, theme as t, wordSpacing as w };
@@ -19,9 +19,9 @@ const textAligns = [
19
19
  ];
20
20
 
21
21
  const outline = [
22
- [/^outline-(?:width-|size-)?(.+)$/, ([, d]) => ({ "outline-width": utilities.handler.bracket.cssvar.fraction.rem(d) })],
22
+ [/^outline-(?:width-|size-)?(.+)$/, ([, d]) => ({ "outline-width": utilities.handler.bracket.cssvar.px(d) })],
23
23
  [/^outline-(?:color-)?(.+)$/, utilities.colorResolver("outline-color", "outline-color")],
24
- [/^outline-offset-(.+)$/, ([, d]) => ({ "outline-offset": utilities.handler.bracket.cssvar.fraction.rem(d) })],
24
+ [/^outline-offset-(.+)$/, ([, d]) => ({ "outline-offset": utilities.handler.bracket.cssvar.px(d) })],
25
25
  ["outline", { "outline-style": "solid" }],
26
26
  [/^outline-(auto|dashed|dotted|double|hidden|solid|groove|ridge|inset|outset|inherit|initial|revert|unset)$/, ([, c]) => ({ "outline-style": c })],
27
27
  ["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
@@ -82,31 +82,28 @@ const borderColorResolver = (direction) => ([, body], { theme }) => {
82
82
  const data = utilities.parseColor(body, theme);
83
83
  if (!data)
84
84
  return;
85
- const { alpha, opacity, color, rgba } = data;
86
- if (!color)
87
- return;
88
- if (rgba) {
85
+ const { alpha, color, cssColor } = data;
86
+ if (cssColor) {
89
87
  if (alpha != null) {
90
88
  return {
91
- [`border${direction}-color`]: `rgba(${rgba.join(",")})`
89
+ [`border${direction}-color`]: utilities.colorToString(cssColor, alpha)
90
+ };
91
+ }
92
+ if (direction === "") {
93
+ return {
94
+ "--un-border-opacity": cssColor.alpha ?? 1,
95
+ [`border${direction}-color`]: utilities.colorToString(cssColor, `var(--un-border${direction}-opacity)`)
92
96
  };
93
97
  } else {
94
- if (direction === "") {
95
- return {
96
- "--un-border-opacity": (opacity && utilities.handler.cssvar(opacity)) ?? 1,
97
- [`border${direction}-color`]: `rgba(${rgba.join(",")},var(--un-border${direction}-opacity))`
98
- };
99
- } else {
100
- return {
101
- "--un-border-opacity": (opacity && utilities.handler.cssvar(opacity)) ?? 1,
102
- [`--un-border${direction}-opacity`]: "var(--un-border-opacity)",
103
- [`border${direction}-color`]: `rgba(${rgba.join(",")},var(--un-border${direction}-opacity))`
104
- };
105
- }
98
+ return {
99
+ "--un-border-opacity": cssColor.alpha ?? 1,
100
+ [`--un-border${direction}-opacity`]: "var(--un-border-opacity)",
101
+ [`border${direction}-color`]: utilities.colorToString(cssColor, `var(--un-border${direction}-opacity)`)
102
+ };
106
103
  }
107
- } else {
104
+ } else if (color) {
108
105
  return {
109
- [`border${direction}-color`]: color.replace("%alpha", `${alpha || 1}`)
106
+ [`border${direction}-color`]: color.replace("%alpha", `${alpha ?? 1}`)
110
107
  };
111
108
  }
112
109
  };
@@ -155,6 +152,7 @@ const bgColors = [
155
152
  const transitionPropertyGroup = {
156
153
  all: "all",
157
154
  colors: ["color", "background-color", "border-color", "text-decoration-color", "fill", "stroke"].join(","),
155
+ none: "none",
158
156
  opacity: "opacity",
159
157
  shadow: "box-shadow",
160
158
  transform: "transform"
@@ -168,22 +166,15 @@ const transitions = [
168
166
  if (p) {
169
167
  return {
170
168
  "transition-property": p,
171
- "transition-timing-function": "cubic-bezier(0.4,0,0.2,1)",
169
+ "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)",
172
170
  "transition-duration": `${duration}ms`
173
171
  };
174
172
  }
175
173
  }],
176
174
  [/^(?:transition-)?duration-(.+)$/, ([, d]) => ({ "transition-duration": utilities.handler.bracket.cssvar.time(d) })],
177
175
  [/^(?:transition-)?delay-(.+)$/, ([, d]) => ({ "transition-delay": utilities.handler.bracket.cssvar.time(d) })],
178
- [/^ease-(.+)$/, ([, d]) => ({ "transition-timing-function": utilities.handler.bracket.cssvar(d) })],
179
- ["ease", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
180
- ["ease-linear", { "transition-timing-function": "linear" }],
181
- ["ease-in", { "transition-timing-function": "cubic-bezier(0.4, 0, 1, 1)" }],
182
- ["ease-out", { "transition-timing-function": "cubic-bezier(0, 0, 0.2, 1)" }],
183
- ["ease-in-out", { "transition-timing-function": "cubic-bezier(0.4, 0, 0.2, 1)" }],
176
+ [/^(?:transition-)?ease(?:-(.+))?$/, ([, d], { theme }) => ({ "transition-timing-function": theme.easing?.[d || "DEFAULT"] ?? utilities.handler.bracket.cssvar(d) })],
184
177
  [/^(?:transition-)?property-(.+)$/, ([, v]) => ({ "transition-property": utilities.handler.global(v) || transitionProperty(v) })],
185
- ["transition-property-none", { "transition-property": "none" }],
186
- ["property-none", { "transition-property": "none" }],
187
178
  ["transition-none", { transition: "none" }]
188
179
  ];
189
180
 
@@ -210,117 +201,6 @@ const flex = [
210
201
  ["flex-nowrap", { "flex-wrap": "nowrap" }]
211
202
  ];
212
203
 
213
- const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
214
- const displays = [
215
- ["inline", { display: "inline" }],
216
- ["block", { display: "block" }],
217
- ["inline-block", { display: "inline-block" }],
218
- ["contents", { display: "contents" }],
219
- ["flow-root", { display: "flow-root" }],
220
- ["list-item", { display: "list-item" }],
221
- ["hidden", { display: "none" }]
222
- ];
223
- const appearances = [
224
- ["visible", { visibility: "visible" }],
225
- ["invisible", { visibility: "hidden" }],
226
- ["backface-visible", { "backface-visibility": "visible" }],
227
- ["backface-hidden", { "backface-visibility": "hidden" }]
228
- ];
229
- const cursors = [
230
- [/^cursor-(.+)$/, ([, c]) => ({ cursor: utilities.handler.bracket.cssvar(c) || c })]
231
- ];
232
- const pointerEvents = [
233
- ["pointer-events-auto", { "pointer-events": "auto" }],
234
- ["pointer-events-none", { "pointer-events": "none" }]
235
- ];
236
- const resizes = [
237
- ["resize-x", { resize: "horizontal" }],
238
- ["resize-y", { resize: "vertical" }],
239
- ["resize", { resize: "both" }],
240
- ["resize-none", { resize: "none" }]
241
- ];
242
- const userSelects = [
243
- ["select-auto", { "user-select": "auto" }],
244
- ["select-all", { "user-select": "all" }],
245
- ["select-text", { "user-select": "text" }],
246
- ["select-none", { "user-select": "none" }]
247
- ];
248
- const whitespaces = [
249
- [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
250
- ];
251
- const contents = [
252
- ["content-empty", { content: '""' }],
253
- ["content-none", { content: '""' }]
254
- ];
255
- const breaks = [
256
- ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
257
- ["break-words", { "overflow-wrap": "break-word" }],
258
- ["break-all", { "word-break": "break-all" }]
259
- ];
260
- const textOverflows = [
261
- ["truncate", { "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }],
262
- ["text-ellipsis", { "text-overflow": "ellipsis" }],
263
- ["text-clip", { "text-overflow": "clip" }]
264
- ];
265
- const textTransforms = [
266
- ["case-upper", { "text-transform": "uppercase" }],
267
- ["case-lower", { "text-transform": "lowercase" }],
268
- ["case-capital", { "text-transform": "capitalize" }],
269
- ["case-normal", { "text-transform": "none" }]
270
- ];
271
- const fontStyles = [
272
- ["italic", { "font-style": "italic" }],
273
- ["not-italic", { "font-style": "normal" }]
274
- ];
275
- const fontSmoothings = [
276
- ["antialiased", {
277
- "-webkit-font-smoothing": "antialiased",
278
- "-moz-osx-font-smoothing": "grayscale",
279
- "font-smoothing": "grayscale"
280
- }],
281
- ["subpixel-antialiased", {
282
- "-webkit-font-smoothing": "auto",
283
- "-moz-osx-font-smoothing": "auto",
284
- "font-smoothing": "auto"
285
- }]
286
- ];
287
-
288
- const shadowBase = {
289
- [core.CONTROL_SHORTCUT_NO_MERGE]: "",
290
- "--un-ring-offset-shadow": "0 0 #0000",
291
- "--un-ring-shadow": "0 0 #0000",
292
- "--un-shadow-inset": varEmpty,
293
- "--un-shadow": "0 0 #0000"
294
- };
295
- const colorableShadows = (shadows, colorVar) => {
296
- const colored = [];
297
- shadows = core.toArray(shadows);
298
- for (let i = 0; i < shadows.length; i++) {
299
- const [size, color] = shadows[i].split(/\s(\S+)$/);
300
- if (color.split("(").length !== color.split(")").length)
301
- return shadows;
302
- colored.push(`${size} var(${colorVar}, ${color})`);
303
- }
304
- return colored;
305
- };
306
- const boxShadows = [
307
- [/^shadow(?:-(.+))?$/, ([, d], { theme }) => {
308
- const v = theme.boxShadow?.[d || "DEFAULT"];
309
- if (v) {
310
- return [
311
- shadowBase,
312
- {
313
- "--un-shadow": colorableShadows(v, "--un-shadow-color").join(","),
314
- "box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
315
- }
316
- ];
317
- }
318
- }],
319
- [/^shadow-(.+)$/, utilities.colorResolver("--un-shadow-color", "shadow")],
320
- [/^shadow-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-shadow-opacity": utilities.handler.bracket.percent(opacity) })],
321
- ["shadow-inset", { "--un-shadow-inset": "inset" }]
322
- ];
323
-
324
204
  const weightMap = {
325
205
  thin: "100",
326
206
  extralight: "200",
@@ -376,7 +256,7 @@ const textShadows = [
376
256
  const v = theme.textShadow?.[s || "DEFAULT"];
377
257
  if (v != null) {
378
258
  return {
379
- "--un-text-shadow": colorableShadows(v, "--un-text-shadow-color").join(","),
259
+ "--un-text-shadow": utilities.colorableShadows(v, "--un-text-shadow-color").join(","),
380
260
  "text-shadow": "var(--un-text-shadow)"
381
261
  };
382
262
  }
@@ -545,14 +425,114 @@ const floats = [
545
425
  ["clear-none", { clear: "none" }]
546
426
  ];
547
427
  const zIndexes = [
548
- [/^z-(.+)$/, ([, v]) => ({ "z-index": utilities.handler.bracket.cssvar.number(v) })],
549
- ["z-auto", { "z-index": "auto" }]
428
+ [/^z-(.+)$/, ([, v]) => ({ "z-index": utilities.handler.bracket.cssvar.auto.number(v) })]
550
429
  ];
551
430
  const boxSizing = [
552
431
  ["box-border", { "box-sizing": "border-box" }],
553
432
  ["box-content", { "box-sizing": "content-box" }]
554
433
  ];
555
434
 
435
+ const varEmpty = "var(--un-empty,/*!*/ /*!*/)";
436
+ const displays = [
437
+ ["inline", { display: "inline" }],
438
+ ["block", { display: "block" }],
439
+ ["inline-block", { display: "inline-block" }],
440
+ ["contents", { display: "contents" }],
441
+ ["flow-root", { display: "flow-root" }],
442
+ ["list-item", { display: "list-item" }],
443
+ ["hidden", { display: "none" }],
444
+ [/^display-(.+)$/, ([, c]) => ({ display: utilities.handler.bracket.cssvar(c) || c })]
445
+ ];
446
+ const appearances = [
447
+ ["visible", { visibility: "visible" }],
448
+ ["invisible", { visibility: "hidden" }],
449
+ ["backface-visible", { "backface-visibility": "visible" }],
450
+ ["backface-hidden", { "backface-visibility": "hidden" }]
451
+ ];
452
+ const cursors = [
453
+ [/^cursor-(.+)$/, ([, c]) => ({ cursor: utilities.handler.bracket.cssvar(c) || c })]
454
+ ];
455
+ const pointerEvents = [
456
+ ["pointer-events-auto", { "pointer-events": "auto" }],
457
+ ["pointer-events-none", { "pointer-events": "none" }]
458
+ ];
459
+ const resizes = [
460
+ ["resize-x", { resize: "horizontal" }],
461
+ ["resize-y", { resize: "vertical" }],
462
+ ["resize", { resize: "both" }],
463
+ ["resize-none", { resize: "none" }]
464
+ ];
465
+ const userSelects = [
466
+ ["select-auto", { "user-select": "auto" }],
467
+ ["select-all", { "user-select": "all" }],
468
+ ["select-text", { "user-select": "text" }],
469
+ ["select-none", { "user-select": "none" }]
470
+ ];
471
+ const whitespaces = [
472
+ [/^(?:whitespace|ws)-(normal|nowrap|pre|pre-line|pre-wrap)$/, ([, v]) => ({ "white-space": v })]
473
+ ];
474
+ const contents = [
475
+ ["content-empty", { content: '""' }],
476
+ ["content-none", { content: '""' }]
477
+ ];
478
+ const breaks = [
479
+ ["break-normal", { "overflow-wrap": "normal", "word-break": "normal" }],
480
+ ["break-words", { "overflow-wrap": "break-word" }],
481
+ ["break-all", { "word-break": "break-all" }]
482
+ ];
483
+ const textOverflows = [
484
+ ["truncate", { "overflow": "hidden", "text-overflow": "ellipsis", "white-space": "nowrap" }],
485
+ ["text-ellipsis", { "text-overflow": "ellipsis" }],
486
+ ["text-clip", { "text-overflow": "clip" }]
487
+ ];
488
+ const textTransforms = [
489
+ ["case-upper", { "text-transform": "uppercase" }],
490
+ ["case-lower", { "text-transform": "lowercase" }],
491
+ ["case-capital", { "text-transform": "capitalize" }],
492
+ ["case-normal", { "text-transform": "none" }]
493
+ ];
494
+ const fontStyles = [
495
+ ["italic", { "font-style": "italic" }],
496
+ ["not-italic", { "font-style": "normal" }]
497
+ ];
498
+ const fontSmoothings = [
499
+ ["antialiased", {
500
+ "-webkit-font-smoothing": "antialiased",
501
+ "-moz-osx-font-smoothing": "grayscale",
502
+ "font-smoothing": "grayscale"
503
+ }],
504
+ ["subpixel-antialiased", {
505
+ "-webkit-font-smoothing": "auto",
506
+ "-moz-osx-font-smoothing": "auto",
507
+ "font-smoothing": "auto"
508
+ }]
509
+ ];
510
+
511
+ const shadowBase = {
512
+ [core.CONTROL_SHORTCUT_NO_MERGE]: "",
513
+ "--un-ring-offset-shadow": "0 0 #0000",
514
+ "--un-ring-shadow": "0 0 #0000",
515
+ "--un-shadow-inset": varEmpty,
516
+ "--un-shadow": "0 0 #0000"
517
+ };
518
+ const boxShadows = [
519
+ [/^shadow(?:-(.+))?$/, ([, d], { theme }) => {
520
+ const v = theme.boxShadow?.[d || "DEFAULT"];
521
+ if (v) {
522
+ return [
523
+ shadowBase,
524
+ {
525
+ "--un-shadow": utilities.colorableShadows(v, "--un-shadow-color").join(","),
526
+ "box-shadow": "var(--un-ring-offset-shadow, 0 0 #0000), var(--un-ring-shadow, 0 0 #0000), var(--un-shadow)"
527
+ }
528
+ ];
529
+ }
530
+ }],
531
+ [/^shadow-(.+)$/, utilities.colorResolver("--un-shadow-color", "shadow")],
532
+ [/^shadow-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-shadow-opacity": utilities.handler.bracket.percent(opacity) })],
533
+ ["shadow-inset", { "--un-shadow-inset": "inset" }]
534
+ ];
535
+
556
536
  const ringBase = {
557
537
  ...shadowBase,
558
538
  "--un-ring-inset": varEmpty,
@@ -806,10 +786,10 @@ const variablesAbbrMap = {
806
786
  ws: "white-space"
807
787
  };
808
788
  const cssVariables = [
809
- [/^(.+?)-\$(.+)$/, ([, name, varname]) => {
789
+ [/^(.+?)-(\$.+)$/, ([, name, varname]) => {
810
790
  const prop = variablesAbbrMap[name];
811
791
  if (prop)
812
- return { [prop]: `var(--${varname})` };
792
+ return { [prop]: utilities.handler.cssvar(varname) };
813
793
  }]
814
794
  ];
815
795
  const cssProperty = [
@@ -828,11 +808,7 @@ ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
828
808
  ];
829
809
 
830
810
  const textDecorations = [
831
- ["underline", { "text-decoration-line": "underline" }],
832
- ["overline", { "text-decoration-line": "overline" }],
833
- ["line-through", { "text-decoration-line": "line-through" }],
834
- ["decoration-underline", { "text-decoration-line": "underline" }],
835
- ["decoration-line-through", { "text-decoration-line": "line-through" }],
811
+ [/^(?:decoration-)?(underline|overline|line-through)$/, ([, s]) => ({ "text-decoration-line": s })],
836
812
  [/^(?:underline|decoration)-(?:size-)?(.+)$/, ([, s]) => ({ "text-decoration-thickness": utilities.handler.bracket.cssvar.px(s) })],
837
813
  [/^(?:underline|decoration)-(auto|from-font)$/, ([, s]) => ({ "text-decoration-thickness": s })],
838
814
  [/^(?:underline|decoration)-(.+)$/, (match, ctx) => {
@@ -937,7 +913,6 @@ exports.borders = borders;
937
913
  exports.boxShadows = boxShadows;
938
914
  exports.boxSizing = boxSizing;
939
915
  exports.breaks = breaks;
940
- exports.colorableShadows = colorableShadows;
941
916
  exports.contents = contents;
942
917
  exports.cssProperty = cssProperty;
943
918
  exports.cssVariables = cssVariables;