@tenphi/tasty 0.0.0-snapshot.9155dd5 → 0.0.0-snapshot.92cfaf9
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/README.md +208 -248
- package/dist/chunks/definitions.d.ts +1 -1
- package/dist/chunks/definitions.js +1 -1
- package/dist/chunks/definitions.js.map +1 -1
- package/dist/config.d.ts +45 -2
- package/dist/config.js +63 -23
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +4 -4
- package/dist/counter-style/index.js +51 -0
- package/dist/counter-style/index.js.map +1 -0
- package/dist/debug.d.ts +26 -141
- package/dist/debug.js +356 -635
- package/dist/debug.js.map +1 -1
- package/dist/font-face/index.js +63 -0
- package/dist/font-face/index.js.map +1 -0
- package/dist/hooks/resolve-ssr-collector.js +15 -0
- package/dist/hooks/resolve-ssr-collector.js.map +1 -0
- package/dist/hooks/useCounterStyle.d.ts +50 -0
- package/dist/hooks/useCounterStyle.js +47 -0
- package/dist/hooks/useCounterStyle.js.map +1 -0
- package/dist/hooks/useFontFace.d.ts +43 -0
- package/dist/hooks/useFontFace.js +71 -0
- package/dist/hooks/useFontFace.js.map +1 -0
- package/dist/hooks/useGlobalStyles.js +1 -5
- package/dist/hooks/useGlobalStyles.js.map +1 -1
- package/dist/hooks/useKeyframes.js +1 -5
- package/dist/hooks/useKeyframes.js.map +1 -1
- package/dist/hooks/useProperty.js +1 -5
- package/dist/hooks/useProperty.js.map +1 -1
- package/dist/hooks/useRawCSS.js +1 -5
- package/dist/hooks/useRawCSS.js.map +1 -1
- package/dist/hooks/useStyles.js +35 -46
- package/dist/hooks/useStyles.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.js +6 -4
- package/dist/injector/index.d.ts +20 -2
- package/dist/injector/index.js +19 -1
- package/dist/injector/index.js.map +1 -1
- package/dist/injector/injector.d.ts +19 -1
- package/dist/injector/injector.js +35 -0
- package/dist/injector/injector.js.map +1 -1
- package/dist/injector/sheet-manager.js +7 -2
- package/dist/injector/sheet-manager.js.map +1 -1
- package/dist/injector/types.d.ts +61 -1
- package/dist/parser/classify.js +3 -3
- package/dist/parser/classify.js.map +1 -1
- package/dist/parser/const.js +17 -1
- package/dist/parser/const.js.map +1 -1
- package/dist/pipeline/index.d.ts +2 -0
- package/dist/pipeline/index.js +56 -17
- package/dist/pipeline/index.js.map +1 -1
- package/dist/pipeline/materialize.js +0 -1
- package/dist/pipeline/materialize.js.map +1 -1
- package/dist/properties/index.js.map +1 -1
- package/dist/ssr/collector.d.ts +17 -0
- package/dist/ssr/collector.js +50 -6
- package/dist/ssr/collector.js.map +1 -1
- package/dist/ssr/format-rules.js +7 -4
- package/dist/ssr/format-rules.js.map +1 -1
- package/dist/ssr/index.js +1 -1
- package/dist/states/index.js +2 -0
- package/dist/states/index.js.map +1 -1
- package/dist/styles/border.js +2 -2
- package/dist/styles/border.js.map +1 -1
- package/dist/styles/predefined.js +1 -1
- package/dist/styles/predefined.js.map +1 -1
- package/dist/styles/preset.d.ts +5 -0
- package/dist/styles/preset.js +48 -47
- package/dist/styles/preset.js.map +1 -1
- package/dist/styles/types.d.ts +46 -7
- package/dist/tasty.d.ts +30 -892
- package/dist/tasty.js +20 -7
- package/dist/tasty.js.map +1 -1
- package/dist/utils/color-math.d.ts +2 -1
- package/dist/utils/color-math.js +40 -8
- package/dist/utils/color-math.js.map +1 -1
- package/dist/utils/color-space.js +78 -35
- package/dist/utils/color-space.js.map +1 -1
- package/dist/utils/mod-attrs.js +1 -1
- package/dist/utils/mod-attrs.js.map +1 -1
- package/dist/utils/process-tokens.js +1 -1
- package/dist/utils/process-tokens.js.map +1 -1
- package/dist/utils/styles.d.ts +1 -3
- package/dist/utils/styles.js +4 -6
- package/dist/utils/styles.js.map +1 -1
- package/dist/utils/typography.js +8 -0
- package/dist/utils/typography.js.map +1 -1
- package/dist/zero/babel.d.ts +14 -2
- package/dist/zero/babel.js +52 -24
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/extractor.js +53 -1
- package/dist/zero/extractor.js.map +1 -1
- package/docs/PIPELINE.md +1 -1
- package/docs/README.md +31 -0
- package/docs/adoption.md +16 -6
- package/docs/comparison.md +16 -9
- package/docs/configuration.md +65 -2
- package/docs/debug.md +152 -339
- package/docs/design-system.md +26 -3
- package/docs/dsl.md +136 -3
- package/docs/getting-started.md +29 -13
- package/docs/injector.md +2 -2
- package/docs/methodology.md +71 -5
- package/docs/runtime.md +228 -34
- package/docs/ssr.md +5 -3
- package/docs/styles.md +28 -23
- package/docs/tasty-static.md +15 -2
- package/package.json +3 -2
package/dist/styles/preset.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { makeEmptyDetails } from "../parser/types.js";
|
|
2
1
|
import { parseStyle } from "../utils/styles.js";
|
|
3
2
|
|
|
4
3
|
//#region src/styles/preset.ts
|
|
4
|
+
const PRESET_MODIFIERS = new Set([
|
|
5
|
+
"strong",
|
|
6
|
+
"bold",
|
|
7
|
+
"italic",
|
|
8
|
+
"icon",
|
|
9
|
+
"tight"
|
|
10
|
+
]);
|
|
5
11
|
/**
|
|
6
12
|
* Convert a value to CSS, handling numbers as pixels for numeric properties
|
|
7
13
|
*/
|
|
@@ -10,46 +16,40 @@ function toCSS(value, isNumeric) {
|
|
|
10
16
|
if (typeof value === "number") return isNumeric ? `${value}px` : String(value);
|
|
11
17
|
return parseStyle(String(value)).groups[0]?.values[0] || String(value);
|
|
12
18
|
}
|
|
13
|
-
function setCSSValue(styles, styleName, presetName,
|
|
14
|
-
|
|
19
|
+
function setCSSValue(styles, styleName, presetName, { varOnly, cssOnly } = {}) {
|
|
20
|
+
const value = (() => {
|
|
15
21
|
if (presetName === "inherit") return "inherit";
|
|
16
|
-
const defaultValue = `var(--default-${styleName}${styleName === "font-family" ? ", var(--font,
|
|
17
|
-
const fontSuffix = styleName === "font-family" ? ", var(--font, sans-
|
|
22
|
+
const defaultValue = `var(--default-${styleName}${styleName === "font-family" ? ", var(--font-sans, var(--font-sans-fallback))" : ""})`;
|
|
23
|
+
const fontSuffix = styleName === "font-family" ? ", var(--font-sans, var(--font-sans-fallback))" : "";
|
|
18
24
|
if (presetName === "default") return `${defaultValue}${fontSuffix}`;
|
|
19
25
|
else return `var(--${presetName}-${styleName}, ${defaultValue})${fontSuffix}`;
|
|
20
26
|
})();
|
|
21
|
-
if (!
|
|
27
|
+
if (!cssOnly) styles[`--${styleName}`] = value;
|
|
28
|
+
if (!varOnly) styles[styleName] = value;
|
|
22
29
|
}
|
|
23
30
|
/**
|
|
24
31
|
* Resolve font/fontFamily value to CSS font-family string.
|
|
25
32
|
*
|
|
26
|
-
* - `font="monospace"` → var(--
|
|
27
|
-
* - `font={true}` → var(--font)
|
|
28
|
-
* - `font="CustomFont"` → CustomFont, var(--font)
|
|
33
|
+
* - `font="monospace"` → var(--font-mono, var(--font-mono-fallback))
|
|
34
|
+
* - `font={true}` → var(--font-sans, var(--font-sans-fallback))
|
|
35
|
+
* - `font="CustomFont"` → CustomFont, var(--font-sans, var(--font-sans-fallback))
|
|
29
36
|
* - `fontFamily="Arial"` → Arial (direct, no fallback)
|
|
30
37
|
*/
|
|
31
38
|
function resolveFontFamily(font, fontFamily) {
|
|
32
|
-
if (fontFamily) return
|
|
33
|
-
value: fontFamily,
|
|
34
|
-
setVar: false
|
|
35
|
-
};
|
|
39
|
+
if (fontFamily) return fontFamily;
|
|
36
40
|
if (font == null || font === false) return null;
|
|
37
|
-
if (font === "monospace") return
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
if (font === true) return {
|
|
42
|
-
value: "var(--font)",
|
|
43
|
-
setVar: true
|
|
44
|
-
};
|
|
45
|
-
return {
|
|
46
|
-
value: `${font}, var(--font)`,
|
|
47
|
-
setVar: true
|
|
48
|
-
};
|
|
41
|
+
if (font === "monospace") return "var(--font-mono, var(--font-mono-fallback))";
|
|
42
|
+
if (font === true) return "var(--font-sans, var(--font-sans-fallback))";
|
|
43
|
+
return `${font}, var(--font-sans, var(--font-sans-fallback))`;
|
|
49
44
|
}
|
|
50
45
|
/**
|
|
51
46
|
* Handles typography preset and individual font properties.
|
|
52
47
|
*
|
|
48
|
+
* Preset syntax uses `/` to separate name from modifier:
|
|
49
|
+
* - `preset="h1"` — name only
|
|
50
|
+
* - `preset="h2 / strong"` — name + modifier
|
|
51
|
+
* - `preset="bold"` — modifier-only shorthand (name defaults to `inherit`)
|
|
52
|
+
*
|
|
53
53
|
* When `preset` is defined, it sets up CSS custom properties for typography.
|
|
54
54
|
* Individual font props can be used with or without `preset`:
|
|
55
55
|
* - With `preset`: overrides the preset value for that property
|
|
@@ -65,29 +65,33 @@ function resolveFontFamily(font, fontFamily) {
|
|
|
65
65
|
function presetStyle({ preset, fontSize, lineHeight, textTransform, letterSpacing, fontWeight, fontStyle, fontFamily, font }) {
|
|
66
66
|
const styles = {};
|
|
67
67
|
if (preset != null && preset !== false) {
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (
|
|
80
|
-
if (
|
|
81
|
-
if (
|
|
82
|
-
setCSSValue(styles, "
|
|
83
|
-
setCSSValue(styles, "
|
|
68
|
+
const { parts } = parseStyle(preset === true ? "" : String(preset)).groups[0] ?? { parts: [] };
|
|
69
|
+
const namePart = parts[0];
|
|
70
|
+
const modPart = parts[1];
|
|
71
|
+
const nameToken = namePart?.mods[0] ?? "";
|
|
72
|
+
const isModOnly = PRESET_MODIFIERS.has(nameToken);
|
|
73
|
+
const name = isModOnly ? "inherit" : nameToken || "inherit";
|
|
74
|
+
const modifier = isModOnly ? nameToken : modPart?.mods[0] ?? "";
|
|
75
|
+
const isStrong = modifier === "strong" || modifier === "bold";
|
|
76
|
+
const isItalic = modifier === "italic";
|
|
77
|
+
const isIcon = modifier === "icon";
|
|
78
|
+
const isTight = modifier === "tight";
|
|
79
|
+
if (fontSize == null) setCSSValue(styles, "font-size", name, { cssOnly: true });
|
|
80
|
+
if (lineHeight == null) setCSSValue(styles, "line-height", name, { cssOnly: true });
|
|
81
|
+
if (letterSpacing == null) setCSSValue(styles, "letter-spacing", name, { cssOnly: true });
|
|
82
|
+
if (fontWeight == null) setCSSValue(styles, "font-weight", name, { cssOnly: true });
|
|
83
|
+
if (fontStyle == null) setCSSValue(styles, "font-style", name, { cssOnly: true });
|
|
84
|
+
if (textTransform == null) setCSSValue(styles, "text-transform", name, { cssOnly: true });
|
|
85
|
+
if (fontFamily == null && font == null) setCSSValue(styles, "font-family", name, { cssOnly: true });
|
|
86
|
+
setCSSValue(styles, "bold-font-weight", name, { varOnly: true });
|
|
87
|
+
setCSSValue(styles, "icon-size", name, { varOnly: true });
|
|
84
88
|
if (isStrong) styles["font-weight"] = "var(--bold-font-weight)";
|
|
85
89
|
if (isItalic) styles["font-style"] = "italic";
|
|
86
90
|
if (isIcon) {
|
|
87
91
|
styles["font-size"] = "var(--icon-size)";
|
|
88
92
|
styles["line-height"] = "var(--icon-size)";
|
|
89
93
|
}
|
|
90
|
-
if (isTight) styles["line-height"] = "
|
|
94
|
+
if (isTight) styles["line-height"] = "1em";
|
|
91
95
|
}
|
|
92
96
|
const fontSizeVal = toCSS(fontSize, true);
|
|
93
97
|
if (fontSizeVal) styles["font-size"] = fontSizeVal;
|
|
@@ -101,11 +105,8 @@ function presetStyle({ preset, fontSize, lineHeight, textTransform, letterSpacin
|
|
|
101
105
|
else if (fontStyle !== "inherit") styles["font-style"] = fontStyle ? "italic" : "normal";
|
|
102
106
|
else styles["font-style"] = "inherit";
|
|
103
107
|
if (textTransform) styles["text-transform"] = textTransform;
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
styles["font-family"] = fontResult.value;
|
|
107
|
-
if (fontResult.setVar) styles["--font-family"] = fontResult.value;
|
|
108
|
-
}
|
|
108
|
+
const fontFamily_ = resolveFontFamily(font, fontFamily);
|
|
109
|
+
if (fontFamily_) styles["font-family"] = fontFamily_;
|
|
109
110
|
if (Object.keys(styles).length === 0) return;
|
|
110
111
|
return styles;
|
|
111
112
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preset.js","names":[],"sources":["../../src/styles/preset.ts"],"sourcesContent":["import { makeEmptyDetails } from '../parser/types';\nimport { parseStyle } from '../utils/styles';\n\nimport type { Styles } from './types';\n\n/**\n * Convert a value to CSS, handling numbers as pixels for numeric properties\n */\nfunction toCSS(\n value: string | number | undefined,\n isNumeric: boolean,\n): string | null {\n if (value == null) return null;\n if (typeof value === 'number') {\n return isNumeric ? `${value}px` : String(value);\n }\n // Parse through style parser to handle custom units like 1x, 2r, etc.\n const processed = parseStyle(String(value));\n return processed.groups[0]?.values[0] || String(value);\n}\n\nfunction setCSSValue(\n styles: Styles,\n styleName: string,\n presetName: string,\n isPropOnly = false,\n) {\n styles[`--${styleName}`] = (() => {\n if (presetName === 'inherit') {\n return 'inherit';\n }\n\n const defaultValue = `var(--default-${styleName}${\n styleName === 'font-family' ? ', var(--font, NonexistentFontName)' : ''\n })`;\n const fontSuffix =\n styleName === 'font-family' ? ', var(--font, sans-serif)' : '';\n\n if (presetName === 'default') {\n return `${defaultValue}${fontSuffix}`;\n } else {\n return `var(--${presetName}-${styleName}, ${defaultValue})${fontSuffix}`;\n }\n })();\n\n if (!isPropOnly) {\n styles[styleName] = styles[`--${styleName}`];\n }\n}\n\ninterface PresetStyleProps {\n preset?: string | boolean;\n fontSize?: string | number;\n lineHeight?: string | number;\n textTransform?: string;\n letterSpacing?: string | number;\n fontWeight?: string | number;\n fontStyle?: string | boolean;\n fontFamily?: string;\n /** Alias for fontFamily with special handling for 'monospace' and boolean */\n font?: string | boolean;\n}\n\n/**\n * Resolve font/fontFamily value to CSS font-family string.\n *\n * - `font=\"monospace\"` → var(--monospace-font)\n * - `font={true}` → var(--font)\n * - `font=\"CustomFont\"` → CustomFont, var(--font)\n * - `fontFamily=\"Arial\"` → Arial (direct, no fallback)\n */\nfunction resolveFontFamily(\n font: string | boolean | undefined,\n fontFamily: string | undefined,\n): { value: string; setVar: boolean } | null {\n // fontFamily takes precedence as a direct value\n if (fontFamily) {\n return { value: fontFamily, setVar: false };\n }\n\n if (font == null || font === false) {\n return null;\n }\n\n if (font === 'monospace') {\n return { value: 'var(--monospace-font)', setVar: true };\n }\n\n if (font === true) {\n return { value: 'var(--font)', setVar: true };\n }\n\n return { value: `${font}, var(--font)`, setVar: true };\n}\n\n/**\n * Handles typography preset and individual font properties.\n *\n * When `preset` is defined, it sets up CSS custom properties for typography.\n * Individual font props can be used with or without `preset`:\n * - With `preset`: overrides the preset value for that property\n * - Without `preset`: outputs the CSS directly\n *\n * Number values are converted to pixels for fontSize, lineHeight, letterSpacing.\n * fontWeight accepts numbers directly (e.g., 400, 700).\n *\n * font vs fontFamily:\n * - `font` is the recommended prop with special handling (monospace, boolean, fallback)\n * - `fontFamily` is a direct value without special handling\n */\nexport function presetStyle({\n preset,\n fontSize,\n lineHeight,\n textTransform,\n letterSpacing,\n fontWeight,\n fontStyle,\n fontFamily,\n font,\n}: PresetStyleProps) {\n const styles: Styles = {};\n const hasPreset = preset != null && preset !== false;\n\n // Handle preset if defined\n if (hasPreset) {\n const presetValue = preset === true ? '' : String(preset);\n\n const processed = parseStyle(presetValue);\n let { mods } = processed.groups[0] ?? makeEmptyDetails();\n\n const isStrong = mods.includes('strong');\n const isItalic = mods.includes('italic');\n const isIcon = mods.includes('icon');\n const isTight = mods.includes('tight');\n\n mods = mods.filter(\n (mod) =>\n mod !== 'strong' &&\n mod !== 'bold' &&\n mod !== 'italic' &&\n mod !== 'icon' &&\n mod !== 'tight',\n );\n\n const name = mods[0] || 'inherit';\n\n // Set preset values for properties not explicitly overridden\n if (fontSize == null) {\n setCSSValue(styles, 'font-size', name);\n }\n if (lineHeight == null) {\n setCSSValue(styles, 'line-height', name);\n }\n if (letterSpacing == null) {\n setCSSValue(styles, 'letter-spacing', name);\n }\n if (fontWeight == null) {\n setCSSValue(styles, 'font-weight', name);\n }\n if (fontStyle == null) {\n setCSSValue(styles, 'font-style', name);\n }\n if (textTransform == null) {\n setCSSValue(styles, 'text-transform', name);\n }\n if (fontFamily == null && font == null) {\n setCSSValue(styles, 'font-family', name);\n }\n\n setCSSValue(styles, 'bold-font-weight', name, true);\n setCSSValue(styles, 'icon-size', name, true);\n\n if (isStrong) {\n styles['font-weight'] = 'var(--bold-font-weight)';\n }\n if (isItalic) {\n styles['font-style'] = 'italic';\n }\n if (isIcon) {\n styles['font-size'] = 'var(--icon-size)';\n styles['line-height'] = 'var(--icon-size)';\n }\n if (isTight) {\n styles['line-height'] = 'var(--font-size)';\n }\n }\n\n // Handle individual font properties (work with or without preset)\n const fontSizeVal = toCSS(fontSize, true);\n if (fontSizeVal) {\n styles['font-size'] = fontSizeVal;\n }\n\n const lineHeightVal = toCSS(lineHeight, true);\n if (lineHeightVal) {\n styles['line-height'] = lineHeightVal;\n }\n\n const letterSpacingVal = toCSS(letterSpacing, true);\n if (letterSpacingVal) {\n styles['letter-spacing'] = letterSpacingVal;\n }\n\n // fontWeight: numbers should NOT get 'px' suffix\n const fontWeightVal = toCSS(fontWeight, false);\n if (fontWeightVal) {\n styles['font-weight'] = fontWeightVal;\n }\n\n // fontStyle: handle boolean (true → italic) and string values\n if (fontStyle != null) {\n if (fontStyle === true) {\n styles['font-style'] = 'italic';\n } else if (fontStyle !== 'inherit') {\n styles['font-style'] = fontStyle ? 'italic' : 'normal';\n } else {\n styles['font-style'] = 'inherit';\n }\n }\n\n if (textTransform) {\n styles['text-transform'] = textTransform;\n }\n\n // Handle font/fontFamily (font has special handling, fontFamily is direct)\n const fontResult = resolveFontFamily(font, fontFamily);\n if (fontResult) {\n styles['font-family'] = fontResult.value;\n if (fontResult.setVar) {\n styles['--font-family'] = fontResult.value;\n }\n }\n\n // Return undefined if no styles to apply\n if (Object.keys(styles).length === 0) {\n return;\n }\n\n return styles;\n}\n\npresetStyle.__lookupStyles = [\n 'preset',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textTransform',\n 'fontWeight',\n 'fontStyle',\n 'fontFamily',\n 'font',\n];\n"],"mappings":";;;;;;;AAQA,SAAS,MACP,OACA,WACe;AACf,KAAI,SAAS,KAAM,QAAO;AAC1B,KAAI,OAAO,UAAU,SACnB,QAAO,YAAY,GAAG,MAAM,MAAM,OAAO,MAAM;AAIjD,QADkB,WAAW,OAAO,MAAM,CAAC,CAC1B,OAAO,IAAI,OAAO,MAAM,OAAO,MAAM;;AAGxD,SAAS,YACP,QACA,WACA,YACA,aAAa,OACb;AACA,QAAO,KAAK,sBAAsB;AAChC,MAAI,eAAe,UACjB,QAAO;EAGT,MAAM,eAAe,iBAAiB,YACpC,cAAc,gBAAgB,uCAAuC,GACtE;EACD,MAAM,aACJ,cAAc,gBAAgB,8BAA8B;AAE9D,MAAI,eAAe,UACjB,QAAO,GAAG,eAAe;MAEzB,QAAO,SAAS,WAAW,GAAG,UAAU,IAAI,aAAa,GAAG;KAE5D;AAEJ,KAAI,CAAC,WACH,QAAO,aAAa,OAAO,KAAK;;;;;;;;;;AAyBpC,SAAS,kBACP,MACA,YAC2C;AAE3C,KAAI,WACF,QAAO;EAAE,OAAO;EAAY,QAAQ;EAAO;AAG7C,KAAI,QAAQ,QAAQ,SAAS,MAC3B,QAAO;AAGT,KAAI,SAAS,YACX,QAAO;EAAE,OAAO;EAAyB,QAAQ;EAAM;AAGzD,KAAI,SAAS,KACX,QAAO;EAAE,OAAO;EAAe,QAAQ;EAAM;AAG/C,QAAO;EAAE,OAAO,GAAG,KAAK;EAAgB,QAAQ;EAAM;;;;;;;;;;;;;;;;;AAkBxD,SAAgB,YAAY,EAC1B,QACA,UACA,YACA,eACA,eACA,YACA,WACA,YACA,QACmB;CACnB,MAAM,SAAiB,EAAE;AAIzB,KAHkB,UAAU,QAAQ,WAAW,OAGhC;EAIb,IAAI,EAAE,SADY,WAFE,WAAW,O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KACf,KAAI,cAAc,KAChB,QAAO,gBAAgB;UACd,cAAc,UACvB,QAAO,gBAAgB,YAAY,WAAW;KAE9C,QAAO,gBAAgB;AAI3B,KAAI,cACF,QAAO,oBAAoB;CAI7B,MAAM,aAAa,kBAAkB,MAAM,WAAW;AACtD,KAAI,YAAY;AACd,SAAO,iBAAiB,WAAW;AACnC,MAAI,WAAW,OACb,QAAO,mBAAmB,WAAW;;AAKzC,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjC;AAGF,QAAO;;AAGT,YAAY,iBAAiB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
|
1
|
+
{"version":3,"file":"preset.js","names":[],"sources":["../../src/styles/preset.ts"],"sourcesContent":["import { parseStyle } from '../utils/styles';\n\nimport type { Styles } from './types';\n\nconst PRESET_MODIFIERS = new Set(['strong', 'bold', 'italic', 'icon', 'tight']);\n\n/**\n * Convert a value to CSS, handling numbers as pixels for numeric properties\n */\nfunction toCSS(\n value: string | number | undefined,\n isNumeric: boolean,\n): string | null {\n if (value == null) return null;\n if (typeof value === 'number') {\n return isNumeric ? `${value}px` : String(value);\n }\n // Parse through style parser to handle custom units like 1x, 2r, etc.\n const processed = parseStyle(String(value));\n return processed.groups[0]?.values[0] || String(value);\n}\n\nfunction setCSSValue(\n styles: Styles,\n styleName: string,\n presetName: string,\n { varOnly, cssOnly }: { varOnly?: boolean; cssOnly?: boolean } = {},\n) {\n const value = (() => {\n if (presetName === 'inherit') {\n return 'inherit';\n }\n\n const defaultValue = `var(--default-${styleName}${\n styleName === 'font-family'\n ? ', var(--font-sans, var(--font-sans-fallback))'\n : ''\n })`;\n const fontSuffix =\n styleName === 'font-family'\n ? ', var(--font-sans, var(--font-sans-fallback))'\n : '';\n\n if (presetName === 'default') {\n return `${defaultValue}${fontSuffix}`;\n } else {\n return `var(--${presetName}-${styleName}, ${defaultValue})${fontSuffix}`;\n }\n })();\n\n if (!cssOnly) {\n styles[`--${styleName}`] = value;\n }\n\n if (!varOnly) {\n styles[styleName] = value;\n }\n}\n\ninterface PresetStyleProps {\n preset?: string | boolean;\n fontSize?: string | number;\n lineHeight?: string | number;\n textTransform?: string;\n letterSpacing?: string | number;\n fontWeight?: string | number;\n fontStyle?: string | boolean;\n fontFamily?: string;\n /** Alias for fontFamily with special handling for 'monospace' and boolean */\n font?: string | boolean;\n}\n\n/**\n * Resolve font/fontFamily value to CSS font-family string.\n *\n * - `font=\"monospace\"` → var(--font-mono, var(--font-mono-fallback))\n * - `font={true}` → var(--font-sans, var(--font-sans-fallback))\n * - `font=\"CustomFont\"` → CustomFont, var(--font-sans, var(--font-sans-fallback))\n * - `fontFamily=\"Arial\"` → Arial (direct, no fallback)\n */\nfunction resolveFontFamily(\n font: string | boolean | undefined,\n fontFamily: string | undefined,\n): string | null {\n // fontFamily takes precedence as a direct value\n if (fontFamily) {\n return fontFamily;\n }\n\n if (font == null || font === false) {\n return null;\n }\n\n if (font === 'monospace') {\n return 'var(--font-mono, var(--font-mono-fallback))';\n }\n\n if (font === true) {\n return 'var(--font-sans, var(--font-sans-fallback))';\n }\n\n return `${font}, var(--font-sans, var(--font-sans-fallback))`;\n}\n\n/**\n * Handles typography preset and individual font properties.\n *\n * Preset syntax uses `/` to separate name from modifier:\n * - `preset=\"h1\"` — name only\n * - `preset=\"h2 / strong\"` — name + modifier\n * - `preset=\"bold\"` — modifier-only shorthand (name defaults to `inherit`)\n *\n * When `preset` is defined, it sets up CSS custom properties for typography.\n * Individual font props can be used with or without `preset`:\n * - With `preset`: overrides the preset value for that property\n * - Without `preset`: outputs the CSS directly\n *\n * Number values are converted to pixels for fontSize, lineHeight, letterSpacing.\n * fontWeight accepts numbers directly (e.g., 400, 700).\n *\n * font vs fontFamily:\n * - `font` is the recommended prop with special handling (monospace, boolean, fallback)\n * - `fontFamily` is a direct value without special handling\n */\nexport function presetStyle({\n preset,\n fontSize,\n lineHeight,\n textTransform,\n letterSpacing,\n fontWeight,\n fontStyle,\n fontFamily,\n font,\n}: PresetStyleProps) {\n const styles: Styles = {};\n const hasPreset = preset != null && preset !== false;\n\n // Handle preset if defined\n if (hasPreset) {\n const presetValue = preset === true ? '' : String(preset);\n\n const processed = parseStyle(presetValue);\n const group = processed.groups[0];\n const { parts } = group ?? { parts: [] };\n\n // parts[0] = preset name (or a modifier for shorthand like preset=\"bold\")\n // parts[1] = optional modifier after slash (e.g. \"t3 / bold\")\n const namePart = parts[0];\n const modPart = parts[1];\n\n const nameToken = namePart?.mods[0] ?? '';\n const isModOnly = PRESET_MODIFIERS.has(nameToken);\n\n const name = isModOnly ? 'inherit' : nameToken || 'inherit';\n const modifier = isModOnly ? nameToken : (modPart?.mods[0] ?? '');\n\n const isStrong = modifier === 'strong' || modifier === 'bold';\n const isItalic = modifier === 'italic';\n const isIcon = modifier === 'icon';\n const isTight = modifier === 'tight';\n\n // Set preset values for properties not explicitly overridden\n if (fontSize == null) {\n setCSSValue(styles, 'font-size', name, { cssOnly: true });\n }\n if (lineHeight == null) {\n setCSSValue(styles, 'line-height', name, { cssOnly: true });\n }\n if (letterSpacing == null) {\n setCSSValue(styles, 'letter-spacing', name, { cssOnly: true });\n }\n if (fontWeight == null) {\n setCSSValue(styles, 'font-weight', name, { cssOnly: true });\n }\n if (fontStyle == null) {\n setCSSValue(styles, 'font-style', name, { cssOnly: true });\n }\n if (textTransform == null) {\n setCSSValue(styles, 'text-transform', name, { cssOnly: true });\n }\n if (fontFamily == null && font == null) {\n setCSSValue(styles, 'font-family', name, { cssOnly: true });\n }\n\n setCSSValue(styles, 'bold-font-weight', name, { varOnly: true });\n setCSSValue(styles, 'icon-size', name, { varOnly: true });\n\n if (isStrong) {\n styles['font-weight'] = 'var(--bold-font-weight)';\n }\n if (isItalic) {\n styles['font-style'] = 'italic';\n }\n if (isIcon) {\n styles['font-size'] = 'var(--icon-size)';\n styles['line-height'] = 'var(--icon-size)';\n }\n if (isTight) {\n styles['line-height'] = '1em';\n }\n }\n\n // Handle individual font properties (work with or without preset)\n const fontSizeVal = toCSS(fontSize, true);\n if (fontSizeVal) {\n styles['font-size'] = fontSizeVal;\n }\n\n const lineHeightVal = toCSS(lineHeight, true);\n if (lineHeightVal) {\n styles['line-height'] = lineHeightVal;\n }\n\n const letterSpacingVal = toCSS(letterSpacing, true);\n if (letterSpacingVal) {\n styles['letter-spacing'] = letterSpacingVal;\n }\n\n // fontWeight: numbers should NOT get 'px' suffix\n const fontWeightVal = toCSS(fontWeight, false);\n if (fontWeightVal) {\n styles['font-weight'] = fontWeightVal;\n }\n\n // fontStyle: handle boolean (true → italic) and string values\n if (fontStyle != null) {\n if (fontStyle === true) {\n styles['font-style'] = 'italic';\n } else if (fontStyle !== 'inherit') {\n styles['font-style'] = fontStyle ? 'italic' : 'normal';\n } else {\n styles['font-style'] = 'inherit';\n }\n }\n\n if (textTransform) {\n styles['text-transform'] = textTransform;\n }\n\n // Handle font/fontFamily (font has special handling, fontFamily is direct)\n const fontFamily_ = resolveFontFamily(font, fontFamily);\n if (fontFamily_) {\n styles['font-family'] = fontFamily_;\n }\n\n // Return undefined if no styles to apply\n if (Object.keys(styles).length === 0) {\n return;\n }\n\n return styles;\n}\n\npresetStyle.__lookupStyles = [\n 'preset',\n 'fontSize',\n 'lineHeight',\n 'letterSpacing',\n 'textTransform',\n 'fontWeight',\n 'fontStyle',\n 'fontFamily',\n 'font',\n];\n"],"mappings":";;;AAIA,MAAM,mBAAmB,IAAI,IAAI;CAAC;CAAU;CAAQ;CAAU;CAAQ;CAAQ,CAAC;;;;AAK/E,SAAS,MACP,OACA,WACe;AACf,KAAI,SAAS,KAAM,QAAO;AAC1B,KAAI,OAAO,UAAU,SACnB,QAAO,YAAY,GAAG,MAAM,MAAM,OAAO,MAAM;AAIjD,QADkB,WAAW,OAAO,MAAM,CAAC,CAC1B,OAAO,IAAI,OAAO,MAAM,OAAO,MAAM;;AAGxD,SAAS,YACP,QACA,WACA,YACA,EAAE,SAAS,YAAsD,EAAE,EACnE;CACA,MAAM,eAAe;A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AGF,QAAO;;AAGT,YAAY,iBAAiB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/dist/styles/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyframesSteps, PropertyDefinition } from "../injector/types.js";
|
|
1
|
+
import { CounterStyleDescriptors, FontFaceInput, KeyframesSteps, PropertyDefinition } from "../injector/types.js";
|
|
2
2
|
import { CSSProperties } from "../utils/css-types.js";
|
|
3
3
|
import { StyleValue, StyleValueStateMap } from "../utils/styles.js";
|
|
4
4
|
|
|
@@ -40,6 +40,7 @@ type PresetNameKey = Extract<keyof TastyPresetNames, string>;
|
|
|
40
40
|
type PresetName = [PresetNameKey] extends [never] ? string : PresetNameKey;
|
|
41
41
|
type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
42
42
|
type OpaquePercentage = '' | `.${Digit}` | `.${Digit}${Digit}` | '.100';
|
|
43
|
+
type ColorValue = `#${NamedColor}${OpaquePercentage}` | `rgb(${string})` | `hsl(${string})` | `okhsl(${string})` | `oklch(${string})` | (string & {});
|
|
43
44
|
type NoType = false | null | undefined;
|
|
44
45
|
interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font' | 'outline' | 'type' | 'gap' | 'padding' | 'margin' | 'width' | 'height' | 'border' | 'transition' | 'placeContent' | 'placeItems'> {
|
|
45
46
|
/**
|
|
@@ -57,13 +58,20 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
57
58
|
/**
|
|
58
59
|
* Set the background color of the element. Shortcut for `background-color` with enhanced support for Tasty color tokens and syntaxes.
|
|
59
60
|
*
|
|
61
|
+
* Supports double-color syntax: the second color is applied as a foreground overlay via a CSS custom property.
|
|
62
|
+
*
|
|
60
63
|
* Examples:
|
|
61
64
|
* - `fill="#purple.10"` // purple background with 10% opacity
|
|
62
65
|
* - `fill="#danger"` // danger theme color
|
|
63
66
|
* - `fill="rgb(255 128 0)"` // custom RGB color
|
|
67
|
+
* - `fill="rgb(255 128 0 / 0.5)"` // RGB with opacity
|
|
68
|
+
* - `fill="hsl(200 100% 50%)"` // HSL color
|
|
69
|
+
* - `fill="okhsl(200 100% 50%)"` // perceptually uniform OKHSL color
|
|
70
|
+
* - `fill="oklch(0.7 0.15 200)"` // OKLCH color
|
|
71
|
+
* - `fill="#primary #secondary"` // double color (second as foreground overlay)
|
|
64
72
|
* - `fill={true}` // default fill color
|
|
65
73
|
*/
|
|
66
|
-
fill?:
|
|
74
|
+
fill?: ColorValue | boolean;
|
|
67
75
|
/**
|
|
68
76
|
* @deprecated Use `fill` instead.
|
|
69
77
|
*/
|
|
@@ -92,19 +100,26 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
92
100
|
* - `svgFill="#purple.10"` // purple fill with 10% opacity
|
|
93
101
|
* - `svgFill="#danger"` // danger theme color
|
|
94
102
|
* - `svgFill="rgb(255 128 0)"` // custom RGB color
|
|
103
|
+
* - `svgFill="hsl(200 100% 50%)"` // HSL color
|
|
104
|
+
* - `svgFill="okhsl(200 100% 50%)"` // OKHSL color
|
|
105
|
+
* - `svgFill="oklch(0.7 0.15 200)"` // OKLCH color
|
|
95
106
|
* - `svgFill="currentColor"` // inherit from parent color
|
|
96
107
|
*/
|
|
97
|
-
svgFill?:
|
|
108
|
+
svgFill?: ColorValue;
|
|
98
109
|
/**
|
|
99
110
|
* Set the text (current) color of the element. Shortcut for `color` with enhanced support for Tasty color tokens and syntaxes.
|
|
100
111
|
*
|
|
101
112
|
* Examples:
|
|
102
113
|
* - `color="#purple"` // purple text color
|
|
103
114
|
* - `color="#danger.6"` // danger color with 60% opacity
|
|
115
|
+
* - `color="rgb(255 128 0)"` // custom RGB color
|
|
116
|
+
* - `color="hsl(200 100% 50%)"` // HSL color
|
|
117
|
+
* - `color="okhsl(200 100% 50%)"` // OKHSL color
|
|
118
|
+
* - `color="oklch(0.7 0.15 200)"` // OKLCH color
|
|
104
119
|
* - `color="red"` // CSS color name
|
|
105
120
|
* - `color={true}` // currentColor
|
|
106
121
|
*/
|
|
107
|
-
color?:
|
|
122
|
+
color?: ColorValue | boolean;
|
|
108
123
|
/**
|
|
109
124
|
* The fade style applies gradient-based fading masks to the edges of an element. Replaces complex CSS mask gradients with a simple, declarative API.
|
|
110
125
|
*
|
|
@@ -351,11 +366,13 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
351
366
|
/**
|
|
352
367
|
* The preset style sets base text settings according to named presets. Affects `font-size`, `line-height`, `letter-spacing`, `font-weight`, and `text-transform`.
|
|
353
368
|
*
|
|
369
|
+
* Syntax: `name`, `name / modifier`, or `modifier` (shorthand, name defaults to `inherit`).
|
|
354
370
|
* Preset names are project-specific. Augment `TastyPresetNames` to register them for autocomplete.
|
|
355
371
|
*
|
|
356
372
|
* Examples:
|
|
357
373
|
* - `preset="h1"` // heading 1 typography
|
|
358
|
-
* - `preset="h2 strong"` // bold heading 2
|
|
374
|
+
* - `preset="h2 / strong"` // bold heading 2
|
|
375
|
+
* - `preset="bold"` // inherit with bold (shorthand)
|
|
359
376
|
* - `preset="t3"` // text size 3
|
|
360
377
|
*/
|
|
361
378
|
preset?: PresetName | (string & {});
|
|
@@ -435,6 +452,24 @@ interface StylesInterface extends Omit<CSSProperties, 'color' | 'fill' | 'font'
|
|
|
435
452
|
* - `'@properties': { '#theme': { initialValue: 'purple' } }` // syntax: '<color>' is auto-set
|
|
436
453
|
*/
|
|
437
454
|
'@properties'?: Record<string, PropertyDefinition>;
|
|
455
|
+
/**
|
|
456
|
+
* Local @font-face definitions for this component.
|
|
457
|
+
* Keys are font-family names, values are descriptors or arrays of descriptors
|
|
458
|
+
* (for multiple weights/styles of the same family).
|
|
459
|
+
*
|
|
460
|
+
* Examples:
|
|
461
|
+
* - `'@fontFace': { Icons: { src: 'url("/fonts/icons.woff2") format("woff2")', fontDisplay: 'block' } }`
|
|
462
|
+
* - `'@fontFace': { 'Brand Sans': [{ src: '...', fontWeight: 400 }, { src: '...', fontWeight: 700 }] }`
|
|
463
|
+
*/
|
|
464
|
+
'@fontFace'?: Record<string, FontFaceInput>;
|
|
465
|
+
/**
|
|
466
|
+
* Local @counter-style definitions for this component.
|
|
467
|
+
* Keys are counter-style names, values are descriptor objects.
|
|
468
|
+
*
|
|
469
|
+
* Examples:
|
|
470
|
+
* - `'@counterStyle': { thumbs: { system: 'cyclic', symbols: '"👍"', suffix: '" "' } }`
|
|
471
|
+
*/
|
|
472
|
+
'@counterStyle'?: Record<string, CounterStyleDescriptors>;
|
|
438
473
|
/**
|
|
439
474
|
* Apply one or more predefined style recipes by name.
|
|
440
475
|
* Recipes are defined globally via `configure({ recipes: { ... } })`.
|
|
@@ -455,7 +490,7 @@ type SuffixForSelector = '&' | '.' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | '
|
|
|
455
490
|
type Selector = `${SuffixForSelector}${string}`;
|
|
456
491
|
type NotSelector = Exclude<string, Selector | keyof StylesInterface>;
|
|
457
492
|
/** Special style keys that should not be wrapped in StyleValue/StyleValueStateMap */
|
|
458
|
-
type SpecialStyleKeys = '@keyframes' | '@properties' | 'recipe';
|
|
493
|
+
type SpecialStyleKeys = '@keyframes' | '@properties' | '@fontFace' | '@counterStyle' | 'recipe';
|
|
459
494
|
type StylesWithoutSelectors = { [key in keyof StylesInterface as key extends SpecialStyleKeys ? never : key]?: StyleValue<StylesInterface[key]> | StyleValueStateMap<StylesInterface[key]> };
|
|
460
495
|
/**
|
|
461
496
|
* Index signature for recipe-specific arbitrary keys.
|
|
@@ -473,16 +508,20 @@ type RecipeIndexSignature = Record<string, StyleValue<string | number | boolean
|
|
|
473
508
|
type RecipeStyles = StylesWithoutSelectors & RecipeIndexSignature & {
|
|
474
509
|
'@keyframes'?: StylesInterface['@keyframes'];
|
|
475
510
|
'@properties'?: StylesInterface['@properties'];
|
|
511
|
+
'@fontFace'?: StylesInterface['@fontFace'];
|
|
512
|
+
'@counterStyle'?: StylesInterface['@counterStyle'];
|
|
476
513
|
};
|
|
477
514
|
/** Special properties that are not regular style values */
|
|
478
515
|
interface SpecialStyleProperties {
|
|
479
516
|
'@keyframes'?: StylesInterface['@keyframes'];
|
|
480
517
|
'@properties'?: StylesInterface['@properties'];
|
|
518
|
+
'@fontFace'?: StylesInterface['@fontFace'];
|
|
519
|
+
'@counterStyle'?: StylesInterface['@counterStyle'];
|
|
481
520
|
recipe?: StylesInterface['recipe'];
|
|
482
521
|
}
|
|
483
522
|
/** Index signature for arbitrary style keys (sub-elements, CSS variables, etc.) */
|
|
484
523
|
interface StylesIndexSignature {
|
|
485
|
-
[key: string]: StyleValue<string | number | boolean | undefined> | StyleValueStateMap<string | number | boolean | undefined> | Styles | false | StylesInterface['@keyframes'] | StylesInterface['@properties'];
|
|
524
|
+
[key: string]: StyleValue<string | number | boolean | undefined> | StyleValueStateMap<string | number | boolean | undefined> | Styles | false | StylesInterface['@keyframes'] | StylesInterface['@properties'] | StylesInterface['@fontFace'] | StylesInterface['@counterStyle'];
|
|
486
525
|
/**
|
|
487
526
|
* Selector combinator: `undefined` (descendant, default), `'>'` (child), `'+'` (adjacent), `'~'` (sibling).
|
|
488
527
|
* Can chain with capitalized names: `'> Body > Row >'`. Spaces required around combinators.
|