bitsnap-react 1.4.15 → 1.6.0

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.
@@ -0,0 +1,464 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { CSSProperties, ReactNode } from 'react';
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';
8
+
9
+ type AppleButtonType = "plain" | "add-money" | "book" | "buy" | "check-out" | "continue" | "contribute" | "donate" | "order" | "pay" | "reload" | "rent" | "set-up" | "subscribe" | "support" | "tip" | "top-up";
10
+ type ColorType = "black" | "white" | "white-outline";
11
+ type Props$3 = {
12
+ style?: {
13
+ width?: string;
14
+ height?: string;
15
+ borderRadius?: string;
16
+ padding?: string;
17
+ boxSizing?: string;
18
+ };
19
+ buttonType?: AppleButtonType;
20
+ colorType?: ColorType;
21
+ items: {
22
+ name: string;
23
+ id: string;
24
+ price: number;
25
+ quantity: number;
26
+ isDeliverable?: boolean;
27
+ metadata?: {
28
+ [key: string]: string | undefined;
29
+ };
30
+ }[];
31
+ onClick?: () => Promise<void>;
32
+ };
33
+ declare function Wrapper$2(props: Props$3): react_jsx_runtime.JSX.Element;
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
+
107
+ type BitsnapCartProps = {
108
+ projectID: string;
109
+ locale?: string;
110
+ children?: React.ReactNode;
111
+ onVisibleChange?: (isVisible: boolean) => void;
112
+ className?: string;
113
+ numberOfProductsInCartOptions?: {
114
+ style?: React.CSSProperties;
115
+ isVisible?: boolean;
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;
122
+ };
123
+ declare function BitsnapCart({ projectID, locale, children, onVisibleChange, className, numberOfProductsInCartOptions, appearance, }: BitsnapCartProps): react_jsx_runtime.JSX.Element;
124
+
125
+ type Props$2 = {
126
+ test?: boolean;
127
+ buttonSizeMode?: "static" | "fill";
128
+ buttonColor?: "white" | "black";
129
+ style?: {
130
+ width?: string;
131
+ };
132
+ items: {
133
+ name: string;
134
+ id: string;
135
+ price: number;
136
+ quantity: number;
137
+ isDeliverable?: boolean;
138
+ metadata?: {
139
+ [key: string]: string | undefined;
140
+ };
141
+ }[];
142
+ };
143
+ declare function Wrapper$1(props: Props$2): react_jsx_runtime.JSX.Element;
144
+
145
+ type PublicNotificationGroup = {
146
+ id: string;
147
+ isOn?: boolean;
148
+ };
149
+ type NotificationGroup = {
150
+ id: string;
151
+ name: string;
152
+ description?: string;
153
+ howOften?: string;
154
+ isOn?: boolean;
155
+ };
156
+ interface CustomizationTexts {
157
+ title?: string | null;
158
+ description?: string | null;
159
+ managingDescription?: string;
160
+ formTitle?: string;
161
+ formEmailLabel?: string;
162
+ formPhoneLabel?: string;
163
+ formPhoneOptional?: string;
164
+ formEmailPlaceholder?: string;
165
+ formPhonePlaceholder?: string;
166
+ formSubmitButton?: string;
167
+ formSuccessMessage?: string;
168
+ agreementText?: string | ReactNode;
169
+ qrCodeTitle?: string;
170
+ qrCodeSubtitle?: string;
171
+ qrCodeScanText?: string;
172
+ groupsNoSelectionWarning?: string;
173
+ groupsTitle?: string;
174
+ groupsSelectAllButton?: string;
175
+ groupsUpdateButton?: string;
176
+ groupsUpdateSuccess?: string;
177
+ manageDataTitle?: string;
178
+ manageDataDescription?: string;
179
+ manageDataUnsubscribeButton?: string;
180
+ manageDataUnsubscribeDescription?: string;
181
+ manageDataUpdatedMessage?: string;
182
+ loginEmailLabel?: string;
183
+ loginEmailPlaceholder?: string;
184
+ loginSendCodeButton?: string;
185
+ loginIHaveCode?: string;
186
+ loginSendingButton?: string;
187
+ loginCodeLabel?: string;
188
+ loginCodeSentMessage?: string;
189
+ loginChangeEmailButton?: string;
190
+ loginResendCodeButton?: string;
191
+ loginInvalidEmailError?: string;
192
+ loginSlugRequiredError?: string;
193
+ loginVerificationFailedError?: string;
194
+ loginInvalidCodeError?: string;
195
+ loginSendEmailError?: string;
196
+ loginVerifyCodeError?: string;
197
+ loginResendEmailError?: string;
198
+ loginTitle?: string;
199
+ loginDescription?: string;
200
+ }
201
+ interface ComponentClassNames {
202
+ container?: string;
203
+ header?: string;
204
+ headerTitle?: string;
205
+ headerLogo?: string;
206
+ headerDescription?: string;
207
+ groupsContainer?: string;
208
+ groupsList?: string;
209
+ groupItem?: string;
210
+ qrCodeSection?: string;
211
+ qrCodeTitle?: string;
212
+ qrCodeContainer?: string;
213
+ formSection?: string;
214
+ formTitle?: string;
215
+ formContainer?: string;
216
+ manageDataSection?: string;
217
+ manageDataTitle?: string;
218
+ }
219
+ /**
220
+ * Props for the NotificationsComponentPublic component.
221
+ */
222
+ interface NotificationsComponentPublicProps {
223
+ /**
224
+ * Unique identifier for the project (if not provided, productID will be used via CartProvider).
225
+ */
226
+ slug?: string;
227
+ /**
228
+ * Unique identifier for the user.
229
+ */
230
+ userID?: string;
231
+ /**
232
+ * Project ID (alternative to slug, used if slug is not provided).
233
+ */
234
+ productID?: string;
235
+ /**
236
+ * Name of the project, displayed in the component.
237
+ */
238
+ projectName?: string;
239
+ /**
240
+ * URL or path to the project's logo (light mode).
241
+ */
242
+ projectLogo?: string;
243
+ /**
244
+ * URL or path to the project's logo (dark mode).
245
+ */
246
+ projectLogoDark?: string;
247
+ /**
248
+ * Array of notification groups that the user can subscribe to. If you will provide group, we will not show all possible public groups from dashboard.
249
+ */
250
+ groups?: PublicNotificationGroup[];
251
+ /**
252
+ * If true, the component is rendered in "manage my notifications" mode.
253
+ */
254
+ isManaging?: boolean;
255
+ /**
256
+ * Custom texts used throughout the component for i18n or personalisation.
257
+ */
258
+ texts?: CustomizationTexts;
259
+ /**
260
+ * If true, show the QR code section that allows users to get a mobile app.
261
+ */
262
+ showQRCode?: boolean;
263
+ /**
264
+ * If true, show the phone input in the notification form.
265
+ */
266
+ showPhoneInput?: boolean;
267
+ /**
268
+ * List of group IDs to hide from the selection interface.
269
+ */
270
+ hiddenGroupIds?: string[];
271
+ /**
272
+ * Custom CSS class names for various component sections (for easier styling).
273
+ */
274
+ className?: ComponentClassNames;
275
+ }
276
+
277
+ type Props$1 = NotificationsComponentPublicProps;
278
+ declare function Wrapper({ slug, userID, productID, projectName, projectLogo, projectLogoDark, groups, isManaging, texts, showQRCode, showPhoneInput, hiddenGroupIds, className, }: Props$1): react_jsx_runtime.JSX.Element;
279
+
280
+ type ErrTypes = "internal" | "badInput" | "notFound";
281
+ type Err = {
282
+ ERR: true;
283
+ error: unknown;
284
+ type?: ErrTypes;
285
+ data?: unknown;
286
+ };
287
+ declare function Err(message: string, type?: ErrTypes, data?: unknown): Err;
288
+
289
+ declare function setLocale(locale?: string): void;
290
+ declare function getLocale(): string;
291
+
292
+ declare function setProjectID$1(projectID: string): void;
293
+
294
+ declare function setCustomHost(host: string): void;
295
+
296
+ declare enum BillingPeriod {
297
+ DAILY = "daily",
298
+ WEEKLY = "weekly",
299
+ MONTHLY = "monthly",
300
+ QUARTERLY = "quarterly",
301
+ SEMI_ANNUALLY = "semi-annually",
302
+ ANNUALLY = "annually"
303
+ }
304
+ type LinkRequest = z__default.infer<typeof linkRequestSchema>;
305
+ declare const linkRequestSchema: z__default.ZodObject<{
306
+ locale: z__default.ZodOptional<z__default.ZodString>;
307
+ askForAddress: z__default.ZodOptional<z__default.ZodBoolean>;
308
+ askForPhone: z__default.ZodOptional<z__default.ZodBoolean>;
309
+ askForNote: z__default.ZodOptional<z__default.ZodBoolean>;
310
+ askForNip: z__default.ZodOptional<z__default.ZodBoolean>;
311
+ delivery: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
312
+ name: z__default.ZodString;
313
+ desc: z__default.ZodOptional<z__default.ZodString>;
314
+ min: z__default.ZodNumber;
315
+ max: z__default.ZodNumber;
316
+ price: z__default.ZodPipe<z__default.ZodNumber, z__default.ZodTransform<number, number>>;
317
+ }, z__default.core.$strip>>>;
318
+ deliveryMethod: z__default.ZodOptional<z__default.ZodString>;
319
+ details: z__default.ZodOptional<z__default.ZodObject<{
320
+ email: z__default.ZodOptional<z__default.ZodString>;
321
+ name: z__default.ZodOptional<z__default.ZodString>;
322
+ lastName: z__default.ZodOptional<z__default.ZodString>;
323
+ phone: z__default.ZodOptional<z__default.ZodString>;
324
+ address: z__default.ZodOptional<z__default.ZodObject<{
325
+ name: z__default.ZodOptional<z__default.ZodString>;
326
+ line1: z__default.ZodOptional<z__default.ZodString>;
327
+ line2: z__default.ZodOptional<z__default.ZodString>;
328
+ city: z__default.ZodOptional<z__default.ZodString>;
329
+ zipCode: z__default.ZodOptional<z__default.ZodString>;
330
+ country: z__default.ZodOptional<z__default.ZodString>;
331
+ }, z__default.core.$strip>>;
332
+ billingAddress: z__default.ZodOptional<z__default.ZodObject<{
333
+ nip: z__default.ZodOptional<z__default.ZodString>;
334
+ name: z__default.ZodOptional<z__default.ZodString>;
335
+ line1: z__default.ZodOptional<z__default.ZodString>;
336
+ line2: z__default.ZodOptional<z__default.ZodString>;
337
+ city: z__default.ZodOptional<z__default.ZodString>;
338
+ zipCode: z__default.ZodOptional<z__default.ZodString>;
339
+ }, z__default.core.$strip>>;
340
+ }, z__default.core.$strip>>;
341
+ countries: z__default.ZodOptional<z__default.ZodArray<z__default.ZodString>>;
342
+ items: z__default.ZodArray<z__default.ZodObject<{
343
+ id: z__default.ZodString;
344
+ quantity: z__default.ZodNumber;
345
+ priceVersion: z__default.ZodOptional<z__default.ZodString>;
346
+ name: z__default.ZodOptional<z__default.ZodString>;
347
+ description: z__default.ZodOptional<z__default.ZodString>;
348
+ imageURL: z__default.ZodOptional<z__default.ZodString>;
349
+ price: z__default.ZodOptional<z__default.ZodNumber>;
350
+ currency: z__default.ZodOptional<z__default.ZodString>;
351
+ recurring: z__default.ZodOptional<z__default.ZodObject<{
352
+ billingPeriod: z__default.ZodEnum<{
353
+ daily: BillingPeriod.DAILY;
354
+ weekly: BillingPeriod.WEEKLY;
355
+ monthly: BillingPeriod.MONTHLY;
356
+ quarterly: BillingPeriod.QUARTERLY;
357
+ "semi-annually": BillingPeriod.SEMI_ANNUALLY;
358
+ annually: BillingPeriod.ANNUALLY;
359
+ }>;
360
+ trialDays: z__default.ZodOptional<z__default.ZodNumber>;
361
+ subscriptionSchedule: z__default.ZodOptional<z__default.ZodNumber>;
362
+ }, z__default.core.$strip>>;
363
+ }, z__default.core.$strip>>;
364
+ metadata: z__default.ZodOptional<z__default.ZodRecord<z__default.ZodString, z__default.ZodString>>;
365
+ additionalAgreements: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
366
+ id: z__default.ZodOptional<z__default.ZodString>;
367
+ name: z__default.ZodString;
368
+ description: z__default.ZodOptional<z__default.ZodString>;
369
+ required: z__default.ZodDefault<z__default.ZodBoolean>;
370
+ answer: z__default.ZodOptional<z__default.ZodBoolean>;
371
+ }, z__default.core.$strip>>>;
372
+ blikCode: z__default.ZodOptional<z__default.ZodString>;
373
+ couponCode: z__default.ZodOptional<z__default.ZodString>;
374
+ redirect: z__default.ZodOptional<z__default.ZodObject<{
375
+ successURL: z__default.ZodOptional<z__default.ZodString>;
376
+ cancelURL: z__default.ZodOptional<z__default.ZodString>;
377
+ }, z__default.core.$strip>>;
378
+ }, z__default.core.$strip>;
379
+
380
+ declare namespace Bitsnap {
381
+ function addProductToCart(id: string, quantity?: number, metadata?: Record<string, string | undefined>, args?: {
382
+ name?: string;
383
+ price?: number;
384
+ currency?: string;
385
+ }): Promise<Err | undefined>;
386
+ function showCart(): void;
387
+ function hideCart(): void;
388
+ }
389
+ declare function createPaymentURL(request: LinkRequest): Promise<Err | {
390
+ url: string;
391
+ }>;
392
+ declare function createCheckout(request: LinkRequest & {
393
+ apiKey?: string;
394
+ testMode?: boolean;
395
+ }): Promise<{
396
+ status: string;
397
+ redirectURL: string;
398
+ }>;
399
+ declare function getReferenceIfPossible(): string | undefined;
400
+ declare function injectReferenceToRequestIfNeeded(request: LinkRequest): LinkRequest;
401
+
402
+ declare const PanelLogin: () => react_jsx_runtime.JSX.Element;
403
+
404
+ declare const PanelPage: () => react_jsx_runtime.JSX.Element;
405
+
406
+ interface Props {
407
+ orderID: string;
408
+ initialEmail?: string;
409
+ accessToken?: string;
410
+ onBack?: () => void;
411
+ }
412
+ declare function PublicOrderPage(props: Props): react_jsx_runtime.JSX.Element;
413
+
414
+ interface GetThemeOutput {
415
+ logoURL?: string;
416
+ logoDarkURL?: string;
417
+ colors?: {
418
+ brand?: string;
419
+ brandDark?: string;
420
+ };
421
+ }
422
+ type PanelScreen = "products" | "notifications" | "profile" | "plans" | "orders" | "order-details";
423
+ type PanelSearchParamsType = {
424
+ product?: string;
425
+ state: PanelScreen;
426
+ orderId?: string;
427
+ };
428
+ interface PanelProps {
429
+ projectID: string;
430
+ theme?: GetThemeOutput;
431
+ loginURL: string;
432
+ }
433
+ interface PanelLoginProps {
434
+ projectID: string;
435
+ theme?: GetThemeOutput;
436
+ }
437
+
438
+ interface PanelConfig {
439
+ projectID?: string;
440
+ loginURL?: string;
441
+ theme?: GetThemeOutput;
442
+ host?: string;
443
+ allowedReturnOrigins: string[];
444
+ }
445
+ declare function setPanelConfig(newConfig: Partial<PanelConfig>): void;
446
+ declare function getPanelConfig(): PanelConfig;
447
+ declare function setProjectID(projectID: string): void;
448
+ declare function setTheme(theme: GetThemeOutput): void;
449
+ declare function setLoginURL(loginURL: string): void;
450
+ declare function setHost(host: string): void;
451
+ declare function setAllowedReturnOrigins(origins: string[]): void;
452
+ declare function getAllowedReturnOrigins(): string[];
453
+
454
+ declare const PanelProvider: React.FC<{
455
+ children: React.ReactNode;
456
+ }>;
457
+ declare const usePanelConfig: () => PanelConfig;
458
+
459
+ declare function getReturnURLFromSearch(search: string): string | null;
460
+ declare function persistReturnURL(returnURL: string | null): void;
461
+ declare function readPersistedReturnURL(): string | null;
462
+ declare function buildAccessTokenRedirect(returnURL: string, accessToken: string): string;
463
+
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 };