@tenphi/tasty 0.0.0-snapshot.e244fdb → 0.0.0-snapshot.e360574
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.
- package/README.md +404 -385
- package/dist/babel-types-BqWM62mn.d.ts +18 -0
- package/dist/chunks/async-storage-f9j9JRtq.js +37 -0
- package/dist/chunks/async-storage-f9j9JRtq.js.map +1 -0
- package/dist/chunks/build-config-CGSGH4Sb.js +60 -0
- package/dist/chunks/build-config-CGSGH4Sb.js.map +1 -0
- package/dist/chunks/{collector-B0LTHw6Z.js → collector-CbphuMNW.js} +8 -6
- package/dist/chunks/collector-CbphuMNW.js.map +1 -0
- package/dist/chunks/{config-engine-C3pF9EK9.js → config-engine-_hRNSRwz.js} +17 -12
- package/dist/chunks/{config-engine-C3pF9EK9.js.map → config-engine-_hRNSRwz.js.map} +1 -1
- package/dist/chunks/config-file-DlZXJMj8.js +25 -0
- package/dist/chunks/config-file-DlZXJMj8.js.map +1 -0
- package/dist/chunks/{css-definitions-D_it4XZH.js → css-definitions-DKApeTsI.js} +55 -30
- package/dist/chunks/css-definitions-DKApeTsI.js.map +1 -0
- package/dist/chunks/{css-resources-BN8apgxt.js → css-resources-P7IBUUZs.js} +2 -2
- package/dist/chunks/{css-resources-BN8apgxt.js.map → css-resources-P7IBUUZs.js.map} +1 -1
- package/dist/chunks/{debug-C9LeNVoJ.js → debug-Der12dU3.js} +22 -21
- package/dist/chunks/{debug-C9LeNVoJ.js.map → debug-Der12dU3.js.map} +1 -1
- package/dist/chunks/{dsl-C5yuAn41.js → dsl-Ddc5EUBK.js} +51 -41
- package/dist/chunks/dsl-Ddc5EUBK.js.map +1 -0
- package/dist/chunks/{react-runtime-O-OUrKLH.js → react-runtime-Kw_SrIv_.js} +214 -82
- package/dist/chunks/react-runtime-Kw_SrIv_.js.map +1 -0
- package/dist/chunks/{runtime-engine-DvnE2g-E.js → runtime-engine-D04uhJXm.js} +96 -102
- package/dist/chunks/runtime-engine-D04uhJXm.js.map +1 -0
- package/dist/chunks/{runtime-state-BTDqSYBk.js → runtime-state-BUq5X_CG.js} +17 -3
- package/dist/chunks/runtime-state-BUq5X_CG.js.map +1 -0
- package/dist/chunks/{shared-utils-DWA4LjIa.js → shared-utils-y-HjvPN4.js} +16 -12
- package/dist/chunks/{shared-utils-DWA4LjIa.js.map → shared-utils-y-HjvPN4.js.map} +1 -1
- package/dist/chunks/{style-engine-C1ECBZxR.js → style-engine-C2Z26n3a.js} +509 -199
- package/dist/chunks/style-engine-C2Z26n3a.js.map +1 -0
- package/dist/chunks/{zero-engine-B6EnYcXY.js → zero-engine-DaRIJYuG.js} +65 -28
- package/dist/chunks/zero-engine-DaRIJYuG.js.map +1 -0
- package/dist/{collector-hl5KNH7k.d.ts → collector-mcfTc7CF.d.ts} +2 -3
- package/dist/{config-DWL1ZYue.d.ts → config-mZhgbrmh.d.ts} +36 -26
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +8 -8
- package/dist/hydrate-CRyjjAyl.d.ts +22 -0
- package/dist/{index-D9N9GV24.d.ts → index-BFfu4ucC.d.ts} +176 -177
- package/dist/index.d.ts +4 -4
- package/dist/index.js +9 -9
- package/dist/{merge-styles-C_oMoJVd.d.ts → merge-styles-CaNZmN4Y.d.ts} +2 -3
- package/dist/ssr/astro-client.d.ts +1 -1
- package/dist/ssr/astro-middleware-extract-static.d.ts +1 -2
- package/dist/ssr/astro-middleware-extract.d.ts +1 -2
- package/dist/ssr/astro-middleware-static.d.ts +1 -2
- package/dist/ssr/astro-middleware.d.ts +1 -2
- package/dist/ssr/astro.d.ts +8 -16
- package/dist/ssr/astro.js +7 -6
- package/dist/ssr/astro.js.map +1 -1
- package/dist/ssr/client.d.ts +2 -0
- package/dist/ssr/client.js +2 -0
- package/dist/ssr/index.d.ts +5 -25
- package/dist/ssr/index.js +4 -4
- package/dist/ssr/index.js.map +1 -1
- package/dist/ssr/next-config.d.ts +3 -5
- package/dist/ssr/next-config.js +20 -21
- package/dist/ssr/next-config.js.map +1 -1
- package/dist/ssr/next.d.ts +3 -9
- package/dist/ssr/next.js +5 -4
- package/dist/ssr/next.js.map +1 -1
- package/dist/static/index.d.ts +8 -9
- package/dist/static/index.js +4 -4
- package/dist/static/index.js.map +1 -1
- package/dist/static/inject.d.ts +1 -2
- package/dist/{types-jKZNpias.d.ts → types-YL3eMjVH.d.ts} +17 -67
- package/dist/zero/babel.d.ts +67 -2
- package/dist/zero/babel.js +66 -58
- package/dist/zero/babel.js.map +1 -1
- package/dist/zero/index.d.ts +44 -8
- package/dist/zero/index.js +24 -2
- package/dist/zero/index.js.map +1 -0
- package/dist/zero/next.d.ts +4 -5
- package/dist/zero/next.js +3 -7
- package/dist/zero/next.js.map +1 -1
- package/docs/README.md +4 -1
- package/docs/adoption.md +25 -17
- package/docs/ai-agents.md +59 -35
- package/docs/comparison.md +9 -8
- package/docs/configuration.md +191 -60
- package/docs/debug.md +3 -2
- package/docs/design-system.md +117 -15
- package/docs/dsl.md +167 -82
- package/docs/getting-started.md +81 -22
- package/docs/injector.md +39 -40
- package/docs/methodology.md +47 -22
- package/docs/migration-v3.md +2 -2
- package/docs/pipeline.md +50 -26
- package/docs/plugins.md +21 -41
- package/docs/react-api.md +30 -8
- package/docs/runtime-benchmarks.md +53 -45
- package/docs/ssr.md +84 -64
- package/docs/styles.md +69 -21
- package/docs/tasty-static.md +133 -56
- package/package.json +55 -40
- package/dist/babel-Zs1Q03qt.d.ts +0 -83
- package/dist/chunks/async-storage-CG5HnUT5.js +0 -20
- package/dist/chunks/async-storage-CG5HnUT5.js.map +0 -1
- package/dist/chunks/build-config-CUQVwdWF.js +0 -42
- package/dist/chunks/build-config-CUQVwdWF.js.map +0 -1
- package/dist/chunks/collector-B0LTHw6Z.js.map +0 -1
- package/dist/chunks/css-definitions-D_it4XZH.js.map +0 -1
- package/dist/chunks/dsl-C5yuAn41.js.map +0 -1
- package/dist/chunks/react-runtime-O-OUrKLH.js.map +0 -1
- package/dist/chunks/runtime-engine-DvnE2g-E.js.map +0 -1
- package/dist/chunks/runtime-state-BTDqSYBk.js.map +0 -1
- package/dist/chunks/style-engine-C1ECBZxR.js.map +0 -1
- package/dist/chunks/zero-engine-B6EnYcXY.js.map +0 -1
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
import { n as isSelector, t as mergeStyles } from "./shared-utils-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
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-DKApeTsI.js";
|
|
3
|
+
import { b as renderStyles, i as baseStylePropsRegistry, q as isFunctionsPolyfillEnabled, s as BASE_STYLES } from "./style-engine-C2Z26n3a.js";
|
|
4
|
+
import { l as getGlobalKeyframes } from "./runtime-state-BUq5X_CG.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-D04uhJXm.js";
|
|
6
|
+
import React, { Fragment, createElement, forwardRef } from "react";
|
|
6
7
|
//#region src/utils/get-display-name.ts
|
|
7
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
|
+
}
|
|
8
17
|
function getDisplayName(Component, fallbackName = DEFAULT_NAME) {
|
|
9
|
-
|
|
10
|
-
return fallbackName;
|
|
18
|
+
return nameOf(Component) ?? fallbackName;
|
|
11
19
|
}
|
|
12
20
|
//#endregion
|
|
13
21
|
//#region src/utils/is-valid-element-type.ts
|
|
@@ -66,6 +74,84 @@ function createSubElement(elementName, definition) {
|
|
|
66
74
|
SubElement.displayName = `SubElement(${elementName})`;
|
|
67
75
|
return SubElement;
|
|
68
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
|
+
}
|
|
69
155
|
function buildTokenPropsMapping(def) {
|
|
70
156
|
if (Array.isArray(def)) return def.map((propName) => {
|
|
71
157
|
if (propName.endsWith("Color") && propName.length > 5) return [propName, `#${propName.slice(0, -5)}`];
|
|
@@ -78,58 +164,68 @@ function tasty(Component, options) {
|
|
|
78
164
|
return tastyElement(Component);
|
|
79
165
|
}
|
|
80
166
|
function tastyWrap(Component, options) {
|
|
81
|
-
const { as: extendTag, element: extendElement, styleProps
|
|
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;
|
|
82
174
|
const propsWithStyles = ["styles"];
|
|
83
175
|
for (const prop of Object.keys(defaultProps)) if (prop.endsWith("Styles")) propsWithStyles.push(prop);
|
|
176
|
+
const mergedCache = /* @__PURE__ */ new WeakMap();
|
|
84
177
|
const _WrappedComponent = forwardRef((props, ref) => {
|
|
85
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;
|
|
86
184
|
const mergedStylesMap = {};
|
|
87
185
|
for (const prop of propsWithStyles) {
|
|
88
186
|
const restValue = restProps[prop];
|
|
89
|
-
const defaultValue = defaultProps[prop];
|
|
90
|
-
mergedStylesMap[prop] = restValue != null && defaultValue != null ?
|
|
187
|
+
const defaultValue = prop === "styles" ? baseStyles : defaultProps[prop];
|
|
188
|
+
mergedStylesMap[prop] = restValue != null && defaultValue != null ? getMergedStyles(mergedCache, defaultValue, restValue).styles : restValue ?? defaultValue;
|
|
91
189
|
}
|
|
92
|
-
|
|
190
|
+
if (propStyles) mergedStylesMap.styles = mergeStyles(mergedStylesMap.styles, propStyles);
|
|
191
|
+
const elementProps = {
|
|
93
192
|
...defaultProps,
|
|
94
193
|
...restProps,
|
|
95
194
|
...mergedStylesMap,
|
|
96
195
|
as: as ?? extendTag,
|
|
97
196
|
element: element || extendElement,
|
|
98
197
|
ref
|
|
99
|
-
}
|
|
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);
|
|
100
209
|
});
|
|
101
210
|
_WrappedComponent.displayName = `TastyWrappedComponent(${getDisplayName(Component, defaultProps.qa ?? extendTag ?? "Anonymous")})`;
|
|
211
|
+
hoistComponentStatics(_WrappedComponent, Component);
|
|
212
|
+
if (elements) Object.assign(_WrappedComponent, createSubElements(elements));
|
|
102
213
|
return _WrappedComponent;
|
|
103
214
|
}
|
|
104
215
|
function tastyElement(tastyOptions) {
|
|
105
|
-
const { as: originalAs = "div", element: defaultElement, styles: defaultStyles, styleProps, modProps: modPropsDef, tokenProps: tokenPropsDef, variants, tokens: defaultTokens, elements, ...defaultProps } = tastyOptions;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
let baseStyles = defaultStyles;
|
|
109
|
-
let extensionStyles;
|
|
110
|
-
if (defaultStyles) for (const key of Object.keys(defaultStyles)) {
|
|
111
|
-
if (isSelector(key)) continue;
|
|
112
|
-
const value = defaultStyles[key];
|
|
113
|
-
if (typeof value === "object" && value !== null && !Array.isArray(value) && !("" in value)) {
|
|
114
|
-
if (!extensionStyles) {
|
|
115
|
-
baseStyles = { ...defaultStyles };
|
|
116
|
-
extensionStyles = {};
|
|
117
|
-
}
|
|
118
|
-
extensionStyles[key] = value;
|
|
119
|
-
delete baseStyles[key];
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
variantStylesMap = {};
|
|
123
|
-
for (const [variant, variantStyles] of Object.entries(variants)) variantStylesMap[variant] = extensionStyles ? mergeStyles(baseStyles, variantStyles, extensionStyles) : mergeStyles(baseStyles, variantStyles);
|
|
124
|
-
if (!variantStylesMap["default"]) variantStylesMap["default"] = defaultStyles;
|
|
125
|
-
}
|
|
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;
|
|
126
219
|
const { qa: defaultQa, qaVal: defaultQaVal, ...otherDefaultProps } = defaultProps;
|
|
127
220
|
const ownPropsToCheck = styleProps ? styleProps.concat(BASE_STYLES) : BASE_STYLES;
|
|
128
221
|
let propsToCheck = ownPropsToCheck;
|
|
129
222
|
let propsToCheckVersion = -1;
|
|
130
|
-
const modPropsKeys = modPropsDef ?
|
|
223
|
+
const modPropsKeys = modPropsDef ? getModPropsKeys(modPropsDef) : void 0;
|
|
131
224
|
const tokenPropsMapping = tokenPropsDef ? buildTokenPropsMapping(tokenPropsDef) : void 0;
|
|
132
|
-
|
|
225
|
+
let classNameCache = /* @__PURE__ */ new Map();
|
|
226
|
+
let mergedCache = /* @__PURE__ */ new WeakMap();
|
|
227
|
+
let cacheInjector;
|
|
228
|
+
let cacheEvictions = 0;
|
|
133
229
|
const STABLE_STYLES = { stableStyles: true };
|
|
134
230
|
const _TastyComponent = forwardRef((incomingProps, ref) => {
|
|
135
231
|
const applyPropHandlers = propHandlerRegistry.apply;
|
|
@@ -150,50 +246,63 @@ function tastyElement(tastyOptions) {
|
|
|
150
246
|
delete otherProps[key];
|
|
151
247
|
}
|
|
152
248
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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;
|
|
159
261
|
}
|
|
160
262
|
}
|
|
161
|
-
let
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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);
|
|
168
276
|
}
|
|
169
|
-
const baseStyles = variantStylesMap ? variantStylesMap[variant || "default"] ?? variantStylesMap["default"] : defaultStyles;
|
|
170
|
-
const allStyles = styles && hasKeys(styles) || !!propStyles ? mergeStyles(baseStyles, styles, propStyles) : baseStyles;
|
|
171
|
-
const useFactoryCache = typeof document !== "undefined";
|
|
172
|
-
let generatedClassName = useFactoryCache && allStyles === baseStyles ? classNameCache.get(allStyles) : void 0;
|
|
173
277
|
let rscCSS;
|
|
174
278
|
if (generatedClassName !== void 0) touch(generatedClassName);
|
|
175
279
|
else {
|
|
176
280
|
const result = computeStyles(allStyles, !useFactoryCache && allStyles === baseStyles ? STABLE_STYLES : void 0);
|
|
177
281
|
generatedClassName = result.className;
|
|
178
282
|
rscCSS = result.css;
|
|
179
|
-
if (
|
|
283
|
+
if (mergedEntry) mergedEntry.className = generatedClassName;
|
|
284
|
+
else if (useFactoryCache && allStyles === baseStyles) classNameCache.set(allStyles, generatedClassName);
|
|
180
285
|
}
|
|
181
286
|
let mergedTokens;
|
|
182
|
-
if (defaultTokens || tokens || propTokens)
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
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
|
+
}
|
|
189
296
|
const processedTokenStyle = processTokens(mergedTokens);
|
|
190
297
|
let mergedStyle;
|
|
191
|
-
if (processedTokenStyle || style)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
298
|
+
if (processedTokenStyle || style) {
|
|
299
|
+
if (!processedTokenStyle) mergedStyle = style;
|
|
300
|
+
else if (!style) mergedStyle = processedTokenStyle;
|
|
301
|
+
else mergedStyle = {
|
|
302
|
+
...processedTokenStyle,
|
|
303
|
+
...style
|
|
304
|
+
};
|
|
305
|
+
}
|
|
197
306
|
const mergedMods = propMods ? {
|
|
198
307
|
...mods,
|
|
199
308
|
...propMods
|
|
@@ -218,6 +327,7 @@ function tastyElement(tastyOptions) {
|
|
|
218
327
|
if (elementProps["data-theme"] === void 0) delete elementProps["data-theme"];
|
|
219
328
|
const el = createElement(as ?? originalAs, elementProps);
|
|
220
329
|
if (rscCSS) {
|
|
330
|
+
checkRequestScope();
|
|
221
331
|
const nonce = getConfig().nonce;
|
|
222
332
|
return createElement(Fragment, null, createElement("style", {
|
|
223
333
|
"data-tasty-rsc": "",
|
|
@@ -228,11 +338,7 @@ function tastyElement(tastyOptions) {
|
|
|
228
338
|
return el;
|
|
229
339
|
});
|
|
230
340
|
_TastyComponent.displayName = `TastyComponent(${defaultProps.qa || originalAs})`;
|
|
231
|
-
if (elements)
|
|
232
|
-
const subElements = {};
|
|
233
|
-
for (const [name, definition] of Object.entries(elements)) subElements[name] = createSubElement(name, definition);
|
|
234
|
-
return Object.assign(_TastyComponent, subElements);
|
|
235
|
-
}
|
|
341
|
+
if (elements) return Object.assign(_TastyComponent, createSubElements(elements));
|
|
236
342
|
return _TastyComponent;
|
|
237
343
|
}
|
|
238
344
|
const Element = /* @__PURE__ */ tasty({});
|
|
@@ -240,16 +346,23 @@ const Element = /* @__PURE__ */ tasty({});
|
|
|
240
346
|
//#region src/ssr/context.ts
|
|
241
347
|
let _ctx;
|
|
242
348
|
function getTastySSRContext() {
|
|
243
|
-
if (!_ctx) _ctx = createContext(null);
|
|
349
|
+
if (!_ctx) _ctx = React.createContext(null);
|
|
244
350
|
return _ctx;
|
|
245
351
|
}
|
|
246
352
|
//#endregion
|
|
247
353
|
//#region src/hooks/useStyles.ts
|
|
354
|
+
const useContextCollector = typeof React.useContext === "function" ? () => React.useContext(getTastySSRContext()) : () => null;
|
|
248
355
|
function useStyles(styles, options) {
|
|
249
|
-
|
|
250
|
-
ssrCollector:
|
|
356
|
+
const result = computeStyles(styles, {
|
|
357
|
+
ssrCollector: useContextCollector(),
|
|
251
358
|
root: options?.root
|
|
252
359
|
});
|
|
360
|
+
if (result.css) {
|
|
361
|
+
checkRequestScope();
|
|
362
|
+
queueRSCCSS(getRSCCache(), result.css);
|
|
363
|
+
return { className: result.className };
|
|
364
|
+
}
|
|
365
|
+
return result;
|
|
253
366
|
}
|
|
254
367
|
//#endregion
|
|
255
368
|
//#region src/hooks/useGlobalStyles.ts
|
|
@@ -258,7 +371,7 @@ const noop = () => {};
|
|
|
258
371
|
function useGlobalStyles(selector, styles, options) {
|
|
259
372
|
if (!styles) return;
|
|
260
373
|
if (!selector) {
|
|
261
|
-
console.warn("[Tasty] useGlobalStyles: selector is required and cannot be empty. Styles will not be injected.");
|
|
374
|
+
if (process.env.NODE_ENV !== "production") console.warn("[Tasty] useGlobalStyles: selector is required and cannot be empty. Styles will not be injected.");
|
|
262
375
|
return;
|
|
263
376
|
}
|
|
264
377
|
const target = getStyleTarget();
|
|
@@ -268,8 +381,8 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
268
381
|
const existing = slots?.get(slotKey);
|
|
269
382
|
if (existing && existing.stylesKey === stylesKey) return;
|
|
270
383
|
const resolvedStyles = resolveRecipes(styles);
|
|
271
|
-
const
|
|
272
|
-
if (
|
|
384
|
+
const rendered = renderStyles(resolvedStyles, selector);
|
|
385
|
+
if (rendered.length === 0) {
|
|
273
386
|
if (slots) {
|
|
274
387
|
existing?.dispose();
|
|
275
388
|
slots.set(slotKey, {
|
|
@@ -279,8 +392,10 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
279
392
|
}
|
|
280
393
|
return;
|
|
281
394
|
}
|
|
395
|
+
const { rules: styleResults, keyframes } = resolveSelectorKeyframes(resolvedStyles, rendered, getGlobalKeyframes());
|
|
282
396
|
if (target.mode === "ssr") {
|
|
283
397
|
target.collector.collectInternals();
|
|
398
|
+
if (keyframes) for (const [name, steps] of keyframes) target.collector.collectKeyframes(name, formatKeyframesCSS(name, steps));
|
|
284
399
|
const css = formatGlobalRules(styleResults);
|
|
285
400
|
if (css) {
|
|
286
401
|
const key = options?.id ? `global:${options.id}` : `global:${selector}:${hashString(css)}`;
|
|
@@ -290,6 +405,7 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
290
405
|
return;
|
|
291
406
|
}
|
|
292
407
|
if (target.mode === "rsc") {
|
|
408
|
+
if (keyframes) for (const [name, steps] of keyframes) pushRSCCSS(target.cache, `__kf:${name}`, formatKeyframesCSS(name, steps));
|
|
293
409
|
const css = formatGlobalRules(styleResults);
|
|
294
410
|
if (css) {
|
|
295
411
|
const key = options?.id ? `__global:${options.id}` : `__global:${selector}:${hashString(css)}`;
|
|
@@ -299,14 +415,30 @@ function useGlobalStyles(selector, styles, options) {
|
|
|
299
415
|
return;
|
|
300
416
|
}
|
|
301
417
|
if (slots) {
|
|
418
|
+
const releaseKeyframes = holdKeyframes(keyframes, options?.root);
|
|
302
419
|
existing?.dispose();
|
|
303
420
|
const { dispose } = injectGlobal(styleResults, { root: options?.root });
|
|
304
421
|
slots.set(slotKey, {
|
|
305
422
|
stylesKey,
|
|
306
|
-
dispose
|
|
423
|
+
dispose: () => {
|
|
424
|
+
dispose();
|
|
425
|
+
releaseKeyframes();
|
|
426
|
+
}
|
|
307
427
|
});
|
|
308
428
|
}
|
|
309
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
|
+
}
|
|
310
442
|
//#endregion
|
|
311
443
|
//#region src/hooks/useRawCSS.ts
|
|
312
444
|
const getClientState$1 = /* @__PURE__ */ createClientState(() => ({
|
|
@@ -426,7 +558,7 @@ function useKeyframes(stepsOrFactory, depsOrOptions, options) {
|
|
|
426
558
|
//#region src/hooks/useProperty.ts
|
|
427
559
|
function useProperty(name, options) {
|
|
428
560
|
if (!name) {
|
|
429
|
-
console.warn(`[Tasty] useProperty: property name is required`);
|
|
561
|
+
if (process.env.NODE_ENV !== "production") console.warn(`[Tasty] useProperty: property name is required`);
|
|
430
562
|
return;
|
|
431
563
|
}
|
|
432
564
|
const target = getStyleTarget();
|
|
@@ -521,7 +653,7 @@ function useCounterStyle(descriptors, options) {
|
|
|
521
653
|
//#region src/hooks/useFunction.ts
|
|
522
654
|
function useFunction(name, definition, options) {
|
|
523
655
|
if (!name) {
|
|
524
|
-
console.warn(`[Tasty] useFunction: function name is required`);
|
|
656
|
+
if (process.env.NODE_ENV !== "production") console.warn(`[Tasty] useFunction: function name is required`);
|
|
525
657
|
return;
|
|
526
658
|
}
|
|
527
659
|
if (isFunctionsPolyfillEnabled()) {
|
|
@@ -546,7 +678,7 @@ function useFunction(name, definition, options) {
|
|
|
546
678
|
//#region src/batch-provider.tsx
|
|
547
679
|
function TastyBatchProvider({ children }) {
|
|
548
680
|
openBatchWindow();
|
|
549
|
-
useInsertionEffect(() => {
|
|
681
|
+
React.useInsertionEffect(() => {
|
|
550
682
|
closeBatchWindow();
|
|
551
683
|
});
|
|
552
684
|
return children;
|
|
@@ -554,4 +686,4 @@ function TastyBatchProvider({ children }) {
|
|
|
554
686
|
//#endregion
|
|
555
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 };
|
|
556
688
|
|
|
557
|
-
//# sourceMappingURL=react-runtime-
|
|
689
|
+
//# sourceMappingURL=react-runtime-Kw_SrIv_.js.map
|