@unocss/preset-uno 0.14.0 → 0.15.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.
@@ -1,190 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunkY6EUTGDCjs = require('./chunk-Y6EUTGDC.js');
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
- _chunkY6EUTGDCjs.__export.call(void 0, 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
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
-
188
-
189
-
190
- exports.directionMap = directionMap; exports.cornerMap = cornerMap; exports.xyzMap = xyzMap; exports.rem = rem; exports.px = px; exports.number = number; exports.percent = percent; exports.fraction = fraction; exports.bracket = bracket; exports.cssvar = cssvar; exports.time = time; exports.global = global; exports.handlersNames = handlersNames; exports.handler = handler; exports.variantMatcher = variantMatcher; exports.capitalize = capitalize;
@@ -1,234 +0,0 @@
1
- import {
2
- variantMatcher
3
- } from "./chunk-O7YRGPXQ.mjs";
4
-
5
- // src/variants/breakpoints.ts
6
- var regexCache = {};
7
- var variantBreakpoints = (matcher, _, theme) => {
8
- const variantEntries = Object.entries(theme.breakpoints || {}).map(([point, size], idx) => [point, size, idx]);
9
- for (const [point, size, idx] of variantEntries) {
10
- if (!regexCache[point])
11
- regexCache[point] = new RegExp(`^((?:[a|l]t-)?${point}[:-])`);
12
- const match = matcher.match(regexCache[point]);
13
- if (!match)
14
- continue;
15
- const [, pre] = match;
16
- let direction = "min";
17
- let order = parseInt(size);
18
- if (pre.startsWith("lt-")) {
19
- direction = "max";
20
- order = -order;
21
- }
22
- const m = matcher.slice(pre.length);
23
- if (m === "container")
24
- continue;
25
- if (pre.startsWith("at-") && idx < variantEntries.length - 1) {
26
- return {
27
- matcher: m,
28
- parent: [`@media (min-width: ${size}) and (max-width: ${variantEntries[idx + 1][1]})`, order]
29
- };
30
- }
31
- return {
32
- matcher: m,
33
- parent: [`@media (${direction}-width: ${size})`, order]
34
- };
35
- }
36
- };
37
-
38
- // src/variants/children.ts
39
- var variantChildren = [
40
- variantMatcher("children", (input) => `${input} > *`),
41
- variantMatcher("all", (input) => `${input} *`),
42
- variantMatcher("next", (input) => `${input}+*`)
43
- ];
44
-
45
- // src/variants/dark.ts
46
- var variantColorsClass = [
47
- variantMatcher("dark", (input) => `.dark $$ ${input}`),
48
- variantMatcher("light", (input) => `.light $$ ${input}`)
49
- ];
50
- var variantColorsMedia = [
51
- (v) => {
52
- const dark = variantMatcher("dark")(v);
53
- if (dark) {
54
- return {
55
- ...dark,
56
- parent: "@media (prefers-color-scheme: dark)"
57
- };
58
- }
59
- const light = variantMatcher("light")(v);
60
- if (light) {
61
- return {
62
- ...light,
63
- parent: "@media (prefers-color-scheme: light)"
64
- };
65
- }
66
- }
67
- ];
68
-
69
- // src/variants/misc.ts
70
- var variantImportant = {
71
- match(matcher) {
72
- if (matcher.startsWith("!")) {
73
- return {
74
- matcher: matcher.slice(1),
75
- body: (body) => {
76
- body.forEach((v) => {
77
- if (v[1])
78
- v[1] += " !important";
79
- });
80
- return body;
81
- }
82
- };
83
- }
84
- }
85
- };
86
- var variantNegative = {
87
- match(matcher) {
88
- if (matcher.startsWith("-")) {
89
- return {
90
- matcher: matcher.slice(1),
91
- body: (body) => {
92
- body.forEach((v) => {
93
- var _a, _b;
94
- if (v[0].startsWith("--un-scale") || ((_a = v[1]) == null ? void 0 : _a.toString()) === "0")
95
- return;
96
- v[1] = (_b = v[1]) == null ? void 0 : _b.toString().replace(/[0-9.]+(?:[a-z]+|%)?/, (i) => `-${i}`);
97
- });
98
- return body;
99
- }
100
- };
101
- }
102
- }
103
- };
104
- var variantSpace = (matcher) => {
105
- if (/^space-?([xy])-?(-?.+)$/.test(matcher) || /^divide-/.test(matcher)) {
106
- return {
107
- matcher,
108
- selector: (input) => {
109
- return `${input}>:not([hidden])~:not([hidden])`;
110
- }
111
- };
112
- }
113
- };
114
-
115
- // src/variants/pseudo.ts
116
- import { toArray } from "@unocss/core";
117
- var PseudoClasses = Object.fromEntries([
118
- "active",
119
- "checked",
120
- "default",
121
- "empty",
122
- "enabled",
123
- "disabled",
124
- "first-of-type",
125
- ["first", "first-child"],
126
- "focus-visible",
127
- "focus-within",
128
- "focus",
129
- "hover",
130
- "indeterminate",
131
- "invalid",
132
- "last-of-type",
133
- ["last", "last-child"],
134
- "link",
135
- "only-child",
136
- "only-of-type",
137
- "optional",
138
- "placeholder-shown",
139
- "read-only",
140
- "read-write",
141
- "required",
142
- "root",
143
- "target",
144
- "valid",
145
- "visited",
146
- ["even-of-type", "nth-of-type(even)"],
147
- ["even", "nth-child(even)"],
148
- ["odd-of-type", "nth-of-type(odd)"],
149
- ["odd", "nth-child(odd)"]
150
- ].map(toArray));
151
- var PseudoElements = [
152
- "before",
153
- "after",
154
- "first-letter",
155
- "first-line",
156
- "selection"
157
- ];
158
- var PseudoElementsRE = new RegExp(`^(${PseudoElements.join("|")})[:-]`);
159
- var PseudoClassesStr = Object.keys(PseudoClasses).join("|");
160
- var PseudoClassesRE = new RegExp(`^(${PseudoClassesStr})[:-]`);
161
- var PseudoClassesNotRE = new RegExp(`^not-(${PseudoClassesStr})[:-]`);
162
- var PseudoClassesGroupRE = new RegExp(`^group-(${PseudoClassesStr})[:-]`);
163
- var PseudoClassesPeerRE = new RegExp(`^peer-(${PseudoClassesStr})[:-]`);
164
- var variantPseudoElements = (input) => {
165
- const match = input.match(PseudoElementsRE);
166
- if (match) {
167
- return {
168
- matcher: input.slice(match[1].length + 1),
169
- selector: (input2) => `${input2}::${match[1]}`
170
- };
171
- }
172
- };
173
- var variantPseudoClasses = {
174
- match: (input) => {
175
- let match = input.match(PseudoClassesRE);
176
- if (match) {
177
- const pseudo = PseudoClasses[match[1]] || match[1];
178
- return {
179
- matcher: input.slice(match[1].length + 1),
180
- selector: (input2) => `${input2}:${pseudo}`
181
- };
182
- }
183
- match = input.match(PseudoClassesNotRE);
184
- if (match) {
185
- const pseudo = PseudoClasses[match[1]] || match[1];
186
- return {
187
- matcher: input.slice(match[1].length + 5),
188
- selector: (input2) => `${input2}:not(:${pseudo})`
189
- };
190
- }
191
- match = input.match(PseudoClassesGroupRE);
192
- if (match) {
193
- const pseudo = PseudoClasses[match[1]] || match[1];
194
- return {
195
- matcher: input.slice(match[1].length + 7),
196
- selector: (s) => s.includes(".group:") ? s.replace(/\.group:/, `.group:${pseudo}:`) : `.group:${pseudo} ${s}`
197
- };
198
- }
199
- match = input.match(PseudoClassesPeerRE);
200
- if (match) {
201
- const pseudo = PseudoClasses[match[1]] || match[1];
202
- return {
203
- matcher: input.slice(match[1].length + 6),
204
- selector: (s) => s.includes(".peer:") ? s.replace(/\.peer:/, `.peer:${pseudo}:`) : `.peer:${pseudo} ~ ${s}`
205
- };
206
- }
207
- },
208
- multiPass: true
209
- };
210
-
211
- // src/variants/default.ts
212
- var variants = [
213
- variantSpace,
214
- variantNegative,
215
- variantImportant,
216
- variantBreakpoints,
217
- ...variantChildren,
218
- variantPseudoClasses,
219
- variantPseudoElements
220
- ];
221
-
222
- export {
223
- variantBreakpoints,
224
- variantChildren,
225
- variantColorsClass,
226
- variantColorsMedia,
227
- variantImportant,
228
- variantNegative,
229
- variantSpace,
230
- PseudoClasses,
231
- variantPseudoElements,
232
- variantPseudoClasses,
233
- variants
234
- };
@@ -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
- };