@kbach/react 0.5.56 → 0.5.58
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-JBV2R655.mjs → chunk-2HWRNTJG.mjs} +144 -53
- package/dist/{chunk-O4EKWQSX.mjs → chunk-EMSB47ES.mjs} +9 -5
- package/dist/{chunk-PESA3FMP.mjs → chunk-F5NQX5YO.mjs} +48 -34
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +218 -113
- package/dist/index.mjs +7 -6
- package/dist/jsx-dev-runtime.js +181 -70
- package/dist/jsx-dev-runtime.mjs +4 -4
- package/dist/jsx-runtime.js +177 -69
- package/dist/jsx-runtime.mjs +3 -3
- package/dist/{types-D-24rbXu.d.ts → types-BESBQANS.d.mts} +7 -2
- package/dist/{types-D-24rbXu.d.mts → types-BESBQANS.d.ts} +7 -2
- package/dist/vite-plugin.d.mts +8 -3
- package/dist/vite-plugin.d.ts +8 -3
- package/dist/vite-plugin.js +144 -55
- package/dist/vite-plugin.mjs +10 -6
- package/package.json +1 -1
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
isNative,
|
|
8
8
|
isWeb,
|
|
9
9
|
subscribeGlobalWidth
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-2HWRNTJG.mjs";
|
|
11
11
|
|
|
12
12
|
// src/core/darkModeStore.ts
|
|
13
13
|
var KEY = "__kbach_dark_store__";
|
|
14
14
|
function getStore() {
|
|
15
15
|
const g = globalThis;
|
|
16
16
|
if (!g[KEY]) {
|
|
17
|
-
g[KEY] = { isDark: false,
|
|
17
|
+
g[KEY] = { isDark: false, subscribers: /* @__PURE__ */ new Set() };
|
|
18
18
|
}
|
|
19
19
|
return g[KEY];
|
|
20
20
|
}
|
|
@@ -23,9 +23,8 @@ function syncGlobalDarkMode(isDark) {
|
|
|
23
23
|
}
|
|
24
24
|
function setGlobalDarkMode(isDark) {
|
|
25
25
|
const store = getStore();
|
|
26
|
+
if (store.isDark === isDark) return;
|
|
26
27
|
store.isDark = isDark;
|
|
27
|
-
if (store.lastNotified === isDark) return;
|
|
28
|
-
store.lastNotified = isDark;
|
|
29
28
|
for (const sub of store.subscribers) sub();
|
|
30
29
|
}
|
|
31
30
|
function getGlobalDarkMode() {
|
|
@@ -37,6 +36,22 @@ function subscribeGlobalDarkMode(callback) {
|
|
|
37
36
|
return () => store.subscribers.delete(callback);
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
// src/useGlobalDarkMode.ts
|
|
40
|
+
import React from "react";
|
|
41
|
+
var useSyncExternalStore = React.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
42
|
+
const [, forceUpdate] = React.useReducer((n) => n + 1, 0);
|
|
43
|
+
React.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
44
|
+
return getSnapshot();
|
|
45
|
+
};
|
|
46
|
+
function useGlobalDarkMode() {
|
|
47
|
+
return useSyncExternalStore(
|
|
48
|
+
subscribeGlobalDarkMode,
|
|
49
|
+
getGlobalDarkMode,
|
|
50
|
+
() => false
|
|
51
|
+
// SSR: default light
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
40
55
|
// src/web-substitute.ts
|
|
41
56
|
var _rnToHtml = {
|
|
42
57
|
View: "div",
|
|
@@ -73,8 +88,8 @@ function getWebTag(type, props) {
|
|
|
73
88
|
_cache.set(obj, null);
|
|
74
89
|
return null;
|
|
75
90
|
}
|
|
76
|
-
if (name === "TextInput"
|
|
77
|
-
const multiline = props.multiline === true || Number(props.numberOfLines) > 1;
|
|
91
|
+
if (name === "TextInput") {
|
|
92
|
+
const multiline = !!props && (props.multiline === true || Number(props.numberOfLines) > 1);
|
|
78
93
|
return multiline ? "textarea" : "input";
|
|
79
94
|
}
|
|
80
95
|
if (_cache.has(obj)) return _cache.get(obj);
|
|
@@ -111,8 +126,7 @@ var _rnOnlyProps = /* @__PURE__ */ new Set([
|
|
|
111
126
|
"shouldRasterizeIOS",
|
|
112
127
|
"focusable",
|
|
113
128
|
"hasTVPreferredFocus",
|
|
114
|
-
|
|
115
|
-
// RN and HTML values differ
|
|
129
|
+
// 'pointerEvents' is handled in transformToWebProps (mapped to CSS style)
|
|
116
130
|
// Text
|
|
117
131
|
"selectable",
|
|
118
132
|
"allowFontScaling",
|
|
@@ -138,7 +152,7 @@ var _rnOnlyProps = /* @__PURE__ */ new Set([
|
|
|
138
152
|
"showsVerticalScrollIndicator",
|
|
139
153
|
"showsHorizontalScrollIndicator",
|
|
140
154
|
"contentContainerStyle",
|
|
141
|
-
|
|
155
|
+
// 'horizontal' is handled in transformToWebProps (converted to CSS overflow-x).
|
|
142
156
|
"keyboardShouldPersistTaps",
|
|
143
157
|
"keyboardDismissMode",
|
|
144
158
|
"pagingEnabled",
|
|
@@ -222,6 +236,8 @@ function transformToWebProps(originalName, tag, props) {
|
|
|
222
236
|
const isPressable = _pressableNames.has(originalName);
|
|
223
237
|
const isTextInput = originalName === "TextInput";
|
|
224
238
|
const isImage = originalName === "Image" || originalName === "ImageBackground";
|
|
239
|
+
const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
|
|
240
|
+
let pendingStyle = null;
|
|
225
241
|
for (const [k, v] of Object.entries(props)) {
|
|
226
242
|
if (_rnOnlyProps.has(k)) continue;
|
|
227
243
|
if (k === "onPress") {
|
|
@@ -265,9 +281,19 @@ function transformToWebProps(originalName, tag, props) {
|
|
|
265
281
|
continue;
|
|
266
282
|
}
|
|
267
283
|
}
|
|
284
|
+
if (isScrollable && k === "horizontal") {
|
|
285
|
+
if (v) pendingStyle = { display: "flex", flexDirection: "row", overflowX: "auto" };
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
if (k === "pointerEvents") {
|
|
289
|
+
if (v === "none" || v === "auto") pendingStyle = { ...pendingStyle ?? {}, pointerEvents: v };
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
268
292
|
if (isImage) {
|
|
269
293
|
if (k === "source") {
|
|
270
|
-
if (
|
|
294
|
+
if (typeof v === "string") {
|
|
295
|
+
out.src = v;
|
|
296
|
+
} else if (v && typeof v === "object" && "uri" in v) {
|
|
271
297
|
out.src = v.uri;
|
|
272
298
|
if (v.headers) out["crossOrigin"] = "anonymous";
|
|
273
299
|
}
|
|
@@ -283,7 +309,7 @@ function transformToWebProps(originalName, tag, props) {
|
|
|
283
309
|
out.style = { ...existing, objectFit: v };
|
|
284
310
|
continue;
|
|
285
311
|
}
|
|
286
|
-
if (k === "
|
|
312
|
+
if (k === "defaultSource") continue;
|
|
287
313
|
}
|
|
288
314
|
if (k === "style") {
|
|
289
315
|
if (Array.isArray(v)) {
|
|
@@ -295,27 +321,14 @@ function transformToWebProps(originalName, tag, props) {
|
|
|
295
321
|
}
|
|
296
322
|
out[k] = v;
|
|
297
323
|
}
|
|
324
|
+
if (pendingStyle) {
|
|
325
|
+
out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
|
|
326
|
+
}
|
|
298
327
|
if (isPressable && !out.role) out.role = "button";
|
|
299
328
|
if (isImage && tag === "img" && out.alt == null) out.alt = "";
|
|
300
329
|
return out;
|
|
301
330
|
}
|
|
302
331
|
|
|
303
|
-
// src/useGlobalDarkMode.ts
|
|
304
|
-
import React from "react";
|
|
305
|
-
var useSyncExternalStore = React.useSyncExternalStore ?? function useSyncExternalStoreFallback(subscribe, getSnapshot, _getServerSnapshot) {
|
|
306
|
-
const [, forceUpdate] = React.useReducer((n) => n + 1, 0);
|
|
307
|
-
React.useEffect(() => subscribe(forceUpdate), [subscribe]);
|
|
308
|
-
return getSnapshot();
|
|
309
|
-
};
|
|
310
|
-
function useGlobalDarkMode() {
|
|
311
|
-
return useSyncExternalStore(
|
|
312
|
-
subscribeGlobalDarkMode,
|
|
313
|
-
getGlobalDarkMode,
|
|
314
|
-
() => false
|
|
315
|
-
// SSR: default light
|
|
316
|
-
);
|
|
317
|
-
}
|
|
318
|
-
|
|
319
332
|
// src/InteractiveWrapper.tsx
|
|
320
333
|
import React3, { forwardRef, useState, useCallback, useMemo } from "react";
|
|
321
334
|
|
|
@@ -436,10 +449,11 @@ var InteractiveWrapper = forwardRef(
|
|
|
436
449
|
const handleMouseLeave = useCallback(chain(onMouseLeave, () => setHovered(false)), [onMouseLeave]);
|
|
437
450
|
const handleFocus = useCallback(chain(onFocus, () => setFocused(true)), [onFocus]);
|
|
438
451
|
const handleBlur = useCallback(chain(onBlur, () => setFocused(false)), [onBlur]);
|
|
452
|
+
const { children, disabled, checked, ...restForComponent } = rest;
|
|
439
453
|
const computedStyle = useMemo(
|
|
440
454
|
() => {
|
|
441
455
|
if (isWeb) return {};
|
|
442
|
-
const s = flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!
|
|
456
|
+
const s = flatten(resolvedStyle, isDark, { pressed, hover: hovered, focus: focused, disabled: !!disabled, checked: !!checked }, breakpoints);
|
|
443
457
|
delete s.__divideX;
|
|
444
458
|
delete s.__divideY;
|
|
445
459
|
delete s.__divideColor;
|
|
@@ -470,20 +484,20 @@ var InteractiveWrapper = forwardRef(
|
|
|
470
484
|
}
|
|
471
485
|
return s;
|
|
472
486
|
},
|
|
473
|
-
[resolvedStyle, isDark, pressed, hovered, focused, width]
|
|
474
|
-
// eslint-disable-line react-hooks/exhaustive-deps
|
|
487
|
+
[resolvedStyle, isDark, pressed, hovered, focused, width, disabled, checked]
|
|
475
488
|
);
|
|
476
489
|
const skipComputedInline = isWeb || !isNative && typeof Component === "string";
|
|
477
490
|
const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
|
|
478
|
-
const { children, ...restWithoutChildren } = rest;
|
|
479
491
|
const componentProps = {
|
|
480
492
|
ref,
|
|
481
|
-
...
|
|
493
|
+
...restForComponent,
|
|
494
|
+
...disabled !== void 0 ? { disabled } : {},
|
|
495
|
+
...checked !== void 0 ? { checked } : {},
|
|
482
496
|
style: finalStyle,
|
|
483
497
|
...!isNative && className ? { className } : {},
|
|
484
498
|
// onPressIn / onPressOut are React Native-only.
|
|
485
499
|
// On web, onPointerDown/Up drive the pressed state instead (covers mouse + touch).
|
|
486
|
-
...!isNative ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
|
|
500
|
+
...!isNative ? { onPointerDown: handlePointerDown, onPointerUp: handlePointerUp, onPointerLeave: handlePointerLeave, onPointerCancel: handlePointerLeave } : { onPressIn: handlePressIn, onPressOut: handlePressOut },
|
|
487
501
|
onMouseEnter: handleMouseEnter,
|
|
488
502
|
onMouseLeave: handleMouseLeave,
|
|
489
503
|
onFocus: handleFocus,
|
|
@@ -497,6 +511,7 @@ InteractiveWrapper.displayName = "Kbach.InteractiveWrapper";
|
|
|
497
511
|
export {
|
|
498
512
|
syncGlobalDarkMode,
|
|
499
513
|
setGlobalDarkMode,
|
|
514
|
+
useGlobalDarkMode,
|
|
500
515
|
EMPTY_BREAKPOINTS,
|
|
501
516
|
useGlobalWidth,
|
|
502
517
|
useConditionalWidth,
|
|
@@ -506,6 +521,5 @@ export {
|
|
|
506
521
|
registerWebElement,
|
|
507
522
|
getWebTag,
|
|
508
523
|
transformToWebProps,
|
|
509
|
-
useGlobalDarkMode,
|
|
510
524
|
InteractiveWrapper
|
|
511
525
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ComponentType, ForwardRefExoticComponent } from 'react';
|
|
3
|
-
import { T as ThemeColors, a as ThemeConfig, P as ParsedClass, R as ResolvedStyle, S as StyleValue, F as FrameworkConfig, b as ResolvedConfig, c as ThemeMode } from './types-
|
|
4
|
-
export { d as PluginAPI } from './types-
|
|
3
|
+
import { T as ThemeColors, a as ThemeConfig, P as ParsedClass, R as ResolvedStyle, S as StyleValue, F as FrameworkConfig, b as ResolvedConfig, c as ThemeMode } from './types-BESBQANS.mjs';
|
|
4
|
+
export { d as PluginAPI } from './types-BESBQANS.mjs';
|
|
5
5
|
export { r as registerWebElement } from './web-substitute-CfpYFnE7.mjs';
|
|
6
6
|
|
|
7
7
|
declare const defaultColors: ThemeColors;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default, { ReactNode, ComponentType, ForwardRefExoticComponent } from 'react';
|
|
3
|
-
import { T as ThemeColors, a as ThemeConfig, P as ParsedClass, R as ResolvedStyle, S as StyleValue, F as FrameworkConfig, b as ResolvedConfig, c as ThemeMode } from './types-
|
|
4
|
-
export { d as PluginAPI } from './types-
|
|
3
|
+
import { T as ThemeColors, a as ThemeConfig, P as ParsedClass, R as ResolvedStyle, S as StyleValue, F as FrameworkConfig, b as ResolvedConfig, c as ThemeMode } from './types-BESBQANS.js';
|
|
4
|
+
export { d as PluginAPI } from './types-BESBQANS.js';
|
|
5
5
|
export { r as registerWebElement } from './web-substitute-CfpYFnE7.js';
|
|
6
6
|
|
|
7
7
|
declare const defaultColors: ThemeColors;
|