@godaddy/gd-commerce-storefront 0.4.0 → 0.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.
- package/README.md +198 -15
- package/dist/index.d.ts +381 -25
- package/dist/index.js +1094 -479
- package/dist/styles.css +30 -6
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ declare class ApiError extends Error {
|
|
|
13
13
|
readonly status: number;
|
|
14
14
|
constructor(message: string, status: number, options?: ErrorOptions);
|
|
15
15
|
}
|
|
16
|
-
|
|
16
|
+
/** Formats minor units, such as cents, as currency. Inside the provider, prefer `useMoney`, which follows its `locale`. */
|
|
17
|
+
declare function money(value: number, currency: string, locale?: string): string;
|
|
17
18
|
//#endregion
|
|
18
19
|
//#region src/cart-model.d.ts
|
|
19
20
|
interface Money {
|
|
@@ -304,17 +305,222 @@ declare function getProductAttributes(skuGroup: SKUGroup | null | undefined): St
|
|
|
304
305
|
/** The product's display name: its label, then its name. */
|
|
305
306
|
declare function getProductName(skuGroup: SKUGroup): string;
|
|
306
307
|
//#endregion
|
|
308
|
+
//#region src/part.d.ts
|
|
309
|
+
/** Replacement content for a part's text: content, or a function of the part's state. */
|
|
310
|
+
type PartLabel<State> = ReactNode | ((state: State) => ReactNode);
|
|
311
|
+
//#endregion
|
|
307
312
|
//#region src/cart.d.ts
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
}
|
|
313
|
+
interface CartButtonProps {
|
|
314
|
+
/** Replaces the label and count. A function receives the item count. Keep the count in the label. */
|
|
315
|
+
children?: PartLabel<{
|
|
316
|
+
itemCount: number;
|
|
317
|
+
}>;
|
|
318
|
+
}
|
|
319
|
+
/** Opens the cart drawer and shows the item count. */
|
|
320
|
+
declare function CartButton({
|
|
321
|
+
children
|
|
322
|
+
}?: CartButtonProps): ReactElement;
|
|
323
|
+
/** What an add-to-cart label can depend on. */
|
|
324
|
+
interface AddToCartLabelState {
|
|
325
|
+
/** The add is running. */
|
|
326
|
+
readonly busy: boolean;
|
|
327
|
+
/** Tracked stock is used up, so the button stays disabled. */
|
|
328
|
+
readonly soldOut: boolean;
|
|
329
|
+
}
|
|
330
|
+
interface AddToCartButtonProps {
|
|
314
331
|
sku: SKU;
|
|
315
332
|
name: string;
|
|
316
333
|
quantity?: number;
|
|
317
|
-
|
|
334
|
+
/** Replaces the label. A function receives `busy` and `soldOut`; the button keeps its rules either way. */
|
|
335
|
+
children?: PartLabel<AddToCartLabelState>;
|
|
336
|
+
}
|
|
337
|
+
declare function AddToCartButton({
|
|
338
|
+
sku,
|
|
339
|
+
name,
|
|
340
|
+
quantity,
|
|
341
|
+
children
|
|
342
|
+
}: AddToCartButtonProps): ReactElement;
|
|
343
|
+
//#endregion
|
|
344
|
+
//#region src/cart-state.d.ts
|
|
345
|
+
/** One cart line, for custom cart parts. */
|
|
346
|
+
interface CartItemState {
|
|
347
|
+
/** Empty when the server returned a line without an ID. Such a line cannot be changed or removed. */
|
|
348
|
+
readonly id: string;
|
|
349
|
+
readonly name: string;
|
|
350
|
+
readonly quantity: number;
|
|
351
|
+
readonly imageUrl: string | null;
|
|
352
|
+
readonly options: readonly {
|
|
353
|
+
readonly attribute: string;
|
|
354
|
+
readonly values: readonly string[];
|
|
355
|
+
}[];
|
|
356
|
+
/** The line total in minor units, or `null` when the server did not price it. */
|
|
357
|
+
readonly subtotal: number | null;
|
|
358
|
+
readonly currency: string;
|
|
359
|
+
}
|
|
360
|
+
/** Read-only cart contents: the connected store's cart, or the sample cart while no store is connected. */
|
|
361
|
+
interface CartState {
|
|
362
|
+
readonly items: readonly CartItemState[];
|
|
363
|
+
readonly itemCount: number;
|
|
364
|
+
/** The cart subtotal in minor units, or `null` when the server did not price it. */
|
|
365
|
+
readonly subtotal: number | null;
|
|
366
|
+
readonly currency: string;
|
|
367
|
+
readonly isSample: boolean;
|
|
368
|
+
/** `true` while the saved cart loads. */
|
|
369
|
+
readonly loading: boolean;
|
|
370
|
+
}
|
|
371
|
+
/** Read the cart from anywhere inside `CommerceProvider`, for example to build a custom cart button. */
|
|
372
|
+
declare function useCart(): CartState;
|
|
373
|
+
//#endregion
|
|
374
|
+
//#region src/cart-parts.d.ts
|
|
375
|
+
/** Props shared by every cart part. `className` is added to the part's outer element. */
|
|
376
|
+
interface CartPartProps {
|
|
377
|
+
className?: string;
|
|
378
|
+
}
|
|
379
|
+
/** Props for a cart part whose text the host can replace, with or without the sample wording. */
|
|
380
|
+
interface CartTextPartProps extends CartPartProps {
|
|
381
|
+
/** Replaces the text. A function receives whether the cart is the sample cart. */
|
|
382
|
+
children?: PartLabel<{
|
|
383
|
+
isSample: boolean;
|
|
384
|
+
}>;
|
|
385
|
+
}
|
|
386
|
+
/** Props for a cart button whose label the host can replace. The button keeps its behavior and state. */
|
|
387
|
+
interface CartActionPartProps extends CartPartProps {
|
|
388
|
+
/** Replaces the button label. A function receives whether the action is running. */
|
|
389
|
+
children?: PartLabel<{
|
|
390
|
+
busy: boolean;
|
|
391
|
+
}>;
|
|
392
|
+
}
|
|
393
|
+
interface CartRootProps {
|
|
394
|
+
children: ReactNode;
|
|
395
|
+
/** Added to the root `<section>`. */
|
|
396
|
+
className?: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Provides the cart to cart parts on a page, such as a `/cart` route. While no store is connected it shows the sample
|
|
400
|
+
* cart. Use `CartDrawerRoot` for the drawer.
|
|
401
|
+
*/
|
|
402
|
+
declare function CartRoot({
|
|
403
|
+
children,
|
|
404
|
+
className
|
|
405
|
+
}: CartRootProps): ReactElement;
|
|
406
|
+
interface CartDrawerRootProps {
|
|
407
|
+
children: ReactNode;
|
|
408
|
+
/** Added to the drawer panel. The packaged drawer passes its width, background and column layout here. */
|
|
409
|
+
className?: string;
|
|
410
|
+
}
|
|
411
|
+
/**
|
|
412
|
+
* The cart dialog. Opens when an item is added or a `CartButton` is pressed, and returns focus when it closes.
|
|
413
|
+
* The panel sits at the right edge at full height; `mr-auto` on it moves it to the left. Mount one per provider,
|
|
414
|
+
* in place of `CartDrawer`.
|
|
415
|
+
*/
|
|
416
|
+
declare function CartDrawerRoot({
|
|
417
|
+
children,
|
|
418
|
+
className
|
|
419
|
+
}: CartDrawerRootProps): ReactElement;
|
|
420
|
+
/** "Your cart", or "Sample cart" before a store is connected, as an H2. In the drawer it names the dialog. */
|
|
421
|
+
declare function CartTitle({
|
|
422
|
+
className,
|
|
423
|
+
children
|
|
424
|
+
}: CartTextPartProps): ReactElement;
|
|
425
|
+
/** One line about the cart. In the drawer it describes the dialog. */
|
|
426
|
+
declare function CartDescription({
|
|
427
|
+
className,
|
|
428
|
+
children
|
|
429
|
+
}: CartTextPartProps): ReactElement;
|
|
430
|
+
/** The drawer's close button. Renders nothing outside the drawer. */
|
|
431
|
+
declare function CartClose({
|
|
432
|
+
className
|
|
433
|
+
}: CartPartProps): ReactElement | null;
|
|
434
|
+
/** A storage warning, and a cart error with a refresh button. Renders nothing when there are neither. */
|
|
435
|
+
declare function CartNotices({
|
|
436
|
+
className
|
|
437
|
+
}: CartPartProps): ReactElement | null;
|
|
438
|
+
/** Read the line from inside `CartItemRoot`, for custom item parts. */
|
|
439
|
+
declare function useCartItem(): CartItemState;
|
|
440
|
+
interface CartItemsProps extends CartPartProps {
|
|
441
|
+
/** One item, rendered for every cart line. Defaults to the packaged item. */
|
|
442
|
+
children?: ReactNode;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* The cart lines as a list. `className` goes on the list element whose children are the items. While the saved cart
|
|
446
|
+
* loads, a status message renders just before it.
|
|
447
|
+
*/
|
|
448
|
+
declare function CartItems({
|
|
449
|
+
className,
|
|
450
|
+
children
|
|
451
|
+
}: CartItemsProps): ReactElement;
|
|
452
|
+
interface CartItemRootProps {
|
|
453
|
+
children: ReactNode;
|
|
454
|
+
/** Added to the item's list item element. */
|
|
455
|
+
className?: string;
|
|
456
|
+
}
|
|
457
|
+
/** One cart line. Render it as the child of `CartItems`, which renders it once for every line. */
|
|
458
|
+
declare function CartItemRoot({
|
|
459
|
+
children,
|
|
460
|
+
className
|
|
461
|
+
}: CartItemRootProps): ReactElement;
|
|
462
|
+
/** The line's product image. Renders nothing without one. */
|
|
463
|
+
declare function CartItemImage({
|
|
464
|
+
className
|
|
465
|
+
}: CartPartProps): ReactElement | null;
|
|
466
|
+
/** The product name as an H3. */
|
|
467
|
+
declare function CartItemName({
|
|
468
|
+
className
|
|
469
|
+
}: CartPartProps): ReactElement;
|
|
470
|
+
/** The selected options, one per line, such as "Color: Blue". Renders nothing without options. */
|
|
471
|
+
declare function CartItemOptions({
|
|
472
|
+
className
|
|
473
|
+
}: CartPartProps): ReactElement | null;
|
|
474
|
+
/** The line total. */
|
|
475
|
+
declare function CartItemPrice({
|
|
476
|
+
className
|
|
477
|
+
}: CartPartProps): ReactElement;
|
|
478
|
+
/** Decrease and increase buttons around the line's quantity. */
|
|
479
|
+
declare function CartItemQuantity({
|
|
480
|
+
className
|
|
481
|
+
}: CartPartProps): ReactElement;
|
|
482
|
+
/** Removes the line. */
|
|
483
|
+
declare function CartItemRemove({
|
|
484
|
+
className,
|
|
485
|
+
children
|
|
486
|
+
}: CartActionPartProps): ReactElement;
|
|
487
|
+
interface CartEmptyProps extends CartPartProps {
|
|
488
|
+
/** Replaces the default message and link. */
|
|
489
|
+
children?: ReactNode;
|
|
490
|
+
}
|
|
491
|
+
/** Renders only when the cart is empty: a message and a link to the catalog, or its children. */
|
|
492
|
+
declare function CartEmpty({
|
|
493
|
+
className,
|
|
494
|
+
children
|
|
495
|
+
}: CartEmptyProps): ReactElement | null;
|
|
496
|
+
interface CartSummaryProps extends CartPartProps {
|
|
497
|
+
children: ReactNode;
|
|
498
|
+
}
|
|
499
|
+
/** A container for the subtotal and checkout. Renders only when the cart has items. */
|
|
500
|
+
declare function CartSummary({
|
|
501
|
+
className,
|
|
502
|
+
children
|
|
503
|
+
}: CartSummaryProps): ReactElement | null;
|
|
504
|
+
/** The subtotal, labeled "Sample subtotal" for samples. Renders nothing until the server prices the cart. */
|
|
505
|
+
declare function CartSubtotal({
|
|
506
|
+
className
|
|
507
|
+
}: CartPartProps): ReactElement | null;
|
|
508
|
+
/**
|
|
509
|
+
* "Shipping, taxes, and discounts are calculated at checkout." Has the stable
|
|
510
|
+
* `commerce-cart-checkout-adjustments-note` class. Renders nothing for samples or an empty cart.
|
|
511
|
+
*/
|
|
512
|
+
declare function CartCheckoutNote({
|
|
513
|
+
className
|
|
514
|
+
}: CartPartProps): ReactElement | null;
|
|
515
|
+
/**
|
|
516
|
+
* The checkout button when `checkoutSuccessPath` is set; otherwise a message that checkout is unavailable.
|
|
517
|
+
* Samples never check out. Renders nothing for an empty cart.
|
|
518
|
+
*/
|
|
519
|
+
declare function CartCheckout({
|
|
520
|
+
className,
|
|
521
|
+
children
|
|
522
|
+
}: CartActionPartProps): ReactElement | null;
|
|
523
|
+
/** The packaged cart drawer. Compose `CartDrawerRoot` and the cart parts for a custom drawer. */
|
|
318
524
|
declare function CartDrawer(): ReactElement;
|
|
319
525
|
//#endregion
|
|
320
526
|
//#region src/catalog.d.ts
|
|
@@ -328,12 +534,21 @@ interface CatalogRootProps {
|
|
|
328
534
|
className?: string;
|
|
329
535
|
/** Permit built-in examples only while the host confirms this site is unbound. */
|
|
330
536
|
sampleProducts?: boolean;
|
|
537
|
+
/** Products per page, a whole number of 1 or more. Defaults to 6. Samples are always one page of six. */
|
|
538
|
+
pageSize?: number;
|
|
539
|
+
/**
|
|
540
|
+
* Keep the page cursor in the page URL, as `after`, so a reload or a shared link keeps the page. Defaults to
|
|
541
|
+
* `true`. Set `false` for every other catalog on the same page, so the catalogs do not share one cursor.
|
|
542
|
+
*/
|
|
543
|
+
urlState?: boolean;
|
|
331
544
|
}
|
|
332
545
|
/** Loads one cursor page of products, or the built-in samples, and provides them to catalog parts. */
|
|
333
546
|
declare function CatalogRoot({
|
|
334
547
|
children,
|
|
335
548
|
className,
|
|
336
|
-
sampleProducts
|
|
549
|
+
sampleProducts,
|
|
550
|
+
pageSize,
|
|
551
|
+
urlState
|
|
337
552
|
}: CatalogRootProps): ReactElement;
|
|
338
553
|
interface CatalogHeaderProps extends CatalogPartProps {
|
|
339
554
|
title?: string;
|
|
@@ -354,30 +569,48 @@ interface CatalogProductsProps extends CatalogPartProps {
|
|
|
354
569
|
children?: ReactNode;
|
|
355
570
|
}
|
|
356
571
|
/**
|
|
357
|
-
* The product cards. `className` goes on the element that contains the cards, such as a grid.
|
|
358
|
-
* placeholder
|
|
572
|
+
* The product cards. `className` goes on the element that contains the cards, such as a grid. While loading, that
|
|
573
|
+
* element holds placeholder cards. The error with its retry and, without a `CatalogEmpty`, the empty message render just before it.
|
|
359
574
|
*/
|
|
360
575
|
declare function CatalogProducts({
|
|
361
576
|
className,
|
|
362
577
|
children
|
|
363
578
|
}: CatalogProductsProps): ReactElement;
|
|
579
|
+
interface CatalogEmptyProps extends CatalogPartProps {
|
|
580
|
+
/** Replaces the default message. */
|
|
581
|
+
children?: ReactNode;
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Renders only when a connected store's catalog has no products: "No products available.", or its children. While
|
|
585
|
+
* one is mounted, `CatalogProducts` leaves out its own empty message. Samples are never empty.
|
|
586
|
+
*/
|
|
587
|
+
declare function CatalogEmpty({
|
|
588
|
+
className,
|
|
589
|
+
children
|
|
590
|
+
}: CatalogEmptyProps): ReactElement | null;
|
|
364
591
|
/** First-page and next-page buttons. Renders nothing for samples, which have one page. */
|
|
365
592
|
declare function CatalogPagination({
|
|
366
593
|
className
|
|
367
594
|
}: CatalogPartProps): ReactElement | null;
|
|
368
595
|
interface CatalogProps {
|
|
596
|
+
/** @deprecated Compose `CatalogRoot` with `<CatalogHeader title='…' />` instead. */
|
|
369
597
|
title?: string;
|
|
598
|
+
/** @deprecated Compose `CatalogRoot` with `<CatalogHeader description='…' />` instead. */
|
|
370
599
|
description?: string;
|
|
600
|
+
/** @deprecated To render the page's own H1, compose `CatalogRoot` without `CatalogHeader` instead. */
|
|
371
601
|
showHeader?: boolean;
|
|
372
602
|
/** Permit built-in examples only while the host confirms this site is unbound. */
|
|
373
603
|
sampleProducts?: boolean;
|
|
604
|
+
/** Products per page. Defaults to 6. */
|
|
605
|
+
pageSize?: number;
|
|
374
606
|
}
|
|
375
607
|
/** The packaged catalog. Compose `CatalogRoot` and the catalog parts for a custom layout. */
|
|
376
608
|
declare function Catalog({
|
|
377
609
|
title,
|
|
378
610
|
description,
|
|
379
611
|
showHeader,
|
|
380
|
-
sampleProducts
|
|
612
|
+
sampleProducts,
|
|
613
|
+
pageSize
|
|
381
614
|
}: CatalogProps): ReactElement;
|
|
382
615
|
//#endregion
|
|
383
616
|
//#region src/commerce-provider.d.ts
|
|
@@ -387,8 +620,12 @@ interface CommerceContextValue {
|
|
|
387
620
|
retryConnection: () => void;
|
|
388
621
|
theme: StorefrontTheme;
|
|
389
622
|
config: StorefrontConfig;
|
|
623
|
+
/** The BCP 47 locale that prices are formatted in, such as `en-US`. */
|
|
624
|
+
locale: string;
|
|
390
625
|
cart: CartOrder | null;
|
|
626
|
+
/** Whether the cart drawer is open. Always `false` when no `CartDrawer` or `CartDrawerRoot` is mounted. */
|
|
391
627
|
open: boolean;
|
|
628
|
+
/** Opens or closes the cart drawer. Opening does nothing without a mounted drawer. */
|
|
392
629
|
setOpen: (open: boolean) => void;
|
|
393
630
|
/** Restores the initiating control after the cart drawer closes. */
|
|
394
631
|
restoreFocus: () => void;
|
|
@@ -405,6 +642,11 @@ interface CommerceContextValue {
|
|
|
405
642
|
checkout: () => Promise<boolean>;
|
|
406
643
|
}
|
|
407
644
|
declare function useCommerce(): CommerceContextValue;
|
|
645
|
+
/**
|
|
646
|
+
* Formats minor units, such as cents, in the provider's `locale`, the way the package's own parts do. Uses the
|
|
647
|
+
* store's currency unless `currency` is given.
|
|
648
|
+
*/
|
|
649
|
+
declare function useMoney(): (value: number, currency?: string) => string;
|
|
408
650
|
type StorefrontTheme = CSSProperties & {
|
|
409
651
|
'--commerce-accent'?: string;
|
|
410
652
|
'--commerce-accent-hover'?: string;
|
|
@@ -421,13 +663,70 @@ interface CommerceProviderProps {
|
|
|
421
663
|
theme?: StorefrontTheme;
|
|
422
664
|
/** Set only when your server has enabled checkout and this return route exists. */
|
|
423
665
|
checkoutSuccessPath?: string;
|
|
666
|
+
/**
|
|
667
|
+
* The BCP 47 locale for formatting prices, such as `de-DE`. Defaults to `en-US`; an invalid tag falls back to it.
|
|
668
|
+
* It never selects UI text: localized text will be a separate, opt-in prop, so setting `locale` cannot change wording.
|
|
669
|
+
*/
|
|
670
|
+
locale?: string;
|
|
671
|
+
/**
|
|
672
|
+
* Called after an item is added, live or sample. With a drawer mounted, the drawer also opens. Without one, such as
|
|
673
|
+
* on a site with a cart page, use it to confirm the add.
|
|
674
|
+
*/
|
|
675
|
+
onItemAdded?: (item: AddedCartItem) => void;
|
|
676
|
+
/** Called for every cart change and failure, such as for analytics. See `CommerceEvent`. */
|
|
677
|
+
onEvent?: (event: CommerceEvent) => void;
|
|
678
|
+
}
|
|
679
|
+
/** A cart operation that can fail. */
|
|
680
|
+
type CommerceOperation = 'add' | 'change-quantity' | 'remove' | 'discount' | 'refresh' | 'checkout';
|
|
681
|
+
/**
|
|
682
|
+
* What `onEvent` reports. Live changes are reported once the server returns the updated cart; sample changes have
|
|
683
|
+
* `isSample: true` and never reach the store. New event types may be added, so ignore types you do not handle.
|
|
684
|
+
*/
|
|
685
|
+
type CommerceEvent = {
|
|
686
|
+
readonly type: 'item-added';
|
|
687
|
+
/** `null` for a sample product, which is not a SKU. */
|
|
688
|
+
readonly skuId: string | null;
|
|
689
|
+
readonly name: string;
|
|
690
|
+
readonly quantity: number;
|
|
691
|
+
readonly isSample: boolean;
|
|
692
|
+
} | {
|
|
693
|
+
readonly type: 'quantity-changed';
|
|
694
|
+
readonly itemId: string;
|
|
695
|
+
readonly quantity: number;
|
|
696
|
+
readonly isSample: boolean;
|
|
697
|
+
} | {
|
|
698
|
+
readonly type: 'item-removed';
|
|
699
|
+
readonly itemId: string;
|
|
700
|
+
readonly isSample: boolean;
|
|
701
|
+
} | {
|
|
702
|
+
readonly type: 'discount-applied';
|
|
703
|
+
readonly code: string;
|
|
704
|
+
}
|
|
705
|
+
/** Sent just before the browser leaves for checkout. */ | {
|
|
706
|
+
readonly type: 'checkout-started';
|
|
707
|
+
readonly cartId: string;
|
|
708
|
+
}
|
|
709
|
+
/** `message` is the one the cart shows. */ | {
|
|
710
|
+
readonly type: 'error';
|
|
711
|
+
readonly operation: CommerceOperation;
|
|
712
|
+
readonly message: string;
|
|
713
|
+
};
|
|
714
|
+
/** The item passed to `onItemAdded`. */
|
|
715
|
+
interface AddedCartItem {
|
|
716
|
+
readonly name: string;
|
|
717
|
+
readonly quantity: number;
|
|
718
|
+
/** `true` for the sample cart, before a store is connected. */
|
|
719
|
+
readonly isSample: boolean;
|
|
424
720
|
}
|
|
425
721
|
declare function CommerceProvider({
|
|
426
722
|
children,
|
|
427
723
|
catalogPath,
|
|
428
724
|
productPath,
|
|
429
725
|
checkoutSuccessPath,
|
|
430
|
-
theme
|
|
726
|
+
theme,
|
|
727
|
+
locale,
|
|
728
|
+
onItemAdded,
|
|
729
|
+
onEvent
|
|
431
730
|
}: CommerceProviderProps): ReactElement;
|
|
432
731
|
//#endregion
|
|
433
732
|
//#region src/commerce-storefront.d.ts
|
|
@@ -438,6 +737,22 @@ declare function CommerceStorefront({
|
|
|
438
737
|
}: CommerceProviderProps): react_jsx_runtime0.JSX.Element;
|
|
439
738
|
//#endregion
|
|
440
739
|
//#region src/product-card.d.ts
|
|
740
|
+
interface ProductImageProps {
|
|
741
|
+
url?: string | null;
|
|
742
|
+
/** The alt text. Pass `''` for a decorative image, such as a thumbnail next to the product name. */
|
|
743
|
+
name: string;
|
|
744
|
+
/** Added to the image, or to its placeholder. */
|
|
745
|
+
className?: string;
|
|
746
|
+
}
|
|
747
|
+
/**
|
|
748
|
+
* A product image that fills its container, with a labeled placeholder when there is no URL or it fails to load.
|
|
749
|
+
* Use it in custom parts so they handle missing images like the package's own.
|
|
750
|
+
*/
|
|
751
|
+
declare function ProductImage({
|
|
752
|
+
url,
|
|
753
|
+
name,
|
|
754
|
+
className
|
|
755
|
+
}: ProductImageProps): ReactElement;
|
|
441
756
|
/** Read-only card state for custom parts rendered inside `ProductCardRoot`. */
|
|
442
757
|
interface ProductCardState {
|
|
443
758
|
/** `null` for a built-in sample, which is not a catalog product. */
|
|
@@ -485,13 +800,23 @@ declare function ProductCardDescription({
|
|
|
485
800
|
declare function ProductCardPrice({
|
|
486
801
|
className
|
|
487
802
|
}: ProductCardPartProps): ReactElement;
|
|
803
|
+
/** What a card action label can depend on. Only `add` can be busy or sold out. */
|
|
804
|
+
interface ProductCardActionLabelState extends AddToCartLabelState {
|
|
805
|
+
/** `add` adds directly; `choose-options` and `view-product` link to the product page. */
|
|
806
|
+
readonly action: 'add' | 'choose-options' | 'view-product';
|
|
807
|
+
}
|
|
808
|
+
interface ProductCardActionProps extends ProductCardPartProps {
|
|
809
|
+
/** Replaces the button or link label. A function receives the action and its state. */
|
|
810
|
+
children?: PartLabel<ProductCardActionLabelState>;
|
|
811
|
+
}
|
|
488
812
|
/**
|
|
489
813
|
* Adds the product directly when it has exactly one SKU and no options; otherwise links to its page to choose.
|
|
490
814
|
* Samples add to the sample cart.
|
|
491
815
|
*/
|
|
492
816
|
declare function ProductCardAction({
|
|
493
|
-
className
|
|
494
|
-
|
|
817
|
+
className,
|
|
818
|
+
children
|
|
819
|
+
}: ProductCardActionProps): ReactElement;
|
|
495
820
|
interface ProductCardProps {
|
|
496
821
|
product: SKUGroup;
|
|
497
822
|
}
|
|
@@ -543,19 +868,45 @@ interface ProductDetailsRootProps {
|
|
|
543
868
|
children: ReactNode;
|
|
544
869
|
/** Added to the root `<article>`. */
|
|
545
870
|
className?: string;
|
|
546
|
-
|
|
547
|
-
|
|
871
|
+
/** The product to show. Defaults to the route's `:productId` parameter. */
|
|
872
|
+
productId?: string;
|
|
873
|
+
/**
|
|
874
|
+
* Keep the selected options and SKU in the page URL, as `option.<attribute>` and `sku`, so a reload or a shared link
|
|
875
|
+
* keeps them. Defaults to `true`. Set `false` for every other root on the same page, such as a quick view, so the
|
|
876
|
+
* roots do not share one selection.
|
|
877
|
+
*/
|
|
878
|
+
urlState?: boolean;
|
|
879
|
+
/** Replaces the loading message. */
|
|
880
|
+
loading?: ReactNode;
|
|
881
|
+
/** Replaces the not-found heading and link. */
|
|
882
|
+
notFound?: ReactNode;
|
|
883
|
+
/** Replaces the load failure. A function receives the failure message and a `retry` for the product request. */
|
|
884
|
+
error?: PartLabel<ProductDetailsErrorState>;
|
|
885
|
+
}
|
|
886
|
+
/** What a replacement for the product load failure receives. */
|
|
887
|
+
interface ProductDetailsErrorState {
|
|
888
|
+
readonly message: string;
|
|
889
|
+
readonly retry: () => void;
|
|
890
|
+
}
|
|
891
|
+
/** Loads one product, by default the route's `:productId`, and provides state to product parts. */
|
|
548
892
|
declare function ProductDetailsRoot({
|
|
549
|
-
|
|
550
|
-
className
|
|
893
|
+
productId: productIdProp,
|
|
894
|
+
className,
|
|
895
|
+
...props
|
|
551
896
|
}: ProductDetailsRootProps): ReactElement;
|
|
552
897
|
//#endregion
|
|
553
898
|
//#region src/product-details.d.ts
|
|
554
899
|
/** The packaged product page for `${productPath}/:productId`. Compose the parts for a custom layout. */
|
|
555
900
|
declare function ProductDetails(): ReactElement;
|
|
901
|
+
interface ProductDetailsBackLinkProps extends ProductDetailsPartProps {
|
|
902
|
+
/** Replaces "← Back to shop". */
|
|
903
|
+
children?: ReactNode;
|
|
904
|
+
}
|
|
905
|
+
/** A link to the catalog. */
|
|
556
906
|
declare function ProductDetailsBackLink({
|
|
557
|
-
className
|
|
558
|
-
|
|
907
|
+
className,
|
|
908
|
+
children
|
|
909
|
+
}: ProductDetailsBackLinkProps): ReactElement;
|
|
559
910
|
/** Main image with thumbnails; the selected SKU's images replace the product's when present. */
|
|
560
911
|
declare function ProductDetailsGallery({
|
|
561
912
|
className
|
|
@@ -599,16 +950,21 @@ declare function ProductDetailsPurchaseStatus({
|
|
|
599
950
|
declare function ProductDetailsAvailability({
|
|
600
951
|
className
|
|
601
952
|
}: ProductDetailsPartProps): ReactElement | null;
|
|
602
|
-
/** Quantity for the verified SKU. Renders nothing until a SKU is verified. */
|
|
953
|
+
/** Quantity for the verified SKU, with a message when it cannot be added. Renders nothing until a SKU is verified. */
|
|
603
954
|
declare function ProductDetailsQuantity({
|
|
604
955
|
className
|
|
605
956
|
}: ProductDetailsPartProps): ReactElement | null;
|
|
957
|
+
interface ProductDetailsAddToCartProps extends ProductDetailsPartProps {
|
|
958
|
+
/** Replaces the button label. A function receives `busy` and `soldOut`; the button keeps its rules either way. */
|
|
959
|
+
children?: PartLabel<AddToCartLabelState>;
|
|
960
|
+
}
|
|
606
961
|
/** Adds the verified SKU and quantity. While disabled, its accessible description says why. */
|
|
607
962
|
declare function ProductDetailsAddToCart({
|
|
608
|
-
className
|
|
609
|
-
|
|
963
|
+
className,
|
|
964
|
+
children
|
|
965
|
+
}: ProductDetailsAddToCartProps): ReactElement;
|
|
610
966
|
//#endregion
|
|
611
967
|
//#region src/storefront-surface.d.ts
|
|
612
968
|
declare function CommerceStatus(): ReactElement | null;
|
|
613
969
|
//#endregion
|
|
614
|
-
export { AddToCartButton, AddToCartItemInput, ApiError, CartAddress, CartButton, CartDiscount, CartDrawer, CartLineItem, CartLineItemDetails, CartNote, CartOrder, CartSelectedAddon, CartSelectedAddonValue, CartSelectedOption, CartShippingInfo, CartSummaryTotals, CartTax, Catalog, CatalogHeader, type CatalogHeaderProps, CatalogPagination, type CatalogPartProps, CatalogProducts, type CatalogProductsProps, type CatalogProps, CatalogRoot, type CatalogRootProps, CatalogSummary, type CommerceContextValue, CommerceProvider, type CommerceProviderProps, CommerceStatus, CommerceStorefront, Connection, ConnectionEdge, DraftOrderContext, InventoryCount, LabelFilter, LineItemTotals, MediaObject, Money, OrderTotals, PageInfo, PriceRange, ProductCard, ProductCardAction, ProductCardDescription, ProductCardImage, type ProductCardPartProps, ProductCardPrice, type ProductCardProps, ProductCardRoot, type ProductCardRootProps, type ProductCardState, ProductCardTitle, ProductDetails, ProductDetailsAddToCart, ProductDetailsAvailability, ProductDetailsBackLink, ProductDetailsDescription, ProductDetailsGallery, ProductDetailsOption, type ProductDetailsOptionProps, type ProductDetailsOptionState, type ProductDetailsOptionValueState, ProductDetailsOptions, type ProductDetailsPartProps, ProductDetailsPrice, ProductDetailsPurchase, ProductDetailsPurchaseStatus, ProductDetailsQuantity, ProductDetailsRoot, type ProductDetailsRootProps, type ProductDetailsState, type ProductDetailsStatus, ProductDetailsTitle, ProductDetailsVariablesInput, ProductGridVariablesInput, SKU, SKUAttributeValue, SKUGroup, SKUGroupAttribute, SKUGroupAttributeValue, SKUGroupSKU, SKUPrice, SkuGroupResult, SkuGroupVariables, SkuGroupsResult, SkuGroupsVariables, SkuResult, SkuVariables, type StorefrontConfig, StorefrontProductAttribute, StorefrontProductAttributeValue, type StorefrontTheme, StringInFilter, addToCart, getAvailableInventoryQuantity, getCartSummaryTotals, getImageUrls, getLabeledSkuOptions, getPrimaryImageUrl, getProductAttributes, getProductName, getSingleMatchedSku, getSingleMatchedSkuId, money, useCommerce, useProductCard, useProductDetails, useProductDetailsOption };
|
|
970
|
+
export { AddToCartButton, type AddToCartButtonProps, AddToCartItemInput, type AddToCartLabelState, type AddedCartItem, ApiError, type CartActionPartProps, CartAddress, CartButton, type CartButtonProps, CartCheckout, CartCheckoutNote, CartClose, CartDescription, CartDiscount, CartDrawer, CartDrawerRoot, type CartDrawerRootProps, CartEmpty, type CartEmptyProps, CartItemImage, CartItemName, CartItemOptions, CartItemPrice, CartItemQuantity, CartItemRemove, CartItemRoot, type CartItemRootProps, type CartItemState, CartItems, type CartItemsProps, CartLineItem, CartLineItemDetails, CartNote, CartNotices, CartOrder, type CartPartProps, CartRoot, type CartRootProps, CartSelectedAddon, CartSelectedAddonValue, CartSelectedOption, CartShippingInfo, type CartState, CartSubtotal, CartSummary, type CartSummaryProps, CartSummaryTotals, CartTax, type CartTextPartProps, CartTitle, Catalog, CatalogEmpty, type CatalogEmptyProps, CatalogHeader, type CatalogHeaderProps, CatalogPagination, type CatalogPartProps, CatalogProducts, type CatalogProductsProps, type CatalogProps, CatalogRoot, type CatalogRootProps, CatalogSummary, type CommerceContextValue, type CommerceEvent, type CommerceOperation, CommerceProvider, type CommerceProviderProps, CommerceStatus, CommerceStorefront, Connection, ConnectionEdge, DraftOrderContext, InventoryCount, LabelFilter, LineItemTotals, MediaObject, Money, OrderTotals, PageInfo, type PartLabel, PriceRange, ProductCard, ProductCardAction, type ProductCardActionLabelState, type ProductCardActionProps, ProductCardDescription, ProductCardImage, type ProductCardPartProps, ProductCardPrice, type ProductCardProps, ProductCardRoot, type ProductCardRootProps, type ProductCardState, ProductCardTitle, ProductDetails, ProductDetailsAddToCart, type ProductDetailsAddToCartProps, ProductDetailsAvailability, ProductDetailsBackLink, type ProductDetailsBackLinkProps, ProductDetailsDescription, type ProductDetailsErrorState, ProductDetailsGallery, ProductDetailsOption, type ProductDetailsOptionProps, type ProductDetailsOptionState, type ProductDetailsOptionValueState, ProductDetailsOptions, type ProductDetailsPartProps, ProductDetailsPrice, ProductDetailsPurchase, ProductDetailsPurchaseStatus, ProductDetailsQuantity, ProductDetailsRoot, type ProductDetailsRootProps, type ProductDetailsState, type ProductDetailsStatus, ProductDetailsTitle, ProductDetailsVariablesInput, ProductGridVariablesInput, ProductImage, type ProductImageProps, SKU, SKUAttributeValue, SKUGroup, SKUGroupAttribute, SKUGroupAttributeValue, SKUGroupSKU, SKUPrice, SkuGroupResult, SkuGroupVariables, SkuGroupsResult, SkuGroupsVariables, SkuResult, SkuVariables, type StorefrontConfig, StorefrontProductAttribute, StorefrontProductAttributeValue, type StorefrontTheme, StringInFilter, addToCart, getAvailableInventoryQuantity, getCartSummaryTotals, getImageUrls, getLabeledSkuOptions, getPrimaryImageUrl, getProductAttributes, getProductName, getSingleMatchedSku, getSingleMatchedSkuId, money, useCart, useCartItem, useCommerce, useMoney, useProductCard, useProductDetails, useProductDetailsOption };
|