@fluentic/style 0.1.0-beta.1 → 0.1.0-beta.11

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 (491) hide show
  1. package/CHANGELOG.md +156 -2
  2. package/README.md +181 -49
  3. package/atomic/atRule/utils.ts +3 -2
  4. package/atomic/className.ts +50 -12
  5. package/atomic/debug/className/className.ts +24 -8
  6. package/atomic/element.ts +5 -2
  7. package/atomic/rule.ts +11 -5
  8. package/atomic/scope.ts +19 -0
  9. package/atomic/theme.ts +44 -3
  10. package/atomic/token.ts +7 -4
  11. package/atomic/utils/cssIdent.ts +54 -0
  12. package/atomic/utils/cssVar.ts +19 -0
  13. package/atomic/utils/debug.ts +1 -1
  14. package/atomic/utils/format.ts +1 -1
  15. package/atomic/utils/hash.ts +14 -0
  16. package/atomic/utils/selector.ts +31 -1
  17. package/atomic/var.ts +3 -2
  18. package/builder/classname/class_name_builder.ts +491 -0
  19. package/builder/classname/fns.ts +77 -0
  20. package/builder/classname/index.ts +3 -0
  21. package/builder/classname/types.ts +41 -0
  22. package/builder/data/const.ts +8 -1
  23. package/builder/data/create.ts +52 -6
  24. package/builder/data/data.ts +33 -8
  25. package/builder/data/debug.ts +1 -0
  26. package/builder/data/index.ts +0 -1
  27. package/builder/data/is.ts +26 -3
  28. package/builder/data/merge/scope.ts +38 -38
  29. package/builder/data/merge/style.ts +115 -20
  30. package/builder/data/state.ts +17 -2
  31. package/builder/extract/index.ts +1 -0
  32. package/builder/extract/sheet.ts +30 -0
  33. package/builder/extract/token.ts +30 -14
  34. package/builder/extract/utils.ts +2 -0
  35. package/builder/extract/withTokens.ts +2 -1
  36. package/builder/selector_override.noop.ts +11 -0
  37. package/builder/selector_override.ts +31 -0
  38. package/builder/selector_override_core.ts +79 -0
  39. package/builder/style_builder.ts +144 -20
  40. package/builder/style_data.ts +25 -0
  41. package/builder/style_fns.ts +57 -57
  42. package/builder/token/data.ts +30 -0
  43. package/builder/token/index.ts +3 -0
  44. package/builder/token/name.ts +54 -0
  45. package/builder/token/symbols.ts +6 -0
  46. package/builder/types/alias.ts +44 -16
  47. package/builder/types/fns.ts +24 -16
  48. package/builder/types/types.ts +37 -7
  49. package/builder/utils.ts +1 -0
  50. package/compiler/compiler/compiler.ts +88 -14
  51. package/compiler/compiler/constants.ts +6 -0
  52. package/compiler/compiler/index.ts +1 -0
  53. package/compiler/compiler/types.ts +4 -1
  54. package/compiler/cssProp.ts +21 -0
  55. package/compiler/extract/extract.ts +42 -14
  56. package/compiler/extract/types.ts +2 -0
  57. package/compiler/index.ts +1 -0
  58. package/compiler/transform/cssProp/index.ts +1 -0
  59. package/compiler/transform/cssProp/plugin.ts +161 -0
  60. package/compiler/transform/debug/plugin.ts +93 -4
  61. package/compiler/transform/debug/transform.ts +2 -1
  62. package/compiler/transform/debug/utils/debug_data.ts +73 -0
  63. package/compiler/transform/evaluator/evaluator.ts +169 -32
  64. package/compiler/transform/evaluator/tracer.ts +48 -11
  65. package/compiler/transform/extract/chain/chain.ts +1370 -162
  66. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  67. package/compiler/transform/extract/chain/types.ts +3 -1
  68. package/compiler/transform/extract/plugin.ts +64 -6
  69. package/compiler/transform/extract/transform.ts +2 -1
  70. package/compiler/transform/extract/utils/replacement.ts +72 -2
  71. package/compiler/transform/extract/utils/state.ts +3 -0
  72. package/compiler/transform/extract/utils/theme.ts +6 -6
  73. package/compiler/transform/index.ts +1 -0
  74. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  75. package/compiler/transform/syntax/static_ids.ts +1 -1
  76. package/compiler/utils/constants.ts +12 -5
  77. package/compiler/utils/file_resolver.ts +2 -0
  78. package/compiler/utils/import_source.ts +19 -8
  79. package/compiler/utils/imports.ts +11 -1
  80. package/config/build.ts +9 -2
  81. package/config/config/check.ts +25 -0
  82. package/config/config/css.ts +18 -1
  83. package/config/config/debug.ts +24 -1
  84. package/config/config/dev.ts +17 -1
  85. package/config/configure.ts +19 -2
  86. package/config/types.ts +7 -0
  87. package/css/index.ts +2 -0
  88. package/css/sheet.ts +152 -0
  89. package/css/styleTarget.ts +251 -0
  90. package/dev/config.ts +2 -3
  91. package/dev/utils.ts +3 -3
  92. package/dialect/extracted/index.ts +5 -0
  93. package/dialect/index.ts +1 -0
  94. package/dialect/namedTokens.ts +153 -0
  95. package/dist/adapter/preact.js +2 -0
  96. package/dist/adapter/react.js +2 -0
  97. package/dist/adapter/solid.js +2 -0
  98. package/dist/className-yhJCGT0F.js +304 -0
  99. package/dist/className-yhJCGT0F.js.map +1 -0
  100. package/dist/combine-Bww7VnSr.js +1254 -0
  101. package/dist/combine-Bww7VnSr.js.map +1 -0
  102. package/dist/compiler/index.mjs +2 -2
  103. package/dist/{compiler-DENc3a2R.mjs → compiler-C3CEGGtI.mjs} +2335 -638
  104. package/dist/compiler-C3CEGGtI.mjs.map +1 -0
  105. package/dist/config/index.js +2 -2
  106. package/dist/config-BAEzRmSJ.js +6 -0
  107. package/dist/{config-Di2VYYKV.js.map → config-BAEzRmSJ.js.map} +1 -1
  108. package/dist/config-BKP5LOkt.js +35 -0
  109. package/dist/config-BKP5LOkt.js.map +1 -0
  110. package/dist/config-C5VWvTav.js +34 -0
  111. package/dist/config-C5VWvTav.js.map +1 -0
  112. package/dist/config-CB4lm2tM.js +1 -0
  113. package/dist/config-CDjbHwb-.js +6 -0
  114. package/dist/config-CDjbHwb-.js.map +1 -0
  115. package/dist/config-DNEnHEf3.js +36 -0
  116. package/dist/config-DNEnHEf3.js.map +1 -0
  117. package/dist/createTransformElement-D8fXZ3wA.js +34 -0
  118. package/dist/createTransformElement-D8fXZ3wA.js.map +1 -0
  119. package/dist/css-BDn0epJ8.js +1339 -0
  120. package/dist/css-BDn0epJ8.js.map +1 -0
  121. package/dist/css-CFxNrYt3.js +4040 -0
  122. package/dist/css-CFxNrYt3.js.map +1 -0
  123. package/dist/css-DEYgrj76.js +524 -0
  124. package/dist/css-DEYgrj76.js.map +1 -0
  125. package/dist/{runtime-CYqNCiaM.js → css-DWBWsyxZ.js} +16 -19
  126. package/dist/css-DWBWsyxZ.js.map +1 -0
  127. package/dist/css.js +2 -2
  128. package/dist/{css_extra-oIi3UEPK.js → css_extra-nTq_Gw0E.js} +2 -2
  129. package/dist/{css_extra-DlOnsnR1.js.map → css_extra-nTq_Gw0E.js.map} +1 -1
  130. package/dist/data-CDrS1Bq4.js +785 -0
  131. package/dist/data-CDrS1Bq4.js.map +1 -0
  132. package/dist/debug-BkVbf0Cz.js +52 -0
  133. package/dist/debug-BkVbf0Cz.js.map +1 -0
  134. package/dist/{debug-n2aZQBSa.js → debug-YuhEIQVO.js} +80 -4
  135. package/dist/debug-YuhEIQVO.js.map +1 -0
  136. package/dist/dev/rsc.js +10 -9
  137. package/dist/dev/rsc.js.map +1 -1
  138. package/dist/{dev-CcphAa3R.js → dev-0imWmSVb.js} +10 -10
  139. package/dist/dev-0imWmSVb.js.map +1 -0
  140. package/dist/dev.js +1 -1
  141. package/dist/dialect/extracted/index.js +2 -0
  142. package/dist/dialect/index.js +2 -0
  143. package/dist/{elementMarker-Bu7gDAkE.js → elementMarker-kvpMjB49.js} +164 -30
  144. package/dist/elementMarker-kvpMjB49.js.map +1 -0
  145. package/dist/entry/dev/adapter/preact.js +12 -0
  146. package/dist/entry/dev/adapter/preact.js.map +1 -0
  147. package/dist/entry/dev/adapter/react.js +12 -0
  148. package/dist/entry/dev/adapter/react.js.map +1 -0
  149. package/dist/entry/dev/adapter/solid.js +12 -0
  150. package/dist/entry/dev/adapter/solid.js.map +1 -0
  151. package/dist/entry/dev/css.js +3 -3
  152. package/dist/entry/dev/jsx-dev-runtime.js +2 -1
  153. package/dist/entry/dev/jsx-runtime.js +2 -1
  154. package/dist/entry/dev.js +13 -9
  155. package/dist/entry/prod/adapter/preact.js +12 -0
  156. package/dist/entry/prod/adapter/preact.js.map +1 -0
  157. package/dist/entry/prod/adapter/react.js +12 -0
  158. package/dist/entry/prod/adapter/react.js.map +1 -0
  159. package/dist/entry/prod/adapter/solid.js +12 -0
  160. package/dist/entry/prod/adapter/solid.js.map +1 -0
  161. package/dist/entry/prod/css.js +3 -3
  162. package/dist/entry/prod/extract.js +242 -3
  163. package/dist/entry/prod/extract.js.map +1 -0
  164. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  165. package/dist/entry/prod/jsx-runtime.js +2 -2
  166. package/dist/entry/prod/runtime.js +3 -4
  167. package/dist/entry/prod.js +84 -1201
  168. package/dist/entry/prod.js.map +1 -1
  169. package/dist/entry/rsc-dev/adapter/preact.js +13 -0
  170. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  171. package/dist/entry/rsc-dev/adapter/react.js +13 -0
  172. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  173. package/dist/entry/rsc-dev/adapter/solid.js +13 -0
  174. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  175. package/dist/entry/rsc-dev/css.js +3 -3
  176. package/dist/entry/rsc-dev/dev.js +11 -13
  177. package/dist/entry/rsc-dev/dev.js.map +1 -1
  178. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  179. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  180. package/dist/entry/rsc-dev.js +582 -664
  181. package/dist/entry/rsc-dev.js.map +1 -1
  182. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  183. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  184. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  185. package/dist/entry/rsc-prod/css.js +9 -3
  186. package/dist/entry/rsc-prod/css.js.map +1 -0
  187. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  188. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  189. package/dist/entry/rsc-prod/runtime.js +3 -4
  190. package/dist/entry/rsc-prod.js +242 -10
  191. package/dist/entry/rsc-prod.js.map +1 -0
  192. package/dist/{styleStore-Dea_WVbr.js → env-Cz8frh6e.js} +1335 -372
  193. package/dist/env-Cz8frh6e.js.map +1 -0
  194. package/dist/getClassName-9CsXbNls.js +545 -0
  195. package/dist/getClassName-9CsXbNls.js.map +1 -0
  196. package/dist/{utils-D7FAOyg6.js → getClassName-DGm-VNDo.js} +28 -65
  197. package/dist/getClassName-DGm-VNDo.js.map +1 -0
  198. package/dist/getClassName-Dtc4yyYI.js +47 -0
  199. package/dist/getClassName-Dtc4yyYI.js.map +1 -0
  200. package/dist/{getClassName-BlvXHYuf.js → getClassName-DtkplEIt.js} +56 -14
  201. package/dist/getClassName-DtkplEIt.js.map +1 -0
  202. package/dist/global-CAc9OjKx.js +14 -0
  203. package/dist/global-CAc9OjKx.js.map +1 -0
  204. package/dist/{format-3nKBE_5t.js → hash-Cr-LCWDt.js} +51 -29
  205. package/dist/hash-Cr-LCWDt.js.map +1 -0
  206. package/dist/index.js +10 -8
  207. package/dist/jsx/jsx-dev-runtime.js +2 -2
  208. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  209. package/dist/jsx/jsx-runtime.js +2 -2
  210. package/dist/jsx/jsx-runtime.server.js +1 -1
  211. package/dist/jsx-CVxpkS04.js +39 -0
  212. package/dist/jsx-CVxpkS04.js.map +1 -0
  213. package/dist/{jsx_dev_runtime-B6xs4by8.js → jsx_dev_runtime-D068tAsT.js} +2 -3
  214. package/dist/{jsx_dev_runtime-B6xs4by8.js.map → jsx_dev_runtime-D068tAsT.js.map} +1 -1
  215. package/dist/{jsx_runtime-iHLDwpcW.js → jsx_runtime-6Qa1lmz2.js} +2 -2
  216. package/dist/{jsx_runtime-iHLDwpcW.js.map → jsx_runtime-6Qa1lmz2.js.map} +1 -1
  217. package/dist/{jsx_runtime-04xfnsi7.js → jsx_runtime-DT1Tr9cH.js} +2 -3
  218. package/dist/{jsx_runtime-04xfnsi7.js.map → jsx_runtime-DT1Tr9cH.js.map} +1 -1
  219. package/dist/{loader-B5Kw0DD-.mjs → loader-_-VjzlrX.mjs} +13 -14
  220. package/dist/loader-_-VjzlrX.mjs.map +1 -0
  221. package/dist/{misc-DCdYYyhK.mjs → misc-B76PUnWe.mjs} +11 -6
  222. package/dist/misc-B76PUnWe.mjs.map +1 -0
  223. package/dist/namedTokens-5AayGokX.js +85 -0
  224. package/dist/namedTokens-5AayGokX.js.map +1 -0
  225. package/dist/plugin/farm/index.mjs +4 -3
  226. package/dist/plugin/farm/index.mjs.map +1 -1
  227. package/dist/plugin/nextjs/index.mjs +151 -31
  228. package/dist/plugin/nextjs/index.mjs.map +1 -1
  229. package/dist/plugin/nextjs/loader.mjs +4 -4
  230. package/dist/plugin/parcel/index.cjs +2 -0
  231. package/dist/plugin/parcel/index.mjs +3 -1
  232. package/dist/plugin/parcel/optimizer.cjs +3 -2
  233. package/dist/plugin/parcel/optimizer.cjs.map +1 -1
  234. package/dist/plugin/parcel/optimizer.mjs +3 -2
  235. package/dist/plugin/parcel/optimizer.mjs.map +1 -1
  236. package/dist/plugin/parcel/resolver.cjs +1 -1
  237. package/dist/plugin/parcel/resolver.mjs +2 -2
  238. package/dist/plugin/parcel/runtime.cjs +1 -1
  239. package/dist/plugin/parcel/runtime.mjs +1 -1
  240. package/dist/plugin/parcel/transformer.cjs +1 -1
  241. package/dist/plugin/parcel/transformer.mjs +2 -2
  242. package/dist/plugin/rspack/index.mjs +3 -2
  243. package/dist/plugin/rspack/index.mjs.map +1 -1
  244. package/dist/plugin/vite/index.mjs +13 -10
  245. package/dist/plugin/vite/index.mjs.map +1 -1
  246. package/dist/plugin/webpack/index.mjs +3 -2
  247. package/dist/plugin/webpack/loader.mjs +2 -2
  248. package/dist/presets/tailwind/index.js +995 -0
  249. package/dist/presets/tailwind/index.js.map +1 -0
  250. package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
  251. package/dist/presets-DSanixJV.js.map +1 -0
  252. package/dist/{registry-yHLRxyoo.mjs → registry-w8ET5R7v.mjs} +2 -2
  253. package/dist/{registry-yHLRxyoo.mjs.map → registry-w8ET5R7v.mjs.map} +1 -1
  254. package/dist/resolveClassNameRuntime-CJjlUP93.js +63 -0
  255. package/dist/resolveClassNameRuntime-CJjlUP93.js.map +1 -0
  256. package/dist/{rules-9HSO1pxL.js → rules-DaMaMHgb.js} +618 -138
  257. package/dist/rules-DaMaMHgb.js.map +1 -0
  258. package/dist/scope-CZdGAnl_.js +601 -0
  259. package/dist/scope-CZdGAnl_.js.map +1 -0
  260. package/dist/selector/index.js +1 -2
  261. package/dist/server.js +17 -11
  262. package/dist/server.js.map +1 -1
  263. package/dist/{shared-CxbHR89f.mjs → shared-C_cYxNzz.mjs} +4 -4
  264. package/dist/{shared-CxbHR89f.mjs.map → shared-C_cYxNzz.mjs.map} +1 -1
  265. package/dist/{shared-CBArHB9-.cjs → shared-PK52rW6T.cjs} +2338 -635
  266. package/dist/shared-PK52rW6T.cjs.map +1 -0
  267. package/dist/sheet-CxkO1Hwt.js +7 -0
  268. package/dist/sheet-CxkO1Hwt.js.map +1 -0
  269. package/dist/{sidecar-BFakLl0X.mjs → sidecar-BhvmXYsD.mjs} +3 -3
  270. package/dist/{sidecar-BFakLl0X.mjs.map → sidecar-BhvmXYsD.mjs.map} +1 -1
  271. package/dist/style-CAhAnRni.js +1129 -0
  272. package/dist/style-CAhAnRni.js.map +1 -0
  273. package/dist/{styleStore-DyNXBcUK.js → styleStore-BzLZwpwy.js} +8 -7
  274. package/dist/styleStore-BzLZwpwy.js.map +1 -0
  275. package/dist/styleStore-DaIJ4OPV.js +58 -0
  276. package/dist/styleStore-DaIJ4OPV.js.map +1 -0
  277. package/dist/token-D33mKTka.js +138 -0
  278. package/dist/token-D33mKTka.js.map +1 -0
  279. package/dist/{trace-Bu_qOqRy.js → trace-B3dpTRJp.js} +3 -3
  280. package/dist/{trace-Bu_qOqRy.js.map → trace-B3dpTRJp.js.map} +1 -1
  281. package/dist/{trace-CU0rvNYr.js → trace-c2WmBbmX.js} +2 -2
  282. package/dist/{trace-CU0rvNYr.js.map → trace-c2WmBbmX.js.map} +1 -1
  283. package/dist/transform-DSpimwwC.js +23 -0
  284. package/dist/transform-DSpimwwC.js.map +1 -0
  285. package/dist/{utils-Bdbqn0f8.mjs → utils-DND33M6y.mjs} +3 -3
  286. package/dist/{utils-Bdbqn0f8.mjs.map → utils-DND33M6y.mjs.map} +1 -1
  287. package/dist/utils-DZK0mfmY.js +42 -0
  288. package/dist/utils-DZK0mfmY.js.map +1 -0
  289. package/dist/utils-D_XgtMtn.js +72 -0
  290. package/dist/utils-D_XgtMtn.js.map +1 -0
  291. package/dist/utils-DxCpyV2E.js +62 -0
  292. package/dist/utils-DxCpyV2E.js.map +1 -0
  293. package/dist/{utils-BbehLOby.js → utils-H1VInWpd.js} +407 -234
  294. package/dist/utils-H1VInWpd.js.map +1 -0
  295. package/dist/utils-NdisireF.mjs +182 -0
  296. package/dist/utils-NdisireF.mjs.map +1 -0
  297. package/dist/utils.js +4 -4
  298. package/dist/utils.js.map +1 -1
  299. package/dist/value-CK0-Xbov.js +160 -0
  300. package/dist/value-CK0-Xbov.js.map +1 -0
  301. package/dist/{webpack-Dh6lox2l.mjs → webpack-D7QO0bKN.mjs} +5 -5
  302. package/dist/webpack-D7QO0bKN.mjs.map +1 -0
  303. package/entry/dev/adapter/preact.ts +8 -0
  304. package/entry/dev/adapter/react.ts +8 -0
  305. package/entry/dev/adapter/solid.ts +8 -0
  306. package/entry/dev/config.ts +1 -1
  307. package/entry/dev/index.ts +1 -0
  308. package/entry/dev/jsx_dev_runtime.ts +1 -0
  309. package/entry/dev/jsx_runtime.ts +1 -0
  310. package/entry/dev/sheet.ts +4 -0
  311. package/entry/prod/adapter/preact.ts +8 -0
  312. package/entry/prod/adapter/react.ts +8 -0
  313. package/entry/prod/adapter/solid.ts +8 -0
  314. package/entry/prod/config_debug.ts +2 -0
  315. package/entry/prod/index.ts +1 -1
  316. package/entry/prod/runtime.ts +4 -2
  317. package/entry/rsc_dev/adapter/preact.ts +9 -0
  318. package/entry/rsc_dev/adapter/react.ts +9 -0
  319. package/entry/rsc_dev/adapter/solid.ts +9 -0
  320. package/entry/rsc_dev/config.ts +1 -1
  321. package/entry/rsc_dev/server.ts +1 -1
  322. package/entry/rsc_prod/adapter/preact.ts +1 -0
  323. package/entry/rsc_prod/adapter/react.ts +1 -0
  324. package/entry/rsc_prod/adapter/solid.ts +1 -0
  325. package/entry/rsc_prod/config_debug.ts +6 -0
  326. package/entry/rsc_prod/index.ts +1 -1
  327. package/entry/rsc_prod/runtime.ts +1 -1
  328. package/entry/rsc_prod/server.ts +1 -1
  329. package/entry/shared/config_debug.ts +9 -0
  330. package/entry/shared/config_dev.ts +14 -0
  331. package/entry/shared/dev.ts +11 -2
  332. package/entry/shared/utils.ts +28 -0
  333. package/jsx/types/index.ts +1 -0
  334. package/jsx/types/preact.ts +14 -0
  335. package/jsx/{types.ts → types/react.ts} +2 -2
  336. package/jsx/types/solid.ts +32 -0
  337. package/package.json +110 -8
  338. package/plugin/bundler/farm/plugin.ts +2 -0
  339. package/plugin/bundler/parcel/optimizer.ts +1 -0
  340. package/plugin/bundler/parcel/plugin.ts +2 -0
  341. package/plugin/bundler/rspack/plugin.ts +1 -0
  342. package/plugin/bundler/vite/plugin.ts +5 -9
  343. package/plugin/bundler/vite/state.ts +11 -6
  344. package/plugin/bundler/webpack/plugin.ts +2 -1
  345. package/plugin/bundler/webpack/shared/loader.ts +9 -7
  346. package/plugin/nextjs/plugin.ts +249 -35
  347. package/plugin/nextjs/types.ts +1 -2
  348. package/plugin/nextjs/utils.ts +121 -0
  349. package/plugin/utils/compiler.ts +2 -0
  350. package/plugin/utils/runtimeEntry.ts +15 -2
  351. package/presets/tailwind/classname/index.ts +2 -0
  352. package/presets/tailwind/classname/transform.ts +239 -0
  353. package/presets/tailwind/classname/types.ts +124 -0
  354. package/presets/tailwind/index.ts +5 -0
  355. package/presets/tailwind/selectors.ts +27 -0
  356. package/presets/tailwind/style/index.ts +2 -0
  357. package/presets/tailwind/style/transform.ts +436 -0
  358. package/presets/tailwind/style/types.ts +346 -0
  359. package/presets/tailwind/theme.ts +479 -0
  360. package/presets/tailwind/types.ts +147 -0
  361. package/runtime/adapter/utils.ts +120 -0
  362. package/runtime/core/cache/combine.ts +76 -28
  363. package/runtime/core/cache/combineRuntime.ts +4 -0
  364. package/runtime/core/cache/index.ts +2 -1
  365. package/runtime/core/cache/item.ts +32 -13
  366. package/runtime/core/cache/itemWithResolver.ts +44 -0
  367. package/runtime/core/cache/pool.ts +16 -31
  368. package/runtime/core/cache/prop.ts +10 -8
  369. package/runtime/core/cache/result.ts +2 -2
  370. package/runtime/core/cache/stateItem.ts +16 -1
  371. package/runtime/core/cache/token.ts +20 -0
  372. package/runtime/core/cache/tokenValues.ts +19 -11
  373. package/runtime/core/combinedStyle.ts +4 -4
  374. package/runtime/extract/combineStyle.ts +211 -0
  375. package/runtime/extract/getClassName.ts +55 -23
  376. package/runtime/extract/index.ts +4 -2
  377. package/runtime/extract/token.ts +41 -0
  378. package/runtime/extract/tokenResolver.ts +17 -0
  379. package/runtime/index.ts +8 -1
  380. package/runtime/rsc/getClassName.ts +4 -0
  381. package/runtime/rsc/observer.ts +4 -0
  382. package/runtime/rsc/styleStore.ts +18 -7
  383. package/runtime/sheet/rule.ts +16 -12
  384. package/runtime/sheet/rules.ts +8 -3
  385. package/runtime/style/scope.ts +0 -24
  386. package/runtime/style/style.ts +181 -6
  387. package/runtime/types.ts +6 -4
  388. package/sheet/dev/dev_layer.ts +18 -7
  389. package/sheet/dev/dev_sort.ts +45 -11
  390. package/sheet/prod.ts +18 -7
  391. package/sheet/types.ts +2 -0
  392. package/sheet/utils/layer.ts +33 -0
  393. package/style/classname.ts +47 -0
  394. package/style/important.ts +19 -0
  395. package/style/index.ts +3 -0
  396. package/style/style.ts +47 -16
  397. package/style/theme.ts +4 -3
  398. package/style/token.ts +26 -21
  399. package/style/tokens.ts +18 -12
  400. package/style/transform.ts +41 -2
  401. package/style/types.ts +6 -4
  402. package/style/utils/expose.ts +4 -3
  403. package/style/value.ts +26 -11
  404. package/style/valueRef.ts +1 -1
  405. package/style/weight.ts +21 -0
  406. package/utils/global.ts +1 -3
  407. package/utils/hash.ts +4 -0
  408. package/utils/symbol.ts +3 -0
  409. package/atomic/layer/README.md +0 -116
  410. package/atomic/utils/css.ts +0 -49
  411. package/dist/assert-BGdigdr5.js.map +0 -1
  412. package/dist/className-C1Ht5Wvv.js +0 -144
  413. package/dist/className-C1Ht5Wvv.js.map +0 -1
  414. package/dist/className-DC2Cq8p3.js +0 -251
  415. package/dist/className-DC2Cq8p3.js.map +0 -1
  416. package/dist/compiler-DENc3a2R.mjs.map +0 -1
  417. package/dist/config-BryWDfQX.js +0 -25
  418. package/dist/config-BryWDfQX.js.map +0 -1
  419. package/dist/config-DKHXWhe1.js +0 -1
  420. package/dist/config-Di2VYYKV.js +0 -6
  421. package/dist/config-DloHOG6I.js +0 -13
  422. package/dist/config-DloHOG6I.js.map +0 -1
  423. package/dist/css-BowBszUt.js +0 -243
  424. package/dist/css-BowBszUt.js.map +0 -1
  425. package/dist/css-ByOrugEX.js +0 -805
  426. package/dist/css-ByOrugEX.js.map +0 -1
  427. package/dist/css-DcazYor9.js +0 -235
  428. package/dist/css-DcazYor9.js.map +0 -1
  429. package/dist/css_extra-DlOnsnR1.js +0 -8
  430. package/dist/css_extra-oIi3UEPK.js.map +0 -1
  431. package/dist/data-BsqOa5br.js +0 -473
  432. package/dist/data-BsqOa5br.js.map +0 -1
  433. package/dist/debug-BAw63qX6.js +0 -15
  434. package/dist/debug-BAw63qX6.js.map +0 -1
  435. package/dist/debug-DGki_v7g.js +0 -15
  436. package/dist/debug-DGki_v7g.js.map +0 -1
  437. package/dist/debug-n2aZQBSa.js.map +0 -1
  438. package/dist/dev-CcphAa3R.js.map +0 -1
  439. package/dist/dev-DfBbuLeE.js +0 -71
  440. package/dist/dev-DfBbuLeE.js.map +0 -1
  441. package/dist/elementMarker-Bu7gDAkE.js.map +0 -1
  442. package/dist/extract-CzWJeQi8.js +0 -121
  443. package/dist/extract-CzWJeQi8.js.map +0 -1
  444. package/dist/extract-DEwSDJ9Z.js +0 -2
  445. package/dist/format-3nKBE_5t.js.map +0 -1
  446. package/dist/getClassName-BlvXHYuf.js.map +0 -1
  447. package/dist/global-CvfmFLsK.js +0 -11
  448. package/dist/global-CvfmFLsK.js.map +0 -1
  449. package/dist/jsx-CwTeyUxr.js +0 -39
  450. package/dist/jsx-CwTeyUxr.js.map +0 -1
  451. package/dist/jsx-D2BksHSv.js +0 -38
  452. package/dist/jsx-D2BksHSv.js.map +0 -1
  453. package/dist/layer-D1SaH07m.js +0 -94
  454. package/dist/layer-D1SaH07m.js.map +0 -1
  455. package/dist/loader-B5Kw0DD-.mjs.map +0 -1
  456. package/dist/misc-DCdYYyhK.mjs.map +0 -1
  457. package/dist/presets-BhXa232U.js +0 -108
  458. package/dist/presets-BhXa232U.js.map +0 -1
  459. package/dist/property-CnLFt5kx.js +0 -406
  460. package/dist/property-CnLFt5kx.js.map +0 -1
  461. package/dist/rules-9HSO1pxL.js.map +0 -1
  462. package/dist/runtime-CYqNCiaM.js.map +0 -1
  463. package/dist/shared-CBArHB9-.cjs.map +0 -1
  464. package/dist/style-B-6jHipw.js +0 -5
  465. package/dist/style-B1UUqjj5.js +0 -743
  466. package/dist/style-B1UUqjj5.js.map +0 -1
  467. package/dist/style-DgHbdbdF.js +0 -752
  468. package/dist/style-DgHbdbdF.js.map +0 -1
  469. package/dist/style-v2bf70TZ.js +0 -1269
  470. package/dist/style-v2bf70TZ.js.map +0 -1
  471. package/dist/styleStore-Dea_WVbr.js.map +0 -1
  472. package/dist/styleStore-DyNXBcUK.js.map +0 -1
  473. package/dist/token-CKXUECuU.js +0 -76
  474. package/dist/token-CKXUECuU.js.map +0 -1
  475. package/dist/token-u_tM-mtg.js +0 -204
  476. package/dist/token-u_tM-mtg.js.map +0 -1
  477. package/dist/utils-BbehLOby.js.map +0 -1
  478. package/dist/utils-CEaq_c-A.mjs +0 -97
  479. package/dist/utils-CEaq_c-A.mjs.map +0 -1
  480. package/dist/utils-CWNHx4EC.js +0 -170
  481. package/dist/utils-CWNHx4EC.js.map +0 -1
  482. package/dist/utils-D7FAOyg6.js.map +0 -1
  483. package/dist/value-BR4e2MKt.js +0 -910
  484. package/dist/value-BR4e2MKt.js.map +0 -1
  485. package/dist/value-E8rEv2Oe.js +0 -136
  486. package/dist/value-E8rEv2Oe.js.map +0 -1
  487. package/dist/valueRef-lshFk1Cs.js +0 -16
  488. package/dist/valueRef-lshFk1Cs.js.map +0 -1
  489. package/dist/webpack-Dh6lox2l.mjs.map +0 -1
  490. package/dist/withTokens-LRidu3Vc.js +0 -95
  491. package/dist/withTokens-LRidu3Vc.js.map +0 -1
package/sheet/prod.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { getLayerBlockCss, getLayerOrderCss } from '../atomic/layer';
2
- import { CSS_CONFIG, CSS_CONFIG_DEFAULT } from '../config/config/css';
2
+ import { CSS_CONFIG, CSS_CONFIG_DEFAULT, isStyleLayerEnabled } from '../config/config/css';
3
3
  import type { SheetOptions, StyleSheet } from './types';
4
4
  import {
5
5
  createNoopSheet,
6
6
  createSheetLayerState,
7
7
  createStyleTag,
8
- getSheetRulePriority,
8
+ getSheetLayerName,
9
+ getSheetLayerNames,
10
+ getSheetRuleLayerPriority,
9
11
  insertStyleTagAfter,
10
12
  normalizeRule,
11
13
  resolveDocument,
@@ -24,12 +26,13 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
24
26
  let layerText = '';
25
27
  let layerTag: HTMLStyleElement | null = null;
26
28
  let ruleTag: HTMLStyleElement | null = null;
29
+ let hasSheetLayer = false;
27
30
 
28
31
  return {
29
32
  updateLayers(layers) {
30
33
  activeLayers = layers;
31
34
 
32
- const next = getLayerOrderCss(layers, layerState.getNames());
35
+ const next = getLayerOrderCss(layers, getSheetLayerNames(layerState, hasSheetLayer));
33
36
  if (next === layerText) return;
34
37
 
35
38
  layerText = next;
@@ -43,12 +46,20 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
43
46
 
44
47
  if (ruleKey && inserted.has(ruleKey)) return;
45
48
 
46
- const priority = typeof rule === 'string' ? null : rule.priority;
47
- const layerName = layerState.getName(getSheetRulePriority(priority));
49
+ const priority = typeof rule === 'string'
50
+ ? getSheetRuleLayerPriority(null, false)
51
+ : getSheetRuleLayerPriority(rule.priority, rule.important);
52
+ const ruleLayer = typeof rule === 'string' ? 'style' : rule.layer ?? 'style';
53
+ if (ruleLayer === 'sheet') hasSheetLayer = true;
54
+ const layerName = ruleLayer === 'sheet'
55
+ ? getSheetLayerName()
56
+ : ruleLayer === false || !isStyleLayerEnabled()
57
+ ? null
58
+ : layerState.getName(priority);
48
59
 
49
60
  const nextLayerText = getLayerOrderCss(
50
61
  activeLayers,
51
- layerState.getNames(),
62
+ getSheetLayerNames(layerState, hasSheetLayer),
52
63
  );
53
64
 
54
65
  if (nextLayerText !== layerText) {
@@ -57,7 +68,7 @@ export function createProdSheet(options: SheetOptions = {}): StyleSheet {
57
68
  layerTag.textContent = nextLayerText;
58
69
  }
59
70
 
60
- const css = getLayerBlockCss(layerName, rawCss);
71
+ const css = layerName ? getLayerBlockCss(layerName, rawCss) : rawCss;
61
72
  const key = typeof rule === 'string' ? css : ruleKey;
62
73
 
63
74
  if (key && inserted.has(key)) return;
package/sheet/types.ts CHANGED
@@ -8,6 +8,8 @@ export type SheetRule = {
8
8
  css: string;
9
9
  key?: string | null;
10
10
  priority?: LayerPriority | null;
11
+ important?: boolean;
12
+ layer?: 'style' | 'sheet' | false;
11
13
  callsite?: SheetCallsite | null;
12
14
  debug?: DebugData | null;
13
15
  debugField?: string | null;
@@ -9,6 +9,39 @@ export function getSheetRulePriority(priority: LayerPriority | null | undefined)
9
9
  return priority ?? LayerDefaultPriority;
10
10
  }
11
11
 
12
+ export function getSheetRuleLayerPriority(
13
+ priority: LayerPriority | null | undefined,
14
+ important: boolean | null | undefined,
15
+ ): LayerPriority {
16
+ const resolved = getSheetRulePriority(priority);
17
+
18
+ // Cascade layer order is reversed for important declarations. Mirror the
19
+ // atomic priority so a higher Fluentic priority still wins in that cascade.
20
+ return important
21
+ ? [
22
+ -resolved[0],
23
+ -resolved[1],
24
+ -resolved[2],
25
+ -resolved[3],
26
+ -resolved[4],
27
+ -resolved[5],
28
+ -resolved[6],
29
+ ]
30
+ : resolved;
31
+ }
32
+
12
33
  export function getStyleLayerName() {
13
34
  return CSS_CONFIG.layerNamespace || LayerDefaultNamespace;
14
35
  }
36
+
37
+ export function getSheetLayerName() {
38
+ return getStyleLayerName() + '.sheet';
39
+ }
40
+
41
+ export function getSheetLayerNames(
42
+ layerState: ReturnType<typeof createSheetLayerState>,
43
+ hasSheetLayer: boolean,
44
+ ) {
45
+ const names = layerState.getNames();
46
+ return hasSheetLayer ? names.concat(getSheetLayerName()) : names;
47
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ type ClassNameFn,
3
+ createClassNameBuilder,
4
+ type ImportantClassName,
5
+ type WeightedClassName,
6
+ } from '../builder/classname';
7
+ import type { SelectorsRecord } from '../builder/types';
8
+ import { PrioritySelectors } from '../selector/presets';
9
+ import type { Type } from '../utils/type';
10
+ import { assignStyleFnMeta } from './style';
11
+ import type { ClassNameTransform } from './transform';
12
+
13
+ export type { ClassNameBuilder, ClassNameFn, ClassNameItem, WeightedClassName } from '../builder/classname';
14
+ export type { ClassNameTransform } from './transform';
15
+
16
+ type InferClassName<Transform> = Transform extends ClassNameTransform<infer ClassName> ? ClassName : never;
17
+
18
+ export function createClassNameFn<
19
+ const Selectors extends SelectorsRecord = typeof PrioritySelectors,
20
+ const Transform extends ClassNameTransform<any> = ClassNameTransform<string>,
21
+ ClassName extends string = InferClassName<Transform>,
22
+ >(args: {
23
+ className?: Type<ClassName>;
24
+ selectors: Selectors;
25
+ transform: Transform;
26
+ }) {
27
+ const { selectors, transform } = args;
28
+
29
+ const fnClassName = createClassNameBuilder<ClassName, Selectors>(selectors, transform);
30
+ const className = fnClassName as ClassNameFn<ClassName, Selectors>;
31
+
32
+ className.weight = (className, weight): WeightedClassName<ClassName> => {
33
+ return { className, weight };
34
+ };
35
+
36
+ className.important = (className): ImportantClassName<ClassName> => {
37
+ return { className, important: true };
38
+ };
39
+
40
+ assignStyleFnMeta(className, {
41
+ mode: 'ClassName',
42
+ selectors,
43
+ transform,
44
+ });
45
+
46
+ return { className };
47
+ }
@@ -0,0 +1,19 @@
1
+ import { symbol } from '../utils/symbol';
2
+
3
+ const STYLE_IMPORTANT: unique symbol = symbol('style.important');
4
+
5
+ export type StyleImportantValue<T = unknown> = {
6
+ readonly [STYLE_IMPORTANT]: true;
7
+ readonly value: T;
8
+ };
9
+
10
+ export function importantValue<T>(value: T): StyleImportantValue<T> {
11
+ return {
12
+ [STYLE_IMPORTANT]: true,
13
+ value,
14
+ };
15
+ }
16
+
17
+ export function isStyleImportantValue(value: unknown): value is StyleImportantValue {
18
+ return !!value && typeof value === 'object' && (value as StyleImportantValue)[STYLE_IMPORTANT] === true;
19
+ }
package/style/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export * from './classname';
2
+ export * from './important';
1
3
  export * from './keyframes';
2
4
  export * from './style';
3
5
  export * from './theme';
@@ -7,3 +9,4 @@ export * from './transform';
7
9
  export * from './types';
8
10
  export * from './value';
9
11
  export * from './valueRef';
12
+ export * from './weight';
package/style/style.ts CHANGED
@@ -1,23 +1,39 @@
1
- import { createScopeBuilder, createSlotBuilder, createStyleBuilder, type SelectorsRecord } from '../builder';
1
+ import {
2
+ createScopeBuilder,
3
+ createSelectorBuilder,
4
+ createSlotBuilder,
5
+ createStyleBuilder,
6
+ type SelectorsRecord,
7
+ } from '../builder';
8
+ import type { ClassNameFn } from '../builder/classname';
2
9
  import { isStyleData } from '../builder/data';
3
10
  import { mergeStyleData } from '../builder/style_data';
4
11
  import { createDefaultFnResult } from '../builder/style_fns';
5
12
  import type { typeAliases } from '../builder/types/alias';
6
13
  import type { StableIdInput } from '../css/utils';
7
14
  import { PrioritySelectors } from '../selector/presets';
8
- import { symbol } from '../utils/global';
15
+ import { symbol } from '../utils/symbol';
9
16
  import { type } from '../utils/type';
10
17
  import type { Type } from '../utils/type';
18
+ import { importantValue } from './important';
11
19
  import { createStyleKeyframes } from './keyframes';
12
- import type { StyleTransform } from './transform';
20
+ import type { ClassNameTransform, StyleTransform } from './transform';
13
21
  import type { CSSProperties } from './types';
22
+ import { weightValue } from './weight';
14
23
 
15
24
  const META: unique symbol = symbol('style.fn:meta');
16
25
 
17
- export type StyleFnMeta = {
18
- selectors: SelectorsRecord;
19
- transform: StyleTransform | null;
20
- };
26
+ export type StyleFnMeta =
27
+ | {
28
+ mode: 'StyleObject';
29
+ selectors: SelectorsRecord;
30
+ transform: StyleTransform | null;
31
+ }
32
+ | {
33
+ mode: 'ClassName';
34
+ selectors: SelectorsRecord;
35
+ transform: ClassNameTransform;
36
+ };
21
37
 
22
38
  export const { style } = createStyleFn({
23
39
  style: type<CSSProperties>,
@@ -29,10 +45,10 @@ export type StyleFn<Style = any, Selectors extends SelectorsRecord = any> = Retu
29
45
  >['style'];
30
46
 
31
47
  export function createStyleFn<
32
- Style,
33
- const Selectors extends SelectorsRecord,
48
+ Style = CSSProperties,
49
+ const Selectors extends SelectorsRecord = typeof PrioritySelectors,
34
50
  >(args: {
35
- style: Type<Style>;
51
+ style?: Type<Style>;
36
52
  selectors: Selectors;
37
53
  transform?: StyleTransform<Style> | null;
38
54
  }) {
@@ -42,11 +58,13 @@ export function createStyleFn<
42
58
 
43
59
  const fnStyle = createStyleBuilder<Style, Selectors>(selectors, transform);
44
60
  const fnSlot = createSlotBuilder<Style, Selectors>(selectors, transform);
45
- const fnScope = createScopeBuilder<Style, Selectors>(selectors);
61
+ const fnScope = createScopeBuilder<Selectors>(selectors);
62
+ const fnSelector = createSelectorBuilder<Style, Selectors>(selectors, transform);
46
63
 
47
- const fnValue: Types['ValueFn'] = (value, weight) => {
48
- return [weight, value];
64
+ const fnWeight: Types['ValueFn'] = (value, weight) => {
65
+ return weightValue(value, weight);
49
66
  };
67
+ const fnImportant: Types['ImportantFn'] = (value) => importantValue(value);
50
68
  const fnRaw: Types['RawFn'] = (style) => style;
51
69
  const fnPlain: Types['PlainFn'] = (style) => style;
52
70
  const fnKeyframes: Types['KeyframesFn'] =
@@ -67,18 +85,21 @@ export function createStyleFn<
67
85
 
68
86
  style.slot = fnSlot;
69
87
  style.scope = fnScope;
70
- style.value = fnValue;
88
+ style.weight = fnWeight;
89
+ style.important = fnImportant;
71
90
  style.raw = fnRaw;
72
91
  style.plain = fnPlain;
73
92
  style.keyframes = fnKeyframes;
74
93
  style.merge = fnMerge;
94
+ style.selector = fnSelector as Types['SelectorFn'];
75
95
 
76
96
  const meta: StyleFnMeta = {
97
+ mode: 'StyleObject',
77
98
  selectors,
78
99
  transform: transform ?? null,
79
100
  };
80
101
 
81
- Object.assign(style, { [META]: meta });
102
+ assignStyleFnMeta(style, meta);
82
103
 
83
104
  return { style };
84
105
  }
@@ -107,6 +128,16 @@ function mergeStyleResult(
107
128
  return target;
108
129
  }
109
130
 
110
- export function getStyleFnMeta(styleFn: StyleFn) {
131
+ export type StyleFnWithMeta = StyleFn | ClassNameFn<any, any>;
132
+
133
+ export function assignStyleFnMeta<T extends object>(
134
+ styleFn: T,
135
+ meta: StyleFnMeta,
136
+ ) {
137
+ Object.assign(styleFn, { [META]: meta });
138
+ return styleFn;
139
+ }
140
+
141
+ export function getStyleFnMeta(styleFn: StyleFnWithMeta) {
111
142
  return (styleFn as any)[META] as StyleFnMeta;
112
143
  }
package/style/theme.ts CHANGED
@@ -8,19 +8,20 @@ import type { StyleTokenOverride } from './token';
8
8
 
9
9
  const idCounter = createIdCounter('theme');
10
10
 
11
+ export type TokenTheme = ThemeData;
12
+
11
13
  export function resetStyleThemeIdCounter() {
12
14
  idCounter.value = 0;
13
15
  }
14
16
 
15
17
  export function createTheme(
16
18
  tokens: readonly StyleTokenOverride[],
17
- stableId?: StableId | string,
18
- ): ThemeData;
19
+ ): TokenTheme;
19
20
  export function createTheme(
20
21
  tokens: readonly StyleTokenOverride[],
21
22
  stableId?: StableId | string,
22
23
  callsite?: BuilderCallsite | null,
23
- ): ThemeData {
24
+ ): TokenTheme {
24
25
  const normalizedStableId = typeof stableId === 'string'
25
26
  ? { name: stableId, id: stableId }
26
27
  : stableId;
package/style/token.ts CHANGED
@@ -1,12 +1,24 @@
1
1
  import type { DebugData } from '../builder/data/debug';
2
- import { globalData, symbol } from '../utils/global';
2
+ import { getStyleTokenId, getStyleTokenName, isStyleTokenData } from '../builder/token/data';
3
+ import { getStyleTokenNameFromId, normalizeStyleTokenName } from '../builder/token/name';
4
+ import { globalData } from '../utils/global';
5
+ import { symbol } from '../utils/symbol';
6
+ export {
7
+ getStyleTokenId,
8
+ getStyleTokenName,
9
+ getStyleTokenVarName,
10
+ isStyleTokenData,
11
+ isStyleTokenOverrideData,
12
+ } from '../builder/token/data';
13
+ export { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../builder/token/symbols';
14
+ import { TOKEN_ID, TOKEN_NAME, TOKEN_OVERRIDE, TOKEN_VAR_NAME } from '../builder/token/symbols';
3
15
 
4
- export const TOKEN_ID: unique symbol = symbol('style:token');
5
- export const TOKEN_OVERRIDE: unique symbol = symbol('style:token.override');
6
16
  export const TOKEN_DEBUG: unique symbol = symbol('style:token.debug');
7
17
 
8
18
  export type StyleTokenData<T = unknown> = {
9
19
  [TOKEN_ID]: string;
20
+ [TOKEN_NAME]?: string | null;
21
+ [TOKEN_VAR_NAME]?: string | null;
10
22
  [TOKEN_OVERRIDE]?: false;
11
23
  value: T;
12
24
  ref: StyleTokenData<T> | null;
@@ -16,6 +28,8 @@ export type StyleTokenOverride<T = unknown> = {
16
28
  [TOKEN_ID]: string;
17
29
  [TOKEN_OVERRIDE]: true;
18
30
  [TOKEN_DEBUG]?: DebugData | null;
31
+ [TOKEN_NAME]?: string | null;
32
+ [TOKEN_VAR_NAME]?: string | null;
19
33
  value: T;
20
34
  ref: StyleTokenData<T> | null;
21
35
  };
@@ -30,12 +44,17 @@ export function resetStyleTokenIdCounter() {
30
44
  idCounter.value = 0;
31
45
  }
32
46
 
33
- export function createStyleToken<T>(value: T | StyleToken<T>, debugId?: string) {
47
+ export function createStyleToken<T>(
48
+ value: T | StyleToken<T>,
49
+ stableId?: string,
50
+ debugName?: string | null,
51
+ ) {
34
52
  const token: StyleToken<T> = (value, debug) => {
35
53
  return createStyleTokenOverride(token, value, debug);
36
54
  };
37
55
 
38
- token[TOKEN_ID] = debugId || String(idCounter.value++);
56
+ token[TOKEN_ID] = stableId || String(idCounter.value++);
57
+ token[TOKEN_NAME] = debugName === undefined ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
39
58
 
40
59
  if (isStyleTokenData<T>(value)) {
41
60
  token.value = value.value;
@@ -57,12 +76,14 @@ export function createStyleTokenOverride<T>(
57
76
  ? {
58
77
  [TOKEN_ID]: getStyleTokenId(token),
59
78
  [TOKEN_OVERRIDE]: true,
79
+ [TOKEN_NAME]: getStyleTokenName(token),
60
80
  value: value.value,
61
81
  ref: value,
62
82
  }
63
83
  : {
64
84
  [TOKEN_ID]: getStyleTokenId(token),
65
85
  [TOKEN_OVERRIDE]: true,
86
+ [TOKEN_NAME]: getStyleTokenName(token),
66
87
  value: value as T,
67
88
  ref: null,
68
89
  };
@@ -83,19 +104,3 @@ export function getStyleTokenOverrideDebug(
83
104
  ) {
84
105
  return token[TOKEN_DEBUG] ?? null;
85
106
  }
86
-
87
- export function isStyleTokenData<T = unknown>(value: unknown): value is StyleToken<T> {
88
- return !!value &&
89
- typeof (value as StyleToken)[TOKEN_ID] === 'string' &&
90
- (value as StyleTokenOverride)[TOKEN_OVERRIDE] !== true;
91
- }
92
-
93
- export function isStyleTokenOverrideData<T = unknown>(value: unknown): value is StyleTokenOverride<T> {
94
- return !!value &&
95
- typeof (value as StyleTokenOverride)[TOKEN_ID] === 'string' &&
96
- (value as StyleTokenOverride)[TOKEN_OVERRIDE] === true;
97
- }
98
-
99
- export function getStyleTokenId<T>(token: StyleTokenData<T> | StyleTokenOverride<T>): string {
100
- return token[TOKEN_ID];
101
- }
package/style/tokens.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import { getChildStyleTokenName } from '../builder/token/name';
1
2
  import type { StyleToken } from './token';
2
- import { createToken, type InferValue, type ValueBase } from './value';
3
+ import { createStyleToken } from './token';
4
+ import type { InferValue, ValueBase } from './value';
3
5
 
4
6
  export type TokenTuple<T extends readonly ValueBase[]> = {
5
7
  [P in T[number]]: StyleToken<InferValue<P>>;
@@ -14,25 +16,27 @@ export type TokenRecord<T extends object> = {
14
16
 
15
17
  export function createTokens<const T extends readonly ValueBase[]>(
16
18
  values: T,
17
- debugId?: string,
18
19
  ): TokenTuple<T>;
19
20
  export function createTokens<T extends object>(
20
21
  values: T,
21
- debugId?: string,
22
22
  ): TokenRecord<T>;
23
23
  export function createTokens(
24
24
  values: readonly ValueBase[] | Record<PropertyKey, unknown>,
25
- debugId?: string,
25
+ stableId?: string,
26
26
  ): any {
27
27
  const tokens: Record<PropertyKey, StyleToken> = {};
28
28
 
29
29
  if (Array.isArray(values)) {
30
30
  for (let i = 0, len = values.length; i < len; i++) {
31
31
  const value = values[i];
32
- tokens[value] = createToken(value, getChildDebugId(debugId, String(i)));
32
+ tokens[value] = createStyleToken(
33
+ value,
34
+ getChildStableId(stableId, String(i)),
35
+ getChildStyleTokenName(stableId, String(i)),
36
+ );
33
37
  }
34
38
  } else {
35
- assignTokenRecord(tokens, values as Record<PropertyKey, unknown>, debugId);
39
+ assignTokenRecord(tokens, values as Record<PropertyKey, unknown>, stableId, stableId ?? null);
36
40
  }
37
41
 
38
42
  return tokens;
@@ -41,24 +45,26 @@ export function createTokens(
41
45
  function assignTokenRecord(
42
46
  target: Record<PropertyKey, unknown>,
43
47
  values: Record<PropertyKey, unknown>,
44
- debugId: string | undefined,
48
+ stableId: string | undefined,
49
+ debugName: string | null,
45
50
  ) {
46
51
  for (let key in values) {
47
52
  const value = values[key];
53
+ const childName = getChildStyleTokenName(debugName, key);
48
54
 
49
55
  if (value && typeof value === 'object' && !Array.isArray(value)) {
50
56
  const child: Record<PropertyKey, unknown> = {};
51
57
  target[key] = child;
52
- assignTokenRecord(child, value as Record<PropertyKey, unknown>, getChildDebugId(debugId, key));
58
+ assignTokenRecord(child, value as Record<PropertyKey, unknown>, getChildStableId(stableId, key), childName);
53
59
  } else {
54
- target[key] = createToken(value, getChildDebugId(debugId, key));
60
+ target[key] = createStyleToken(value, getChildStableId(stableId, key), childName);
55
61
  }
56
62
  }
57
63
  }
58
64
 
59
- function getChildDebugId(
60
- debugId: string | undefined,
65
+ function getChildStableId(
66
+ stableId: string | undefined,
61
67
  child: string,
62
68
  ) {
63
- return debugId ? debugId + '--' + child : undefined;
69
+ return stableId ? stableId + '--' + child : undefined;
64
70
  }
@@ -1,9 +1,48 @@
1
- import type { CSSProperties, StyleObject } from './types';
1
+ import { symbol } from '../utils/symbol';
2
+ import type { CSSProperties, StyleObject, StyleValue } from './types';
3
+
4
+ const CLASS_NAME_VALUE: unique symbol = symbol('transform.classNameValue');
5
+
6
+ export type ClassNameValue<Value = unknown> = {
7
+ readonly [CLASS_NAME_VALUE]: true;
8
+ readonly value: Value;
9
+ readonly className: string;
10
+ };
11
+
12
+ export type TransformStyleObject<Style = unknown> = {
13
+ [P in keyof Style]: StyleValue<Style[P] | ClassNameValue<Style[P]>>;
14
+ };
2
15
 
3
16
  export type StyleTransform<Style = unknown> = {
4
- transform(style: StyleObject<Style>): StyleObject<CSSProperties>;
17
+ transform(style: StyleObject<Style>): TransformStyleObject<CSSProperties>;
18
+ };
19
+
20
+ export type ClassNameTransform<ClassName extends string = string> = {
21
+ transform(className: ClassName): TransformStyleObject<CSSProperties>;
5
22
  };
6
23
 
24
+ export function classNameValue<const Value>(
25
+ value: Value,
26
+ className: string,
27
+ ): ClassNameValue<Value> {
28
+ return {
29
+ [CLASS_NAME_VALUE]: true,
30
+ value,
31
+ className,
32
+ };
33
+ }
34
+
35
+ export function isClassNameValue(value: unknown): value is ClassNameValue {
36
+ return !!value &&
37
+ typeof value === 'object' &&
38
+ (value as ClassNameValue)[CLASS_NAME_VALUE] === true &&
39
+ typeof (value as ClassNameValue).className === 'string';
40
+ }
41
+
7
42
  export function styleTransform<Style>(options: StyleTransform<Style>) {
8
43
  return options;
9
44
  }
45
+
46
+ export function classNameTransform<ClassName extends string>(options: ClassNameTransform<ClassName>) {
47
+ return options;
48
+ }
package/style/types.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { CSSProperties } from '../atomic/utils/types';
2
+ import type { StyleImportantValue } from './important';
2
3
  import type { StyleTokenData } from './token';
3
4
  import type { AtRuleRef } from './valueRef';
5
+ import type { StyleWeightValue } from './weight';
4
6
 
5
7
  export type { CSSProperties };
6
8
 
@@ -10,10 +12,10 @@ type StyleTokenize<T> = Exclude<
10
12
  StyleTokenData<undefined>
11
13
  >;
12
14
 
13
- type Value<T> = T | StyleValueTuple<Exclude<T, null | undefined>>;
14
- type PlainValue<T> = T | StyleValueTuple<Exclude<T, null | undefined>>;
15
-
16
- export type StyleValueTuple<T = unknown> = [priority: number, value: T];
15
+ type Important<T> = StyleImportantValue<Exclude<T, null | undefined>>;
16
+ type Weight<T> = StyleWeightValue<Exclude<T, null | undefined>>;
17
+ type Value<T> = T | Weight<T> | Important<T>;
18
+ type PlainValue<T> = T | Weight<T> | Important<T>;
17
19
 
18
20
  export type StyleValue<T> = Value<T | StyleTokenize<T> | AtRuleRef>;
19
21
 
@@ -1,9 +1,10 @@
1
- import type { AnyBuilderData, SlotData } from '../../builder/data';
2
- import { isSlotData } from '../../builder/data';
1
+ import type { AnyBuilderData, SelectorData, SlotData } from '../../builder/data';
2
+ import { isSelectorData, isSlotData } from '../../builder/data';
3
3
  import { isStyleTokenData, type StyleTokenData } from '../token';
4
4
 
5
5
  type ExposedStyleItem<T> = T extends StyleTokenData ? T
6
6
  : T extends SlotData ? T
7
+ : T extends SelectorData ? T
7
8
  : T extends AnyBuilderData ? never
8
9
  : T extends readonly unknown[] ? never
9
10
  : T extends object ? ExposedStyle<T>
@@ -34,7 +35,7 @@ function exposeStyleObject(source: object) {
34
35
  }
35
36
 
36
37
  function exposeStyleValue(value: unknown): unknown {
37
- if (isStyleTokenData(value) || isSlotData(value)) return value;
38
+ if (isStyleTokenData(value) || isSlotData(value) || isSelectorData(value)) return value;
38
39
 
39
40
  if (!value || typeof value !== 'object' || Array.isArray(value)) return undefined;
40
41