@roku-ui/preset 0.16.0 → 0.16.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.
- package/dist/index.cjs +3 -919
- package/dist/index.mjs +3 -919
- package/package.json +9 -9
package/dist/index.cjs
CHANGED
|
@@ -2,926 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
var fs = require('node:fs');
|
|
4
4
|
var unocss = require('unocss');
|
|
5
|
-
require('magic-string');
|
|
6
5
|
|
|
7
6
|
var tailwindReset = "/*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n2. [UnoCSS]: allow to override the default border color with css var `--un-default-border-color`\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: var(--un-default-border-color, #e5e7eb); /* 2 */\n}\n\n::before,\n::after {\n --un-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n7. Disable tap highlights on iOS.\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font-family by default.\n2. Use the user's configured `mono` font-feature-settings by default.\n3. Use the user's configured `mono` font-variation-settings by default.\n4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-feature-settings: normal; /* 2 */\n font-variation-settings: normal; /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\n[type='button'],\n[type='reset'],\n[type='submit'] {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\ndialog {\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/*\nMake elements with the HTML hidden attribute stay hidden by default.\n*/\n\n[hidden]:where(:not([hidden=\"until-found\"])) {\n display: none;\n}\n";
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
return typeof s === "string";
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function escapeRegExp(string) {
|
|
14
|
-
return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
15
|
-
}
|
|
16
|
-
function escapeSelector(str) {
|
|
17
|
-
const length = str.length;
|
|
18
|
-
let index = -1;
|
|
19
|
-
let codeUnit;
|
|
20
|
-
let result = "";
|
|
21
|
-
const firstCodeUnit = str.charCodeAt(0);
|
|
22
|
-
while (++index < length) {
|
|
23
|
-
codeUnit = str.charCodeAt(index);
|
|
24
|
-
if (codeUnit === 0) {
|
|
25
|
-
result += "\uFFFD";
|
|
26
|
-
continue;
|
|
27
|
-
}
|
|
28
|
-
if (codeUnit === 37) {
|
|
29
|
-
result += "\\%";
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (codeUnit === 44) {
|
|
33
|
-
result += "\\,";
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
if (
|
|
37
|
-
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
38
|
-
// U+007F, […]
|
|
39
|
-
codeUnit >= 1 && codeUnit <= 31 || codeUnit === 127 || index === 0 && codeUnit >= 48 && codeUnit <= 57 || index === 1 && codeUnit >= 48 && codeUnit <= 57 && firstCodeUnit === 45
|
|
40
|
-
) {
|
|
41
|
-
result += `\\${codeUnit.toString(16)} `;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (
|
|
45
|
-
// If the character is the first character and is a `-` (U+002D), and
|
|
46
|
-
// there is no second character, […]
|
|
47
|
-
index === 0 && length === 1 && codeUnit === 45
|
|
48
|
-
) {
|
|
49
|
-
result += `\\${str.charAt(index)}`;
|
|
50
|
-
continue;
|
|
51
|
-
}
|
|
52
|
-
if (codeUnit >= 128 || codeUnit === 45 || codeUnit === 95 || codeUnit >= 48 && codeUnit <= 57 || codeUnit >= 65 && codeUnit <= 90 || codeUnit >= 97 && codeUnit <= 122) {
|
|
53
|
-
result += str.charAt(index);
|
|
54
|
-
continue;
|
|
55
|
-
}
|
|
56
|
-
result += `\\${str.charAt(index)}`;
|
|
57
|
-
}
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function getStringComponent(str, open, close, separators) {
|
|
62
|
-
if (str === "")
|
|
63
|
-
return;
|
|
64
|
-
if (isString(separators))
|
|
65
|
-
separators = [separators];
|
|
66
|
-
if (separators.length === 0)
|
|
67
|
-
return;
|
|
68
|
-
const l = str.length;
|
|
69
|
-
let parenthesis = 0;
|
|
70
|
-
for (let i = 0; i < l; i++) {
|
|
71
|
-
switch (str[i]) {
|
|
72
|
-
case open:
|
|
73
|
-
parenthesis++;
|
|
74
|
-
break;
|
|
75
|
-
case close:
|
|
76
|
-
if (--parenthesis < 0)
|
|
77
|
-
return;
|
|
78
|
-
break;
|
|
79
|
-
default:
|
|
80
|
-
for (const separator of separators) {
|
|
81
|
-
const separatorLength = separator.length;
|
|
82
|
-
if (separatorLength && separator === str.slice(i, i + separatorLength) && parenthesis === 0) {
|
|
83
|
-
if (i === 0 || i === l - separatorLength)
|
|
84
|
-
return;
|
|
85
|
-
return [
|
|
86
|
-
str.slice(0, i),
|
|
87
|
-
str.slice(i + separatorLength)
|
|
88
|
-
];
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return [
|
|
94
|
-
str,
|
|
95
|
-
""
|
|
96
|
-
];
|
|
97
|
-
}
|
|
98
|
-
function getStringComponents(str, separators, limit) {
|
|
99
|
-
limit = limit ?? 10;
|
|
100
|
-
const components = [];
|
|
101
|
-
let i = 0;
|
|
102
|
-
while (str !== "") {
|
|
103
|
-
if (++i > limit)
|
|
104
|
-
return;
|
|
105
|
-
const componentPair = getStringComponent(str, "(", ")", separators);
|
|
106
|
-
if (!componentPair)
|
|
107
|
-
return;
|
|
108
|
-
const [component, rest] = componentPair;
|
|
109
|
-
components.push(component);
|
|
110
|
-
str = rest;
|
|
111
|
-
}
|
|
112
|
-
if (components.length > 0)
|
|
113
|
-
return components;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
const cssColorFunctions = ["hsl", "hsla", "hwb", "lab", "lch", "oklab", "oklch", "rgb", "rgba"];
|
|
117
|
-
const alphaPlaceholders = ["%alpha", "<alpha-value>"];
|
|
118
|
-
const alphaPlaceholdersRE = new RegExp(alphaPlaceholders.map((v) => escapeRegExp(v)).join("|"));
|
|
119
|
-
function parseCssColor(str = "") {
|
|
120
|
-
const color = parseColor$1(str);
|
|
121
|
-
if (color == null || color === false)
|
|
122
|
-
return;
|
|
123
|
-
const { type: casedType, components, alpha } = color;
|
|
124
|
-
const type = casedType.toLowerCase();
|
|
125
|
-
if (components.length === 0)
|
|
126
|
-
return;
|
|
127
|
-
if (cssColorFunctions.includes(type) && ![1, 3].includes(components.length))
|
|
128
|
-
return;
|
|
129
|
-
return {
|
|
130
|
-
type,
|
|
131
|
-
components: components.map((c) => typeof c === "string" ? c.trim() : c),
|
|
132
|
-
alpha: typeof alpha === "string" ? alpha.trim() : alpha
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
function colorOpacityToString(color) {
|
|
136
|
-
const alpha = color.alpha ?? 1;
|
|
137
|
-
return typeof alpha === "string" && alphaPlaceholders.includes(alpha) ? 1 : alpha;
|
|
138
|
-
}
|
|
139
|
-
function colorToString(color, alphaOverride) {
|
|
140
|
-
if (typeof color === "string")
|
|
141
|
-
return color.replace(alphaPlaceholdersRE, `${alphaOverride ?? 1}`);
|
|
142
|
-
const { components } = color;
|
|
143
|
-
let { alpha, type } = color;
|
|
144
|
-
alpha = alphaOverride ?? alpha;
|
|
145
|
-
type = type.toLowerCase();
|
|
146
|
-
if (["hsla", "rgba"].includes(type))
|
|
147
|
-
return `${type}(${components.join(", ")}${alpha == null ? "" : `, ${alpha}`})`;
|
|
148
|
-
alpha = alpha == null ? "" : ` / ${alpha}`;
|
|
149
|
-
if (cssColorFunctions.includes(type))
|
|
150
|
-
return `${type}(${components.join(" ")}${alpha})`;
|
|
151
|
-
return `color(${type} ${components.join(" ")}${alpha})`;
|
|
152
|
-
}
|
|
153
|
-
function parseColor$1(str) {
|
|
154
|
-
if (!str)
|
|
155
|
-
return;
|
|
156
|
-
let color = parseHexColor(str);
|
|
157
|
-
if (color != null)
|
|
158
|
-
return color;
|
|
159
|
-
color = cssColorKeyword(str);
|
|
160
|
-
if (color != null)
|
|
161
|
-
return color;
|
|
162
|
-
color = parseCssCommaColorFunction(str);
|
|
163
|
-
if (color != null)
|
|
164
|
-
return color;
|
|
165
|
-
color = parseCssSpaceColorFunction(str);
|
|
166
|
-
if (color != null)
|
|
167
|
-
return color;
|
|
168
|
-
color = parseCssColorFunction(str);
|
|
169
|
-
if (color != null)
|
|
170
|
-
return color;
|
|
171
|
-
}
|
|
172
|
-
function parseHexColor(str) {
|
|
173
|
-
const [, body] = str.match(/^#([\da-f]+)$/i) || [];
|
|
174
|
-
if (!body)
|
|
175
|
-
return;
|
|
176
|
-
switch (body.length) {
|
|
177
|
-
case 3:
|
|
178
|
-
case 4:
|
|
179
|
-
const digits = Array.from(body, (s) => Number.parseInt(s, 16)).map((n) => n << 4 | n);
|
|
180
|
-
return {
|
|
181
|
-
type: "rgb",
|
|
182
|
-
components: digits.slice(0, 3),
|
|
183
|
-
alpha: body.length === 3 ? void 0 : Math.round(digits[3] / 255 * 100) / 100
|
|
184
|
-
};
|
|
185
|
-
case 6:
|
|
186
|
-
case 8:
|
|
187
|
-
const value = Number.parseInt(body, 16);
|
|
188
|
-
return {
|
|
189
|
-
type: "rgb",
|
|
190
|
-
components: body.length === 6 ? [value >> 16 & 255, value >> 8 & 255, value & 255] : [value >> 24 & 255, value >> 16 & 255, value >> 8 & 255],
|
|
191
|
-
alpha: body.length === 6 ? void 0 : Math.round((value & 255) / 255 * 100) / 100
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
function cssColorKeyword(str) {
|
|
196
|
-
const color = {
|
|
197
|
-
rebeccapurple: [102, 51, 153, 1]
|
|
198
|
-
}[str];
|
|
199
|
-
if (color != null) {
|
|
200
|
-
return {
|
|
201
|
-
type: "rgb",
|
|
202
|
-
components: color.slice(0, 3),
|
|
203
|
-
alpha: color[3]
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
function parseCssCommaColorFunction(color) {
|
|
208
|
-
const match = color.match(/^(rgb|rgba|hsl|hsla)\((.+)\)$/i);
|
|
209
|
-
if (!match)
|
|
210
|
-
return;
|
|
211
|
-
const [, type, componentString] = match;
|
|
212
|
-
const components = getStringComponents(componentString, ",", 5);
|
|
213
|
-
if (components) {
|
|
214
|
-
if ([3, 4].includes(components.length)) {
|
|
215
|
-
return {
|
|
216
|
-
type,
|
|
217
|
-
components: components.slice(0, 3),
|
|
218
|
-
alpha: components[3]
|
|
219
|
-
};
|
|
220
|
-
} else if (components.length !== 1) {
|
|
221
|
-
return false;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
const cssColorFunctionsRe = new RegExp(`^(${cssColorFunctions.join("|")})\\((.+)\\)$`, "i");
|
|
226
|
-
function parseCssSpaceColorFunction(color) {
|
|
227
|
-
const match = color.match(cssColorFunctionsRe);
|
|
228
|
-
if (!match)
|
|
229
|
-
return;
|
|
230
|
-
const [, fn, componentString] = match;
|
|
231
|
-
const parsed = parseCssSpaceColorValues(`${fn} ${componentString}`);
|
|
232
|
-
if (parsed) {
|
|
233
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
234
|
-
return {
|
|
235
|
-
type,
|
|
236
|
-
components,
|
|
237
|
-
alpha
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
function parseCssColorFunction(color) {
|
|
242
|
-
const match = color.match(/^color\((.+)\)$/);
|
|
243
|
-
if (!match)
|
|
244
|
-
return;
|
|
245
|
-
const parsed = parseCssSpaceColorValues(match[1]);
|
|
246
|
-
if (parsed) {
|
|
247
|
-
const { alpha, components: [type, ...components] } = parsed;
|
|
248
|
-
return {
|
|
249
|
-
type,
|
|
250
|
-
components,
|
|
251
|
-
alpha
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
function parseCssSpaceColorValues(componentString) {
|
|
256
|
-
const components = getStringComponents(componentString, " ");
|
|
257
|
-
if (!components)
|
|
258
|
-
return;
|
|
259
|
-
let totalComponents = components.length;
|
|
260
|
-
if (components[totalComponents - 2] === "/") {
|
|
261
|
-
return {
|
|
262
|
-
components: components.slice(0, totalComponents - 2),
|
|
263
|
-
alpha: components[totalComponents - 1]
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
if (components[totalComponents - 2] != null && (components[totalComponents - 2].endsWith("/") || components[totalComponents - 1].startsWith("/"))) {
|
|
267
|
-
const removed = components.splice(totalComponents - 2);
|
|
268
|
-
components.push(removed.join(" "));
|
|
269
|
-
--totalComponents;
|
|
270
|
-
}
|
|
271
|
-
const withAlpha = getStringComponents(components[totalComponents - 1], "/", 2);
|
|
272
|
-
if (!withAlpha)
|
|
273
|
-
return;
|
|
274
|
-
if (withAlpha.length === 1 || withAlpha[withAlpha.length - 1] === "")
|
|
275
|
-
return { components };
|
|
276
|
-
const alpha = withAlpha.pop();
|
|
277
|
-
components[totalComponents - 1] = withAlpha.join("/");
|
|
278
|
-
return {
|
|
279
|
-
components,
|
|
280
|
-
alpha
|
|
281
|
-
};
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function createValueHandler(handlers) {
|
|
285
|
-
const handler = function(str) {
|
|
286
|
-
const s = this.__options?.sequence || [];
|
|
287
|
-
this.__options.sequence = [];
|
|
288
|
-
for (const n of s) {
|
|
289
|
-
const res = handlers[n](str);
|
|
290
|
-
if (res != null)
|
|
291
|
-
return res;
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
function addProcessor(that, name) {
|
|
295
|
-
if (!that.__options) {
|
|
296
|
-
that.__options = {
|
|
297
|
-
sequence: []
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
that.__options.sequence.push(name);
|
|
301
|
-
return that;
|
|
302
|
-
}
|
|
303
|
-
for (const name of Object.keys(handlers)) {
|
|
304
|
-
Object.defineProperty(handler, name, {
|
|
305
|
-
enumerable: true,
|
|
306
|
-
configurable: true,
|
|
307
|
-
get() {
|
|
308
|
-
return addProcessor(this, name);
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
return handler;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
const basePositionMap = [
|
|
316
|
-
"top",
|
|
317
|
-
"top center",
|
|
318
|
-
"top left",
|
|
319
|
-
"top right",
|
|
320
|
-
"bottom",
|
|
321
|
-
"bottom center",
|
|
322
|
-
"bottom left",
|
|
323
|
-
"bottom right",
|
|
324
|
-
"left",
|
|
325
|
-
"left center",
|
|
326
|
-
"left top",
|
|
327
|
-
"left bottom",
|
|
328
|
-
"right",
|
|
329
|
-
"right center",
|
|
330
|
-
"right top",
|
|
331
|
-
"right bottom",
|
|
332
|
-
"center",
|
|
333
|
-
"center top",
|
|
334
|
-
"center bottom",
|
|
335
|
-
"center left",
|
|
336
|
-
"center right",
|
|
337
|
-
"center center"
|
|
338
|
-
];
|
|
339
|
-
Object.assign(
|
|
340
|
-
{},
|
|
341
|
-
...basePositionMap.map((p) => ({ [p.replace(/ /, "-")]: p })),
|
|
342
|
-
...basePositionMap.map((p) => ({ [p.replace(/\b(\w)\w+/g, "$1").replace(/ /, "")]: p }))
|
|
343
|
-
);
|
|
344
|
-
const globalKeywords = [
|
|
345
|
-
"inherit",
|
|
346
|
-
"initial",
|
|
347
|
-
"revert",
|
|
348
|
-
"revert-layer",
|
|
349
|
-
"unset"
|
|
350
|
-
];
|
|
351
|
-
|
|
352
|
-
const numberWithUnitRE = /^(-?\d*(?:\.\d+)?)(px|pt|pc|%|r?(?:em|ex|lh|cap|ch|ic)|(?:[sld]?v|cq)(?:[whib]|min|max)|in|cm|mm|rpx)?$/i;
|
|
353
|
-
const numberRE = /^(-?\d*(?:\.\d+)?)$/;
|
|
354
|
-
const unitOnlyRE = /^(px|[sld]?v[wh])$/i;
|
|
355
|
-
const unitOnlyMap = {
|
|
356
|
-
px: 1,
|
|
357
|
-
vw: 100,
|
|
358
|
-
vh: 100,
|
|
359
|
-
svw: 100,
|
|
360
|
-
svh: 100,
|
|
361
|
-
dvw: 100,
|
|
362
|
-
dvh: 100,
|
|
363
|
-
lvh: 100,
|
|
364
|
-
lvw: 100
|
|
365
|
-
};
|
|
366
|
-
const bracketTypeRe = /^\[(color|image|length|size|position|quoted|string):/i;
|
|
367
|
-
|
|
368
|
-
const cssProps = [
|
|
369
|
-
// basic props
|
|
370
|
-
"color",
|
|
371
|
-
"border-color",
|
|
372
|
-
"background-color",
|
|
373
|
-
"outline-color",
|
|
374
|
-
"text-decoration-color",
|
|
375
|
-
"flex-grow",
|
|
376
|
-
"flex",
|
|
377
|
-
"flex-shrink",
|
|
378
|
-
"caret-color",
|
|
379
|
-
"font",
|
|
380
|
-
"gap",
|
|
381
|
-
"opacity",
|
|
382
|
-
"visibility",
|
|
383
|
-
"z-index",
|
|
384
|
-
"font-weight",
|
|
385
|
-
"zoom",
|
|
386
|
-
"text-shadow",
|
|
387
|
-
"transform",
|
|
388
|
-
"box-shadow",
|
|
389
|
-
"border",
|
|
390
|
-
// positions
|
|
391
|
-
"background-position",
|
|
392
|
-
"left",
|
|
393
|
-
"right",
|
|
394
|
-
"top",
|
|
395
|
-
"bottom",
|
|
396
|
-
"object-position",
|
|
397
|
-
// sizes
|
|
398
|
-
"max-height",
|
|
399
|
-
"min-height",
|
|
400
|
-
"max-width",
|
|
401
|
-
"min-width",
|
|
402
|
-
"height",
|
|
403
|
-
"width",
|
|
404
|
-
"border-width",
|
|
405
|
-
"margin",
|
|
406
|
-
"padding",
|
|
407
|
-
"outline-width",
|
|
408
|
-
"outline-offset",
|
|
409
|
-
"font-size",
|
|
410
|
-
"line-height",
|
|
411
|
-
"text-indent",
|
|
412
|
-
"vertical-align",
|
|
413
|
-
"border-spacing",
|
|
414
|
-
"letter-spacing",
|
|
415
|
-
"word-spacing",
|
|
416
|
-
// enhances
|
|
417
|
-
"stroke",
|
|
418
|
-
"filter",
|
|
419
|
-
"backdrop-filter",
|
|
420
|
-
"fill",
|
|
421
|
-
"mask",
|
|
422
|
-
"mask-size",
|
|
423
|
-
"mask-border",
|
|
424
|
-
"clip-path",
|
|
425
|
-
"clip",
|
|
426
|
-
"border-radius"
|
|
427
|
-
];
|
|
428
|
-
function round(n) {
|
|
429
|
-
return +n.toFixed(10);
|
|
430
|
-
}
|
|
431
|
-
function numberWithUnit(str) {
|
|
432
|
-
const match = str.match(numberWithUnitRE);
|
|
433
|
-
if (!match)
|
|
434
|
-
return;
|
|
435
|
-
const [, n, unit] = match;
|
|
436
|
-
const num = Number.parseFloat(n);
|
|
437
|
-
if (unit && !Number.isNaN(num))
|
|
438
|
-
return `${round(num)}${unit}`;
|
|
439
|
-
}
|
|
440
|
-
function auto(str) {
|
|
441
|
-
if (str === "auto" || str === "a")
|
|
442
|
-
return "auto";
|
|
443
|
-
}
|
|
444
|
-
function rem(str) {
|
|
445
|
-
if (!str)
|
|
446
|
-
return;
|
|
447
|
-
if (unitOnlyRE.test(str))
|
|
448
|
-
return `${unitOnlyMap[str]}${str}`;
|
|
449
|
-
const match = str.match(numberWithUnitRE);
|
|
450
|
-
if (!match)
|
|
451
|
-
return;
|
|
452
|
-
const [, n, unit] = match;
|
|
453
|
-
const num = Number.parseFloat(n);
|
|
454
|
-
if (!Number.isNaN(num)) {
|
|
455
|
-
if (num === 0)
|
|
456
|
-
return "0";
|
|
457
|
-
return unit ? `${round(num)}${unit}` : `${round(num / 4)}rem`;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
function px(str) {
|
|
461
|
-
if (unitOnlyRE.test(str))
|
|
462
|
-
return `${unitOnlyMap[str]}${str}`;
|
|
463
|
-
const match = str.match(numberWithUnitRE);
|
|
464
|
-
if (!match)
|
|
465
|
-
return;
|
|
466
|
-
const [, n, unit] = match;
|
|
467
|
-
const num = Number.parseFloat(n);
|
|
468
|
-
if (!Number.isNaN(num))
|
|
469
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}px`;
|
|
470
|
-
}
|
|
471
|
-
function number(str) {
|
|
472
|
-
if (!numberRE.test(str))
|
|
473
|
-
return;
|
|
474
|
-
const num = Number.parseFloat(str);
|
|
475
|
-
if (!Number.isNaN(num))
|
|
476
|
-
return round(num);
|
|
477
|
-
}
|
|
478
|
-
function percent(str) {
|
|
479
|
-
if (str.endsWith("%"))
|
|
480
|
-
str = str.slice(0, -1);
|
|
481
|
-
if (!numberRE.test(str))
|
|
482
|
-
return;
|
|
483
|
-
const num = Number.parseFloat(str);
|
|
484
|
-
if (!Number.isNaN(num))
|
|
485
|
-
return `${round(num / 100)}`;
|
|
486
|
-
}
|
|
487
|
-
function fraction(str) {
|
|
488
|
-
if (!str)
|
|
489
|
-
return;
|
|
490
|
-
if (str === "full")
|
|
491
|
-
return "100%";
|
|
492
|
-
const [left, right] = str.split("/");
|
|
493
|
-
const num = Number.parseFloat(left) / Number.parseFloat(right);
|
|
494
|
-
if (!Number.isNaN(num)) {
|
|
495
|
-
if (num === 0)
|
|
496
|
-
return "0";
|
|
497
|
-
return `${round(num * 100)}%`;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
function bracketWithType(str, requiredType) {
|
|
501
|
-
if (str && str.startsWith("[") && str.endsWith("]")) {
|
|
502
|
-
let base;
|
|
503
|
-
let hintedType;
|
|
504
|
-
const match = str.match(bracketTypeRe);
|
|
505
|
-
if (!match) {
|
|
506
|
-
base = str.slice(1, -1);
|
|
507
|
-
} else {
|
|
508
|
-
if (!requiredType)
|
|
509
|
-
hintedType = match[1];
|
|
510
|
-
base = str.slice(match[0].length, -1);
|
|
511
|
-
}
|
|
512
|
-
if (!base)
|
|
513
|
-
return;
|
|
514
|
-
if (base === '=""')
|
|
515
|
-
return;
|
|
516
|
-
if (base.startsWith("--"))
|
|
517
|
-
base = `var(${base})`;
|
|
518
|
-
let curly = 0;
|
|
519
|
-
for (const i of base) {
|
|
520
|
-
if (i === "[") {
|
|
521
|
-
curly += 1;
|
|
522
|
-
} else if (i === "]") {
|
|
523
|
-
curly -= 1;
|
|
524
|
-
if (curly < 0)
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
if (curly)
|
|
529
|
-
return;
|
|
530
|
-
switch (hintedType) {
|
|
531
|
-
case "string":
|
|
532
|
-
return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_");
|
|
533
|
-
case "quoted":
|
|
534
|
-
return base.replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(["\\])/g, "\\$1").replace(/^(.+)$/, '"$1"');
|
|
535
|
-
}
|
|
536
|
-
return base.replace(/(url\(.*?\))/g, (v) => v.replace(/_/g, "\\_")).replace(/(^|[^\\])_/g, "$1 ").replace(/\\_/g, "_").replace(/(?:calc|clamp|max|min)\((.*)/g, (match2) => {
|
|
537
|
-
const vars = [];
|
|
538
|
-
return match2.replace(/var\((--.+?)[,)]/g, (match3, g1) => {
|
|
539
|
-
vars.push(g1);
|
|
540
|
-
return match3.replace(g1, "--un-calc");
|
|
541
|
-
}).replace(/(-?\d*\.?\d(?!-\d.+[,)](?![^+\-/*])\D)(?:%|[a-z]+)?|\))([+\-/*])/g, "$1 $2 ").replace(/--un-calc/g, () => vars.shift());
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
function bracket(str) {
|
|
546
|
-
return bracketWithType(str);
|
|
547
|
-
}
|
|
548
|
-
function bracketOfColor(str) {
|
|
549
|
-
return bracketWithType(str, "color");
|
|
550
|
-
}
|
|
551
|
-
function bracketOfLength(str) {
|
|
552
|
-
return bracketWithType(str, "length");
|
|
553
|
-
}
|
|
554
|
-
function bracketOfPosition(str) {
|
|
555
|
-
return bracketWithType(str, "position");
|
|
556
|
-
}
|
|
557
|
-
function cssvar(str) {
|
|
558
|
-
if (/^\$[^\s'"`;{}]/.test(str)) {
|
|
559
|
-
const [name, defaultValue] = str.slice(1).split(",");
|
|
560
|
-
return `var(--${escapeSelector(name)}${defaultValue ? `, ${defaultValue}` : ""})`;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
function time(str) {
|
|
564
|
-
const match = str.match(/^(-?[0-9.]+)(s|ms)?$/i);
|
|
565
|
-
if (!match)
|
|
566
|
-
return;
|
|
567
|
-
const [, n, unit] = match;
|
|
568
|
-
const num = Number.parseFloat(n);
|
|
569
|
-
if (!Number.isNaN(num)) {
|
|
570
|
-
if (num === 0 && !unit)
|
|
571
|
-
return "0s";
|
|
572
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}ms`;
|
|
573
|
-
}
|
|
574
|
-
}
|
|
575
|
-
function degree(str) {
|
|
576
|
-
const match = str.match(/^(-?[0-9.]+)(deg|rad|grad|turn)?$/i);
|
|
577
|
-
if (!match)
|
|
578
|
-
return;
|
|
579
|
-
const [, n, unit] = match;
|
|
580
|
-
const num = Number.parseFloat(n);
|
|
581
|
-
if (!Number.isNaN(num)) {
|
|
582
|
-
if (num === 0)
|
|
583
|
-
return "0";
|
|
584
|
-
return unit ? `${round(num)}${unit}` : `${round(num)}deg`;
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
function global(str) {
|
|
588
|
-
if (globalKeywords.includes(str))
|
|
589
|
-
return str;
|
|
590
|
-
}
|
|
591
|
-
function properties(str) {
|
|
592
|
-
if (str.split(",").every((prop) => cssProps.includes(prop)))
|
|
593
|
-
return str;
|
|
594
|
-
}
|
|
595
|
-
function position(str) {
|
|
596
|
-
if (["top", "left", "right", "bottom", "center"].includes(str))
|
|
597
|
-
return str;
|
|
598
|
-
}
|
|
599
|
-
|
|
600
|
-
const valueHandlers = {
|
|
601
|
-
__proto__: null,
|
|
602
|
-
auto: auto,
|
|
603
|
-
bracket: bracket,
|
|
604
|
-
bracketOfColor: bracketOfColor,
|
|
605
|
-
bracketOfLength: bracketOfLength,
|
|
606
|
-
bracketOfPosition: bracketOfPosition,
|
|
607
|
-
cssvar: cssvar,
|
|
608
|
-
degree: degree,
|
|
609
|
-
fraction: fraction,
|
|
610
|
-
global: global,
|
|
611
|
-
number: number,
|
|
612
|
-
numberWithUnit: numberWithUnit,
|
|
613
|
-
percent: percent,
|
|
614
|
-
position: position,
|
|
615
|
-
properties: properties,
|
|
616
|
-
px: px,
|
|
617
|
-
rem: rem,
|
|
618
|
-
time: time
|
|
619
|
-
};
|
|
620
|
-
|
|
621
|
-
const handler = createValueHandler(valueHandlers);
|
|
622
|
-
const h = handler;
|
|
623
|
-
function getThemeColorForKey(theme, colors, key = "colors") {
|
|
624
|
-
let obj = theme[key];
|
|
625
|
-
let index = -1;
|
|
626
|
-
for (const c of colors) {
|
|
627
|
-
index += 1;
|
|
628
|
-
if (obj && typeof obj !== "string") {
|
|
629
|
-
const camel = colors.slice(index).join("-").replace(/(-[a-z])/g, (n) => n.slice(1).toUpperCase());
|
|
630
|
-
if (obj[camel])
|
|
631
|
-
return obj[camel];
|
|
632
|
-
if (obj[c]) {
|
|
633
|
-
obj = obj[c];
|
|
634
|
-
continue;
|
|
635
|
-
}
|
|
636
|
-
}
|
|
637
|
-
return void 0;
|
|
638
|
-
}
|
|
639
|
-
return obj;
|
|
640
|
-
}
|
|
641
|
-
function getThemeColor(theme, colors, key) {
|
|
642
|
-
return getThemeColorForKey(theme, colors, key) || getThemeColorForKey(theme, colors, "colors");
|
|
643
|
-
}
|
|
644
|
-
function splitShorthand(body, type) {
|
|
645
|
-
const [front, rest] = getStringComponent(body, "[", "]", ["/", ":"]) ?? [];
|
|
646
|
-
if (front != null) {
|
|
647
|
-
const match = (front.match(bracketTypeRe) ?? [])[1];
|
|
648
|
-
if (match == null || match === type)
|
|
649
|
-
return [front, rest];
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
function parseColor(body, theme, key) {
|
|
653
|
-
const split = splitShorthand(body, "color");
|
|
654
|
-
if (!split)
|
|
655
|
-
return;
|
|
656
|
-
const [main, opacity] = split;
|
|
657
|
-
const colors = main.replace(/([a-z])(\d)/g, "$1-$2").split(/-/g);
|
|
658
|
-
const [name] = colors;
|
|
659
|
-
if (!name)
|
|
660
|
-
return;
|
|
661
|
-
let color;
|
|
662
|
-
const bracket = h.bracketOfColor(main);
|
|
663
|
-
const bracketOrMain = bracket || main;
|
|
664
|
-
if (h.numberWithUnit(bracketOrMain))
|
|
665
|
-
return;
|
|
666
|
-
if (/^#[\da-f]+$/i.test(bracketOrMain))
|
|
667
|
-
color = bracketOrMain;
|
|
668
|
-
else if (/^hex-[\da-fA-F]+$/.test(bracketOrMain))
|
|
669
|
-
color = `#${bracketOrMain.slice(4)}`;
|
|
670
|
-
else if (main.startsWith("$"))
|
|
671
|
-
color = h.cssvar(main);
|
|
672
|
-
color = color || bracket;
|
|
673
|
-
if (!color) {
|
|
674
|
-
const colorData = getThemeColor(theme, [main], key);
|
|
675
|
-
if (typeof colorData === "string")
|
|
676
|
-
color = colorData;
|
|
677
|
-
}
|
|
678
|
-
let no = "DEFAULT";
|
|
679
|
-
if (!color) {
|
|
680
|
-
let colorData;
|
|
681
|
-
const [scale] = colors.slice(-1);
|
|
682
|
-
if (/^\d+$/.test(scale)) {
|
|
683
|
-
no = scale;
|
|
684
|
-
colorData = getThemeColor(theme, colors.slice(0, -1), key);
|
|
685
|
-
if (!colorData || typeof colorData === "string")
|
|
686
|
-
color = void 0;
|
|
687
|
-
else
|
|
688
|
-
color = colorData[no];
|
|
689
|
-
} else {
|
|
690
|
-
colorData = getThemeColor(theme, colors, key);
|
|
691
|
-
if (!colorData && colors.length <= 2) {
|
|
692
|
-
[, no = no] = colors;
|
|
693
|
-
colorData = getThemeColor(theme, [name], key);
|
|
694
|
-
}
|
|
695
|
-
if (typeof colorData === "string")
|
|
696
|
-
color = colorData;
|
|
697
|
-
else if (no && colorData)
|
|
698
|
-
color = colorData[no];
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
return {
|
|
702
|
-
opacity,
|
|
703
|
-
name,
|
|
704
|
-
no,
|
|
705
|
-
color,
|
|
706
|
-
cssColor: parseCssColor(color),
|
|
707
|
-
alpha: h.bracket.cssvar.percent(opacity ?? "")
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
function colorResolver(property, varName, key, shouldPass) {
|
|
711
|
-
return ([, body], { theme, generator }) => {
|
|
712
|
-
const data = parseColor(body, theme, key);
|
|
713
|
-
if (!data)
|
|
714
|
-
return;
|
|
715
|
-
const { alpha, color, cssColor } = data;
|
|
716
|
-
const isDev = generator.config.envMode === "dev";
|
|
717
|
-
const rawColorComment = isDev && color ? ` /* ${color} */` : "";
|
|
718
|
-
const css = {};
|
|
719
|
-
if (cssColor) {
|
|
720
|
-
if (alpha != null) {
|
|
721
|
-
css[property] = colorToString(cssColor, alpha) + rawColorComment;
|
|
722
|
-
} else {
|
|
723
|
-
const opacityVar = `--un-${varName}-opacity`;
|
|
724
|
-
const result = colorToString(cssColor, `var(${opacityVar})`);
|
|
725
|
-
if (result.includes(opacityVar))
|
|
726
|
-
css[opacityVar] = colorOpacityToString(cssColor);
|
|
727
|
-
css[property] = result + rawColorComment;
|
|
728
|
-
}
|
|
729
|
-
} else if (color) {
|
|
730
|
-
if (alpha != null) {
|
|
731
|
-
css[property] = colorToString(color, alpha) + rawColorComment;
|
|
732
|
-
} else {
|
|
733
|
-
const opacityVar = `--un-${varName}-opacity`;
|
|
734
|
-
const result = colorToString(color, `var(${opacityVar})`);
|
|
735
|
-
if (result.includes(opacityVar))
|
|
736
|
-
css[opacityVar] = 1;
|
|
737
|
-
css[property] = result + rawColorComment;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
return css;
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
const defaultOption = {
|
|
745
|
-
scrollbarWidth: '8px',
|
|
746
|
-
scrollbarHeight: '8px',
|
|
747
|
-
scrollbarTrackRadius: '4px',
|
|
748
|
-
scrollbarThumbRadius: '4px',
|
|
749
|
-
scrollbarTrackColor: '#f5f5f5',
|
|
750
|
-
scrollbarThumbColor: '#ddd',
|
|
751
|
-
varPrefix: '',
|
|
752
|
-
prefix: '',
|
|
753
|
-
numberToUnit: value => `${value / 4}rem`,
|
|
754
|
-
noCompatible: true,
|
|
755
|
-
};
|
|
756
|
-
const customRules = {
|
|
757
|
-
'radius': ['track-radius', 'thumb-radius'],
|
|
758
|
-
'w': ['width'],
|
|
759
|
-
'h': ['height'],
|
|
760
|
-
'track-radius': ['track-radius'],
|
|
761
|
-
'thumb-radius': ['thumb-radius'],
|
|
762
|
-
};
|
|
763
|
-
const numberVarRegex = new RegExp(`^scrollbar-(${Object.keys(customRules).join('|')})-(\\d+)([a-zA-Z]*)$`);
|
|
764
|
-
function presetScrollbar(option) {
|
|
765
|
-
const config = {
|
|
766
|
-
...defaultOption,
|
|
767
|
-
...option,
|
|
768
|
-
};
|
|
769
|
-
function resolveVar(name) {
|
|
770
|
-
const prefix = config.varPrefix;
|
|
771
|
-
return `--${prefix ? `${prefix}-` : ''}scrollbar-${name}`;
|
|
772
|
-
}
|
|
773
|
-
const variantsRE = /^(scrollbar(-track|-thumb)?):.+$/;
|
|
774
|
-
return {
|
|
775
|
-
name: 'unocss-preset-scrollbar',
|
|
776
|
-
prefix: config.prefix,
|
|
777
|
-
shortcuts: [
|
|
778
|
-
[
|
|
779
|
-
'scrollbar',
|
|
780
|
-
[
|
|
781
|
-
{ overflow: 'auto' },
|
|
782
|
-
'scrollbar-custom-property',
|
|
783
|
-
'scrollbar-width-auto',
|
|
784
|
-
`scrollbar-color-[var(${resolveVar('thumb')})_var(${resolveVar('track')})]`,
|
|
785
|
-
`scrollbar-track:scrollbar-background-color-[var(${resolveVar('track')})]`,
|
|
786
|
-
`scrollbar-thumb:scrollbar-background-color-[var(${resolveVar('thumb')})]`,
|
|
787
|
-
`scrollbar:scrollbar-width-[var(${resolveVar('width')})]`,
|
|
788
|
-
`scrollbar:scrollbar-height-[var(${resolveVar('height')})]`,
|
|
789
|
-
],
|
|
790
|
-
],
|
|
791
|
-
[
|
|
792
|
-
'scrollbar-rounded',
|
|
793
|
-
`
|
|
794
|
-
scrollbar-track:scrollbar-border-radius-[var(${resolveVar('track-radius')})]
|
|
795
|
-
scrollbar-thumb:scrollbar-border-radius-[var(${resolveVar('thumb-radius')})]
|
|
796
|
-
`,
|
|
797
|
-
],
|
|
798
|
-
[
|
|
799
|
-
'scrollbar-thin',
|
|
800
|
-
`
|
|
801
|
-
scrollbar-w-8px
|
|
802
|
-
scrollbar-h-8px
|
|
803
|
-
scrollbar-width-thin
|
|
804
|
-
`,
|
|
805
|
-
],
|
|
806
|
-
[
|
|
807
|
-
'scrollbar-none',
|
|
808
|
-
`
|
|
809
|
-
scrollbar:hidden
|
|
810
|
-
scrollbar-width-none
|
|
811
|
-
`,
|
|
812
|
-
],
|
|
813
|
-
[
|
|
814
|
-
'roku-scrollbar',
|
|
815
|
-
`scrollbar
|
|
816
|
-
scrollbar-rounded
|
|
817
|
-
scrollbar-thin
|
|
818
|
-
scrollbar-thumb-color-surface-4
|
|
819
|
-
scrollbar-track-color-surface-3
|
|
820
|
-
scrollbar-thumb-hover-color-surface-4
|
|
821
|
-
dark:scrollbar-thumb-color-surface-7
|
|
822
|
-
dark:scrollbar-track-color-surface-8
|
|
823
|
-
dark:scrollbar-thumb-hover-color-surface-5
|
|
824
|
-
`,
|
|
825
|
-
],
|
|
826
|
-
],
|
|
827
|
-
variants: [
|
|
828
|
-
// ::-webkit-scrollbar-track
|
|
829
|
-
// ::-webkit-scrollbar-thumb
|
|
830
|
-
// ::-webkit-scrollbar
|
|
831
|
-
(matcher) => {
|
|
832
|
-
if (!variantsRE.test(matcher)) {
|
|
833
|
-
return;
|
|
834
|
-
}
|
|
835
|
-
const variant = matcher.replace(variantsRE, '$1');
|
|
836
|
-
return {
|
|
837
|
-
matcher: matcher.slice(variant.length + 1),
|
|
838
|
-
selector: (s) => {
|
|
839
|
-
return `${s}::-webkit-${variant}`;
|
|
840
|
-
},
|
|
841
|
-
};
|
|
842
|
-
},
|
|
843
|
-
],
|
|
844
|
-
rules: [
|
|
845
|
-
[
|
|
846
|
-
/^scrollbar-color-(.+)$/,
|
|
847
|
-
([_, prop]) => {
|
|
848
|
-
if (config.noCompatible) {
|
|
849
|
-
return {};
|
|
850
|
-
}
|
|
851
|
-
// when use scrollbar-color, ::-webkit-scrollbar styling is disabled.
|
|
852
|
-
// https://developer.mozilla.org/en-US/docs/Web/CSS/::-webkit-scrollbar
|
|
853
|
-
return {
|
|
854
|
-
'scrollbar-color': handler.bracket.cssvar.auto.fraction.rem(prop),
|
|
855
|
-
};
|
|
856
|
-
},
|
|
857
|
-
],
|
|
858
|
-
[
|
|
859
|
-
/^scrollbar-width-(auto|thin|none)/,
|
|
860
|
-
([_, prop]) => {
|
|
861
|
-
const res = {};
|
|
862
|
-
if (!config.noCompatible || prop === 'none') {
|
|
863
|
-
res['scrollbar-width'] = prop;
|
|
864
|
-
}
|
|
865
|
-
return res;
|
|
866
|
-
},
|
|
867
|
-
],
|
|
868
|
-
[
|
|
869
|
-
/^scrollbar-custom-property$/,
|
|
870
|
-
([_]) => ({
|
|
871
|
-
[resolveVar('track')]: config.scrollbarTrackColor,
|
|
872
|
-
[resolveVar('thumb')]: config.scrollbarThumbColor,
|
|
873
|
-
[resolveVar('width')]: config.scrollbarWidth,
|
|
874
|
-
[resolveVar('height')]: config.scrollbarHeight,
|
|
875
|
-
[resolveVar('track-radius')]: config.scrollbarTrackRadius,
|
|
876
|
-
[resolveVar('thumb-radius')]: config.scrollbarThumbRadius,
|
|
877
|
-
}),
|
|
878
|
-
],
|
|
879
|
-
[
|
|
880
|
-
/^scrollbar-thumb-color-(.+)$/,
|
|
881
|
-
colorResolver(resolveVar('thumb'), 'scrollbar-thumb'),
|
|
882
|
-
{ autocomplete: 'scrollbar-thumb-color-$colors' },
|
|
883
|
-
],
|
|
884
|
-
[
|
|
885
|
-
/^scrollbar-track-color-(.+)$/,
|
|
886
|
-
colorResolver(resolveVar('track'), 'scrollbar-track'),
|
|
887
|
-
{ autocomplete: 'scrollbar-track-color-$colors' },
|
|
888
|
-
],
|
|
889
|
-
[
|
|
890
|
-
/^scrollbar-((?:width|height|background-color|border-radius)?)-(\[var.+\])$/,
|
|
891
|
-
([_, prop, value,]) => {
|
|
892
|
-
return {
|
|
893
|
-
[`${prop}`]: handler.bracket(value),
|
|
894
|
-
};
|
|
895
|
-
},
|
|
896
|
-
],
|
|
897
|
-
[
|
|
898
|
-
numberVarRegex,
|
|
899
|
-
([_, type, value, unit,]) => {
|
|
900
|
-
const val = unit ? value + unit : config.numberToUnit(Number.parseInt(value));
|
|
901
|
-
const vars = customRules[type]
|
|
902
|
-
.map(v => resolveVar(v));
|
|
903
|
-
return vars.reduce((acc, v) => {
|
|
904
|
-
acc[v] = val;
|
|
905
|
-
return acc;
|
|
906
|
-
}, {});
|
|
907
|
-
},
|
|
908
|
-
{ autocomplete: `scrollbar-(${Object.keys(customRules).join('|')})-<num>` },
|
|
909
|
-
],
|
|
910
|
-
[
|
|
911
|
-
/^scrollbar-thumb-hover-color-(.*)$/,
|
|
912
|
-
([, color]) => {
|
|
913
|
-
return `.scrollbar::-webkit-scrollbar-thumb:hover { background-color: rgba(var(--r-color-${color})); }`;
|
|
914
|
-
},
|
|
915
|
-
],
|
|
916
|
-
[
|
|
917
|
-
'hidden',
|
|
918
|
-
{ display: 'none' },
|
|
919
|
-
],
|
|
920
|
-
],
|
|
921
|
-
};
|
|
922
|
-
}
|
|
923
|
-
|
|
924
|
-
var baseStyle = ":root[data-scheme=\"dark\"] {\r\n color-scheme: dark;\r\n}\r\n\r\n:root[data-scheme=\"light\"] {\r\n color-scheme: light;\r\n}\r\n\r\n/* dark */\r\n[data-scheme=\"light\"] [data-scheme=\"dark\"] *, [data-scheme=\"dark\"] *, [data-scheme=\"dark\"] {\r\n color-scheme: dark;\r\n --r-surface-background-base-color: rgb(var(--r-color-surface-10));\r\n --r-surface-background-color: rgb(var(--r-color-surface-9));\r\n --r-surface-background-variant-color: rgb(var(--r-color-surface-7));\r\n --r-surface-border-color: rgb(var(--r-color-surface-7));\r\n --r-surface-text-color: rgb(var(--r-color-surface-3));\r\n --r-surface-text-dimmed-color: rgb(var(--r-color-surface-5));\r\n\r\n --r-primary-background-color: rgb(var(--r-color-primary-5));\r\n --r-secondary-background-color: rgb(var(--r-color-secondary-5));\r\n --r-tertiary-background-color: rgb(var(--r-color-tertiary-5));\r\n --r-error-background-color: rgb(var(--r-color-error-5));\r\n\r\n --r-primary-text-color: rgb(var(--r-color-primary-3));\r\n --r-secondary-text-color: rgb(var(--r-color-secondary-3));\r\n --r-tertiary-text-color: rgb(var(--r-color-tertiary-3));\r\n --r-error-text-color: rgb(var(--r-color-error-3));\r\n\r\n\r\n}\r\n\r\n/* light */\r\n[data-scheme=\"light\"] *, [data-scheme=\"light\"], * {\r\n color-scheme: light;\r\n --r-surface-background-base-color: rgb(var(--r-color-surface-0));\r\n --r-surface-background-color: rgb(var(--r-color-surface-1));\r\n --r-surface-background-variant-color: rgb(var(--r-color-surface-2));\r\n --r-surface-border-color: rgb(var(--r-color-surface-3));\r\n --r-surface-text-color: rgb(var(--r-color-surface-7));\r\n --r-surface-text-dimmed-color: rgb(var(--r-color-surface-6));\r\n\r\n --r-primary-background-color: rgb(var(--r-color-primary-4));\r\n --r-secondary-background-color: rgb(var(--r-color-secondary-4));\r\n --r-tertiary-background-color: rgb(var(--r-color-tertiary-4));\r\n --r-error-background-color: rgb(var(--r-color-error-4));\r\n\r\n --r-primary-text-color: rgb(var(--r-color-primary-6));\r\n --r-secondary-text-color: rgb(var(--r-color-secondary-6));\r\n --r-tertiary-text-color: rgb(var(--r-color-tertiary-6));\r\n --r-error-text-color: rgb(var(--r-color-error-6));\r\n}\r\n\r\n:root {\r\n color-scheme: light dark;\r\n}";
|
|
8
|
+
var baseStyle = ":root[data-scheme=\"dark\"] {\r\n color-scheme: dark;\r\n}\r\n\r\n:root[data-scheme=\"light\"] {\r\n color-scheme: light;\r\n}\r\n\r\n/* dark */\r\n[data-scheme=\"light\"] [data-scheme=\"dark\"] *, [data-scheme=\"dark\"] *, [data-scheme=\"dark\"] {\r\n color-scheme: dark;\r\n --r-surface-background-base-color: rgb(var(--r-color-surface-10));\r\n --r-surface-background-color: rgb(var(--r-color-surface-9));\r\n --r-surface-background-variant-1-color: rgb(var(--r-color-surface-8));\r\n --r-surface-background-variant-2-color: rgb(var(--r-color-surface-7));\r\n --r-surface-border-color: rgb(var(--r-color-surface-7));\r\n --r-surface-text-color: rgb(var(--r-color-surface-1));\r\n --r-surface-text-dimmed-color: rgb(var(--r-color-surface-2));\r\n\r\n --r-primary-background-color: rgb(var(--r-color-primary-5));\r\n --r-secondary-background-color: rgb(var(--r-color-secondary-5));\r\n --r-tertiary-background-color: rgb(var(--r-color-tertiary-5));\r\n --r-error-background-color: rgb(var(--r-color-error-5));\r\n\r\n --r-primary-text-color: rgb(var(--r-color-primary-3));\r\n --r-secondary-text-color: rgb(var(--r-color-secondary-3));\r\n --r-tertiary-text-color: rgb(var(--r-color-tertiary-3));\r\n --r-error-text-color: rgb(var(--r-color-error-3));\r\n\r\n\r\n}\r\n\r\n/* light */\r\n[data-scheme=\"light\"] *, [data-scheme=\"light\"], * {\r\n color-scheme: light;\r\n --r-surface-background-base-color: rgb(var(--r-color-surface-0));\r\n --r-surface-background-color: rgb(var(--r-color-surface-1));\r\n --r-surface-background-variant-1-color: rgb(var(--r-color-surface-2));\r\n --r-surface-background-variant-2-color: rgb(var(--r-color-surface-2));\r\n --r-surface-border-color: rgb(var(--r-color-surface-3));\r\n --r-surface-text-color: rgb(var(--r-color-surface-10));\r\n --r-surface-text-dimmed-color: rgb(var(--r-color-surface-9));\r\n\r\n --r-primary-background-color: rgb(var(--r-color-primary-4));\r\n --r-secondary-background-color: rgb(var(--r-color-secondary-4));\r\n --r-tertiary-background-color: rgb(var(--r-color-tertiary-4));\r\n --r-error-background-color: rgb(var(--r-color-error-4));\r\n\r\n --r-primary-text-color: rgb(var(--r-color-primary-6));\r\n --r-secondary-text-color: rgb(var(--r-color-secondary-6));\r\n --r-tertiary-text-color: rgb(var(--r-color-tertiary-6));\r\n --r-error-text-color: rgb(var(--r-color-error-6));\r\n}\r\n\r\n:root {\r\n color-scheme: light dark;\r\n}";
|
|
925
9
|
|
|
926
10
|
const colorKeys = ['surface', 'primary', 'secondary', 'tertiary', 'error'];
|
|
927
11
|
const colors = colorKeys.reduce((colors, key) => {
|
|
@@ -950,7 +34,8 @@ const rokuPreset = () => () => {
|
|
|
950
34
|
'custom-input-colors': 'border bg-[var(--l-bg)] dark:bg-[var(--d-bg)] text-[var(--l-text)] dark:text-[var(--d-text)] placeholder-[var(--l-placeholder)] dark:placeholder-[var(--d-placeholder)] border-[var(--l-border)] dark:border-[var(--d-border)] focus:border-[var(--l-border-f)] dark:focus:border-[var(--d-border-f)]',
|
|
951
35
|
'bg-surface': 'bg-[--r-surface-background-color]',
|
|
952
36
|
'bg-surface-base': 'bg-[--r-surface-background-base-color]',
|
|
953
|
-
'bg-surface-variant': 'bg-[--r-surface-background-variant-color]',
|
|
37
|
+
'bg-surface-variant-1': 'bg-[--r-surface-background-variant-1-color]',
|
|
38
|
+
'bg-surface-variant-2': 'bg-[--r-surface-background-variant-2-color]',
|
|
954
39
|
'border-surface': 'border-[--r-surface-border-color]',
|
|
955
40
|
'text-surface': 'text-[--r-surface-text-color]',
|
|
956
41
|
'text-surface-dimmed': 'text-[--r-surface-text-dimmed-color]',
|
|
@@ -978,7 +63,6 @@ const rokuPreset = () => () => {
|
|
|
978
63
|
'vertical-align': 'middle',
|
|
979
64
|
},
|
|
980
65
|
}),
|
|
981
|
-
presetScrollbar({}),
|
|
982
66
|
],
|
|
983
67
|
content: {
|
|
984
68
|
inline: [file],
|