635 lines
25 KiB
JavaScript
635 lines
25 KiB
JavaScript
import * as _ from '@unocss/preset-mini/rules';
|
|
import { borderStyles } from '@unocss/preset-mini/rules';
|
|
import { h, globalKeywords, makeGlobalStaticRules, positionMap, parseColor, colorResolver, directionMap } from '@unocss/preset-mini/utils';
|
|
import { colorToString, colorOpacityToString } from '@unocss/rule-utils';
|
|
import { c as container } from './preset-wind.BzmnsdqZ.mjs';
|
|
import { t as tables, g as touchActions, c as scrolls, i as fontVariantNumeric, a as filters } from './preset-wind.DjKJQ_OR.mjs';
|
|
|
|
const animations = [
|
|
[/^(?:animate-)?keyframes-(.+)$/, ([, name], { theme }) => {
|
|
const kf = theme.animation?.keyframes?.[name];
|
|
if (kf) {
|
|
return [
|
|
`@keyframes ${name}${kf}`,
|
|
{ animation: name }
|
|
];
|
|
}
|
|
}, { autocomplete: ["animate-keyframes-$animation.keyframes", "keyframes-$animation.keyframes"] }],
|
|
[/^animate-(.+)$/, ([, name], { theme }) => {
|
|
const kf = theme.animation?.keyframes?.[name];
|
|
if (kf) {
|
|
const duration = theme.animation?.durations?.[name] ?? "1s";
|
|
const timing = theme.animation?.timingFns?.[name] ?? "linear";
|
|
const count = theme.animation?.counts?.[name] ?? 1;
|
|
const props = theme.animation?.properties?.[name];
|
|
return [
|
|
`@keyframes ${name}${kf}`,
|
|
{
|
|
animation: `${name} ${duration} ${timing} ${count}`,
|
|
...props
|
|
}
|
|
];
|
|
}
|
|
return { animation: h.bracket.cssvar(name) };
|
|
}, { autocomplete: "animate-$animation.keyframes" }],
|
|
[/^animate-name-(.+)/, ([, d]) => ({ "animation-name": h.bracket.cssvar(d) ?? d })],
|
|
// timings
|
|
[/^animate-duration-(.+)$/, ([, d], { theme }) => ({ "animation-duration": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }), { autocomplete: ["animate-duration", "animate-duration-$duration"] }],
|
|
[/^animate-delay-(.+)$/, ([, d], { theme }) => ({ "animation-delay": theme.duration?.[d || "DEFAULT"] ?? h.bracket.cssvar.time(d) }), { autocomplete: ["animate-delay", "animate-delay-$duration"] }],
|
|
[/^animate-ease(?:-(.+))?$/, ([, d], { theme }) => ({ "animation-timing-function": theme.easing?.[d || "DEFAULT"] ?? h.bracket.cssvar(d) }), { autocomplete: ["animate-ease", "animate-ease-$easing"] }],
|
|
// fill mode
|
|
[/^animate-(fill-mode-|fill-|mode-)?(.+)$/, ([, t, d]) => ["none", "forwards", "backwards", "both", ...[t ? globalKeywords : []]].includes(d) ? { "animation-fill-mode": d } : void 0, {
|
|
autocomplete: [
|
|
"animate-(fill|mode|fill-mode)",
|
|
"animate-(fill|mode|fill-mode)-(none|forwards|backwards|both|inherit|initial|revert|revert-layer|unset)",
|
|
"animate-(none|forwards|backwards|both|inherit|initial|revert|revert-layer|unset)"
|
|
]
|
|
}],
|
|
// direction
|
|
[/^animate-(direction-)?(.+)$/, ([, t, d]) => ["normal", "reverse", "alternate", "alternate-reverse", ...[t ? globalKeywords : []]].includes(d) ? { "animation-direction": d } : void 0, {
|
|
autocomplete: [
|
|
"animate-direction",
|
|
"animate-direction-(normal|reverse|alternate|alternate-reverse|inherit|initial|revert|revert-layer|unset)",
|
|
"animate-(normal|reverse|alternate|alternate-reverse|inherit|initial|revert|revert-layer|unset)"
|
|
]
|
|
}],
|
|
// others
|
|
[/^animate-(?:iteration-count-|iteration-|count-)(.+)$/, ([, d]) => ({ "animation-iteration-count": h.bracket.cssvar(d) ?? d.replace(/-/g, ",") }), { autocomplete: ["animate-(iteration|count|iteration-count)", "animate-(iteration|count|iteration-count)-<num>"] }],
|
|
[/^animate-(play-state-|play-|state-)?(.+)$/, ([, t, d]) => ["paused", "running", ...[t ? globalKeywords : []]].includes(d) ? { "animation-play-state": d } : void 0, {
|
|
autocomplete: [
|
|
"animate-(play|state|play-state)",
|
|
"animate-(play|state|play-state)-(paused|running|inherit|initial|revert|revert-layer|unset)",
|
|
"animate-(paused|running|inherit|initial|revert|revert-layer|unset)"
|
|
]
|
|
}],
|
|
["animate-none", { animation: "none" }],
|
|
...makeGlobalStaticRules("animate", "animation")
|
|
];
|
|
|
|
function bgGradientToValue(cssColor) {
|
|
if (cssColor)
|
|
return colorToString(cssColor, 0);
|
|
return "rgb(255 255 255 / 0)";
|
|
}
|
|
function bgGradientColorValue(mode, cssColor, color, alpha) {
|
|
if (cssColor) {
|
|
if (alpha != null)
|
|
return colorToString(cssColor, alpha);
|
|
else
|
|
return colorToString(cssColor, `var(--un-${mode}-opacity, ${colorOpacityToString(cssColor)})`);
|
|
}
|
|
return colorToString(color, alpha);
|
|
}
|
|
function bgGradientColorResolver() {
|
|
return ([, mode, body], { theme }) => {
|
|
const data = parseColor(body, theme, "backgroundColor");
|
|
if (!data)
|
|
return;
|
|
const { alpha, color, cssColor } = data;
|
|
if (!color)
|
|
return;
|
|
const colorString = bgGradientColorValue(mode, cssColor, color, alpha);
|
|
switch (mode) {
|
|
case "from":
|
|
return {
|
|
"--un-gradient-from-position": "0%",
|
|
"--un-gradient-from": `${colorString} var(--un-gradient-from-position)`,
|
|
"--un-gradient-to-position": "100%",
|
|
"--un-gradient-to": `${bgGradientToValue(cssColor)} var(--un-gradient-to-position)`,
|
|
"--un-gradient-stops": "var(--un-gradient-from), var(--un-gradient-to)"
|
|
};
|
|
case "via":
|
|
return {
|
|
"--un-gradient-via-position": "50%",
|
|
"--un-gradient-to": bgGradientToValue(cssColor),
|
|
"--un-gradient-stops": `var(--un-gradient-from), ${colorString} var(--un-gradient-via-position), var(--un-gradient-to)`
|
|
};
|
|
case "to":
|
|
return {
|
|
"--un-gradient-to-position": "100%",
|
|
"--un-gradient-to": `${colorString} var(--un-gradient-to-position)`
|
|
};
|
|
}
|
|
};
|
|
}
|
|
function bgGradientPositionResolver() {
|
|
return ([, mode, body]) => {
|
|
return {
|
|
[`--un-gradient-${mode}-position`]: `${Number(h.bracket.cssvar.percent(body)) * 100}%`
|
|
};
|
|
};
|
|
}
|
|
const backgroundStyles = [
|
|
// gradients
|
|
[/^bg-gradient-(.+)$/, ([, d]) => ({ "--un-gradient": h.bracket(d) }), {
|
|
autocomplete: ["bg-gradient", "bg-gradient-(from|to|via)", "bg-gradient-(from|to|via)-$colors", "bg-gradient-(from|to|via)-(op|opacity)", "bg-gradient-(from|to|via)-(op|opacity)-<percent>"]
|
|
}],
|
|
[/^(?:bg-gradient-)?stops-(\[.+\])$/, ([, s]) => ({ "--un-gradient-stops": h.bracket(s) })],
|
|
[/^(?:bg-gradient-)?(from)-(.+)$/, bgGradientColorResolver()],
|
|
[/^(?:bg-gradient-)?(via)-(.+)$/, bgGradientColorResolver()],
|
|
[/^(?:bg-gradient-)?(to)-(.+)$/, bgGradientColorResolver()],
|
|
[/^(?:bg-gradient-)?(from|via|to)-op(?:acity)?-?(.+)$/, ([, position, opacity]) => ({ [`--un-${position}-opacity`]: h.bracket.percent(opacity) })],
|
|
[/^(from|via|to)-([\d.]+)%$/, bgGradientPositionResolver()],
|
|
// images
|
|
[/^bg-gradient-((?:repeating-)?(?:linear|radial|conic))$/, ([, s]) => ({
|
|
"background-image": `${s}-gradient(var(--un-gradient, var(--un-gradient-stops, rgb(255 255 255 / 0))))`
|
|
}), { autocomplete: ["bg-gradient-repeating", "bg-gradient-(linear|radial|conic)", "bg-gradient-repeating-(linear|radial|conic)"] }],
|
|
// ignore any center position
|
|
[/^bg-gradient-to-([rltb]{1,2})$/, ([, d]) => {
|
|
if (d in positionMap) {
|
|
return {
|
|
"--un-gradient-shape": `to ${positionMap[d]} in oklch`,
|
|
"--un-gradient": "var(--un-gradient-shape), var(--un-gradient-stops)",
|
|
"background-image": "linear-gradient(var(--un-gradient))"
|
|
};
|
|
}
|
|
}, { autocomplete: `bg-gradient-to-(${Object.keys(positionMap).filter((k) => k.length <= 2 && Array.from(k).every((c) => "rltb".includes(c))).join("|")})` }],
|
|
[/^(?:bg-gradient-)?shape-(.+)$/, ([, d]) => {
|
|
const v = d in positionMap ? `to ${positionMap[d]}` : h.bracket(d);
|
|
if (v != null) {
|
|
return {
|
|
"--un-gradient-shape": `${v} in oklch`,
|
|
"--un-gradient": "var(--un-gradient-shape), var(--un-gradient-stops)"
|
|
};
|
|
}
|
|
}, { autocomplete: ["bg-gradient-shape", `bg-gradient-shape-(${Object.keys(positionMap).join("|")})`, `shape-(${Object.keys(positionMap).join("|")})`] }],
|
|
["bg-none", { "background-image": "none" }],
|
|
["box-decoration-slice", { "box-decoration-break": "slice" }],
|
|
["box-decoration-clone", { "box-decoration-break": "clone" }],
|
|
...makeGlobalStaticRules("box-decoration", "box-decoration-break"),
|
|
// size
|
|
["bg-auto", { "background-size": "auto" }],
|
|
["bg-cover", { "background-size": "cover" }],
|
|
["bg-contain", { "background-size": "contain" }],
|
|
// attachments
|
|
["bg-fixed", { "background-attachment": "fixed" }],
|
|
["bg-local", { "background-attachment": "local" }],
|
|
["bg-scroll", { "background-attachment": "scroll" }],
|
|
// clips
|
|
["bg-clip-border", { "-webkit-background-clip": "border-box", "background-clip": "border-box" }],
|
|
["bg-clip-content", { "-webkit-background-clip": "content-box", "background-clip": "content-box" }],
|
|
["bg-clip-padding", { "-webkit-background-clip": "padding-box", "background-clip": "padding-box" }],
|
|
["bg-clip-text", { "-webkit-background-clip": "text", "background-clip": "text" }],
|
|
...globalKeywords.map((keyword) => [`bg-clip-${keyword}`, {
|
|
"-webkit-background-clip": keyword,
|
|
"background-clip": keyword
|
|
}]),
|
|
// positions
|
|
// skip 1 & 2 letters shortcut
|
|
[/^bg-([-\w]{3,})$/, ([, s]) => ({ "background-position": positionMap[s] })],
|
|
// repeats
|
|
["bg-repeat", { "background-repeat": "repeat" }],
|
|
["bg-no-repeat", { "background-repeat": "no-repeat" }],
|
|
["bg-repeat-x", { "background-repeat": "repeat-x" }],
|
|
["bg-repeat-y", { "background-repeat": "repeat-y" }],
|
|
["bg-repeat-round", { "background-repeat": "round" }],
|
|
["bg-repeat-space", { "background-repeat": "space" }],
|
|
...makeGlobalStaticRules("bg-repeat", "background-repeat"),
|
|
// origins
|
|
["bg-origin-border", { "background-origin": "border-box" }],
|
|
["bg-origin-padding", { "background-origin": "padding-box" }],
|
|
["bg-origin-content", { "background-origin": "content-box" }],
|
|
...makeGlobalStaticRules("bg-origin", "background-origin")
|
|
];
|
|
|
|
const listStyles = {
|
|
"disc": "disc",
|
|
"circle": "circle",
|
|
"square": "square",
|
|
"decimal": "decimal",
|
|
"zero-decimal": "decimal-leading-zero",
|
|
"greek": "lower-greek",
|
|
"roman": "lower-roman",
|
|
"upper-roman": "upper-roman",
|
|
"alpha": "lower-alpha",
|
|
"upper-alpha": "upper-alpha",
|
|
"latin": "lower-latin",
|
|
"upper-latin": "upper-latin"
|
|
};
|
|
const listStyle = [
|
|
// base
|
|
[/^list-(.+?)(?:-(outside|inside))?$/, ([, alias, position]) => {
|
|
const style = listStyles[alias];
|
|
if (style) {
|
|
if (position) {
|
|
return {
|
|
"list-style-position": position,
|
|
"list-style-type": style
|
|
};
|
|
}
|
|
return { "list-style-type": style };
|
|
}
|
|
}, { autocomplete: [`list-(${Object.keys(listStyles).join("|")})`, `list-(${Object.keys(listStyles).join("|")})-(outside|inside)`] }],
|
|
// styles
|
|
["list-outside", { "list-style-position": "outside" }],
|
|
["list-inside", { "list-style-position": "inside" }],
|
|
["list-none", { "list-style-type": "none" }],
|
|
// image
|
|
[/^list-image-(.+)$/, ([, d]) => {
|
|
if (/^\[url\(.+\)\]$/.test(d))
|
|
return { "list-style-image": h.bracket(d) };
|
|
}],
|
|
["list-image-none", { "list-style-image": "none" }],
|
|
...makeGlobalStaticRules("list", "list-style-type")
|
|
];
|
|
const accents = [
|
|
[/^accent-(.+)$/, colorResolver("accent-color", "accent", "accentColor"), { autocomplete: "accent-$colors" }],
|
|
[/^accent-op(?:acity)?-?(.+)$/, ([, d]) => ({ "--un-accent-opacity": h.bracket.percent(d) }), { autocomplete: ["accent-(op|opacity)", "accent-(op|opacity)-<percent>"] }]
|
|
];
|
|
const carets = [
|
|
[/^caret-(.+)$/, colorResolver("caret-color", "caret", "textColor"), { autocomplete: "caret-$colors" }],
|
|
[/^caret-op(?:acity)?-?(.+)$/, ([, d]) => ({ "--un-caret-opacity": h.bracket.percent(d) }), { autocomplete: ["caret-(op|opacity)", "caret-(op|opacity)-<percent>"] }]
|
|
];
|
|
const imageRenderings = [
|
|
["image-render-auto", { "image-rendering": "auto" }],
|
|
["image-render-edge", { "image-rendering": "crisp-edges" }],
|
|
["image-render-pixel", [
|
|
["-ms-interpolation-mode", "nearest-neighbor"],
|
|
["image-rendering", "-webkit-optimize-contrast"],
|
|
["image-rendering", "-moz-crisp-edges"],
|
|
["image-rendering", "-o-pixelated"],
|
|
["image-rendering", "pixelated"]
|
|
]]
|
|
];
|
|
const overscrolls = [
|
|
["overscroll-auto", { "overscroll-behavior": "auto" }],
|
|
["overscroll-contain", { "overscroll-behavior": "contain" }],
|
|
["overscroll-none", { "overscroll-behavior": "none" }],
|
|
...makeGlobalStaticRules("overscroll", "overscroll-behavior"),
|
|
["overscroll-x-auto", { "overscroll-behavior-x": "auto" }],
|
|
["overscroll-x-contain", { "overscroll-behavior-x": "contain" }],
|
|
["overscroll-x-none", { "overscroll-behavior-x": "none" }],
|
|
...makeGlobalStaticRules("overscroll-x", "overscroll-behavior-x"),
|
|
["overscroll-y-auto", { "overscroll-behavior-y": "auto" }],
|
|
["overscroll-y-contain", { "overscroll-behavior-y": "contain" }],
|
|
["overscroll-y-none", { "overscroll-behavior-y": "none" }],
|
|
...makeGlobalStaticRules("overscroll-y", "overscroll-behavior-y")
|
|
];
|
|
const scrollBehaviors = [
|
|
["scroll-auto", { "scroll-behavior": "auto" }],
|
|
["scroll-smooth", { "scroll-behavior": "smooth" }],
|
|
...makeGlobalStaticRules("scroll", "scroll-behavior")
|
|
];
|
|
|
|
const columns = [
|
|
[/^columns-(.+)$/, ([, v]) => ({ columns: h.bracket.global.number.auto.numberWithUnit(v) }), { autocomplete: "columns-<num>" }],
|
|
// break before
|
|
["break-before-auto", { "break-before": "auto" }],
|
|
["break-before-avoid", { "break-before": "avoid" }],
|
|
["break-before-all", { "break-before": "all" }],
|
|
["break-before-avoid-page", { "break-before": "avoid-page" }],
|
|
["break-before-page", { "break-before": "page" }],
|
|
["break-before-left", { "break-before": "left" }],
|
|
["break-before-right", { "break-before": "right" }],
|
|
["break-before-column", { "break-before": "column" }],
|
|
...makeGlobalStaticRules("break-before"),
|
|
// break inside
|
|
["break-inside-auto", { "break-inside": "auto" }],
|
|
["break-inside-avoid", { "break-inside": "avoid" }],
|
|
["break-inside-avoid-page", { "break-inside": "avoid-page" }],
|
|
["break-inside-avoid-column", { "break-inside": "avoid-column" }],
|
|
...makeGlobalStaticRules("break-inside"),
|
|
// break after
|
|
["break-after-auto", { "break-after": "auto" }],
|
|
["break-after-avoid", { "break-after": "avoid" }],
|
|
["break-after-all", { "break-after": "all" }],
|
|
["break-after-avoid-page", { "break-after": "avoid-page" }],
|
|
["break-after-page", { "break-after": "page" }],
|
|
["break-after-left", { "break-after": "left" }],
|
|
["break-after-right", { "break-after": "right" }],
|
|
["break-after-column", { "break-after": "column" }],
|
|
...makeGlobalStaticRules("break-after")
|
|
];
|
|
|
|
const divides = [
|
|
// divides
|
|
[/^divide-?([xy])$/, handlerDivide, { autocomplete: ["divide-(x|y|block|inline)", "divide-(x|y|block|inline)-reverse", "divide-(x|y|block|inline)-$lineWidth"] }],
|
|
[/^divide-?([xy])-?(.+)$/, handlerDivide],
|
|
[/^divide-?([xy])-reverse$/, ([, d]) => ({ [`--un-divide-${d}-reverse`]: 1 })],
|
|
[/^divide-(block|inline)$/, handlerDivide],
|
|
[/^divide-(block|inline)-(.+)$/, handlerDivide],
|
|
[/^divide-(block|inline)-reverse$/, ([, d]) => ({ [`--un-divide-${d}-reverse`]: 1 })],
|
|
// color & opacity
|
|
[/^divide-(.+)$/, colorResolver("border-color", "divide", "borderColor"), { autocomplete: "divide-$colors" }],
|
|
[/^divide-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-divide-opacity": h.bracket.percent(opacity) }), { autocomplete: ["divide-(op|opacity)", "divide-(op|opacity)-<percent>"] }],
|
|
// styles
|
|
...borderStyles.map((style) => [`divide-${style}`, { "border-style": style }])
|
|
];
|
|
function handlerDivide([, d, s], { theme }) {
|
|
let v = theme.lineWidth?.[s || "DEFAULT"] ?? h.bracket.cssvar.px(s || "1");
|
|
if (v != null) {
|
|
if (v === "0")
|
|
v = "0px";
|
|
const results = directionMap[d].map((item) => {
|
|
const key = `border${item}-width`;
|
|
const value = item.endsWith("right") || item.endsWith("bottom") ? `calc(${v} * var(--un-divide-${d}-reverse))` : `calc(${v} * calc(1 - var(--un-divide-${d}-reverse)))`;
|
|
return [key, value];
|
|
});
|
|
if (results) {
|
|
return [
|
|
[`--un-divide-${d}-reverse`, 0],
|
|
...results
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
const lineClamps = [
|
|
[/^line-clamp-(\d+)$/, ([, v]) => ({
|
|
"overflow": "hidden",
|
|
"display": "-webkit-box",
|
|
"-webkit-box-orient": "vertical",
|
|
"-webkit-line-clamp": v,
|
|
"line-clamp": v
|
|
}), { autocomplete: ["line-clamp", "line-clamp-<num>"] }],
|
|
...["none", ...globalKeywords].map((keyword) => [`line-clamp-${keyword}`, {
|
|
"overflow": "visible",
|
|
"display": "block",
|
|
"-webkit-box-orient": "horizontal",
|
|
"-webkit-line-clamp": keyword,
|
|
"line-clamp": keyword
|
|
}])
|
|
];
|
|
|
|
const placeholders = [
|
|
// The prefix `$ ` is intentional. This rule is not to be matched directly from user-generated token.
|
|
// See variants/placeholder.
|
|
[/^\$ placeholder-(.+)$/, colorResolver("color", "placeholder", "accentColor"), { autocomplete: "placeholder-$colors" }],
|
|
[/^\$ placeholder-op(?:acity)?-?(.+)$/, ([, opacity]) => ({ "--un-placeholder-opacity": h.bracket.percent(opacity) }), { autocomplete: ["placeholder-(op|opacity)", "placeholder-(op|opacity)-<percent>"] }]
|
|
];
|
|
|
|
const spaces = [
|
|
[/^space-([xy])-(.+)$/, handlerSpace, { autocomplete: ["space-(x|y|block|inline)", "space-(x|y|block|inline)-reverse", "space-(x|y|block|inline)-$spacing"] }],
|
|
[/^space-([xy])-reverse$/, ([, d]) => ({ [`--un-space-${d}-reverse`]: 1 })],
|
|
[/^space-(block|inline)-(.+)$/, handlerSpace],
|
|
[/^space-(block|inline)-reverse$/, ([, d]) => ({ [`--un-space-${d}-reverse`]: 1 })]
|
|
];
|
|
function handlerSpace([, d, s], { theme }) {
|
|
let v = theme.spacing?.[s || "DEFAULT"] ?? h.bracket.cssvar.auto.fraction.rem(s || "1");
|
|
if (v != null) {
|
|
if (v === "0")
|
|
v = "0px";
|
|
const results = directionMap[d].map((item) => {
|
|
const key = `margin${item}`;
|
|
const value = item.endsWith("right") || item.endsWith("bottom") ? `calc(${v} * var(--un-space-${d}-reverse))` : `calc(${v} * calc(1 - var(--un-space-${d}-reverse)))`;
|
|
return [key, value];
|
|
});
|
|
if (results) {
|
|
return [
|
|
[`--un-space-${d}-reverse`, 0],
|
|
...results
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
const textTransforms = [
|
|
// tailwind compat
|
|
["uppercase", { "text-transform": "uppercase" }],
|
|
["lowercase", { "text-transform": "lowercase" }],
|
|
["capitalize", { "text-transform": "capitalize" }],
|
|
["normal-case", { "text-transform": "none" }]
|
|
];
|
|
const hyphens = [
|
|
...["manual", "auto", "none", ...globalKeywords].map((keyword) => [`hyphens-${keyword}`, {
|
|
"-webkit-hyphens": keyword,
|
|
"-ms-hyphens": keyword,
|
|
"hyphens": keyword
|
|
}])
|
|
];
|
|
const writingModes = [
|
|
["write-vertical-right", { "writing-mode": "vertical-rl" }],
|
|
["write-vertical-left", { "writing-mode": "vertical-lr" }],
|
|
["write-normal", { "writing-mode": "horizontal-tb" }],
|
|
...makeGlobalStaticRules("write", "writing-mode")
|
|
];
|
|
const writingOrientations = [
|
|
["write-orient-mixed", { "text-orientation": "mixed" }],
|
|
["write-orient-sideways", { "text-orientation": "sideways" }],
|
|
["write-orient-upright", { "text-orientation": "upright" }],
|
|
...makeGlobalStaticRules("write-orient", "text-orientation")
|
|
];
|
|
const screenReadersAccess = [
|
|
[
|
|
"sr-only",
|
|
{
|
|
"position": "absolute",
|
|
"width": "1px",
|
|
"height": "1px",
|
|
"padding": "0",
|
|
"margin": "-1px",
|
|
"overflow": "hidden",
|
|
"clip": "rect(0,0,0,0)",
|
|
"white-space": "nowrap",
|
|
"border-width": 0
|
|
}
|
|
],
|
|
[
|
|
"not-sr-only",
|
|
{
|
|
"position": "static",
|
|
"width": "auto",
|
|
"height": "auto",
|
|
"padding": "0",
|
|
"margin": "0",
|
|
"overflow": "visible",
|
|
"clip": "auto",
|
|
"white-space": "normal"
|
|
}
|
|
]
|
|
];
|
|
const isolations = [
|
|
["isolate", { isolation: "isolate" }],
|
|
["isolate-auto", { isolation: "auto" }],
|
|
["isolation-auto", { isolation: "auto" }]
|
|
];
|
|
const objectPositions = [
|
|
// object fit
|
|
["object-cover", { "object-fit": "cover" }],
|
|
["object-contain", { "object-fit": "contain" }],
|
|
["object-fill", { "object-fit": "fill" }],
|
|
["object-scale-down", { "object-fit": "scale-down" }],
|
|
["object-none", { "object-fit": "none" }],
|
|
// object position
|
|
[/^object-(.+)$/, ([, d]) => {
|
|
if (positionMap[d])
|
|
return { "object-position": positionMap[d] };
|
|
if (h.bracketOfPosition(d) != null)
|
|
return { "object-position": h.bracketOfPosition(d).split(" ").map((e) => h.position.fraction.auto.px.cssvar(e) ?? e).join(" ") };
|
|
}, { autocomplete: `object-(${Object.keys(positionMap).join("|")})` }]
|
|
];
|
|
const backgroundBlendModes = [
|
|
["bg-blend-multiply", { "background-blend-mode": "multiply" }],
|
|
["bg-blend-screen", { "background-blend-mode": "screen" }],
|
|
["bg-blend-overlay", { "background-blend-mode": "overlay" }],
|
|
["bg-blend-darken", { "background-blend-mode": "darken" }],
|
|
["bg-blend-lighten", { "background-blend-mode": "lighten" }],
|
|
["bg-blend-color-dodge", { "background-blend-mode": "color-dodge" }],
|
|
["bg-blend-color-burn", { "background-blend-mode": "color-burn" }],
|
|
["bg-blend-hard-light", { "background-blend-mode": "hard-light" }],
|
|
["bg-blend-soft-light", { "background-blend-mode": "soft-light" }],
|
|
["bg-blend-difference", { "background-blend-mode": "difference" }],
|
|
["bg-blend-exclusion", { "background-blend-mode": "exclusion" }],
|
|
["bg-blend-hue", { "background-blend-mode": "hue" }],
|
|
["bg-blend-saturation", { "background-blend-mode": "saturation" }],
|
|
["bg-blend-color", { "background-blend-mode": "color" }],
|
|
["bg-blend-luminosity", { "background-blend-mode": "luminosity" }],
|
|
["bg-blend-normal", { "background-blend-mode": "normal" }],
|
|
...makeGlobalStaticRules("bg-blend", "background-blend")
|
|
];
|
|
const mixBlendModes = [
|
|
["mix-blend-multiply", { "mix-blend-mode": "multiply" }],
|
|
["mix-blend-screen", { "mix-blend-mode": "screen" }],
|
|
["mix-blend-overlay", { "mix-blend-mode": "overlay" }],
|
|
["mix-blend-darken", { "mix-blend-mode": "darken" }],
|
|
["mix-blend-lighten", { "mix-blend-mode": "lighten" }],
|
|
["mix-blend-color-dodge", { "mix-blend-mode": "color-dodge" }],
|
|
["mix-blend-color-burn", { "mix-blend-mode": "color-burn" }],
|
|
["mix-blend-hard-light", { "mix-blend-mode": "hard-light" }],
|
|
["mix-blend-soft-light", { "mix-blend-mode": "soft-light" }],
|
|
["mix-blend-difference", { "mix-blend-mode": "difference" }],
|
|
["mix-blend-exclusion", { "mix-blend-mode": "exclusion" }],
|
|
["mix-blend-hue", { "mix-blend-mode": "hue" }],
|
|
["mix-blend-saturation", { "mix-blend-mode": "saturation" }],
|
|
["mix-blend-color", { "mix-blend-mode": "color" }],
|
|
["mix-blend-luminosity", { "mix-blend-mode": "luminosity" }],
|
|
["mix-blend-plus-lighter", { "mix-blend-mode": "plus-lighter" }],
|
|
["mix-blend-normal", { "mix-blend-mode": "normal" }],
|
|
...makeGlobalStaticRules("mix-blend")
|
|
];
|
|
const dynamicViewportHeight = [
|
|
["min-h-dvh", { "min-height": "100dvh" }],
|
|
["min-h-svh", { "min-height": "100svh" }],
|
|
["min-h-lvh", { "min-height": "100lvh" }],
|
|
["h-dvh", { height: "100dvh" }],
|
|
["h-svh", { height: "100svh" }],
|
|
["h-lvh", { height: "100lvh" }],
|
|
["max-h-dvh", { "max-height": "100dvh" }],
|
|
["max-h-svh", { "max-height": "100svh" }],
|
|
["max-h-lvh", { "max-height": "100lvh" }]
|
|
];
|
|
|
|
const variablesAbbrMap = {
|
|
"bg-blend": "background-blend-mode",
|
|
"bg-clip": "-webkit-background-clip",
|
|
"bg-gradient": "linear-gradient",
|
|
"bg-image": "background-image",
|
|
"bg-origin": "background-origin",
|
|
"bg-position": "background-position",
|
|
"bg-repeat": "background-repeat",
|
|
"bg-size": "background-size",
|
|
"mix-blend": "mix-blend-mode",
|
|
"object": "object-fit",
|
|
"object-position": "object-position",
|
|
"write": "writing-mode",
|
|
"write-orient": "text-orientation"
|
|
};
|
|
const cssVariables = [
|
|
[/^(.+?)-(\$.+)$/, ([, name, varname]) => {
|
|
const prop = variablesAbbrMap[name];
|
|
if (prop)
|
|
return { [prop]: h.cssvar(varname) };
|
|
}]
|
|
];
|
|
|
|
const viewTransition = [
|
|
[/^view-transition-([\w-]+)$/, ([, name]) => {
|
|
return { "view-transition-name": name };
|
|
}]
|
|
];
|
|
|
|
const rules = [
|
|
_.cssVariables,
|
|
cssVariables,
|
|
_.cssProperty,
|
|
container,
|
|
_.contains,
|
|
screenReadersAccess,
|
|
_.pointerEvents,
|
|
_.appearances,
|
|
_.positions,
|
|
_.insets,
|
|
lineClamps,
|
|
isolations,
|
|
_.zIndexes,
|
|
_.orders,
|
|
_.grids,
|
|
_.floats,
|
|
_.margins,
|
|
_.boxSizing,
|
|
_.displays,
|
|
_.aspectRatio,
|
|
_.sizes,
|
|
_.flex,
|
|
tables,
|
|
_.transforms,
|
|
animations,
|
|
_.cursors,
|
|
touchActions,
|
|
_.userSelects,
|
|
_.resizes,
|
|
scrolls,
|
|
listStyle,
|
|
_.appearance,
|
|
columns,
|
|
_.placements,
|
|
_.alignments,
|
|
_.justifies,
|
|
_.gaps,
|
|
_.flexGridJustifiesAlignments,
|
|
spaces,
|
|
divides,
|
|
_.overflows,
|
|
overscrolls,
|
|
scrollBehaviors,
|
|
_.textOverflows,
|
|
_.whitespaces,
|
|
_.breaks,
|
|
_.borders,
|
|
_.bgColors,
|
|
backgroundStyles,
|
|
_.colorScheme,
|
|
_.svgUtilities,
|
|
objectPositions,
|
|
_.paddings,
|
|
_.textAligns,
|
|
_.textIndents,
|
|
_.textWraps,
|
|
_.verticalAligns,
|
|
_.fonts,
|
|
_.textTransforms,
|
|
textTransforms,
|
|
_.fontStyles,
|
|
fontVariantNumeric,
|
|
_.textDecorations,
|
|
_.fontSmoothings,
|
|
_.tabSizes,
|
|
_.textStrokes,
|
|
_.textShadows,
|
|
hyphens,
|
|
writingModes,
|
|
writingOrientations,
|
|
carets,
|
|
accents,
|
|
_.opacity,
|
|
backgroundBlendModes,
|
|
mixBlendModes,
|
|
_.boxShadows,
|
|
_.outline,
|
|
_.rings,
|
|
imageRenderings,
|
|
filters,
|
|
_.transitions,
|
|
_.willChange,
|
|
_.contentVisibility,
|
|
_.contents,
|
|
placeholders,
|
|
_.containerParent,
|
|
viewTransition,
|
|
dynamicViewportHeight,
|
|
// should be the last
|
|
_.questionMark
|
|
].flat(1);
|
|
|
|
export { animations as a, backgroundStyles as b, accents as c, carets as d, columns as e, divides as f, lineClamps as g, spaces as h, imageRenderings as i, hyphens as j, writingOrientations as k, listStyle as l, screenReadersAccess as m, isolations as n, overscrolls as o, placeholders as p, objectPositions as q, rules as r, scrollBehaviors as s, textTransforms as t, backgroundBlendModes as u, mixBlendModes as v, writingModes as w, dynamicViewportHeight as x, cssVariables as y, viewTransition as z };
|