@kbach/react-native 1.1.1-beta.1 → 1.1.1-beta.2
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/AGENTS.md +10 -0
- package/README.md +25 -2
- package/android/src/main/jniLibs/arm64-v8a/libkbach_core_engine.so +0 -0
- package/android/src/main/jniLibs/x86_64/libkbach_core_engine.so +0 -0
- package/dist/{chunk-FSO4WVCH.mjs → chunk-BN6RWNCE.mjs} +1 -1
- package/dist/chunk-TCSCNQQ7.mjs +623 -0
- package/dist/{chunk-6F44N62F.mjs → chunk-VMI2JVCQ.mjs} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +69 -1
- package/dist/index.web.d.ts +1 -1
- package/dist/index.web.js +12 -1
- package/dist/index.web.mjs +13 -2
- package/dist/jsx-dev-runtime.js +76 -2
- package/dist/jsx-dev-runtime.web.js +1 -1
- package/dist/jsx-dev-runtime.web.mjs +3 -3
- package/dist/jsx-runtime.js +76 -2
- package/dist/jsx-runtime.web.js +1 -1
- package/dist/jsx-runtime.web.mjs +2 -2
- package/dist/{semanticElements-Bk3TB-vt.d.ts → semanticElements-CY-W_7tU.d.ts} +7 -0
- package/dist/theme.d.ts +2 -0
- package/llms.txt +7 -2
- package/package.json +1 -1
- package/dist/chunk-R7E5D3D6.mjs +0 -623
package/dist/index.web.mjs
CHANGED
|
@@ -10,15 +10,23 @@ import {
|
|
|
10
10
|
subscribeDynamicTokens,
|
|
11
11
|
subscribeGlobalDarkMode,
|
|
12
12
|
toggleGlobalDarkMode
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BN6RWNCE.mjs";
|
|
14
14
|
import {
|
|
15
15
|
defaultTheme,
|
|
16
16
|
getTheme,
|
|
17
17
|
resolveClassName,
|
|
18
18
|
setTheme
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-TCSCNQQ7.mjs";
|
|
20
20
|
|
|
21
21
|
// src/config.ts
|
|
22
|
+
function composeMap(compose) {
|
|
23
|
+
const out = {};
|
|
24
|
+
for (const [name, value] of Object.entries(compose)) {
|
|
25
|
+
const text = Array.isArray(value) ? value.join(" ") : value;
|
|
26
|
+
if (typeof text === "string" && text.trim() !== "" && name.trim() !== "") out[name.trim()] = text.trim();
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
22
30
|
function parseHexRgb(hex) {
|
|
23
31
|
const m = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(hex.trim());
|
|
24
32
|
if (!m) return null;
|
|
@@ -88,6 +96,9 @@ function resolveKbachConfig(config) {
|
|
|
88
96
|
if (config.extend?.container) {
|
|
89
97
|
theme = { ...theme, container: { ...theme.container, ...config.extend.container } };
|
|
90
98
|
}
|
|
99
|
+
if (config.compose) {
|
|
100
|
+
theme = { ...theme, compose: { ...theme.compose, ...composeMap(config.compose) } };
|
|
101
|
+
}
|
|
91
102
|
if (config.darkMode) {
|
|
92
103
|
theme = { ...theme, darkMode: config.darkMode };
|
|
93
104
|
}
|
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -981,6 +981,63 @@ function expandToken(token, prefix, important, out) {
|
|
|
981
981
|
for (const part of splitTopLevel(token.slice(open + 1, close))) expandToken(part, innerPrefix, rest === "!" || important, out);
|
|
982
982
|
}
|
|
983
983
|
|
|
984
|
+
// src/jsEngine/compose.ts
|
|
985
|
+
var MAX_DEPTH = 8;
|
|
986
|
+
function splitVariants(token) {
|
|
987
|
+
let depth = 0;
|
|
988
|
+
let last = -1;
|
|
989
|
+
for (let i = 0; i < token.length; i++) {
|
|
990
|
+
const ch = token[i];
|
|
991
|
+
if (ch === "[" || ch === "(") depth++;
|
|
992
|
+
else if (ch === "]" || ch === ")") depth--;
|
|
993
|
+
else if (ch === ":" && depth === 0) last = i;
|
|
994
|
+
}
|
|
995
|
+
return last < 0 ? ["", token] : [token.slice(0, last + 1), token.slice(last + 1)];
|
|
996
|
+
}
|
|
997
|
+
function stripImportant(base) {
|
|
998
|
+
if (base.endsWith("!")) return [base.slice(0, -1), true];
|
|
999
|
+
if (base.startsWith("!")) return [base.slice(1), true];
|
|
1000
|
+
return [base, false];
|
|
1001
|
+
}
|
|
1002
|
+
function withImportant(cls, important) {
|
|
1003
|
+
const [, base] = splitVariants(cls);
|
|
1004
|
+
return important && !cls.endsWith("!") && !base.startsWith("!") ? cls + "!" : cls;
|
|
1005
|
+
}
|
|
1006
|
+
function expandInto(prefix, value, important, compose, path, out) {
|
|
1007
|
+
for (const cls of expandVariantGroups(value).split(/\s+/).filter(Boolean)) {
|
|
1008
|
+
const [variants, base] = splitVariants(cls);
|
|
1009
|
+
const [name, bang] = stripImportant(base);
|
|
1010
|
+
const inner = Object.prototype.hasOwnProperty.call(compose, name) ? compose[name] : void 0;
|
|
1011
|
+
if (inner !== void 0 && path.length < MAX_DEPTH && !path.includes(name)) {
|
|
1012
|
+
path.push(name);
|
|
1013
|
+
expandInto(prefix + variants, inner, important || bang, compose, path, out);
|
|
1014
|
+
path.pop();
|
|
1015
|
+
} else {
|
|
1016
|
+
out.push(withImportant(prefix + cls, important));
|
|
1017
|
+
}
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function expandComposeToken(token, compose) {
|
|
1021
|
+
if (!compose) return null;
|
|
1022
|
+
const [variants, base] = splitVariants(token);
|
|
1023
|
+
const [name, important] = stripImportant(base);
|
|
1024
|
+
if (!Object.prototype.hasOwnProperty.call(compose, name)) return null;
|
|
1025
|
+
const out = [];
|
|
1026
|
+
expandInto(variants, compose[name], important, compose, [name], out);
|
|
1027
|
+
return out;
|
|
1028
|
+
}
|
|
1029
|
+
function expandComposeClasses(classString, compose) {
|
|
1030
|
+
if (!compose || Object.keys(compose).length === 0) return classString;
|
|
1031
|
+
const composed = [];
|
|
1032
|
+
const own = [];
|
|
1033
|
+
for (const token of classString.split(/\s+/).filter(Boolean)) {
|
|
1034
|
+
const classes = expandComposeToken(token, compose);
|
|
1035
|
+
if (classes) composed.push(...classes);
|
|
1036
|
+
else own.push(token);
|
|
1037
|
+
}
|
|
1038
|
+
return composed.length === 0 ? classString : [...composed, ...own].join(" ");
|
|
1039
|
+
}
|
|
1040
|
+
|
|
984
1041
|
// src/jsxRuntimeCore.ts
|
|
985
1042
|
var DYNAMIC_TOKEN_MATCH_RE = /var\(--([a-zA-Z0-9-]+)\)/g;
|
|
986
1043
|
function substituteDynamicTokens(classStrRaw) {
|
|
@@ -1175,6 +1232,23 @@ function ReactiveElement({
|
|
|
1175
1232
|
elementKey
|
|
1176
1233
|
);
|
|
1177
1234
|
}
|
|
1235
|
+
var flatCache = /* @__PURE__ */ new Map();
|
|
1236
|
+
var flatCacheTheme = null;
|
|
1237
|
+
function flatClasses(classNameProp) {
|
|
1238
|
+
const theme = (0, import_theme.getTheme)();
|
|
1239
|
+
if (!theme.compose && !classNameProp.includes(":(")) return classNameProp;
|
|
1240
|
+
if (theme !== flatCacheTheme) {
|
|
1241
|
+
flatCache.clear();
|
|
1242
|
+
flatCacheTheme = theme;
|
|
1243
|
+
}
|
|
1244
|
+
let flat = flatCache.get(classNameProp);
|
|
1245
|
+
if (flat === void 0) {
|
|
1246
|
+
flat = expandComposeClasses(classNameProp.includes(":(") ? expandVariantGroups(classNameProp) : classNameProp, theme.compose);
|
|
1247
|
+
if (flatCache.size >= 500) flatCache.clear();
|
|
1248
|
+
flatCache.set(classNameProp, flat);
|
|
1249
|
+
}
|
|
1250
|
+
return flat;
|
|
1251
|
+
}
|
|
1178
1252
|
function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
1179
1253
|
if (type === null || typeof type === "symbol" || !rawProps) {
|
|
1180
1254
|
return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
@@ -1183,7 +1257,7 @@ function processElement(resolveStyle2, type, rawProps, key, isStaticChildren) {
|
|
|
1183
1257
|
if (typeof classNameProp !== "string") {
|
|
1184
1258
|
return makeElement(isStaticChildren, type, rawProps, key);
|
|
1185
1259
|
}
|
|
1186
|
-
const classStrRaw =
|
|
1260
|
+
const classStrRaw = flatClasses(classNameProp);
|
|
1187
1261
|
if (DARK_MODIFIER_RE.test(classStrRaw) || BREAKPOINT_MODIFIER_RE.test(classStrRaw) || HOVER_MODIFIER_RE.test(classStrRaw) || FOCUS_MODIFIER_RE.test(classStrRaw) || classStrRaw.includes("var(--") || PERCENT_RELATIVE_CALC_HINT_RE.test(classStrRaw) || usesModeAwareColor(classStrRaw)) {
|
|
1188
1262
|
return (0, import_jsx_runtime.jsx)(
|
|
1189
1263
|
ReactiveElement,
|
|
@@ -2519,7 +2593,7 @@ Fix: use a plain px/rem calc, a fraction utility (e.g. w-1/2), or resolve this v
|
|
|
2519
2593
|
return { value: null, warning };
|
|
2520
2594
|
}
|
|
2521
2595
|
function resolveStyleJsWithWarnings(classString, theme, colorScheme, pressed, width) {
|
|
2522
|
-
classString = expandVariantGroups(classString);
|
|
2596
|
+
classString = expandComposeClasses(expandVariantGroups(classString), theme.compose);
|
|
2523
2597
|
const style = {};
|
|
2524
2598
|
const warnings = [];
|
|
2525
2599
|
let shadowOffset = null;
|