@paypal/checkout-components 5.0.386 → 5.0.387

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.
@@ -481,6 +481,29 @@ const generateDisableMaxHeightStyles = ({
481
481
  .join("\n");
482
482
  };
483
483
 
484
+ const generateRebrandedDisableMaxHeightStyles = (): string => {
485
+ return Object.keys(BUTTON_REDESIGN_STYLE)
486
+ .map((redesign_size) => {
487
+ const { gap, fontSize, minHeight, maxHeight } =
488
+ getResponsiveRebrandedStyleVariables({
489
+ redesign_size,
490
+ });
491
+
492
+ return `
493
+ @media (min-height: ${minHeight}px) and (max-height: ${maxHeight}px) {
494
+ .${CLASS.BUTTON_REBRAND} > .${CLASS.BUTTON_LABEL} {
495
+ gap: ${gap}px;
496
+ }
497
+ .${CLASS.CONTAINER} .${CLASS.BUTTON_ROW} .${CLASS.TEXT},
498
+ .${CLASS.CONTAINER} .${CLASS.BUTTON_ROW} .${CLASS.SPACE} {
499
+ font-size: ${fontSize}px;
500
+ position: relative;
501
+ }
502
+ `;
503
+ })
504
+ .join("\n");
505
+ };
506
+
484
507
  const generateRebrandedButtonSizeStyles = ({
485
508
  height,
486
509
  disableMaxWidth,
@@ -506,6 +529,7 @@ const generateRebrandedButtonSizeStyles = ({
506
529
  maxHeight,
507
530
  minWidth,
508
531
  maxWidth,
532
+ minDualWidth,
509
533
  } = getResponsiveRebrandedStyleVariables({
510
534
  height,
511
535
  redesign_size,
@@ -520,7 +544,11 @@ const generateRebrandedButtonSizeStyles = ({
520
544
  }
521
545
 
522
546
  .${CLASS.BUTTON_ROW} {
523
- ${disableMaxHeight ? "" : `height: ${height || defaultHeight}px;`}
547
+ ${
548
+ disableMaxHeight
549
+ ? "height: 100%;"
550
+ : `height: ${height || defaultHeight}px;`
551
+ }
524
552
  vertical-align: top;
525
553
  ${disableMaxHeight ? "" : `max-height: ${height || maxHeight}px;`}
526
554
  }
@@ -563,37 +591,86 @@ const generateRebrandedButtonSizeStyles = ({
563
591
  )}px;
564
592
  }
565
593
 
566
- // TO:DO no margin on last-child not getting applied
594
+ /* TO:DO no margin on last-child not getting applied */
567
595
  .${CLASS.BUTTON_ROW}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.VERTICAL}.${
568
596
  CLASS.NUMBER
569
597
  }-${BUTTON_NUMBER.MULTIPLE}:last-child {
570
598
  margin-bottom: 0;
571
599
  }
572
- }`;
600
+ }
601
+
602
+ @media only screen and (min-width: ${minWidth}px) and (max-width: ${minDualWidth}px) {
603
+ .${CLASS.BUTTON_ROW}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${
604
+ CLASS.NUMBER
605
+ }-${BUTTON_NUMBER.MULTIPLE}.${CLASS.NUMBER}-0 {
606
+ width: 100%;
607
+ margin-right: 0;
608
+ }
573
609
 
574
- const disableMaxHeightStyles = `
575
- @media only screen and (min-width: ${minWidth}px) {
576
- .${CLASS.CONTAINER} {
577
- min-width: ${minWidth}px;
578
- ${disableMaxWidth ? "" : `max-width: ${maxWidth}px;`};
579
- ${disableMaxHeight ? "height: 100%;" : ""};
610
+ .${CLASS.BUTTON_ROW}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${
611
+ CLASS.NUMBER
612
+ }-${BUTTON_NUMBER.MULTIPLE}.${CLASS.NUMBER}-1 {
613
+ display: none;
614
+ }
615
+
616
+ .${CLASS.CONTAINER}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${
617
+ CLASS.NUMBER
618
+ }-${BUTTON_NUMBER.MULTIPLE} .${CLASS.TAGLINE} {
619
+ display: none;
580
620
  }
581
621
  }
582
622
 
583
- @media only screen and (min-height: ${minHeight}px) and (max-height: ${maxHeight}px) {
584
- .${CLASS.BUTTON_ROW} {
585
- height: ${height || minHeight}px;
586
- vertical-align: top;
587
- min-height: ${height || minHeight}px;
588
- max-height: ${height || maxHeight}px;
623
+ @media only screen and (min-width: ${max(minWidth, minDualWidth)}px) {
624
+ .${CLASS.BUTTON_ROW}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${
625
+ CLASS.NUMBER
626
+ }-${BUTTON_NUMBER.MULTIPLE}.${CLASS.NUMBER}-0 {
627
+ display: inline-block;
628
+ width: calc(${FIRST_BUTTON_PERC}% - ${perc(buttonHeight, 7)}px);
629
+ margin-right: ${perc(buttonHeight, 7) * 2}px;
589
630
  }
590
631
 
591
- .${CLASS.BUTTON_REBRAND} > .${CLASS.BUTTON_LABEL} {
592
- margin: 0px 4vw;
593
- box-sizing: border-box;
594
- height: ${buttonHeight * 0.76}px;
632
+ .${CLASS.BUTTON_ROW}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${
633
+ CLASS.NUMBER
634
+ }-${BUTTON_NUMBER.MULTIPLE}.${CLASS.NUMBER}-1 {
635
+ display: inline-block;
636
+ width: calc(${100 - FIRST_BUTTON_PERC}% - ${perc(
637
+ buttonHeight,
638
+ 7
639
+ )}px);
595
640
  }
596
- }`;
641
+
642
+ .${CLASS.CONTAINER}.${CLASS.WALLET} .${CLASS.BUTTON_ROW}.${
643
+ CLASS.WALLET
644
+ }.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${CLASS.NUMBER}-${
645
+ BUTTON_NUMBER.MULTIPLE
646
+ } {
647
+ width: calc(${WALLET_BUTTON_PERC}% - ${perc(buttonHeight, 7)}px);
648
+ }
649
+
650
+ .${CLASS.CONTAINER}.${CLASS.WALLET} .${CLASS.BUTTON_ROW}:not(.${
651
+ CLASS.WALLET
652
+ }).${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${CLASS.NUMBER}-${
653
+ BUTTON_NUMBER.MULTIPLE
654
+ } {
655
+ width: calc(${100 - WALLET_BUTTON_PERC}% - ${perc(
656
+ buttonHeight,
657
+ 7
658
+ )}px);
659
+ }
660
+
661
+ .${CLASS.CONTAINER}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${
662
+ CLASS.NUMBER
663
+ }-${BUTTON_NUMBER.MULTIPLE} .${CLASS.TAGLINE} {
664
+ display: block;
665
+ }
666
+
667
+ .${CLASS.CONTAINER}.${CLASS.LAYOUT}-${BUTTON_LAYOUT.HORIZONTAL}.${
668
+ CLASS.NUMBER
669
+ }-${BUTTON_NUMBER.MULTIPLE} .${CLASS.TAGLINE} .${CLASS.TEXT} {
670
+ display: block;
671
+ }
672
+ }
673
+ `;
597
674
 
598
675
  const heightBasedStyles = `
599
676
  @media only screen and (min-height: ${minHeight}px) and (max-height: ${maxHeight}px) {
@@ -734,9 +811,8 @@ const generateRebrandedButtonSizeStyles = ({
734
811
  width: ${buttonHeight}px;
735
812
  }
736
813
  }`;
737
- return disableMaxHeight
738
- ? disableMaxHeightStyles + heightBasedStyles
739
- : widthBasedStyles + heightBasedStyles;
814
+
815
+ return widthBasedStyles + heightBasedStyles;
740
816
  })
741
817
  .join("\n");
742
818
  };
@@ -780,6 +856,10 @@ export function buttonResponsiveStyle({
780
856
  })
781
857
  : "";
782
858
 
859
+ const disableMaxHeightRebrandedStyles =
860
+ disableMaxHeightStyles +
861
+ (disableMaxHeight ? generateRebrandedDisableMaxHeightStyles() : "");
862
+
783
863
  const baseStyles = `
784
864
  .${CLASS.BUTTON} {
785
865
  display: inline-block;
@@ -827,7 +907,7 @@ export function buttonResponsiveStyle({
827
907
  }`;
828
908
 
829
909
  const rebrandedStyles = shouldApplyRebrandedStyles
830
- ? buttonRedesignSizeStyles
910
+ ? buttonRedesignSizeStyles + disableMaxHeightRebrandedStyles
831
911
  : buttonSizeStyles + disableMaxHeightStyles;
832
912
 
833
913
  return baseStyles + rebrandedStyles;
@@ -61,6 +61,7 @@ import {
61
61
  isApplePaySupported,
62
62
  supportsPopups as userAgentSupportsPopups,
63
63
  noop,
64
+ getUserAgent,
64
65
  } from "@krakenjs/belter/src";
65
66
  import {
66
67
  FUNDING,
@@ -89,6 +90,10 @@ import {
89
90
  type ButtonExtensions,
90
91
  } from "../../ui/buttons/props";
91
92
  import { isFundingEligible } from "../../funding";
93
+ import {
94
+ supportsVenmoPopups,
95
+ isSupportedNativeVenmoBrowser,
96
+ } from "../../funding/util";
92
97
  import { getPixelComponent } from "../pixel";
93
98
  import { CLASS } from "../../constants";
94
99
  import { PayPalAppSwitchOverlay } from "../../ui/overlay/paypal-app-switch/overlay";
@@ -251,6 +256,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
251
256
  createSubscription,
252
257
  createVaultSetupToken,
253
258
  displayOnly,
259
+ userAgent,
254
260
  } = props;
255
261
 
256
262
  const flow = determineFlow({
@@ -294,6 +300,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
294
300
  supportedNativeBrowser,
295
301
  experiment,
296
302
  displayOnly,
303
+ userAgent,
297
304
  })
298
305
  ) {
299
306
  return {
@@ -714,6 +721,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
714
721
  createSubscription,
715
722
  createVaultSetupToken,
716
723
  displayOnly,
724
+ userAgent = getUserAgent(),
717
725
  } = props;
718
726
 
719
727
  const flow = determineFlow({
@@ -744,6 +752,7 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
744
752
  supportsPopups,
745
753
  supportedNativeBrowser,
746
754
  displayOnly,
755
+ userAgent,
747
756
  })
748
757
  ) {
749
758
  throw new Error(`${fundingSource} is not eligible`);
@@ -1266,13 +1275,32 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
1266
1275
 
1267
1276
  supportedNativeBrowser: {
1268
1277
  type: "boolean",
1269
- value: isSupportedNativeBrowser,
1278
+ value: ({ props }) => {
1279
+ if (props.fundingSource === FUNDING.VENMO) {
1280
+ return isSupportedNativeVenmoBrowser(
1281
+ props.experiment,
1282
+ props.userAgent
1283
+ );
1284
+ }
1285
+
1286
+ return isSupportedNativeBrowser();
1287
+ },
1270
1288
  queryParam: true,
1271
1289
  },
1272
1290
 
1273
1291
  supportsPopups: {
1274
1292
  type: "boolean",
1275
- value: () => userAgentSupportsPopups(),
1293
+ value: ({ props }) => {
1294
+ if (props.fundingSource === FUNDING.VENMO) {
1295
+ return supportsVenmoPopups(
1296
+ props.experiment,
1297
+ userAgentSupportsPopups(),
1298
+ props.userAgent
1299
+ );
1300
+ }
1301
+
1302
+ return userAgentSupportsPopups();
1303
+ },
1276
1304
  queryParam: true,
1277
1305
  },
1278
1306
 
@@ -1316,6 +1344,13 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
1316
1344
  required: false,
1317
1345
  queryParam: true,
1318
1346
  },
1347
+
1348
+ userAgent: {
1349
+ type: "string",
1350
+ required: false,
1351
+ queryParam: true,
1352
+ value: getUserAgent,
1353
+ },
1319
1354
  },
1320
1355
 
1321
1356
  exports: {