@flopay/react 0.3.12 → 0.3.14

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.
package/dist/index.cjs CHANGED
@@ -406,6 +406,14 @@ var FLOPAY_KEYFRAMES = `
406
406
  function FloPayKeyframes() {
407
407
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: FLOPAY_KEYFRAMES });
408
408
  }
409
+ function toCssSize(value) {
410
+ if (typeof value === "number") return `${value}px`;
411
+ return value;
412
+ }
413
+ function toCssWeight(value) {
414
+ if (typeof value === "number" || typeof value === "string") return value;
415
+ return void 0;
416
+ }
409
417
  function ProcessingOverlay({ status, errorMessage }) {
410
418
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
411
419
  position: "fixed",
@@ -762,7 +770,7 @@ function WalletButtonInner({
762
770
  amazonPay: "never",
763
771
  klarna: "never"
764
772
  },
765
- layout: { overflow: "never" }
773
+ layout: { maxColumns: 1, overflow: "never" }
766
774
  }
767
775
  }
768
776
  ) }),
@@ -1207,23 +1215,58 @@ function SplitCardFormInner({
1207
1215
  const cardInputBg = isButtons ? bStyles.cardInputBackground ?? "white" : "white";
1208
1216
  const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
1209
1217
  const hideTitle = isEmptySlotContent(cardTitleContent);
1210
- const stripeElementStyle = isButtons && (bStyles.cardInputColor || bStyles.cardInputPlaceholderColor || bStyles.cardInputFontSize) ? {
1218
+ const nameInputOverrides = isButtons ? bStyles.nameInput : void 0;
1219
+ const resolvedInputFontSize = bStyles.cardInputFontSize ?? toCssSize(nameInputOverrides?.fontSize) ?? "16px";
1220
+ const resolvedInputFontFamily = typeof nameInputOverrides?.fontFamily === "string" ? nameInputOverrides.fontFamily : "Poppins, sans-serif";
1221
+ const resolvedInputFontWeight = toCssWeight(nameInputOverrides?.fontWeight) ?? 400;
1222
+ const resolvedInputColor = bStyles.cardInputColor ?? (typeof nameInputOverrides?.color === "string" ? nameInputOverrides.color : void 0) ?? "#262833";
1223
+ const resolvedPlaceholderColor = bStyles.cardInputPlaceholderColor ?? "#9ca3af";
1224
+ const sharedInputTypography = {
1225
+ fontSize: resolvedInputFontSize,
1226
+ fontFamily: resolvedInputFontFamily,
1227
+ fontWeight: resolvedInputFontWeight,
1228
+ color: resolvedInputColor,
1229
+ WebkitFontSmoothing: "antialiased",
1230
+ MozOsxFontSmoothing: "grayscale"
1231
+ };
1232
+ const sharedInputPlaceholderVars = {
1233
+ "--flopay-input-placeholder-color": resolvedPlaceholderColor,
1234
+ "--flopay-input-font-size": resolvedInputFontSize,
1235
+ "--flopay-input-font-family": resolvedInputFontFamily,
1236
+ "--flopay-input-font-weight": String(resolvedInputFontWeight)
1237
+ };
1238
+ const stripeElementStyle = {
1211
1239
  style: {
1212
1240
  base: {
1213
- ...bStyles.cardInputColor ? { color: bStyles.cardInputColor } : {},
1214
- ...bStyles.cardInputFontSize ? { fontSize: bStyles.cardInputFontSize } : {},
1215
- ...bStyles.cardInputPlaceholderColor ? { "::placeholder": { color: bStyles.cardInputPlaceholderColor } } : {}
1241
+ ...sharedInputTypography,
1242
+ fontSmoothing: "antialiased",
1243
+ "::placeholder": {
1244
+ color: resolvedPlaceholderColor,
1245
+ fontSize: resolvedInputFontSize,
1246
+ fontFamily: resolvedInputFontFamily,
1247
+ fontWeight: resolvedInputFontWeight
1248
+ }
1216
1249
  },
1217
1250
  invalid: { color: "#ef4444" }
1218
1251
  }
1219
- } : {};
1252
+ };
1220
1253
  const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
1221
1254
  backgroundColor: cardBg,
1222
1255
  borderRadius: "8px",
1223
1256
  padding: isButtons ? "0" : "1rem",
1224
1257
  ...isButtons ? bStyles.cardFormContainer : {},
1225
- ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {}
1258
+ ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {},
1259
+ ...sharedInputPlaceholderVars
1226
1260
  }, children: [
1261
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `
1262
+ .flopay-shared-input::placeholder {
1263
+ color: var(--flopay-input-placeholder-color);
1264
+ opacity: 1;
1265
+ font-size: var(--flopay-input-font-size);
1266
+ font-family: var(--flopay-input-font-family);
1267
+ font-weight: var(--flopay-input-font-weight);
1268
+ }
1269
+ ` }),
1227
1270
  isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
1228
1271
  display: "flex",
1229
1272
  alignItems: "center",
@@ -1312,6 +1355,7 @@ function SplitCardFormInner({
1312
1355
  }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1313
1356
  "input",
1314
1357
  {
1358
+ className: "flopay-shared-input",
1315
1359
  placeholder: "Full Name on Card",
1316
1360
  autoComplete: "cc-name",
1317
1361
  value: fullName,
@@ -1323,9 +1367,7 @@ function SplitCardFormInner({
1323
1367
  border: "none",
1324
1368
  outline: "none",
1325
1369
  background: "transparent",
1326
- fontSize: bStyles.cardInputFontSize ?? "16px",
1327
- fontFamily: "Poppins, sans-serif",
1328
- color: bStyles.cardInputColor ?? "#262833",
1370
+ ...sharedInputTypography,
1329
1371
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1330
1372
  }
1331
1373
  }
@@ -1360,9 +1402,7 @@ function SplitCardFormInner({
1360
1402
  border: "none",
1361
1403
  outline: "none",
1362
1404
  background: "transparent",
1363
- fontSize: bStyles.cardInputFontSize ?? "16px",
1364
- fontFamily: "Poppins, sans-serif",
1365
- color: bStyles.cardInputColor ?? "#262833",
1405
+ ...sharedInputTypography,
1366
1406
  cursor: "pointer",
1367
1407
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1368
1408
  },
@@ -1383,6 +1423,7 @@ function SplitCardFormInner({
1383
1423
  }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1384
1424
  "input",
1385
1425
  {
1426
+ className: "flopay-shared-input",
1386
1427
  placeholder: (0, import_shared4.getPostalCodeLabel)(selectedCountry),
1387
1428
  autoComplete: "postal-code",
1388
1429
  value: zipCode,
@@ -1399,9 +1440,7 @@ function SplitCardFormInner({
1399
1440
  border: "none",
1400
1441
  outline: "none",
1401
1442
  background: "transparent",
1402
- fontSize: bStyles.cardInputFontSize ?? "16px",
1403
- fontFamily: "Poppins, sans-serif",
1404
- color: bStyles.cardInputColor ?? "#262833",
1443
+ ...sharedInputTypography,
1405
1444
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1406
1445
  }
1407
1446
  }
@@ -1658,6 +1697,7 @@ function FloPayCheckout({
1658
1697
  const [confirmProcessing, setConfirmProcessing] = (0, import_react7.useState)(false);
1659
1698
  const [modeError, setModeError] = (0, import_react7.useState)(null);
1660
1699
  const [createSessionPatch, setCreateSessionPatch] = (0, import_react7.useState)(void 0);
1700
+ const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = (0, import_react7.useState)("");
1661
1701
  const [cardBootstrapPending, setCardBootstrapPending] = (0, import_react7.useState)(false);
1662
1702
  const [deferredCardOpen, setDeferredCardOpen] = (0, import_react7.useState)(false);
1663
1703
  const autoCheckoutAttempted = (0, import_react7.useRef)(false);
@@ -1669,10 +1709,22 @@ function FloPayCheckout({
1669
1709
  onDeclineRef.current = onDecline;
1670
1710
  const onSessionCompletedRef = (0, import_react7.useRef)(onSessionCompleted);
1671
1711
  onSessionCompletedRef.current = onSessionCompleted;
1712
+ const baseCreateSessionHash = (0, import_react7.useMemo)(
1713
+ () => createSessionParams ? hashCreateParams(createSessionParams) : "",
1714
+ [createSessionParams]
1715
+ );
1716
+ const activeCreateSessionPatch = (0, import_react7.useMemo)(
1717
+ () => createSessionPatchBaseHash === baseCreateSessionHash ? createSessionPatch : void 0,
1718
+ [createSessionPatch, createSessionPatchBaseHash, baseCreateSessionHash]
1719
+ );
1672
1720
  const effectiveCreateSession = (0, import_react7.useMemo)(
1673
- () => createSessionParams ? mergeInlineSessionPatch(createSessionParams, createSessionPatch) : void 0,
1674
- [createSessionParams, createSessionPatch]
1721
+ () => createSessionParams ? mergeInlineSessionPatch(createSessionParams, activeCreateSessionPatch) : void 0,
1722
+ [createSessionParams, activeCreateSessionPatch]
1675
1723
  );
1724
+ (0, import_react7.useEffect)(() => {
1725
+ setCreateSessionPatch(void 0);
1726
+ setCreateSessionPatchBaseHash(baseCreateSessionHash);
1727
+ }, [baseCreateSessionHash]);
1676
1728
  const emitDecline = (0, import_react7.useCallback)(
1677
1729
  (method, input, overrides) => {
1678
1730
  onDeclineRef.current?.(buildDeclineEvent(method, input, overrides));
@@ -1860,6 +1912,7 @@ function FloPayCheckout({
1860
1912
  inflightRef.current.delete(cacheKey);
1861
1913
  }
1862
1914
  if (patch) {
1915
+ setCreateSessionPatchBaseHash(baseCreateSessionHash);
1863
1916
  setCreateSessionPatch((prev) => mergeInlineSessionPatches(prev, patch));
1864
1917
  }
1865
1918
  const { sid, result: realResult } = resolved;
@@ -1931,6 +1984,7 @@ function FloPayCheckout({
1931
1984
  }
1932
1985
  }, [
1933
1986
  bootstrapInlineSession,
1987
+ baseCreateSessionHash,
1934
1988
  cardBootstrapPending,
1935
1989
  effectiveCreateSession,
1936
1990
  onButtonClick,
@@ -2259,7 +2313,6 @@ function FloPayCheckout({
2259
2313
  enableAVS,
2260
2314
  avsLayout,
2261
2315
  country: session?.customer?.country,
2262
- zip: session?.customer?.zip,
2263
2316
  initialCardOpen: deferredCardOpen,
2264
2317
  submitLabel,
2265
2318
  className