@tenphi/tasty 0.0.0-snapshot.05c1c22

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.
Files changed (314) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +629 -0
  3. package/dist/_virtual/_rolldown/runtime.js +7 -0
  4. package/dist/chunks/cacheKey.d.ts +1 -0
  5. package/dist/chunks/cacheKey.js +77 -0
  6. package/dist/chunks/cacheKey.js.map +1 -0
  7. package/dist/chunks/definitions.d.ts +37 -0
  8. package/dist/chunks/definitions.js +258 -0
  9. package/dist/chunks/definitions.js.map +1 -0
  10. package/dist/chunks/index.d.ts +1 -0
  11. package/dist/chunks/renderChunk.d.ts +1 -0
  12. package/dist/chunks/renderChunk.js +59 -0
  13. package/dist/chunks/renderChunk.js.map +1 -0
  14. package/dist/config.d.ts +366 -0
  15. package/dist/config.js +503 -0
  16. package/dist/config.js.map +1 -0
  17. package/dist/core/index.d.ts +33 -0
  18. package/dist/core/index.js +26 -0
  19. package/dist/counter-style/index.js +51 -0
  20. package/dist/counter-style/index.js.map +1 -0
  21. package/dist/debug.d.ts +89 -0
  22. package/dist/debug.js +453 -0
  23. package/dist/debug.js.map +1 -0
  24. package/dist/font-face/index.js +63 -0
  25. package/dist/font-face/index.js.map +1 -0
  26. package/dist/hooks/index.d.ts +7 -0
  27. package/dist/hooks/resolve-ssr-collector.js +14 -0
  28. package/dist/hooks/resolve-ssr-collector.js.map +1 -0
  29. package/dist/hooks/useCounterStyle.d.ts +50 -0
  30. package/dist/hooks/useCounterStyle.js +46 -0
  31. package/dist/hooks/useCounterStyle.js.map +1 -0
  32. package/dist/hooks/useFontFace.d.ts +43 -0
  33. package/dist/hooks/useFontFace.js +70 -0
  34. package/dist/hooks/useFontFace.js.map +1 -0
  35. package/dist/hooks/useGlobalStyles.d.ts +30 -0
  36. package/dist/hooks/useGlobalStyles.js +78 -0
  37. package/dist/hooks/useGlobalStyles.js.map +1 -0
  38. package/dist/hooks/useKeyframes.d.ts +56 -0
  39. package/dist/hooks/useKeyframes.js +64 -0
  40. package/dist/hooks/useKeyframes.js.map +1 -0
  41. package/dist/hooks/useProperty.d.ts +79 -0
  42. package/dist/hooks/useProperty.js +109 -0
  43. package/dist/hooks/useProperty.js.map +1 -0
  44. package/dist/hooks/useRawCSS.d.ts +53 -0
  45. package/dist/hooks/useRawCSS.js +35 -0
  46. package/dist/hooks/useRawCSS.js.map +1 -0
  47. package/dist/hooks/useStyles.d.ts +45 -0
  48. package/dist/hooks/useStyles.js +237 -0
  49. package/dist/hooks/useStyles.js.map +1 -0
  50. package/dist/index.d.ts +50 -0
  51. package/dist/index.js +35 -0
  52. package/dist/injector/index.d.ts +183 -0
  53. package/dist/injector/index.js +179 -0
  54. package/dist/injector/index.js.map +1 -0
  55. package/dist/injector/injector.d.ts +166 -0
  56. package/dist/injector/injector.js +464 -0
  57. package/dist/injector/injector.js.map +1 -0
  58. package/dist/injector/sheet-manager.d.ts +136 -0
  59. package/dist/injector/sheet-manager.js +733 -0
  60. package/dist/injector/sheet-manager.js.map +1 -0
  61. package/dist/injector/types.d.ts +204 -0
  62. package/dist/keyframes/index.js +206 -0
  63. package/dist/keyframes/index.js.map +1 -0
  64. package/dist/parser/classify.js +319 -0
  65. package/dist/parser/classify.js.map +1 -0
  66. package/dist/parser/const.js +49 -0
  67. package/dist/parser/const.js.map +1 -0
  68. package/dist/parser/lru.js +109 -0
  69. package/dist/parser/lru.js.map +1 -0
  70. package/dist/parser/parser.d.ts +25 -0
  71. package/dist/parser/parser.js +115 -0
  72. package/dist/parser/parser.js.map +1 -0
  73. package/dist/parser/tokenizer.js +69 -0
  74. package/dist/parser/tokenizer.js.map +1 -0
  75. package/dist/parser/types.d.ts +51 -0
  76. package/dist/parser/types.js +46 -0
  77. package/dist/parser/types.js.map +1 -0
  78. package/dist/pipeline/conditions.d.ts +134 -0
  79. package/dist/pipeline/conditions.js +406 -0
  80. package/dist/pipeline/conditions.js.map +1 -0
  81. package/dist/pipeline/exclusive.js +230 -0
  82. package/dist/pipeline/exclusive.js.map +1 -0
  83. package/dist/pipeline/index.d.ts +55 -0
  84. package/dist/pipeline/index.js +708 -0
  85. package/dist/pipeline/index.js.map +1 -0
  86. package/dist/pipeline/materialize.js +1103 -0
  87. package/dist/pipeline/materialize.js.map +1 -0
  88. package/dist/pipeline/parseStateKey.d.ts +15 -0
  89. package/dist/pipeline/parseStateKey.js +446 -0
  90. package/dist/pipeline/parseStateKey.js.map +1 -0
  91. package/dist/pipeline/simplify.js +515 -0
  92. package/dist/pipeline/simplify.js.map +1 -0
  93. package/dist/pipeline/warnings.js +18 -0
  94. package/dist/pipeline/warnings.js.map +1 -0
  95. package/dist/plugins/index.d.ts +2 -0
  96. package/dist/plugins/okhsl-plugin.d.ts +35 -0
  97. package/dist/plugins/okhsl-plugin.js +97 -0
  98. package/dist/plugins/okhsl-plugin.js.map +1 -0
  99. package/dist/plugins/types.d.ts +76 -0
  100. package/dist/properties/index.js +222 -0
  101. package/dist/properties/index.js.map +1 -0
  102. package/dist/properties/property-type-resolver.d.ts +24 -0
  103. package/dist/properties/property-type-resolver.js +90 -0
  104. package/dist/properties/property-type-resolver.js.map +1 -0
  105. package/dist/ssr/astro.d.ts +29 -0
  106. package/dist/ssr/astro.js +64 -0
  107. package/dist/ssr/astro.js.map +1 -0
  108. package/dist/ssr/async-storage.d.ts +17 -0
  109. package/dist/ssr/async-storage.js +34 -0
  110. package/dist/ssr/async-storage.js.map +1 -0
  111. package/dist/ssr/collect-auto-properties.js +39 -0
  112. package/dist/ssr/collect-auto-properties.js.map +1 -0
  113. package/dist/ssr/collector.d.ts +102 -0
  114. package/dist/ssr/collector.js +226 -0
  115. package/dist/ssr/collector.js.map +1 -0
  116. package/dist/ssr/context.d.ts +8 -0
  117. package/dist/ssr/context.js +13 -0
  118. package/dist/ssr/context.js.map +1 -0
  119. package/dist/ssr/format-global-rules.js +22 -0
  120. package/dist/ssr/format-global-rules.js.map +1 -0
  121. package/dist/ssr/format-keyframes.js +69 -0
  122. package/dist/ssr/format-keyframes.js.map +1 -0
  123. package/dist/ssr/format-property.js +49 -0
  124. package/dist/ssr/format-property.js.map +1 -0
  125. package/dist/ssr/format-rules.js +73 -0
  126. package/dist/ssr/format-rules.js.map +1 -0
  127. package/dist/ssr/hydrate.d.ts +22 -0
  128. package/dist/ssr/hydrate.js +49 -0
  129. package/dist/ssr/hydrate.js.map +1 -0
  130. package/dist/ssr/index.d.ts +5 -0
  131. package/dist/ssr/index.js +11 -0
  132. package/dist/ssr/index.js.map +1 -0
  133. package/dist/ssr/next.d.ts +45 -0
  134. package/dist/ssr/next.js +69 -0
  135. package/dist/ssr/next.js.map +1 -0
  136. package/dist/ssr/ssr-collector-ref.js +12 -0
  137. package/dist/ssr/ssr-collector-ref.js.map +1 -0
  138. package/dist/states/index.d.ts +49 -0
  139. package/dist/states/index.js +170 -0
  140. package/dist/states/index.js.map +1 -0
  141. package/dist/static/index.d.ts +5 -0
  142. package/dist/static/index.js +4 -0
  143. package/dist/static/inject.d.ts +5 -0
  144. package/dist/static/inject.js +17 -0
  145. package/dist/static/inject.js.map +1 -0
  146. package/dist/static/tastyStatic.d.ts +46 -0
  147. package/dist/static/tastyStatic.js +30 -0
  148. package/dist/static/tastyStatic.js.map +1 -0
  149. package/dist/static/types.d.ts +49 -0
  150. package/dist/static/types.js +24 -0
  151. package/dist/static/types.js.map +1 -0
  152. package/dist/styles/align.d.ts +15 -0
  153. package/dist/styles/align.js +14 -0
  154. package/dist/styles/align.js.map +1 -0
  155. package/dist/styles/border.d.ts +25 -0
  156. package/dist/styles/border.js +113 -0
  157. package/dist/styles/border.js.map +1 -0
  158. package/dist/styles/color.d.ts +14 -0
  159. package/dist/styles/color.js +26 -0
  160. package/dist/styles/color.js.map +1 -0
  161. package/dist/styles/createStyle.js +79 -0
  162. package/dist/styles/createStyle.js.map +1 -0
  163. package/dist/styles/dimension.js +96 -0
  164. package/dist/styles/dimension.js.map +1 -0
  165. package/dist/styles/display.d.ts +37 -0
  166. package/dist/styles/display.js +66 -0
  167. package/dist/styles/display.js.map +1 -0
  168. package/dist/styles/fade.d.ts +15 -0
  169. package/dist/styles/fade.js +57 -0
  170. package/dist/styles/fade.js.map +1 -0
  171. package/dist/styles/fill.d.ts +42 -0
  172. package/dist/styles/fill.js +51 -0
  173. package/dist/styles/fill.js.map +1 -0
  174. package/dist/styles/flow.d.ts +16 -0
  175. package/dist/styles/flow.js +12 -0
  176. package/dist/styles/flow.js.map +1 -0
  177. package/dist/styles/gap.d.ts +31 -0
  178. package/dist/styles/gap.js +36 -0
  179. package/dist/styles/gap.js.map +1 -0
  180. package/dist/styles/height.d.ts +17 -0
  181. package/dist/styles/height.js +19 -0
  182. package/dist/styles/height.js.map +1 -0
  183. package/dist/styles/index.d.ts +1 -0
  184. package/dist/styles/index.js +8 -0
  185. package/dist/styles/index.js.map +1 -0
  186. package/dist/styles/inset.d.ts +52 -0
  187. package/dist/styles/inset.js +149 -0
  188. package/dist/styles/inset.js.map +1 -0
  189. package/dist/styles/justify.d.ts +15 -0
  190. package/dist/styles/justify.js +14 -0
  191. package/dist/styles/justify.js.map +1 -0
  192. package/dist/styles/list.d.ts +16 -0
  193. package/dist/styles/list.js +98 -0
  194. package/dist/styles/list.js.map +1 -0
  195. package/dist/styles/margin.d.ts +24 -0
  196. package/dist/styles/margin.js +103 -0
  197. package/dist/styles/margin.js.map +1 -0
  198. package/dist/styles/outline.d.ts +29 -0
  199. package/dist/styles/outline.js +64 -0
  200. package/dist/styles/outline.js.map +1 -0
  201. package/dist/styles/padding.d.ts +24 -0
  202. package/dist/styles/padding.js +103 -0
  203. package/dist/styles/padding.js.map +1 -0
  204. package/dist/styles/predefined.d.ts +71 -0
  205. package/dist/styles/predefined.js +237 -0
  206. package/dist/styles/predefined.js.map +1 -0
  207. package/dist/styles/preset.d.ts +52 -0
  208. package/dist/styles/preset.js +126 -0
  209. package/dist/styles/preset.js.map +1 -0
  210. package/dist/styles/radius.d.ts +12 -0
  211. package/dist/styles/radius.js +71 -0
  212. package/dist/styles/radius.js.map +1 -0
  213. package/dist/styles/scrollbar.d.ts +25 -0
  214. package/dist/styles/scrollbar.js +46 -0
  215. package/dist/styles/scrollbar.js.map +1 -0
  216. package/dist/styles/shadow.d.ts +14 -0
  217. package/dist/styles/shadow.js +23 -0
  218. package/dist/styles/shadow.js.map +1 -0
  219. package/dist/styles/transition.d.ts +14 -0
  220. package/dist/styles/transition.js +157 -0
  221. package/dist/styles/transition.js.map +1 -0
  222. package/dist/styles/types.d.ts +549 -0
  223. package/dist/styles/width.d.ts +17 -0
  224. package/dist/styles/width.js +19 -0
  225. package/dist/styles/width.js.map +1 -0
  226. package/dist/tasty.d.ts +119 -0
  227. package/dist/tasty.js +231 -0
  228. package/dist/tasty.js.map +1 -0
  229. package/dist/types.d.ts +184 -0
  230. package/dist/utils/cache-wrapper.js +21 -0
  231. package/dist/utils/cache-wrapper.js.map +1 -0
  232. package/dist/utils/case-converter.js +8 -0
  233. package/dist/utils/case-converter.js.map +1 -0
  234. package/dist/utils/color-math.d.ts +46 -0
  235. package/dist/utils/color-math.js +749 -0
  236. package/dist/utils/color-math.js.map +1 -0
  237. package/dist/utils/color-space.d.ts +5 -0
  238. package/dist/utils/color-space.js +228 -0
  239. package/dist/utils/color-space.js.map +1 -0
  240. package/dist/utils/colors.d.ts +5 -0
  241. package/dist/utils/colors.js +10 -0
  242. package/dist/utils/colors.js.map +1 -0
  243. package/dist/utils/css-types.d.ts +7 -0
  244. package/dist/utils/dotize.d.ts +26 -0
  245. package/dist/utils/dotize.js +122 -0
  246. package/dist/utils/dotize.js.map +1 -0
  247. package/dist/utils/filter-base-props.d.ts +15 -0
  248. package/dist/utils/filter-base-props.js +45 -0
  249. package/dist/utils/filter-base-props.js.map +1 -0
  250. package/dist/utils/get-display-name.d.ts +7 -0
  251. package/dist/utils/get-display-name.js +10 -0
  252. package/dist/utils/get-display-name.js.map +1 -0
  253. package/dist/utils/has-keys.js +13 -0
  254. package/dist/utils/has-keys.js.map +1 -0
  255. package/dist/utils/is-dev-env.js +19 -0
  256. package/dist/utils/is-dev-env.js.map +1 -0
  257. package/dist/utils/is-valid-element-type.js +15 -0
  258. package/dist/utils/is-valid-element-type.js.map +1 -0
  259. package/dist/utils/merge-styles.d.ts +7 -0
  260. package/dist/utils/merge-styles.js +145 -0
  261. package/dist/utils/merge-styles.js.map +1 -0
  262. package/dist/utils/mod-attrs.d.ts +6 -0
  263. package/dist/utils/mod-attrs.js +20 -0
  264. package/dist/utils/mod-attrs.js.map +1 -0
  265. package/dist/utils/process-tokens.d.ts +21 -0
  266. package/dist/utils/process-tokens.js +90 -0
  267. package/dist/utils/process-tokens.js.map +1 -0
  268. package/dist/utils/resolve-recipes.d.ts +17 -0
  269. package/dist/utils/resolve-recipes.js +146 -0
  270. package/dist/utils/resolve-recipes.js.map +1 -0
  271. package/dist/utils/selector-transform.js +32 -0
  272. package/dist/utils/selector-transform.js.map +1 -0
  273. package/dist/utils/string.js +8 -0
  274. package/dist/utils/string.js.map +1 -0
  275. package/dist/utils/styles.d.ts +99 -0
  276. package/dist/utils/styles.js +220 -0
  277. package/dist/utils/styles.js.map +1 -0
  278. package/dist/utils/typography.d.ts +47 -0
  279. package/dist/utils/typography.js +51 -0
  280. package/dist/utils/typography.js.map +1 -0
  281. package/dist/utils/warnings.d.ts +16 -0
  282. package/dist/utils/warnings.js +16 -0
  283. package/dist/utils/warnings.js.map +1 -0
  284. package/dist/zero/babel.d.ts +182 -0
  285. package/dist/zero/babel.js +438 -0
  286. package/dist/zero/babel.js.map +1 -0
  287. package/dist/zero/css-writer.d.ts +45 -0
  288. package/dist/zero/css-writer.js +73 -0
  289. package/dist/zero/css-writer.js.map +1 -0
  290. package/dist/zero/extractor.d.ts +24 -0
  291. package/dist/zero/extractor.js +266 -0
  292. package/dist/zero/extractor.js.map +1 -0
  293. package/dist/zero/index.d.ts +3 -0
  294. package/dist/zero/index.js +3 -0
  295. package/dist/zero/next.d.ts +86 -0
  296. package/dist/zero/next.js +143 -0
  297. package/dist/zero/next.js.map +1 -0
  298. package/docs/PIPELINE.md +519 -0
  299. package/docs/README.md +31 -0
  300. package/docs/adoption.md +296 -0
  301. package/docs/comparison.md +420 -0
  302. package/docs/configuration.md +326 -0
  303. package/docs/debug.md +318 -0
  304. package/docs/design-system.md +424 -0
  305. package/docs/dsl.md +673 -0
  306. package/docs/getting-started.md +217 -0
  307. package/docs/injector.md +528 -0
  308. package/docs/methodology.md +567 -0
  309. package/docs/runtime.md +485 -0
  310. package/docs/ssr.md +384 -0
  311. package/docs/styles.md +582 -0
  312. package/docs/tasty-static.md +520 -0
  313. package/package.json +215 -0
  314. package/tasty.config.ts +14 -0
@@ -0,0 +1,29 @@
1
+ //#region src/styles/outline.d.ts
2
+ interface OutlineStyleProps {
3
+ outline?: string | boolean | number;
4
+ outlineOffset?: string | number;
5
+ }
6
+ /**
7
+ * Generates CSS for outline property with optional offset.
8
+ *
9
+ * Syntax:
10
+ * - `outline="2px solid #red"` - outline only
11
+ * - `outline="2px solid #red / 4px"` - outline with offset (slash separator)
12
+ * - `outline="2px / 4px"` - width with offset (simpler form)
13
+ * - `outline={true}` - default 1ow solid outline
14
+ * - `outlineOffset="4px"` - offset as separate prop (can be combined with outline)
15
+ *
16
+ * Priority: slash syntax in outline takes precedence over outlineOffset prop
17
+ *
18
+ * @return CSS properties for outline and optionally outline-offset
19
+ */
20
+ declare function outlineStyle({
21
+ outline,
22
+ outlineOffset
23
+ }: OutlineStyleProps): Record<string, string> | undefined;
24
+ declare namespace outlineStyle {
25
+ var __lookupStyles: string[];
26
+ }
27
+ //#endregion
28
+ export { outlineStyle };
29
+ //# sourceMappingURL=outline.d.ts.map
@@ -0,0 +1,64 @@
1
+ import { filterMods, parseStyle } from "../utils/styles.js";
2
+ //#region src/styles/outline.ts
3
+ const BORDER_STYLES = [
4
+ "none",
5
+ "hidden",
6
+ "dotted",
7
+ "dashed",
8
+ "solid",
9
+ "double",
10
+ "groove",
11
+ "ridge",
12
+ "inset",
13
+ "outset"
14
+ ];
15
+ /**
16
+ * Generates CSS for outline property with optional offset.
17
+ *
18
+ * Syntax:
19
+ * - `outline="2px solid #red"` - outline only
20
+ * - `outline="2px solid #red / 4px"` - outline with offset (slash separator)
21
+ * - `outline="2px / 4px"` - width with offset (simpler form)
22
+ * - `outline={true}` - default 1ow solid outline
23
+ * - `outlineOffset="4px"` - offset as separate prop (can be combined with outline)
24
+ *
25
+ * Priority: slash syntax in outline takes precedence over outlineOffset prop
26
+ *
27
+ * @return CSS properties for outline and optionally outline-offset
28
+ */
29
+ function outlineStyle({ outline, outlineOffset }) {
30
+ const result = {};
31
+ if (outline != null && outline !== false) {
32
+ let outlineValue = outline;
33
+ if (outline === true) outlineValue = "1ow";
34
+ if (outline === 0) outlineValue = "0";
35
+ const group = parseStyle(String(outlineValue)).groups[0];
36
+ if (group) {
37
+ const { parts } = group;
38
+ const outlinePart = parts[0] ?? {
39
+ values: [],
40
+ mods: [],
41
+ colors: []
42
+ };
43
+ const offsetPart = parts[1];
44
+ const typeMods = filterMods(outlinePart.mods, BORDER_STYLES);
45
+ result["outline"] = [
46
+ outlinePart.values[0] || "var(--outline-width)",
47
+ typeMods[0] || "solid",
48
+ outlinePart.colors[0] || "var(--outline-color)"
49
+ ].join(" ");
50
+ if (offsetPart?.values[0]) result["outline-offset"] = offsetPart.values[0];
51
+ }
52
+ }
53
+ if (outlineOffset != null && !result["outline-offset"]) {
54
+ const offsetValue = typeof outlineOffset === "number" ? `${outlineOffset}px` : outlineOffset;
55
+ result["outline-offset"] = parseStyle(offsetValue).groups[0]?.values[0] || offsetValue;
56
+ }
57
+ if (Object.keys(result).length === 0) return;
58
+ return result;
59
+ }
60
+ outlineStyle.__lookupStyles = ["outline", "outlineOffset"];
61
+ //#endregion
62
+ export { outlineStyle };
63
+
64
+ //# sourceMappingURL=outline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outline.js","names":[],"sources":["../../src/styles/outline.ts"],"sourcesContent":["import { filterMods, parseStyle } from '../utils/styles';\n\nconst BORDER_STYLES = [\n 'none',\n 'hidden',\n 'dotted',\n 'dashed',\n 'solid',\n 'double',\n 'groove',\n 'ridge',\n 'inset',\n 'outset',\n];\n\ninterface OutlineStyleProps {\n outline?: string | boolean | number;\n outlineOffset?: string | number;\n}\n\n/**\n * Generates CSS for outline property with optional offset.\n *\n * Syntax:\n * - `outline=\"2px solid #red\"` - outline only\n * - `outline=\"2px solid #red / 4px\"` - outline with offset (slash separator)\n * - `outline=\"2px / 4px\"` - width with offset (simpler form)\n * - `outline={true}` - default 1ow solid outline\n * - `outlineOffset=\"4px\"` - offset as separate prop (can be combined with outline)\n *\n * Priority: slash syntax in outline takes precedence over outlineOffset prop\n *\n * @return CSS properties for outline and optionally outline-offset\n */\nexport function outlineStyle({ outline, outlineOffset }: OutlineStyleProps) {\n const result: Record<string, string> = {};\n\n // Handle outline (0 is valid - means no outline)\n if (outline != null && outline !== false) {\n let outlineValue: string | boolean | number = outline;\n if (outline === true) outlineValue = '1ow';\n if (outline === 0) outlineValue = '0';\n\n const processed = parseStyle(String(outlineValue));\n const group = processed.groups[0];\n\n if (group) {\n const { parts } = group;\n const outlinePart = parts[0] ?? { values: [], mods: [], colors: [] };\n const offsetPart = parts[1];\n\n const typeMods = filterMods(outlinePart.mods, BORDER_STYLES);\n\n const value = outlinePart.values[0] || 'var(--outline-width)';\n const type = typeMods[0] || 'solid';\n const outlineColor = outlinePart.colors[0] || 'var(--outline-color)';\n\n result['outline'] = [value, type, outlineColor].join(' ');\n\n // Check for offset in second part (after /) - takes precedence\n if (offsetPart?.values[0]) {\n result['outline-offset'] = offsetPart.values[0];\n }\n }\n }\n\n // Handle outlineOffset prop (only if not already set by slash syntax)\n if (outlineOffset != null && !result['outline-offset']) {\n const offsetValue =\n typeof outlineOffset === 'number' ? `${outlineOffset}px` : outlineOffset;\n const processed = parseStyle(offsetValue);\n result['outline-offset'] = processed.groups[0]?.values[0] || offsetValue;\n }\n\n // Return undefined if no styles to apply\n if (Object.keys(result).length === 0) {\n return;\n }\n\n return result;\n}\n\noutlineStyle.__lookupStyles = ['outline', 'outlineOffset'];\n"],"mappings":";;AAEA,MAAM,gBAAgB;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;;;;AAqBD,SAAgB,aAAa,EAAE,SAAS,iBAAoC;CAC1E,MAAM,SAAiC,EAAE;AAGzC,KAAI,WAAW,QAAQ,YAAY,OAAO;EACxC,IAAI,eAA0C;AAC9C,MAAI,YAAY,KAAM,gBAAe;AACrC,MAAI,YAAY,EAAG,gBAAe;EAGlC,MAAM,QADY,WAAW,OAAO,aAAa,CAAC,CAC1B,OAAO;AAE/B,MAAI,OAAO;GACT,MAAM,EAAE,UAAU;GAClB,MAAM,cAAc,MAAM,MAAM;IAAE,QAAQ,EAAE;IAAE,MAAM,EAAE;IAAE,QAAQ,EAAE;IAAE;GACpE,MAAM,aAAa,MAAM;GAEzB,MAAM,WAAW,WAAW,YAAY,MAAM,cAAc;AAM5D,UAAO,aAAa;IAJN,YAAY,OAAO,MAAM;IAC1B,SAAS,MAAM;IACP,YAAY,OAAO,MAAM;IAEC,CAAC,KAAK,IAAI;AAGzD,OAAI,YAAY,OAAO,GACrB,QAAO,oBAAoB,WAAW,OAAO;;;AAMnD,KAAI,iBAAiB,QAAQ,CAAC,OAAO,mBAAmB;EACtD,MAAM,cACJ,OAAO,kBAAkB,WAAW,GAAG,cAAc,MAAM;AAE7D,SAAO,oBADW,WAAW,YAAY,CACJ,OAAO,IAAI,OAAO,MAAM;;AAI/D,KAAI,OAAO,KAAK,OAAO,CAAC,WAAW,EACjC;AAGF,QAAO;;AAGT,aAAa,iBAAiB,CAAC,WAAW,gBAAgB"}
@@ -0,0 +1,24 @@
1
+ //#region src/styles/padding.d.ts
2
+ declare function paddingStyle({
3
+ padding,
4
+ paddingBlock,
5
+ paddingInline,
6
+ paddingTop,
7
+ paddingRight,
8
+ paddingBottom,
9
+ paddingLeft
10
+ }: {
11
+ padding?: string | number | boolean;
12
+ paddingBlock?: string | number | boolean;
13
+ paddingInline?: string | number | boolean;
14
+ paddingTop?: string | number | boolean;
15
+ paddingRight?: string | number | boolean;
16
+ paddingBottom?: string | number | boolean;
17
+ paddingLeft?: string | number | boolean;
18
+ }): {};
19
+ declare namespace paddingStyle {
20
+ var __lookupStyles: string[];
21
+ }
22
+ //#endregion
23
+ export { paddingStyle };
24
+ //# sourceMappingURL=padding.d.ts.map
@@ -0,0 +1,103 @@
1
+ import { DIRECTIONS, filterMods, parseStyle } from "../utils/styles.js";
2
+ //#region src/styles/padding.ts
3
+ /**
4
+ * Parse a padding value and return the first processed value
5
+ */
6
+ function parsePaddingValue(value) {
7
+ if (typeof value === "number") return `${value}px`;
8
+ if (!value) return null;
9
+ if (value === true) value = "1x";
10
+ const { values } = parseStyle(value).groups[0] ?? { values: [] };
11
+ return values[0] || "var(--gap)";
12
+ }
13
+ /**
14
+ * Extract values and directions from a single parsed group.
15
+ */
16
+ function extractGroupData(group) {
17
+ const { values = [], mods = [] } = group;
18
+ return {
19
+ values: values.length ? values : ["var(--gap)"],
20
+ directions: filterMods(mods, DIRECTIONS)
21
+ };
22
+ }
23
+ /**
24
+ * Apply a single group's values and directions onto a direction map.
25
+ */
26
+ function applyGroup(dirs, values, directions) {
27
+ if (!values.length) return;
28
+ if (directions.length === 0) {
29
+ dirs.top = values[0];
30
+ dirs.right = values[1] || values[0];
31
+ dirs.bottom = values[2] || values[0];
32
+ dirs.left = values[3] || values[1] || values[0];
33
+ } else directions.forEach((dir, i) => {
34
+ dirs[dir] = values[i] ?? values[0];
35
+ });
36
+ }
37
+ /**
38
+ * Optimize padding output shorthand.
39
+ */
40
+ function optimizePadding(dirs) {
41
+ const { top, right, bottom, left } = dirs;
42
+ if (top === right && right === bottom && bottom === left) return { padding: top };
43
+ if (top === bottom && left === right) return { padding: `${top} ${left}` };
44
+ return { padding: `${top} ${right} ${bottom} ${left}` };
45
+ }
46
+ function paddingStyle({ padding, paddingBlock, paddingInline, paddingTop, paddingRight, paddingBottom, paddingLeft }) {
47
+ if (padding == null && paddingBlock == null && paddingInline == null && paddingTop == null && paddingRight == null && paddingBottom == null && paddingLeft == null) return {};
48
+ const dirs = {
49
+ top: "0",
50
+ right: "0",
51
+ bottom: "0",
52
+ left: "0"
53
+ };
54
+ if (padding != null) {
55
+ if (typeof padding === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${padding}px`;
56
+ else if (padding === true) padding = "1x";
57
+ if (typeof padding === "string" && padding) {
58
+ const groups = parseStyle(padding).groups ?? [];
59
+ for (const group of groups) {
60
+ const { values, directions } = extractGroupData(group);
61
+ applyGroup(dirs, values, directions);
62
+ }
63
+ }
64
+ }
65
+ if (paddingBlock != null) {
66
+ const val = parsePaddingValue(paddingBlock);
67
+ if (val) dirs.top = dirs.bottom = val;
68
+ }
69
+ if (paddingInline != null) {
70
+ const val = parsePaddingValue(paddingInline);
71
+ if (val) dirs.left = dirs.right = val;
72
+ }
73
+ if (paddingTop != null) {
74
+ const val = parsePaddingValue(paddingTop);
75
+ if (val) dirs.top = val;
76
+ }
77
+ if (paddingRight != null) {
78
+ const val = parsePaddingValue(paddingRight);
79
+ if (val) dirs.right = val;
80
+ }
81
+ if (paddingBottom != null) {
82
+ const val = parsePaddingValue(paddingBottom);
83
+ if (val) dirs.bottom = val;
84
+ }
85
+ if (paddingLeft != null) {
86
+ const val = parsePaddingValue(paddingLeft);
87
+ if (val) dirs.left = val;
88
+ }
89
+ return optimizePadding(dirs);
90
+ }
91
+ paddingStyle.__lookupStyles = [
92
+ "padding",
93
+ "paddingTop",
94
+ "paddingRight",
95
+ "paddingBottom",
96
+ "paddingLeft",
97
+ "paddingBlock",
98
+ "paddingInline"
99
+ ];
100
+ //#endregion
101
+ export { paddingStyle };
102
+
103
+ //# sourceMappingURL=padding.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"padding.js","names":[],"sources":["../../src/styles/padding.ts"],"sourcesContent":["import type { StyleDetails } from '../parser/types';\nimport { DIRECTIONS, filterMods, parseStyle } from '../utils/styles';\n\ntype Direction = (typeof DIRECTIONS)[number];\n\n/**\n * Parse a padding value and return the first processed value\n */\nfunction parsePaddingValue(value: string | number | boolean): string | null {\n if (typeof value === 'number') return `${value}px`;\n if (!value) return null;\n if (value === true) value = '1x';\n\n const { values } = parseStyle(value).groups[0] ?? { values: [] };\n\n return values[0] || 'var(--gap)';\n}\n\n/**\n * Extract values and directions from a single parsed group.\n */\nfunction extractGroupData(group: StyleDetails): {\n values: string[];\n directions: Direction[];\n} {\n const { values = [], mods = [] } = group;\n return {\n values: values.length ? values : ['var(--gap)'],\n directions: filterMods(mods, DIRECTIONS) as Direction[],\n };\n}\n\n/**\n * Apply a single group's values and directions onto a direction map.\n */\nfunction applyGroup(\n dirs: Record<Direction, string>,\n values: string[],\n directions: Direction[],\n): void {\n if (!values.length) return;\n\n if (directions.length === 0) {\n dirs.top = values[0];\n dirs.right = values[1] || values[0];\n dirs.bottom = values[2] || values[0];\n dirs.left = values[3] || values[1] || values[0];\n } else {\n directions.forEach((dir, i) => {\n dirs[dir] = values[i] ?? values[0];\n });\n }\n}\n\n/**\n * Optimize padding output shorthand.\n */\nfunction optimizePadding(dirs: Record<Direction, string>): {\n padding: string;\n} {\n const { top, right, bottom, left } = dirs;\n if (top === right && right === bottom && bottom === left) {\n return { padding: top };\n }\n if (top === bottom && left === right) {\n return { padding: `${top} ${left}` };\n }\n return { padding: `${top} ${right} ${bottom} ${left}` };\n}\n\nexport function paddingStyle({\n padding,\n paddingBlock,\n paddingInline,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n}: {\n padding?: string | number | boolean;\n paddingBlock?: string | number | boolean;\n paddingInline?: string | number | boolean;\n paddingTop?: string | number | boolean;\n paddingRight?: string | number | boolean;\n paddingBottom?: string | number | boolean;\n paddingLeft?: string | number | boolean;\n}) {\n if (\n padding == null &&\n paddingBlock == null &&\n paddingInline == null &&\n paddingTop == null &&\n paddingRight == null &&\n paddingBottom == null &&\n paddingLeft == null\n ) {\n return {};\n }\n\n const dirs: Record<Direction, string> = {\n top: '0',\n right: '0',\n bottom: '0',\n left: '0',\n };\n\n // Priority 1 (lowest): padding\n if (padding != null) {\n if (typeof padding === 'number') {\n const v = `${padding}px`;\n dirs.top = dirs.right = dirs.bottom = dirs.left = v;\n } else if (padding === true) {\n padding = '1x';\n }\n\n if (typeof padding === 'string' && padding) {\n const processed = parseStyle(padding);\n const groups = processed.groups ?? [];\n\n for (const group of groups) {\n const { values, directions } = extractGroupData(group);\n applyGroup(dirs, values, directions);\n }\n }\n }\n\n // Priority 2 (medium): paddingBlock/paddingInline\n if (paddingBlock != null) {\n const val = parsePaddingValue(paddingBlock);\n if (val) dirs.top = dirs.bottom = val;\n }\n if (paddingInline != null) {\n const val = parsePaddingValue(paddingInline);\n if (val) dirs.left = dirs.right = val;\n }\n\n // Priority 3 (highest): individual directions\n if (paddingTop != null) {\n const val = parsePaddingValue(paddingTop);\n if (val) dirs.top = val;\n }\n if (paddingRight != null) {\n const val = parsePaddingValue(paddingRight);\n if (val) dirs.right = val;\n }\n if (paddingBottom != null) {\n const val = parsePaddingValue(paddingBottom);\n if (val) dirs.bottom = val;\n }\n if (paddingLeft != null) {\n const val = parsePaddingValue(paddingLeft);\n if (val) dirs.left = val;\n }\n\n return optimizePadding(dirs);\n}\n\npaddingStyle.__lookupStyles = [\n 'padding',\n 'paddingTop',\n 'paddingRight',\n 'paddingBottom',\n 'paddingLeft',\n 'paddingBlock',\n 'paddingInline',\n];\n"],"mappings":";;;;;AAQA,SAAS,kBAAkB,OAAiD;AAC1E,KAAI,OAAO,UAAU,SAAU,QAAO,GAAG,MAAM;AAC/C,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,UAAU,KAAM,SAAQ;CAE5B,MAAM,EAAE,WAAW,WAAW,MAAM,CAAC,OAAO,MAAM,EAAE,QAAQ,EAAE,EAAE;AAEhE,QAAO,OAAO,MAAM;;;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AAM,SADY,WAAW,QAAQ,CACZ,UAAU,EAAE;AAErC,QAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,EAAE,QAAQ,eAAe,iBAAiB,MAAM;AACtD,eAAW,MAAM,QAAQ,WAAW;;;;AAM1C,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,kBAAkB,aAAa;AAC3C,MAAI,IAAK,MAAK,MAAM,KAAK,SAAS;;AAEpC,KAAI,iBAAiB,MAAM;EACzB,MAAM,MAAM,kBAAkB,cAAc;AAC5C,MAAI,IAAK,MAAK,OAAO,KAAK,QAAQ;;AAIpC,KAAI,cAAc,MAAM;EACtB,MAAM,MAAM,kBAAkB,WAAW;AACzC,MAAI,IAAK,MAAK,MAAM;;AAEtB,KAAI,gBAAgB,MAAM;EACxB,MAAM,MAAM,kBAAkB,aAAa;AAC3C,MAAI,IAAK,MAAK,QAAQ;;AAExB,KAAI,iBAAiB,MAAM;EACzB,MAAM,MAAM,kBAAkB,cAAc;AAC5C,MAAI,IAAK,MAAK,SAAS;;AAEzB,KAAI,eAAe,MAAM;EACvB,MAAM,MAAM,kBAAkB,YAAY;AAC1C,MAAI,IAAK,MAAK,OAAO;;AAGvB,QAAO,gBAAgB,KAAK;;AAG9B,aAAa,iBAAiB;CAC5B;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
@@ -0,0 +1,71 @@
1
+ import { alignStyle } from "./align.js";
2
+ import { borderStyle } from "./border.js";
3
+ import { colorStyle } from "./color.js";
4
+ import { displayStyle } from "./display.js";
5
+ import { fadeStyle } from "./fade.js";
6
+ import { fillStyle, svgFillStyle } from "./fill.js";
7
+ import { flowStyle } from "./flow.js";
8
+ import { gapStyle } from "./gap.js";
9
+ import { heightStyle } from "./height.js";
10
+ import { insetStyle } from "./inset.js";
11
+ import { justifyStyle } from "./justify.js";
12
+ import { marginStyle } from "./margin.js";
13
+ import { outlineStyle } from "./outline.js";
14
+ import { paddingStyle } from "./padding.js";
15
+ import { presetStyle } from "./preset.js";
16
+ import { radiusStyle } from "./radius.js";
17
+ import { scrollbarStyle } from "./scrollbar.js";
18
+ import { shadowStyle } from "./shadow.js";
19
+ import { transitionStyle } from "./transition.js";
20
+ import { widthStyle } from "./width.js";
21
+
22
+ //#region src/styles/predefined.d.ts
23
+ /**
24
+ * Exported object containing wrapped predefined style handlers.
25
+ * Users can import and call these to extend or delegate to built-in behavior.
26
+ *
27
+ * Internal handlers use *Style suffix for searchability.
28
+ * External API uses short names for convenience.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { styleHandlers, configure } from '@tenphi/tasty';
33
+ *
34
+ * configure({
35
+ * handlers: {
36
+ * fill: ({ fill }) => {
37
+ * if (fill?.startsWith('gradient:')) {
38
+ * return { background: fill.slice(9) };
39
+ * }
40
+ * return styleHandlers.fill({ fill });
41
+ * },
42
+ * },
43
+ * });
44
+ * ```
45
+ */
46
+ declare const styleHandlers: {
47
+ readonly align: typeof alignStyle;
48
+ readonly border: typeof borderStyle;
49
+ readonly color: typeof colorStyle;
50
+ readonly display: typeof displayStyle;
51
+ readonly fade: typeof fadeStyle;
52
+ readonly fill: typeof fillStyle;
53
+ readonly svgFill: typeof svgFillStyle;
54
+ readonly flow: typeof flowStyle;
55
+ readonly gap: typeof gapStyle;
56
+ readonly height: typeof heightStyle;
57
+ readonly inset: typeof insetStyle;
58
+ readonly justify: typeof justifyStyle;
59
+ readonly margin: typeof marginStyle;
60
+ readonly outline: typeof outlineStyle;
61
+ readonly padding: typeof paddingStyle;
62
+ readonly preset: typeof presetStyle;
63
+ readonly radius: typeof radiusStyle;
64
+ readonly scrollbar: typeof scrollbarStyle;
65
+ readonly shadow: typeof shadowStyle;
66
+ readonly transition: typeof transitionStyle;
67
+ readonly width: typeof widthStyle;
68
+ };
69
+ //#endregion
70
+ export { styleHandlers };
71
+ //# sourceMappingURL=predefined.d.ts.map
@@ -0,0 +1,237 @@
1
+ import { isDevEnv } from "../utils/is-dev-env.js";
2
+ import { alignStyle } from "./align.js";
3
+ import { borderStyle } from "./border.js";
4
+ import { createStyle } from "./createStyle.js";
5
+ import { colorStyle } from "./color.js";
6
+ import { displayStyle } from "./display.js";
7
+ import { fadeStyle } from "./fade.js";
8
+ import { fillStyle, svgFillStyle } from "./fill.js";
9
+ import { flowStyle } from "./flow.js";
10
+ import { gapStyle } from "./gap.js";
11
+ import { heightStyle } from "./height.js";
12
+ import { insetStyle } from "./inset.js";
13
+ import { justifyStyle } from "./justify.js";
14
+ import { marginStyle } from "./margin.js";
15
+ import { outlineStyle } from "./outline.js";
16
+ import { paddingStyle } from "./padding.js";
17
+ import { presetStyle } from "./preset.js";
18
+ import { radiusStyle } from "./radius.js";
19
+ import { scrollbarStyle } from "./scrollbar.js";
20
+ import { shadowStyle } from "./shadow.js";
21
+ import { transitionStyle } from "./transition.js";
22
+ import { widthStyle } from "./width.js";
23
+ //#region src/styles/predefined.ts
24
+ const devMode = isDevEnv();
25
+ const columnsConverter = (val) => {
26
+ if (typeof val === "number") return "minmax(1px, 1fr) ".repeat(val).trim();
27
+ };
28
+ const rowsConverter = (val) => {
29
+ if (typeof val === "number") return "auto ".repeat(val).trim();
30
+ };
31
+ const STYLE_HANDLER_MAP = {};
32
+ let initialHandlerMapSnapshot = null;
33
+ /**
34
+ * Capture a snapshot of the current STYLE_HANDLER_MAP.
35
+ * Called after predefine() to preserve built-in handler state.
36
+ */
37
+ function captureInitialHandlerState() {
38
+ initialHandlerMapSnapshot = {};
39
+ for (const key of Object.keys(STYLE_HANDLER_MAP)) initialHandlerMapSnapshot[key] = [...STYLE_HANDLER_MAP[key]];
40
+ }
41
+ /**
42
+ * Reset STYLE_HANDLER_MAP to the initial built-in state.
43
+ * Called by resetConfig() to restore handlers after tests.
44
+ */
45
+ function resetHandlers() {
46
+ if (!initialHandlerMapSnapshot) return;
47
+ for (const key of Object.keys(STYLE_HANDLER_MAP)) delete STYLE_HANDLER_MAP[key];
48
+ for (const key of Object.keys(initialHandlerMapSnapshot)) STYLE_HANDLER_MAP[key] = [...initialHandlerMapSnapshot[key]];
49
+ }
50
+ function defineCustomStyle(names, handler) {
51
+ let handlerWithLookup;
52
+ if (typeof names === "function") {
53
+ handlerWithLookup = names;
54
+ names = handlerWithLookup.__lookupStyles;
55
+ } else if (handler) handlerWithLookup = Object.assign(handler, { __lookupStyles: names });
56
+ else {
57
+ console.warn("Tasty: incorrect custom style definition: ", names);
58
+ return;
59
+ }
60
+ if (Array.isArray(names)) names.forEach((name) => {
61
+ if (!STYLE_HANDLER_MAP[name]) STYLE_HANDLER_MAP[name] = [];
62
+ STYLE_HANDLER_MAP[name].push(handlerWithLookup);
63
+ });
64
+ }
65
+ function defineStyleAlias(styleName, cssStyleName, converter) {
66
+ const styleHandler = createStyle(styleName, cssStyleName, converter);
67
+ if (!STYLE_HANDLER_MAP[styleName]) STYLE_HANDLER_MAP[styleName] = [];
68
+ STYLE_HANDLER_MAP[styleName].push(styleHandler);
69
+ }
70
+ function predefine() {
71
+ defineStyleAlias("gridAreas", "grid-template-areas");
72
+ defineStyleAlias("gridColumns", "grid-template-columns", columnsConverter);
73
+ defineStyleAlias("gridRows", "grid-template-rows", rowsConverter);
74
+ defineStyleAlias("gridTemplate", "grid-template", (val) => {
75
+ if (typeof val !== "string") return;
76
+ return val.split("/").map((s, i) => (i ? columnsConverter : rowsConverter)(s)).join("/");
77
+ });
78
+ [
79
+ displayStyle,
80
+ transitionStyle,
81
+ fillStyle,
82
+ svgFillStyle,
83
+ widthStyle,
84
+ marginStyle,
85
+ gapStyle,
86
+ flowStyle,
87
+ colorStyle,
88
+ heightStyle,
89
+ radiusStyle,
90
+ borderStyle,
91
+ shadowStyle,
92
+ paddingStyle,
93
+ alignStyle,
94
+ justifyStyle,
95
+ presetStyle,
96
+ outlineStyle,
97
+ scrollbarStyle,
98
+ fadeStyle,
99
+ insetStyle
100
+ ].forEach((handler) => defineCustomStyle(handler));
101
+ captureInitialHandlerState();
102
+ return {
103
+ STYLE_HANDLER_MAP,
104
+ defineCustomStyle,
105
+ defineStyleAlias
106
+ };
107
+ }
108
+ /**
109
+ * Normalize a handler definition to a StyleHandler with __lookupStyles.
110
+ * - Function only: lookup styles inferred from key name
111
+ * - [string, fn]: single lookup style
112
+ * - [string[], fn]: multiple lookup styles
113
+ */
114
+ function normalizeHandlerDefinition(keyName, definition) {
115
+ let handler;
116
+ let lookupStyles;
117
+ if (typeof definition === "function") {
118
+ handler = definition;
119
+ lookupStyles = [keyName];
120
+ } else if (Array.isArray(definition)) {
121
+ const [first, fn] = definition;
122
+ if (typeof fn !== "function") throw new Error(`[Tasty] Invalid handler definition for "${keyName}". Tuple must have a function as the second element: [string, function] or [string[], function].`);
123
+ handler = fn;
124
+ if (typeof first === "string") lookupStyles = [first];
125
+ else if (Array.isArray(first)) lookupStyles = first;
126
+ else throw new Error(`[Tasty] Invalid handler definition for "${keyName}". First element must be a string or string array.`);
127
+ } else throw new Error(`[Tasty] Invalid handler definition for "${keyName}". Expected function, [string, function], or [string[], function].`);
128
+ validateHandler(keyName, handler, lookupStyles);
129
+ const wrappedHandler = ((props) => handler(props));
130
+ wrappedHandler.__lookupStyles = lookupStyles;
131
+ return wrappedHandler;
132
+ }
133
+ /**
134
+ * Validate a handler definition in development mode.
135
+ */
136
+ function validateHandler(name, handler, lookupStyles) {
137
+ if (!devMode) return;
138
+ if (typeof handler !== "function") console.warn(`[Tasty] Handler "${name}" is not a function. Handlers must be functions that return CSSMap, CSSMap[], or void.`);
139
+ if (!lookupStyles || !Array.isArray(lookupStyles) || lookupStyles.length === 0) console.warn(`[Tasty] Handler "${name}" has invalid lookupStyles. Expected non-empty array of style names.`);
140
+ }
141
+ /**
142
+ * Register a custom handler, replacing any existing handlers for the same lookup styles.
143
+ * This is called by configure() to process user-defined handlers.
144
+ *
145
+ * When registering a handler for style X, any existing handler that processes X
146
+ * is removed from ALL its lookup styles to prevent double-processing.
147
+ * For example, if gapStyle handles ['display', 'flow', 'gap'] and a new handler
148
+ * is registered for just ['gap'], gapStyle is removed from display and flow too.
149
+ */
150
+ function registerHandler(handler) {
151
+ const lookupStyles = handler.__lookupStyles;
152
+ if (!lookupStyles || lookupStyles.length === 0) {
153
+ if (devMode) console.warn("[Tasty] Cannot register handler without __lookupStyles property.");
154
+ return;
155
+ }
156
+ const handlersToRemove = /* @__PURE__ */ new Set();
157
+ for (const styleName of lookupStyles) {
158
+ const existing = STYLE_HANDLER_MAP[styleName];
159
+ if (existing) for (const existingHandler of existing) handlersToRemove.add(existingHandler);
160
+ }
161
+ for (const oldHandler of handlersToRemove) {
162
+ const oldLookupStyles = oldHandler.__lookupStyles;
163
+ if (oldLookupStyles) for (const oldStyleName of oldLookupStyles) {
164
+ const handlers = STYLE_HANDLER_MAP[oldStyleName];
165
+ if (handlers) {
166
+ const filtered = handlers.filter((h) => h !== oldHandler);
167
+ if (filtered.length === 0) delete STYLE_HANDLER_MAP[oldStyleName];
168
+ else STYLE_HANDLER_MAP[oldStyleName] = filtered;
169
+ }
170
+ }
171
+ }
172
+ for (const styleName of lookupStyles) {
173
+ const existing = STYLE_HANDLER_MAP[styleName];
174
+ if (existing) existing.push(handler);
175
+ else STYLE_HANDLER_MAP[styleName] = [handler];
176
+ }
177
+ }
178
+ /**
179
+ * Create a wrapped handler that can be safely called by users.
180
+ * The wrapper preserves __lookupStyles for proper registration.
181
+ */
182
+ function wrapHandler(handler) {
183
+ const fn = handler;
184
+ const wrapped = ((props) => fn(props));
185
+ wrapped.__lookupStyles = handler.__lookupStyles;
186
+ return wrapped;
187
+ }
188
+ /**
189
+ * Exported object containing wrapped predefined style handlers.
190
+ * Users can import and call these to extend or delegate to built-in behavior.
191
+ *
192
+ * Internal handlers use *Style suffix for searchability.
193
+ * External API uses short names for convenience.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * import { styleHandlers, configure } from '@tenphi/tasty';
198
+ *
199
+ * configure({
200
+ * handlers: {
201
+ * fill: ({ fill }) => {
202
+ * if (fill?.startsWith('gradient:')) {
203
+ * return { background: fill.slice(9) };
204
+ * }
205
+ * return styleHandlers.fill({ fill });
206
+ * },
207
+ * },
208
+ * });
209
+ * ```
210
+ */
211
+ const styleHandlers = {
212
+ align: wrapHandler(alignStyle),
213
+ border: wrapHandler(borderStyle),
214
+ color: wrapHandler(colorStyle),
215
+ display: wrapHandler(displayStyle),
216
+ fade: wrapHandler(fadeStyle),
217
+ fill: wrapHandler(fillStyle),
218
+ svgFill: wrapHandler(svgFillStyle),
219
+ flow: wrapHandler(flowStyle),
220
+ gap: wrapHandler(gapStyle),
221
+ height: wrapHandler(heightStyle),
222
+ inset: wrapHandler(insetStyle),
223
+ justify: wrapHandler(justifyStyle),
224
+ margin: wrapHandler(marginStyle),
225
+ outline: wrapHandler(outlineStyle),
226
+ padding: wrapHandler(paddingStyle),
227
+ preset: wrapHandler(presetStyle),
228
+ radius: wrapHandler(radiusStyle),
229
+ scrollbar: wrapHandler(scrollbarStyle),
230
+ shadow: wrapHandler(shadowStyle),
231
+ transition: wrapHandler(transitionStyle),
232
+ width: wrapHandler(widthStyle)
233
+ };
234
+ //#endregion
235
+ export { normalizeHandlerDefinition, predefine, registerHandler, resetHandlers, styleHandlers };
236
+
237
+ //# sourceMappingURL=predefined.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predefined.js","names":[],"sources":["../../src/styles/predefined.ts"],"sourcesContent":["import { isDevEnv } from '../utils/is-dev-env';\nimport type {\n RawStyleHandler,\n StyleHandler,\n StyleHandlerDefinition,\n} from '../utils/styles';\n\nimport { alignStyle } from './align';\nimport { borderStyle } from './border';\nimport { colorStyle } from './color';\nimport { createStyle } from './createStyle';\nimport { displayStyle } from './display';\nimport { fadeStyle } from './fade';\nimport { fillStyle, svgFillStyle } from './fill';\nimport { flowStyle } from './flow';\n// Note: fontStyle (font.ts) and fontStyleStyle (fontStyle.ts) removed\n// Both font and fontStyle props are now handled by presetStyle\nimport { gapStyle } from './gap';\nimport { heightStyle } from './height';\nimport { insetStyle } from './inset';\nimport { justifyStyle } from './justify';\nimport { marginStyle } from './margin';\nimport { outlineStyle } from './outline';\nimport { paddingStyle } from './padding';\nimport { presetStyle } from './preset';\nimport { radiusStyle } from './radius';\nimport { scrollbarStyle } from './scrollbar';\nimport { shadowStyle } from './shadow';\nimport { transitionStyle } from './transition';\nimport { widthStyle } from './width';\n\nconst devMode = isDevEnv();\n\nconst _numberConverter = (val: string | number | boolean | undefined) => {\n if (typeof val === 'number') {\n return `${val}px`;\n }\n\n return val;\n};\nconst columnsConverter = (val: string | number | boolean | undefined) => {\n if (typeof val === 'number') {\n return 'minmax(1px, 1fr) '.repeat(val).trim();\n }\n\n return;\n};\nconst rowsConverter = (val: string | number | boolean | undefined) => {\n if (typeof val === 'number') {\n return 'auto '.repeat(val).trim();\n }\n\n return;\n};\n\ntype StyleHandlerMap = Record<string, StyleHandler[]>;\n\nexport const STYLE_HANDLER_MAP: StyleHandlerMap = {};\n\n// Store initial handler state for reset functionality\nlet initialHandlerMapSnapshot: StyleHandlerMap | null = null;\n\n/**\n * Capture a snapshot of the current STYLE_HANDLER_MAP.\n * Called after predefine() to preserve built-in handler state.\n */\nfunction captureInitialHandlerState(): void {\n initialHandlerMapSnapshot = {};\n for (const key of Object.keys(STYLE_HANDLER_MAP)) {\n // Shallow copy the array - handlers themselves are immutable\n initialHandlerMapSnapshot[key] = [...STYLE_HANDLER_MAP[key]];\n }\n}\n\n/**\n * Reset STYLE_HANDLER_MAP to the initial built-in state.\n * Called by resetConfig() to restore handlers after tests.\n */\nexport function resetHandlers(): void {\n if (!initialHandlerMapSnapshot) {\n // predefine() hasn't been called yet, nothing to reset\n return;\n }\n\n // Clear current map\n for (const key of Object.keys(STYLE_HANDLER_MAP)) {\n delete STYLE_HANDLER_MAP[key];\n }\n\n // Restore initial state\n for (const key of Object.keys(initialHandlerMapSnapshot)) {\n STYLE_HANDLER_MAP[key] = [...initialHandlerMapSnapshot[key]];\n }\n}\n\nexport function defineCustomStyle(\n names: string[] | StyleHandler,\n handler?: RawStyleHandler,\n) {\n let handlerWithLookup: StyleHandler;\n\n if (typeof names === 'function') {\n handlerWithLookup = names;\n names = handlerWithLookup.__lookupStyles;\n } else if (handler) {\n handlerWithLookup = Object.assign(handler, { __lookupStyles: names });\n } else {\n console.warn('Tasty: incorrect custom style definition: ', names);\n return;\n }\n\n if (Array.isArray(names)) {\n // just to pass type checking\n names.forEach((name) => {\n if (!STYLE_HANDLER_MAP[name]) {\n STYLE_HANDLER_MAP[name] = [];\n }\n\n STYLE_HANDLER_MAP[name].push(handlerWithLookup);\n });\n }\n}\n\ntype ConverterHandler = (\n s: string | boolean | number | undefined,\n) => string | undefined;\n\nexport function defineStyleAlias(\n styleName: string,\n cssStyleName?: string,\n converter?: ConverterHandler,\n) {\n const styleHandler = createStyle(styleName, cssStyleName, converter);\n\n if (!STYLE_HANDLER_MAP[styleName]) {\n STYLE_HANDLER_MAP[styleName] = [];\n }\n\n STYLE_HANDLER_MAP[styleName].push(styleHandler);\n}\n\nexport function predefine() {\n // Style aliases\n defineStyleAlias('gridAreas', 'grid-template-areas');\n defineStyleAlias('gridColumns', 'grid-template-columns', columnsConverter);\n defineStyleAlias('gridRows', 'grid-template-rows', rowsConverter);\n defineStyleAlias(\n 'gridTemplate',\n 'grid-template',\n (val: string | boolean | number | undefined) => {\n if (typeof val !== 'string') return;\n\n return val\n .split('/')\n .map((s, i) => (i ? columnsConverter : rowsConverter)(s))\n .join('/');\n },\n );\n // Note: outlineOffset is now handled by outlineStyle\n\n [\n displayStyle,\n transitionStyle,\n fillStyle,\n svgFillStyle,\n widthStyle,\n marginStyle,\n gapStyle,\n flowStyle,\n colorStyle,\n heightStyle,\n radiusStyle,\n borderStyle,\n shadowStyle,\n paddingStyle,\n alignStyle,\n justifyStyle,\n presetStyle,\n outlineStyle,\n scrollbarStyle,\n fadeStyle,\n insetStyle,\n ]\n // @ts-expect-error handler type varies across built-in style handlers\n .forEach((handler) => defineCustomStyle(handler));\n\n // Capture initial state after all built-in handlers are registered\n captureInitialHandlerState();\n\n return { STYLE_HANDLER_MAP, defineCustomStyle, defineStyleAlias };\n}\n\n// ============================================================================\n// Handler Registration API (for configure())\n// ============================================================================\n\n/**\n * Normalize a handler definition to a StyleHandler with __lookupStyles.\n * - Function only: lookup styles inferred from key name\n * - [string, fn]: single lookup style\n * - [string[], fn]: multiple lookup styles\n */\nexport function normalizeHandlerDefinition(\n keyName: string,\n definition: StyleHandlerDefinition,\n): StyleHandler {\n let handler: RawStyleHandler;\n let lookupStyles: string[];\n\n if (typeof definition === 'function') {\n // Function only - lookup styles inferred from key name\n handler = definition;\n lookupStyles = [keyName];\n } else if (Array.isArray(definition)) {\n const [first, fn] = definition;\n\n if (typeof fn !== 'function') {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'Tuple must have a function as the second element: [string, function] or [string[], function].',\n );\n }\n\n handler = fn;\n\n if (typeof first === 'string') {\n // [string, fn] - single lookup style\n lookupStyles = [first];\n } else if (Array.isArray(first)) {\n // [string[], fn] - multiple lookup styles\n lookupStyles = first;\n } else {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'First element must be a string or string array.',\n );\n }\n } else {\n throw new Error(\n `[Tasty] Invalid handler definition for \"${keyName}\". ` +\n 'Expected function, [string, function], or [string[], function].',\n );\n }\n\n // Validate handler in dev mode\n validateHandler(keyName, handler, lookupStyles);\n\n // Wrap the handler to avoid mutation issues when the same function\n // is reused for multiple handler definitions. Each registration\n // gets its own function identity with its own __lookupStyles.\n const wrappedHandler = ((props) => handler(props)) as StyleHandler;\n wrappedHandler.__lookupStyles = lookupStyles;\n\n return wrappedHandler;\n}\n\n/**\n * Validate a handler definition in development mode.\n */\nfunction validateHandler(\n name: string,\n handler: RawStyleHandler,\n lookupStyles: string[],\n): void {\n if (!devMode) return;\n\n if (typeof handler !== 'function') {\n console.warn(\n `[Tasty] Handler \"${name}\" is not a function. ` +\n 'Handlers must be functions that return CSSMap, CSSMap[], or void.',\n );\n }\n\n if (\n !lookupStyles ||\n !Array.isArray(lookupStyles) ||\n lookupStyles.length === 0\n ) {\n console.warn(\n `[Tasty] Handler \"${name}\" has invalid lookupStyles. ` +\n 'Expected non-empty array of style names.',\n );\n }\n}\n\n/**\n * Validate a handler result in development mode.\n * Call this after invoking a handler to check the return value.\n */\nexport function validateHandlerResult(name: string, result: unknown): void {\n if (!devMode) return;\n if (result === undefined || result === null) return; // void is valid\n\n // Check for empty string (migration from old pattern)\n if (result === '') {\n console.warn(\n `[Tasty] Handler \"${name}\" returned empty string. ` +\n 'Return void/undefined instead for no output.',\n );\n return;\n }\n\n // Check result is object (CSSMap or CSSMap[])\n if (typeof result !== 'object') {\n console.warn(\n `[Tasty] Handler \"${name}\" returned invalid type: ${typeof result}. ` +\n 'Expected CSSMap, CSSMap[], or void.',\n );\n }\n}\n\n/**\n * Register a custom handler, replacing any existing handlers for the same lookup styles.\n * This is called by configure() to process user-defined handlers.\n *\n * When registering a handler for style X, any existing handler that processes X\n * is removed from ALL its lookup styles to prevent double-processing.\n * For example, if gapStyle handles ['display', 'flow', 'gap'] and a new handler\n * is registered for just ['gap'], gapStyle is removed from display and flow too.\n */\nexport function registerHandler(handler: StyleHandler): void {\n const lookupStyles = handler.__lookupStyles;\n\n if (!lookupStyles || lookupStyles.length === 0) {\n if (devMode) {\n console.warn(\n '[Tasty] Cannot register handler without __lookupStyles property.',\n );\n }\n return;\n }\n\n // Find and remove existing handlers that would conflict\n // A handler conflicts if it handles any of the same styles as the new handler\n const handlersToRemove = new Set<StyleHandler>();\n\n for (const styleName of lookupStyles) {\n const existing = STYLE_HANDLER_MAP[styleName];\n if (existing) {\n for (const existingHandler of existing) {\n handlersToRemove.add(existingHandler);\n }\n }\n }\n\n // Remove conflicting handlers from ALL their lookup styles\n for (const oldHandler of handlersToRemove) {\n const oldLookupStyles = oldHandler.__lookupStyles;\n if (oldLookupStyles) {\n for (const oldStyleName of oldLookupStyles) {\n const handlers = STYLE_HANDLER_MAP[oldStyleName];\n if (handlers) {\n const filtered = handlers.filter((h) => h !== oldHandler);\n if (filtered.length === 0) {\n delete STYLE_HANDLER_MAP[oldStyleName];\n } else {\n STYLE_HANDLER_MAP[oldStyleName] = filtered;\n }\n }\n }\n }\n }\n\n // Register the new handler under its lookup styles\n for (const styleName of lookupStyles) {\n const existing = STYLE_HANDLER_MAP[styleName];\n if (existing) {\n existing.push(handler);\n } else {\n STYLE_HANDLER_MAP[styleName] = [handler];\n }\n }\n}\n\n// ============================================================================\n// Wrapped Style Handlers Export\n// ============================================================================\n\n/**\n * Create a wrapped handler that can be safely called by users.\n * The wrapper preserves __lookupStyles for proper registration.\n */\nfunction wrapHandler<T extends { __lookupStyles: string[] }>(handler: T): T {\n const fn = handler as unknown as (props: unknown) => unknown;\n const wrapped = ((props: unknown) => fn(props)) as unknown as T;\n wrapped.__lookupStyles = handler.__lookupStyles;\n return wrapped;\n}\n\n/**\n * Exported object containing wrapped predefined style handlers.\n * Users can import and call these to extend or delegate to built-in behavior.\n *\n * Internal handlers use *Style suffix for searchability.\n * External API uses short names for convenience.\n *\n * @example\n * ```ts\n * import { styleHandlers, configure } from '@tenphi/tasty';\n *\n * configure({\n * handlers: {\n * fill: ({ fill }) => {\n * if (fill?.startsWith('gradient:')) {\n * return { background: fill.slice(9) };\n * }\n * return styleHandlers.fill({ fill });\n * },\n * },\n * });\n * ```\n */\nexport const styleHandlers = {\n align: wrapHandler(alignStyle),\n border: wrapHandler(borderStyle),\n color: wrapHandler(colorStyle),\n display: wrapHandler(displayStyle),\n fade: wrapHandler(fadeStyle),\n fill: wrapHandler(fillStyle),\n svgFill: wrapHandler(svgFillStyle),\n flow: wrapHandler(flowStyle),\n gap: wrapHandler(gapStyle),\n height: wrapHandler(heightStyle),\n inset: wrapHandler(insetStyle),\n justify: wrapHandler(justifyStyle),\n margin: wrapHandler(marginStyle),\n outline: wrapHandler(outlineStyle),\n padding: wrapHandler(paddingStyle),\n preset: wrapHandler(presetStyle),\n radius: wrapHandler(radiusStyle),\n scrollbar: wrapHandler(scrollbarStyle),\n shadow: wrapH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SAAS;CAC1B,QAAQ,YAAY,YAAY;CAChC,OAAO,YAAY,WAAW;CAC9B,SAAS,YAAY,aAAa;CAClC,QAAQ,YAAY,YAAY;CAChC,SAAS,YAAY,aAAa;CAClC,SAAS,YAAY,aAAa;CAClC,QAAQ,YAAY,YAAY;CAChC,QAAQ,YAAY,YAAY;CAChC,WAAW,YAAY,eAAe;CACtC,QAAQ,YAAY,YAAY;CAChC,YAAY,YAAY,gBAAgB;CACxC,OAAO,YAAY,WAAW;CAC/B"}
@@ -0,0 +1,52 @@
1
+ import { Styles } from "./types.js";
2
+
3
+ //#region src/styles/preset.d.ts
4
+ interface PresetStyleProps {
5
+ preset?: string | boolean;
6
+ fontSize?: string | number;
7
+ lineHeight?: string | number;
8
+ textTransform?: string;
9
+ letterSpacing?: string | number;
10
+ fontWeight?: string | number;
11
+ fontStyle?: string | boolean;
12
+ fontFamily?: string;
13
+ /** Alias for fontFamily with special handling for 'monospace' and boolean */
14
+ font?: string | boolean;
15
+ }
16
+ /**
17
+ * Handles typography preset and individual font properties.
18
+ *
19
+ * Preset syntax uses `/` to separate name from modifier:
20
+ * - `preset="h1"` — name only
21
+ * - `preset="h2 / strong"` — name + modifier
22
+ * - `preset="bold"` — modifier-only shorthand (name defaults to `inherit`)
23
+ *
24
+ * When `preset` is defined, it sets up CSS custom properties for typography.
25
+ * Individual font props can be used with or without `preset`:
26
+ * - With `preset`: overrides the preset value for that property
27
+ * - Without `preset`: outputs the CSS directly
28
+ *
29
+ * Number values are converted to pixels for fontSize, lineHeight, letterSpacing.
30
+ * fontWeight accepts numbers directly (e.g., 400, 700).
31
+ *
32
+ * font vs fontFamily:
33
+ * - `font` is the recommended prop with special handling (monospace, boolean, fallback)
34
+ * - `fontFamily` is a direct value without special handling
35
+ */
36
+ declare function presetStyle({
37
+ preset,
38
+ fontSize,
39
+ lineHeight,
40
+ textTransform,
41
+ letterSpacing,
42
+ fontWeight,
43
+ fontStyle,
44
+ fontFamily,
45
+ font
46
+ }: PresetStyleProps): Styles | undefined;
47
+ declare namespace presetStyle {
48
+ var __lookupStyles: string[];
49
+ }
50
+ //#endregion
51
+ export { presetStyle };
52
+ //# sourceMappingURL=preset.d.ts.map