@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
package/dist/index.es.js CHANGED
@@ -1,11 +1,11 @@
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 _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
5
5
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
6
6
  import { jsx, jsxs } from 'react/jsx-runtime';
7
7
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
8
- import { createContext, useContext, cloneElement, useMemo, useEffect } from 'react';
8
+ import { cloneElement, useMemo, useEffect } from 'react';
9
9
  import Animated, { Easing, useAnimatedProps, useSharedValue, withRepeat, withTiming } from 'react-native-reanimated';
10
10
  import Svg, { Circle } from 'react-native-svg';
11
11
  export { Image } from '@tamagui/image';
@@ -422,13 +422,13 @@ var Center = styled(View, {
422
422
  alignItems: 'center'
423
423
  });
424
424
 
425
- var _excluded$1 = ["as"];
425
+ var _excluded = ["as"];
426
426
  /**
427
427
  * A polymorphic Pressable component that can render as any Tamagui primitive.
428
428
  */
429
429
  function Pressable(_ref) {
430
430
  var as = _ref.as,
431
- rest = _objectWithoutProperties(_ref, _excluded$1);
431
+ rest = _objectWithoutProperties(_ref, _excluded);
432
432
  var Component = styled(as !== null && as !== void 0 ? as : View, {
433
433
  name: 'Pressable',
434
434
  role: 'button',
@@ -446,78 +446,56 @@ var VStack = styled(Stack, {
446
446
  flexDirection: 'column'
447
447
  });
448
448
 
449
- function getVariantAndWeightValues(weightProp, variantProp, typographyWeightAncestorValue, typographyVariantAncestorValue) {
450
- var computedVariant = variantProp || typographyVariantAncestorValue || undefined;
451
- if (computedVariant) {
452
- if (BODY_VARIANTS.includes(computedVariant)) {
453
- var computedWeight = weightProp || typographyWeightAncestorValue || undefined;
454
- return {
455
- weight: computedWeight,
456
- variant: computedVariant
457
- };
458
- }
459
- // Content Caps variant have fixed weights so we override any provided weight
460
- if (CONTENT_CAPS_VARIANTS.includes(computedVariant)) {
461
- return {
462
- weight: 'bold',
463
- variant: computedVariant
464
- };
465
- }
466
- // Heading variants have fixed weights so we override any provided weight
467
- if (HEADING_VARIANTS.includes(computedVariant)) {
468
- return {
469
- weight: 'semibold',
470
- variant: computedVariant
471
- };
472
- }
473
- // Label variants have fixed weights so we override any provided weight
474
- if (LABEL_VARIANTS.includes(computedVariant)) {
475
- return {
476
- weight: 'semibold',
477
- variant: computedVariant
478
- };
479
- }
480
- }
481
- return {
482
- weight: weightProp,
483
- variant: undefined
484
- };
485
- }
486
-
487
- var TypographyVariantContext = /*#__PURE__*/createContext(null);
488
- var TypographyWeightContext = /*#__PURE__*/createContext(null);
489
- var TypograhyColorContext = /*#__PURE__*/createContext(null);
490
- var TypographyContext = /*#__PURE__*/createContext(false);
491
- var useTypographyColor = function () {
492
- return useContext(TypograhyColorContext);
493
- };
494
- var useTypographyVariant = function () {
495
- return useContext(TypographyVariantContext);
496
- };
497
- var useTypographyWeight = function () {
498
- return useContext(TypographyWeightContext);
499
- };
500
- var useTypographyContext = function () {
501
- return useContext(TypographyContext);
502
- };
449
+ var typographyStyleContext = createStyledContext({
450
+ color: undefined,
451
+ weight: undefined,
452
+ variant: undefined
453
+ });
503
454
 
504
- var InternalTypographyBase = styled(Text, {
455
+ var InternalTypography = styled(Text, {
456
+ context: typographyStyleContext,
505
457
  fontFamily: '$GTStandard',
458
+ fontSize: '$body-m',
459
+ lineHeight: '$body-m',
460
+ letterSpacing: '$body-m',
461
+ fontWeight: '$regular',
506
462
  color: '$content.base.hi',
507
463
  '$platform-web': {
508
464
  WebkitFontSmoothing: 'antialiased'
509
465
  },
510
466
  variants: {
511
467
  variant: function (_variant) {
512
- if (!_variant) return {};
513
- var isContentCapsVariant = CONTENT_CAPS_VARIANTS.includes(_variant);
514
- return {
515
- fontFamily: isContentCapsVariant ? '$GTStandardNarrow' : '$GTStandard',
516
- textTransform: isContentCapsVariant ? 'uppercase' : undefined,
468
+ var commonVariantStyles = {
517
469
  fontSize: "$".concat(_variant),
518
470
  lineHeight: "$".concat(_variant),
519
471
  letterSpacing: "$".concat(_variant)
520
472
  };
473
+
474
+ // Body variant
475
+ if (BODY_VARIANTS.includes(_variant)) {
476
+ return _objectSpread({}, commonVariantStyles);
477
+ }
478
+ // Content Caps variant
479
+ if (CONTENT_CAPS_VARIANTS.includes(_variant)) {
480
+ return _objectSpread({
481
+ fontFamily: '$GTStandardNarrow',
482
+ textTransform: 'uppercase',
483
+ fontWeight: '$bold'
484
+ }, commonVariantStyles);
485
+ }
486
+ // Heading variants
487
+ if (HEADING_VARIANTS.includes(_variant)) {
488
+ return _objectSpread({
489
+ fontWeight: '$semibold'
490
+ }, commonVariantStyles);
491
+ }
492
+ // Label variants
493
+ if (LABEL_VARIANTS.includes(_variant)) {
494
+ return _objectSpread({
495
+ fontWeight: '$semibold'
496
+ }, commonVariantStyles);
497
+ }
498
+ return undefined;
521
499
  },
522
500
  weight: {
523
501
  regular: {
@@ -532,52 +510,9 @@ var InternalTypographyBase = styled(Text, {
532
510
  }
533
511
  },
534
512
  defaultVariants: {
535
- variant: 'body-m',
536
513
  weight: 'regular'
537
514
  }
538
515
  });
539
- var InternalTypography = InternalTypographyBase.styleable(function (props, ref) {
540
- var typographyVariantAncestorValue = useTypographyVariant();
541
- var typographyWeightAncestorValue = useTypographyWeight();
542
- var typographyColorAncestorValue = useTypographyColor();
543
- var typographyContext = useTypographyContext();
544
- var _getVariantAndWeightV = getVariantAndWeightValues(props.weight, props.variant, typographyWeightAncestorValue, typographyVariantAncestorValue),
545
- variant = _getVariantAndWeightV.variant,
546
- weight = _getVariantAndWeightV.weight;
547
- var color = props.color || typographyColorAncestorValue || undefined;
548
- var content = /*#__PURE__*/jsx(InternalTypographyBase, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
549
- ref: ref
550
- }, props), color ? {
551
- color: color
552
- } : undefined), weight ? {
553
- weight: weight
554
- } : undefined), variant ? {
555
- variant: variant
556
- } : undefined));
557
- content = typographyContext ? content : /*#__PURE__*/jsx(TypographyContext.Provider, {
558
- value: true,
559
- children: content
560
- });
561
-
562
- // If a variant is provided, we set it in the context for children to be able to inherit variant value
563
- content = props.variant ? /*#__PURE__*/jsx(TypographyVariantContext.Provider, {
564
- value: props.variant,
565
- children: content
566
- }) : content;
567
-
568
- // If a weight is provided, we set it in the context for children to be able to inherit weight value
569
- content = props.weight ? /*#__PURE__*/jsx(TypographyWeightContext.Provider, {
570
- value: props.weight,
571
- children: content
572
- }) : content;
573
-
574
- // If a color is provided, we set it in the context for children to be able to inherit color value
575
- content = props.color ? /*#__PURE__*/jsx(TypograhyColorContext.Provider, {
576
- value: props.color,
577
- children: content
578
- }) : content;
579
- return content;
580
- });
581
516
  function TypographyBase(props) {
582
517
  return /*#__PURE__*/jsx(InternalTypography, _objectSpread({}, props));
583
518
  }
@@ -591,6 +526,13 @@ var createHeading = function (level) {
591
526
  };
592
527
  };
593
528
 
529
+ // eslint-disable-next-line no-restricted-imports
530
+ // This hook is a wrapper around Tamagui's useProps to extract only the non-media props from the given props object.
531
+ // 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).
532
+ function useProps(props) {
533
+ return useProps$1(props);
534
+ }
535
+
594
536
  var IconContainer = styled(View, {
595
537
  name: 'Icon',
596
538
  variants: {
@@ -603,76 +545,45 @@ var IconContainer = styled(View, {
603
545
  }
604
546
  }
605
547
  });
606
- function Icon(_ref2) {
607
- var icon = _ref2.icon,
608
- _ref2$color = _ref2.color,
609
- color = _ref2$color === void 0 ? '$content.base.hi' : _ref2$color,
610
- _ref2$size = _ref2.size,
611
- size = _ref2$size === void 0 ? '$icon.m' : _ref2$size,
612
- testID = _ref2.testID,
613
- alignSelf = _ref2.alignSelf;
548
+ var InternalIcon = IconContainer.styleable(function (props) {
549
+ var flattenProps = useProps(props);
614
550
  var style = useStyle({
615
- color: color
551
+ color: flattenProps.color || '$content.base.hi'
616
552
  });
617
- var clonedIcon = /*#__PURE__*/cloneElement(icon, {
553
+ var clonedIcon = /*#__PURE__*/cloneElement(flattenProps.icon, {
618
554
  color: style.color
619
555
  });
620
556
  return /*#__PURE__*/jsx(IconContainer, {
621
- size: size,
622
- testID: testID,
623
- alignSelf: alignSelf,
557
+ size: flattenProps.size,
558
+ testID: flattenProps.testID,
559
+ alignSelf: flattenProps.alignSelf,
624
560
  children: clonedIcon
625
561
  });
626
- }
562
+ });
627
563
 
628
564
  var InternalTypographyView = styled(View, {
629
- name: 'TypographyView'
565
+ name: 'TypographyViewInternal',
566
+ '$platform-web': {
567
+ display: 'inline-flex'
568
+ }
630
569
  });
631
- /**
632
- *
633
- * A wrapper component that applies typography styles to its children in order to maintain consistent style between web and native
634
- * In native, it simply renders a View as it renders correctly by default
635
- * In web, it ensures that the display is set to inline-flex when inside a Typography context
636
- *
637
- * React Native Web includes this implementation in its codebase
638
- * but Tamagui does not use React Native Webview, we need to implement it ourselves
639
- *
640
- * Inside a Typography component, always use TypographyView to wrap external components like Icon or Svg
641
- */
642
570
  function TypographyView(props) {
643
- var isInTypographyContext = useTypographyContext();
644
- return /*#__PURE__*/jsx(InternalTypographyView, _objectSpread(_objectSpread({}, props), {}, {
645
- "$platform-web": isInTypographyContext ? _objectSpread(_objectSpread({}, props['$platform-web']), {}, {
646
- display: 'inline-flex'
647
- }) : props['$platform-web']
648
- }));
571
+ return /*#__PURE__*/jsx(InternalTypographyView, _objectSpread({}, props));
649
572
  }
650
573
 
651
- var _excluded = ["color"];
652
- function TypographyIconInternal(props) {
574
+ var TypographyIconInternal = styled(InternalIcon, {
575
+ name: 'TypographyIconInternal',
576
+ context: typographyStyleContext
577
+ });
578
+ function TypographyIcon(props) {
653
579
  return /*#__PURE__*/jsx(TypographyView, {
654
- children: /*#__PURE__*/jsx(Icon, _objectSpread({}, props))
580
+ children: /*#__PURE__*/jsx(TypographyIconInternal, _objectSpread({}, props))
655
581
  });
656
582
  }
657
- function TypographyIconInheritColor(props) {
658
- var typographyColorAncestorValue = useTypographyColor();
659
- return /*#__PURE__*/jsx(TypographyIconInternal, _objectSpread({
660
- color: typographyColorAncestorValue || undefined
661
- }, props));
662
- }
663
- function TypographyIcon(_ref) {
664
- var color = _ref.color,
665
- props = _objectWithoutProperties(_ref, _excluded);
666
- if (color) {
667
- return /*#__PURE__*/jsx(TypographyIconInternal, _objectSpread({
668
- color: color
669
- }, props));
670
- }
671
- return /*#__PURE__*/jsx(TypographyIconInheritColor, _objectSpread({}, props));
672
- }
673
583
 
674
584
  var InternalTypographyLink = styled(InternalTypography, {
675
585
  name: 'TypographyLink',
586
+ context: typographyStyleContext,
676
587
  role: 'link',
677
588
  variants: {
678
589
  disabled: {