@sazito/checkout 0.1.2 → 0.2.1

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.
@@ -71,6 +71,14 @@ interface CheckoutTheme {
71
71
  danger?: string;
72
72
  /** Success and completed-state color. */
73
73
  success?: string;
74
+ /** Foreground used on top of solid success surfaces. */
75
+ successForeground?: string;
76
+ /** Background plate behind carrier and shipping-method logos. */
77
+ logoBackground?: string;
78
+ /** Neutral surface used when a shipping color is white or near-white. */
79
+ shippingNeutral?: string;
80
+ /** Foreground used on the neutral shipping surface. */
81
+ shippingNeutralForeground?: string;
74
82
  /** Base corner radius in px. */
75
83
  radius?: number;
76
84
  /** Font family. Defaults to `inherit` so the host font flows through. */
@@ -71,6 +71,14 @@ interface CheckoutTheme {
71
71
  danger?: string;
72
72
  /** Success and completed-state color. */
73
73
  success?: string;
74
+ /** Foreground used on top of solid success surfaces. */
75
+ successForeground?: string;
76
+ /** Background plate behind carrier and shipping-method logos. */
77
+ logoBackground?: string;
78
+ /** Neutral surface used when a shipping color is white or near-white. */
79
+ shippingNeutral?: string;
80
+ /** Foreground used on the neutral shipping surface. */
81
+ shippingNeutralForeground?: string;
74
82
  /** Base corner radius in px. */
75
83
  radius?: number;
76
84
  /** Font family. Defaults to `inherit` so the host font flows through. */
@@ -1,9 +1,9 @@
1
1
  'use client';
2
2
  import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
3
  import { isValidElement, cloneElement, useMemo, useState, useRef, useEffect, useCallback } from 'react';
4
- import { u as useCheckout, b as useSazitoClient, C as CheckoutProvider } from '../chunks/use-checkout-gAjnCzae.js';
5
- export { S as SazitoProvider } from '../chunks/use-checkout-gAjnCzae.js';
6
- import { m as formatPercent, E as sortCartItemsNewestFirst, H as toPersianDigits, r as isDigitalServiceGroup, t as isValidIranianMobile, z as normalizeIranianPhone, A as paymentMethodInfo, l as formatNumber } from '../chunks/labels-ByA_yGKl.js';
4
+ import { u as useCheckout, b as useSazitoClient, C as CheckoutProvider } from '../chunks/use-checkout-DwHd4uFh.js';
5
+ export { S as SazitoProvider } from '../chunks/use-checkout-DwHd4uFh.js';
6
+ import { m as formatPercent, E as sortCartItemsNewestFirst, H as toPersianDigits, r as isDigitalServiceGroup, t as isValidIranianMobile, z as normalizeIranianPhone, A as paymentMethodInfo, l as formatNumber } from '../chunks/labels-CTR6b-KZ.js';
7
7
  import '@sazito/client-sdk';
8
8
 
9
9
  /**
@@ -574,8 +574,8 @@ function shippingRateIconStyle(color) {
574
574
  // the card. Render a neutral chip with a slate glyph instead.
575
575
  if (luminance > 0.9) {
576
576
  return {
577
- '--szc-rate-color': '#eef0f5',
578
- '--szc-rate-foreground': '#475569'
577
+ '--szc-rate-color': 'var(--szc-shipping-neutral)',
578
+ '--szc-rate-foreground': 'var(--szc-shipping-neutral-foreground)'
579
579
  };
580
580
  }
581
581
  const foreground = luminance > 0.62
@@ -741,14 +741,22 @@ function themeVars(theme) {
741
741
  vars['--szc-danger'] = theme.danger;
742
742
  if (theme?.success)
743
743
  vars['--szc-success'] = theme.success;
744
+ if (theme?.successForeground)
745
+ vars['--szc-success-foreground'] = theme.successForeground;
746
+ if (theme?.logoBackground)
747
+ vars['--szc-logo-bg'] = theme.logoBackground;
748
+ if (theme?.shippingNeutral)
749
+ vars['--szc-shipping-neutral'] = theme.shippingNeutral;
750
+ if (theme?.shippingNeutralForeground)
751
+ vars['--szc-shipping-neutral-foreground'] = theme.shippingNeutralForeground;
744
752
  if (theme?.radius != null)
745
753
  vars['--szc-radius'] = `${theme.radius}px`;
746
754
  if (theme?.fontFamily)
747
755
  vars['--szc-font'] = theme.fontFamily;
748
756
  return vars;
749
757
  }
750
- function CheckoutSkeleton({ label }) {
751
- return (jsxs("div", { className: "szc-layout szc-skeleton-layout", role: "status", "aria-label": label, children: [jsxs("main", { className: "szc-main", "aria-hidden": "true", children: [jsxs("div", { className: "szc-skeleton-cart-row", children: [jsx("span", { className: "szc-skeleton szc-skeleton--thumb" }), jsxs("div", { className: "szc-skeleton-copy", children: [jsx("span", { className: "szc-skeleton szc-skeleton--title" }), jsx("span", { className: "szc-skeleton szc-skeleton--text" }), jsx("span", { className: "szc-skeleton szc-skeleton--price" })] }), jsx("span", { className: "szc-skeleton szc-skeleton--counter" })] }), jsxs("div", { className: "szc-skeleton-cart-row", children: [jsx("span", { className: "szc-skeleton szc-skeleton--thumb" }), jsxs("div", { className: "szc-skeleton-copy", children: [jsx("span", { className: "szc-skeleton szc-skeleton--title" }), jsx("span", { className: "szc-skeleton szc-skeleton--text" }), jsx("span", { className: "szc-skeleton szc-skeleton--price" })] }), jsx("span", { className: "szc-skeleton szc-skeleton--counter" })] })] }), jsxs("div", { className: "szc-side", "aria-hidden": "true", children: [jsxs("aside", { className: "szc-summary szc-summary--skeleton", children: [jsxs("div", { className: "szc-summary__total-head", children: [jsx("span", { className: "szc-skeleton szc-skeleton--summary-label" }), jsx("span", { className: "szc-skeleton szc-skeleton--summary-total" })] }), jsxs("div", { className: "szc-skeleton-summary-lines", children: [jsxs("div", { children: [jsx("span", { className: "szc-skeleton" }), jsx("span", { className: "szc-skeleton" })] }), jsxs("div", { children: [jsx("span", { className: "szc-skeleton" }), jsx("span", { className: "szc-skeleton" })] })] }), jsxs("div", { className: "szc-skeleton-summary-grand", children: [jsx("span", { className: "szc-skeleton" }), jsx("span", { className: "szc-skeleton" })] })] }), jsx("div", { className: "szc-side__cta", children: jsx("span", { className: "szc-skeleton szc-skeleton--button" }) })] })] }));
758
+ function CheckoutLoading({ label }) {
759
+ return (jsxs("div", { className: "szc-checkout-loading", role: "status", "aria-live": "polite", children: [jsx(Spinner, { className: "szc-checkout-loading__spinner" }), jsx("span", { children: label })] }));
752
760
  }
753
761
  function SazitoCheckout({ theme, continueShoppingUrl, className, renderNextButton, renderBackButton, renderEmptyCart, }) {
754
762
  const { state, actions, t, summary, money } = useCheckout();
@@ -823,7 +831,7 @@ function SazitoCheckout({ theme, continueShoppingUrl, className, renderNextButto
823
831
  ? CardIcon
824
832
  : ClipboardIcon;
825
833
  const mobileHead = (jsxs("div", { className: "szc-mobile-head", children: [footerVisible && backVisible ? (jsx("button", { type: "button", className: "szc-mobile-head__back", "aria-label": t.back, onClick: backOnClick, children: jsx("svg", { className: "szc-back-arrow", viewBox: "0 0 16 16", width: "18", height: "18", fill: "none", "aria-hidden": "true", children: jsx("path", { d: "M9.5 3.5 5 8l4.5 4.5", stroke: "currentColor", strokeWidth: "1.8", strokeLinecap: "round", strokeLinejoin: "round" }) }) })) : (jsx("span", {})), jsxs("span", { className: "szc-mobile-head__title", children: [jsx("span", { className: "szc-mobile-head__dot", children: jsx(HeadIcon, {}) }), headTitle] }), flowIndex >= 0 ? (jsx("span", { className: "szc-mobile-head__count", children: t.stepOf(formatNumber(flowIndex + 1, state.locale), formatNumber(flowSteps.length, state.locale)) })) : (jsx("span", {}))] }));
826
- return (jsxs("div", { className: `szc-root${className ? ` ${className}` : ''}`, dir: direction, style: themeVars(theme), children: [mobileHead, jsx(Stepper, {}), bootstrapping ? (jsx(CheckoutSkeleton, { label: t.loading })) : fatal ? (jsx(ErrorBanner, { message: error.message })) : isResult ? (jsx("div", { className: "szc-result-wrap", children: jsx(ResultStep, { continueShoppingUrl: continueShoppingUrl }) })) : (jsx(Fragment, { children: jsxs("div", { className: `szc-layout${cartEmpty ? ' szc-layout--full' : ''}`, children: [jsxs("main", { className: "szc-main", children: [error ? jsx(ErrorBanner, { message: error.message }) : null, step === 'cart' ? jsx(CartStep, { continueShoppingUrl: continueShoppingUrl, renderEmpty: renderEmptyCart }) : null, step === 'shipping' ? jsx(ShippingStep, {}) : null, step === 'payment' ? jsx(PaymentStep, {}) : null, actionsVisible && backButtonNode ? (jsx("div", { className: "szc-back-row", children: backButtonNode })) : null] }), !cartEmpty ? (jsxs("div", { className: "szc-side", children: [jsx(OrderSummary, {}), actionsVisible ? jsx("div", { className: "szc-side__cta", children: nextButtonNode }) : null] })) : null] }) })), actionsVisible ? (jsx("div", { className: "szc-footer-bar", children: jsxs("div", { className: "szc-footer", children: [jsxs("div", { className: "szc-footer__total", children: [jsx("span", { className: "szc-footer__total-label", children: t.total }), jsx("span", { className: "szc-footer__total-value", children: money(summary.total) })] }), jsx("div", { className: "szc-footer__actions", children: nextButtonNode })] }) })) : null] }));
834
+ return (jsxs("div", { className: `szc-root${className ? ` ${className}` : ''}`, dir: direction, style: themeVars(theme), children: [mobileHead, jsx(Stepper, {}), bootstrapping ? (jsx(CheckoutLoading, { label: t.loading })) : fatal ? (jsx(ErrorBanner, { message: error.message })) : isResult ? (jsx("div", { className: "szc-result-wrap", children: jsx(ResultStep, { continueShoppingUrl: continueShoppingUrl }) })) : (jsx(Fragment, { children: jsxs("div", { className: `szc-layout${cartEmpty ? ' szc-layout--full' : ''}`, children: [jsxs("main", { className: "szc-main", children: [error ? jsx(ErrorBanner, { message: error.message }) : null, step === 'cart' ? jsx(CartStep, { continueShoppingUrl: continueShoppingUrl, renderEmpty: renderEmptyCart }) : null, step === 'shipping' ? jsx(ShippingStep, {}) : null, step === 'payment' ? jsx(PaymentStep, {}) : null, actionsVisible && backButtonNode ? (jsx("div", { className: "szc-back-row", children: backButtonNode })) : null] }), !cartEmpty ? (jsxs("div", { className: "szc-side", children: [jsx(OrderSummary, {}), actionsVisible ? jsx("div", { className: "szc-side__cta", children: nextButtonNode }) : null] })) : null] }) })), actionsVisible ? (jsx("div", { className: "szc-footer-bar", children: jsxs("div", { className: "szc-footer", children: [jsxs("div", { className: "szc-footer__total", children: [jsx("span", { className: "szc-footer__total-label", children: t.total }), jsx("span", { className: "szc-footer__total-value", children: money(summary.total) })] }), jsx("div", { className: "szc-footer__actions", children: nextButtonNode })] }) })) : null] }));
827
835
  }
828
836
 
829
837
  function SazitoCheckoutPage({ credentials, config, paymentReturnParams, className, renderNextButton, renderBackButton, renderEmptyCart, }) {