@flopay/react 0.3.4 → 0.3.11

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
@@ -162,10 +162,29 @@ function DefaultCardButtonContent() {
162
162
  )
163
163
  ] });
164
164
  }
165
+ function DefaultBackButtonContent() {
166
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: "Go back" });
167
+ }
168
+ function DefaultTitleContent() {
169
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: "Secure card checkout" });
170
+ }
171
+ function isEmptySlotContent(content) {
172
+ return content !== void 0 && (content === "" || content === null || content === false);
173
+ }
165
174
  function CardButtonContentSlot({
166
175
  content
167
176
  }) {
168
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DefaultCardButtonContent, {}) });
177
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DefaultCardButtonContent, {}) : content });
178
+ }
179
+ function BackButtonContentSlot({
180
+ content
181
+ }) {
182
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DefaultBackButtonContent, {}) : content });
183
+ }
184
+ function TitleContentSlot({
185
+ content
186
+ }) {
187
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DefaultTitleContent, {}) : content });
169
188
  }
170
189
 
171
190
  // src/elements.tsx
@@ -355,6 +374,14 @@ function ProcessingOverlay({ status, errorMessage }) {
355
374
  status === "success" && "PAYMENT SUCCESSFUL",
356
375
  status === "error" && "PAYMENT FAILED"
357
376
  ] }),
377
+ status === "success" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: {
378
+ fontSize: 13,
379
+ color: "#6b7280",
380
+ fontWeight: 400,
381
+ maxWidth: 260,
382
+ lineHeight: 1.4,
383
+ margin: 0
384
+ }, children: "You will be automatically redirected, do not close or navigate away from this window." }),
358
385
  status === "error" && errorMessage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: {
359
386
  fontSize: 13,
360
387
  color: "#6b7280",
@@ -634,6 +661,8 @@ function SplitCardFormInner({
634
661
  buttonsTheme,
635
662
  buttonsStyles: buttonsStylesOverride,
636
663
  cardButtonContent,
664
+ cardBackButtonContent,
665
+ cardTitleContent,
637
666
  onButtonClick,
638
667
  enableAVS = false,
639
668
  avsLayout: avsLayoutProp = "row",
@@ -980,6 +1009,8 @@ function SplitCardFormInner({
980
1009
  const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
981
1010
  const cardBg = isButtons ? bStyles.cardFormContainer?.backgroundColor ?? "white" : "#EDEDFF";
982
1011
  const cardInputBg = isButtons ? bStyles.cardInputBackground ?? "white" : "white";
1012
+ const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
1013
+ const hideTitle = isEmptySlotContent(cardTitleContent);
983
1014
  const stripeElementStyle = isButtons && (bStyles.cardInputColor || bStyles.cardInputPlaceholderColor || bStyles.cardInputFontSize) ? {
984
1015
  style: {
985
1016
  base: {
@@ -1010,7 +1041,7 @@ function SplitCardFormInner({
1010
1041
  style: {
1011
1042
  display: "inline-flex",
1012
1043
  alignItems: "center",
1013
- gap: "0.5rem",
1044
+ gap: hideBackButtonLabel ? 0 : "0.5rem",
1014
1045
  background: "none",
1015
1046
  border: "none",
1016
1047
  cursor: "pointer",
@@ -1035,11 +1066,11 @@ function SplitCardFormInner({
1035
1066
  transition: "background-color 0.15s",
1036
1067
  ...bStyles.backButtonIcon
1037
1068
  }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
1038
- "Go back"
1069
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
1039
1070
  ]
1040
1071
  }
1041
1072
  ),
1042
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1073
+ hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1043
1074
  flex: 1,
1044
1075
  textAlign: "center",
1045
1076
  fontWeight: 600,
@@ -1047,9 +1078,9 @@ function SplitCardFormInner({
1047
1078
  color: "#262833",
1048
1079
  paddingRight: 80,
1049
1080
  ...bStyles.title
1050
- }, children: "Secure card checkout" })
1081
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TitleContentSlot, { content: cardTitleContent }) })
1051
1082
  ] }),
1052
- !isButtons && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: "Secure card checkout" }),
1083
+ !isButtons && !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TitleContentSlot, { content: cardTitleContent }) }),
1053
1084
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1054
1085
  backgroundColor: cardInputBg,
1055
1086
  border: `1px solid ${resolvedBorder}`,
@@ -1398,6 +1429,8 @@ function FloPayCheckout({
1398
1429
  buttonsTheme,
1399
1430
  buttonsStyles,
1400
1431
  cardButtonContent,
1432
+ cardBackButtonContent,
1433
+ cardTitleContent,
1401
1434
  onButtonClick,
1402
1435
  enableAVS,
1403
1436
  avsLayout,
@@ -1855,7 +1888,9 @@ function FloPayCheckout({
1855
1888
  showGooglePay,
1856
1889
  buttonsTheme,
1857
1890
  buttonsStyles,
1858
- cardButtonContent
1891
+ cardButtonContent,
1892
+ cardBackButtonContent,
1893
+ cardTitleContent
1859
1894
  }
1860
1895
  ) });
1861
1896
  }
@@ -1943,6 +1978,8 @@ function FloPayCheckout({
1943
1978
  buttonsTheme,
1944
1979
  buttonsStyles,
1945
1980
  cardButtonContent,
1981
+ cardBackButtonContent,
1982
+ cardTitleContent,
1946
1983
  onButtonClick,
1947
1984
  enableAVS,
1948
1985
  avsLayout,
@@ -1985,7 +2022,9 @@ function InterimButtonsView({
1985
2022
  showGooglePay,
1986
2023
  buttonsTheme,
1987
2024
  buttonsStyles: stylesOverride,
1988
- cardButtonContent
2025
+ cardButtonContent,
2026
+ cardBackButtonContent,
2027
+ cardTitleContent
1989
2028
  }) {
1990
2029
  const [showCardForm, setShowCardForm] = (0, import_react7.useState)(false);
1991
2030
  const bStyles = (0, import_react7.useMemo)(() => {
@@ -1996,6 +2035,8 @@ function InterimButtonsView({
1996
2035
  ...stylesOverride,
1997
2036
  cardButton: { ...base.cardButton, ...stylesOverride.cardButton },
1998
2037
  cardFormContainer: { ...base.cardFormContainer, ...stylesOverride.cardFormContainer },
2038
+ backButton: { ...base.backButton, ...stylesOverride.backButton },
2039
+ backButtonIcon: { ...base.backButtonIcon, ...stylesOverride.backButtonIcon },
1999
2040
  submitButton: { ...base.submitButton, ...stylesOverride.submitButton },
2000
2041
  title: { ...base.title, ...stylesOverride.title }
2001
2042
  };
@@ -2009,6 +2050,8 @@ function InterimButtonsView({
2009
2050
  if (showCardForm) {
2010
2051
  const inputBorder = bStyles.cardInputBorder ?? "#e5e7eb";
2011
2052
  const inputBg = bStyles.cardInputBackground ?? "white";
2053
+ const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
2054
+ const hideTitle = isEmptySlotContent(cardTitleContent);
2012
2055
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2013
2056
  backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
2014
2057
  borderRadius: "8px",
@@ -2022,10 +2065,11 @@ function InterimButtonsView({
2022
2065
  {
2023
2066
  type: "button",
2024
2067
  onClick: () => setShowCardForm(false),
2068
+ "aria-label": "Back to payment methods",
2025
2069
  style: {
2026
2070
  display: "inline-flex",
2027
2071
  alignItems: "center",
2028
- gap: "0.5rem",
2072
+ gap: hideBackButtonLabel ? 0 : "0.5rem",
2029
2073
  background: "none",
2030
2074
  border: "none",
2031
2075
  cursor: "pointer",
@@ -2047,11 +2091,11 @@ function InterimButtonsView({
2047
2091
  backgroundColor: "#f3f4f6",
2048
2092
  ...bStyles.backButtonIcon
2049
2093
  }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
2050
- "Go back"
2094
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
2051
2095
  ]
2052
2096
  }
2053
2097
  ),
2054
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2098
+ hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2055
2099
  flex: 1,
2056
2100
  textAlign: "center",
2057
2101
  fontWeight: 600,
@@ -2059,7 +2103,7 @@ function InterimButtonsView({
2059
2103
  color: "#262833",
2060
2104
  paddingRight: 80,
2061
2105
  ...bStyles.title
2062
- }, children: "Secure card checkout" })
2106
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TitleContentSlot, { content: cardTitleContent }) })
2063
2107
  ] }),
2064
2108
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
2065
2109
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex" }, children: [