bitsnap-react 1.6.1 → 1.7.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 +135 -0
- package/dist/CartProvider-F2VH7WFO.mjs +2 -0
- package/dist/CartProvider-F2VH7WFO.mjs.map +1 -0
- package/dist/CartProvider-PDEV6GCV.css +2 -0
- package/dist/CartProvider-PDEV6GCV.css.map +1 -0
- package/dist/appearance-core-Dt2grZdl.d.mts +19 -0
- package/dist/appearance-core-Dt2grZdl.d.ts +19 -0
- package/dist/catalog.css +2 -0
- package/dist/catalog.css.map +1 -0
- package/dist/catalog.d.mts +214 -0
- package/dist/catalog.d.ts +214 -0
- package/dist/catalog.js +2 -0
- package/dist/catalog.js.map +1 -0
- package/dist/catalog.mjs +2 -0
- package/dist/catalog.mjs.map +1 -0
- package/dist/chunk-3TENJTY4.mjs +2 -0
- package/dist/chunk-3TENJTY4.mjs.map +1 -0
- package/dist/chunk-4HOZFM6V.mjs +2 -0
- package/dist/chunk-4HOZFM6V.mjs.map +1 -0
- package/dist/chunk-6KQBDN7M.mjs +2 -0
- package/dist/chunk-6KQBDN7M.mjs.map +1 -0
- package/dist/chunk-FTYJTO6O.mjs +2 -0
- package/dist/chunk-FTYJTO6O.mjs.map +1 -0
- package/dist/chunk-RATFYRKZ.mjs +4 -0
- package/dist/chunk-RATFYRKZ.mjs.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +62 -23
- package/dist/index.d.ts +62 -23
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -3
- package/dist/index.mjs.map +1 -1
- package/dist/methods-PFZSMZFU.mjs +2 -0
- package/dist/methods-PFZSMZFU.mjs.map +1 -0
- package/dist/methods-QAZED7TJ.css +2 -0
- package/dist/methods-QAZED7TJ.css.map +1 -0
- package/dist/models.d.mts +54 -0
- package/dist/models.d.ts +54 -0
- package/dist/models.js +1 -1
- package/dist/models.js.map +1 -1
- package/dist/models.mjs +1 -1
- package/dist/models.mjs.map +1 -1
- package/dist/returns.d.mts +602 -52
- package/dist/returns.d.ts +602 -52
- package/dist/returns.js +1 -1
- package/dist/returns.js.map +1 -1
- package/dist/returns.mjs +1 -1
- package/package.json +21 -26
- package/dist/chunk-O4ICBP4G.mjs +0 -2
- package/dist/chunk-O4ICBP4G.mjs.map +0 -1
package/dist/returns.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
import { S as SlotAppearance, A as AppearanceElements } from './appearance-core-Dt2grZdl.mjs';
|
|
2
4
|
import { Timestamp } from '@bufbuild/protobuf/wkt';
|
|
3
5
|
import { Message } from '@bufbuild/protobuf';
|
|
4
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
|
-
import React from 'react';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @generated from enum common.v1.Environment
|
|
@@ -18,6 +18,323 @@ declare enum Environment {
|
|
|
18
18
|
TEST = 1
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Returns appearance API.
|
|
23
|
+
*
|
|
24
|
+
* It mirrors `CheckoutAppearance` (theme, tokens, elements) so a shop can reuse
|
|
25
|
+
* one brand object for both. The resolver is pure: it turns the caller input
|
|
26
|
+
* into a theme name, the tokens in effect, the slot overrides and the inline
|
|
27
|
+
* style for the theme boundary.
|
|
28
|
+
*/
|
|
29
|
+
type ReturnsTheme = "light" | "dark";
|
|
30
|
+
type ReturnsAppearanceTokens = {
|
|
31
|
+
/** Font family of the returns views. The library never loads fonts. */
|
|
32
|
+
fontFamily?: string;
|
|
33
|
+
/** Base font size. */
|
|
34
|
+
fontSize?: string;
|
|
35
|
+
/** Page background. */
|
|
36
|
+
background?: string;
|
|
37
|
+
/** Raised surfaces: cards, skeletons, summaries. */
|
|
38
|
+
surface?: string;
|
|
39
|
+
/** Main text color. */
|
|
40
|
+
foreground?: string;
|
|
41
|
+
/** Secondary text: descriptions, dates, hints. */
|
|
42
|
+
mutedForeground?: string;
|
|
43
|
+
/** Borders of cards, inputs and separators. */
|
|
44
|
+
border?: string;
|
|
45
|
+
/** Primary button background. */
|
|
46
|
+
buttonBackground?: string;
|
|
47
|
+
/** Primary button text. */
|
|
48
|
+
buttonForeground?: string;
|
|
49
|
+
/** Primary button background on hover. */
|
|
50
|
+
buttonHoverBackground?: string;
|
|
51
|
+
/** Hover surface of secondary buttons and selectable cards. */
|
|
52
|
+
hoverSurface?: string;
|
|
53
|
+
/** Focus ring color. Also applied to shared UI primitives through `--ring`. */
|
|
54
|
+
focusRing?: string;
|
|
55
|
+
/** Error color. */
|
|
56
|
+
error?: string;
|
|
57
|
+
/** Success color: result screen, completed and refunded statuses. */
|
|
58
|
+
success?: string;
|
|
59
|
+
/** Warning color: statuses that need attention. */
|
|
60
|
+
warning?: string;
|
|
61
|
+
/** Status badge background. */
|
|
62
|
+
badgeBackground?: string;
|
|
63
|
+
/** Status badge text. */
|
|
64
|
+
badgeForeground?: string;
|
|
65
|
+
/** Background of text inputs and the note field. */
|
|
66
|
+
inputBackground?: string;
|
|
67
|
+
/** Corner radius, applied through `--radius`. */
|
|
68
|
+
radius?: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Stable slot names. They are exposed as `data-bitsnap-returns-slot`
|
|
72
|
+
* attributes so they can also be targeted from plain CSS.
|
|
73
|
+
*/
|
|
74
|
+
declare const RETURNS_SLOT_NAMES: readonly ["root", "header", "title", "description", "backButton", "stepIndicator", "error", "emptyState", "skeleton", "emailForm", "emailInput", "codeForm", "codeInput", "resendButton", "logoutButton", "orderList", "orderCard", "orderReference", "orderDate", "orderTotal", "pagination", "lineList", "line", "lineName", "linePrice", "lineQuantityControl", "quantityButton", "quantityInput", "lineIneligibleReason", "noteInput", "summary", "submitButton", "secondaryButton", "successState", "returnReference", "returnInstructions", "returnList", "returnCard", "statusBadge", "history", "historyEntry"];
|
|
75
|
+
type ReturnsSlotName = (typeof RETURNS_SLOT_NAMES)[number];
|
|
76
|
+
type ReturnsSlotAppearance = SlotAppearance;
|
|
77
|
+
type ReturnsAppearanceElements = AppearanceElements<ReturnsSlotName>;
|
|
78
|
+
type ReturnsAppearance = {
|
|
79
|
+
/** `"light"` or `"dark"`. Omitted means `"light"`. */
|
|
80
|
+
theme?: ReturnsTheme;
|
|
81
|
+
/** Partial overrides applied over the theme preset. */
|
|
82
|
+
tokens?: ReturnsAppearanceTokens;
|
|
83
|
+
/** Per element `className`/`style` overrides. */
|
|
84
|
+
elements?: ReturnsAppearanceElements;
|
|
85
|
+
};
|
|
86
|
+
type ResolvedReturnsAppearance = {
|
|
87
|
+
theme: ReturnsTheme;
|
|
88
|
+
/** Tokens that are in effect (the theme preset plus caller overrides). */
|
|
89
|
+
tokens: ReturnsAppearanceTokens;
|
|
90
|
+
elements: ReturnsAppearanceElements;
|
|
91
|
+
/** Theme marker class for the theme boundary. */
|
|
92
|
+
boundaryClassName: string;
|
|
93
|
+
/** Inline custom properties applied to the returns root. */
|
|
94
|
+
boundaryStyle: CSSProperties;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Every string the returns views render. Pass a partial object through the
|
|
99
|
+
* `texts` prop of `BitsnapReturns`/`ReturnsProvider` to override any of them,
|
|
100
|
+
* whatever the locale. Strings with `{name}` placeholders keep them in
|
|
101
|
+
* overrides; unknown placeholders are left untouched.
|
|
102
|
+
*/
|
|
103
|
+
type ReturnsTexts = {
|
|
104
|
+
/** Label of the back buttons. */
|
|
105
|
+
back: string;
|
|
106
|
+
/** Step indicator, placeholders `{current}` and `{total}`. */
|
|
107
|
+
stepIndicator: string;
|
|
108
|
+
/** Skeleton accessible label. */
|
|
109
|
+
loading: string;
|
|
110
|
+
/** Button that opens the list of previous returns. */
|
|
111
|
+
myReturnsLink: string;
|
|
112
|
+
emailStepTitle: string;
|
|
113
|
+
emailStepDescription: string;
|
|
114
|
+
emailLabel: string;
|
|
115
|
+
emailPlaceholder: string;
|
|
116
|
+
emailSubmit: string;
|
|
117
|
+
codeStepTitle: string;
|
|
118
|
+
/** Placeholder `{email}`. */
|
|
119
|
+
codeStepDescription: string;
|
|
120
|
+
codeLabel: string;
|
|
121
|
+
codeSubmit: string;
|
|
122
|
+
resend: string;
|
|
123
|
+
/** Placeholder `{seconds}`. */
|
|
124
|
+
resendIn: string;
|
|
125
|
+
logout: string;
|
|
126
|
+
ordersTitle: string;
|
|
127
|
+
ordersDescription: string;
|
|
128
|
+
ordersEmpty: string;
|
|
129
|
+
/** Placeholder `{reference}`. */
|
|
130
|
+
orderTitle: string;
|
|
131
|
+
/** Placeholder `{count}`. */
|
|
132
|
+
orderReturnableLines: string;
|
|
133
|
+
orderSelect: string;
|
|
134
|
+
paginationPrevious: string;
|
|
135
|
+
paginationNext: string;
|
|
136
|
+
/** Placeholders `{page}` and `{total}` (number of orders). */
|
|
137
|
+
paginationInfo: string;
|
|
138
|
+
/** Placeholder `{reference}`. */
|
|
139
|
+
orderDetailTitle: string;
|
|
140
|
+
orderDetailDescription: string;
|
|
141
|
+
/** Placeholder `{name}`. */
|
|
142
|
+
quantityLabel: string;
|
|
143
|
+
/** Placeholder `{name}`. */
|
|
144
|
+
quantityDecrease: string;
|
|
145
|
+
/** Placeholder `{name}`. */
|
|
146
|
+
quantityIncrease: string;
|
|
147
|
+
/** Placeholder `{available}`. */
|
|
148
|
+
quantityOfAvailable: string;
|
|
149
|
+
/** Shown for an ineligible line without a reason from the backend. */
|
|
150
|
+
lineIneligibleFallback: string;
|
|
151
|
+
noteLabel: string;
|
|
152
|
+
notePlaceholder: string;
|
|
153
|
+
selectionContinue: string;
|
|
154
|
+
selectionEmpty: string;
|
|
155
|
+
previousReturnsTitle: string;
|
|
156
|
+
confirmationTitle: string;
|
|
157
|
+
confirmationDescription: string;
|
|
158
|
+
confirmationSummary: string;
|
|
159
|
+
/** Placeholder `{quantity}`. */
|
|
160
|
+
confirmationQuantity: string;
|
|
161
|
+
confirmationNote: string;
|
|
162
|
+
confirmationSubmit: string;
|
|
163
|
+
successTitle: string;
|
|
164
|
+
successDescription: string;
|
|
165
|
+
successReference: string;
|
|
166
|
+
successInstructions: string;
|
|
167
|
+
successDone: string;
|
|
168
|
+
myReturnsTitle: string;
|
|
169
|
+
myReturnsDescription: string;
|
|
170
|
+
myReturnsEmpty: string;
|
|
171
|
+
myReturnOpen: string;
|
|
172
|
+
myReturnDetailTitle: string;
|
|
173
|
+
/** Placeholder `{reference}`. */
|
|
174
|
+
myReturnTitle: string;
|
|
175
|
+
myReturnCreatedAt: string;
|
|
176
|
+
myReturnRefund: string;
|
|
177
|
+
myReturnLines: string;
|
|
178
|
+
/** Placeholders `{requested}`, `{approved}`, `{received}`. */
|
|
179
|
+
myReturnLineQuantities: string;
|
|
180
|
+
myReturnNote: string;
|
|
181
|
+
myReturnHistory: string;
|
|
182
|
+
statusSubmitted: string;
|
|
183
|
+
statusApproved: string;
|
|
184
|
+
statusRejected: string;
|
|
185
|
+
statusAwaitingReceipt: string;
|
|
186
|
+
statusReceived: string;
|
|
187
|
+
statusCompleted: string;
|
|
188
|
+
statusCancelled: string;
|
|
189
|
+
statusRefunded: string;
|
|
190
|
+
/** Any status the backend adds later. */
|
|
191
|
+
statusFallback: string;
|
|
192
|
+
refundStatusNotStarted: string;
|
|
193
|
+
refundStatusPending: string;
|
|
194
|
+
refundStatusSucceeded: string;
|
|
195
|
+
refundStatusFailed: string;
|
|
196
|
+
refundStatusFallback: string;
|
|
197
|
+
errorGeneric: string;
|
|
198
|
+
errorInvalidEmail: string;
|
|
199
|
+
errorInvalidCode: string;
|
|
200
|
+
errorSessionExpired: string;
|
|
201
|
+
errorOrderNotFound: string;
|
|
202
|
+
errorReturnNotFound: string;
|
|
203
|
+
errorQuantityUnavailable: string;
|
|
204
|
+
errorItemNotReturnable: string;
|
|
205
|
+
errorReturnsDisabled: string;
|
|
206
|
+
errorRateLimited: string;
|
|
207
|
+
errorIdempotencyConflict: string;
|
|
208
|
+
errorDeliveryFailed: string;
|
|
209
|
+
errorRetry: string;
|
|
210
|
+
};
|
|
211
|
+
type ReturnsTextKey = keyof ReturnsTexts;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Compatibility layer for the `bitsnap-react` 1.6.0 returns widget. Everything
|
|
215
|
+
* here is pure; the components and hooks apply it at their boundary.
|
|
216
|
+
*/
|
|
217
|
+
/** Environment as a string or as the proto enum used by 1.6.0. */
|
|
218
|
+
type ReturnsEnvironmentInput = "production" | "test" | Environment;
|
|
219
|
+
/** Text keys of the 1.6.0 widget. */
|
|
220
|
+
type LegacyReturnsTexts = Partial<{
|
|
221
|
+
title: string;
|
|
222
|
+
email: string;
|
|
223
|
+
sendCode: string;
|
|
224
|
+
code: string;
|
|
225
|
+
verify: string;
|
|
226
|
+
orders: string;
|
|
227
|
+
submit: string;
|
|
228
|
+
note: string;
|
|
229
|
+
loading: string;
|
|
230
|
+
history: string;
|
|
231
|
+
}>;
|
|
232
|
+
/** Our text keys plus the 1.6.0 ones. Our keys win when both are given. */
|
|
233
|
+
type ReturnsTextsInput = Partial<ReturnsTexts> & LegacyReturnsTexts;
|
|
234
|
+
/** 1.6.0 `theme` prop. */
|
|
235
|
+
type LegacyReturnsTheme = {
|
|
236
|
+
brandColor?: string;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Backend environment the returns calls run against. The library has no other
|
|
241
|
+
* environment switch for public API calls, so this defaults to `"production"`.
|
|
242
|
+
*/
|
|
243
|
+
type ReturnsEnvironment = "production" | "test";
|
|
244
|
+
type ReturnsSessionStatus =
|
|
245
|
+
/** Server render and first client render: storage has not been read yet. */
|
|
246
|
+
"hydrating"
|
|
247
|
+
/** A `panelAccessToken` is being exchanged for a returns session. */
|
|
248
|
+
| "exchanging" | "anonymous" | "authenticated";
|
|
249
|
+
/** A pending email verification. */
|
|
250
|
+
type ReturnsChallenge = {
|
|
251
|
+
challengeId: string;
|
|
252
|
+
email: string;
|
|
253
|
+
/** Unix milliseconds when the next code may be requested. */
|
|
254
|
+
resendAvailableAt: number;
|
|
255
|
+
};
|
|
256
|
+
type ReturnsProviderProps = {
|
|
257
|
+
/** Bitsnap project ID. */
|
|
258
|
+
projectID: string;
|
|
259
|
+
/**
|
|
260
|
+
* API host. Defaults to the host set with `setCustomHost`/`setHost`, then to
|
|
261
|
+
* `https://bitsnap.pl`. Each provider keeps its own transport.
|
|
262
|
+
*/
|
|
263
|
+
host?: string;
|
|
264
|
+
/**
|
|
265
|
+
* Backend environment, `"production"` unless set to `"test"`. The proto
|
|
266
|
+
* `Environment` enum is accepted too.
|
|
267
|
+
*/
|
|
268
|
+
environment?: ReturnsEnvironmentInput;
|
|
269
|
+
/** Theme, tokens and per-element overrides. */
|
|
270
|
+
appearance?: ReturnsAppearance;
|
|
271
|
+
/**
|
|
272
|
+
* Text overrides, applied whatever the locale. The keys of `bitsnap-react`
|
|
273
|
+
* 1.6.0 (`title`, `email`, `sendCode`, ...) are accepted too; our own keys
|
|
274
|
+
* win when both are given.
|
|
275
|
+
*/
|
|
276
|
+
texts?: ReturnsTextsInput;
|
|
277
|
+
/** `bitsnap-react` 1.6.0 brand color. Explicit `appearance.tokens` win. */
|
|
278
|
+
theme?: LegacyReturnsTheme;
|
|
279
|
+
/** Locale of texts, dates and money. Defaults to the library locale. */
|
|
280
|
+
locale?: string;
|
|
281
|
+
/**
|
|
282
|
+
* Customer panel access token. When set, it is exchanged for a returns
|
|
283
|
+
* session on mount, so the customer needs no second verification code.
|
|
284
|
+
* Changing or removing it drops the session.
|
|
285
|
+
*/
|
|
286
|
+
panelAccessToken?: string;
|
|
287
|
+
/** Class of the themed root element. */
|
|
288
|
+
className?: string;
|
|
289
|
+
children?: ReactNode;
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Holds everything the returns views share: the per-instance transport, the
|
|
293
|
+
* query client (when the app has none), appearance, texts and the returns
|
|
294
|
+
* session. It renders the themed root element, so step components composed
|
|
295
|
+
* under it are themed without extra markup.
|
|
296
|
+
*
|
|
297
|
+
* ```tsx
|
|
298
|
+
* <ReturnsProvider projectID="…" appearance={brand}>
|
|
299
|
+
* <ReturnsOrderList onSelectOrder={setOrderId} />
|
|
300
|
+
* </ReturnsProvider>
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
declare function ReturnsProvider({ projectID, host, environment, appearance, texts, theme, locale, panelAccessToken, className, children, }: ReturnsProviderProps): react_jsx_runtime.JSX.Element;
|
|
304
|
+
/** Name of {@link ReturnsProvider} in `bitsnap-react` 1.6.0. */
|
|
305
|
+
declare const BitsnapReturnsProvider: typeof ReturnsProvider;
|
|
306
|
+
type BitsnapReturnsProviderProps = ReturnsProviderProps;
|
|
307
|
+
|
|
308
|
+
type BitsnapReturnsProps = Omit<ReturnsProviderProps, "children">;
|
|
309
|
+
/**
|
|
310
|
+
* Customer return flow: email, code, orders, line selection, confirmation and
|
|
311
|
+
* result, plus the list of earlier returns. It is `ReturnsProvider` with the
|
|
312
|
+
* default step router; compose your own page from the step components to
|
|
313
|
+
* change the layout.
|
|
314
|
+
*
|
|
315
|
+
* ```tsx
|
|
316
|
+
* <BitsnapReturns projectID="…" appearance={brand} texts={{ emailStepTitle: "Return a product" }} />
|
|
317
|
+
* ```
|
|
318
|
+
*/
|
|
319
|
+
declare function BitsnapReturns(props: BitsnapReturnsProps): react_jsx_runtime.JSX.Element;
|
|
320
|
+
|
|
321
|
+
type ReturnsEmailStepProps = {
|
|
322
|
+
/** Called after the verification code was sent, with the trimmed email. */
|
|
323
|
+
onSubmitted?: (email: string) => void;
|
|
324
|
+
className?: string;
|
|
325
|
+
};
|
|
326
|
+
/** First step: asks for the email the order was placed with. */
|
|
327
|
+
declare function ReturnsEmailStep({ onSubmitted, className, }: ReturnsEmailStepProps): react_jsx_runtime.JSX.Element;
|
|
328
|
+
type ReturnsCodeStepProps = {
|
|
329
|
+
/** Called once the code was accepted and the session exists. */
|
|
330
|
+
onVerified?: () => void;
|
|
331
|
+
/** Shows a back button, for example to change the email. */
|
|
332
|
+
onBack?: () => void;
|
|
333
|
+
className?: string;
|
|
334
|
+
};
|
|
335
|
+
/** Second step: asks for the code that was emailed to the customer. */
|
|
336
|
+
declare function ReturnsCodeStep({ onVerified, onBack, className, }: ReturnsCodeStepProps): react_jsx_runtime.JSX.Element;
|
|
337
|
+
|
|
21
338
|
/**
|
|
22
339
|
* @generated from message public.v1.StartReturnSessionResponse
|
|
23
340
|
*/
|
|
@@ -46,7 +363,7 @@ type VerifyReturnSessionResponse = Message<"public.v1.VerifyReturnSessionRespons
|
|
|
46
363
|
/**
|
|
47
364
|
* @generated from field: google.protobuf.Timestamp expires_at = 2;
|
|
48
365
|
*/
|
|
49
|
-
expiresAt?: Timestamp;
|
|
366
|
+
expiresAt?: Timestamp | undefined;
|
|
50
367
|
};
|
|
51
368
|
/**
|
|
52
369
|
* @generated from message public.v1.ReturnOrderSummary
|
|
@@ -67,7 +384,7 @@ type ReturnOrderSummary = Message<"public.v1.ReturnOrderSummary"> & {
|
|
|
67
384
|
/**
|
|
68
385
|
* @generated from field: google.protobuf.Timestamp purchased_at = 4;
|
|
69
386
|
*/
|
|
70
|
-
purchasedAt?: Timestamp;
|
|
387
|
+
purchasedAt?: Timestamp | undefined;
|
|
71
388
|
/**
|
|
72
389
|
* @generated from field: int64 total_minor = 5;
|
|
73
390
|
*/
|
|
@@ -194,7 +511,7 @@ type ReturnOrderDetail = Message<"public.v1.ReturnOrderDetail"> & {
|
|
|
194
511
|
/**
|
|
195
512
|
* @generated from field: google.protobuf.Timestamp purchased_at = 4;
|
|
196
513
|
*/
|
|
197
|
-
purchasedAt?: Timestamp;
|
|
514
|
+
purchasedAt?: Timestamp | undefined;
|
|
198
515
|
/**
|
|
199
516
|
* @generated from field: int64 total_minor = 5;
|
|
200
517
|
*/
|
|
@@ -227,7 +544,7 @@ type ReturnHistoryEntry = Message<"public.v1.ReturnHistoryEntry"> & {
|
|
|
227
544
|
/**
|
|
228
545
|
* @generated from field: google.protobuf.Timestamp created_at = 4;
|
|
229
546
|
*/
|
|
230
|
-
createdAt?: Timestamp;
|
|
547
|
+
createdAt?: Timestamp | undefined;
|
|
231
548
|
};
|
|
232
549
|
/**
|
|
233
550
|
* @generated from message public.v1.ReturnRequestLineView
|
|
@@ -305,7 +622,7 @@ type ReturnRequestView = Message<"public.v1.ReturnRequestView"> & {
|
|
|
305
622
|
/**
|
|
306
623
|
* @generated from field: google.protobuf.Timestamp created_at = 10;
|
|
307
624
|
*/
|
|
308
|
-
createdAt?: Timestamp;
|
|
625
|
+
createdAt?: Timestamp | undefined;
|
|
309
626
|
/**
|
|
310
627
|
* @generated from field: repeated public.v1.ReturnRequestLineView lines = 11;
|
|
311
628
|
*/
|
|
@@ -326,7 +643,7 @@ type GetReturnableOrderResponse = Message<"public.v1.GetReturnableOrderResponse"
|
|
|
326
643
|
/**
|
|
327
644
|
* @generated from field: public.v1.ReturnOrderDetail order = 1;
|
|
328
645
|
*/
|
|
329
|
-
order?: ReturnOrderDetail;
|
|
646
|
+
order?: ReturnOrderDetail | undefined;
|
|
330
647
|
/**
|
|
331
648
|
* @generated from field: repeated public.v1.ReturnHistoryEntry return_history = 2;
|
|
332
649
|
*/
|
|
@@ -339,7 +656,7 @@ type CreateReturnRequestResponse = Message<"public.v1.CreateReturnRequestRespons
|
|
|
339
656
|
/**
|
|
340
657
|
* @generated from field: public.v1.ReturnRequestView request = 1;
|
|
341
658
|
*/
|
|
342
|
-
request?: ReturnRequestView;
|
|
659
|
+
request?: ReturnRequestView | undefined;
|
|
343
660
|
};
|
|
344
661
|
/**
|
|
345
662
|
* @generated from message public.v1.ListMyReturnsResponse
|
|
@@ -359,59 +676,292 @@ type ListMyReturnsResponse = Message<"public.v1.ListMyReturnsResponse"> & {
|
|
|
359
676
|
total: number;
|
|
360
677
|
};
|
|
361
678
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
679
|
+
/** One line chosen for return. */
|
|
680
|
+
type SelectedReturnLine = {
|
|
681
|
+
lineId: string;
|
|
682
|
+
quantity: number;
|
|
683
|
+
};
|
|
684
|
+
|
|
685
|
+
type ReturnsOrderListProps = {
|
|
686
|
+
/** Called with the canonical order ID of the chosen order. */
|
|
687
|
+
onSelectOrder?: (orderId: string) => void;
|
|
688
|
+
/** Shows a "my returns" button that calls this. */
|
|
689
|
+
onOpenMyReturns?: () => void;
|
|
690
|
+
/** Shows the sign out button. Defaults to `true`. */
|
|
691
|
+
showLogout?: boolean;
|
|
692
|
+
/** Orders per page. Defaults to 10. */
|
|
693
|
+
pageSize?: number;
|
|
694
|
+
className?: string;
|
|
695
|
+
};
|
|
696
|
+
/** Orders of the customer that still have products to return. */
|
|
697
|
+
declare function ReturnsOrderList({ onSelectOrder, onOpenMyReturns, showLogout, pageSize, className, }: ReturnsOrderListProps): react_jsx_runtime.JSX.Element;
|
|
698
|
+
type ReturnsOrderDetailProps = {
|
|
699
|
+
/** Canonical order ID, as given to `onSelectOrder`. */
|
|
700
|
+
orderId: string;
|
|
701
|
+
/** Called with the selected lines and the note when the form is valid. */
|
|
702
|
+
onContinue?: (selection: {
|
|
703
|
+
items: SelectedReturnLine[];
|
|
704
|
+
note: string;
|
|
705
|
+
}) => void;
|
|
706
|
+
onBack?: () => void;
|
|
707
|
+
/** Selection to start with, for example when coming back from the confirmation. */
|
|
708
|
+
initialItems?: SelectedReturnLine[];
|
|
709
|
+
initialNote?: string;
|
|
710
|
+
className?: string;
|
|
711
|
+
};
|
|
712
|
+
/** Line and quantity selection of one order. */
|
|
713
|
+
declare function ReturnsOrderDetail({ orderId, onContinue, onBack, initialItems, initialNote, className, }: ReturnsOrderDetailProps): react_jsx_runtime.JSX.Element;
|
|
714
|
+
type ReturnsConfirmationProps = {
|
|
715
|
+
/** Canonical order ID. */
|
|
716
|
+
orderId: string;
|
|
717
|
+
/** Lines chosen in the order detail step. */
|
|
718
|
+
items: SelectedReturnLine[];
|
|
719
|
+
note?: string;
|
|
720
|
+
/** Called with the new return's ID and the created request. */
|
|
721
|
+
onSubmitted?: (returnId: string, request: ReturnRequestView) => void;
|
|
722
|
+
onBack?: () => void;
|
|
723
|
+
className?: string;
|
|
724
|
+
};
|
|
725
|
+
/** Review of the selected lines and the submit action. */
|
|
726
|
+
declare function ReturnsConfirmation({ orderId, items, note, onSubmitted, onBack, className, }: ReturnsConfirmationProps): react_jsx_runtime.JSX.Element;
|
|
727
|
+
type ReturnsResultProps = {
|
|
728
|
+
/** ID of the created return, as given to `onSubmitted`. */
|
|
729
|
+
returnId: string;
|
|
730
|
+
/** Called by the primary button, normally to go back to the orders. */
|
|
731
|
+
onContinue?: () => void;
|
|
732
|
+
/** Shows a "my returns" button that calls this. */
|
|
733
|
+
onOpenMyReturns?: () => void;
|
|
734
|
+
className?: string;
|
|
735
|
+
};
|
|
736
|
+
/** Success screen with the reference and the return instructions. */
|
|
737
|
+
declare function ReturnsResult({ returnId, onContinue, onOpenMyReturns, className, }: ReturnsResultProps): react_jsx_runtime.JSX.Element;
|
|
738
|
+
|
|
739
|
+
type ReturnsMyReturnsListProps = {
|
|
740
|
+
/** Called with the ID of the chosen return. */
|
|
741
|
+
onSelectReturn?: (returnId: string) => void;
|
|
742
|
+
onBack?: () => void;
|
|
743
|
+
/** Returns per page. Defaults to 10. */
|
|
744
|
+
pageSize?: number;
|
|
745
|
+
className?: string;
|
|
746
|
+
};
|
|
747
|
+
/** Return requests the customer has submitted, with their status. */
|
|
748
|
+
declare function ReturnsMyReturnsList({ onSelectReturn, onBack, pageSize, className, }: ReturnsMyReturnsListProps): react_jsx_runtime.JSX.Element;
|
|
749
|
+
type ReturnsMyReturnDetailProps = {
|
|
750
|
+
/** ID of the return to show. */
|
|
751
|
+
returnId: string;
|
|
752
|
+
onBack?: () => void;
|
|
753
|
+
className?: string;
|
|
754
|
+
};
|
|
755
|
+
/** Status, lines, refund and history of one return request. */
|
|
756
|
+
declare function ReturnsMyReturnDetail({ returnId, onBack, className, }: ReturnsMyReturnDetailProps): react_jsx_runtime.JSX.Element;
|
|
757
|
+
|
|
758
|
+
/** React Query style status shared by the query and mutation results. */
|
|
759
|
+
type QueryStatus = "pending" | "error" | "success";
|
|
760
|
+
type MutationStatus = "idle" | QueryStatus;
|
|
761
|
+
type UseReturnSessionResult = {
|
|
762
|
+
status: ReturnsSessionStatus;
|
|
377
763
|
isAuthenticated: boolean;
|
|
764
|
+
/** Pending email verification, set after `start` succeeded. */
|
|
765
|
+
challenge: ReturnsChallenge | undefined;
|
|
766
|
+
isStarting: boolean;
|
|
767
|
+
isVerifying: boolean;
|
|
768
|
+
/** Last failure of `start` or `verify`, or of the panel token exchange. */
|
|
769
|
+
error: Error | null;
|
|
770
|
+
errorKey: ReturnsTextKey | undefined;
|
|
771
|
+
/** Same as `isStarting` (`bitsnap-react` 1.6.0 name). */
|
|
378
772
|
starting: boolean;
|
|
773
|
+
/** Same as `isVerifying` (`bitsnap-react` 1.6.0 name). */
|
|
379
774
|
verifying: boolean;
|
|
775
|
+
/**
|
|
776
|
+
* `bitsnap-react` 1.6.0 API: sends a code and resolves with the response
|
|
777
|
+
* (including `challengeId`). Rejects on failure. Also stores the challenge
|
|
778
|
+
* like `start`.
|
|
779
|
+
*/
|
|
780
|
+
startSession: (email: string) => Promise<StartReturnSessionResponse>;
|
|
781
|
+
/**
|
|
782
|
+
* `bitsnap-react` 1.6.0 API: verifies a code, stores the session like
|
|
783
|
+
* `verify` and resolves with the response. Rejects on failure.
|
|
784
|
+
*/
|
|
785
|
+
verifySession: (input: {
|
|
786
|
+
challengeId: string;
|
|
787
|
+
code: string;
|
|
788
|
+
}) => Promise<VerifyReturnSessionResponse>;
|
|
789
|
+
/** Sends a code to `email`. Resolves to `true` when the code was sent. */
|
|
790
|
+
start: (email: string) => Promise<boolean>;
|
|
791
|
+
/** Verifies the code of the pending challenge. Resolves to `true` on success. */
|
|
792
|
+
verify: (code: string) => Promise<boolean>;
|
|
793
|
+
/** Sends a new code to the email of the pending challenge. */
|
|
794
|
+
resend: () => Promise<boolean>;
|
|
795
|
+
/** Drops the session and the pending challenge. */
|
|
796
|
+
logout: () => void;
|
|
797
|
+
};
|
|
798
|
+
/** Email verification and the returns session of the nearest provider. */
|
|
799
|
+
declare function useReturnSession(): UseReturnSessionResult;
|
|
800
|
+
type PagedOptions = {
|
|
801
|
+
/** Items per page. Defaults to 10. */
|
|
802
|
+
pageSize?: number;
|
|
803
|
+
};
|
|
804
|
+
type UseReturnOrdersResult = {
|
|
805
|
+
orders: ReturnOrderSummary[];
|
|
806
|
+
/** Total number of returnable orders. */
|
|
807
|
+
total: number;
|
|
808
|
+
/** Response for the requested page (React Query style). */
|
|
809
|
+
data: ListReturnOrdersResponse | undefined;
|
|
810
|
+
isLoading: boolean;
|
|
811
|
+
isFetching: boolean;
|
|
380
812
|
error: Error | null;
|
|
813
|
+
errorKey: ReturnsTextKey | undefined;
|
|
814
|
+
status: QueryStatus;
|
|
815
|
+
isError: boolean;
|
|
816
|
+
isSuccess: boolean;
|
|
817
|
+
/** 1-based number of the current page. */
|
|
818
|
+
page: number;
|
|
819
|
+
hasNext: boolean;
|
|
820
|
+
hasPrevious: boolean;
|
|
821
|
+
next: () => void;
|
|
822
|
+
previous: () => void;
|
|
823
|
+
refetch: () => Promise<unknown>;
|
|
381
824
|
};
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
825
|
+
/**
|
|
826
|
+
* Orders of the signed-in customer that have lines to return, page by page.
|
|
827
|
+
* Call it with `{ pageSize }` (pages are walked with `next`/`previous`) or, as
|
|
828
|
+
* in `bitsnap-react` 1.6.0, with `(pageSize, pageToken)`; then the explicit
|
|
829
|
+
* token is requested and `data.nextPageToken` drives paging.
|
|
830
|
+
*/
|
|
831
|
+
declare function useReturnOrders(options?: PagedOptions): UseReturnOrdersResult;
|
|
832
|
+
declare function useReturnOrders(pageSize?: number, pageToken?: string): UseReturnOrdersResult;
|
|
833
|
+
type UseReturnableOrderResult = {
|
|
834
|
+
order: ReturnOrderDetail | undefined;
|
|
835
|
+
/** Earlier return requests for this order. */
|
|
836
|
+
returnHistory: ReturnHistoryEntry[];
|
|
837
|
+
/** Response (React Query style): `data.order` is the order. */
|
|
838
|
+
data: GetReturnableOrderResponse | undefined;
|
|
839
|
+
isLoading: boolean;
|
|
840
|
+
error: Error | null;
|
|
841
|
+
errorKey: ReturnsTextKey | undefined;
|
|
842
|
+
status: QueryStatus;
|
|
843
|
+
isError: boolean;
|
|
844
|
+
isSuccess: boolean;
|
|
845
|
+
refetch: () => Promise<unknown>;
|
|
846
|
+
};
|
|
847
|
+
/**
|
|
848
|
+
* One order with the eligibility of each line. Without an `orderId` the query
|
|
849
|
+
* is disabled.
|
|
850
|
+
*/
|
|
851
|
+
declare function useReturnableOrder(orderId?: string): UseReturnableOrderResult;
|
|
852
|
+
type CreateReturnInput = {
|
|
853
|
+
orderId: string;
|
|
854
|
+
items: {
|
|
855
|
+
lineId: string;
|
|
856
|
+
quantity: number;
|
|
857
|
+
}[];
|
|
858
|
+
note?: string;
|
|
859
|
+
};
|
|
860
|
+
/** Input of the `bitsnap-react` 1.6.0 `mutateAsync`/`mutate`. */
|
|
861
|
+
type LegacyCreateReturnInput = {
|
|
385
862
|
canonicalOrderID: string;
|
|
386
863
|
items: {
|
|
387
864
|
lineId: string;
|
|
388
865
|
quantity: number;
|
|
389
866
|
}[];
|
|
390
867
|
note?: string;
|
|
868
|
+
/** Used as given. A fresh key is generated per call when omitted. */
|
|
391
869
|
idempotencyKey?: string;
|
|
392
|
-
}, unknown>;
|
|
393
|
-
declare function useMyReturns(pageSize?: number, pageToken?: string): _tanstack_react_query.UseQueryResult<void | ListMyReturnsResponse, Error>;
|
|
394
|
-
type BitsnapReturnsProps = {
|
|
395
|
-
projectID: string;
|
|
396
|
-
host?: string;
|
|
397
|
-
environment?: Environment;
|
|
398
|
-
texts?: Partial<{
|
|
399
|
-
title: string;
|
|
400
|
-
email: string;
|
|
401
|
-
sendCode: string;
|
|
402
|
-
code: string;
|
|
403
|
-
verify: string;
|
|
404
|
-
orders: string;
|
|
405
|
-
submit: string;
|
|
406
|
-
note: string;
|
|
407
|
-
loading: string;
|
|
408
|
-
history: string;
|
|
409
|
-
}>;
|
|
410
|
-
theme?: {
|
|
411
|
-
brandColor?: string;
|
|
412
|
-
};
|
|
413
|
-
className?: string;
|
|
414
870
|
};
|
|
415
|
-
|
|
871
|
+
type UseCreateReturnResult = {
|
|
872
|
+
/**
|
|
873
|
+
* Submits the return request. Resolves to the created request, or
|
|
874
|
+
* `undefined` when it failed (see `error`). Retrying reuses the same
|
|
875
|
+
* idempotency key, so a retry can never create a second request.
|
|
876
|
+
*/
|
|
877
|
+
submit: (input: CreateReturnInput) => Promise<ReturnRequestView | undefined>;
|
|
878
|
+
isPending: boolean;
|
|
879
|
+
error: Error | null;
|
|
880
|
+
errorKey: ReturnsTextKey | undefined;
|
|
881
|
+
/**
|
|
882
|
+
* `bitsnap-react` 1.6.0 API (React Query mutation semantics): resolves with
|
|
883
|
+
* the response (`result.request`) and rejects on failure.
|
|
884
|
+
*/
|
|
885
|
+
mutateAsync: (input: LegacyCreateReturnInput) => Promise<CreateReturnRequestResponse>;
|
|
886
|
+
/** Fire and forget version of `mutateAsync`; failures land in `error`. */
|
|
887
|
+
mutate: (input: LegacyCreateReturnInput, options?: {
|
|
888
|
+
onSuccess?: (response: CreateReturnRequestResponse) => void;
|
|
889
|
+
onError?: (error: Error) => void;
|
|
890
|
+
}) => void;
|
|
891
|
+
/** Response of the last successful request. */
|
|
892
|
+
data: CreateReturnRequestResponse | undefined;
|
|
893
|
+
reset: () => void;
|
|
894
|
+
status: MutationStatus;
|
|
895
|
+
isError: boolean;
|
|
896
|
+
isSuccess: boolean;
|
|
897
|
+
};
|
|
898
|
+
/**
|
|
899
|
+
* Creates a return request. With `submit` the idempotency key is generated
|
|
900
|
+
* once per hook instance, which is once per confirmation screen, and reused on
|
|
901
|
+
* retry.
|
|
902
|
+
*/
|
|
903
|
+
declare function useCreateReturn(): UseCreateReturnResult;
|
|
904
|
+
type UseMyReturnsResult = {
|
|
905
|
+
returns: ReturnRequestView[];
|
|
906
|
+
total: number;
|
|
907
|
+
/** Response for the requested page (React Query style). */
|
|
908
|
+
data: ListMyReturnsResponse | undefined;
|
|
909
|
+
isLoading: boolean;
|
|
910
|
+
isFetching: boolean;
|
|
911
|
+
error: Error | null;
|
|
912
|
+
errorKey: ReturnsTextKey | undefined;
|
|
913
|
+
status: QueryStatus;
|
|
914
|
+
isError: boolean;
|
|
915
|
+
isSuccess: boolean;
|
|
916
|
+
page: number;
|
|
917
|
+
hasNext: boolean;
|
|
918
|
+
hasPrevious: boolean;
|
|
919
|
+
next: () => void;
|
|
920
|
+
previous: () => void;
|
|
921
|
+
refetch: () => Promise<unknown>;
|
|
922
|
+
};
|
|
923
|
+
/**
|
|
924
|
+
* Return requests of the signed-in customer, page by page. Accepts
|
|
925
|
+
* `{ pageSize }` or the `bitsnap-react` 1.6.0 `(pageSize, pageToken)` form,
|
|
926
|
+
* like `useReturnOrders`.
|
|
927
|
+
*/
|
|
928
|
+
declare function useMyReturns(options?: PagedOptions): UseMyReturnsResult;
|
|
929
|
+
declare function useMyReturns(pageSize?: number, pageToken?: string): UseMyReturnsResult;
|
|
930
|
+
type UseMyReturnResult = {
|
|
931
|
+
request: ReturnRequestView | undefined;
|
|
932
|
+
isLoading: boolean;
|
|
933
|
+
error: unknown;
|
|
934
|
+
errorKey: ReturnsTextKey | undefined;
|
|
935
|
+
refetch: () => void;
|
|
936
|
+
};
|
|
937
|
+
/** One return request of the signed-in customer. */
|
|
938
|
+
declare function useMyReturn(returnId: string): UseMyReturnResult;
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
* Returns scoped appearance provider. It only wraps the returns views, so the
|
|
942
|
+
* configuration never leaks into checkout, the panel or the host page.
|
|
943
|
+
*/
|
|
944
|
+
declare function ReturnsAppearanceProvider({ appearance, children, }: {
|
|
945
|
+
appearance?: ReturnsAppearance;
|
|
946
|
+
children: ReactNode;
|
|
947
|
+
}): react_jsx_runtime.JSX.Element;
|
|
948
|
+
declare function useReturnsAppearance(): ResolvedReturnsAppearance;
|
|
949
|
+
/**
|
|
950
|
+
* Returns the caller overrides for a slot, meant to be merged with the
|
|
951
|
+
* built-in presentation:
|
|
952
|
+
*
|
|
953
|
+
* ```tsx
|
|
954
|
+
* const slot = useReturnsSlot("title");
|
|
955
|
+
*
|
|
956
|
+
* return <h2 className={cn("text-xl font-semibold", slot.className)} style={slot.style} />;
|
|
957
|
+
* ```
|
|
958
|
+
*/
|
|
959
|
+
declare function useReturnsSlot(slot: ReturnsSlotName): ReturnsSlotAppearance;
|
|
960
|
+
|
|
961
|
+
/**
|
|
962
|
+
* Returns a lookup for the returns strings: the caller override when provided,
|
|
963
|
+
* otherwise the default for the locale. Optional `values` fill `{placeholders}`.
|
|
964
|
+
*/
|
|
965
|
+
declare function useReturnsText(): (key: ReturnsTextKey, values?: Record<string, string | number>) => string;
|
|
416
966
|
|
|
417
|
-
export { BitsnapReturns, type BitsnapReturnsProps, BitsnapReturnsProvider, type BitsnapReturnsProviderProps, Environment, useCreateReturn, useMyReturns, useReturnOrders, useReturnSession, useReturnableOrder };
|
|
967
|
+
export { BitsnapReturns, type BitsnapReturnsProps, BitsnapReturnsProvider, type BitsnapReturnsProviderProps, type CreateReturnInput, Environment, type LegacyCreateReturnInput, type LegacyReturnsTexts, type LegacyReturnsTheme, RETURNS_SLOT_NAMES, type ReturnsAppearance, type ReturnsAppearanceElements, ReturnsAppearanceProvider, type ReturnsAppearanceTokens, type ReturnsChallenge, ReturnsCodeStep, type ReturnsCodeStepProps, ReturnsConfirmation, type ReturnsConfirmationProps, ReturnsEmailStep, type ReturnsEmailStepProps, type ReturnsEnvironment, type ReturnsEnvironmentInput, ReturnsMyReturnDetail, type ReturnsMyReturnDetailProps, ReturnsMyReturnsList, type ReturnsMyReturnsListProps, ReturnsOrderDetail, type ReturnsOrderDetailProps, ReturnsOrderList, type ReturnsOrderListProps, ReturnsProvider, type ReturnsProviderProps, ReturnsResult, type ReturnsResultProps, type ReturnsSessionStatus, type ReturnsSlotAppearance, type ReturnsSlotName, type ReturnsTextKey, type ReturnsTexts, type ReturnsTextsInput, type ReturnsTheme, type SelectedReturnLine, type UseCreateReturnResult, type UseMyReturnResult, type UseMyReturnsResult, type UseReturnOrdersResult, type UseReturnSessionResult, type UseReturnableOrderResult, useCreateReturn, useMyReturn, useMyReturns, useReturnOrders, useReturnSession, useReturnableOrder, useReturnsAppearance, useReturnsSlot, useReturnsText };
|