@unocss/preset-mini 0.16.1 → 0.17.2

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/rules.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Rule, RuleContext } from '@unocss/core';
1
+ import { Rule } from '@unocss/core';
2
2
  import { T as Theme } from './types-7963d0b3';
3
3
 
4
4
  declare const verticalAligns: Rule[];
@@ -7,19 +7,10 @@ declare const textAligns: Rule[];
7
7
  declare const outline: Rule[];
8
8
  declare const appearance: Rule[];
9
9
  declare const placeholder: Rule[];
10
+ declare const willChange: Rule[];
10
11
 
11
12
  declare const borders: Rule[];
12
13
 
13
- declare const parseColorUtil: (body: string, theme: Theme) => {
14
- opacity: string;
15
- name: string;
16
- no: string;
17
- color: string | undefined;
18
- rgba: [number, number, number, number] | [number, number, number] | undefined;
19
- } | undefined;
20
- declare const colorResolver: (attribute: string, varName: string) => ([, body]: string[], { theme }: RuleContext<Theme>) => {
21
- [x: string]: string | number;
22
- } | undefined;
23
14
  /**
24
15
  * @example op10 op-30 opacity-100
25
16
  */
@@ -32,7 +23,6 @@ declare const bgColors: Rule[];
32
23
  declare const borderColors: Rule[];
33
24
  declare const ringColors: Rule[];
34
25
  declare const ringOffsetColors: Rule[];
35
- declare const fillColors: Rule[];
36
26
 
37
27
  declare const rules: Rule[];
38
28
 
@@ -86,6 +76,8 @@ declare const textTransforms: Rule[];
86
76
  declare const fontStyles: Rule[];
87
77
  declare const fontSmoothings: Rule[];
88
78
 
79
+ declare const svgUtilities: Rule[];
80
+
89
81
  declare const transforms: Rule[];
90
82
 
91
83
  declare const transitions: Rule[];
@@ -100,4 +92,4 @@ declare const cssVariables: Rule[];
100
92
 
101
93
  declare const textDecorations: Rule[];
102
94
 
103
- export { alignments, appearance, appearances, aspectRatio, bgColors, borderColors, borders, boxShadows, boxSizing, breaks, colorResolver, contents, cssVariables, cursors, displays, fillColors, flex, floats, fontSmoothings, fontStyles, fonts, gaps, grids, insets, justifies, margins, opacity, orders, outline, overflows, paddings, parseColorUtil, placeholder, placements, pointerEvents, positions, questionMark, resizes, ringColors, ringOffsetColors, rings, rules, sizes, tabSizes, textAligns, textColors, textDecorations, textIndents, textOverflows, textShadows, textStrokes, textTransforms, transforms, transitions, userSelects, varEmpty, verticalAligns, whitespaces, zIndexes };
95
+ export { alignments, appearance, appearances, aspectRatio, bgColors, borderColors, borders, boxShadows, boxSizing, breaks, contents, cssVariables, cursors, displays, flex, floats, fontSmoothings, fontStyles, fonts, gaps, grids, insets, justifies, margins, opacity, orders, outline, overflows, paddings, placeholder, placements, pointerEvents, positions, questionMark, resizes, ringColors, ringOffsetColors, rings, rules, sizes, svgUtilities, tabSizes, textAligns, textColors, textDecorations, textIndents, textOverflows, textShadows, textStrokes, textTransforms, transforms, transitions, userSelects, varEmpty, verticalAligns, whitespaces, willChange, zIndexes };
package/dist/rules.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { x as alignments, a as appearance, M as appearances, H as aspectRatio, g as bgColors, h as borderColors, b as borders, F as boxShadows, C as boxSizing, T as breaks, d as colorResolver, S as contents, a3 as cssVariables, N as cursors, L as displays, k as fillColors, l as flex, A as floats, X as fontSmoothings, W as fontStyles, _ as fonts, m as gaps, n as grids, z as insets, u as justifies, J as margins, e as opacity, w as orders, o as outline, q as overflows, I as paddings, c as parseColorUtil, p as placeholder, y as placements, O as pointerEvents, s as positions, D as questionMark, P as resizes, i as ringColors, j as ringOffsetColors, E as rings, r as rules, G as sizes, $ as tabSizes, t as textAligns, f as textColors, a4 as textDecorations, a0 as textIndents, U as textOverflows, a2 as textShadows, a1 as textStrokes, V as textTransforms, Y as transforms, Z as transitions, Q as userSelects, K as varEmpty, v as verticalAligns, R as whitespaces, B as zIndexes } from './chunks/default2.mjs';
1
+ export { s as alignments, a as appearance, K as appearances, F as aspectRatio, e as bgColors, f as borderColors, b as borders, D as boxShadows, A as boxSizing, R as breaks, Q as contents, a2 as cssVariables, L as cursors, J as displays, i as flex, y as floats, V as fontSmoothings, U as fontStyles, Z as fonts, j as gaps, k as grids, x as insets, n as justifies, H as margins, c as opacity, q as orders, o as outline, l as overflows, G as paddings, p as placeholder, u as placements, M as pointerEvents, m as positions, B as questionMark, N as resizes, g as ringColors, h as ringOffsetColors, C as rings, r as rules, E as sizes, W as svgUtilities, _ as tabSizes, t as textAligns, d as textColors, a3 as textDecorations, $ as textIndents, S as textOverflows, a1 as textShadows, a0 as textStrokes, T as textTransforms, X as transforms, Y as transitions, O as userSelects, I as varEmpty, v as verticalAligns, P as whitespaces, w as willChange, z as zIndexes } from './chunks/default2.mjs';
2
+ import './chunks/utilities.mjs';
2
3
  import '@unocss/core';
3
- import './chunks/index.mjs';
4
4
  import './chunks/pseudo.mjs';
package/dist/utils.cjs CHANGED
@@ -2,17 +2,20 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./chunks/index.cjs');
5
+ const utilities = require('./chunks/utilities.cjs');
6
6
  const variants = require('./chunks/variants.cjs');
7
7
  require('@unocss/core');
8
8
 
9
9
 
10
10
 
11
- exports.capitalize = index.capitalize;
12
- exports.cornerMap = index.cornerMap;
13
- exports.directionMap = index.directionMap;
14
- exports.h = index.h;
15
- exports.handler = index.handler;
16
- exports.valueHandlers = index.valueHandlers;
17
- exports.xyzMap = index.xyzMap;
11
+ exports.capitalize = utilities.capitalize;
12
+ exports.colorResolver = utilities.colorResolver;
13
+ exports.cornerMap = utilities.cornerMap;
14
+ exports.directionMap = utilities.directionMap;
15
+ exports.directionSize = utilities.directionSize;
16
+ exports.h = utilities.h;
17
+ exports.handler = utilities.handler;
18
+ exports.parseColor = utilities.parseColor;
19
+ exports.valueHandlers = utilities.valueHandlers;
20
+ exports.xyzMap = utilities.xyzMap;
18
21
  exports.variantMatcher = variants.variantMatcher;
package/dist/utils.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import * as _unocss_core from '@unocss/core';
2
- import { VariantHandler } from '@unocss/core';
2
+ import { VariantHandler, DynamicMatcher, ParsedColorValue } from '@unocss/core';
3
+ import { T as Theme } from './types-7963d0b3';
3
4
 
4
5
  declare const directionMap: Record<string, string[]>;
5
6
  declare const cornerMap: Record<string, string[]>;
6
7
  declare const xyzMap: Record<string, string[]>;
7
8
 
9
+ declare function numberWithUnit(str: string): string | undefined;
10
+ declare function auto(str: string): "auto" | undefined;
8
11
  declare function rem(str: string): string | undefined;
9
12
  declare function px(str: string): string | undefined;
10
13
  declare function number(str: string): number | undefined;
@@ -14,7 +17,10 @@ declare function bracket(str: string): string | undefined;
14
17
  declare function cssvar(str: string): string | undefined;
15
18
  declare function time(str: string): string | undefined;
16
19
  declare function global(str: string): string | undefined;
20
+ declare function properties(str: string): string | undefined;
17
21
 
22
+ declare const handlers_numberWithUnit: typeof numberWithUnit;
23
+ declare const handlers_auto: typeof auto;
18
24
  declare const handlers_rem: typeof rem;
19
25
  declare const handlers_px: typeof px;
20
26
  declare const handlers_number: typeof number;
@@ -24,8 +30,11 @@ declare const handlers_bracket: typeof bracket;
24
30
  declare const handlers_cssvar: typeof cssvar;
25
31
  declare const handlers_time: typeof time;
26
32
  declare const handlers_global: typeof global;
33
+ declare const handlers_properties: typeof properties;
27
34
  declare namespace handlers {
28
35
  export {
36
+ handlers_numberWithUnit as numberWithUnit,
37
+ handlers_auto as auto,
29
38
  handlers_rem as rem,
30
39
  handlers_px as px,
31
40
  handlers_number as number,
@@ -35,14 +44,65 @@ declare namespace handlers {
35
44
  handlers_cssvar as cssvar,
36
45
  handlers_time as time,
37
46
  handlers_global as global,
47
+ handlers_properties as properties,
38
48
  };
39
49
  }
40
50
 
41
- declare const handler: _unocss_core.ValueHandler<"number" | "rem" | "px" | "percent" | "fraction" | "bracket" | "cssvar" | "time" | "global">;
42
- declare const h: _unocss_core.ValueHandler<"number" | "rem" | "px" | "percent" | "fraction" | "bracket" | "cssvar" | "time" | "global">;
51
+ declare const handler: _unocss_core.ValueHandler<"number" | "auto" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "cssvar" | "time" | "global" | "properties">;
52
+ declare const h: _unocss_core.ValueHandler<"number" | "auto" | "numberWithUnit" | "rem" | "px" | "percent" | "fraction" | "bracket" | "cssvar" | "time" | "global" | "properties">;
43
53
 
44
54
  declare const variantMatcher: (name: string, selector?: ((input: string) => string | undefined) | undefined) => (input: string) => VariantHandler | undefined;
45
55
 
46
56
  declare function capitalize<T extends string>(str: T): Capitalize<T>;
57
+ /**
58
+ * Provide {@link DynamicMatcher} function returning spacing definition. See spacing rules.
59
+ *
60
+ * @param {string} propertyPrefix - Property for the css value to be created. Postfix will be appended according to direction matched.
61
+ * @return {DynamicMatcher} {@link DynamicMatcher}
62
+ * @see {@link directionMap}
63
+ */
64
+ declare const directionSize: (propertyPrefix: string) => DynamicMatcher;
65
+ /**
66
+ * Parse color string into rgba (if possible) with opacity opacity. Color value will be matched to theme object before converting to rgb value.
67
+ *
68
+ * @example Parseable strings:
69
+ * 'red' // From theme, if 'red' is available
70
+ * 'red-100' // From theme, plus scale
71
+ * 'red-100/20' // From theme, plus scale/opacity
72
+ * '#f12' // Hex color
73
+ * 'hex-f12' // Alternative hex color
74
+ * '[rgb(100,2,3)]/[var(--op)]' // Bracket with rgb color and bracket with opacity
75
+ *
76
+ * @param {string} body - Color string to be parsed.
77
+ * @param {Theme} theme - {@link Theme} object.
78
+ * @return {ParsedColorValue|undefined} {@link ParsedColorValue} object if string is parseable.
79
+ */
80
+ declare const parseColor: (body: string, theme: Theme) => ParsedColorValue | undefined;
81
+ /**
82
+ * Provide {@link DynamicMatcher} function to produce color value matched from rule.
83
+ *
84
+ * @see {@link parseColor}
85
+ *
86
+ * @example Resolving 'red' from theme:
87
+ * colorResolver('background-color', 'background')('', 'red')
88
+ * return { 'background-color': '#f12' }
89
+ *
90
+ * @example Resolving 'red-100' from theme:
91
+ * colorResolver('background-color', 'background')('', 'red-100')
92
+ * return { '--un-background-opacity': '1', 'background-color': 'rgba(254,226,226,var(--un-bg-opacity))' }
93
+ *
94
+ * @example Resolving 'red-100/20' from theme:
95
+ * colorResolver('background-color', 'background')('', 'red-100/20')
96
+ * return { 'background-color': 'rgba(204,251,241,0.22)' }
97
+ *
98
+ * @example Resolving 'hex-124':
99
+ * colorResolver('color', 'text')('', 'hex-124')
100
+ * return { '--un-text-opacity': '1', 'color': 'rgba(17,34,68,var(--un-text-opacity))' }
101
+ *
102
+ * @param {string} property - Property for the css value to be created.
103
+ * @param {string} varName - Base name for the opacity variable.
104
+ * @return {DynamicMatcher} {@link DynamicMatcher} object.
105
+ */
106
+ declare const colorResolver: (property: string, varName: string) => DynamicMatcher;
47
107
 
48
- export { capitalize, cornerMap, directionMap, h, handler, handlers as valueHandlers, variantMatcher, xyzMap };
108
+ export { capitalize, colorResolver, cornerMap, directionMap, directionSize, h, handler, parseColor, handlers as valueHandlers, variantMatcher, xyzMap };
package/dist/utils.mjs CHANGED
@@ -1,3 +1,3 @@
1
- export { a as capitalize, c as cornerMap, d as directionMap, b as h, h as handler, v as valueHandlers, x as xyzMap } from './chunks/index.mjs';
1
+ export { b as capitalize, c as colorResolver, a as cornerMap, d as directionMap, e as directionSize, f as h, h as handler, p as parseColor, v as valueHandlers, x as xyzMap } from './chunks/utilities.mjs';
2
2
  export { v as variantMatcher } from './chunks/variants.mjs';
3
3
  import '@unocss/core';
package/dist/variants.cjs CHANGED
@@ -10,14 +10,15 @@ require('@unocss/core');
10
10
 
11
11
 
12
12
  exports.variantBreakpoints = _default.variantBreakpoints;
13
- exports.variantChildren = _default.variantChildren;
14
13
  exports.variantColorsClass = _default.variantColorsClass;
15
14
  exports.variantColorsMedia = _default.variantColorsMedia;
15
+ exports.variantCombinators = _default.variantCombinators;
16
16
  exports.variantImportant = _default.variantImportant;
17
17
  exports.variantNegative = _default.variantNegative;
18
18
  exports.variantSpace = _default.variantSpace;
19
19
  exports.variants = _default.variants;
20
- exports.CONTROL_BYPASS_PSEUDO = pseudo.CONTROL_BYPASS_PSEUDO;
20
+ exports.CONTROL_BYPASS_PSEUDO_CLASS = pseudo.CONTROL_BYPASS_PSEUDO_CLASS;
21
21
  exports.PseudoClasses = pseudo.PseudoClasses;
22
+ exports.partClasses = pseudo.partClasses;
22
23
  exports.variantPseudoClasses = pseudo.variantPseudoClasses;
23
24
  exports.variantPseudoElements = pseudo.variantPseudoElements;
@@ -3,7 +3,7 @@ import { T as Theme } from './types-7963d0b3';
3
3
 
4
4
  declare const variantBreakpoints: Variant<Theme>;
5
5
 
6
- declare const variantChildren: Variant[];
6
+ declare const variantCombinators: Variant[];
7
7
 
8
8
  declare const variantColorsClass: Variant[];
9
9
  declare const variantColorsMedia: Variant[];
@@ -14,9 +14,10 @@ declare const variantImportant: Variant;
14
14
  declare const variantNegative: Variant;
15
15
  declare const variantSpace: Variant;
16
16
 
17
- declare const CONTROL_BYPASS_PSEUDO = "$$no-pseudo";
17
+ declare const CONTROL_BYPASS_PSEUDO_CLASS = "$$no-pseudo";
18
18
  declare const PseudoClasses: Record<string, string | undefined>;
19
19
  declare const variantPseudoElements: VariantFunction;
20
20
  declare const variantPseudoClasses: VariantObject;
21
+ declare const partClasses: VariantObject;
21
22
 
22
- export { CONTROL_BYPASS_PSEUDO, PseudoClasses, variantBreakpoints, variantChildren, variantColorsClass, variantColorsMedia, variantImportant, variantNegative, variantPseudoClasses, variantPseudoElements, variantSpace, variants };
23
+ export { CONTROL_BYPASS_PSEUDO_CLASS, PseudoClasses, partClasses, variantBreakpoints, variantColorsClass, variantColorsMedia, variantCombinators, variantImportant, variantNegative, variantPseudoClasses, variantPseudoElements, variantSpace, variants };
package/dist/variants.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { c as variantBreakpoints, d as variantChildren, b as variantColorsClass, a as variantColorsMedia, e as variantImportant, f as variantNegative, g as variantSpace, v as variants } from './chunks/default3.mjs';
2
- export { C as CONTROL_BYPASS_PSEUDO, P as PseudoClasses, v as variantPseudoClasses, a as variantPseudoElements } from './chunks/pseudo.mjs';
1
+ export { c as variantBreakpoints, b as variantColorsClass, a as variantColorsMedia, d as variantCombinators, e as variantImportant, f as variantNegative, g as variantSpace, v as variants } from './chunks/default3.mjs';
2
+ export { C as CONTROL_BYPASS_PSEUDO_CLASS, P as PseudoClasses, p as partClasses, v as variantPseudoClasses, a as variantPseudoElements } from './chunks/pseudo.mjs';
3
3
  import './chunks/variants.mjs';
4
4
  import '@unocss/core';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unocss/preset-mini",
3
- "version": "0.16.1",
3
+ "version": "0.17.2",
4
4
  "description": "The minimal preset for UnoCSS",
5
5
  "keywords": [
6
6
  "unocss",
@@ -61,7 +61,7 @@
61
61
  "*.css"
62
62
  ],
63
63
  "dependencies": {
64
- "@unocss/core": "0.16.1"
64
+ "@unocss/core": "0.17.2"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "unbuild",
@@ -1,142 +0,0 @@
1
- 'use strict';
2
-
3
- const core = require('@unocss/core');
4
-
5
- const directionMap = {
6
- "l": ["-left"],
7
- "r": ["-right"],
8
- "t": ["-top"],
9
- "b": ["-bottom"],
10
- "s": ["-inline-start"],
11
- "e": ["-inline-end"],
12
- "x": ["-left", "-right"],
13
- "y": ["-top", "-bottom"],
14
- "": [""],
15
- "a": [""]
16
- };
17
- const cornerMap = {
18
- "t": ["-top-left", "-top-right"],
19
- "r": ["-top-right", "-bottom-right"],
20
- "b": ["-bottom-left", "-bottom-right"],
21
- "l": ["-bottom-left", "-top-left"],
22
- "tl": ["-top-left"],
23
- "lt": ["-top-left"],
24
- "tr": ["-top-right"],
25
- "rt": ["-top-right"],
26
- "bl": ["-bottom-left"],
27
- "lb": ["-bottom-left"],
28
- "br": ["-bottom-right"],
29
- "rb": ["-bottom-right"],
30
- "": [""]
31
- };
32
- const xyzMap = {
33
- "x": ["-x"],
34
- "y": ["-y"],
35
- "z": ["-z"],
36
- "": ["-x", "-y"]
37
- };
38
-
39
- const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
40
- const numberRE = /^(-?[0-9.]+)$/i;
41
- const unitOnlyRE = /^(px)$/i;
42
- function rem(str) {
43
- if (str === "auto" || str === "a")
44
- return "auto";
45
- if (str.match(unitOnlyRE))
46
- return `1${str}`;
47
- const match = str.match(numberWithUnitRE);
48
- if (!match)
49
- return;
50
- const [, n, unit] = match;
51
- if (unit)
52
- return str;
53
- const num = parseFloat(n);
54
- if (!Number.isNaN(num))
55
- return `${num / 4}rem`;
56
- }
57
- function px(str) {
58
- if (str.match(unitOnlyRE))
59
- return `1${str}`;
60
- const match = str.match(numberWithUnitRE);
61
- if (!match)
62
- return;
63
- const [, n, unit] = match;
64
- if (unit)
65
- return str;
66
- const num = parseFloat(n);
67
- if (!Number.isNaN(num))
68
- return `${num}px`;
69
- }
70
- function number(str) {
71
- if (!numberRE.test(str))
72
- return;
73
- const num = parseFloat(str);
74
- if (!Number.isNaN(num))
75
- return num;
76
- }
77
- function percent(str) {
78
- if (str.endsWith("%"))
79
- str = str.slice(0, -1);
80
- const num = parseFloat(str);
81
- if (!Number.isNaN(num))
82
- return `${num / 100}`;
83
- }
84
- function fraction(str) {
85
- if (str === "full")
86
- return "100%";
87
- const [left, right] = str.split("/");
88
- const num = parseFloat(left) / parseFloat(right);
89
- if (!Number.isNaN(num))
90
- return `${num * 100}%`;
91
- }
92
- function bracket(str) {
93
- if (str && str[0] === "[" && str[str.length - 1] === "]") {
94
- return str.slice(1, -1).replace(/_/g, " ").replace(/calc\((.*)/g, (v) => {
95
- return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
96
- });
97
- }
98
- }
99
- function cssvar(str) {
100
- if (str.startsWith("$"))
101
- return `var(--${str.slice(1)})`;
102
- }
103
- function time(str) {
104
- const duration = Number(str.replace(/(s|ms)$/, ""));
105
- if (isNaN(duration))
106
- return;
107
- if (/ms|s$/.test(str))
108
- return str;
109
- return `${str}ms`;
110
- }
111
- function global(str) {
112
- if (["inherit", "initial", "unset"].includes(str))
113
- return str;
114
- }
115
-
116
- const valueHandlers = {
117
- __proto__: null,
118
- rem: rem,
119
- px: px,
120
- number: number,
121
- percent: percent,
122
- fraction: fraction,
123
- bracket: bracket,
124
- cssvar: cssvar,
125
- time: time,
126
- global: global
127
- };
128
-
129
- const handler = core.createValueHandler(valueHandlers);
130
- const h = handler;
131
-
132
- function capitalize(str) {
133
- return str.charAt(0).toUpperCase() + str.slice(1);
134
- }
135
-
136
- exports.capitalize = capitalize;
137
- exports.cornerMap = cornerMap;
138
- exports.directionMap = directionMap;
139
- exports.h = h;
140
- exports.handler = handler;
141
- exports.valueHandlers = valueHandlers;
142
- exports.xyzMap = xyzMap;
@@ -1,134 +0,0 @@
1
- import { createValueHandler } from '@unocss/core';
2
-
3
- const directionMap = {
4
- "l": ["-left"],
5
- "r": ["-right"],
6
- "t": ["-top"],
7
- "b": ["-bottom"],
8
- "s": ["-inline-start"],
9
- "e": ["-inline-end"],
10
- "x": ["-left", "-right"],
11
- "y": ["-top", "-bottom"],
12
- "": [""],
13
- "a": [""]
14
- };
15
- const cornerMap = {
16
- "t": ["-top-left", "-top-right"],
17
- "r": ["-top-right", "-bottom-right"],
18
- "b": ["-bottom-left", "-bottom-right"],
19
- "l": ["-bottom-left", "-top-left"],
20
- "tl": ["-top-left"],
21
- "lt": ["-top-left"],
22
- "tr": ["-top-right"],
23
- "rt": ["-top-right"],
24
- "bl": ["-bottom-left"],
25
- "lb": ["-bottom-left"],
26
- "br": ["-bottom-right"],
27
- "rb": ["-bottom-right"],
28
- "": [""]
29
- };
30
- const xyzMap = {
31
- "x": ["-x"],
32
- "y": ["-y"],
33
- "z": ["-z"],
34
- "": ["-x", "-y"]
35
- };
36
-
37
- const numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
38
- const numberRE = /^(-?[0-9.]+)$/i;
39
- const unitOnlyRE = /^(px)$/i;
40
- function rem(str) {
41
- if (str === "auto" || str === "a")
42
- return "auto";
43
- if (str.match(unitOnlyRE))
44
- return `1${str}`;
45
- const match = str.match(numberWithUnitRE);
46
- if (!match)
47
- return;
48
- const [, n, unit] = match;
49
- if (unit)
50
- return str;
51
- const num = parseFloat(n);
52
- if (!Number.isNaN(num))
53
- return `${num / 4}rem`;
54
- }
55
- function px(str) {
56
- if (str.match(unitOnlyRE))
57
- return `1${str}`;
58
- const match = str.match(numberWithUnitRE);
59
- if (!match)
60
- return;
61
- const [, n, unit] = match;
62
- if (unit)
63
- return str;
64
- const num = parseFloat(n);
65
- if (!Number.isNaN(num))
66
- return `${num}px`;
67
- }
68
- function number(str) {
69
- if (!numberRE.test(str))
70
- return;
71
- const num = parseFloat(str);
72
- if (!Number.isNaN(num))
73
- return num;
74
- }
75
- function percent(str) {
76
- if (str.endsWith("%"))
77
- str = str.slice(0, -1);
78
- const num = parseFloat(str);
79
- if (!Number.isNaN(num))
80
- return `${num / 100}`;
81
- }
82
- function fraction(str) {
83
- if (str === "full")
84
- return "100%";
85
- const [left, right] = str.split("/");
86
- const num = parseFloat(left) / parseFloat(right);
87
- if (!Number.isNaN(num))
88
- return `${num * 100}%`;
89
- }
90
- function bracket(str) {
91
- if (str && str[0] === "[" && str[str.length - 1] === "]") {
92
- return str.slice(1, -1).replace(/_/g, " ").replace(/calc\((.*)/g, (v) => {
93
- return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
94
- });
95
- }
96
- }
97
- function cssvar(str) {
98
- if (str.startsWith("$"))
99
- return `var(--${str.slice(1)})`;
100
- }
101
- function time(str) {
102
- const duration = Number(str.replace(/(s|ms)$/, ""));
103
- if (isNaN(duration))
104
- return;
105
- if (/ms|s$/.test(str))
106
- return str;
107
- return `${str}ms`;
108
- }
109
- function global(str) {
110
- if (["inherit", "initial", "unset"].includes(str))
111
- return str;
112
- }
113
-
114
- const valueHandlers = {
115
- __proto__: null,
116
- rem: rem,
117
- px: px,
118
- number: number,
119
- percent: percent,
120
- fraction: fraction,
121
- bracket: bracket,
122
- cssvar: cssvar,
123
- time: time,
124
- global: global
125
- };
126
-
127
- const handler = createValueHandler(valueHandlers);
128
- const h = handler;
129
-
130
- function capitalize(str) {
131
- return str.charAt(0).toUpperCase() + str.slice(1);
132
- }
133
-
134
- export { capitalize as a, h as b, cornerMap as c, directionMap as d, handler as h, valueHandlers as v, xyzMap as x };