@kbach/react 0.3.9 → 0.3.10

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-UG3UVDJA.mjs";
11
+ } from "./chunk-LZYPVC5K.mjs";
12
12
 
13
13
  // src/jsx-runtime.tsx
14
14
  import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
@@ -115,15 +115,6 @@ function processElement(type, rawProps, key, isStaticChildren) {
115
115
  return makeElement(isStaticChildren, type, rawProps, key);
116
116
  }
117
117
  const config = getConfig();
118
- if (isWeb && classStr) {
119
- resolve(classStr, config.theme, config.darkMode);
120
- const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
121
- return makeElement(isStaticChildren, type, {
122
- ...passProps2,
123
- className: classStr,
124
- ...userStyle2 !== void 0 ? { style: userStyle2 } : {}
125
- }, key);
126
- }
127
118
  const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
128
119
  const { style: userStyle, ...passProps } = omitConsumed(rawProps);
129
120
  const { interactive, modeOrResponsive } = bucketMods(resolved);
@@ -2317,13 +2317,45 @@ var NOOP_SUB = (_) => () => {
2317
2317
  };
2318
2318
  var ZERO_SNAP = () => 0;
2319
2319
  var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
2320
+ var _webListeners = null;
2321
+ var _webRaf = 0;
2322
+ function _webResizeHandler() {
2323
+ cancelAnimationFrame(_webRaf);
2324
+ _webRaf = requestAnimationFrame(() => {
2325
+ if (_webListeners) for (const cb of _webListeners) cb();
2326
+ });
2327
+ }
2328
+ function subscribeWebWidth(cb) {
2329
+ if (typeof window === "undefined") return () => {
2330
+ };
2331
+ if (!_webListeners) {
2332
+ _webListeners = /* @__PURE__ */ new Set();
2333
+ window.addEventListener("resize", _webResizeHandler);
2334
+ }
2335
+ _webListeners.add(cb);
2336
+ return () => {
2337
+ _webListeners.delete(cb);
2338
+ if (_webListeners.size === 0) {
2339
+ window.removeEventListener("resize", _webResizeHandler);
2340
+ cancelAnimationFrame(_webRaf);
2341
+ _webListeners = null;
2342
+ }
2343
+ };
2344
+ }
2345
+ function getWebWidth() {
2346
+ return typeof window !== "undefined" ? window.innerWidth : 0;
2347
+ }
2320
2348
  function useGlobalWidth() {
2321
- return useSyncExternalStore2(subscribeGlobalWidth, getGlobalWidth, ZERO_SNAP);
2349
+ return useSyncExternalStore2(
2350
+ isWeb ? subscribeWebWidth : subscribeGlobalWidth,
2351
+ isWeb ? getWebWidth : getGlobalWidth,
2352
+ ZERO_SNAP
2353
+ );
2322
2354
  }
2323
2355
  function useConditionalWidth(active) {
2324
2356
  return useSyncExternalStore2(
2325
- active ? subscribeGlobalWidth : NOOP_SUB,
2326
- active ? getGlobalWidth : ZERO_SNAP,
2357
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2358
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2327
2359
  ZERO_SNAP
2328
2360
  );
2329
2361
  }
package/dist/index.js CHANGED
@@ -2762,13 +2762,45 @@ var NOOP_SUB = (_) => () => {
2762
2762
  };
2763
2763
  var ZERO_SNAP = () => 0;
2764
2764
  var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
2765
+ var _webListeners = null;
2766
+ var _webRaf = 0;
2767
+ function _webResizeHandler() {
2768
+ cancelAnimationFrame(_webRaf);
2769
+ _webRaf = requestAnimationFrame(() => {
2770
+ if (_webListeners) for (const cb of _webListeners) cb();
2771
+ });
2772
+ }
2773
+ function subscribeWebWidth(cb) {
2774
+ if (typeof window === "undefined") return () => {
2775
+ };
2776
+ if (!_webListeners) {
2777
+ _webListeners = /* @__PURE__ */ new Set();
2778
+ window.addEventListener("resize", _webResizeHandler);
2779
+ }
2780
+ _webListeners.add(cb);
2781
+ return () => {
2782
+ _webListeners.delete(cb);
2783
+ if (_webListeners.size === 0) {
2784
+ window.removeEventListener("resize", _webResizeHandler);
2785
+ cancelAnimationFrame(_webRaf);
2786
+ _webListeners = null;
2787
+ }
2788
+ };
2789
+ }
2790
+ function getWebWidth() {
2791
+ return typeof window !== "undefined" ? window.innerWidth : 0;
2792
+ }
2765
2793
  function useGlobalWidth() {
2766
- return useSyncExternalStore(subscribeGlobalWidth, getGlobalWidth, ZERO_SNAP);
2794
+ return useSyncExternalStore(
2795
+ isWeb ? subscribeWebWidth : subscribeGlobalWidth,
2796
+ isWeb ? getWebWidth : getGlobalWidth,
2797
+ ZERO_SNAP
2798
+ );
2767
2799
  }
2768
2800
  function useConditionalWidth(active) {
2769
2801
  return useSyncExternalStore(
2770
- active ? subscribeGlobalWidth : NOOP_SUB,
2771
- active ? getGlobalWidth : ZERO_SNAP,
2802
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2803
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2772
2804
  ZERO_SNAP
2773
2805
  );
2774
2806
  }
package/dist/index.mjs CHANGED
@@ -21,7 +21,7 @@ import {
21
21
  updateConfig,
22
22
  useGlobalDarkMode,
23
23
  useGlobalWidth
24
- } from "./chunk-UG3UVDJA.mjs";
24
+ } from "./chunk-LZYPVC5K.mjs";
25
25
 
26
26
  // src/context.tsx
27
27
  import { createContext, useContext } from "react";
@@ -2307,10 +2307,38 @@ var NOOP_SUB = (_) => () => {
2307
2307
  };
2308
2308
  var ZERO_SNAP = () => 0;
2309
2309
  var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
2310
+ var _webListeners = null;
2311
+ var _webRaf = 0;
2312
+ function _webResizeHandler() {
2313
+ cancelAnimationFrame(_webRaf);
2314
+ _webRaf = requestAnimationFrame(() => {
2315
+ if (_webListeners) for (const cb of _webListeners) cb();
2316
+ });
2317
+ }
2318
+ function subscribeWebWidth(cb) {
2319
+ if (typeof window === "undefined") return () => {
2320
+ };
2321
+ if (!_webListeners) {
2322
+ _webListeners = /* @__PURE__ */ new Set();
2323
+ window.addEventListener("resize", _webResizeHandler);
2324
+ }
2325
+ _webListeners.add(cb);
2326
+ return () => {
2327
+ _webListeners.delete(cb);
2328
+ if (_webListeners.size === 0) {
2329
+ window.removeEventListener("resize", _webResizeHandler);
2330
+ cancelAnimationFrame(_webRaf);
2331
+ _webListeners = null;
2332
+ }
2333
+ };
2334
+ }
2335
+ function getWebWidth() {
2336
+ return typeof window !== "undefined" ? window.innerWidth : 0;
2337
+ }
2310
2338
  function useConditionalWidth(active) {
2311
2339
  return useSyncExternalStore2(
2312
- active ? subscribeGlobalWidth : NOOP_SUB,
2313
- active ? getGlobalWidth : ZERO_SNAP,
2340
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2341
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2314
2342
  ZERO_SNAP
2315
2343
  );
2316
2344
  }
@@ -2485,15 +2513,6 @@ function processElement(type, rawProps, key, isStaticChildren) {
2485
2513
  return makeElement(isStaticChildren, type, rawProps, key);
2486
2514
  }
2487
2515
  const config = getConfig();
2488
- if (isWeb && classStr) {
2489
- resolve(classStr, config.theme, config.darkMode);
2490
- const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
2491
- return makeElement(isStaticChildren, type, {
2492
- ...passProps2,
2493
- className: classStr,
2494
- ...userStyle2 !== void 0 ? { style: userStyle2 } : {}
2495
- }, key);
2496
- }
2497
2516
  const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
2498
2517
  const { style: userStyle, ...passProps } = omitConsumed(rawProps);
2499
2518
  const { interactive, modeOrResponsive } = bucketMods(resolved);
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-HDKCXMOY.mjs";
6
- import "./chunk-UG3UVDJA.mjs";
5
+ } from "./chunk-3AMSZMOL.mjs";
6
+ import "./chunk-LZYPVC5K.mjs";
7
7
 
8
8
  // src/jsx-dev-runtime.tsx
9
9
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -2306,10 +2306,38 @@ var NOOP_SUB = (_) => () => {
2306
2306
  };
2307
2307
  var ZERO_SNAP = () => 0;
2308
2308
  var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
2309
+ var _webListeners = null;
2310
+ var _webRaf = 0;
2311
+ function _webResizeHandler() {
2312
+ cancelAnimationFrame(_webRaf);
2313
+ _webRaf = requestAnimationFrame(() => {
2314
+ if (_webListeners) for (const cb of _webListeners) cb();
2315
+ });
2316
+ }
2317
+ function subscribeWebWidth(cb) {
2318
+ if (typeof window === "undefined") return () => {
2319
+ };
2320
+ if (!_webListeners) {
2321
+ _webListeners = /* @__PURE__ */ new Set();
2322
+ window.addEventListener("resize", _webResizeHandler);
2323
+ }
2324
+ _webListeners.add(cb);
2325
+ return () => {
2326
+ _webListeners.delete(cb);
2327
+ if (_webListeners.size === 0) {
2328
+ window.removeEventListener("resize", _webResizeHandler);
2329
+ cancelAnimationFrame(_webRaf);
2330
+ _webListeners = null;
2331
+ }
2332
+ };
2333
+ }
2334
+ function getWebWidth() {
2335
+ return typeof window !== "undefined" ? window.innerWidth : 0;
2336
+ }
2309
2337
  function useConditionalWidth(active) {
2310
2338
  return useSyncExternalStore2(
2311
- active ? subscribeGlobalWidth : NOOP_SUB,
2312
- active ? getGlobalWidth : ZERO_SNAP,
2339
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2340
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2313
2341
  ZERO_SNAP
2314
2342
  );
2315
2343
  }
@@ -2484,15 +2512,6 @@ function processElement(type, rawProps, key, isStaticChildren) {
2484
2512
  return makeElement(isStaticChildren, type, rawProps, key);
2485
2513
  }
2486
2514
  const config = getConfig();
2487
- if (isWeb && classStr) {
2488
- resolve(classStr, config.theme, config.darkMode);
2489
- const { style: userStyle2, ...passProps2 } = omitConsumed(rawProps);
2490
- return makeElement(isStaticChildren, type, {
2491
- ...passProps2,
2492
- className: classStr,
2493
- ...userStyle2 !== void 0 ? { style: userStyle2 } : {}
2494
- }, key);
2495
- }
2496
2515
  const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
2497
2516
  const { style: userStyle, ...passProps } = omitConsumed(rawProps);
2498
2517
  const { interactive, modeOrResponsive } = bucketMods(resolved);
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-HDKCXMOY.mjs";
6
- import "./chunk-UG3UVDJA.mjs";
5
+ } from "./chunk-3AMSZMOL.mjs";
6
+ import "./chunk-LZYPVC5K.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.9",
3
+ "version": "0.3.10",
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",