@tenphi/tasty 0.0.0-snapshot.fafcbfe → 0.0.0-snapshot.fc19da9

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 (330) hide show
  1. package/README.md +497 -266
  2. package/dist/babel-types-DpUCD2L_.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-BDLYGmKn.js +60 -0
  6. package/dist/chunks/build-config-BDLYGmKn.js.map +1 -0
  7. package/dist/chunks/collector-DqcB0UUT.js +210 -0
  8. package/dist/chunks/collector-DqcB0UUT.js.map +1 -0
  9. package/dist/chunks/config-engine-CGIMO2PV.js +272 -0
  10. package/dist/chunks/config-engine-CGIMO2PV.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-BibU6ZnP.js +904 -0
  14. package/dist/chunks/css-definitions-BibU6ZnP.js.map +1 -0
  15. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-BzYPQ0H2.js +502 -0
  18. package/dist/chunks/debug-BzYPQ0H2.js.map +1 -0
  19. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  20. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-B2e-Wha-.js +689 -0
  24. package/dist/chunks/react-runtime-B2e-Wha-.js.map +1 -0
  25. package/dist/chunks/runtime-engine-yeyCAx2e.js +2431 -0
  26. package/dist/chunks/runtime-engine-yeyCAx2e.js.map +1 -0
  27. package/dist/chunks/runtime-state-C0u1jp-Q.js +141 -0
  28. package/dist/chunks/runtime-state-C0u1jp-Q.js.map +1 -0
  29. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-D35rvcdB.js +5420 -0
  32. package/dist/chunks/style-engine-D35rvcdB.js.map +1 -0
  33. package/dist/chunks/zero-engine-DpkieEPZ.js +310 -0
  34. package/dist/chunks/zero-engine-DpkieEPZ.js.map +1 -0
  35. package/dist/collector-D4POJ53X.d.ts +164 -0
  36. package/dist/config-DvPUj4cw.d.ts +1364 -0
  37. package/dist/core/index.d.ts +5 -33
  38. package/dist/core/index.js +9 -26
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/index-DC4q-xDq.d.ts +1946 -0
  41. package/dist/index.d.ts +5 -40
  42. package/dist/index.js +11 -33
  43. package/dist/{utils/merge-styles.d.ts → merge-styles-Jb5iZ-Jf.d.ts} +3 -4
  44. package/dist/ssr/astro-client.d.ts +1 -0
  45. package/dist/ssr/astro-client.js +6 -0
  46. package/dist/ssr/astro-client.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  49. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  50. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  51. package/dist/ssr/astro-middleware-extract.js +9 -0
  52. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  53. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  54. package/dist/ssr/astro-middleware-static.js +7 -0
  55. package/dist/ssr/astro-middleware-static.js.map +1 -0
  56. package/dist/ssr/astro-middleware.d.ts +18 -0
  57. package/dist/ssr/astro-middleware.js +7 -0
  58. package/dist/ssr/astro-middleware.js.map +1 -0
  59. package/dist/ssr/astro.d.ts +127 -0
  60. package/dist/ssr/astro.js +221 -0
  61. package/dist/ssr/astro.js.map +1 -0
  62. package/dist/ssr/client.d.ts +2 -0
  63. package/dist/ssr/client.js +2 -0
  64. package/dist/ssr/index.d.ts +17 -0
  65. package/dist/ssr/index.js +10 -0
  66. package/dist/ssr/index.js.map +1 -0
  67. package/dist/ssr/next-config.d.ts +64 -0
  68. package/dist/ssr/next-config.js +123 -0
  69. package/dist/ssr/next-config.js.map +1 -0
  70. package/dist/ssr/next.d.ts +46 -0
  71. package/dist/ssr/next.js +60 -0
  72. package/dist/ssr/next.js.map +1 -0
  73. package/dist/static/index.d.ts +90 -5
  74. package/dist/static/index.js +31 -4
  75. package/dist/static/index.js.map +1 -0
  76. package/dist/static/inject.d.ts +4 -0
  77. package/dist/static/inject.js +17 -0
  78. package/dist/static/inject.js.map +1 -0
  79. package/dist/types-ZbF2_6LV.d.ts +1567 -0
  80. package/dist/zero/babel.d.ts +49 -90
  81. package/dist/zero/babel.js +252 -119
  82. package/dist/zero/babel.js.map +1 -1
  83. package/dist/zero/index.d.ts +117 -3
  84. package/dist/zero/index.js +23 -3
  85. package/dist/zero/index.js.map +1 -0
  86. package/dist/zero/next.d.ts +58 -33
  87. package/dist/zero/next.js +89 -59
  88. package/dist/zero/next.js.map +1 -1
  89. package/docs/README.md +42 -0
  90. package/docs/adoption.md +331 -0
  91. package/docs/ai-agents.md +252 -0
  92. package/docs/comparison.md +449 -0
  93. package/docs/configuration.md +943 -0
  94. package/docs/debug.md +333 -0
  95. package/docs/design-system.md +557 -0
  96. package/docs/dsl.md +1093 -0
  97. package/docs/getting-started.md +297 -0
  98. package/docs/injector.md +633 -0
  99. package/docs/methodology.md +673 -0
  100. package/docs/migration-v3.md +285 -0
  101. package/docs/pipeline.md +768 -0
  102. package/docs/plugins.md +333 -0
  103. package/docs/react-api.md +703 -0
  104. package/docs/runtime-benchmarks.md +388 -0
  105. package/docs/ssr.md +630 -0
  106. package/docs/styles.md +725 -0
  107. package/docs/tasty-static.md +659 -0
  108. package/package.json +238 -50
  109. package/tasty.config.ts +6 -0
  110. package/dist/_virtual/_rolldown/runtime.js +0 -8
  111. package/dist/chunks/cacheKey.js +0 -70
  112. package/dist/chunks/cacheKey.js.map +0 -1
  113. package/dist/chunks/definitions.d.ts +0 -37
  114. package/dist/chunks/definitions.js +0 -260
  115. package/dist/chunks/definitions.js.map +0 -1
  116. package/dist/chunks/renderChunk.js +0 -61
  117. package/dist/chunks/renderChunk.js.map +0 -1
  118. package/dist/config.d.ts +0 -280
  119. package/dist/config.js +0 -403
  120. package/dist/config.js.map +0 -1
  121. package/dist/debug.d.ts +0 -204
  122. package/dist/debug.js +0 -733
  123. package/dist/debug.js.map +0 -1
  124. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  125. package/dist/hooks/useGlobalStyles.js +0 -56
  126. package/dist/hooks/useGlobalStyles.js.map +0 -1
  127. package/dist/hooks/useKeyframes.d.ts +0 -56
  128. package/dist/hooks/useKeyframes.js +0 -54
  129. package/dist/hooks/useKeyframes.js.map +0 -1
  130. package/dist/hooks/useProperty.d.ts +0 -79
  131. package/dist/hooks/useProperty.js +0 -91
  132. package/dist/hooks/useProperty.js.map +0 -1
  133. package/dist/hooks/useRawCSS.d.ts +0 -53
  134. package/dist/hooks/useRawCSS.js +0 -28
  135. package/dist/hooks/useRawCSS.js.map +0 -1
  136. package/dist/hooks/useStyles.d.ts +0 -40
  137. package/dist/hooks/useStyles.js +0 -169
  138. package/dist/hooks/useStyles.js.map +0 -1
  139. package/dist/injector/index.d.ts +0 -157
  140. package/dist/injector/index.js +0 -154
  141. package/dist/injector/index.js.map +0 -1
  142. package/dist/injector/injector.d.ts +0 -139
  143. package/dist/injector/injector.js +0 -404
  144. package/dist/injector/injector.js.map +0 -1
  145. package/dist/injector/sheet-manager.d.ts +0 -127
  146. package/dist/injector/sheet-manager.js +0 -714
  147. package/dist/injector/sheet-manager.js.map +0 -1
  148. package/dist/injector/types.d.ts +0 -135
  149. package/dist/keyframes/index.js +0 -206
  150. package/dist/keyframes/index.js.map +0 -1
  151. package/dist/parser/classify.js +0 -319
  152. package/dist/parser/classify.js.map +0 -1
  153. package/dist/parser/const.js +0 -33
  154. package/dist/parser/const.js.map +0 -1
  155. package/dist/parser/lru.js +0 -109
  156. package/dist/parser/lru.js.map +0 -1
  157. package/dist/parser/parser.d.ts +0 -25
  158. package/dist/parser/parser.js +0 -116
  159. package/dist/parser/parser.js.map +0 -1
  160. package/dist/parser/tokenizer.js +0 -69
  161. package/dist/parser/tokenizer.js.map +0 -1
  162. package/dist/parser/types.d.ts +0 -51
  163. package/dist/parser/types.js +0 -46
  164. package/dist/parser/types.js.map +0 -1
  165. package/dist/pipeline/conditions.d.ts +0 -134
  166. package/dist/pipeline/conditions.js +0 -400
  167. package/dist/pipeline/conditions.js.map +0 -1
  168. package/dist/pipeline/exclusive.js +0 -231
  169. package/dist/pipeline/exclusive.js.map +0 -1
  170. package/dist/pipeline/index.d.ts +0 -53
  171. package/dist/pipeline/index.js +0 -641
  172. package/dist/pipeline/index.js.map +0 -1
  173. package/dist/pipeline/materialize.js +0 -908
  174. package/dist/pipeline/materialize.js.map +0 -1
  175. package/dist/pipeline/parseStateKey.d.ts +0 -15
  176. package/dist/pipeline/parseStateKey.js +0 -430
  177. package/dist/pipeline/parseStateKey.js.map +0 -1
  178. package/dist/pipeline/simplify.js +0 -557
  179. package/dist/pipeline/simplify.js.map +0 -1
  180. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  181. package/dist/plugins/okhsl-plugin.js +0 -371
  182. package/dist/plugins/okhsl-plugin.js.map +0 -1
  183. package/dist/plugins/types.d.ts +0 -69
  184. package/dist/properties/index.js +0 -158
  185. package/dist/properties/index.js.map +0 -1
  186. package/dist/states/index.d.ts +0 -49
  187. package/dist/states/index.js +0 -416
  188. package/dist/states/index.js.map +0 -1
  189. package/dist/static/tastyStatic.d.ts +0 -46
  190. package/dist/static/tastyStatic.js +0 -31
  191. package/dist/static/tastyStatic.js.map +0 -1
  192. package/dist/static/types.d.ts +0 -49
  193. package/dist/static/types.js +0 -24
  194. package/dist/static/types.js.map +0 -1
  195. package/dist/styles/align.d.ts +0 -15
  196. package/dist/styles/align.js +0 -14
  197. package/dist/styles/align.js.map +0 -1
  198. package/dist/styles/border.d.ts +0 -25
  199. package/dist/styles/border.js +0 -114
  200. package/dist/styles/border.js.map +0 -1
  201. package/dist/styles/color.d.ts +0 -14
  202. package/dist/styles/color.js +0 -23
  203. package/dist/styles/color.js.map +0 -1
  204. package/dist/styles/createStyle.js +0 -77
  205. package/dist/styles/createStyle.js.map +0 -1
  206. package/dist/styles/dimension.js +0 -97
  207. package/dist/styles/dimension.js.map +0 -1
  208. package/dist/styles/display.d.ts +0 -37
  209. package/dist/styles/display.js +0 -67
  210. package/dist/styles/display.js.map +0 -1
  211. package/dist/styles/fade.d.ts +0 -15
  212. package/dist/styles/fade.js +0 -58
  213. package/dist/styles/fade.js.map +0 -1
  214. package/dist/styles/fill.d.ts +0 -44
  215. package/dist/styles/fill.js +0 -51
  216. package/dist/styles/fill.js.map +0 -1
  217. package/dist/styles/flow.d.ts +0 -16
  218. package/dist/styles/flow.js +0 -12
  219. package/dist/styles/flow.js.map +0 -1
  220. package/dist/styles/gap.d.ts +0 -31
  221. package/dist/styles/gap.js +0 -37
  222. package/dist/styles/gap.js.map +0 -1
  223. package/dist/styles/height.d.ts +0 -17
  224. package/dist/styles/height.js +0 -20
  225. package/dist/styles/height.js.map +0 -1
  226. package/dist/styles/index.d.ts +0 -2
  227. package/dist/styles/index.js +0 -9
  228. package/dist/styles/index.js.map +0 -1
  229. package/dist/styles/inset.d.ts +0 -52
  230. package/dist/styles/inset.js +0 -150
  231. package/dist/styles/inset.js.map +0 -1
  232. package/dist/styles/justify.d.ts +0 -15
  233. package/dist/styles/justify.js +0 -14
  234. package/dist/styles/justify.js.map +0 -1
  235. package/dist/styles/list.d.ts +0 -16
  236. package/dist/styles/list.js +0 -98
  237. package/dist/styles/list.js.map +0 -1
  238. package/dist/styles/margin.d.ts +0 -24
  239. package/dist/styles/margin.js +0 -104
  240. package/dist/styles/margin.js.map +0 -1
  241. package/dist/styles/outline.d.ts +0 -29
  242. package/dist/styles/outline.js +0 -65
  243. package/dist/styles/outline.js.map +0 -1
  244. package/dist/styles/padding.d.ts +0 -24
  245. package/dist/styles/padding.js +0 -104
  246. package/dist/styles/padding.js.map +0 -1
  247. package/dist/styles/predefined.d.ts +0 -73
  248. package/dist/styles/predefined.js +0 -241
  249. package/dist/styles/predefined.js.map +0 -1
  250. package/dist/styles/preset.d.ts +0 -47
  251. package/dist/styles/preset.js +0 -126
  252. package/dist/styles/preset.js.map +0 -1
  253. package/dist/styles/radius.d.ts +0 -14
  254. package/dist/styles/radius.js +0 -51
  255. package/dist/styles/radius.js.map +0 -1
  256. package/dist/styles/scrollbar.d.ts +0 -21
  257. package/dist/styles/scrollbar.js +0 -105
  258. package/dist/styles/scrollbar.js.map +0 -1
  259. package/dist/styles/shadow.d.ts +0 -14
  260. package/dist/styles/shadow.js +0 -24
  261. package/dist/styles/shadow.js.map +0 -1
  262. package/dist/styles/styledScrollbar.d.ts +0 -47
  263. package/dist/styles/styledScrollbar.js +0 -38
  264. package/dist/styles/styledScrollbar.js.map +0 -1
  265. package/dist/styles/transition.d.ts +0 -14
  266. package/dist/styles/transition.js +0 -158
  267. package/dist/styles/transition.js.map +0 -1
  268. package/dist/styles/types.d.ts +0 -498
  269. package/dist/styles/width.d.ts +0 -17
  270. package/dist/styles/width.js +0 -20
  271. package/dist/styles/width.js.map +0 -1
  272. package/dist/tasty.d.ts +0 -982
  273. package/dist/tasty.js +0 -191
  274. package/dist/tasty.js.map +0 -1
  275. package/dist/tokens/typography.d.ts +0 -19
  276. package/dist/tokens/typography.js +0 -237
  277. package/dist/tokens/typography.js.map +0 -1
  278. package/dist/types.d.ts +0 -184
  279. package/dist/utils/cache-wrapper.js +0 -26
  280. package/dist/utils/cache-wrapper.js.map +0 -1
  281. package/dist/utils/case-converter.js +0 -8
  282. package/dist/utils/case-converter.js.map +0 -1
  283. package/dist/utils/colors.d.ts +0 -5
  284. package/dist/utils/colors.js +0 -9
  285. package/dist/utils/colors.js.map +0 -1
  286. package/dist/utils/css-types.d.ts +0 -7
  287. package/dist/utils/dotize.d.ts +0 -26
  288. package/dist/utils/dotize.js +0 -122
  289. package/dist/utils/dotize.js.map +0 -1
  290. package/dist/utils/filter-base-props.d.ts +0 -15
  291. package/dist/utils/filter-base-props.js +0 -45
  292. package/dist/utils/filter-base-props.js.map +0 -1
  293. package/dist/utils/get-display-name.d.ts +0 -7
  294. package/dist/utils/get-display-name.js +0 -10
  295. package/dist/utils/get-display-name.js.map +0 -1
  296. package/dist/utils/hsl-to-rgb.js +0 -38
  297. package/dist/utils/hsl-to-rgb.js.map +0 -1
  298. package/dist/utils/is-dev-env.js +0 -19
  299. package/dist/utils/is-dev-env.js.map +0 -1
  300. package/dist/utils/is-valid-element-type.js +0 -15
  301. package/dist/utils/is-valid-element-type.js.map +0 -1
  302. package/dist/utils/merge-styles.js.map +0 -1
  303. package/dist/utils/mod-attrs.d.ts +0 -8
  304. package/dist/utils/mod-attrs.js +0 -21
  305. package/dist/utils/mod-attrs.js.map +0 -1
  306. package/dist/utils/okhsl-to-rgb.js +0 -296
  307. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  308. package/dist/utils/process-tokens.d.ts +0 -31
  309. package/dist/utils/process-tokens.js +0 -171
  310. package/dist/utils/process-tokens.js.map +0 -1
  311. package/dist/utils/resolve-recipes.d.ts +0 -17
  312. package/dist/utils/resolve-recipes.js +0 -147
  313. package/dist/utils/resolve-recipes.js.map +0 -1
  314. package/dist/utils/string.js +0 -8
  315. package/dist/utils/string.js.map +0 -1
  316. package/dist/utils/styles.d.ts +0 -183
  317. package/dist/utils/styles.js +0 -585
  318. package/dist/utils/styles.js.map +0 -1
  319. package/dist/utils/typography.d.ts +0 -36
  320. package/dist/utils/typography.js +0 -53
  321. package/dist/utils/typography.js.map +0 -1
  322. package/dist/utils/warnings.d.ts +0 -16
  323. package/dist/utils/warnings.js +0 -16
  324. package/dist/utils/warnings.js.map +0 -1
  325. package/dist/zero/css-writer.d.ts +0 -45
  326. package/dist/zero/css-writer.js +0 -74
  327. package/dist/zero/css-writer.js.map +0 -1
  328. package/dist/zero/extractor.d.ts +0 -24
  329. package/dist/zero/extractor.js +0 -150
  330. package/dist/zero/extractor.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"next.js","names":[],"sources":["../../src/zero/next.ts"],"sourcesContent":["/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * Provides a convenient way to configure the Babel plugin for Next.js projects.\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/next');\n *\n * module.exports = withTastyZero({\n * output: 'public/tasty.css',\n * })({\n * // your Next.js config\n * });\n * ```\n */\n\nimport * as path from 'path';\n\n// Next.js types (inline to avoid requiring next as a dependency)\ninterface WebpackConfigContext {\n isServer: boolean;\n dev: boolean;\n buildId: string;\n dir: string;\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- webpack config types are complex */\ninterface NextConfig {\n webpack?: (config: any, context: WebpackConfigContext) => any;\n [key: string]: unknown;\n}\n\nexport interface TastyZeroNextOptions {\n /**\n * Output path for CSS relative to project root.\n * @default 'public/tasty.css'\n */\n output?: string;\n\n /**\n * Whether to enable the plugin.\n * @default true\n */\n enabled?: boolean;\n}\n\n/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * @param options - Configuration options\n * @returns A function that wraps the Next.js config\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/next');\n *\n * module.exports = withTastyZero()({\n * reactStrictMode: true,\n * });\n * ```\n */\nexport function withTastyZero(options: TastyZeroNextOptions = {}) {\n const { output = 'public/tasty.css', enabled = true } = options;\n\n return (nextConfig: NextConfig = {}): NextConfig => {\n if (!enabled) {\n return nextConfig;\n }\n\n return {\n ...nextConfig,\n\n webpack(config: any, context: WebpackConfigContext) {\n const { isServer, dir } = context;\n\n // Only process on client build to avoid duplicate CSS generation\n if (!isServer) {\n // Get absolute output path\n const absoluteOutput = path.resolve(dir || process.cwd(), output);\n\n // Find existing babel-loader rule or add new one\n const babelPluginConfig = [\n require.resolve('./babel'),\n { output: absoluteOutput },\n ];\n\n // Add our plugin to the existing babel config or create new rule\n const existingRule = config.module?.rules?.find(\n (rule: any) =>\n rule.use?.loader === 'babel-loader' ||\n rule.use?.some?.((u: any) => u.loader === 'babel-loader'),\n );\n\n if (existingRule) {\n // Add to existing babel-loader\n const babelUse = Array.isArray(existingRule.use)\n ? existingRule.use.find((u: any) => u.loader === 'babel-loader')\n : existingRule.use;\n\n if (babelUse?.options) {\n babelUse.options.plugins = babelUse.options.plugins || [];\n babelUse.options.plugins.push(babelPluginConfig);\n }\n } else {\n // Add new rule for our plugin\n config.module = config.module || {};\n config.module.rules = config.module.rules || [];\n config.module.rules.push({\n test: /\\.(tsx?|jsx?)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: require.resolve('babel-loader'),\n options: {\n plugins: [babelPluginConfig],\n },\n },\n ],\n });\n }\n }\n\n // Chain with existing webpack config\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(config, context);\n }\n\n return config;\n },\n };\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,SAAgB,cAAc,UAAgC,EAAE,EAAE;CAChE,MAAM,EAAE,SAAS,oBAAoB,UAAU,SAAS;AAExD,SAAQ,aAAyB,EAAE,KAAiB;AAClD,MAAI,CAAC,QACH,QAAO;AAGT,SAAO;GACL,GAAG;GAEH,QAAQ,QAAa,SAA+B;IAClD,MAAM,EAAE,UAAU,QAAQ;AAG1B,QAAI,CAAC,UAAU;KAEb,MAAM,iBAAiB,KAAK,QAAQ,OAAO,QAAQ,KAAK,EAAE,OAAO;KAGjE,MAAM,oBAAoB,WAChB,QAAQ,UAAU,EAC1B,EAAE,QAAQ,gBAAgB,CAC3B;KAGD,MAAM,eAAe,OAAO,QAAQ,OAAO,MACxC,SACC,KAAK,KAAK,WAAW,kBACrB,KAAK,KAAK,QAAQ,MAAW,EAAE,WAAW,eAAe,CAC5D;AAED,SAAI,cAAc;MAEhB,MAAM,WAAW,MAAM,QAAQ,aAAa,IAAI,GAC5C,aAAa,IAAI,MAAM,MAAW,EAAE,WAAW,eAAe,GAC9D,aAAa;AAEjB,UAAI,UAAU,SAAS;AACrB,gBAAS,QAAQ,UAAU,SAAS,QAAQ,WAAW,EAAE;AACzD,gBAAS,QAAQ,QAAQ,KAAK,kBAAkB;;YAE7C;AAEL,aAAO,SAAS,OAAO,UAAU,EAAE;AACnC,aAAO,OAAO,QAAQ,OAAO,OAAO,SAAS,EAAE;AAC/C,aAAO,OAAO,MAAM,KAAK;OACvB,MAAM;OACN,SAAS;OACT,KAAK,CACH;QACE,kBAAgB,QAAQ,eAAe;QACvC,SAAS,EACP,SAAS,CAAC,kBAAkB,EAC7B;QACF,CACF;OACF,CAAC;;;AAKN,QAAI,OAAO,WAAW,YAAY,WAChC,QAAO,WAAW,QAAQ,QAAQ,QAAQ;AAG5C,WAAO;;GAEV"}
1
+ {"version":3,"file":"next.js","names":[],"sources":["../../src/zero/next.ts"],"sourcesContent":["/**\n * Next.js configuration wrapper for tasty-zero.\n *\n * Supports both webpack and Turbopack bundlers:\n * - **webpack**: Injects a babel-loader rule with the tasty-zero Babel plugin\n * via `webpack()` config hook. Config is passed as a jiti factory function.\n * - **Turbopack**: Adds a `turbopack.rules` entry with babel-loader and\n * JSON-serializable options (`configFile` path instead of a function).\n * The Babel plugin loads the config internally via jiti.\n *\n * The generated CSS is injected automatically — `@tenphi/tasty/static`\n * imports are replaced with an import of the output CSS file at build time.\n * No manual CSS import in layout files is needed.\n *\n * @example\n * ```javascript\n * // next.config.js\n * const { withTastyZero } = require('@tenphi/tasty/zero/next');\n *\n * module.exports = withTastyZero({\n * output: 'public/tasty.css',\n * configFile: './app/tasty-zero.config.ts',\n * })({\n * // your Next.js config\n * });\n * ```\n */\n\nimport { createRequire } from 'module';\nimport * as path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport type { TastyZeroBabelOptions, TastyZeroConfig } from './babel';\nimport { loadConfigFile } from './config-file';\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = path.dirname(__filename);\n\n// Next.js types (inline to avoid requiring next as a dependency)\ninterface WebpackConfigContext {\n isServer: boolean;\n dev: boolean;\n buildId: string;\n dir: string;\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any -- webpack/Next.js config types are complex */\ninterface TurbopackLoaderItem {\n loader: string;\n options?: Record<string, unknown>;\n}\n\ninterface TurbopackRuleConfig {\n loaders: (string | TurbopackLoaderItem)[];\n as?: string;\n condition?: unknown;\n}\n\ninterface TurbopackConfig {\n rules?: Record<string, TurbopackRuleConfig | TurbopackRuleConfig[]>;\n [key: string]: unknown;\n}\n\ninterface NextConfig {\n webpack?: (config: any, context: WebpackConfigContext) => any;\n turbopack?: TurbopackConfig;\n [key: string]: unknown;\n}\n\nexport interface TastyZeroNextOptions {\n /**\n * Output path for CSS relative to project root.\n * @default 'public/tasty.css'\n */\n output?: string;\n\n /**\n * Whether to enable the plugin.\n * @default true\n */\n enabled?: boolean;\n\n /**\n * Tasty configuration for build-time processing.\n * For static configs that don't change during dev.\n *\n * For configs that depend on theme files, use `configFile` instead.\n */\n config?: TastyZeroConfig;\n\n /**\n * Path to a TypeScript/JavaScript module that exports the tasty zero config\n * as its default export. The module is re-evaluated on each\n * compilation, enabling hot reload when the file (or its imports) change.\n *\n * @example './app/tasty-zero.config.ts'\n */\n configFile?: string;\n\n /**\n * Extra file paths (relative to project root) that the config depends on.\n * When any of these files change, the Babel cache is invalidated and\n * the config is re-evaluated.\n *\n * The `configFile` itself is always tracked automatically.\n * Use this for transitive dependencies that aren't directly imported\n * by the config file, or when using `config` instead of `configFile`.\n *\n * @example ['./app/theme.ts']\n */\n configDeps?: string[];\n\n /**\n * Output mode for extracted CSS.\n *\n * - `'file'` (default): CSS is written to a single output file.\n * - `'inject'`: CSS is embedded inline in JS and injected at runtime.\n * No CSS file is written. Best for reusable components and extensions.\n *\n * When `mode` is `'inject'`, `output` is ignored.\n *\n * @default 'file'\n */\n mode?: 'file' | 'inject';\n}\n\n/**\n * Next.js configuration wrapper for tasty-zero.\n * Configures both webpack and Turbopack bundlers automatically.\n */\nexport function withTastyZero(options: TastyZeroNextOptions = {}) {\n const {\n output = 'public/tasty.css',\n enabled = true,\n config: tastyConfig,\n configFile,\n configDeps = [],\n mode,\n } = options;\n\n return (nextConfig: NextConfig = {}): NextConfig => {\n if (!enabled) {\n return nextConfig;\n }\n\n const projectDir = process.cwd();\n const absoluteOutput = path.resolve(projectDir, output);\n const babelPluginPath = path.resolve(__dirname, 'babel.js');\n\n const absoluteConfigFile = configFile\n ? path.resolve(projectDir, configFile)\n : undefined;\n\n const allDeps = [\n ...(absoluteConfigFile ? [absoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(projectDir, dep)),\n ];\n\n // --- Turbopack configuration ---\n // Turbopack loader options must be JSON-serializable (no functions).\n // The Babel plugin loads config internally via `configFile` path + jiti.\n const turbopackBabelOptions: Record<string, unknown> = {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [\n [\n babelPluginPath,\n {\n output: absoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n ...(absoluteConfigFile\n ? { configFile: absoluteConfigFile }\n : tastyConfig\n ? { config: tastyConfig }\n : {}),\n ...(allDeps.length > 0 ? { configDeps: allDeps } : {}),\n },\n ],\n ],\n };\n\n const existingTurbopack = nextConfig.turbopack || {};\n const existingRules = existingTurbopack.rules || {};\n\n const existingExperimental =\n (nextConfig.experimental as Record<string, unknown>) || {};\n\n return {\n ...nextConfig,\n\n experimental: {\n ...existingExperimental,\n turbopackUseBuiltinBabel: true,\n },\n\n turbopack: {\n ...existingTurbopack,\n rules: {\n ...existingRules,\n '*.{ts,tsx,js,jsx}': {\n condition: { not: 'foreign' },\n loaders: [\n {\n loader: 'babel-loader',\n options: turbopackBabelOptions,\n },\n ],\n },\n },\n },\n\n webpack(config: any, context: WebpackConfigContext) {\n const { dir } = context;\n\n const wpProjectDir = dir || projectDir;\n const wpAbsoluteOutput = path.resolve(wpProjectDir, output);\n const projectRequire = createRequire(\n path.resolve(wpProjectDir, 'package.json'),\n );\n\n const wpAbsoluteConfigFile = configFile\n ? path.resolve(wpProjectDir, configFile)\n : undefined;\n\n const wpAllDeps = [\n ...(wpAbsoluteConfigFile ? [wpAbsoluteConfigFile] : []),\n ...configDeps.map((dep) => path.resolve(wpProjectDir, dep)),\n ];\n\n const babelPluginOptions: TastyZeroBabelOptions = {\n output: wpAbsoluteOutput,\n injectImport: true,\n ...(mode ? { mode } : {}),\n };\n\n if (wpAbsoluteConfigFile) {\n babelPluginOptions.config = () =>\n loadConfigFile<TastyZeroConfig>(wpAbsoluteConfigFile, wpProjectDir);\n } else if (tastyConfig) {\n babelPluginOptions.config = tastyConfig;\n }\n\n if (wpAllDeps.length > 0) {\n babelPluginOptions.configDeps = wpAllDeps;\n }\n\n const babelPluginConfig = [babelPluginPath, babelPluginOptions];\n\n const existingRule = config.module?.rules?.find(\n (rule: any) =>\n rule.use?.loader === 'babel-loader' ||\n rule.use?.some?.((u: any) => u.loader === 'babel-loader'),\n );\n\n if (existingRule) {\n const babelUse = Array.isArray(existingRule.use)\n ? existingRule.use.find((u: any) => u.loader === 'babel-loader')\n : existingRule.use;\n\n if (babelUse?.options) {\n babelUse.options.plugins = babelUse.options.plugins || [];\n babelUse.options.plugins.push(babelPluginConfig);\n }\n } else {\n config.module = config.module || {};\n config.module.rules = config.module.rules || [];\n config.module.rules.push({\n test: /\\.(tsx?|jsx?)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: projectRequire.resolve('babel-loader'),\n options: {\n babelrc: false,\n configFile: false,\n parserOpts: {\n plugins: ['typescript', 'jsx', 'decorators-legacy'],\n },\n plugins: [babelPluginConfig],\n },\n },\n ],\n });\n }\n\n if (typeof nextConfig.webpack === 'function') {\n return nextConfig.webpack(config, context);\n }\n\n return config;\n },\n };\n };\n}\n"],"mappings":"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"}
package/docs/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Tasty Docs
2
+
3
+ Tasty is CSS-in-JS for React design systems. You describe hover, disabled, variants, themes, responsive behavior, and other conditions as state maps; Tasty compiles them so one branch wins without specificity fights or source-order surprises.
4
+
5
+ Use this hub to move from the core idea to a working component, then into design-system patterns or API reference as needed.
6
+
7
+ ## Start Here
8
+
9
+ - **Understand why**: [Introduction](../README.md) for the problem, the state-map model, and the product overview.
10
+ - **Try it**: [Getting Started](getting-started.md) to build a stateful component, add shared configuration, and choose a rendering mode.
11
+ - **Build a component system**: [Methodology](methodology.md) for root + sub-elements, typed public APIs, tokens, and extension patterns; then [Building a Design System](design-system.md).
12
+ - **Evaluate or adopt it**: [Comparison](comparison.md) for tool-selection context and [Adoption Guide](adoption.md) for an incremental rollout.
13
+ - **Understand the compiler**: [Style rendering pipeline](pipeline.md) for how state maps become mutually exclusive selectors.
14
+
15
+ ## By Role
16
+
17
+ - **Application developer using an existing design system**: [Getting Started](getting-started.md), then [React API](react-api.md).
18
+ - **Design-system author**: [Methodology](methodology.md), [Building a Design System](design-system.md), [Configuration](configuration.md), and [Adoption Guide](adoption.md).
19
+ - **Platform or tooling engineer**: [Configuration](configuration.md), [Plugins & Extension Points](plugins.md), [Build-Time Extraction (`tastyStatic`)](tasty-static.md), [Server-Side Rendering](ssr.md), and [Debug Utilities](debug.md).
20
+
21
+ ## By Styling Approach
22
+
23
+ - **React components**: [React API](react-api.md)
24
+ - **Zero-client-runtime React with `tasty()`**: [Server-Side Rendering](ssr.md), especially the static Astro integration
25
+ - **Build-time extraction with `tastyStatic()`**: [Build-Time Extraction](tasty-static.md)
26
+ - **Hydrated `tasty()` with server collection**: [Server-Side Rendering](ssr.md)
27
+ - **Upgrading from v2**: [Migration Guide (v2 → v3)](migration-v3.md)
28
+
29
+ ## By Task
30
+
31
+ - **Learn the style language**: [Style DSL](dsl.md)
32
+ - **Set up linting and autocomplete**: [Getting Started — ESLint plugin](getting-started.md#eslint-plugin) and [TypeScript autocomplete](getting-started.md#typescript-autocomplete)
33
+ - **Design a component's public API** (`styleProps`, `modProps`, `tokenProps`, variants, sub-elements): [React API](react-api.md), then [Methodology](methodology.md)
34
+ - **Generate a color palette with contrast solving**: [Glaze](../README.md#glaze)
35
+ - **Brief an AI agent (or yourself) on writing correct styles**: [Style Rules for AI Agents](ai-agents.md)
36
+ - **Look up a property handler**: [Style Properties](styles.md)
37
+ - **Define tokens, units, recipes, keyframes, properties, functions, or polyfills globally**: [Configuration](configuration.md)
38
+ - **Extend Tasty with a plugin, custom handler, or custom prop**: [Plugins & Extension Points](plugins.md)
39
+ - **Debug generated CSS or cache behavior**: [Debug Utilities](debug.md)
40
+ - **Understand how selector generation works internally**: [Style rendering pipeline](pipeline.md)
41
+ - **Understand runtime injection internals**: [Style Injector](injector.md)
42
+ - **Reproduce and interpret performance measurements**: [Runtime Benchmarks](runtime-benchmarks.md)
@@ -0,0 +1,331 @@
1
+ # Adoption Guide
2
+
3
+ Tasty is most useful where reusable component styling has become a state-resolution problem: hover intersects with disabled, variants intersect with themes, and every extension makes selector behavior harder to predict.
4
+
5
+ It normally sits underneath a design system’s existing components. You can preserve their public React APIs while moving their style logic into state maps that produce one declared winner. Adoption should start with a small, state-heavy component—not an all-at-once rewrite.
6
+
7
+ This guide is for design-system maintainers and platform engineers evaluating Tasty or introducing it into an existing codebase. Use it for rollout strategy and adoption sequencing; use the [Comparison guide](comparison.md) when the open question is whether Tasty is the right tool.
8
+
9
+ ---
10
+
11
+ ## Where Tasty sits in the stack
12
+
13
+ Tasty is not the surface your product engineers interact with directly. It sits one layer below:
14
+
15
+ ```
16
+ Product code
17
+ └─ DS components (Button, Card, Layout, ...)
18
+ └─ Tasty engine (tasty(), configure(), style functions)
19
+ └─ CSS (mutually exclusive selectors, tokens, custom properties)
20
+ ```
21
+
22
+ **What Tasty owns:**
23
+
24
+ - The DSL and value parser (tokens, custom units, auto-calc, color opacity)
25
+ - State compilation (mutually exclusive selectors from state maps)
26
+ - Style injection and deduplication (runtime or build-time)
27
+ - The `tasty()` component factory and style functions (`useStyles`, `useGlobalStyles`, …)
28
+ - The lint rules and TypeScript extension interfaces that check usage against your vocabulary
29
+
30
+ **What the DS team owns:**
31
+
32
+ - Token names and values (colors, spacing, typography)
33
+ - Custom units and their semantics
34
+ - State aliases (`@mobile`, `@dark`, `@compact`)
35
+ - Recipes (reusable style bundles)
36
+ - Which style props each component exposes
37
+ - Sub-element structure for compound components
38
+ - The override and extension rules product teams follow
39
+
40
+ Two teams using Tasty can end up with very different authoring models. That is by design.
41
+
42
+ ---
43
+
44
+ ## Who should adopt Tasty
45
+
46
+ **Strong fit:**
47
+
48
+ - A design-system or platform team that owns shared component APIs
49
+ - Components with complex, intersecting states (hover + disabled + theme + breakpoint)
50
+ - Teams that need deterministic style resolution without cascade/specificity bugs
51
+ - Organizations that want tokens, states, and extension rules to stay consistent across products
52
+
53
+ **Not the right fit:**
54
+
55
+ - Solo developers building a one-off app with minimal UI structure
56
+ - Teams that want a shared utility vocabulary and direct markup authoring (Tailwind is better here)
57
+ - Projects where low ceremony matters more than central governance
58
+ - Codebases where intersecting state complexity is low
59
+
60
+ For a detailed comparison with Tailwind, Panda CSS, vanilla-extract, StyleX, Stitches, and Emotion, see the [Comparison guide](comparison.md).
61
+
62
+ ---
63
+
64
+ ## What you are expected to define
65
+
66
+ Tasty provides the engine. The DS team defines the language that runs on it. Here is what that typically involves:
67
+
68
+ | Layer | What you define | Where |
69
+ | ------------------ | ----------------------------------------------------------------------------------- | --------------------------------------------------- |
70
+ | **Tokens** | Color names and named values (`#surface`, `$sidebar-width`) | `configure({ tokens })` |
71
+ | **Units** | Spacing step, radius, border and outline widths (`x`, `r`, `bw`, `ow`, or your own) | `configure({ units })` |
72
+ | **State aliases** | Responsive breakpoints, theme modes, feature flags | `configure({ states })` |
73
+ | **Recipes** | Reusable style bundles (card, elevated, input-reset) | `configure({ recipes })` |
74
+ | **Typography** | Preset definitions (h1-h6, t1-t4, etc.) | `configure({ presets: { ... } })` |
75
+ | **Style props** | Which CSS properties each component exposes as React props | `styleProps` in each component |
76
+ | **Sub-elements** | Inner parts of compound components (Title, Icon, Content) | `elements` + capitalized keys in `styles` |
77
+ | **Component API** | Typed props for states, values, and looks | `modProps`, `tokenProps`, `variants` |
78
+ | **Override rules** | How product engineers extend or constrain components | Styled wrappers via `tasty(Base, { ... })` |
79
+ | **Guardrails** | The names the linter and TypeScript check against | `tasty.config.ts`, `declare module '@tenphi/tasty'` |
80
+
81
+ The same engine can power a minimal design system with a handful of tokens:
82
+
83
+ ```tsx
84
+ configure({
85
+ tokens: { '#bg': '#white', '#text': '#111' },
86
+ states: { '@dark': '@root(schema=dark)' },
87
+ });
88
+ ```
89
+
90
+ ...or an enterprise-scale system with dozens of tokens, multiple state aliases, typography presets, recipes, and custom units. The scope is yours to decide.
91
+
92
+ Here is how the layers connect end-to-end. The DS team configures the engine, defines components, and product engineers consume them:
93
+
94
+ ```tsx
95
+ // ds/config.ts — DS team defines the language
96
+ configure({
97
+ tokens: {
98
+ '#primary': 'oklch(55% 0.25 265)',
99
+ '#surface': '#fff',
100
+ '#text': '#111',
101
+ },
102
+ states: { '@mobile': '@media(w < 768px)', '@dark': '@root(schema=dark)' },
103
+ recipes: {
104
+ card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
105
+ },
106
+ });
107
+
108
+ // ds/components/Card.tsx — DS team builds components on top
109
+ const Card = tasty({
110
+ styles: {
111
+ recipe: 'card',
112
+ Title: { preset: 'h3', color: '#primary' },
113
+ Body: { preset: 't2', color: '#text' },
114
+ },
115
+ elements: { Title: 'h2', Body: 'div' },
116
+ styleProps: ['padding', 'fill'],
117
+ });
118
+
119
+ // app/Dashboard.tsx — product engineer uses the component
120
+ <Card padding={{ '': '4x', '@mobile': '2x' }}>
121
+ <Card.Title>Monthly Revenue</Card.Title>
122
+ <Card.Body>$1.2M — up 12% from last month</Card.Body>
123
+ </Card>;
124
+ ```
125
+
126
+ See [Configuration](configuration.md) for the full `configure()` API.
127
+
128
+ ---
129
+
130
+ ## Incremental adoption
131
+
132
+ You do not need to adopt everything at once. Tasty is designed to be introduced layer by layer.
133
+
134
+ A practical first slice is one component that already suffers from intersecting state and variant logic: a button, input, menu item, disclosure, or interactive card. Keep its public API unchanged, move one or two properties into Tasty state maps, and verify that the declared priority matches the behavior your team expects.
135
+
136
+ This proves the differentiator before you invest in a complete token vocabulary or migrate an entire component library.
137
+
138
+ ### Phase 1 -- Pilot one state-heavy component
139
+
140
+ Choose a component with a known hover/disabled, focus/error, or variant/theme interaction. Preserve its external props and visual behavior. The pilot should answer three questions:
141
+
142
+ 1. Is the state map easier to review than the existing selectors or conditional class logic?
143
+ 2. Does extending the component keep the intended state priority?
144
+ 3. Can your current tokens and component API move over without product-code churn?
145
+
146
+ If the answer is yes, establish the shared design-system vocabulary around the successful slice.
147
+
148
+ ### Phase 2 -- Tokens and units
149
+
150
+ Start by defining your design tokens and custom units. This is the lowest-risk step: it only configures the parser and does not require rewriting any components.
151
+
152
+ ```tsx
153
+ import { configure } from '@tenphi/tasty';
154
+
155
+ configure({
156
+ tokens: {
157
+ '#primary': 'oklch(55% 0.25 265)',
158
+ '#surface': '#white',
159
+ '#text': '#111',
160
+ '$card-padding': '4x',
161
+ $gap: '8px',
162
+ $radius: '6px',
163
+ '$border-width': '1px',
164
+ },
165
+ // Built-in units (x, r, cr, bw, ow) compile to fixed values by default.
166
+ // A DS often points them at the custom properties above, so the scale
167
+ // is controlled by CSS at runtime rather than fixed at build time:
168
+ units: {
169
+ x: 'var(--gap)', // 2x → calc(2 * var(--gap))
170
+ r: 'var(--radius)',
171
+ bw: 'var(--border-width)',
172
+ },
173
+ });
174
+ ```
175
+
176
+ Turn on the guardrails in the same step. Add [`@tenphi/eslint-plugin-tasty`](https://github.com/tenphi/eslint-plugin-tasty) with `tasty.configs.recommended` and a `tasty.config.ts` that lists the tokens, units, states, presets, and recipes as you define them, and register the same color and preset names for TypeScript autocomplete (`TastyNamedColors`, `TastyPresetNames`). Every component you migrate from here on is checked against the vocabulary. See [Getting Started — ESLint plugin](getting-started.md#eslint-plugin).
177
+
178
+ ### Phase 3 -- State aliases and recipes
179
+
180
+ Define the state vocabulary your components will share. This is where you start encoding your team's conventions.
181
+
182
+ ```tsx
183
+ configure({
184
+ states: {
185
+ '@mobile': '@media(w < 768px)',
186
+ '@tablet': '@media(768px <= w < 1024px)',
187
+ '@dark':
188
+ '@root(schema=dark) | (!@root(schema) & @media(prefers-color-scheme: dark))',
189
+ },
190
+ recipes: {
191
+ card: { padding: '4x', fill: '#surface', radius: '1r', border: true },
192
+ elevated: { shadow: '0 2x 4x #shadow' },
193
+ },
194
+ });
195
+ ```
196
+
197
+ ### Phase 4 -- Migrate a few primitives
198
+
199
+ Pick 2-3 widely used primitives (Box, Text, Button) and rewrite them with `tasty()`. Keep the public API identical so product code does not need to change.
200
+
201
+ ```tsx
202
+ const Box = tasty({
203
+ as: 'div',
204
+ styles: {
205
+ display: 'flex',
206
+ flow: 'column',
207
+ gap: '1x',
208
+ },
209
+ styleProps: ['gap', 'flow', 'padding', 'fill'],
210
+ });
211
+ ```
212
+
213
+ At this point you can validate the DSL, token workflow, and component authoring experience before expanding the rollout.
214
+
215
+ ### Phase 5 -- Expand state resolution
216
+
217
+ Move the components with the most painful intersecting states (buttons with hover + disabled + theme variants, inputs with focus + error + readonly) to Tasty's state map syntax. This is where mutually exclusive selectors start paying off.
218
+
219
+ ```tsx
220
+ const Button = tasty({
221
+ as: 'button',
222
+ styles: {
223
+ fill: {
224
+ '': '#primary',
225
+ ':hover': '#primary-hover',
226
+ ':active': '#primary-pressed',
227
+ // `disabled` is a data-attribute modifier → [data-disabled].
228
+ // Tasty auto-applies it from the native `disabled` attribute.
229
+ // `[disabled]` (attribute selector) also works here.
230
+ disabled: '#surface',
231
+ },
232
+ color: {
233
+ '': '#on-primary',
234
+ disabled: '#text.40',
235
+ },
236
+ cursor: {
237
+ '': 'pointer',
238
+ disabled: 'not-allowed',
239
+ },
240
+ transition: 'theme',
241
+ },
242
+ });
243
+ ```
244
+
245
+ ### Phase 6 -- Standardize style props and sub-elements
246
+
247
+ Define which style props each component category exposes. Layout components get flow/gap/padding. Interactive components get positioning. Compound components declare sub-elements.
248
+
249
+ ```tsx
250
+ const Card = tasty({
251
+ styles: {
252
+ recipe: 'card elevated',
253
+ Title: { preset: 'h3', color: '#primary' },
254
+ Content: { color: '#text', preset: 't2' },
255
+ },
256
+ elements: { Title: 'h2', Content: 'div' },
257
+ styleProps: ['padding', 'fill', 'radius'],
258
+ });
259
+ ```
260
+
261
+ ### Phase 7 -- Expand to full DS coverage
262
+
263
+ Migrate the remaining components, switch the [ESLint plugin](https://github.com/tenphi/eslint-plugin-tasty) to `tasty.configs.strict` to also catch unknown `$` tokens and state aliases, and choose between [server-only `tasty()`](ssr.md) and [`tastyStatic()` build-time extraction](tasty-static.md) when a page should ship no Tasty styling runtime.
264
+
265
+ ---
266
+
267
+ ## What changes for product engineers
268
+
269
+ When a DS is powered by Tasty, product engineers typically interact with **components, not Tasty itself**. Here is what changes from their perspective:
270
+
271
+ **They do not write CSS directly.** Styling decisions are embedded in the components the DS provides. Product code consumes components, tokens, and style props.
272
+
273
+ **Overrides use styled wrappers.** Instead of passing one-off `className` or `style` props, product engineers extend components:
274
+
275
+ ```tsx
276
+ import { tasty } from '@tenphi/tasty';
277
+ import { Button } from 'my-ds';
278
+
279
+ // Replace mode: providing '' (default) key replaces the parent's fill entirely
280
+ const DangerButton = tasty(Button, {
281
+ styles: {
282
+ fill: { '': '#danger', ':hover': '#danger-hover' },
283
+ },
284
+ });
285
+
286
+ // Extend mode: omitting '' key preserves parent states and adds/overrides
287
+ const LoadingButton = tasty(Button, {
288
+ styles: {
289
+ fill: {
290
+ loading: '#yellow', // new state appended
291
+ disabled: '#gray.20', // existing state overridden in place
292
+ },
293
+ },
294
+ });
295
+ ```
296
+
297
+ **Style props replace raw CSS.** Layout, spacing, and positioning are controlled through typed props on the components that expose them:
298
+
299
+ ```tsx
300
+ <Space flow="row" gap="2x" placeItems="center">
301
+ <Title>Dashboard</Title>
302
+ <Button placeSelf="end">Add Item</Button>
303
+ </Space>
304
+ ```
305
+
306
+ **Components are server components by default.** All `tasty()` components and style functions are hook-free, so they work as React Server Components without `'use client'`. In server-only contexts they ship no Tasty styling runtime. Astro without `client:*` directives ships no client JavaScript; server-only Next.js RSC follows the same Tasty architecture, while final output depends on the application deployment. Product engineers only add `'use client'` when their component needs actual React interactivity (state, effects, event handlers), never because of styling.
307
+
308
+ **No cascade/specificity concerns.** Tasty's mutually exclusive selectors mean extending a component cannot accidentally break another. Import order, class name collisions, and specificity arithmetic are non-issues.
309
+
310
+ ---
311
+
312
+ ## Migration and Interop Notes
313
+
314
+ - **From Tailwind**: keep utility-authored product surfaces as-is at first, and use Tasty to build or replace the design-system primitives underneath them instead of forcing an all-at-once markup rewrite.
315
+ - **From CSS-in-JS libraries**: start with shared primitives such as `Box`, `Text`, and `Button`, preserve the external component API, and move state logic into Tasty state maps so behavior changes without product-code churn.
316
+ - **From CSS Modules or plain CSS**: migrate token definitions and repeated patterns first, then wrap existing DOM structure with `tasty()` components gradually rather than converting every stylesheet at once.
317
+
318
+ ---
319
+
320
+ ## Learn more
321
+
322
+ - [README](../README.md) -- overview, quick start, and feature highlights
323
+ - [Getting Started](getting-started.md) -- installation, first component, tooling setup
324
+ - [Methodology](methodology.md) -- the recommended patterns for structuring Tasty components
325
+ - [Building a Design System](design-system.md) -- practical guide to building a DS layer with Tasty
326
+ - [Style DSL](dsl.md) -- state maps, tokens, units, extending semantics, keyframes, @property
327
+ - [React API](react-api.md) -- `tasty()` factory, component props, variants, sub-elements, style functions
328
+ - [Configuration](configuration.md) -- tokens, recipes, custom units, style handlers, and TypeScript extensions
329
+ - [Style Properties](styles.md) -- complete reference for all enhanced style properties
330
+ - [Comparison](comparison.md) -- positioning and trade-offs vs. other styling systems
331
+ - [Build-Time Extraction (`tastyStatic`)](tasty-static.md) -- static styling with the Babel plugin