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.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkY5D3E72P_cjs = require('./chunk-Y5D3E72P.cjs');
|
|
3
4
|
var React = require('react');
|
|
4
5
|
var tailwindMerge = require('tailwind-merge');
|
|
5
6
|
|
|
@@ -8,43 +9,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
8
9
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
9
10
|
|
|
10
11
|
/* tailwind-styled-v4 v4 | MIT | https://github.com/dictionar32/tailwind-styled-v4 */
|
|
11
|
-
var __defProp = Object.defineProperty;
|
|
12
|
-
var __defProps = Object.defineProperties;
|
|
13
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
14
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
15
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
16
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
17
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
18
|
-
var __spreadValues = (a, b) => {
|
|
19
|
-
for (var prop in b || (b = {}))
|
|
20
|
-
if (__hasOwnProp.call(b, prop))
|
|
21
|
-
__defNormalProp(a, prop, b[prop]);
|
|
22
|
-
if (__getOwnPropSymbols)
|
|
23
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
24
|
-
if (__propIsEnum.call(b, prop))
|
|
25
|
-
__defNormalProp(a, prop, b[prop]);
|
|
26
|
-
}
|
|
27
|
-
return a;
|
|
28
|
-
};
|
|
29
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
30
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
31
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
32
|
-
}) : x)(function(x) {
|
|
33
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
34
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
35
|
-
});
|
|
36
|
-
var __objRest = (source, exclude) => {
|
|
37
|
-
var target = {};
|
|
38
|
-
for (var prop in source)
|
|
39
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
40
|
-
target[prop] = source[prop];
|
|
41
|
-
if (source != null && __getOwnPropSymbols)
|
|
42
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
|
43
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
44
|
-
target[prop] = source[prop];
|
|
45
|
-
}
|
|
46
|
-
return target;
|
|
47
|
-
};
|
|
48
12
|
|
|
49
13
|
// src/containerQuery.ts
|
|
50
14
|
var CONTAINER_BREAKPOINTS = {
|
|
@@ -60,7 +24,7 @@ if (typeof window !== "undefined") {
|
|
|
60
24
|
window.__TW_CONTAINER_REGISTRY__ = containerRegistry;
|
|
61
25
|
}
|
|
62
26
|
function hashContainer(tag, container, name) {
|
|
63
|
-
const key = tag + (name
|
|
27
|
+
const key = tag + (name ?? "") + JSON.stringify(Object.entries(container).sort());
|
|
64
28
|
let hash = 5381;
|
|
65
29
|
for (let i = 0; i < key.length; i++) {
|
|
66
30
|
hash = (hash << 5) + hash ^ key.charCodeAt(i);
|
|
@@ -119,31 +83,29 @@ var LAYOUT_MAP = {
|
|
|
119
83
|
"justify-end": "justify-content:flex-end"
|
|
120
84
|
};
|
|
121
85
|
function layoutClassesToCss(classes) {
|
|
122
|
-
var _a, _b;
|
|
123
86
|
const decls = [];
|
|
124
87
|
for (const cls of classes.trim().split(/\s+/)) {
|
|
125
88
|
if (LAYOUT_MAP[cls]) decls.push(LAYOUT_MAP[cls]);
|
|
126
89
|
else if (cls.startsWith("w-[")) {
|
|
127
|
-
const val =
|
|
90
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
128
91
|
if (val) decls.push(`width:${val}`);
|
|
129
92
|
} else if (cls.startsWith("max-w-[")) {
|
|
130
|
-
const val =
|
|
93
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
131
94
|
if (val) decls.push(`max-width:${val}`);
|
|
132
95
|
}
|
|
133
96
|
}
|
|
134
97
|
return decls.join(";");
|
|
135
98
|
}
|
|
136
99
|
function buildContainerRules(id, container, containerName) {
|
|
137
|
-
var _a, _b, _c;
|
|
138
100
|
const rules = [];
|
|
139
101
|
for (const [key, value] of Object.entries(container)) {
|
|
140
102
|
let minWidth;
|
|
141
103
|
let classes;
|
|
142
104
|
if (typeof value === "string") {
|
|
143
|
-
minWidth =
|
|
105
|
+
minWidth = CONTAINER_BREAKPOINTS[key] ?? key;
|
|
144
106
|
classes = value;
|
|
145
107
|
} else {
|
|
146
|
-
minWidth =
|
|
108
|
+
minWidth = value.minWidth ?? CONTAINER_BREAKPOINTS[key] ?? key;
|
|
147
109
|
classes = value.classes;
|
|
148
110
|
}
|
|
149
111
|
const css = layoutClassesToCss(classes);
|
|
@@ -160,10 +122,10 @@ function injectContainerStyles(id, container, containerName) {
|
|
|
160
122
|
const css = buildContainerRules(id, container, containerName);
|
|
161
123
|
if (!css) return;
|
|
162
124
|
try {
|
|
163
|
-
const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
|
|
125
|
+
const { batchedInject } = chunkY5D3E72P_cjs.__require("@tailwind-styled/runtime-css/batched");
|
|
164
126
|
for (const rule of css.split("\n").filter(Boolean)) batchedInject(rule);
|
|
165
127
|
return;
|
|
166
|
-
} catch
|
|
128
|
+
} catch {
|
|
167
129
|
}
|
|
168
130
|
const style = document.createElement("style");
|
|
169
131
|
style.id = styleId;
|
|
@@ -174,13 +136,10 @@ function injectContainerStyles(id, container, containerName) {
|
|
|
174
136
|
function processContainer(tag, container, containerName) {
|
|
175
137
|
const id = hashContainer(tag, container, containerName);
|
|
176
138
|
if (!containerRegistry.has(id)) {
|
|
177
|
-
const breakpoints = Object.entries(container).map(([key, value]) => {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
classes: typeof value === "string" ? value : value.classes
|
|
182
|
-
};
|
|
183
|
-
});
|
|
139
|
+
const breakpoints = Object.entries(container).map(([key, value]) => ({
|
|
140
|
+
minWidth: CONTAINER_BREAKPOINTS[key] ?? key,
|
|
141
|
+
classes: typeof value === "string" ? value : value.classes
|
|
142
|
+
}));
|
|
184
143
|
containerRegistry.set(id, {
|
|
185
144
|
id,
|
|
186
145
|
tag,
|
|
@@ -307,12 +266,11 @@ var TW_MAP = {
|
|
|
307
266
|
"text-zinc-500": "color:rgb(113,113,122)"
|
|
308
267
|
};
|
|
309
268
|
function twClassesToCss(classes) {
|
|
310
|
-
var _a;
|
|
311
269
|
const decls = [];
|
|
312
270
|
for (const cls of classes.trim().split(/\s+/)) {
|
|
313
271
|
if (TW_MAP[cls]) decls.push(TW_MAP[cls]);
|
|
314
272
|
else if (cls.includes("[") && cls.includes("]")) {
|
|
315
|
-
const val =
|
|
273
|
+
const val = cls.match(/\[(.+)\]/)?.[1];
|
|
316
274
|
if (!val) continue;
|
|
317
275
|
if (cls.startsWith("bg-[")) decls.push(`background-color:${val}`);
|
|
318
276
|
else if (cls.startsWith("text-[")) decls.push(`color:${val}`);
|
|
@@ -336,10 +294,10 @@ function injectStateStyles(id, state) {
|
|
|
336
294
|
}
|
|
337
295
|
if (rules.length === 0) return;
|
|
338
296
|
try {
|
|
339
|
-
const { batchedInject } = __require("@tailwind-styled/runtime-css/batched");
|
|
297
|
+
const { batchedInject } = chunkY5D3E72P_cjs.__require("@tailwind-styled/runtime-css/batched");
|
|
340
298
|
for (const rule of rules) batchedInject(rule);
|
|
341
299
|
return;
|
|
342
|
-
} catch
|
|
300
|
+
} catch {
|
|
343
301
|
}
|
|
344
302
|
const style = document.createElement("style");
|
|
345
303
|
style.id = styleId;
|
|
@@ -393,10 +351,9 @@ function makeFilterProps(variantKeys) {
|
|
|
393
351
|
};
|
|
394
352
|
}
|
|
395
353
|
function resolveVariants(variants, props, defaults) {
|
|
396
|
-
var _a;
|
|
397
354
|
const classes = [];
|
|
398
355
|
for (const key in variants) {
|
|
399
|
-
const val =
|
|
356
|
+
const val = props[key] ?? defaults[key];
|
|
400
357
|
if (val !== void 0 && variants[key][String(val)]) {
|
|
401
358
|
classes.push(variants[key][String(val)]);
|
|
402
359
|
}
|
|
@@ -406,36 +363,35 @@ function resolveVariants(variants, props, defaults) {
|
|
|
406
363
|
function resolveCompound(compounds, props) {
|
|
407
364
|
const classes = [];
|
|
408
365
|
for (const compound of compounds) {
|
|
409
|
-
const
|
|
366
|
+
const { class: cls, ...conditions } = compound;
|
|
410
367
|
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
411
368
|
if (match) classes.push(cls);
|
|
412
369
|
}
|
|
413
370
|
return classes.join(" ");
|
|
414
371
|
}
|
|
415
372
|
function createComponent(tag, config) {
|
|
416
|
-
var _a, _b, _c, _d, _e;
|
|
417
373
|
const isStatic = typeof config === "string";
|
|
418
|
-
const base = isStatic ? config :
|
|
419
|
-
const variants = isStatic ? {} :
|
|
420
|
-
const compoundVariants = isStatic ? [] :
|
|
421
|
-
const defaultVariants = isStatic ? {} :
|
|
374
|
+
const base = isStatic ? config : config.base ?? "";
|
|
375
|
+
const variants = isStatic ? {} : config.variants ?? {};
|
|
376
|
+
const compoundVariants = isStatic ? [] : config.compoundVariants ?? [];
|
|
377
|
+
const defaultVariants = isStatic ? {} : config.defaultVariants ?? {};
|
|
422
378
|
const stateConfig = isStatic ? void 0 : config.state;
|
|
423
379
|
const containerConfig = isStatic ? void 0 : config.container;
|
|
424
380
|
const containerName = isStatic ? void 0 : config.containerName;
|
|
425
381
|
const stateResult = stateConfig ? processState(typeof tag === "string" ? tag : "component", stateConfig) : null;
|
|
426
382
|
const containerResult = containerConfig ? processContainer(typeof tag === "string" ? tag : "component", containerConfig, containerName) : null;
|
|
427
|
-
const engineClasses = [stateResult
|
|
383
|
+
const engineClasses = [stateResult?.stateClass, containerResult?.containerClass].filter(Boolean).join(" ");
|
|
428
384
|
const variantKeySet = new Set(Object.keys(variants));
|
|
429
385
|
const filterProps = makeFilterProps(variantKeySet);
|
|
430
|
-
const tagStr = typeof tag === "string" ? tag :
|
|
386
|
+
const tagStr = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
431
387
|
if (isStatic || Object.keys(variants).length === 0) {
|
|
432
388
|
const Component2 = React__default.default.forwardRef((props, ref) => {
|
|
433
|
-
const
|
|
434
|
-
return React__default.default.createElement(tag,
|
|
435
|
-
ref
|
|
436
|
-
|
|
389
|
+
const { className, ...rest } = props;
|
|
390
|
+
return React__default.default.createElement(tag, {
|
|
391
|
+
ref,
|
|
392
|
+
...filterProps(rest),
|
|
437
393
|
className: tailwindMerge.twMerge(base, engineClasses, className)
|
|
438
|
-
})
|
|
394
|
+
});
|
|
439
395
|
});
|
|
440
396
|
Component2.displayName = `tw.${tagStr}`;
|
|
441
397
|
attachExtend(Component2, tag, base, config);
|
|
@@ -445,11 +401,11 @@ function createComponent(tag, config) {
|
|
|
445
401
|
const { className } = props;
|
|
446
402
|
const variantClasses = resolveVariants(variants, props, defaultVariants);
|
|
447
403
|
const compoundClasses = resolveCompound(compoundVariants, props);
|
|
448
|
-
return React__default.default.createElement(tag,
|
|
449
|
-
ref
|
|
450
|
-
|
|
404
|
+
return React__default.default.createElement(tag, {
|
|
405
|
+
ref,
|
|
406
|
+
...filterProps(props),
|
|
451
407
|
className: tailwindMerge.twMerge(base, variantClasses, compoundClasses, engineClasses, className)
|
|
452
|
-
})
|
|
408
|
+
});
|
|
453
409
|
});
|
|
454
410
|
Component.displayName = `tw.${tagStr}`;
|
|
455
411
|
attachExtend(Component, tag, base, config);
|
|
@@ -461,32 +417,35 @@ function attachExtend(Component, originalTag, base, config) {
|
|
|
461
417
|
const merged = tailwindMerge.twMerge(base, extra);
|
|
462
418
|
return createComponent(
|
|
463
419
|
originalTag,
|
|
464
|
-
typeof config === "string" ? merged :
|
|
420
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
465
421
|
);
|
|
466
422
|
};
|
|
467
423
|
Component.withVariants = (newConfig) => {
|
|
468
|
-
var _a, _b, _c, _d, _e, _f;
|
|
469
424
|
const existing = typeof config === "object" ? config : {};
|
|
470
|
-
return createComponent(originalTag,
|
|
425
|
+
return createComponent(originalTag, {
|
|
426
|
+
...existing,
|
|
471
427
|
base,
|
|
472
|
-
variants:
|
|
428
|
+
variants: { ...existing.variants ?? void 0, ...newConfig.variants ?? void 0 },
|
|
473
429
|
compoundVariants: [
|
|
474
|
-
...
|
|
475
|
-
...
|
|
430
|
+
...existing.compoundVariants ?? [],
|
|
431
|
+
...newConfig.compoundVariants ?? []
|
|
476
432
|
],
|
|
477
|
-
defaultVariants:
|
|
478
|
-
|
|
433
|
+
defaultVariants: {
|
|
434
|
+
...existing.defaultVariants ?? void 0,
|
|
435
|
+
...newConfig.defaultVariants ?? void 0
|
|
436
|
+
}
|
|
437
|
+
});
|
|
479
438
|
};
|
|
480
|
-
Component.animate = (opts) => {
|
|
439
|
+
Component.animate = async (opts) => {
|
|
481
440
|
try {
|
|
482
|
-
const { animate: animateFn } = __require("@tailwind-styled/animate");
|
|
483
|
-
const animClass = animateFn(opts);
|
|
441
|
+
const { animate: animateFn } = chunkY5D3E72P_cjs.__require("@tailwind-styled/animate");
|
|
442
|
+
const animClass = await animateFn(opts);
|
|
484
443
|
const merged = tailwindMerge.twMerge(base, animClass);
|
|
485
444
|
return createComponent(
|
|
486
445
|
originalTag,
|
|
487
|
-
typeof config === "string" ? merged :
|
|
446
|
+
typeof config === "string" ? merged : { ...config, base: merged }
|
|
488
447
|
);
|
|
489
|
-
} catch
|
|
448
|
+
} catch {
|
|
490
449
|
console.warn("[tailwind-styled-v4] .animate() requires @tailwind-styled/animate");
|
|
491
450
|
return Component;
|
|
492
451
|
}
|
|
@@ -495,16 +454,15 @@ function attachExtend(Component, originalTag, base, config) {
|
|
|
495
454
|
function cv(config) {
|
|
496
455
|
const { base = "", variants = {}, compoundVariants = [], defaultVariants = {} } = config;
|
|
497
456
|
return (props = {}) => {
|
|
498
|
-
var _a;
|
|
499
457
|
const classes = [base];
|
|
500
458
|
for (const key in variants) {
|
|
501
|
-
const val =
|
|
459
|
+
const val = props[key] ?? defaultVariants[key];
|
|
502
460
|
if (val !== void 0 && variants[key][String(val)]) {
|
|
503
461
|
classes.push(variants[key][String(val)]);
|
|
504
462
|
}
|
|
505
463
|
}
|
|
506
464
|
for (const compound of compoundVariants) {
|
|
507
|
-
const
|
|
465
|
+
const { class: cls, ...conditions } = compound;
|
|
508
466
|
const match = Object.entries(conditions).every(([k, v]) => props[k] === v);
|
|
509
467
|
if (match) classes.push(cls);
|
|
510
468
|
}
|
|
@@ -519,6 +477,25 @@ function cx(...inputs) {
|
|
|
519
477
|
return tailwindMerge.twMerge(...inputs.filter(Boolean));
|
|
520
478
|
}
|
|
521
479
|
var cxm = cx;
|
|
480
|
+
function normalizeClassInput(classLists) {
|
|
481
|
+
return classLists.filter(Boolean).map((v) => String(v).trim()).filter((v) => v.length > 0);
|
|
482
|
+
}
|
|
483
|
+
function createTwMerge(_options = {}) {
|
|
484
|
+
return function twMerge5(...classLists) {
|
|
485
|
+
const clean = normalizeClassInput(classLists);
|
|
486
|
+
return tailwindMerge.twMerge(clean.join(" "));
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
var twMerge4 = createTwMerge();
|
|
490
|
+
function mergeWithRules(rules, ...classLists) {
|
|
491
|
+
const base = twMerge4(...classLists);
|
|
492
|
+
let classes = base.split(/\s+/).filter(Boolean);
|
|
493
|
+
for (const rule of Object.values(rules)) {
|
|
494
|
+
const next = rule(classes);
|
|
495
|
+
classes = twMerge4(next).split(/\s+/).filter(Boolean);
|
|
496
|
+
}
|
|
497
|
+
return classes.join(" ");
|
|
498
|
+
}
|
|
522
499
|
|
|
523
500
|
// src/liveTokenEngine.ts
|
|
524
501
|
var _currentTokens = {};
|
|
@@ -555,16 +532,16 @@ function syncStyleEl() {
|
|
|
555
532
|
_styleEl.textContent = buildRootCss(_currentTokens);
|
|
556
533
|
}
|
|
557
534
|
function notifySubscribers() {
|
|
558
|
-
const snapshot =
|
|
535
|
+
const snapshot = { ..._currentTokens };
|
|
559
536
|
for (const sub of _subscribers) {
|
|
560
537
|
try {
|
|
561
538
|
sub(snapshot);
|
|
562
|
-
} catch
|
|
539
|
+
} catch {
|
|
563
540
|
}
|
|
564
541
|
}
|
|
565
542
|
}
|
|
566
543
|
function liveToken(tokens) {
|
|
567
|
-
_currentTokens =
|
|
544
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
568
545
|
syncStyleEl();
|
|
569
546
|
const vars = {};
|
|
570
547
|
for (const name of Object.keys(tokens)) {
|
|
@@ -582,19 +559,19 @@ function liveToken(tokens) {
|
|
|
582
559
|
setTokens(newTokens);
|
|
583
560
|
},
|
|
584
561
|
snapshot() {
|
|
585
|
-
return
|
|
562
|
+
return { ..._currentTokens };
|
|
586
563
|
}
|
|
587
564
|
};
|
|
588
565
|
}
|
|
589
566
|
function setToken(name, value) {
|
|
590
|
-
_currentTokens =
|
|
567
|
+
_currentTokens = { ..._currentTokens, [name]: value };
|
|
591
568
|
if (typeof document !== "undefined") {
|
|
592
569
|
document.documentElement.style.setProperty(tokenVar(name), value);
|
|
593
570
|
}
|
|
594
571
|
notifySubscribers();
|
|
595
572
|
}
|
|
596
573
|
function setTokens(tokens) {
|
|
597
|
-
_currentTokens =
|
|
574
|
+
_currentTokens = { ..._currentTokens, ...tokens };
|
|
598
575
|
if (typeof document !== "undefined") {
|
|
599
576
|
const root = document.documentElement;
|
|
600
577
|
for (const [name, value] of Object.entries(tokens)) {
|
|
@@ -612,7 +589,7 @@ function applyTokenSet(tokens) {
|
|
|
612
589
|
}
|
|
613
590
|
}
|
|
614
591
|
}
|
|
615
|
-
_currentTokens =
|
|
592
|
+
_currentTokens = { ...tokens };
|
|
616
593
|
syncStyleEl();
|
|
617
594
|
notifySubscribers();
|
|
618
595
|
}
|
|
@@ -620,7 +597,7 @@ function getToken(name) {
|
|
|
620
597
|
return _currentTokens[name];
|
|
621
598
|
}
|
|
622
599
|
function getTokens() {
|
|
623
|
-
return
|
|
600
|
+
return { ..._currentTokens };
|
|
624
601
|
}
|
|
625
602
|
function subscribeTokens(fn) {
|
|
626
603
|
_subscribers.add(fn);
|
|
@@ -634,17 +611,19 @@ function generateTokenCssString() {
|
|
|
634
611
|
function createUseTokens() {
|
|
635
612
|
let useState, useEffect;
|
|
636
613
|
try {
|
|
637
|
-
const react = __require("react");
|
|
614
|
+
const react = chunkY5D3E72P_cjs.__require("react");
|
|
638
615
|
useState = react.useState;
|
|
639
616
|
useEffect = react.useEffect;
|
|
640
|
-
} catch
|
|
617
|
+
} catch {
|
|
641
618
|
return null;
|
|
642
619
|
}
|
|
643
620
|
return function useTokens() {
|
|
644
|
-
const [tokens, setTokens_] = useState(
|
|
621
|
+
const [tokens, setTokens_] = useState({
|
|
622
|
+
..._currentTokens
|
|
623
|
+
});
|
|
645
624
|
useEffect(() => {
|
|
646
|
-
setTokens_(
|
|
647
|
-
const unsub = subscribeTokens((t2) => setTokens_(
|
|
625
|
+
setTokens_({ ..._currentTokens });
|
|
626
|
+
const unsub = subscribeTokens((t2) => setTokens_({ ...t2 }));
|
|
648
627
|
return unsub;
|
|
649
628
|
}, []);
|
|
650
629
|
return tokens;
|
|
@@ -659,11 +638,10 @@ function tokenVarRef(prefix, group, name) {
|
|
|
659
638
|
return `var(${tokenVarName(prefix, group, name)})`;
|
|
660
639
|
}
|
|
661
640
|
function resolveTokenRef(tokens, prefix, value) {
|
|
662
|
-
var _a;
|
|
663
641
|
if (value.startsWith("token:")) {
|
|
664
642
|
const path = value.slice(6);
|
|
665
643
|
const [group, name] = path.split(".");
|
|
666
|
-
if (group && name &&
|
|
644
|
+
if (group && name && tokens[group]?.[name] !== void 0) {
|
|
667
645
|
return tokenVarRef(prefix, group, name);
|
|
668
646
|
}
|
|
669
647
|
}
|
|
@@ -686,37 +664,35 @@ function injectTokensToRoot(tokens, prefix) {
|
|
|
686
664
|
document.head.appendChild(style);
|
|
687
665
|
}
|
|
688
666
|
function resolveComponentConfig(config, tokens, prefix) {
|
|
689
|
-
var _a, _b, _c, _d, _e;
|
|
690
667
|
const resolveStr = (s) => resolveTokenRef(tokens, prefix, s);
|
|
691
|
-
const base = resolveStr(
|
|
692
|
-
const systemBase = resolveStr(
|
|
668
|
+
const base = resolveStr(config.base ?? "");
|
|
669
|
+
const systemBase = resolveStr(config.systemBase ?? "");
|
|
693
670
|
const mergedBase = [systemBase, base].filter(Boolean).join(" ");
|
|
694
671
|
const variants = {};
|
|
695
|
-
for (const [variantKey, variantMap] of Object.entries(
|
|
672
|
+
for (const [variantKey, variantMap] of Object.entries(config.variants ?? {})) {
|
|
696
673
|
variants[variantKey] = {};
|
|
697
674
|
for (const [optKey, classes] of Object.entries(variantMap)) {
|
|
698
675
|
variants[variantKey][optKey] = classes.split(" ").map(resolveStr).join(" ");
|
|
699
676
|
}
|
|
700
677
|
}
|
|
701
|
-
const compoundVariants = (
|
|
702
|
-
const
|
|
703
|
-
return
|
|
678
|
+
const compoundVariants = (config.compoundVariants ?? []).map((cv2) => {
|
|
679
|
+
const { class: cls, ...rest } = cv2;
|
|
680
|
+
return { class: resolveStr(cls), ...rest };
|
|
704
681
|
});
|
|
705
682
|
return {
|
|
706
683
|
base: mergedBase,
|
|
707
684
|
variants,
|
|
708
685
|
compoundVariants,
|
|
709
|
-
defaultVariants:
|
|
686
|
+
defaultVariants: config.defaultVariants ?? {},
|
|
710
687
|
state: config.state,
|
|
711
688
|
container: config.container,
|
|
712
689
|
containerName: config.containerName
|
|
713
690
|
};
|
|
714
691
|
}
|
|
715
692
|
function createStyledSystem(config) {
|
|
716
|
-
|
|
717
|
-
const
|
|
718
|
-
const
|
|
719
|
-
const componentDefs = (_c = config.components) != null ? _c : {};
|
|
693
|
+
const prefix = config.prefix ?? "sys";
|
|
694
|
+
const tokens = config.tokens ?? {};
|
|
695
|
+
const componentDefs = config.components ?? {};
|
|
720
696
|
const shouldInject = config.injectTokens !== false;
|
|
721
697
|
if (shouldInject && typeof window !== "undefined") {
|
|
722
698
|
injectTokensToRoot(tokens, prefix);
|
|
@@ -730,9 +706,8 @@ function createStyledSystem(config) {
|
|
|
730
706
|
}
|
|
731
707
|
const factories = {};
|
|
732
708
|
for (const [name, compCfg] of Object.entries(componentDefs)) {
|
|
733
|
-
const tag =
|
|
709
|
+
const tag = compCfg.tag ?? "div";
|
|
734
710
|
factories[name] = (overrides) => {
|
|
735
|
-
var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
|
|
736
711
|
const baseResolved = resolvedConfigs.get(name);
|
|
737
712
|
if (!overrides || Object.keys(overrides).length === 0) {
|
|
738
713
|
return createComponent(tag, baseResolved);
|
|
@@ -744,15 +719,21 @@ function createStyledSystem(config) {
|
|
|
744
719
|
);
|
|
745
720
|
const merged = {
|
|
746
721
|
base: [baseResolved.base, overrideResolved.base].filter(Boolean).join(" "),
|
|
747
|
-
variants:
|
|
722
|
+
variants: {
|
|
723
|
+
...baseResolved.variants ?? void 0,
|
|
724
|
+
...overrideResolved.variants ?? void 0
|
|
725
|
+
},
|
|
748
726
|
compoundVariants: [
|
|
749
|
-
...
|
|
750
|
-
...
|
|
727
|
+
...baseResolved.compoundVariants ?? [],
|
|
728
|
+
...overrideResolved.compoundVariants ?? []
|
|
751
729
|
],
|
|
752
|
-
defaultVariants:
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
730
|
+
defaultVariants: {
|
|
731
|
+
...baseResolved.defaultVariants ?? void 0,
|
|
732
|
+
...overrideResolved.defaultVariants ?? void 0
|
|
733
|
+
},
|
|
734
|
+
state: overrideResolved.state ?? baseResolved.state,
|
|
735
|
+
container: overrideResolved.container ?? baseResolved.container,
|
|
736
|
+
containerName: overrideResolved.containerName ?? baseResolved.containerName
|
|
756
737
|
};
|
|
757
738
|
return createComponent(tag, merged);
|
|
758
739
|
};
|
|
@@ -763,10 +744,9 @@ function createStyledSystem(config) {
|
|
|
763
744
|
return tokenVarRef(prefix, group, name);
|
|
764
745
|
}
|
|
765
746
|
function rawToken(path) {
|
|
766
|
-
var _a2;
|
|
767
747
|
const [group, name] = path.split(".");
|
|
768
748
|
if (!group || !name) return void 0;
|
|
769
|
-
return
|
|
749
|
+
return tokens[group]?.[name];
|
|
770
750
|
}
|
|
771
751
|
function setTokens2(updates) {
|
|
772
752
|
if (typeof document === "undefined") return;
|
|
@@ -804,11 +784,42 @@ function createStyledSystem(config) {
|
|
|
804
784
|
});
|
|
805
785
|
}
|
|
806
786
|
|
|
787
|
+
// src/styled.ts
|
|
788
|
+
function resolveVariantClass(options, props) {
|
|
789
|
+
const out = [];
|
|
790
|
+
const variants = options.variants ?? {};
|
|
791
|
+
const defaults = options.defaultVariants ?? {};
|
|
792
|
+
for (const [variantName, valueMap] of Object.entries(variants)) {
|
|
793
|
+
const value = props[variantName] ?? defaults[variantName];
|
|
794
|
+
if (value === void 0) continue;
|
|
795
|
+
const key = String(value);
|
|
796
|
+
const cls = valueMap[key];
|
|
797
|
+
if (cls) out.push(cls);
|
|
798
|
+
}
|
|
799
|
+
for (const compound of options.compoundVariants ?? []) {
|
|
800
|
+
const matches = Object.entries(compound.variants).every(([k, expected]) => {
|
|
801
|
+
const current = props[k] ?? defaults[k];
|
|
802
|
+
return String(current) === expected;
|
|
803
|
+
});
|
|
804
|
+
if (matches) out.push(compound.className);
|
|
805
|
+
}
|
|
806
|
+
return out;
|
|
807
|
+
}
|
|
808
|
+
function resolveStyledClassName(options, props = {}) {
|
|
809
|
+
const parts = [options.base ?? "", ...resolveVariantClass(options, props), props.className ?? ""];
|
|
810
|
+
return twMerge4(...parts);
|
|
811
|
+
}
|
|
812
|
+
function styled(options) {
|
|
813
|
+
return function getClassName(props = {}) {
|
|
814
|
+
return resolveStyledClassName(options, props);
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
|
|
807
818
|
// src/twProxy.ts
|
|
808
819
|
function parseTemplate(strings, exprs) {
|
|
809
820
|
return strings.raw.reduce((acc, str, i) => {
|
|
810
821
|
const expr = exprs[i];
|
|
811
|
-
const exprStr = typeof expr === "function" ? "" : expr
|
|
822
|
+
const exprStr = typeof expr === "function" ? "" : expr ?? "";
|
|
812
823
|
return acc + str + String(exprStr);
|
|
813
824
|
}, "").split("\n").map((l) => l.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
814
825
|
}
|
|
@@ -931,8 +942,7 @@ function makeServerTag(tag) {
|
|
|
931
942
|
const baseFactory = makeTag(tag);
|
|
932
943
|
if (typeof window !== "undefined" && process.env.NODE_ENV !== "production") {
|
|
933
944
|
return ((...args) => {
|
|
934
|
-
|
|
935
|
-
const tagName = typeof tag === "string" ? tag : (_a = tag.displayName) != null ? _a : "Component";
|
|
945
|
+
const tagName = typeof tag === "string" ? tag : tag.displayName ?? "Component";
|
|
936
946
|
console.warn(
|
|
937
947
|
`[tailwind-styled-v4] tw.server.${tagName} rendered in browser. Ensure withTailwindStyled or Vite plugin is configured.`
|
|
938
948
|
);
|
|
@@ -1002,7 +1012,6 @@ function createTheme(tokenMap) {
|
|
|
1002
1012
|
return resolved;
|
|
1003
1013
|
}
|
|
1004
1014
|
function getGroupPrefix(group) {
|
|
1005
|
-
var _a;
|
|
1006
1015
|
const map = {
|
|
1007
1016
|
colors: "bg",
|
|
1008
1017
|
// default to bg; user can use t.text() for text colors
|
|
@@ -1010,7 +1019,7 @@ function getGroupPrefix(group) {
|
|
|
1010
1019
|
spacing: "p",
|
|
1011
1020
|
shadows: "shadow"
|
|
1012
1021
|
};
|
|
1013
|
-
return
|
|
1022
|
+
return map[group] ?? "";
|
|
1014
1023
|
}
|
|
1015
1024
|
var v4Tokens = {
|
|
1016
1025
|
/** bg-[var(--color-background)] */
|
|
@@ -1023,35 +1032,321 @@ var v4Tokens = {
|
|
|
1023
1032
|
fontMono: twVar("font", "font-mono")
|
|
1024
1033
|
};
|
|
1025
1034
|
|
|
1035
|
+
// src/parser.ts
|
|
1036
|
+
var _getNodePath = () => typeof chunkY5D3E72P_cjs.__require !== "undefined" ? chunkY5D3E72P_cjs.__require("path") : null;
|
|
1037
|
+
var _getCreateRequire = () => {
|
|
1038
|
+
if (typeof chunkY5D3E72P_cjs.__require !== "undefined") {
|
|
1039
|
+
try {
|
|
1040
|
+
return chunkY5D3E72P_cjs.__require("module").createRequire;
|
|
1041
|
+
} catch {
|
|
1042
|
+
return null;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
return null;
|
|
1046
|
+
};
|
|
1047
|
+
var _binding;
|
|
1048
|
+
function getBinding() {
|
|
1049
|
+
if (_binding !== void 0) return _binding;
|
|
1050
|
+
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_NO_RUST === "1") {
|
|
1051
|
+
return _binding = null;
|
|
1052
|
+
}
|
|
1053
|
+
if (typeof process === "undefined" || typeof process.cwd !== "function") {
|
|
1054
|
+
return _binding = null;
|
|
1055
|
+
}
|
|
1056
|
+
const runtimeDir = typeof __dirname === "string" ? __dirname : process.cwd();
|
|
1057
|
+
const nodePath = _getNodePath();
|
|
1058
|
+
const nodeCreateRequire = _getCreateRequire();
|
|
1059
|
+
if (!nodePath) return _binding = null;
|
|
1060
|
+
const req = typeof chunkY5D3E72P_cjs.__require === "function" ? chunkY5D3E72P_cjs.__require : nodeCreateRequire ? nodeCreateRequire(nodePath.join(runtimeDir, "noop.cjs")) : null;
|
|
1061
|
+
if (!req) return _binding = null;
|
|
1062
|
+
const candidates = [
|
|
1063
|
+
nodePath.resolve(process.cwd(), "native", "tailwind_styled_parser.node"),
|
|
1064
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "native", "tailwind_styled_parser.node"),
|
|
1065
|
+
nodePath.resolve(runtimeDir, "..", "..", "..", "..", "native", "tailwind_styled_parser.node")
|
|
1066
|
+
];
|
|
1067
|
+
for (const c of candidates) {
|
|
1068
|
+
try {
|
|
1069
|
+
const mod = req(c);
|
|
1070
|
+
if (mod?.parseClasses) return _binding = mod;
|
|
1071
|
+
} catch {
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
return _binding = null;
|
|
1075
|
+
}
|
|
1076
|
+
function splitClassListJS(input) {
|
|
1077
|
+
const out = [];
|
|
1078
|
+
let token = "";
|
|
1079
|
+
let square = 0;
|
|
1080
|
+
let round = 0;
|
|
1081
|
+
let escaped = false;
|
|
1082
|
+
for (const ch of input) {
|
|
1083
|
+
if (escaped) {
|
|
1084
|
+
token += ch;
|
|
1085
|
+
escaped = false;
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1088
|
+
if (ch === "\\") {
|
|
1089
|
+
token += ch;
|
|
1090
|
+
escaped = true;
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (ch === "[") square++;
|
|
1094
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1095
|
+
else if (ch === "(") round++;
|
|
1096
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1097
|
+
const isSpace = /\s/.test(ch);
|
|
1098
|
+
if (isSpace && square === 0 && round === 0) {
|
|
1099
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1100
|
+
token = "";
|
|
1101
|
+
continue;
|
|
1102
|
+
}
|
|
1103
|
+
token += ch;
|
|
1104
|
+
}
|
|
1105
|
+
if (token.trim().length > 0) out.push(token.trim());
|
|
1106
|
+
return out;
|
|
1107
|
+
}
|
|
1108
|
+
function parseClassTokenJS(rawToken) {
|
|
1109
|
+
const parts = [];
|
|
1110
|
+
let current = "";
|
|
1111
|
+
let square = 0;
|
|
1112
|
+
let round = 0;
|
|
1113
|
+
let escaped = false;
|
|
1114
|
+
for (const ch of rawToken) {
|
|
1115
|
+
if (escaped) {
|
|
1116
|
+
current += ch;
|
|
1117
|
+
escaped = false;
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
if (ch === "\\") {
|
|
1121
|
+
current += ch;
|
|
1122
|
+
escaped = true;
|
|
1123
|
+
continue;
|
|
1124
|
+
}
|
|
1125
|
+
if (ch === "[") square++;
|
|
1126
|
+
else if (ch === "]") square = Math.max(0, square - 1);
|
|
1127
|
+
else if (ch === "(") round++;
|
|
1128
|
+
else if (ch === ")") round = Math.max(0, round - 1);
|
|
1129
|
+
if (ch === ":" && square === 0 && round === 0) {
|
|
1130
|
+
parts.push(current);
|
|
1131
|
+
current = "";
|
|
1132
|
+
continue;
|
|
1133
|
+
}
|
|
1134
|
+
current += ch;
|
|
1135
|
+
}
|
|
1136
|
+
parts.push(current);
|
|
1137
|
+
const variants = parts.slice(0, -1).filter(Boolean);
|
|
1138
|
+
const baseToken = parts[parts.length - 1] ?? "";
|
|
1139
|
+
const parsed = { raw: rawToken, base: baseToken, variants };
|
|
1140
|
+
const opacityMatch = baseToken.match(/^(.*)\/(\d{1,3})$/);
|
|
1141
|
+
if (opacityMatch && opacityMatch[1].length > 0) {
|
|
1142
|
+
parsed.base = opacityMatch[1];
|
|
1143
|
+
parsed.modifier = { type: "opacity", value: opacityMatch[2] };
|
|
1144
|
+
return parsed;
|
|
1145
|
+
}
|
|
1146
|
+
const arbitraryMatch = baseToken.match(/\((--[a-zA-Z0-9_-]+)\)/);
|
|
1147
|
+
if (arbitraryMatch) {
|
|
1148
|
+
parsed.modifier = { type: "arbitrary", value: arbitraryMatch[1] };
|
|
1149
|
+
}
|
|
1150
|
+
return parsed;
|
|
1151
|
+
}
|
|
1152
|
+
function splitClassList(input) {
|
|
1153
|
+
const binding = getBinding();
|
|
1154
|
+
if (binding?.parseClasses) {
|
|
1155
|
+
try {
|
|
1156
|
+
return binding.parseClasses(input).map((p) => p.raw);
|
|
1157
|
+
} catch {
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
return splitClassListJS(input);
|
|
1161
|
+
}
|
|
1162
|
+
function parseClassToken(rawToken) {
|
|
1163
|
+
const binding = getBinding();
|
|
1164
|
+
if (binding?.parseClasses) {
|
|
1165
|
+
try {
|
|
1166
|
+
const results = binding.parseClasses(rawToken);
|
|
1167
|
+
if (results.length === 1) {
|
|
1168
|
+
const r = results[0];
|
|
1169
|
+
const parsed = {
|
|
1170
|
+
raw: r.raw,
|
|
1171
|
+
base: r.base,
|
|
1172
|
+
variants: r.variants
|
|
1173
|
+
};
|
|
1174
|
+
if (r.modifierType && r.modifierValue) {
|
|
1175
|
+
parsed.modifier = {
|
|
1176
|
+
type: r.modifierType,
|
|
1177
|
+
value: r.modifierValue
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
return parsed;
|
|
1181
|
+
}
|
|
1182
|
+
} catch {
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
return parseClassTokenJS(rawToken);
|
|
1186
|
+
}
|
|
1187
|
+
function parseTailwindClasses(input) {
|
|
1188
|
+
const binding = getBinding();
|
|
1189
|
+
if (binding?.parseClasses) {
|
|
1190
|
+
try {
|
|
1191
|
+
return binding.parseClasses(input).map((r) => {
|
|
1192
|
+
const parsed = { raw: r.raw, base: r.base, variants: r.variants };
|
|
1193
|
+
if (r.modifierType && r.modifierValue) {
|
|
1194
|
+
parsed.modifier = {
|
|
1195
|
+
type: r.modifierType,
|
|
1196
|
+
value: r.modifierValue
|
|
1197
|
+
};
|
|
1198
|
+
}
|
|
1199
|
+
return parsed;
|
|
1200
|
+
});
|
|
1201
|
+
} catch {
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
return splitClassListJS(input).map(parseClassTokenJS);
|
|
1205
|
+
}
|
|
1206
|
+
|
|
1207
|
+
// src/themeReader.ts
|
|
1208
|
+
var THEME_BLOCK_RE = /@theme\s*\{([\s\S]*?)\}/g;
|
|
1209
|
+
var CSS_VAR_RE = /--([a-zA-Z0-9_-]+)\s*:\s*([^;]+);/g;
|
|
1210
|
+
var cache = /* @__PURE__ */ new Map();
|
|
1211
|
+
function createEmptyTheme() {
|
|
1212
|
+
return {
|
|
1213
|
+
colors: {},
|
|
1214
|
+
spacing: {},
|
|
1215
|
+
fonts: {},
|
|
1216
|
+
breakpoints: {},
|
|
1217
|
+
animations: {},
|
|
1218
|
+
raw: {}
|
|
1219
|
+
};
|
|
1220
|
+
}
|
|
1221
|
+
function setToken2(theme, key, value) {
|
|
1222
|
+
theme.raw[key] = value;
|
|
1223
|
+
if (key.startsWith("color-")) {
|
|
1224
|
+
theme.colors[key.slice("color-".length)] = value;
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
if (key.startsWith("spacing-")) {
|
|
1228
|
+
theme.spacing[key.slice("spacing-".length)] = value;
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
if (key.startsWith("font-")) {
|
|
1232
|
+
theme.fonts[key.slice("font-".length)] = value;
|
|
1233
|
+
return;
|
|
1234
|
+
}
|
|
1235
|
+
if (key.startsWith("breakpoint-")) {
|
|
1236
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = value;
|
|
1237
|
+
return;
|
|
1238
|
+
}
|
|
1239
|
+
if (key.startsWith("animate-")) {
|
|
1240
|
+
theme.animations[key.slice("animate-".length)] = value;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1243
|
+
function resolveThemeValue(key, theme, visited = /* @__PURE__ */ new Set()) {
|
|
1244
|
+
const token = key.replace(/^--/, "");
|
|
1245
|
+
const raw = theme.raw[token];
|
|
1246
|
+
if (!raw) return "";
|
|
1247
|
+
if (visited.has(token)) return raw;
|
|
1248
|
+
const nested = raw.match(/^var\((--[a-zA-Z0-9_-]+)\)$/);
|
|
1249
|
+
if (!nested) return raw;
|
|
1250
|
+
visited.add(token);
|
|
1251
|
+
return resolveThemeValue(nested[1], theme, visited);
|
|
1252
|
+
}
|
|
1253
|
+
function extractThemeFromCSS(cssContent) {
|
|
1254
|
+
const hit = cache.get(cssContent);
|
|
1255
|
+
if (hit) return hit;
|
|
1256
|
+
const theme = createEmptyTheme();
|
|
1257
|
+
let blockMatch;
|
|
1258
|
+
while ((blockMatch = THEME_BLOCK_RE.exec(cssContent)) !== null) {
|
|
1259
|
+
const block = blockMatch[1];
|
|
1260
|
+
let varMatch;
|
|
1261
|
+
while ((varMatch = CSS_VAR_RE.exec(block)) !== null) {
|
|
1262
|
+
const key = varMatch[1];
|
|
1263
|
+
const value = varMatch[2].trim();
|
|
1264
|
+
setToken2(theme, key, value);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
for (const key of Object.keys(theme.raw)) {
|
|
1268
|
+
const resolved = resolveThemeValue(`--${key}`, theme);
|
|
1269
|
+
theme.raw[key] = resolved;
|
|
1270
|
+
if (key.startsWith("color-")) {
|
|
1271
|
+
theme.colors[key.slice("color-".length)] = resolved;
|
|
1272
|
+
} else if (key.startsWith("spacing-")) {
|
|
1273
|
+
theme.spacing[key.slice("spacing-".length)] = resolved;
|
|
1274
|
+
} else if (key.startsWith("font-")) {
|
|
1275
|
+
theme.fonts[key.slice("font-".length)] = resolved;
|
|
1276
|
+
} else if (key.startsWith("breakpoint-")) {
|
|
1277
|
+
theme.breakpoints[key.slice("breakpoint-".length)] = resolved;
|
|
1278
|
+
} else if (key.startsWith("animate-")) {
|
|
1279
|
+
theme.animations[key.slice("animate-".length)] = resolved;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
cache.set(cssContent, theme);
|
|
1283
|
+
return theme;
|
|
1284
|
+
}
|
|
1285
|
+
function generateTypeDefinitions(theme) {
|
|
1286
|
+
const toRecordType = (name, obj) => {
|
|
1287
|
+
const keys = Object.keys(obj);
|
|
1288
|
+
if (keys.length === 0) return ` ${name}: Record<string, string>`;
|
|
1289
|
+
const mapped = keys.map((k) => ` "${k}": string`).join("\n");
|
|
1290
|
+
return ` ${name}: {
|
|
1291
|
+
${mapped}
|
|
1292
|
+
}`;
|
|
1293
|
+
};
|
|
1294
|
+
return [
|
|
1295
|
+
"export interface TailwindStyledThemeTokens {",
|
|
1296
|
+
toRecordType("colors", theme.colors),
|
|
1297
|
+
toRecordType("spacing", theme.spacing),
|
|
1298
|
+
toRecordType("fonts", theme.fonts),
|
|
1299
|
+
toRecordType("breakpoints", theme.breakpoints),
|
|
1300
|
+
toRecordType("animations", theme.animations),
|
|
1301
|
+
"}",
|
|
1302
|
+
""
|
|
1303
|
+
].join("\n");
|
|
1304
|
+
}
|
|
1305
|
+
function clearThemeReaderCache() {
|
|
1306
|
+
cache.clear();
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1026
1309
|
exports.applyTokenSet = applyTokenSet;
|
|
1310
|
+
exports.clearThemeReaderCache = clearThemeReaderCache;
|
|
1027
1311
|
exports.cn = cn;
|
|
1028
1312
|
exports.containerRef = tokenRef;
|
|
1029
1313
|
exports.createComponent = createComponent;
|
|
1030
1314
|
exports.createStyledSystem = createStyledSystem;
|
|
1031
1315
|
exports.createTheme = createTheme;
|
|
1316
|
+
exports.createTwMerge = createTwMerge;
|
|
1032
1317
|
exports.createUseTokens = createUseTokens;
|
|
1033
1318
|
exports.cssVar = cssVar;
|
|
1034
1319
|
exports.cv = cv;
|
|
1035
1320
|
exports.cx = cx;
|
|
1036
1321
|
exports.cxm = cxm;
|
|
1322
|
+
exports.extractThemeFromCSS = extractThemeFromCSS;
|
|
1037
1323
|
exports.generateContainerCss = generateContainerCss;
|
|
1038
1324
|
exports.generateStateCss = generateStateCss;
|
|
1039
1325
|
exports.generateTokenCssString = generateTokenCssString;
|
|
1326
|
+
exports.generateTypeDefinitions = generateTypeDefinitions;
|
|
1040
1327
|
exports.getContainerRegistry = getContainerRegistry;
|
|
1041
1328
|
exports.getStateRegistry = getStateRegistry;
|
|
1042
1329
|
exports.getToken = getToken;
|
|
1043
1330
|
exports.getTokens = getTokens;
|
|
1044
1331
|
exports.liveToken = liveToken;
|
|
1332
|
+
exports.mergeWithRules = mergeWithRules;
|
|
1333
|
+
exports.parseClassToken = parseClassToken;
|
|
1334
|
+
exports.parseTailwindClasses = parseTailwindClasses;
|
|
1045
1335
|
exports.processContainer = processContainer;
|
|
1046
1336
|
exports.processState = processState;
|
|
1337
|
+
exports.resolveStyledClassName = resolveStyledClassName;
|
|
1338
|
+
exports.resolveThemeValue = resolveThemeValue;
|
|
1047
1339
|
exports.server = server;
|
|
1048
1340
|
exports.setToken = setToken;
|
|
1049
1341
|
exports.setTokens = setTokens;
|
|
1342
|
+
exports.splitClassList = splitClassList;
|
|
1343
|
+
exports.styled = styled;
|
|
1050
1344
|
exports.subscribeTokens = subscribeTokens;
|
|
1051
1345
|
exports.t = t;
|
|
1052
1346
|
exports.tokenRef = tokenRef;
|
|
1053
1347
|
exports.tokenVar = tokenVar;
|
|
1054
1348
|
exports.tw = tw;
|
|
1349
|
+
exports.twMerge = twMerge4;
|
|
1055
1350
|
exports.twVar = twVar;
|
|
1056
1351
|
exports.v4Tokens = v4Tokens;
|
|
1057
1352
|
//# sourceMappingURL=index.cjs.map
|