1037 lines
42 KiB
JavaScript
1037 lines
42 KiB
JavaScript
|
|
import { g as globalKeywords, a as h, t as isCSSMathFn, l as colorResolver, d as directionMap, n as hasParseableColor, c as cornerMap, k as parseColor, u as isSize, q as makeGlobalStaticRules, i as insetMap, r as resolveBreakpoints, j as directionSize, m as colorableShadows, s as splitShorthand } from './preset-mini.DcESQHgx.mjs';
|
||
|
|
import { colorToString, colorOpacityToString } from '@unocss/rule-utils';
|
||
|
|
import { g as contains, p as pointerEvents, e as appearances, d as displays, s as transforms, f as cursors, u as userSelects, h as resizes, l as textOverflows, w as whitespaces, k as breaks, t as textWraps, m as textTransforms, n as fontStyles, o as fontSmoothings, c as boxShadows, a as rings, i as contentVisibility, j as contents } from './preset-mini.C5mgDWy5.mjs';
|
||
|
|
import { toArray } from '@unocss/core';
|
||
|
|
|
||
|
|
const verticalAlignAlias = {
|
||
|
|
"mid": "middle",
|
||
|
|
"base": "baseline",
|
||
|
|
"btm": "bottom",
|
||
|
|
"baseline": "baseline",
|
||
|
|
"top": "top",
|
||
|
|
"start": "top",
|
||
|
|
"middle": "middle",
|
||
|
|
"bottom": "bottom",
|
||
|
|
"end": "bottom",
|
||
|
|
"text-top": "text-top",
|
||
|
|
"text-bottom": "text-bottom",
|
||
|
|
"sub": "sub",
|
||
|
|
"super": "super",
|
||
|
|
...Object.fromEntries(globalKeywords.map((x) => [x, x]))
|
||
|
|
};
|
||
|
|
const verticalAligns = [
|
||
|
|
[
|
||
|
|
/^(?:vertical|align|v)-([-\w]+%?)$/,
|
||
|
|
([, v]) => ({ "vertical-align": verticalAlignAlias[v] ?? h.numberWithUnit(v) }),
|
||
|
|
{
|
||
|
|
autocomplete: [
|
||
|
|
`(vertical|align|v)-(${Object.keys(verticalAlignAlias).join("|")})`,
|
||
|
|
"(vertical|align|v)-<percentage>"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
];
|
||
|
|
const textAlignValues = ["center", "left", "right", "justify", "start", "end"];
|
||
|
|
const textAligns = [
|
||
|
|
...textAlignValues.map((v) => [`text-${v}`, { "text-align": v }]),
|
||
|
|
...[
|
||
|
|
...globalKeywords,
|
||
|
|
...textAlignValues
|
||
|
|
].map((v) => [`text-align-${v}`, { "text-align": v }])
|
||
|
|
];
|
||
|
|
|
||
|
|
const outline = [
|
||
|
|
// size
|
||
|
|
[/^outline-(?:width-|size-)?(.+)$/, handleWidth$2, { autocomplete: "outline-(width|size)-<num>" }],
|
||
|
|
// color
|
||
|
|
[/^outline-(?:color-)?(.+)$/, handleColorOrWidth$2, { autocomplete: "outline-$colors" }],
|
||
|
|
// offset
|
||
|
|
[/^outline-offset-(.+)$/, ([, d], { theme }) => ({ "outline-offset": theme.lineWidth?.[d] ?? h.bracket.cssvar.global.px(d) }), { autocomplete: "outline-(offset)-<num>" }],
|
||
|
|
// style
|
||
|
|
["outline", { "outline-style": "solid" }],
|
||
|
|
...["auto", "dashed", "dotted", "double", "hidden", "solid", "groove", "ridge", "inset", "outset", ...globalKeywords].map((v) => [`outline-${v}`, { "outline-style": v }]),
|
||
|
|
["outline-none", { "outline": "2px solid transparent", "outline-offset": "2px" }]
|
||
|
|
];
|
||
|
|
function handleWidth$2([, b], { theme }) {
|
||
|
|
return { "outline-width": theme.lineWidth?.[b] ?? h.bracket.cssvar.global.px(b) };
|
||
|
|
}
|
||
|
|
function handleColorOrWidth$2(match, ctx) {
|
||
|
|
if (isCSSMathFn(h.bracket(match[1])))
|
||
|
|
return handleWidth$2(match, ctx);
|
||
|
|
return colorResolver("outline-color", "outline-color", "borderColor")(match, ctx);
|
||
|
|
}
|
||
|
|
const appearance = [
|
||
|
|
["appearance-auto", { "-webkit-appearance": "auto", "appearance": "auto" }],
|
||
|
|
["appearance-none", { "-webkit-appearance": "none", "appearance": "none" }]
|
||
|
|
];
|
||
|
|
function willChangeProperty(prop) {
|
||
|
|
return h.properties.auto.global(prop) ?? {
|
||
|
|
contents: "contents",
|
||
|
|
scroll: "scroll-position"
|
||
|
|
}[prop];
|
||
|
|
}
|
||
|
|
const willChange = [
|
||
|
|
[/^will-change-(.+)/, ([, p]) => ({ "will-change": willChangeProperty(p) })]
|
||
|
|
];
|
||
|
|
|
||
|
|
const borderStyles = ["solid", "dashed", "dotted", "double", "hidden", "none", "groove", "ridge", "inset", "outset", ...globalKeywords];
|
||
|
|
const borders = [
|
||
|
|
// compound
|
||
|
|
[/^(?:border|b)()(?:-(.+))?$/, handlerBorderSize, { autocomplete: "(border|b)-<directions>" }],
|
||
|
|
[/^(?:border|b)-([xy])(?:-(.+))?$/, handlerBorderSize],
|
||
|
|
[/^(?:border|b)-([rltbse])(?:-(.+))?$/, handlerBorderSize],
|
||
|
|
[/^(?:border|b)-(block|inline)(?:-(.+))?$/, handlerBorderSize],
|
||
|
|
[/^(?:border|b)-([bi][se])(?:-(.+))?$/, handlerBorderSize],
|
||
|
|
// size
|
||
|
|
[/^(?:border|b)-()(?:width|size)-(.+)$/, handlerBorderSize, { autocomplete: ["(border|b)-<num>", "(border|b)-<directions>-<num>"] }],
|
||
|
|
[/^(?:border|b)-([xy])-(?:width|size)-(.+)$/, handlerBorderSize],
|
||
|
|
[/^(?:border|b)-([rltbse])-(?:width|size)-(.+)$/, handlerBorderSize],
|
||
|
|
[/^(?:border|b)-(block|inline)-(?:width|size)-(.+)$/, handlerBorderSize],
|
||
|
|
[/^(?:border|b)-([bi][se])-(?:width|size)-(.+)$/, handlerBorderSize],
|
||
|
|
// colors
|
||
|
|
[/^(?:border|b)-()(?:color-)?(.+)$/, handlerBorderColorOrSize, { autocomplete: ["(border|b)-$colors", "(border|b)-<directions>-$colors"] }],
|
||
|
|
[/^(?:border|b)-([xy])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
|
||
|
|
[/^(?:border|b)-([rltbse])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
|
||
|
|
[/^(?:border|b)-(block|inline)-(?:color-)?(.+)$/, handlerBorderColorOrSize],
|
||
|
|
[/^(?:border|b)-([bi][se])-(?:color-)?(.+)$/, handlerBorderColorOrSize],
|
||
|
|
// opacity
|
||
|
|
[/^(?:border|b)-()op(?:acity)?-?(.+)$/, handlerBorderOpacity, { autocomplete: "(border|b)-(op|opacity)-<percent>" }],
|
||
|
|
[/^(?:border|b)-([xy])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
|
||
|
|
[/^(?:border|b)-([rltbse])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
|
||
|
|
[/^(?:border|b)-(block|inline)-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
|
||
|
|
[/^(?:border|b)-([bi][se])-op(?:acity)?-?(.+)$/, handlerBorderOpacity],
|
||
|
|
// radius
|
||
|
|
[/^(?:border-|b-)?(?:rounded|rd)()(?:-(.+))?$/, handlerRounded, { autocomplete: ["(border|b)-(rounded|rd)", "(border|b)-(rounded|rd)-$borderRadius", "(rounded|rd)", "(rounded|rd)-$borderRadius"] }],
|
||
|
|
[/^(?:border-|b-)?(?:rounded|rd)-([rltbse])(?:-(.+))?$/, handlerRounded],
|
||
|
|
[/^(?:border-|b-)?(?:rounded|rd)-([rltb]{2})(?:-(.+))?$/, handlerRounded],
|
||
|
|
[/^(?:border-|b-)?(?:rounded|rd)-([bise][se])(?:-(.+))?$/, handlerRounded],
|
||
|
|
[/^(?:border-|b-)?(?:rounded|rd)-([bi][se]-[bi][se])(?:-(.+))?$/, handlerRounded],
|
||
|
|
// style
|
||
|
|
[/^(?:border|b)-(?:style-)?()(.+)$/, handlerBorderStyle, { autocomplete: ["(border|b)-style", `(border|b)-(${borderStyles.join("|")})`, "(border|b)-<directions>-style", `(border|b)-<directions>-(${borderStyles.join("|")})`, `(border|b)-<directions>-style-(${borderStyles.join("|")})`, `(border|b)-style-(${borderStyles.join("|")})`] }],
|
||
|
|
[/^(?:border|b)-([xy])-(?:style-)?(.+)$/, handlerBorderStyle],
|
||
|
|
[/^(?:border|b)-([rltbse])-(?:style-)?(.+)$/, handlerBorderStyle],
|
||
|
|
[/^(?:border|b)-(block|inline)-(?:style-)?(.+)$/, handlerBorderStyle],
|
||
|
|
[/^(?:border|b)-([bi][se])-(?:style-)?(.+)$/, handlerBorderStyle]
|
||
|
|
];
|
||
|
|
function transformBorderColor(color, alpha, direction) {
|
||
|
|
if (alpha != null) {
|
||
|
|
return {
|
||
|
|
[`border${direction}-color`]: colorToString(color, alpha)
|
||
|
|
};
|
||
|
|
}
|
||
|
|
if (direction === "") {
|
||
|
|
const object = {};
|
||
|
|
const opacityVar = `--un-border-opacity`;
|
||
|
|
const result = colorToString(color, `var(${opacityVar})`);
|
||
|
|
if (result.includes(opacityVar))
|
||
|
|
object[opacityVar] = typeof color === "string" ? 1 : colorOpacityToString(color);
|
||
|
|
object["border-color"] = result;
|
||
|
|
return object;
|
||
|
|
} else {
|
||
|
|
const object = {};
|
||
|
|
const opacityVar = "--un-border-opacity";
|
||
|
|
const opacityDirectionVar = `--un-border${direction}-opacity`;
|
||
|
|
const result = colorToString(color, `var(${opacityDirectionVar})`);
|
||
|
|
if (result.includes(opacityDirectionVar)) {
|
||
|
|
object[opacityVar] = typeof color === "string" ? 1 : colorOpacityToString(color);
|
||
|
|
object[opacityDirectionVar] = `var(${opacityVar})`;
|
||
|
|
}
|
||
|
|
object[`border${direction}-color`] = result;
|
||
|
|
return object;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function borderColorResolver(direction) {
|
||
|
|
return ([, body], theme) => {
|
||
|
|
const data = parseColor(body, theme, "borderColor");
|
||
|
|
if (!data)
|
||
|
|
return;
|
||
|
|
const { alpha, color, cssColor } = data;
|
||
|
|
if (cssColor)
|
||
|
|
return transformBorderColor(cssColor, alpha, direction);
|
||
|
|
else if (color)
|
||
|
|
return transformBorderColor(color, alpha, direction);
|
||
|
|
};
|
||
|
|
}
|
||
|
|
function handlerBorderSize([, a = "", b], { theme }) {
|
||
|
|
const v = theme.lineWidth?.[b || "DEFAULT"] ?? h.bracket.cssvar.global.px(b || "1");
|
||
|
|
if (a in directionMap && v != null)
|
||
|
|
return directionMap[a].map((i) => [`border${i}-width`, v]);
|
||
|
|
}
|
||
|
|
function handlerBorderColorOrSize([, a = "", b], ctx) {
|
||
|
|
if (a in directionMap) {
|
||
|
|
if (isCSSMathFn(h.bracket(b)))
|
||
|
|
return handlerBorderSize(["", a, b], ctx);
|
||
|
|
if (hasParseableColor(b, ctx.theme, "borderColor")) {
|
||
|
|
return Object.assign(
|
||
|
|
{},
|
||
|
|
...directionMap[a].map((i) => borderColorResolver(i)(["", b], ctx.theme))
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
function handlerBorderOpacity([, a = "", opacity]) {
|
||
|
|
const v = h.bracket.percent.cssvar(opacity);
|
||
|
|
if (a in directionMap && v != null)
|
||
|
|
return directionMap[a].map((i) => [`--un-border${i}-opacity`, v]);
|
||
|
|
}
|
||
|
|
function handlerRounded([, a = "", s], { theme }) {
|
||
|
|
const v = theme.borderRadius?.[s || "DEFAULT"] || h.bracket.cssvar.global.fraction.rem(s || "1");
|
||
|
|
if (a in cornerMap && v != null)
|
||
|
|
return cornerMap[a].map((i) => [`border${i}-radius`, v]);
|
||
|
|
}
|
||
|
|
function handlerBorderStyle([, a = "", s]) {
|
||
|
|
if (borderStyles.includes(s) && a in directionMap)
|
||
|
|
return directionMap[a].map((i) => [`border${i}-style`, s]);
|
||
|
|
}
|
||
|
|
|
||
|
|
const opacity = [
|
||
|
|
[/^op(?:acity)?-?(.+)$/, ([, d]) => ({ opacity: h.bracket.percent.cssvar(d) })]
|
||
|
|
];
|
||
|
|
const bgUrlRE = /^\[url\(.+\)\]$/;
|
||
|
|
const bgLengthRE = /^\[(?:length|size):.+\]$/;
|
||
|
|
const bgPositionRE = /^\[position:.+\]$/;
|
||
|
|
const bgGradientRE = /^\[(?:linear|conic|radial)-gradient\(.+\)\]$/;
|
||
|
|
const bgImageRE = /^\[image:.+\]$/;
|
||
|
|
const bgColors = [
|
||
|
|
[/^bg-(.+)$/, (...args) => {
|
||
|
|
const d = args[0][1];
|
||
|
|
if (bgUrlRE.test(d))
|
||
|
|
return { "--un-url": h.bracket(d), "background-image": "var(--un-url)" };
|
||
|
|
if (bgLengthRE.test(d) && h.bracketOfLength(d) != null)
|
||
|
|
return { "background-size": h.bracketOfLength(d).split(" ").map((e) => h.fraction.auto.px.cssvar(e) ?? e).join(" ") };
|
||
|
|
if ((isSize(d) || bgPositionRE.test(d)) && h.bracketOfPosition(d) != null)
|
||
|
|
return { "background-position": h.bracketOfPosition(d).split(" ").map((e) => h.position.fraction.auto.px.cssvar(e) ?? e).join(" ") };
|
||
|
|
if (bgGradientRE.test(d) || bgImageRE.test(d)) {
|
||
|
|
const s = h.bracket(d);
|
||
|
|
if (s) {
|
||
|
|
const url = s.startsWith("http") ? `url(${s})` : h.cssvar(s);
|
||
|
|
return { "background-image": url ?? s };
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return colorResolver("background-color", "bg", "backgroundColor")(...args);
|
||
|
|
}, { autocomplete: "bg-$colors" }],
|
||
|
|
[/^bg-op(?:acity)?-?(.+)$/, ([, opacity2]) => ({ "--un-bg-opacity": h.bracket.percent.cssvar(opacity2) }), { autocomplete: "bg-(op|opacity)-<percent>" }]
|
||
|
|
];
|
||
|
|
const colorScheme = [
|
||
|
|
[/^color-scheme-(\w+)$/, ([, v]) => ({ "color-scheme": v })]
|
||
|
|
];
|
||
|
|
|
||
|
|
const containerParent = [
|
||
|
|
[/^@container(?:\/(\w+))?(?:-(normal))?$/, ([, l, v]) => {
|
||
|
|
return {
|
||
|
|
"container-type": v ?? "inline-size",
|
||
|
|
"container-name": l
|
||
|
|
};
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
|
||
|
|
const decorationStyles = ["solid", "double", "dotted", "dashed", "wavy", ...globalKeywords];
|
||
|
|
const textDecorations = [
|
||
|
|
[/^(?:decoration-)?(underline|overline|line-through)$/, ([, s]) => ({ "text-decoration-line": s }), { autocomplete: "decoration-(underline|overline|line-through)" }],
|
||
|
|
// size
|
||
|
|
[/^(?:underline|decoration)-(?:size-)?(.+)$/, handleWidth$1, { autocomplete: "(underline|decoration)-<num>" }],
|
||
|
|
[/^(?:underline|decoration)-(auto|from-font)$/, ([, s]) => ({ "text-decoration-thickness": s }), { autocomplete: "(underline|decoration)-(auto|from-font)" }],
|
||
|
|
// colors
|
||
|
|
[/^(?:underline|decoration)-(.+)$/, handleColorOrWidth$1, { autocomplete: "(underline|decoration)-$colors" }],
|
||
|
|
[/^(?:underline|decoration)-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-line-opacity": h.bracket.percent.cssvar(opacity) }), { autocomplete: "(underline|decoration)-(op|opacity)-<percent>" }],
|
||
|
|
// offset
|
||
|
|
[/^(?:underline|decoration)-offset-(.+)$/, ([, s], { theme }) => ({ "text-underline-offset": theme.lineWidth?.[s] ?? h.auto.bracket.cssvar.global.px(s) }), { autocomplete: "(underline|decoration)-(offset)-<num>" }],
|
||
|
|
// style
|
||
|
|
...decorationStyles.map((v) => [`underline-${v}`, { "text-decoration-style": v }]),
|
||
|
|
...decorationStyles.map((v) => [`decoration-${v}`, { "text-decoration-style": v }]),
|
||
|
|
["no-underline", { "text-decoration": "none" }],
|
||
|
|
["decoration-none", { "text-decoration": "none" }]
|
||
|
|
];
|
||
|
|
function handleWidth$1([, b], { theme }) {
|
||
|
|
return { "text-decoration-thickness": theme.lineWidth?.[b] ?? h.bracket.cssvar.global.px(b) };
|
||
|
|
}
|
||
|
|
function handleColorOrWidth$1(match, ctx) {
|
||
|
|
if (isCSSMathFn(h.bracket(match[1])))
|
||
|
|
return handleWidth$1(match, ctx);
|
||
|
|
const result = colorResolver("text-decoration-color", "line", "borderColor")(match, ctx);
|
||
|
|
if (result) {
|
||
|
|
return {
|
||
|
|
"-webkit-text-decoration-color": result["text-decoration-color"],
|
||
|
|
...result
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const flex = [
|
||
|
|
// display
|
||
|
|
["flex", { display: "flex" }],
|
||
|
|
["inline-flex", { display: "inline-flex" }],
|
||
|
|
["flex-inline", { display: "inline-flex" }],
|
||
|
|
// flex
|
||
|
|
[/^flex-(.*)$/, ([, d]) => ({ flex: h.bracket(d) != null ? h.bracket(d).split(" ").map((e) => h.cssvar.fraction(e) ?? e).join(" ") : h.cssvar.fraction(d) })],
|
||
|
|
["flex-1", { flex: "1 1 0%" }],
|
||
|
|
["flex-auto", { flex: "1 1 auto" }],
|
||
|
|
["flex-initial", { flex: "0 1 auto" }],
|
||
|
|
["flex-none", { flex: "none" }],
|
||
|
|
// shrink/grow/basis
|
||
|
|
[/^(?:flex-)?shrink(?:-(.*))?$/, ([, d = ""]) => ({ "flex-shrink": h.bracket.cssvar.number(d) ?? 1 }), { autocomplete: ["flex-shrink-<num>", "shrink-<num>"] }],
|
||
|
|
[/^(?:flex-)?grow(?:-(.*))?$/, ([, d = ""]) => ({ "flex-grow": h.bracket.cssvar.number(d) ?? 1 }), { autocomplete: ["flex-grow-<num>", "grow-<num>"] }],
|
||
|
|
[/^(?:flex-)?basis-(.+)$/, ([, d], { theme }) => ({ "flex-basis": theme.spacing?.[d] ?? h.bracket.cssvar.auto.fraction.rem(d) }), { autocomplete: ["flex-basis-$spacing", "basis-$spacing"] }],
|
||
|
|
// directions
|
||
|
|
["flex-row", { "flex-direction": "row" }],
|
||
|
|
["flex-row-reverse", { "flex-direction": "row-reverse" }],
|
||
|
|
["flex-col", { "flex-direction": "column" }],
|
||
|
|
["flex-col-reverse", { "flex-direction": "column-reverse" }],
|
||
|
|
// wraps
|
||
|
|
["flex-wrap", { "flex-wrap": "wrap" }],
|
||
|
|
["flex-wrap-reverse", { "flex-wrap": "wrap-reverse" }],
|
||
|
|
["flex-nowrap", { "flex-wrap": "nowrap" }]
|
||
|
|
];
|
||
|
|
|
||
|
|
const directions = {
|
||
|
|
"": "",
|
||
|
|
"x": "column-",
|
||
|
|
"y": "row-",
|
||
|
|
"col": "column-",
|
||
|
|
"row": "row-"
|
||
|
|
};
|
||
|
|
function handleGap([, d = "", s], { theme }) {
|
||
|
|
const v = theme.spacing?.[s] ?? h.bracket.cssvar.global.rem(s);
|
||
|
|
if (v != null) {
|
||
|
|
return {
|
||
|
|
[`${directions[d]}gap`]: v
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}
|
||
|
|
const gaps = [
|
||
|
|
[/^(?:flex-|grid-)?gap-?()(.+)$/, handleGap, { autocomplete: ["gap-$spacing", "gap-<num>"] }],
|
||
|
|
[/^(?:flex-|grid-)?gap-([xy])-?(.+)$/, handleGap, { autocomplete: ["gap-(x|y)-$spacing", "gap-(x|y)-<num>"] }],
|
||
|
|
[/^(?:flex-|grid-)?gap-(col|row)-?(.+)$/, handleGap, { autocomplete: ["gap-(col|row)-$spacing", "gap-(col|row)-<num>"] }]
|
||
|
|
];
|
||
|
|
|
||
|
|
function rowCol(s) {
|
||
|
|
return s.replace("col", "column");
|
||
|
|
}
|
||
|
|
function rowColTheme(s) {
|
||
|
|
return s[0] === "r" ? "Row" : "Column";
|
||
|
|
}
|
||
|
|
function autoDirection(c, theme, prop) {
|
||
|
|
const v = theme[`gridAuto${rowColTheme(c)}`]?.[prop];
|
||
|
|
if (v != null)
|
||
|
|
return v;
|
||
|
|
switch (prop) {
|
||
|
|
case "min":
|
||
|
|
return "min-content";
|
||
|
|
case "max":
|
||
|
|
return "max-content";
|
||
|
|
case "fr":
|
||
|
|
return "minmax(0,1fr)";
|
||
|
|
}
|
||
|
|
return h.bracket.cssvar.auto.rem(prop);
|
||
|
|
}
|
||
|
|
const grids = [
|
||
|
|
// displays
|
||
|
|
["grid", { display: "grid" }],
|
||
|
|
["inline-grid", { display: "inline-grid" }],
|
||
|
|
// global
|
||
|
|
[/^(?:grid-)?(row|col)-(.+)$/, ([, c, v], { theme }) => ({
|
||
|
|
[`grid-${rowCol(c)}`]: theme[`grid${rowColTheme(c)}`]?.[v] ?? h.bracket.cssvar.auto(v)
|
||
|
|
})],
|
||
|
|
// span
|
||
|
|
[/^(?:grid-)?(row|col)-span-(.+)$/, ([, c, s]) => {
|
||
|
|
if (s === "full")
|
||
|
|
return { [`grid-${rowCol(c)}`]: "1/-1" };
|
||
|
|
const v = h.bracket.number(s);
|
||
|
|
if (v != null)
|
||
|
|
return { [`grid-${rowCol(c)}`]: `span ${v}/span ${v}` };
|
||
|
|
}, { autocomplete: "(grid-row|grid-col|row|col)-span-<num>" }],
|
||
|
|
// starts & ends
|
||
|
|
[/^(?:grid-)?(row|col)-start-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-start`]: h.bracket.cssvar(v) ?? v })],
|
||
|
|
[/^(?:grid-)?(row|col)-end-(.+)$/, ([, c, v]) => ({ [`grid-${rowCol(c)}-end`]: h.bracket.cssvar(v) ?? v }), { autocomplete: "(grid-row|grid-col|row|col)-(start|end)-<num>" }],
|
||
|
|
// auto flows
|
||
|
|
[/^(?:grid-)?auto-(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({ [`grid-auto-${rowCol(c)}`]: autoDirection(c, theme, v) }), { autocomplete: "(grid-auto|auto)-(rows|cols)-<num>" }],
|
||
|
|
// grid-auto-flow, auto-flow: uno
|
||
|
|
// grid-flow: wind
|
||
|
|
[/^(?:grid-auto-flow|auto-flow|grid-flow)-(.+)$/, ([, v]) => ({ "grid-auto-flow": h.bracket.cssvar(v) })],
|
||
|
|
[/^(?:grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)$/, ([, v]) => ({ "grid-auto-flow": rowCol(v).replace("-", " ") }), { autocomplete: ["(grid-auto-flow|auto-flow|grid-flow)-(row|col|dense|row-dense|col-dense)"] }],
|
||
|
|
// templates
|
||
|
|
[/^(?:grid-)?(rows|cols)-(.+)$/, ([, c, v], { theme }) => ({
|
||
|
|
[`grid-template-${rowCol(c)}`]: theme[`gridTemplate${rowColTheme(c)}`]?.[v] ?? h.bracket.cssvar(v)
|
||
|
|
})],
|
||
|
|
[/^(?:grid-)?(rows|cols)-minmax-([\w.-]+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(auto-fill,minmax(${d},1fr))` })],
|
||
|
|
[/^(?:grid-)?(rows|cols)-(\d+)$/, ([, c, d]) => ({ [`grid-template-${rowCol(c)}`]: `repeat(${d},minmax(0,1fr))` }), { autocomplete: "(grid-rows|grid-cols|rows|cols)-<num>" }],
|
||
|
|
// areas
|
||
|
|
[/^grid-area(s)?-(.+)$/, ([, s, v]) => {
|
||
|
|
if (s != null)
|
||
|
|
return { "grid-template-areas": h.cssvar(v) ?? v.split("-").map((s2) => `"${h.bracket(s2)}"`).join(" ") };
|
||
|
|
return { "grid-area": h.bracket.cssvar(v) };
|
||
|
|
}],
|
||
|
|
// template none
|
||
|
|
["grid-rows-none", { "grid-template-rows": "none" }],
|
||
|
|
["grid-cols-none", { "grid-template-columns": "none" }],
|
||
|
|
// template subgrid
|
||
|
|
["grid-rows-subgrid", { "grid-template-rows": "subgrid" }],
|
||
|
|
["grid-cols-subgrid", { "grid-template-columns": "subgrid" }]
|
||
|
|
];
|
||
|
|
|
||
|
|
const overflowValues = [
|
||
|
|
"auto",
|
||
|
|
"hidden",
|
||
|
|
"clip",
|
||
|
|
"visible",
|
||
|
|
"scroll",
|
||
|
|
"overlay",
|
||
|
|
...globalKeywords
|
||
|
|
];
|
||
|
|
const overflows = [
|
||
|
|
[/^(?:overflow|of)-(.+)$/, ([, v]) => overflowValues.includes(v) ? { overflow: v } : void 0, { autocomplete: [`(overflow|of)-(${overflowValues.join("|")})`, `(overflow|of)-(x|y)-(${overflowValues.join("|")})`] }],
|
||
|
|
[/^(?:overflow|of)-([xy])-(.+)$/, ([, d, v]) => overflowValues.includes(v) ? { [`overflow-${d}`]: v } : void 0]
|
||
|
|
];
|
||
|
|
|
||
|
|
const positions = [
|
||
|
|
[/^(?:position-|pos-)?(relative|absolute|fixed|sticky)$/, ([, v]) => ({ position: v }), {
|
||
|
|
autocomplete: [
|
||
|
|
"(position|pos)-<position>",
|
||
|
|
"(position|pos)-<globalKeyword>",
|
||
|
|
"<position>"
|
||
|
|
]
|
||
|
|
}],
|
||
|
|
[/^(?:position-|pos-)([-\w]+)$/, ([, v]) => globalKeywords.includes(v) ? { position: v } : void 0],
|
||
|
|
[/^(?:position-|pos-)?(static)$/, ([, v]) => ({ position: v })]
|
||
|
|
];
|
||
|
|
const justifies = [
|
||
|
|
// contents
|
||
|
|
["justify-start", { "justify-content": "flex-start" }],
|
||
|
|
["justify-end", { "justify-content": "flex-end" }],
|
||
|
|
["justify-center", { "justify-content": "center" }],
|
||
|
|
["justify-between", { "justify-content": "space-between" }],
|
||
|
|
["justify-around", { "justify-content": "space-around" }],
|
||
|
|
["justify-evenly", { "justify-content": "space-evenly" }],
|
||
|
|
["justify-stretch", { "justify-content": "stretch" }],
|
||
|
|
["justify-left", { "justify-content": "left" }],
|
||
|
|
["justify-right", { "justify-content": "right" }],
|
||
|
|
...makeGlobalStaticRules("justify", "justify-content"),
|
||
|
|
// items
|
||
|
|
["justify-items-start", { "justify-items": "start" }],
|
||
|
|
["justify-items-end", { "justify-items": "end" }],
|
||
|
|
["justify-items-center", { "justify-items": "center" }],
|
||
|
|
["justify-items-stretch", { "justify-items": "stretch" }],
|
||
|
|
...makeGlobalStaticRules("justify-items"),
|
||
|
|
// selfs
|
||
|
|
["justify-self-auto", { "justify-self": "auto" }],
|
||
|
|
["justify-self-start", { "justify-self": "start" }],
|
||
|
|
["justify-self-end", { "justify-self": "end" }],
|
||
|
|
["justify-self-center", { "justify-self": "center" }],
|
||
|
|
["justify-self-stretch", { "justify-self": "stretch" }],
|
||
|
|
...makeGlobalStaticRules("justify-self")
|
||
|
|
];
|
||
|
|
const orders = [
|
||
|
|
[/^order-(.+)$/, ([, v]) => ({ order: h.bracket.cssvar.number(v) })],
|
||
|
|
["order-first", { order: "-9999" }],
|
||
|
|
["order-last", { order: "9999" }],
|
||
|
|
["order-none", { order: "0" }]
|
||
|
|
];
|
||
|
|
const alignments = [
|
||
|
|
// contents
|
||
|
|
["content-center", { "align-content": "center" }],
|
||
|
|
["content-start", { "align-content": "flex-start" }],
|
||
|
|
["content-end", { "align-content": "flex-end" }],
|
||
|
|
["content-between", { "align-content": "space-between" }],
|
||
|
|
["content-around", { "align-content": "space-around" }],
|
||
|
|
["content-evenly", { "align-content": "space-evenly" }],
|
||
|
|
...makeGlobalStaticRules("content", "align-content"),
|
||
|
|
// items
|
||
|
|
["items-start", { "align-items": "flex-start" }],
|
||
|
|
["items-end", { "align-items": "flex-end" }],
|
||
|
|
["items-center", { "align-items": "center" }],
|
||
|
|
["items-baseline", { "align-items": "baseline" }],
|
||
|
|
["items-stretch", { "align-items": "stretch" }],
|
||
|
|
...makeGlobalStaticRules("items", "align-items"),
|
||
|
|
// selfs
|
||
|
|
["self-auto", { "align-self": "auto" }],
|
||
|
|
["self-start", { "align-self": "flex-start" }],
|
||
|
|
["self-end", { "align-self": "flex-end" }],
|
||
|
|
["self-center", { "align-self": "center" }],
|
||
|
|
["self-stretch", { "align-self": "stretch" }],
|
||
|
|
["self-baseline", { "align-self": "baseline" }],
|
||
|
|
...makeGlobalStaticRules("self", "align-self")
|
||
|
|
];
|
||
|
|
const placements = [
|
||
|
|
// contents
|
||
|
|
["place-content-center", { "place-content": "center" }],
|
||
|
|
["place-content-start", { "place-content": "start" }],
|
||
|
|
["place-content-end", { "place-content": "end" }],
|
||
|
|
["place-content-between", { "place-content": "space-between" }],
|
||
|
|
["place-content-around", { "place-content": "space-around" }],
|
||
|
|
["place-content-evenly", { "place-content": "space-evenly" }],
|
||
|
|
["place-content-stretch", { "place-content": "stretch" }],
|
||
|
|
...makeGlobalStaticRules("place-content"),
|
||
|
|
// items
|
||
|
|
["place-items-start", { "place-items": "start" }],
|
||
|
|
["place-items-end", { "place-items": "end" }],
|
||
|
|
["place-items-center", { "place-items": "center" }],
|
||
|
|
["place-items-stretch", { "place-items": "stretch" }],
|
||
|
|
...makeGlobalStaticRules("place-items"),
|
||
|
|
// selfs
|
||
|
|
["place-self-auto", { "place-self": "auto" }],
|
||
|
|
["place-self-start", { "place-self": "start" }],
|
||
|
|
["place-self-end", { "place-self": "end" }],
|
||
|
|
["place-self-center", { "place-self": "center" }],
|
||
|
|
["place-self-stretch", { "place-self": "stretch" }],
|
||
|
|
...makeGlobalStaticRules("place-self")
|
||
|
|
];
|
||
|
|
const flexGridJustifiesAlignments = [...justifies, ...alignments, ...placements].flatMap(([k, v]) => [
|
||
|
|
[`flex-${k}`, v],
|
||
|
|
[`grid-${k}`, v]
|
||
|
|
]);
|
||
|
|
function handleInsetValue(v, { theme }) {
|
||
|
|
return theme.spacing?.[v] ?? h.bracket.cssvar.global.auto.fraction.rem(v);
|
||
|
|
}
|
||
|
|
function handleInsetValues([, d, v], ctx) {
|
||
|
|
const r = handleInsetValue(v, ctx);
|
||
|
|
if (r != null && d in insetMap)
|
||
|
|
return insetMap[d].map((i) => [i.slice(1), r]);
|
||
|
|
}
|
||
|
|
const insets = [
|
||
|
|
[
|
||
|
|
/^(?:position-|pos-)?inset-(.+)$/,
|
||
|
|
([, v], ctx) => ({ inset: handleInsetValue(v, ctx) }),
|
||
|
|
{
|
||
|
|
autocomplete: [
|
||
|
|
"(position|pos)-inset-<directions>-$spacing",
|
||
|
|
"(position|pos)-inset-(block|inline)-$spacing",
|
||
|
|
"(position|pos)-inset-(bs|be|is|ie)-$spacing",
|
||
|
|
"(position|pos)-(top|left|right|bottom)-$spacing"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
[/^(?:position-|pos-)?(start|end)-(.+)$/, handleInsetValues],
|
||
|
|
[/^(?:position-|pos-)?inset-([xy])-(.+)$/, handleInsetValues],
|
||
|
|
[/^(?:position-|pos-)?inset-([rltbse])-(.+)$/, handleInsetValues],
|
||
|
|
[/^(?:position-|pos-)?inset-(block|inline)-(.+)$/, handleInsetValues],
|
||
|
|
[/^(?:position-|pos-)?inset-([bi][se])-(.+)$/, handleInsetValues],
|
||
|
|
[/^(?:position-|pos-)?(top|left|right|bottom)-(.+)$/, ([, d, v], ctx) => ({ [d]: handleInsetValue(v, ctx) })]
|
||
|
|
];
|
||
|
|
const floats = [
|
||
|
|
// floats
|
||
|
|
["float-left", { float: "left" }],
|
||
|
|
["float-right", { float: "right" }],
|
||
|
|
["float-start", { float: "inline-start" }],
|
||
|
|
["float-end", { float: "inline-end" }],
|
||
|
|
["float-none", { float: "none" }],
|
||
|
|
...makeGlobalStaticRules("float"),
|
||
|
|
// clears
|
||
|
|
["clear-left", { clear: "left" }],
|
||
|
|
["clear-right", { clear: "right" }],
|
||
|
|
["clear-both", { clear: "both" }],
|
||
|
|
["clear-start", { clear: "inline-start" }],
|
||
|
|
["clear-end", { clear: "inline-end" }],
|
||
|
|
["clear-none", { clear: "none" }],
|
||
|
|
...makeGlobalStaticRules("clear")
|
||
|
|
];
|
||
|
|
const zIndexes = [
|
||
|
|
[/^(?:position-|pos-)?z([\d.]+)$/, ([, v]) => ({ "z-index": h.number(v) })],
|
||
|
|
[/^(?:position-|pos-)?z-(.+)$/, ([, v], { theme }) => ({ "z-index": theme.zIndex?.[v] ?? h.bracket.cssvar.global.auto.number(v) }), { autocomplete: "z-<num>" }]
|
||
|
|
];
|
||
|
|
const boxSizing = [
|
||
|
|
["box-border", { "box-sizing": "border-box" }],
|
||
|
|
["box-content", { "box-sizing": "content-box" }],
|
||
|
|
...makeGlobalStaticRules("box", "box-sizing")
|
||
|
|
];
|
||
|
|
|
||
|
|
const questionMark = [
|
||
|
|
[
|
||
|
|
/^(where|\?)$/,
|
||
|
|
(_, { constructCSS, generator }) => {
|
||
|
|
if (generator.userConfig.envMode === "dev")
|
||
|
|
return `@keyframes __un_qm{0%{box-shadow:inset 4px 4px #ff1e90, inset -4px -4px #ff1e90}100%{box-shadow:inset 8px 8px #3399ff, inset -8px -8px #3399ff}} ${constructCSS({ animation: "__un_qm 0.5s ease-in-out alternate infinite" })}`;
|
||
|
|
}
|
||
|
|
]
|
||
|
|
];
|
||
|
|
|
||
|
|
const sizeMapping = {
|
||
|
|
h: "height",
|
||
|
|
w: "width",
|
||
|
|
inline: "inline-size",
|
||
|
|
block: "block-size"
|
||
|
|
};
|
||
|
|
function getPropName(minmax, hw) {
|
||
|
|
return `${minmax || ""}${sizeMapping[hw]}`;
|
||
|
|
}
|
||
|
|
function getSizeValue(minmax, hw, theme, prop) {
|
||
|
|
const str = getPropName(minmax, hw).replace(/-(\w)/g, (_, p) => p.toUpperCase());
|
||
|
|
const v = theme[str]?.[prop];
|
||
|
|
if (v != null)
|
||
|
|
return v;
|
||
|
|
switch (prop) {
|
||
|
|
case "fit":
|
||
|
|
case "max":
|
||
|
|
case "min":
|
||
|
|
return `${prop}-content`;
|
||
|
|
}
|
||
|
|
return h.bracket.cssvar.global.auto.fraction.rem(prop);
|
||
|
|
}
|
||
|
|
const sizes = [
|
||
|
|
[/^size-(min-|max-)?(.+)$/, ([, m, s], { theme }) => ({ [getPropName(m, "w")]: getSizeValue(m, "w", theme, s), [getPropName(m, "h")]: getSizeValue(m, "h", theme, s) })],
|
||
|
|
[/^(?:size-)?(min-|max-)?([wh])-?(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) })],
|
||
|
|
[/^(?:size-)?(min-|max-)?(block|inline)-(.+)$/, ([, m, w, s], { theme }) => ({ [getPropName(m, w)]: getSizeValue(m, w, theme, s) }), {
|
||
|
|
autocomplete: [
|
||
|
|
"(w|h)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
|
||
|
|
"(block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
|
||
|
|
"(max|min)-(w|h|block|inline)",
|
||
|
|
"(max|min)-(w|h|block|inline)-$width|height|maxWidth|maxHeight|minWidth|minHeight|inlineSize|blockSize|maxInlineSize|maxBlockSize|minInlineSize|minBlockSize",
|
||
|
|
"(w|h)-full",
|
||
|
|
"(max|min)-(w|h)-full"
|
||
|
|
]
|
||
|
|
}],
|
||
|
|
[/^(?:size-)?(min-|max-)?(h)-screen-(.+)$/, ([, m, h2, p], context) => ({ [getPropName(m, h2)]: handleBreakpoint(context, p, "verticalBreakpoints") })],
|
||
|
|
[/^(?:size-)?(min-|max-)?(w)-screen-(.+)$/, ([, m, w, p], context) => ({ [getPropName(m, w)]: handleBreakpoint(context, p) }), {
|
||
|
|
autocomplete: [
|
||
|
|
"(w|h)-screen",
|
||
|
|
"(min|max)-(w|h)-screen",
|
||
|
|
"h-screen-$verticalBreakpoints",
|
||
|
|
"(min|max)-h-screen-$verticalBreakpoints",
|
||
|
|
"w-screen-$breakpoints",
|
||
|
|
"(min|max)-w-screen-$breakpoints"
|
||
|
|
]
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
function handleBreakpoint(context, point, key = "breakpoints") {
|
||
|
|
const bp = resolveBreakpoints(context, key);
|
||
|
|
if (bp)
|
||
|
|
return bp.find((i) => i.point === point)?.size;
|
||
|
|
}
|
||
|
|
function getAspectRatio(prop) {
|
||
|
|
if (/^\d+\/\d+$/.test(prop))
|
||
|
|
return prop;
|
||
|
|
switch (prop) {
|
||
|
|
case "square":
|
||
|
|
return "1/1";
|
||
|
|
case "video":
|
||
|
|
return "16/9";
|
||
|
|
}
|
||
|
|
return h.bracket.cssvar.global.auto.number(prop);
|
||
|
|
}
|
||
|
|
const aspectRatio = [
|
||
|
|
[/^(?:size-)?aspect-(?:ratio-)?(.+)$/, ([, d]) => ({ "aspect-ratio": getAspectRatio(d) }), { autocomplete: ["aspect-(square|video|ratio)", "aspect-ratio-(square|video)"] }]
|
||
|
|
];
|
||
|
|
|
||
|
|
const paddings = [
|
||
|
|
[/^pa?()-?(.+)$/, directionSize("padding"), { autocomplete: ["(m|p)<num>", "(m|p)-<num>"] }],
|
||
|
|
[/^p-?xy()()$/, directionSize("padding"), { autocomplete: "(m|p)-(xy)" }],
|
||
|
|
[/^p-?([xy])(?:-?(.+))?$/, directionSize("padding")],
|
||
|
|
[/^p-?([rltbse])(?:-?(.+))?$/, directionSize("padding"), { autocomplete: "(m|p)<directions>-<num>" }],
|
||
|
|
[/^p-(block|inline)(?:-(.+))?$/, directionSize("padding"), { autocomplete: "(m|p)-(block|inline)-<num>" }],
|
||
|
|
[/^p-?([bi][se])(?:-?(.+))?$/, directionSize("padding"), { autocomplete: "(m|p)-(bs|be|is|ie)-<num>" }]
|
||
|
|
];
|
||
|
|
const margins = [
|
||
|
|
[/^ma?()-?(.+)$/, directionSize("margin")],
|
||
|
|
[/^m-?xy()()$/, directionSize("margin")],
|
||
|
|
[/^m-?([xy])(?:-?(.+))?$/, directionSize("margin")],
|
||
|
|
[/^m-?([rltbse])(?:-?(.+))?$/, directionSize("margin")],
|
||
|
|
[/^m-(block|inline)(?:-(.+))?$/, directionSize("margin")],
|
||
|
|
[/^m-?([bi][se])(?:-?(.+))?$/, directionSize("margin")]
|
||
|
|
];
|
||
|
|
|
||
|
|
const svgUtilities = [
|
||
|
|
// fills
|
||
|
|
[/^fill-(.+)$/, colorResolver("fill", "fill", "backgroundColor"), { autocomplete: "fill-$colors" }],
|
||
|
|
[/^fill-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-fill-opacity": h.bracket.percent.cssvar(opacity) }), { autocomplete: "fill-(op|opacity)-<percent>" }],
|
||
|
|
["fill-none", { fill: "none" }],
|
||
|
|
// stroke size
|
||
|
|
[/^stroke-(?:width-|size-)?(.+)$/, handleWidth, { autocomplete: ["stroke-width-$lineWidth", "stroke-size-$lineWidth"] }],
|
||
|
|
// stroke dash
|
||
|
|
[/^stroke-dash-(.+)$/, ([, s]) => ({ "stroke-dasharray": h.bracket.cssvar.number(s) }), { autocomplete: "stroke-dash-<num>" }],
|
||
|
|
[/^stroke-offset-(.+)$/, ([, s], { theme }) => ({ "stroke-dashoffset": theme.lineWidth?.[s] ?? h.bracket.cssvar.px.numberWithUnit(s) }), { autocomplete: "stroke-offset-$lineWidth" }],
|
||
|
|
// stroke colors
|
||
|
|
[/^stroke-(.+)$/, handleColorOrWidth, { autocomplete: "stroke-$colors" }],
|
||
|
|
[/^stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-stroke-opacity": h.bracket.percent.cssvar(opacity) }), { autocomplete: "stroke-(op|opacity)-<percent>" }],
|
||
|
|
// line cap
|
||
|
|
["stroke-cap-square", { "stroke-linecap": "square" }],
|
||
|
|
["stroke-cap-round", { "stroke-linecap": "round" }],
|
||
|
|
["stroke-cap-auto", { "stroke-linecap": "butt" }],
|
||
|
|
// line join
|
||
|
|
["stroke-join-arcs", { "stroke-linejoin": "arcs" }],
|
||
|
|
["stroke-join-bevel", { "stroke-linejoin": "bevel" }],
|
||
|
|
["stroke-join-clip", { "stroke-linejoin": "miter-clip" }],
|
||
|
|
["stroke-join-round", { "stroke-linejoin": "round" }],
|
||
|
|
["stroke-join-auto", { "stroke-linejoin": "miter" }],
|
||
|
|
// none
|
||
|
|
["stroke-none", { stroke: "none" }]
|
||
|
|
];
|
||
|
|
function handleWidth([, b], { theme }) {
|
||
|
|
return { "stroke-width": theme.lineWidth?.[b] ?? h.bracket.cssvar.fraction.px.number(b) };
|
||
|
|
}
|
||
|
|
function handleColorOrWidth(match, ctx) {
|
||
|
|
if (isCSSMathFn(h.bracket(match[1])))
|
||
|
|
return handleWidth(match, ctx);
|
||
|
|
return colorResolver("stroke", "stroke", "borderColor")(match, ctx);
|
||
|
|
}
|
||
|
|
|
||
|
|
function resolveTransitionProperty(prop, theme) {
|
||
|
|
let p;
|
||
|
|
if (h.cssvar(prop) != null) {
|
||
|
|
p = h.cssvar(prop);
|
||
|
|
} else {
|
||
|
|
if (prop.startsWith("[") && prop.endsWith("]")) {
|
||
|
|
prop = prop.slice(1, -1);
|
||
|
|
}
|
||
|
|
const props = prop.split(",").map((p2) => theme.transitionProperty?.[p2] ?? h.properties(p2));
|
||
|
|
if (props.every(Boolean)) {
|
||
|
|
p = props.join(",");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return p;
|
||
|
|
}
|
||
|
|
const transitions = [
|
||
|
|
// transition
|
||
|
|
[
|
||
|
|
/^transition(?:-(\D+?))?(?:-(\d+))?$/,
|
||
|
|
([, prop, d], { theme }) => {
|
||
|
|
if (!prop && !d) {
|
||
|
|
return {
|
||
|
|
"transition-property": theme.transitionProperty?.DEFAULT,
|
||
|
|
"transition-timing-function": theme.easing?.DEFAULT,
|
||
|
|
"transition-duration": theme.duration?.DEFAULT ?? h.time("150")
|
||
|
|
};
|
||
|
|
} else if (prop != null) {
|
||
|
|
const p = resolveTransitionProperty(prop, theme);
|
||
|
|
const duration = theme.duration?.[d || "DEFAULT"] ?? h.time(d || "150");
|
||
|
|
if (p) {
|
||
|
|
return {
|
||
|
|
"transition-property": p,
|
||
|
|
"transition-timing-function": theme.easing?.DEFAULT,
|
||
|
|
"transition-duration": duration
|
||
|
|
};
|
||
|
|
}
|
||
|
|
} else if (d != null) {
|
||
|
|
return {
|
||
|
|
"transition-property": theme.transitionProperty?.DEFAULT,
|
||
|
|
"transition-timing-function": theme.easing?.DEFAULT,
|
||
|
|
"transition-duration": theme.duration?.[d] ?? h.time(d)
|
||
|
|
};
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
autocomplete: "transition-$transitionProperty-$duration"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
// timings
|
||
|
|
[
|
||
|
|
/^(?:transition-)?duration-(.+)$/,
|
||
|
|
([, d], { theme }) => ({ "transition-duration": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }),
|
||
|
|
{ autocomplete: ["transition-duration-$duration", "duration-$duration"] }
|
||
|
|
],
|
||
|
|
[
|
||
|
|
/^(?:transition-)?delay-(.+)$/,
|
||
|
|
([, d], { theme }) => ({ "transition-delay": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }),
|
||
|
|
{ autocomplete: ["transition-delay-$duration", "delay-$duration"] }
|
||
|
|
],
|
||
|
|
[
|
||
|
|
/^(?:transition-)?ease(?:-(.+))?$/,
|
||
|
|
([, d], { theme }) => ({ "transition-timing-function": theme.easing?.[d || "DEFAULT"] ?? h.bracket.cssvar(d) }),
|
||
|
|
{ autocomplete: ["transition-ease-(linear|in|out|in-out|DEFAULT)", "ease-(linear|in|out|in-out|DEFAULT)"] }
|
||
|
|
],
|
||
|
|
// props
|
||
|
|
[
|
||
|
|
/^(?:transition-)?property-(.+)$/,
|
||
|
|
([, v], { theme }) => {
|
||
|
|
const p = h.global(v) || resolveTransitionProperty(v, theme);
|
||
|
|
if (p)
|
||
|
|
return { "transition-property": p };
|
||
|
|
},
|
||
|
|
{ autocomplete: [
|
||
|
|
`transition-property-(${[...globalKeywords].join("|")})`,
|
||
|
|
"transition-property-$transitionProperty",
|
||
|
|
"property-$transitionProperty"
|
||
|
|
] }
|
||
|
|
],
|
||
|
|
// none
|
||
|
|
["transition-none", { transition: "none" }],
|
||
|
|
...makeGlobalStaticRules("transition"),
|
||
|
|
// behavior
|
||
|
|
["transition-discrete", { "transition-behavior": "allow-discrete" }],
|
||
|
|
["transition-normal", { "transition-behavior": "normal" }]
|
||
|
|
];
|
||
|
|
|
||
|
|
const fonts = [
|
||
|
|
// text
|
||
|
|
[/^text-(.+)$/, handleText, { autocomplete: "text-$fontSize" }],
|
||
|
|
// text size
|
||
|
|
[/^(?:text|font)-size-(.+)$/, handleSize, { autocomplete: "text-size-$fontSize" }],
|
||
|
|
// text colors
|
||
|
|
[/^text-(?:color-)?(.+)$/, handlerColorOrSize, { autocomplete: "text-$colors" }],
|
||
|
|
// colors
|
||
|
|
[/^(?:color|c)-(.+)$/, colorResolver("color", "text", "textColor"), { autocomplete: "(color|c)-$colors" }],
|
||
|
|
// style
|
||
|
|
[/^(?:text|color|c)-(.+)$/, ([, v]) => globalKeywords.includes(v) ? { color: v } : void 0, { autocomplete: `(text|color|c)-(${globalKeywords.join("|")})` }],
|
||
|
|
// opacity
|
||
|
|
[/^(?:text|color|c)-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-text-opacity": h.bracket.percent.cssvar(opacity) }), { autocomplete: "(text|color|c)-(op|opacity)-<percent>" }],
|
||
|
|
// weights
|
||
|
|
[
|
||
|
|
/^(?:font|fw)-?([^-]+)$/,
|
||
|
|
([, s], { theme }) => ({ "font-weight": theme.fontWeight?.[s] || h.bracket.global.number(s) }),
|
||
|
|
{
|
||
|
|
autocomplete: [
|
||
|
|
"(font|fw)-(100|200|300|400|500|600|700|800|900)",
|
||
|
|
"(font|fw)-$fontWeight"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
// leadings
|
||
|
|
[
|
||
|
|
/^(?:font-)?(?:leading|lh|line-height)-(.+)$/,
|
||
|
|
([, s], { theme }) => ({ "line-height": handleThemeByKey(s, theme, "lineHeight") }),
|
||
|
|
{ autocomplete: "(leading|lh|line-height)-$lineHeight" }
|
||
|
|
],
|
||
|
|
// synthesis
|
||
|
|
["font-synthesis-weight", { "font-synthesis": "weight" }],
|
||
|
|
["font-synthesis-style", { "font-synthesis": "style" }],
|
||
|
|
["font-synthesis-small-caps", { "font-synthesis": "small-caps" }],
|
||
|
|
["font-synthesis-none", { "font-synthesis": "none" }],
|
||
|
|
[/^font-synthesis-(.+)$/, ([, s]) => ({ "font-synthesis": h.bracket.cssvar.global(s) })],
|
||
|
|
// tracking
|
||
|
|
[
|
||
|
|
/^(?:font-)?tracking-(.+)$/,
|
||
|
|
([, s], { theme }) => ({ "letter-spacing": theme.letterSpacing?.[s] || h.bracket.cssvar.global.rem(s) }),
|
||
|
|
{ autocomplete: "tracking-$letterSpacing" }
|
||
|
|
],
|
||
|
|
// word-spacing
|
||
|
|
[
|
||
|
|
/^(?:font-)?word-spacing-(.+)$/,
|
||
|
|
([, s], { theme }) => ({ "word-spacing": theme.wordSpacing?.[s] || h.bracket.cssvar.global.rem(s) }),
|
||
|
|
{ autocomplete: "word-spacing-$wordSpacing" }
|
||
|
|
],
|
||
|
|
// stretch
|
||
|
|
["font-stretch-normal", { "font-stretch": "normal" }],
|
||
|
|
["font-stretch-ultra-condensed", { "font-stretch": "ultra-condensed" }],
|
||
|
|
["font-stretch-extra-condensed", { "font-stretch": "extra-condensed" }],
|
||
|
|
["font-stretch-condensed", { "font-stretch": "condensed" }],
|
||
|
|
["font-stretch-semi-condensed", { "font-stretch": "semi-condensed" }],
|
||
|
|
["font-stretch-semi-expanded", { "font-stretch": "semi-expanded" }],
|
||
|
|
["font-stretch-expanded", { "font-stretch": "expanded" }],
|
||
|
|
["font-stretch-extra-expanded", { "font-stretch": "extra-expanded" }],
|
||
|
|
["font-stretch-ultra-expanded", { "font-stretch": "ultra-expanded" }],
|
||
|
|
[
|
||
|
|
/^font-stretch-(.+)$/,
|
||
|
|
([, s]) => ({ "font-stretch": h.bracket.cssvar.fraction.global(s) }),
|
||
|
|
{ autocomplete: "font-stretch-<percentage>" }
|
||
|
|
],
|
||
|
|
// family
|
||
|
|
[
|
||
|
|
/^font-(.+)$/,
|
||
|
|
([, d], { theme }) => ({ "font-family": theme.fontFamily?.[d] || h.bracket.cssvar.global(d) }),
|
||
|
|
{ autocomplete: "font-$fontFamily" }
|
||
|
|
]
|
||
|
|
];
|
||
|
|
const tabSizes = [
|
||
|
|
[/^tab(?:-(.+))?$/, ([, s]) => {
|
||
|
|
const v = h.bracket.cssvar.global.number(s || "4");
|
||
|
|
if (v != null) {
|
||
|
|
return {
|
||
|
|
"-moz-tab-size": v,
|
||
|
|
"-o-tab-size": v,
|
||
|
|
"tab-size": v
|
||
|
|
};
|
||
|
|
}
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
const textIndents = [
|
||
|
|
[/^indent(?:-(.+))?$/, ([, s], { theme }) => ({ "text-indent": theme.textIndent?.[s || "DEFAULT"] || h.bracket.cssvar.global.fraction.rem(s) }), { autocomplete: "indent-$textIndent" }]
|
||
|
|
];
|
||
|
|
const textStrokes = [
|
||
|
|
// widths
|
||
|
|
[/^text-stroke(?:-(.+))?$/, ([, s], { theme }) => ({ "-webkit-text-stroke-width": theme.textStrokeWidth?.[s || "DEFAULT"] || h.bracket.cssvar.px(s) }), { autocomplete: "text-stroke-$textStrokeWidth" }],
|
||
|
|
// colors
|
||
|
|
[/^text-stroke-(.+)$/, colorResolver("-webkit-text-stroke-color", "text-stroke", "borderColor"), { autocomplete: "text-stroke-$colors" }],
|
||
|
|
[/^text-stroke-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-text-stroke-opacity": h.bracket.percent.cssvar(opacity) }), { autocomplete: "text-stroke-(op|opacity)-<percent>" }]
|
||
|
|
];
|
||
|
|
const textShadows = [
|
||
|
|
[/^text-shadow(?:-(.+))?$/, ([, s], { theme }) => {
|
||
|
|
const v = theme.textShadow?.[s || "DEFAULT"];
|
||
|
|
if (v != null) {
|
||
|
|
return {
|
||
|
|
"--un-text-shadow": colorableShadows(v, "--un-text-shadow-color").join(","),
|
||
|
|
"text-shadow": "var(--un-text-shadow)"
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return { "text-shadow": h.bracket.cssvar.global(s) };
|
||
|
|
}, { autocomplete: "text-shadow-$textShadow" }],
|
||
|
|
// colors
|
||
|
|
[/^text-shadow-color-(.+)$/, colorResolver("--un-text-shadow-color", "text-shadow", "shadowColor"), { autocomplete: "text-shadow-color-$colors" }],
|
||
|
|
[/^text-shadow-color-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-text-shadow-opacity": h.bracket.percent.cssvar(opacity) }), { autocomplete: "text-shadow-color-(op|opacity)-<percent>" }]
|
||
|
|
];
|
||
|
|
function handleThemeByKey(s, theme, key) {
|
||
|
|
return theme[key]?.[s] || h.bracket.cssvar.global.rem(s);
|
||
|
|
}
|
||
|
|
function handleSize([, s], { theme }) {
|
||
|
|
const themed = toArray(theme.fontSize?.[s]);
|
||
|
|
const size = themed?.[0] ?? h.bracket.cssvar.global.rem(s);
|
||
|
|
if (size != null)
|
||
|
|
return { "font-size": size };
|
||
|
|
}
|
||
|
|
function handlerColorOrSize(match, ctx) {
|
||
|
|
if (isCSSMathFn(h.bracket(match[1])))
|
||
|
|
return handleSize(match, ctx);
|
||
|
|
return colorResolver("color", "text", "textColor")(match, ctx);
|
||
|
|
}
|
||
|
|
function handleText([, s = "base"], { theme }) {
|
||
|
|
const split = splitShorthand(s, "length");
|
||
|
|
if (!split)
|
||
|
|
return;
|
||
|
|
const [size, leading] = split;
|
||
|
|
const sizePairs = toArray(theme.fontSize?.[size]);
|
||
|
|
const lineHeight = leading ? handleThemeByKey(leading, theme, "lineHeight") : void 0;
|
||
|
|
if (sizePairs?.[0]) {
|
||
|
|
const [fontSize2, height, letterSpacing] = sizePairs;
|
||
|
|
if (typeof height === "object") {
|
||
|
|
return {
|
||
|
|
"font-size": fontSize2,
|
||
|
|
...height
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return {
|
||
|
|
"font-size": fontSize2,
|
||
|
|
"line-height": lineHeight ?? height ?? "1",
|
||
|
|
"letter-spacing": letterSpacing ? handleThemeByKey(letterSpacing, theme, "letterSpacing") : void 0
|
||
|
|
};
|
||
|
|
}
|
||
|
|
const fontSize = h.bracketOfLength.rem(size);
|
||
|
|
if (lineHeight && fontSize) {
|
||
|
|
return {
|
||
|
|
"font-size": fontSize,
|
||
|
|
"line-height": lineHeight
|
||
|
|
};
|
||
|
|
}
|
||
|
|
return { "font-size": h.bracketOfLength.rem(s) };
|
||
|
|
}
|
||
|
|
|
||
|
|
const variablesAbbrMap = {
|
||
|
|
backface: "backface-visibility",
|
||
|
|
break: "word-break",
|
||
|
|
case: "text-transform",
|
||
|
|
content: "align-content",
|
||
|
|
fw: "font-weight",
|
||
|
|
items: "align-items",
|
||
|
|
justify: "justify-content",
|
||
|
|
select: "user-select",
|
||
|
|
self: "align-self",
|
||
|
|
vertical: "vertical-align",
|
||
|
|
visible: "visibility",
|
||
|
|
whitespace: "white-space",
|
||
|
|
ws: "white-space"
|
||
|
|
};
|
||
|
|
const cssVariables = [
|
||
|
|
[/^(.+?)-(\$.+)$/, ([, name, varname]) => {
|
||
|
|
const prop = variablesAbbrMap[name];
|
||
|
|
if (prop)
|
||
|
|
return { [prop]: h.cssvar(varname) };
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
const cssProperty = [
|
||
|
|
[/^\[(.*)\]$/, ([_, body]) => {
|
||
|
|
if (!body.includes(":"))
|
||
|
|
return;
|
||
|
|
const [prop, ...rest] = body.split(":");
|
||
|
|
const value = rest.join(":");
|
||
|
|
if (!isURI(body) && /^[a-z-]+$/.test(prop) && isValidCSSBody(value)) {
|
||
|
|
const parsed = h.bracket(`[${value}]`);
|
||
|
|
if (parsed)
|
||
|
|
return { [prop]: parsed };
|
||
|
|
}
|
||
|
|
}]
|
||
|
|
];
|
||
|
|
function isValidCSSBody(body) {
|
||
|
|
let i = 0;
|
||
|
|
function findUntil(c) {
|
||
|
|
while (i < body.length) {
|
||
|
|
i += 1;
|
||
|
|
const char = body[i];
|
||
|
|
if (char === c)
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
for (i = 0; i < body.length; i++) {
|
||
|
|
const c = body[i];
|
||
|
|
if ("\"`'".includes(c)) {
|
||
|
|
if (!findUntil(c))
|
||
|
|
return false;
|
||
|
|
} else if (c === "(") {
|
||
|
|
if (!findUntil(")"))
|
||
|
|
return false;
|
||
|
|
} else if ("[]{}:".includes(c)) {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
function isURI(declaration) {
|
||
|
|
if (!declaration.includes("://"))
|
||
|
|
return false;
|
||
|
|
try {
|
||
|
|
return new URL(declaration).host !== "";
|
||
|
|
} catch {
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
const rules = [
|
||
|
|
cssVariables,
|
||
|
|
cssProperty,
|
||
|
|
contains,
|
||
|
|
pointerEvents,
|
||
|
|
appearances,
|
||
|
|
positions,
|
||
|
|
insets,
|
||
|
|
zIndexes,
|
||
|
|
orders,
|
||
|
|
grids,
|
||
|
|
floats,
|
||
|
|
margins,
|
||
|
|
boxSizing,
|
||
|
|
displays,
|
||
|
|
aspectRatio,
|
||
|
|
sizes,
|
||
|
|
flex,
|
||
|
|
transforms,
|
||
|
|
cursors,
|
||
|
|
userSelects,
|
||
|
|
resizes,
|
||
|
|
appearance,
|
||
|
|
placements,
|
||
|
|
alignments,
|
||
|
|
justifies,
|
||
|
|
gaps,
|
||
|
|
flexGridJustifiesAlignments,
|
||
|
|
overflows,
|
||
|
|
textOverflows,
|
||
|
|
whitespaces,
|
||
|
|
breaks,
|
||
|
|
borders,
|
||
|
|
bgColors,
|
||
|
|
colorScheme,
|
||
|
|
svgUtilities,
|
||
|
|
paddings,
|
||
|
|
textAligns,
|
||
|
|
textIndents,
|
||
|
|
textWraps,
|
||
|
|
verticalAligns,
|
||
|
|
fonts,
|
||
|
|
textTransforms,
|
||
|
|
fontStyles,
|
||
|
|
textDecorations,
|
||
|
|
fontSmoothings,
|
||
|
|
tabSizes,
|
||
|
|
textStrokes,
|
||
|
|
textShadows,
|
||
|
|
opacity,
|
||
|
|
boxShadows,
|
||
|
|
outline,
|
||
|
|
rings,
|
||
|
|
transitions,
|
||
|
|
willChange,
|
||
|
|
contentVisibility,
|
||
|
|
contents,
|
||
|
|
containerParent,
|
||
|
|
// should be the last
|
||
|
|
questionMark
|
||
|
|
].flat(1);
|
||
|
|
|
||
|
|
export { zIndexes as A, boxSizing as B, questionMark as C, sizes as D, aspectRatio as E, paddings as F, margins as G, svgUtilities as H, transitions as I, fonts as J, tabSizes as K, textIndents as L, textStrokes as M, textShadows as N, cssVariables as O, cssProperty as P, appearance as a, borderStyles as b, borders as c, opacity as d, bgColors as e, colorScheme as f, containerParent as g, handlerBorderStyle as h, textDecorations as i, flex as j, gaps as k, grids as l, overflows as m, justifies as n, outline as o, positions as p, orders as q, rules as r, alignments as s, textAligns as t, placements as u, verticalAligns as v, willChange as w, flexGridJustifiesAlignments as x, insets as y, floats as z };
|