@tenphi/tasty 0.0.0-snapshot.f0e2124 → 0.0.0-snapshot.f144f3c

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 (328) hide show
  1. package/README.md +372 -233
  2. package/dist/babel-Zs1Q03qt.d.ts +83 -0
  3. package/dist/chunks/async-storage-DKK-wTD4.js +44 -0
  4. package/dist/chunks/async-storage-DKK-wTD4.js.map +1 -0
  5. package/dist/chunks/build-config-fM2Tf2dv.js +45 -0
  6. package/dist/chunks/build-config-fM2Tf2dv.js.map +1 -0
  7. package/dist/chunks/collector-HR9noXq_.js +318 -0
  8. package/dist/chunks/collector-HR9noXq_.js.map +1 -0
  9. package/dist/chunks/config-engine-DabuZ55f.js +331 -0
  10. package/dist/chunks/config-engine-DabuZ55f.js.map +1 -0
  11. package/dist/chunks/css-definitions-z79zG4t4.js +1229 -0
  12. package/dist/chunks/css-definitions-z79zG4t4.js.map +1 -0
  13. package/dist/chunks/css-resources-Cyl_axbI.js +149 -0
  14. package/dist/chunks/css-resources-Cyl_axbI.js.map +1 -0
  15. package/dist/chunks/debug-FLjTrfFW.js +576 -0
  16. package/dist/chunks/debug-FLjTrfFW.js.map +1 -0
  17. package/dist/chunks/dsl-BVhxBy6V.js +1915 -0
  18. package/dist/chunks/dsl-BVhxBy6V.js.map +1 -0
  19. package/dist/chunks/hydration-CLdVKcH2.js +59 -0
  20. package/dist/chunks/hydration-CLdVKcH2.js.map +1 -0
  21. package/dist/chunks/react-runtime-v7wWFkFD.js +882 -0
  22. package/dist/chunks/react-runtime-v7wWFkFD.js.map +1 -0
  23. package/dist/chunks/runtime-engine-BYEGKOF1.js +3452 -0
  24. package/dist/chunks/runtime-engine-BYEGKOF1.js.map +1 -0
  25. package/dist/chunks/runtime-state-icjb9GAD.js +138 -0
  26. package/dist/chunks/runtime-state-icjb9GAD.js.map +1 -0
  27. package/dist/{utils/merge-styles.js → chunks/shared-utils-OIg0N_dp.js} +43 -6
  28. package/dist/chunks/shared-utils-OIg0N_dp.js.map +1 -0
  29. package/dist/chunks/style-engine-C34heV9d.js +6920 -0
  30. package/dist/chunks/style-engine-C34heV9d.js.map +1 -0
  31. package/dist/{zero/extractor.js → chunks/zero-engine-DkyjChVU.js} +188 -13
  32. package/dist/chunks/zero-engine-DkyjChVU.js.map +1 -0
  33. package/dist/collector-hl5KNH7k.d.ts +165 -0
  34. package/dist/config-DWL1ZYue.d.ts +1358 -0
  35. package/dist/core/index.d.ts +5 -33
  36. package/dist/core/index.js +9 -26
  37. package/dist/index-CYLgmbWy.d.ts +1971 -0
  38. package/dist/index.d.ts +5 -48
  39. package/dist/index.js +11 -33
  40. package/dist/{utils/merge-styles.d.ts → merge-styles-C_oMoJVd.d.ts} +3 -3
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +19 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +11 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +11 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +18 -0
  51. package/dist/ssr/astro-middleware-static.js +18 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +19 -0
  54. package/dist/ssr/astro-middleware.js +19 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +135 -0
  57. package/dist/ssr/astro.js +300 -0
  58. package/dist/ssr/astro.js.map +1 -0
  59. package/dist/ssr/index.d.ts +37 -0
  60. package/dist/ssr/index.js +10 -0
  61. package/dist/ssr/index.js.map +1 -0
  62. package/dist/ssr/next-config.d.ts +66 -0
  63. package/dist/ssr/next-config.js +135 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +52 -0
  66. package/dist/ssr/next.js +90 -0
  67. package/dist/ssr/next.js.map +1 -0
  68. package/dist/static/index.d.ts +91 -5
  69. package/dist/static/index.js +49 -4
  70. package/dist/static/index.js.map +1 -0
  71. package/dist/static/inject.d.ts +5 -0
  72. package/dist/static/inject.js +17 -0
  73. package/dist/static/inject.js.map +1 -0
  74. package/dist/types-jKZNpias.d.ts +1616 -0
  75. package/dist/zero/babel.d.ts +2 -113
  76. package/dist/zero/babel.js +237 -46
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +81 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +56 -30
  81. package/dist/zero/next.js +106 -41
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +323 -0
  85. package/docs/ai-agents.md +229 -0
  86. package/docs/comparison.md +448 -0
  87. package/docs/configuration.md +823 -0
  88. package/docs/debug.md +332 -0
  89. package/docs/design-system.md +455 -0
  90. package/docs/dsl.md +1021 -0
  91. package/docs/getting-started.md +238 -0
  92. package/docs/injector.md +634 -0
  93. package/docs/methodology.md +648 -0
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +741 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +681 -0
  98. package/docs/runtime-benchmarks.md +351 -0
  99. package/docs/ssr.md +610 -0
  100. package/docs/styles.md +677 -0
  101. package/docs/tasty-static.md +582 -0
  102. package/package.json +171 -47
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -70
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -260
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -61
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -288
  113. package/dist/config.js +0 -403
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  119. package/dist/hooks/useGlobalStyles.js +0 -56
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -54
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -91
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -28
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -40
  131. package/dist/hooks/useStyles.js +0 -169
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -157
  134. package/dist/injector/index.js +0 -154
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -139
  137. package/dist/injector/injector.js +0 -426
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -135
  140. package/dist/injector/sheet-manager.js +0 -728
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -319
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -660
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -844
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -438
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -371
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -69
  180. package/dist/properties/index.js +0 -237
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -83
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/states/index.d.ts +0 -49
  186. package/dist/states/index.js +0 -416
  187. package/dist/states/index.js.map +0 -1
  188. package/dist/static/tastyStatic.d.ts +0 -46
  189. package/dist/static/tastyStatic.js +0 -31
  190. package/dist/static/tastyStatic.js.map +0 -1
  191. package/dist/static/types.d.ts +0 -49
  192. package/dist/static/types.js +0 -24
  193. package/dist/static/types.js.map +0 -1
  194. package/dist/styles/align.d.ts +0 -15
  195. package/dist/styles/align.js +0 -14
  196. package/dist/styles/align.js.map +0 -1
  197. package/dist/styles/border.d.ts +0 -25
  198. package/dist/styles/border.js +0 -114
  199. package/dist/styles/border.js.map +0 -1
  200. package/dist/styles/color.d.ts +0 -14
  201. package/dist/styles/color.js +0 -23
  202. package/dist/styles/color.js.map +0 -1
  203. package/dist/styles/createStyle.js +0 -77
  204. package/dist/styles/createStyle.js.map +0 -1
  205. package/dist/styles/dimension.js +0 -97
  206. package/dist/styles/dimension.js.map +0 -1
  207. package/dist/styles/display.d.ts +0 -37
  208. package/dist/styles/display.js +0 -67
  209. package/dist/styles/display.js.map +0 -1
  210. package/dist/styles/fade.d.ts +0 -15
  211. package/dist/styles/fade.js +0 -58
  212. package/dist/styles/fade.js.map +0 -1
  213. package/dist/styles/fill.d.ts +0 -42
  214. package/dist/styles/fill.js +0 -52
  215. package/dist/styles/fill.js.map +0 -1
  216. package/dist/styles/flow.d.ts +0 -16
  217. package/dist/styles/flow.js +0 -12
  218. package/dist/styles/flow.js.map +0 -1
  219. package/dist/styles/gap.d.ts +0 -31
  220. package/dist/styles/gap.js +0 -37
  221. package/dist/styles/gap.js.map +0 -1
  222. package/dist/styles/height.d.ts +0 -17
  223. package/dist/styles/height.js +0 -20
  224. package/dist/styles/height.js.map +0 -1
  225. package/dist/styles/index.d.ts +0 -2
  226. package/dist/styles/index.js +0 -9
  227. package/dist/styles/index.js.map +0 -1
  228. package/dist/styles/inset.d.ts +0 -52
  229. package/dist/styles/inset.js +0 -150
  230. package/dist/styles/inset.js.map +0 -1
  231. package/dist/styles/justify.d.ts +0 -15
  232. package/dist/styles/justify.js +0 -14
  233. package/dist/styles/justify.js.map +0 -1
  234. package/dist/styles/list.d.ts +0 -16
  235. package/dist/styles/list.js +0 -98
  236. package/dist/styles/list.js.map +0 -1
  237. package/dist/styles/margin.d.ts +0 -24
  238. package/dist/styles/margin.js +0 -104
  239. package/dist/styles/margin.js.map +0 -1
  240. package/dist/styles/outline.d.ts +0 -29
  241. package/dist/styles/outline.js +0 -65
  242. package/dist/styles/outline.js.map +0 -1
  243. package/dist/styles/padding.d.ts +0 -24
  244. package/dist/styles/padding.js +0 -104
  245. package/dist/styles/padding.js.map +0 -1
  246. package/dist/styles/predefined.d.ts +0 -73
  247. package/dist/styles/predefined.js +0 -241
  248. package/dist/styles/predefined.js.map +0 -1
  249. package/dist/styles/preset.d.ts +0 -47
  250. package/dist/styles/preset.js +0 -126
  251. package/dist/styles/preset.js.map +0 -1
  252. package/dist/styles/radius.d.ts +0 -14
  253. package/dist/styles/radius.js +0 -51
  254. package/dist/styles/radius.js.map +0 -1
  255. package/dist/styles/scrollbar.d.ts +0 -21
  256. package/dist/styles/scrollbar.js +0 -112
  257. package/dist/styles/scrollbar.js.map +0 -1
  258. package/dist/styles/shadow.d.ts +0 -14
  259. package/dist/styles/shadow.js +0 -24
  260. package/dist/styles/shadow.js.map +0 -1
  261. package/dist/styles/styledScrollbar.d.ts +0 -47
  262. package/dist/styles/styledScrollbar.js +0 -38
  263. package/dist/styles/styledScrollbar.js.map +0 -1
  264. package/dist/styles/transition.d.ts +0 -14
  265. package/dist/styles/transition.js +0 -158
  266. package/dist/styles/transition.js.map +0 -1
  267. package/dist/styles/types.d.ts +0 -498
  268. package/dist/styles/width.d.ts +0 -17
  269. package/dist/styles/width.js +0 -20
  270. package/dist/styles/width.js.map +0 -1
  271. package/dist/tasty.d.ts +0 -982
  272. package/dist/tasty.js +0 -206
  273. package/dist/tasty.js.map +0 -1
  274. package/dist/tokens/typography.d.ts +0 -19
  275. package/dist/tokens/typography.js +0 -237
  276. package/dist/tokens/typography.js.map +0 -1
  277. package/dist/types.d.ts +0 -184
  278. package/dist/utils/cache-wrapper.js +0 -26
  279. package/dist/utils/cache-wrapper.js.map +0 -1
  280. package/dist/utils/case-converter.js +0 -8
  281. package/dist/utils/case-converter.js.map +0 -1
  282. package/dist/utils/colors.d.ts +0 -5
  283. package/dist/utils/colors.js +0 -9
  284. package/dist/utils/colors.js.map +0 -1
  285. package/dist/utils/css-types.d.ts +0 -7
  286. package/dist/utils/dotize.d.ts +0 -26
  287. package/dist/utils/dotize.js +0 -122
  288. package/dist/utils/dotize.js.map +0 -1
  289. package/dist/utils/filter-base-props.d.ts +0 -15
  290. package/dist/utils/filter-base-props.js +0 -45
  291. package/dist/utils/filter-base-props.js.map +0 -1
  292. package/dist/utils/get-display-name.d.ts +0 -7
  293. package/dist/utils/get-display-name.js +0 -10
  294. package/dist/utils/get-display-name.js.map +0 -1
  295. package/dist/utils/hsl-to-rgb.js +0 -38
  296. package/dist/utils/hsl-to-rgb.js.map +0 -1
  297. package/dist/utils/is-dev-env.js +0 -19
  298. package/dist/utils/is-dev-env.js.map +0 -1
  299. package/dist/utils/is-valid-element-type.js +0 -15
  300. package/dist/utils/is-valid-element-type.js.map +0 -1
  301. package/dist/utils/merge-styles.js.map +0 -1
  302. package/dist/utils/mod-attrs.d.ts +0 -8
  303. package/dist/utils/mod-attrs.js +0 -21
  304. package/dist/utils/mod-attrs.js.map +0 -1
  305. package/dist/utils/okhsl-to-rgb.js +0 -296
  306. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  307. package/dist/utils/process-tokens.d.ts +0 -31
  308. package/dist/utils/process-tokens.js +0 -171
  309. package/dist/utils/process-tokens.js.map +0 -1
  310. package/dist/utils/resolve-recipes.d.ts +0 -17
  311. package/dist/utils/resolve-recipes.js +0 -147
  312. package/dist/utils/resolve-recipes.js.map +0 -1
  313. package/dist/utils/string.js +0 -8
  314. package/dist/utils/string.js.map +0 -1
  315. package/dist/utils/styles.d.ts +0 -178
  316. package/dist/utils/styles.js +0 -751
  317. package/dist/utils/styles.js.map +0 -1
  318. package/dist/utils/typography.d.ts +0 -36
  319. package/dist/utils/typography.js +0 -53
  320. package/dist/utils/typography.js.map +0 -1
  321. package/dist/utils/warnings.d.ts +0 -16
  322. package/dist/utils/warnings.js +0 -16
  323. package/dist/utils/warnings.js.map +0 -1
  324. package/dist/zero/css-writer.d.ts +0 -45
  325. package/dist/zero/css-writer.js +0 -74
  326. package/dist/zero/css-writer.js.map +0 -1
  327. package/dist/zero/extractor.d.ts +0 -24
  328. package/dist/zero/extractor.js.map +0 -1
@@ -0,0 +1,882 @@
1
+ import { n as isSelector, t as mergeStyles } from "./shared-utils-OIg0N_dp.js";
2
+ import { D as makeKeyframeName, E as makeCounterStyleName, U as parseFunctionName, V as formatFunctionRule, W as registerFunctionPolyfill, a as formatPropertyCSS, b as formatFontFaceRule, h as formatCounterStyleRule, i as formatKeyframesCSS, j as hashString, n as formatGlobalRules, v as fontFaceContentHash } from "./css-definitions-z79zG4t4.js";
3
+ import { U as isFunctionsPolyfillEnabled, b as renderStyles, i as baseStylePropsRegistry, s as BASE_STYLES } from "./style-engine-C34heV9d.js";
4
+ import { $ as propHandlerRegistry, B as getNamePrefix, E as injectRawCSS, I as getConfig, J as closeBatchWindow, L as getGlobalInjector, M as touch, T as injectGlobal, Z as openBatchWindow, c as hasKeys, d as getStyleTarget, f as pushRSCCSS, i as _modAttrs, k as keyframes, l as collectAutoInferredProperties, n as createClientState, o as computeStyles, r as processTokens, s as resolveRecipes, t as depsEqual, u as collectAutoInferredPropertiesRSC } from "./runtime-engine-BYEGKOF1.js";
5
+ import { Fragment, createContext, createElement, forwardRef, useContext, useInsertionEffect } from "react";
6
+ //#region src/utils/get-display-name.ts
7
+ const DEFAULT_NAME = "Anonymous";
8
+ function getDisplayName(Component, fallbackName = DEFAULT_NAME) {
9
+ if (typeof Component === "function") return Component.displayName ?? Component.name ?? fallbackName;
10
+ return fallbackName;
11
+ }
12
+ //#endregion
13
+ //#region src/utils/is-valid-element-type.ts
14
+ /**
15
+ * Lightweight replacement for `react-is`'s isValidElementType.
16
+ * Detects string tags, function/class components, and React exotic types
17
+ * (forwardRef, memo, lazy, etc.) via their internal $$typeof symbol.
18
+ */
19
+ function isValidElementType(value) {
20
+ if (typeof value === "string" || typeof value === "function") return true;
21
+ if (typeof value === "object" && value !== null) return typeof value.$$typeof === "symbol";
22
+ return false;
23
+ }
24
+ //#endregion
25
+ //#region src/tasty.tsx
26
+ /** is* properties and their corresponding HTML attributes. */
27
+ const IS_PROPERTIES = [
28
+ ["isDisabled", "disabled"],
29
+ ["isHidden", "hidden"],
30
+ ["isChecked", "checked"]
31
+ ];
32
+ /**
33
+ * Helper function to handle is* properties consistently
34
+ * Transforms is* props to HTML attributes and adds corresponding data-* attributes
35
+ */
36
+ function handleIsProperties(props) {
37
+ for (const [isProperty, targetAttribute] of IS_PROPERTIES) {
38
+ if (isProperty in props) {
39
+ props[targetAttribute] = props[isProperty];
40
+ delete props[isProperty];
41
+ }
42
+ const dataAttribute = `data-${targetAttribute}`;
43
+ if (!(dataAttribute in props) && props[targetAttribute]) props[dataAttribute] = "";
44
+ }
45
+ }
46
+ /**
47
+ * Creates a sub-element component for compound component patterns.
48
+ * Sub-elements are lightweight components with data-element attribute for CSS targeting.
49
+ */
50
+ function createSubElement(elementName, definition) {
51
+ const config = typeof definition === "string" ? { as: definition } : definition;
52
+ const tag = config.as ?? "div";
53
+ const defaultQa = config.qa;
54
+ const defaultQaVal = config.qaVal;
55
+ const SubElement = forwardRef((props, ref) => {
56
+ const { qa, qaVal, mods, tokens, isDisabled, isHidden, isChecked, className, style, ...htmlProps } = props;
57
+ let modDataAttrs;
58
+ if (mods) modDataAttrs = _modAttrs(mods);
59
+ const tokenStyle = tokens ? processTokens(tokens) : void 0;
60
+ let mergedStyle;
61
+ if (tokenStyle || style) mergedStyle = tokenStyle && style ? {
62
+ ...tokenStyle,
63
+ ...style
64
+ } : tokenStyle ?? style;
65
+ const elementProps = {
66
+ "data-element": elementName,
67
+ "data-qa": qa ?? defaultQa,
68
+ "data-qaval": qaVal ?? defaultQaVal,
69
+ ...modDataAttrs || {},
70
+ ...htmlProps,
71
+ className,
72
+ style: mergedStyle,
73
+ isDisabled,
74
+ isHidden,
75
+ isChecked,
76
+ ref
77
+ };
78
+ handleIsProperties(elementProps);
79
+ if (elementProps["data-qa"] === void 0) delete elementProps["data-qa"];
80
+ if (elementProps["data-qaval"] === void 0) delete elementProps["data-qaval"];
81
+ return createElement(tag, elementProps);
82
+ });
83
+ SubElement.displayName = `SubElement(${elementName})`;
84
+ return SubElement;
85
+ }
86
+ /**
87
+ * Pre-compute the mapping from prop name to token key at component-creation time.
88
+ * Array form: `'progress'` -> `'$progress'`, `'accentColor'` -> `'#accent'`.
89
+ * Object form: entries used as-is.
90
+ */
91
+ function buildTokenPropsMapping(def) {
92
+ if (Array.isArray(def)) return def.map((propName) => {
93
+ if (propName.endsWith("Color") && propName.length > 5) return [propName, `#${propName.slice(0, -5)}`];
94
+ return [propName, `$${propName}`];
95
+ });
96
+ return Object.entries(def);
97
+ }
98
+ function tasty(Component, options) {
99
+ if (isValidElementType(Component)) return tastyWrap(Component, options);
100
+ return tastyElement(Component);
101
+ }
102
+ function tastyWrap(Component, options) {
103
+ const { as: extendTag, element: extendElement, styleProps: _styleProps, modProps: _modProps, tokenProps: _tokenProps, variants: _variants, elements: _elements, ...defaultProps } = options ?? {};
104
+ const propsWithStyles = ["styles"];
105
+ for (const prop of Object.keys(defaultProps)) if (prop.endsWith("Styles")) propsWithStyles.push(prop);
106
+ const _WrappedComponent = forwardRef((props, ref) => {
107
+ const { as, element, ...restProps } = props;
108
+ const mergedStylesMap = {};
109
+ for (const prop of propsWithStyles) {
110
+ const restValue = restProps[prop];
111
+ const defaultValue = defaultProps[prop];
112
+ mergedStylesMap[prop] = restValue != null && defaultValue != null ? mergeStyles(defaultValue, restValue) : restValue ?? defaultValue;
113
+ }
114
+ return createElement(Component, {
115
+ ...defaultProps,
116
+ ...restProps,
117
+ ...mergedStylesMap,
118
+ as: as ?? extendTag,
119
+ element: element || extendElement,
120
+ ref
121
+ });
122
+ });
123
+ _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(Component, defaultProps.qa ?? extendTag ?? "Anonymous")})`;
124
+ return _WrappedComponent;
125
+ }
126
+ function tastyElement(tastyOptions) {
127
+ const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
128
+ let variantStylesMap;
129
+ if (variants) {
130
+ let baseStyles = defaultStyles;
131
+ let extensionStyles;
132
+ if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
133
+ if (isSelector(key)) continue;
134
+ const value = defaultStyles[key];
135
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
136
+ if (!extensionStyles) {
137
+ baseStyles = { ...defaultStyles };
138
+ extensionStyles = {};
139
+ }
140
+ extensionStyles[key] = value;
141
+ delete baseStyles[key];
142
+ }
143
+ }
144
+ variantStylesMap = {};
145
+ for (const [variant, variantStyles] of Object.entries(variants)) variantStylesMap[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
146
+ if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
147
+ }
148
+ const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps;
149
+ const ownPropsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
150
+ let propsToCheck = ownPropsToCheck;
151
+ let propsToCheckVersion = -1;
152
+ const modPropsKeys = modPropsDef ? Array.isArray(modPropsDef) ? modPropsDef : Object.keys(modPropsDef) : void 0;
153
+ const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
154
+ const classNameCache = /* @__PURE__ */ new Map();
155
+ const STABLE_STYLES = { stableStyles: true };
156
+ const _TastyComponent = forwardRef((incomingProps, ref) => {
157
+ const applyPropHandlers = propHandlerRegistry.apply;
158
+ const { as, styles: rawStyles, variant, mods, element, qa, qaVal, className: userClassName, tokens, style, theme, ...otherProps } = applyPropHandlers ? applyPropHandlers(incomingProps) : incomingProps;
159
+ const styles = rawStyles;
160
+ let propStyles = null;
161
+ if (propsToCheckVersion !== baseStylePropsRegistry.version) {
162
+ const promoted = baseStylePropsRegistry.list;
163
+ propsToCheck = promoted.length === 0 ? ownPropsToCheck : ownPropsToCheck.concat(promoted);
164
+ propsToCheckVersion = baseStylePropsRegistry.version;
165
+ }
166
+ for (const prop of propsToCheck) {
167
+ const key = prop;
168
+ if (key in otherProps) {
169
+ if (!propStyles) propStyles = {};
170
+ const value = otherProps[key];
171
+ propStyles[key] = value;
172
+ delete otherProps[key];
173
+ }
174
+ }
175
+ let propMods;
176
+ if (modPropsKeys) {
177
+ for (const key of modPropsKeys) if (key in otherProps) {
178
+ if (!propMods) propMods = {};
179
+ propMods[key] = otherProps[key];
180
+ delete otherProps[key];
181
+ }
182
+ }
183
+ let propTokens;
184
+ if (tokenPropsMapping) {
185
+ for (const [propName, tokenKey] of tokenPropsMapping) if (propName in otherProps) {
186
+ if (!propTokens) propTokens = {};
187
+ propTokens[tokenKey] = otherProps[propName];
188
+ delete otherProps[propName];
189
+ }
190
+ }
191
+ const baseStyles = variantStylesMap ? variantStylesMap[variant || "default"] ?? variantStylesMap["default"] : defaultStyles;
192
+ const allStyles = styles && hasKeys(styles) || !!propStyles ? mergeStyles(baseStyles, styles, propStyles) : baseStyles;
193
+ const useFactoryCache = typeof document !== "undefined";
194
+ let stylesResult;
195
+ if (useFactoryCache && allStyles === baseStyles && classNameCache.has(allStyles)) {
196
+ stylesResult = { className: classNameCache.get(allStyles) };
197
+ touch(stylesResult.className);
198
+ } else {
199
+ stylesResult = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES : void 0);
200
+ if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, stylesResult.className);
201
+ }
202
+ let mergedTokens;
203
+ if (defaultTokens || tokens || propTokens) if (!defaultTokens && !propTokens) mergedTokens = tokens;
204
+ else if (!tokens && !propTokens) mergedTokens = defaultTokens;
205
+ else mergedTokens = {
206
+ ...defaultTokens,
207
+ ...tokens,
208
+ ...propTokens
209
+ };
210
+ const processedTokenStyle = processTokens(mergedTokens);
211
+ let mergedStyle;
212
+ if (processedTokenStyle || style) if (!processedTokenStyle) mergedStyle = style;
213
+ else if (!style) mergedStyle = processedTokenStyle;
214
+ else mergedStyle = {
215
+ ...processedTokenStyle,
216
+ ...style
217
+ };
218
+ const mergedMods = propMods ? {
219
+ ...mods,
220
+ ...propMods
221
+ } : mods;
222
+ let modDataAttrs;
223
+ if (mergedMods) modDataAttrs = _modAttrs(mergedMods);
224
+ const finalClassName = [userClassName || "", stylesResult.className].filter(Boolean).join(" ");
225
+ const elementProps = {
226
+ "data-element": element || defaultElement,
227
+ "data-qa": qa || defaultQa,
228
+ "data-qaval": qaVal || defaultQaVal,
229
+ "data-theme": theme,
230
+ ...otherDefaultProps,
231
+ ...modDataAttrs || {},
232
+ ...otherProps,
233
+ className: finalClassName,
234
+ style: mergedStyle,
235
+ ref
236
+ };
237
+ handleIsProperties(elementProps);
238
+ if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
239
+ const el = createElement(as ?? originalAs, elementProps);
240
+ if (stylesResult.css) {
241
+ const nonce = getConfig().nonce;
242
+ return createElement(Fragment, null, createElement("style", {
243
+ "data-tasty-rsc": "",
244
+ nonce,
245
+ dangerouslySetInnerHTML: { __html: stylesResult.css }
246
+ }), el);
247
+ }
248
+ return el;
249
+ });
250
+ _TastyComponent.displayName = `TastyComponent(${defaultProps.qa || originalAs})`;
251
+ if (elements) {
252
+ const subElements = {};
253
+ for (const [name, definition] of Object.entries(elements)) subElements[name] = createSubElement(name, definition);
254
+ return Object.assign(_TastyComponent, subElements);
255
+ }
256
+ return _TastyComponent;
257
+ }
258
+ const Element = /* @__PURE__ */ tasty({});
259
+ //#endregion
260
+ //#region src/ssr/context.ts
261
+ /**
262
+ * React context for SSR collector discovery.
263
+ *
264
+ * Used by Next.js TastyRegistry to provide the ServerStyleCollector
265
+ * to useStyles() via React context (the streaming-compatible path).
266
+ *
267
+ * This avoids relying on globalThis for cross-layer communication,
268
+ * which leaks between RSC and SSR module graphs in Next.js App Router.
269
+ *
270
+ * The context is created lazily to avoid calling createContext() at
271
+ * module evaluation time, which would break Server Components that
272
+ * import from `@tenphi/tasty` without using any React hooks.
273
+ */
274
+ let _ctx;
275
+ function getTastySSRContext() {
276
+ if (!_ctx) _ctx = createContext(null);
277
+ return _ctx;
278
+ }
279
+ //#endregion
280
+ //#region src/hooks/useStyles.ts
281
+ /**
282
+ * Hook to generate CSS classes from Tasty styles.
283
+ * Thin wrapper around `computeStyles()` that adds React context-based
284
+ * SSR collector discovery for backward compatibility with TastyRegistry.
285
+ *
286
+ * For hook-free usage (e.g. in server components), use `computeStyles()` directly.
287
+ *
288
+ * @example
289
+ * ```tsx
290
+ * function MyComponent() {
291
+ * const { className } = useStyles({
292
+ * padding: '2x',
293
+ * fill: '#purple',
294
+ * radius: '1r',
295
+ * });
296
+ *
297
+ * return <div className={className}>Styled content</div>;
298
+ * }
299
+ * ```
300
+ */
301
+ function useStyles(styles, options) {
302
+ return computeStyles(styles, {
303
+ ssrCollector: useContext(getTastySSRContext()),
304
+ root: options?.root
305
+ });
306
+ }
307
+ //#endregion
308
+ //#region src/hooks/useGlobalStyles.ts
309
+ const getClientGlobalSlots = /* @__PURE__ */ createClientState(() => /* @__PURE__ */ new Map());
310
+ const noop = () => {};
311
+ /**
312
+ * Inject global styles for a given selector.
313
+ * Useful for styling elements by selector without generating classNames.
314
+ *
315
+ * SSR-aware: when a ServerStyleCollector is available, CSS is collected
316
+ * during the render phase instead of being injected into the DOM.
317
+ *
318
+ * Works in all environments: client, SSR with collector, and React Server Components.
319
+ *
320
+ * Injected styles are permanent — they are not cleaned up on component unmount.
321
+ * Use the `id` option for update tracking when styles change over the
322
+ * component lifecycle.
323
+ *
324
+ * Update tracking is per-slot and per-root: a slot (`id`, or the selector when
325
+ * no `id` is given) holds exactly one injection per `root`. Changing the styles
326
+ * replaces it; rendering styles that produce no CSS clears it.
327
+ *
328
+ * @param selector - CSS selector to apply styles to (e.g., '.my-class', ':root', 'body')
329
+ * @param styles - Tasty styles object
330
+ * @param options - Optional settings including `id` for update tracking
331
+ *
332
+ * @example
333
+ * ```tsx
334
+ * function MyComponent() {
335
+ * useGlobalStyles('.card', {
336
+ * padding: '2x',
337
+ * radius: '1r',
338
+ * fill: '#white',
339
+ * });
340
+ *
341
+ * return <div className="card">Content</div>;
342
+ * }
343
+ * ```
344
+ */
345
+ function useGlobalStyles(selector, styles, options) {
346
+ if (!styles) return;
347
+ if (!selector) {
348
+ console.warn("[Tasty] useGlobalStyles: selector is required and cannot be empty. Styles will not be injected.");
349
+ return;
350
+ }
351
+ const target = getStyleTarget();
352
+ const slots = target.mode === "client" ? getClientGlobalSlots(options?.root ?? document) : null;
353
+ const slotKey = options?.id ?? selector;
354
+ const stylesKey = slots ? JSON.stringify(styles) : "";
355
+ const existing = slots?.get(slotKey);
356
+ if (existing && existing.stylesKey === stylesKey) return;
357
+ const resolvedStyles = resolveRecipes(styles);
358
+ const styleResults = renderStyles(resolvedStyles, selector);
359
+ if (styleResults.length === 0) {
360
+ if (slots) {
361
+ existing?.dispose();
362
+ slots.set(slotKey, {
363
+ stylesKey,
364
+ dispose: noop
365
+ });
366
+ }
367
+ return;
368
+ }
369
+ if (target.mode === "ssr") {
370
+ target.collector.collectInternals();
371
+ const css = formatGlobalRules(styleResults);
372
+ if (css) {
373
+ const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
374
+ target.collector.collectGlobalStyles(key, css, options?.id != null);
375
+ }
376
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredProperties(styleResults, target.collector, resolvedStyles);
377
+ return;
378
+ }
379
+ if (target.mode === "rsc") {
380
+ const css = formatGlobalRules(styleResults);
381
+ if (css) {
382
+ const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
383
+ pushRSCCSS(target.cache, key, css, options?.id != null);
384
+ }
385
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredPropertiesRSC(styleResults, target.cache, resolvedStyles);
386
+ return;
387
+ }
388
+ if (slots) {
389
+ existing?.dispose();
390
+ const { dispose } = injectGlobal(styleResults, { root: options?.root });
391
+ slots.set(slotKey, {
392
+ stylesKey,
393
+ dispose
394
+ });
395
+ }
396
+ }
397
+ //#endregion
398
+ //#region src/hooks/useRawCSS.ts
399
+ const getClientState$1 = /* @__PURE__ */ createClientState(() => ({
400
+ entries: /* @__PURE__ */ new Map(),
401
+ dedup: /* @__PURE__ */ new Set(),
402
+ deps: /* @__PURE__ */ new Map()
403
+ }));
404
+ /**
405
+ * Inject raw CSS text directly without parsing.
406
+ * This is a low-overhead alternative for injecting global CSS that doesn't need tasty processing.
407
+ *
408
+ * The CSS is inserted into a separate style element (data-tasty-raw) to avoid conflicts
409
+ * with tasty's chunked style sheets.
410
+ *
411
+ * Works in all environments: client, SSR with collector, and React Server Components.
412
+ *
413
+ * Injected styles are permanent — they are not cleaned up on component unmount.
414
+ * Use the `id` option for update tracking when styles change over the
415
+ * component lifecycle.
416
+ *
417
+ * @example Static CSS string
418
+ * ```tsx
419
+ * function GlobalStyles() {
420
+ * useRawCSS(`
421
+ * body {
422
+ * margin: 0;
423
+ * padding: 0;
424
+ * font-family: sans-serif;
425
+ * }
426
+ * `);
427
+ *
428
+ * return null;
429
+ * }
430
+ * ```
431
+ *
432
+ * @example Factory function with dependencies
433
+ * ```tsx
434
+ * function ThemeStyles({ theme }: { theme: 'light' | 'dark' }) {
435
+ * useRawCSS(() => `
436
+ * :root {
437
+ * --bg-color: ${theme === 'dark' ? '#1a1a1a' : '#ffffff'};
438
+ * --text-color: ${theme === 'dark' ? '#ffffff' : '#1a1a1a'};
439
+ * }
440
+ * `, [theme], { id: 'theme-vars' });
441
+ *
442
+ * return null;
443
+ * }
444
+ * ```
445
+ *
446
+ * @example With options
447
+ * ```tsx
448
+ * function ShadowStyles({ shadowRoot }) {
449
+ * useRawCSS(() => `.scoped { color: red; }`, [], { root: shadowRoot });
450
+ * return null;
451
+ * }
452
+ * ```
453
+ */
454
+ function useRawCSS(cssOrFactory, depsOrOptions, options) {
455
+ const isFactory = typeof cssOrFactory === "function";
456
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
457
+ const opts = isFactory ? options : depsOrOptions;
458
+ const id = opts?.id;
459
+ const target = getStyleTarget();
460
+ const state = target.mode === "client" ? getClientState$1(opts?.root ?? document) : null;
461
+ if (isFactory && deps && id && state) {
462
+ const cachedDeps = state.deps.get(id);
463
+ if (cachedDeps && depsEqual(cachedDeps, deps)) return;
464
+ }
465
+ const css = isFactory ? cssOrFactory() : cssOrFactory;
466
+ if (!css.trim()) return;
467
+ if (target.mode !== "client") {
468
+ const key = `${target.mode === "rsc" ? "__" : ""}raw:${id || hashString(css)}`;
469
+ const replace = id != null;
470
+ if (target.mode === "ssr") target.collector.collectRawCSS(key, css, replace);
471
+ else pushRSCCSS(target.cache, key, css, replace);
472
+ return;
473
+ }
474
+ if (!state) return;
475
+ if (id) {
476
+ const existing = state.entries.get(id);
477
+ if (existing) {
478
+ if (existing.css === css) return;
479
+ existing.dispose();
480
+ }
481
+ const { dispose } = injectRawCSS(css, opts);
482
+ state.entries.set(id, {
483
+ css,
484
+ dispose
485
+ });
486
+ if (deps) state.deps.set(id, deps);
487
+ } else {
488
+ const contentKey = hashString(css);
489
+ if (state.dedup.has(contentKey)) return;
490
+ state.dedup.add(contentKey);
491
+ injectRawCSS(css, opts);
492
+ }
493
+ }
494
+ //#endregion
495
+ //#region src/hooks/useKeyframes.ts
496
+ const getClientState = /* @__PURE__ */ createClientState(() => ({
497
+ contentToName: /* @__PURE__ */ new Map(),
498
+ namedSlots: /* @__PURE__ */ new Map(),
499
+ factoryDeps: /* @__PURE__ */ new Map()
500
+ }));
501
+ function useKeyframes(stepsOrFactory, depsOrOptions, options) {
502
+ const isFactory = typeof stepsOrFactory === "function";
503
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
504
+ const opts = isFactory ? options : depsOrOptions;
505
+ const target = getStyleTarget();
506
+ const clientState = target.mode === "client" ? getClientState(opts?.root ?? document) : null;
507
+ if (isFactory && deps && opts?.name && clientState) {
508
+ const cached = clientState.factoryDeps.get(opts.name);
509
+ if (cached && depsEqual(cached.deps, deps)) return cached.name;
510
+ }
511
+ const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
512
+ if (!steps || Object.keys(steps).length === 0) return "";
513
+ if (target.mode === "ssr") {
514
+ const actualName = target.collector.allocateKeyframeName(opts?.name);
515
+ const css = formatKeyframesCSS(actualName, steps);
516
+ target.collector.collectKeyframes(actualName, css);
517
+ return actualName;
518
+ }
519
+ if (target.mode === "rsc") {
520
+ const serializedContent = JSON.stringify(steps);
521
+ const key = `__kf:${opts?.name ?? ""}:${serializedContent}`;
522
+ const existingName = target.cache.generatedNames.get(key);
523
+ if (existingName) return existingName;
524
+ const actualName = opts?.name ?? makeKeyframeName(getNamePrefix(), hashString(serializedContent));
525
+ const css = formatKeyframesCSS(actualName, steps);
526
+ pushRSCCSS(target.cache, key, css);
527
+ target.cache.generatedNames.set(key, actualName);
528
+ return actualName;
529
+ }
530
+ const state = clientState ?? getClientState(opts?.root ?? document);
531
+ const serializedContent = JSON.stringify(steps);
532
+ const cacheKey = `${opts?.name ?? ""}:${serializedContent}`;
533
+ const cachedName = state.contentToName.get(cacheKey);
534
+ if (cachedName) return cachedName;
535
+ const providedName = opts?.name;
536
+ if (providedName) {
537
+ const slot = state.namedSlots.get(providedName);
538
+ if (slot && slot.cacheKey !== cacheKey) {
539
+ slot.dispose();
540
+ state.contentToName.delete(slot.cacheKey);
541
+ state.namedSlots.delete(providedName);
542
+ }
543
+ }
544
+ const result = keyframes(steps, {
545
+ name: providedName,
546
+ root: opts?.root
547
+ });
548
+ const name = result.toString();
549
+ state.contentToName.set(cacheKey, name);
550
+ if (providedName) {
551
+ state.namedSlots.set(providedName, {
552
+ cacheKey,
553
+ dispose: result.dispose
554
+ });
555
+ if (deps) state.factoryDeps.set(providedName, {
556
+ deps,
557
+ name
558
+ });
559
+ }
560
+ return name;
561
+ }
562
+ //#endregion
563
+ //#region src/hooks/useProperty.ts
564
+ /**
565
+ * Register a CSS @property custom property.
566
+ * This enables advanced features like animating custom properties.
567
+ *
568
+ * Note: @property rules are global and persistent once defined.
569
+ * The function ensures the property is only registered once per root.
570
+ *
571
+ * Accepts tasty token syntax for the property name:
572
+ * - `$name` → defines `--name`
573
+ * - `#name` → defines `--name-color` (auto-sets syntax: '<color>', defaults initialValue: 'transparent')
574
+ * - `--name` → defines `--name` (legacy format)
575
+ *
576
+ * Works in all environments: client, SSR with collector, and React Server Components.
577
+ *
578
+ * @param name - The property token ($name, #name) or CSS property name (--name)
579
+ * @param options - Property configuration
580
+ *
581
+ * @example Basic property with token syntax
582
+ * ```tsx
583
+ * function Spinner() {
584
+ * useProperty('$rotation', {
585
+ * syntax: '<angle>',
586
+ * inherits: false,
587
+ * initialValue: '0deg',
588
+ * });
589
+ *
590
+ * return <div className="spinner" />;
591
+ * }
592
+ * ```
593
+ *
594
+ * @example Color property with token syntax (auto-sets syntax)
595
+ * ```tsx
596
+ * function MyComponent() {
597
+ * useProperty('#theme', {
598
+ * initialValue: 'red', // syntax: '<color>' is auto-set
599
+ * });
600
+ *
601
+ * // Now --theme-color can be animated with CSS transitions
602
+ * return <div style={{ '--theme-color': 'blue' } as React.CSSProperties}>Colored</div>;
603
+ * }
604
+ * ```
605
+ *
606
+ * @example Legacy format (still supported)
607
+ * ```tsx
608
+ * function ResizableBox() {
609
+ * useProperty('--box-size', {
610
+ * syntax: '<length>',
611
+ * initialValue: '100px',
612
+ * });
613
+ *
614
+ * return <div style={{ width: 'var(--box-size)' }} />;
615
+ * }
616
+ * ```
617
+ */
618
+ function useProperty(name, options) {
619
+ if (!name) {
620
+ console.warn(`[Tasty] useProperty: property name is required`);
621
+ return;
622
+ }
623
+ const target = getStyleTarget();
624
+ if (target.mode === "ssr") {
625
+ target.collector.collectInternals();
626
+ const css = formatPropertyCSS(name, {
627
+ syntax: options?.syntax,
628
+ inherits: options?.inherits,
629
+ initialValue: options?.initialValue
630
+ });
631
+ if (css) target.collector.collectProperty(name, css);
632
+ return;
633
+ }
634
+ if (target.mode === "rsc") {
635
+ const css = formatPropertyCSS(name, {
636
+ syntax: options?.syntax,
637
+ inherits: options?.inherits,
638
+ initialValue: options?.initialValue
639
+ });
640
+ if (css) pushRSCCSS(target.cache, `__prop:${name}`, css);
641
+ return;
642
+ }
643
+ const injector = getGlobalInjector();
644
+ if (injector.isPropertyDefined(name, { root: options?.root })) return;
645
+ injector.property(name, {
646
+ syntax: options?.syntax,
647
+ inherits: options?.inherits,
648
+ initialValue: options?.initialValue,
649
+ root: options?.root
650
+ });
651
+ }
652
+ //#endregion
653
+ //#region src/hooks/useFontFace.ts
654
+ /**
655
+ * Inject CSS @font-face rules.
656
+ * Permanent — no cleanup on unmount. Deduplicates by content hash.
657
+ *
658
+ * Works in all environments: client, SSR with collector, and React Server Components.
659
+ *
660
+ * @param family - The font-family name
661
+ * @param input - Single descriptor object or array of descriptors (for multiple weights/styles)
662
+ * @param options - Optional settings (e.g. Shadow DOM root)
663
+ *
664
+ * @example Single weight
665
+ * ```tsx
666
+ * function App() {
667
+ * useFontFace('Brand Sans', {
668
+ * src: 'url("/fonts/brand-sans.woff2") format("woff2")',
669
+ * fontWeight: '400 700',
670
+ * fontDisplay: 'swap',
671
+ * });
672
+ *
673
+ * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
674
+ * }
675
+ * ```
676
+ *
677
+ * @example Multiple weights
678
+ * ```tsx
679
+ * function App() {
680
+ * useFontFace('Brand Sans', [
681
+ * { src: 'url("/fonts/brand-regular.woff2") format("woff2")', fontWeight: 400, fontDisplay: 'swap' },
682
+ * { src: 'url("/fonts/brand-bold.woff2") format("woff2")', fontWeight: 700, fontDisplay: 'swap' },
683
+ * ]);
684
+ *
685
+ * return <div style={{ fontFamily: '"Brand Sans", sans-serif' }}>Hello</div>;
686
+ * }
687
+ * ```
688
+ */
689
+ function useFontFace(family, input, options) {
690
+ if (!family) return;
691
+ const descriptors = Array.isArray(input) ? input : [input];
692
+ const target = getStyleTarget();
693
+ if (target.mode === "ssr") {
694
+ for (const desc of descriptors) {
695
+ const hash = fontFaceContentHash(family, desc);
696
+ const css = formatFontFaceRule(family, desc);
697
+ target.collector.collectFontFace(hash, css);
698
+ }
699
+ return;
700
+ }
701
+ if (target.mode === "rsc") {
702
+ for (const desc of descriptors) {
703
+ const hash = fontFaceContentHash(family, desc);
704
+ const css = formatFontFaceRule(family, desc);
705
+ pushRSCCSS(target.cache, `__ff:${hash}`, css);
706
+ }
707
+ return;
708
+ }
709
+ const injector = getGlobalInjector();
710
+ for (const desc of descriptors) injector.fontFace(family, desc, { root: options?.root });
711
+ }
712
+ //#endregion
713
+ //#region src/hooks/useCounterStyle.ts
714
+ let clientCounterStyleCounter = 0;
715
+ const getClientContentToName = /* @__PURE__ */ createClientState(() => /* @__PURE__ */ new Map());
716
+ /**
717
+ * Inject a CSS @counter-style rule and return the generated name.
718
+ * Permanent — no cleanup on unmount. Deduplicates by name.
719
+ *
720
+ * Works in all environments: client, SSR with collector, and React Server Components.
721
+ *
722
+ * @example Basic usage
723
+ * ```tsx
724
+ * function EmojiList() {
725
+ * const styleName = useCounterStyle({
726
+ * system: 'cyclic',
727
+ * symbols: '"👍"',
728
+ * suffix: '" "',
729
+ * }, { name: 'thumbs' });
730
+ *
731
+ * return (
732
+ * <ol style={{ listStyleType: styleName }}>
733
+ * <li>First</li>
734
+ * <li>Second</li>
735
+ * </ol>
736
+ * );
737
+ * }
738
+ * ```
739
+ *
740
+ */
741
+ function useCounterStyle(descriptors, options) {
742
+ if (!descriptors || !descriptors.system) return "";
743
+ const target = getStyleTarget();
744
+ if (target.mode === "ssr") {
745
+ const actualName = target.collector.allocateCounterStyleName(options?.name);
746
+ const css = formatCounterStyleRule(actualName, descriptors);
747
+ target.collector.collectCounterStyle(actualName, css);
748
+ return actualName;
749
+ }
750
+ if (target.mode === "rsc") {
751
+ const serializedContent = JSON.stringify(descriptors);
752
+ const key = `__cs:${options?.name ?? ""}:${serializedContent}`;
753
+ const existingName = target.cache.generatedNames.get(key);
754
+ if (existingName) return existingName;
755
+ const actualName = options?.name ?? makeCounterStyleName(getNamePrefix(), hashString(serializedContent));
756
+ const css = formatCounterStyleRule(actualName, descriptors);
757
+ pushRSCCSS(target.cache, key, css);
758
+ target.cache.generatedNames.set(key, actualName);
759
+ return actualName;
760
+ }
761
+ const contentToName = getClientContentToName(options?.root ?? document);
762
+ const serializedContent = JSON.stringify(descriptors);
763
+ const cacheKey = `${options?.name ?? ""}:${serializedContent}`;
764
+ const existingName = contentToName.get(cacheKey);
765
+ if (existingName) return existingName;
766
+ const name = options?.name ?? makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));
767
+ contentToName.set(cacheKey, name);
768
+ getGlobalInjector().counterStyle(name, descriptors, { root: options?.root });
769
+ return name;
770
+ }
771
+ //#endregion
772
+ //#region src/hooks/useFunction.ts
773
+ /**
774
+ * Register a CSS @function (custom function).
775
+ *
776
+ * @function rules are global and persistent once defined. The hook ensures the
777
+ * function is only registered once per root (deduplicated by function name).
778
+ *
779
+ * Accepts tasty token syntax for the function name:
780
+ * - `$$name` → defines `--name` (matches the call site `$$name(...)`)
781
+ * - `$name` / `--name` → also accepted
782
+ *
783
+ * Works in all environments: client, SSR with collector, and React Server Components.
784
+ *
785
+ * @param name - The function name token (`$$name`, `$name`, or `--name`)
786
+ * @param definition - Function definition (args, returns, result, local vars)
787
+ *
788
+ * Call the function through the Tasty DSL, not a raw `style` prop: an inline
789
+ * `style` value reaches the browser unparsed, so the `$$name(...)` sugar is never
790
+ * expanded and `polyfills.functions` cannot rewrite it either.
791
+ *
792
+ * @example
793
+ * ```tsx
794
+ * const Box = tasty({ styles: { marginTop: '$$negative(10px)' } });
795
+ *
796
+ * function Layout() {
797
+ * useFunction('$$negative', { args: ['$value'], result: '(-1 * $value)' });
798
+ * return <Box />;
799
+ * }
800
+ * ```
801
+ */
802
+ function useFunction(name, definition, options) {
803
+ if (!name) {
804
+ console.warn(`[Tasty] useFunction: function name is required`);
805
+ return;
806
+ }
807
+ if (isFunctionsPolyfillEnabled()) {
808
+ registerFunctionPolyfill(name, definition);
809
+ return;
810
+ }
811
+ const target = getStyleTarget();
812
+ if (target.mode === "ssr") {
813
+ target.collector.collectInternals();
814
+ const css = formatFunctionRule(name, definition);
815
+ if (css) target.collector.collectFunction(parseFunctionName(name), css);
816
+ return;
817
+ }
818
+ if (target.mode === "rsc") {
819
+ const css = formatFunctionRule(name, definition);
820
+ if (css) pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);
821
+ return;
822
+ }
823
+ getGlobalInjector().func(name, definition, { root: options?.root });
824
+ }
825
+ //#endregion
826
+ //#region src/batch-provider.tsx
827
+ /**
828
+ * Opens a *batch window* for the commit it renders in, so `batchInjection`
829
+ * can defer stylesheet writes without ever letting a layout effect measure an
830
+ * unstyled element.
831
+ *
832
+ * Every `insertRule()` on a live sheet invalidates style for that sheet's
833
+ * scope. When components inject during React's render phase while others read
834
+ * layout in the same pass, the two interleave and the browser recalculates
835
+ * style between every injection. Batching collapses that into one invalidation
836
+ * per flush — but only if the flush happens before anything can measure.
837
+ *
838
+ * ```
839
+ * provider renders -> window OPEN
840
+ * children render -> injections queued
841
+ * provider insertionEffect -> FLUSH, window CLOSED
842
+ * layout effects run -> rules are in the sheet
843
+ * ```
844
+ *
845
+ * `useInsertionEffect` runs in React's mutation phase, after every render in
846
+ * the commit and before any `useLayoutEffect` — which is exactly why React
847
+ * added it for CSS-in-JS libraries. Effects fire child-first, so this
848
+ * provider's runs after every descendant's and still before all layout
849
+ * effects.
850
+ *
851
+ * A commit that does not re-render this provider gets no window, and those
852
+ * injections are written synchronously instead. That is the point: turning
853
+ * `batchInjection: true` on can only ever make injection cheaper, never make a
854
+ * measurement wrong. It also means batching applies to commits this provider
855
+ * takes part in, so mount it as high in the tree as you can.
856
+ *
857
+ * Requires `configure({ batchInjection: true })`; without it this component
858
+ * only renders its children. `batchInjection: 'always'` does not need the
859
+ * provider at all — see that option's docs for the trade-off it accepts.
860
+ *
861
+ * @example
862
+ * ```tsx
863
+ * configure({ batchInjection: true });
864
+ *
865
+ * createRoot(el).render(
866
+ * <TastyBatchProvider>
867
+ * <App />
868
+ * </TastyBatchProvider>,
869
+ * );
870
+ * ```
871
+ */
872
+ function TastyBatchProvider({ children }) {
873
+ openBatchWindow();
874
+ useInsertionEffect(() => {
875
+ closeBatchWindow();
876
+ });
877
+ return children;
878
+ }
879
+ //#endregion
880
+ export { useProperty as a, useGlobalStyles as c, Element as d, tasty as f, useFontFace as i, useStyles as l, useFunction as n, useKeyframes as o, getDisplayName as p, useCounterStyle as r, useRawCSS as s, TastyBatchProvider as t, getTastySSRContext as u };
881
+
882
+ //# sourceMappingURL=react-runtime-v7wWFkFD.js.map