@ornikar/bumper 3.1.0 → 3.2.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 (81) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/definitions/shared/storybook/StoryTitle.d.ts +1 -1
  3. package/dist/definitions/system/content/icon/Icon.d.ts +6 -1
  4. package/dist/definitions/system/content/icon/Icon.d.ts.map +1 -1
  5. package/dist/definitions/system/content/typography/Typography.d.ts +10 -52
  6. package/dist/definitions/system/content/typography/Typography.d.ts.map +1 -1
  7. package/dist/definitions/system/content/typography/TypographyIcon.d.ts +5 -2
  8. package/dist/definitions/system/content/typography/TypographyIcon.d.ts.map +1 -1
  9. package/dist/definitions/system/content/typography/TypographyLink.d.ts +1 -1
  10. package/dist/definitions/system/content/typography/TypographyLink.d.ts.map +1 -1
  11. package/dist/definitions/system/content/typography/TypographyView.d.ts +2 -2
  12. package/dist/definitions/system/content/typography/TypographyView.d.ts.map +1 -1
  13. package/dist/definitions/system/content/typography/utils/typographyContext.d.ts +8 -13
  14. package/dist/definitions/system/content/typography/utils/typographyContext.d.ts.map +1 -1
  15. package/dist/definitions/system/core/hooks/useProps.d.ts +3 -0
  16. package/dist/definitions/system/core/hooks/useProps.d.ts.map +1 -0
  17. package/dist/definitions/system/dataDisplays/Badge/Badge.d.ts.map +1 -1
  18. package/dist/definitions/system/types.d.ts +1 -2
  19. package/dist/definitions/system/types.d.ts.map +1 -1
  20. package/dist/index-metro.es.android.js +69 -160
  21. package/dist/index-metro.es.android.js.map +1 -1
  22. package/dist/index-metro.es.ios.js +69 -160
  23. package/dist/index-metro.es.ios.js.map +1 -1
  24. package/dist/index-node-22.22.cjs.js +71 -163
  25. package/dist/index-node-22.22.cjs.js.map +1 -1
  26. package/dist/index-node-22.22.cjs.web.js +71 -163
  27. package/dist/index-node-22.22.cjs.web.js.map +1 -1
  28. package/dist/index-node-22.22.es.mjs +72 -164
  29. package/dist/index-node-22.22.es.mjs.map +1 -1
  30. package/dist/index-node-22.22.es.web.mjs +72 -164
  31. package/dist/index-node-22.22.es.web.mjs.map +1 -1
  32. package/dist/index.es.js +69 -158
  33. package/dist/index.es.js.map +1 -1
  34. package/dist/index.es.web.js +69 -158
  35. package/dist/index.es.web.js.map +1 -1
  36. package/dist/tsbuildinfo +1 -1
  37. package/package.json +1 -1
  38. package/src/.eslintrc.json +2 -2
  39. package/src/system/content/icon/Icon.tsx +10 -4
  40. package/src/system/content/icon/__snapshots_web__/Icon.features.stories.tsx.snap +11 -22
  41. package/src/system/content/typography/Typography.tsx +66 -75
  42. package/src/system/content/typography/TypographyIcon.tsx +14 -19
  43. package/src/system/content/typography/TypographyLink.features.stories.tsx +34 -8
  44. package/src/system/content/typography/TypographyLink.stories.tsx +2 -1
  45. package/src/system/content/typography/TypographyLink.tsx +2 -0
  46. package/src/system/content/typography/TypographyView.tsx +10 -17
  47. package/src/system/content/typography/__snapshots__/TypographyLink.features.stories.tsx.snap +164 -0
  48. package/src/system/content/typography/__snapshots_web__/Typography.features.stories.tsx.snap +40 -86
  49. package/src/system/content/typography/__snapshots_web__/Typography.stories.tsx.snap +0 -1
  50. package/src/system/content/typography/__snapshots_web__/TypographyIcon.features.stories.tsx.snap +42 -67
  51. package/src/system/content/typography/__snapshots_web__/TypographyIcon.stories.tsx.snap +1 -1
  52. package/src/system/content/typography/__snapshots_web__/TypographyLink.features.stories.tsx.snap +120 -20
  53. package/src/system/content/typography/__snapshots_web__/TypographyLink.stories.tsx.snap +1 -2
  54. package/src/system/content/typography/utils/typographyContext.ts +13 -25
  55. package/src/system/core/hooks/useProps.ts +9 -0
  56. package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.features.stories.tsx.snap +37 -74
  57. package/src/system/core/primitives/ScrollView/__snapshots_web__/ScrollView.stories.tsx.snap +10 -20
  58. package/src/system/core/primitives/__snapshots_web__/Center.features.stories.tsx.snap +5 -10
  59. package/src/system/core/primitives/__snapshots_web__/Center.stories.tsx.snap +1 -2
  60. package/src/system/core/primitives/__snapshots_web__/Pressable.features.stories.tsx.snap +9 -18
  61. package/src/system/core/primitives/__snapshots_web__/Pressable.stories.tsx.snap +0 -1
  62. package/src/system/core/primitives/__snapshots_web__/Stack.features.stories.tsx.snap +33 -66
  63. package/src/system/core/primitives/__snapshots_web__/Stack.stories.tsx.snap +3 -6
  64. package/src/system/core/primitives/__snapshots_web__/View.features.stories.tsx.snap +60 -120
  65. package/src/system/core/themes/light/__snapshots_web__/light.stories.tsx.snap +111 -222
  66. package/src/system/core/tokens/__snapshots_web__/breakpoints.stories.tsx.snap +11 -22
  67. package/src/system/core/tokens/__snapshots_web__/bumperIcon.stories.tsx.snap +7 -14
  68. package/src/system/core/tokens/__snapshots_web__/fonts.stories.tsx.snap +67 -134
  69. package/src/system/core/tokens/__snapshots_web__/radius.stories.tsx.snap +11 -22
  70. package/src/system/core/tokens/__snapshots_web__/size.stories.tsx.snap +25 -50
  71. package/src/system/core/tokens/__snapshots_web__/space.stories.tsx.snap +28 -56
  72. package/src/system/core/tokens/palettes/__snapshots_web__/deepPurpleColorPalette.stories.tsx.snap +133 -266
  73. package/src/system/dataDisplays/Badge/Badge.tsx +2 -1
  74. package/src/system/dataDisplays/Badge/__snapshots_web__/Badge.features.stories.tsx.snap +8 -16
  75. package/src/system/dataDisplays/Badge/__snapshots_web__/Badge.stories.tsx.snap +1 -2
  76. package/src/system/loading/loader/__snapshots_web__/Loader.features.stories.tsx.snap +2 -4
  77. package/src/system/types.ts +2 -1
  78. package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts +0 -10
  79. package/dist/definitions/system/content/typography/utils/getVariantAndWeightValues.d.ts.map +0 -1
  80. package/src/system/content/typography/utils/getVariantAndWeightValues.test.tsx +0 -178
  81. package/src/system/content/typography/utils/getVariantAndWeightValues.tsx +0 -40
@@ -1,9 +1,9 @@
1
- import { px, createFont, createTokens, createTamagui, TamaguiProvider, styled, View, Stack, Text, useStyle, useProps, useMedia } from '@tamagui/core';
1
+ import { px, createFont, createTokens, createTamagui, TamaguiProvider, styled, View, Stack, createStyledContext, Text, useProps as useProps$1, useStyle, useMedia } from '@tamagui/core';
2
2
  export { Stack, View } from '@tamagui/core';
3
3
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
4
4
  import { jsx, jsxs } from 'react/jsx-runtime';
5
5
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
6
- import { createContext, useContext, cloneElement, useMemo, useEffect } from 'react';
6
+ import { cloneElement, useMemo, useEffect } from 'react';
7
7
  import Animated, { Easing, useAnimatedProps, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
8
8
  import Svg, { Circle } from 'react-native-svg';
9
9
  export { Image } from '@tamagui/image';
@@ -425,7 +425,7 @@ const Center = styled(View, {
425
425
  alignItems: 'center'
426
426
  });
427
427
 
428
- const _excluded$1 = ["as"];
428
+ const _excluded = ["as"];
429
429
  /**
430
430
  * A polymorphic Pressable component that can render as any Tamagui primitive.
431
431
  */
@@ -433,7 +433,7 @@ function Pressable(_ref) {
433
433
  let {
434
434
  as
435
435
  } = _ref,
436
- rest = _objectWithoutProperties(_ref, _excluded$1);
436
+ rest = _objectWithoutProperties(_ref, _excluded);
437
437
  const Component = styled(as !== null && as !== void 0 ? as : View, {
438
438
  name: 'Pressable',
439
439
  role: 'button',
@@ -451,78 +451,56 @@ const VStack = styled(Stack, {
451
451
  flexDirection: 'column'
452
452
  });
453
453
 
454
- function getVariantAndWeightValues(weightProp, variantProp, typographyWeightAncestorValue, typographyVariantAncestorValue) {
455
- const computedVariant = variantProp || typographyVariantAncestorValue || undefined;
456
- if (computedVariant) {
457
- if (BODY_VARIANTS.includes(computedVariant)) {
458
- const computedWeight = weightProp || typographyWeightAncestorValue || undefined;
459
- return {
460
- weight: computedWeight,
461
- variant: computedVariant
462
- };
463
- }
464
- // Content Caps variant have fixed weights so we override any provided weight
465
- if (CONTENT_CAPS_VARIANTS.includes(computedVariant)) {
466
- return {
467
- weight: 'bold',
468
- variant: computedVariant
469
- };
470
- }
471
- // Heading variants have fixed weights so we override any provided weight
472
- if (HEADING_VARIANTS.includes(computedVariant)) {
473
- return {
474
- weight: 'semibold',
475
- variant: computedVariant
476
- };
477
- }
478
- // Label variants have fixed weights so we override any provided weight
479
- if (LABEL_VARIANTS.includes(computedVariant)) {
480
- return {
481
- weight: 'semibold',
482
- variant: computedVariant
483
- };
484
- }
485
- }
486
- return {
487
- weight: weightProp,
488
- variant: undefined
489
- };
490
- }
491
-
492
- const TypographyVariantContext = /*#__PURE__*/createContext(null);
493
- const TypographyWeightContext = /*#__PURE__*/createContext(null);
494
- const TypograhyColorContext = /*#__PURE__*/createContext(null);
495
- const TypographyContext = /*#__PURE__*/createContext(false);
496
- const useTypographyColor = () => {
497
- return useContext(TypograhyColorContext);
498
- };
499
- const useTypographyVariant = () => {
500
- return useContext(TypographyVariantContext);
501
- };
502
- const useTypographyWeight = () => {
503
- return useContext(TypographyWeightContext);
504
- };
505
- const useTypographyContext = () => {
506
- return useContext(TypographyContext);
507
- };
454
+ const typographyStyleContext = createStyledContext({
455
+ color: undefined,
456
+ weight: undefined,
457
+ variant: undefined
458
+ });
508
459
 
509
- const InternalTypographyBase = styled(Text, {
460
+ const InternalTypography = styled(Text, {
461
+ context: typographyStyleContext,
510
462
  fontFamily: '$GTStandard',
463
+ fontSize: '$body-m',
464
+ lineHeight: '$body-m',
465
+ letterSpacing: '$body-m',
466
+ fontWeight: '$regular',
511
467
  color: '$content.base.hi',
512
468
  '$platform-web': {
513
469
  WebkitFontSmoothing: 'antialiased'
514
470
  },
515
471
  variants: {
516
472
  variant: variant => {
517
- if (!variant) return {};
518
- const isContentCapsVariant = CONTENT_CAPS_VARIANTS.includes(variant);
519
- return {
520
- fontFamily: isContentCapsVariant ? '$GTStandardNarrow' : '$GTStandard',
521
- textTransform: isContentCapsVariant ? 'uppercase' : undefined,
473
+ const commonVariantStyles = {
522
474
  fontSize: `$${variant}`,
523
475
  lineHeight: `$${variant}`,
524
476
  letterSpacing: `$${variant}`
525
477
  };
478
+
479
+ // Body variant
480
+ if (BODY_VARIANTS.includes(variant)) {
481
+ return _objectSpread({}, commonVariantStyles);
482
+ }
483
+ // Content Caps variant
484
+ if (CONTENT_CAPS_VARIANTS.includes(variant)) {
485
+ return _objectSpread({
486
+ fontFamily: '$GTStandardNarrow',
487
+ textTransform: 'uppercase',
488
+ fontWeight: '$bold'
489
+ }, commonVariantStyles);
490
+ }
491
+ // Heading variants
492
+ if (HEADING_VARIANTS.includes(variant)) {
493
+ return _objectSpread({
494
+ fontWeight: '$semibold'
495
+ }, commonVariantStyles);
496
+ }
497
+ // Label variants
498
+ if (LABEL_VARIANTS.includes(variant)) {
499
+ return _objectSpread({
500
+ fontWeight: '$semibold'
501
+ }, commonVariantStyles);
502
+ }
503
+ return undefined;
526
504
  },
527
505
  weight: {
528
506
  regular: {
@@ -537,53 +515,9 @@ const InternalTypographyBase = styled(Text, {
537
515
  }
538
516
  },
539
517
  defaultVariants: {
540
- variant: 'body-m',
541
518
  weight: 'regular'
542
519
  }
543
520
  });
544
- const InternalTypography = InternalTypographyBase.styleable((props, ref) => {
545
- const typographyVariantAncestorValue = useTypographyVariant();
546
- const typographyWeightAncestorValue = useTypographyWeight();
547
- const typographyColorAncestorValue = useTypographyColor();
548
- const typographyContext = useTypographyContext();
549
- const {
550
- variant,
551
- weight
552
- } = getVariantAndWeightValues(props.weight, props.variant, typographyWeightAncestorValue, typographyVariantAncestorValue);
553
- const color = props.color || typographyColorAncestorValue || undefined;
554
- let content = /*#__PURE__*/jsx(InternalTypographyBase, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
555
- ref: ref
556
- }, props), color ? {
557
- color
558
- } : undefined), weight ? {
559
- weight
560
- } : undefined), variant ? {
561
- variant
562
- } : undefined));
563
- content = typographyContext ? content : /*#__PURE__*/jsx(TypographyContext.Provider, {
564
- value: true,
565
- children: content
566
- });
567
-
568
- // If a variant is provided, we set it in the context for children to be able to inherit variant value
569
- content = props.variant ? /*#__PURE__*/jsx(TypographyVariantContext.Provider, {
570
- value: props.variant,
571
- children: content
572
- }) : content;
573
-
574
- // If a weight is provided, we set it in the context for children to be able to inherit weight value
575
- content = props.weight ? /*#__PURE__*/jsx(TypographyWeightContext.Provider, {
576
- value: props.weight,
577
- children: content
578
- }) : content;
579
-
580
- // If a color is provided, we set it in the context for children to be able to inherit color value
581
- content = props.color ? /*#__PURE__*/jsx(TypograhyColorContext.Provider, {
582
- value: props.color,
583
- children: content
584
- }) : content;
585
- return content;
586
- });
587
521
  function TypographyBase(props) {
588
522
  return /*#__PURE__*/jsx(InternalTypography, _objectSpread({}, props));
589
523
  }
@@ -597,6 +531,13 @@ const createHeading = level => {
597
531
  };
598
532
  };
599
533
 
534
+ // eslint-disable-next-line no-restricted-imports
535
+ // This hook is a wrapper around Tamagui's useProps to extract only the non-media props from the given props object.
536
+ // It uses our custom PropsWithoutMediaStyles type to ensure that all media props are optional, even if they are required in the original props type. This is necessary for our components which have required media props (like variant for Typography).
537
+ function useProps(props) {
538
+ return useProps$1(props);
539
+ }
540
+
600
541
  const IconContainer = styled(View, {
601
542
  name: 'Icon',
602
543
  variants: {
@@ -610,77 +551,45 @@ const IconContainer = styled(View, {
610
551
  }
611
552
  }
612
553
  });
613
- function Icon({
614
- icon,
615
- color = '$content.base.hi',
616
- size = '$icon.m',
617
- testID,
618
- alignSelf
619
- }) {
554
+ const InternalIcon = IconContainer.styleable(props => {
555
+ const flattenProps = useProps(props);
620
556
  const style = useStyle({
621
- color
557
+ color: flattenProps.color || '$content.base.hi'
622
558
  });
623
- const clonedIcon = /*#__PURE__*/cloneElement(icon, {
559
+ const clonedIcon = /*#__PURE__*/cloneElement(flattenProps.icon, {
624
560
  color: style.color
625
561
  });
626
562
  return /*#__PURE__*/jsx(IconContainer, {
627
- size: size,
628
- testID: testID,
629
- alignSelf: alignSelf,
563
+ size: flattenProps.size,
564
+ testID: flattenProps.testID,
565
+ alignSelf: flattenProps.alignSelf,
630
566
  children: clonedIcon
631
567
  });
632
- }
568
+ });
633
569
 
634
570
  const InternalTypographyView = styled(View, {
635
- name: 'TypographyView'
571
+ name: 'TypographyViewInternal',
572
+ '$platform-web': {
573
+ display: 'inline-flex'
574
+ }
636
575
  });
637
- /**
638
- *
639
- * A wrapper component that applies typography styles to its children in order to maintain consistent style between web and native
640
- * In native, it simply renders a View as it renders correctly by default
641
- * In web, it ensures that the display is set to inline-flex when inside a Typography context
642
- *
643
- * React Native Web includes this implementation in its codebase
644
- * but Tamagui does not use React Native Webview, we need to implement it ourselves
645
- *
646
- * Inside a Typography component, always use TypographyView to wrap external components like Icon or Svg
647
- */
648
576
  function TypographyView(props) {
649
- const isInTypographyContext = useTypographyContext();
650
- return /*#__PURE__*/jsx(InternalTypographyView, _objectSpread(_objectSpread({}, props), {}, {
651
- "$platform-web": isInTypographyContext ? _objectSpread(_objectSpread({}, props['$platform-web']), {}, {
652
- display: 'inline-flex'
653
- }) : props['$platform-web']
654
- }));
577
+ return /*#__PURE__*/jsx(InternalTypographyView, _objectSpread({}, props));
655
578
  }
656
579
 
657
- const _excluded = ["color"];
658
- function TypographyIconInternal(props) {
580
+ const TypographyIconInternal = styled(InternalIcon, {
581
+ name: 'TypographyIconInternal',
582
+ context: typographyStyleContext
583
+ });
584
+ function TypographyIcon(props) {
659
585
  return /*#__PURE__*/jsx(TypographyView, {
660
- children: /*#__PURE__*/jsx(Icon, _objectSpread({}, props))
586
+ children: /*#__PURE__*/jsx(TypographyIconInternal, _objectSpread({}, props))
661
587
  });
662
588
  }
663
- function TypographyIconInheritColor(props) {
664
- const typographyColorAncestorValue = useTypographyColor();
665
- return /*#__PURE__*/jsx(TypographyIconInternal, _objectSpread({
666
- color: typographyColorAncestorValue || undefined
667
- }, props));
668
- }
669
- function TypographyIcon(_ref) {
670
- let {
671
- color
672
- } = _ref,
673
- props = _objectWithoutProperties(_ref, _excluded);
674
- if (color) {
675
- return /*#__PURE__*/jsx(TypographyIconInternal, _objectSpread({
676
- color: color
677
- }, props));
678
- }
679
- return /*#__PURE__*/jsx(TypographyIconInheritColor, _objectSpread({}, props));
680
- }
681
589
 
682
590
  const InternalTypographyLink = styled(InternalTypography, {
683
591
  name: 'TypographyLink',
592
+ context: typographyStyleContext,
684
593
  role: 'link',
685
594
  variants: {
686
595
  disabled: {