@flopay/react 0.3.5 → 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
@@ -642,6 +661,8 @@ function SplitCardFormInner({
642
661
  buttonsTheme,
643
662
  buttonsStyles: buttonsStylesOverride,
644
663
  cardButtonContent,
664
+ cardBackButtonContent,
665
+ cardTitleContent,
645
666
  onButtonClick,
646
667
  enableAVS = false,
647
668
  avsLayout: avsLayoutProp = "row",
@@ -988,6 +1009,8 @@ function SplitCardFormInner({
988
1009
  const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
989
1010
  const cardBg = isButtons ? bStyles.cardFormContainer?.backgroundColor ?? "white" : "#EDEDFF";
990
1011
  const cardInputBg = isButtons ? bStyles.cardInputBackground ?? "white" : "white";
1012
+ const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
1013
+ const hideTitle = isEmptySlotContent(cardTitleContent);
991
1014
  const stripeElementStyle = isButtons && (bStyles.cardInputColor || bStyles.cardInputPlaceholderColor || bStyles.cardInputFontSize) ? {
992
1015
  style: {
993
1016
  base: {
@@ -1018,7 +1041,7 @@ function SplitCardFormInner({
1018
1041
  style: {
1019
1042
  display: "inline-flex",
1020
1043
  alignItems: "center",
1021
- gap: "0.5rem",
1044
+ gap: hideBackButtonLabel ? 0 : "0.5rem",
1022
1045
  background: "none",
1023
1046
  border: "none",
1024
1047
  cursor: "pointer",
@@ -1043,11 +1066,11 @@ function SplitCardFormInner({
1043
1066
  transition: "background-color 0.15s",
1044
1067
  ...bStyles.backButtonIcon
1045
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" }) }) }),
1046
- "Go back"
1069
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
1047
1070
  ]
1048
1071
  }
1049
1072
  ),
1050
- /* @__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: {
1051
1074
  flex: 1,
1052
1075
  textAlign: "center",
1053
1076
  fontWeight: 600,
@@ -1055,9 +1078,9 @@ function SplitCardFormInner({
1055
1078
  color: "#262833",
1056
1079
  paddingRight: 80,
1057
1080
  ...bStyles.title
1058
- }, children: "Secure card checkout" })
1081
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TitleContentSlot, { content: cardTitleContent }) })
1059
1082
  ] }),
1060
- !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 }) }),
1061
1084
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1062
1085
  backgroundColor: cardInputBg,
1063
1086
  border: `1px solid ${resolvedBorder}`,
@@ -1406,6 +1429,8 @@ function FloPayCheckout({
1406
1429
  buttonsTheme,
1407
1430
  buttonsStyles,
1408
1431
  cardButtonContent,
1432
+ cardBackButtonContent,
1433
+ cardTitleContent,
1409
1434
  onButtonClick,
1410
1435
  enableAVS,
1411
1436
  avsLayout,
@@ -1863,7 +1888,9 @@ function FloPayCheckout({
1863
1888
  showGooglePay,
1864
1889
  buttonsTheme,
1865
1890
  buttonsStyles,
1866
- cardButtonContent
1891
+ cardButtonContent,
1892
+ cardBackButtonContent,
1893
+ cardTitleContent
1867
1894
  }
1868
1895
  ) });
1869
1896
  }
@@ -1951,6 +1978,8 @@ function FloPayCheckout({
1951
1978
  buttonsTheme,
1952
1979
  buttonsStyles,
1953
1980
  cardButtonContent,
1981
+ cardBackButtonContent,
1982
+ cardTitleContent,
1954
1983
  onButtonClick,
1955
1984
  enableAVS,
1956
1985
  avsLayout,
@@ -1993,7 +2022,9 @@ function InterimButtonsView({
1993
2022
  showGooglePay,
1994
2023
  buttonsTheme,
1995
2024
  buttonsStyles: stylesOverride,
1996
- cardButtonContent
2025
+ cardButtonContent,
2026
+ cardBackButtonContent,
2027
+ cardTitleContent
1997
2028
  }) {
1998
2029
  const [showCardForm, setShowCardForm] = (0, import_react7.useState)(false);
1999
2030
  const bStyles = (0, import_react7.useMemo)(() => {
@@ -2004,6 +2035,8 @@ function InterimButtonsView({
2004
2035
  ...stylesOverride,
2005
2036
  cardButton: { ...base.cardButton, ...stylesOverride.cardButton },
2006
2037
  cardFormContainer: { ...base.cardFormContainer, ...stylesOverride.cardFormContainer },
2038
+ backButton: { ...base.backButton, ...stylesOverride.backButton },
2039
+ backButtonIcon: { ...base.backButtonIcon, ...stylesOverride.backButtonIcon },
2007
2040
  submitButton: { ...base.submitButton, ...stylesOverride.submitButton },
2008
2041
  title: { ...base.title, ...stylesOverride.title }
2009
2042
  };
@@ -2017,6 +2050,8 @@ function InterimButtonsView({
2017
2050
  if (showCardForm) {
2018
2051
  const inputBorder = bStyles.cardInputBorder ?? "#e5e7eb";
2019
2052
  const inputBg = bStyles.cardInputBackground ?? "white";
2053
+ const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
2054
+ const hideTitle = isEmptySlotContent(cardTitleContent);
2020
2055
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2021
2056
  backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
2022
2057
  borderRadius: "8px",
@@ -2030,10 +2065,11 @@ function InterimButtonsView({
2030
2065
  {
2031
2066
  type: "button",
2032
2067
  onClick: () => setShowCardForm(false),
2068
+ "aria-label": "Back to payment methods",
2033
2069
  style: {
2034
2070
  display: "inline-flex",
2035
2071
  alignItems: "center",
2036
- gap: "0.5rem",
2072
+ gap: hideBackButtonLabel ? 0 : "0.5rem",
2037
2073
  background: "none",
2038
2074
  border: "none",
2039
2075
  cursor: "pointer",
@@ -2055,11 +2091,11 @@ function InterimButtonsView({
2055
2091
  backgroundColor: "#f3f4f6",
2056
2092
  ...bStyles.backButtonIcon
2057
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" }) }) }),
2058
- "Go back"
2094
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
2059
2095
  ]
2060
2096
  }
2061
2097
  ),
2062
- /* @__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: {
2063
2099
  flex: 1,
2064
2100
  textAlign: "center",
2065
2101
  fontWeight: 600,
@@ -2067,7 +2103,7 @@ function InterimButtonsView({
2067
2103
  color: "#262833",
2068
2104
  paddingRight: 80,
2069
2105
  ...bStyles.title
2070
- }, children: "Secure card checkout" })
2106
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TitleContentSlot, { content: cardTitleContent }) })
2071
2107
  ] }),
2072
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" } }) }),
2073
2109
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex" }, children: [