tailwind-styled-v4 5.1.17 → 5.1.19
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/index.browser.mjs +0 -3
- package/dist/index.browser.mjs.map +1 -1
- package/dist/index.d.mts +24 -35
- package/dist/index.d.ts +24 -35
- package/dist/index.js +23 -450
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -441
- package/dist/index.mjs.map +1 -1
- package/dist/runtime.d.mts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.js +2 -3
- package/dist/runtime.js.map +1 -1
- package/dist/runtime.mjs +1 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/theme.d.mts +23 -76
- package/dist/theme.d.ts +23 -76
- package/dist/theme.js +4 -221
- package/dist/theme.js.map +1 -1
- package/dist/theme.mjs +3 -208
- package/dist/theme.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,214 +1,18 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
1
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
4
2
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
5
3
|
}) : x)(function(x) {
|
|
6
4
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
7
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
8
6
|
});
|
|
9
|
-
var __esm = (fn, res) => function __init() {
|
|
10
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// node_modules/tsup/assets/esm_shims.js
|
|
14
|
-
import path from "path";
|
|
15
|
-
import { fileURLToPath } from "url";
|
|
16
|
-
var getFilename, __filename;
|
|
17
|
-
var init_esm_shims = __esm({
|
|
18
|
-
"node_modules/tsup/assets/esm_shims.js"() {
|
|
19
|
-
"use strict";
|
|
20
|
-
getFilename = () => fileURLToPath(import.meta.url);
|
|
21
|
-
__filename = /* @__PURE__ */ getFilename();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// packages/domain/shared/src/native-resolution.ts
|
|
26
|
-
import { createRequire } from "module";
|
|
27
|
-
import * as fs from "fs";
|
|
28
|
-
import * as path2 from "path";
|
|
29
|
-
function _safeCreateRequire() {
|
|
30
|
-
if (typeof import.meta !== "undefined" && import.meta.url && !import.meta.url.includes("unknown")) {
|
|
31
|
-
return createRequire(import.meta.url);
|
|
32
|
-
}
|
|
33
|
-
if (typeof __filename !== "undefined") {
|
|
34
|
-
return createRequire(__filename);
|
|
35
|
-
}
|
|
36
|
-
return createRequire(new URL(`file://${process.cwd()}/`).href);
|
|
37
|
-
}
|
|
38
|
-
function platformKey() {
|
|
39
|
-
if (isBrowser) return "browser";
|
|
40
|
-
return `${process.platform}-${process.arch}`;
|
|
41
|
-
}
|
|
42
|
-
function resolveNativeBinary(runtimeDir) {
|
|
43
|
-
const platform = platformKey();
|
|
44
|
-
const tried = [];
|
|
45
|
-
if (isBrowser) {
|
|
46
|
-
return { path: null, source: "not-found", platform, tried: ["not available in browser"] };
|
|
47
|
-
}
|
|
48
|
-
if (process.env.TWS_NO_NATIVE === "1" || process.env.TWS_DISABLE_NATIVE === "1") {
|
|
49
|
-
return { path: null, source: "not-found", platform, tried: [] };
|
|
50
|
-
}
|
|
51
|
-
const envPath = process.env.TW_NATIVE_PATH?.trim();
|
|
52
|
-
if (envPath) {
|
|
53
|
-
if (fs.existsSync(envPath)) {
|
|
54
|
-
return { path: envPath, source: "env", platform, tried };
|
|
55
|
-
}
|
|
56
|
-
tried.push(`env:${envPath} (not found)`);
|
|
57
|
-
}
|
|
58
|
-
const prebuiltPkgs = PLATFORM_MAP[platform] ?? [];
|
|
59
|
-
for (const pkg of prebuiltPkgs) {
|
|
60
|
-
try {
|
|
61
|
-
const candidate = _require.resolve(`${pkg}/tailwind_styled_parser.node`);
|
|
62
|
-
if (fs.existsSync(candidate)) {
|
|
63
|
-
return { path: candidate, source: "prebuilt", platform, tried };
|
|
64
|
-
}
|
|
65
|
-
tried.push(`prebuilt:${pkg} (resolved but missing)`);
|
|
66
|
-
} catch {
|
|
67
|
-
tried.push(`prebuilt:${pkg} (not installed)`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
const napiPlatform = platform === "linux-x64" ? "linux-x64-gnu" : platform === "linux-arm64" ? "linux-arm64-gnu" : platform;
|
|
71
|
-
const BINARY_NAMES_SELF = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
72
|
-
if (runtimeDir) {
|
|
73
|
-
for (const depth of ["..", path2.join("..", ".."), path2.join("..", "..", "..")]) {
|
|
74
|
-
const pkgRoot = path2.resolve(runtimeDir, depth);
|
|
75
|
-
for (const bin of BINARY_NAMES_SELF) {
|
|
76
|
-
for (const suffix of ["", `.${platform}`, `.${napiPlatform}`]) {
|
|
77
|
-
const candidate = path2.resolve(pkgRoot, "native", `${bin}${suffix}.node`);
|
|
78
|
-
tried.push(`self-bundled:${candidate}`);
|
|
79
|
-
if (fs.existsSync(candidate)) {
|
|
80
|
-
return { path: candidate, source: "prebuilt", platform, tried };
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
const cwd = process.cwd();
|
|
87
|
-
const base = runtimeDir ?? cwd;
|
|
88
|
-
const BINARY_NAMES = ["tailwind-styled-native", "tailwind_styled_parser"];
|
|
89
|
-
const localCandidates = [];
|
|
90
|
-
for (const bin of BINARY_NAMES) {
|
|
91
|
-
localCandidates.push(path2.resolve(base, `${bin}.node`));
|
|
92
|
-
localCandidates.push(path2.resolve(base, "..", `${bin}.node`));
|
|
93
|
-
localCandidates.push(path2.resolve(base, `${bin}.${platform}.node`));
|
|
94
|
-
localCandidates.push(path2.resolve(base, `${bin}.${napiPlatform}.node`));
|
|
95
|
-
}
|
|
96
|
-
for (const startDir of [cwd, base]) {
|
|
97
|
-
let dir = startDir;
|
|
98
|
-
for (let i = 0; i < 6; i++) {
|
|
99
|
-
const nativeDir = path2.resolve(dir, "native");
|
|
100
|
-
for (const bin of BINARY_NAMES) {
|
|
101
|
-
localCandidates.push(path2.resolve(nativeDir, `${bin}.node`));
|
|
102
|
-
localCandidates.push(path2.resolve(nativeDir, `${bin}.${platform}.node`));
|
|
103
|
-
localCandidates.push(path2.resolve(nativeDir, `${bin}.${napiPlatform}.node`));
|
|
104
|
-
localCandidates.push(path2.resolve(nativeDir, "target", "release", `${bin}.node`));
|
|
105
|
-
}
|
|
106
|
-
const parent = path2.resolve(dir, "..");
|
|
107
|
-
if (parent === dir) break;
|
|
108
|
-
dir = parent;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
for (const candidate of localCandidates) {
|
|
112
|
-
tried.push(`local:${candidate}`);
|
|
113
|
-
if (fs.existsSync(candidate)) {
|
|
114
|
-
return { path: candidate, source: "local", platform, tried };
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return { path: null, source: "not-found", platform, tried };
|
|
118
|
-
}
|
|
119
|
-
var isBrowser, _require, PLATFORM_MAP;
|
|
120
|
-
var init_native_resolution = __esm({
|
|
121
|
-
"packages/domain/shared/src/native-resolution.ts"() {
|
|
122
|
-
"use strict";
|
|
123
|
-
init_esm_shims();
|
|
124
|
-
isBrowser = typeof window !== "undefined" || typeof document !== "undefined";
|
|
125
|
-
_require = _safeCreateRequire();
|
|
126
|
-
PLATFORM_MAP = {
|
|
127
|
-
"linux-x64": ["@tailwind-styled/native-linux-x64-gnu", "@tailwind-styled/native-linux-x64"],
|
|
128
|
-
"linux-arm64": ["@tailwind-styled/native-linux-arm64-gnu", "@tailwind-styled/native-linux-arm64"],
|
|
129
|
-
"darwin-x64": ["@tailwind-styled/native-darwin-x64"],
|
|
130
|
-
"darwin-arm64": ["@tailwind-styled/native-darwin-arm64"],
|
|
131
|
-
"win32-x64": ["@tailwind-styled/native-win32-x64-msvc", "@tailwind-styled/native-win32-x64"],
|
|
132
|
-
"win32-arm64": ["@tailwind-styled/native-win32-arm64-msvc", "@tailwind-styled/native-win32-arm64"]
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
// packages/domain/shared/src/index.ts
|
|
138
|
-
import { createHash } from "crypto";
|
|
139
|
-
import fs2 from "fs";
|
|
140
|
-
import path3 from "path";
|
|
141
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
142
|
-
import { createRequire as createRequire2 } from "module";
|
|
143
|
-
var _require2;
|
|
144
|
-
var init_src = __esm({
|
|
145
|
-
"packages/domain/shared/src/index.ts"() {
|
|
146
|
-
"use strict";
|
|
147
|
-
init_esm_shims();
|
|
148
|
-
init_native_resolution();
|
|
149
|
-
_require2 = createRequire2(
|
|
150
|
-
typeof __filename !== "undefined" ? `file://${__filename}` : import.meta.url ?? "file://unknown"
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
// src/umbrella/index.ts
|
|
156
|
-
init_esm_shims();
|
|
157
7
|
|
|
158
8
|
// packages/domain/core/src/twProxy.ts
|
|
159
|
-
init_esm_shims();
|
|
160
9
|
import React2 from "react";
|
|
161
10
|
|
|
162
11
|
// packages/domain/core/src/createComponent.ts
|
|
163
|
-
init_esm_shims();
|
|
164
12
|
import React from "react";
|
|
165
13
|
|
|
166
|
-
// packages/domain/core/src/
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// packages/domain/core/src/native.ts
|
|
170
|
-
init_esm_shims();
|
|
171
|
-
init_src();
|
|
172
|
-
import { createRequire as createRequire3 } from "module";
|
|
173
|
-
import { dirname } from "path";
|
|
174
|
-
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
175
|
-
var isBrowser2 = typeof window !== "undefined" || typeof document !== "undefined";
|
|
176
|
-
var NATIVE_UNAVAILABLE_MESSAGE = "[tailwind-styled/core] Native binding is required but not available.\nPlease ensure you have run: npm run build:rust";
|
|
177
|
-
var _nodeRequire = createRequire3(
|
|
178
|
-
typeof __filename !== "undefined" ? `file://${__filename}` : typeof import.meta !== "undefined" && import.meta.url ? import.meta.url : "file://unknown"
|
|
179
|
-
);
|
|
180
|
-
var _loadNative = (path4) => _nodeRequire(path4);
|
|
181
|
-
var nativeBinding = null;
|
|
182
|
-
var bindingLoadAttempted = false;
|
|
183
|
-
var getBinding = () => {
|
|
184
|
-
if (isBrowser2) {
|
|
185
|
-
return null;
|
|
186
|
-
}
|
|
187
|
-
if (nativeBinding) return nativeBinding;
|
|
188
|
-
if (bindingLoadAttempted) {
|
|
189
|
-
throw new Error(NATIVE_UNAVAILABLE_MESSAGE);
|
|
190
|
-
}
|
|
191
|
-
bindingLoadAttempted = true;
|
|
192
|
-
try {
|
|
193
|
-
const runtimeDir = dirname(
|
|
194
|
-
typeof __filename !== "undefined" ? __filename : typeof import.meta !== "undefined" && import.meta.url ? fileURLToPath3(import.meta.url) : process.cwd()
|
|
195
|
-
);
|
|
196
|
-
const result = resolveNativeBinary(runtimeDir);
|
|
197
|
-
if (result.path && result.path.endsWith(".node")) {
|
|
198
|
-
const mod = _loadNative(result.path);
|
|
199
|
-
if (mod?.batchSplitClasses) {
|
|
200
|
-
nativeBinding = mod;
|
|
201
|
-
return nativeBinding;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
throw new Error(`${NATIVE_UNAVAILABLE_MESSAGE}
|
|
205
|
-
|
|
206
|
-
Tried: ${result.tried.join("\n")}`);
|
|
207
|
-
} catch (err) {
|
|
208
|
-
throw err instanceof Error ? err : new Error(String(err));
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
var getNativeBinding = getBinding;
|
|
14
|
+
// packages/domain/core/src/native.browser.ts
|
|
15
|
+
var getNativeBinding = () => null;
|
|
212
16
|
|
|
213
17
|
// packages/domain/core/src/containerQuery.ts
|
|
214
18
|
var CONTAINER_BREAKPOINTS = {
|
|
@@ -335,11 +139,7 @@ function getContainerRegistry() {
|
|
|
335
139
|
return containerRegistry;
|
|
336
140
|
}
|
|
337
141
|
|
|
338
|
-
// packages/domain/core/src/merge.ts
|
|
339
|
-
init_esm_shims();
|
|
340
|
-
|
|
341
142
|
// packages/domain/core/src/mergeFallback.ts
|
|
342
|
-
init_esm_shims();
|
|
343
143
|
var TEXT_SIZE_SUFFIXES = /* @__PURE__ */ new Set([
|
|
344
144
|
"xs",
|
|
345
145
|
"sm",
|
|
@@ -655,7 +455,6 @@ function mergeWithRules(rules, ...classLists) {
|
|
|
655
455
|
}
|
|
656
456
|
|
|
657
457
|
// packages/domain/core/src/parseTemplateFallback.ts
|
|
658
|
-
init_esm_shims();
|
|
659
458
|
var SUB_RE = /(?:\[([a-zA-Z][a-zA-Z0-9_-]*)\]|([a-zA-Z][a-zA-Z0-9_-]*))\s*\{([^}]*)\}/g;
|
|
660
459
|
var COMMENT_RE = /\/\/[^\n]*/g;
|
|
661
460
|
function collapseSpaces(s) {
|
|
@@ -686,7 +485,6 @@ function parseTemplateJs(raw) {
|
|
|
686
485
|
}
|
|
687
486
|
|
|
688
487
|
// packages/domain/core/src/stateEngine.ts
|
|
689
|
-
init_esm_shims();
|
|
690
488
|
var stateRegistry = /* @__PURE__ */ new Map();
|
|
691
489
|
if (typeof window !== "undefined") {
|
|
692
490
|
window.__TW_STATE_REGISTRY__ = stateRegistry;
|
|
@@ -1361,7 +1159,6 @@ var tw = Object.assign(twCallable, tagFactories, {
|
|
|
1361
1159
|
});
|
|
1362
1160
|
|
|
1363
1161
|
// packages/domain/core/src/cv.ts
|
|
1364
|
-
init_esm_shims();
|
|
1365
1162
|
var __generatedRegistry = {};
|
|
1366
1163
|
function registerVariantTable(componentId, table) {
|
|
1367
1164
|
__generatedRegistry[componentId] = table;
|
|
@@ -1497,7 +1294,6 @@ function cv(config, componentId) {
|
|
|
1497
1294
|
}
|
|
1498
1295
|
|
|
1499
1296
|
// packages/domain/core/src/cx.ts
|
|
1500
|
-
init_esm_shims();
|
|
1501
1297
|
function cn(...inputs) {
|
|
1502
1298
|
const strings = [];
|
|
1503
1299
|
for (const item of inputs) {
|
|
@@ -1534,7 +1330,6 @@ function cx(...inputs) {
|
|
|
1534
1330
|
var cxm = cx;
|
|
1535
1331
|
|
|
1536
1332
|
// packages/domain/core/src/styledSystem.ts
|
|
1537
|
-
init_esm_shims();
|
|
1538
1333
|
function tokenVarName(prefix, group, name) {
|
|
1539
1334
|
return `--${prefix}-${group}-${name}`;
|
|
1540
1335
|
}
|
|
@@ -1543,8 +1338,8 @@ function tokenVarRef(prefix, group, name) {
|
|
|
1543
1338
|
}
|
|
1544
1339
|
function resolveTokenRef(tokens, prefix, value) {
|
|
1545
1340
|
if (value.startsWith("token:")) {
|
|
1546
|
-
const
|
|
1547
|
-
const [group, name] =
|
|
1341
|
+
const path = value.slice(6);
|
|
1342
|
+
const [group, name] = path.split(".");
|
|
1548
1343
|
if (group && name && tokens[group]?.[name] !== void 0) {
|
|
1549
1344
|
return tokenVarRef(prefix, group, name);
|
|
1550
1345
|
}
|
|
@@ -1659,17 +1454,17 @@ function createStyledSystem(config) {
|
|
|
1659
1454
|
return createComponent(runtimeTag, merged);
|
|
1660
1455
|
};
|
|
1661
1456
|
}
|
|
1662
|
-
function token(
|
|
1663
|
-
const [group, name] =
|
|
1664
|
-
if (!group || !name) return
|
|
1457
|
+
function token(path) {
|
|
1458
|
+
const [group, name] = path.split(".");
|
|
1459
|
+
if (!group || !name) return path;
|
|
1665
1460
|
return tokenVarRef(prefix, group, name);
|
|
1666
1461
|
}
|
|
1667
|
-
function rawToken(
|
|
1668
|
-
const [group, name] =
|
|
1462
|
+
function rawToken(path) {
|
|
1463
|
+
const [group, name] = path.split(".");
|
|
1669
1464
|
if (!group || !name) return void 0;
|
|
1670
1465
|
return tokens[group]?.[name];
|
|
1671
1466
|
}
|
|
1672
|
-
function
|
|
1467
|
+
function setTokens(updates) {
|
|
1673
1468
|
if (typeof document === "undefined") return;
|
|
1674
1469
|
const styleId = `__tw-sys-tokens-${prefix}`;
|
|
1675
1470
|
const style = document.getElementById(styleId) ?? (() => {
|
|
@@ -1693,14 +1488,13 @@ function createStyledSystem(config) {
|
|
|
1693
1488
|
return Object.assign(factories, {
|
|
1694
1489
|
token,
|
|
1695
1490
|
rawToken,
|
|
1696
|
-
setTokens
|
|
1491
|
+
setTokens,
|
|
1697
1492
|
getConfig,
|
|
1698
1493
|
tokens
|
|
1699
1494
|
});
|
|
1700
1495
|
}
|
|
1701
1496
|
|
|
1702
1497
|
// packages/domain/core/src/styled.ts
|
|
1703
|
-
init_esm_shims();
|
|
1704
1498
|
function resolveVariantClass(options, props) {
|
|
1705
1499
|
const out = [];
|
|
1706
1500
|
const variants = options.variants ?? {};
|
|
@@ -1732,7 +1526,6 @@ function styled(options) {
|
|
|
1732
1526
|
}
|
|
1733
1527
|
|
|
1734
1528
|
// packages/domain/core/src/twTheme.ts
|
|
1735
|
-
init_esm_shims();
|
|
1736
1529
|
function cssVar(varName, fallback) {
|
|
1737
1530
|
const name = varName.startsWith("--") ? varName : `--${varName}`;
|
|
1738
1531
|
return fallback ? `var(${name}, ${fallback})` : `var(${name})`;
|
|
@@ -1797,207 +1590,8 @@ var v4Tokens = {
|
|
|
1797
1590
|
fontMono: twVar("font", "font-mono")
|
|
1798
1591
|
};
|
|
1799
1592
|
|
|
1800
|
-
// packages/domain/core/src/liveTokenEngine.ts
|
|
1801
|
-
init_esm_shims();
|
|
1802
|
-
|
|
1803
|
-
// packages/domain/theme/src/liveTokens.ts
|
|
1804
|
-
init_esm_shims();
|
|
1805
|
-
|
|
1806
|
-
// packages/domain/theme/src/liveTokenEngine.ts
|
|
1807
|
-
init_esm_shims();
|
|
1808
|
-
import React3 from "react";
|
|
1809
|
-
var TOKEN_ENGINE_KEY = "__TW_TOKEN_ENGINE__";
|
|
1810
|
-
function tokenVar(name) {
|
|
1811
|
-
const normalized = name.replace(/[^a-zA-Z0-9-]/g, "-").toLowerCase();
|
|
1812
|
-
return `--tw-token-${normalized}`;
|
|
1813
|
-
}
|
|
1814
|
-
function tokenRef(name) {
|
|
1815
|
-
return `var(${tokenVar(name)})`;
|
|
1816
|
-
}
|
|
1817
|
-
var buildRootCss = (tokens) => {
|
|
1818
|
-
const vars = Object.entries(tokens).map(([name, value]) => ` ${tokenVar(name)}: ${value};`).join("\n");
|
|
1819
|
-
return `:root {
|
|
1820
|
-
${vars}
|
|
1821
|
-
}`;
|
|
1822
|
-
};
|
|
1823
|
-
var createLiveTokenEngine = () => {
|
|
1824
|
-
const state = {
|
|
1825
|
-
currentTokens: {},
|
|
1826
|
-
styleEl: null,
|
|
1827
|
-
// Belum boleh nyentuh live DOM sampai komponen pertama selesai mount.
|
|
1828
|
-
// Ini yang nyegah hydration mismatch: tanpa flag ini, liveToken() yang
|
|
1829
|
-
// dipanggil di module top-level akan langsung document.documentElement
|
|
1830
|
-
// .style.setProperty(...) saat bundle client di-evaluasi — JAUH sebelum
|
|
1831
|
-
// React selesai hydrate — sehingga <html> versi live DOM beda dengan
|
|
1832
|
-
// <html> yang di-render server (yang gak pernah nyentuh `document`).
|
|
1833
|
-
hydrated: false
|
|
1834
|
-
};
|
|
1835
|
-
const subscribers = /* @__PURE__ */ new Set();
|
|
1836
|
-
const syncStyleEl = () => {
|
|
1837
|
-
if (!state.hydrated || typeof document === "undefined") return;
|
|
1838
|
-
if (!state.styleEl) {
|
|
1839
|
-
const styleEl = document.createElement("style");
|
|
1840
|
-
styleEl.id = "tw-live-tokens";
|
|
1841
|
-
styleEl.setAttribute("data-tw-tokens", "true");
|
|
1842
|
-
document.head.appendChild(styleEl);
|
|
1843
|
-
state.styleEl = styleEl;
|
|
1844
|
-
}
|
|
1845
|
-
state.styleEl.textContent = buildRootCss(state.currentTokens);
|
|
1846
|
-
};
|
|
1847
|
-
const notifySubscribers = () => {
|
|
1848
|
-
const snapshot = { ...state.currentTokens };
|
|
1849
|
-
for (const subscriber of subscribers) {
|
|
1850
|
-
try {
|
|
1851
|
-
subscriber(snapshot);
|
|
1852
|
-
} catch {
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
};
|
|
1856
|
-
const setToken2 = (name, value) => {
|
|
1857
|
-
state.currentTokens = { ...state.currentTokens, [name]: value };
|
|
1858
|
-
if (state.hydrated && typeof document !== "undefined") {
|
|
1859
|
-
document.documentElement.style.setProperty(tokenVar(name), value);
|
|
1860
|
-
}
|
|
1861
|
-
syncStyleEl();
|
|
1862
|
-
notifySubscribers();
|
|
1863
|
-
};
|
|
1864
|
-
const setTokens2 = (tokens) => {
|
|
1865
|
-
state.currentTokens = { ...state.currentTokens, ...tokens };
|
|
1866
|
-
if (state.hydrated && typeof document !== "undefined") {
|
|
1867
|
-
const root = document.documentElement;
|
|
1868
|
-
for (const [name, value] of Object.entries(tokens)) {
|
|
1869
|
-
root.style.setProperty(tokenVar(name), value);
|
|
1870
|
-
}
|
|
1871
|
-
}
|
|
1872
|
-
syncStyleEl();
|
|
1873
|
-
notifySubscribers();
|
|
1874
|
-
};
|
|
1875
|
-
const applyTokenSet2 = (tokens) => {
|
|
1876
|
-
if (state.hydrated && typeof document !== "undefined") {
|
|
1877
|
-
const root = document.documentElement;
|
|
1878
|
-
for (const name of Object.keys(state.currentTokens)) {
|
|
1879
|
-
if (!(name in tokens)) {
|
|
1880
|
-
root.style.removeProperty(tokenVar(name));
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
for (const [name, value] of Object.entries(tokens)) {
|
|
1884
|
-
root.style.setProperty(tokenVar(name), value);
|
|
1885
|
-
}
|
|
1886
|
-
}
|
|
1887
|
-
state.currentTokens = { ...tokens };
|
|
1888
|
-
syncStyleEl();
|
|
1889
|
-
notifySubscribers();
|
|
1890
|
-
};
|
|
1891
|
-
const markHydrated = () => {
|
|
1892
|
-
if (state.hydrated || typeof document === "undefined") return;
|
|
1893
|
-
state.hydrated = true;
|
|
1894
|
-
const root = document.documentElement;
|
|
1895
|
-
for (const [name, value] of Object.entries(state.currentTokens)) {
|
|
1896
|
-
root.style.setProperty(tokenVar(name), value);
|
|
1897
|
-
}
|
|
1898
|
-
syncStyleEl();
|
|
1899
|
-
};
|
|
1900
|
-
if (typeof window !== "undefined") {
|
|
1901
|
-
requestAnimationFrame(() => requestAnimationFrame(markHydrated));
|
|
1902
|
-
}
|
|
1903
|
-
return {
|
|
1904
|
-
markHydrated,
|
|
1905
|
-
liveToken(tokens) {
|
|
1906
|
-
setTokens2(tokens);
|
|
1907
|
-
const vars = {};
|
|
1908
|
-
for (const name of Object.keys(tokens)) {
|
|
1909
|
-
vars[name] = tokenRef(name);
|
|
1910
|
-
}
|
|
1911
|
-
return {
|
|
1912
|
-
vars,
|
|
1913
|
-
get(name) {
|
|
1914
|
-
return state.currentTokens[name];
|
|
1915
|
-
},
|
|
1916
|
-
set(name, value) {
|
|
1917
|
-
setToken2(name, value);
|
|
1918
|
-
},
|
|
1919
|
-
setAll(nextTokens) {
|
|
1920
|
-
setTokens2(nextTokens);
|
|
1921
|
-
},
|
|
1922
|
-
snapshot() {
|
|
1923
|
-
return { ...state.currentTokens };
|
|
1924
|
-
}
|
|
1925
|
-
};
|
|
1926
|
-
},
|
|
1927
|
-
getToken(name) {
|
|
1928
|
-
return state.currentTokens[name];
|
|
1929
|
-
},
|
|
1930
|
-
getTokens() {
|
|
1931
|
-
return { ...state.currentTokens };
|
|
1932
|
-
},
|
|
1933
|
-
setToken: setToken2,
|
|
1934
|
-
setTokens: setTokens2,
|
|
1935
|
-
applyTokenSet: applyTokenSet2,
|
|
1936
|
-
generateTokenCssString() {
|
|
1937
|
-
return buildRootCss(state.currentTokens);
|
|
1938
|
-
},
|
|
1939
|
-
subscribe(fn) {
|
|
1940
|
-
subscribers.add(fn);
|
|
1941
|
-
return () => {
|
|
1942
|
-
subscribers.delete(fn);
|
|
1943
|
-
};
|
|
1944
|
-
}
|
|
1945
|
-
};
|
|
1946
|
-
};
|
|
1947
|
-
var engine = createLiveTokenEngine();
|
|
1948
|
-
function liveToken(tokens) {
|
|
1949
|
-
return engine.liveToken(tokens);
|
|
1950
|
-
}
|
|
1951
|
-
function setToken(name, value) {
|
|
1952
|
-
engine.setToken(name, value);
|
|
1953
|
-
}
|
|
1954
|
-
function setTokens(tokens) {
|
|
1955
|
-
engine.setTokens(tokens);
|
|
1956
|
-
}
|
|
1957
|
-
function applyTokenSet(tokens) {
|
|
1958
|
-
engine.applyTokenSet(tokens);
|
|
1959
|
-
}
|
|
1960
|
-
function getToken(name) {
|
|
1961
|
-
return engine.getToken(name);
|
|
1962
|
-
}
|
|
1963
|
-
function getTokens() {
|
|
1964
|
-
return engine.getTokens();
|
|
1965
|
-
}
|
|
1966
|
-
function subscribeTokens(fn) {
|
|
1967
|
-
return engine.subscribe(fn);
|
|
1968
|
-
}
|
|
1969
|
-
function generateTokenCssString() {
|
|
1970
|
-
return engine.generateTokenCssString();
|
|
1971
|
-
}
|
|
1972
|
-
function createUseTokens() {
|
|
1973
|
-
return function useTokens() {
|
|
1974
|
-
const [tokens, setTokensState] = React3.useState({});
|
|
1975
|
-
React3.useEffect(() => {
|
|
1976
|
-
engine.markHydrated();
|
|
1977
|
-
setTokensState(engine.getTokens());
|
|
1978
|
-
return engine.subscribe((nextTokens) => setTokensState(nextTokens));
|
|
1979
|
-
}, []);
|
|
1980
|
-
return tokens;
|
|
1981
|
-
};
|
|
1982
|
-
}
|
|
1983
|
-
var liveTokenEngine = {
|
|
1984
|
-
getToken: engine.getToken,
|
|
1985
|
-
getTokens: engine.getTokens,
|
|
1986
|
-
setToken: engine.setToken,
|
|
1987
|
-
setTokens: engine.setTokens,
|
|
1988
|
-
applyTokenSet: engine.applyTokenSet,
|
|
1989
|
-
subscribeTokens: engine.subscribe,
|
|
1990
|
-
subscribe: engine.subscribe
|
|
1991
|
-
};
|
|
1992
|
-
var globalTokenEngine = globalThis;
|
|
1993
|
-
globalTokenEngine[TOKEN_ENGINE_KEY] = liveTokenEngine;
|
|
1994
|
-
if (typeof window !== "undefined") {
|
|
1995
|
-
window.__TW_TOKEN_ENGINE__ = liveTokenEngine;
|
|
1996
|
-
}
|
|
1997
|
-
|
|
1998
1593
|
// packages/domain/core/src/registry.ts
|
|
1999
|
-
|
|
2000
|
-
import React4 from "react";
|
|
1594
|
+
import React3 from "react";
|
|
2001
1595
|
var subComponentRegistry = /* @__PURE__ */ new Map();
|
|
2002
1596
|
function registerSubComponent(entry) {
|
|
2003
1597
|
subComponentRegistry.set(entry.name, entry);
|
|
@@ -2018,17 +1612,17 @@ function withSubComponents(Component, subComponentNames) {
|
|
|
2018
1612
|
}
|
|
2019
1613
|
registerSubComponent({
|
|
2020
1614
|
name: "icon",
|
|
2021
|
-
component: ({ children, className }) =>
|
|
1615
|
+
component: ({ children, className }) => React3.createElement("span", { className }, children),
|
|
2022
1616
|
defaultClasses: ""
|
|
2023
1617
|
});
|
|
2024
1618
|
registerSubComponent({
|
|
2025
1619
|
name: "text",
|
|
2026
|
-
component: ({ children, className }) =>
|
|
1620
|
+
component: ({ children, className }) => React3.createElement("span", { className }, children),
|
|
2027
1621
|
defaultClasses: ""
|
|
2028
1622
|
});
|
|
2029
1623
|
registerSubComponent({
|
|
2030
1624
|
name: "badge",
|
|
2031
|
-
component: ({ children, className }) =>
|
|
1625
|
+
component: ({ children, className }) => React3.createElement(
|
|
2032
1626
|
"span",
|
|
2033
1627
|
{
|
|
2034
1628
|
className: `ml-2 px-2 py-0.5 text-xs rounded-full bg-red-500 text-white ${className || ""}`
|
|
@@ -2039,67 +1633,60 @@ registerSubComponent({
|
|
|
2039
1633
|
});
|
|
2040
1634
|
registerSubComponent({
|
|
2041
1635
|
name: "header",
|
|
2042
|
-
component: ({ children, className }) =>
|
|
1636
|
+
component: ({ children, className }) => React3.createElement("header", { className: `font-bold text-lg ${className || ""}` }, children),
|
|
2043
1637
|
defaultClasses: "font-bold text-lg"
|
|
2044
1638
|
});
|
|
2045
1639
|
registerSubComponent({
|
|
2046
1640
|
name: "body",
|
|
2047
|
-
component: ({ children, className }) =>
|
|
1641
|
+
component: ({ children, className }) => React3.createElement("div", { className: `flex-1 ${className || ""}` }, children),
|
|
2048
1642
|
defaultClasses: "flex-1"
|
|
2049
1643
|
});
|
|
2050
1644
|
registerSubComponent({
|
|
2051
1645
|
name: "footer",
|
|
2052
|
-
component: ({ children, className }) =>
|
|
1646
|
+
component: ({ children, className }) => React3.createElement("footer", { className: `border-t pt-4 ${className || ""}` }, children),
|
|
2053
1647
|
defaultClasses: "border-t pt-4"
|
|
2054
1648
|
});
|
|
2055
1649
|
registerSubComponent({
|
|
2056
1650
|
name: "content",
|
|
2057
|
-
component: ({ children, className }) =>
|
|
1651
|
+
component: ({ children, className }) => React3.createElement("div", { className }, children),
|
|
2058
1652
|
defaultClasses: ""
|
|
2059
1653
|
});
|
|
2060
1654
|
registerSubComponent({
|
|
2061
1655
|
name: "title",
|
|
2062
|
-
component: ({ children, className }) =>
|
|
1656
|
+
component: ({ children, className }) => React3.createElement("div", { className: `font-semibold ${className || ""}` }, children),
|
|
2063
1657
|
defaultClasses: "font-semibold"
|
|
2064
1658
|
});
|
|
2065
1659
|
registerSubComponent({
|
|
2066
1660
|
name: "message",
|
|
2067
|
-
component: ({ children, className }) =>
|
|
1661
|
+
component: ({ children, className }) => React3.createElement("div", { className: `text-sm ${className || ""}` }, children),
|
|
2068
1662
|
defaultClasses: "text-sm"
|
|
2069
1663
|
});
|
|
2070
1664
|
registerSubComponent({
|
|
2071
1665
|
name: "close",
|
|
2072
|
-
component: ({ children, className }) =>
|
|
1666
|
+
component: ({ children, className }) => React3.createElement("span", { className: `cursor-pointer ${className || ""}` }, children),
|
|
2073
1667
|
defaultClasses: "cursor-pointer"
|
|
2074
1668
|
});
|
|
2075
1669
|
registerSubComponent({
|
|
2076
1670
|
name: "image",
|
|
2077
|
-
component: ({ className }) =>
|
|
1671
|
+
component: ({ className }) => React3.createElement("img", { className }),
|
|
2078
1672
|
defaultClasses: ""
|
|
2079
1673
|
});
|
|
2080
1674
|
export {
|
|
2081
|
-
applyTokenSet,
|
|
2082
1675
|
cn,
|
|
2083
|
-
tokenRef as containerRef,
|
|
2084
1676
|
createComponent,
|
|
2085
1677
|
createStyledSystem,
|
|
2086
1678
|
createTheme,
|
|
2087
1679
|
createTwMerge,
|
|
2088
|
-
createUseTokens,
|
|
2089
1680
|
cssVar,
|
|
2090
1681
|
cv,
|
|
2091
1682
|
cx,
|
|
2092
1683
|
cxm,
|
|
2093
1684
|
generateContainerCss,
|
|
2094
1685
|
generateStateCss,
|
|
2095
|
-
generateTokenCssString,
|
|
2096
1686
|
getAllSubComponents,
|
|
2097
1687
|
getContainerRegistry,
|
|
2098
1688
|
getStateRegistry,
|
|
2099
1689
|
getSubComponent,
|
|
2100
|
-
getToken,
|
|
2101
|
-
getTokens,
|
|
2102
|
-
liveToken,
|
|
2103
1690
|
mergeWithRules,
|
|
2104
1691
|
processContainer,
|
|
2105
1692
|
processState,
|
|
@@ -2107,13 +1694,8 @@ export {
|
|
|
2107
1694
|
registerVariantTable,
|
|
2108
1695
|
resolveStyledClassName,
|
|
2109
1696
|
server,
|
|
2110
|
-
setToken,
|
|
2111
|
-
setTokens,
|
|
2112
1697
|
styled,
|
|
2113
|
-
subscribeTokens,
|
|
2114
1698
|
t,
|
|
2115
|
-
tokenRef,
|
|
2116
|
-
tokenVar,
|
|
2117
1699
|
tw,
|
|
2118
1700
|
twMerge,
|
|
2119
1701
|
twVar,
|