@kbach/react 0.5.47 → 0.5.48
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/{chunk-NIBECTRQ.mjs → chunk-BKSXIWL7.mjs} +8 -7
- package/dist/chunk-YZNSWFJT.mjs +544 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +121 -24
- package/dist/index.mjs +30 -16
- package/dist/jsx-dev-runtime.js +116 -29
- package/dist/jsx-dev-runtime.mjs +2 -3
- package/dist/jsx-runtime.d.mts +12 -1
- package/dist/jsx-runtime.d.ts +12 -1
- package/dist/jsx-runtime.js +125 -31
- package/dist/jsx-runtime.mjs +6 -5
- package/dist/vite-plugin.js +29 -18
- package/dist/vite-plugin.mjs +22 -12
- package/package.json +1 -1
- package/dist/chunk-LCK5OGHT.mjs +0 -226
- package/dist/chunk-U3GY5Y6J.mjs +0 -232
package/dist/jsx-runtime.js
CHANGED
|
@@ -33,7 +33,8 @@ __export(jsx_runtime_exports, {
|
|
|
33
33
|
Fragment: () => import_react5.Fragment,
|
|
34
34
|
_invalidateDefaultFontCache: () => _invalidateDefaultFontCache,
|
|
35
35
|
jsx: () => jsx,
|
|
36
|
-
jsxs: () => jsxs
|
|
36
|
+
jsxs: () => jsxs,
|
|
37
|
+
registerWebElement: () => registerWebElement
|
|
37
38
|
});
|
|
38
39
|
module.exports = __toCommonJS(jsx_runtime_exports);
|
|
39
40
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -787,7 +788,12 @@ function resolveColor(value, colors, isArbitrary) {
|
|
|
787
788
|
}
|
|
788
789
|
}
|
|
789
790
|
if (!hex) return null;
|
|
790
|
-
if (!opacityPart)
|
|
791
|
+
if (!opacityPart) {
|
|
792
|
+
if (!isWeb && hex.startsWith("#") && hex.length === 9) {
|
|
793
|
+
return hexToRgba(hex, Math.round(parseInt(hex.slice(7, 9), 16) / 255 * 1e3) / 1e3);
|
|
794
|
+
}
|
|
795
|
+
return hex;
|
|
796
|
+
}
|
|
791
797
|
let alpha;
|
|
792
798
|
if (opacityPart.startsWith("[") && opacityPart.endsWith("]")) {
|
|
793
799
|
const v = parseFloat(opacityPart.slice(1, -1));
|
|
@@ -2350,12 +2356,6 @@ var RESOLVERS = {
|
|
|
2350
2356
|
function resolveUtility(parsed, theme) {
|
|
2351
2357
|
if (!parsed.value) {
|
|
2352
2358
|
if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
|
|
2353
|
-
if (parsed.utility === "grd" || parsed.utility === "grid") {
|
|
2354
|
-
return getEffectiveIsWeb() ? { display: "grid" } : null;
|
|
2355
|
-
}
|
|
2356
|
-
if (parsed.utility === "inline-grid") {
|
|
2357
|
-
return getEffectiveIsWeb() ? { display: "inline-grid" } : null;
|
|
2358
|
-
}
|
|
2359
2359
|
if (parsed.utility in getStandalone()) return getStandalone()[parsed.utility] ?? null;
|
|
2360
2360
|
}
|
|
2361
2361
|
const resolver = PLUGIN_RESOLVERS[parsed.utility] ?? RESOLVERS[parsed.utility];
|
|
@@ -2940,6 +2940,8 @@ function buildConfig(userConfig) {
|
|
|
2940
2940
|
};
|
|
2941
2941
|
clearPluginUtilities();
|
|
2942
2942
|
clearPluginModifiers();
|
|
2943
|
+
const _store = getConfigStore();
|
|
2944
|
+
for (const k of Object.keys(_store.customVariants)) delete _store.customVariants[k];
|
|
2943
2945
|
const pluginAPI = makePluginAPI(resolved.theme);
|
|
2944
2946
|
for (const plugin of resolved.plugins) {
|
|
2945
2947
|
plugin(pluginAPI);
|
|
@@ -3146,7 +3148,7 @@ var InteractiveWrapper = (0, import_react3.forwardRef)(
|
|
|
3146
3148
|
const handleBlur = (0, import_react3.useCallback)(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
3147
3149
|
const computedStyle = (0, import_react3.useMemo)(
|
|
3148
3150
|
() => {
|
|
3149
|
-
const s = flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused }, breakpoints);
|
|
3151
|
+
const s = flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!rest.disabled, checked: !!rest.checked }, breakpoints);
|
|
3150
3152
|
delete s.__divideX;
|
|
3151
3153
|
delete s.__divideY;
|
|
3152
3154
|
delete s.__divideColor;
|
|
@@ -3180,8 +3182,8 @@ var InteractiveWrapper = (0, import_react3.forwardRef)(
|
|
|
3180
3182
|
[resolvedStyle, isDark, pressed, hovered, focused, width]
|
|
3181
3183
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
3182
3184
|
);
|
|
3183
|
-
const
|
|
3184
|
-
const finalStyle =
|
|
3185
|
+
const skipComputedInline = isWeb || !isNative && typeof Component === "string";
|
|
3186
|
+
const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3185
3187
|
const { children, ...restWithoutChildren } = rest;
|
|
3186
3188
|
const componentProps = {
|
|
3187
3189
|
ref,
|
|
@@ -3209,11 +3211,15 @@ var DarkWrapper = import_react4.default.forwardRef(
|
|
|
3209
3211
|
const needsWidth = hasResponsiveBuckets(resolvedStyle);
|
|
3210
3212
|
const width = useConditionalWidth(needsWidth);
|
|
3211
3213
|
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS2;
|
|
3212
|
-
const
|
|
3213
|
-
|
|
3214
|
-
|
|
3215
|
-
|
|
3216
|
-
|
|
3214
|
+
const isNonStringComponent = typeof Component !== "string";
|
|
3215
|
+
const computedStyle = (0, import_react4.useMemo)(() => {
|
|
3216
|
+
const s = flatten(resolvedStyle, isDark, {}, breakpoints);
|
|
3217
|
+
stripInternalMarkers(s);
|
|
3218
|
+
if (isNonStringComponent) stripWebOnlyProps(s);
|
|
3219
|
+
return s;
|
|
3220
|
+
}, [resolvedStyle, isDark, width, isNonStringComponent]);
|
|
3221
|
+
const skipComputedInline = isWeb || !isNative && typeof Component === "string";
|
|
3222
|
+
const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3217
3223
|
const props = { ref, ...rest, style: finalStyle };
|
|
3218
3224
|
return Array.isArray(children) ? import_react4.default.createElement(Component, props, ...children) : import_react4.default.createElement(Component, props, children);
|
|
3219
3225
|
}
|
|
@@ -3331,14 +3337,101 @@ function stripWebOnlyInlineProps(s) {
|
|
|
3331
3337
|
delete s.position;
|
|
3332
3338
|
}
|
|
3333
3339
|
}
|
|
3340
|
+
var _rnToHtml = {
|
|
3341
|
+
View: "div",
|
|
3342
|
+
SafeAreaView: "div",
|
|
3343
|
+
KeyboardAvoidingView: "div",
|
|
3344
|
+
ScrollView: "div",
|
|
3345
|
+
VirtualizedList: "div",
|
|
3346
|
+
Text: "span",
|
|
3347
|
+
Pressable: "div",
|
|
3348
|
+
TouchableOpacity: "div",
|
|
3349
|
+
TouchableHighlight: "div",
|
|
3350
|
+
TouchableWithoutFeedback: "div",
|
|
3351
|
+
TouchableNativeFeedback: "div"
|
|
3352
|
+
};
|
|
3353
|
+
var _userWebTypeMap = /* @__PURE__ */ new Map();
|
|
3354
|
+
var _webTypeCache = /* @__PURE__ */ new WeakMap();
|
|
3355
|
+
function registerWebElement(rnComponent, htmlTag) {
|
|
3356
|
+
if (typeof rnComponent !== "object" && typeof rnComponent !== "function") return;
|
|
3357
|
+
_userWebTypeMap.set(rnComponent, htmlTag);
|
|
3358
|
+
_webTypeCache.delete(rnComponent);
|
|
3359
|
+
}
|
|
3360
|
+
function getWebTag(type) {
|
|
3361
|
+
if (typeof type === "string") return null;
|
|
3362
|
+
if (type === null || typeof type !== "function" && typeof type !== "object") return null;
|
|
3363
|
+
const obj = type;
|
|
3364
|
+
if (_userWebTypeMap.has(obj)) return _userWebTypeMap.get(obj);
|
|
3365
|
+
if (_webTypeCache.has(obj)) return _webTypeCache.get(obj);
|
|
3366
|
+
const name = obj.displayName ?? obj.name;
|
|
3367
|
+
const tag = name ? _rnToHtml[name] ?? null : null;
|
|
3368
|
+
_webTypeCache.set(obj, tag);
|
|
3369
|
+
return tag;
|
|
3370
|
+
}
|
|
3371
|
+
var _rnOnlyProps = /* @__PURE__ */ new Set([
|
|
3372
|
+
"onLongPress",
|
|
3373
|
+
"delayLongPress",
|
|
3374
|
+
"activeOpacity",
|
|
3375
|
+
"underlayColor",
|
|
3376
|
+
"hitSlop",
|
|
3377
|
+
"pressRetentionOffset",
|
|
3378
|
+
"accessible",
|
|
3379
|
+
"accessibilityState",
|
|
3380
|
+
"accessibilityLiveRegion",
|
|
3381
|
+
"importantForAccessibility",
|
|
3382
|
+
"nativeID",
|
|
3383
|
+
"collapsable",
|
|
3384
|
+
"needsOffscreenAlphaCompositing",
|
|
3385
|
+
"renderToHardwareTextureAndroid",
|
|
3386
|
+
"shouldRasterizeIOS",
|
|
3387
|
+
"pointerEvents"
|
|
3388
|
+
// RN prop — values differ from HTML pointer-events CSS
|
|
3389
|
+
]);
|
|
3390
|
+
var _pressableDisplayNames = /* @__PURE__ */ new Set([
|
|
3391
|
+
"Pressable",
|
|
3392
|
+
"TouchableOpacity",
|
|
3393
|
+
"TouchableHighlight",
|
|
3394
|
+
"TouchableWithoutFeedback",
|
|
3395
|
+
"TouchableNativeFeedback"
|
|
3396
|
+
]);
|
|
3397
|
+
function transformToWebProps(originalName, props) {
|
|
3398
|
+
const out = {};
|
|
3399
|
+
const isPressable = _pressableDisplayNames.has(originalName);
|
|
3400
|
+
for (const [k, v] of Object.entries(props)) {
|
|
3401
|
+
if (_rnOnlyProps.has(k)) continue;
|
|
3402
|
+
if (k === "onPress") {
|
|
3403
|
+
if (!("onClick" in props)) out.onClick = v;
|
|
3404
|
+
continue;
|
|
3405
|
+
}
|
|
3406
|
+
if (k === "accessibilityLabel") {
|
|
3407
|
+
if (out["aria-label"] == null) out["aria-label"] = v;
|
|
3408
|
+
continue;
|
|
3409
|
+
}
|
|
3410
|
+
if (k === "accessibilityRole") {
|
|
3411
|
+
if (out.role == null) out.role = v;
|
|
3412
|
+
continue;
|
|
3413
|
+
}
|
|
3414
|
+
if (k === "testID") {
|
|
3415
|
+
if (out["data-testid"] == null) out["data-testid"] = v;
|
|
3416
|
+
continue;
|
|
3417
|
+
}
|
|
3418
|
+
out[k] = v;
|
|
3419
|
+
}
|
|
3420
|
+
if (isPressable && !out.role) out.role = "button";
|
|
3421
|
+
return out;
|
|
3422
|
+
}
|
|
3334
3423
|
function processElement(type, rawProps, key, isStaticChildren) {
|
|
3335
3424
|
if (typeof type === "symbol") return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
3336
|
-
|
|
3337
|
-
const
|
|
3425
|
+
const webTag = isWeb ? getWebTag(type) : null;
|
|
3426
|
+
const effectiveType = webTag ?? type;
|
|
3427
|
+
const originalName = webTag ? type?.displayName ?? type?.name : void 0;
|
|
3428
|
+
if (!rawProps) return (0, import_jsx_runtime.jsx)(effectiveType, null, key);
|
|
3429
|
+
const workingProps = webTag && originalName ? transformToWebProps(originalName, rawProps) : rawProps;
|
|
3430
|
+
const { className, kb: kbProp, __kbachStyles, __kbachClasses } = workingProps;
|
|
3338
3431
|
const classStr = className ?? kbProp ?? __kbachClasses;
|
|
3339
3432
|
if (!isNative && isRuntimeCSSDisabled() && classStr && !__kbachStyles) {
|
|
3340
|
-
const { style: userStyle2, ...passProps2 } = omitConsumed(
|
|
3341
|
-
return makeElement(isStaticChildren,
|
|
3433
|
+
const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
|
|
3434
|
+
return makeElement(isStaticChildren, effectiveType, {
|
|
3342
3435
|
...passProps2,
|
|
3343
3436
|
className: normalizeClassString(classStr),
|
|
3344
3437
|
...userStyle2 !== void 0 ? { style: userStyle2 } : {}
|
|
@@ -3346,18 +3439,18 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3346
3439
|
}
|
|
3347
3440
|
if (!classStr && !__kbachStyles) {
|
|
3348
3441
|
const defaultFont = getCachedDefaultFont();
|
|
3349
|
-
if (!defaultFont) return makeElement(isStaticChildren,
|
|
3350
|
-
const { style: userStyle2, ...passProps2 } = omitConsumed(
|
|
3442
|
+
if (!defaultFont) return makeElement(isStaticChildren, effectiveType, workingProps, key);
|
|
3443
|
+
const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
|
|
3351
3444
|
const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
|
|
3352
|
-
return makeElement(isStaticChildren,
|
|
3445
|
+
return makeElement(isStaticChildren, effectiveType, { ...passProps2, style: finalStyle2 }, key);
|
|
3353
3446
|
}
|
|
3354
3447
|
const config = getConfig();
|
|
3355
3448
|
const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
|
|
3356
|
-
const { style: userStyle, ...passProps } = omitConsumed(
|
|
3449
|
+
const { style: userStyle, ...passProps } = omitConsumed(workingProps);
|
|
3357
3450
|
const { interactive, modeOrResponsive } = bucketMods(resolved);
|
|
3358
3451
|
if (interactive) {
|
|
3359
3452
|
return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
|
|
3360
|
-
Component:
|
|
3453
|
+
Component: effectiveType,
|
|
3361
3454
|
resolvedStyle: resolved,
|
|
3362
3455
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
3363
3456
|
style: userStyle,
|
|
@@ -3366,24 +3459,24 @@ function processElement(type, rawProps, key, isStaticChildren) {
|
|
|
3366
3459
|
}
|
|
3367
3460
|
if (modeOrResponsive) {
|
|
3368
3461
|
return (0, import_jsx_runtime.jsx)(DarkWrapper, {
|
|
3369
|
-
Component:
|
|
3462
|
+
Component: effectiveType,
|
|
3370
3463
|
resolvedStyle: resolved,
|
|
3371
3464
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
3372
3465
|
style: userStyle,
|
|
3373
3466
|
...passProps
|
|
3374
3467
|
}, key);
|
|
3375
3468
|
}
|
|
3376
|
-
const
|
|
3469
|
+
const skipComputedInline = isWeb || !isNative && typeof effectiveType === "string";
|
|
3377
3470
|
let finalStyle;
|
|
3378
|
-
if (!
|
|
3471
|
+
if (!skipComputedInline) {
|
|
3379
3472
|
const computedStyle = flatten(resolved, false);
|
|
3380
3473
|
stripInternalMarkers2(computedStyle);
|
|
3381
|
-
if (typeof
|
|
3474
|
+
if (typeof effectiveType !== "string") stripWebOnlyInlineProps(computedStyle);
|
|
3382
3475
|
finalStyle = mergeStyle(computedStyle, userStyle);
|
|
3383
3476
|
} else {
|
|
3384
3477
|
finalStyle = userStyle ?? void 0;
|
|
3385
3478
|
}
|
|
3386
|
-
return makeElement(isStaticChildren,
|
|
3479
|
+
return makeElement(isStaticChildren, effectiveType, {
|
|
3387
3480
|
...passProps,
|
|
3388
3481
|
style: finalStyle,
|
|
3389
3482
|
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {}
|
|
@@ -3400,5 +3493,6 @@ function jsxs(type, props, key) {
|
|
|
3400
3493
|
Fragment,
|
|
3401
3494
|
_invalidateDefaultFontCache,
|
|
3402
3495
|
jsx,
|
|
3403
|
-
jsxs
|
|
3496
|
+
jsxs,
|
|
3497
|
+
registerWebElement
|
|
3404
3498
|
});
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -2,13 +2,14 @@ import {
|
|
|
2
2
|
Fragment,
|
|
3
3
|
_invalidateDefaultFontCache,
|
|
4
4
|
jsx,
|
|
5
|
-
jsxs
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import "./chunk-
|
|
5
|
+
jsxs,
|
|
6
|
+
registerWebElement
|
|
7
|
+
} from "./chunk-YZNSWFJT.mjs";
|
|
8
|
+
import "./chunk-BKSXIWL7.mjs";
|
|
9
9
|
export {
|
|
10
10
|
Fragment,
|
|
11
11
|
_invalidateDefaultFontCache,
|
|
12
12
|
jsx,
|
|
13
|
-
jsxs
|
|
13
|
+
jsxs,
|
|
14
|
+
registerWebElement
|
|
14
15
|
};
|
package/dist/vite-plugin.js
CHANGED
|
@@ -642,7 +642,12 @@ function resolveColor(value, colors, isArbitrary) {
|
|
|
642
642
|
}
|
|
643
643
|
}
|
|
644
644
|
if (!hex) return null;
|
|
645
|
-
if (!opacityPart)
|
|
645
|
+
if (!opacityPart) {
|
|
646
|
+
if (!isWeb && hex.startsWith("#") && hex.length === 9) {
|
|
647
|
+
return hexToRgba(hex, Math.round(parseInt(hex.slice(7, 9), 16) / 255 * 1e3) / 1e3);
|
|
648
|
+
}
|
|
649
|
+
return hex;
|
|
650
|
+
}
|
|
646
651
|
let alpha;
|
|
647
652
|
if (opacityPart.startsWith("[") && opacityPart.endsWith("]")) {
|
|
648
653
|
const v = parseFloat(opacityPart.slice(1, -1));
|
|
@@ -2205,12 +2210,6 @@ var RESOLVERS = {
|
|
|
2205
2210
|
function resolveUtility(parsed, theme) {
|
|
2206
2211
|
if (!parsed.value) {
|
|
2207
2212
|
if (parsed.utility in PLUGIN_STANDALONE) return PLUGIN_STANDALONE[parsed.utility] ?? null;
|
|
2208
|
-
if (parsed.utility === "grd" || parsed.utility === "grid") {
|
|
2209
|
-
return getEffectiveIsWeb() ? { display: "grid" } : null;
|
|
2210
|
-
}
|
|
2211
|
-
if (parsed.utility === "inline-grid") {
|
|
2212
|
-
return getEffectiveIsWeb() ? { display: "inline-grid" } : null;
|
|
2213
|
-
}
|
|
2214
2213
|
if (parsed.utility in getStandalone()) return getStandalone()[parsed.utility] ?? null;
|
|
2215
2214
|
}
|
|
2216
2215
|
const resolver = PLUGIN_RESOLVERS[parsed.utility] ?? RESOLVERS[parsed.utility];
|
|
@@ -2763,6 +2762,8 @@ function buildConfig(userConfig) {
|
|
|
2763
2762
|
};
|
|
2764
2763
|
clearPluginUtilities();
|
|
2765
2764
|
clearPluginModifiers();
|
|
2765
|
+
const _store = getConfigStore();
|
|
2766
|
+
for (const k of Object.keys(_store.customVariants)) delete _store.customVariants[k];
|
|
2766
2767
|
const pluginAPI = makePluginAPI(resolved.theme);
|
|
2767
2768
|
for (const plugin of resolved.plugins) {
|
|
2768
2769
|
plugin(pluginAPI);
|
|
@@ -3008,13 +3009,25 @@ function extractClassStrings(code) {
|
|
|
3008
3009
|
i++;
|
|
3009
3010
|
}
|
|
3010
3011
|
jsxExprRe.lastIndex = i + 1;
|
|
3011
|
-
const innerStrings = block.match(/["'`]([^"'`]{1,
|
|
3012
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
3012
3013
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
3013
3014
|
}
|
|
3014
|
-
const
|
|
3015
|
-
while ((m =
|
|
3016
|
-
|
|
3017
|
-
|
|
3015
|
+
const clsxCallRe = /(?:clsx|cn|classnames|cx)\(/g;
|
|
3016
|
+
while ((m = clsxCallRe.exec(code)) !== null) {
|
|
3017
|
+
let depth = 1;
|
|
3018
|
+
let i = m.index + m[0].length;
|
|
3019
|
+
let block = "";
|
|
3020
|
+
while (i < code.length && depth > 0) {
|
|
3021
|
+
const ch = code[i];
|
|
3022
|
+
if (ch === "(") depth++;
|
|
3023
|
+
else if (ch === ")") {
|
|
3024
|
+
if (--depth === 0) break;
|
|
3025
|
+
}
|
|
3026
|
+
block += ch;
|
|
3027
|
+
i++;
|
|
3028
|
+
}
|
|
3029
|
+
clsxCallRe.lastIndex = i + 1;
|
|
3030
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
3018
3031
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
3019
3032
|
}
|
|
3020
3033
|
const templateRe = /`([^`]{1,2000})`/g;
|
|
@@ -3064,12 +3077,10 @@ function kbach(userConfig) {
|
|
|
3064
3077
|
function processFile(filePath, code) {
|
|
3065
3078
|
const key = normPath(filePath);
|
|
3066
3079
|
const tokens = /* @__PURE__ */ new Set();
|
|
3067
|
-
for (const
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
3072
|
-
}
|
|
3080
|
+
for (const tok of extractClassStrings(code)) {
|
|
3081
|
+
tokens.add(tok);
|
|
3082
|
+
if (!tokenCSS.has(tok)) {
|
|
3083
|
+
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
3073
3084
|
}
|
|
3074
3085
|
}
|
|
3075
3086
|
fileTokens.set(key, tokens);
|
package/dist/vite-plugin.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
generateClassCSS,
|
|
5
5
|
setCSSGenMode,
|
|
6
6
|
splitClassTokens
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-BKSXIWL7.mjs";
|
|
8
8
|
|
|
9
9
|
// src/vite-plugin.ts
|
|
10
10
|
import { readFileSync, writeFileSync, readdirSync, statSync } from "fs";
|
|
@@ -186,13 +186,25 @@ function extractClassStrings(code) {
|
|
|
186
186
|
i++;
|
|
187
187
|
}
|
|
188
188
|
jsxExprRe.lastIndex = i + 1;
|
|
189
|
-
const innerStrings = block.match(/["'`]([^"'`]{1,
|
|
189
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
190
190
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
191
191
|
}
|
|
192
|
-
const
|
|
193
|
-
while ((m =
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
const clsxCallRe = /(?:clsx|cn|classnames|cx)\(/g;
|
|
193
|
+
while ((m = clsxCallRe.exec(code)) !== null) {
|
|
194
|
+
let depth = 1;
|
|
195
|
+
let i = m.index + m[0].length;
|
|
196
|
+
let block = "";
|
|
197
|
+
while (i < code.length && depth > 0) {
|
|
198
|
+
const ch = code[i];
|
|
199
|
+
if (ch === "(") depth++;
|
|
200
|
+
else if (ch === ")") {
|
|
201
|
+
if (--depth === 0) break;
|
|
202
|
+
}
|
|
203
|
+
block += ch;
|
|
204
|
+
i++;
|
|
205
|
+
}
|
|
206
|
+
clsxCallRe.lastIndex = i + 1;
|
|
207
|
+
const innerStrings = block.match(/["'`]([^"'`]{1,2000})["'`]/g) ?? [];
|
|
196
208
|
for (const s of innerStrings) pushTokens(s.slice(1, -1), found);
|
|
197
209
|
}
|
|
198
210
|
const templateRe = /`([^`]{1,2000})`/g;
|
|
@@ -242,12 +254,10 @@ function kbach(userConfig) {
|
|
|
242
254
|
function processFile(filePath, code) {
|
|
243
255
|
const key = normPath(filePath);
|
|
244
256
|
const tokens = /* @__PURE__ */ new Set();
|
|
245
|
-
for (const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
250
|
-
}
|
|
257
|
+
for (const tok of extractClassStrings(code)) {
|
|
258
|
+
tokens.add(tok);
|
|
259
|
+
if (!tokenCSS.has(tok)) {
|
|
260
|
+
tokenCSS.set(tok, generateClassCSS(tok, cfg.theme, cfg.darkMode, screens));
|
|
251
261
|
}
|
|
252
262
|
}
|
|
253
263
|
fileTokens.set(key, tokens);
|
package/package.json
CHANGED
package/dist/chunk-LCK5OGHT.mjs
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
EMPTY_BREAKPOINTS2 as EMPTY_BREAKPOINTS,
|
|
3
|
-
InteractiveWrapper,
|
|
4
|
-
hasResponsiveBuckets,
|
|
5
|
-
useConditionalWidth,
|
|
6
|
-
useGlobalDarkMode
|
|
7
|
-
} from "./chunk-U3GY5Y6J.mjs";
|
|
8
|
-
import {
|
|
9
|
-
flatten,
|
|
10
|
-
getActiveBreakpoints,
|
|
11
|
-
getConfig,
|
|
12
|
-
getDefaultFontFamily,
|
|
13
|
-
getInteractiveModifiers,
|
|
14
|
-
getModeModifiers,
|
|
15
|
-
getResponsiveModifiers,
|
|
16
|
-
isNative,
|
|
17
|
-
isRuntimeCSSDisabled,
|
|
18
|
-
normalizeClassString,
|
|
19
|
-
resolve
|
|
20
|
-
} from "./chunk-NIBECTRQ.mjs";
|
|
21
|
-
|
|
22
|
-
// src/jsx-runtime.tsx
|
|
23
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
-
import { Fragment } from "react";
|
|
25
|
-
|
|
26
|
-
// src/DarkWrapper.tsx
|
|
27
|
-
import React from "react";
|
|
28
|
-
var DarkWrapper = React.forwardRef(
|
|
29
|
-
function DarkWrapper2({ Component, resolvedStyle, style: styleProp, children, ...rest }, ref) {
|
|
30
|
-
const isDark = useGlobalDarkMode();
|
|
31
|
-
const needsWidth = hasResponsiveBuckets(resolvedStyle);
|
|
32
|
-
const width = useConditionalWidth(needsWidth);
|
|
33
|
-
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
|
|
34
|
-
const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
|
|
35
|
-
stripInternalMarkers(computedStyle);
|
|
36
|
-
if (typeof Component !== "string") stripWebOnlyProps(computedStyle);
|
|
37
|
-
const isWebHTMLElement = !isNative && typeof Component === "string";
|
|
38
|
-
const finalStyle = isWebHTMLElement ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
39
|
-
const props = { ref, ...rest, style: finalStyle };
|
|
40
|
-
return Array.isArray(children) ? React.createElement(Component, props, ...children) : React.createElement(Component, props, children);
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
DarkWrapper.displayName = "Kbach.DarkWrapper";
|
|
44
|
-
function stripInternalMarkers(s) {
|
|
45
|
-
delete s.__divideX;
|
|
46
|
-
delete s.__divideY;
|
|
47
|
-
delete s.__divideColor;
|
|
48
|
-
delete s.__divideStyle;
|
|
49
|
-
delete s.__keyframe;
|
|
50
|
-
}
|
|
51
|
-
function stripWebOnlyProps(s) {
|
|
52
|
-
if (s.display === "grid" || s.display === "inline-grid") delete s.display;
|
|
53
|
-
delete s.gridTemplateColumns;
|
|
54
|
-
delete s.gridTemplateRows;
|
|
55
|
-
delete s.gridColumn;
|
|
56
|
-
delete s.gridRow;
|
|
57
|
-
delete s.gridArea;
|
|
58
|
-
delete s.gridColumnStart;
|
|
59
|
-
delete s.gridColumnEnd;
|
|
60
|
-
delete s.gridRowStart;
|
|
61
|
-
delete s.gridRowEnd;
|
|
62
|
-
delete s.gridAutoFlow;
|
|
63
|
-
delete s.gridAutoColumns;
|
|
64
|
-
delete s.gridAutoRows;
|
|
65
|
-
delete s.placeItems;
|
|
66
|
-
delete s.placeContent;
|
|
67
|
-
delete s.justifyItems;
|
|
68
|
-
delete s.placeSelf;
|
|
69
|
-
delete s.justifySelf;
|
|
70
|
-
if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
|
|
71
|
-
delete s.position;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// src/jsx-runtime.tsx
|
|
76
|
-
var _cachedDefaultFont = void 0;
|
|
77
|
-
var _defaultFontVersion = 0;
|
|
78
|
-
var _lastFontVersion = -1;
|
|
79
|
-
function _invalidateDefaultFontCache() {
|
|
80
|
-
_defaultFontVersion++;
|
|
81
|
-
}
|
|
82
|
-
function getCachedDefaultFont() {
|
|
83
|
-
if (_lastFontVersion !== _defaultFontVersion) {
|
|
84
|
-
_cachedDefaultFont = getDefaultFontFamily();
|
|
85
|
-
_lastFontVersion = _defaultFontVersion;
|
|
86
|
-
}
|
|
87
|
-
return _cachedDefaultFont;
|
|
88
|
-
}
|
|
89
|
-
var _bucketModsCache = /* @__PURE__ */ new WeakMap();
|
|
90
|
-
function bucketMods(resolved) {
|
|
91
|
-
const cached = _bucketModsCache.get(resolved);
|
|
92
|
-
if (cached) return cached;
|
|
93
|
-
const interactiveMods = getInteractiveModifiers();
|
|
94
|
-
const modeMods = getModeModifiers();
|
|
95
|
-
const responsiveMods = getResponsiveModifiers();
|
|
96
|
-
let interactive = false;
|
|
97
|
-
let modeOrResponsive = false;
|
|
98
|
-
for (const key of Object.keys(resolved)) {
|
|
99
|
-
if (key === "base") continue;
|
|
100
|
-
for (const mod of key.split(":")) {
|
|
101
|
-
if (!interactive && interactiveMods.has(mod)) interactive = true;
|
|
102
|
-
if (!modeOrResponsive && (modeMods.has(mod) || responsiveMods.has(mod))) modeOrResponsive = true;
|
|
103
|
-
}
|
|
104
|
-
if (interactive && modeOrResponsive) break;
|
|
105
|
-
}
|
|
106
|
-
const result = { interactive, modeOrResponsive };
|
|
107
|
-
_bucketModsCache.set(resolved, result);
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
var CONSUMED_PROPS = /* @__PURE__ */ new Set(["className", "kb", "__kbachStyles", "__kbachClasses"]);
|
|
111
|
-
function omitConsumed(props) {
|
|
112
|
-
const out = {};
|
|
113
|
-
for (const key of Object.keys(props)) {
|
|
114
|
-
if (!CONSUMED_PROPS.has(key)) out[key] = props[key];
|
|
115
|
-
}
|
|
116
|
-
return out;
|
|
117
|
-
}
|
|
118
|
-
function mergeStyle(computed, userStyle) {
|
|
119
|
-
if (!userStyle) return computed;
|
|
120
|
-
if (Array.isArray(userStyle)) return Object.assign({}, computed, ...userStyle);
|
|
121
|
-
return { ...computed, ...userStyle };
|
|
122
|
-
}
|
|
123
|
-
function makeElement(isStaticChildren, type, props, key) {
|
|
124
|
-
return (isStaticChildren ? _jsxs : _jsx)(type, props, key);
|
|
125
|
-
}
|
|
126
|
-
function stripInternalMarkers2(s) {
|
|
127
|
-
delete s.__divideX;
|
|
128
|
-
delete s.__divideY;
|
|
129
|
-
delete s.__divideColor;
|
|
130
|
-
delete s.__divideStyle;
|
|
131
|
-
delete s.__keyframe;
|
|
132
|
-
}
|
|
133
|
-
function stripWebOnlyInlineProps(s) {
|
|
134
|
-
if (s.display === "grid" || s.display === "inline-grid") delete s.display;
|
|
135
|
-
delete s.gridTemplateColumns;
|
|
136
|
-
delete s.gridTemplateRows;
|
|
137
|
-
delete s.gridColumn;
|
|
138
|
-
delete s.gridRow;
|
|
139
|
-
delete s.gridArea;
|
|
140
|
-
delete s.gridColumnStart;
|
|
141
|
-
delete s.gridColumnEnd;
|
|
142
|
-
delete s.gridRowStart;
|
|
143
|
-
delete s.gridRowEnd;
|
|
144
|
-
delete s.gridAutoFlow;
|
|
145
|
-
delete s.gridAutoColumns;
|
|
146
|
-
delete s.gridAutoRows;
|
|
147
|
-
delete s.placeItems;
|
|
148
|
-
delete s.placeContent;
|
|
149
|
-
delete s.justifyItems;
|
|
150
|
-
delete s.placeSelf;
|
|
151
|
-
delete s.justifySelf;
|
|
152
|
-
if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
|
|
153
|
-
delete s.position;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
function processElement(type, rawProps, key, isStaticChildren) {
|
|
157
|
-
if (typeof type === "symbol") return makeElement(isStaticChildren, type, rawProps ?? {}, key);
|
|
158
|
-
if (!rawProps) return _jsx(type, null, key);
|
|
159
|
-
const { className, kb: kbProp, __kbachStyles, __kbachClasses } = rawProps;
|
|
160
|
-
const classStr = className ?? kbProp ?? __kbachClasses;
|
|
161
|
-
if (!isNative && isRuntimeCSSDisabled() && classStr && !__kbachStyles) {
|
|
162
|
-
const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
|
|
163
|
-
return makeElement(isStaticChildren, type, {
|
|
164
|
-
...passProps2,
|
|
165
|
-
className: normalizeClassString(classStr),
|
|
166
|
-
...userStyle2 !== void 0 ? { style: userStyle2 } : {}
|
|
167
|
-
}, key);
|
|
168
|
-
}
|
|
169
|
-
if (!classStr && !__kbachStyles) {
|
|
170
|
-
const defaultFont = getCachedDefaultFont();
|
|
171
|
-
if (!defaultFont) return makeElement(isStaticChildren, type, rawProps, key);
|
|
172
|
-
const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
|
|
173
|
-
const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
|
|
174
|
-
return makeElement(isStaticChildren, type, { ...passProps2, style: finalStyle2 }, key);
|
|
175
|
-
}
|
|
176
|
-
const config = getConfig();
|
|
177
|
-
const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
|
|
178
|
-
const { style: userStyle, ...passProps } = omitConsumed(rawProps);
|
|
179
|
-
const { interactive, modeOrResponsive } = bucketMods(resolved);
|
|
180
|
-
if (interactive) {
|
|
181
|
-
return _jsx(InteractiveWrapper, {
|
|
182
|
-
Component: type,
|
|
183
|
-
resolvedStyle: resolved,
|
|
184
|
-
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
185
|
-
style: userStyle,
|
|
186
|
-
...passProps
|
|
187
|
-
}, key);
|
|
188
|
-
}
|
|
189
|
-
if (modeOrResponsive) {
|
|
190
|
-
return _jsx(DarkWrapper, {
|
|
191
|
-
Component: type,
|
|
192
|
-
resolvedStyle: resolved,
|
|
193
|
-
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {},
|
|
194
|
-
style: userStyle,
|
|
195
|
-
...passProps
|
|
196
|
-
}, key);
|
|
197
|
-
}
|
|
198
|
-
const isWebHTMLElement = !isNative && typeof type === "string";
|
|
199
|
-
let finalStyle;
|
|
200
|
-
if (!isWebHTMLElement) {
|
|
201
|
-
const computedStyle = flatten(resolved, false);
|
|
202
|
-
stripInternalMarkers2(computedStyle);
|
|
203
|
-
if (typeof type !== "string") stripWebOnlyInlineProps(computedStyle);
|
|
204
|
-
finalStyle = mergeStyle(computedStyle, userStyle);
|
|
205
|
-
} else {
|
|
206
|
-
finalStyle = userStyle ?? void 0;
|
|
207
|
-
}
|
|
208
|
-
return makeElement(isStaticChildren, type, {
|
|
209
|
-
...passProps,
|
|
210
|
-
style: finalStyle,
|
|
211
|
-
...!isNative && classStr ? { className: normalizeClassString(classStr) } : {}
|
|
212
|
-
}, key);
|
|
213
|
-
}
|
|
214
|
-
function jsx(type, props, key) {
|
|
215
|
-
return processElement(type, props, key, false);
|
|
216
|
-
}
|
|
217
|
-
function jsxs(type, props, key) {
|
|
218
|
-
return processElement(type, props, key, true);
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export {
|
|
222
|
-
Fragment,
|
|
223
|
-
_invalidateDefaultFontCache,
|
|
224
|
-
jsx,
|
|
225
|
-
jsxs
|
|
226
|
-
};
|