@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.d.cts CHANGED
@@ -83,6 +83,10 @@ interface FloPayCheckoutProps {
83
83
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
84
84
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
85
85
  cardButtonContent?: React.ReactNode;
86
+ /** Custom React content rendered for the buttons-layout card back button label. */
87
+ cardBackButtonContent?: React.ReactNode;
88
+ /** Custom React content rendered for the card-form title. */
89
+ cardTitleContent?: React.ReactNode;
86
90
  /**
87
91
  * Called when a payment method button is clicked.
88
92
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
@@ -138,7 +142,7 @@ interface FloPayCheckoutProps {
138
142
  * />
139
143
  * ```
140
144
  */
141
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
145
+ declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
142
146
 
143
147
  /**
144
148
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -380,6 +384,10 @@ interface SplitCardFormProps {
380
384
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
381
385
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
382
386
  cardButtonContent?: React.ReactNode;
387
+ /** Custom React content rendered for the buttons-layout card back button label. */
388
+ cardBackButtonContent?: React.ReactNode;
389
+ /** Custom React content rendered for the card-form title. */
390
+ cardTitleContent?: React.ReactNode;
383
391
  /**
384
392
  * Called when a payment method button is clicked.
385
393
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
package/dist/index.d.ts CHANGED
@@ -83,6 +83,10 @@ interface FloPayCheckoutProps {
83
83
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
84
84
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
85
85
  cardButtonContent?: React.ReactNode;
86
+ /** Custom React content rendered for the buttons-layout card back button label. */
87
+ cardBackButtonContent?: React.ReactNode;
88
+ /** Custom React content rendered for the card-form title. */
89
+ cardTitleContent?: React.ReactNode;
86
90
  /**
87
91
  * Called when a payment method button is clicked.
88
92
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
@@ -138,7 +142,7 @@ interface FloPayCheckoutProps {
138
142
  * />
139
143
  * ```
140
144
  */
141
- declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
145
+ declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
142
146
 
143
147
  /**
144
148
  * Returns the current `FloPay` instance, or `null` if the provider
@@ -380,6 +384,10 @@ interface SplitCardFormProps {
380
384
  buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
381
385
  /** Custom React content rendered inside the card button when `layout="buttons"`. */
382
386
  cardButtonContent?: React.ReactNode;
387
+ /** Custom React content rendered for the buttons-layout card back button label. */
388
+ cardBackButtonContent?: React.ReactNode;
389
+ /** Custom React content rendered for the card-form title. */
390
+ cardTitleContent?: React.ReactNode;
383
391
  /**
384
392
  * Called when a payment method button is clicked.
385
393
  * `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
package/dist/index.mjs CHANGED
@@ -113,10 +113,29 @@ function DefaultCardButtonContent() {
113
113
  )
114
114
  ] });
115
115
  }
116
+ function DefaultBackButtonContent() {
117
+ return /* @__PURE__ */ jsx2(Fragment, { children: "Go back" });
118
+ }
119
+ function DefaultTitleContent() {
120
+ return /* @__PURE__ */ jsx2(Fragment, { children: "Secure card checkout" });
121
+ }
122
+ function isEmptySlotContent(content) {
123
+ return content !== void 0 && (content === "" || content === null || content === false);
124
+ }
116
125
  function CardButtonContentSlot({
117
126
  content
118
127
  }) {
119
- return /* @__PURE__ */ jsx2(Fragment, { children: content ?? /* @__PURE__ */ jsx2(DefaultCardButtonContent, {}) });
128
+ return /* @__PURE__ */ jsx2(Fragment, { children: content === void 0 ? /* @__PURE__ */ jsx2(DefaultCardButtonContent, {}) : content });
129
+ }
130
+ function BackButtonContentSlot({
131
+ content
132
+ }) {
133
+ return /* @__PURE__ */ jsx2(Fragment, { children: content === void 0 ? /* @__PURE__ */ jsx2(DefaultBackButtonContent, {}) : content });
134
+ }
135
+ function TitleContentSlot({
136
+ content
137
+ }) {
138
+ return /* @__PURE__ */ jsx2(Fragment, { children: content === void 0 ? /* @__PURE__ */ jsx2(DefaultTitleContent, {}) : content });
120
139
  }
121
140
 
122
141
  // src/elements.tsx
@@ -598,6 +617,8 @@ function SplitCardFormInner({
598
617
  buttonsTheme,
599
618
  buttonsStyles: buttonsStylesOverride,
600
619
  cardButtonContent,
620
+ cardBackButtonContent,
621
+ cardTitleContent,
601
622
  onButtonClick,
602
623
  enableAVS = false,
603
624
  avsLayout: avsLayoutProp = "row",
@@ -944,6 +965,8 @@ function SplitCardFormInner({
944
965
  const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
945
966
  const cardBg = isButtons ? bStyles.cardFormContainer?.backgroundColor ?? "white" : "#EDEDFF";
946
967
  const cardInputBg = isButtons ? bStyles.cardInputBackground ?? "white" : "white";
968
+ const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
969
+ const hideTitle = isEmptySlotContent(cardTitleContent);
947
970
  const stripeElementStyle = isButtons && (bStyles.cardInputColor || bStyles.cardInputPlaceholderColor || bStyles.cardInputFontSize) ? {
948
971
  style: {
949
972
  base: {
@@ -974,7 +997,7 @@ function SplitCardFormInner({
974
997
  style: {
975
998
  display: "inline-flex",
976
999
  alignItems: "center",
977
- gap: "0.5rem",
1000
+ gap: hideBackButtonLabel ? 0 : "0.5rem",
978
1001
  background: "none",
979
1002
  border: "none",
980
1003
  cursor: "pointer",
@@ -999,11 +1022,11 @@ function SplitCardFormInner({
999
1022
  transition: "background-color 0.15s",
1000
1023
  ...bStyles.backButtonIcon
1001
1024
  }, children: /* @__PURE__ */ jsx4("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx4("path", { d: "M15 18l-6-6 6-6" }) }) }),
1002
- "Go back"
1025
+ /* @__PURE__ */ jsx4(BackButtonContentSlot, { content: cardBackButtonContent })
1003
1026
  ]
1004
1027
  }
1005
1028
  ),
1006
- /* @__PURE__ */ jsx4("div", { style: {
1029
+ hideTitle ? /* @__PURE__ */ jsx4("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx4("div", { style: {
1007
1030
  flex: 1,
1008
1031
  textAlign: "center",
1009
1032
  fontWeight: 600,
@@ -1011,9 +1034,9 @@ function SplitCardFormInner({
1011
1034
  color: "#262833",
1012
1035
  paddingRight: 80,
1013
1036
  ...bStyles.title
1014
- }, children: "Secure card checkout" })
1037
+ }, children: /* @__PURE__ */ jsx4(TitleContentSlot, { content: cardTitleContent }) })
1015
1038
  ] }),
1016
- !isButtons && /* @__PURE__ */ jsx4("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: "Secure card checkout" }),
1039
+ !isButtons && !hideTitle && /* @__PURE__ */ jsx4("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: /* @__PURE__ */ jsx4(TitleContentSlot, { content: cardTitleContent }) }),
1017
1040
  /* @__PURE__ */ jsx4("div", { style: {
1018
1041
  backgroundColor: cardInputBg,
1019
1042
  border: `1px solid ${resolvedBorder}`,
@@ -1362,6 +1385,8 @@ function FloPayCheckout({
1362
1385
  buttonsTheme,
1363
1386
  buttonsStyles,
1364
1387
  cardButtonContent,
1388
+ cardBackButtonContent,
1389
+ cardTitleContent,
1365
1390
  onButtonClick,
1366
1391
  enableAVS,
1367
1392
  avsLayout,
@@ -1819,7 +1844,9 @@ function FloPayCheckout({
1819
1844
  showGooglePay,
1820
1845
  buttonsTheme,
1821
1846
  buttonsStyles,
1822
- cardButtonContent
1847
+ cardButtonContent,
1848
+ cardBackButtonContent,
1849
+ cardTitleContent
1823
1850
  }
1824
1851
  ) });
1825
1852
  }
@@ -1907,6 +1934,8 @@ function FloPayCheckout({
1907
1934
  buttonsTheme,
1908
1935
  buttonsStyles,
1909
1936
  cardButtonContent,
1937
+ cardBackButtonContent,
1938
+ cardTitleContent,
1910
1939
  onButtonClick,
1911
1940
  enableAVS,
1912
1941
  avsLayout,
@@ -1949,7 +1978,9 @@ function InterimButtonsView({
1949
1978
  showGooglePay,
1950
1979
  buttonsTheme,
1951
1980
  buttonsStyles: stylesOverride,
1952
- cardButtonContent
1981
+ cardButtonContent,
1982
+ cardBackButtonContent,
1983
+ cardTitleContent
1953
1984
  }) {
1954
1985
  const [showCardForm, setShowCardForm] = useState3(false);
1955
1986
  const bStyles = useMemo3(() => {
@@ -1960,6 +1991,8 @@ function InterimButtonsView({
1960
1991
  ...stylesOverride,
1961
1992
  cardButton: { ...base.cardButton, ...stylesOverride.cardButton },
1962
1993
  cardFormContainer: { ...base.cardFormContainer, ...stylesOverride.cardFormContainer },
1994
+ backButton: { ...base.backButton, ...stylesOverride.backButton },
1995
+ backButtonIcon: { ...base.backButtonIcon, ...stylesOverride.backButtonIcon },
1963
1996
  submitButton: { ...base.submitButton, ...stylesOverride.submitButton },
1964
1997
  title: { ...base.title, ...stylesOverride.title }
1965
1998
  };
@@ -1973,6 +2006,8 @@ function InterimButtonsView({
1973
2006
  if (showCardForm) {
1974
2007
  const inputBorder = bStyles.cardInputBorder ?? "#e5e7eb";
1975
2008
  const inputBg = bStyles.cardInputBackground ?? "white";
2009
+ const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
2010
+ const hideTitle = isEmptySlotContent(cardTitleContent);
1976
2011
  return /* @__PURE__ */ jsxs3("div", { style: {
1977
2012
  backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
1978
2013
  borderRadius: "8px",
@@ -1986,10 +2021,11 @@ function InterimButtonsView({
1986
2021
  {
1987
2022
  type: "button",
1988
2023
  onClick: () => setShowCardForm(false),
2024
+ "aria-label": "Back to payment methods",
1989
2025
  style: {
1990
2026
  display: "inline-flex",
1991
2027
  alignItems: "center",
1992
- gap: "0.5rem",
2028
+ gap: hideBackButtonLabel ? 0 : "0.5rem",
1993
2029
  background: "none",
1994
2030
  border: "none",
1995
2031
  cursor: "pointer",
@@ -2011,11 +2047,11 @@ function InterimButtonsView({
2011
2047
  backgroundColor: "#f3f4f6",
2012
2048
  ...bStyles.backButtonIcon
2013
2049
  }, children: /* @__PURE__ */ jsx5("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx5("path", { d: "M15 18l-6-6 6-6" }) }) }),
2014
- "Go back"
2050
+ /* @__PURE__ */ jsx5(BackButtonContentSlot, { content: cardBackButtonContent })
2015
2051
  ]
2016
2052
  }
2017
2053
  ),
2018
- /* @__PURE__ */ jsx5("div", { style: {
2054
+ hideTitle ? /* @__PURE__ */ jsx5("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx5("div", { style: {
2019
2055
  flex: 1,
2020
2056
  textAlign: "center",
2021
2057
  fontWeight: 600,
@@ -2023,7 +2059,7 @@ function InterimButtonsView({
2023
2059
  color: "#262833",
2024
2060
  paddingRight: 80,
2025
2061
  ...bStyles.title
2026
- }, children: "Secure card checkout" })
2062
+ }, children: /* @__PURE__ */ jsx5(TitleContentSlot, { content: cardTitleContent }) })
2027
2063
  ] }),
2028
2064
  /* @__PURE__ */ jsx5("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx5("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
2029
2065
  /* @__PURE__ */ jsxs3("div", { style: { display: "flex" }, children: [