@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.5

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 (430) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/README.md +10 -9
  3. package/atomic/className.ts +12 -12
  4. package/atomic/debug/className/className.ts +10 -15
  5. package/atomic/element.ts +1 -1
  6. package/atomic/rule.ts +8 -5
  7. package/atomic/scope.ts +19 -0
  8. package/atomic/theme.ts +41 -2
  9. package/atomic/token.ts +4 -3
  10. package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
  11. package/atomic/utils/cssVar.ts +19 -0
  12. package/atomic/utils/debug.ts +1 -1
  13. package/atomic/utils/selector.ts +14 -1
  14. package/builder/classname/class_name_builder.ts +68 -24
  15. package/builder/classname/fns.ts +2 -2
  16. package/builder/classname/types.ts +7 -0
  17. package/builder/data/const.ts +7 -1
  18. package/builder/data/create.ts +42 -0
  19. package/builder/data/data.ts +20 -1
  20. package/builder/data/index.ts +0 -1
  21. package/builder/data/is.ts +23 -0
  22. package/builder/data/merge/scope.ts +20 -19
  23. package/builder/data/merge/style.ts +71 -21
  24. package/builder/data/state.ts +16 -2
  25. package/builder/extract/index.ts +1 -0
  26. package/builder/extract/sheet.ts +26 -0
  27. package/builder/extract/token.ts +30 -14
  28. package/builder/extract/utils.ts +2 -0
  29. package/builder/extract/withTokens.ts +2 -1
  30. package/builder/selector_override.noop.ts +11 -0
  31. package/builder/selector_override.ts +30 -0
  32. package/builder/selector_override_core.ts +66 -0
  33. package/builder/style_builder.ts +127 -3
  34. package/builder/style_data.ts +24 -0
  35. package/builder/style_fns.ts +24 -24
  36. package/builder/token/data.ts +30 -0
  37. package/builder/token/index.ts +3 -0
  38. package/builder/token/name.ts +54 -0
  39. package/builder/token/symbols.ts +6 -0
  40. package/builder/types/alias.ts +34 -6
  41. package/builder/types/fns.ts +13 -5
  42. package/builder/types/types.ts +32 -2
  43. package/builder/utils.ts +1 -0
  44. package/compiler/compiler/compiler.ts +4 -7
  45. package/compiler/compiler/constants.ts +6 -0
  46. package/compiler/compiler/index.ts +1 -0
  47. package/compiler/compiler/types.ts +2 -0
  48. package/compiler/cssProp.ts +35 -0
  49. package/compiler/index.ts +1 -0
  50. package/compiler/transform/cssProp/index.ts +1 -0
  51. package/compiler/transform/cssProp/plugin.ts +129 -0
  52. package/compiler/transform/debug/plugin.ts +85 -1
  53. package/compiler/transform/debug/transform.ts +2 -1
  54. package/compiler/transform/evaluator/evaluator.ts +106 -30
  55. package/compiler/transform/evaluator/tracer.ts +30 -2
  56. package/compiler/transform/extract/chain/chain.ts +541 -63
  57. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  58. package/compiler/transform/extract/chain/types.ts +1 -1
  59. package/compiler/transform/extract/plugin.ts +20 -4
  60. package/compiler/transform/extract/transform.ts +2 -1
  61. package/compiler/transform/extract/utils/replacement.ts +52 -2
  62. package/compiler/transform/extract/utils/state.ts +2 -0
  63. package/compiler/transform/extract/utils/theme.ts +6 -6
  64. package/compiler/transform/index.ts +1 -0
  65. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  66. package/compiler/transform/syntax/static_ids.ts +1 -1
  67. package/compiler/utils/constants.ts +8 -1
  68. package/compiler/utils/imports.ts +11 -1
  69. package/config/build.ts +1 -8
  70. package/config/config/css.ts +1 -0
  71. package/config/config/debug.ts +11 -0
  72. package/css/index.ts +2 -0
  73. package/css/sheet.ts +119 -0
  74. package/css/styleTarget.ts +251 -0
  75. package/dialect/namedTokens.ts +22 -5
  76. package/dist/adapter/preact.js +2 -0
  77. package/dist/adapter/react.js +2 -0
  78. package/dist/adapter/solid.js +2 -0
  79. package/dist/className-hiAsQ9V6.js +303 -0
  80. package/dist/className-hiAsQ9V6.js.map +1 -0
  81. package/dist/{style-Bw5ka-Nq.js → combine-Ca6LfFxv.js} +427 -722
  82. package/dist/combine-Ca6LfFxv.js.map +1 -0
  83. package/dist/compiler/index.mjs +2 -2
  84. package/dist/{compiler-D5v5tJXI.mjs → compiler-OgDBuqfs.mjs} +1635 -607
  85. package/dist/compiler-OgDBuqfs.mjs.map +1 -0
  86. package/dist/config/index.js +2 -2
  87. package/dist/config-B-KbXpIh.js +6 -0
  88. package/dist/{config-OXHoDUIo.js.map → config-B-KbXpIh.js.map} +1 -1
  89. package/dist/config-Barf8f4B.js +35 -0
  90. package/dist/config-Barf8f4B.js.map +1 -0
  91. package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
  92. package/dist/config-BtANtGAh.js.map +1 -0
  93. package/dist/config-CsB4MuFI.js +6 -0
  94. package/dist/config-CsB4MuFI.js.map +1 -0
  95. package/dist/config-DOWSNV8w.js +1 -0
  96. package/dist/{config-FIfi5aJ8.js → config-t76UljYv.js} +9 -7
  97. package/dist/config-t76UljYv.js.map +1 -0
  98. package/dist/createTransformElement-DDqld3RF.js +34 -0
  99. package/dist/createTransformElement-DDqld3RF.js.map +1 -0
  100. package/dist/css-CZwrac6F.js +3923 -0
  101. package/dist/css-CZwrac6F.js.map +1 -0
  102. package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
  103. package/dist/css-GtUPEO9U.js.map +1 -0
  104. package/dist/css-YfHN_8Nk.js +479 -0
  105. package/dist/css-YfHN_8Nk.js.map +1 -0
  106. package/dist/css-a9O5so0b.js +1246 -0
  107. package/dist/css-a9O5so0b.js.map +1 -0
  108. package/dist/css.js +2 -2
  109. package/dist/{css_extra-DeTuIlcO.js → css_extra-BiG57TKN.js} +2 -2
  110. package/dist/{css_extra-DQdCrYoC.js.map → css_extra-BiG57TKN.js.map} +1 -1
  111. package/dist/{css_extra-DQdCrYoC.js → css_extra-CXXZAylc.js} +2 -2
  112. package/dist/{css_extra-DeTuIlcO.js.map → css_extra-CXXZAylc.js.map} +1 -1
  113. package/dist/data-CzHJg147.js +763 -0
  114. package/dist/data-CzHJg147.js.map +1 -0
  115. package/dist/{debug-D96KGgpH.js → debug-DkrxyknP.js} +80 -4
  116. package/dist/debug-DkrxyknP.js.map +1 -0
  117. package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
  118. package/dist/debug-DycdGrul.js.map +1 -0
  119. package/dist/dev/rsc.js +6 -9
  120. package/dist/dev/rsc.js.map +1 -1
  121. package/dist/{dev-fOtWB5K3.js → dev-z4laBwlS.js} +7 -6
  122. package/dist/{dev-fOtWB5K3.js.map → dev-z4laBwlS.js.map} +1 -1
  123. package/dist/dev.js +1 -1
  124. package/dist/dialect/extracted/index.js +1 -1
  125. package/dist/dialect/index.js +1 -1
  126. package/dist/{elementMarker-CvqqIb7J.js → elementMarker-CqhU_l_m.js} +95 -9
  127. package/dist/elementMarker-CqhU_l_m.js.map +1 -0
  128. package/dist/entry/dev/adapter/preact.js +12 -0
  129. package/dist/entry/dev/adapter/preact.js.map +1 -0
  130. package/dist/entry/dev/adapter/react.js +12 -0
  131. package/dist/entry/dev/adapter/react.js.map +1 -0
  132. package/dist/entry/dev/adapter/solid.js +12 -0
  133. package/dist/entry/dev/adapter/solid.js.map +1 -0
  134. package/dist/entry/dev/css.js +3 -3
  135. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  136. package/dist/entry/dev/jsx-runtime.js +2 -2
  137. package/dist/entry/dev.js +13 -12
  138. package/dist/entry/prod/adapter/preact.js +12 -0
  139. package/dist/entry/prod/adapter/preact.js.map +1 -0
  140. package/dist/entry/prod/adapter/react.js +12 -0
  141. package/dist/entry/prod/adapter/react.js.map +1 -0
  142. package/dist/entry/prod/adapter/solid.js +12 -0
  143. package/dist/entry/prod/adapter/solid.js.map +1 -0
  144. package/dist/entry/prod/css.js +3 -3
  145. package/dist/entry/prod/extract.js +240 -3
  146. package/dist/entry/prod/extract.js.map +1 -0
  147. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  148. package/dist/entry/prod/jsx-runtime.js +2 -2
  149. package/dist/entry/prod/runtime.js +3 -4
  150. package/dist/entry/prod.js +85 -1201
  151. package/dist/entry/prod.js.map +1 -1
  152. package/dist/entry/rsc-dev/adapter/preact.js +12 -0
  153. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  154. package/dist/entry/rsc-dev/adapter/react.js +12 -0
  155. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  156. package/dist/entry/rsc-dev/adapter/solid.js +12 -0
  157. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  158. package/dist/entry/rsc-dev/css.js +3 -3
  159. package/dist/entry/rsc-dev/dev.js +6 -10
  160. package/dist/entry/rsc-dev/dev.js.map +1 -1
  161. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  162. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  163. package/dist/entry/rsc-dev.js +323 -615
  164. package/dist/entry/rsc-dev.js.map +1 -1
  165. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  166. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  167. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  168. package/dist/entry/rsc-prod/css.js +9 -3
  169. package/dist/entry/rsc-prod/css.js.map +1 -0
  170. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  171. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  172. package/dist/entry/rsc-prod/runtime.js +3 -4
  173. package/dist/entry/rsc-prod.js +241 -10
  174. package/dist/entry/rsc-prod.js.map +1 -0
  175. package/dist/{styleStore-ydQcDBD4.js → env-Db2cRt-h.js} +1256 -355
  176. package/dist/env-Db2cRt-h.js.map +1 -0
  177. package/dist/{jsx-A4cK517J.js → getClassName-DKtQl5ZX.js} +5 -11
  178. package/dist/getClassName-DKtQl5ZX.js.map +1 -0
  179. package/dist/{utils-hoYnMiA7.js → getClassName-DaZF5nfJ.js} +28 -65
  180. package/dist/getClassName-DaZF5nfJ.js.map +1 -0
  181. package/dist/getClassName-a6p2uMFM.js +536 -0
  182. package/dist/getClassName-a6p2uMFM.js.map +1 -0
  183. package/dist/{getClassName-oiQ8CnkS.js → getClassName-aD9zqg9U.js} +56 -14
  184. package/dist/getClassName-aD9zqg9U.js.map +1 -0
  185. package/dist/global-zYTvWskP.js +10 -0
  186. package/dist/{global-Cul1dX8k.js.map → global-zYTvWskP.js.map} +1 -1
  187. package/dist/{hash-Bycpk3MR.js → hash-BOlQThNz.js} +48 -4
  188. package/dist/hash-BOlQThNz.js.map +1 -0
  189. package/dist/index.js +10 -10
  190. package/dist/jsx/jsx-dev-runtime.js +2 -2
  191. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  192. package/dist/jsx/jsx-runtime.js +2 -2
  193. package/dist/jsx/jsx-runtime.server.js +1 -1
  194. package/dist/jsx-C2pnWLcb.js +39 -0
  195. package/dist/jsx-C2pnWLcb.js.map +1 -0
  196. package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
  197. package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
  198. package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-BgK90E2O.js} +2 -3
  199. package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
  200. package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-XJSHujgI.js} +2 -2
  201. package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-XJSHujgI.js.map} +1 -1
  202. package/dist/{loader-BAth2yZ1.mjs → loader-DHvgp0fK.mjs} +3 -3
  203. package/dist/{loader-BAth2yZ1.mjs.map → loader-DHvgp0fK.mjs.map} +1 -1
  204. package/dist/{misc-DFBKJGLT.mjs → misc-BuSLnvx0.mjs} +4 -4
  205. package/dist/misc-BuSLnvx0.mjs.map +1 -0
  206. package/dist/{namedTokens-BUa6raTb.js → namedTokens-D3tt-joz.js} +8 -6
  207. package/dist/namedTokens-D3tt-joz.js.map +1 -0
  208. package/dist/plugin/farm/index.mjs +4 -3
  209. package/dist/plugin/farm/index.mjs.map +1 -1
  210. package/dist/plugin/nextjs/index.mjs +5 -5
  211. package/dist/plugin/nextjs/index.mjs.map +1 -1
  212. package/dist/plugin/nextjs/loader.mjs +4 -4
  213. package/dist/plugin/parcel/index.cjs +2 -0
  214. package/dist/plugin/parcel/index.mjs +3 -1
  215. package/dist/plugin/parcel/optimizer.cjs +3 -2
  216. package/dist/plugin/parcel/optimizer.cjs.map +1 -1
  217. package/dist/plugin/parcel/optimizer.mjs +3 -2
  218. package/dist/plugin/parcel/optimizer.mjs.map +1 -1
  219. package/dist/plugin/parcel/resolver.cjs +1 -1
  220. package/dist/plugin/parcel/resolver.mjs +2 -2
  221. package/dist/plugin/parcel/runtime.cjs +1 -1
  222. package/dist/plugin/parcel/runtime.mjs +1 -1
  223. package/dist/plugin/parcel/transformer.cjs +1 -1
  224. package/dist/plugin/parcel/transformer.mjs +2 -2
  225. package/dist/plugin/rspack/index.mjs +3 -2
  226. package/dist/plugin/rspack/index.mjs.map +1 -1
  227. package/dist/plugin/vite/index.mjs +6 -6
  228. package/dist/plugin/vite/index.mjs.map +1 -1
  229. package/dist/plugin/webpack/index.mjs +3 -2
  230. package/dist/plugin/webpack/loader.mjs +2 -2
  231. package/dist/presets/tailwind/index.js +9 -7
  232. package/dist/presets/tailwind/index.js.map +1 -1
  233. package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
  234. package/dist/presets-DSanixJV.js.map +1 -0
  235. package/dist/{registry-CiwvMfx8.mjs → registry-r3BKWqpI.mjs} +2 -2
  236. package/dist/{registry-CiwvMfx8.mjs.map → registry-r3BKWqpI.mjs.map} +1 -1
  237. package/dist/resolveClassNameRuntime-D5a37GNr.js +63 -0
  238. package/dist/resolveClassNameRuntime-D5a37GNr.js.map +1 -0
  239. package/dist/{rules-DlXcch7-.js → rules-B0_rKPfB.js} +598 -132
  240. package/dist/rules-B0_rKPfB.js.map +1 -0
  241. package/dist/scope-BSuRLice.js +601 -0
  242. package/dist/scope-BSuRLice.js.map +1 -0
  243. package/dist/selector/index.js +1 -2
  244. package/dist/server.js +15 -13
  245. package/dist/server.js.map +1 -1
  246. package/dist/{shared-yDD0nfm1.cjs → shared-8_Msr7Q5.cjs} +1630 -597
  247. package/dist/shared-8_Msr7Q5.cjs.map +1 -0
  248. package/dist/{shared-x59dI2NW.mjs → shared-BGO_05rW.mjs} +4 -4
  249. package/dist/{shared-x59dI2NW.mjs.map → shared-BGO_05rW.mjs.map} +1 -1
  250. package/dist/sheet-BpLZIIuO.js +7 -0
  251. package/dist/{sheet-B-uJfHRY.js.map → sheet-BpLZIIuO.js.map} +1 -1
  252. package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-Bu2x35JE.mjs} +3 -3
  253. package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-Bu2x35JE.mjs.map} +1 -1
  254. package/dist/{styleStore-DJ0Msgkh.js → styleStore-BDy5TH6N.js} +5 -6
  255. package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-BDy5TH6N.js.map} +1 -1
  256. package/dist/styleStore-DX3z_UVK.js +51 -0
  257. package/dist/styleStore-DX3z_UVK.js.map +1 -0
  258. package/dist/token-BsW_S8fN.js +138 -0
  259. package/dist/token-BsW_S8fN.js.map +1 -0
  260. package/dist/{trace-D8j96G57.js → trace-BdKEpgME.js} +2 -2
  261. package/dist/{trace-D8j96G57.js.map → trace-BdKEpgME.js.map} +1 -1
  262. package/dist/{trace-CO36aenp.js → trace-DcuMxR45.js} +3 -3
  263. package/dist/{trace-CO36aenp.js.map → trace-DcuMxR45.js.map} +1 -1
  264. package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
  265. package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
  266. package/dist/{style-DFFK06Of.js → types-BEUgXuu2.js} +356 -129
  267. package/dist/types-BEUgXuu2.js.map +1 -0
  268. package/dist/{utils-D2fygyTm.mjs → utils-BPDxr-oc.mjs} +4 -4
  269. package/dist/{utils-D2fygyTm.mjs.map → utils-BPDxr-oc.mjs.map} +1 -1
  270. package/dist/utils-CLnpwhJd.js +83 -0
  271. package/dist/utils-CLnpwhJd.js.map +1 -0
  272. package/dist/utils-CUl1BU40.js +72 -0
  273. package/dist/utils-CUl1BU40.js.map +1 -0
  274. package/dist/{utils-DTXCTUlS.mjs → utils-DZjLTV4D.mjs} +3 -3
  275. package/dist/{utils-DTXCTUlS.mjs.map → utils-DZjLTV4D.mjs.map} +1 -1
  276. package/dist/utils-okFWrQsg.js +41 -0
  277. package/dist/utils-okFWrQsg.js.map +1 -0
  278. package/dist/{utils-DVFxZnVC.js → utils-sBVZEq4u.js} +190 -144
  279. package/dist/utils-sBVZEq4u.js.map +1 -0
  280. package/dist/utils.js +4 -4
  281. package/dist/utils.js.map +1 -1
  282. package/dist/value-CpJpQ00y.js +145 -0
  283. package/dist/value-CpJpQ00y.js.map +1 -0
  284. package/dist/{webpack-BOU7_xld.mjs → webpack-DTKgR-HY.mjs} +5 -5
  285. package/dist/webpack-DTKgR-HY.mjs.map +1 -0
  286. package/entry/dev/adapter/preact.ts +8 -0
  287. package/entry/dev/adapter/react.ts +8 -0
  288. package/entry/dev/adapter/solid.ts +8 -0
  289. package/entry/prod/adapter/preact.ts +8 -0
  290. package/entry/prod/adapter/react.ts +8 -0
  291. package/entry/prod/adapter/solid.ts +8 -0
  292. package/entry/prod/config_debug.ts +2 -0
  293. package/entry/prod/index.ts +1 -1
  294. package/entry/prod/runtime.ts +3 -1
  295. package/entry/rsc_dev/adapter/preact.ts +1 -0
  296. package/entry/rsc_dev/adapter/react.ts +1 -0
  297. package/entry/rsc_dev/adapter/solid.ts +1 -0
  298. package/entry/rsc_prod/adapter/preact.ts +1 -0
  299. package/entry/rsc_prod/adapter/react.ts +1 -0
  300. package/entry/rsc_prod/adapter/solid.ts +1 -0
  301. package/entry/rsc_prod/config_debug.ts +6 -0
  302. package/entry/rsc_prod/index.ts +1 -1
  303. package/entry/shared/config_debug.ts +9 -0
  304. package/entry/shared/config_dev.ts +9 -7
  305. package/jsx/types/index.ts +3 -0
  306. package/jsx/types/preact.ts +14 -0
  307. package/jsx/{types.ts → types/react.ts} +2 -2
  308. package/jsx/types/solid.ts +32 -0
  309. package/package.json +78 -12
  310. package/plugin/bundler/farm/plugin.ts +2 -0
  311. package/plugin/bundler/parcel/optimizer.ts +1 -0
  312. package/plugin/bundler/parcel/plugin.ts +2 -0
  313. package/plugin/bundler/rspack/plugin.ts +1 -0
  314. package/plugin/bundler/vite/plugin.ts +3 -8
  315. package/plugin/bundler/vite/state.ts +2 -2
  316. package/plugin/bundler/webpack/plugin.ts +2 -1
  317. package/plugin/nextjs/plugin.ts +3 -0
  318. package/plugin/utils/compiler.ts +2 -0
  319. package/plugin/utils/runtimeEntry.ts +2 -2
  320. package/presets/tailwind/style/transform.ts +9 -3
  321. package/runtime/adapter/utils.ts +94 -0
  322. package/runtime/core/cache/combine.ts +76 -28
  323. package/runtime/core/cache/combineRuntime.ts +4 -0
  324. package/runtime/core/cache/index.ts +2 -1
  325. package/runtime/core/cache/item.ts +32 -13
  326. package/runtime/core/cache/itemWithResolver.ts +44 -0
  327. package/runtime/core/cache/pool.ts +15 -30
  328. package/runtime/core/cache/prop.ts +10 -8
  329. package/runtime/core/cache/result.ts +2 -2
  330. package/runtime/core/cache/stateItem.ts +16 -1
  331. package/runtime/core/cache/token.ts +20 -0
  332. package/runtime/core/cache/tokenValues.ts +19 -11
  333. package/runtime/core/combinedStyle.ts +4 -4
  334. package/runtime/extract/combineStyle.ts +211 -0
  335. package/runtime/extract/getClassName.ts +54 -17
  336. package/runtime/extract/index.ts +3 -1
  337. package/runtime/extract/token.ts +41 -0
  338. package/runtime/extract/tokenResolver.ts +17 -0
  339. package/runtime/sheet/rule.ts +3 -10
  340. package/runtime/style/scope.ts +0 -24
  341. package/runtime/style/style.ts +181 -6
  342. package/runtime/types.ts +3 -3
  343. package/style/classname.ts +12 -6
  344. package/style/important.ts +19 -0
  345. package/style/index.ts +2 -0
  346. package/style/style.ts +17 -5
  347. package/style/theme.ts +0 -1
  348. package/style/token.ts +26 -21
  349. package/style/tokens.ts +18 -12
  350. package/style/transform.ts +1 -1
  351. package/style/types.ts +6 -4
  352. package/style/utils/expose.ts +4 -3
  353. package/style/value.ts +26 -11
  354. package/style/valueRef.ts +1 -1
  355. package/style/weight.ts +21 -0
  356. package/utils/global.ts +1 -3
  357. package/utils/symbol.ts +3 -0
  358. package/dist/assert-BGdigdr5.js.map +0 -1
  359. package/dist/className-CKo4TxuT.js +0 -144
  360. package/dist/className-CKo4TxuT.js.map +0 -1
  361. package/dist/className-ZJ5pBA-o.js +0 -263
  362. package/dist/className-ZJ5pBA-o.js.map +0 -1
  363. package/dist/compiler-D5v5tJXI.mjs.map +0 -1
  364. package/dist/config-BEvP7108.js.map +0 -1
  365. package/dist/config-B_cbG3S6.js +0 -1
  366. package/dist/config-FIfi5aJ8.js.map +0 -1
  367. package/dist/config-OXHoDUIo.js +0 -6
  368. package/dist/css-CELBp6Gu.js +0 -58
  369. package/dist/css-CELBp6Gu.js.map +0 -1
  370. package/dist/css-DcuJ_jSH.js +0 -243
  371. package/dist/css-DcuJ_jSH.js.map +0 -1
  372. package/dist/css-dPoZJDQH.js +0 -807
  373. package/dist/css-dPoZJDQH.js.map +0 -1
  374. package/dist/css-oOt6ZR54.js +0 -237
  375. package/dist/css-oOt6ZR54.js.map +0 -1
  376. package/dist/data-CeYstKMP.js +0 -482
  377. package/dist/data-CeYstKMP.js.map +0 -1
  378. package/dist/debug-D96KGgpH.js.map +0 -1
  379. package/dist/dev-p8tW7X-A.js +0 -81
  380. package/dist/dev-p8tW7X-A.js.map +0 -1
  381. package/dist/elementMarker-CvqqIb7J.js.map +0 -1
  382. package/dist/extract-CzWJeQi8.js +0 -121
  383. package/dist/extract-CzWJeQi8.js.map +0 -1
  384. package/dist/extract-DeOytHKW.js +0 -2
  385. package/dist/getClassName-oiQ8CnkS.js.map +0 -1
  386. package/dist/global-Cul1dX8k.js +0 -14
  387. package/dist/global-zaCE-g1C.js.map +0 -1
  388. package/dist/hash-Bycpk3MR.js.map +0 -1
  389. package/dist/jsx-A4cK517J.js.map +0 -1
  390. package/dist/jsx-Ba-XV33u.js +0 -39
  391. package/dist/jsx-Ba-XV33u.js.map +0 -1
  392. package/dist/layer-CbQzwZF-.js +0 -94
  393. package/dist/layer-CbQzwZF-.js.map +0 -1
  394. package/dist/misc-DFBKJGLT.mjs.map +0 -1
  395. package/dist/namedTokens-BUa6raTb.js.map +0 -1
  396. package/dist/presets-BhXa232U.js +0 -108
  397. package/dist/presets-BhXa232U.js.map +0 -1
  398. package/dist/property-CF6JgpTq.js +0 -406
  399. package/dist/property-CF6JgpTq.js.map +0 -1
  400. package/dist/rules-DlXcch7-.js.map +0 -1
  401. package/dist/runtime-BKChZZ2-.js.map +0 -1
  402. package/dist/shared-yDD0nfm1.cjs.map +0 -1
  403. package/dist/sheet-B-uJfHRY.js +0 -7
  404. package/dist/style-91J0B5ef.js +0 -771
  405. package/dist/style-91J0B5ef.js.map +0 -1
  406. package/dist/style-Bw5ka-Nq.js.map +0 -1
  407. package/dist/style-DFFK06Of.js.map +0 -1
  408. package/dist/style-pz8e5To1.js +0 -5
  409. package/dist/styleStore-ydQcDBD4.js.map +0 -1
  410. package/dist/token-CKXUECuU.js +0 -76
  411. package/dist/token-CKXUECuU.js.map +0 -1
  412. package/dist/token-DTOyFLmp.js +0 -58
  413. package/dist/token-DTOyFLmp.js.map +0 -1
  414. package/dist/token-DT_sCPtm.js +0 -298
  415. package/dist/token-DT_sCPtm.js.map +0 -1
  416. package/dist/utils-Bmw655wa.js +0 -170
  417. package/dist/utils-Bmw655wa.js.map +0 -1
  418. package/dist/utils-DVFxZnVC.js.map +0 -1
  419. package/dist/utils-hoYnMiA7.js.map +0 -1
  420. package/dist/value-D-ZcRzLA.js +0 -42
  421. package/dist/value-D-ZcRzLA.js.map +0 -1
  422. package/dist/value-DvFkGBy2.js +0 -1029
  423. package/dist/value-DvFkGBy2.js.map +0 -1
  424. package/dist/value-dG9LK0Gq.js +0 -85
  425. package/dist/value-dG9LK0Gq.js.map +0 -1
  426. package/dist/valueRef-CsLVJwjA.js +0 -16
  427. package/dist/valueRef-CsLVJwjA.js.map +0 -1
  428. package/dist/webpack-BOU7_xld.mjs.map +0 -1
  429. package/dist/withTokens-LRidu3Vc.js +0 -95
  430. package/dist/withTokens-LRidu3Vc.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # @fluentic/style
2
2
 
3
+ ## 0.1.0-beta.5
4
+
5
+ ### Patch Changes
6
+
7
+ - Add attachable selector sheets for styling fixed third-party class names
8
+ without emitting global CSS.
9
+
10
+ - Add `style.selector(...)` selector targets and `createSheet(...)` from
11
+ `@fluentic/style/css` for manual selector rules that still attach through
12
+ generated Fluentic classes.
13
+ - Support selector overrides and token overrides inside sheets so component
14
+ wrappers can expose local third-party themes with the same shape as
15
+ scoped style composition.
16
+ - Add `&` and `&?` selector handling for attached-element and portal-friendly
17
+ selector rules. Comma-separated selector strings are rejected; pass an
18
+ array when a rule should target multiple selectors.
19
+ - Add `createStyleTarget(...)` for applying style props to explicit DOM
20
+ targets such as `document.body`, with shared-target reference counting for
21
+ overlapping portal users.
22
+ - Make `combineStyle(...)` compose sheets directly, and add
23
+ `combineStyle.with(...)` plus array-only `combineStyle.multi(...)` for
24
+ cache-friendly style and sheet composition.
25
+ - Support selector sheet extraction, local token overrides, debug class
26
+ names, source tracing, and sourcemap data across runtime and extracted
27
+ builds.
28
+ - Add Preact css-prop support with a `CssPropPresets.Preact` compiler
29
+ preset, runtime adapters, JSX types, and a Vite example.
30
+ - Keep plugin css-prop configuration focused on `CssPropPresets` instead of
31
+ exporting each framework preset as a separate top-level plugin API.
32
+ - Add `style.important(...)` and `className.important(...)` for interop cases
33
+ that need emitted `!important` declarations, especially selector sheets
34
+ wrapping third-party CSS.
35
+ - Add `style.weight(...)` as the style-object counterpart to
36
+ `className.weight(...)`.
37
+ - Keep the extracted production runtime below 5 KB minified and gzipped with
38
+ `combineStyle` included, and keep selector parsing helpers out of the
39
+ extracted production entry.
40
+ - Add a React Select third-party selectors example, Preact integration docs,
41
+ and a clearer third-party styling guide for selector sheets, style targets,
42
+ portal menus, and the new `combineStyle` helpers.
43
+
44
+ ## 0.1.0-beta.4
45
+
46
+ ### Patch Changes
47
+
48
+ - Slim the extracted production runtime token path and fix named token refs in token-bound extracted styles.
49
+
50
+ - Keep token symbols, guards, naming, and extracted token helpers in builder/runtime internals instead of the public style token surface.
51
+ - Split extracted combine, token resolution, CSS variable, scope, and debug config helpers so extracted builds retain less eager runtime code.
52
+ - Make named tokens carry their extracted CSS variable name so production token bindings can reference named token values without compiler metadata errors.
53
+ - Hide manual stable ids from the public token and theme factory types while preserving internal compiler-provided identities.
54
+ - Add snapshot and runtime contract coverage for createToken, createTokens, createValues, createTheme, scopes, bindScope, combineStyle, and named-token refs in extracted output.
55
+ - Keep the Parcel optimizer on Node's `Buffer` import path and declare the Parcel example polyfill dependency so workspace builds do not rely on Parcel auto-install.
56
+
3
57
  ## 0.1.0-beta.3
4
58
 
5
59
  ### Patch Changes
@@ -14,7 +68,7 @@ for transform-driven styling.
14
68
  ### Highlights
15
69
 
16
70
  - Add `createClassNameFn` for class-name-driven style builders.
17
- - Support nested class-name values, conditional falsey entries, weighted
71
+ - Support nested class-name values, conditional falsy entries, weighted
18
72
  class-name tokens, selector chaining, at-rules, and merges.
19
73
  - Add compiler extraction for class-name style chains.
20
74
  - Add Tailwind presets for both style-object and class-name authoring.
package/README.md CHANGED
@@ -1,17 +1,18 @@
1
1
  # Fluentic Style
2
2
 
3
- Component style composition for React.
3
+ Build your own styling language on top of a stable JSX styling model.
4
4
 
5
- React styling has a lot of good answers already: CSS files, utility classes,
5
+ Styling JSX apps has a lot of good answers already: CSS files, utility classes,
6
6
  CSS-in-JS, compiled CSS, design tokens, and component libraries. Fluentic
7
7
  explores a specific question inside that space: what if styles composed around
8
- React components the same way props and state do?
8
+ components the same way props and state do?
9
9
 
10
10
  With Fluentic, you start simple with type-safe `style(...)` and the JSX `css`
11
- prop. If your team prefers utility class names, you can also create class-name
12
- style chains, including a Tailwind-like preset. When a component needs variants,
13
- themes, nested parts, or consumer overrides, add slots, scopes, tokens, and
14
- `combineStyle(...)` so those styles stay organized around the component.
11
+ prop in React, Preact, Solid, and compatible JSX runtimes. If your team prefers
12
+ utility class names, you can also create class-name style chains, including a
13
+ Tailwind-like preset. When a component needs variants, themes, nested parts, or
14
+ consumer overrides, add slots, scopes, tokens, and `combineStyle(...)` so those
15
+ styles stay organized around the component.
15
16
 
16
17
  For production builds, styles are extracted into static atomic CSS output.
17
18
  Dynamic values from props and state still work as usual.
@@ -35,7 +36,7 @@ Or with pnpm:
35
36
  pnpm add @fluentic/style@beta
36
37
  ```
37
38
 
38
- Use Fluentic in a React app. Add a bundler plugin later when you want production
39
+ Use Fluentic in a JSX app. Add a bundler plugin later when you want production
39
40
  extraction.
40
41
 
41
42
  ## Configure Runtime JSX
@@ -380,7 +381,7 @@ production builds. Current benchmark snapshots:
380
381
  The main production checks are runtime cost and bundle size. In the production
381
382
  path most apps use, Fluentic extracts CSS at build time and ships the extracted
382
383
  production runtime for `css` prop composition, dynamic values, class-name
383
- merging, and token resolution. That runtime entry currently reports `5.00 KB`
384
+ merging, and token resolution. That runtime entry currently reports `4.92 KB`
384
385
  min+gzip.
385
386
  Browser and SSR benchmarks track whether style resolution stays fast in
386
387
  app-shaped renders. See the
@@ -1,17 +1,19 @@
1
1
  import type { BuilderCallsite, ItemSelector } from '../builder/data';
2
2
  import { CSS_CONFIG } from '../config/config/css';
3
3
  import { DEV_CONFIG } from '../config/config/dev';
4
- import type { ClassNameFormat, ScopeClassNameFormat, TransformClassNameFormat } from '../config/types';
4
+ import type { ClassNameFormat, TransformClassNameFormat } from '../config/types';
5
5
  import { hashString } from '../utils/hash';
6
- import { getDebugClassName, getDebugScopeClassName, getDebugTransformClassName } from './debug/className';
6
+ import { getDebugClassName, getDebugSheetClassName, getDebugTransformClassName } from './debug/className';
7
7
  import { getDebugPropertyName } from './debug/property';
8
8
  import { getDebugAtRuleName, getDebugSelectorName } from './debug/selector';
9
+ export { getScopeClassName } from './scope';
9
10
  import { getIdentifierSafeHash } from './utils/hash';
10
- import { getSelectorHash, getSelectorText } from './utils/selector';
11
+ import { getSelectorHash, getSelectorText, hasSheetSelectorAnchor } from './utils/selector';
11
12
 
12
13
  export function getAtomicClassName(
13
14
  property: string,
14
15
  priority: number | null,
16
+ important: boolean,
15
17
  value: string,
16
18
  selector: ItemSelector | null,
17
19
  parentSelector: ItemSelector | null,
@@ -22,11 +24,13 @@ export function getAtomicClassName(
22
24
  classNameFormat: ClassNameFormat | null,
23
25
  transformClassName: string | null,
24
26
  transformClassNameFormat: TransformClassNameFormat | null,
27
+ sheetClassNameFormat: ClassNameFormat | null = null,
25
28
  hashLength: number | null = null,
26
29
  ) {
27
30
  let hash = property;
28
31
 
29
32
  hash += '\n' + (priority || '');
33
+ if (important) hash += '\nimportant';
30
34
  hash += '\n' + value;
31
35
  hash += '\n' + (selector ? getSelectorHash(selector) : '');
32
36
  hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
@@ -50,8 +54,9 @@ export function getAtomicClassName(
50
54
 
51
55
  const propertyName = getDebugPropertyName(property, value);
52
56
 
53
- const className = getDebugClassName(
54
- classNameFormat,
57
+ const isSheetClassName = hasSheetSelectorAnchor(selector);
58
+ const className = (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(
59
+ isSheetClassName ? sheetClassNameFormat : classNameFormat,
55
60
  hash,
56
61
  {
57
62
  atRule: atRule
@@ -80,16 +85,10 @@ function getRuntimeClassNameHashLength(debugClassName: boolean) {
80
85
  return CSS_CONFIG.hashLength ?? 7;
81
86
  }
82
87
 
83
- export function getScopeClassName(
84
- className: string,
85
- scopeClassNameFormat: ScopeClassNameFormat | null,
86
- ) {
87
- return getDebugScopeClassName(scopeClassNameFormat, { className });
88
- }
89
-
90
88
  export function getClassNameDedupe(
91
89
  property: string,
92
90
  priority: number | null,
91
+ important: boolean,
93
92
  selector: ItemSelector | null,
94
93
  parentSelector: ItemSelector | null,
95
94
  atRule: ItemSelector[] | null,
@@ -97,6 +96,7 @@ export function getClassNameDedupe(
97
96
  let hash = property;
98
97
 
99
98
  hash += '\n' + (priority || '');
99
+ if (important) hash += '\nimportant';
100
100
  hash += '\n' + (selector ? getSelectorHash(selector) : '');
101
101
  hash += '\n' + (parentSelector ? getSelectorHash(parentSelector) : '');
102
102
  hash += '\n' + (atRule ? atRule.map(getSelectorHash).join('\n') : '');
@@ -1,8 +1,6 @@
1
1
  import type {
2
2
  ClassNameFormat,
3
3
  ClassNameInfo,
4
- ScopeClassNameFormat,
5
- ScopeClassNameInfo,
6
4
  TransformClassNameFormat,
7
5
  TransformClassNameInfo,
8
6
  } from '../../../config/types';
@@ -10,9 +8,9 @@ import { createNameFormatter } from '../../utils/format';
10
8
 
11
9
  export const CLASS_NAME_FORMAT = '[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash';
12
10
 
13
- export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
11
+ export const SHEET_CLASS_NAME_FORMAT = 'sheet-(property)[-(value)]--$hash';
14
12
 
15
- export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
13
+ export const TRANSFORM_CLASS_NAME_FORMAT = '(className)--$hash';
16
14
 
17
15
  export const formatClassName = createNameFormatter<ClassNameInfo>([
18
16
  'atRule',
@@ -22,10 +20,6 @@ export const formatClassName = createNameFormatter<ClassNameInfo>([
22
20
  'value',
23
21
  ]);
24
22
 
25
- export const formatScopeClassName = createNameFormatter<ScopeClassNameInfo>([
26
- 'className',
27
- ]);
28
-
29
23
  export const formatTransformClassName = createNameFormatter<TransformClassNameInfo>([
30
24
  'className',
31
25
  ]);
@@ -38,6 +32,14 @@ export function getDebugClassName(
38
32
  return formatClassName(format || CLASS_NAME_FORMAT, hash, info);
39
33
  }
40
34
 
35
+ export function getDebugSheetClassName(
36
+ format: ClassNameFormat | null,
37
+ hash: string,
38
+ info: ClassNameInfo,
39
+ ) {
40
+ return formatClassName(format || SHEET_CLASS_NAME_FORMAT, hash, info);
41
+ }
42
+
41
43
  export function getDebugTransformClassName(
42
44
  format: TransformClassNameFormat | null,
43
45
  hash: string,
@@ -45,10 +47,3 @@ export function getDebugTransformClassName(
45
47
  ) {
46
48
  return formatTransformClassName(format || TRANSFORM_CLASS_NAME_FORMAT, hash, info);
47
49
  }
48
-
49
- export function getDebugScopeClassName(
50
- format: ScopeClassNameFormat | null,
51
- info: ScopeClassNameInfo,
52
- ) {
53
- return formatScopeClassName(format || SCOPE_CLASS_NAME_FORMAT, null, info);
54
- }
package/atomic/element.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CSS_CONFIG } from '../config/config/css';
2
2
  import { DEV_CONFIG } from '../config/config/dev';
3
3
  import type { ElementClassNameFormat, ElementClassNameInfo } from '../config/types';
4
- import { escapeCssIdent } from './utils/css';
4
+ import { escapeCssIdent } from './utils/cssIdent';
5
5
  import { sanitizeDebugName } from './utils/debug';
6
6
  import { createNameFormatter } from './utils/format';
7
7
  import { getIdentifierSafeHash } from './utils/hash';
package/atomic/rule.ts CHANGED
@@ -1,26 +1,29 @@
1
1
  import type { ItemSelector } from '../builder/data/state';
2
2
  import type { ScopeClassNameFormat } from '../config/types';
3
- import { getScopeClassName } from './className';
4
3
  import { LayerMediaPriorities, type LayerPriority, LayerSelectorPriorities } from './layer';
5
4
  import { getCssPropertyName, getPropertyPriority } from './property';
6
- import { escapeCssIdent } from './utils/css';
7
- import { getSelectorPriority, getSelectorText } from './utils/selector';
5
+ import { getScopeClassName } from './scope';
6
+ import { escapeCssIdent } from './utils/cssIdent';
7
+ import { getSelectorPriority, getSelectorText, hasSheetSelectorAnchor } from './utils/selector';
8
8
  import { getCssPropertyValue } from './value';
9
9
 
10
10
  export function buildAtomicRule(
11
11
  className: string,
12
12
  property: string,
13
13
  value: string,
14
+ important: boolean,
14
15
  selector: ItemSelector | null,
15
16
  parentSelector: ItemSelector | null,
16
17
  atRules: ItemSelector[] | null,
17
18
  scopeClassNameFormat: ScopeClassNameFormat | null,
18
19
  ): string {
19
20
  const cssProp = getCssPropertyName(property);
20
- const cssValue = getCssPropertyValue(property, value);
21
+ const cssValue = getCssPropertyValue(property, value) + (important ? ' !important' : '');
21
22
  const escapedClass = escapeCssIdent(className);
22
23
 
23
- const classSelector = '.' + escapedClass;
24
+ const classSelector = hasSheetSelectorAnchor(selector)
25
+ ? `:where(.${escapedClass})`
26
+ : '.' + escapedClass;
24
27
  const itemSelector = selector ? getSelectorText(selector) : '';
25
28
 
26
29
  let selectorStr = classSelector + itemSelector;
@@ -0,0 +1,19 @@
1
+ import type { ScopeClassNameFormat, ScopeClassNameInfo } from '../config/types';
2
+
3
+ export const SCOPE_CLASS_NAME_FORMAT = '-(className)';
4
+
5
+ export function getScopeClassName(
6
+ className: string,
7
+ scopeClassNameFormat: ScopeClassNameFormat | null,
8
+ ) {
9
+ return formatScopeClassName(scopeClassNameFormat || SCOPE_CLASS_NAME_FORMAT, { className });
10
+ }
11
+
12
+ function formatScopeClassName(
13
+ format: ScopeClassNameFormat,
14
+ info: ScopeClassNameInfo,
15
+ ) {
16
+ if (typeof format === 'function') return format(info);
17
+
18
+ return format.replace(/\[|\]/g, '').replace(/\(className\)/g, info.className);
19
+ }
package/atomic/theme.ts CHANGED
@@ -2,7 +2,8 @@ import { CSS_CONFIG } from '../config/config/css';
2
2
  import type { ThemeNameFormat, ThemeNameInfo, TokenNameFormat } from '../config/types';
3
3
  import type { StyleTokenOverride } from '../style/token';
4
4
  import { getTokenOverrideValue, getTokenVarName } from './token';
5
- import { escapeCssIdent, escapeCssValue } from './utils/css';
5
+ import { escapeCssIdent } from './utils/cssIdent';
6
+ import { escapeCssValue } from './utils/cssVar';
6
7
  import { createNameFormatter } from './utils/format';
7
8
  import { getIdentifierSafeHash } from './utils/hash';
8
9
 
@@ -18,7 +19,7 @@ export function createThemeClassName(
18
19
  return formatThemeName(
19
20
  themeNameFormat || THEME_NAME_FORMAT,
20
21
  getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
21
- { name },
22
+ { name: normalizeThemeName(name) },
22
23
  );
23
24
  }
24
25
 
@@ -48,3 +49,41 @@ function getThemeDeclaration(
48
49
 
49
50
  return name + ':' + value;
50
51
  }
52
+
53
+ export function normalizeThemeName(value: string | null | undefined): string | null {
54
+ if (!value) return null;
55
+
56
+ value = value.trim();
57
+ if (!value) return null;
58
+ if (/^\d+$/.test(value)) return null;
59
+ if (isGeneratedNameHash(value)) return null;
60
+
61
+ const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
62
+ if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) {
63
+ return normalizeThemeName(stableSuffix[1]);
64
+ }
65
+
66
+ value = stripGenericThemePrefix(value);
67
+ if (!value) return null;
68
+
69
+ return value;
70
+ }
71
+
72
+ function stripGenericThemePrefix(value: string) {
73
+ const parts = value.split('--');
74
+
75
+ while (parts[0] === 'theme' || parts[0] === 'themes') {
76
+ parts.shift();
77
+ }
78
+
79
+ value = parts.join('--');
80
+
81
+ if (value.startsWith('theme-')) return value.slice('theme-'.length);
82
+ if (value.startsWith('themes-')) return value.slice('themes-'.length);
83
+
84
+ return value;
85
+ }
86
+
87
+ function isGeneratedNameHash(value: string) {
88
+ return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
89
+ }
package/atomic/token.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { CSS_CONFIG } from '../config/config/css';
2
2
  import type { TokenNameFormat, TokenNameInfo } from '../config/types';
3
- import { getStyleTokenId, type StyleTokenData, type StyleTokenOverride } from '../style/token';
4
- import { getCssVar, getCssVarRawFallback } from './utils/css';
3
+ import { getStyleTokenId, getStyleTokenName, type StyleTokenData, type StyleTokenOverride } from '../style/token';
4
+ import { getCssVar, getCssVarRawFallback } from './utils/cssVar';
5
5
  import { createNameFormatter } from './utils/format';
6
6
  import { getIdentifierSafeHash } from './utils/hash';
7
7
 
@@ -14,11 +14,12 @@ export function getTokenVarName(
14
14
  format: TokenNameFormat | null,
15
15
  ) {
16
16
  const id = getStyleTokenId(token);
17
+ const debugName = getStyleTokenName(token);
17
18
 
18
19
  const name = formatTokenName(
19
20
  format || TOKEN_NAME_FORMAT,
20
21
  getIdentifierSafeHash(id, CSS_CONFIG.hashLength),
21
- { name: id },
22
+ { name: debugName },
22
23
  );
23
24
 
24
25
  return '--' + name;
@@ -1,23 +1,3 @@
1
- export function getCssVar(varName: string, value: string) {
2
- return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
3
- }
4
-
5
- export function getCssVarRawFallback(varName: string, fallbackCss: string) {
6
- return 'var(' + varName + ', ' + fallbackCss + ')';
7
- }
8
-
9
- export function escapeCssValue(value: string): string {
10
- if (!value) return '';
11
-
12
- return value
13
- .trim()
14
- // Escape existing backslashes first so we don't break them.
15
- .replace(/\\/g, '\\\\')
16
- .replace(/"/g, '\\"')
17
- .replace(/'/g, "\\'")
18
- .replace(/;/g, '\\;');
19
- }
20
-
21
1
  export function escapeCssIdent(ident: string): string {
22
2
  let result = '';
23
3
 
@@ -0,0 +1,19 @@
1
+ export function getCssVar(varName: string, value: string) {
2
+ return 'var(' + varName + ', ' + escapeCssValue(value) + ')';
3
+ }
4
+
5
+ export function getCssVarRawFallback(varName: string, fallbackCss: string) {
6
+ return 'var(' + varName + ', ' + fallbackCss + ')';
7
+ }
8
+
9
+ export function escapeCssValue(value: string): string {
10
+ if (!value) return '';
11
+
12
+ return value
13
+ .trim()
14
+ // Escape existing backslashes first so we don't break them.
15
+ .replace(/\\/g, '\\\\')
16
+ .replace(/"/g, '\\"')
17
+ .replace(/'/g, "\\'")
18
+ .replace(/;/g, '\\;');
19
+ }
@@ -1,4 +1,4 @@
1
- import { sanitizeCssIdentName } from './css';
1
+ import { sanitizeCssIdentName } from './cssIdent';
2
2
 
3
3
  export function normalizeDebugKeywordValue(value: string) {
4
4
  const normalized = value.trim().toLowerCase();
@@ -1,7 +1,9 @@
1
+ import { SHEET_SELECTOR_ANCHOR } from '../../builder/data/const';
1
2
  import type { ItemSelector } from '../../builder/data/state';
2
3
 
3
4
  export function getSelectorText(selector: ItemSelector): string {
4
- return Array.isArray(selector) ? selector[0] : selector;
5
+ const text = Array.isArray(selector) ? selector[0] : selector;
6
+ return stripSheetSelectorAnchor(text);
5
7
  }
6
8
 
7
9
  export function getSelectorHash(selector: ItemSelector): string {
@@ -12,3 +14,14 @@ export function getSelectorPriority(selector: ItemSelector | null): number {
12
14
  if (!selector) return 0;
13
15
  return Array.isArray(selector) ? selector[1] : 0;
14
16
  }
17
+
18
+ export function hasSheetSelectorAnchor(selector: ItemSelector | null): boolean {
19
+ const text = selector ? Array.isArray(selector) ? selector[0] : selector : '';
20
+ return text.startsWith(SHEET_SELECTOR_ANCHOR);
21
+ }
22
+
23
+ function stripSheetSelectorAnchor(selector: string) {
24
+ return selector.startsWith(SHEET_SELECTOR_ANCHOR)
25
+ ? selector.slice(SHEET_SELECTOR_ANCHOR.length)
26
+ : selector;
27
+ }
@@ -1,7 +1,8 @@
1
1
  import { DEV_CONFIG } from '../../config/config/dev';
2
2
  import type { Selector } from '../../selector';
3
- import { type ClassNameTransform, classNameValue, isClassNameValue } from '../../style';
4
- import type { StyleValueTuple } from '../../style/types';
3
+ import { type ClassNameTransform, classNameValue, importantValue, isClassNameValue } from '../../style';
4
+ import { isStyleImportantValue } from '../../style/important';
5
+ import { isStyleWeightValue, weightValue } from '../../style/weight';
5
6
  import { traceMarker } from '../../utils/trace';
6
7
  import {
7
8
  createStyleData,
@@ -21,11 +22,19 @@ import { mergeStyleData } from '../style_data';
21
22
  import { createDefaultFnResult, createFns } from '../style_fns';
22
23
  import type { SelectorsRecord } from '../types';
23
24
  import { FnPrefixStyle, resolveCallsite } from '../utils';
24
- import type { ClassNameBuilder, ClassNameFn, ClassNameItem, ClassNameMergeData, WeightedClassName } from './types';
25
+ import type {
26
+ ClassNameBuilder,
27
+ ClassNameFn,
28
+ ClassNameItem,
29
+ ClassNameMergeData,
30
+ ImportantClassName,
31
+ WeightedClassName,
32
+ } from './types';
25
33
 
26
34
  type StyleRecord = Record<string, unknown>;
27
35
  type FlattenedClassName<ClassName extends string> = {
28
36
  className: ClassName;
37
+ important: boolean;
29
38
  weight: number | null;
30
39
  };
31
40
 
@@ -144,11 +153,11 @@ function createAtRuleFn<ClassName extends string>(
144
153
 
145
154
  let arg: string | readonly string[];
146
155
  let items: readonly ClassNameItem<ClassName>[];
147
- let priority: number | null = null;
156
+ let weight: number | null = null;
148
157
 
149
158
  if (hasArg) {
150
159
  if (isMedia && typeof withoutDebug[0] === 'number') {
151
- priority = withoutDebug[0];
160
+ weight = withoutDebug[0];
152
161
  arg = withoutDebug[1] as string | readonly string[];
153
162
  items = withoutDebug.slice(2) as readonly ClassNameItem<ClassName>[];
154
163
  } else {
@@ -156,7 +165,7 @@ function createAtRuleFn<ClassName extends string>(
156
165
  items = withoutDebug.slice(1) as readonly ClassNameItem<ClassName>[];
157
166
  }
158
167
  } else if (isMedia && typeof withoutDebug[0] === 'number') {
159
- priority = withoutDebug[0];
168
+ weight = withoutDebug[0];
160
169
  arg = fnSelector.selector;
161
170
  items = withoutDebug.slice(1) as readonly ClassNameItem<ClassName>[];
162
171
  } else {
@@ -187,7 +196,7 @@ function createAtRuleFn<ClassName extends string>(
187
196
  classNameStyle.style,
188
197
  classNameStyle.debug,
189
198
  null,
190
- [priority !== null ? [selector, priority] : selector],
199
+ [weight !== null ? [selector, weight] : selector],
191
200
  );
192
201
  }
193
202
 
@@ -321,8 +330,9 @@ function classNameItemsToStyle<ClassName extends string>(
321
330
  const weighted: StyleRecord = item.weight === null
322
331
  ? transformed
323
332
  : applyClassNameWeight(transformed, item.weight);
333
+ const nextStyle = item.important ? applyClassNameImportant(weighted) : weighted;
324
334
 
325
- style = style ? Object.assign({}, style, weighted) : weighted;
335
+ style = style ? Object.assign({}, style, nextStyle) : nextStyle;
326
336
 
327
337
  const loc = debug?.classNames?.[item.className];
328
338
  if (loc) {
@@ -359,20 +369,29 @@ function decorateClassNameStyle<ClassName extends string>(
359
369
  continue;
360
370
  }
361
371
 
362
- if (Array.isArray(value) && value.length === 2 && typeof value[0] === 'number') {
363
- const rawValue = (value as StyleValueTuple)[1];
364
- result[property] = isClassNameValue(rawValue)
365
- ? value
366
- : [(value as StyleValueTuple)[0], classNameValue(rawValue, className)];
367
- continue;
368
- }
369
-
370
- result[property] = isClassNameValue(value) ? value : classNameValue(value, className);
372
+ result[property] = decorateClassNameValue(value, className);
371
373
  }
372
374
 
373
375
  return result;
374
376
  }
375
377
 
378
+ function decorateClassNameValue<ClassName extends string>(
379
+ value: unknown,
380
+ className: ClassName,
381
+ ): unknown {
382
+ if (isClassNameValue(value)) return value;
383
+
384
+ if (isStyleImportantValue(value)) {
385
+ return importantValue(decorateClassNameValue(value.value, className));
386
+ }
387
+
388
+ if (isStyleWeightValue(value)) {
389
+ return weightValue(decorateClassNameValue(value.value, className), value.weight);
390
+ }
391
+
392
+ return classNameValue(value, className);
393
+ }
394
+
376
395
  function flattenClassNameItems<ClassName extends string>(
377
396
  items: readonly ClassNameItem<ClassName>[],
378
397
  ): FlattenedClassName<ClassName>[] {
@@ -392,7 +411,7 @@ function collectClassNameItem<ClassName extends string>(
392
411
  if (!item) return;
393
412
 
394
413
  if (typeof item === 'string') {
395
- result.push({ className: item, weight: null });
414
+ result.push({ className: item, important: false, weight: null });
396
415
  return;
397
416
  }
398
417
 
@@ -402,7 +421,12 @@ function collectClassNameItem<ClassName extends string>(
402
421
  }
403
422
 
404
423
  if (isWeightedClassName(item)) {
405
- result.push(item);
424
+ result.push({ ...item, important: false });
425
+ return;
426
+ }
427
+
428
+ if (isImportantClassName(item)) {
429
+ result.push({ className: item.className, important: true, weight: null });
406
430
  }
407
431
  }
408
432
 
@@ -415,6 +439,15 @@ function isWeightedClassName<ClassName extends string>(
415
439
  return typeof weighted.className === 'string' && typeof weighted.weight === 'number';
416
440
  }
417
441
 
442
+ function isImportantClassName<ClassName extends string>(
443
+ item: unknown,
444
+ ): item is ImportantClassName<ClassName> {
445
+ if (!item || typeof item !== 'object') return false;
446
+
447
+ const important = item as Partial<ImportantClassName<ClassName>>;
448
+ return typeof important.className === 'string' && important.important === true;
449
+ }
450
+
418
451
  function applyClassNameWeight(
419
452
  style: StyleRecord,
420
453
  weight: number,
@@ -427,16 +460,27 @@ function applyClassNameWeight(
427
460
  continue;
428
461
  }
429
462
 
430
- const rawValue = Array.isArray(value) && value.length === 2 && typeof value[0] === 'number'
431
- ? value[1]
432
- : value;
433
-
434
- weighted[property] = [weight, rawValue];
463
+ weighted[property] = weightValue(value, weight);
435
464
  }
436
465
 
437
466
  return weighted;
438
467
  }
439
468
 
469
+ function applyClassNameImportant(style: StyleRecord): StyleRecord {
470
+ const important: StyleRecord = {};
471
+
472
+ for (const [property, value] of Object.entries(style)) {
473
+ if (value === null || value === undefined) {
474
+ important[property] = value;
475
+ continue;
476
+ }
477
+
478
+ important[property] = importantValue(value);
479
+ }
480
+
481
+ return important;
482
+ }
483
+
440
484
  function splitDebug<T>(
441
485
  params: readonly T[],
442
486
  ): [items: T[], debug: DebugData | undefined] {
@@ -29,11 +29,11 @@ type ClassNameAtRuleNoArgFn<ClassName extends string, Self> = {
29
29
  };
30
30
 
31
31
  type ClassNameMediaFn<ClassName extends string, Self, Arg> = ClassNameAtRuleFn<ClassName, Self, Arg> & {
32
- (priority: number, selector: Arg, ...items: ClassNameItems<ClassName>): Self;
32
+ (weight: number, selector: Arg, ...items: ClassNameItems<ClassName>): Self;
33
33
  };
34
34
 
35
35
  type ClassNameMediaNoArgFn<ClassName extends string, Self> = ClassNameAtRuleNoArgFn<ClassName, Self> & {
36
- (priority: number, ...items: ClassNameItems<ClassName>): Self;
36
+ (weight: number, ...items: ClassNameItems<ClassName>): Self;
37
37
  };
38
38
 
39
39
  type ClassNameAtRuleArgFn<ClassName extends string, Self, Arg extends string> = ClassNameAtRuleFn<ClassName, Self, Arg>;