@ornikar/kitt-universal 25.45.4-canary.1fa8dd864c345808028f3e3165c5c7fcf9bc9e2a.0 → 25.46.1-canary.9950f4eb84cbfcf1d45de4e6c9ad226210c5404f.0

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/dist/definitions/BottomSheet/BottomSheet.d.ts +3 -2
  3. package/dist/definitions/BottomSheet/BottomSheet.d.ts.map +1 -1
  4. package/dist/definitions/CardModal/CardModal.d.ts +3 -2
  5. package/dist/definitions/CardModal/CardModal.d.ts.map +1 -1
  6. package/dist/definitions/FullscreenModal/FullscreenModal.d.ts +3 -2
  7. package/dist/definitions/FullscreenModal/FullscreenModal.d.ts.map +1 -1
  8. package/dist/definitions/Tooltip/Tooltip.d.ts.map +1 -1
  9. package/dist/definitions/index.d.ts +1 -1
  10. package/dist/definitions/index.d.ts.map +1 -1
  11. package/dist/definitions/native-base/CurrentBreakpointContext.d.ts +19 -0
  12. package/dist/definitions/native-base/CurrentBreakpointContext.d.ts.map +1 -0
  13. package/dist/definitions/native-base/KittNativeBaseProvider.d.ts.map +1 -1
  14. package/dist/definitions/native-base/utils.d.ts +11 -12
  15. package/dist/definitions/native-base/utils.d.ts.map +1 -1
  16. package/dist/definitions/utils/windowSize/MatchWindowSize.d.ts +3 -2
  17. package/dist/definitions/utils/windowSize/MatchWindowSize.d.ts.map +1 -1
  18. package/dist/index-metro.es.android.js +173 -97
  19. package/dist/index-metro.es.android.js.map +1 -1
  20. package/dist/index-metro.es.ios.js +173 -97
  21. package/dist/index-metro.es.ios.js.map +1 -1
  22. package/dist/index-node-20.10.cjs.js +169 -93
  23. package/dist/index-node-20.10.cjs.js.map +1 -1
  24. package/dist/index-node-20.10.cjs.web.js +161 -82
  25. package/dist/index-node-20.10.cjs.web.js.map +1 -1
  26. package/dist/index-node-20.10.es.mjs +170 -95
  27. package/dist/index-node-20.10.es.mjs.map +1 -1
  28. package/dist/index-node-20.10.es.web.mjs +162 -84
  29. package/dist/index-node-20.10.es.web.mjs.map +1 -1
  30. package/dist/index.es.js +175 -95
  31. package/dist/index.es.js.map +1 -1
  32. package/dist/index.es.web.js +166 -85
  33. package/dist/index.es.web.js.map +1 -1
  34. package/dist/tsbuildinfo +1 -1
  35. package/package.json +1 -1
  36. package/dist/definitions/utils/windowSize/useCurrentBreakpointName.d.ts +0 -3
  37. package/dist/definitions/utils/windowSize/useCurrentBreakpointName.d.ts.map +0 -1
@@ -2708,8 +2708,129 @@ const VStack = nativeBase.VStack;
2708
2708
  const HStack = nativeBase.HStack;
2709
2709
  const Center = nativeBase.Center;
2710
2710
 
2711
+ const KittBreakpoints = {
2712
+ /**
2713
+ * min-width: 0
2714
+ */
2715
+ BASE: 0,
2716
+ /**
2717
+ * min-width: 480px
2718
+ */
2719
+ SMALL: 480,
2720
+ /**
2721
+ * min-width: 768px
2722
+ */
2723
+ MEDIUM: 768,
2724
+ /**
2725
+ * min-width: 1024px
2726
+ */
2727
+ LARGE: 1024,
2728
+ /**
2729
+ * min-width: 1280px
2730
+ */
2731
+ WIDE: 1280
2732
+ };
2733
+ const KittBreakpointsMax = {
2734
+ /**
2735
+ * max-width: 479px
2736
+ */
2737
+ BASE: KittBreakpoints.SMALL - 1,
2738
+ /**
2739
+ * max-width: 767px
2740
+ */
2741
+ SMALL: KittBreakpoints.MEDIUM - 1,
2742
+ /**
2743
+ * max-width: 1023px
2744
+ */
2745
+ MEDIUM: KittBreakpoints.LARGE - 1,
2746
+ /**
2747
+ * max-width: 1279px
2748
+ */
2749
+ LARGE: KittBreakpoints.WIDE - 1
2750
+ };
2751
+ let KittBreakpointNameEnum = /*#__PURE__*/function (KittBreakpointNameEnum) {
2752
+ KittBreakpointNameEnum["BASE"] = "base";
2753
+ KittBreakpointNameEnum["SMALL"] = "small";
2754
+ KittBreakpointNameEnum["MEDIUM"] = "medium";
2755
+ KittBreakpointNameEnum["LARGE"] = "large";
2756
+ KittBreakpointNameEnum["WIDE"] = "wide";
2757
+ return KittBreakpointNameEnum;
2758
+ }({});
2759
+
2711
2760
  // eslint-disable-next-line no-restricted-imports
2712
- const useBreakpointValue = nativeBase.useBreakpointValue;
2761
+ const CurrentBreakpointContext = /*#__PURE__*/React.createContext(undefined);
2762
+ /**
2763
+ * Provider that uses the native-base breakpoint system to detect the current viewport size and maps it to Kitt's breakpoint names.
2764
+ */
2765
+ function CurrentBreakpointProvider({
2766
+ children
2767
+ }) {
2768
+ const breakpoint = nativeBase.useBreakpointValue({
2769
+ base: KittBreakpointNameEnum.BASE,
2770
+ small: KittBreakpointNameEnum.SMALL,
2771
+ medium: KittBreakpointNameEnum.MEDIUM,
2772
+ large: KittBreakpointNameEnum.LARGE,
2773
+ wide: KittBreakpointNameEnum.WIDE
2774
+ });
2775
+ const value = React.useMemo(() => ({
2776
+ breakpoint
2777
+ }), [breakpoint]);
2778
+ return /*#__PURE__*/jsxRuntime.jsx(CurrentBreakpointContext.Provider, {
2779
+ value: value,
2780
+ children: children
2781
+ });
2782
+ }
2783
+
2784
+ /**
2785
+ * React hook that provides information about the current breakpoint.
2786
+ * Unlike the native-base counterpart, this hook does not trigger a re-render on every viewport size change.
2787
+ */
2788
+ function useCurrentBreakpointName() {
2789
+ const context = React.useContext(CurrentBreakpointContext);
2790
+ if (context === undefined) {
2791
+ throw new Error('useCurrentBreakpoint must be used within an CurrentBreakpointProvider');
2792
+ }
2793
+ return context;
2794
+ }
2795
+
2796
+ /**
2797
+ * Retrieves the appropriate value for the given breakpoint with fallback to smaller breakpoints.
2798
+ * Mimics Native Base's logic.
2799
+ */
2800
+ function getValueForBreakpoint(breakpoint, {
2801
+ base,
2802
+ small,
2803
+ medium,
2804
+ large,
2805
+ wide
2806
+ }) {
2807
+ switch (breakpoint) {
2808
+ case KittBreakpointNameEnum.WIDE:
2809
+ return wide ?? large ?? medium ?? small ?? base;
2810
+ case KittBreakpointNameEnum.LARGE:
2811
+ return large ?? medium ?? small ?? base;
2812
+ case KittBreakpointNameEnum.MEDIUM:
2813
+ return medium ?? small ?? base;
2814
+ case KittBreakpointNameEnum.SMALL:
2815
+ return small ?? base;
2816
+ case KittBreakpointNameEnum.BASE:
2817
+ default:
2818
+ return base;
2819
+ }
2820
+ }
2821
+
2822
+ /**
2823
+ * A hook that returns a value based on the current breakpoint.
2824
+ * Mimics the behavior of Native Base's useBreakpointValue, but uses our custom context for better performance.
2825
+ */
2826
+ function useBreakpointValue(values) {
2827
+ const {
2828
+ breakpoint
2829
+ } = useCurrentBreakpointName();
2830
+ return React.useMemo(() => {
2831
+ return getValueForBreakpoint(breakpoint, values);
2832
+ }, [breakpoint, values]);
2833
+ }
2713
2834
 
2714
2835
  function createResponsiveStyleFromProp(responsiveBooleanValue, valueIfTrue, valueIfFalse) {
2715
2836
  // Handles simple boolean values
@@ -2781,55 +2902,6 @@ function AnimatedContainer$2({
2781
2902
  });
2782
2903
  }
2783
2904
 
2784
- const KittBreakpoints = {
2785
- /**
2786
- * min-width: 0
2787
- */
2788
- BASE: 0,
2789
- /**
2790
- * min-width: 480px
2791
- */
2792
- SMALL: 480,
2793
- /**
2794
- * min-width: 768px
2795
- */
2796
- MEDIUM: 768,
2797
- /**
2798
- * min-width: 1024px
2799
- */
2800
- LARGE: 1024,
2801
- /**
2802
- * min-width: 1280px
2803
- */
2804
- WIDE: 1280
2805
- };
2806
- const KittBreakpointsMax = {
2807
- /**
2808
- * max-width: 479px
2809
- */
2810
- BASE: KittBreakpoints.SMALL - 1,
2811
- /**
2812
- * max-width: 767px
2813
- */
2814
- SMALL: KittBreakpoints.MEDIUM - 1,
2815
- /**
2816
- * max-width: 1023px
2817
- */
2818
- MEDIUM: KittBreakpoints.LARGE - 1,
2819
- /**
2820
- * max-width: 1279px
2821
- */
2822
- LARGE: KittBreakpoints.WIDE - 1
2823
- };
2824
- let KittBreakpointNameEnum = /*#__PURE__*/function (KittBreakpointNameEnum) {
2825
- KittBreakpointNameEnum["BASE"] = "base";
2826
- KittBreakpointNameEnum["SMALL"] = "small";
2827
- KittBreakpointNameEnum["MEDIUM"] = "medium";
2828
- KittBreakpointNameEnum["LARGE"] = "large";
2829
- KittBreakpointNameEnum["WIDE"] = "wide";
2830
- return KittBreakpointNameEnum;
2831
- }({});
2832
-
2833
2905
  const typographyColors = ['black', 'black-anthracite', 'black-disabled', 'black-light', 'white', 'white-light', 'primary', 'primary-light', 'accent', 'success', 'danger', 'warning'];
2834
2906
 
2835
2907
  function getNBThemeColorFromColorProps(colorName) {
@@ -3759,6 +3831,9 @@ function BottomSheetComp({
3759
3831
  hasHandle = true,
3760
3832
  enableDynamicSizing = true,
3761
3833
  snapPoints = ['100%'],
3834
+ contentContainer: ContentContainer = ({
3835
+ children
3836
+ }) => children,
3762
3837
  ...rest
3763
3838
  }, ref) {
3764
3839
  const {
@@ -3789,9 +3864,11 @@ function BottomSheetComp({
3789
3864
  ...rest,
3790
3865
  topInset: top,
3791
3866
  children: props => /*#__PURE__*/jsxRuntime.jsx(Wrapper, {
3792
- children: typeof Content === 'function' ? /*#__PURE__*/jsxRuntime.jsx(Content, {
3793
- ...props?.data
3794
- }) : Content
3867
+ children: /*#__PURE__*/jsxRuntime.jsx(ContentContainer, {
3868
+ children: typeof Content === 'function' ? /*#__PURE__*/jsxRuntime.jsx(Content, {
3869
+ ...props?.data
3870
+ }) : Content
3871
+ })
3795
3872
  })
3796
3873
  });
3797
3874
  }
@@ -4194,6 +4271,9 @@ function CardModal({
4194
4271
  header,
4195
4272
  body,
4196
4273
  footer,
4274
+ contentContainer: ContentContainer = ({
4275
+ children: originalChildren
4276
+ }) => originalChildren,
4197
4277
  ...props
4198
4278
  }) {
4199
4279
  return /*#__PURE__*/jsxRuntime.jsx(View, {
@@ -4206,8 +4286,10 @@ function CardModal({
4206
4286
  maxHeight: "100%",
4207
4287
  maxWidth: maxWidth,
4208
4288
  minHeight: "kitt.cardModal.minHeight",
4209
- children: children || /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4210
- children: [header || null, body || null, footer || null]
4289
+ children: /*#__PURE__*/jsxRuntime.jsx(ContentContainer, {
4290
+ children: children || /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
4291
+ children: [header || null, body || null, footer || null]
4292
+ })
4211
4293
  })
4212
4294
  });
4213
4295
  }
@@ -7986,25 +8068,30 @@ function FullscreenModal({
7986
8068
  body,
7987
8069
  header,
7988
8070
  footer,
7989
- backgroundColor
8071
+ backgroundColor,
8072
+ contentContainer: ContentContainer = ({
8073
+ children
8074
+ }) => children
7990
8075
  }) {
7991
- return /*#__PURE__*/jsxRuntime.jsxs(FullscreenModalContainer, {
8076
+ return /*#__PURE__*/jsxRuntime.jsx(FullscreenModalContainer, {
7992
8077
  backgroundColor: backgroundColor,
7993
- children: [header ? /*#__PURE__*/jsxRuntime.jsx(View, {
7994
- children: header
7995
- }) : null, /*#__PURE__*/jsxRuntime.jsxs(View, {
7996
- flexGrow: 1,
7997
- flexShrink: 1,
7998
- justifyContent: "space-between",
7999
- children: [/*#__PURE__*/jsxRuntime.jsx(reactNative.ScrollView, {
8000
- bounces: false,
8001
- contentContainerStyle: {
8002
- flexGrow: 1,
8003
- position: 'relative'
8004
- },
8005
- children: body
8006
- }), footer || null]
8007
- })]
8078
+ children: /*#__PURE__*/jsxRuntime.jsxs(ContentContainer, {
8079
+ children: [header ? /*#__PURE__*/jsxRuntime.jsx(View, {
8080
+ children: header
8081
+ }) : null, /*#__PURE__*/jsxRuntime.jsxs(View, {
8082
+ flexGrow: 1,
8083
+ flexShrink: 1,
8084
+ justifyContent: "space-between",
8085
+ children: [/*#__PURE__*/jsxRuntime.jsx(reactNative.ScrollView, {
8086
+ bounces: false,
8087
+ contentContainerStyle: {
8088
+ flexGrow: 1,
8089
+ position: 'relative'
8090
+ },
8091
+ children: body
8092
+ }), footer || null]
8093
+ })]
8094
+ })
8008
8095
  });
8009
8096
  }
8010
8097
  FullscreenModal.Header = FullscreenModalHeader;
@@ -11373,7 +11460,9 @@ function KittNativeBaseProvider({
11373
11460
  isSSR: isSSR,
11374
11461
  children: /*#__PURE__*/jsxRuntime.jsx(KittThemeContext.Provider, {
11375
11462
  value: kittInternalTheme,
11376
- children: children
11463
+ children: /*#__PURE__*/jsxRuntime.jsx(CurrentBreakpointProvider, {
11464
+ children: children
11465
+ })
11377
11466
  })
11378
11467
  });
11379
11468
  }
@@ -13288,13 +13377,6 @@ function Tooltip({
13288
13377
  });
13289
13378
  const tooltipY = Math.round(y ?? 0) || 0;
13290
13379
  const tooltipX = Math.round(x ?? 0) || 0;
13291
- console.log({
13292
- tooltipY,
13293
- tooltipX,
13294
- placement,
13295
- currentFloatingPadding,
13296
- floatingWidth
13297
- });
13298
13380
  React.useEffect(() => {
13299
13381
  if (!onUpdate) return;
13300
13382
  onUpdate({
@@ -13330,7 +13412,6 @@ function Tooltip({
13330
13412
  children: renderPressable({
13331
13413
  ref: getPressableRect,
13332
13414
  onPress: () => {
13333
- console.log('handlePress', pressed.value);
13334
13415
  if (onToggle) onToggle(!!pressed.value);
13335
13416
  pressed.value = !pressed.value;
13336
13417
  },
@@ -13583,21 +13664,15 @@ function MatchWindowSize({
13583
13664
  }
13584
13665
  /**
13585
13666
  * Display based on current breakpoint
13667
+ * Mimics the behavior of Native Base's SwitchBreakpoints, but uses our custom context for better performance.
13586
13668
  *
13587
13669
  * WARNING: Currently not SSR friendly (but could be).
13588
13670
  */
13589
- function SwitchBreakpoints(breakpoints) {
13590
- return useBreakpointValue(breakpoints);
13591
- }
13592
-
13593
- function useCurrentBreakpointName() {
13594
- return useBreakpointValue({
13595
- base: KittBreakpointNameEnum.BASE,
13596
- small: KittBreakpointNameEnum.SMALL,
13597
- medium: KittBreakpointNameEnum.MEDIUM,
13598
- large: KittBreakpointNameEnum.LARGE,
13599
- wide: KittBreakpointNameEnum.WIDE
13600
- });
13671
+ function SwitchBreakpoints(values) {
13672
+ const {
13673
+ breakpoint
13674
+ } = useCurrentBreakpointName();
13675
+ return getValueForBreakpoint(breakpoint, values);
13601
13676
  }
13602
13677
 
13603
13678
  function useStepAnimations({
@@ -13965,6 +14040,7 @@ exports.View = View;
13965
14040
  exports.createChoicesComponent = createChoicesComponent;
13966
14041
  exports.createResponsiveStyleFromProp = createResponsiveStyleFromProp;
13967
14042
  exports.getStaticMapImageUrl = getStaticMapImageUrl;
14043
+ exports.getValueForBreakpoint = getValueForBreakpoint;
13968
14044
  exports.hex2rgba = hex2rgba;
13969
14045
  exports.matchWindowSize = matchWindowSize;
13970
14046
  exports.storyPadding = storyPadding;