@funnelsgrove/payments 0.1.45 → 0.1.46

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.
@@ -50,6 +50,10 @@ const formatCountdown = (remainingSeconds) => {
50
50
  return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
51
51
  };
52
52
  const getFixedSupportedBillingCountry = (supportedCountries) => supportedCountries.length === 1 ? supportedCountries[0] : null;
53
+ const checkoutCountryLabels = {
54
+ US: 'United States',
55
+ };
56
+ const getCheckoutCountryLabel = (countryCode) => { var _a; return (_a = checkoutCountryLabels[countryCode]) !== null && _a !== void 0 ? _a : countryCode; };
53
57
  function getFriendlyCardErrorMessage(error) {
54
58
  return error instanceof Error && error.message
55
59
  ? error.message
@@ -70,6 +74,9 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
70
74
  const [emailDraft, setEmailDraft] = useState(initialCustomerEmail);
71
75
  const normalizedSupportedCountries = useMemo(() => normalizeSupportedCheckoutCountries(supportedCountries), [supportedCountries]);
72
76
  const fixedBillingCountry = getFixedSupportedBillingCountry(normalizedSupportedCountries);
77
+ const fixedBillingCountryLabel = fixedBillingCountry
78
+ ? getCheckoutCountryLabel(fixedBillingCountry)
79
+ : null;
73
80
  const cardBrandLabels = useMemo(() => paymentMethodLabels.length > 0 ? paymentMethodLabels : defaultPaymentMethodLabels, [paymentMethodLabels]);
74
81
  const normalizedPromoCode = promoCode.trim();
75
82
  const showPromo = promoActive !== null && promoActive !== void 0 ? promoActive : (discountPercent > 0 && normalizedPromoCode.length > 0);
@@ -297,7 +304,7 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
297
304
  }
298
305
  setEmailDraft(event.target.value);
299
306
  onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(event.target.value);
300
- } }) })] }), _jsx(PaymentElement, { options: paymentElementOptions, onChange: handlePaymentElementChange })] }), 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] })] })] })] }));
307
+ } }) })] }), _jsx(PaymentElement, { options: paymentElementOptions, onChange: handlePaymentElementChange }), fixedBillingCountry && fixedBillingCountryLabel ? (_jsxs("label", { className: 'shared-checkout-v2-country-field', children: [_jsx("span", { className: 'shared-checkout-v2-country-label', children: "Country" }), _jsx("span", { className: 'shared-checkout-v2-country-control', children: _jsx("select", { "aria-label": 'Country', className: 'shared-checkout-v2-country-select', value: fixedBillingCountry, onChange: () => setBillingCountry(fixedBillingCountry), children: _jsx("option", { value: fixedBillingCountry, children: fixedBillingCountryLabel }) }) })] })) : null] }), 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] })] })] })] }));
301
308
  }
302
309
  export function SharedStripeCheckoutV2Dialog(_a) {
303
310
  var { checkoutAnalytics, checkoutSessionId, clientSecret, onClose, stripePromise, supportedCountries } = _a, props = __rest(_a, ["checkoutAnalytics", "checkoutSessionId", "clientSecret", "onClose", "stripePromise", "supportedCountries"]);
@@ -813,6 +820,58 @@ const sharedStripeCheckoutV2Styles = `
813
820
  box-shadow: none;
814
821
  }
815
822
 
823
+ .shared-checkout-v2-country-field {
824
+ box-sizing: border-box;
825
+ display: flex;
826
+ flex-direction: column;
827
+ gap: 7px;
828
+ margin: 14px 0 0;
829
+ color: #303136;
830
+ font-size: 14px;
831
+ font-weight: 400;
832
+ line-height: 1.2;
833
+ }
834
+
835
+ .shared-checkout-v2-country-label {
836
+ padding: 0 14px;
837
+ }
838
+
839
+ .shared-checkout-v2-country-control {
840
+ position: relative;
841
+ display: block;
842
+ }
843
+
844
+ .shared-checkout-v2-country-control::after {
845
+ position: absolute;
846
+ right: 17px;
847
+ top: 50%;
848
+ width: 8px;
849
+ height: 8px;
850
+ border-right: 2px solid #6f7380;
851
+ border-bottom: 2px solid #6f7380;
852
+ content: '';
853
+ pointer-events: none;
854
+ transform: translateY(-65%) rotate(45deg);
855
+ }
856
+
857
+ .shared-checkout-v2-country-select {
858
+ width: 100%;
859
+ min-height: 50px;
860
+ box-sizing: border-box;
861
+ appearance: none;
862
+ border: 1px solid #dedede;
863
+ border-radius: 0;
864
+ background: #fff;
865
+ box-shadow: 0 1px 2px rgb(16 24 40 / 8%);
866
+ color: #303136;
867
+ font: inherit;
868
+ font-size: 18px;
869
+ font-weight: 400;
870
+ line-height: 1.2;
871
+ outline: none;
872
+ padding: 0 44px 0 14px;
873
+ }
874
+
816
875
  .shared-checkout-v2-error {
817
876
  margin: 0;
818
877
  color: #c43737;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.1.45",
3
+ "version": "0.1.46",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",