@funnelsgrove/payments 0.1.14 → 0.1.15

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.
@@ -166,12 +166,7 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
166
166
  }, 0);
167
167
  return () => window.clearTimeout(resizeTimer);
168
168
  }, [effectiveSelectedMethod]);
169
- const ensureCustomerEmail = async () => {
170
- const normalizedEmail = resolvedCustomerEmail.trim();
171
- if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
172
- setSharedError(customerEmailInvalidMessage);
173
- return null;
174
- }
169
+ const commitCustomerEmail = async (normalizedEmail) => {
175
170
  if (!customerEmailEditable || !onCustomerEmailCommit) {
176
171
  return normalizedEmail;
177
172
  }
@@ -183,6 +178,26 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
183
178
  onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(nextEmail);
184
179
  return nextEmail;
185
180
  };
181
+ const commitEmailDraftIfValid = (value) => {
182
+ const normalizedEmail = value.trim();
183
+ if (!customerEmailEditable || !onCustomerEmailCommit) {
184
+ return;
185
+ }
186
+ if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
187
+ return;
188
+ }
189
+ void commitCustomerEmail(normalizedEmail).catch((commitError) => {
190
+ setSharedError(getFriendlyCardErrorMessage(commitError));
191
+ });
192
+ };
193
+ const ensureCustomerEmail = async () => {
194
+ const normalizedEmail = resolvedCustomerEmail.trim();
195
+ if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
196
+ setSharedError(customerEmailInvalidMessage);
197
+ return null;
198
+ }
199
+ return commitCustomerEmail(normalizedEmail);
200
+ };
186
201
  const handleSubmit = async (event) => {
187
202
  event.preventDefault();
188
203
  if (submitting) {
@@ -251,7 +266,7 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
251
266
  effectiveSelectedMethod === 'card' ? 'is-visible' : '',
252
267
  ]
253
268
  .filter(Boolean)
254
- .join(' '), children: [_jsxs("div", { className: 'shared-checkout-v2-card-box', children: [_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { className: 'shared-checkout-v2-email-label', children: customerEmailLabel }), _jsx("span", { className: 'shared-checkout-v2-email-control', children: _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable, inputMode: 'email', readOnly: !customerEmailEditable, value: customerEmailEditable ? emailDraft : initialCustomerEmail, placeholder: customerEmailPlaceholder, onChange: (event) => {
269
+ .join(' '), children: [_jsxs("div", { className: 'shared-checkout-v2-card-box', children: [_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { className: 'shared-checkout-v2-email-label', children: customerEmailLabel }), _jsx("span", { className: 'shared-checkout-v2-email-control', children: _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable, inputMode: 'email', readOnly: !customerEmailEditable, value: customerEmailEditable ? emailDraft : initialCustomerEmail, placeholder: customerEmailPlaceholder, onBlur: (event) => commitEmailDraftIfValid(event.currentTarget.value), onChange: (event) => {
255
270
  if (!customerEmailEditable) {
256
271
  return;
257
272
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",