@birdycom/omniacss-migrate 0.11.0 → 0.11.2
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/LICENSE +21 -21
- package/README.md +129 -129
- package/bin/omniacss-migrate.mjs +8 -8
- package/package.json +61 -61
- package/scripts/build-color-map.mjs +31 -31
- package/scripts/extract-palette.mjs +13 -13
- package/scripts/tailwind-palette.json +290 -290
- package/src/bootstrap/compat.mjs +72 -72
- package/src/bootstrap/convert.mjs +102 -102
- package/src/bootstrap/migrate.mjs +259 -259
- package/src/bootstrap/rules.mjs +212 -212
- package/src/cli.mjs +139 -139
- package/src/codemod.mjs +82 -82
- package/src/core.mjs +67 -67
- package/src/data/colors.json +290 -290
- package/src/extract.mjs +91 -91
- package/src/index.mjs +12 -12
- package/src/native.mjs +72 -72
- package/src/postcss.mjs +308 -308
- package/src/preflight.mjs +52 -52
- package/src/project.mjs +194 -194
- package/src/resolve.mjs +220 -220
- package/src/scan.mjs +106 -106
- package/src/setup.mjs +205 -205
- package/src/utilities.mjs +713 -713
- package/src/values.mjs +184 -184
- package/src/variants.mjs +189 -189
- package/src/vite.mjs +81 -81
package/src/utilities.mjs
CHANGED
|
@@ -1,713 +1,713 @@
|
|
|
1
|
-
// File: packages/migrate/src/utilities.mjs
|
|
2
|
-
// Utility table of the compat resolver: Tailwind-style class (without variants) -> declarations.
|
|
3
|
-
// Colors only ever resolve to Omnia palette tokens. Scales are rem based (same numbers as the familiar 0.25rem step).
|
|
4
|
-
// Author: Serge Cools | Framework: OmniaCSS
|
|
5
|
-
|
|
6
|
-
import { arb, color, fmt, frac, inferType, isNum, negate, rem, spacing, withAlpha } from "./values.mjs";
|
|
7
|
-
|
|
8
|
-
/** Parse "a:b;c:d" into [["a","b"],["c","d"]] (semicolons inside parentheses are kept). */
|
|
9
|
-
export function decls(str) {
|
|
10
|
-
const out = [];
|
|
11
|
-
let depth = 0, cur = "";
|
|
12
|
-
for (const ch of str + ";") {
|
|
13
|
-
if (ch === "(") depth++;
|
|
14
|
-
if (ch === ")") depth--;
|
|
15
|
-
if (ch === ";" && depth === 0) {
|
|
16
|
-
const i = cur.indexOf(":");
|
|
17
|
-
if (i > 0 && cur.trim()) out.push([cur.slice(0, i).trim(), cur.slice(i + 1).trim()]);
|
|
18
|
-
cur = "";
|
|
19
|
-
} else cur += ch;
|
|
20
|
-
}
|
|
21
|
-
return out;
|
|
22
|
-
}
|
|
23
|
-
const d = (prop, val) => [[prop, val]];
|
|
24
|
-
|
|
25
|
-
// ---------------------------------------------------------------------------------------------- scales
|
|
26
|
-
|
|
27
|
-
const BLACK = "var(--color-black-50)";
|
|
28
|
-
const sh = (y, blur, spread, a) => `0 ${y}px ${blur}px ${spread}px oklch(from var(--oc-shadow-color, ${BLACK}) l c h / ${a})`;
|
|
29
|
-
/** Omnia's own shadow values (core dist), plus the extra steps. */
|
|
30
|
-
const SHADOWS = {
|
|
31
|
-
"2xs": sh(1, 0, 0, 0.05),
|
|
32
|
-
xs: sh(1, 2, 0, 0.06),
|
|
33
|
-
sm: sh(1, 2, 0, 0.08),
|
|
34
|
-
DEFAULT: `${sh(1, 3, 0, 0.12)}, ${sh(1, 2, -1, 0.1)}`,
|
|
35
|
-
md: `${sh(4, 6, -1, 0.15)}, ${sh(2, 4, -2, 0.12)}`,
|
|
36
|
-
lg: `${sh(10, 15, -3, 0.18)}, ${sh(4, 6, -4, 0.14)}`,
|
|
37
|
-
xl: `${sh(20, 25, -5, 0.22)}, ${sh(8, 10, -6, 0.16)}`,
|
|
38
|
-
"2xl": sh(25, 50, -12, 0.35),
|
|
39
|
-
inner: `inset 0 2px 4px 0 oklch(from var(--oc-shadow-color, ${BLACK}) l c h / 0.12)`,
|
|
40
|
-
};
|
|
41
|
-
// Tailwind 3 naming: shadow-sm = small, shadow = default. Tailwind 4 shifted every name one step down.
|
|
42
|
-
const SHADOW_NAMES = (name, ctx) => {
|
|
43
|
-
if (name === "none") return "0 0 transparent";
|
|
44
|
-
if (name === "inner") return SHADOWS.inner;
|
|
45
|
-
if (ctx.v4) return ({ sm: "DEFAULT" })[name] ? SHADOWS[({ sm: "DEFAULT" })[name]] : SHADOWS[name];
|
|
46
|
-
return SHADOWS[name];
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const FONT_SIZES = {
|
|
50
|
-
xs: ["0.75rem", "calc(1 / 0.75)"], sm: ["0.875rem", "calc(1.25 / 0.875)"], base: ["1rem", "calc(1.5 / 1)"], lg: ["1.125rem", "calc(1.75 / 1.125)"],
|
|
51
|
-
xl: ["1.25rem", "calc(1.75 / 1.25)"], "2xl": ["1.5rem", "calc(2 / 1.5)"], "3xl": ["1.875rem", "calc(2.25 / 1.875)"], "4xl": ["2.25rem", "calc(2.5 / 2.25)"],
|
|
52
|
-
"5xl": ["3rem", "1"], "6xl": ["3.75rem", "1"], "7xl": ["4.5rem", "1"], "8xl": ["6rem", "1"], "9xl": ["8rem", "1"],
|
|
53
|
-
};
|
|
54
|
-
const LEADING = { none: "1", tight: "1.25", snug: "1.375", normal: "1.5", relaxed: "1.625", loose: "2" };
|
|
55
|
-
const TRACKING = { tighter: "-0.05em", tight: "-0.025em", normal: "0em", wide: "0.025em", wider: "0.05em", widest: "0.1em" };
|
|
56
|
-
const WEIGHTS = { thin: 100, extralight: 200, light: 300, normal: 400, medium: 500, semibold: 600, bold: 700, extrabold: 800, black: 900 };
|
|
57
|
-
const FAMILIES = {
|
|
58
|
-
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
59
|
-
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
60
|
-
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
|
61
|
-
};
|
|
62
|
-
const RADIUS = { none: "0px", xs: "0.125rem", sm: "0.25rem", DEFAULT: "0.25rem", md: "0.375rem", lg: "0.5rem", xl: "0.75rem", "2xl": "1rem", "3xl": "1.5rem", "4xl": "2rem", full: "calc(infinity * 1px)" };
|
|
63
|
-
const RADIUS_V3 = { sm: "0.125rem", DEFAULT: "0.25rem" };
|
|
64
|
-
const CONTAINERS = { "3xs": 16, "2xs": 18, xs: 20, sm: 24, md: 28, lg: 32, xl: 36, "2xl": 42, "3xl": 48, "4xl": 56, "5xl": 64, "6xl": 72, "7xl": 80 };
|
|
65
|
-
const BLUR = { none: "", "3xs": "", xs: "4px", sm: "8px", DEFAULT: "8px", md: "12px", lg: "16px", xl: "24px", "2xl": "40px", "3xl": "64px" };
|
|
66
|
-
const BLUR_V3 = { sm: "4px", DEFAULT: "8px", md: "12px", lg: "16px", xl: "24px", "2xl": "40px", "3xl": "64px" };
|
|
67
|
-
const EASE = { linear: "linear", in: "cubic-bezier(0.4, 0, 1, 1)", out: "cubic-bezier(0, 0, 0.2, 1)", "in-out": "cubic-bezier(0.4, 0, 0.2, 1)" };
|
|
68
|
-
const TRANSITION_ALL = "color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter, display, content-visibility, overlay, pointer-events";
|
|
69
|
-
const TRANSITION_DEFAULT = "color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter";
|
|
70
|
-
const T = (props) => `transition-property:${props};transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:0.15s`;
|
|
71
|
-
|
|
72
|
-
// ---------------------------------------------------------------------------------------------- static table
|
|
73
|
-
|
|
74
|
-
const S = {};
|
|
75
|
-
const add = (obj) => { for (const [k, v] of Object.entries(obj)) S[k] = decls(v); };
|
|
76
|
-
|
|
77
|
-
add({
|
|
78
|
-
// display
|
|
79
|
-
block: "display:block", "inline-block": "display:inline-block", inline: "display:inline", flex: "display:flex", "inline-flex": "display:inline-flex",
|
|
80
|
-
grid: "display:grid", "inline-grid": "display:inline-grid", contents: "display:contents", hidden: "display:none", table: "display:table",
|
|
81
|
-
"inline-table": "display:inline-table", "table-row": "display:table-row", "table-cell": "display:table-cell", "table-caption": "display:table-caption",
|
|
82
|
-
"table-column": "display:table-column", "table-column-group": "display:table-column-group", "table-footer-group": "display:table-footer-group",
|
|
83
|
-
"table-header-group": "display:table-header-group", "table-row-group": "display:table-row-group", "flow-root": "display:flow-root", "list-item": "display:list-item",
|
|
84
|
-
visible: "visibility:visible", invisible: "visibility:hidden", collapse: "visibility:collapse",
|
|
85
|
-
"sr-only": "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border-width:0",
|
|
86
|
-
"not-sr-only": "position:static;width:auto;height:auto;padding:0;margin:0;overflow:visible;clip-path:none;white-space:normal",
|
|
87
|
-
// position
|
|
88
|
-
static: "position:static", fixed: "position:fixed", absolute: "position:absolute", relative: "position:relative", sticky: "position:sticky",
|
|
89
|
-
isolate: "isolation:isolate", "isolation-auto": "isolation:auto",
|
|
90
|
-
// box
|
|
91
|
-
"box-border": "box-sizing:border-box", "box-content": "box-sizing:content-box",
|
|
92
|
-
"float-left": "float:left", "float-right": "float:right", "float-none": "float:none", "float-start": "float:inline-start", "float-end": "float:inline-end",
|
|
93
|
-
"clear-left": "clear:left", "clear-right": "clear:right", "clear-both": "clear:both", "clear-none": "clear:none",
|
|
94
|
-
// flex
|
|
95
|
-
"flex-row": "flex-direction:row", "flex-row-reverse": "flex-direction:row-reverse", "flex-col": "flex-direction:column", "flex-col-reverse": "flex-direction:column-reverse",
|
|
96
|
-
"flex-wrap": "flex-wrap:wrap", "flex-wrap-reverse": "flex-wrap:wrap-reverse", "flex-nowrap": "flex-wrap:nowrap",
|
|
97
|
-
"flex-1": "flex:1", "flex-auto": "flex:1 1 auto", "flex-initial": "flex:0 1 auto", "flex-none": "flex:none",
|
|
98
|
-
grow: "flex-grow:1", "grow-0": "flex-grow:0", "flex-grow": "flex-grow:1", "flex-grow-0": "flex-grow:0",
|
|
99
|
-
shrink: "flex-shrink:1", "shrink-0": "flex-shrink:0", "flex-shrink": "flex-shrink:1", "flex-shrink-0": "flex-shrink:0",
|
|
100
|
-
// alignment
|
|
101
|
-
"justify-normal": "justify-content:normal", "justify-start": "justify-content:flex-start", "justify-end": "justify-content:flex-end", "justify-center": "justify-content:center",
|
|
102
|
-
"justify-between": "justify-content:space-between", "justify-around": "justify-content:space-around", "justify-evenly": "justify-content:space-evenly", "justify-stretch": "justify-content:stretch",
|
|
103
|
-
"justify-center-safe": "justify-content:safe center", "justify-end-safe": "justify-content:safe flex-end",
|
|
104
|
-
"justify-items-start": "justify-items:start", "justify-items-end": "justify-items:end", "justify-items-center": "justify-items:center", "justify-items-stretch": "justify-items:stretch",
|
|
105
|
-
"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",
|
|
106
|
-
"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",
|
|
107
|
-
"items-center-safe": "align-items:safe center", "items-baseline-last": "align-items:last baseline",
|
|
108
|
-
"content-normal": "align-content:normal", "content-center": "align-content:center", "content-start": "align-content:flex-start", "content-end": "align-content:flex-end",
|
|
109
|
-
"content-between": "align-content:space-between", "content-around": "align-content:space-around", "content-evenly": "align-content:space-evenly", "content-baseline": "align-content:baseline", "content-stretch": "align-content:stretch",
|
|
110
|
-
"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",
|
|
111
|
-
"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",
|
|
112
|
-
"place-content-around": "place-content:space-around", "place-content-evenly": "place-content:space-evenly", "place-content-stretch": "place-content:stretch",
|
|
113
|
-
"place-items-start": "place-items:start", "place-items-end": "place-items:end", "place-items-center": "place-items:center", "place-items-baseline": "place-items:baseline", "place-items-stretch": "place-items:stretch",
|
|
114
|
-
"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",
|
|
115
|
-
// grid
|
|
116
|
-
"grid-flow-row": "grid-auto-flow:row", "grid-flow-col": "grid-auto-flow:column", "grid-flow-dense": "grid-auto-flow:dense", "grid-flow-row-dense": "grid-auto-flow:row dense", "grid-flow-col-dense": "grid-auto-flow:column dense",
|
|
117
|
-
"grid-cols-none": "grid-template-columns:none", "grid-cols-subgrid": "grid-template-columns:subgrid", "grid-rows-none": "grid-template-rows:none", "grid-rows-subgrid": "grid-template-rows:subgrid",
|
|
118
|
-
"col-auto": "grid-column:auto", "col-span-full": "grid-column:1 / -1", "row-auto": "grid-row:auto", "row-span-full": "grid-row:1 / -1",
|
|
119
|
-
"col-start-auto": "grid-column-start:auto", "col-end-auto": "grid-column-end:auto", "row-start-auto": "grid-row-start:auto", "row-end-auto": "grid-row-end:auto",
|
|
120
|
-
"auto-cols-auto": "grid-auto-columns:auto", "auto-cols-min": "grid-auto-columns:min-content", "auto-cols-max": "grid-auto-columns:max-content", "auto-cols-fr": "grid-auto-columns:minmax(0, 1fr)",
|
|
121
|
-
"auto-rows-auto": "grid-auto-rows:auto", "auto-rows-min": "grid-auto-rows:min-content", "auto-rows-max": "grid-auto-rows:max-content", "auto-rows-fr": "grid-auto-rows:minmax(0, 1fr)",
|
|
122
|
-
"order-first": "order:-9999", "order-last": "order:9999", "order-none": "order:0",
|
|
123
|
-
// overflow & scroll
|
|
124
|
-
"overflow-auto": "overflow:auto", "overflow-hidden": "overflow:hidden", "overflow-clip": "overflow:clip", "overflow-visible": "overflow:visible", "overflow-scroll": "overflow:scroll",
|
|
125
|
-
"overflow-x-auto": "overflow-x:auto", "overflow-x-hidden": "overflow-x:hidden", "overflow-x-clip": "overflow-x:clip", "overflow-x-visible": "overflow-x:visible", "overflow-x-scroll": "overflow-x:scroll",
|
|
126
|
-
"overflow-y-auto": "overflow-y:auto", "overflow-y-hidden": "overflow-y:hidden", "overflow-y-clip": "overflow-y:clip", "overflow-y-visible": "overflow-y:visible", "overflow-y-scroll": "overflow-y:scroll",
|
|
127
|
-
"overscroll-auto": "overscroll-behavior:auto", "overscroll-contain": "overscroll-behavior:contain", "overscroll-none": "overscroll-behavior:none",
|
|
128
|
-
"overscroll-x-auto": "overscroll-behavior-x:auto", "overscroll-x-contain": "overscroll-behavior-x:contain", "overscroll-x-none": "overscroll-behavior-x:none",
|
|
129
|
-
"overscroll-y-auto": "overscroll-behavior-y:auto", "overscroll-y-contain": "overscroll-behavior-y:contain", "overscroll-y-none": "overscroll-behavior-y:none",
|
|
130
|
-
"scroll-auto": "scroll-behavior:auto", "scroll-smooth": "scroll-behavior:smooth",
|
|
131
|
-
"snap-none": "scroll-snap-type:none", "snap-x": "scroll-snap-type:x var(--oc-snap-strictness, proximity)", "snap-y": "scroll-snap-type:y var(--oc-snap-strictness, proximity)", "snap-both": "scroll-snap-type:both var(--oc-snap-strictness, proximity)",
|
|
132
|
-
"snap-mandatory": "--oc-snap-strictness:mandatory", "snap-proximity": "--oc-snap-strictness:proximity",
|
|
133
|
-
"snap-start": "scroll-snap-align:start", "snap-end": "scroll-snap-align:end", "snap-center": "scroll-snap-align:center", "snap-align-none": "scroll-snap-align:none",
|
|
134
|
-
"snap-normal": "scroll-snap-stop:normal", "snap-always": "scroll-snap-stop:always",
|
|
135
|
-
// typography
|
|
136
|
-
"text-left": "text-align:left", "text-center": "text-align:center", "text-right": "text-align:right", "text-justify": "text-align:justify", "text-start": "text-align:start", "text-end": "text-align:end",
|
|
137
|
-
"text-wrap": "text-wrap:wrap", "text-nowrap": "text-wrap:nowrap", "text-balance": "text-wrap:balance", "text-pretty": "text-wrap:pretty",
|
|
138
|
-
"text-ellipsis": "text-overflow:ellipsis", "text-clip": "text-overflow:clip", truncate: "overflow:hidden;text-overflow:ellipsis;white-space:nowrap",
|
|
139
|
-
uppercase: "text-transform:uppercase", lowercase: "text-transform:lowercase", capitalize: "text-transform:capitalize", "normal-case": "text-transform:none",
|
|
140
|
-
underline: "text-decoration-line:underline", overline: "text-decoration-line:overline", "line-through": "text-decoration-line:line-through", "no-underline": "text-decoration-line:none",
|
|
141
|
-
"decoration-solid": "text-decoration-style:solid", "decoration-double": "text-decoration-style:double", "decoration-dotted": "text-decoration-style:dotted", "decoration-dashed": "text-decoration-style:dashed", "decoration-wavy": "text-decoration-style:wavy",
|
|
142
|
-
"decoration-auto": "text-decoration-thickness:auto", "decoration-from-font": "text-decoration-thickness:from-font",
|
|
143
|
-
"underline-offset-auto": "text-underline-offset:auto",
|
|
144
|
-
italic: "font-style:italic", "not-italic": "font-style:normal", antialiased: "-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale", "subpixel-antialiased": "-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto",
|
|
145
|
-
"whitespace-normal": "white-space:normal", "whitespace-nowrap": "white-space:nowrap", "whitespace-pre": "white-space:pre", "whitespace-pre-line": "white-space:pre-line", "whitespace-pre-wrap": "white-space:pre-wrap", "whitespace-break-spaces": "white-space:break-spaces",
|
|
146
|
-
"break-normal": "overflow-wrap:normal;word-break:normal", "break-words": "overflow-wrap:break-word", "break-all": "word-break:break-all", "break-keep": "word-break:keep-all",
|
|
147
|
-
"hyphens-none": "hyphens:none", "hyphens-manual": "hyphens:manual", "hyphens-auto": "hyphens:auto",
|
|
148
|
-
"normal-nums": "font-variant-numeric:normal", ordinal: "font-variant-numeric:ordinal", "slashed-zero": "font-variant-numeric:slashed-zero", "lining-nums": "font-variant-numeric:lining-nums",
|
|
149
|
-
"oldstyle-nums": "font-variant-numeric:oldstyle-nums", "proportional-nums": "font-variant-numeric:proportional-nums", "tabular-nums": "font-variant-numeric:tabular-nums",
|
|
150
|
-
"diagonal-fractions": "font-variant-numeric:diagonal-fractions", "stacked-fractions": "font-variant-numeric:stacked-fractions",
|
|
151
|
-
"list-none": "list-style-type:none", "list-disc": "list-style-type:disc", "list-decimal": "list-style-type:decimal", "list-inside": "list-style-position:inside", "list-outside": "list-style-position:outside",
|
|
152
|
-
"align-baseline": "vertical-align:baseline", "align-top": "vertical-align:top", "align-middle": "vertical-align:middle", "align-bottom": "vertical-align:bottom", "align-text-top": "vertical-align:text-top", "align-text-bottom": "vertical-align:text-bottom", "align-sub": "vertical-align:sub", "align-super": "vertical-align:super",
|
|
153
|
-
"line-clamp-none": "overflow:visible;display:block;-webkit-box-orient:horizontal;-webkit-line-clamp:unset;line-clamp:unset",
|
|
154
|
-
// borders
|
|
155
|
-
"border-solid": "border-style:solid", "border-dashed": "border-style:dashed", "border-dotted": "border-style:dotted", "border-double": "border-style:double", "border-hidden": "border-style:hidden", "border-none": "border-style:none",
|
|
156
|
-
"divide-solid": "border-style:solid", "divide-dashed": "border-style:dashed", "divide-dotted": "border-style:dotted", "divide-none": "border-style:none",
|
|
157
|
-
"border-collapse": "border-collapse:collapse", "border-separate": "border-collapse:separate",
|
|
158
|
-
"outline-none": "outline-style:none", "outline-hidden": "outline:2px solid transparent;outline-offset:2px", "outline-solid": "outline-style:solid", "outline-dashed": "outline-style:dashed", "outline-dotted": "outline-style:dotted", "outline-double": "outline-style:double",
|
|
159
|
-
outline: "outline-style:solid;outline-width:1px",
|
|
160
|
-
// backgrounds
|
|
161
|
-
"bg-fixed": "background-attachment:fixed", "bg-local": "background-attachment:local", "bg-scroll": "background-attachment:scroll",
|
|
162
|
-
"bg-clip-border": "background-clip:border-box", "bg-clip-padding": "background-clip:padding-box", "bg-clip-content": "background-clip:content-box", "bg-clip-text": "-webkit-background-clip:text;background-clip:text",
|
|
163
|
-
"bg-origin-border": "background-origin:border-box", "bg-origin-padding": "background-origin:padding-box", "bg-origin-content": "background-origin:content-box",
|
|
164
|
-
"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",
|
|
165
|
-
"bg-auto": "background-size:auto", "bg-cover": "background-size:cover", "bg-contain": "background-size:contain", "bg-none": "background-image:none",
|
|
166
|
-
"bg-center": "background-position:center", "bg-top": "background-position:top", "bg-bottom": "background-position:bottom", "bg-left": "background-position:left", "bg-right": "background-position:right",
|
|
167
|
-
"bg-left-top": "background-position:left top", "bg-left-bottom": "background-position:left bottom", "bg-right-top": "background-position:right top", "bg-right-bottom": "background-position:right bottom",
|
|
168
|
-
"bg-top-left": "background-position:left top", "bg-top-right": "background-position:right top", "bg-bottom-left": "background-position:left bottom", "bg-bottom-right": "background-position:right bottom",
|
|
169
|
-
"bg-blend-normal": "background-blend-mode:normal", "bg-blend-multiply": "background-blend-mode:multiply", "bg-blend-screen": "background-blend-mode:screen", "bg-blend-overlay": "background-blend-mode:overlay",
|
|
170
|
-
// objects
|
|
171
|
-
"object-contain": "object-fit:contain", "object-cover": "object-fit:cover", "object-fill": "object-fit:fill", "object-none": "object-fit:none", "object-scale-down": "object-fit:scale-down",
|
|
172
|
-
"object-center": "object-position:center", "object-top": "object-position:top", "object-bottom": "object-position:bottom", "object-left": "object-position:left", "object-right": "object-position:right",
|
|
173
|
-
"object-left-top": "object-position:left top", "object-right-top": "object-position:right top", "object-left-bottom": "object-position:left bottom", "object-right-bottom": "object-position:right bottom",
|
|
174
|
-
"aspect-auto": "aspect-ratio:auto", "aspect-square": "aspect-ratio:1 / 1", "aspect-video": "aspect-ratio:16 / 9",
|
|
175
|
-
// interactivity
|
|
176
|
-
"pointer-events-none": "pointer-events:none", "pointer-events-auto": "pointer-events:auto",
|
|
177
|
-
"select-none": "-webkit-user-select:none;user-select:none", "select-text": "-webkit-user-select:text;user-select:text", "select-all": "-webkit-user-select:all;user-select:all", "select-auto": "-webkit-user-select:auto;user-select:auto",
|
|
178
|
-
"resize-none": "resize:none", resize: "resize:both", "resize-x": "resize:horizontal", "resize-y": "resize:vertical",
|
|
179
|
-
"appearance-none": "appearance:none", "appearance-auto": "appearance:auto",
|
|
180
|
-
"touch-auto": "touch-action:auto", "touch-none": "touch-action:none", "touch-manipulation": "touch-action:manipulation", "touch-pan-x": "touch-action:pan-x", "touch-pan-y": "touch-action:pan-y", "touch-pinch-zoom": "touch-action:pinch-zoom",
|
|
181
|
-
"will-change-auto": "will-change:auto", "will-change-scroll": "will-change:scroll-position", "will-change-contents": "will-change:contents", "will-change-transform": "will-change:transform",
|
|
182
|
-
"field-sizing-content": "field-sizing:content", "field-sizing-fixed": "field-sizing:fixed",
|
|
183
|
-
"scheme-light": "color-scheme:light", "scheme-dark": "color-scheme:dark", "scheme-light-dark": "color-scheme:light dark", "scheme-normal": "color-scheme:normal",
|
|
184
|
-
// effects
|
|
185
|
-
"mix-blend-normal": "mix-blend-mode:normal", "mix-blend-multiply": "mix-blend-mode:multiply", "mix-blend-screen": "mix-blend-mode:screen", "mix-blend-overlay": "mix-blend-mode:overlay",
|
|
186
|
-
"mix-blend-darken": "mix-blend-mode:darken", "mix-blend-lighten": "mix-blend-mode:lighten", "mix-blend-difference": "mix-blend-mode:difference", "mix-blend-plus-lighter": "mix-blend-mode:plus-lighter",
|
|
187
|
-
// transitions & animation
|
|
188
|
-
transition: T(TRANSITION_DEFAULT), "transition-all": T("all"), "transition-colors": T("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
189
|
-
"transition-opacity": T("opacity"), "transition-shadow": T("box-shadow"), "transition-transform": T("transform, translate, scale, rotate"), "transition-none": "transition-property:none",
|
|
190
|
-
"transition-discrete": "transition-behavior:allow-discrete", "transition-normal": "transition-behavior:normal",
|
|
191
|
-
"ease-linear": `transition-timing-function:${EASE.linear}`, "ease-in": `transition-timing-function:${EASE.in}`, "ease-out": `transition-timing-function:${EASE.out}`, "ease-in-out": `transition-timing-function:${EASE["in-out"]}`,
|
|
192
|
-
"ease-initial": "transition-timing-function:initial",
|
|
193
|
-
"animate-none": "animation:none",
|
|
194
|
-
// transforms
|
|
195
|
-
"transform-none": "transform:none", "transform-gpu": "transform:translateZ(0)", transform: "", "transform-cpu": "",
|
|
196
|
-
"origin-center": "transform-origin:center", "origin-top": "transform-origin:top", "origin-top-right": "transform-origin:top right", "origin-right": "transform-origin:right",
|
|
197
|
-
"origin-bottom-right": "transform-origin:bottom right", "origin-bottom": "transform-origin:bottom", "origin-bottom-left": "transform-origin:bottom left", "origin-left": "transform-origin:left", "origin-top-left": "transform-origin:top left",
|
|
198
|
-
"backface-visible": "backface-visibility:visible", "backface-hidden": "backface-visibility:hidden",
|
|
199
|
-
"transform-style-3d": "transform-style:preserve-3d", "transform-3d": "transform-style:preserve-3d", "transform-flat": "transform-style:flat",
|
|
200
|
-
// misc
|
|
201
|
-
"container-type-normal": "container-type:normal", "@container": "container-type:inline-size", "@container-normal": "container-type:normal",
|
|
202
|
-
"fill-none": "fill:none", "stroke-none": "stroke:none",
|
|
203
|
-
"table-auto": "table-layout:auto", "table-fixed": "table-layout:fixed", "caption-top": "caption-side:top", "caption-bottom": "caption-side:bottom",
|
|
204
|
-
"filter-none": "filter:none", filter: "", "backdrop-filter-none": "backdrop-filter:none", "backdrop-filter": "",
|
|
205
|
-
"forced-color-adjust-auto": "forced-color-adjust:auto", "forced-color-adjust-none": "forced-color-adjust:none",
|
|
206
|
-
"break-before-auto": "break-before:auto", "break-after-auto": "break-after:auto", "break-inside-avoid": "break-inside:avoid", "break-inside-auto": "break-inside:auto",
|
|
207
|
-
"content-none": "content:none", "text-shadow-none": "text-shadow:none",
|
|
208
|
-
"animate-in": "animation-name:enter;animation-duration:150ms;--oc-enter-opacity:initial;--oc-enter-scale:initial;--oc-enter-rotate:initial;--oc-enter-translate-x:initial;--oc-enter-translate-y:initial",
|
|
209
|
-
"animate-out": "animation-name:exit;animation-duration:150ms;--oc-exit-opacity:initial;--oc-exit-scale:initial;--oc-exit-rotate:initial;--oc-exit-translate-x:initial;--oc-exit-translate-y:initial",
|
|
210
|
-
"running": "animation-play-state:running", "paused": "animation-play-state:paused",
|
|
211
|
-
"fill-mode-none": "animation-fill-mode:none", "fill-mode-forwards": "animation-fill-mode:forwards", "fill-mode-backwards": "animation-fill-mode:backwards", "fill-mode-both": "animation-fill-mode:both",
|
|
212
|
-
"direction-normal": "animation-direction:normal", "direction-reverse": "animation-direction:reverse", "direction-alternate": "animation-direction:alternate", "direction-alternate-reverse": "animation-direction:alternate-reverse",
|
|
213
|
-
"repeat-0": "animation-iteration-count:0", "repeat-1": "animation-iteration-count:1", "repeat-infinite": "animation-iteration-count:infinite",
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
export const KEYFRAMES = {
|
|
217
|
-
spin: "@keyframes spin{to{transform:rotate(360deg)}}",
|
|
218
|
-
ping: "@keyframes ping{75%,100%{transform:scale(2);opacity:0}}",
|
|
219
|
-
pulse: "@keyframes pulse{50%{opacity:0.5}}",
|
|
220
|
-
bounce: "@keyframes bounce{0%,100%{transform:translateY(-25%);animation-timing-function:cubic-bezier(0.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,0.2,1)}}",
|
|
221
|
-
enter: "@keyframes enter{from{opacity:var(--oc-enter-opacity,1);transform:translate3d(var(--oc-enter-translate-x,0),var(--oc-enter-translate-y,0),0) scale3d(var(--oc-enter-scale,1),var(--oc-enter-scale,1),var(--oc-enter-scale,1)) rotate(var(--oc-enter-rotate,0))}}",
|
|
222
|
-
exit: "@keyframes exit{to{opacity:var(--oc-exit-opacity,1);transform:translate3d(var(--oc-exit-translate-x,0),var(--oc-exit-translate-y,0),0) scale3d(var(--oc-exit-scale,1),var(--oc-exit-scale,1),var(--oc-exit-scale,1)) rotate(var(--oc-exit-rotate,0))}}",
|
|
223
|
-
};
|
|
224
|
-
const ANIMATIONS = {
|
|
225
|
-
spin: "spin 1s linear infinite", ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite", pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite", bounce: "bounce 1s infinite",
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
// ---------------------------------------------------------------------------------------------- handler helpers
|
|
229
|
-
|
|
230
|
-
/** Tokens that only mark an element (no CSS). */
|
|
231
|
-
export const MARKERS = /^(group|peer|dark|light|not-prose|prose-invert|container-query|@container\/[\w-]+|group\/[\w-]+|peer\/[\w-]+|theme-[\w-]+)$/;
|
|
232
|
-
|
|
233
|
-
const num = (v) => isNum(v);
|
|
234
|
-
const sp = (u, v = u.value, o = {}) => spacing(v, u.ctx, { neg: u.neg, ...o });
|
|
235
|
-
const SIZE_KW = { auto: "auto", full: "100%", min: "min-content", max: "max-content", fit: "fit-content", screen: "100vw", svw: "100svw", lvw: "100lvw", dvw: "100dvw", px: "1px" };
|
|
236
|
-
|
|
237
|
-
function sizeValue(u, axis, kind) {
|
|
238
|
-
const v = u.value;
|
|
239
|
-
if (kind === "size") return sp(u, v, { keywords: { ...SIZE_KW, screen: undefined, auto: "auto", full: "100%" } });
|
|
240
|
-
const kw = { ...SIZE_KW };
|
|
241
|
-
if (axis === "h") Object.assign(kw, { screen: "100vh", svh: "100svh", lvh: "100lvh", dvh: "100dvh", lh: "1lh" });
|
|
242
|
-
else Object.assign(kw, { svw: "100svw", lvw: "100lvw", dvw: "100dvw" });
|
|
243
|
-
if (axis === "h") { delete kw.svw; delete kw.lvw; delete kw.dvw; }
|
|
244
|
-
if (kind === "min" || kind === "max") {
|
|
245
|
-
if (kind === "max" && CONTAINERS[v] && axis === "w") return `${CONTAINERS[v]}rem`;
|
|
246
|
-
if (kind === "max" && v === "none") return "none";
|
|
247
|
-
if (kind === "max" && v === "prose") return "65ch";
|
|
248
|
-
if (kind === "max" && axis === "w" && /^screen-/.test(v)) return u.ctx.screens[v.slice(7)] || null;
|
|
249
|
-
if (kind === "max" && v === "screen" && axis === "w") return "100vw";
|
|
250
|
-
if (kind === "min") kw.auto = undefined;
|
|
251
|
-
if (kind === "max") kw.auto = undefined;
|
|
252
|
-
if (kind === "min" && v === "0") return "0px";
|
|
253
|
-
if (kind === "max" && v === "0") return "0px";
|
|
254
|
-
}
|
|
255
|
-
if (kind === "w" && CONTAINERS[v] && v !== "full" && !/^\d/.test(v)) return `${CONTAINERS[v]}rem`;
|
|
256
|
-
return sp(u, v, { keywords: kw });
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
const sideProps = (base, sides) => sides.map((s) => (s ? `${base}-${s}` : base));
|
|
260
|
-
const SIDE = { t: "top", r: "right", b: "bottom", l: "left", s: "inline-start", e: "inline-end" };
|
|
261
|
-
|
|
262
|
-
function boxHandler(prop) {
|
|
263
|
-
// m, mx, my, mt … (margin / padding / scroll-margin / scroll-padding)
|
|
264
|
-
return (u, root) => {
|
|
265
|
-
const key = root.slice(prefixLen(prop));
|
|
266
|
-
const v = sp(u, u.value, { keywords: { auto: "auto" }, fractions: false });
|
|
267
|
-
if (v == null) return null;
|
|
268
|
-
if (u.value === "auto" && u.neg) return null;
|
|
269
|
-
const mk = (sides) => sides.map((s) => [s, v]);
|
|
270
|
-
const p = (s) => (s ? `${prop}-${s}` : prop);
|
|
271
|
-
if (key === "") return d(prop, v);
|
|
272
|
-
if (key === "x") return [[`${prop}-inline`, v]];
|
|
273
|
-
if (key === "y") return [[`${prop}-block`, v]];
|
|
274
|
-
if (SIDE[key]) return [[p(SIDE[key]), v]];
|
|
275
|
-
return null;
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
const prefixLen = (prop) => ({ margin: 1, padding: 1, "scroll-margin": 2, "scroll-padding": 2 })[prop];
|
|
279
|
-
|
|
280
|
-
function insetHandler(prop) {
|
|
281
|
-
return (u) => {
|
|
282
|
-
const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } });
|
|
283
|
-
return v == null ? null : d(prop, v);
|
|
284
|
-
};
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
function colorDecl(prop) {
|
|
288
|
-
return (u) => { const c = color(u.value, u.mod, u.ctx); return c == null ? null : d(prop, c); };
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/** Rule for `from-`, `via-`, `to-` gradient stops. */
|
|
292
|
-
function stopHandler(which) {
|
|
293
|
-
return (u) => {
|
|
294
|
-
const a = arb(u.value);
|
|
295
|
-
if (a && (a.type === "length" || a.type === "percentage" || (!a.type && inferType(a.value) === "length"))) return null;
|
|
296
|
-
if (!a && /^\d+%$/.test(u.value)) return null;
|
|
297
|
-
const c = color(u.value, u.mod, u.ctx);
|
|
298
|
-
if (c == null) return null;
|
|
299
|
-
if (which === "via") return [["--oc-via", c], ["--oc-stops", "var(--oc-from, transparent), var(--oc-via), var(--oc-to, transparent)"]];
|
|
300
|
-
return [[`--oc-${which}`, c]];
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
const GRADIENT_DIRS = { t: "to top", tr: "to top right", r: "to right", br: "to bottom right", b: "to bottom", bl: "to bottom left", l: "to left", tl: "to top left" };
|
|
304
|
-
const STOPS = "var(--oc-stops, var(--oc-from, transparent), var(--oc-to, transparent))";
|
|
305
|
-
|
|
306
|
-
function filterHandler(varName, fnName, { backdrop = false, scale = (v) => frac(v), unit = "" } = {}) {
|
|
307
|
-
return (u) => {
|
|
308
|
-
let val;
|
|
309
|
-
const a = arb(u.value);
|
|
310
|
-
if (a) val = a.value;
|
|
311
|
-
else if (u.value === "") val = "";
|
|
312
|
-
else if (num(u.value)) val = scale(u.value) + unit;
|
|
313
|
-
else return null;
|
|
314
|
-
if (u.neg && val) val = negate(val);
|
|
315
|
-
return [[`--oc-${backdrop ? "bd-" : ""}${varName}`, `${fnName}(${val})`], ...filterCompose(backdrop)];
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
const FILTER_VARS = ["blur", "brightness", "contrast", "grayscale", "hue-rotate", "invert", "saturate", "sepia", "drop-shadow"];
|
|
319
|
-
const BD_VARS = ["blur", "brightness", "contrast", "grayscale", "hue-rotate", "invert", "opacity", "saturate", "sepia"];
|
|
320
|
-
function filterCompose(backdrop) {
|
|
321
|
-
const vars = backdrop ? BD_VARS : FILTER_VARS;
|
|
322
|
-
const pre = backdrop ? "--oc-bd-" : "--oc-";
|
|
323
|
-
const val = vars.map((n) => `var(${pre}${n},)`).join(" ");
|
|
324
|
-
return backdrop ? [["-webkit-backdrop-filter", val], ["backdrop-filter", val]] : [["filter", val]];
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
function ringShadow(width, inset) {
|
|
328
|
-
return [
|
|
329
|
-
[inset ? "--oc-inset-ring-shadow" : "--oc-ring-shadow", `${inset ? "inset " : ""}0 0 0 calc(${width} + var(--oc-ring-offset-width, 0px)) var(${inset ? "--oc-inset-ring-color" : "--oc-ring-color"}, currentColor)`],
|
|
330
|
-
["box-shadow", "var(--oc-inset-shadow, 0 0 transparent), var(--oc-inset-ring-shadow, 0 0 transparent), var(--oc-ring-offset-shadow, 0 0 transparent), var(--oc-ring-shadow, 0 0 transparent), var(--oc-shadow, 0 0 transparent)"],
|
|
331
|
-
];
|
|
332
|
-
}
|
|
333
|
-
const SHADOW_COMPOSE = ["box-shadow", "var(--oc-inset-shadow, 0 0 transparent), var(--oc-inset-ring-shadow, 0 0 transparent), var(--oc-ring-offset-shadow, 0 0 transparent), var(--oc-ring-shadow, 0 0 transparent), var(--oc-shadow, 0 0 transparent)"];
|
|
334
|
-
|
|
335
|
-
function translate(axis) {
|
|
336
|
-
return (u) => {
|
|
337
|
-
let v = u.value;
|
|
338
|
-
const kw = { full: "100%" };
|
|
339
|
-
const val = spacing(v, u.ctx, { neg: u.neg, keywords: kw });
|
|
340
|
-
if (val == null) return null;
|
|
341
|
-
if (axis === "z") return d("translate", `0 0 ${val}`);
|
|
342
|
-
return [[`--oc-translate-${axis}`, val], ["translate", "var(--oc-translate-x, 0) var(--oc-translate-y, 0)"]];
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
function scaleHandler(axis) {
|
|
346
|
-
return (u) => {
|
|
347
|
-
const a = arb(u.value);
|
|
348
|
-
const v = a ? a.value : num(u.value) ? frac(u.value) : null;
|
|
349
|
-
if (v == null) return null;
|
|
350
|
-
const val = u.neg ? negate(v) : v;
|
|
351
|
-
const out = [];
|
|
352
|
-
if (axis !== "y") out.push(["--oc-scale-x", val]);
|
|
353
|
-
if (axis !== "x") out.push(["--oc-scale-y", val]);
|
|
354
|
-
out.push(["scale", "var(--oc-scale-x, 1) var(--oc-scale-y, 1)"]);
|
|
355
|
-
return out;
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
function lenOrNum(u, unit, allowNeg = true) {
|
|
360
|
-
const a = arb(u.value);
|
|
361
|
-
let v = a ? a.value : num(u.value) ? u.value + unit : null;
|
|
362
|
-
if (v == null) return null;
|
|
363
|
-
return u.neg && allowNeg ? negate(v) : v;
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
/** `border-*`/`ring-*`/`outline-*`/`divide-*` width-or-color resolver. */
|
|
367
|
-
function widthOrColor(u, widthProp, colorProp, opts = {}) {
|
|
368
|
-
const v = u.value;
|
|
369
|
-
const a = arb(v);
|
|
370
|
-
const widths = opts.widths || ["0", "1", "2", "4", "8"];
|
|
371
|
-
if (a) {
|
|
372
|
-
const t = a.type || (inferType(a.value) === "color" ? "color" : inferType(a.value) === "length" || inferType(a.value) === "number" ? "length" : null);
|
|
373
|
-
if (t === "color") { const c = color(v, u.mod, u.ctx, { hinted: true }); return c == null ? null : d(colorProp, c); }
|
|
374
|
-
if (t === "length" || t === "line-width" || t === "number") return d(widthProp, a.type === "number" || inferType(a.value) === "number" ? a.value + "px" : a.value);
|
|
375
|
-
const c = color(v, u.mod, u.ctx, { hinted: true });
|
|
376
|
-
return c == null ? null : d(colorProp, c);
|
|
377
|
-
}
|
|
378
|
-
if (widths.includes(v)) return d(widthProp, `${v}px`);
|
|
379
|
-
const c = color(v, u.mod, u.ctx);
|
|
380
|
-
return c == null ? null : d(colorProp, c);
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
// ---------------------------------------------------------------------------------------------- handlers
|
|
384
|
-
|
|
385
|
-
const H = {};
|
|
386
|
-
|
|
387
|
-
// spacing
|
|
388
|
-
for (const root of ["m", "mx", "my", "mt", "mr", "mb", "ml", "ms", "me"]) H[root] = (u) => boxHandler("margin")(u, root);
|
|
389
|
-
for (const root of ["p", "px", "py", "pt", "pr", "pb", "pl", "ps", "pe"]) H[root] = (u) => boxHandler("padding")(u, root);
|
|
390
|
-
for (const root of ["scroll-m", "scroll-mx", "scroll-my", "scroll-mt", "scroll-mr", "scroll-mb", "scroll-ml", "scroll-ms", "scroll-me"]) H[root] = (u) => boxHandler("scroll-margin")(u, root);
|
|
391
|
-
for (const root of ["scroll-p", "scroll-px", "scroll-py", "scroll-pt", "scroll-pr", "scroll-pb", "scroll-pl", "scroll-ps", "scroll-pe"]) H[root] = (u) => boxHandler("scroll-padding")(u, root);
|
|
392
|
-
|
|
393
|
-
H.gap = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("gap", v); };
|
|
394
|
-
H["gap-x"] = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("column-gap", v); };
|
|
395
|
-
H["gap-y"] = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("row-gap", v); };
|
|
396
|
-
H["space-x"] = (u) => { if (u.value === "reverse") return null; const v = sp(u, u.value, { fractions: false }); return v == null ? null : { decls: d("margin-inline-start", v), tail: " > :not(:first-child)" }; };
|
|
397
|
-
H["space-y"] = (u) => { if (u.value === "reverse") return null; const v = sp(u, u.value, { fractions: false }); return v == null ? null : { decls: d("margin-block-start", v), tail: " > :not(:first-child)" }; };
|
|
398
|
-
|
|
399
|
-
// positioning
|
|
400
|
-
H.inset = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } }); return v == null ? null : d("inset", v); };
|
|
401
|
-
H["inset-x"] = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } }); return v == null ? null : d("inset-inline", v); };
|
|
402
|
-
H["inset-y"] = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } }); return v == null ? null : d("inset-block", v); };
|
|
403
|
-
for (const [r, p] of [["top", "top"], ["right", "right"], ["bottom", "bottom"], ["left", "left"], ["start", "inset-inline-start"], ["end", "inset-inline-end"]]) H[r] = insetHandler(p);
|
|
404
|
-
H.z = (u) => { const a = arb(u.value); const v = u.value === "auto" ? "auto" : a ? a.value : num(u.value) ? (u.neg ? "-" : "") + u.value : null; return v == null ? null : d("z-index", v); };
|
|
405
|
-
H.order = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? (u.neg ? "-" : "") + u.value : null; return v == null ? null : d("order", v); };
|
|
406
|
-
|
|
407
|
-
// sizing
|
|
408
|
-
H.w = (u) => { const v = sizeValue(u, "w", "w"); return v == null ? null : d("width", v); };
|
|
409
|
-
H.h = (u) => { const v = sizeValue(u, "h", "h"); return v == null ? null : d("height", v); };
|
|
410
|
-
H.size = (u) => { const v = sizeValue(u, "w", "size"); return v == null ? null : [["width", v], ["height", v]]; };
|
|
411
|
-
H["min-w"] = (u) => { const v = sizeValue(u, "w", "min"); return v == null ? null : d("min-width", v); };
|
|
412
|
-
H["max-w"] = (u) => { const v = sizeValue(u, "w", "max"); return v == null ? null : d("max-width", v); };
|
|
413
|
-
H["min-h"] = (u) => { const v = sizeValue(u, "h", "min"); return v == null ? null : d("min-height", v); };
|
|
414
|
-
H["max-h"] = (u) => { const v = sizeValue(u, "h", "max"); return v == null ? null : d("max-height", v); };
|
|
415
|
-
H.basis = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%", ...Object.fromEntries(Object.entries(CONTAINERS).map(([k, n]) => [k, `${n}rem`])) } }); return v == null ? null : d("flex-basis", v); };
|
|
416
|
-
H.aspect = (u) => { const a = arb(u.value); if (a) return d("aspect-ratio", a.value); const m = u.value.match(/^(\d+)\/(\d+)$/); return m ? d("aspect-ratio", `${m[1]} / ${m[2]}`) : null; };
|
|
417
|
-
H.columns = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? u.value : u.value === "auto" ? "auto" : CONTAINERS[u.value] ? `${CONTAINERS[u.value]}rem` : null; return v == null ? null : d("columns", v); };
|
|
418
|
-
|
|
419
|
-
// flex / grid
|
|
420
|
-
H.flex = (u) => { const a = arb(u.value); if (a) return d("flex", a.value); if (num(u.value)) return d("flex", `${u.value} ${u.value} 0%`); const m = u.value.match(/^(\d+)\/(\d+)$/); return m ? d("flex", `calc(${m[1]} / ${m[2]} * 100%)`) : null; };
|
|
421
|
-
H.grow = (u) => { const a = arb(u.value); return a ? d("flex-grow", a.value) : num(u.value) ? d("flex-grow", u.value) : null; };
|
|
422
|
-
H.shrink = (u) => { const a = arb(u.value); return a ? d("flex-shrink", a.value) : num(u.value) ? d("flex-shrink", u.value) : null; };
|
|
423
|
-
const track = (prop) => (u) => { const a = arb(u.value); if (a) return d(prop, a.value); return num(u.value) && +u.value > 0 ? d(prop, `repeat(${u.value}, minmax(0, 1fr))`) : null; };
|
|
424
|
-
H["grid-cols"] = track("grid-template-columns");
|
|
425
|
-
H["grid-rows"] = track("grid-template-rows");
|
|
426
|
-
const span = (prop) => (u) => { const a = arb(u.value); if (a) return d(prop, a.value); return num(u.value) ? d(prop, `span ${u.value} / span ${u.value}`) : null; };
|
|
427
|
-
H["col-span"] = span("grid-column");
|
|
428
|
-
H["row-span"] = span("grid-row");
|
|
429
|
-
const line = (prop) => (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? (u.neg ? "-" : "") + u.value : null; return v == null ? null : d(prop, v); };
|
|
430
|
-
H["col-start"] = line("grid-column-start"); H["col-end"] = line("grid-column-end"); H["row-start"] = line("grid-row-start"); H["row-end"] = line("grid-row-end");
|
|
431
|
-
H.col = (u) => { const a = arb(u.value); return a ? d("grid-column", a.value) : num(u.value) ? d("grid-column", (u.neg ? "-" : "") + u.value) : null; };
|
|
432
|
-
H.row = (u) => { const a = arb(u.value); return a ? d("grid-row", a.value) : num(u.value) ? d("grid-row", (u.neg ? "-" : "") + u.value) : null; };
|
|
433
|
-
H["auto-cols"] = (u) => { const a = arb(u.value); return a ? d("grid-auto-columns", a.value) : null; };
|
|
434
|
-
H["auto-rows"] = (u) => { const a = arb(u.value); return a ? d("grid-auto-rows", a.value) : null; };
|
|
435
|
-
|
|
436
|
-
// typography
|
|
437
|
-
H.text = (u) => {
|
|
438
|
-
const v = u.value;
|
|
439
|
-
const a = arb(v);
|
|
440
|
-
const sizeDecl = (size, lh) => {
|
|
441
|
-
const out = [["font-size", size]];
|
|
442
|
-
const m = u.mod;
|
|
443
|
-
if (m) {
|
|
444
|
-
const ma = arb(m);
|
|
445
|
-
out.push(["line-height", ma ? ma.value : LEADING[m] || (num(m) ? rem(+m) : m)]);
|
|
446
|
-
} else if (lh) out.push(["line-height", lh]);
|
|
447
|
-
return out;
|
|
448
|
-
};
|
|
449
|
-
if (a) {
|
|
450
|
-
const t = a.type || inferType(a.value);
|
|
451
|
-
if (t === "length" || t === "percentage" || t === "absolute-size" || t === "relative-size") return sizeDecl(a.value);
|
|
452
|
-
if (t === "color") { const c = color(v, u.mod, u.ctx, { hinted: true }); return c == null ? null : d("color", c); }
|
|
453
|
-
if (a.type === null && /^var\(/.test(a.value)) { const c = color(v, u.mod, u.ctx, { hinted: true }); return d("color", c); }
|
|
454
|
-
if (a.type === "number" || t === "number") return sizeDecl(a.value + "px");
|
|
455
|
-
return null;
|
|
456
|
-
}
|
|
457
|
-
if (u.ctx.hasTheme(`--text-${v}`)) return sizeDecl(`var(--text-${v})`, u.ctx.hasTheme(`--text-${v}--line-height`) ? `var(--text-${v}--line-height)` : undefined);
|
|
458
|
-
if (FONT_SIZES[v]) return sizeDecl(...FONT_SIZES[v]);
|
|
459
|
-
const c = color(v, u.mod, u.ctx);
|
|
460
|
-
return c == null ? null : d("color", c);
|
|
461
|
-
};
|
|
462
|
-
H.font = (u) => {
|
|
463
|
-
const v = u.value; const a = arb(v);
|
|
464
|
-
if (a) {
|
|
465
|
-
if (a.type === "family-name" || /[a-z]/i.test(a.value) && !/^\d/.test(a.value) && a.type !== "number") return d("font-family", a.value);
|
|
466
|
-
return d("font-weight", a.value);
|
|
467
|
-
}
|
|
468
|
-
if (WEIGHTS[v] != null) return d("font-weight", u.ctx.hasTheme(`--font-weight-${v}`) ? `var(--font-weight-${v})` : String(WEIGHTS[v]));
|
|
469
|
-
if (u.ctx.hasTheme(`--font-${v}`)) return d("font-family", `var(--font-${v})`);
|
|
470
|
-
if (FAMILIES[v]) return d("font-family", FAMILIES[v]);
|
|
471
|
-
return null;
|
|
472
|
-
};
|
|
473
|
-
H.leading = (u) => {
|
|
474
|
-
const a = arb(u.value); if (a) return d("line-height", a.value);
|
|
475
|
-
if (LEADING[u.value]) return d("line-height", LEADING[u.value]);
|
|
476
|
-
const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("line-height", v);
|
|
477
|
-
};
|
|
478
|
-
H.tracking = (u) => { const a = arb(u.value); const v = a ? a.value : TRACKING[u.value]; return v == null ? null : d("letter-spacing", u.neg ? negate(v) : v); };
|
|
479
|
-
H.indent = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("text-indent", v); };
|
|
480
|
-
H["line-clamp"] = (u) => {
|
|
481
|
-
const a = arb(u.value); const n = a ? a.value : num(u.value) ? u.value : null;
|
|
482
|
-
return n == null ? null : [["overflow", "hidden"], ["display", "-webkit-box"], ["-webkit-box-orient", "vertical"], ["-webkit-line-clamp", n], ["line-clamp", n]];
|
|
483
|
-
};
|
|
484
|
-
H["underline-offset"] = (u) => { const v = lenOrNum(u, "px"); return v == null ? null : d("text-underline-offset", v); };
|
|
485
|
-
H.decoration = (u) => {
|
|
486
|
-
const a = arb(u.value);
|
|
487
|
-
if (num(u.value)) return d("text-decoration-thickness", `${u.value}px`);
|
|
488
|
-
if (a && (a.type === "length" || inferType(a.value) === "length")) return d("text-decoration-thickness", a.value);
|
|
489
|
-
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("text-decoration-color", c);
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
// colors
|
|
493
|
-
H.bg = (u) => {
|
|
494
|
-
const v = u.value; const a = arb(v);
|
|
495
|
-
if (a) {
|
|
496
|
-
const t = a.type || inferType(a.value);
|
|
497
|
-
if (t === "image" || a.type === "url") return d("background-image", a.value);
|
|
498
|
-
if (t === "length" || t === "size" || t === "bg-size" || t === "percentage") return d(a.type === "position" ? "background-position" : "background-size", a.value);
|
|
499
|
-
if (t === "position") return d("background-position", a.value);
|
|
500
|
-
const c = color(v, u.mod, u.ctx, { hinted: true }); return c == null ? null : d("background-color", c);
|
|
501
|
-
}
|
|
502
|
-
const lin = v.match(/^(?:gradient|linear)-to-(t|tr|r|br|b|bl|l|tl)$/);
|
|
503
|
-
if (lin) return [["background-image", `linear-gradient(${GRADIENT_DIRS[lin[1]]}, ${STOPS})`]];
|
|
504
|
-
const ang = v.match(/^linear-(\d+)$/);
|
|
505
|
-
if (ang) return [["background-image", `linear-gradient(${u.neg ? "-" : ""}${ang[1]}deg, ${STOPS})`]];
|
|
506
|
-
if (v === "radial") return d("background-image", `radial-gradient(in oklab, ${STOPS})`);
|
|
507
|
-
if (v === "conic") return d("background-image", `conic-gradient(from 0deg, ${STOPS})`);
|
|
508
|
-
const c = color(v, u.mod, u.ctx); return c == null ? null : d("background-color", c);
|
|
509
|
-
};
|
|
510
|
-
H.from = stopHandler("from"); H.via = stopHandler("via"); H.to = stopHandler("to");
|
|
511
|
-
H.fill = colorDecl("fill");
|
|
512
|
-
H.stroke = (u) => {
|
|
513
|
-
const a = arb(u.value);
|
|
514
|
-
if (num(u.value)) return d("stroke-width", u.value);
|
|
515
|
-
if (a && (a.type === "length" || a.type === "number" || inferType(a.value) === "length")) return d("stroke-width", a.value);
|
|
516
|
-
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("stroke", c);
|
|
517
|
-
};
|
|
518
|
-
H.accent = colorDecl("accent-color");
|
|
519
|
-
H.caret = colorDecl("caret-color");
|
|
520
|
-
H.placeholder = (u) => { const c = color(u.value, u.mod, u.ctx); return c == null ? null : { decls: d("color", c), tail: "::placeholder" }; };
|
|
521
|
-
|
|
522
|
-
// borders & radius
|
|
523
|
-
const borderSides = { "": "", x: "-inline", y: "-block", t: "-top", r: "-right", b: "-bottom", l: "-left", s: "-inline-start", e: "-inline-end" };
|
|
524
|
-
for (const [k, side] of Object.entries(borderSides)) {
|
|
525
|
-
const root = k ? `border-${k}` : "border";
|
|
526
|
-
H[root] = (u) => {
|
|
527
|
-
if (u.value === "") return d(`border${side}-width`, "1px");
|
|
528
|
-
return widthOrColor(u, `border${side}-width`, `border${side}-color`);
|
|
529
|
-
};
|
|
530
|
-
}
|
|
531
|
-
H["border-spacing"] = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("border-spacing", v); };
|
|
532
|
-
const divide = (axis) => (u) => {
|
|
533
|
-
if (u.value === "" ) return { decls: [[`border-${axis}-width`, "1px"], ["border-style", "solid"]], tail: " > :not(:first-child)" };
|
|
534
|
-
if (u.value === "reverse") return null;
|
|
535
|
-
const r = widthOrColor(u, `border-${axis}-width`, "border-color");
|
|
536
|
-
if (!r) return null;
|
|
537
|
-
return { decls: r, tail: " > :not(:first-child)" };
|
|
538
|
-
};
|
|
539
|
-
H["divide-x"] = divide("inline-start");
|
|
540
|
-
H["divide-y"] = divide("block-start");
|
|
541
|
-
H.divide = (u) => { const c = color(u.value, u.mod, u.ctx); return c == null ? null : { decls: d("border-color", c), tail: " > :not(:first-child)" }; };
|
|
542
|
-
|
|
543
|
-
const radiusCorners = { "": ["border-radius"], t: ["border-top-left-radius", "border-top-right-radius"], r: ["border-top-right-radius", "border-bottom-right-radius"], b: ["border-bottom-right-radius", "border-bottom-left-radius"], l: ["border-top-left-radius", "border-bottom-left-radius"],
|
|
544
|
-
tl: ["border-top-left-radius"], tr: ["border-top-right-radius"], br: ["border-bottom-right-radius"], bl: ["border-bottom-left-radius"],
|
|
545
|
-
s: ["border-start-start-radius", "border-end-start-radius"], e: ["border-start-end-radius", "border-end-end-radius"], ss: ["border-start-start-radius"], se: ["border-start-end-radius"], ee: ["border-end-end-radius"], es: ["border-end-start-radius"] };
|
|
546
|
-
for (const [k, props] of Object.entries(radiusCorners)) {
|
|
547
|
-
H[k ? `rounded-${k}` : "rounded"] = (u) => {
|
|
548
|
-
const v = u.value || "DEFAULT";
|
|
549
|
-
const a = arb(v);
|
|
550
|
-
let val;
|
|
551
|
-
if (a) val = a.value;
|
|
552
|
-
else if (u.ctx.hasTheme(`--radius-${v}`) && v !== "DEFAULT") val = `var(--radius-${v})`;
|
|
553
|
-
else if (v === "DEFAULT" && u.ctx.hasTheme("--radius") && false) val = "var(--radius)";
|
|
554
|
-
else if (!u.ctx.v4 && RADIUS_V3[v]) val = RADIUS_V3[v];
|
|
555
|
-
else if (RADIUS[v]) val = RADIUS[v];
|
|
556
|
-
else return null;
|
|
557
|
-
if (val === "calc(infinity * 1px)") val = "9999px";
|
|
558
|
-
return props.map((p) => [p, val]);
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
// effects
|
|
563
|
-
H.opacity = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? frac(u.value) : null; return v == null ? null : d("opacity", v); };
|
|
564
|
-
H.shadow = (u) => {
|
|
565
|
-
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
566
|
-
if (a) {
|
|
567
|
-
if (a.type === "color" || (!a.type && inferType(a.value) === "color")) { const c = color(v, u.mod, u.ctx, { hinted: true }); return d("--oc-shadow-color", c); }
|
|
568
|
-
const val = a.value;
|
|
569
|
-
return [["--oc-shadow", val], SHADOW_COMPOSE];
|
|
570
|
-
}
|
|
571
|
-
if (u.ctx.hasTheme(`--shadow-${v}`) && v !== "DEFAULT") return [["--oc-shadow", `var(--shadow-${v})`], SHADOW_COMPOSE];
|
|
572
|
-
const known = v === "none" || v === "inner" || Object.hasOwn(SHADOWS, v) || v === "3xl";
|
|
573
|
-
if (known && v !== "3xl") { const s = SHADOW_NAMES(v, u.ctx); if (s) return [["--oc-shadow", s], SHADOW_COMPOSE]; }
|
|
574
|
-
const c = color(v, u.mod, u.ctx); return c == null ? null : d("--oc-shadow-color", c);
|
|
575
|
-
};
|
|
576
|
-
H["inset-shadow"] = (u) => {
|
|
577
|
-
const v = u.value || "sm"; const a = arb(v);
|
|
578
|
-
if (a) return [["--oc-inset-shadow", `inset ${a.value}`], SHADOW_COMPOSE];
|
|
579
|
-
const map = { "2xs": "inset 0 1px 0 0", xs: "inset 0 1px 1px 0", sm: "inset 0 2px 4px 0" };
|
|
580
|
-
if (map[v]) return [["--oc-inset-shadow", `${map[v]} oklch(from var(--oc-shadow-color, ${BLACK}) l c h / 0.1)`], SHADOW_COMPOSE];
|
|
581
|
-
const c = color(v, u.mod, u.ctx); return c == null ? null : d("--oc-shadow-color", c);
|
|
582
|
-
};
|
|
583
|
-
H.ring = (u) => {
|
|
584
|
-
const v = u.value;
|
|
585
|
-
if (v === "") return ringShadow(u.ctx.v4 ? "1px" : "3px");
|
|
586
|
-
if (v === "inset") return [["--oc-ring-inset", "inset"]];
|
|
587
|
-
if (num(u.value)) return ringShadow(`${u.value}px`);
|
|
588
|
-
const a = arb(v); if (a && (a.type === "length" || inferType(a.value) === "length")) return ringShadow(a.value);
|
|
589
|
-
const c = color(v, u.mod, u.ctx); return c == null ? null : d("--oc-ring-color", c);
|
|
590
|
-
};
|
|
591
|
-
H["inset-ring"] = (u) => {
|
|
592
|
-
if (u.value === "") return ringShadow("1px", true);
|
|
593
|
-
if (num(u.value)) return ringShadow(`${u.value}px`, true);
|
|
594
|
-
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("--oc-inset-ring-color", c);
|
|
595
|
-
};
|
|
596
|
-
H["ring-offset"] = (u) => {
|
|
597
|
-
if (num(u.value)) return [["--oc-ring-offset-width", `${u.value}px`], ["--oc-ring-offset-shadow", "0 0 0 var(--oc-ring-offset-width) var(--oc-ring-offset-color, var(--color-white-100))"]];
|
|
598
|
-
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("--oc-ring-offset-color", c);
|
|
599
|
-
};
|
|
600
|
-
H.outline = (u) => {
|
|
601
|
-
if (u.value === "") return [["outline-style", "solid"], ["outline-width", "1px"]];
|
|
602
|
-
return widthOrColor(u, "outline-width", "outline-color");
|
|
603
|
-
};
|
|
604
|
-
H["outline-offset"] = (u) => { const v = lenOrNum(u, "px"); return v == null ? null : d("outline-offset", v); };
|
|
605
|
-
|
|
606
|
-
// transitions
|
|
607
|
-
H.duration = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? `${u.value}ms` : null; return v == null ? null : [["--oc-duration", v], ["transition-duration", v]]; };
|
|
608
|
-
H.delay = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? `${u.value}ms` : null; return v == null ? null : [["transition-delay", v], ["animation-delay", v]]; };
|
|
609
|
-
H.ease = (u) => { const a = arb(u.value); const v = a ? a.value : EASE[u.value]; return v == null ? null : d("transition-timing-function", v); };
|
|
610
|
-
H.animate = (u) => {
|
|
611
|
-
const a = arb(u.value); if (a) return d("animation", a.value);
|
|
612
|
-
if (ANIMATIONS[u.value]) return { decls: d("animation", ANIMATIONS[u.value]), keyframes: [u.value] };
|
|
613
|
-
return null;
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
// transforms
|
|
617
|
-
H["translate-x"] = translate("x"); H["translate-y"] = translate("y"); H["translate-z"] = translate("z");
|
|
618
|
-
H.translate = (u) => { const v = spacing(u.value, u.ctx, { neg: u.neg, keywords: { full: "100%" } }); return v == null ? null : [["--oc-translate-x", v], ["--oc-translate-y", v], ["translate", "var(--oc-translate-x, 0) var(--oc-translate-y, 0)"]]; };
|
|
619
|
-
H.rotate = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("rotate", v); };
|
|
620
|
-
H["rotate-x"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `rotateX(${v})`); };
|
|
621
|
-
H["rotate-y"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `rotateY(${v})`); };
|
|
622
|
-
H.scale = scaleHandler(""); H["scale-x"] = scaleHandler("x"); H["scale-y"] = scaleHandler("y");
|
|
623
|
-
H["skew-x"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `skewX(${v})`); };
|
|
624
|
-
H["skew-y"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `skewY(${v})`); };
|
|
625
|
-
H.skew = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `skewX(${v}) skewY(${v})`); };
|
|
626
|
-
H.origin = (u) => { const a = arb(u.value); return a ? d("transform-origin", a.value) : null; };
|
|
627
|
-
H.perspective = (u) => { const a = arb(u.value); const m = { none: "none", dramatic: "100px", near: "300px", normal: "500px", midrange: "800px", distant: "1200px" }; const v = a ? a.value : m[u.value]; return v == null ? null : d("perspective", v); };
|
|
628
|
-
|
|
629
|
-
// filters
|
|
630
|
-
H.blur = (u) => {
|
|
631
|
-
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
632
|
-
let val = a ? a.value : u.ctx.v4 ? BLUR[v] : BLUR_V3[v];
|
|
633
|
-
if (v === "none") val = "";
|
|
634
|
-
if (val == null) return null;
|
|
635
|
-
return [["--oc-blur", val ? `blur(${val})` : "blur(0)"], ...filterCompose(false)];
|
|
636
|
-
};
|
|
637
|
-
H.brightness = filterHandler("brightness", "brightness");
|
|
638
|
-
H.contrast = filterHandler("contrast", "contrast");
|
|
639
|
-
H.grayscale = (u) => filterHandler("grayscale", "grayscale", { scale: (v) => frac(v) })(u.value === "" ? { ...u, value: "100" } : u);
|
|
640
|
-
H.invert = (u) => filterHandler("invert", "invert")(u.value === "" ? { ...u, value: "100" } : u);
|
|
641
|
-
H.sepia = (u) => filterHandler("sepia", "sepia")(u.value === "" ? { ...u, value: "100" } : u);
|
|
642
|
-
H.saturate = filterHandler("saturate", "saturate");
|
|
643
|
-
H["hue-rotate"] = filterHandler("hue-rotate", "hue-rotate", { scale: (v) => v, unit: "deg" });
|
|
644
|
-
H["drop-shadow"] = (u) => {
|
|
645
|
-
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
646
|
-
const map = { xs: "0 1px 1px", sm: "0 1px 2px", DEFAULT: "0 1px 2px", md: "0 3px 3px", lg: "0 4px 4px", xl: "0 9px 7px", "2xl": "0 25px 25px" };
|
|
647
|
-
const alpha = { xs: 0.05, sm: 0.15, DEFAULT: 0.1, md: 0.12, lg: 0.15, xl: 0.1, "2xl": 0.15 };
|
|
648
|
-
let val;
|
|
649
|
-
if (a) val = a.value; else if (map[v]) val = `${map[v]} oklch(from var(--oc-shadow-color, ${BLACK}) l c h / ${alpha[v]})`; else if (v === "none") val = "0 0 transparent"; else return null;
|
|
650
|
-
return [["--oc-drop-shadow", `drop-shadow(${val})`], ...filterCompose(false)];
|
|
651
|
-
};
|
|
652
|
-
H["backdrop-blur"] = (u) => {
|
|
653
|
-
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
654
|
-
const val = a ? a.value : u.ctx.v4 ? BLUR[v] : BLUR_V3[v];
|
|
655
|
-
if (val == null) return null;
|
|
656
|
-
return [["--oc-bd-blur", `blur(${val || 0})`], ...filterCompose(true)];
|
|
657
|
-
};
|
|
658
|
-
H["backdrop-brightness"] = filterHandler("brightness", "brightness", { backdrop: true });
|
|
659
|
-
H["backdrop-contrast"] = filterHandler("contrast", "contrast", { backdrop: true });
|
|
660
|
-
H["backdrop-grayscale"] = (u) => filterHandler("grayscale", "grayscale", { backdrop: true })(u.value === "" ? { ...u, value: "100" } : u);
|
|
661
|
-
H["backdrop-invert"] = (u) => filterHandler("invert", "invert", { backdrop: true })(u.value === "" ? { ...u, value: "100" } : u);
|
|
662
|
-
H["backdrop-opacity"] = filterHandler("opacity", "opacity", { backdrop: true });
|
|
663
|
-
H["backdrop-saturate"] = filterHandler("saturate", "saturate", { backdrop: true });
|
|
664
|
-
H["backdrop-sepia"] = (u) => filterHandler("sepia", "sepia", { backdrop: true })(u.value === "" ? { ...u, value: "100" } : u);
|
|
665
|
-
H["backdrop-hue-rotate"] = filterHandler("hue-rotate", "hue-rotate", { backdrop: true, scale: (v) => v, unit: "deg" });
|
|
666
|
-
|
|
667
|
-
// misc
|
|
668
|
-
H.cursor = (u) => { const a = arb(u.value); const v = a ? a.value : /^[a-z-]+$/.test(u.value) ? u.value : null; return v == null ? null : d("cursor", v); };
|
|
669
|
-
H.content = (u) => { const a = arb(u.value); return a ? [["--oc-content", a.value], ["content", "var(--oc-content)"]] : null; };
|
|
670
|
-
H.will = (u) => { const a = arb(u.value); return a ? d("will-change", a.value) : null; };
|
|
671
|
-
|
|
672
|
-
// transition-[color,background-color] / text-shadow / wrap / bg-size
|
|
673
|
-
H.transition = (u) => {
|
|
674
|
-
const a = arb(u.value);
|
|
675
|
-
if (!a) return null;
|
|
676
|
-
return [["transition-property", a.value], ["transition-timing-function", "cubic-bezier(0.4, 0, 0.2, 1)"], ["transition-duration", "0.15s"]];
|
|
677
|
-
};
|
|
678
|
-
const TEXT_SHADOWS = { "2xs": "0px 1px 0px 0.15", xs: "0px 1px 1px 0.2", sm: "0px 1px 0px 0.075, 0px 1px 1px 0.075, 0px 2px 2px 0.075", md: "0px 1px 1px 0.1, 0px 1px 2px 0.1, 0px 2px 4px 0.1", lg: "0px 1px 2px 0.1, 0px 3px 2px 0.1, 0px 4px 8px 0.1" };
|
|
679
|
-
H["text-shadow"] = (u) => {
|
|
680
|
-
const a = arb(u.value);
|
|
681
|
-
if (a) return d("text-shadow", a.value);
|
|
682
|
-
if (TEXT_SHADOWS[u.value]) {
|
|
683
|
-
const val = TEXT_SHADOWS[u.value].split(/,\s*/).map((p) => { const parts = p.split(" "); const alpha = parts.pop(); return `${parts.join(" ")} oklch(from var(--oc-shadow-color, ${BLACK}) l c h / ${alpha})`; }).join(", ");
|
|
684
|
-
return d("text-shadow", val);
|
|
685
|
-
}
|
|
686
|
-
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("--oc-shadow-color", c);
|
|
687
|
-
};
|
|
688
|
-
S["wrap-break-word"] = decls("overflow-wrap:break-word");
|
|
689
|
-
S["wrap-anywhere"] = decls("overflow-wrap:anywhere");
|
|
690
|
-
S["wrap-normal"] = decls("overflow-wrap:normal");
|
|
691
|
-
H["bg-size"] = (u) => { const a = arb(u.value); return a ? d("background-size", a.value) : null; };
|
|
692
|
-
H["bg-position"] = (u) => { const a = arb(u.value); return a ? d("background-position", a.value) : null; };
|
|
693
|
-
|
|
694
|
-
// tailwindcss-animate plugin
|
|
695
|
-
const dirs = { top: ["y", -1], bottom: ["y", 1], left: ["x", -1], right: ["x", 1], start: ["x", -1], end: ["x", 1] };
|
|
696
|
-
H["fade-in"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-enter-opacity", String(v)); };
|
|
697
|
-
H["fade-out"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-exit-opacity", String(v)); };
|
|
698
|
-
H["zoom-in"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-enter-scale", String(v)); };
|
|
699
|
-
H["zoom-out"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-exit-scale", String(v)); };
|
|
700
|
-
H["spin-in"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("--oc-enter-rotate", v); };
|
|
701
|
-
H["spin-out"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("--oc-exit-rotate", v); };
|
|
702
|
-
H["slide-in-from"] = (u) => slide(u, "enter");
|
|
703
|
-
H["slide-out-to"] = (u) => slide(u, "exit");
|
|
704
|
-
function slide(u, kind) {
|
|
705
|
-
const [dir, rest] = [u.value.split("-")[0], u.value.split("-").slice(1).join("-")];
|
|
706
|
-
const [axis, sign] = dirs[dir] || [];
|
|
707
|
-
if (!axis) return null;
|
|
708
|
-
const amount = rest === "" ? "100%" : rest === "full" ? "100%" : spacing(rest, u.ctx, {});
|
|
709
|
-
if (amount == null) return null;
|
|
710
|
-
return d(`--oc-${kind}-translate-${axis}`, sign < 0 ? negate(amount) : amount);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
export { S as STATIC, H as HANDLERS, TRANSITION_ALL };
|
|
1
|
+
// File: packages/migrate/src/utilities.mjs
|
|
2
|
+
// Utility table of the compat resolver: Tailwind-style class (without variants) -> declarations.
|
|
3
|
+
// Colors only ever resolve to Omnia palette tokens. Scales are rem based (same numbers as the familiar 0.25rem step).
|
|
4
|
+
// Author: Serge Cools | Framework: OmniaCSS
|
|
5
|
+
|
|
6
|
+
import { arb, color, fmt, frac, inferType, isNum, negate, rem, spacing, withAlpha } from "./values.mjs";
|
|
7
|
+
|
|
8
|
+
/** Parse "a:b;c:d" into [["a","b"],["c","d"]] (semicolons inside parentheses are kept). */
|
|
9
|
+
export function decls(str) {
|
|
10
|
+
const out = [];
|
|
11
|
+
let depth = 0, cur = "";
|
|
12
|
+
for (const ch of str + ";") {
|
|
13
|
+
if (ch === "(") depth++;
|
|
14
|
+
if (ch === ")") depth--;
|
|
15
|
+
if (ch === ";" && depth === 0) {
|
|
16
|
+
const i = cur.indexOf(":");
|
|
17
|
+
if (i > 0 && cur.trim()) out.push([cur.slice(0, i).trim(), cur.slice(i + 1).trim()]);
|
|
18
|
+
cur = "";
|
|
19
|
+
} else cur += ch;
|
|
20
|
+
}
|
|
21
|
+
return out;
|
|
22
|
+
}
|
|
23
|
+
const d = (prop, val) => [[prop, val]];
|
|
24
|
+
|
|
25
|
+
// ---------------------------------------------------------------------------------------------- scales
|
|
26
|
+
|
|
27
|
+
const BLACK = "var(--color-black-50)";
|
|
28
|
+
const sh = (y, blur, spread, a) => `0 ${y}px ${blur}px ${spread}px oklch(from var(--oc-shadow-color, ${BLACK}) l c h / ${a})`;
|
|
29
|
+
/** Omnia's own shadow values (core dist), plus the extra steps. */
|
|
30
|
+
const SHADOWS = {
|
|
31
|
+
"2xs": sh(1, 0, 0, 0.05),
|
|
32
|
+
xs: sh(1, 2, 0, 0.06),
|
|
33
|
+
sm: sh(1, 2, 0, 0.08),
|
|
34
|
+
DEFAULT: `${sh(1, 3, 0, 0.12)}, ${sh(1, 2, -1, 0.1)}`,
|
|
35
|
+
md: `${sh(4, 6, -1, 0.15)}, ${sh(2, 4, -2, 0.12)}`,
|
|
36
|
+
lg: `${sh(10, 15, -3, 0.18)}, ${sh(4, 6, -4, 0.14)}`,
|
|
37
|
+
xl: `${sh(20, 25, -5, 0.22)}, ${sh(8, 10, -6, 0.16)}`,
|
|
38
|
+
"2xl": sh(25, 50, -12, 0.35),
|
|
39
|
+
inner: `inset 0 2px 4px 0 oklch(from var(--oc-shadow-color, ${BLACK}) l c h / 0.12)`,
|
|
40
|
+
};
|
|
41
|
+
// Tailwind 3 naming: shadow-sm = small, shadow = default. Tailwind 4 shifted every name one step down.
|
|
42
|
+
const SHADOW_NAMES = (name, ctx) => {
|
|
43
|
+
if (name === "none") return "0 0 transparent";
|
|
44
|
+
if (name === "inner") return SHADOWS.inner;
|
|
45
|
+
if (ctx.v4) return ({ sm: "DEFAULT" })[name] ? SHADOWS[({ sm: "DEFAULT" })[name]] : SHADOWS[name];
|
|
46
|
+
return SHADOWS[name];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const FONT_SIZES = {
|
|
50
|
+
xs: ["0.75rem", "calc(1 / 0.75)"], sm: ["0.875rem", "calc(1.25 / 0.875)"], base: ["1rem", "calc(1.5 / 1)"], lg: ["1.125rem", "calc(1.75 / 1.125)"],
|
|
51
|
+
xl: ["1.25rem", "calc(1.75 / 1.25)"], "2xl": ["1.5rem", "calc(2 / 1.5)"], "3xl": ["1.875rem", "calc(2.25 / 1.875)"], "4xl": ["2.25rem", "calc(2.5 / 2.25)"],
|
|
52
|
+
"5xl": ["3rem", "1"], "6xl": ["3.75rem", "1"], "7xl": ["4.5rem", "1"], "8xl": ["6rem", "1"], "9xl": ["8rem", "1"],
|
|
53
|
+
};
|
|
54
|
+
const LEADING = { none: "1", tight: "1.25", snug: "1.375", normal: "1.5", relaxed: "1.625", loose: "2" };
|
|
55
|
+
const TRACKING = { tighter: "-0.05em", tight: "-0.025em", normal: "0em", wide: "0.025em", wider: "0.05em", widest: "0.1em" };
|
|
56
|
+
const WEIGHTS = { thin: 100, extralight: 200, light: 300, normal: 400, medium: 500, semibold: 600, bold: 700, extrabold: 800, black: 900 };
|
|
57
|
+
const FAMILIES = {
|
|
58
|
+
sans: 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',
|
|
59
|
+
serif: 'ui-serif, Georgia, Cambria, "Times New Roman", Times, serif',
|
|
60
|
+
mono: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',
|
|
61
|
+
};
|
|
62
|
+
const RADIUS = { none: "0px", xs: "0.125rem", sm: "0.25rem", DEFAULT: "0.25rem", md: "0.375rem", lg: "0.5rem", xl: "0.75rem", "2xl": "1rem", "3xl": "1.5rem", "4xl": "2rem", full: "calc(infinity * 1px)" };
|
|
63
|
+
const RADIUS_V3 = { sm: "0.125rem", DEFAULT: "0.25rem" };
|
|
64
|
+
const CONTAINERS = { "3xs": 16, "2xs": 18, xs: 20, sm: 24, md: 28, lg: 32, xl: 36, "2xl": 42, "3xl": 48, "4xl": 56, "5xl": 64, "6xl": 72, "7xl": 80 };
|
|
65
|
+
const BLUR = { none: "", "3xs": "", xs: "4px", sm: "8px", DEFAULT: "8px", md: "12px", lg: "16px", xl: "24px", "2xl": "40px", "3xl": "64px" };
|
|
66
|
+
const BLUR_V3 = { sm: "4px", DEFAULT: "8px", md: "12px", lg: "16px", xl: "24px", "2xl": "40px", "3xl": "64px" };
|
|
67
|
+
const EASE = { linear: "linear", in: "cubic-bezier(0.4, 0, 1, 1)", out: "cubic-bezier(0, 0, 0.2, 1)", "in-out": "cubic-bezier(0.4, 0, 0.2, 1)" };
|
|
68
|
+
const TRANSITION_ALL = "color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter, display, content-visibility, overlay, pointer-events";
|
|
69
|
+
const TRANSITION_DEFAULT = "color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter";
|
|
70
|
+
const T = (props) => `transition-property:${props};transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:0.15s`;
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------------------------------------- static table
|
|
73
|
+
|
|
74
|
+
const S = {};
|
|
75
|
+
const add = (obj) => { for (const [k, v] of Object.entries(obj)) S[k] = decls(v); };
|
|
76
|
+
|
|
77
|
+
add({
|
|
78
|
+
// display
|
|
79
|
+
block: "display:block", "inline-block": "display:inline-block", inline: "display:inline", flex: "display:flex", "inline-flex": "display:inline-flex",
|
|
80
|
+
grid: "display:grid", "inline-grid": "display:inline-grid", contents: "display:contents", hidden: "display:none", table: "display:table",
|
|
81
|
+
"inline-table": "display:inline-table", "table-row": "display:table-row", "table-cell": "display:table-cell", "table-caption": "display:table-caption",
|
|
82
|
+
"table-column": "display:table-column", "table-column-group": "display:table-column-group", "table-footer-group": "display:table-footer-group",
|
|
83
|
+
"table-header-group": "display:table-header-group", "table-row-group": "display:table-row-group", "flow-root": "display:flow-root", "list-item": "display:list-item",
|
|
84
|
+
visible: "visibility:visible", invisible: "visibility:hidden", collapse: "visibility:collapse",
|
|
85
|
+
"sr-only": "position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border-width:0",
|
|
86
|
+
"not-sr-only": "position:static;width:auto;height:auto;padding:0;margin:0;overflow:visible;clip-path:none;white-space:normal",
|
|
87
|
+
// position
|
|
88
|
+
static: "position:static", fixed: "position:fixed", absolute: "position:absolute", relative: "position:relative", sticky: "position:sticky",
|
|
89
|
+
isolate: "isolation:isolate", "isolation-auto": "isolation:auto",
|
|
90
|
+
// box
|
|
91
|
+
"box-border": "box-sizing:border-box", "box-content": "box-sizing:content-box",
|
|
92
|
+
"float-left": "float:left", "float-right": "float:right", "float-none": "float:none", "float-start": "float:inline-start", "float-end": "float:inline-end",
|
|
93
|
+
"clear-left": "clear:left", "clear-right": "clear:right", "clear-both": "clear:both", "clear-none": "clear:none",
|
|
94
|
+
// flex
|
|
95
|
+
"flex-row": "flex-direction:row", "flex-row-reverse": "flex-direction:row-reverse", "flex-col": "flex-direction:column", "flex-col-reverse": "flex-direction:column-reverse",
|
|
96
|
+
"flex-wrap": "flex-wrap:wrap", "flex-wrap-reverse": "flex-wrap:wrap-reverse", "flex-nowrap": "flex-wrap:nowrap",
|
|
97
|
+
"flex-1": "flex:1", "flex-auto": "flex:1 1 auto", "flex-initial": "flex:0 1 auto", "flex-none": "flex:none",
|
|
98
|
+
grow: "flex-grow:1", "grow-0": "flex-grow:0", "flex-grow": "flex-grow:1", "flex-grow-0": "flex-grow:0",
|
|
99
|
+
shrink: "flex-shrink:1", "shrink-0": "flex-shrink:0", "flex-shrink": "flex-shrink:1", "flex-shrink-0": "flex-shrink:0",
|
|
100
|
+
// alignment
|
|
101
|
+
"justify-normal": "justify-content:normal", "justify-start": "justify-content:flex-start", "justify-end": "justify-content:flex-end", "justify-center": "justify-content:center",
|
|
102
|
+
"justify-between": "justify-content:space-between", "justify-around": "justify-content:space-around", "justify-evenly": "justify-content:space-evenly", "justify-stretch": "justify-content:stretch",
|
|
103
|
+
"justify-center-safe": "justify-content:safe center", "justify-end-safe": "justify-content:safe flex-end",
|
|
104
|
+
"justify-items-start": "justify-items:start", "justify-items-end": "justify-items:end", "justify-items-center": "justify-items:center", "justify-items-stretch": "justify-items:stretch",
|
|
105
|
+
"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",
|
|
106
|
+
"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",
|
|
107
|
+
"items-center-safe": "align-items:safe center", "items-baseline-last": "align-items:last baseline",
|
|
108
|
+
"content-normal": "align-content:normal", "content-center": "align-content:center", "content-start": "align-content:flex-start", "content-end": "align-content:flex-end",
|
|
109
|
+
"content-between": "align-content:space-between", "content-around": "align-content:space-around", "content-evenly": "align-content:space-evenly", "content-baseline": "align-content:baseline", "content-stretch": "align-content:stretch",
|
|
110
|
+
"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",
|
|
111
|
+
"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",
|
|
112
|
+
"place-content-around": "place-content:space-around", "place-content-evenly": "place-content:space-evenly", "place-content-stretch": "place-content:stretch",
|
|
113
|
+
"place-items-start": "place-items:start", "place-items-end": "place-items:end", "place-items-center": "place-items:center", "place-items-baseline": "place-items:baseline", "place-items-stretch": "place-items:stretch",
|
|
114
|
+
"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",
|
|
115
|
+
// grid
|
|
116
|
+
"grid-flow-row": "grid-auto-flow:row", "grid-flow-col": "grid-auto-flow:column", "grid-flow-dense": "grid-auto-flow:dense", "grid-flow-row-dense": "grid-auto-flow:row dense", "grid-flow-col-dense": "grid-auto-flow:column dense",
|
|
117
|
+
"grid-cols-none": "grid-template-columns:none", "grid-cols-subgrid": "grid-template-columns:subgrid", "grid-rows-none": "grid-template-rows:none", "grid-rows-subgrid": "grid-template-rows:subgrid",
|
|
118
|
+
"col-auto": "grid-column:auto", "col-span-full": "grid-column:1 / -1", "row-auto": "grid-row:auto", "row-span-full": "grid-row:1 / -1",
|
|
119
|
+
"col-start-auto": "grid-column-start:auto", "col-end-auto": "grid-column-end:auto", "row-start-auto": "grid-row-start:auto", "row-end-auto": "grid-row-end:auto",
|
|
120
|
+
"auto-cols-auto": "grid-auto-columns:auto", "auto-cols-min": "grid-auto-columns:min-content", "auto-cols-max": "grid-auto-columns:max-content", "auto-cols-fr": "grid-auto-columns:minmax(0, 1fr)",
|
|
121
|
+
"auto-rows-auto": "grid-auto-rows:auto", "auto-rows-min": "grid-auto-rows:min-content", "auto-rows-max": "grid-auto-rows:max-content", "auto-rows-fr": "grid-auto-rows:minmax(0, 1fr)",
|
|
122
|
+
"order-first": "order:-9999", "order-last": "order:9999", "order-none": "order:0",
|
|
123
|
+
// overflow & scroll
|
|
124
|
+
"overflow-auto": "overflow:auto", "overflow-hidden": "overflow:hidden", "overflow-clip": "overflow:clip", "overflow-visible": "overflow:visible", "overflow-scroll": "overflow:scroll",
|
|
125
|
+
"overflow-x-auto": "overflow-x:auto", "overflow-x-hidden": "overflow-x:hidden", "overflow-x-clip": "overflow-x:clip", "overflow-x-visible": "overflow-x:visible", "overflow-x-scroll": "overflow-x:scroll",
|
|
126
|
+
"overflow-y-auto": "overflow-y:auto", "overflow-y-hidden": "overflow-y:hidden", "overflow-y-clip": "overflow-y:clip", "overflow-y-visible": "overflow-y:visible", "overflow-y-scroll": "overflow-y:scroll",
|
|
127
|
+
"overscroll-auto": "overscroll-behavior:auto", "overscroll-contain": "overscroll-behavior:contain", "overscroll-none": "overscroll-behavior:none",
|
|
128
|
+
"overscroll-x-auto": "overscroll-behavior-x:auto", "overscroll-x-contain": "overscroll-behavior-x:contain", "overscroll-x-none": "overscroll-behavior-x:none",
|
|
129
|
+
"overscroll-y-auto": "overscroll-behavior-y:auto", "overscroll-y-contain": "overscroll-behavior-y:contain", "overscroll-y-none": "overscroll-behavior-y:none",
|
|
130
|
+
"scroll-auto": "scroll-behavior:auto", "scroll-smooth": "scroll-behavior:smooth",
|
|
131
|
+
"snap-none": "scroll-snap-type:none", "snap-x": "scroll-snap-type:x var(--oc-snap-strictness, proximity)", "snap-y": "scroll-snap-type:y var(--oc-snap-strictness, proximity)", "snap-both": "scroll-snap-type:both var(--oc-snap-strictness, proximity)",
|
|
132
|
+
"snap-mandatory": "--oc-snap-strictness:mandatory", "snap-proximity": "--oc-snap-strictness:proximity",
|
|
133
|
+
"snap-start": "scroll-snap-align:start", "snap-end": "scroll-snap-align:end", "snap-center": "scroll-snap-align:center", "snap-align-none": "scroll-snap-align:none",
|
|
134
|
+
"snap-normal": "scroll-snap-stop:normal", "snap-always": "scroll-snap-stop:always",
|
|
135
|
+
// typography
|
|
136
|
+
"text-left": "text-align:left", "text-center": "text-align:center", "text-right": "text-align:right", "text-justify": "text-align:justify", "text-start": "text-align:start", "text-end": "text-align:end",
|
|
137
|
+
"text-wrap": "text-wrap:wrap", "text-nowrap": "text-wrap:nowrap", "text-balance": "text-wrap:balance", "text-pretty": "text-wrap:pretty",
|
|
138
|
+
"text-ellipsis": "text-overflow:ellipsis", "text-clip": "text-overflow:clip", truncate: "overflow:hidden;text-overflow:ellipsis;white-space:nowrap",
|
|
139
|
+
uppercase: "text-transform:uppercase", lowercase: "text-transform:lowercase", capitalize: "text-transform:capitalize", "normal-case": "text-transform:none",
|
|
140
|
+
underline: "text-decoration-line:underline", overline: "text-decoration-line:overline", "line-through": "text-decoration-line:line-through", "no-underline": "text-decoration-line:none",
|
|
141
|
+
"decoration-solid": "text-decoration-style:solid", "decoration-double": "text-decoration-style:double", "decoration-dotted": "text-decoration-style:dotted", "decoration-dashed": "text-decoration-style:dashed", "decoration-wavy": "text-decoration-style:wavy",
|
|
142
|
+
"decoration-auto": "text-decoration-thickness:auto", "decoration-from-font": "text-decoration-thickness:from-font",
|
|
143
|
+
"underline-offset-auto": "text-underline-offset:auto",
|
|
144
|
+
italic: "font-style:italic", "not-italic": "font-style:normal", antialiased: "-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale", "subpixel-antialiased": "-webkit-font-smoothing:auto;-moz-osx-font-smoothing:auto",
|
|
145
|
+
"whitespace-normal": "white-space:normal", "whitespace-nowrap": "white-space:nowrap", "whitespace-pre": "white-space:pre", "whitespace-pre-line": "white-space:pre-line", "whitespace-pre-wrap": "white-space:pre-wrap", "whitespace-break-spaces": "white-space:break-spaces",
|
|
146
|
+
"break-normal": "overflow-wrap:normal;word-break:normal", "break-words": "overflow-wrap:break-word", "break-all": "word-break:break-all", "break-keep": "word-break:keep-all",
|
|
147
|
+
"hyphens-none": "hyphens:none", "hyphens-manual": "hyphens:manual", "hyphens-auto": "hyphens:auto",
|
|
148
|
+
"normal-nums": "font-variant-numeric:normal", ordinal: "font-variant-numeric:ordinal", "slashed-zero": "font-variant-numeric:slashed-zero", "lining-nums": "font-variant-numeric:lining-nums",
|
|
149
|
+
"oldstyle-nums": "font-variant-numeric:oldstyle-nums", "proportional-nums": "font-variant-numeric:proportional-nums", "tabular-nums": "font-variant-numeric:tabular-nums",
|
|
150
|
+
"diagonal-fractions": "font-variant-numeric:diagonal-fractions", "stacked-fractions": "font-variant-numeric:stacked-fractions",
|
|
151
|
+
"list-none": "list-style-type:none", "list-disc": "list-style-type:disc", "list-decimal": "list-style-type:decimal", "list-inside": "list-style-position:inside", "list-outside": "list-style-position:outside",
|
|
152
|
+
"align-baseline": "vertical-align:baseline", "align-top": "vertical-align:top", "align-middle": "vertical-align:middle", "align-bottom": "vertical-align:bottom", "align-text-top": "vertical-align:text-top", "align-text-bottom": "vertical-align:text-bottom", "align-sub": "vertical-align:sub", "align-super": "vertical-align:super",
|
|
153
|
+
"line-clamp-none": "overflow:visible;display:block;-webkit-box-orient:horizontal;-webkit-line-clamp:unset;line-clamp:unset",
|
|
154
|
+
// borders
|
|
155
|
+
"border-solid": "border-style:solid", "border-dashed": "border-style:dashed", "border-dotted": "border-style:dotted", "border-double": "border-style:double", "border-hidden": "border-style:hidden", "border-none": "border-style:none",
|
|
156
|
+
"divide-solid": "border-style:solid", "divide-dashed": "border-style:dashed", "divide-dotted": "border-style:dotted", "divide-none": "border-style:none",
|
|
157
|
+
"border-collapse": "border-collapse:collapse", "border-separate": "border-collapse:separate",
|
|
158
|
+
"outline-none": "outline-style:none", "outline-hidden": "outline:2px solid transparent;outline-offset:2px", "outline-solid": "outline-style:solid", "outline-dashed": "outline-style:dashed", "outline-dotted": "outline-style:dotted", "outline-double": "outline-style:double",
|
|
159
|
+
outline: "outline-style:solid;outline-width:1px",
|
|
160
|
+
// backgrounds
|
|
161
|
+
"bg-fixed": "background-attachment:fixed", "bg-local": "background-attachment:local", "bg-scroll": "background-attachment:scroll",
|
|
162
|
+
"bg-clip-border": "background-clip:border-box", "bg-clip-padding": "background-clip:padding-box", "bg-clip-content": "background-clip:content-box", "bg-clip-text": "-webkit-background-clip:text;background-clip:text",
|
|
163
|
+
"bg-origin-border": "background-origin:border-box", "bg-origin-padding": "background-origin:padding-box", "bg-origin-content": "background-origin:content-box",
|
|
164
|
+
"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",
|
|
165
|
+
"bg-auto": "background-size:auto", "bg-cover": "background-size:cover", "bg-contain": "background-size:contain", "bg-none": "background-image:none",
|
|
166
|
+
"bg-center": "background-position:center", "bg-top": "background-position:top", "bg-bottom": "background-position:bottom", "bg-left": "background-position:left", "bg-right": "background-position:right",
|
|
167
|
+
"bg-left-top": "background-position:left top", "bg-left-bottom": "background-position:left bottom", "bg-right-top": "background-position:right top", "bg-right-bottom": "background-position:right bottom",
|
|
168
|
+
"bg-top-left": "background-position:left top", "bg-top-right": "background-position:right top", "bg-bottom-left": "background-position:left bottom", "bg-bottom-right": "background-position:right bottom",
|
|
169
|
+
"bg-blend-normal": "background-blend-mode:normal", "bg-blend-multiply": "background-blend-mode:multiply", "bg-blend-screen": "background-blend-mode:screen", "bg-blend-overlay": "background-blend-mode:overlay",
|
|
170
|
+
// objects
|
|
171
|
+
"object-contain": "object-fit:contain", "object-cover": "object-fit:cover", "object-fill": "object-fit:fill", "object-none": "object-fit:none", "object-scale-down": "object-fit:scale-down",
|
|
172
|
+
"object-center": "object-position:center", "object-top": "object-position:top", "object-bottom": "object-position:bottom", "object-left": "object-position:left", "object-right": "object-position:right",
|
|
173
|
+
"object-left-top": "object-position:left top", "object-right-top": "object-position:right top", "object-left-bottom": "object-position:left bottom", "object-right-bottom": "object-position:right bottom",
|
|
174
|
+
"aspect-auto": "aspect-ratio:auto", "aspect-square": "aspect-ratio:1 / 1", "aspect-video": "aspect-ratio:16 / 9",
|
|
175
|
+
// interactivity
|
|
176
|
+
"pointer-events-none": "pointer-events:none", "pointer-events-auto": "pointer-events:auto",
|
|
177
|
+
"select-none": "-webkit-user-select:none;user-select:none", "select-text": "-webkit-user-select:text;user-select:text", "select-all": "-webkit-user-select:all;user-select:all", "select-auto": "-webkit-user-select:auto;user-select:auto",
|
|
178
|
+
"resize-none": "resize:none", resize: "resize:both", "resize-x": "resize:horizontal", "resize-y": "resize:vertical",
|
|
179
|
+
"appearance-none": "appearance:none", "appearance-auto": "appearance:auto",
|
|
180
|
+
"touch-auto": "touch-action:auto", "touch-none": "touch-action:none", "touch-manipulation": "touch-action:manipulation", "touch-pan-x": "touch-action:pan-x", "touch-pan-y": "touch-action:pan-y", "touch-pinch-zoom": "touch-action:pinch-zoom",
|
|
181
|
+
"will-change-auto": "will-change:auto", "will-change-scroll": "will-change:scroll-position", "will-change-contents": "will-change:contents", "will-change-transform": "will-change:transform",
|
|
182
|
+
"field-sizing-content": "field-sizing:content", "field-sizing-fixed": "field-sizing:fixed",
|
|
183
|
+
"scheme-light": "color-scheme:light", "scheme-dark": "color-scheme:dark", "scheme-light-dark": "color-scheme:light dark", "scheme-normal": "color-scheme:normal",
|
|
184
|
+
// effects
|
|
185
|
+
"mix-blend-normal": "mix-blend-mode:normal", "mix-blend-multiply": "mix-blend-mode:multiply", "mix-blend-screen": "mix-blend-mode:screen", "mix-blend-overlay": "mix-blend-mode:overlay",
|
|
186
|
+
"mix-blend-darken": "mix-blend-mode:darken", "mix-blend-lighten": "mix-blend-mode:lighten", "mix-blend-difference": "mix-blend-mode:difference", "mix-blend-plus-lighter": "mix-blend-mode:plus-lighter",
|
|
187
|
+
// transitions & animation
|
|
188
|
+
transition: T(TRANSITION_DEFAULT), "transition-all": T("all"), "transition-colors": T("color, background-color, border-color, outline-color, text-decoration-color, fill, stroke"),
|
|
189
|
+
"transition-opacity": T("opacity"), "transition-shadow": T("box-shadow"), "transition-transform": T("transform, translate, scale, rotate"), "transition-none": "transition-property:none",
|
|
190
|
+
"transition-discrete": "transition-behavior:allow-discrete", "transition-normal": "transition-behavior:normal",
|
|
191
|
+
"ease-linear": `transition-timing-function:${EASE.linear}`, "ease-in": `transition-timing-function:${EASE.in}`, "ease-out": `transition-timing-function:${EASE.out}`, "ease-in-out": `transition-timing-function:${EASE["in-out"]}`,
|
|
192
|
+
"ease-initial": "transition-timing-function:initial",
|
|
193
|
+
"animate-none": "animation:none",
|
|
194
|
+
// transforms
|
|
195
|
+
"transform-none": "transform:none", "transform-gpu": "transform:translateZ(0)", transform: "", "transform-cpu": "",
|
|
196
|
+
"origin-center": "transform-origin:center", "origin-top": "transform-origin:top", "origin-top-right": "transform-origin:top right", "origin-right": "transform-origin:right",
|
|
197
|
+
"origin-bottom-right": "transform-origin:bottom right", "origin-bottom": "transform-origin:bottom", "origin-bottom-left": "transform-origin:bottom left", "origin-left": "transform-origin:left", "origin-top-left": "transform-origin:top left",
|
|
198
|
+
"backface-visible": "backface-visibility:visible", "backface-hidden": "backface-visibility:hidden",
|
|
199
|
+
"transform-style-3d": "transform-style:preserve-3d", "transform-3d": "transform-style:preserve-3d", "transform-flat": "transform-style:flat",
|
|
200
|
+
// misc
|
|
201
|
+
"container-type-normal": "container-type:normal", "@container": "container-type:inline-size", "@container-normal": "container-type:normal",
|
|
202
|
+
"fill-none": "fill:none", "stroke-none": "stroke:none",
|
|
203
|
+
"table-auto": "table-layout:auto", "table-fixed": "table-layout:fixed", "caption-top": "caption-side:top", "caption-bottom": "caption-side:bottom",
|
|
204
|
+
"filter-none": "filter:none", filter: "", "backdrop-filter-none": "backdrop-filter:none", "backdrop-filter": "",
|
|
205
|
+
"forced-color-adjust-auto": "forced-color-adjust:auto", "forced-color-adjust-none": "forced-color-adjust:none",
|
|
206
|
+
"break-before-auto": "break-before:auto", "break-after-auto": "break-after:auto", "break-inside-avoid": "break-inside:avoid", "break-inside-auto": "break-inside:auto",
|
|
207
|
+
"content-none": "content:none", "text-shadow-none": "text-shadow:none",
|
|
208
|
+
"animate-in": "animation-name:enter;animation-duration:150ms;--oc-enter-opacity:initial;--oc-enter-scale:initial;--oc-enter-rotate:initial;--oc-enter-translate-x:initial;--oc-enter-translate-y:initial",
|
|
209
|
+
"animate-out": "animation-name:exit;animation-duration:150ms;--oc-exit-opacity:initial;--oc-exit-scale:initial;--oc-exit-rotate:initial;--oc-exit-translate-x:initial;--oc-exit-translate-y:initial",
|
|
210
|
+
"running": "animation-play-state:running", "paused": "animation-play-state:paused",
|
|
211
|
+
"fill-mode-none": "animation-fill-mode:none", "fill-mode-forwards": "animation-fill-mode:forwards", "fill-mode-backwards": "animation-fill-mode:backwards", "fill-mode-both": "animation-fill-mode:both",
|
|
212
|
+
"direction-normal": "animation-direction:normal", "direction-reverse": "animation-direction:reverse", "direction-alternate": "animation-direction:alternate", "direction-alternate-reverse": "animation-direction:alternate-reverse",
|
|
213
|
+
"repeat-0": "animation-iteration-count:0", "repeat-1": "animation-iteration-count:1", "repeat-infinite": "animation-iteration-count:infinite",
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
export const KEYFRAMES = {
|
|
217
|
+
spin: "@keyframes spin{to{transform:rotate(360deg)}}",
|
|
218
|
+
ping: "@keyframes ping{75%,100%{transform:scale(2);opacity:0}}",
|
|
219
|
+
pulse: "@keyframes pulse{50%{opacity:0.5}}",
|
|
220
|
+
bounce: "@keyframes bounce{0%,100%{transform:translateY(-25%);animation-timing-function:cubic-bezier(0.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,0.2,1)}}",
|
|
221
|
+
enter: "@keyframes enter{from{opacity:var(--oc-enter-opacity,1);transform:translate3d(var(--oc-enter-translate-x,0),var(--oc-enter-translate-y,0),0) scale3d(var(--oc-enter-scale,1),var(--oc-enter-scale,1),var(--oc-enter-scale,1)) rotate(var(--oc-enter-rotate,0))}}",
|
|
222
|
+
exit: "@keyframes exit{to{opacity:var(--oc-exit-opacity,1);transform:translate3d(var(--oc-exit-translate-x,0),var(--oc-exit-translate-y,0),0) scale3d(var(--oc-exit-scale,1),var(--oc-exit-scale,1),var(--oc-exit-scale,1)) rotate(var(--oc-exit-rotate,0))}}",
|
|
223
|
+
};
|
|
224
|
+
const ANIMATIONS = {
|
|
225
|
+
spin: "spin 1s linear infinite", ping: "ping 1s cubic-bezier(0, 0, 0.2, 1) infinite", pulse: "pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite", bounce: "bounce 1s infinite",
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// ---------------------------------------------------------------------------------------------- handler helpers
|
|
229
|
+
|
|
230
|
+
/** Tokens that only mark an element (no CSS). */
|
|
231
|
+
export const MARKERS = /^(group|peer|dark|light|not-prose|prose-invert|container-query|@container\/[\w-]+|group\/[\w-]+|peer\/[\w-]+|theme-[\w-]+)$/;
|
|
232
|
+
|
|
233
|
+
const num = (v) => isNum(v);
|
|
234
|
+
const sp = (u, v = u.value, o = {}) => spacing(v, u.ctx, { neg: u.neg, ...o });
|
|
235
|
+
const SIZE_KW = { auto: "auto", full: "100%", min: "min-content", max: "max-content", fit: "fit-content", screen: "100vw", svw: "100svw", lvw: "100lvw", dvw: "100dvw", px: "1px" };
|
|
236
|
+
|
|
237
|
+
function sizeValue(u, axis, kind) {
|
|
238
|
+
const v = u.value;
|
|
239
|
+
if (kind === "size") return sp(u, v, { keywords: { ...SIZE_KW, screen: undefined, auto: "auto", full: "100%" } });
|
|
240
|
+
const kw = { ...SIZE_KW };
|
|
241
|
+
if (axis === "h") Object.assign(kw, { screen: "100vh", svh: "100svh", lvh: "100lvh", dvh: "100dvh", lh: "1lh" });
|
|
242
|
+
else Object.assign(kw, { svw: "100svw", lvw: "100lvw", dvw: "100dvw" });
|
|
243
|
+
if (axis === "h") { delete kw.svw; delete kw.lvw; delete kw.dvw; }
|
|
244
|
+
if (kind === "min" || kind === "max") {
|
|
245
|
+
if (kind === "max" && CONTAINERS[v] && axis === "w") return `${CONTAINERS[v]}rem`;
|
|
246
|
+
if (kind === "max" && v === "none") return "none";
|
|
247
|
+
if (kind === "max" && v === "prose") return "65ch";
|
|
248
|
+
if (kind === "max" && axis === "w" && /^screen-/.test(v)) return u.ctx.screens[v.slice(7)] || null;
|
|
249
|
+
if (kind === "max" && v === "screen" && axis === "w") return "100vw";
|
|
250
|
+
if (kind === "min") kw.auto = undefined;
|
|
251
|
+
if (kind === "max") kw.auto = undefined;
|
|
252
|
+
if (kind === "min" && v === "0") return "0px";
|
|
253
|
+
if (kind === "max" && v === "0") return "0px";
|
|
254
|
+
}
|
|
255
|
+
if (kind === "w" && CONTAINERS[v] && v !== "full" && !/^\d/.test(v)) return `${CONTAINERS[v]}rem`;
|
|
256
|
+
return sp(u, v, { keywords: kw });
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const sideProps = (base, sides) => sides.map((s) => (s ? `${base}-${s}` : base));
|
|
260
|
+
const SIDE = { t: "top", r: "right", b: "bottom", l: "left", s: "inline-start", e: "inline-end" };
|
|
261
|
+
|
|
262
|
+
function boxHandler(prop) {
|
|
263
|
+
// m, mx, my, mt … (margin / padding / scroll-margin / scroll-padding)
|
|
264
|
+
return (u, root) => {
|
|
265
|
+
const key = root.slice(prefixLen(prop));
|
|
266
|
+
const v = sp(u, u.value, { keywords: { auto: "auto" }, fractions: false });
|
|
267
|
+
if (v == null) return null;
|
|
268
|
+
if (u.value === "auto" && u.neg) return null;
|
|
269
|
+
const mk = (sides) => sides.map((s) => [s, v]);
|
|
270
|
+
const p = (s) => (s ? `${prop}-${s}` : prop);
|
|
271
|
+
if (key === "") return d(prop, v);
|
|
272
|
+
if (key === "x") return [[`${prop}-inline`, v]];
|
|
273
|
+
if (key === "y") return [[`${prop}-block`, v]];
|
|
274
|
+
if (SIDE[key]) return [[p(SIDE[key]), v]];
|
|
275
|
+
return null;
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
const prefixLen = (prop) => ({ margin: 1, padding: 1, "scroll-margin": 2, "scroll-padding": 2 })[prop];
|
|
279
|
+
|
|
280
|
+
function insetHandler(prop) {
|
|
281
|
+
return (u) => {
|
|
282
|
+
const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } });
|
|
283
|
+
return v == null ? null : d(prop, v);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function colorDecl(prop) {
|
|
288
|
+
return (u) => { const c = color(u.value, u.mod, u.ctx); return c == null ? null : d(prop, c); };
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/** Rule for `from-`, `via-`, `to-` gradient stops. */
|
|
292
|
+
function stopHandler(which) {
|
|
293
|
+
return (u) => {
|
|
294
|
+
const a = arb(u.value);
|
|
295
|
+
if (a && (a.type === "length" || a.type === "percentage" || (!a.type && inferType(a.value) === "length"))) return null;
|
|
296
|
+
if (!a && /^\d+%$/.test(u.value)) return null;
|
|
297
|
+
const c = color(u.value, u.mod, u.ctx);
|
|
298
|
+
if (c == null) return null;
|
|
299
|
+
if (which === "via") return [["--oc-via", c], ["--oc-stops", "var(--oc-from, transparent), var(--oc-via), var(--oc-to, transparent)"]];
|
|
300
|
+
return [[`--oc-${which}`, c]];
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
const GRADIENT_DIRS = { t: "to top", tr: "to top right", r: "to right", br: "to bottom right", b: "to bottom", bl: "to bottom left", l: "to left", tl: "to top left" };
|
|
304
|
+
const STOPS = "var(--oc-stops, var(--oc-from, transparent), var(--oc-to, transparent))";
|
|
305
|
+
|
|
306
|
+
function filterHandler(varName, fnName, { backdrop = false, scale = (v) => frac(v), unit = "" } = {}) {
|
|
307
|
+
return (u) => {
|
|
308
|
+
let val;
|
|
309
|
+
const a = arb(u.value);
|
|
310
|
+
if (a) val = a.value;
|
|
311
|
+
else if (u.value === "") val = "";
|
|
312
|
+
else if (num(u.value)) val = scale(u.value) + unit;
|
|
313
|
+
else return null;
|
|
314
|
+
if (u.neg && val) val = negate(val);
|
|
315
|
+
return [[`--oc-${backdrop ? "bd-" : ""}${varName}`, `${fnName}(${val})`], ...filterCompose(backdrop)];
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
const FILTER_VARS = ["blur", "brightness", "contrast", "grayscale", "hue-rotate", "invert", "saturate", "sepia", "drop-shadow"];
|
|
319
|
+
const BD_VARS = ["blur", "brightness", "contrast", "grayscale", "hue-rotate", "invert", "opacity", "saturate", "sepia"];
|
|
320
|
+
function filterCompose(backdrop) {
|
|
321
|
+
const vars = backdrop ? BD_VARS : FILTER_VARS;
|
|
322
|
+
const pre = backdrop ? "--oc-bd-" : "--oc-";
|
|
323
|
+
const val = vars.map((n) => `var(${pre}${n},)`).join(" ");
|
|
324
|
+
return backdrop ? [["-webkit-backdrop-filter", val], ["backdrop-filter", val]] : [["filter", val]];
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
function ringShadow(width, inset) {
|
|
328
|
+
return [
|
|
329
|
+
[inset ? "--oc-inset-ring-shadow" : "--oc-ring-shadow", `${inset ? "inset " : ""}0 0 0 calc(${width} + var(--oc-ring-offset-width, 0px)) var(${inset ? "--oc-inset-ring-color" : "--oc-ring-color"}, currentColor)`],
|
|
330
|
+
["box-shadow", "var(--oc-inset-shadow, 0 0 transparent), var(--oc-inset-ring-shadow, 0 0 transparent), var(--oc-ring-offset-shadow, 0 0 transparent), var(--oc-ring-shadow, 0 0 transparent), var(--oc-shadow, 0 0 transparent)"],
|
|
331
|
+
];
|
|
332
|
+
}
|
|
333
|
+
const SHADOW_COMPOSE = ["box-shadow", "var(--oc-inset-shadow, 0 0 transparent), var(--oc-inset-ring-shadow, 0 0 transparent), var(--oc-ring-offset-shadow, 0 0 transparent), var(--oc-ring-shadow, 0 0 transparent), var(--oc-shadow, 0 0 transparent)"];
|
|
334
|
+
|
|
335
|
+
function translate(axis) {
|
|
336
|
+
return (u) => {
|
|
337
|
+
let v = u.value;
|
|
338
|
+
const kw = { full: "100%" };
|
|
339
|
+
const val = spacing(v, u.ctx, { neg: u.neg, keywords: kw });
|
|
340
|
+
if (val == null) return null;
|
|
341
|
+
if (axis === "z") return d("translate", `0 0 ${val}`);
|
|
342
|
+
return [[`--oc-translate-${axis}`, val], ["translate", "var(--oc-translate-x, 0) var(--oc-translate-y, 0)"]];
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
function scaleHandler(axis) {
|
|
346
|
+
return (u) => {
|
|
347
|
+
const a = arb(u.value);
|
|
348
|
+
const v = a ? a.value : num(u.value) ? frac(u.value) : null;
|
|
349
|
+
if (v == null) return null;
|
|
350
|
+
const val = u.neg ? negate(v) : v;
|
|
351
|
+
const out = [];
|
|
352
|
+
if (axis !== "y") out.push(["--oc-scale-x", val]);
|
|
353
|
+
if (axis !== "x") out.push(["--oc-scale-y", val]);
|
|
354
|
+
out.push(["scale", "var(--oc-scale-x, 1) var(--oc-scale-y, 1)"]);
|
|
355
|
+
return out;
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function lenOrNum(u, unit, allowNeg = true) {
|
|
360
|
+
const a = arb(u.value);
|
|
361
|
+
let v = a ? a.value : num(u.value) ? u.value + unit : null;
|
|
362
|
+
if (v == null) return null;
|
|
363
|
+
return u.neg && allowNeg ? negate(v) : v;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** `border-*`/`ring-*`/`outline-*`/`divide-*` width-or-color resolver. */
|
|
367
|
+
function widthOrColor(u, widthProp, colorProp, opts = {}) {
|
|
368
|
+
const v = u.value;
|
|
369
|
+
const a = arb(v);
|
|
370
|
+
const widths = opts.widths || ["0", "1", "2", "4", "8"];
|
|
371
|
+
if (a) {
|
|
372
|
+
const t = a.type || (inferType(a.value) === "color" ? "color" : inferType(a.value) === "length" || inferType(a.value) === "number" ? "length" : null);
|
|
373
|
+
if (t === "color") { const c = color(v, u.mod, u.ctx, { hinted: true }); return c == null ? null : d(colorProp, c); }
|
|
374
|
+
if (t === "length" || t === "line-width" || t === "number") return d(widthProp, a.type === "number" || inferType(a.value) === "number" ? a.value + "px" : a.value);
|
|
375
|
+
const c = color(v, u.mod, u.ctx, { hinted: true });
|
|
376
|
+
return c == null ? null : d(colorProp, c);
|
|
377
|
+
}
|
|
378
|
+
if (widths.includes(v)) return d(widthProp, `${v}px`);
|
|
379
|
+
const c = color(v, u.mod, u.ctx);
|
|
380
|
+
return c == null ? null : d(colorProp, c);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// ---------------------------------------------------------------------------------------------- handlers
|
|
384
|
+
|
|
385
|
+
const H = {};
|
|
386
|
+
|
|
387
|
+
// spacing
|
|
388
|
+
for (const root of ["m", "mx", "my", "mt", "mr", "mb", "ml", "ms", "me"]) H[root] = (u) => boxHandler("margin")(u, root);
|
|
389
|
+
for (const root of ["p", "px", "py", "pt", "pr", "pb", "pl", "ps", "pe"]) H[root] = (u) => boxHandler("padding")(u, root);
|
|
390
|
+
for (const root of ["scroll-m", "scroll-mx", "scroll-my", "scroll-mt", "scroll-mr", "scroll-mb", "scroll-ml", "scroll-ms", "scroll-me"]) H[root] = (u) => boxHandler("scroll-margin")(u, root);
|
|
391
|
+
for (const root of ["scroll-p", "scroll-px", "scroll-py", "scroll-pt", "scroll-pr", "scroll-pb", "scroll-pl", "scroll-ps", "scroll-pe"]) H[root] = (u) => boxHandler("scroll-padding")(u, root);
|
|
392
|
+
|
|
393
|
+
H.gap = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("gap", v); };
|
|
394
|
+
H["gap-x"] = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("column-gap", v); };
|
|
395
|
+
H["gap-y"] = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("row-gap", v); };
|
|
396
|
+
H["space-x"] = (u) => { if (u.value === "reverse") return null; const v = sp(u, u.value, { fractions: false }); return v == null ? null : { decls: d("margin-inline-start", v), tail: " > :not(:first-child)" }; };
|
|
397
|
+
H["space-y"] = (u) => { if (u.value === "reverse") return null; const v = sp(u, u.value, { fractions: false }); return v == null ? null : { decls: d("margin-block-start", v), tail: " > :not(:first-child)" }; };
|
|
398
|
+
|
|
399
|
+
// positioning
|
|
400
|
+
H.inset = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } }); return v == null ? null : d("inset", v); };
|
|
401
|
+
H["inset-x"] = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } }); return v == null ? null : d("inset-inline", v); };
|
|
402
|
+
H["inset-y"] = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%" } }); return v == null ? null : d("inset-block", v); };
|
|
403
|
+
for (const [r, p] of [["top", "top"], ["right", "right"], ["bottom", "bottom"], ["left", "left"], ["start", "inset-inline-start"], ["end", "inset-inline-end"]]) H[r] = insetHandler(p);
|
|
404
|
+
H.z = (u) => { const a = arb(u.value); const v = u.value === "auto" ? "auto" : a ? a.value : num(u.value) ? (u.neg ? "-" : "") + u.value : null; return v == null ? null : d("z-index", v); };
|
|
405
|
+
H.order = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? (u.neg ? "-" : "") + u.value : null; return v == null ? null : d("order", v); };
|
|
406
|
+
|
|
407
|
+
// sizing
|
|
408
|
+
H.w = (u) => { const v = sizeValue(u, "w", "w"); return v == null ? null : d("width", v); };
|
|
409
|
+
H.h = (u) => { const v = sizeValue(u, "h", "h"); return v == null ? null : d("height", v); };
|
|
410
|
+
H.size = (u) => { const v = sizeValue(u, "w", "size"); return v == null ? null : [["width", v], ["height", v]]; };
|
|
411
|
+
H["min-w"] = (u) => { const v = sizeValue(u, "w", "min"); return v == null ? null : d("min-width", v); };
|
|
412
|
+
H["max-w"] = (u) => { const v = sizeValue(u, "w", "max"); return v == null ? null : d("max-width", v); };
|
|
413
|
+
H["min-h"] = (u) => { const v = sizeValue(u, "h", "min"); return v == null ? null : d("min-height", v); };
|
|
414
|
+
H["max-h"] = (u) => { const v = sizeValue(u, "h", "max"); return v == null ? null : d("max-height", v); };
|
|
415
|
+
H.basis = (u) => { const v = sp(u, u.value, { keywords: { auto: "auto", full: "100%", ...Object.fromEntries(Object.entries(CONTAINERS).map(([k, n]) => [k, `${n}rem`])) } }); return v == null ? null : d("flex-basis", v); };
|
|
416
|
+
H.aspect = (u) => { const a = arb(u.value); if (a) return d("aspect-ratio", a.value); const m = u.value.match(/^(\d+)\/(\d+)$/); return m ? d("aspect-ratio", `${m[1]} / ${m[2]}`) : null; };
|
|
417
|
+
H.columns = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? u.value : u.value === "auto" ? "auto" : CONTAINERS[u.value] ? `${CONTAINERS[u.value]}rem` : null; return v == null ? null : d("columns", v); };
|
|
418
|
+
|
|
419
|
+
// flex / grid
|
|
420
|
+
H.flex = (u) => { const a = arb(u.value); if (a) return d("flex", a.value); if (num(u.value)) return d("flex", `${u.value} ${u.value} 0%`); const m = u.value.match(/^(\d+)\/(\d+)$/); return m ? d("flex", `calc(${m[1]} / ${m[2]} * 100%)`) : null; };
|
|
421
|
+
H.grow = (u) => { const a = arb(u.value); return a ? d("flex-grow", a.value) : num(u.value) ? d("flex-grow", u.value) : null; };
|
|
422
|
+
H.shrink = (u) => { const a = arb(u.value); return a ? d("flex-shrink", a.value) : num(u.value) ? d("flex-shrink", u.value) : null; };
|
|
423
|
+
const track = (prop) => (u) => { const a = arb(u.value); if (a) return d(prop, a.value); return num(u.value) && +u.value > 0 ? d(prop, `repeat(${u.value}, minmax(0, 1fr))`) : null; };
|
|
424
|
+
H["grid-cols"] = track("grid-template-columns");
|
|
425
|
+
H["grid-rows"] = track("grid-template-rows");
|
|
426
|
+
const span = (prop) => (u) => { const a = arb(u.value); if (a) return d(prop, a.value); return num(u.value) ? d(prop, `span ${u.value} / span ${u.value}`) : null; };
|
|
427
|
+
H["col-span"] = span("grid-column");
|
|
428
|
+
H["row-span"] = span("grid-row");
|
|
429
|
+
const line = (prop) => (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? (u.neg ? "-" : "") + u.value : null; return v == null ? null : d(prop, v); };
|
|
430
|
+
H["col-start"] = line("grid-column-start"); H["col-end"] = line("grid-column-end"); H["row-start"] = line("grid-row-start"); H["row-end"] = line("grid-row-end");
|
|
431
|
+
H.col = (u) => { const a = arb(u.value); return a ? d("grid-column", a.value) : num(u.value) ? d("grid-column", (u.neg ? "-" : "") + u.value) : null; };
|
|
432
|
+
H.row = (u) => { const a = arb(u.value); return a ? d("grid-row", a.value) : num(u.value) ? d("grid-row", (u.neg ? "-" : "") + u.value) : null; };
|
|
433
|
+
H["auto-cols"] = (u) => { const a = arb(u.value); return a ? d("grid-auto-columns", a.value) : null; };
|
|
434
|
+
H["auto-rows"] = (u) => { const a = arb(u.value); return a ? d("grid-auto-rows", a.value) : null; };
|
|
435
|
+
|
|
436
|
+
// typography
|
|
437
|
+
H.text = (u) => {
|
|
438
|
+
const v = u.value;
|
|
439
|
+
const a = arb(v);
|
|
440
|
+
const sizeDecl = (size, lh) => {
|
|
441
|
+
const out = [["font-size", size]];
|
|
442
|
+
const m = u.mod;
|
|
443
|
+
if (m) {
|
|
444
|
+
const ma = arb(m);
|
|
445
|
+
out.push(["line-height", ma ? ma.value : LEADING[m] || (num(m) ? rem(+m) : m)]);
|
|
446
|
+
} else if (lh) out.push(["line-height", lh]);
|
|
447
|
+
return out;
|
|
448
|
+
};
|
|
449
|
+
if (a) {
|
|
450
|
+
const t = a.type || inferType(a.value);
|
|
451
|
+
if (t === "length" || t === "percentage" || t === "absolute-size" || t === "relative-size") return sizeDecl(a.value);
|
|
452
|
+
if (t === "color") { const c = color(v, u.mod, u.ctx, { hinted: true }); return c == null ? null : d("color", c); }
|
|
453
|
+
if (a.type === null && /^var\(/.test(a.value)) { const c = color(v, u.mod, u.ctx, { hinted: true }); return d("color", c); }
|
|
454
|
+
if (a.type === "number" || t === "number") return sizeDecl(a.value + "px");
|
|
455
|
+
return null;
|
|
456
|
+
}
|
|
457
|
+
if (u.ctx.hasTheme(`--text-${v}`)) return sizeDecl(`var(--text-${v})`, u.ctx.hasTheme(`--text-${v}--line-height`) ? `var(--text-${v}--line-height)` : undefined);
|
|
458
|
+
if (FONT_SIZES[v]) return sizeDecl(...FONT_SIZES[v]);
|
|
459
|
+
const c = color(v, u.mod, u.ctx);
|
|
460
|
+
return c == null ? null : d("color", c);
|
|
461
|
+
};
|
|
462
|
+
H.font = (u) => {
|
|
463
|
+
const v = u.value; const a = arb(v);
|
|
464
|
+
if (a) {
|
|
465
|
+
if (a.type === "family-name" || /[a-z]/i.test(a.value) && !/^\d/.test(a.value) && a.type !== "number") return d("font-family", a.value);
|
|
466
|
+
return d("font-weight", a.value);
|
|
467
|
+
}
|
|
468
|
+
if (WEIGHTS[v] != null) return d("font-weight", u.ctx.hasTheme(`--font-weight-${v}`) ? `var(--font-weight-${v})` : String(WEIGHTS[v]));
|
|
469
|
+
if (u.ctx.hasTheme(`--font-${v}`)) return d("font-family", `var(--font-${v})`);
|
|
470
|
+
if (FAMILIES[v]) return d("font-family", FAMILIES[v]);
|
|
471
|
+
return null;
|
|
472
|
+
};
|
|
473
|
+
H.leading = (u) => {
|
|
474
|
+
const a = arb(u.value); if (a) return d("line-height", a.value);
|
|
475
|
+
if (LEADING[u.value]) return d("line-height", LEADING[u.value]);
|
|
476
|
+
const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("line-height", v);
|
|
477
|
+
};
|
|
478
|
+
H.tracking = (u) => { const a = arb(u.value); const v = a ? a.value : TRACKING[u.value]; return v == null ? null : d("letter-spacing", u.neg ? negate(v) : v); };
|
|
479
|
+
H.indent = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("text-indent", v); };
|
|
480
|
+
H["line-clamp"] = (u) => {
|
|
481
|
+
const a = arb(u.value); const n = a ? a.value : num(u.value) ? u.value : null;
|
|
482
|
+
return n == null ? null : [["overflow", "hidden"], ["display", "-webkit-box"], ["-webkit-box-orient", "vertical"], ["-webkit-line-clamp", n], ["line-clamp", n]];
|
|
483
|
+
};
|
|
484
|
+
H["underline-offset"] = (u) => { const v = lenOrNum(u, "px"); return v == null ? null : d("text-underline-offset", v); };
|
|
485
|
+
H.decoration = (u) => {
|
|
486
|
+
const a = arb(u.value);
|
|
487
|
+
if (num(u.value)) return d("text-decoration-thickness", `${u.value}px`);
|
|
488
|
+
if (a && (a.type === "length" || inferType(a.value) === "length")) return d("text-decoration-thickness", a.value);
|
|
489
|
+
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("text-decoration-color", c);
|
|
490
|
+
};
|
|
491
|
+
|
|
492
|
+
// colors
|
|
493
|
+
H.bg = (u) => {
|
|
494
|
+
const v = u.value; const a = arb(v);
|
|
495
|
+
if (a) {
|
|
496
|
+
const t = a.type || inferType(a.value);
|
|
497
|
+
if (t === "image" || a.type === "url") return d("background-image", a.value);
|
|
498
|
+
if (t === "length" || t === "size" || t === "bg-size" || t === "percentage") return d(a.type === "position" ? "background-position" : "background-size", a.value);
|
|
499
|
+
if (t === "position") return d("background-position", a.value);
|
|
500
|
+
const c = color(v, u.mod, u.ctx, { hinted: true }); return c == null ? null : d("background-color", c);
|
|
501
|
+
}
|
|
502
|
+
const lin = v.match(/^(?:gradient|linear)-to-(t|tr|r|br|b|bl|l|tl)$/);
|
|
503
|
+
if (lin) return [["background-image", `linear-gradient(${GRADIENT_DIRS[lin[1]]}, ${STOPS})`]];
|
|
504
|
+
const ang = v.match(/^linear-(\d+)$/);
|
|
505
|
+
if (ang) return [["background-image", `linear-gradient(${u.neg ? "-" : ""}${ang[1]}deg, ${STOPS})`]];
|
|
506
|
+
if (v === "radial") return d("background-image", `radial-gradient(in oklab, ${STOPS})`);
|
|
507
|
+
if (v === "conic") return d("background-image", `conic-gradient(from 0deg, ${STOPS})`);
|
|
508
|
+
const c = color(v, u.mod, u.ctx); return c == null ? null : d("background-color", c);
|
|
509
|
+
};
|
|
510
|
+
H.from = stopHandler("from"); H.via = stopHandler("via"); H.to = stopHandler("to");
|
|
511
|
+
H.fill = colorDecl("fill");
|
|
512
|
+
H.stroke = (u) => {
|
|
513
|
+
const a = arb(u.value);
|
|
514
|
+
if (num(u.value)) return d("stroke-width", u.value);
|
|
515
|
+
if (a && (a.type === "length" || a.type === "number" || inferType(a.value) === "length")) return d("stroke-width", a.value);
|
|
516
|
+
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("stroke", c);
|
|
517
|
+
};
|
|
518
|
+
H.accent = colorDecl("accent-color");
|
|
519
|
+
H.caret = colorDecl("caret-color");
|
|
520
|
+
H.placeholder = (u) => { const c = color(u.value, u.mod, u.ctx); return c == null ? null : { decls: d("color", c), tail: "::placeholder" }; };
|
|
521
|
+
|
|
522
|
+
// borders & radius
|
|
523
|
+
const borderSides = { "": "", x: "-inline", y: "-block", t: "-top", r: "-right", b: "-bottom", l: "-left", s: "-inline-start", e: "-inline-end" };
|
|
524
|
+
for (const [k, side] of Object.entries(borderSides)) {
|
|
525
|
+
const root = k ? `border-${k}` : "border";
|
|
526
|
+
H[root] = (u) => {
|
|
527
|
+
if (u.value === "") return d(`border${side}-width`, "1px");
|
|
528
|
+
return widthOrColor(u, `border${side}-width`, `border${side}-color`);
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
H["border-spacing"] = (u) => { const v = sp(u, u.value, { fractions: false }); return v == null ? null : d("border-spacing", v); };
|
|
532
|
+
const divide = (axis) => (u) => {
|
|
533
|
+
if (u.value === "" ) return { decls: [[`border-${axis}-width`, "1px"], ["border-style", "solid"]], tail: " > :not(:first-child)" };
|
|
534
|
+
if (u.value === "reverse") return null;
|
|
535
|
+
const r = widthOrColor(u, `border-${axis}-width`, "border-color");
|
|
536
|
+
if (!r) return null;
|
|
537
|
+
return { decls: r, tail: " > :not(:first-child)" };
|
|
538
|
+
};
|
|
539
|
+
H["divide-x"] = divide("inline-start");
|
|
540
|
+
H["divide-y"] = divide("block-start");
|
|
541
|
+
H.divide = (u) => { const c = color(u.value, u.mod, u.ctx); return c == null ? null : { decls: d("border-color", c), tail: " > :not(:first-child)" }; };
|
|
542
|
+
|
|
543
|
+
const radiusCorners = { "": ["border-radius"], t: ["border-top-left-radius", "border-top-right-radius"], r: ["border-top-right-radius", "border-bottom-right-radius"], b: ["border-bottom-right-radius", "border-bottom-left-radius"], l: ["border-top-left-radius", "border-bottom-left-radius"],
|
|
544
|
+
tl: ["border-top-left-radius"], tr: ["border-top-right-radius"], br: ["border-bottom-right-radius"], bl: ["border-bottom-left-radius"],
|
|
545
|
+
s: ["border-start-start-radius", "border-end-start-radius"], e: ["border-start-end-radius", "border-end-end-radius"], ss: ["border-start-start-radius"], se: ["border-start-end-radius"], ee: ["border-end-end-radius"], es: ["border-end-start-radius"] };
|
|
546
|
+
for (const [k, props] of Object.entries(radiusCorners)) {
|
|
547
|
+
H[k ? `rounded-${k}` : "rounded"] = (u) => {
|
|
548
|
+
const v = u.value || "DEFAULT";
|
|
549
|
+
const a = arb(v);
|
|
550
|
+
let val;
|
|
551
|
+
if (a) val = a.value;
|
|
552
|
+
else if (u.ctx.hasTheme(`--radius-${v}`) && v !== "DEFAULT") val = `var(--radius-${v})`;
|
|
553
|
+
else if (v === "DEFAULT" && u.ctx.hasTheme("--radius") && false) val = "var(--radius)";
|
|
554
|
+
else if (!u.ctx.v4 && RADIUS_V3[v]) val = RADIUS_V3[v];
|
|
555
|
+
else if (RADIUS[v]) val = RADIUS[v];
|
|
556
|
+
else return null;
|
|
557
|
+
if (val === "calc(infinity * 1px)") val = "9999px";
|
|
558
|
+
return props.map((p) => [p, val]);
|
|
559
|
+
};
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// effects
|
|
563
|
+
H.opacity = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? frac(u.value) : null; return v == null ? null : d("opacity", v); };
|
|
564
|
+
H.shadow = (u) => {
|
|
565
|
+
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
566
|
+
if (a) {
|
|
567
|
+
if (a.type === "color" || (!a.type && inferType(a.value) === "color")) { const c = color(v, u.mod, u.ctx, { hinted: true }); return d("--oc-shadow-color", c); }
|
|
568
|
+
const val = a.value;
|
|
569
|
+
return [["--oc-shadow", val], SHADOW_COMPOSE];
|
|
570
|
+
}
|
|
571
|
+
if (u.ctx.hasTheme(`--shadow-${v}`) && v !== "DEFAULT") return [["--oc-shadow", `var(--shadow-${v})`], SHADOW_COMPOSE];
|
|
572
|
+
const known = v === "none" || v === "inner" || Object.hasOwn(SHADOWS, v) || v === "3xl";
|
|
573
|
+
if (known && v !== "3xl") { const s = SHADOW_NAMES(v, u.ctx); if (s) return [["--oc-shadow", s], SHADOW_COMPOSE]; }
|
|
574
|
+
const c = color(v, u.mod, u.ctx); return c == null ? null : d("--oc-shadow-color", c);
|
|
575
|
+
};
|
|
576
|
+
H["inset-shadow"] = (u) => {
|
|
577
|
+
const v = u.value || "sm"; const a = arb(v);
|
|
578
|
+
if (a) return [["--oc-inset-shadow", `inset ${a.value}`], SHADOW_COMPOSE];
|
|
579
|
+
const map = { "2xs": "inset 0 1px 0 0", xs: "inset 0 1px 1px 0", sm: "inset 0 2px 4px 0" };
|
|
580
|
+
if (map[v]) return [["--oc-inset-shadow", `${map[v]} oklch(from var(--oc-shadow-color, ${BLACK}) l c h / 0.1)`], SHADOW_COMPOSE];
|
|
581
|
+
const c = color(v, u.mod, u.ctx); return c == null ? null : d("--oc-shadow-color", c);
|
|
582
|
+
};
|
|
583
|
+
H.ring = (u) => {
|
|
584
|
+
const v = u.value;
|
|
585
|
+
if (v === "") return ringShadow(u.ctx.v4 ? "1px" : "3px");
|
|
586
|
+
if (v === "inset") return [["--oc-ring-inset", "inset"]];
|
|
587
|
+
if (num(u.value)) return ringShadow(`${u.value}px`);
|
|
588
|
+
const a = arb(v); if (a && (a.type === "length" || inferType(a.value) === "length")) return ringShadow(a.value);
|
|
589
|
+
const c = color(v, u.mod, u.ctx); return c == null ? null : d("--oc-ring-color", c);
|
|
590
|
+
};
|
|
591
|
+
H["inset-ring"] = (u) => {
|
|
592
|
+
if (u.value === "") return ringShadow("1px", true);
|
|
593
|
+
if (num(u.value)) return ringShadow(`${u.value}px`, true);
|
|
594
|
+
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("--oc-inset-ring-color", c);
|
|
595
|
+
};
|
|
596
|
+
H["ring-offset"] = (u) => {
|
|
597
|
+
if (num(u.value)) return [["--oc-ring-offset-width", `${u.value}px`], ["--oc-ring-offset-shadow", "0 0 0 var(--oc-ring-offset-width) var(--oc-ring-offset-color, var(--color-white-100))"]];
|
|
598
|
+
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("--oc-ring-offset-color", c);
|
|
599
|
+
};
|
|
600
|
+
H.outline = (u) => {
|
|
601
|
+
if (u.value === "") return [["outline-style", "solid"], ["outline-width", "1px"]];
|
|
602
|
+
return widthOrColor(u, "outline-width", "outline-color");
|
|
603
|
+
};
|
|
604
|
+
H["outline-offset"] = (u) => { const v = lenOrNum(u, "px"); return v == null ? null : d("outline-offset", v); };
|
|
605
|
+
|
|
606
|
+
// transitions
|
|
607
|
+
H.duration = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? `${u.value}ms` : null; return v == null ? null : [["--oc-duration", v], ["transition-duration", v]]; };
|
|
608
|
+
H.delay = (u) => { const a = arb(u.value); const v = a ? a.value : num(u.value) ? `${u.value}ms` : null; return v == null ? null : [["transition-delay", v], ["animation-delay", v]]; };
|
|
609
|
+
H.ease = (u) => { const a = arb(u.value); const v = a ? a.value : EASE[u.value]; return v == null ? null : d("transition-timing-function", v); };
|
|
610
|
+
H.animate = (u) => {
|
|
611
|
+
const a = arb(u.value); if (a) return d("animation", a.value);
|
|
612
|
+
if (ANIMATIONS[u.value]) return { decls: d("animation", ANIMATIONS[u.value]), keyframes: [u.value] };
|
|
613
|
+
return null;
|
|
614
|
+
};
|
|
615
|
+
|
|
616
|
+
// transforms
|
|
617
|
+
H["translate-x"] = translate("x"); H["translate-y"] = translate("y"); H["translate-z"] = translate("z");
|
|
618
|
+
H.translate = (u) => { const v = spacing(u.value, u.ctx, { neg: u.neg, keywords: { full: "100%" } }); return v == null ? null : [["--oc-translate-x", v], ["--oc-translate-y", v], ["translate", "var(--oc-translate-x, 0) var(--oc-translate-y, 0)"]]; };
|
|
619
|
+
H.rotate = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("rotate", v); };
|
|
620
|
+
H["rotate-x"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `rotateX(${v})`); };
|
|
621
|
+
H["rotate-y"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `rotateY(${v})`); };
|
|
622
|
+
H.scale = scaleHandler(""); H["scale-x"] = scaleHandler("x"); H["scale-y"] = scaleHandler("y");
|
|
623
|
+
H["skew-x"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `skewX(${v})`); };
|
|
624
|
+
H["skew-y"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `skewY(${v})`); };
|
|
625
|
+
H.skew = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("transform", `skewX(${v}) skewY(${v})`); };
|
|
626
|
+
H.origin = (u) => { const a = arb(u.value); return a ? d("transform-origin", a.value) : null; };
|
|
627
|
+
H.perspective = (u) => { const a = arb(u.value); const m = { none: "none", dramatic: "100px", near: "300px", normal: "500px", midrange: "800px", distant: "1200px" }; const v = a ? a.value : m[u.value]; return v == null ? null : d("perspective", v); };
|
|
628
|
+
|
|
629
|
+
// filters
|
|
630
|
+
H.blur = (u) => {
|
|
631
|
+
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
632
|
+
let val = a ? a.value : u.ctx.v4 ? BLUR[v] : BLUR_V3[v];
|
|
633
|
+
if (v === "none") val = "";
|
|
634
|
+
if (val == null) return null;
|
|
635
|
+
return [["--oc-blur", val ? `blur(${val})` : "blur(0)"], ...filterCompose(false)];
|
|
636
|
+
};
|
|
637
|
+
H.brightness = filterHandler("brightness", "brightness");
|
|
638
|
+
H.contrast = filterHandler("contrast", "contrast");
|
|
639
|
+
H.grayscale = (u) => filterHandler("grayscale", "grayscale", { scale: (v) => frac(v) })(u.value === "" ? { ...u, value: "100" } : u);
|
|
640
|
+
H.invert = (u) => filterHandler("invert", "invert")(u.value === "" ? { ...u, value: "100" } : u);
|
|
641
|
+
H.sepia = (u) => filterHandler("sepia", "sepia")(u.value === "" ? { ...u, value: "100" } : u);
|
|
642
|
+
H.saturate = filterHandler("saturate", "saturate");
|
|
643
|
+
H["hue-rotate"] = filterHandler("hue-rotate", "hue-rotate", { scale: (v) => v, unit: "deg" });
|
|
644
|
+
H["drop-shadow"] = (u) => {
|
|
645
|
+
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
646
|
+
const map = { xs: "0 1px 1px", sm: "0 1px 2px", DEFAULT: "0 1px 2px", md: "0 3px 3px", lg: "0 4px 4px", xl: "0 9px 7px", "2xl": "0 25px 25px" };
|
|
647
|
+
const alpha = { xs: 0.05, sm: 0.15, DEFAULT: 0.1, md: 0.12, lg: 0.15, xl: 0.1, "2xl": 0.15 };
|
|
648
|
+
let val;
|
|
649
|
+
if (a) val = a.value; else if (map[v]) val = `${map[v]} oklch(from var(--oc-shadow-color, ${BLACK}) l c h / ${alpha[v]})`; else if (v === "none") val = "0 0 transparent"; else return null;
|
|
650
|
+
return [["--oc-drop-shadow", `drop-shadow(${val})`], ...filterCompose(false)];
|
|
651
|
+
};
|
|
652
|
+
H["backdrop-blur"] = (u) => {
|
|
653
|
+
const v = u.value || "DEFAULT"; const a = arb(v);
|
|
654
|
+
const val = a ? a.value : u.ctx.v4 ? BLUR[v] : BLUR_V3[v];
|
|
655
|
+
if (val == null) return null;
|
|
656
|
+
return [["--oc-bd-blur", `blur(${val || 0})`], ...filterCompose(true)];
|
|
657
|
+
};
|
|
658
|
+
H["backdrop-brightness"] = filterHandler("brightness", "brightness", { backdrop: true });
|
|
659
|
+
H["backdrop-contrast"] = filterHandler("contrast", "contrast", { backdrop: true });
|
|
660
|
+
H["backdrop-grayscale"] = (u) => filterHandler("grayscale", "grayscale", { backdrop: true })(u.value === "" ? { ...u, value: "100" } : u);
|
|
661
|
+
H["backdrop-invert"] = (u) => filterHandler("invert", "invert", { backdrop: true })(u.value === "" ? { ...u, value: "100" } : u);
|
|
662
|
+
H["backdrop-opacity"] = filterHandler("opacity", "opacity", { backdrop: true });
|
|
663
|
+
H["backdrop-saturate"] = filterHandler("saturate", "saturate", { backdrop: true });
|
|
664
|
+
H["backdrop-sepia"] = (u) => filterHandler("sepia", "sepia", { backdrop: true })(u.value === "" ? { ...u, value: "100" } : u);
|
|
665
|
+
H["backdrop-hue-rotate"] = filterHandler("hue-rotate", "hue-rotate", { backdrop: true, scale: (v) => v, unit: "deg" });
|
|
666
|
+
|
|
667
|
+
// misc
|
|
668
|
+
H.cursor = (u) => { const a = arb(u.value); const v = a ? a.value : /^[a-z-]+$/.test(u.value) ? u.value : null; return v == null ? null : d("cursor", v); };
|
|
669
|
+
H.content = (u) => { const a = arb(u.value); return a ? [["--oc-content", a.value], ["content", "var(--oc-content)"]] : null; };
|
|
670
|
+
H.will = (u) => { const a = arb(u.value); return a ? d("will-change", a.value) : null; };
|
|
671
|
+
|
|
672
|
+
// transition-[color,background-color] / text-shadow / wrap / bg-size
|
|
673
|
+
H.transition = (u) => {
|
|
674
|
+
const a = arb(u.value);
|
|
675
|
+
if (!a) return null;
|
|
676
|
+
return [["transition-property", a.value], ["transition-timing-function", "cubic-bezier(0.4, 0, 0.2, 1)"], ["transition-duration", "0.15s"]];
|
|
677
|
+
};
|
|
678
|
+
const TEXT_SHADOWS = { "2xs": "0px 1px 0px 0.15", xs: "0px 1px 1px 0.2", sm: "0px 1px 0px 0.075, 0px 1px 1px 0.075, 0px 2px 2px 0.075", md: "0px 1px 1px 0.1, 0px 1px 2px 0.1, 0px 2px 4px 0.1", lg: "0px 1px 2px 0.1, 0px 3px 2px 0.1, 0px 4px 8px 0.1" };
|
|
679
|
+
H["text-shadow"] = (u) => {
|
|
680
|
+
const a = arb(u.value);
|
|
681
|
+
if (a) return d("text-shadow", a.value);
|
|
682
|
+
if (TEXT_SHADOWS[u.value]) {
|
|
683
|
+
const val = TEXT_SHADOWS[u.value].split(/,\s*/).map((p) => { const parts = p.split(" "); const alpha = parts.pop(); return `${parts.join(" ")} oklch(from var(--oc-shadow-color, ${BLACK}) l c h / ${alpha})`; }).join(", ");
|
|
684
|
+
return d("text-shadow", val);
|
|
685
|
+
}
|
|
686
|
+
const c = color(u.value, u.mod, u.ctx); return c == null ? null : d("--oc-shadow-color", c);
|
|
687
|
+
};
|
|
688
|
+
S["wrap-break-word"] = decls("overflow-wrap:break-word");
|
|
689
|
+
S["wrap-anywhere"] = decls("overflow-wrap:anywhere");
|
|
690
|
+
S["wrap-normal"] = decls("overflow-wrap:normal");
|
|
691
|
+
H["bg-size"] = (u) => { const a = arb(u.value); return a ? d("background-size", a.value) : null; };
|
|
692
|
+
H["bg-position"] = (u) => { const a = arb(u.value); return a ? d("background-position", a.value) : null; };
|
|
693
|
+
|
|
694
|
+
// tailwindcss-animate plugin
|
|
695
|
+
const dirs = { top: ["y", -1], bottom: ["y", 1], left: ["x", -1], right: ["x", 1], start: ["x", -1], end: ["x", 1] };
|
|
696
|
+
H["fade-in"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-enter-opacity", String(v)); };
|
|
697
|
+
H["fade-out"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-exit-opacity", String(v)); };
|
|
698
|
+
H["zoom-in"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-enter-scale", String(v)); };
|
|
699
|
+
H["zoom-out"] = (u) => { const v = u.value === "" ? 0 : num(u.value) ? frac(u.value) : null; return v == null ? null : d("--oc-exit-scale", String(v)); };
|
|
700
|
+
H["spin-in"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("--oc-enter-rotate", v); };
|
|
701
|
+
H["spin-out"] = (u) => { const v = lenOrNum(u, "deg"); return v == null ? null : d("--oc-exit-rotate", v); };
|
|
702
|
+
H["slide-in-from"] = (u) => slide(u, "enter");
|
|
703
|
+
H["slide-out-to"] = (u) => slide(u, "exit");
|
|
704
|
+
function slide(u, kind) {
|
|
705
|
+
const [dir, rest] = [u.value.split("-")[0], u.value.split("-").slice(1).join("-")];
|
|
706
|
+
const [axis, sign] = dirs[dir] || [];
|
|
707
|
+
if (!axis) return null;
|
|
708
|
+
const amount = rest === "" ? "100%" : rest === "full" ? "100%" : spacing(rest, u.ctx, {});
|
|
709
|
+
if (amount == null) return null;
|
|
710
|
+
return d(`--oc-${kind}-translate-${axis}`, sign < 0 ? negate(amount) : amount);
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export { S as STATIC, H as HANDLERS, TRANSITION_ALL };
|