@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.
- package/README.md +4 -0
- package/dist/chunks/{labels-DJ_RnkCQ.cjs → labels-BlZiVd3n.cjs} +82 -43
- package/dist/chunks/labels-BlZiVd3n.cjs.map +1 -0
- package/dist/chunks/{labels-ByA_yGKl.js → labels-CTR6b-KZ.js} +82 -43
- package/dist/chunks/labels-CTR6b-KZ.js.map +1 -0
- package/dist/chunks/{use-checkout-CQBSONj1.cjs → use-checkout-BEaLKgNa.cjs} +2 -2
- package/dist/chunks/{use-checkout-CQBSONj1.cjs.map → use-checkout-BEaLKgNa.cjs.map} +1 -1
- package/dist/chunks/{use-checkout-gAjnCzae.js → use-checkout-DwHd4uFh.js} +2 -2
- package/dist/chunks/{use-checkout-gAjnCzae.js.map → use-checkout-DwHd4uFh.js.map} +1 -1
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.d.cts +9 -0
- package/dist/core/index.d.ts +9 -0
- package/dist/core/index.js +1 -1
- package/dist/next/index.cjs +15 -7
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.d.cts +8 -0
- package/dist/next/index.d.ts +8 -0
- package/dist/next/index.js +16 -8
- package/dist/next/index.js.map +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.cts +8 -0
- package/dist/react/index.d.ts +8 -0
- package/dist/react/index.js +2 -2
- package/dist/styles.css +36 -118
- package/package.json +1 -1
- package/dist/chunks/labels-ByA_yGKl.js.map +0 -1
- package/dist/chunks/labels-DJ_RnkCQ.cjs.map +0 -1
package/dist/next/index.d.cts
CHANGED
|
@@ -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. */
|
package/dist/next/index.d.ts
CHANGED
|
@@ -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. */
|
package/dist/next/index.js
CHANGED
|
@@ -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-
|
|
5
|
-
export { S as SazitoProvider } from '../chunks/use-checkout-
|
|
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-
|
|
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': '
|
|
578
|
-
'--szc-rate-foreground': '
|
|
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
|
|
751
|
-
return (jsxs("div", { className: "szc-
|
|
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(
|
|
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, }) {
|