tailwind-styled-v4 4.0.0 → 5.0.0
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/dist/animate.cjs +754 -235
- package/dist/animate.cjs.map +1 -1
- package/dist/animate.d.cts +55 -99
- package/dist/animate.d.ts +55 -99
- package/dist/animate.js +742 -235
- package/dist/animate.js.map +1 -1
- package/dist/chunk-VZEJV27B.js +11 -0
- package/dist/chunk-VZEJV27B.js.map +1 -0
- package/dist/chunk-Y5D3E72P.cjs +13 -0
- package/dist/chunk-Y5D3E72P.cjs.map +1 -0
- package/dist/css.cjs +61 -11
- package/dist/css.cjs.map +1 -1
- package/dist/css.d.cts +3 -18
- package/dist/css.d.ts +3 -18
- package/dist/css.js +61 -11
- package/dist/css.js.map +1 -1
- package/dist/devtools.cjs +200 -88
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js +200 -88
- package/dist/devtools.js.map +1 -1
- package/dist/index.cjs +430 -135
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +74 -3
- package/dist/index.d.ts +74 -3
- package/dist/index.js +415 -132
- package/dist/index.js.map +1 -1
- package/dist/next.cjs +118 -138
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.cts +28 -19
- package/dist/next.d.ts +28 -19
- package/dist/next.js +111 -131
- package/dist/next.js.map +1 -1
- package/dist/preset.cjs +312 -18
- package/dist/preset.cjs.map +1 -1
- package/dist/preset.d.cts +29 -2
- package/dist/preset.d.ts +29 -2
- package/dist/preset.js +311 -19
- package/dist/preset.js.map +1 -1
- package/dist/turbopackLoader.cjs +24 -2676
- package/dist/turbopackLoader.cjs.map +1 -1
- package/dist/turbopackLoader.d.cts +3 -13
- package/dist/turbopackLoader.d.ts +3 -13
- package/dist/turbopackLoader.js +24 -2670
- package/dist/turbopackLoader.js.map +1 -1
- package/dist/vite.cjs +90 -57
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.d.cts +35 -6
- package/dist/vite.d.ts +35 -6
- package/dist/vite.js +90 -58
- package/dist/vite.js.map +1 -1
- package/dist/webpackLoader.cjs +27 -2646
- package/dist/webpackLoader.cjs.map +1 -1
- package/dist/webpackLoader.d.cts +3 -10
- package/dist/webpackLoader.d.ts +3 -10
- package/dist/webpackLoader.js +27 -2640
- package/dist/webpackLoader.js.map +1 -1
- package/package.json +31 -28
- package/dist/astTransform-ua-eapqs.d.cts +0 -41
- package/dist/astTransform-ua-eapqs.d.ts +0 -41
- package/dist/compiler.cjs +0 -3594
- package/dist/compiler.cjs.map +0 -1
- package/dist/compiler.d.cts +0 -716
- package/dist/compiler.d.ts +0 -716
- package/dist/compiler.js +0 -3535
- package/dist/compiler.js.map +0 -1
- package/dist/plugins.cjs +0 -396
- package/dist/plugins.cjs.map +0 -1
- package/dist/plugins.d.cts +0 -231
- package/dist/plugins.d.ts +0 -231
- package/dist/plugins.js +0 -381
- package/dist/plugins.js.map +0 -1
- package/dist/theme.cjs +0 -154
- package/dist/theme.cjs.map +0 -1
- package/dist/theme.d.cts +0 -181
- package/dist/theme.d.ts +0 -181
- package/dist/theme.js +0 -148
- package/dist/theme.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
|
+
import { __require } from './chunk-VZEJV27B.js';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import { twMerge } from 'tailwind-merge';
|
|
3
4
|
|
|
4
5
|
/* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
5
|
-
var __defProp = Object.defineProperty;
|
|
6
|
-
var __defProps = Object.defineProperties;
|
|
7
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
8
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
25
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
26
|
-
}) : x)(function(x) {
|
|
27
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
28
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
29
|
-
});
|
|
30
|
-
var __objRest = (source, exclude) => {
|
|
31
|
-
var target = {};
|
|
32
|
-
for (var prop in source)
|
|
33
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
34
|
-
target[prop] = source[prop];
|
|
35
|
-
if (source != null && __getOwnPropSymbols)
|
|
36
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
37
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
38
|
-
target[prop] = source[prop];
|
|
39
|
-
}
|
|
40
|
-
return target;
|
|
41
|
-
};
|
|
42
6
|
|
|
43
7
|
// src/containerQuery.ts
|
|
44
8
|
var CONTAINER_BREAKPOINTS = {
|
|
@@ -54,7 +18,7 @@ if (typeof window !== "undefined") {
|
|
|
54
18
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
55
19
|
}
|
|
56
20
|
function hashContainer(tag, container, name) {
|
|
57
|
-
const key = tag + (name
|
|
21
|
+
const key = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
58
22
|
let hash = 5381;
|
|
59
23
|
for (let i = 0; i < key.length; i++) {
|
|
60
24
|
hash = (hash << 5) + hash ^ key.charCodeAt(i);
|
|
@@ -113,31 +77,29 @@ var LAYOUT_MAP = {
|
|
|
113
77
|
"justify-end": "justify-content:flex-end"
|
|
114
78
|
};
|
|
115
79
|
function layoutClassesToCss(classes) {
|
|
116
|
-
var _a, _b;
|
|
117
80
|
const decls = [];
|
|
118
81
|
for (const cls of classes.trim().split(/\s+/)) {
|
|
119
82
|
if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
|
|
120
83
|
else if (cls.startsWith("w-[")) {
|
|
121
|
-
const val =
|
|
84
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
122
85
|
if (val) decls.push(`width:${val}`);
|
|
123
86
|
} else if (cls.startsWith("max-w-[")) {
|
|
124
|
-
const val =
|
|
87
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
125
88
|
if (val) decls.push(`max-width:${val}`);
|
|
126
89
|
}
|
|
127
90
|
}
|
|
128
91
|
return decls.join(";");
|
|
129
92
|
}
|
|
130
93
|
function buildContainerRules(id, container, containerName) {
|
|
131
|
-
var _a, _b, _c;
|
|
132
94
|
const rules = [];
|
|
133
95
|
for (const [key, value] of Object.entries(container)) {
|
|
134
96
|
let minWidth;
|
|
135
97
|
let classes;
|
|
136
98
|
if (typeof value === "string") {
|
|
137
|
-
minWidth =
|
|
99
|
+
minWidth = CONTAINER_BREAKPOINTS[key] ?? key;
|
|
138
100
|
classes = value;
|
|
139
101
|
} else {
|
|
140
|
-
minWidth =
|
|
102
|
+
minWidth = value.minWidth ?? CONTAINER_BREAKPOINTS[key] ?? key;
|
|
141
103
|
classes = value.classes;
|
|
142
104
|
}
|
|
143
105
|
const css = layoutClassesToCss(classes);
|
|
@@ -157,7 +119,7 @@ function injectContainerStyles(id, container, containerName) {
|
|
|
157
119
|
const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
|
|
158
120
|
for (const rule of css.split("\n").filter(Boolean)) batchedInject(rule);
|
|
159
121
|
return;
|
|
160
|
-
} catch
|
|
122
|
+
} catch {
|
|
161
123
|
}
|
|
162
124
|
const style = document.createElement("style");
|
|
163
125
|
style.id = styleId;
|
|
@@ -168,13 +130,10 @@ function injectContainerStyles(id, container, containerName) {
|
|
|
168
130
|
function processContainer(tag, container, containerName) {
|
|
169
131
|
const id = hashContainer(tag, container, containerName);
|
|
170
132
|
if (!containerRegistry.has(id)) {
|
|
171
|
-
const breakpoints = Object.entries(container).map(([key, value]) => {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
classes: typeof value === "string" ? value : value.classes
|
|
176
|
-
};
|
|
177
|
-
});
|
|
133
|
+
const breakpoints = Object.entries(container).map(([key, value]) => ({
|
|
134
|
+
minWidth: CONTAINER_BREAKPOINTS[key] ?? key,
|
|
135
|
+
classes: typeof value === "string" ? value : value.classes
|
|
136
|
+
}));
|
|
178
137
|
containerRegistry.set(id, {
|
|
179
138
|
id,
|
|
180
139
|
tag,
|
|
@@ -301,12 +260,11 @@ var TW_MAP = {
|
|
|
301
260
|
"text-zinc-500": "color:rgb(113,113,122)"
|
|
302
261
|
};
|
|
303
262
|
function twClassesToCss(classes) {
|
|
304
|
-
var _a;
|
|
305
263
|
const decls = [];
|
|
306
264
|
for (const cls of classes.trim().split(/\s+/)) {
|
|
307
265
|
if (TW_MAP[cls]) decls.push(TW_MAP[cls]);
|
|
308
266
|
else if (cls.includes("[") && cls.includes("]")) {
|
|
309
|
-
const val =
|
|
267
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
310
268
|
if (!val) continue;
|
|
311
269
|
if (cls.startsWith("bg-[")) decls.push(`background-color:${val}`);
|
|
312
270
|
else if (cls.startsWith("text-[")) decls.push(`color:${val}`);
|
|
@@ -333,7 +291,7 @@ function injectStateStyles(id, state) {
|
|
|
333
291
|
const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
|
|
334
292
|
for (const rule of rules) batchedInject(rule);
|
|
335
293
|
return;
|
|
336
|
-
} catch
|
|
294
|
+
} catch {
|
|
337
295
|
}
|
|
338
296
|
const style = document.createElement("style");
|
|
339
297
|
style.id = styleId;
|
|
@@ -387,10 +345,9 @@ function makeFilterProps(variantKeys) {
|
|
|
387
345
|
};
|
|
388
346
|
}
|
|
389
347
|
function resolveVariants(variants, props, defaults) {
|
|
390
|
-
var _a;
|
|
391
348
|
const classes = [];
|
|
392
349
|
for (const key in variants) {
|
|
393
|
-
const val =
|
|
350
|
+
const val = props[key] ?? defaults[key];
|
|
394
351
|
if (val !== void 0 && variants[key][String(val)]) {
|
|
395
352
|
classes.push(variants[key][String(val)]);
|
|
396
353
|
}
|
|
@@ -400,36 +357,35 @@ function resolveVariants(variants, props, defaults) {
|
|
|
400
357
|
function resolveCompound(compounds, props) {
|
|
401
358
|
const classes = [];
|
|
402
359
|
for (const compound of compounds) {
|
|
403
|
-
const
|
|
360
|
+
const { class: cls, ...conditions } = compound;
|
|
404
361
|
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
405
362
|
if (match) classes.push(cls);
|
|
406
363
|
}
|
|
407
364
|
return classes.join(" ");
|
|
408
365
|
}
|
|
409
366
|
function createComponent(tag, config) {
|
|
410
|
-
var _a, _b, _c, _d, _e;
|
|
411
367
|
const isStatic = typeof config === "string";
|
|
412
|
-
const base = isStatic ? config :
|
|
413
|
-
const variants = isStatic ? {} :
|
|
414
|
-
const compoundVariants = isStatic ? [] :
|
|
415
|
-
const defaultVariants = isStatic ? {} :
|
|
368
|
+
const base = isStatic ? config : config.base ?? "";
|
|
369
|
+
const variants = isStatic ? {} : config.variants ?? {};
|
|
370
|
+
const compoundVariants = isStatic ? [] : config.compoundVariants ?? [];
|
|
371
|
+
const defaultVariants = isStatic ? {} : config.defaultVariants ?? {};
|
|
416
372
|
const stateConfig = isStatic ? void 0 : config.state;
|
|
417
373
|
const containerConfig = isStatic ? void 0 : config.container;
|
|
418
374
|
const containerName = isStatic ? void 0 : config.containerName;
|
|
419
375
|
const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
|
|
420
376
|
const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
|
|
421
|
-
const engineClasses = [stateResult
|
|
377
|
+
const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
|
|
422
378
|
const variantKeySet = new Set(Object.keys(variants));
|
|
423
379
|
const filterProps = makeFilterProps(variantKeySet);
|
|
424
|
-
const tagStr = typeof tag === "string" ? tag :
|
|
380
|
+
const tagStr = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
425
381
|
if (isStatic || Object.keys(variants).length === 0) {
|
|
426
382
|
const Component2 = React.forwardRef((props, ref) => {
|
|
427
|
-
const
|
|
428
|
-
return React.createElement(tag,
|
|
429
|
-
ref
|
|
430
|
-
|
|
383
|
+
const { className, ...rest } = props;
|
|
384
|
+
return React.createElement(tag, {
|
|
385
|
+
ref,
|
|
386
|
+
...filterProps(rest),
|
|
431
387
|
className: twMerge(base, engineClasses, className)
|
|
432
|
-
})
|
|
388
|
+
});
|
|
433
389
|
});
|
|
434
390
|
Component2.displayName = `tw.${tagStr}`;
|
|
435
391
|
attachExtend(Component2, tag, base, config);
|
|
@@ -439,11 +395,11 @@ function createComponent(tag, config) {
|
|
|
439
395
|
const { className } = props;
|
|
440
396
|
const variantClasses = resolveVariants(variants, props, defaultVariants);
|
|
441
397
|
const compoundClasses = resolveCompound(compoundVariants, props);
|
|
442
|
-
return React.createElement(tag,
|
|
443
|
-
ref
|
|
444
|
-
|
|
398
|
+
return React.createElement(tag, {
|
|
399
|
+
ref,
|
|
400
|
+
...filterProps(props),
|
|
445
401
|
className: twMerge(base, variantClasses, compoundClasses, engineClasses, className)
|
|
446
|
-
})
|
|
402
|
+
});
|
|
447
403
|
});
|
|
448
404
|
Component.displayName = `tw.${tagStr}`;
|
|
449
405
|
attachExtend(Component, tag, base, config);
|
|
@@ -455,32 +411,35 @@ function attachExtend(Component, originalTag, base, config) {
|
|
|
455
411
|
const merged = twMerge(base, extra);
|
|
456
412
|
return createComponent(
|
|
457
413
|
originalTag,
|
|
458
|
-
typeof config === "string" ? merged :
|
|
414
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
459
415
|
);
|
|
460
416
|
};
|
|
461
417
|
Component.withVariants = (newConfig) => {
|
|
462
|
-
var _a, _b, _c, _d, _e, _f;
|
|
463
418
|
const existing = typeof config === "object" ? config : {};
|
|
464
|
-
return createComponent(originalTag,
|
|
419
|
+
return createComponent(originalTag, {
|
|
420
|
+
...existing,
|
|
465
421
|
base,
|
|
466
|
-
variants:
|
|
422
|
+
variants: { ...existing.variants ?? void 0, ...newConfig.variants ?? void 0 },
|
|
467
423
|
compoundVariants: [
|
|
468
|
-
...
|
|
469
|
-
...
|
|
424
|
+
...existing.compoundVariants ?? [],
|
|
425
|
+
...newConfig.compoundVariants ?? []
|
|
470
426
|
],
|
|
471
|
-
defaultVariants:
|
|
472
|
-
|
|
427
|
+
defaultVariants: {
|
|
428
|
+
...existing.defaultVariants ?? void 0,
|
|
429
|
+
...newConfig.defaultVariants ?? void 0
|
|
430
|
+
}
|
|
431
|
+
});
|
|
473
432
|
};
|
|
474
|
-
Component.animate = (opts) => {
|
|
433
|
+
Component.animate = async (opts) => {
|
|
475
434
|
try {
|
|
476
435
|
const { animate: animateFn } = __require("@tailwind-styled/animate");
|
|
477
|
-
const animClass = animateFn(opts);
|
|
436
|
+
const animClass = await animateFn(opts);
|
|
478
437
|
const merged = twMerge(base, animClass);
|
|
479
438
|
return createComponent(
|
|
480
439
|
originalTag,
|
|
481
|
-
typeof config === "string" ? merged :
|
|
440
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
482
441
|
);
|
|
483
|
-
} catch
|
|
442
|
+
} catch {
|
|
484
443
|
console.warn("[tailwind-styled-v4] .animate() requires @tailwind-styled/animate");
|
|
485
444
|
return Component;
|
|
486
445
|
}
|
|
@@ -489,16 +448,15 @@ function attachExtend(Component, originalTag, base, config) {
|
|
|
489
448
|
function cv(config) {
|
|
490
449
|
const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
|
|
491
450
|
return (props = {}) => {
|
|
492
|
-
var _a;
|
|
493
451
|
const classes = [base];
|
|
494
452
|
for (const key in variants) {
|
|
495
|
-
const val =
|
|
453
|
+
const val = props[key] ?? defaultVariants[key];
|
|
496
454
|
if (val !== void 0 && variants[key][String(val)]) {
|
|
497
455
|
classes.push(variants[key][String(val)]);
|
|
498
456
|
}
|
|
499
457
|
}
|
|
500
458
|
for (const compound of compoundVariants) {
|
|
501
|
-
const
|
|
459
|
+
const { class: cls, ...conditions } = compound;
|
|
502
460
|
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
503
461
|
if (match) classes.push(cls);
|
|
504
462
|
}
|
|
@@ -513,6 +471,25 @@ function cx(...inputs) {
|
|
|
513
471
|
return twMerge(...inputs.filter(Boolean));
|
|
514
472
|
}
|
|
515
473
|
var cxm = cx;
|
|
474
|
+
function normalizeClassInput(classLists) {
|
|
475
|
+
return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
|
|
476
|
+
}
|
|
477
|
+
function createTwMerge(_options = {}) {
|
|
478
|
+
return function twMerge5(...classLists) {
|
|
479
|
+
const clean = normalizeClassInput(classLists);
|
|
480
|
+
return twMerge(clean.join(" "));
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
var twMerge4 = createTwMerge();
|
|
484
|
+
function mergeWithRules(rules, ...classLists) {
|
|
485
|
+
const base = twMerge4(...classLists);
|
|
486
|
+
let classes = base.split(/\s+/).filter(Boolean);
|
|
487
|
+
for (const rule of Object.values(rules)) {
|
|
488
|
+
const next = rule(classes);
|
|
489
|
+
classes = twMerge4(next).split(/\s+/).filter(Boolean);
|
|
490
|
+
}
|
|
491
|
+
return classes.join(" ");
|
|
492
|
+
}
|
|
516
493
|
|
|
517
494
|
// src/liveTokenEngine.ts
|
|
518
495
|
var _currentTokens = {};
|
|
@@ -549,16 +526,16 @@ function syncStyleEl() {
|
|
|
549
526
|
_styleEl.textContent = buildRootCss(_currentTokens);
|
|
550
527
|
}
|
|
551
528
|
function notifySubscribers() {
|
|
552
|
-
const snapshot =
|
|
529
|
+
const snapshot = { ..._currentTokens };
|
|
553
530
|
for (const sub of _subscribers) {
|
|
554
531
|
try {
|
|
555
532
|
sub(snapshot);
|
|
556
|
-
} catch
|
|
533
|
+
} catch {
|
|
557
534
|
}
|
|
558
535
|
}
|
|
559
536
|
}
|
|
560
537
|
function liveToken(tokens) {
|
|
561
|
-
_currentTokens =
|
|
538
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
562
539
|
syncStyleEl();
|
|
563
540
|
const vars = {};
|
|
564
541
|
for (const name of Object.keys(tokens)) {
|
|
@@ -576,19 +553,19 @@ function liveToken(tokens) {
|
|
|
576
553
|
setTokens(newTokens);
|
|
577
554
|
},
|
|
578
555
|
snapshot() {
|
|
579
|
-
return
|
|
556
|
+
return { ..._currentTokens };
|
|
580
557
|
}
|
|
581
558
|
};
|
|
582
559
|
}
|
|
583
560
|
function setToken(name, value) {
|
|
584
|
-
_currentTokens =
|
|
561
|
+
_currentTokens = { ..._currentTokens, [name]: value };
|
|
585
562
|
if (typeof document !== "undefined") {
|
|
586
563
|
document.documentElement.style.setProperty(tokenVar(name), value);
|
|
587
564
|
}
|
|
588
565
|
notifySubscribers();
|
|
589
566
|
}
|
|
590
567
|
function setTokens(tokens) {
|
|
591
|
-
_currentTokens =
|
|
568
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
592
569
|
if (typeof document !== "undefined") {
|
|
593
570
|
const root = document.documentElement;
|
|
594
571
|
for (const [name, value] of Object.entries(tokens)) {
|
|
@@ -606,7 +583,7 @@ function applyTokenSet(tokens) {
|
|
|
606
583
|
}
|
|
607
584
|
}
|
|
608
585
|
}
|
|
609
|
-
_currentTokens =
|
|
586
|
+
_currentTokens = { ...tokens };
|
|
610
587
|
syncStyleEl();
|
|
611
588
|
notifySubscribers();
|
|
612
589
|
}
|
|
@@ -614,7 +591,7 @@ function getToken(name) {
|
|
|
614
591
|
return _currentTokens[name];
|
|
615
592
|
}
|
|
616
593
|
function getTokens() {
|
|
617
|
-
return
|
|
594
|
+
return { ..._currentTokens };
|
|
618
595
|
}
|
|
619
596
|
function subscribeTokens(fn) {
|
|
620
597
|
_subscribers.add(fn);
|
|
@@ -631,14 +608,16 @@ function createUseTokens() {
|
|
|
631
608
|
const react = __require("react");
|
|
632
609
|
useState = react.useState;
|
|
633
610
|
useEffect = react.useEffect;
|
|
634
|
-
} catch
|
|
611
|
+
} catch {
|
|
635
612
|
return null;
|
|
636
613
|
}
|
|
637
614
|
return function useTokens() {
|
|
638
|
-
const [tokens, setTokens_] = useState(
|
|
615
|
+
const [tokens, setTokens_] = useState({
|
|
616
|
+
..._currentTokens
|
|
617
|
+
});
|
|
639
618
|
useEffect(() => {
|
|
640
|
-
setTokens_(
|
|
641
|
-
const unsub = subscribeTokens((t2) => setTokens_(
|
|
619
|
+
setTokens_({ ..._currentTokens });
|
|
620
|
+
const unsub = subscribeTokens((t2) => setTokens_({ ...t2 }));
|
|
642
621
|
return unsub;
|
|
643
622
|
}, []);
|
|
644
623
|
return tokens;
|
|
@@ -653,11 +632,10 @@ function tokenVarRef(prefix, group, name) {
|
|
|
653
632
|
return `var(${tokenVarName(prefix, group, name)})`;
|
|
654
633
|
}
|
|
655
634
|
function resolveTokenRef(tokens, prefix, value) {
|
|
656
|
-
var _a;
|
|
657
635
|
if (value.startsWith("token:")) {
|
|
658
636
|
const path = value.slice(6);
|
|
659
637
|
const [group, name] = path.split(".");
|
|
660
|
-
if (group && name &&
|
|
638
|
+
if (group && name && tokens[group]?.[name] !== void 0) {
|
|
661
639
|
return tokenVarRef(prefix, group, name);
|
|
662
640
|
}
|
|
663
641
|
}
|
|
@@ -680,37 +658,35 @@ function injectTokensToRoot(tokens, prefix) {
|
|
|
680
658
|
document.head.appendChild(style);
|
|
681
659
|
}
|
|
682
660
|
function resolveComponentConfig(config, tokens, prefix) {
|
|
683
|
-
var _a, _b, _c, _d, _e;
|
|
684
661
|
const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);
|
|
685
|
-
const base = resolveStr(
|
|
686
|
-
const systemBase = resolveStr(
|
|
662
|
+
const base = resolveStr(config.base ?? "");
|
|
663
|
+
const systemBase = resolveStr(config.systemBase ?? "");
|
|
687
664
|
const mergedBase = [systemBase, base].filter(Boolean).join(" ");
|
|
688
665
|
const variants = {};
|
|
689
|
-
for (const [variantKey, variantMap] of Object.entries(
|
|
666
|
+
for (const [variantKey, variantMap] of Object.entries(config.variants ?? {})) {
|
|
690
667
|
variants[variantKey] = {};
|
|
691
668
|
for (const [optKey, classes] of Object.entries(variantMap)) {
|
|
692
669
|
variants[variantKey][optKey] = classes.split(" ").map(resolveStr).join(" ");
|
|
693
670
|
}
|
|
694
671
|
}
|
|
695
|
-
const compoundVariants = (
|
|
696
|
-
const
|
|
697
|
-
return
|
|
672
|
+
const compoundVariants = (config.compoundVariants ?? []).map((cv2) => {
|
|
673
|
+
const { class: cls, ...rest } = cv2;
|
|
674
|
+
return { class: resolveStr(cls), ...rest };
|
|
698
675
|
});
|
|
699
676
|
return {
|
|
700
677
|
base: mergedBase,
|
|
701
678
|
variants,
|
|
702
679
|
compoundVariants,
|
|
703
|
-
defaultVariants:
|
|
680
|
+
defaultVariants: config.defaultVariants ?? {},
|
|
704
681
|
state: config.state,
|
|
705
682
|
container: config.container,
|
|
706
683
|
containerName: config.containerName
|
|
707
684
|
};
|
|
708
685
|
}
|
|
709
686
|
function createStyledSystem(config) {
|
|
710
|
-
|
|
711
|
-
const
|
|
712
|
-
const
|
|
713
|
-
const componentDefs = (_c = config.components) != null ? _c : {};
|
|
687
|
+
const prefix = config.prefix ?? "sys";
|
|
688
|
+
const tokens = config.tokens ?? {};
|
|
689
|
+
const componentDefs = config.components ?? {};
|
|
714
690
|
const shouldInject = config.injectTokens !== false;
|
|
715
691
|
if (shouldInject && typeof window !== "undefined") {
|
|
716
692
|
injectTokensToRoot(tokens, prefix);
|
|
@@ -724,9 +700,8 @@ function createStyledSystem(config) {
|
|
|
724
700
|
}
|
|
725
701
|
const factories = {};
|
|
726
702
|
for (const [name, compCfg] of Object.entries(componentDefs)) {
|
|
727
|
-
const tag =
|
|
703
|
+
const tag = compCfg.tag ?? "div";
|
|
728
704
|
factories[name] = (overrides) => {
|
|
729
|
-
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
730
705
|
const baseResolved = resolvedConfigs.get(name);
|
|
731
706
|
if (!overrides || Object.keys(overrides).length === 0) {
|
|
732
707
|
return createComponent(tag, baseResolved);
|
|
@@ -738,15 +713,21 @@ function createStyledSystem(config) {
|
|
|
738
713
|
);
|
|
739
714
|
const merged = {
|
|
740
715
|
base: [baseResolved.base, overrideResolved.base].filter(Boolean).join(" "),
|
|
741
|
-
variants:
|
|
716
|
+
variants: {
|
|
717
|
+
...baseResolved.variants ?? void 0,
|
|
718
|
+
...overrideResolved.variants ?? void 0
|
|
719
|
+
},
|
|
742
720
|
compoundVariants: [
|
|
743
|
-
...
|
|
744
|
-
...
|
|
721
|
+
...baseResolved.compoundVariants ?? [],
|
|
722
|
+
...overrideResolved.compoundVariants ?? []
|
|
745
723
|
],
|
|
746
|
-
defaultVariants:
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
724
|
+
defaultVariants: {
|
|
725
|
+
...baseResolved.defaultVariants ?? void 0,
|
|
726
|
+
...overrideResolved.defaultVariants ?? void 0
|
|
727
|
+
},
|
|
728
|
+
state: overrideResolved.state ?? baseResolved.state,
|
|
729
|
+
container: overrideResolved.container ?? baseResolved.container,
|
|
730
|
+
containerName: overrideResolved.containerName ?? baseResolved.containerName
|
|
750
731
|
};
|
|
751
732
|
return createComponent(tag, merged);
|
|
752
733
|
};
|
|
@@ -757,10 +738,9 @@ function createStyledSystem(config) {
|
|
|
757
738
|
return tokenVarRef(prefix, group, name);
|
|
758
739
|
}
|
|
759
740
|
function rawToken(path) {
|
|
760
|
-
var _a2;
|
|
761
741
|
const [group, name] = path.split(".");
|
|
762
742
|
if (!group || !name) return void 0;
|
|
763
|
-
return
|
|
743
|
+
return tokens[group]?.[name];
|
|
764
744
|
}
|
|
765
745
|
function setTokens2(updates) {
|
|
766
746
|
if (typeof document === "undefined") return;
|
|
@@ -798,11 +778,42 @@ function createStyledSystem(config) {
|
|
|
798
778
|
});
|
|
799
779
|
}
|
|
800
780
|
|
|
781
|
+
// src/styled.ts
|
|
782
|
+
function resolveVariantClass(options, props) {
|
|
783
|
+
const out = [];
|
|
784
|
+
const variants = options.variants ?? {};
|
|
785
|
+
const defaults = options.defaultVariants ?? {};
|
|
786
|
+
for (const [variantName, valueMap] of Object.entries(variants)) {
|
|
787
|
+
const value = props[variantName] ?? defaults[variantName];
|
|
788
|
+
if (value === void 0) continue;
|
|
789
|
+
const key = String(value);
|
|
790
|
+
const cls = valueMap[key];
|
|
791
|
+
if (cls) out.push(cls);
|
|
792
|
+
}
|
|
793
|
+
for (const compound of options.compoundVariants ?? []) {
|
|
794
|
+
const matches = Object.entries(compound.variants).every(([k, expected]) => {
|
|
795
|
+
const current = props[k] ?? defaults[k];
|
|
796
|
+
return String(current) === expected;
|
|
797
|
+
});
|
|
798
|
+
if (matches) out.push(compound.className);
|
|
799
|
+
}
|
|
800
|
+
return out;
|
|
801
|
+
}
|
|
802
|
+
function resolveStyledClassName(options, props = {}) {
|
|
803
|
+
const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
|
|
804
|
+
return twMerge4(...parts);
|
|
805
|
+
}
|
|
806
|
+
function styled(options) {
|
|
807
|
+
return function getClassName(props = {}) {
|
|
808
|
+
return resolveStyledClassName(options, props);
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
|
|
801
812
|
// src/twProxy.ts
|
|
802
813
|
function parseTemplate(strings, exprs) {
|
|
803
814
|
return strings.raw.reduce((acc, str, i) => {
|
|
804
815
|
const expr = exprs[i];
|
|
805
|
-
const exprStr = typeof expr === "function" ? "" : expr
|
|
816
|
+
const exprStr = typeof expr === "function" ? "" : expr ?? "";
|
|
806
817
|
return acc + str + String(exprStr);
|
|
807
818
|
}, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
808
819
|
}
|
|
@@ -925,8 +936,7 @@ function makeServerTag(tag) {
|
|
|
925
936
|
const baseFactory = makeTag(tag);
|
|
926
937
|
if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
927
938
|
return ((...args) => {
|
|
928
|
-
|
|
929
|
-
const tagName = typeof tag === "string" ? tag : (_a = tag.displayName) != null ? _a : "Component";
|
|
939
|
+
const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
930
940
|
console.warn(
|
|
931
941
|
`[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
|
|
932
942
|
);
|
|
@@ -996,7 +1006,6 @@ function createTheme(tokenMap) {
|
|
|
996
1006
|
return resolved;
|
|
997
1007
|
}
|
|
998
1008
|
function getGroupPrefix(group) {
|
|
999
|
-
var _a;
|
|
1000
1009
|
const map = {
|
|
1001
1010
|
colors: "bg",
|
|
1002
1011
|
// default to bg; user can use t.text() for text colors
|
|
@@ -1004,7 +1013,7 @@ function getGroupPrefix(group) {
|
|
|
1004
1013
|
spacing: "p",
|
|
1005
1014
|
shadows: "shadow"
|
|
1006
1015
|
};
|
|
1007
|
-
return
|
|
1016
|
+
return map[group] ?? "";
|
|
1008
1017
|
}
|
|
1009
1018
|
var v4Tokens = {
|
|
1010
1019
|
/** bg-[var(--color-background)] */
|
|
@@ -1017,6 +1026,280 @@ var v4Tokens = {
|
|
|
1017
1026
|
fontMono: twVar("font", "font-mono")
|
|
1018
1027
|
};
|
|
1019
1028
|
|
|
1020
|
-
|
|
1029
|
+
// src/parser.ts
|
|
1030
|
+
var _getNodePath = () => typeof __require !== "undefined" ? __require("path") : null;
|
|
1031
|
+
var _getCreateRequire = () => {
|
|
1032
|
+
if (typeof __require !== "undefined") {
|
|
1033
|
+
try {
|
|
1034
|
+
return __require("module").createRequire;
|
|
1035
|
+
} catch {
|
|
1036
|
+
return null;
|
|
1037
|
+
}
|
|
1038
|
+
}
|
|
1039
|
+
return null;
|
|
1040
|
+
};
|
|
1041
|
+
var _binding;
|
|
1042
|
+
function getBinding() {
|
|
1043
|
+
if (_binding !== void 0) return _binding;
|
|
1044
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
|
|
1045
|
+
return _binding = null;
|
|
1046
|
+
}
|
|
1047
|
+
if (typeof process === "undefined" || typeof process.cwd !== "function") {
|
|
1048
|
+
return _binding = null;
|
|
1049
|
+
}
|
|
1050
|
+
const runtimeDir = typeof __dirname === "string" ? __dirname : process.cwd();
|
|
1051
|
+
const nodePath = _getNodePath();
|
|
1052
|
+
const nodeCreateRequire = _getCreateRequire();
|
|
1053
|
+
if (!nodePath) return _binding = null;
|
|
1054
|
+
const req = typeof __require === "function" ? __require : nodeCreateRequire ? nodeCreateRequire(nodePath.join(runtimeDir, "noop.cjs")) : null;
|
|
1055
|
+
if (!req) return _binding = null;
|
|
1056
|
+
const candidates = [
|
|
1057
|
+
nodePath.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
|
|
1058
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
1059
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node")
|
|
1060
|
+
];
|
|
1061
|
+
for (const c of candidates) {
|
|
1062
|
+
try {
|
|
1063
|
+
const mod = req(c);
|
|
1064
|
+
if (mod?.parseClasses) return _binding = mod;
|
|
1065
|
+
} catch {
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
return _binding = null;
|
|
1069
|
+
}
|
|
1070
|
+
function splitClassListJS(input) {
|
|
1071
|
+
const out = [];
|
|
1072
|
+
let token = "";
|
|
1073
|
+
let square = 0;
|
|
1074
|
+
let round = 0;
|
|
1075
|
+
let escaped = false;
|
|
1076
|
+
for (const ch of input) {
|
|
1077
|
+
if (escaped) {
|
|
1078
|
+
token += ch;
|
|
1079
|
+
escaped = false;
|
|
1080
|
+
continue;
|
|
1081
|
+
}
|
|
1082
|
+
if (ch === "\\") {
|
|
1083
|
+
token += ch;
|
|
1084
|
+
escaped = true;
|
|
1085
|
+
continue;
|
|
1086
|
+
}
|
|
1087
|
+
if (ch === "[") square++;
|
|
1088
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1089
|
+
else if (ch === "(") round++;
|
|
1090
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1091
|
+
const isSpace = /\s/.test(ch);
|
|
1092
|
+
if (isSpace && square === 0 && round === 0) {
|
|
1093
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1094
|
+
token = "";
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
token += ch;
|
|
1098
|
+
}
|
|
1099
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1100
|
+
return out;
|
|
1101
|
+
}
|
|
1102
|
+
function parseClassTokenJS(rawToken) {
|
|
1103
|
+
const parts = [];
|
|
1104
|
+
let current = "";
|
|
1105
|
+
let square = 0;
|
|
1106
|
+
let round = 0;
|
|
1107
|
+
let escaped = false;
|
|
1108
|
+
for (const ch of rawToken) {
|
|
1109
|
+
if (escaped) {
|
|
1110
|
+
current += ch;
|
|
1111
|
+
escaped = false;
|
|
1112
|
+
continue;
|
|
1113
|
+
}
|
|
1114
|
+
if (ch === "\\") {
|
|
1115
|
+
current += ch;
|
|
1116
|
+
escaped = true;
|
|
1117
|
+
continue;
|
|
1118
|
+
}
|
|
1119
|
+
if (ch === "[") square++;
|
|
1120
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1121
|
+
else if (ch === "(") round++;
|
|
1122
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1123
|
+
if (ch === ":" && square === 0 && round === 0) {
|
|
1124
|
+
parts.push(current);
|
|
1125
|
+
current = "";
|
|
1126
|
+
continue;
|
|
1127
|
+
}
|
|
1128
|
+
current += ch;
|
|
1129
|
+
}
|
|
1130
|
+
parts.push(current);
|
|
1131
|
+
const variants = parts.slice(0, -1).filter(Boolean);
|
|
1132
|
+
const baseToken = parts[parts.length - 1] ?? "";
|
|
1133
|
+
const parsed = { raw: rawToken, base: baseToken, variants };
|
|
1134
|
+
const opacityMatch = baseToken.match(/^(.*)\/(\d{1,3})$/);
|
|
1135
|
+
if (opacityMatch && opacityMatch[1].length > 0) {
|
|
1136
|
+
parsed.base = opacityMatch[1];
|
|
1137
|
+
parsed.modifier = { type: "opacity", value: opacityMatch[2] };
|
|
1138
|
+
return parsed;
|
|
1139
|
+
}
|
|
1140
|
+
const arbitraryMatch = baseToken.match(/\((--[a-zA-Z0-9_-]+)\)/);
|
|
1141
|
+
if (arbitraryMatch) {
|
|
1142
|
+
parsed.modifier = { type: "arbitrary", value: arbitraryMatch[1] };
|
|
1143
|
+
}
|
|
1144
|
+
return parsed;
|
|
1145
|
+
}
|
|
1146
|
+
function splitClassList(input) {
|
|
1147
|
+
const binding = getBinding();
|
|
1148
|
+
if (binding?.parseClasses) {
|
|
1149
|
+
try {
|
|
1150
|
+
return binding.parseClasses(input).map((p) => p.raw);
|
|
1151
|
+
} catch {
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return splitClassListJS(input);
|
|
1155
|
+
}
|
|
1156
|
+
function parseClassToken(rawToken) {
|
|
1157
|
+
const binding = getBinding();
|
|
1158
|
+
if (binding?.parseClasses) {
|
|
1159
|
+
try {
|
|
1160
|
+
const results = binding.parseClasses(rawToken);
|
|
1161
|
+
if (results.length === 1) {
|
|
1162
|
+
const r = results[0];
|
|
1163
|
+
const parsed = {
|
|
1164
|
+
raw: r.raw,
|
|
1165
|
+
base: r.base,
|
|
1166
|
+
variants: r.variants
|
|
1167
|
+
};
|
|
1168
|
+
if (r.modifierType && r.modifierValue) {
|
|
1169
|
+
parsed.modifier = {
|
|
1170
|
+
type: r.modifierType,
|
|
1171
|
+
value: r.modifierValue
|
|
1172
|
+
};
|
|
1173
|
+
}
|
|
1174
|
+
return parsed;
|
|
1175
|
+
}
|
|
1176
|
+
} catch {
|
|
1177
|
+
}
|
|
1178
|
+
}
|
|
1179
|
+
return parseClassTokenJS(rawToken);
|
|
1180
|
+
}
|
|
1181
|
+
function parseTailwindClasses(input) {
|
|
1182
|
+
const binding = getBinding();
|
|
1183
|
+
if (binding?.parseClasses) {
|
|
1184
|
+
try {
|
|
1185
|
+
return binding.parseClasses(input).map((r) => {
|
|
1186
|
+
const parsed = { raw: r.raw, base: r.base, variants: r.variants };
|
|
1187
|
+
if (r.modifierType && r.modifierValue) {
|
|
1188
|
+
parsed.modifier = {
|
|
1189
|
+
type: r.modifierType,
|
|
1190
|
+
value: r.modifierValue
|
|
1191
|
+
};
|
|
1192
|
+
}
|
|
1193
|
+
return parsed;
|
|
1194
|
+
});
|
|
1195
|
+
} catch {
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
return splitClassListJS(input).map(parseClassTokenJS);
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// src/themeReader.ts
|
|
1202
|
+
var THEME_BLOCK_RE = /@theme\s*\{([\s\S]*?)\}/g;
|
|
1203
|
+
var CSS_VAR_RE = /--([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/g;
|
|
1204
|
+
var cache = /* @__PURE__ */ new Map();
|
|
1205
|
+
function createEmptyTheme() {
|
|
1206
|
+
return {
|
|
1207
|
+
colors: {},
|
|
1208
|
+
spacing: {},
|
|
1209
|
+
fonts: {},
|
|
1210
|
+
breakpoints: {},
|
|
1211
|
+
animations: {},
|
|
1212
|
+
raw: {}
|
|
1213
|
+
};
|
|
1214
|
+
}
|
|
1215
|
+
function setToken2(theme, key, value) {
|
|
1216
|
+
theme.raw[key] = value;
|
|
1217
|
+
if (key.startsWith("color-")) {
|
|
1218
|
+
theme.colors[key.slice("color-".length)] = value;
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
if (key.startsWith("spacing-")) {
|
|
1222
|
+
theme.spacing[key.slice("spacing-".length)] = value;
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
if (key.startsWith("font-")) {
|
|
1226
|
+
theme.fonts[key.slice("font-".length)] = value;
|
|
1227
|
+
return;
|
|
1228
|
+
}
|
|
1229
|
+
if (key.startsWith("breakpoint-")) {
|
|
1230
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = value;
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
if (key.startsWith("animate-")) {
|
|
1234
|
+
theme.animations[key.slice("animate-".length)] = value;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
function resolveThemeValue(key, theme, visited = /* @__PURE__ */ new Set()) {
|
|
1238
|
+
const token = key.replace(/^--/, "");
|
|
1239
|
+
const raw = theme.raw[token];
|
|
1240
|
+
if (!raw) return "";
|
|
1241
|
+
if (visited.has(token)) return raw;
|
|
1242
|
+
const nested = raw.match(/^var\((--[a-zA-Z0-9_-]+)\)$/);
|
|
1243
|
+
if (!nested) return raw;
|
|
1244
|
+
visited.add(token);
|
|
1245
|
+
return resolveThemeValue(nested[1], theme, visited);
|
|
1246
|
+
}
|
|
1247
|
+
function extractThemeFromCSS(cssContent) {
|
|
1248
|
+
const hit = cache.get(cssContent);
|
|
1249
|
+
if (hit) return hit;
|
|
1250
|
+
const theme = createEmptyTheme();
|
|
1251
|
+
let blockMatch;
|
|
1252
|
+
while ((blockMatch = THEME_BLOCK_RE.exec(cssContent)) !== null) {
|
|
1253
|
+
const block = blockMatch[1];
|
|
1254
|
+
let varMatch;
|
|
1255
|
+
while ((varMatch = CSS_VAR_RE.exec(block)) !== null) {
|
|
1256
|
+
const key = varMatch[1];
|
|
1257
|
+
const value = varMatch[2].trim();
|
|
1258
|
+
setToken2(theme, key, value);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
for (const key of Object.keys(theme.raw)) {
|
|
1262
|
+
const resolved = resolveThemeValue(`--${key}`, theme);
|
|
1263
|
+
theme.raw[key] = resolved;
|
|
1264
|
+
if (key.startsWith("color-")) {
|
|
1265
|
+
theme.colors[key.slice("color-".length)] = resolved;
|
|
1266
|
+
} else if (key.startsWith("spacing-")) {
|
|
1267
|
+
theme.spacing[key.slice("spacing-".length)] = resolved;
|
|
1268
|
+
} else if (key.startsWith("font-")) {
|
|
1269
|
+
theme.fonts[key.slice("font-".length)] = resolved;
|
|
1270
|
+
} else if (key.startsWith("breakpoint-")) {
|
|
1271
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = resolved;
|
|
1272
|
+
} else if (key.startsWith("animate-")) {
|
|
1273
|
+
theme.animations[key.slice("animate-".length)] = resolved;
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
cache.set(cssContent, theme);
|
|
1277
|
+
return theme;
|
|
1278
|
+
}
|
|
1279
|
+
function generateTypeDefinitions(theme) {
|
|
1280
|
+
const toRecordType = (name, obj) => {
|
|
1281
|
+
const keys = Object.keys(obj);
|
|
1282
|
+
if (keys.length === 0) return ` ${name}: Record<string, string>`;
|
|
1283
|
+
const mapped = keys.map((k) => ` "${k}": string`).join("\n");
|
|
1284
|
+
return ` ${name}: {
|
|
1285
|
+
${mapped}
|
|
1286
|
+
}`;
|
|
1287
|
+
};
|
|
1288
|
+
return [
|
|
1289
|
+
"export interface TailwindStyledThemeTokens {",
|
|
1290
|
+
toRecordType("colors", theme.colors),
|
|
1291
|
+
toRecordType("spacing", theme.spacing),
|
|
1292
|
+
toRecordType("fonts", theme.fonts),
|
|
1293
|
+
toRecordType("breakpoints", theme.breakpoints),
|
|
1294
|
+
toRecordType("animations", theme.animations),
|
|
1295
|
+
"}",
|
|
1296
|
+
""
|
|
1297
|
+
].join("\n");
|
|
1298
|
+
}
|
|
1299
|
+
function clearThemeReaderCache() {
|
|
1300
|
+
cache.clear();
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
export { applyTokenSet, clearThemeReaderCache, cn, tokenRef as containerRef, createComponent, createStyledSystem, createTheme, createTwMerge, createUseTokens, cssVar, cv, cx, cxm, extractThemeFromCSS, generateContainerCss, generateStateCss, generateTokenCssString, generateTypeDefinitions, getContainerRegistry, getStateRegistry, getToken, getTokens, liveToken, mergeWithRules, parseClassToken, parseTailwindClasses, processContainer, processState, resolveStyledClassName, resolveThemeValue, server, setToken, setTokens, splitClassList, styled, subscribeTokens, t, tokenRef, tokenVar, tw, twMerge4 as twMerge, twVar, v4Tokens };
|
|
1021
1304
|
//# sourceMappingURL=index.js.map
|
|
1022
1305
|
//# sourceMappingURL=index.js.map
|