@kbach/react 0.2.7 → 0.2.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.
@@ -1797,7 +1797,10 @@ function getStyleEl() {
1797
1797
  function injectRule(rule) {
1798
1798
  if (_injectedRules.has(rule)) return;
1799
1799
  _injectedRules.add(rule);
1800
- getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1800
+ try {
1801
+ getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1802
+ } catch {
1803
+ }
1801
1804
  }
1802
1805
  function injectClassRule(cls, bucketKey, styles, darkMode) {
1803
1806
  const cssDecls = styleValueToCSS(styles);
@@ -1826,8 +1829,41 @@ function injectClassRule(cls, bucketKey, styles, darkMode) {
1826
1829
  }
1827
1830
  injectRule(rule);
1828
1831
  }
1832
+ var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
1833
+ "shadowColor",
1834
+ "shadowOffset",
1835
+ "shadowOpacity",
1836
+ "shadowRadius",
1837
+ "elevation",
1838
+ "includeFontPadding",
1839
+ "textAlignVertical",
1840
+ "writingDirection"
1841
+ ]);
1842
+ var CSS_UNITLESS = /* @__PURE__ */ new Set([
1843
+ "opacity",
1844
+ "fontWeight",
1845
+ "flex",
1846
+ "flexGrow",
1847
+ "flexShrink",
1848
+ "order",
1849
+ "zIndex",
1850
+ "aspectRatio",
1851
+ "columnCount",
1852
+ "lineHeight"
1853
+ ]);
1829
1854
  function styleValueToCSS(styles) {
1830
- return Object.entries(styles).filter(([, v]) => v !== void 0 && v !== null && typeof v !== "object").map(([prop, val]) => `${camelToKebab(prop)}: ${val}`).join("; ");
1855
+ return Object.entries(styles).filter(
1856
+ ([prop, v]) => v !== void 0 && v !== null && typeof v !== "object" && !RN_ONLY_PROPS.has(prop)
1857
+ ).map(([prop, val]) => {
1858
+ const cssProp = camelToKebab(prop);
1859
+ let cssVal;
1860
+ if (typeof val === "number") {
1861
+ cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
1862
+ } else {
1863
+ cssVal = String(val);
1864
+ }
1865
+ return `${cssProp}: ${cssVal}`;
1866
+ }).join("; ");
1831
1867
  }
1832
1868
  function camelToKebab(str) {
1833
1869
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -5,7 +5,7 @@ import {
5
5
  isWeb,
6
6
  resolve,
7
7
  useGlobalDarkMode
8
- } from "./chunk-LYGD2GSW.mjs";
8
+ } from "./chunk-GN4JPJHC.mjs";
9
9
 
10
10
  // src/jsx-runtime.tsx
11
11
  import { jsx as _jsx, jsxs as _jsxs, Fragment } from "react/jsx-runtime";
package/dist/index.js CHANGED
@@ -1861,7 +1861,10 @@ function getStyleEl() {
1861
1861
  function injectRule(rule) {
1862
1862
  if (_injectedRules.has(rule)) return;
1863
1863
  _injectedRules.add(rule);
1864
- getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1864
+ try {
1865
+ getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1866
+ } catch {
1867
+ }
1865
1868
  }
1866
1869
  function injectClassRule(cls, bucketKey, styles, darkMode) {
1867
1870
  const cssDecls = styleValueToCSS(styles);
@@ -1890,8 +1893,41 @@ function injectClassRule(cls, bucketKey, styles, darkMode) {
1890
1893
  }
1891
1894
  injectRule(rule);
1892
1895
  }
1896
+ var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
1897
+ "shadowColor",
1898
+ "shadowOffset",
1899
+ "shadowOpacity",
1900
+ "shadowRadius",
1901
+ "elevation",
1902
+ "includeFontPadding",
1903
+ "textAlignVertical",
1904
+ "writingDirection"
1905
+ ]);
1906
+ var CSS_UNITLESS = /* @__PURE__ */ new Set([
1907
+ "opacity",
1908
+ "fontWeight",
1909
+ "flex",
1910
+ "flexGrow",
1911
+ "flexShrink",
1912
+ "order",
1913
+ "zIndex",
1914
+ "aspectRatio",
1915
+ "columnCount",
1916
+ "lineHeight"
1917
+ ]);
1893
1918
  function styleValueToCSS(styles) {
1894
- return Object.entries(styles).filter(([, v]) => v !== void 0 && v !== null && typeof v !== "object").map(([prop, val]) => `${camelToKebab(prop)}: ${val}`).join("; ");
1919
+ return Object.entries(styles).filter(
1920
+ ([prop, v]) => v !== void 0 && v !== null && typeof v !== "object" && !RN_ONLY_PROPS.has(prop)
1921
+ ).map(([prop, val]) => {
1922
+ const cssProp = camelToKebab(prop);
1923
+ let cssVal;
1924
+ if (typeof val === "number") {
1925
+ cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
1926
+ } else {
1927
+ cssVal = String(val);
1928
+ }
1929
+ return `${cssProp}: ${cssVal}`;
1930
+ }).join("; ");
1895
1931
  }
1896
1932
  function camelToKebab(str) {
1897
1933
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
package/dist/index.mjs CHANGED
@@ -15,7 +15,7 @@ import {
15
15
  syncGlobalDarkMode,
16
16
  updateConfig,
17
17
  useGlobalDarkMode
18
- } from "./chunk-LYGD2GSW.mjs";
18
+ } from "./chunk-GN4JPJHC.mjs";
19
19
 
20
20
  // src/context.tsx
21
21
  import { createContext, useContext } from "react";
@@ -1830,7 +1830,10 @@ function getStyleEl() {
1830
1830
  function injectRule(rule) {
1831
1831
  if (_injectedRules.has(rule)) return;
1832
1832
  _injectedRules.add(rule);
1833
- getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1833
+ try {
1834
+ getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1835
+ } catch {
1836
+ }
1834
1837
  }
1835
1838
  function injectClassRule(cls, bucketKey, styles, darkMode) {
1836
1839
  const cssDecls = styleValueToCSS(styles);
@@ -1859,8 +1862,41 @@ function injectClassRule(cls, bucketKey, styles, darkMode) {
1859
1862
  }
1860
1863
  injectRule(rule);
1861
1864
  }
1865
+ var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
1866
+ "shadowColor",
1867
+ "shadowOffset",
1868
+ "shadowOpacity",
1869
+ "shadowRadius",
1870
+ "elevation",
1871
+ "includeFontPadding",
1872
+ "textAlignVertical",
1873
+ "writingDirection"
1874
+ ]);
1875
+ var CSS_UNITLESS = /* @__PURE__ */ new Set([
1876
+ "opacity",
1877
+ "fontWeight",
1878
+ "flex",
1879
+ "flexGrow",
1880
+ "flexShrink",
1881
+ "order",
1882
+ "zIndex",
1883
+ "aspectRatio",
1884
+ "columnCount",
1885
+ "lineHeight"
1886
+ ]);
1862
1887
  function styleValueToCSS(styles) {
1863
- return Object.entries(styles).filter(([, v]) => v !== void 0 && v !== null && typeof v !== "object").map(([prop, val]) => `${camelToKebab(prop)}: ${val}`).join("; ");
1888
+ return Object.entries(styles).filter(
1889
+ ([prop, v]) => v !== void 0 && v !== null && typeof v !== "object" && !RN_ONLY_PROPS.has(prop)
1890
+ ).map(([prop, val]) => {
1891
+ const cssProp = camelToKebab(prop);
1892
+ let cssVal;
1893
+ if (typeof val === "number") {
1894
+ cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
1895
+ } else {
1896
+ cssVal = String(val);
1897
+ }
1898
+ return `${cssProp}: ${cssVal}`;
1899
+ }).join("; ");
1864
1900
  }
1865
1901
  function camelToKebab(str) {
1866
1902
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-QMJ4XUJA.mjs";
6
- import "./chunk-LYGD2GSW.mjs";
5
+ } from "./chunk-YDKLJFFY.mjs";
6
+ import "./chunk-GN4JPJHC.mjs";
7
7
 
8
8
  // src/jsx-dev-runtime.tsx
9
9
  function jsxDEV(type, props, key, isStaticChildren, _source, _self) {
@@ -1829,7 +1829,10 @@ function getStyleEl() {
1829
1829
  function injectRule(rule) {
1830
1830
  if (_injectedRules.has(rule)) return;
1831
1831
  _injectedRules.add(rule);
1832
- getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1832
+ try {
1833
+ getStyleEl().sheet?.insertRule(rule, getStyleEl().sheet.cssRules.length);
1834
+ } catch {
1835
+ }
1833
1836
  }
1834
1837
  function injectClassRule(cls, bucketKey, styles, darkMode) {
1835
1838
  const cssDecls = styleValueToCSS(styles);
@@ -1858,8 +1861,41 @@ function injectClassRule(cls, bucketKey, styles, darkMode) {
1858
1861
  }
1859
1862
  injectRule(rule);
1860
1863
  }
1864
+ var RN_ONLY_PROPS = /* @__PURE__ */ new Set([
1865
+ "shadowColor",
1866
+ "shadowOffset",
1867
+ "shadowOpacity",
1868
+ "shadowRadius",
1869
+ "elevation",
1870
+ "includeFontPadding",
1871
+ "textAlignVertical",
1872
+ "writingDirection"
1873
+ ]);
1874
+ var CSS_UNITLESS = /* @__PURE__ */ new Set([
1875
+ "opacity",
1876
+ "fontWeight",
1877
+ "flex",
1878
+ "flexGrow",
1879
+ "flexShrink",
1880
+ "order",
1881
+ "zIndex",
1882
+ "aspectRatio",
1883
+ "columnCount",
1884
+ "lineHeight"
1885
+ ]);
1861
1886
  function styleValueToCSS(styles) {
1862
- return Object.entries(styles).filter(([, v]) => v !== void 0 && v !== null && typeof v !== "object").map(([prop, val]) => `${camelToKebab(prop)}: ${val}`).join("; ");
1887
+ return Object.entries(styles).filter(
1888
+ ([prop, v]) => v !== void 0 && v !== null && typeof v !== "object" && !RN_ONLY_PROPS.has(prop)
1889
+ ).map(([prop, val]) => {
1890
+ const cssProp = camelToKebab(prop);
1891
+ let cssVal;
1892
+ if (typeof val === "number") {
1893
+ cssVal = val === 0 || CSS_UNITLESS.has(prop) ? String(val) : `${val}px`;
1894
+ } else {
1895
+ cssVal = String(val);
1896
+ }
1897
+ return `${cssProp}: ${cssVal}`;
1898
+ }).join("; ");
1863
1899
  }
1864
1900
  function camelToKebab(str) {
1865
1901
  return str.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -2,8 +2,8 @@ import {
2
2
  Fragment,
3
3
  jsx,
4
4
  jsxs
5
- } from "./chunk-QMJ4XUJA.mjs";
6
- import "./chunk-LYGD2GSW.mjs";
5
+ } from "./chunk-YDKLJFFY.mjs";
6
+ import "./chunk-GN4JPJHC.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.2.7",
3
+ "version": "0.2.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",