@funnelsgrove/payments 0.1.9 → 0.1.10

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.
@@ -31,7 +31,7 @@ function getFriendlyCardErrorMessage(error) {
31
31
  ? error.message
32
32
  : 'Payment failed. Please review your card details and try again.';
33
33
  }
34
- function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel, closeAriaLabel, countdownLabel, customerEmail, customerEmailEditable = false, customerEmailLabel = 'Email', customerEmailPlaceholder = 'Enter your email', customerEmailInvalidMessage = 'Enter a valid email address.', customerName, discountAmountLabel, discountLabel, discountPercent, initialWalletAvailable, nameOnCardPlaceholder = 'Name on card', onClose, onCustomerEmailChange, onCustomerEmailCommit, onError, onSuccess, paymentMethodLabels = defaultPaymentMethodLabels, promoActive, processingLabel, promoCode, promoCodeLabel, remainingSeconds, returnUrl, savedLabel, secureLabel, satisfactionLabel, satisfactionPercent, summaryLabel, themeColor, title, totalLabel, totalValue, walletButtonLabel, originalPriceLabel, originalPriceValue, }) {
34
+ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel, closeAriaLabel, countdownLabel, customerEmail, customerEmailEditable = false, customerEmailLabel = 'Email', customerEmailPlaceholder = 'Enter your email', customerEmailInvalidMessage = 'Enter a valid email address.', customerName, discountAmountLabel, discountLabel, discountPercent, initialWalletAvailable, onClose, onCustomerEmailChange, onCustomerEmailCommit, onError, onSuccess, paymentMethodLabels = defaultPaymentMethodLabels, promoActive, processingLabel, promoCode, promoCodeLabel, remainingSeconds, returnUrl, savedLabel, secureLabel, satisfactionLabel, satisfactionPercent, summaryLabel, themeColor, title, totalLabel, totalValue, walletButtonLabel, originalPriceLabel, originalPriceValue, }) {
35
35
  const checkoutState = useCheckout();
36
36
  const walletPaymentMethods = usePlatformWalletPaymentMethods();
37
37
  const [selectedMethod, setSelectedMethod] = useState('wallet');
@@ -41,16 +41,21 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
41
41
  : walletAvailable;
42
42
  const [submitting, setSubmitting] = useState(false);
43
43
  const [error, setError] = useState(null);
44
- const [emailDraft, setEmailDraft] = useState((customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '');
45
- const [nameOnCard, setNameOnCard] = useState((customerName === null || customerName === void 0 ? void 0 : customerName.trim()) || '');
44
+ const initialCustomerEmail = (customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '';
45
+ const [emailDraft, setEmailDraft] = useState(initialCustomerEmail);
46
46
  const cardBrandLabels = useMemo(() => paymentMethodLabels.length > 0 ? paymentMethodLabels : defaultPaymentMethodLabels, [paymentMethodLabels]);
47
47
  const normalizedPromoCode = promoCode.trim();
48
48
  const showPromo = promoActive !== null && promoActive !== void 0 ? promoActive : (discountPercent > 0 && normalizedPromoCode.length > 0);
49
49
  const countdownValue = formatCountdown(remainingSeconds);
50
- const initialCustomerEmail = (customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '';
51
50
  const resolvedCustomerEmail = customerEmailEditable
52
51
  ? emailDraft.trim() || initialCustomerEmail
53
52
  : initialCustomerEmail;
53
+ const emailFieldClassName = [
54
+ 'shared-checkout-v2-email-field',
55
+ customerEmailEditable ? '' : 'is-disabled',
56
+ ]
57
+ .filter(Boolean)
58
+ .join(' ');
54
59
  const checkoutStyle = {
55
60
  '--shared-checkout-v2-theme-color': themeColor,
56
61
  '--shared-checkout-v2-button-color': buttonColor,
@@ -90,7 +95,21 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
90
95
  }, [walletPaymentMethods]);
91
96
  const paymentElementOptions = useMemo(() => {
92
97
  return {
93
- layout: 'tabs',
98
+ fields: {
99
+ billingDetails: {
100
+ name: 'never',
101
+ email: 'never',
102
+ address: {
103
+ country: 'auto',
104
+ },
105
+ },
106
+ },
107
+ layout: {
108
+ type: 'accordion',
109
+ defaultCollapsed: false,
110
+ radios: false,
111
+ spacedAccordionItems: false,
112
+ },
94
113
  wallets: {
95
114
  applePay: 'never',
96
115
  googlePay: 'never',
@@ -114,6 +133,11 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
114
133
  setSelectedMethod('card');
115
134
  }
116
135
  };
136
+ useEffect(() => {
137
+ if (!customerEmailEditable) {
138
+ setEmailDraft(initialCustomerEmail);
139
+ }
140
+ }, [customerEmailEditable, initialCustomerEmail]);
117
141
  useEffect(() => {
118
142
  if (effectiveSelectedMethod !== 'card' || typeof window === 'undefined') {
119
143
  return;
@@ -212,10 +236,13 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
212
236
  effectiveSelectedMethod === 'card' ? 'is-visible' : '',
213
237
  ]
214
238
  .filter(Boolean)
215
- .join(' '), children: [customerEmailEditable ? (_jsxs("label", { className: 'shared-checkout-v2-email-field', children: [_jsx("span", { children: customerEmailLabel }), _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', inputMode: 'email', value: emailDraft, placeholder: customerEmailPlaceholder, onChange: (event) => {
239
+ .join(' '), children: [_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { children: customerEmailLabel }), _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable, inputMode: 'email', readOnly: !customerEmailEditable, value: emailDraft, placeholder: customerEmailPlaceholder, onChange: (event) => {
240
+ if (!customerEmailEditable) {
241
+ return;
242
+ }
216
243
  setEmailDraft(event.target.value);
217
244
  onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(event.target.value);
218
- } })] })) : null, _jsx("div", { className: 'shared-checkout-v2-card-box', children: _jsx(PaymentElement, { options: paymentElementOptions }) }), _jsx("input", { type: 'text', autoComplete: 'cc-name', className: 'shared-checkout-v2-name-input', value: nameOnCard, placeholder: nameOnCardPlaceholder, onChange: (event) => setNameOnCard(event.target.value) }), visibleError ? _jsx("p", { className: 'shared-checkout-v2-error', children: visibleError }) : null, _jsxs("button", { type: 'submit', className: 'shared-checkout-v2-card-submit', disabled: submitting, children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-card-submit-icon' }), submitting ? processingLabel : cardSubmitLabel] }), _jsx("div", { className: 'shared-checkout-v2-card-brands', "aria-hidden": 'true', children: cardBrandLabels.map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'shared-checkout-v2-card-brand' }, label))) }), _jsxs("p", { className: 'shared-checkout-v2-secure-pill', children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-secure-pill-icon' }), secureLabel] })] })] })] }));
245
+ } })] }), _jsx("div", { className: 'shared-checkout-v2-card-box', children: _jsx(PaymentElement, { options: paymentElementOptions }) }), visibleError ? _jsx("p", { className: 'shared-checkout-v2-error', children: visibleError }) : null, _jsxs("button", { type: 'submit', className: 'shared-checkout-v2-card-submit', disabled: submitting, children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-card-submit-icon' }), submitting ? processingLabel : cardSubmitLabel] }), _jsx("div", { className: 'shared-checkout-v2-card-brands', "aria-hidden": 'true', children: cardBrandLabels.map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'shared-checkout-v2-card-brand' }, label))) }), _jsxs("p", { className: 'shared-checkout-v2-secure-pill shared-checkout-v2-secure-pill--card', children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-secure-pill-icon' }), secureLabel] })] })] })] }));
219
246
  }
220
247
  export function SharedStripeCheckoutV2Dialog(_a) {
221
248
  var { clientSecret, onClose, stripePromise } = _a, props = __rest(_a, ["clientSecret", "onClose", "stripePromise"]);
@@ -624,8 +651,11 @@ const sharedStripeCheckoutV2Styles = `
624
651
  }
625
652
 
626
653
  .shared-checkout-v2-card-panel {
654
+ position: relative;
627
655
  gap: 10px;
628
- padding: 2px 15px 5px;
656
+ margin-bottom: 42px;
657
+ background: #f2f2f3;
658
+ padding: 16px 15px 58px;
629
659
  }
630
660
 
631
661
  .shared-checkout-v2-wallet-panel.is-visible,
@@ -643,92 +673,56 @@ const sharedStripeCheckoutV2Styles = `
643
673
  }
644
674
 
645
675
  .shared-checkout-v2-email-field {
646
- display: grid;
647
- gap: 7px;
648
- color: #25272a;
649
- font-size: 13px;
650
- font-weight: 800;
651
- }
652
-
653
- .shared-checkout-v2-email-input,
654
- .shared-checkout-v2-name-input {
655
- width: 100%;
656
- min-height: 56px;
676
+ min-height: 64px;
657
677
  box-sizing: border-box;
658
- border: 1px solid #8f94a0;
659
- border-radius: 14px;
660
- background: #f6f7fc;
661
- padding: 0 24px;
662
- color: #303136;
663
- font: inherit;
664
- font-size: 19px;
678
+ display: flex;
679
+ flex-direction: column;
680
+ justify-content: center;
681
+ border: 1px solid #dadde4;
682
+ border-radius: 6px;
683
+ background: #fff;
684
+ padding: 8px 14px;
685
+ box-shadow: 0 1px 2px rgb(16 24 40 / 10%);
686
+ color: #647087;
687
+ font-size: 14px;
665
688
  font-weight: 500;
666
- outline: none;
667
- }
668
-
669
- .shared-checkout-v2-email-input::placeholder,
670
- .shared-checkout-v2-name-input::placeholder {
671
- color: #8c909a;
672
- }
673
-
674
- .shared-checkout-v2-card-box {
675
- overflow: hidden;
676
- border: 1px solid #8f94a0;
677
- border-radius: 14px;
678
- background: #f6f7fc;
689
+ line-height: 1;
679
690
  }
680
691
 
681
- .shared-checkout-v2-card-number,
682
- .shared-checkout-v2-card-half {
683
- position: relative;
684
- min-height: 56px;
685
- box-sizing: border-box;
686
- display: flex;
687
- align-items: center;
688
- padding: 0 24px;
692
+ .shared-checkout-v2-email-field.is-disabled {
693
+ cursor: default;
689
694
  }
690
695
 
691
- .shared-checkout-v2-card-number > div,
692
- .shared-checkout-v2-card-half > div {
693
- position: relative;
694
- z-index: 1;
696
+ .shared-checkout-v2-email-input {
695
697
  width: 100%;
698
+ min-height: 30px;
699
+ box-sizing: border-box;
700
+ border: 0;
701
+ background: transparent;
702
+ padding: 0;
703
+ color: #303136;
704
+ font: inherit;
705
+ font-size: 20px;
706
+ font-weight: 400;
707
+ line-height: 1.2;
708
+ outline: none;
696
709
  }
697
710
 
698
- .shared-checkout-v2-card-number {
699
- border-bottom: 1px solid #8f94a0;
700
- }
701
-
702
- .shared-checkout-v2-card-row {
703
- display: grid;
704
- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
705
- }
706
-
707
- .shared-checkout-v2-card-half:first-child {
708
- border-right: 1px solid #8f94a0;
709
- }
710
-
711
- .shared-checkout-v2-card-half--cvc {
712
- justify-content: space-between;
713
- gap: 10px;
711
+ .shared-checkout-v2-email-input:disabled {
712
+ color: #74767c;
713
+ opacity: 1;
714
+ -webkit-text-fill-color: #74767c;
714
715
  }
715
716
 
716
- .shared-checkout-v2-card-half--cvc > div {
717
- flex: 1;
717
+ .shared-checkout-v2-email-input::placeholder {
718
+ color: #8c909a;
718
719
  }
719
720
 
720
- .shared-checkout-v2-cvc-info {
721
- width: 24px;
722
- height: 24px;
723
- border-radius: 999px;
724
- display: inline-flex;
725
- align-items: center;
726
- justify-content: center;
727
- background: #8c909a;
728
- color: #fff;
729
- font-size: 16px;
730
- font-weight: 900;
731
- line-height: 1;
721
+ .shared-checkout-v2-card-box {
722
+ overflow: visible;
723
+ border: 0;
724
+ border-radius: 0;
725
+ background: transparent;
732
726
  }
733
727
 
734
728
  .shared-checkout-v2-error {
@@ -780,6 +774,14 @@ const sharedStripeCheckoutV2Styles = `
780
774
  height: 25px;
781
775
  }
782
776
 
777
+ .shared-checkout-v2-secure-pill--card {
778
+ position: absolute;
779
+ left: 50%;
780
+ bottom: -33px;
781
+ transform: translateX(-50%);
782
+ white-space: nowrap;
783
+ }
784
+
783
785
  .shared-checkout-v2-sr-only {
784
786
  position: absolute;
785
787
  width: 1px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",