@tenphi/tasty 0.0.0-snapshot.06c8a41 → 0.0.0-snapshot.07ea4a0

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 (132) hide show
  1. package/README.md +408 -385
  2. package/dist/babel-types-BKDTT4--.d.ts +18 -0
  3. package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
  4. package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
  5. package/dist/chunks/build-config-CW4k04_V.js +60 -0
  6. package/dist/chunks/build-config-CW4k04_V.js.map +1 -0
  7. package/dist/{collector-B3OsM252.js → chunks/collector-DKWQXEwN.js} +10 -127
  8. package/dist/chunks/collector-DKWQXEwN.js.map +1 -0
  9. package/dist/chunks/config-engine-DTglOA78.js +272 -0
  10. package/dist/chunks/config-engine-DTglOA78.js.map +1 -0
  11. package/dist/chunks/config-file-DlZXJMj8.js +25 -0
  12. package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
  13. package/dist/chunks/css-definitions-_C7C-daI.js +910 -0
  14. package/dist/chunks/css-definitions-_C7C-daI.js.map +1 -0
  15. package/dist/{css-resources-Cyl_axbI.js → chunks/css-resources-P7IBUUZs.js} +2 -9
  16. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  17. package/dist/chunks/debug-BapJwy9w.js +502 -0
  18. package/dist/chunks/debug-BapJwy9w.js.map +1 -0
  19. package/dist/chunks/dsl-DYSJc1-T.js +1383 -0
  20. package/dist/chunks/dsl-DYSJc1-T.js.map +1 -0
  21. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  22. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  23. package/dist/chunks/react-runtime-DayjnPuC.js +689 -0
  24. package/dist/chunks/react-runtime-DayjnPuC.js.map +1 -0
  25. package/dist/chunks/runtime-engine-IwGbSMb4.js +2432 -0
  26. package/dist/chunks/runtime-engine-IwGbSMb4.js.map +1 -0
  27. package/dist/chunks/runtime-state-CVrL92zX.js +152 -0
  28. package/dist/chunks/runtime-state-CVrL92zX.js.map +1 -0
  29. package/dist/{merge-styles-DuoZEsm9.js → chunks/shared-utils-y-HjvPN4.js} +60 -55
  30. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  31. package/dist/chunks/style-engine-CVmNIjow.js +5521 -0
  32. package/dist/chunks/style-engine-CVmNIjow.js.map +1 -0
  33. package/dist/{css-writer-Bgowobbx.js → chunks/zero-engine-igHhzYM6.js} +65 -145
  34. package/dist/chunks/zero-engine-igHhzYM6.js.map +1 -0
  35. package/dist/{collector-BTVXj2hS.d.ts → collector-CTU-nl0g.d.ts} +6 -5
  36. package/dist/{config-LfIDmVHx.d.ts → config-CcxqSZI2.d.ts} +45 -40
  37. package/dist/core/index.d.ts +5 -5
  38. package/dist/core/index.js +9 -6
  39. package/dist/hydrate-CRyjjAyl.d.ts +22 -0
  40. package/dist/{index-Bm9ltvdH.d.ts → index--GdqCPlp.d.ts} +271 -242
  41. package/dist/index.d.ts +5 -5
  42. package/dist/index.js +11 -922
  43. package/dist/{merge-styles-BcLl1u_d.d.ts → merge-styles-DSkVc6CD.d.ts} +2 -3
  44. package/dist/ssr/astro-client.d.ts +1 -1
  45. package/dist/ssr/astro-client.js +1 -14
  46. package/dist/ssr/astro-client.js.map +1 -1
  47. package/dist/ssr/astro-middleware-extract-static.d.ts +1 -2
  48. package/dist/ssr/astro-middleware-extract-static.js +1 -1
  49. package/dist/ssr/astro-middleware-extract.d.ts +1 -2
  50. package/dist/ssr/astro-middleware-extract.js +1 -1
  51. package/dist/ssr/astro-middleware-static.d.ts +1 -2
  52. package/dist/ssr/astro-middleware-static.js +1 -12
  53. package/dist/ssr/astro-middleware-static.js.map +1 -1
  54. package/dist/ssr/astro-middleware.d.ts +1 -2
  55. package/dist/ssr/astro-middleware.js +1 -13
  56. package/dist/ssr/astro-middleware.js.map +1 -1
  57. package/dist/ssr/astro.d.ts +8 -16
  58. package/dist/ssr/astro.js +220 -1
  59. package/dist/ssr/astro.js.map +1 -0
  60. package/dist/ssr/client.d.ts +2 -0
  61. package/dist/ssr/client.js +2 -0
  62. package/dist/ssr/index.d.ts +5 -25
  63. package/dist/ssr/index.js +5 -5
  64. package/dist/ssr/index.js.map +1 -1
  65. package/dist/ssr/next-config.d.ts +3 -5
  66. package/dist/ssr/next-config.js +43 -35
  67. package/dist/ssr/next-config.js.map +1 -1
  68. package/dist/ssr/next.d.ts +3 -9
  69. package/dist/ssr/next.js +7 -38
  70. package/dist/ssr/next.js.map +1 -1
  71. package/dist/static/index.d.ts +8 -9
  72. package/dist/static/index.js +4 -22
  73. package/dist/static/index.js.map +1 -1
  74. package/dist/static/inject.d.ts +1 -2
  75. package/dist/{index-BmogEzTo.d.ts → types-DJEM_BOJ.d.ts} +852 -860
  76. package/dist/zero/babel.d.ts +67 -2
  77. package/dist/zero/babel.js +77 -140
  78. package/dist/zero/babel.js.map +1 -1
  79. package/dist/zero/index.d.ts +62 -8
  80. package/dist/zero/index.js +24 -2
  81. package/dist/zero/index.js.map +1 -0
  82. package/dist/zero/next.d.ts +4 -5
  83. package/dist/zero/next.js +3 -38
  84. package/dist/zero/next.js.map +1 -1
  85. package/docs/README.md +4 -1
  86. package/docs/adoption.md +25 -17
  87. package/docs/ai-agents.md +66 -33
  88. package/docs/comparison.md +9 -8
  89. package/docs/configuration.md +192 -60
  90. package/docs/debug.md +5 -7
  91. package/docs/design-system.md +117 -15
  92. package/docs/dsl.md +204 -82
  93. package/docs/getting-started.md +81 -22
  94. package/docs/injector.md +41 -40
  95. package/docs/methodology.md +48 -23
  96. package/docs/migration-v3.md +3 -3
  97. package/docs/pipeline.md +54 -27
  98. package/docs/plugins.md +22 -42
  99. package/docs/react-api.md +72 -9
  100. package/docs/runtime-benchmarks.md +146 -91
  101. package/docs/ssr.md +92 -66
  102. package/docs/styles.md +117 -31
  103. package/docs/tasty-static.md +162 -58
  104. package/package.json +96 -38
  105. package/dist/astro-CeYENy2x.js +0 -301
  106. package/dist/astro-CeYENy2x.js.map +0 -1
  107. package/dist/async-storage-DKK-wTD4.js +0 -44
  108. package/dist/async-storage-DKK-wTD4.js.map +0 -1
  109. package/dist/babel-DWCsafYw.d.ts +0 -83
  110. package/dist/collector-B3OsM252.js.map +0 -1
  111. package/dist/config-B3gPdCqd.js +0 -12421
  112. package/dist/config-B3gPdCqd.js.map +0 -1
  113. package/dist/context-CA8YKeMn.js +0 -24
  114. package/dist/context-CA8YKeMn.js.map +0 -1
  115. package/dist/core-DGm0CFHP.js +0 -1732
  116. package/dist/core-DGm0CFHP.js.map +0 -1
  117. package/dist/css-resources-Cyl_axbI.js.map +0 -1
  118. package/dist/css-writer-Bgowobbx.js.map +0 -1
  119. package/dist/format-global-rules-DklyaXv-.js +0 -22
  120. package/dist/format-global-rules-DklyaXv-.js.map +0 -1
  121. package/dist/format-rules-XRw9u7d4.js +0 -104
  122. package/dist/format-rules-XRw9u7d4.js.map +0 -1
  123. package/dist/hydrate-CNOmZprz.js +0 -37
  124. package/dist/hydrate-CNOmZprz.js.map +0 -1
  125. package/dist/index.js.map +0 -1
  126. package/dist/keyframes-DE-OE76F.js +0 -535
  127. package/dist/keyframes-DE-OE76F.js.map +0 -1
  128. package/dist/merge-styles-DuoZEsm9.js.map +0 -1
  129. package/dist/resolve-recipes-H9NqOQuP.js +0 -144
  130. package/dist/resolve-recipes-H9NqOQuP.js.map +0 -1
  131. package/dist/ssr-collector-ref-COs_ioWl.js +0 -29
  132. package/dist/ssr-collector-ref-COs_ioWl.js.map +0 -1
@@ -0,0 +1,689 @@
1
+ import { n as isSelector, t as mergeStyles } from "./shared-utils-y-HjvPN4.js";
2
+ import { K as parseFunctionName, N as hashString, O as makeCounterStyleName, S as formatFontFaceRule, W as formatFunctionRule, _ as formatCounterStyleRule, b as fontFaceContentHash, i as formatKeyframesCSS, k as makeKeyframeName, m as resolveSelectorKeyframes, n as formatGlobalRules, o as formatPropertyCSS, q as registerFunctionPolyfill } from "./css-definitions-_C7C-daI.js";
3
+ import { b as renderStyles, i as baseStylePropsRegistry, q as isFunctionsPolyfillEnabled, s as BASE_STYLES } from "./style-engine-CVmNIjow.js";
4
+ import { u as getGlobalKeyframes } from "./runtime-state-CVrL92zX.js";
5
+ import { $ as openBatchWindow, B as getGlobalInjector, F as touch, H as getNamePrefix, M as keyframes, O as injectGlobal, X as closeBatchWindow, c as hasKeys, d as checkRequestScope, f as getRSCCache, h as queueRSCCSS, i as modAttrs, k as injectRawCSS, l as collectAutoInferredProperties, m as pushRSCCSS, n as createClientState, o as computeStyles, p as getStyleTarget, r as processTokens, s as resolveRecipes, t as depsEqual, tt as propHandlerRegistry, u as collectAutoInferredPropertiesRSC, z as getConfig } from "./runtime-engine-IwGbSMb4.js";
6
+ import React, { Fragment, createElement, forwardRef } from "react";
7
+ //#region src/utils/get-display-name.ts
8
+ const DEFAULT_NAME = "Anonymous";
9
+ function nameOf(type) {
10
+ if (typeof type === "string") return type;
11
+ if (!type || typeof type !== "function" && typeof type !== "object") return;
12
+ const { displayName, name, render, type: inner } = type;
13
+ if (displayName) return displayName;
14
+ if (typeof type === "function") return name || void 0;
15
+ return nameOf(render) ?? nameOf(inner);
16
+ }
17
+ function getDisplayName(Component, fallbackName = DEFAULT_NAME) {
18
+ return nameOf(Component) ?? fallbackName;
19
+ }
20
+ //#endregion
21
+ //#region src/utils/is-valid-element-type.ts
22
+ function isValidElementType(value) {
23
+ if (typeof value === "string" || typeof value === "function") return true;
24
+ if (typeof value === "object" && value !== null) return typeof value.$$typeof === "symbol";
25
+ return false;
26
+ }
27
+ //#endregion
28
+ //#region src/tasty.tsx
29
+ function handleIsProperty(props, isProperty, targetAttribute, dataAttribute) {
30
+ if (isProperty in props) {
31
+ props[targetAttribute] = props[isProperty];
32
+ delete props[isProperty];
33
+ }
34
+ if (!(dataAttribute in props) && props[targetAttribute]) props[dataAttribute] = "";
35
+ }
36
+ function handleIsProperties(props) {
37
+ handleIsProperty(props, "isDisabled", "disabled", "data-disabled");
38
+ handleIsProperty(props, "isHidden", "hidden", "data-hidden");
39
+ handleIsProperty(props, "isChecked", "checked", "data-checked");
40
+ }
41
+ function createSubElement(elementName, definition) {
42
+ const config = typeof definition === "string" ? { as: definition } : definition;
43
+ const tag = config.as ?? "div";
44
+ const defaultQa = config.qa;
45
+ const defaultQaVal = config.qaVal;
46
+ const SubElement = forwardRef((props, ref) => {
47
+ const { qa, qaVal, mods, tokens, isDisabled, isHidden, isChecked, className, style, ...htmlProps } = props;
48
+ let modDataAttrs;
49
+ if (mods) modDataAttrs = modAttrs(mods);
50
+ const tokenStyle = tokens ? processTokens(tokens) : void 0;
51
+ let mergedStyle;
52
+ if (tokenStyle || style) mergedStyle = tokenStyle && style ? {
53
+ ...tokenStyle,
54
+ ...style
55
+ } : tokenStyle ?? style;
56
+ const elementProps = {
57
+ "data-element": elementName,
58
+ "data-qa": qa ?? defaultQa,
59
+ "data-qaval": qaVal ?? defaultQaVal,
60
+ ...modDataAttrs || {},
61
+ ...htmlProps,
62
+ className,
63
+ style: mergedStyle,
64
+ isDisabled: isDisabled ?? htmlProps.disabled,
65
+ isHidden: isHidden ?? htmlProps.hidden,
66
+ isChecked: isChecked ?? htmlProps.checked,
67
+ ref
68
+ };
69
+ handleIsProperties(elementProps);
70
+ if (elementProps["data-qa"] === void 0) delete elementProps["data-qa"];
71
+ if (elementProps["data-qaval"] === void 0) delete elementProps["data-qaval"];
72
+ return createElement(tag, elementProps);
73
+ });
74
+ SubElement.displayName = `SubElement(${elementName})`;
75
+ return SubElement;
76
+ }
77
+ function createSubElements(elements) {
78
+ const subElements = {};
79
+ for (const [name, definition] of Object.entries(elements)) subElements[name] = createSubElement(name, definition);
80
+ return subElements;
81
+ }
82
+ const REACT_STATICS = /* @__PURE__ */ new Set([
83
+ "$$typeof",
84
+ "render",
85
+ "type",
86
+ "compare",
87
+ "displayName",
88
+ "defaultProps",
89
+ "propTypes",
90
+ "contextType",
91
+ "contextTypes",
92
+ "childContextTypes",
93
+ "getDerivedStateFromProps",
94
+ "getDerivedStateFromError"
95
+ ]);
96
+ function hoistComponentStatics(target, source) {
97
+ for (const key of Object.keys(source)) {
98
+ if (REACT_STATICS.has(key) || key in target) continue;
99
+ const value = source[key];
100
+ if (typeof value !== "string" && isValidElementType(value)) target[key] = value;
101
+ }
102
+ }
103
+ function buildVariantStylesMap(defaultStyles, variants) {
104
+ let baseStyles = defaultStyles;
105
+ let extensionStyles;
106
+ if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
107
+ if (isSelector(key)) continue;
108
+ const value = defaultStyles[key];
109
+ if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
110
+ if (!extensionStyles) {
111
+ baseStyles = { ...defaultStyles };
112
+ extensionStyles = {};
113
+ }
114
+ extensionStyles[key] = value;
115
+ delete baseStyles[key];
116
+ }
117
+ }
118
+ const variantStylesMap = {};
119
+ for (const [variant, variantStyles] of Object.entries(variants)) variantStylesMap[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
120
+ if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
121
+ return variantStylesMap;
122
+ }
123
+ function getMergedStyles(cache, base, extra) {
124
+ let entry = cache.get(extra);
125
+ if (!entry || entry.base !== base) {
126
+ entry = {
127
+ base,
128
+ styles: mergeStyles(base, extra)
129
+ };
130
+ cache.set(extra, entry);
131
+ }
132
+ return entry;
133
+ }
134
+ function takeProps(props, keys) {
135
+ let taken;
136
+ for (const key of keys) if (key in props) {
137
+ if (!taken) taken = {};
138
+ taken[key] = props[key];
139
+ delete props[key];
140
+ }
141
+ return taken;
142
+ }
143
+ function takeTokenProps(props, mapping) {
144
+ let tokens;
145
+ for (const [propName, tokenKey] of mapping) if (propName in props) {
146
+ if (!tokens) tokens = {};
147
+ tokens[tokenKey] = props[propName];
148
+ delete props[propName];
149
+ }
150
+ return tokens;
151
+ }
152
+ function getModPropsKeys(def) {
153
+ return Array.isArray(def) ? def : Object.keys(def);
154
+ }
155
+ function buildTokenPropsMapping(def) {
156
+ if (Array.isArray(def)) return def.map((propName) => {
157
+ if (propName.endsWith("Color") && propName.length > 5) return [propName, `#${propName.slice(0, -5)}`];
158
+ return [propName, `$${propName}`];
159
+ });
160
+ return Object.entries(def);
161
+ }
162
+ function tasty(Component, options) {
163
+ if (isValidElementType(Component)) return tastyWrap(Component, options);
164
+ return tastyElement(Component);
165
+ }
166
+ function tastyWrap(Component, options) {
167
+ const { as: extendTag, element: extendElement, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, variant: defaultVariant, elements, ...defaultProps } = options ?? {};
168
+ const defaultStyles = defaultProps.styles;
169
+ const variantStylesMap = variants ? buildVariantStylesMap(defaultStyles, variants) : void 0;
170
+ const fallbackVariant = defaultVariant ?? "default";
171
+ const stylePropNames = styleProps;
172
+ const modPropsKeys = modPropsDef ? getModPropsKeys(modPropsDef) : void 0;
173
+ const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
174
+ const propsWithStyles = ["styles"];
175
+ for (const prop of Object.keys(defaultProps)) if (prop.endsWith("Styles")) propsWithStyles.push(prop);
176
+ const mergedCache = /* @__PURE__ */ new WeakMap();
177
+ const _WrappedComponent = forwardRef((props, ref) => {
178
+ const { as, element, ...restProps } = props;
179
+ const propStyles = stylePropNames ? takeProps(restProps, stylePropNames) : void 0;
180
+ const propMods = modPropsKeys ? takeProps(restProps, modPropsKeys) : void 0;
181
+ const propTokens = tokenPropsMapping ? takeTokenProps(restProps, tokenPropsMapping) : void 0;
182
+ const variant = restProps.variant ?? defaultVariant;
183
+ const baseStyles = variantStylesMap ? variantStylesMap[variant || fallbackVariant] ?? variantStylesMap[fallbackVariant] ?? variantStylesMap["default"] : defaultStyles;
184
+ const mergedStylesMap = {};
185
+ for (const prop of propsWithStyles) {
186
+ const restValue = restProps[prop];
187
+ const defaultValue = prop === "styles" ? baseStyles : defaultProps[prop];
188
+ mergedStylesMap[prop] = restValue != null && defaultValue != null ? getMergedStyles(mergedCache, defaultValue, restValue).styles : restValue ?? defaultValue;
189
+ }
190
+ if (propStyles) mergedStylesMap.styles = mergeStyles(mergedStylesMap.styles, propStyles);
191
+ const elementProps = {
192
+ ...defaultProps,
193
+ ...restProps,
194
+ ...mergedStylesMap,
195
+ as: as ?? extendTag,
196
+ element: element || extendElement,
197
+ ref
198
+ };
199
+ if (variant !== void 0) elementProps.variant = variant;
200
+ if (propMods) elementProps.mods = {
201
+ ...elementProps.mods,
202
+ ...propMods
203
+ };
204
+ if (propTokens) elementProps.tokens = {
205
+ ...elementProps.tokens,
206
+ ...propTokens
207
+ };
208
+ return createElement(Component, elementProps);
209
+ });
210
+ _WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(Component, defaultProps.qa ?? extendTag ?? "Anonymous")})`;
211
+ hoistComponentStatics(_WrappedComponent, Component);
212
+ if (elements) Object.assign(_WrappedComponent, createSubElements(elements));
213
+ return _WrappedComponent;
214
+ }
215
+ function tastyElement(tastyOptions) {
216
+ const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, variant: defaultVariant, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
217
+ const variantStylesMap = variants ? buildVariantStylesMap(defaultStyles, variants) : void 0;
218
+ const fallbackStyles = variantStylesMap ? variantStylesMap[defaultVariant ?? "default"] ?? variantStylesMap["default"] : defaultStyles;
219
+ const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps;
220
+ const ownPropsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
221
+ let propsToCheck = ownPropsToCheck;
222
+ let propsToCheckVersion = -1;
223
+ const modPropsKeys = modPropsDef ? getModPropsKeys(modPropsDef) : void 0;
224
+ const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
225
+ let classNameCache = /* @__PURE__ */ new Map();
226
+ let mergedCache = /* @__PURE__ */ new WeakMap();
227
+ let cacheInjector;
228
+ let cacheEvictions = 0;
229
+ const STABLE_STYLES = { stableStyles: true };
230
+ const _TastyComponent = forwardRef((incomingProps, ref) => {
231
+ const applyPropHandlers = propHandlerRegistry.apply;
232
+ const { as, styles: rawStyles, variant, mods, element, qa, qaVal, className: userClassName, tokens, style, theme, ...otherProps } = applyPropHandlers ? applyPropHandlers(incomingProps) : incomingProps;
233
+ const styles = rawStyles;
234
+ let propStyles = null;
235
+ if (propsToCheckVersion !== baseStylePropsRegistry.version) {
236
+ const promoted = baseStylePropsRegistry.list;
237
+ propsToCheck = promoted.length === 0 ? ownPropsToCheck : ownPropsToCheck.concat(promoted);
238
+ propsToCheckVersion = baseStylePropsRegistry.version;
239
+ }
240
+ for (const prop of propsToCheck) {
241
+ const key = prop;
242
+ if (key in otherProps) {
243
+ if (!propStyles) propStyles = {};
244
+ const value = otherProps[key];
245
+ propStyles[key] = value;
246
+ delete otherProps[key];
247
+ }
248
+ }
249
+ const propMods = modPropsKeys ? takeProps(otherProps, modPropsKeys) : void 0;
250
+ const propTokens = tokenPropsMapping ? takeTokenProps(otherProps, tokenPropsMapping) : void 0;
251
+ const baseStyles = variantStylesMap ? variant && variantStylesMap[variant] || fallbackStyles : defaultStyles;
252
+ const hasInstanceStyles = !!styles && hasKeys(styles);
253
+ const useFactoryCache = typeof document !== "undefined";
254
+ if (useFactoryCache) {
255
+ const injector = getGlobalInjector();
256
+ if (injector !== cacheInjector || injector.evictions !== cacheEvictions) {
257
+ classNameCache = /* @__PURE__ */ new Map();
258
+ mergedCache = /* @__PURE__ */ new WeakMap();
259
+ cacheInjector = injector;
260
+ cacheEvictions = injector.evictions;
261
+ }
262
+ }
263
+ let allStyles;
264
+ let generatedClassName;
265
+ let mergedEntry;
266
+ if (propStyles) allStyles = mergeStyles(baseStyles, styles, propStyles);
267
+ else if (hasInstanceStyles) {
268
+ if (useFactoryCache) {
269
+ mergedEntry = getMergedStyles(mergedCache, baseStyles, styles);
270
+ allStyles = mergedEntry.styles;
271
+ generatedClassName = mergedEntry.className;
272
+ } else allStyles = mergeStyles(baseStyles, styles);
273
+ } else {
274
+ allStyles = baseStyles;
275
+ if (useFactoryCache) generatedClassName = classNameCache.get(baseStyles);
276
+ }
277
+ let rscCSS;
278
+ if (generatedClassName !== void 0) touch(generatedClassName);
279
+ else {
280
+ const result = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES : void 0);
281
+ generatedClassName = result.className;
282
+ rscCSS = result.css;
283
+ if (mergedEntry) mergedEntry.className = generatedClassName;
284
+ else if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, generatedClassName);
285
+ }
286
+ let mergedTokens;
287
+ if (defaultTokens || tokens || propTokens) {
288
+ if (!defaultTokens && !propTokens) mergedTokens = tokens;
289
+ else if (!tokens && !propTokens) mergedTokens = defaultTokens;
290
+ else mergedTokens = {
291
+ ...defaultTokens,
292
+ ...tokens,
293
+ ...propTokens
294
+ };
295
+ }
296
+ const processedTokenStyle = processTokens(mergedTokens);
297
+ let mergedStyle;
298
+ if (processedTokenStyle || style) {
299
+ if (!processedTokenStyle) mergedStyle = style;
300
+ else if (!style) mergedStyle = processedTokenStyle;
301
+ else mergedStyle = {
302
+ ...processedTokenStyle,
303
+ ...style
304
+ };
305
+ }
306
+ const mergedMods = propMods ? {
307
+ ...mods,
308
+ ...propMods
309
+ } : mods;
310
+ let modDataAttrs;
311
+ if (mergedMods) modDataAttrs = modAttrs(mergedMods);
312
+ let finalClassName = generatedClassName;
313
+ if (userClassName) finalClassName = finalClassName ? `${userClassName} ${finalClassName}` : userClassName;
314
+ const elementProps = {
315
+ "data-element": element || defaultElement,
316
+ "data-qa": qa || defaultQa,
317
+ "data-qaval": qaVal || defaultQaVal,
318
+ "data-theme": theme,
319
+ ...otherDefaultProps,
320
+ ...modDataAttrs || {},
321
+ ...otherProps,
322
+ className: finalClassName,
323
+ style: mergedStyle,
324
+ ref
325
+ };
326
+ handleIsProperties(elementProps);
327
+ if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
328
+ const el = createElement(as ?? originalAs, elementProps);
329
+ if (rscCSS) {
330
+ checkRequestScope();
331
+ const nonce = getConfig().nonce;
332
+ return createElement(Fragment, null, createElement("style", {
333
+ "data-tasty-rsc": "",
334
+ nonce,
335
+ dangerouslySetInnerHTML: { __html: rscCSS }
336
+ }), el);
337
+ }
338
+ return el;
339
+ });
340
+ _TastyComponent.displayName = `TastyComponent(${defaultProps.qa || originalAs})`;
341
+ if (elements) return Object.assign(_TastyComponent, createSubElements(elements));
342
+ return _TastyComponent;
343
+ }
344
+ const Element = /* @__PURE__ */ tasty({});
345
+ //#endregion
346
+ //#region src/ssr/context.ts
347
+ let _ctx;
348
+ function getTastySSRContext() {
349
+ if (!_ctx) _ctx = React.createContext(null);
350
+ return _ctx;
351
+ }
352
+ //#endregion
353
+ //#region src/hooks/useStyles.ts
354
+ const useContextCollector = typeof React.useContext === "function" ? () => React.useContext(getTastySSRContext()) : () => null;
355
+ function useStyles(styles, options) {
356
+ const result = computeStyles(styles, {
357
+ ssrCollector: useContextCollector(),
358
+ root: options?.root
359
+ });
360
+ if (result.css) {
361
+ checkRequestScope();
362
+ queueRSCCSS(getRSCCache(), result.css);
363
+ return { className: result.className };
364
+ }
365
+ return result;
366
+ }
367
+ //#endregion
368
+ //#region src/hooks/useGlobalStyles.ts
369
+ const getClientGlobalSlots = /* @__PURE__ */ createClientState(() => /* @__PURE__ */ new Map());
370
+ const noop = () => {};
371
+ function useGlobalStyles(selector, styles, options) {
372
+ if (!styles) return;
373
+ if (!selector) {
374
+ if (process.env.NODE_ENV !== "production") console.warn("[Tasty] useGlobalStyles: selector is required and cannot be empty. Styles will not be injected.");
375
+ return;
376
+ }
377
+ const target = getStyleTarget();
378
+ const slots = target.mode === "client" ? getClientGlobalSlots(options?.root ?? document) : null;
379
+ const slotKey = options?.id ?? selector;
380
+ const stylesKey = slots ? JSON.stringify(styles) : "";
381
+ const existing = slots?.get(slotKey);
382
+ if (existing && existing.stylesKey === stylesKey) return;
383
+ const resolvedStyles = resolveRecipes(styles);
384
+ const rendered = renderStyles(resolvedStyles, selector);
385
+ if (rendered.length === 0) {
386
+ if (slots) {
387
+ existing?.dispose();
388
+ slots.set(slotKey, {
389
+ stylesKey,
390
+ dispose: noop
391
+ });
392
+ }
393
+ return;
394
+ }
395
+ const { rules: styleResults, keyframes } = resolveSelectorKeyframes(resolvedStyles, rendered, getGlobalKeyframes());
396
+ if (target.mode === "ssr") {
397
+ target.collector.collectInternals();
398
+ if (keyframes) for (const [name, steps] of keyframes) target.collector.collectKeyframes(name, formatKeyframesCSS(name, steps));
399
+ const css = formatGlobalRules(styleResults);
400
+ if (css) {
401
+ const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
402
+ target.collector.collectGlobalStyles(key, css, options?.id != null);
403
+ }
404
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredProperties(styleResults, target.collector, resolvedStyles);
405
+ return;
406
+ }
407
+ if (target.mode === "rsc") {
408
+ if (keyframes) for (const [name, steps] of keyframes) pushRSCCSS(target.cache, `__kf:${name}`, formatKeyframesCSS(name, steps));
409
+ const css = formatGlobalRules(styleResults);
410
+ if (css) {
411
+ const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
412
+ pushRSCCSS(target.cache, key, css, options?.id != null);
413
+ }
414
+ if (getConfig().autoPropertyTypes !== false) collectAutoInferredPropertiesRSC(styleResults, target.cache, resolvedStyles);
415
+ return;
416
+ }
417
+ if (slots) {
418
+ const releaseKeyframes = holdKeyframes(keyframes, options?.root);
419
+ existing?.dispose();
420
+ const { dispose } = injectGlobal(styleResults, { root: options?.root });
421
+ slots.set(slotKey, {
422
+ stylesKey,
423
+ dispose: () => {
424
+ dispose();
425
+ releaseKeyframes();
426
+ }
427
+ });
428
+ }
429
+ }
430
+ function holdKeyframes(keyframes, root) {
431
+ if (!keyframes) return noop;
432
+ const injector = getGlobalInjector();
433
+ const disposers = [...keyframes].map(([name, steps]) => injector.keyframes(steps, {
434
+ name,
435
+ root,
436
+ distinctByName: true
437
+ }).dispose);
438
+ return () => {
439
+ for (const dispose of disposers) dispose();
440
+ };
441
+ }
442
+ //#endregion
443
+ //#region src/hooks/useRawCSS.ts
444
+ const getClientState$1 = /* @__PURE__ */ createClientState(() => ({
445
+ entries: /* @__PURE__ */ new Map(),
446
+ dedup: /* @__PURE__ */ new Set(),
447
+ deps: /* @__PURE__ */ new Map()
448
+ }));
449
+ function useRawCSS(cssOrFactory, depsOrOptions, options) {
450
+ const isFactory = typeof cssOrFactory === "function";
451
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
452
+ const opts = isFactory ? options : depsOrOptions;
453
+ const id = opts?.id;
454
+ const target = getStyleTarget();
455
+ const state = target.mode === "client" ? getClientState$1(opts?.root ?? document) : null;
456
+ if (isFactory && deps && id && state) {
457
+ const cachedDeps = state.deps.get(id);
458
+ if (cachedDeps && depsEqual(cachedDeps, deps)) return;
459
+ }
460
+ const css = isFactory ? cssOrFactory() : cssOrFactory;
461
+ if (!css.trim()) return;
462
+ if (target.mode !== "client") {
463
+ const key = `${target.mode === "rsc" ? "__" : ""}raw:${id || hashString(css)}`;
464
+ const replace = id != null;
465
+ if (target.mode === "ssr") target.collector.collectRawCSS(key, css, replace);
466
+ else pushRSCCSS(target.cache, key, css, replace);
467
+ return;
468
+ }
469
+ if (!state) return;
470
+ if (id) {
471
+ const existing = state.entries.get(id);
472
+ if (existing) {
473
+ if (existing.css === css) return;
474
+ existing.dispose();
475
+ }
476
+ const { dispose } = injectRawCSS(css, opts);
477
+ state.entries.set(id, {
478
+ css,
479
+ dispose
480
+ });
481
+ if (deps) state.deps.set(id, deps);
482
+ } else {
483
+ const contentKey = hashString(css);
484
+ if (state.dedup.has(contentKey)) return;
485
+ state.dedup.add(contentKey);
486
+ injectRawCSS(css, opts);
487
+ }
488
+ }
489
+ //#endregion
490
+ //#region src/hooks/useKeyframes.ts
491
+ const getClientState = /* @__PURE__ */ createClientState(() => ({
492
+ contentToName: /* @__PURE__ */ new Map(),
493
+ namedSlots: /* @__PURE__ */ new Map(),
494
+ factoryDeps: /* @__PURE__ */ new Map()
495
+ }));
496
+ function useKeyframes(stepsOrFactory, depsOrOptions, options) {
497
+ const isFactory = typeof stepsOrFactory === "function";
498
+ const deps = isFactory && Array.isArray(depsOrOptions) ? depsOrOptions : void 0;
499
+ const opts = isFactory ? options : depsOrOptions;
500
+ const target = getStyleTarget();
501
+ const clientState = target.mode === "client" ? getClientState(opts?.root ?? document) : null;
502
+ if (isFactory && deps && opts?.name && clientState) {
503
+ const cached = clientState.factoryDeps.get(opts.name);
504
+ if (cached && depsEqual(cached.deps, deps)) return cached.name;
505
+ }
506
+ const steps = isFactory ? stepsOrFactory() : stepsOrFactory;
507
+ if (!steps || Object.keys(steps).length === 0) return "";
508
+ if (target.mode === "ssr") {
509
+ const actualName = target.collector.allocateKeyframeName(opts?.name);
510
+ const css = formatKeyframesCSS(actualName, steps);
511
+ target.collector.collectKeyframes(actualName, css);
512
+ return actualName;
513
+ }
514
+ if (target.mode === "rsc") {
515
+ const serializedContent = JSON.stringify(steps);
516
+ const key = `__kf:${opts?.name ?? ""}:${serializedContent}`;
517
+ const existingName = target.cache.generatedNames.get(key);
518
+ if (existingName) return existingName;
519
+ const actualName = opts?.name ?? makeKeyframeName(getNamePrefix(), hashString(serializedContent));
520
+ const css = formatKeyframesCSS(actualName, steps);
521
+ pushRSCCSS(target.cache, key, css);
522
+ target.cache.generatedNames.set(key, actualName);
523
+ return actualName;
524
+ }
525
+ const state = clientState ?? getClientState(opts?.root ?? document);
526
+ const serializedContent = JSON.stringify(steps);
527
+ const cacheKey = `${opts?.name ?? ""}:${serializedContent}`;
528
+ const cachedName = state.contentToName.get(cacheKey);
529
+ if (cachedName) return cachedName;
530
+ const providedName = opts?.name;
531
+ if (providedName) {
532
+ const slot = state.namedSlots.get(providedName);
533
+ if (slot && slot.cacheKey !== cacheKey) {
534
+ slot.dispose();
535
+ state.contentToName.delete(slot.cacheKey);
536
+ state.namedSlots.delete(providedName);
537
+ }
538
+ }
539
+ const result = keyframes(steps, {
540
+ name: providedName,
541
+ root: opts?.root
542
+ });
543
+ const name = result.toString();
544
+ state.contentToName.set(cacheKey, name);
545
+ if (providedName) {
546
+ state.namedSlots.set(providedName, {
547
+ cacheKey,
548
+ dispose: result.dispose
549
+ });
550
+ if (deps) state.factoryDeps.set(providedName, {
551
+ deps,
552
+ name
553
+ });
554
+ }
555
+ return name;
556
+ }
557
+ //#endregion
558
+ //#region src/hooks/useProperty.ts
559
+ function useProperty(name, options) {
560
+ if (!name) {
561
+ if (process.env.NODE_ENV !== "production") console.warn(`[Tasty] useProperty: property name is required`);
562
+ return;
563
+ }
564
+ const target = getStyleTarget();
565
+ if (target.mode === "ssr") {
566
+ target.collector.collectInternals();
567
+ const css = formatPropertyCSS(name, {
568
+ syntax: options?.syntax,
569
+ inherits: options?.inherits,
570
+ initialValue: options?.initialValue
571
+ });
572
+ if (css) target.collector.collectProperty(name, css);
573
+ return;
574
+ }
575
+ if (target.mode === "rsc") {
576
+ const css = formatPropertyCSS(name, {
577
+ syntax: options?.syntax,
578
+ inherits: options?.inherits,
579
+ initialValue: options?.initialValue
580
+ });
581
+ if (css) pushRSCCSS(target.cache, `__prop:${name}`, css);
582
+ return;
583
+ }
584
+ const injector = getGlobalInjector();
585
+ if (injector.isPropertyDefined(name, { root: options?.root })) return;
586
+ injector.property(name, {
587
+ syntax: options?.syntax,
588
+ inherits: options?.inherits,
589
+ initialValue: options?.initialValue,
590
+ root: options?.root
591
+ });
592
+ }
593
+ //#endregion
594
+ //#region src/hooks/useFontFace.ts
595
+ function useFontFace(family, input, options) {
596
+ if (!family) return;
597
+ const descriptors = Array.isArray(input) ? input : [input];
598
+ const target = getStyleTarget();
599
+ if (target.mode === "ssr") {
600
+ for (const desc of descriptors) {
601
+ const hash = fontFaceContentHash(family, desc);
602
+ const css = formatFontFaceRule(family, desc);
603
+ target.collector.collectFontFace(hash, css);
604
+ }
605
+ return;
606
+ }
607
+ if (target.mode === "rsc") {
608
+ for (const desc of descriptors) {
609
+ const hash = fontFaceContentHash(family, desc);
610
+ const css = formatFontFaceRule(family, desc);
611
+ pushRSCCSS(target.cache, `__ff:${hash}`, css);
612
+ }
613
+ return;
614
+ }
615
+ const injector = getGlobalInjector();
616
+ for (const desc of descriptors) injector.fontFace(family, desc, { root: options?.root });
617
+ }
618
+ //#endregion
619
+ //#region src/hooks/useCounterStyle.ts
620
+ let clientCounterStyleCounter = 0;
621
+ const getClientContentToName = /* @__PURE__ */ createClientState(() => /* @__PURE__ */ new Map());
622
+ function useCounterStyle(descriptors, options) {
623
+ if (!descriptors || !descriptors.system) return "";
624
+ const target = getStyleTarget();
625
+ if (target.mode === "ssr") {
626
+ const actualName = target.collector.allocateCounterStyleName(options?.name);
627
+ const css = formatCounterStyleRule(actualName, descriptors);
628
+ target.collector.collectCounterStyle(actualName, css);
629
+ return actualName;
630
+ }
631
+ if (target.mode === "rsc") {
632
+ const serializedContent = JSON.stringify(descriptors);
633
+ const key = `__cs:${options?.name ?? ""}:${serializedContent}`;
634
+ const existingName = target.cache.generatedNames.get(key);
635
+ if (existingName) return existingName;
636
+ const actualName = options?.name ?? makeCounterStyleName(getNamePrefix(), hashString(serializedContent));
637
+ const css = formatCounterStyleRule(actualName, descriptors);
638
+ pushRSCCSS(target.cache, key, css);
639
+ target.cache.generatedNames.set(key, actualName);
640
+ return actualName;
641
+ }
642
+ const contentToName = getClientContentToName(options?.root ?? document);
643
+ const serializedContent = JSON.stringify(descriptors);
644
+ const cacheKey = `${options?.name ?? ""}:${serializedContent}`;
645
+ const existingName = contentToName.get(cacheKey);
646
+ if (existingName) return existingName;
647
+ const name = options?.name ?? makeCounterStyleName(getNamePrefix(), String(clientCounterStyleCounter++));
648
+ contentToName.set(cacheKey, name);
649
+ getGlobalInjector().counterStyle(name, descriptors, { root: options?.root });
650
+ return name;
651
+ }
652
+ //#endregion
653
+ //#region src/hooks/useFunction.ts
654
+ function useFunction(name, definition, options) {
655
+ if (!name) {
656
+ if (process.env.NODE_ENV !== "production") console.warn(`[Tasty] useFunction: function name is required`);
657
+ return;
658
+ }
659
+ if (isFunctionsPolyfillEnabled()) {
660
+ registerFunctionPolyfill(name, definition);
661
+ return;
662
+ }
663
+ const target = getStyleTarget();
664
+ if (target.mode === "ssr") {
665
+ target.collector.collectInternals();
666
+ const css = formatFunctionRule(name, definition);
667
+ if (css) target.collector.collectFunction(parseFunctionName(name), css);
668
+ return;
669
+ }
670
+ if (target.mode === "rsc") {
671
+ const css = formatFunctionRule(name, definition);
672
+ if (css) pushRSCCSS(target.cache, `__func:${parseFunctionName(name)}`, css);
673
+ return;
674
+ }
675
+ getGlobalInjector().func(name, definition, { root: options?.root });
676
+ }
677
+ //#endregion
678
+ //#region src/batch-provider.tsx
679
+ function TastyBatchProvider({ children }) {
680
+ openBatchWindow();
681
+ React.useInsertionEffect(() => {
682
+ closeBatchWindow();
683
+ });
684
+ return children;
685
+ }
686
+ //#endregion
687
+ 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 };
688
+
689
+ //# sourceMappingURL=react-runtime-DayjnPuC.js.map