@kbach/react 0.3.6 → 0.3.8

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.
@@ -8,7 +8,7 @@ import {
8
8
  resolve,
9
9
  useConditionalWidth,
10
10
  useGlobalDarkMode
11
- } from "./chunk-UFSME6UC.mjs";
11
+ } from "./chunk-WYY3PRRC.mjs";
12
12
 
13
13
  // src/jsx-runtime.tsx
14
14
  import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
@@ -28,7 +28,7 @@ function hasResponsiveBuckets(resolved) {
28
28
  var DarkWrapper = React.forwardRef(
29
29
  function DarkWrapper2({ Component, resolvedStyle, style: styleProp, children, ...rest }, ref) {
30
30
  const isDark = useGlobalDarkMode();
31
- const needsWidth = !isWeb && hasResponsiveBuckets(resolvedStyle);
31
+ const needsWidth = hasResponsiveBuckets(resolvedStyle);
32
32
  const width = useConditionalWidth(needsWidth);
33
33
  const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
34
34
  const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
@@ -507,8 +507,8 @@ var defaultTheme = {
507
507
  }
508
508
  },
509
509
  screens: {
510
- sm: 390,
511
- // large phones (iPhone 12+, most Android flagships)
510
+ sm: 360,
511
+ // phones (virtually all modern devices)
512
512
  md: 768,
513
513
  // tablets (iPad and up)
514
514
  lg: 1024,
@@ -2362,7 +2362,7 @@ var InteractiveWrapper = forwardRef(
2362
2362
  ...rest
2363
2363
  }, ref) {
2364
2364
  const isDark = useGlobalDarkMode();
2365
- const needsWidth = !isWeb && hasResponsiveBuckets(resolvedStyle);
2365
+ const needsWidth = hasResponsiveBuckets(resolvedStyle);
2366
2366
  const width = useConditionalWidth(needsWidth);
2367
2367
  const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
2368
2368
  const [pressed, setPressed] = useState(false);
package/dist/index.js CHANGED
@@ -637,8 +637,8 @@ var defaultTheme = {
637
637
  }
638
638
  },
639
639
  screens: {
640
- sm: 390,
641
- // large phones (iPhone 12+, most Android flagships)
640
+ sm: 360,
641
+ // phones (virtually all modern devices)
642
642
  md: 768,
643
643
  // tablets (iPad and up)
644
644
  lg: 1024,
@@ -2463,6 +2463,9 @@ function ThemeProvider({
2463
2463
  const effectiveWidth = windowWidthProp ?? (isWeb ? webWidth : 0);
2464
2464
  syncGlobalWidth(effectiveWidth);
2465
2465
  syncGlobalScreens(resolvedConfig.theme.screens);
2466
+ (0, import_react3.useEffect)(() => {
2467
+ setGlobalWidth(effectiveWidth);
2468
+ }, [effectiveWidth]);
2466
2469
  (0, import_react3.useEffect)(() => {
2467
2470
  if (!isWeb || typeof window === "undefined") return;
2468
2471
  let raf = 0;
@@ -2776,7 +2779,7 @@ function useConditionalWidth(active) {
2776
2779
  function useStyles(classString, state = {}) {
2777
2780
  const { isDark, config } = useTheme();
2778
2781
  const width = useGlobalWidth();
2779
- const breakpoints = isWeb ? EMPTY_BREAKPOINTS : getActiveBreakpoints(width);
2782
+ const breakpoints = getActiveBreakpoints(width);
2780
2783
  const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
2781
2784
  return (0, import_react7.useMemo)(() => {
2782
2785
  const resolved = resolve(normalised, config.theme, config.darkMode);
@@ -2863,7 +2866,7 @@ var InteractiveWrapper = (0, import_react9.forwardRef)(
2863
2866
  ...rest
2864
2867
  }, ref) {
2865
2868
  const isDark = useGlobalDarkMode();
2866
- const needsWidth = !isWeb && hasResponsiveBuckets(resolvedStyle);
2869
+ const needsWidth = hasResponsiveBuckets(resolvedStyle);
2867
2870
  const width = useConditionalWidth(needsWidth);
2868
2871
  const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
2869
2872
  const [pressed, setPressed] = (0, import_react9.useState)(false);
package/dist/index.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  import {
2
- EMPTY_BREAKPOINTS,
3
2
  InteractiveWrapper,
4
3
  __require,
5
4
  buildConfig,
@@ -22,7 +21,7 @@ import {
22
21
  updateConfig,
23
22
  useGlobalDarkMode,
24
23
  useGlobalWidth
25
- } from "./chunk-UFSME6UC.mjs";
24
+ } from "./chunk-WYY3PRRC.mjs";
26
25
 
27
26
  // src/context.tsx
28
27
  import { createContext, useContext } from "react";
@@ -148,6 +147,9 @@ function ThemeProvider({
148
147
  const effectiveWidth = windowWidthProp ?? (isWeb ? webWidth : 0);
149
148
  syncGlobalWidth(effectiveWidth);
150
149
  syncGlobalScreens(resolvedConfig.theme.screens);
150
+ useEffect(() => {
151
+ setGlobalWidth(effectiveWidth);
152
+ }, [effectiveWidth]);
151
153
  useEffect(() => {
152
154
  if (!isWeb || typeof window === "undefined") return;
153
155
  let raf = 0;
@@ -442,7 +444,7 @@ import { useMemo as useMemo4 } from "react";
442
444
  function useStyles(classString, state = {}) {
443
445
  const { isDark, config } = useTheme();
444
446
  const width = useGlobalWidth();
445
- const breakpoints = isWeb ? EMPTY_BREAKPOINTS : getActiveBreakpoints(width);
447
+ const breakpoints = getActiveBreakpoints(width);
446
448
  const normalised = Array.isArray(classString) ? classString.join(" ") : classString;
447
449
  return useMemo4(() => {
448
450
  const resolved = resolve(normalised, config.theme, config.darkMode);
@@ -540,8 +540,8 @@ var defaultTheme = {
540
540
  }
541
541
  },
542
542
  screens: {
543
- sm: 390,
544
- // large phones (iPhone 12+, most Android flagships)
543
+ sm: 360,
544
+ // phones (virtually all modern devices)
545
545
  md: 768,
546
546
  // tablets (iPad and up)
547
547
  lg: 1024,
@@ -2349,7 +2349,7 @@ var InteractiveWrapper = (0, import_react3.forwardRef)(
2349
2349
  ...rest
2350
2350
  }, ref) {
2351
2351
  const isDark = useGlobalDarkMode();
2352
- const needsWidth = !isWeb && hasResponsiveBuckets(resolvedStyle);
2352
+ const needsWidth = hasResponsiveBuckets(resolvedStyle);
2353
2353
  const width = useConditionalWidth(needsWidth);
2354
2354
  const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
2355
2355
  const [pressed, setPressed] = (0, import_react3.useState)(false);
@@ -2400,7 +2400,7 @@ function hasResponsiveBuckets2(resolved) {
2400
2400
  var DarkWrapper = import_react4.default.forwardRef(
2401
2401
  function DarkWrapper2({ Component, resolvedStyle, style: styleProp, children, ...rest }, ref) {
2402
2402
  const isDark = useGlobalDarkMode();
2403
- const needsWidth = !isWeb && hasResponsiveBuckets2(resolvedStyle);
2403
+ const needsWidth = hasResponsiveBuckets2(resolvedStyle);
2404
2404
  const width = useConditionalWidth(needsWidth);
2405
2405
  const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
2406
2406
  const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-ALKTUEAA.mjs";
6
- import "./chunk-UFSME6UC.mjs";
5
+ } from "./chunk-H5232HHF.mjs";
6
+ import "./chunk-WYY3PRRC.mjs";
7
7
 
8
8
  // src/jsx-dev-runtime.tsx
9
9
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -539,8 +539,8 @@ var defaultTheme = {
539
539
  }
540
540
  },
541
541
  screens: {
542
- sm: 390,
543
- // large phones (iPhone 12+, most Android flagships)
542
+ sm: 360,
543
+ // phones (virtually all modern devices)
544
544
  md: 768,
545
545
  // tablets (iPad and up)
546
546
  lg: 1024,
@@ -2348,7 +2348,7 @@ var InteractiveWrapper = (0, import_react3.forwardRef)(
2348
2348
  ...rest
2349
2349
  }, ref) {
2350
2350
  const isDark = useGlobalDarkMode();
2351
- const needsWidth = !isWeb && hasResponsiveBuckets(resolvedStyle);
2351
+ const needsWidth = hasResponsiveBuckets(resolvedStyle);
2352
2352
  const width = useConditionalWidth(needsWidth);
2353
2353
  const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
2354
2354
  const [pressed, setPressed] = (0, import_react3.useState)(false);
@@ -2399,7 +2399,7 @@ function hasResponsiveBuckets2(resolved) {
2399
2399
  var DarkWrapper = import_react4.default.forwardRef(
2400
2400
  function DarkWrapper2({ Component, resolvedStyle, style: styleProp, children, ...rest }, ref) {
2401
2401
  const isDark = useGlobalDarkMode();
2402
- const needsWidth = !isWeb && hasResponsiveBuckets2(resolvedStyle);
2402
+ const needsWidth = hasResponsiveBuckets2(resolvedStyle);
2403
2403
  const width = useConditionalWidth(needsWidth);
2404
2404
  const breakpoints = needsWidth ? getActiveBreakpoints(width) : EMPTY_BREAKPOINTS;
2405
2405
  const computedStyle = flatten(resolvedStyle, isDark, {}, breakpoints);
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-ALKTUEAA.mjs";
6
- import "./chunk-UFSME6UC.mjs";
5
+ } from "./chunk-H5232HHF.mjs";
6
+ import "./chunk-WYY3PRRC.mjs";
7
7
  export {
8
8
  Fragment,
9
9
  jsx,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
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",