@reevit/react 0.4.6 → 0.4.7

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
@@ -360,6 +360,36 @@ function mapAvailableProviders(providers) {
360
360
  };
361
361
  }).filter((provider) => provider.methods.length > 0);
362
362
  }
363
+ function normalizeBranding(branding) {
364
+ if (!branding) {
365
+ return {};
366
+ }
367
+ const raw = branding;
368
+ const theme = { ...raw };
369
+ const getString = (value) => typeof value === "string" ? value : void 0;
370
+ const getBoolean = (value) => typeof value === "boolean" ? value : void 0;
371
+ const setIf = (key, value) => {
372
+ if (value !== void 0) {
373
+ theme[key] = value;
374
+ }
375
+ };
376
+ setIf("logoUrl", getString(raw.logoUrl ?? raw.logo_url));
377
+ setIf("companyName", getString(raw.companyName ?? raw.company_name));
378
+ setIf("primaryColor", getString(raw.primaryColor ?? raw.primary_color));
379
+ setIf("primaryForegroundColor", getString(raw.primaryForegroundColor ?? raw.primary_foreground_color));
380
+ setIf("backgroundColor", getString(raw.backgroundColor ?? raw.background_color));
381
+ setIf("surfaceColor", getString(raw.surfaceColor ?? raw.surface_color));
382
+ setIf("textColor", getString(raw.textColor ?? raw.text_color));
383
+ setIf("mutedTextColor", getString(raw.mutedTextColor ?? raw.muted_text_color));
384
+ setIf("borderRadius", getString(raw.borderRadius ?? raw.border_radius));
385
+ setIf("fontFamily", getString(raw.fontFamily ?? raw.font_family));
386
+ setIf("darkMode", getBoolean(raw.darkMode ?? raw.dark_mode));
387
+ setIf("pspSelectorBgColor", getString(raw.pspSelectorBgColor ?? raw.psp_selector_bg_color));
388
+ setIf("pspSelectorTextColor", getString(raw.pspSelectorTextColor ?? raw.psp_selector_text_color));
389
+ setIf("pspSelectorBorderColor", getString(raw.pspSelectorBorderColor ?? raw.psp_selector_border_color));
390
+ setIf("pspSelectorUseBorder", getBoolean(raw.pspSelectorUseBorder ?? raw.psp_selector_use_border));
391
+ return theme;
392
+ }
363
393
  function mapToPaymentIntent(response, config) {
364
394
  return {
365
395
  id: response.id,
@@ -379,7 +409,7 @@ function mapToPaymentIntent(response, config) {
379
409
  netAmount: response.net_amount,
380
410
  metadata: config.metadata,
381
411
  availableProviders: mapAvailableProviders(response.available_psps),
382
- branding: response.branding
412
+ branding: normalizeBranding(response.branding)
383
413
  };
384
414
  }
385
415
  function useReevit(options) {
@@ -2178,6 +2208,7 @@ function ReevitCheckout({
2178
2208
  };
2179
2209
  }, [paymentIntent?.branding, theme]);
2180
2210
  const themeStyles = resolvedTheme ? createThemeVariables(resolvedTheme) : {};
2211
+ const brandName = resolvedTheme?.companyName;
2181
2212
  const themeMode = resolvedTheme?.darkMode;
2182
2213
  const dataTheme = useMemo(() => {
2183
2214
  if (typeof themeMode === "boolean") {
@@ -2420,7 +2451,17 @@ function ReevitCheckout({
2420
2451
  "aria-modal": "true",
2421
2452
  children: [
2422
2453
  /* @__PURE__ */ jsxs("div", { className: "reevit-modal__header", children: [
2423
- /* @__PURE__ */ jsx("div", { className: "reevit-modal__branding", children: /* @__PURE__ */ jsx("img", { src: resolvedTheme?.logoUrl || "https://i.imgur.com/bzUR5Lm.png", alt: "Checkout", className: "reevit-modal__logo" }) }),
2454
+ /* @__PURE__ */ jsxs("div", { className: "reevit-modal__branding", children: [
2455
+ /* @__PURE__ */ jsx(
2456
+ "img",
2457
+ {
2458
+ src: resolvedTheme?.logoUrl || "https://i.imgur.com/bzUR5Lm.png",
2459
+ alt: brandName || "Reevit",
2460
+ className: "reevit-modal__logo"
2461
+ }
2462
+ ),
2463
+ brandName && /* @__PURE__ */ jsx("span", { className: "reevit-modal__brand-name", children: brandName })
2464
+ ] }),
2424
2465
  /* @__PURE__ */ jsx("button", { className: "reevit-modal__close", onClick: handleClose, "aria-label": "Close", children: "\u2715" })
2425
2466
  ] }),
2426
2467
  /* @__PURE__ */ jsxs("div", { className: "reevit-modal__amount", children: [