@revova/hydrogen 1.0.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.
- package/README.md +384 -0
- package/dist/index.cjs +1587 -0
- package/dist/index.d.cts +398 -0
- package/dist/index.d.ts +398 -0
- package/dist/index.js +1533 -0
- package/package.json +51 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
type ReviewWidgetProps = {
|
|
4
|
+
proxyUrl: string;
|
|
5
|
+
productId: string;
|
|
6
|
+
locale?: string;
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
showForm?: boolean;
|
|
9
|
+
starColor?: string;
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
declare function ReviewWidget({ proxyUrl, productId, locale, pageSize, showForm, starColor, className, }: ReviewWidgetProps): React.JSX.Element | null;
|
|
13
|
+
|
|
14
|
+
type ReviewMedia = {
|
|
15
|
+
url: string;
|
|
16
|
+
mimeType: string;
|
|
17
|
+
};
|
|
18
|
+
type ReviewFieldAnswer = {
|
|
19
|
+
fieldId: string;
|
|
20
|
+
value: unknown;
|
|
21
|
+
field: {
|
|
22
|
+
id: string;
|
|
23
|
+
label: string;
|
|
24
|
+
type: string;
|
|
25
|
+
config: unknown;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
type AdminReply = {
|
|
29
|
+
body: string;
|
|
30
|
+
createdAt: string;
|
|
31
|
+
};
|
|
32
|
+
type Review = {
|
|
33
|
+
id: string;
|
|
34
|
+
rating: number;
|
|
35
|
+
title: string | null;
|
|
36
|
+
body: string | null;
|
|
37
|
+
email: string | null;
|
|
38
|
+
isAnonymous: boolean;
|
|
39
|
+
verifiedBuyer: boolean;
|
|
40
|
+
isPinned: boolean;
|
|
41
|
+
helpfulCount: number;
|
|
42
|
+
sentiment: 'POSITIVE' | 'NEUTRAL' | 'NEGATIVE' | null;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
variantTitle: string | null;
|
|
45
|
+
media: ReviewMedia[];
|
|
46
|
+
fieldAnswers: ReviewFieldAnswer[];
|
|
47
|
+
reply: AdminReply | null;
|
|
48
|
+
translatedTitle?: string | null;
|
|
49
|
+
translatedBody?: string | null;
|
|
50
|
+
};
|
|
51
|
+
type FormField = {
|
|
52
|
+
id: string;
|
|
53
|
+
type: string;
|
|
54
|
+
label: string | null;
|
|
55
|
+
position: number;
|
|
56
|
+
required: boolean;
|
|
57
|
+
config: unknown;
|
|
58
|
+
};
|
|
59
|
+
type ResolvedForm = {
|
|
60
|
+
id: string;
|
|
61
|
+
fields: FormField[];
|
|
62
|
+
};
|
|
63
|
+
type ReviewsPagination = {
|
|
64
|
+
page: number;
|
|
65
|
+
limit: number;
|
|
66
|
+
total: number;
|
|
67
|
+
totalPages: number;
|
|
68
|
+
};
|
|
69
|
+
type ReviewsResponse = {
|
|
70
|
+
reviews: Review[];
|
|
71
|
+
pagination: ReviewsPagination;
|
|
72
|
+
form: ResolvedForm | null;
|
|
73
|
+
};
|
|
74
|
+
type SubmitReviewPayload = {
|
|
75
|
+
productId: string;
|
|
76
|
+
variantId?: string;
|
|
77
|
+
variantTitle?: string;
|
|
78
|
+
email: string;
|
|
79
|
+
isAnonymous?: boolean;
|
|
80
|
+
formId: string;
|
|
81
|
+
fieldAnswers: {
|
|
82
|
+
fieldId: string;
|
|
83
|
+
value: unknown;
|
|
84
|
+
}[];
|
|
85
|
+
mediaIds?: string[];
|
|
86
|
+
};
|
|
87
|
+
type SubmitReviewResponse = {
|
|
88
|
+
reviewId: string;
|
|
89
|
+
status: 'PENDING' | 'APPROVED';
|
|
90
|
+
requiresEmailVerification: boolean;
|
|
91
|
+
message?: string;
|
|
92
|
+
};
|
|
93
|
+
type AttributeRating = {
|
|
94
|
+
label: string;
|
|
95
|
+
value: number;
|
|
96
|
+
};
|
|
97
|
+
type GlobalReview = {
|
|
98
|
+
id: string;
|
|
99
|
+
rating: number;
|
|
100
|
+
title: string | null;
|
|
101
|
+
body: string | null;
|
|
102
|
+
authorName: string;
|
|
103
|
+
verifiedBuyer: boolean;
|
|
104
|
+
productId: string;
|
|
105
|
+
createdAt: string;
|
|
106
|
+
image: string | null;
|
|
107
|
+
attributeRatings: AttributeRating[];
|
|
108
|
+
};
|
|
109
|
+
type ShopStats = {
|
|
110
|
+
totalReviews: number;
|
|
111
|
+
averageRating: string | null;
|
|
112
|
+
};
|
|
113
|
+
type WidgetTheme = {
|
|
114
|
+
primaryColor: string;
|
|
115
|
+
starColor: string;
|
|
116
|
+
textColor: string;
|
|
117
|
+
subtextColor: string;
|
|
118
|
+
backgroundColor: string;
|
|
119
|
+
borderRadius: number;
|
|
120
|
+
fontFamily: string;
|
|
121
|
+
};
|
|
122
|
+
type WidgetConfig = {
|
|
123
|
+
popup: {
|
|
124
|
+
enabled: boolean;
|
|
125
|
+
intervalSeconds: number;
|
|
126
|
+
displaySeconds: number;
|
|
127
|
+
position: string;
|
|
128
|
+
};
|
|
129
|
+
floatingTab: {
|
|
130
|
+
enabled: boolean;
|
|
131
|
+
position: string;
|
|
132
|
+
label: string;
|
|
133
|
+
color: string;
|
|
134
|
+
};
|
|
135
|
+
trustBadge: {
|
|
136
|
+
enabled: boolean;
|
|
137
|
+
style: string;
|
|
138
|
+
};
|
|
139
|
+
ticker: {
|
|
140
|
+
enabled: boolean;
|
|
141
|
+
speedSeconds: number;
|
|
142
|
+
maxItems: number;
|
|
143
|
+
};
|
|
144
|
+
floatingButton: {
|
|
145
|
+
enabled: boolean;
|
|
146
|
+
text: string;
|
|
147
|
+
color: string;
|
|
148
|
+
position: string;
|
|
149
|
+
};
|
|
150
|
+
theme: WidgetTheme;
|
|
151
|
+
};
|
|
152
|
+
type WidgetGlobalsResponse = {
|
|
153
|
+
config: WidgetConfig | null;
|
|
154
|
+
stats: ShopStats | null;
|
|
155
|
+
reviews: GlobalReview[];
|
|
156
|
+
};
|
|
157
|
+
type HelpfulVotePayload = {
|
|
158
|
+
reviewId: string;
|
|
159
|
+
vote: 'helpful' | 'not_helpful';
|
|
160
|
+
};
|
|
161
|
+
type HelpfulVoteResponse = {
|
|
162
|
+
helpfulCount: number;
|
|
163
|
+
};
|
|
164
|
+
type SortKey = 'recent' | 'helpful' | 'rating_high' | 'rating_low';
|
|
165
|
+
type UseReviewsOptions = {
|
|
166
|
+
proxyUrl: string;
|
|
167
|
+
productId: string;
|
|
168
|
+
page?: number;
|
|
169
|
+
limit?: number;
|
|
170
|
+
sort?: SortKey;
|
|
171
|
+
locale?: string;
|
|
172
|
+
};
|
|
173
|
+
type UseWidgetGlobalsOptions = {
|
|
174
|
+
proxyUrl: string;
|
|
175
|
+
limit?: number;
|
|
176
|
+
};
|
|
177
|
+
type QnAAnswer = {
|
|
178
|
+
id: string;
|
|
179
|
+
body: string;
|
|
180
|
+
displayName: string;
|
|
181
|
+
isAdminReply: boolean;
|
|
182
|
+
helpfulCount: number;
|
|
183
|
+
createdAt: string;
|
|
184
|
+
};
|
|
185
|
+
type ProductQuestion = {
|
|
186
|
+
id: string;
|
|
187
|
+
body: string;
|
|
188
|
+
displayName: string;
|
|
189
|
+
verifiedBuyer: boolean;
|
|
190
|
+
answersCount: number;
|
|
191
|
+
createdAt: string;
|
|
192
|
+
answers: QnAAnswer[];
|
|
193
|
+
};
|
|
194
|
+
type QnAPagination = {
|
|
195
|
+
page: number;
|
|
196
|
+
total: number;
|
|
197
|
+
totalPages: number;
|
|
198
|
+
};
|
|
199
|
+
type QnAResponse = {
|
|
200
|
+
questions: ProductQuestion[];
|
|
201
|
+
pagination: QnAPagination;
|
|
202
|
+
};
|
|
203
|
+
type SubmitQuestionPayload = {
|
|
204
|
+
intent: 'question';
|
|
205
|
+
productId: string;
|
|
206
|
+
email: string;
|
|
207
|
+
displayName?: string;
|
|
208
|
+
body: string;
|
|
209
|
+
isAnonymous?: boolean;
|
|
210
|
+
};
|
|
211
|
+
type SubmitAnswerPayload = {
|
|
212
|
+
intent: 'answer';
|
|
213
|
+
questionId: string;
|
|
214
|
+
email: string;
|
|
215
|
+
displayName?: string;
|
|
216
|
+
body: string;
|
|
217
|
+
isAnonymous?: boolean;
|
|
218
|
+
};
|
|
219
|
+
type UseQnAOptions = {
|
|
220
|
+
proxyUrl: string;
|
|
221
|
+
productId: string;
|
|
222
|
+
page?: number;
|
|
223
|
+
sort?: 'recent' | 'helpful';
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
type ReviewFormProps = {
|
|
227
|
+
proxyUrl: string;
|
|
228
|
+
productId: string;
|
|
229
|
+
form: ResolvedForm;
|
|
230
|
+
onSuccess?: () => void;
|
|
231
|
+
className?: string;
|
|
232
|
+
};
|
|
233
|
+
declare function ReviewForm({ proxyUrl, productId, form, onSuccess, className }: ReviewFormProps): React.JSX.Element;
|
|
234
|
+
|
|
235
|
+
type ReviewCountProps = {
|
|
236
|
+
proxyUrl: string;
|
|
237
|
+
starColor?: string;
|
|
238
|
+
starSize?: number;
|
|
239
|
+
className?: string;
|
|
240
|
+
};
|
|
241
|
+
declare function ReviewCount({ proxyUrl, starColor, starSize, className }: ReviewCountProps): React.JSX.Element | null;
|
|
242
|
+
|
|
243
|
+
type StarRatingProps = {
|
|
244
|
+
rating: number;
|
|
245
|
+
max?: number;
|
|
246
|
+
size?: number | undefined;
|
|
247
|
+
color?: string | undefined;
|
|
248
|
+
className?: string | undefined;
|
|
249
|
+
};
|
|
250
|
+
declare function StarRating({ rating, max, size, color, className }: StarRatingProps): React.JSX.Element;
|
|
251
|
+
|
|
252
|
+
type ReviewCarouselProps = {
|
|
253
|
+
proxyUrl: string;
|
|
254
|
+
limit?: number;
|
|
255
|
+
autoPlay?: boolean;
|
|
256
|
+
intervalMs?: number;
|
|
257
|
+
starColor?: string;
|
|
258
|
+
className?: string;
|
|
259
|
+
};
|
|
260
|
+
declare function ReviewCarousel({ proxyUrl, limit, autoPlay, intervalMs, starColor, className, }: ReviewCarouselProps): React.JSX.Element | null;
|
|
261
|
+
|
|
262
|
+
type ReviewGalleryProps = {
|
|
263
|
+
proxyUrl: string;
|
|
264
|
+
limit?: number;
|
|
265
|
+
columns?: number;
|
|
266
|
+
starColor?: string;
|
|
267
|
+
className?: string;
|
|
268
|
+
};
|
|
269
|
+
declare function ReviewGallery({ proxyUrl, limit, columns, starColor, className, }: ReviewGalleryProps): React.JSX.Element | null;
|
|
270
|
+
|
|
271
|
+
type QnAWidgetProps = {
|
|
272
|
+
proxyUrl: string;
|
|
273
|
+
productId: string;
|
|
274
|
+
className?: string;
|
|
275
|
+
};
|
|
276
|
+
declare function QnAWidget({ proxyUrl, productId, className }: QnAWidgetProps): React.JSX.Element | null;
|
|
277
|
+
|
|
278
|
+
type SocialProofPopupProps = {
|
|
279
|
+
proxyUrl: string;
|
|
280
|
+
position?: 'bottom-left' | 'bottom-right';
|
|
281
|
+
intervalMs?: number;
|
|
282
|
+
displayMs?: number;
|
|
283
|
+
starColor?: string;
|
|
284
|
+
className?: string;
|
|
285
|
+
};
|
|
286
|
+
declare function SocialProofPopup({ proxyUrl, position, intervalMs, displayMs, starColor, className, }: SocialProofPopupProps): React.JSX.Element | null;
|
|
287
|
+
|
|
288
|
+
type ReviewTickerProps = {
|
|
289
|
+
proxyUrl: string;
|
|
290
|
+
limit?: number;
|
|
291
|
+
speedSeconds?: number;
|
|
292
|
+
starColor?: string;
|
|
293
|
+
className?: string;
|
|
294
|
+
};
|
|
295
|
+
declare function ReviewTicker({ proxyUrl, limit, speedSeconds, starColor, className, }: ReviewTickerProps): React.JSX.Element | null;
|
|
296
|
+
|
|
297
|
+
type FloatingReviewsTabProps = {
|
|
298
|
+
proxyUrl: string;
|
|
299
|
+
label?: string;
|
|
300
|
+
position?: 'left' | 'right';
|
|
301
|
+
color?: string;
|
|
302
|
+
limit?: number;
|
|
303
|
+
starColor?: string;
|
|
304
|
+
className?: string;
|
|
305
|
+
};
|
|
306
|
+
declare function FloatingReviewsTab({ proxyUrl, label, position, color, limit, starColor, className, }: FloatingReviewsTabProps): React.JSX.Element;
|
|
307
|
+
|
|
308
|
+
type TrustBadgeProps = {
|
|
309
|
+
proxyUrl: string;
|
|
310
|
+
style?: 'inline' | 'pill' | 'card';
|
|
311
|
+
starColor?: string;
|
|
312
|
+
className?: string;
|
|
313
|
+
};
|
|
314
|
+
declare function TrustBadge({ proxyUrl, style: badgeStyle, starColor, className }: TrustBadgeProps): React.JSX.Element | null;
|
|
315
|
+
|
|
316
|
+
type FloatingReviewButtonProps = {
|
|
317
|
+
proxyUrl: string;
|
|
318
|
+
productId: string;
|
|
319
|
+
text?: string;
|
|
320
|
+
color?: string;
|
|
321
|
+
position?: 'bottom-left' | 'bottom-right';
|
|
322
|
+
className?: string;
|
|
323
|
+
};
|
|
324
|
+
declare function FloatingReviewButton({ proxyUrl, productId, text, color, position, className, }: FloatingReviewButtonProps): React.JSX.Element | null;
|
|
325
|
+
|
|
326
|
+
type State$3 = {
|
|
327
|
+
data: ReviewsResponse | null;
|
|
328
|
+
loading: boolean;
|
|
329
|
+
error: Error | null;
|
|
330
|
+
};
|
|
331
|
+
type UseReviewsReturn = State$3 & {
|
|
332
|
+
refetch: () => void;
|
|
333
|
+
setPage: (page: number) => void;
|
|
334
|
+
setSort: (sort: SortKey) => void;
|
|
335
|
+
currentPage: number;
|
|
336
|
+
currentSort: SortKey;
|
|
337
|
+
};
|
|
338
|
+
declare function useReviews({ proxyUrl, productId, page: initialPage, limit, sort: initialSort, locale, }: UseReviewsOptions): UseReviewsReturn;
|
|
339
|
+
|
|
340
|
+
type State$2 = {
|
|
341
|
+
data: WidgetGlobalsResponse | null;
|
|
342
|
+
loading: boolean;
|
|
343
|
+
error: Error | null;
|
|
344
|
+
};
|
|
345
|
+
declare function useWidgetGlobals({ proxyUrl, limit }: UseWidgetGlobalsOptions): State$2;
|
|
346
|
+
|
|
347
|
+
type SubmitState$1 = {
|
|
348
|
+
submitting: boolean;
|
|
349
|
+
success: boolean;
|
|
350
|
+
error: string | null;
|
|
351
|
+
result: SubmitReviewResponse | null;
|
|
352
|
+
};
|
|
353
|
+
type UseSubmitReviewReturn = SubmitState$1 & {
|
|
354
|
+
submit: (payload: SubmitReviewPayload) => Promise<void>;
|
|
355
|
+
reset: () => void;
|
|
356
|
+
};
|
|
357
|
+
declare function useSubmitReview(proxyUrl: string): UseSubmitReviewReturn;
|
|
358
|
+
|
|
359
|
+
type UseHelpfulVoteReturn = {
|
|
360
|
+
vote: (payload: HelpfulVotePayload) => Promise<void>;
|
|
361
|
+
loading: boolean;
|
|
362
|
+
voted: boolean;
|
|
363
|
+
};
|
|
364
|
+
declare function useHelpfulVote(proxyUrl: string): UseHelpfulVoteReturn;
|
|
365
|
+
|
|
366
|
+
type State$1 = {
|
|
367
|
+
data: QnAResponse | null;
|
|
368
|
+
loading: boolean;
|
|
369
|
+
error: Error | null;
|
|
370
|
+
};
|
|
371
|
+
type SubmitState = {
|
|
372
|
+
submitting: boolean;
|
|
373
|
+
success: boolean;
|
|
374
|
+
error: string | null;
|
|
375
|
+
};
|
|
376
|
+
type UseQnAReturn = State$1 & {
|
|
377
|
+
setPage: (page: number) => void;
|
|
378
|
+
currentPage: number;
|
|
379
|
+
refetch: () => void;
|
|
380
|
+
submitQuestion: (payload: SubmitQuestionPayload) => Promise<void>;
|
|
381
|
+
submitAnswer: (payload: SubmitAnswerPayload) => Promise<void>;
|
|
382
|
+
submitState: SubmitState;
|
|
383
|
+
resetSubmit: () => void;
|
|
384
|
+
};
|
|
385
|
+
declare function useQnA({ proxyUrl, productId, page: initialPage, sort }: UseQnAOptions): UseQnAReturn;
|
|
386
|
+
|
|
387
|
+
type State = {
|
|
388
|
+
form: ResolvedForm | null;
|
|
389
|
+
loading: boolean;
|
|
390
|
+
error: Error | null;
|
|
391
|
+
};
|
|
392
|
+
/**
|
|
393
|
+
* Fetches the resolved form for a product without loading any reviews.
|
|
394
|
+
* Uses the reviews proxy with limit=1 and extracts only the form field.
|
|
395
|
+
*/
|
|
396
|
+
declare function useForm(proxyUrl: string, productId: string): State;
|
|
397
|
+
|
|
398
|
+
export { type AdminReply, type AttributeRating, FloatingReviewButton, FloatingReviewsTab, type FormField, type GlobalReview, type HelpfulVotePayload, type HelpfulVoteResponse, type ProductQuestion, type QnAAnswer, type QnAPagination, type QnAResponse, QnAWidget, type ResolvedForm, type Review, ReviewCarousel, ReviewCount, type ReviewFieldAnswer, ReviewForm, ReviewGallery, type ReviewMedia, ReviewTicker, ReviewWidget, type ReviewsPagination, type ReviewsResponse, type ShopStats, SocialProofPopup, type SortKey, StarRating, type SubmitAnswerPayload, type SubmitQuestionPayload, type SubmitReviewPayload, type SubmitReviewResponse, TrustBadge, type UseQnAOptions, type UseReviewsOptions, type UseWidgetGlobalsOptions, type WidgetConfig, type WidgetGlobalsResponse, type WidgetTheme, useForm, useHelpfulVote, useQnA, useReviews, useSubmitReview, useWidgetGlobals };
|