@kbach/react 0.6.31 → 0.6.33

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.
@@ -9,6 +9,7 @@ import {
9
9
  getDefaultFontFamily,
10
10
  getEffectiveIsWeb,
11
11
  getGlobalScreens,
12
+ getImpliedRNStyle,
12
13
  getInteractiveModifiers,
13
14
  getModeModifiers,
14
15
  getResponsiveModifiers,
@@ -25,7 +26,7 @@ import {
25
26
  transformToWebProps,
26
27
  useConditionalGlobalDarkMode,
27
28
  useConditionalWidth
28
- } from "./chunk-OIJ6RP4F.mjs";
29
+ } from "./chunk-QCBA2JJK.mjs";
29
30
 
30
31
  // src/jsx-runtime.tsx
31
32
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -50,7 +51,7 @@ var DarkWrapper = React.forwardRef(
50
51
  return s;
51
52
  }, [resolvedStyle, isDark, width, screens, isNonStringComponent]);
52
53
  const skipComputedInline = isWebPlatform;
53
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
54
+ const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
54
55
  const props = { ref, ...rest, style: finalStyle };
55
56
  return Array.isArray(children) ? React.createElement(Component, props, ...children) : React.createElement(Component, props, children);
56
57
  }
@@ -108,19 +109,11 @@ function omitConsumed(props) {
108
109
  }
109
110
  function mergeStyle(computed, userStyle) {
110
111
  if (!userStyle) return computed;
111
- if (Array.isArray(userStyle)) return Object.assign({}, computed, ...userStyle);
112
- return { ...computed, ...userStyle };
112
+ return Array.isArray(userStyle) ? [computed, ...userStyle] : [computed, userStyle];
113
113
  }
114
- function withImpliedFlexIfNeeded(webTag, resolvedBase, userStyle) {
115
- if (!webTag || !resolvedBase) return userStyle;
116
- const explicitDisplay = resolvedBase.display;
117
- const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
118
- const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
119
- if (!willBeFlex) return userStyle;
120
- const compensation = {};
121
- if (explicitDisplay === void 0) compensation.display = "flex";
122
- if (resolvedBase.flexDirection === void 0) compensation.flexDirection = "column";
123
- if (Object.keys(compensation).length === 0) return userStyle;
114
+ function withImpliedRNStyleIfNeeded(webTag, resolvedBase, userStyle) {
115
+ const compensation = getImpliedRNStyle(webTag, resolvedBase);
116
+ if (!compensation) return userStyle;
124
117
  return Array.isArray(userStyle) ? [compensation, ...userStyle] : { ...compensation, ...userStyle };
125
118
  }
126
119
  function makeElement(isStaticChildren, type, props, key) {
@@ -167,7 +160,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
167
160
  }
168
161
  const resolved = !isWeb && __kbachStyles != null ? __kbachStyles : expandedClassStr ? resolve(expandedClassStr, config.theme, config.darkMode) : {};
169
162
  const { style: rawUserStyle, ...passProps } = omitConsumed(workingProps);
170
- const userStyle = withImpliedFlexIfNeeded(webTag, resolved.base, rawUserStyle);
163
+ const userStyle = withImpliedRNStyleIfNeeded(webTag, resolved.base, rawUserStyle);
171
164
  const { interactive, modeOrResponsive } = bucketMods(resolved);
172
165
  if (interactive) {
173
166
  return _jsx(InteractiveWrapper, {
@@ -3522,6 +3522,19 @@ function getWebTag(type, props) {
3522
3522
  _cache.set(obj, tag);
3523
3523
  return tag;
3524
3524
  }
3525
+ function getImpliedRNStyle(webTag, resolvedBase) {
3526
+ if (!webTag || !resolvedBase) return void 0;
3527
+ const compensation = {};
3528
+ if (resolvedBase.position === void 0) compensation.position = "relative";
3529
+ const explicitDisplay = resolvedBase.display;
3530
+ const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
3531
+ const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
3532
+ if (willBeFlex) {
3533
+ if (explicitDisplay === void 0) compensation.display = "flex";
3534
+ if (resolvedBase.flexDirection === void 0) compensation.flexDirection = "column";
3535
+ }
3536
+ return Object.keys(compensation).length > 0 ? compensation : void 0;
3537
+ }
3525
3538
  var _rnOnlyProps = /* @__PURE__ */ new Set([
3526
3539
  // Interaction
3527
3540
  "onLongPress",
@@ -3873,7 +3886,7 @@ var InteractiveWrapper = forwardRef(
3873
3886
  [resolvedStyle, isDark, pressed, hovered, focused, width, disabled, checked, isNonStringComponent]
3874
3887
  );
3875
3888
  const skipComputedInline = isWebPlatform;
3876
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
3889
+ const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
3877
3890
  const componentProps = {
3878
3891
  ref,
3879
3892
  ...restForComponent,
@@ -3961,6 +3974,7 @@ export {
3961
3974
  stripWebOnlyProps,
3962
3975
  registerWebElement,
3963
3976
  getWebTag,
3977
+ getImpliedRNStyle,
3964
3978
  transformToWebProps,
3965
3979
  InteractiveWrapper
3966
3980
  };
package/dist/index.js CHANGED
@@ -544,6 +544,19 @@ function getWebTag(type, props) {
544
544
  _cache.set(obj, tag);
545
545
  return tag;
546
546
  }
547
+ function getImpliedRNStyle(webTag, resolvedBase) {
548
+ if (!webTag || !resolvedBase) return void 0;
549
+ const compensation = {};
550
+ if (resolvedBase.position === void 0) compensation.position = "relative";
551
+ const explicitDisplay = resolvedBase.display;
552
+ const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
553
+ const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
554
+ if (willBeFlex) {
555
+ if (explicitDisplay === void 0) compensation.display = "flex";
556
+ if (resolvedBase.flexDirection === void 0) compensation.flexDirection = "column";
557
+ }
558
+ return Object.keys(compensation).length > 0 ? compensation : void 0;
559
+ }
547
560
  var _rnOnlyProps = /* @__PURE__ */ new Set([
548
561
  // Interaction
549
562
  "onLongPress",
@@ -842,9 +855,13 @@ function styled(Component, baseClasses = "") {
842
855
  [resolved, isDark, pressed, hovered, focused, disabled, checked, width]
843
856
  // eslint-disable-line react-hooks/exhaustive-deps
844
857
  );
845
- const extraStyle = Array.isArray(styleProp) ? Object.assign({}, ...styleProp) : styleProp;
846
- const finalStyle = isWebPlatform ? extraStyle ?? void 0 : extraStyle ? { ...computedStyle, ...extraStyle } : computedStyle;
847
858
  const webTag = isWebPlatform ? getWebTag(Component, rest) : null;
859
+ const finalStyle = isWebPlatform ? (() => {
860
+ const flatStyleProp = (Array.isArray(styleProp) ? Object.assign({}, ...styleProp) : styleProp) ?? void 0;
861
+ const compensation = getImpliedRNStyle(webTag, resolved.base);
862
+ if (!compensation) return flatStyleProp;
863
+ return flatStyleProp ? { ...compensation, ...flatStyleProp } : compensation;
864
+ })() : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
848
865
  const effectiveComponent = webTag ?? Component;
849
866
  const componentName2 = Component.displayName ?? Component.name ?? "";
850
867
  const effectiveRest = webTag && componentName2 ? transformToWebProps(componentName2, webTag, rest) : rest;
@@ -1030,7 +1047,7 @@ var InteractiveWrapper = (0, import_react9.forwardRef)(
1030
1047
  [resolvedStyle, isDark, pressed, hovered, focused, width, disabled, checked, isNonStringComponent]
1031
1048
  );
1032
1049
  const skipComputedInline = isWebPlatform;
1033
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
1050
+ const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
1034
1051
  const componentProps = {
1035
1052
  ref,
1036
1053
  ...restForComponent,
package/dist/index.mjs CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  getActiveBreakpoints,
15
15
  getConfig,
16
16
  getEffectiveIsWeb,
17
+ getImpliedRNStyle,
17
18
  getWebTag,
18
19
  hasInteractiveBuckets,
19
20
  hasResponsiveBuckets,
@@ -43,7 +44,7 @@ import {
43
44
  useGlobalDarkMode,
44
45
  useGlobalWidth,
45
46
  useSyncExternalStore
46
- } from "./chunk-OIJ6RP4F.mjs";
47
+ } from "./chunk-QCBA2JJK.mjs";
47
48
 
48
49
  // src/context.tsx
49
50
  import { createContext, useContext } from "react";
@@ -406,9 +407,13 @@ function styled(Component, baseClasses = "") {
406
407
  [resolved, isDark, pressed, hovered, focused, disabled, checked, width]
407
408
  // eslint-disable-line react-hooks/exhaustive-deps
408
409
  );
409
- const extraStyle = Array.isArray(styleProp) ? Object.assign({}, ...styleProp) : styleProp;
410
- const finalStyle = isWebPlatform ? extraStyle ?? void 0 : extraStyle ? { ...computedStyle, ...extraStyle } : computedStyle;
411
410
  const webTag = isWebPlatform ? getWebTag(Component, rest) : null;
411
+ const finalStyle = isWebPlatform ? (() => {
412
+ const flatStyleProp = (Array.isArray(styleProp) ? Object.assign({}, ...styleProp) : styleProp) ?? void 0;
413
+ const compensation = getImpliedRNStyle(webTag, resolved.base);
414
+ if (!compensation) return flatStyleProp;
415
+ return flatStyleProp ? { ...compensation, ...flatStyleProp } : compensation;
416
+ })() : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
412
417
  const effectiveComponent = webTag ?? Component;
413
418
  const componentName2 = Component.displayName ?? Component.name ?? "";
414
419
  const effectiveRest = webTag && componentName2 ? transformToWebProps(componentName2, webTag, rest) : rest;
@@ -234,7 +234,7 @@ var InteractiveWrapper = (0, import_react2.forwardRef)(
234
234
  [resolvedStyle, isDark, pressed, hovered, focused, width, disabled, checked, isNonStringComponent]
235
235
  );
236
236
  const skipComputedInline = isWebPlatform;
237
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
237
+ const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
238
238
  const componentProps = {
239
239
  ref,
240
240
  ...restForComponent,
@@ -291,7 +291,7 @@ var DarkWrapper = import_react3.default.forwardRef(
291
291
  return s;
292
292
  }, [resolvedStyle, isDark, width, screens, isNonStringComponent]);
293
293
  const skipComputedInline = isWebPlatform;
294
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
294
+ const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
295
295
  const props = { ref, ...rest, style: finalStyle };
296
296
  return Array.isArray(children) ? import_react3.default.createElement(Component, props, ...children) : import_react3.default.createElement(Component, props, children);
297
297
  }
@@ -338,6 +338,19 @@ function getWebTag(type, props) {
338
338
  _cache.set(obj, tag);
339
339
  return tag;
340
340
  }
341
+ function getImpliedRNStyle(webTag, resolvedBase) {
342
+ if (!webTag || !resolvedBase) return void 0;
343
+ const compensation = {};
344
+ if (resolvedBase.position === void 0) compensation.position = "relative";
345
+ const explicitDisplay = resolvedBase.display;
346
+ const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
347
+ const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
348
+ if (willBeFlex) {
349
+ if (explicitDisplay === void 0) compensation.display = "flex";
350
+ if (resolvedBase.flexDirection === void 0) compensation.flexDirection = "column";
351
+ }
352
+ return Object.keys(compensation).length > 0 ? compensation : void 0;
353
+ }
341
354
  var _rnOnlyProps = /* @__PURE__ */ new Set([
342
355
  // Interaction
343
356
  "onLongPress",
@@ -619,19 +632,11 @@ function omitConsumed(props) {
619
632
  }
620
633
  function mergeStyle(computed, userStyle) {
621
634
  if (!userStyle) return computed;
622
- if (Array.isArray(userStyle)) return Object.assign({}, computed, ...userStyle);
623
- return { ...computed, ...userStyle };
635
+ return Array.isArray(userStyle) ? [computed, ...userStyle] : [computed, userStyle];
624
636
  }
625
- function withImpliedFlexIfNeeded(webTag, resolvedBase, userStyle) {
626
- if (!webTag || !resolvedBase) return userStyle;
627
- const explicitDisplay = resolvedBase.display;
628
- const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
629
- const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
630
- if (!willBeFlex) return userStyle;
631
- const compensation = {};
632
- if (explicitDisplay === void 0) compensation.display = "flex";
633
- if (resolvedBase.flexDirection === void 0) compensation.flexDirection = "column";
634
- if (Object.keys(compensation).length === 0) return userStyle;
637
+ function withImpliedRNStyleIfNeeded(webTag, resolvedBase, userStyle) {
638
+ const compensation = getImpliedRNStyle(webTag, resolvedBase);
639
+ if (!compensation) return userStyle;
635
640
  return Array.isArray(userStyle) ? [compensation, ...userStyle] : { ...compensation, ...userStyle };
636
641
  }
637
642
  function makeElement(isStaticChildren, type, props, key) {
@@ -678,7 +683,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
678
683
  }
679
684
  const resolved = !import_core6.isWeb && __kbachStyles != null ? __kbachStyles : expandedClassStr ? (0, import_core6.resolve)(expandedClassStr, config.theme, config.darkMode) : {};
680
685
  const { style: rawUserStyle, ...passProps } = omitConsumed(workingProps);
681
- const userStyle = withImpliedFlexIfNeeded(webTag, resolved.base, rawUserStyle);
686
+ const userStyle = withImpliedRNStyleIfNeeded(webTag, resolved.base, rawUserStyle);
682
687
  const { interactive, modeOrResponsive } = bucketMods(resolved);
683
688
  if (interactive) {
684
689
  return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
@@ -3,8 +3,8 @@ import {
3
3
  Fragment,
4
4
  jsx,
5
5
  jsxs
6
- } from "./chunk-MOWXWICC.mjs";
7
- import "./chunk-OIJ6RP4F.mjs";
6
+ } from "./chunk-4DFD4WX3.mjs";
7
+ import "./chunk-QCBA2JJK.mjs";
8
8
 
9
9
  // src/jsx-dev-runtime.tsx
10
10
  function jsxDEV(type, props, key, isStaticChildren, source, self) {
@@ -235,7 +235,7 @@ var InteractiveWrapper = (0, import_react2.forwardRef)(
235
235
  [resolvedStyle, isDark, pressed, hovered, focused, width, disabled, checked, isNonStringComponent]
236
236
  );
237
237
  const skipComputedInline = isWebPlatform;
238
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
238
+ const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
239
239
  const componentProps = {
240
240
  ref,
241
241
  ...restForComponent,
@@ -292,7 +292,7 @@ var DarkWrapper = import_react3.default.forwardRef(
292
292
  return s;
293
293
  }, [resolvedStyle, isDark, width, screens, isNonStringComponent]);
294
294
  const skipComputedInline = isWebPlatform;
295
- const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? Object.assign({}, computedStyle, ...styleProp) : { ...computedStyle, ...styleProp } : computedStyle;
295
+ const finalStyle = skipComputedInline ? styleProp ?? void 0 : styleProp ? Array.isArray(styleProp) ? [computedStyle, ...styleProp] : [computedStyle, styleProp] : computedStyle;
296
296
  const props = { ref, ...rest, style: finalStyle };
297
297
  return Array.isArray(children) ? import_react3.default.createElement(Component, props, ...children) : import_react3.default.createElement(Component, props, children);
298
298
  }
@@ -344,6 +344,19 @@ function getWebTag(type, props) {
344
344
  _cache.set(obj, tag);
345
345
  return tag;
346
346
  }
347
+ function getImpliedRNStyle(webTag, resolvedBase) {
348
+ if (!webTag || !resolvedBase) return void 0;
349
+ const compensation = {};
350
+ if (resolvedBase.position === void 0) compensation.position = "relative";
351
+ const explicitDisplay = resolvedBase.display;
352
+ const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
353
+ const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
354
+ if (willBeFlex) {
355
+ if (explicitDisplay === void 0) compensation.display = "flex";
356
+ if (resolvedBase.flexDirection === void 0) compensation.flexDirection = "column";
357
+ }
358
+ return Object.keys(compensation).length > 0 ? compensation : void 0;
359
+ }
347
360
  var _rnOnlyProps = /* @__PURE__ */ new Set([
348
361
  // Interaction
349
362
  "onLongPress",
@@ -625,19 +638,11 @@ function omitConsumed(props) {
625
638
  }
626
639
  function mergeStyle(computed, userStyle) {
627
640
  if (!userStyle) return computed;
628
- if (Array.isArray(userStyle)) return Object.assign({}, computed, ...userStyle);
629
- return { ...computed, ...userStyle };
641
+ return Array.isArray(userStyle) ? [computed, ...userStyle] : [computed, userStyle];
630
642
  }
631
- function withImpliedFlexIfNeeded(webTag, resolvedBase, userStyle) {
632
- if (!webTag || !resolvedBase) return userStyle;
633
- const explicitDisplay = resolvedBase.display;
634
- const hasFlexItemProps = "flexGrow" in resolvedBase || "flexShrink" in resolvedBase || "flex" in resolvedBase;
635
- const willBeFlex = explicitDisplay === "flex" || explicitDisplay === void 0 && hasFlexItemProps;
636
- if (!willBeFlex) return userStyle;
637
- const compensation = {};
638
- if (explicitDisplay === void 0) compensation.display = "flex";
639
- if (resolvedBase.flexDirection === void 0) compensation.flexDirection = "column";
640
- if (Object.keys(compensation).length === 0) return userStyle;
643
+ function withImpliedRNStyleIfNeeded(webTag, resolvedBase, userStyle) {
644
+ const compensation = getImpliedRNStyle(webTag, resolvedBase);
645
+ if (!compensation) return userStyle;
641
646
  return Array.isArray(userStyle) ? [compensation, ...userStyle] : { ...compensation, ...userStyle };
642
647
  }
643
648
  function makeElement(isStaticChildren, type, props, key) {
@@ -684,7 +689,7 @@ function processElement(type, rawProps, key, isStaticChildren) {
684
689
  }
685
690
  const resolved = !import_core6.isWeb && __kbachStyles != null ? __kbachStyles : expandedClassStr ? (0, import_core6.resolve)(expandedClassStr, config.theme, config.darkMode) : {};
686
691
  const { style: rawUserStyle, ...passProps } = omitConsumed(workingProps);
687
- const userStyle = withImpliedFlexIfNeeded(webTag, resolved.base, rawUserStyle);
692
+ const userStyle = withImpliedRNStyleIfNeeded(webTag, resolved.base, rawUserStyle);
688
693
  const { interactive, modeOrResponsive } = bucketMods(resolved);
689
694
  if (interactive) {
690
695
  return (0, import_jsx_runtime.jsx)(InteractiveWrapper, {
@@ -4,10 +4,10 @@ import {
4
4
  _invalidateDefaultFontCache,
5
5
  jsx,
6
6
  jsxs
7
- } from "./chunk-MOWXWICC.mjs";
7
+ } from "./chunk-4DFD4WX3.mjs";
8
8
  import {
9
9
  registerWebElement
10
- } from "./chunk-OIJ6RP4F.mjs";
10
+ } from "./chunk-QCBA2JJK.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.31",
3
+ "version": "0.6.33",
4
4
  "description": "React / React Native components and hooks for the Kbach framework",
5
5
  "repository": {
6
6
  "type": "git",