@kbach/react 0.6.46 → 0.6.48

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.
@@ -3106,6 +3106,27 @@ var CSS_UNITLESS = /* @__PURE__ */ new Set([
3106
3106
  "gridRowStart",
3107
3107
  "gridRowEnd"
3108
3108
  ]);
3109
+ var TEXT_ONLY_STYLE_KEYS = [
3110
+ "color",
3111
+ "fontSize",
3112
+ "fontWeight",
3113
+ "fontStyle",
3114
+ "fontVariant",
3115
+ "letterSpacing",
3116
+ "lineHeight",
3117
+ "textAlign",
3118
+ "textAlignVertical",
3119
+ "textDecorationLine",
3120
+ "textDecorationColor",
3121
+ "textDecorationStyle",
3122
+ "textShadowColor",
3123
+ "textShadowOffset",
3124
+ "textShadowRadius",
3125
+ "textTransform",
3126
+ "writingDirection",
3127
+ "includeFontPadding",
3128
+ "verticalAlign"
3129
+ ];
3109
3130
  var RN_SHORTHAND_EXPAND = {
3110
3131
  marginHorizontal: ["margin-left", "margin-right"],
3111
3132
  marginVertical: ["margin-top", "margin-bottom"],
@@ -3265,8 +3286,10 @@ function flatten(resolved, isDark, state = {}, breakpoints = /* @__PURE__ */ new
3265
3286
  }
3266
3287
  if (isNative) {
3267
3288
  const defaultFont = getDefaultFontFamily();
3268
- if (defaultFont && !("fontFamily" in result)) {
3269
- result.fontFamily = defaultFont;
3289
+ const r = result;
3290
+ const looksLikeText = TEXT_ONLY_STYLE_KEYS.some((k) => k in r);
3291
+ if (defaultFont && looksLikeText && !("fontFamily" in r)) {
3292
+ r.fontFamily = defaultFont;
3270
3293
  }
3271
3294
  }
3272
3295
  if (!isNative) {
@@ -3814,6 +3837,16 @@ var _resizeModeMap = {
3814
3837
  "center": "none",
3815
3838
  "repeat": "none"
3816
3839
  };
3840
+ var PLACEHOLDER_RULE_CLASS = "kbach-ph";
3841
+ var _placeholderRuleInjected = false;
3842
+ function ensurePlaceholderColorRuleInjected() {
3843
+ if (_placeholderRuleInjected || typeof document === "undefined") return;
3844
+ _placeholderRuleInjected = true;
3845
+ const style = document.createElement("style");
3846
+ style.setAttribute("data-kbach-placeholder", "");
3847
+ style.textContent = `.${PLACEHOLDER_RULE_CLASS}::placeholder{color:var(--kbach-ph-color)}`;
3848
+ document.head.appendChild(style);
3849
+ }
3817
3850
  function transformToWebProps(originalName, tag, props) {
3818
3851
  const out = {};
3819
3852
  const isPressable = _pressableNames.has(originalName);
@@ -3821,6 +3854,7 @@ function transformToWebProps(originalName, tag, props) {
3821
3854
  const isImage = originalName === "Image" || originalName === "ImageBackground";
3822
3855
  const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
3823
3856
  let pendingStyle = null;
3857
+ let pendingClassName = null;
3824
3858
  for (const [k, v] of Object.entries(props)) {
3825
3859
  if (_rnOnlyProps.has(k)) continue;
3826
3860
  if (k === "onPress") {
@@ -3844,6 +3878,22 @@ function transformToWebProps(originalName, tag, props) {
3844
3878
  if (!("onChange" in props)) out.onChange = (e) => v(e.target.value);
3845
3879
  continue;
3846
3880
  }
3881
+ if (k === "onSubmitEditing") {
3882
+ if (!("onKeyDown" in props)) {
3883
+ out.onKeyDown = (e) => {
3884
+ if (e.key === "Enter") v();
3885
+ };
3886
+ }
3887
+ continue;
3888
+ }
3889
+ if (k === "placeholderTextColor") {
3890
+ if (v) {
3891
+ ensurePlaceholderColorRuleInjected();
3892
+ pendingClassName = PLACEHOLDER_RULE_CLASS;
3893
+ pendingStyle = { ...pendingStyle ?? {}, "--kbach-ph-color": v };
3894
+ }
3895
+ continue;
3896
+ }
3847
3897
  if (k === "secureTextEntry") {
3848
3898
  if (v && !("type" in props)) out.type = "password";
3849
3899
  continue;
@@ -3905,6 +3955,9 @@ function transformToWebProps(originalName, tag, props) {
3905
3955
  if (pendingStyle) {
3906
3956
  out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
3907
3957
  }
3958
+ if (pendingClassName) {
3959
+ out.className = out.className ? `${out.className} ${pendingClassName}` : pendingClassName;
3960
+ }
3908
3961
  if (isPressable && !out.role) out.role = "button";
3909
3962
  if (isImage && tag === "img" && out.alt == null) out.alt = "";
3910
3963
  return out;
@@ -26,7 +26,7 @@ import {
26
26
  transformToWebProps,
27
27
  useConditionalGlobalDarkMode,
28
28
  useConditionalWidth
29
- } from "./chunk-FYVFEEFX.mjs";
29
+ } from "./chunk-CFUH3CUD.mjs";
30
30
 
31
31
  // src/jsx-runtime.tsx
32
32
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -144,7 +144,9 @@ function processElement(type, rawProps, key, isStaticChildren) {
144
144
  if (!classStr && !__kbachStyles) {
145
145
  if (getEffectiveIsWeb()) return makeElement(isStaticChildren, effectiveType, omitConsumed(workingProps), key);
146
146
  const defaultFont = getCachedDefaultFont();
147
- if (!defaultFont) return makeElement(isStaticChildren, effectiveType, workingProps, key);
147
+ if (!defaultFont || getWebTag(type) !== "span") {
148
+ return makeElement(isStaticChildren, effectiveType, workingProps, key);
149
+ }
148
150
  const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
149
151
  const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
150
152
  return makeElement(isStaticChildren, effectiveType, { ...passProps2, style: finalStyle2 }, key);
@@ -3194,6 +3194,27 @@ var CSS_UNITLESS = /* @__PURE__ */ new Set([
3194
3194
  "gridRowStart",
3195
3195
  "gridRowEnd"
3196
3196
  ]);
3197
+ var TEXT_ONLY_STYLE_KEYS = [
3198
+ "color",
3199
+ "fontSize",
3200
+ "fontWeight",
3201
+ "fontStyle",
3202
+ "fontVariant",
3203
+ "letterSpacing",
3204
+ "lineHeight",
3205
+ "textAlign",
3206
+ "textAlignVertical",
3207
+ "textDecorationLine",
3208
+ "textDecorationColor",
3209
+ "textDecorationStyle",
3210
+ "textShadowColor",
3211
+ "textShadowOffset",
3212
+ "textShadowRadius",
3213
+ "textTransform",
3214
+ "writingDirection",
3215
+ "includeFontPadding",
3216
+ "verticalAlign"
3217
+ ];
3197
3218
  var RN_SHORTHAND_EXPAND = {
3198
3219
  marginHorizontal: ["margin-left", "margin-right"],
3199
3220
  marginVertical: ["margin-top", "margin-bottom"],
@@ -3363,8 +3384,10 @@ function flatten(resolved, isDark, state = {}, breakpoints = /* @__PURE__ */ new
3363
3384
  }
3364
3385
  if (isNative) {
3365
3386
  const defaultFont = getDefaultFontFamily();
3366
- if (defaultFont && !("fontFamily" in result)) {
3367
- result.fontFamily = defaultFont;
3387
+ const r = result;
3388
+ const looksLikeText = TEXT_ONLY_STYLE_KEYS.some((k) => k in r);
3389
+ if (defaultFont && looksLikeText && !("fontFamily" in r)) {
3390
+ r.fontFamily = defaultFont;
3368
3391
  }
3369
3392
  }
3370
3393
  if (!isNative) {
package/dist/index.js CHANGED
@@ -716,6 +716,16 @@ var _resizeModeMap = {
716
716
  "center": "none",
717
717
  "repeat": "none"
718
718
  };
719
+ var PLACEHOLDER_RULE_CLASS = "kbach-ph";
720
+ var _placeholderRuleInjected = false;
721
+ function ensurePlaceholderColorRuleInjected() {
722
+ if (_placeholderRuleInjected || typeof document === "undefined") return;
723
+ _placeholderRuleInjected = true;
724
+ const style = document.createElement("style");
725
+ style.setAttribute("data-kbach-placeholder", "");
726
+ style.textContent = `.${PLACEHOLDER_RULE_CLASS}::placeholder{color:var(--kbach-ph-color)}`;
727
+ document.head.appendChild(style);
728
+ }
719
729
  function transformToWebProps(originalName, tag, props) {
720
730
  const out = {};
721
731
  const isPressable = _pressableNames.has(originalName);
@@ -723,6 +733,7 @@ function transformToWebProps(originalName, tag, props) {
723
733
  const isImage = originalName === "Image" || originalName === "ImageBackground";
724
734
  const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
725
735
  let pendingStyle = null;
736
+ let pendingClassName = null;
726
737
  for (const [k, v] of Object.entries(props)) {
727
738
  if (_rnOnlyProps.has(k)) continue;
728
739
  if (k === "onPress") {
@@ -746,6 +757,22 @@ function transformToWebProps(originalName, tag, props) {
746
757
  if (!("onChange" in props)) out.onChange = (e) => v(e.target.value);
747
758
  continue;
748
759
  }
760
+ if (k === "onSubmitEditing") {
761
+ if (!("onKeyDown" in props)) {
762
+ out.onKeyDown = (e) => {
763
+ if (e.key === "Enter") v();
764
+ };
765
+ }
766
+ continue;
767
+ }
768
+ if (k === "placeholderTextColor") {
769
+ if (v) {
770
+ ensurePlaceholderColorRuleInjected();
771
+ pendingClassName = PLACEHOLDER_RULE_CLASS;
772
+ pendingStyle = { ...pendingStyle ?? {}, "--kbach-ph-color": v };
773
+ }
774
+ continue;
775
+ }
749
776
  if (k === "secureTextEntry") {
750
777
  if (v && !("type" in props)) out.type = "password";
751
778
  continue;
@@ -807,6 +834,9 @@ function transformToWebProps(originalName, tag, props) {
807
834
  if (pendingStyle) {
808
835
  out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
809
836
  }
837
+ if (pendingClassName) {
838
+ out.className = out.className ? `${out.className} ${pendingClassName}` : pendingClassName;
839
+ }
810
840
  if (isPressable && !out.role) out.role = "button";
811
841
  if (isImage && tag === "img" && out.alt == null) out.alt = "";
812
842
  return out;
package/dist/index.mjs CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  useGlobalDarkMode,
49
49
  useGlobalWidth,
50
50
  useSyncExternalStore
51
- } from "./chunk-FYVFEEFX.mjs";
51
+ } from "./chunk-CFUH3CUD.mjs";
52
52
 
53
53
  // src/context.tsx
54
54
  import { createContext, useContext } from "react";
@@ -500,6 +500,16 @@ var _resizeModeMap = {
500
500
  "center": "none",
501
501
  "repeat": "none"
502
502
  };
503
+ var PLACEHOLDER_RULE_CLASS = "kbach-ph";
504
+ var _placeholderRuleInjected = false;
505
+ function ensurePlaceholderColorRuleInjected() {
506
+ if (_placeholderRuleInjected || typeof document === "undefined") return;
507
+ _placeholderRuleInjected = true;
508
+ const style = document.createElement("style");
509
+ style.setAttribute("data-kbach-placeholder", "");
510
+ style.textContent = `.${PLACEHOLDER_RULE_CLASS}::placeholder{color:var(--kbach-ph-color)}`;
511
+ document.head.appendChild(style);
512
+ }
503
513
  function transformToWebProps(originalName, tag, props) {
504
514
  const out = {};
505
515
  const isPressable = _pressableNames.has(originalName);
@@ -507,6 +517,7 @@ function transformToWebProps(originalName, tag, props) {
507
517
  const isImage = originalName === "Image" || originalName === "ImageBackground";
508
518
  const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
509
519
  let pendingStyle = null;
520
+ let pendingClassName = null;
510
521
  for (const [k, v] of Object.entries(props)) {
511
522
  if (_rnOnlyProps.has(k)) continue;
512
523
  if (k === "onPress") {
@@ -530,6 +541,22 @@ function transformToWebProps(originalName, tag, props) {
530
541
  if (!("onChange" in props)) out.onChange = (e) => v(e.target.value);
531
542
  continue;
532
543
  }
544
+ if (k === "onSubmitEditing") {
545
+ if (!("onKeyDown" in props)) {
546
+ out.onKeyDown = (e) => {
547
+ if (e.key === "Enter") v();
548
+ };
549
+ }
550
+ continue;
551
+ }
552
+ if (k === "placeholderTextColor") {
553
+ if (v) {
554
+ ensurePlaceholderColorRuleInjected();
555
+ pendingClassName = PLACEHOLDER_RULE_CLASS;
556
+ pendingStyle = { ...pendingStyle ?? {}, "--kbach-ph-color": v };
557
+ }
558
+ continue;
559
+ }
533
560
  if (k === "secureTextEntry") {
534
561
  if (v && !("type" in props)) out.type = "password";
535
562
  continue;
@@ -591,6 +618,9 @@ function transformToWebProps(originalName, tag, props) {
591
618
  if (pendingStyle) {
592
619
  out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
593
620
  }
621
+ if (pendingClassName) {
622
+ out.className = out.className ? `${out.className} ${pendingClassName}` : pendingClassName;
623
+ }
594
624
  if (isPressable && !out.role) out.role = "button";
595
625
  if (isImage && tag === "img" && out.alt == null) out.alt = "";
596
626
  return out;
@@ -682,7 +712,9 @@ function processElement(type, rawProps, key, isStaticChildren) {
682
712
  if (!classStr && !__kbachStyles) {
683
713
  if ((0, import_core6.getEffectiveIsWeb)()) return makeElement(isStaticChildren, effectiveType, omitConsumed(workingProps), key);
684
714
  const defaultFont = getCachedDefaultFont();
685
- if (!defaultFont) return makeElement(isStaticChildren, effectiveType, workingProps, key);
715
+ if (!defaultFont || getWebTag(type) !== "span") {
716
+ return makeElement(isStaticChildren, effectiveType, workingProps, key);
717
+ }
686
718
  const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
687
719
  const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
688
720
  return makeElement(isStaticChildren, effectiveType, { ...passProps2, style: finalStyle2 }, key);
@@ -3,8 +3,8 @@ import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-4Y44K364.mjs";
7
- import "./chunk-FYVFEEFX.mjs";
6
+ } from "./chunk-YI75WFHE.mjs";
7
+ import "./chunk-CFUH3CUD.mjs";
8
8
 
9
9
  // src/jsx-dev-runtime.tsx
10
10
  function jsxDEV(type, props, key, isStaticChildren, source, self) {
@@ -506,6 +506,16 @@ var _resizeModeMap = {
506
506
  "center": "none",
507
507
  "repeat": "none"
508
508
  };
509
+ var PLACEHOLDER_RULE_CLASS = "kbach-ph";
510
+ var _placeholderRuleInjected = false;
511
+ function ensurePlaceholderColorRuleInjected() {
512
+ if (_placeholderRuleInjected || typeof document === "undefined") return;
513
+ _placeholderRuleInjected = true;
514
+ const style = document.createElement("style");
515
+ style.setAttribute("data-kbach-placeholder", "");
516
+ style.textContent = `.${PLACEHOLDER_RULE_CLASS}::placeholder{color:var(--kbach-ph-color)}`;
517
+ document.head.appendChild(style);
518
+ }
509
519
  function transformToWebProps(originalName, tag, props) {
510
520
  const out = {};
511
521
  const isPressable = _pressableNames.has(originalName);
@@ -513,6 +523,7 @@ function transformToWebProps(originalName, tag, props) {
513
523
  const isImage = originalName === "Image" || originalName === "ImageBackground";
514
524
  const isScrollable = originalName === "ScrollView" || originalName === "FlatList" || originalName === "SectionList";
515
525
  let pendingStyle = null;
526
+ let pendingClassName = null;
516
527
  for (const [k, v] of Object.entries(props)) {
517
528
  if (_rnOnlyProps.has(k)) continue;
518
529
  if (k === "onPress") {
@@ -536,6 +547,22 @@ function transformToWebProps(originalName, tag, props) {
536
547
  if (!("onChange" in props)) out.onChange = (e) => v(e.target.value);
537
548
  continue;
538
549
  }
550
+ if (k === "onSubmitEditing") {
551
+ if (!("onKeyDown" in props)) {
552
+ out.onKeyDown = (e) => {
553
+ if (e.key === "Enter") v();
554
+ };
555
+ }
556
+ continue;
557
+ }
558
+ if (k === "placeholderTextColor") {
559
+ if (v) {
560
+ ensurePlaceholderColorRuleInjected();
561
+ pendingClassName = PLACEHOLDER_RULE_CLASS;
562
+ pendingStyle = { ...pendingStyle ?? {}, "--kbach-ph-color": v };
563
+ }
564
+ continue;
565
+ }
539
566
  if (k === "secureTextEntry") {
540
567
  if (v && !("type" in props)) out.type = "password";
541
568
  continue;
@@ -597,6 +624,9 @@ function transformToWebProps(originalName, tag, props) {
597
624
  if (pendingStyle) {
598
625
  out.style = out.style ? { ...pendingStyle, ...out.style } : pendingStyle;
599
626
  }
627
+ if (pendingClassName) {
628
+ out.className = out.className ? `${out.className} ${pendingClassName}` : pendingClassName;
629
+ }
600
630
  if (isPressable && !out.role) out.role = "button";
601
631
  if (isImage && tag === "img" && out.alt == null) out.alt = "";
602
632
  return out;
@@ -688,7 +718,9 @@ function processElement(type, rawProps, key, isStaticChildren) {
688
718
  if (!classStr && !__kbachStyles) {
689
719
  if ((0, import_core6.getEffectiveIsWeb)()) return makeElement(isStaticChildren, effectiveType, omitConsumed(workingProps), key);
690
720
  const defaultFont = getCachedDefaultFont();
691
- if (!defaultFont) return makeElement(isStaticChildren, effectiveType, workingProps, key);
721
+ if (!defaultFont || getWebTag(type) !== "span") {
722
+ return makeElement(isStaticChildren, effectiveType, workingProps, key);
723
+ }
692
724
  const { style: userStyle2, ...passProps2 } = omitConsumed(workingProps);
693
725
  const finalStyle2 = userStyle2 ? Array.isArray(userStyle2) ? { fontFamily: defaultFont, ...Object.assign({}, ...userStyle2) } : { fontFamily: defaultFont, ...userStyle2 } : { fontFamily: defaultFont };
694
726
  return makeElement(isStaticChildren, effectiveType, { ...passProps2, style: finalStyle2 }, key);
@@ -4,10 +4,10 @@ import {
4
4
  _invalidateDefaultFontCache,
5
5
  jsx,
6
6
  jsxs
7
- } from "./chunk-4Y44K364.mjs";
7
+ } from "./chunk-YI75WFHE.mjs";
8
8
  import {
9
9
  registerWebElement
10
- } from "./chunk-FYVFEEFX.mjs";
10
+ } from "./chunk-CFUH3CUD.mjs";
11
11
  export {
12
12
  Fragment,
13
13
  _invalidateDefaultFontCache,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kbach/react",
3
- "version": "0.6.46",
3
+ "version": "0.6.48",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "license": "MIT",
6
6
  "repository": {