@kbach/react 0.3.9 → 0.3.11

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-SMSQ7JQV.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);
@@ -1134,14 +1134,15 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
1134
1134
  }
1135
1135
  var STANDALONE = {
1136
1136
  // Display
1137
- // On native, Views are flex containers by default — `display: 'flex'` is a no-op.
1137
+ // React Native only supports display:'flex'|'none'. Setting 'flex' explicitly is
1138
+ // a no-op normally, but is needed to re-show an element that was hidden via `hidden`.
1138
1139
  // `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
1139
- flex: isWeb ? { display: "flex" } : {},
1140
+ flex: { display: "flex" },
1140
1141
  block: isWeb ? { display: "block" } : null,
1141
1142
  "inline-block": isWeb ? { display: "inline-block" } : null,
1142
1143
  inline: isWeb ? { display: "inline" } : null,
1143
1144
  grid: isWeb ? { display: "grid" } : null,
1144
- "inline-flex": isWeb ? { display: "inline-flex" } : {},
1145
+ "inline-flex": { display: isWeb ? "inline-flex" : "flex" },
1145
1146
  "inline-grid": isWeb ? { display: "inline-grid" } : null,
1146
1147
  hidden: { display: "none" },
1147
1148
  contents: isWeb ? { display: "contents" } : null,
@@ -1533,7 +1534,7 @@ var RESOLVERS = {
1533
1534
  },
1534
1535
  // ── Flex ───────────────────────────────────────────────────────────────────
1535
1536
  flex: ({ value, isArbitrary }, { flex }) => {
1536
- if (!value) return isWeb ? { display: "flex" } : {};
1537
+ if (!value) return { display: "flex" };
1537
1538
  if (isArbitrary) {
1538
1539
  const v = parseFloat(value);
1539
1540
  return isNaN(v) ? null : { flex: v };
@@ -2317,13 +2318,45 @@ var NOOP_SUB = (_) => () => {
2317
2318
  };
2318
2319
  var ZERO_SNAP = () => 0;
2319
2320
  var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
2321
+ var _webListeners = null;
2322
+ var _webRaf = 0;
2323
+ function _webResizeHandler() {
2324
+ cancelAnimationFrame(_webRaf);
2325
+ _webRaf = requestAnimationFrame(() => {
2326
+ if (_webListeners) for (const cb of _webListeners) cb();
2327
+ });
2328
+ }
2329
+ function subscribeWebWidth(cb) {
2330
+ if (typeof window === "undefined") return () => {
2331
+ };
2332
+ if (!_webListeners) {
2333
+ _webListeners = /* @__PURE__ */ new Set();
2334
+ window.addEventListener("resize", _webResizeHandler);
2335
+ }
2336
+ _webListeners.add(cb);
2337
+ return () => {
2338
+ _webListeners.delete(cb);
2339
+ if (_webListeners.size === 0) {
2340
+ window.removeEventListener("resize", _webResizeHandler);
2341
+ cancelAnimationFrame(_webRaf);
2342
+ _webListeners = null;
2343
+ }
2344
+ };
2345
+ }
2346
+ function getWebWidth() {
2347
+ return typeof window !== "undefined" ? window.innerWidth : 0;
2348
+ }
2320
2349
  function useGlobalWidth() {
2321
- return useSyncExternalStore2(subscribeGlobalWidth, getGlobalWidth, ZERO_SNAP);
2350
+ return useSyncExternalStore2(
2351
+ isWeb ? subscribeWebWidth : subscribeGlobalWidth,
2352
+ isWeb ? getWebWidth : getGlobalWidth,
2353
+ ZERO_SNAP
2354
+ );
2322
2355
  }
2323
2356
  function useConditionalWidth(active) {
2324
2357
  return useSyncExternalStore2(
2325
- active ? subscribeGlobalWidth : NOOP_SUB,
2326
- active ? getGlobalWidth : ZERO_SNAP,
2358
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2359
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2327
2360
  ZERO_SNAP
2328
2361
  );
2329
2362
  }
package/dist/index.js CHANGED
@@ -1300,14 +1300,15 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
1300
1300
  }
1301
1301
  var STANDALONE = {
1302
1302
  // Display
1303
- // On native, Views are flex containers by default — `display: 'flex'` is a no-op.
1303
+ // React Native only supports display:'flex'|'none'. Setting 'flex' explicitly is
1304
+ // a no-op normally, but is needed to re-show an element that was hidden via `hidden`.
1304
1305
  // `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
1305
- flex: isWeb ? { display: "flex" } : {},
1306
+ flex: { display: "flex" },
1306
1307
  block: isWeb ? { display: "block" } : null,
1307
1308
  "inline-block": isWeb ? { display: "inline-block" } : null,
1308
1309
  inline: isWeb ? { display: "inline" } : null,
1309
1310
  grid: isWeb ? { display: "grid" } : null,
1310
- "inline-flex": isWeb ? { display: "inline-flex" } : {},
1311
+ "inline-flex": { display: isWeb ? "inline-flex" : "flex" },
1311
1312
  "inline-grid": isWeb ? { display: "inline-grid" } : null,
1312
1313
  hidden: { display: "none" },
1313
1314
  contents: isWeb ? { display: "contents" } : null,
@@ -1699,7 +1700,7 @@ var RESOLVERS = {
1699
1700
  },
1700
1701
  // ── Flex ───────────────────────────────────────────────────────────────────
1701
1702
  flex: ({ value, isArbitrary }, { flex }) => {
1702
- if (!value) return isWeb ? { display: "flex" } : {};
1703
+ if (!value) return { display: "flex" };
1703
1704
  if (isArbitrary) {
1704
1705
  const v = parseFloat(value);
1705
1706
  return isNaN(v) ? null : { flex: v };
@@ -2762,13 +2763,45 @@ var NOOP_SUB = (_) => () => {
2762
2763
  };
2763
2764
  var ZERO_SNAP = () => 0;
2764
2765
  var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
2766
+ var _webListeners = null;
2767
+ var _webRaf = 0;
2768
+ function _webResizeHandler() {
2769
+ cancelAnimationFrame(_webRaf);
2770
+ _webRaf = requestAnimationFrame(() => {
2771
+ if (_webListeners) for (const cb of _webListeners) cb();
2772
+ });
2773
+ }
2774
+ function subscribeWebWidth(cb) {
2775
+ if (typeof window === "undefined") return () => {
2776
+ };
2777
+ if (!_webListeners) {
2778
+ _webListeners = /* @__PURE__ */ new Set();
2779
+ window.addEventListener("resize", _webResizeHandler);
2780
+ }
2781
+ _webListeners.add(cb);
2782
+ return () => {
2783
+ _webListeners.delete(cb);
2784
+ if (_webListeners.size === 0) {
2785
+ window.removeEventListener("resize", _webResizeHandler);
2786
+ cancelAnimationFrame(_webRaf);
2787
+ _webListeners = null;
2788
+ }
2789
+ };
2790
+ }
2791
+ function getWebWidth() {
2792
+ return typeof window !== "undefined" ? window.innerWidth : 0;
2793
+ }
2765
2794
  function useGlobalWidth() {
2766
- return useSyncExternalStore(subscribeGlobalWidth, getGlobalWidth, ZERO_SNAP);
2795
+ return useSyncExternalStore(
2796
+ isWeb ? subscribeWebWidth : subscribeGlobalWidth,
2797
+ isWeb ? getWebWidth : getGlobalWidth,
2798
+ ZERO_SNAP
2799
+ );
2767
2800
  }
2768
2801
  function useConditionalWidth(active) {
2769
2802
  return useSyncExternalStore(
2770
- active ? subscribeGlobalWidth : NOOP_SUB,
2771
- active ? getGlobalWidth : ZERO_SNAP,
2803
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2804
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2772
2805
  ZERO_SNAP
2773
2806
  );
2774
2807
  }
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-SMSQ7JQV.mjs";
25
25
 
26
26
  // src/context.tsx
27
27
  import { createContext, useContext } from "react";
@@ -1203,14 +1203,15 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
1203
1203
  }
1204
1204
  var STANDALONE = {
1205
1205
  // Display
1206
- // On native, Views are flex containers by default — `display: 'flex'` is a no-op.
1206
+ // React Native only supports display:'flex'|'none'. Setting 'flex' explicitly is
1207
+ // a no-op normally, but is needed to re-show an element that was hidden via `hidden`.
1207
1208
  // `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
1208
- flex: isWeb ? { display: "flex" } : {},
1209
+ flex: { display: "flex" },
1209
1210
  block: isWeb ? { display: "block" } : null,
1210
1211
  "inline-block": isWeb ? { display: "inline-block" } : null,
1211
1212
  inline: isWeb ? { display: "inline" } : null,
1212
1213
  grid: isWeb ? { display: "grid" } : null,
1213
- "inline-flex": isWeb ? { display: "inline-flex" } : {},
1214
+ "inline-flex": { display: isWeb ? "inline-flex" : "flex" },
1214
1215
  "inline-grid": isWeb ? { display: "inline-grid" } : null,
1215
1216
  hidden: { display: "none" },
1216
1217
  contents: isWeb ? { display: "contents" } : null,
@@ -1602,7 +1603,7 @@ var RESOLVERS = {
1602
1603
  },
1603
1604
  // ── Flex ───────────────────────────────────────────────────────────────────
1604
1605
  flex: ({ value, isArbitrary }, { flex }) => {
1605
- if (!value) return isWeb ? { display: "flex" } : {};
1606
+ if (!value) return { display: "flex" };
1606
1607
  if (isArbitrary) {
1607
1608
  const v = parseFloat(value);
1608
1609
  return isNaN(v) ? null : { flex: v };
@@ -2307,10 +2308,38 @@ var NOOP_SUB = (_) => () => {
2307
2308
  };
2308
2309
  var ZERO_SNAP = () => 0;
2309
2310
  var EMPTY_BREAKPOINTS = /* @__PURE__ */ new Set();
2311
+ var _webListeners = null;
2312
+ var _webRaf = 0;
2313
+ function _webResizeHandler() {
2314
+ cancelAnimationFrame(_webRaf);
2315
+ _webRaf = requestAnimationFrame(() => {
2316
+ if (_webListeners) for (const cb of _webListeners) cb();
2317
+ });
2318
+ }
2319
+ function subscribeWebWidth(cb) {
2320
+ if (typeof window === "undefined") return () => {
2321
+ };
2322
+ if (!_webListeners) {
2323
+ _webListeners = /* @__PURE__ */ new Set();
2324
+ window.addEventListener("resize", _webResizeHandler);
2325
+ }
2326
+ _webListeners.add(cb);
2327
+ return () => {
2328
+ _webListeners.delete(cb);
2329
+ if (_webListeners.size === 0) {
2330
+ window.removeEventListener("resize", _webResizeHandler);
2331
+ cancelAnimationFrame(_webRaf);
2332
+ _webListeners = null;
2333
+ }
2334
+ };
2335
+ }
2336
+ function getWebWidth() {
2337
+ return typeof window !== "undefined" ? window.innerWidth : 0;
2338
+ }
2310
2339
  function useConditionalWidth(active) {
2311
2340
  return useSyncExternalStore2(
2312
- active ? subscribeGlobalWidth : NOOP_SUB,
2313
- active ? getGlobalWidth : ZERO_SNAP,
2341
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2342
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2314
2343
  ZERO_SNAP
2315
2344
  );
2316
2345
  }
@@ -2485,15 +2514,6 @@ function processElement(type, rawProps, key, isStaticChildren) {
2485
2514
  return makeElement(isStaticChildren, type, rawProps, key);
2486
2515
  }
2487
2516
  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
2517
  const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
2498
2518
  const { style: userStyle, ...passProps } = omitConsumed(rawProps);
2499
2519
  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-PIVTTJGI.mjs";
6
+ import "./chunk-SMSQ7JQV.mjs";
7
7
 
8
8
  // src/jsx-dev-runtime.tsx
9
9
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -1202,14 +1202,15 @@ function resolveFontSize(value, fontSizes, isArbitrary) {
1202
1202
  }
1203
1203
  var STANDALONE = {
1204
1204
  // Display
1205
- // On native, Views are flex containers by default — `display: 'flex'` is a no-op.
1205
+ // React Native only supports display:'flex'|'none'. Setting 'flex' explicitly is
1206
+ // a no-op normally, but is needed to re-show an element that was hidden via `hidden`.
1206
1207
  // `grid`, `inline-*`, `contents`, `flow-root` have no native equivalent.
1207
- flex: isWeb ? { display: "flex" } : {},
1208
+ flex: { display: "flex" },
1208
1209
  block: isWeb ? { display: "block" } : null,
1209
1210
  "inline-block": isWeb ? { display: "inline-block" } : null,
1210
1211
  inline: isWeb ? { display: "inline" } : null,
1211
1212
  grid: isWeb ? { display: "grid" } : null,
1212
- "inline-flex": isWeb ? { display: "inline-flex" } : {},
1213
+ "inline-flex": { display: isWeb ? "inline-flex" : "flex" },
1213
1214
  "inline-grid": isWeb ? { display: "inline-grid" } : null,
1214
1215
  hidden: { display: "none" },
1215
1216
  contents: isWeb ? { display: "contents" } : null,
@@ -1601,7 +1602,7 @@ var RESOLVERS = {
1601
1602
  },
1602
1603
  // ── Flex ───────────────────────────────────────────────────────────────────
1603
1604
  flex: ({ value, isArbitrary }, { flex }) => {
1604
- if (!value) return isWeb ? { display: "flex" } : {};
1605
+ if (!value) return { display: "flex" };
1605
1606
  if (isArbitrary) {
1606
1607
  const v = parseFloat(value);
1607
1608
  return isNaN(v) ? null : { flex: v };
@@ -2306,10 +2307,38 @@ var NOOP_SUB = (_) => () => {
2306
2307
  };
2307
2308
  var ZERO_SNAP = () => 0;
2308
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
+ }
2309
2338
  function useConditionalWidth(active) {
2310
2339
  return useSyncExternalStore2(
2311
- active ? subscribeGlobalWidth : NOOP_SUB,
2312
- active ? getGlobalWidth : ZERO_SNAP,
2340
+ active ? isWeb ? subscribeWebWidth : subscribeGlobalWidth : NOOP_SUB,
2341
+ active ? isWeb ? getWebWidth : getGlobalWidth : ZERO_SNAP,
2313
2342
  ZERO_SNAP
2314
2343
  );
2315
2344
  }
@@ -2484,15 +2513,6 @@ function processElement(type, rawProps, key, isStaticChildren) {
2484
2513
  return makeElement(isStaticChildren, type, rawProps, key);
2485
2514
  }
2486
2515
  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
2516
  const resolved = __kbachStyles ?? (classStr ? resolve(classStr, config.theme, config.darkMode) : {});
2497
2517
  const { style: userStyle, ...passProps } = omitConsumed(rawProps);
2498
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-PIVTTJGI.mjs";
6
+ import "./chunk-SMSQ7JQV.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.11",
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",