@kbach/react 0.5.60 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -9
- package/dist/{chunk-NP4FVE77.mjs → chunk-6NED62DB.mjs} +23 -20
- package/dist/{chunk-LU2QNVYU.mjs → chunk-AAAI37Y4.mjs} +4 -4
- package/dist/{chunk-2MVCYYH5.mjs → chunk-D4LJICWZ.mjs} +5 -6
- package/dist/index.d.mts +1 -29
- package/dist/index.d.ts +1 -29
- package/dist/index.js +78 -205
- package/dist/index.mjs +17 -156
- package/dist/jsx-dev-runtime.js +29 -18
- package/dist/jsx-dev-runtime.mjs +3 -3
- package/dist/jsx-runtime.js +29 -18
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/vite-plugin.js +37 -14
- package/dist/vite-plugin.mjs +3 -1
- package/kbach-react.md +0 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33,7 +33,6 @@ __export(index_exports, {
|
|
|
33
33
|
InteractiveWrapper: () => InteractiveWrapper,
|
|
34
34
|
ThemeContext: () => ThemeContext,
|
|
35
35
|
ThemeProvider: () => ThemeProvider,
|
|
36
|
-
ThemeToggle: () => ThemeToggle,
|
|
37
36
|
buildConfig: () => buildConfig,
|
|
38
37
|
cx: () => cx,
|
|
39
38
|
defaultColors: () => defaultColors,
|
|
@@ -1326,10 +1325,12 @@ var RESOLVERS = {
|
|
|
1326
1325
|
const color = resolveColor(value, colors, isArbitrary);
|
|
1327
1326
|
return color ? { backgroundColor: color } : null;
|
|
1328
1327
|
},
|
|
1329
|
-
"bg-opacity": ({ value }, _) => {
|
|
1328
|
+
"bg-opacity": ({ value, isArbitrary }, _) => {
|
|
1330
1329
|
if (!getEffectiveIsWeb()) return null;
|
|
1331
|
-
const
|
|
1332
|
-
|
|
1330
|
+
const n = parseFloat(value);
|
|
1331
|
+
if (isNaN(n)) return null;
|
|
1332
|
+
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1333
|
+
return { "--bg-opacity": v };
|
|
1333
1334
|
},
|
|
1334
1335
|
// ── Text ───────────────────────────────────────────────────────────────────
|
|
1335
1336
|
text: ({ value, isArbitrary }, { colors, fontSize }) => {
|
|
@@ -1344,10 +1345,12 @@ var RESOLVERS = {
|
|
|
1344
1345
|
const color = resolveColor(value, colors, false);
|
|
1345
1346
|
return color ? { color } : null;
|
|
1346
1347
|
},
|
|
1347
|
-
"text-opacity": ({ value }, _) => {
|
|
1348
|
+
"text-opacity": ({ value, isArbitrary }, _) => {
|
|
1348
1349
|
if (!getEffectiveIsWeb()) return null;
|
|
1349
|
-
const
|
|
1350
|
-
|
|
1350
|
+
const n = parseFloat(value);
|
|
1351
|
+
if (isNaN(n)) return null;
|
|
1352
|
+
const v = isArbitrary ? n > 1 ? n / 100 : n : n / 100;
|
|
1353
|
+
return { "--text-opacity": v };
|
|
1351
1354
|
},
|
|
1352
1355
|
// ── Padding ────────────────────────────────────────────────────────────────
|
|
1353
1356
|
p: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
@@ -2248,9 +2251,9 @@ var RESOLVERS = {
|
|
|
2248
2251
|
const n = parseFloat(value);
|
|
2249
2252
|
return { flexShrink: isNaN(n) ? 1 : n };
|
|
2250
2253
|
},
|
|
2251
|
-
order: ({ value,
|
|
2252
|
-
const n = parseInt(value);
|
|
2253
|
-
return isNaN(n) ? null : { order: n };
|
|
2254
|
+
order: ({ value, negative }, _) => {
|
|
2255
|
+
const n = parseInt(value, 10);
|
|
2256
|
+
return isNaN(n) ? null : { order: negative ? -n : n };
|
|
2254
2257
|
},
|
|
2255
2258
|
// ── Gap ────────────────────────────────────────────────────────────────────
|
|
2256
2259
|
gap: ({ value, negative, isArbitrary }, { spacing }) => {
|
|
@@ -2467,10 +2470,17 @@ var RESOLVERS = {
|
|
|
2467
2470
|
const DEFAULT_RING_COLOR = "rgba(59, 130, 246, 0.5)";
|
|
2468
2471
|
const DEFAULT_RING_WIDTH = 3;
|
|
2469
2472
|
const offsetTokens = { "0": 0, "1": 1, "2": 2, "4": 4, "8": 8 };
|
|
2470
|
-
|
|
2471
|
-
if (
|
|
2473
|
+
let offsetWidth;
|
|
2474
|
+
if (!isArbitrary) {
|
|
2475
|
+
offsetWidth = value in offsetTokens ? offsetTokens[value] : null;
|
|
2476
|
+
} else {
|
|
2477
|
+
offsetWidth = /^-?\d+(\.\d+)?$/.test(value) ? parseFloat(value) : value;
|
|
2478
|
+
}
|
|
2479
|
+
if (offsetWidth === null || typeof offsetWidth === "number" && isNaN(offsetWidth)) return null;
|
|
2480
|
+
const isZero = offsetWidth === 0 || offsetWidth === "0";
|
|
2481
|
+
const offsetCss = typeof offsetWidth === "number" ? `${offsetWidth}px` : offsetWidth;
|
|
2472
2482
|
return {
|
|
2473
|
-
boxShadow:
|
|
2483
|
+
boxShadow: isZero ? `0 0 0 ${DEFAULT_RING_WIDTH}px ${DEFAULT_RING_COLOR}` : `0 0 0 ${offsetCss} #fff, 0 0 0 calc(${offsetCss} + ${DEFAULT_RING_WIDTH}px) ${DEFAULT_RING_COLOR}`
|
|
2474
2484
|
};
|
|
2475
2485
|
},
|
|
2476
2486
|
// ── Space between ─────────────────────────────────────────────────────────
|
|
@@ -3416,153 +3426,14 @@ function ThemeProvider({
|
|
|
3416
3426
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ThemeContext.Provider, { value: contextValue, children });
|
|
3417
3427
|
}
|
|
3418
3428
|
|
|
3419
|
-
// src/ThemeToggle.tsx
|
|
3420
|
-
var import_react4 = __toESM(require("react"));
|
|
3421
|
-
function getPrimitives() {
|
|
3422
|
-
try {
|
|
3423
|
-
const RN = require("react-native");
|
|
3424
|
-
return {
|
|
3425
|
-
View: RN.View,
|
|
3426
|
-
Text: RN.Text,
|
|
3427
|
-
Touchable: RN.TouchableOpacity,
|
|
3428
|
-
Switch: RN.Switch
|
|
3429
|
-
};
|
|
3430
|
-
} catch {
|
|
3431
|
-
const View = ({ style, ...rest }) => import_react4.default.createElement("div", { style, ...rest });
|
|
3432
|
-
const Text = ({ style, ...rest }) => import_react4.default.createElement("span", { style, ...rest });
|
|
3433
|
-
const Touchable = ({ onPress, style, ...rest }) => import_react4.default.createElement("button", { onClick: onPress, style, ...rest });
|
|
3434
|
-
const Switch = ({
|
|
3435
|
-
value,
|
|
3436
|
-
onValueChange,
|
|
3437
|
-
accessibilityLabel
|
|
3438
|
-
}) => import_react4.default.createElement("input", {
|
|
3439
|
-
type: "checkbox",
|
|
3440
|
-
checked: value,
|
|
3441
|
-
onChange: (e) => onValueChange?.(e.target.checked),
|
|
3442
|
-
"aria-label": accessibilityLabel
|
|
3443
|
-
});
|
|
3444
|
-
return { View, Text, Touchable, Switch };
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
var { View: _View, Text: _Text, Touchable: _Touchable, Switch: _Switch } = getPrimitives();
|
|
3448
|
-
function ThemeToggle({
|
|
3449
|
-
variant = "button",
|
|
3450
|
-
label,
|
|
3451
|
-
lightLabel = "Light",
|
|
3452
|
-
darkLabel = "Dark",
|
|
3453
|
-
includeSystem = false,
|
|
3454
|
-
style,
|
|
3455
|
-
labelStyle
|
|
3456
|
-
}) {
|
|
3457
|
-
const { mode, isDark, setMode, toggle } = useTheme();
|
|
3458
|
-
const View = _View, Text = _Text, Touchable = _Touchable, Switch = _Switch;
|
|
3459
|
-
if (variant === "switch") {
|
|
3460
|
-
return import_react4.default.createElement(
|
|
3461
|
-
View,
|
|
3462
|
-
{ style: { flexDirection: "row", alignItems: "center", gap: 8, ...style } },
|
|
3463
|
-
import_react4.default.createElement(Text, { style: { fontSize: 14, ...labelStyle } }, lightLabel),
|
|
3464
|
-
import_react4.default.createElement(Switch, {
|
|
3465
|
-
value: isDark,
|
|
3466
|
-
onValueChange: (v) => setMode(v ? "dark" : "light"),
|
|
3467
|
-
trackColor: { false: "#d1d5db", true: "#6366f1" },
|
|
3468
|
-
thumbColor: isDark ? "#ffffff" : "#f3f4f6",
|
|
3469
|
-
ios_backgroundColor: "#d1d5db",
|
|
3470
|
-
accessibilityLabel: "Toggle dark mode"
|
|
3471
|
-
}),
|
|
3472
|
-
import_react4.default.createElement(Text, { style: { fontSize: 14, ...labelStyle } }, darkLabel)
|
|
3473
|
-
);
|
|
3474
|
-
}
|
|
3475
|
-
if (variant === "icon-button") {
|
|
3476
|
-
const icon = isDark ? darkLabel : lightLabel;
|
|
3477
|
-
return import_react4.default.createElement(
|
|
3478
|
-
Touchable,
|
|
3479
|
-
{
|
|
3480
|
-
onPress: toggle,
|
|
3481
|
-
style: {
|
|
3482
|
-
padding: 8,
|
|
3483
|
-
borderRadius: 8,
|
|
3484
|
-
backgroundColor: isDark ? "#374151" : "#f3f4f6",
|
|
3485
|
-
...style
|
|
3486
|
-
},
|
|
3487
|
-
accessibilityRole: "button",
|
|
3488
|
-
accessibilityLabel: `Switch to ${isDark ? "light" : "dark"} mode`,
|
|
3489
|
-
accessibilityState: {}
|
|
3490
|
-
},
|
|
3491
|
-
import_react4.default.createElement(Text, { style: { fontSize: 18, ...labelStyle } }, icon)
|
|
3492
|
-
);
|
|
3493
|
-
}
|
|
3494
|
-
if (includeSystem) {
|
|
3495
|
-
const modes = [
|
|
3496
|
-
{ key: "light", label: lightLabel },
|
|
3497
|
-
{ key: "dark", label: darkLabel },
|
|
3498
|
-
{ key: "system", label: "System" }
|
|
3499
|
-
];
|
|
3500
|
-
return import_react4.default.createElement(
|
|
3501
|
-
View,
|
|
3502
|
-
{ style: { flexDirection: "row", gap: 4, ...style } },
|
|
3503
|
-
...modes.map(
|
|
3504
|
-
({ key, label: mLabel }) => import_react4.default.createElement(
|
|
3505
|
-
Touchable,
|
|
3506
|
-
{
|
|
3507
|
-
key,
|
|
3508
|
-
onPress: () => setMode(key),
|
|
3509
|
-
style: {
|
|
3510
|
-
paddingHorizontal: 12,
|
|
3511
|
-
paddingVertical: 6,
|
|
3512
|
-
borderRadius: 6,
|
|
3513
|
-
backgroundColor: mode === key ? isDark ? "#6366f1" : "#3b82f6" : isDark ? "#374151" : "#e5e7eb"
|
|
3514
|
-
},
|
|
3515
|
-
accessibilityRole: "button",
|
|
3516
|
-
accessibilityLabel: `Set ${key} theme`,
|
|
3517
|
-
accessibilityState: { selected: mode === key }
|
|
3518
|
-
},
|
|
3519
|
-
import_react4.default.createElement(Text, {
|
|
3520
|
-
style: {
|
|
3521
|
-
fontSize: 13,
|
|
3522
|
-
fontWeight: "500",
|
|
3523
|
-
color: mode === key ? "#ffffff" : isDark ? "#d1d5db" : "#374151",
|
|
3524
|
-
...labelStyle
|
|
3525
|
-
}
|
|
3526
|
-
}, mLabel)
|
|
3527
|
-
)
|
|
3528
|
-
)
|
|
3529
|
-
);
|
|
3530
|
-
}
|
|
3531
|
-
const currentLabel = label ?? (isDark ? darkLabel : lightLabel);
|
|
3532
|
-
return import_react4.default.createElement(
|
|
3533
|
-
Touchable,
|
|
3534
|
-
{
|
|
3535
|
-
onPress: toggle,
|
|
3536
|
-
style: {
|
|
3537
|
-
paddingHorizontal: 16,
|
|
3538
|
-
paddingVertical: 8,
|
|
3539
|
-
borderRadius: 8,
|
|
3540
|
-
backgroundColor: isDark ? "#374151" : "#e5e7eb",
|
|
3541
|
-
...style
|
|
3542
|
-
},
|
|
3543
|
-
accessibilityRole: "button",
|
|
3544
|
-
accessibilityLabel: `Switch to ${isDark ? "light" : "dark"} mode`,
|
|
3545
|
-
accessibilityState: {}
|
|
3546
|
-
},
|
|
3547
|
-
import_react4.default.createElement(Text, {
|
|
3548
|
-
style: {
|
|
3549
|
-
fontSize: 14,
|
|
3550
|
-
fontWeight: "500",
|
|
3551
|
-
color: isDark ? "#f9fafb" : "#111827",
|
|
3552
|
-
...labelStyle
|
|
3553
|
-
}
|
|
3554
|
-
}, currentLabel)
|
|
3555
|
-
);
|
|
3556
|
-
}
|
|
3557
|
-
|
|
3558
3429
|
// src/styled.tsx
|
|
3559
|
-
var
|
|
3430
|
+
var import_react6 = __toESM(require("react"));
|
|
3560
3431
|
|
|
3561
3432
|
// src/useGlobalDarkMode.ts
|
|
3562
|
-
var
|
|
3563
|
-
var useSyncExternalStore =
|
|
3564
|
-
const [, forceUpdate] =
|
|
3565
|
-
|
|
3433
|
+
var import_react4 = __toESM(require("react"));
|
|
3434
|
+
var useSyncExternalStore = import_react4.default.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
3435
|
+
const [, forceUpdate] = import_react4.default.useReducer((n) => n + 1, 0);
|
|
3436
|
+
import_react4.default.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
3566
3437
|
return getSnapshot();
|
|
3567
3438
|
};
|
|
3568
3439
|
function useGlobalDarkMode() {
|
|
@@ -3575,10 +3446,10 @@ function useGlobalDarkMode() {
|
|
|
3575
3446
|
}
|
|
3576
3447
|
|
|
3577
3448
|
// src/useGlobalWidth.ts
|
|
3578
|
-
var
|
|
3579
|
-
var useSyncExternalStore2 =
|
|
3580
|
-
const [, forceUpdate] =
|
|
3581
|
-
|
|
3449
|
+
var import_react5 = __toESM(require("react"));
|
|
3450
|
+
var useSyncExternalStore2 = import_react5.default.useSyncExternalStore ?? function useSyncExternalStoreFallback2(subscribe, getSnapshot, _getServerSnapshot) {
|
|
3451
|
+
const [, forceUpdate] = import_react5.default.useReducer((n) => n + 1, 0);
|
|
3452
|
+
import_react5.default.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
3582
3453
|
return getSnapshot();
|
|
3583
3454
|
};
|
|
3584
3455
|
var NOOP_SUB = (_) => () => {
|
|
@@ -3929,7 +3800,7 @@ function transformToWebProps(originalName, tag, props) {
|
|
|
3929
3800
|
|
|
3930
3801
|
// src/styled.tsx
|
|
3931
3802
|
function styled(Component, baseClasses = "") {
|
|
3932
|
-
const Styled = (0,
|
|
3803
|
+
const Styled = (0, import_react6.forwardRef)(
|
|
3933
3804
|
(props, ref) => {
|
|
3934
3805
|
const {
|
|
3935
3806
|
kb: extraClasses,
|
|
@@ -3949,52 +3820,52 @@ function styled(Component, baseClasses = "") {
|
|
|
3949
3820
|
const checked = !!props.checked;
|
|
3950
3821
|
const { config } = useTheme();
|
|
3951
3822
|
const isDark = useGlobalDarkMode();
|
|
3952
|
-
const [pressed, setPressed] = (0,
|
|
3953
|
-
const [hovered, setHovered] = (0,
|
|
3954
|
-
const [focused, setFocused] = (0,
|
|
3955
|
-
const handlePressIn = (0,
|
|
3823
|
+
const [pressed, setPressed] = (0, import_react6.useState)(false);
|
|
3824
|
+
const [hovered, setHovered] = (0, import_react6.useState)(false);
|
|
3825
|
+
const [focused, setFocused] = (0, import_react6.useState)(false);
|
|
3826
|
+
const handlePressIn = (0, import_react6.useCallback)((e) => {
|
|
3956
3827
|
setPressed(true);
|
|
3957
3828
|
onPressIn?.(e);
|
|
3958
3829
|
}, [onPressIn]);
|
|
3959
|
-
const handlePressOut = (0,
|
|
3830
|
+
const handlePressOut = (0, import_react6.useCallback)((e) => {
|
|
3960
3831
|
setPressed(false);
|
|
3961
3832
|
onPressOut?.(e);
|
|
3962
3833
|
}, [onPressOut]);
|
|
3963
|
-
const handlePointerDown = (0,
|
|
3834
|
+
const handlePointerDown = (0, import_react6.useCallback)((e) => {
|
|
3964
3835
|
setPressed(true);
|
|
3965
3836
|
onPointerDown?.(e);
|
|
3966
3837
|
}, [onPointerDown]);
|
|
3967
|
-
const handlePointerUp = (0,
|
|
3838
|
+
const handlePointerUp = (0, import_react6.useCallback)((e) => {
|
|
3968
3839
|
setPressed(false);
|
|
3969
3840
|
onPointerUp?.(e);
|
|
3970
3841
|
}, [onPointerUp]);
|
|
3971
|
-
const handlePointerLeave = (0,
|
|
3842
|
+
const handlePointerLeave = (0, import_react6.useCallback)((e) => {
|
|
3972
3843
|
setPressed(false);
|
|
3973
3844
|
onPointerLeave?.(e);
|
|
3974
3845
|
}, [onPointerLeave]);
|
|
3975
|
-
const handleMouseEnter = (0,
|
|
3846
|
+
const handleMouseEnter = (0, import_react6.useCallback)((e) => {
|
|
3976
3847
|
setHovered(true);
|
|
3977
3848
|
onMouseEnter?.(e);
|
|
3978
3849
|
}, [onMouseEnter]);
|
|
3979
|
-
const handleMouseLeave = (0,
|
|
3850
|
+
const handleMouseLeave = (0, import_react6.useCallback)((e) => {
|
|
3980
3851
|
setHovered(false);
|
|
3981
3852
|
onMouseLeave?.(e);
|
|
3982
3853
|
}, [onMouseLeave]);
|
|
3983
|
-
const handleFocus = (0,
|
|
3854
|
+
const handleFocus = (0, import_react6.useCallback)((e) => {
|
|
3984
3855
|
setFocused(true);
|
|
3985
3856
|
onFocus?.(e);
|
|
3986
3857
|
}, [onFocus]);
|
|
3987
|
-
const handleBlur = (0,
|
|
3858
|
+
const handleBlur = (0, import_react6.useCallback)((e) => {
|
|
3988
3859
|
setFocused(false);
|
|
3989
3860
|
onBlur?.(e);
|
|
3990
3861
|
}, [onBlur]);
|
|
3991
3862
|
const combined = extraClasses ? `${baseClasses} ${extraClasses}` : baseClasses;
|
|
3992
|
-
const resolved = (0,
|
|
3993
|
-
const hasInteractive = (0,
|
|
3863
|
+
const resolved = (0, import_react6.useMemo)(() => resolve(combined, config.theme, config.darkMode), [combined, config.theme, config.darkMode]);
|
|
3864
|
+
const hasInteractive = (0, import_react6.useMemo)(() => hasInteractiveBuckets(resolved), [resolved]);
|
|
3994
3865
|
const needsWidth = hasResponsiveBuckets(resolved);
|
|
3995
3866
|
const width = useConditionalWidth(needsWidth);
|
|
3996
3867
|
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
|
|
3997
|
-
const computedStyle = (0,
|
|
3868
|
+
const computedStyle = (0, import_react6.useMemo)(
|
|
3998
3869
|
() => isWeb ? {} : flatten(resolved, isDark, { pressed, hover: hovered, focus: focused, disabled, checked }, breakpoints),
|
|
3999
3870
|
[resolved, isDark, pressed, hovered, focused, disabled, checked, width]
|
|
4000
3871
|
// eslint-disable-line react-hooks/exhaustive-deps
|
|
@@ -4005,7 +3876,7 @@ function styled(Component, baseClasses = "") {
|
|
|
4005
3876
|
const effectiveComponent = webTag ?? Component;
|
|
4006
3877
|
const componentName2 = Component.displayName ?? Component.name ?? "";
|
|
4007
3878
|
const effectiveRest = webTag && componentName2 ? transformToWebProps(componentName2, webTag, rest) : rest;
|
|
4008
|
-
return
|
|
3879
|
+
return import_react6.default.createElement(effectiveComponent, {
|
|
4009
3880
|
ref,
|
|
4010
3881
|
...effectiveRest,
|
|
4011
3882
|
style: finalStyle,
|
|
@@ -4013,7 +3884,9 @@ function styled(Component, baseClasses = "") {
|
|
|
4013
3884
|
...isWeb && combined ? { className: normalizeClassString(combined) } : {},
|
|
4014
3885
|
// Only attach state-tracking handlers when interactive modifiers are present.
|
|
4015
3886
|
// Always forward user-provided handlers to avoid silently swallowing them.
|
|
4016
|
-
|
|
3887
|
+
// onPressIn/onPressOut are forwarded on web too (not just native) since
|
|
3888
|
+
// react-native-web components rely on receiving them directly.
|
|
3889
|
+
...isWeb ? hasInteractive ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerLeave, onPressIn, onPressOut } : { onPointerDown, onPointerUp, onPointerLeave, onPressIn, onPressOut } : hasInteractive ? { onPressIn: handlePressIn, onPressOut: handlePressOut } : { onPressIn, onPressOut },
|
|
4017
3890
|
onMouseEnter: hasInteractive ? handleMouseEnter : onMouseEnter,
|
|
4018
3891
|
onMouseLeave: hasInteractive ? handleMouseLeave : onMouseLeave,
|
|
4019
3892
|
onFocus: hasInteractive ? handleFocus : onFocus,
|
|
@@ -4027,12 +3900,12 @@ function styled(Component, baseClasses = "") {
|
|
|
4027
3900
|
}
|
|
4028
3901
|
|
|
4029
3902
|
// src/useStyles.ts
|
|
4030
|
-
var
|
|
3903
|
+
var import_react7 = require("react");
|
|
4031
3904
|
function useStyles(classString, state = {}) {
|
|
4032
3905
|
const { isDark, config } = useTheme();
|
|
4033
3906
|
const width = useGlobalWidth();
|
|
4034
3907
|
const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
|
|
4035
|
-
return (0,
|
|
3908
|
+
return (0, import_react7.useMemo)(() => {
|
|
4036
3909
|
const resolved = resolve(normalised, config.theme, config.darkMode);
|
|
4037
3910
|
const breakpoints = getActiveBreakpoints(width);
|
|
4038
3911
|
return flatten(resolved, isDark, state, breakpoints);
|
|
@@ -4041,19 +3914,19 @@ function useStyles(classString, state = {}) {
|
|
|
4041
3914
|
function useResolvedStyle(classString) {
|
|
4042
3915
|
const { config } = useTheme();
|
|
4043
3916
|
const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
|
|
4044
|
-
return (0,
|
|
3917
|
+
return (0, import_react7.useMemo)(
|
|
4045
3918
|
() => resolve(normalised, config.theme, config.darkMode),
|
|
4046
3919
|
[normalised, config]
|
|
4047
3920
|
);
|
|
4048
3921
|
}
|
|
4049
3922
|
|
|
4050
3923
|
// src/useBreakpoint.ts
|
|
4051
|
-
var
|
|
3924
|
+
var import_react8 = require("react");
|
|
4052
3925
|
function useBreakpoint() {
|
|
4053
3926
|
const { config } = useTheme();
|
|
4054
3927
|
const width = useGlobalWidth();
|
|
4055
3928
|
const screens = config.theme.screens;
|
|
4056
|
-
const sorted = (0,
|
|
3929
|
+
const sorted = (0, import_react8.useMemo)(
|
|
4057
3930
|
() => Object.entries(screens).filter((entry) => typeof entry[1] === "number").sort(([, a], [, b]) => b - a),
|
|
4058
3931
|
[screens]
|
|
4059
3932
|
);
|
|
@@ -4066,7 +3939,7 @@ function useResponsive() {
|
|
|
4066
3939
|
const { config } = useTheme();
|
|
4067
3940
|
const width = useGlobalWidth();
|
|
4068
3941
|
const screens = config.theme.screens;
|
|
4069
|
-
return (0,
|
|
3942
|
+
return (0, import_react8.useMemo)(() => {
|
|
4070
3943
|
const result = {};
|
|
4071
3944
|
for (const [name, minW] of Object.entries(screens)) {
|
|
4072
3945
|
if (typeof minW === "number") result[name] = width >= minW;
|
|
@@ -4076,14 +3949,14 @@ function useResponsive() {
|
|
|
4076
3949
|
}
|
|
4077
3950
|
|
|
4078
3951
|
// src/InteractiveWrapper.tsx
|
|
4079
|
-
var
|
|
3952
|
+
var import_react9 = __toESM(require("react"));
|
|
4080
3953
|
function chain(original, extra) {
|
|
4081
3954
|
return (...args) => {
|
|
4082
3955
|
original?.(...args);
|
|
4083
3956
|
extra();
|
|
4084
3957
|
};
|
|
4085
3958
|
}
|
|
4086
|
-
var InteractiveWrapper = (0,
|
|
3959
|
+
var InteractiveWrapper = (0, import_react9.forwardRef)(
|
|
4087
3960
|
function InteractiveWrapper2({
|
|
4088
3961
|
Component,
|
|
4089
3962
|
resolvedStyle,
|
|
@@ -4104,20 +3977,20 @@ var InteractiveWrapper = (0, import_react10.forwardRef)(
|
|
|
4104
3977
|
const needsWidth = hasResponsiveBuckets(resolvedStyle);
|
|
4105
3978
|
const width = useConditionalWidth(needsWidth);
|
|
4106
3979
|
const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
|
|
4107
|
-
const [pressed, setPressed] = (0,
|
|
4108
|
-
const [hovered, setHovered] = (0,
|
|
4109
|
-
const [focused, setFocused] = (0,
|
|
4110
|
-
const handlePressIn = (0,
|
|
4111
|
-
const handlePressOut = (0,
|
|
4112
|
-
const handlePointerDown = (0,
|
|
4113
|
-
const handlePointerUp = (0,
|
|
4114
|
-
const handlePointerLeave = (0,
|
|
4115
|
-
const handleMouseEnter = (0,
|
|
4116
|
-
const handleMouseLeave = (0,
|
|
4117
|
-
const handleFocus = (0,
|
|
4118
|
-
const handleBlur = (0,
|
|
3980
|
+
const [pressed, setPressed] = (0, import_react9.useState)(false);
|
|
3981
|
+
const [hovered, setHovered] = (0, import_react9.useState)(false);
|
|
3982
|
+
const [focused, setFocused] = (0, import_react9.useState)(false);
|
|
3983
|
+
const handlePressIn = (0, import_react9.useCallback)(chain(onPressIn, () => setPressed(true)), [onPressIn]);
|
|
3984
|
+
const handlePressOut = (0, import_react9.useCallback)(chain(onPressOut, () => setPressed(false)), [onPressOut]);
|
|
3985
|
+
const handlePointerDown = (0, import_react9.useCallback)(chain(onPointerDown, () => setPressed(true)), [onPointerDown]);
|
|
3986
|
+
const handlePointerUp = (0, import_react9.useCallback)(chain(onPointerUp, () => setPressed(false)), [onPointerUp]);
|
|
3987
|
+
const handlePointerLeave = (0, import_react9.useCallback)(chain(onPointerLeave, () => setPressed(false)), [onPointerLeave]);
|
|
3988
|
+
const handleMouseEnter = (0, import_react9.useCallback)(chain(onMouseEnter, () => setHovered(true)), [onMouseEnter]);
|
|
3989
|
+
const handleMouseLeave = (0, import_react9.useCallback)(chain(onMouseLeave, () => setHovered(false)), [onMouseLeave]);
|
|
3990
|
+
const handleFocus = (0, import_react9.useCallback)(chain(onFocus, () => setFocused(true)), [onFocus]);
|
|
3991
|
+
const handleBlur = (0, import_react9.useCallback)(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
4119
3992
|
const { children, disabled, checked, ...restForComponent } = rest;
|
|
4120
|
-
const computedStyle = (0,
|
|
3993
|
+
const computedStyle = (0, import_react9.useMemo)(
|
|
4121
3994
|
() => {
|
|
4122
3995
|
if (isWeb) return {};
|
|
4123
3996
|
const s = flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!disabled, checked: !!checked }, breakpoints);
|
|
@@ -4162,15 +4035,16 @@ var InteractiveWrapper = (0, import_react10.forwardRef)(
|
|
|
4162
4035
|
...checked !== void 0 ? { checked } : {},
|
|
4163
4036
|
style: finalStyle,
|
|
4164
4037
|
...!isNative && className ? { className } : {},
|
|
4165
|
-
//
|
|
4166
|
-
//
|
|
4167
|
-
|
|
4038
|
+
// On web, onPointerDown/Up drive the wrapper's own pressed state (covers mouse + touch),
|
|
4039
|
+
// but onPressIn/onPressOut are still forwarded unchanged — react-native-web components
|
|
4040
|
+
// (and any component that accepts both prop names) depend on receiving them directly.
|
|
4041
|
+
...!isNative ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerLeave, onPressIn, onPressOut } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
|
|
4168
4042
|
onMouseEnter: handleMouseEnter,
|
|
4169
4043
|
onMouseLeave: handleMouseLeave,
|
|
4170
4044
|
onFocus: handleFocus,
|
|
4171
4045
|
onBlur: handleBlur
|
|
4172
4046
|
};
|
|
4173
|
-
return Array.isArray(children) ?
|
|
4047
|
+
return Array.isArray(children) ? import_react9.default.createElement(Component, componentProps, ...children) : import_react9.default.createElement(Component, componentProps, children);
|
|
4174
4048
|
}
|
|
4175
4049
|
);
|
|
4176
4050
|
InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
|
|
@@ -4192,7 +4066,6 @@ function cx(...classes) {
|
|
|
4192
4066
|
InteractiveWrapper,
|
|
4193
4067
|
ThemeContext,
|
|
4194
4068
|
ThemeProvider,
|
|
4195
|
-
ThemeToggle,
|
|
4196
4069
|
buildConfig,
|
|
4197
4070
|
cx,
|
|
4198
4071
|
defaultColors,
|