@unocss/preset-uno 0.14.1 → 0.15.1

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,190 +0,0 @@
1
- import {
2
- __export
3
- } from "./chunk-5SH5BFJ4.mjs";
4
-
5
- // src/utils/mappings.ts
6
- var directionMap = {
7
- "l": ["-left"],
8
- "r": ["-right"],
9
- "t": ["-top"],
10
- "b": ["-bottom"],
11
- "s": ["-inline-start"],
12
- "e": ["-inline-end"],
13
- "x": ["-left", "-right"],
14
- "y": ["-top", "-bottom"],
15
- "": [""],
16
- "a": [""]
17
- };
18
- var cornerMap = {
19
- "t": ["-top-left", "-top-right"],
20
- "r": ["-top-right", "-bottom-right"],
21
- "b": ["-bottom-left", "-bottom-right"],
22
- "l": ["-bottom-left", "-top-left"],
23
- "tl": ["-top-left"],
24
- "lt": ["-top-left"],
25
- "tr": ["-top-right"],
26
- "rt": ["-top-right"],
27
- "bl": ["-bottom-left"],
28
- "lb": ["-bottom-left"],
29
- "br": ["-bottom-right"],
30
- "rb": ["-bottom-right"],
31
- "": [""]
32
- };
33
- var xyzMap = {
34
- "x": ["-x"],
35
- "y": ["-y"],
36
- "z": ["-z"],
37
- "": ["-x", "-y"]
38
- };
39
-
40
- // src/utils/handlers/handlers.ts
41
- var handlers_exports = {};
42
- __export(handlers_exports, {
43
- bracket: () => bracket,
44
- cssvar: () => cssvar,
45
- fraction: () => fraction,
46
- global: () => global,
47
- number: () => number,
48
- percent: () => percent,
49
- px: () => px,
50
- rem: () => rem,
51
- time: () => time
52
- });
53
- var numberWithUnitRE = /^(-?[0-9.]+)(px|pt|pc|rem|em|%|vh|vw|in|cm|mm|ex|ch|vmin|vmax)?$/i;
54
- var numberRE = /^(-?[0-9.]+)$/i;
55
- function rem(str) {
56
- if (str === "auto" || str === "a")
57
- return "auto";
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 / 4}rem`;
67
- }
68
- function px(str) {
69
- const match = str.match(numberWithUnitRE);
70
- if (!match)
71
- return;
72
- const [, n, unit] = match;
73
- if (unit)
74
- return str;
75
- const num = parseFloat(n);
76
- if (!Number.isNaN(num))
77
- return `${num}px`;
78
- }
79
- function number(str) {
80
- if (!numberRE.test(str))
81
- return;
82
- const num = parseFloat(str);
83
- if (!Number.isNaN(num))
84
- return num;
85
- }
86
- function percent(str) {
87
- if (str.endsWith("%"))
88
- str = str.slice(0, -1);
89
- const num = parseFloat(str);
90
- if (!Number.isNaN(num))
91
- return `${num / 100}`;
92
- }
93
- function fraction(str) {
94
- if (str === "full")
95
- return "100%";
96
- const [left, right] = str.split("/");
97
- const num = parseFloat(left) / parseFloat(right);
98
- if (!Number.isNaN(num))
99
- return `${num * 100}%`;
100
- }
101
- function bracket(str) {
102
- if (str && str[0] === "[" && str[str.length - 1] === "]") {
103
- return str.slice(1, -1).replace(/_/g, " ").replace(/calc\((.*)/g, (v) => {
104
- return v.replace(/(-?\d*\.?\d(?!\b-.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ");
105
- });
106
- }
107
- }
108
- function cssvar(str) {
109
- if (str.startsWith("$"))
110
- return `var(--${str.slice(1)})`;
111
- }
112
- function time(str) {
113
- const duration = Number(str.replace(/(s|ms)$/, ""));
114
- if (isNaN(duration))
115
- return;
116
- if (/ms|s$/.test(str))
117
- return str;
118
- return `${str}ms`;
119
- }
120
- function global(str) {
121
- if (["inherit", "initial", "unset"].includes(str))
122
- return str;
123
- }
124
-
125
- // src/utils/handlers/shorthand.ts
126
- var handlersNames = Object.keys(handlers_exports);
127
- var handler = function(str) {
128
- var _a;
129
- const s = ((_a = this.__options) == null ? void 0 : _a.sequence) || [];
130
- this.__options.sequence = [];
131
- for (const n of s) {
132
- const res = handlers_exports[n](str);
133
- if (res != null)
134
- return res;
135
- }
136
- return void 0;
137
- };
138
- function addProcessor(that, name) {
139
- if (!that.__options) {
140
- that.__options = {
141
- sequence: []
142
- };
143
- }
144
- that.__options.sequence.push(name);
145
- return that;
146
- }
147
- handlersNames.forEach((i) => {
148
- Object.defineProperty(handler, i, {
149
- enumerable: true,
150
- get() {
151
- return addProcessor(this, i);
152
- }
153
- });
154
- });
155
-
156
- // src/utils/variants.ts
157
- var variantMatcher = (name, selector) => {
158
- const length = name.length + 1;
159
- const re = new RegExp(`^${name}[:-]`);
160
- return (input) => {
161
- return input.match(re) ? {
162
- matcher: input.slice(length),
163
- selector
164
- } : void 0;
165
- };
166
- };
167
-
168
- // src/utils/index.ts
169
- function capitalize(str) {
170
- return str.charAt(0).toUpperCase() + str.slice(1);
171
- }
172
-
173
- export {
174
- directionMap,
175
- cornerMap,
176
- xyzMap,
177
- rem,
178
- px,
179
- number,
180
- percent,
181
- fraction,
182
- bracket,
183
- cssvar,
184
- time,
185
- global,
186
- handlersNames,
187
- handler,
188
- variantMatcher,
189
- capitalize
190
- };