@kbach/react 0.1.6 → 0.1.9
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 +29 -29
- package/dist/{chunk-FUSJKUE7.mjs → chunk-CNS23UB5.mjs} +9 -7
- package/dist/chunk-PYBA3DFG.mjs +2046 -0
- package/dist/index.d.mts +128 -9
- package/dist/index.d.ts +128 -9
- package/dist/index.js +1985 -40
- package/dist/index.mjs +26 -35
- package/dist/jsx-dev-runtime.js +1943 -18
- package/dist/jsx-dev-runtime.mjs +2 -2
- package/dist/jsx-runtime.js +1943 -18
- package/dist/jsx-runtime.mjs +2 -2
- package/package.json +1 -4
- package/dist/chunk-IZK5HMWK.mjs +0 -85
package/dist/jsx-runtime.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kbach/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "React / React Native components and hooks for the Kbach framework",
|
|
5
5
|
"source": "./src/index.ts",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -36,18 +36,15 @@
|
|
|
36
36
|
"lint": "tsc --noEmit"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@kbach/core": "0.1.1",
|
|
40
39
|
"@types/react": "^19.2.0",
|
|
41
40
|
"tsup": "^8.0.0",
|
|
42
41
|
"vitest": "^1.0.0"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
45
|
-
"@kbach/core": ">=0.1.1",
|
|
46
44
|
"react": ">=17.0.0",
|
|
47
45
|
"react-native": ">=0.70.0"
|
|
48
46
|
},
|
|
49
47
|
"peerDependenciesMeta": {
|
|
50
|
-
"@kbach/core": { "optional": false },
|
|
51
48
|
"react-native": {
|
|
52
49
|
"optional": true
|
|
53
50
|
}
|
package/dist/chunk-IZK5HMWK.mjs
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
5
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
// src/useGlobalDarkMode.ts
|
|
9
|
-
import React from "react";
|
|
10
|
-
import { getGlobalDarkMode, subscribeGlobalDarkMode } from "@kbach/core";
|
|
11
|
-
var useSyncExternalStore = React.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
12
|
-
const [, forceUpdate] = React.useReducer((n) => n + 1, 0);
|
|
13
|
-
React.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
14
|
-
return getSnapshot();
|
|
15
|
-
};
|
|
16
|
-
function useGlobalDarkMode() {
|
|
17
|
-
return useSyncExternalStore(
|
|
18
|
-
subscribeGlobalDarkMode,
|
|
19
|
-
getGlobalDarkMode,
|
|
20
|
-
() => false
|
|
21
|
-
// SSR: default light
|
|
22
|
-
);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// src/InteractiveWrapper.tsx
|
|
26
|
-
import React2, { forwardRef, useState, useCallback, useMemo } from "react";
|
|
27
|
-
import { flatten, isWeb } from "@kbach/core";
|
|
28
|
-
function chain(original, extra) {
|
|
29
|
-
return (...args) => {
|
|
30
|
-
original?.(...args);
|
|
31
|
-
extra();
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
var InteractiveWrapper = forwardRef(
|
|
35
|
-
function InteractiveWrapper2({
|
|
36
|
-
Component,
|
|
37
|
-
resolvedStyle,
|
|
38
|
-
className,
|
|
39
|
-
style: styleProp,
|
|
40
|
-
onPressIn,
|
|
41
|
-
onPressOut,
|
|
42
|
-
onMouseEnter,
|
|
43
|
-
onMouseLeave,
|
|
44
|
-
onFocus,
|
|
45
|
-
onBlur,
|
|
46
|
-
...rest
|
|
47
|
-
}, ref) {
|
|
48
|
-
const isDark = useGlobalDarkMode();
|
|
49
|
-
const [pressed, setPressed] = useState(false);
|
|
50
|
-
const [hovered, setHovered] = useState(false);
|
|
51
|
-
const [focused, setFocused] = useState(false);
|
|
52
|
-
const handlePressIn = useCallback(chain(onPressIn, () => setPressed(true)), [onPressIn]);
|
|
53
|
-
const handlePressOut = useCallback(chain(onPressOut, () => setPressed(false)), [onPressOut]);
|
|
54
|
-
const handleMouseEnter = useCallback(chain(onMouseEnter, () => setHovered(true)), [onMouseEnter]);
|
|
55
|
-
const handleMouseLeave = useCallback(chain(onMouseLeave, () => setHovered(false)), [onMouseLeave]);
|
|
56
|
-
const handleFocus = useCallback(chain(onFocus, () => setFocused(true)), [onFocus]);
|
|
57
|
-
const handleBlur = useCallback(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
58
|
-
const computedStyle = useMemo(
|
|
59
|
-
() => flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused }),
|
|
60
|
-
[resolvedStyle, isDark, pressed, hovered, focused]
|
|
61
|
-
);
|
|
62
|
-
const finalStyle = styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
63
|
-
const { children, ...restWithoutChildren } = rest;
|
|
64
|
-
const componentProps = {
|
|
65
|
-
ref,
|
|
66
|
-
...restWithoutChildren,
|
|
67
|
-
style: finalStyle,
|
|
68
|
-
...isWeb && className ? { className } : {},
|
|
69
|
-
onPressIn: handlePressIn,
|
|
70
|
-
onPressOut: handlePressOut,
|
|
71
|
-
onMouseEnter: handleMouseEnter,
|
|
72
|
-
onMouseLeave: handleMouseLeave,
|
|
73
|
-
onFocus: handleFocus,
|
|
74
|
-
onBlur: handleBlur
|
|
75
|
-
};
|
|
76
|
-
return Array.isArray(children) ? React2.createElement(Component, componentProps, ...children) : React2.createElement(Component, componentProps, children);
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
|
|
80
|
-
|
|
81
|
-
export {
|
|
82
|
-
__require,
|
|
83
|
-
useGlobalDarkMode,
|
|
84
|
-
InteractiveWrapper
|
|
85
|
-
};
|