82 lines
2.5 KiB
Plaintext
82 lines
2.5 KiB
Plaintext
import { entriesToCss, toArray, definePreset } from '@unocss/core';
|
|
import { extractorArbitraryVariants } from '@unocss/extractor-arbitrary-variants';
|
|
import { g as globalKeywords } from './shared/preset-mini.Stl9mkMB.mjs';
|
|
export { p as parseColor } from './shared/preset-mini.Stl9mkMB.mjs';
|
|
import { theme } from './theme.mjs';
|
|
import { rules } from './rules.mjs';
|
|
import { variants } from './variants.mjs';
|
|
export { colors } from './colors.mjs';
|
|
import '@unocss/rule-utils';
|
|
import './shared/preset-mini.dPVVIvNm.mjs';
|
|
|
|
const preflights = [
|
|
{
|
|
layer: "preflights",
|
|
getCSS(ctx) {
|
|
if (ctx.theme.preflightBase) {
|
|
const css = entriesToCss(Object.entries(ctx.theme.preflightBase));
|
|
const roots = toArray(ctx.theme.preflightRoot ?? ["*,::before,::after", "::backdrop"]);
|
|
return roots.map((root) => `${root}{${css}}`).join("");
|
|
}
|
|
}
|
|
}
|
|
];
|
|
|
|
const shorthands = {
|
|
position: [
|
|
"relative",
|
|
"absolute",
|
|
"fixed",
|
|
"sticky",
|
|
"static"
|
|
],
|
|
globalKeyword: globalKeywords
|
|
};
|
|
|
|
const presetMini = definePreset((options = {}) => {
|
|
options.dark = options.dark ?? "class";
|
|
options.attributifyPseudo = options.attributifyPseudo ?? false;
|
|
options.preflight = options.preflight ?? true;
|
|
options.variablePrefix = options.variablePrefix ?? "un-";
|
|
return {
|
|
name: "@unocss/preset-mini",
|
|
theme,
|
|
rules,
|
|
variants: variants(options),
|
|
options,
|
|
prefix: options.prefix,
|
|
postprocess: VarPrefixPostprocessor(options.variablePrefix),
|
|
preflights: options.preflight ? normalizePreflights(preflights, options.variablePrefix) : [],
|
|
extractorDefault: options.arbitraryVariants === false ? void 0 : extractorArbitraryVariants,
|
|
autocomplete: {
|
|
shorthands
|
|
}
|
|
};
|
|
});
|
|
function VarPrefixPostprocessor(prefix) {
|
|
if (prefix !== "un-") {
|
|
return (obj) => {
|
|
obj.entries.forEach((i) => {
|
|
i[0] = i[0].replace(/^--un-/, `--${prefix}`);
|
|
if (typeof i[1] === "string")
|
|
i[1] = i[1].replace(/var\(--un-/g, `var(--${prefix}`);
|
|
});
|
|
};
|
|
}
|
|
}
|
|
function normalizePreflights(preflights3, variablePrefix) {
|
|
if (variablePrefix !== "un-") {
|
|
return preflights3.map((p) => ({
|
|
...p,
|
|
getCSS: (() => async (ctx) => {
|
|
const css = await p.getCSS(ctx);
|
|
if (css)
|
|
return css.replace(/--un-/g, `--${variablePrefix}`);
|
|
})()
|
|
}));
|
|
}
|
|
return preflights3;
|
|
}
|
|
|
|
export { VarPrefixPostprocessor, presetMini as default, normalizePreflights, preflights, presetMini, theme };
|