@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.mjs CHANGED
@@ -362,6 +362,14 @@ var FLOPAY_KEYFRAMES = `
362
362
  function FloPayKeyframes() {
363
363
  return /* @__PURE__ */ jsx4("style", { children: FLOPAY_KEYFRAMES });
364
364
  }
365
+ function toCssSize(value) {
366
+ if (typeof value === "number") return `${value}px`;
367
+ return value;
368
+ }
369
+ function toCssWeight(value) {
370
+ if (typeof value === "number" || typeof value === "string") return value;
371
+ return void 0;
372
+ }
365
373
  function ProcessingOverlay({ status, errorMessage }) {
366
374
  return /* @__PURE__ */ jsx4("div", { style: {
367
375
  position: "fixed",
@@ -718,7 +726,7 @@ function WalletButtonInner({
718
726
  amazonPay: "never",
719
727
  klarna: "never"
720
728
  },
721
- layout: { overflow: "never" }
729
+ layout: { maxColumns: 1, overflow: "never" }
722
730
  }
723
731
  }
724
732
  ) }),
@@ -1163,23 +1171,58 @@ function SplitCardFormInner({
1163
1171
  const cardInputBg = isButtons ? bStyles.cardInputBackground ?? "white" : "white";
1164
1172
  const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
1165
1173
  const hideTitle = isEmptySlotContent(cardTitleContent);
1166
- const stripeElementStyle = isButtons && (bStyles.cardInputColor || bStyles.cardInputPlaceholderColor || bStyles.cardInputFontSize) ? {
1174
+ const nameInputOverrides = isButtons ? bStyles.nameInput : void 0;
1175
+ const resolvedInputFontSize = bStyles.cardInputFontSize ?? toCssSize(nameInputOverrides?.fontSize) ?? "16px";
1176
+ const resolvedInputFontFamily = typeof nameInputOverrides?.fontFamily === "string" ? nameInputOverrides.fontFamily : "Poppins, sans-serif";
1177
+ const resolvedInputFontWeight = toCssWeight(nameInputOverrides?.fontWeight) ?? 400;
1178
+ const resolvedInputColor = bStyles.cardInputColor ?? (typeof nameInputOverrides?.color === "string" ? nameInputOverrides.color : void 0) ?? "#262833";
1179
+ const resolvedPlaceholderColor = bStyles.cardInputPlaceholderColor ?? "#9ca3af";
1180
+ const sharedInputTypography = {
1181
+ fontSize: resolvedInputFontSize,
1182
+ fontFamily: resolvedInputFontFamily,
1183
+ fontWeight: resolvedInputFontWeight,
1184
+ color: resolvedInputColor,
1185
+ WebkitFontSmoothing: "antialiased",
1186
+ MozOsxFontSmoothing: "grayscale"
1187
+ };
1188
+ const sharedInputPlaceholderVars = {
1189
+ "--flopay-input-placeholder-color": resolvedPlaceholderColor,
1190
+ "--flopay-input-font-size": resolvedInputFontSize,
1191
+ "--flopay-input-font-family": resolvedInputFontFamily,
1192
+ "--flopay-input-font-weight": String(resolvedInputFontWeight)
1193
+ };
1194
+ const stripeElementStyle = {
1167
1195
  style: {
1168
1196
  base: {
1169
- ...bStyles.cardInputColor ? { color: bStyles.cardInputColor } : {},
1170
- ...bStyles.cardInputFontSize ? { fontSize: bStyles.cardInputFontSize } : {},
1171
- ...bStyles.cardInputPlaceholderColor ? { "::placeholder": { color: bStyles.cardInputPlaceholderColor } } : {}
1197
+ ...sharedInputTypography,
1198
+ fontSmoothing: "antialiased",
1199
+ "::placeholder": {
1200
+ color: resolvedPlaceholderColor,
1201
+ fontSize: resolvedInputFontSize,
1202
+ fontFamily: resolvedInputFontFamily,
1203
+ fontWeight: resolvedInputFontWeight
1204
+ }
1172
1205
  },
1173
1206
  invalid: { color: "#ef4444" }
1174
1207
  }
1175
- } : {};
1208
+ };
1176
1209
  const cardFormBlock = /* @__PURE__ */ jsxs2("div", { style: {
1177
1210
  backgroundColor: cardBg,
1178
1211
  borderRadius: "8px",
1179
1212
  padding: isButtons ? "0" : "1rem",
1180
1213
  ...isButtons ? bStyles.cardFormContainer : {},
1181
- ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {}
1214
+ ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {},
1215
+ ...sharedInputPlaceholderVars
1182
1216
  }, children: [
1217
+ /* @__PURE__ */ jsx4("style", { children: `
1218
+ .flopay-shared-input::placeholder {
1219
+ color: var(--flopay-input-placeholder-color);
1220
+ opacity: 1;
1221
+ font-size: var(--flopay-input-font-size);
1222
+ font-family: var(--flopay-input-font-family);
1223
+ font-weight: var(--flopay-input-font-weight);
1224
+ }
1225
+ ` }),
1183
1226
  isButtons && showCardForm && /* @__PURE__ */ jsxs2("div", { style: {
1184
1227
  display: "flex",
1185
1228
  alignItems: "center",
@@ -1268,6 +1311,7 @@ function SplitCardFormInner({
1268
1311
  }, children: /* @__PURE__ */ jsx4(
1269
1312
  "input",
1270
1313
  {
1314
+ className: "flopay-shared-input",
1271
1315
  placeholder: "Full Name on Card",
1272
1316
  autoComplete: "cc-name",
1273
1317
  value: fullName,
@@ -1279,9 +1323,7 @@ function SplitCardFormInner({
1279
1323
  border: "none",
1280
1324
  outline: "none",
1281
1325
  background: "transparent",
1282
- fontSize: bStyles.cardInputFontSize ?? "16px",
1283
- fontFamily: "Poppins, sans-serif",
1284
- color: bStyles.cardInputColor ?? "#262833",
1326
+ ...sharedInputTypography,
1285
1327
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1286
1328
  }
1287
1329
  }
@@ -1316,9 +1358,7 @@ function SplitCardFormInner({
1316
1358
  border: "none",
1317
1359
  outline: "none",
1318
1360
  background: "transparent",
1319
- fontSize: bStyles.cardInputFontSize ?? "16px",
1320
- fontFamily: "Poppins, sans-serif",
1321
- color: bStyles.cardInputColor ?? "#262833",
1361
+ ...sharedInputTypography,
1322
1362
  cursor: "pointer",
1323
1363
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1324
1364
  },
@@ -1339,6 +1379,7 @@ function SplitCardFormInner({
1339
1379
  }, children: /* @__PURE__ */ jsx4(
1340
1380
  "input",
1341
1381
  {
1382
+ className: "flopay-shared-input",
1342
1383
  placeholder: getPostalCodeLabel(selectedCountry),
1343
1384
  autoComplete: "postal-code",
1344
1385
  value: zipCode,
@@ -1355,9 +1396,7 @@ function SplitCardFormInner({
1355
1396
  border: "none",
1356
1397
  outline: "none",
1357
1398
  background: "transparent",
1358
- fontSize: bStyles.cardInputFontSize ?? "16px",
1359
- fontFamily: "Poppins, sans-serif",
1360
- color: bStyles.cardInputColor ?? "#262833",
1399
+ ...sharedInputTypography,
1361
1400
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1362
1401
  }
1363
1402
  }
@@ -1614,6 +1653,7 @@ function FloPayCheckout({
1614
1653
  const [confirmProcessing, setConfirmProcessing] = useState3(false);
1615
1654
  const [modeError, setModeError] = useState3(null);
1616
1655
  const [createSessionPatch, setCreateSessionPatch] = useState3(void 0);
1656
+ const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = useState3("");
1617
1657
  const [cardBootstrapPending, setCardBootstrapPending] = useState3(false);
1618
1658
  const [deferredCardOpen, setDeferredCardOpen] = useState3(false);
1619
1659
  const autoCheckoutAttempted = useRef3(false);
@@ -1625,10 +1665,22 @@ function FloPayCheckout({
1625
1665
  onDeclineRef.current = onDecline;
1626
1666
  const onSessionCompletedRef = useRef3(onSessionCompleted);
1627
1667
  onSessionCompletedRef.current = onSessionCompleted;
1668
+ const baseCreateSessionHash = useMemo3(
1669
+ () => createSessionParams ? hashCreateParams(createSessionParams) : "",
1670
+ [createSessionParams]
1671
+ );
1672
+ const activeCreateSessionPatch = useMemo3(
1673
+ () => createSessionPatchBaseHash === baseCreateSessionHash ? createSessionPatch : void 0,
1674
+ [createSessionPatch, createSessionPatchBaseHash, baseCreateSessionHash]
1675
+ );
1628
1676
  const effectiveCreateSession = useMemo3(
1629
- () => createSessionParams ? mergeInlineSessionPatch(createSessionParams, createSessionPatch) : void 0,
1630
- [createSessionParams, createSessionPatch]
1677
+ () => createSessionParams ? mergeInlineSessionPatch(createSessionParams, activeCreateSessionPatch) : void 0,
1678
+ [createSessionParams, activeCreateSessionPatch]
1631
1679
  );
1680
+ useEffect4(() => {
1681
+ setCreateSessionPatch(void 0);
1682
+ setCreateSessionPatchBaseHash(baseCreateSessionHash);
1683
+ }, [baseCreateSessionHash]);
1632
1684
  const emitDecline = useCallback2(
1633
1685
  (method, input, overrides) => {
1634
1686
  onDeclineRef.current?.(buildDeclineEvent(method, input, overrides));
@@ -1816,6 +1868,7 @@ function FloPayCheckout({
1816
1868
  inflightRef.current.delete(cacheKey);
1817
1869
  }
1818
1870
  if (patch) {
1871
+ setCreateSessionPatchBaseHash(baseCreateSessionHash);
1819
1872
  setCreateSessionPatch((prev) => mergeInlineSessionPatches(prev, patch));
1820
1873
  }
1821
1874
  const { sid, result: realResult } = resolved;
@@ -1887,6 +1940,7 @@ function FloPayCheckout({
1887
1940
  }
1888
1941
  }, [
1889
1942
  bootstrapInlineSession,
1943
+ baseCreateSessionHash,
1890
1944
  cardBootstrapPending,
1891
1945
  effectiveCreateSession,
1892
1946
  onButtonClick,
@@ -2215,7 +2269,6 @@ function FloPayCheckout({
2215
2269
  enableAVS,
2216
2270
  avsLayout,
2217
2271
  country: session?.customer?.country,
2218
- zip: session?.customer?.zip,
2219
2272
  initialCardOpen: deferredCardOpen,
2220
2273
  submitLabel,
2221
2274
  className