@kbach/react 0.6.1 → 0.6.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/dist/{chunk-MPHPB357.mjs → chunk-GRZ6MVIL.mjs} +518 -19
- package/dist/{chunk-6ZORO3BP.mjs → chunk-NWW57Q5Q.mjs} +10 -11
- package/dist/index.d.mts +131 -3
- package/dist/index.d.ts +131 -3
- package/dist/index.js +1 -0
- package/dist/index.mjs +15 -16
- package/dist/jsx-dev-runtime.js +1 -0
- package/dist/jsx-dev-runtime.mjs +3 -3
- package/dist/jsx-runtime.js +1 -0
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/vite-plugin.d.mts +102 -1
- package/dist/vite-plugin.d.ts +102 -1
- package/dist/vite-plugin.mjs +2881 -11
- package/jsx-dev-runtime.js +1 -0
- package/jsx-runtime.js +1 -0
- package/kbach-react.md +1 -8
- package/package.json +3 -3
- package/dist/chunk-36QRQNPL.mjs +0 -528
- package/dist/types-BESBQANS.d.mts +0 -131
- package/dist/types-BESBQANS.d.ts +0 -131
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
1
3
|
// src/core/theme.ts
|
|
2
4
|
var defaultColors = {
|
|
3
5
|
transparent: "transparent",
|
|
@@ -545,9 +547,6 @@ var _resolveTargetOverride = null;
|
|
|
545
547
|
function setResolveTarget(target) {
|
|
546
548
|
_resolveTargetOverride = target;
|
|
547
549
|
}
|
|
548
|
-
function setCSSGenMode(on) {
|
|
549
|
-
_resolveTargetOverride = on ? "web" : null;
|
|
550
|
-
}
|
|
551
550
|
function getEffectiveIsWeb() {
|
|
552
551
|
if (_resolveTargetOverride) return _resolveTargetOverride === "web";
|
|
553
552
|
return isWeb || !isNative;
|
|
@@ -2815,16 +2814,6 @@ function injectClassRule(cls, bucketKey, styles, darkMode, important) {
|
|
|
2815
2814
|
const cssRules = buildClassCSSRules(cls, bucketKey, styles, darkMode, important, getGlobalScreens());
|
|
2816
2815
|
for (const r of cssRules) injectRule(r);
|
|
2817
2816
|
}
|
|
2818
|
-
function generateClassCSS(classString, theme, darkMode = "attribute", screens = {}) {
|
|
2819
|
-
const rules = [];
|
|
2820
|
-
for (const parsed of parseClasses(classString)) {
|
|
2821
|
-
const styles = resolveUtility(parsed, theme);
|
|
2822
|
-
if (!styles) continue;
|
|
2823
|
-
const bucketKey = parsed.modifiers.length === 0 ? "base" : parsed.modifiers.join(":");
|
|
2824
|
-
rules.push(...buildClassCSSRules(parsed.original, bucketKey, styles, darkMode, parsed.important, screens));
|
|
2825
|
-
}
|
|
2826
|
-
return rules.join("\n");
|
|
2827
|
-
}
|
|
2828
2817
|
function resolve(classString, theme, darkMode = "attribute") {
|
|
2829
2818
|
const cache = getThemeCache(theme);
|
|
2830
2819
|
const cacheKey = `${classString}::${darkMode}`;
|
|
@@ -3101,13 +3090,511 @@ var customVariants = new Proxy(
|
|
|
3101
3090
|
}
|
|
3102
3091
|
);
|
|
3103
3092
|
|
|
3093
|
+
// src/core/darkModeStore.ts
|
|
3094
|
+
var KEY = "__kbach_dark_store__";
|
|
3095
|
+
function getStore2() {
|
|
3096
|
+
const g = globalThis;
|
|
3097
|
+
if (!g[KEY]) {
|
|
3098
|
+
g[KEY] = { isDark: false, subscribers: /* @__PURE__ */ new Set() };
|
|
3099
|
+
}
|
|
3100
|
+
return g[KEY];
|
|
3101
|
+
}
|
|
3102
|
+
function syncGlobalDarkMode(isDark) {
|
|
3103
|
+
getStore2().isDark = isDark;
|
|
3104
|
+
}
|
|
3105
|
+
function setGlobalDarkMode(isDark) {
|
|
3106
|
+
const store = getStore2();
|
|
3107
|
+
if (store.isDark === isDark) return;
|
|
3108
|
+
store.isDark = isDark;
|
|
3109
|
+
for (const sub of store.subscribers) sub();
|
|
3110
|
+
}
|
|
3111
|
+
function getGlobalDarkMode() {
|
|
3112
|
+
return getStore2().isDark;
|
|
3113
|
+
}
|
|
3114
|
+
function subscribeGlobalDarkMode(callback) {
|
|
3115
|
+
const store = getStore2();
|
|
3116
|
+
store.subscribers.add(callback);
|
|
3117
|
+
return () => store.subscribers.delete(callback);
|
|
3118
|
+
}
|
|
3119
|
+
|
|
3120
|
+
// src/useSyncExternalStoreShim.ts
|
|
3121
|
+
import React from "react";
|
|
3122
|
+
var useSyncExternalStore = React.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
3123
|
+
const [, forceUpdate] = React.useReducer((n) => n + 1, 0);
|
|
3124
|
+
React.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
3125
|
+
return getSnapshot();
|
|
3126
|
+
};
|
|
3127
|
+
|
|
3128
|
+
// src/useGlobalDarkMode.ts
|
|
3129
|
+
function useGlobalDarkMode() {
|
|
3130
|
+
return useSyncExternalStore(
|
|
3131
|
+
subscribeGlobalDarkMode,
|
|
3132
|
+
getGlobalDarkMode,
|
|
3133
|
+
() => false
|
|
3134
|
+
// SSR: default light
|
|
3135
|
+
);
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
// src/shared-utils.ts
|
|
3139
|
+
function hasResponsiveBuckets(resolved) {
|
|
3140
|
+
const responsiveMods = getResponsiveModifiers();
|
|
3141
|
+
for (const key of Object.keys(resolved)) {
|
|
3142
|
+
if (key === "base") continue;
|
|
3143
|
+
for (const mod of key.split(":")) {
|
|
3144
|
+
if (responsiveMods.has(mod)) return true;
|
|
3145
|
+
}
|
|
3146
|
+
}
|
|
3147
|
+
return false;
|
|
3148
|
+
}
|
|
3149
|
+
function hasInteractiveBuckets(resolved) {
|
|
3150
|
+
const interactiveMods = getInteractiveModifiers();
|
|
3151
|
+
for (const key of Object.keys(resolved)) {
|
|
3152
|
+
if (key === "base") continue;
|
|
3153
|
+
for (const mod of key.split(":")) {
|
|
3154
|
+
if (interactiveMods.has(mod)) return true;
|
|
3155
|
+
}
|
|
3156
|
+
}
|
|
3157
|
+
return false;
|
|
3158
|
+
}
|
|
3159
|
+
function chain(original, extra) {
|
|
3160
|
+
return (...args) => {
|
|
3161
|
+
original?.(...args);
|
|
3162
|
+
extra();
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
function stripInternalMarkers(s) {
|
|
3166
|
+
delete s.__divideX;
|
|
3167
|
+
delete s.__divideY;
|
|
3168
|
+
delete s.__divideColor;
|
|
3169
|
+
delete s.__divideStyle;
|
|
3170
|
+
delete s.__keyframe;
|
|
3171
|
+
}
|
|
3172
|
+
function stripWebOnlyProps(s) {
|
|
3173
|
+
if (s.display === "grid" || s.display === "inline-grid") delete s.display;
|
|
3174
|
+
delete s.gridTemplateColumns;
|
|
3175
|
+
delete s.gridTemplateRows;
|
|
3176
|
+
delete s.gridColumn;
|
|
3177
|
+
delete s.gridRow;
|
|
3178
|
+
delete s.gridArea;
|
|
3179
|
+
delete s.gridColumnStart;
|
|
3180
|
+
delete s.gridColumnEnd;
|
|
3181
|
+
delete s.gridRowStart;
|
|
3182
|
+
delete s.gridRowEnd;
|
|
3183
|
+
delete s.gridAutoFlow;
|
|
3184
|
+
delete s.gridAutoColumns;
|
|
3185
|
+
delete s.gridAutoRows;
|
|
3186
|
+
delete s.placeItems;
|
|
3187
|
+
delete s.placeContent;
|
|
3188
|
+
delete s.justifyItems;
|
|
3189
|
+
delete s.placeSelf;
|
|
3190
|
+
delete s.justifySelf;
|
|
3191
|
+
if (s.position === "sticky" || s.position === "fixed" || s.position === "static") {
|
|
3192
|
+
delete s.position;
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
|
|
3196
|
+
// src/web-substitute.ts
|
|
3197
|
+
var _rnToHtml = {
|
|
3198
|
+
View: "div",
|
|
3199
|
+
SafeAreaView: "div",
|
|
3200
|
+
KeyboardAvoidingView: "div",
|
|
3201
|
+
ScrollView: "div",
|
|
3202
|
+
VirtualizedList: "div",
|
|
3203
|
+
FlatList: "div",
|
|
3204
|
+
SectionList: "div",
|
|
3205
|
+
Text: "span",
|
|
3206
|
+
TextInput: "input",
|
|
3207
|
+
Image: "img",
|
|
3208
|
+
ImageBackground: "div",
|
|
3209
|
+
Pressable: "div",
|
|
3210
|
+
TouchableOpacity: "div",
|
|
3211
|
+
TouchableHighlight: "div",
|
|
3212
|
+
TouchableWithoutFeedback: "div",
|
|
3213
|
+
TouchableNativeFeedback: "div"
|
|
3214
|
+
};
|
|
3215
|
+
var _userMap = /* @__PURE__ */ new Map();
|
|
3216
|
+
var _cache = /* @__PURE__ */ new WeakMap();
|
|
3217
|
+
function registerWebElement(rnComponent, htmlTag) {
|
|
3218
|
+
if (typeof rnComponent !== "object" && typeof rnComponent !== "function") return;
|
|
3219
|
+
_userMap.set(rnComponent, htmlTag);
|
|
3220
|
+
_cache.delete(rnComponent);
|
|
3221
|
+
}
|
|
3222
|
+
function getWebTag(type, props) {
|
|
3223
|
+
if (typeof type === "string") return null;
|
|
3224
|
+
if (type === null || typeof type !== "function" && typeof type !== "object") return null;
|
|
3225
|
+
const obj = type;
|
|
3226
|
+
if (_userMap.has(obj)) return _userMap.get(obj);
|
|
3227
|
+
const name = obj.displayName ?? obj.name;
|
|
3228
|
+
if (!name) {
|
|
3229
|
+
_cache.set(obj, null);
|
|
3230
|
+
return null;
|
|
3231
|
+
}
|
|
3232
|
+
if (name === "TextInput") {
|
|
3233
|
+
const multiline = !!props && (props.multiline === true || Number(props.numberOfLines) > 1);
|
|
3234
|
+
return multiline ? "textarea" : "input";
|
|
3235
|
+
}
|
|
3236
|
+
if (_cache.has(obj)) return _cache.get(obj);
|
|
3237
|
+
const tag = _rnToHtml[name] ?? null;
|
|
3238
|
+
_cache.set(obj, tag);
|
|
3239
|
+
return tag;
|
|
3240
|
+
}
|
|
3241
|
+
var _rnOnlyProps = /* @__PURE__ */ new Set([
|
|
3242
|
+
// Interaction
|
|
3243
|
+
"onLongPress",
|
|
3244
|
+
"delayLongPress",
|
|
3245
|
+
"activeOpacity",
|
|
3246
|
+
"underlayColor",
|
|
3247
|
+
"hitSlop",
|
|
3248
|
+
"pressRetentionOffset",
|
|
3249
|
+
"android_ripple",
|
|
3250
|
+
"android_disableSound",
|
|
3251
|
+
"onHoverIn",
|
|
3252
|
+
"onHoverOut",
|
|
3253
|
+
"onHoverStart",
|
|
3254
|
+
"onHoverEnd",
|
|
3255
|
+
// Layout event
|
|
3256
|
+
"onLayout",
|
|
3257
|
+
// Accessibility
|
|
3258
|
+
"accessible",
|
|
3259
|
+
"accessibilityState",
|
|
3260
|
+
"accessibilityLiveRegion",
|
|
3261
|
+
"importantForAccessibility",
|
|
3262
|
+
// Platform
|
|
3263
|
+
"nativeID",
|
|
3264
|
+
"collapsable",
|
|
3265
|
+
"needsOffscreenAlphaCompositing",
|
|
3266
|
+
"renderToHardwareTextureAndroid",
|
|
3267
|
+
"shouldRasterizeIOS",
|
|
3268
|
+
"focusable",
|
|
3269
|
+
"hasTVPreferredFocus",
|
|
3270
|
+
// 'pointerEvents' is handled in transformToWebProps (mapped to CSS style)
|
|
3271
|
+
// Text
|
|
3272
|
+
"selectable",
|
|
3273
|
+
"allowFontScaling",
|
|
3274
|
+
"adjustsFontSizeToFit",
|
|
3275
|
+
"minimumFontScale",
|
|
3276
|
+
"ellipsizeMode",
|
|
3277
|
+
"numberOfLines",
|
|
3278
|
+
"onTextLayout",
|
|
3279
|
+
"textBreakStrategy",
|
|
3280
|
+
"lineBreakStrategyIOS",
|
|
3281
|
+
// TextInput
|
|
3282
|
+
"multiline",
|
|
3283
|
+
"resizeMode",
|
|
3284
|
+
// handled separately
|
|
3285
|
+
"blurOnSubmit",
|
|
3286
|
+
"clearButtonMode",
|
|
3287
|
+
"clearTextOnFocus",
|
|
3288
|
+
"enablesReturnKeyAutomatically",
|
|
3289
|
+
"returnKeyType",
|
|
3290
|
+
"spellCheck",
|
|
3291
|
+
// ScrollView
|
|
3292
|
+
"scrollEnabled",
|
|
3293
|
+
"showsVerticalScrollIndicator",
|
|
3294
|
+
"showsHorizontalScrollIndicator",
|
|
3295
|
+
"contentContainerStyle",
|
|
3296
|
+
// 'horizontal' is handled in transformToWebProps (converted to CSS overflow-x).
|
|
3297
|
+
"keyboardShouldPersistTaps",
|
|
3298
|
+
"keyboardDismissMode",
|
|
3299
|
+
"pagingEnabled",
|
|
3300
|
+
"scrollEventThrottle",
|
|
3301
|
+
"decelerationRate",
|
|
3302
|
+
"bounces",
|
|
3303
|
+
"alwaysBounceHorizontal",
|
|
3304
|
+
"alwaysBounceVertical",
|
|
3305
|
+
"snapToAlignment",
|
|
3306
|
+
"snapToInterval",
|
|
3307
|
+
"snapToOffsets",
|
|
3308
|
+
"removeClippedSubviews",
|
|
3309
|
+
"overScrollMode",
|
|
3310
|
+
"stickyHeaderIndices",
|
|
3311
|
+
"invertStickyHeaders",
|
|
3312
|
+
"onScrollBeginDrag",
|
|
3313
|
+
"onScrollEndDrag",
|
|
3314
|
+
"onMomentumScrollBegin",
|
|
3315
|
+
"onMomentumScrollEnd",
|
|
3316
|
+
"contentInset",
|
|
3317
|
+
"contentInsetAdjustmentBehavior",
|
|
3318
|
+
"automaticallyAdjustContentInsets",
|
|
3319
|
+
"automaticallyAdjustsScrollIndicatorInsets",
|
|
3320
|
+
// expo-image
|
|
3321
|
+
"contentPosition",
|
|
3322
|
+
"cachePolicy",
|
|
3323
|
+
"recyclingKey",
|
|
3324
|
+
"blurRadius",
|
|
3325
|
+
"fadeDuration",
|
|
3326
|
+
"responsivePolicy",
|
|
3327
|
+
"tintColor",
|
|
3328
|
+
"allowDownscaling",
|
|
3329
|
+
"placeholderContentFit",
|
|
3330
|
+
// FlatList / SectionList
|
|
3331
|
+
"data",
|
|
3332
|
+
"renderItem",
|
|
3333
|
+
"keyExtractor",
|
|
3334
|
+
"getItemLayout",
|
|
3335
|
+
"initialScrollIndex",
|
|
3336
|
+
"initialNumToRender",
|
|
3337
|
+
"maxToRenderPerBatch",
|
|
3338
|
+
"windowSize",
|
|
3339
|
+
"updateCellsBatchingPeriod",
|
|
3340
|
+
"onEndReached",
|
|
3341
|
+
"onEndReachedThreshold",
|
|
3342
|
+
"ListHeaderComponent",
|
|
3343
|
+
"ListFooterComponent",
|
|
3344
|
+
"ListEmptyComponent",
|
|
3345
|
+
"ListHeaderComponentStyle",
|
|
3346
|
+
"ListFooterComponentStyle",
|
|
3347
|
+
"ItemSeparatorComponent",
|
|
3348
|
+
"SectionSeparatorComponent",
|
|
3349
|
+
"inverted",
|
|
3350
|
+
"getItem",
|
|
3351
|
+
"getItemCount"
|
|
3352
|
+
]);
|
|
3353
|
+
var _pressableNames = /* @__PURE__ */ new Set([
|
|
3354
|
+
"Pressable",
|
|
3355
|
+
"TouchableOpacity",
|
|
3356
|
+
"TouchableHighlight",
|
|
3357
|
+
"TouchableWithoutFeedback",
|
|
3358
|
+
"TouchableNativeFeedback"
|
|
3359
|
+
]);
|
|
3360
|
+
var _keyboardTypeMap = {
|
|
3361
|
+
"numeric": "number",
|
|
3362
|
+
"number-pad": "number",
|
|
3363
|
+
"decimal-pad": "decimal",
|
|
3364
|
+
"email-address": "email",
|
|
3365
|
+
"phone-pad": "tel",
|
|
3366
|
+
"url": "url"
|
|
3367
|
+
};
|
|
3368
|
+
var _resizeModeMap = {
|
|
3369
|
+
"contain": "contain",
|
|
3370
|
+
"cover": "cover",
|
|
3371
|
+
"stretch": "fill",
|
|
3372
|
+
"center": "none",
|
|
3373
|
+
"repeat": "none"
|
|
3374
|
+
};
|
|
3375
|
+
function transformToWebProps(originalName, tag, props) {
|
|
3376
|
+
const out = {};
|
|
3377
|
+
const isPressable = _pressableNames.has(originalName);
|
|
3378
|
+
const isTextInput = originalName === "TextInput";
|
|
3379
|
+
const isImage = originalName === "Image" || originalName === "ImageBackground";
|
|
3380
|
+
const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
|
|
3381
|
+
let pendingStyle = null;
|
|
3382
|
+
for (const [k, v] of Object.entries(props)) {
|
|
3383
|
+
if (_rnOnlyProps.has(k)) continue;
|
|
3384
|
+
if (k === "onPress") {
|
|
3385
|
+
if (!("onClick" in props)) out.onClick = v;
|
|
3386
|
+
continue;
|
|
3387
|
+
}
|
|
3388
|
+
if (k === "accessibilityLabel") {
|
|
3389
|
+
if (out["aria-label"] == null) out["aria-label"] = v;
|
|
3390
|
+
continue;
|
|
3391
|
+
}
|
|
3392
|
+
if (k === "accessibilityRole") {
|
|
3393
|
+
if (out.role == null) out.role = v;
|
|
3394
|
+
continue;
|
|
3395
|
+
}
|
|
3396
|
+
if (k === "testID") {
|
|
3397
|
+
if (out["data-testid"] == null) out["data-testid"] = v;
|
|
3398
|
+
continue;
|
|
3399
|
+
}
|
|
3400
|
+
if (isTextInput) {
|
|
3401
|
+
if (k === "onChangeText") {
|
|
3402
|
+
if (!("onChange" in props)) out.onChange = (e) => v(e.target.value);
|
|
3403
|
+
continue;
|
|
3404
|
+
}
|
|
3405
|
+
if (k === "secureTextEntry") {
|
|
3406
|
+
if (v && !("type" in props)) out.type = "password";
|
|
3407
|
+
continue;
|
|
3408
|
+
}
|
|
3409
|
+
if (k === "keyboardType") {
|
|
3410
|
+
if (!("type" in props) && !("secureTextEntry" in props)) {
|
|
3411
|
+
const mapped = _keyboardTypeMap[v];
|
|
3412
|
+
if (mapped) out.type = mapped;
|
|
3413
|
+
}
|
|
3414
|
+
continue;
|
|
3415
|
+
}
|
|
3416
|
+
if (k === "editable") {
|
|
3417
|
+
if (v === false) out.readOnly = true;
|
|
3418
|
+
continue;
|
|
3419
|
+
}
|
|
3420
|
+
if (k === "maxLength") {
|
|
3421
|
+
out.maxLength = v;
|
|
3422
|
+
continue;
|
|
3423
|
+
}
|
|
3424
|
+
}
|
|
3425
|
+
if (isScrollable && k === "horizontal") {
|
|
3426
|
+
if (v) pendingStyle = { display: "flex", flexDirection: "row", overflowX: "auto" };
|
|
3427
|
+
continue;
|
|
3428
|
+
}
|
|
3429
|
+
if (k === "pointerEvents") {
|
|
3430
|
+
if (v === "none" || v === "auto") pendingStyle = { ...pendingStyle ?? {}, pointerEvents: v };
|
|
3431
|
+
continue;
|
|
3432
|
+
}
|
|
3433
|
+
if (isImage) {
|
|
3434
|
+
if (k === "source") {
|
|
3435
|
+
if (typeof v === "string") {
|
|
3436
|
+
out.src = v;
|
|
3437
|
+
} else if (v && typeof v === "object" && "uri" in v) {
|
|
3438
|
+
out.src = v.uri;
|
|
3439
|
+
if (v.headers) out["crossOrigin"] = "anonymous";
|
|
3440
|
+
}
|
|
3441
|
+
continue;
|
|
3442
|
+
}
|
|
3443
|
+
if (k === "resizeMode") {
|
|
3444
|
+
pendingStyle = { ...pendingStyle ?? {}, objectFit: _resizeModeMap[v] ?? "cover" };
|
|
3445
|
+
continue;
|
|
3446
|
+
}
|
|
3447
|
+
if (k === "contentFit") {
|
|
3448
|
+
pendingStyle = { ...pendingStyle ?? {}, objectFit: v };
|
|
3449
|
+
continue;
|
|
3450
|
+
}
|
|
3451
|
+
if (k === "defaultSource") continue;
|
|
3452
|
+
}
|
|
3453
|
+
if (k === "style") {
|
|
3454
|
+
if (Array.isArray(v)) {
|
|
3455
|
+
out.style = Object.assign({}, ...v.filter(Boolean));
|
|
3456
|
+
} else if (v != null) {
|
|
3457
|
+
out.style = v;
|
|
3458
|
+
}
|
|
3459
|
+
continue;
|
|
3460
|
+
}
|
|
3461
|
+
out[k] = v;
|
|
3462
|
+
}
|
|
3463
|
+
if (pendingStyle) {
|
|
3464
|
+
out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
|
|
3465
|
+
}
|
|
3466
|
+
if (isPressable && !out.role) out.role = "button";
|
|
3467
|
+
if (isImage && tag === "img" && out.alt == null) out.alt = "";
|
|
3468
|
+
return out;
|
|
3469
|
+
}
|
|
3470
|
+
|
|
3471
|
+
// src/InteractiveWrapper.tsx
|
|
3472
|
+
import React2, { forwardRef, useState, useCallback, useMemo } from "react";
|
|
3473
|
+
|
|
3474
|
+
// src/useGlobalWidth.ts
|
|
3475
|
+
var NOOP_SUB = (_) => () => {
|
|
3476
|
+
};
|
|
3477
|
+
var ZERO_SNAP = () => 0;
|
|
3478
|
+
var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
|
|
3479
|
+
var _webListeners = null;
|
|
3480
|
+
var _webRaf = 0;
|
|
3481
|
+
function _webResizeHandler() {
|
|
3482
|
+
cancelAnimationFrame(_webRaf);
|
|
3483
|
+
_webRaf = requestAnimationFrame(() => {
|
|
3484
|
+
if (_webListeners) for (const cb of _webListeners) cb();
|
|
3485
|
+
});
|
|
3486
|
+
}
|
|
3487
|
+
function subscribeWebWidth(cb) {
|
|
3488
|
+
if (typeof window === "undefined") return () => {
|
|
3489
|
+
};
|
|
3490
|
+
if (!_webListeners) {
|
|
3491
|
+
_webListeners = /* @__PURE__ */ new Set();
|
|
3492
|
+
window.addEventListener("resize", _webResizeHandler);
|
|
3493
|
+
}
|
|
3494
|
+
_webListeners.add(cb);
|
|
3495
|
+
return () => {
|
|
3496
|
+
_webListeners.delete(cb);
|
|
3497
|
+
if (_webListeners.size === 0) {
|
|
3498
|
+
window.removeEventListener("resize", _webResizeHandler);
|
|
3499
|
+
cancelAnimationFrame(_webRaf);
|
|
3500
|
+
_webListeners = null;
|
|
3501
|
+
}
|
|
3502
|
+
};
|
|
3503
|
+
}
|
|
3504
|
+
function getWebWidth() {
|
|
3505
|
+
return typeof window !== "undefined" ? window.innerWidth : 0;
|
|
3506
|
+
}
|
|
3507
|
+
function useGlobalWidth() {
|
|
3508
|
+
return useSyncExternalStore(
|
|
3509
|
+
isWeb ? subscribeWebWidth : subscribeGlobalWidth,
|
|
3510
|
+
isWeb ? getWebWidth : getGlobalWidth,
|
|
3511
|
+
ZERO_SNAP
|
|
3512
|
+
);
|
|
3513
|
+
}
|
|
3514
|
+
function useConditionalWidth(active) {
|
|
3515
|
+
return useSyncExternalStore(
|
|
3516
|
+
active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
|
|
3517
|
+
active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
|
|
3518
|
+
ZERO_SNAP
|
|
3519
|
+
);
|
|
3520
|
+
}
|
|
3521
|
+
|
|
3522
|
+
// src/InteractiveWrapper.tsx
|
|
3523
|
+
var InteractiveWrapper = forwardRef(
|
|
3524
|
+
function InteractiveWrapper2({
|
|
3525
|
+
Component,
|
|
3526
|
+
resolvedStyle,
|
|
3527
|
+
className,
|
|
3528
|
+
style: styleProp,
|
|
3529
|
+
onPressIn,
|
|
3530
|
+
onPressOut,
|
|
3531
|
+
onPointerDown,
|
|
3532
|
+
onPointerUp,
|
|
3533
|
+
onPointerLeave,
|
|
3534
|
+
onPointerCancel,
|
|
3535
|
+
onMouseEnter,
|
|
3536
|
+
onMouseLeave,
|
|
3537
|
+
onFocus,
|
|
3538
|
+
onBlur,
|
|
3539
|
+
...rest
|
|
3540
|
+
}, ref) {
|
|
3541
|
+
const isDark = useGlobalDarkMode();
|
|
3542
|
+
const needsWidth = hasResponsiveBuckets(resolvedStyle);
|
|
3543
|
+
const width = useConditionalWidth(needsWidth);
|
|
3544
|
+
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
|
|
3545
|
+
const [pressed, setPressed] = useState(false);
|
|
3546
|
+
const [hovered, setHovered] = useState(false);
|
|
3547
|
+
const [focused, setFocused] = useState(false);
|
|
3548
|
+
const handlePressIn = useCallback(chain(onPressIn, () => setPressed(true)), [onPressIn]);
|
|
3549
|
+
const handlePressOut = useCallback(chain(onPressOut, () => setPressed(false)), [onPressOut]);
|
|
3550
|
+
const handlePointerDown = useCallback(chain(onPointerDown, () => setPressed(true)), [onPointerDown]);
|
|
3551
|
+
const handlePointerUp = useCallback(chain(onPointerUp, () => setPressed(false)), [onPointerUp]);
|
|
3552
|
+
const handlePointerLeave = useCallback(chain(onPointerLeave, () => setPressed(false)), [onPointerLeave]);
|
|
3553
|
+
const handlePointerCancel = useCallback(chain(onPointerCancel, () => setPressed(false)), [onPointerCancel]);
|
|
3554
|
+
const handleMouseEnter = useCallback(chain(onMouseEnter, () => setHovered(true)), [onMouseEnter]);
|
|
3555
|
+
const handleMouseLeave = useCallback(chain(onMouseLeave, () => setHovered(false)), [onMouseLeave]);
|
|
3556
|
+
const handleFocus = useCallback(chain(onFocus, () => setFocused(true)), [onFocus]);
|
|
3557
|
+
const handleBlur = useCallback(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
3558
|
+
const { children, disabled, checked, ...restForComponent } = rest;
|
|
3559
|
+
const computedStyle = useMemo(
|
|
3560
|
+
() => {
|
|
3561
|
+
if (isWeb) return {};
|
|
3562
|
+
const s = flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!disabled, checked: !!checked }, breakpoints);
|
|
3563
|
+
stripInternalMarkers(s);
|
|
3564
|
+
if (typeof Component !== "string") stripWebOnlyProps(s);
|
|
3565
|
+
return s;
|
|
3566
|
+
},
|
|
3567
|
+
[resolvedStyle, isDark, pressed, hovered, focused, width, disabled, checked]
|
|
3568
|
+
);
|
|
3569
|
+
const skipComputedInline = isWeb || !isNative && typeof Component === "string";
|
|
3570
|
+
const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
3571
|
+
const componentProps = {
|
|
3572
|
+
ref,
|
|
3573
|
+
...restForComponent,
|
|
3574
|
+
...disabled !== void 0 ? { disabled } : {},
|
|
3575
|
+
...checked !== void 0 ? { checked } : {},
|
|
3576
|
+
style: finalStyle,
|
|
3577
|
+
...!isNative && className ? { className } : {},
|
|
3578
|
+
// On web, onPointerDown/Up drive the wrapper's own pressed state (covers mouse + touch),
|
|
3579
|
+
// but onPressIn/onPressOut are still forwarded unchanged — react-native-web components
|
|
3580
|
+
// (and any component that accepts both prop names) depend on receiving them directly.
|
|
3581
|
+
...!isNative ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerCancel, onPressIn, onPressOut } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
|
|
3582
|
+
onMouseEnter: handleMouseEnter,
|
|
3583
|
+
onMouseLeave: handleMouseLeave,
|
|
3584
|
+
onFocus: handleFocus,
|
|
3585
|
+
onBlur: handleBlur
|
|
3586
|
+
};
|
|
3587
|
+
return Array.isArray(children) ? React2.createElement(Component, componentProps, ...children) : React2.createElement(Component, componentProps, children);
|
|
3588
|
+
}
|
|
3589
|
+
);
|
|
3590
|
+
InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
|
|
3591
|
+
|
|
3104
3592
|
export {
|
|
3105
3593
|
defaultColors,
|
|
3106
3594
|
defaultTheme,
|
|
3107
3595
|
isWeb,
|
|
3108
3596
|
isNative,
|
|
3109
3597
|
setResolveTarget,
|
|
3110
|
-
setCSSGenMode,
|
|
3111
3598
|
getInteractiveModifiers,
|
|
3112
3599
|
getModeModifiers,
|
|
3113
3600
|
getResponsiveModifiers,
|
|
@@ -3116,18 +3603,14 @@ export {
|
|
|
3116
3603
|
splitClassTokens,
|
|
3117
3604
|
normalizeClassString,
|
|
3118
3605
|
parseClasses,
|
|
3119
|
-
BASE_RESET,
|
|
3120
3606
|
syncGlobalWidth,
|
|
3121
3607
|
syncGlobalScreens,
|
|
3122
3608
|
getGlobalScreens,
|
|
3123
3609
|
setGlobalWidth,
|
|
3124
|
-
getGlobalWidth,
|
|
3125
|
-
subscribeGlobalWidth,
|
|
3126
3610
|
getActiveBreakpoints,
|
|
3127
3611
|
getDefaultFontFamily,
|
|
3128
3612
|
disableRuntimeCSS,
|
|
3129
3613
|
isRuntimeCSSDisabled,
|
|
3130
|
-
generateClassCSS,
|
|
3131
3614
|
resolve,
|
|
3132
3615
|
flatten,
|
|
3133
3616
|
clearCache,
|
|
@@ -3135,5 +3618,21 @@ export {
|
|
|
3135
3618
|
buildConfig,
|
|
3136
3619
|
onConfigChange,
|
|
3137
3620
|
updateConfig,
|
|
3138
|
-
initConfig
|
|
3621
|
+
initConfig,
|
|
3622
|
+
syncGlobalDarkMode,
|
|
3623
|
+
setGlobalDarkMode,
|
|
3624
|
+
useSyncExternalStore,
|
|
3625
|
+
useGlobalDarkMode,
|
|
3626
|
+
EMPTY_BREAKPOINTS,
|
|
3627
|
+
useGlobalWidth,
|
|
3628
|
+
useConditionalWidth,
|
|
3629
|
+
hasResponsiveBuckets,
|
|
3630
|
+
hasInteractiveBuckets,
|
|
3631
|
+
chain,
|
|
3632
|
+
stripInternalMarkers,
|
|
3633
|
+
stripWebOnlyProps,
|
|
3634
|
+
registerWebElement,
|
|
3635
|
+
getWebTag,
|
|
3636
|
+
transformToWebProps,
|
|
3637
|
+
InteractiveWrapper
|
|
3139
3638
|
};
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
import {
|
|
2
3
|
EMPTY_BREAKPOINTS,
|
|
3
4
|
InteractiveWrapper,
|
|
4
|
-
getWebTag,
|
|
5
|
-
hasResponsiveBuckets,
|
|
6
|
-
stripInternalMarkers,
|
|
7
|
-
stripWebOnlyProps,
|
|
8
|
-
transformToWebProps,
|
|
9
|
-
useConditionalWidth,
|
|
10
|
-
useGlobalDarkMode
|
|
11
|
-
} from "./chunk-36QRQNPL.mjs";
|
|
12
|
-
import {
|
|
13
5
|
flatten,
|
|
14
6
|
getActiveBreakpoints,
|
|
15
7
|
getConfig,
|
|
@@ -18,13 +10,20 @@ import {
|
|
|
18
10
|
getInteractiveModifiers,
|
|
19
11
|
getModeModifiers,
|
|
20
12
|
getResponsiveModifiers,
|
|
13
|
+
getWebTag,
|
|
14
|
+
hasResponsiveBuckets,
|
|
21
15
|
isNative,
|
|
22
16
|
isRuntimeCSSDisabled,
|
|
23
17
|
isWeb,
|
|
24
18
|
normalizeClassString,
|
|
25
19
|
onConfigChange,
|
|
26
|
-
resolve
|
|
27
|
-
|
|
20
|
+
resolve,
|
|
21
|
+
stripInternalMarkers,
|
|
22
|
+
stripWebOnlyProps,
|
|
23
|
+
transformToWebProps,
|
|
24
|
+
useConditionalWidth,
|
|
25
|
+
useGlobalDarkMode
|
|
26
|
+
} from "./chunk-GRZ6MVIL.mjs";
|
|
28
27
|
|
|
29
28
|
// src/jsx-runtime.tsx
|
|
30
29
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|