@kbach/react 0.1.6 → 0.2.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.
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-FUSJKUE7.mjs";
6
- import "./chunk-IZK5HMWK.mjs";
5
+ } from "./chunk-CNS23UB5.mjs";
6
+ import "./chunk-PYBA3DFG.mjs";
7
7
  export {
8
8
  Fragment,
9
9
  jsx,
package/package.json CHANGED
@@ -1,59 +1,56 @@
1
- {
2
- "name": "@kbach/react",
3
- "version": "0.1.6",
4
- "description": "React / React Native components and hooks for the Kbach framework",
5
- "source": "./src/index.ts",
6
- "main": "./dist/index.js",
7
- "module": "./dist/index.mjs",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "source": "./src/index.ts",
13
- "import": "./dist/index.mjs",
14
- "require": "./dist/index.js"
15
- },
16
- "./jsx-runtime": {
17
- "types": "./dist/jsx-runtime.d.ts",
18
- "source": "./src/jsx-runtime.tsx",
19
- "import": "./dist/jsx-runtime.mjs",
20
- "require": "./dist/jsx-runtime.js"
21
- },
22
- "./jsx-dev-runtime": {
23
- "types": "./dist/jsx-dev-runtime.d.ts",
24
- "source": "./src/jsx-dev-runtime.tsx",
25
- "import": "./dist/jsx-dev-runtime.mjs",
26
- "require": "./dist/jsx-dev-runtime.js"
27
- },
28
- "./types": {
29
- "types": "./types.d.ts"
30
- }
31
- },
32
- "scripts": {
33
- "build": "tsup src/index.ts src/jsx-runtime.tsx src/jsx-dev-runtime.tsx --format esm,cjs --dts --clean",
34
- "dev": "tsup src/index.ts src/jsx-runtime.tsx src/jsx-dev-runtime.tsx --format esm,cjs --dts --watch",
35
- "test": "vitest run --passWithNoTests",
36
- "lint": "tsc --noEmit"
37
- },
38
- "devDependencies": {
39
- "@kbach/core": "0.1.1",
40
- "@types/react": "^19.2.0",
41
- "tsup": "^8.0.0",
42
- "vitest": "^1.0.0"
43
- },
44
- "peerDependencies": {
45
- "@kbach/core": ">=0.1.1",
46
- "react": ">=17.0.0",
47
- "react-native": ">=0.70.0"
48
- },
49
- "peerDependenciesMeta": {
50
- "@kbach/core": { "optional": false },
51
- "react-native": {
52
- "optional": true
53
- }
54
- },
55
- "publishConfig": {
56
- "access": "public"
57
- },
58
- "files": ["dist"]
59
- }
1
+ {
2
+ "name": "@kbach/react",
3
+ "version": "0.2.0",
4
+ "description": "React / React Native components and hooks for the Kbach framework",
5
+ "source": "./src/index.ts",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.mjs",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "source": "./src/index.ts",
13
+ "import": "./dist/index.mjs",
14
+ "require": "./dist/index.js"
15
+ },
16
+ "./jsx-runtime": {
17
+ "types": "./dist/jsx-runtime.d.ts",
18
+ "source": "./src/jsx-runtime.tsx",
19
+ "import": "./dist/jsx-runtime.mjs",
20
+ "require": "./dist/jsx-runtime.js"
21
+ },
22
+ "./jsx-dev-runtime": {
23
+ "types": "./dist/jsx-dev-runtime.d.ts",
24
+ "source": "./src/jsx-dev-runtime.tsx",
25
+ "import": "./dist/jsx-dev-runtime.mjs",
26
+ "require": "./dist/jsx-dev-runtime.js"
27
+ },
28
+ "./types": {
29
+ "types": "./types.d.ts"
30
+ }
31
+ },
32
+ "scripts": {
33
+ "build": "tsup src/index.ts src/jsx-runtime.tsx src/jsx-dev-runtime.tsx --format esm,cjs --dts --clean",
34
+ "dev": "tsup src/index.ts src/jsx-runtime.tsx src/jsx-dev-runtime.tsx --format esm,cjs --dts --watch",
35
+ "test": "vitest run --passWithNoTests",
36
+ "lint": "tsc --noEmit"
37
+ },
38
+ "devDependencies": {
39
+ "@types/react": "^19.2.0",
40
+ "tsup": "^8.0.0",
41
+ "vitest": "^1.0.0"
42
+ },
43
+ "peerDependencies": {
44
+ "react": ">=17.0.0",
45
+ "react-native": ">=0.70.0"
46
+ },
47
+ "peerDependenciesMeta": {
48
+ "react-native": {
49
+ "optional": true
50
+ }
51
+ },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
55
+ "files": ["dist"]
56
+ }
@@ -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
- };