bitsnap-react 1.5.0 → 1.6.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/dist/index.d.mts CHANGED
@@ -1,6 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
2
+ import { CSSProperties, ReactNode } from 'react';
3
3
  import z__default from 'zod';
4
+ export { BitsnapReturns, BitsnapReturnsProps, BitsnapReturnsProvider, BitsnapReturnsProviderProps, Environment, useCreateReturn, useMyReturns, useReturnOrders, useReturnSession, useReturnableOrder } from './returns.mjs';
5
+ import '@tanstack/react-query';
6
+ import '@bufbuild/protobuf/wkt';
7
+ import '@bufbuild/protobuf';
4
8
 
5
9
  type AppleButtonType = "plain" | "add-money" | "book" | "buy" | "check-out" | "continue" | "contribute" | "donate" | "order" | "pay" | "reload" | "rent" | "set-up" | "subscribe" | "support" | "tip" | "top-up";
6
10
  type ColorType = "black" | "white" | "white-outline";
@@ -28,6 +32,78 @@ type Props$3 = {
28
32
  };
29
33
  declare function Wrapper$2(props: Props$3): react_jsx_runtime.JSX.Element;
30
34
 
35
+ /**
36
+ * Checkout appearance API.
37
+ *
38
+ * `CheckoutAppearance` is resolved once per render into plain data: a theme
39
+ * name, the tokens that are actually in effect, the per-slot overrides and the
40
+ * inline style that both theme boundaries (the drawer root and the portalled
41
+ * country dropdown) have to receive. Everything here is pure so it can be
42
+ * tested without a DOM.
43
+ *
44
+ * Backward compatibility: the resolver never invents values. A token is only
45
+ * present in the resolved output when the caller provided it or when the
46
+ * caller explicitly selected a theme preset, so every unset token keeps falling
47
+ * back to the value the checkout renders today (see `checkout.css`).
48
+ */
49
+ type CheckoutTheme = "dark" | "light";
50
+ type CheckoutAppearanceTokens = {
51
+ /** Checkout wide font family. The library never loads fonts. */
52
+ fontFamily?: string;
53
+ /** Base font size of the checkout. */
54
+ fontSize?: string;
55
+ /** Panel background. */
56
+ background?: string;
57
+ /** Raised surfaces: country dropdown, search bar, loading skeletons. */
58
+ surface?: string;
59
+ /** Main text color. */
60
+ foreground?: string;
61
+ /** Secondary text: empty cart, delivery info, country label, search input. */
62
+ mutedForeground?: string;
63
+ /** Borders: country trigger, dropdown, product separators. */
64
+ border?: string;
65
+ /** Checkout button background. */
66
+ buttonBackground?: string;
67
+ /** Checkout button text. */
68
+ buttonForeground?: string;
69
+ /** Checkout button background on hover. */
70
+ buttonHoverBackground?: string;
71
+ /** Hover and selected surfaces: close button, country options. */
72
+ hoverSurface?: string;
73
+ /** Focus ring color. Also applied to shared UI primitives through `--ring`. */
74
+ focusRing?: string;
75
+ /** Error and unavailable state color. */
76
+ error?: string;
77
+ /** Drawer backdrop color. */
78
+ overlay?: string;
79
+ /** Corner radius, applied through `--radius`. */
80
+ radius?: string;
81
+ };
82
+ /**
83
+ * Stable slot names. They are exposed as `data-bitsnap-checkout-slot`
84
+ * attributes so they can also be targeted from plain CSS.
85
+ */
86
+ declare const CHECKOUT_SLOT_NAMES: readonly ["root", "overlay", "panel", "header", "title", "closeButton", "productList", "product", "productImage", "productName", "productPrice", "quantityControl", "quantityInput", "quantityButton", "removeButton", "summary", "totalLabel", "totalValue", "deliveryText", "countryLabel", "countryTrigger", "countryDropdown", "countrySearch", "countryOption", "paymentButtons", "checkoutButton", "emptyState", "error", "skeleton"];
87
+ type CheckoutSlotName = (typeof CHECKOUT_SLOT_NAMES)[number];
88
+ type CheckoutSlotAppearance = {
89
+ /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */
90
+ className?: string;
91
+ /** Merged after the built-in inline styles. */
92
+ style?: CSSProperties;
93
+ };
94
+ type CheckoutAppearanceElements = Partial<Record<CheckoutSlotName, CheckoutSlotAppearance>>;
95
+ type CheckoutAppearance = {
96
+ /**
97
+ * `"dark"` keeps the current presentation, `"light"` applies the light preset.
98
+ * Omitted means `"dark"`.
99
+ */
100
+ theme?: CheckoutTheme;
101
+ /** Partial overrides. Anything omitted keeps today's value. */
102
+ tokens?: CheckoutAppearanceTokens;
103
+ /** Per element `className`/`style` overrides. */
104
+ elements?: CheckoutAppearanceElements;
105
+ };
106
+
31
107
  type BitsnapCartProps = {
32
108
  projectID: string;
33
109
  locale?: string;
@@ -38,8 +114,13 @@ type BitsnapCartProps = {
38
114
  style?: React.CSSProperties;
39
115
  isVisible?: boolean;
40
116
  };
117
+ /**
118
+ * Optional checkout appearance. Omitting it (or passing `{}`) keeps the
119
+ * current presentation; every token and element slot is partial.
120
+ */
121
+ appearance?: CheckoutAppearance;
41
122
  };
42
- declare function BitsnapCart({ projectID, locale, children, onVisibleChange, className, numberOfProductsInCartOptions, }: BitsnapCartProps): react_jsx_runtime.JSX.Element;
123
+ declare function BitsnapCart({ projectID, locale, children, onVisibleChange, className, numberOfProductsInCartOptions, appearance, }: BitsnapCartProps): react_jsx_runtime.JSX.Element;
43
124
 
44
125
  type Props$2 = {
45
126
  test?: boolean;
@@ -261,6 +342,7 @@ declare const linkRequestSchema: z__default.ZodObject<{
261
342
  items: z__default.ZodArray<z__default.ZodObject<{
262
343
  id: z__default.ZodString;
263
344
  quantity: z__default.ZodNumber;
345
+ priceVersion: z__default.ZodOptional<z__default.ZodString>;
264
346
  name: z__default.ZodOptional<z__default.ZodString>;
265
347
  description: z__default.ZodOptional<z__default.ZodString>;
266
348
  imageURL: z__default.ZodOptional<z__default.ZodString>;
@@ -379,4 +461,4 @@ declare function persistReturnURL(returnURL: string | null): void;
379
461
  declare function readPersistedReturnURL(): string | null;
380
462
  declare function buildAccessTokenRedirect(returnURL: string, accessToken: string): string;
381
463
 
382
- export { Wrapper$2 as ApplePayButton, type Props$3 as ApplePayButtonProps, Bitsnap, type BitsnapCartProps, BitsnapCart as BitsnapCheckout, type ComponentClassNames, type CustomizationTexts, type GetThemeOutput, Wrapper$1 as GooglePayButton, type Props$2 as GooglePayButtonProps, type LinkRequest, type NotificationGroup, Wrapper as NotificationsComponent, type Props$1 as NotificationsComponentProps, type NotificationsComponentPublicProps, PanelPage as Panel, type PanelConfig, PanelLogin, type PanelLoginProps, type PanelProps, PanelProvider, type PanelScreen, type PanelSearchParamsType, type PublicNotificationGroup, PublicOrderPage, buildAccessTokenRedirect, createCheckout, createPaymentURL, getAllowedReturnOrigins, getLocale, getPanelConfig, getReferenceIfPossible, getReturnURLFromSearch, injectReferenceToRequestIfNeeded, persistReturnURL, readPersistedReturnURL, setAllowedReturnOrigins, setCustomHost, setHost, setLocale, setLoginURL, setPanelConfig, setProjectID as setPanelProjectID, setProjectID$1 as setProjectID, setTheme, usePanelConfig };
464
+ export { Wrapper$2 as ApplePayButton, type Props$3 as ApplePayButtonProps, Bitsnap, type BitsnapCartProps, BitsnapCart as BitsnapCheckout, CHECKOUT_SLOT_NAMES, type CheckoutAppearance, type CheckoutAppearanceElements, type CheckoutAppearanceTokens, type CheckoutSlotAppearance, type CheckoutSlotName, type CheckoutTheme, type ComponentClassNames, type CustomizationTexts, type GetThemeOutput, Wrapper$1 as GooglePayButton, type Props$2 as GooglePayButtonProps, type LinkRequest, type NotificationGroup, Wrapper as NotificationsComponent, type Props$1 as NotificationsComponentProps, type NotificationsComponentPublicProps, PanelPage as Panel, type PanelConfig, PanelLogin, type PanelLoginProps, type PanelProps, PanelProvider, type PanelScreen, type PanelSearchParamsType, type PublicNotificationGroup, PublicOrderPage, buildAccessTokenRedirect, createCheckout, createPaymentURL, getAllowedReturnOrigins, getLocale, getPanelConfig, getReferenceIfPossible, getReturnURLFromSearch, injectReferenceToRequestIfNeeded, persistReturnURL, readPersistedReturnURL, setAllowedReturnOrigins, setCustomHost, setHost, setLocale, setLoginURL, setPanelConfig, setProjectID as setPanelProjectID, setProjectID$1 as setProjectID, setTheme, usePanelConfig };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,10 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
2
+ import { CSSProperties, ReactNode } from 'react';
3
3
  import z__default from 'zod';
4
+ export { BitsnapReturns, BitsnapReturnsProps, BitsnapReturnsProvider, BitsnapReturnsProviderProps, Environment, useCreateReturn, useMyReturns, useReturnOrders, useReturnSession, useReturnableOrder } from './returns.js';
5
+ import '@tanstack/react-query';
6
+ import '@bufbuild/protobuf/wkt';
7
+ import '@bufbuild/protobuf';
4
8
 
5
9
  type AppleButtonType = "plain" | "add-money" | "book" | "buy" | "check-out" | "continue" | "contribute" | "donate" | "order" | "pay" | "reload" | "rent" | "set-up" | "subscribe" | "support" | "tip" | "top-up";
6
10
  type ColorType = "black" | "white" | "white-outline";
@@ -28,6 +32,78 @@ type Props$3 = {
28
32
  };
29
33
  declare function Wrapper$2(props: Props$3): react_jsx_runtime.JSX.Element;
30
34
 
35
+ /**
36
+ * Checkout appearance API.
37
+ *
38
+ * `CheckoutAppearance` is resolved once per render into plain data: a theme
39
+ * name, the tokens that are actually in effect, the per-slot overrides and the
40
+ * inline style that both theme boundaries (the drawer root and the portalled
41
+ * country dropdown) have to receive. Everything here is pure so it can be
42
+ * tested without a DOM.
43
+ *
44
+ * Backward compatibility: the resolver never invents values. A token is only
45
+ * present in the resolved output when the caller provided it or when the
46
+ * caller explicitly selected a theme preset, so every unset token keeps falling
47
+ * back to the value the checkout renders today (see `checkout.css`).
48
+ */
49
+ type CheckoutTheme = "dark" | "light";
50
+ type CheckoutAppearanceTokens = {
51
+ /** Checkout wide font family. The library never loads fonts. */
52
+ fontFamily?: string;
53
+ /** Base font size of the checkout. */
54
+ fontSize?: string;
55
+ /** Panel background. */
56
+ background?: string;
57
+ /** Raised surfaces: country dropdown, search bar, loading skeletons. */
58
+ surface?: string;
59
+ /** Main text color. */
60
+ foreground?: string;
61
+ /** Secondary text: empty cart, delivery info, country label, search input. */
62
+ mutedForeground?: string;
63
+ /** Borders: country trigger, dropdown, product separators. */
64
+ border?: string;
65
+ /** Checkout button background. */
66
+ buttonBackground?: string;
67
+ /** Checkout button text. */
68
+ buttonForeground?: string;
69
+ /** Checkout button background on hover. */
70
+ buttonHoverBackground?: string;
71
+ /** Hover and selected surfaces: close button, country options. */
72
+ hoverSurface?: string;
73
+ /** Focus ring color. Also applied to shared UI primitives through `--ring`. */
74
+ focusRing?: string;
75
+ /** Error and unavailable state color. */
76
+ error?: string;
77
+ /** Drawer backdrop color. */
78
+ overlay?: string;
79
+ /** Corner radius, applied through `--radius`. */
80
+ radius?: string;
81
+ };
82
+ /**
83
+ * Stable slot names. They are exposed as `data-bitsnap-checkout-slot`
84
+ * attributes so they can also be targeted from plain CSS.
85
+ */
86
+ declare const CHECKOUT_SLOT_NAMES: readonly ["root", "overlay", "panel", "header", "title", "closeButton", "productList", "product", "productImage", "productName", "productPrice", "quantityControl", "quantityInput", "quantityButton", "removeButton", "summary", "totalLabel", "totalValue", "deliveryText", "countryLabel", "countryTrigger", "countryDropdown", "countrySearch", "countryOption", "paymentButtons", "checkoutButton", "emptyState", "error", "skeleton"];
87
+ type CheckoutSlotName = (typeof CHECKOUT_SLOT_NAMES)[number];
88
+ type CheckoutSlotAppearance = {
89
+ /** Merged after the built-in classes with `cn`, so Tailwind conflicts resolve. */
90
+ className?: string;
91
+ /** Merged after the built-in inline styles. */
92
+ style?: CSSProperties;
93
+ };
94
+ type CheckoutAppearanceElements = Partial<Record<CheckoutSlotName, CheckoutSlotAppearance>>;
95
+ type CheckoutAppearance = {
96
+ /**
97
+ * `"dark"` keeps the current presentation, `"light"` applies the light preset.
98
+ * Omitted means `"dark"`.
99
+ */
100
+ theme?: CheckoutTheme;
101
+ /** Partial overrides. Anything omitted keeps today's value. */
102
+ tokens?: CheckoutAppearanceTokens;
103
+ /** Per element `className`/`style` overrides. */
104
+ elements?: CheckoutAppearanceElements;
105
+ };
106
+
31
107
  type BitsnapCartProps = {
32
108
  projectID: string;
33
109
  locale?: string;
@@ -38,8 +114,13 @@ type BitsnapCartProps = {
38
114
  style?: React.CSSProperties;
39
115
  isVisible?: boolean;
40
116
  };
117
+ /**
118
+ * Optional checkout appearance. Omitting it (or passing `{}`) keeps the
119
+ * current presentation; every token and element slot is partial.
120
+ */
121
+ appearance?: CheckoutAppearance;
41
122
  };
42
- declare function BitsnapCart({ projectID, locale, children, onVisibleChange, className, numberOfProductsInCartOptions, }: BitsnapCartProps): react_jsx_runtime.JSX.Element;
123
+ declare function BitsnapCart({ projectID, locale, children, onVisibleChange, className, numberOfProductsInCartOptions, appearance, }: BitsnapCartProps): react_jsx_runtime.JSX.Element;
43
124
 
44
125
  type Props$2 = {
45
126
  test?: boolean;
@@ -261,6 +342,7 @@ declare const linkRequestSchema: z__default.ZodObject<{
261
342
  items: z__default.ZodArray<z__default.ZodObject<{
262
343
  id: z__default.ZodString;
263
344
  quantity: z__default.ZodNumber;
345
+ priceVersion: z__default.ZodOptional<z__default.ZodString>;
264
346
  name: z__default.ZodOptional<z__default.ZodString>;
265
347
  description: z__default.ZodOptional<z__default.ZodString>;
266
348
  imageURL: z__default.ZodOptional<z__default.ZodString>;
@@ -379,4 +461,4 @@ declare function persistReturnURL(returnURL: string | null): void;
379
461
  declare function readPersistedReturnURL(): string | null;
380
462
  declare function buildAccessTokenRedirect(returnURL: string, accessToken: string): string;
381
463
 
382
- export { Wrapper$2 as ApplePayButton, type Props$3 as ApplePayButtonProps, Bitsnap, type BitsnapCartProps, BitsnapCart as BitsnapCheckout, type ComponentClassNames, type CustomizationTexts, type GetThemeOutput, Wrapper$1 as GooglePayButton, type Props$2 as GooglePayButtonProps, type LinkRequest, type NotificationGroup, Wrapper as NotificationsComponent, type Props$1 as NotificationsComponentProps, type NotificationsComponentPublicProps, PanelPage as Panel, type PanelConfig, PanelLogin, type PanelLoginProps, type PanelProps, PanelProvider, type PanelScreen, type PanelSearchParamsType, type PublicNotificationGroup, PublicOrderPage, buildAccessTokenRedirect, createCheckout, createPaymentURL, getAllowedReturnOrigins, getLocale, getPanelConfig, getReferenceIfPossible, getReturnURLFromSearch, injectReferenceToRequestIfNeeded, persistReturnURL, readPersistedReturnURL, setAllowedReturnOrigins, setCustomHost, setHost, setLocale, setLoginURL, setPanelConfig, setProjectID as setPanelProjectID, setProjectID$1 as setProjectID, setTheme, usePanelConfig };
464
+ export { Wrapper$2 as ApplePayButton, type Props$3 as ApplePayButtonProps, Bitsnap, type BitsnapCartProps, BitsnapCart as BitsnapCheckout, CHECKOUT_SLOT_NAMES, type CheckoutAppearance, type CheckoutAppearanceElements, type CheckoutAppearanceTokens, type CheckoutSlotAppearance, type CheckoutSlotName, type CheckoutTheme, type ComponentClassNames, type CustomizationTexts, type GetThemeOutput, Wrapper$1 as GooglePayButton, type Props$2 as GooglePayButtonProps, type LinkRequest, type NotificationGroup, Wrapper as NotificationsComponent, type Props$1 as NotificationsComponentProps, type NotificationsComponentPublicProps, PanelPage as Panel, type PanelConfig, PanelLogin, type PanelLoginProps, type PanelProps, PanelProvider, type PanelScreen, type PanelSearchParamsType, type PublicNotificationGroup, PublicOrderPage, buildAccessTokenRedirect, createCheckout, createPaymentURL, getAllowedReturnOrigins, getLocale, getPanelConfig, getReferenceIfPossible, getReturnURLFromSearch, injectReferenceToRequestIfNeeded, persistReturnURL, readPersistedReturnURL, setAllowedReturnOrigins, setCustomHost, setHost, setLocale, setLoginURL, setPanelConfig, setProjectID as setPanelProjectID, setProjectID$1 as setProjectID, setTheme, usePanelConfig };