@cartbase/storefront 0.20.0 → 0.20.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.
Files changed (99) hide show
  1. package/LICENSE +21 -21
  2. package/package.json +258 -258
  3. package/src/api/auth.ts +108 -108
  4. package/src/api/carts.ts +523 -523
  5. package/src/api/categories.ts +184 -184
  6. package/src/api/checkout.ts +526 -526
  7. package/src/api/collections.ts +130 -130
  8. package/src/api/consent.ts +75 -75
  9. package/src/api/content.ts +125 -125
  10. package/src/api/customers.ts +303 -303
  11. package/src/api/gift-cards.ts +112 -112
  12. package/src/api/http.ts +180 -180
  13. package/src/api/index.ts +30 -30
  14. package/src/api/menus.ts +77 -77
  15. package/src/api/metaobjects.ts +136 -136
  16. package/src/api/orders.ts +290 -290
  17. package/src/api/redirects.ts +37 -37
  18. package/src/api/regions.ts +200 -200
  19. package/src/api/search.ts +163 -163
  20. package/src/api/store.ts +35 -35
  21. package/src/api/types.ts +91 -91
  22. package/src/cart-drawer/context.tsx +778 -778
  23. package/src/cart-drawer/cross-sell-carousel.tsx +211 -211
  24. package/src/cart-drawer/cross-sell-sidebar.tsx +158 -158
  25. package/src/cart-drawer/gift-wrap.tsx +82 -82
  26. package/src/cart-drawer/item/index.tsx +162 -162
  27. package/src/cart-drawer/item/upsell.tsx +110 -110
  28. package/src/cart-drawer/labels.ts +123 -123
  29. package/src/cart-drawer/mutation-queue.ts +78 -78
  30. package/src/cart-drawer/notes.tsx +131 -131
  31. package/src/cart-drawer/sticky-footer.tsx +73 -73
  32. package/src/cart-drawer/summary-breakdown.tsx +197 -197
  33. package/src/checkout/address-error-copy.ts +117 -117
  34. package/src/checkout/boxnow-locker-selector.tsx +410 -410
  35. package/src/checkout/compare-addresses.ts +40 -40
  36. package/src/checkout/discount-section.tsx +218 -218
  37. package/src/checkout/error-copy-codes.ts +63 -63
  38. package/src/checkout/geocode.ts +154 -154
  39. package/src/checkout/gift-card-section.tsx +224 -224
  40. package/src/checkout/index.ts +72 -72
  41. package/src/checkout/labels.ts +495 -495
  42. package/src/checkout/payment-button.tsx +372 -372
  43. package/src/checkout/payment-error-copy.ts +154 -154
  44. package/src/checkout/promotion-error-copy.ts +91 -91
  45. package/src/common/country-flag.tsx +52 -52
  46. package/src/common/country-select.tsx +11 -11
  47. package/src/common/index.ts +20 -20
  48. package/src/common/market-select.tsx +57 -57
  49. package/src/index.ts +12 -12
  50. package/src/lib/country-name.ts +59 -59
  51. package/src/lib/get-product-price.ts +133 -133
  52. package/src/lib/media-image.tsx +39 -39
  53. package/src/lib/payment-constants.ts +53 -53
  54. package/src/lib/platform.ts +13 -13
  55. package/src/lib/price.tsx +39 -39
  56. package/src/lib/store-api-error.ts +36 -36
  57. package/src/lib/variant-caption.ts +32 -32
  58. package/src/locales/context.ts +37 -37
  59. package/src/locales/en.ts +26 -26
  60. package/src/locales/index.ts +19 -19
  61. package/src/locales/provider.tsx +59 -59
  62. package/src/locales/types.ts +77 -77
  63. package/src/order/index.ts +62 -62
  64. package/src/order/labels.ts +79 -79
  65. package/src/order/order-totals.tsx +250 -250
  66. package/src/primitives/select-field.tsx +93 -93
  67. package/src/products/image-gallery.tsx +43 -43
  68. package/src/products/option-select.tsx +67 -67
  69. package/src/products/product-info.tsx +5 -5
  70. package/src/products/product-price.tsx +69 -69
  71. package/src/products/product-promises.tsx +61 -61
  72. package/src/products/product-specs.tsx +65 -65
  73. package/src/products/product-tabs.tsx +123 -123
  74. package/src/products/purchase-options.tsx +130 -130
  75. package/src/products/sets.ts +110 -110
  76. package/src/products/variant-matching.ts +71 -71
  77. package/src/products/variant-url.ts +74 -74
  78. package/src/reviews-ui/lightbox-state.ts +46 -46
  79. package/src/reviews-ui/review-header.tsx +166 -166
  80. package/src/reviews-ui/review-lightbox.tsx +271 -271
  81. package/src/reviews-ui/review-list.tsx +193 -193
  82. package/src/reviews-ui/review-widget.tsx +219 -218
  83. package/src/reviews-ui/widget-options.ts +55 -55
  84. package/src/store/category-template.tsx +136 -136
  85. package/src/store/index.ts +40 -40
  86. package/src/tracking/chatgpt-pixel.tsx +99 -99
  87. package/src/tracking/consent-init.tsx +62 -62
  88. package/src/tracking/events.ts +348 -348
  89. package/src/tracking/ga4.tsx +93 -93
  90. package/src/tracking/google-ads.ts +84 -84
  91. package/src/tracking/gtm.tsx +60 -60
  92. package/src/tracking/inline-script.ts +49 -49
  93. package/src/tracking/oaiq.ts +206 -206
  94. package/src/tracking/tiktok-pixel.tsx +91 -91
  95. package/src/tracking/track-init.tsx +56 -56
  96. package/src/tracking/track-order-purchase.tsx +122 -122
  97. package/src/tracking/ttq.ts +180 -180
  98. package/src/tracking/use-tracking-config.ts +54 -54
  99. package/theme/index.css +25 -25
@@ -1,77 +1,77 @@
1
- import type { CartDrawerLabels } from "../cart-drawer/labels"
2
- import type { CheckoutLabels } from "../checkout/labels"
3
- import type { OrderLabels } from "../order/labels"
4
- import type { ProductLabels } from "../products/labels"
5
- import type { ReviewsUiLabels } from "../reviews-ui/labels"
6
- import type { StoreLabels } from "../store/labels"
7
-
8
- /**
9
- * A LOCALE IS ONE OBJECT COVERING THE WHOLE STOREFRONT.
10
- *
11
- * Before this (2026-09-13) every area shipped its own English defaults and
12
- * its own Bulgarian file, so localizing a store meant importing six packs
13
- * and mounting four separate providers, and a global package shipped
14
- * Bulgarian copy to every merchant on earth. Alexander's ruling: the
15
- * library is international ENGLISH, and a language is a pack the store
16
- * opts into.
17
- *
18
- * So: English is the library's own default and lives in each area's
19
- * `labels.ts` beside its type. Every other language is a locale pack
20
- * imported by subpath — `@cartbase/storefront/locales/es`,
21
- * `/locales/bg` — and is typed against these six shapes, which means a
22
- * missing translation is a COMPILE ERROR rather than a silent fall back to
23
- * English in the middle of a Spanish checkout.
24
- *
25
- * Adding a language is one file in `src/locales/` plus its export path.
26
- * Nothing else in the package changes, and no component knows a language
27
- * exists.
28
- */
29
- export interface StorefrontLocale {
30
- /** BCP 47 code, for the app's own persistence and for `<html lang>`. */
31
- code: string
32
- /** The language's own name, for a switcher that does not want Intl. */
33
- name: string
34
- products: ProductLabels
35
- store: StoreLabels
36
- cartDrawer: CartDrawerLabels
37
- checkout: CheckoutLabels
38
- order: OrderLabels
39
- reviews: ReviewsUiLabels
40
- }
41
-
42
- /**
43
- * THE AREAS WHOSE PACK THE APP MUST HAND OVER AS A PROP, and the prop is
44
- * REQUIRED.
45
- *
46
- * Not a style choice and not a gap in this layer: a React SERVER component
47
- * cannot read a client context, and these areas are rendered on the server.
48
- * `StorefrontLocaleProvider` therefore reaches the client components and
49
- * nothing else, and a server-rendered heading would stay English however
50
- * many providers were mounted above it.
51
- *
52
- * Since 2026-09-14 the page-level templates of these areas REQUIRE the pack
53
- * (`labels: StoreLabels`, never `labels?`), so a page that forgets it fails
54
- * to compile instead of shipping silent English. That was the defect: on
55
- * 2026-09-13 evoo, a Bulgarian store, ended a product page in the English
56
- * "Related products / You might also want to check out these products", and
57
- * its search page and order confirmation stayed English, with no error, no
58
- * warning and no failing test. English is not a special case: an English
59
- * store passes `en.store`. The scaffold declares `STORE_LOCALE` once in its
60
- * config and every page reads its area from it.
61
- *
62
- * Hand the pack to each page-level template once and everything inside it
63
- * follows:
64
- *
65
- * <StoreTemplate labels={STORE_LOCALE.store} />
66
- * <SearchTemplate labels={STORE_LOCALE.store} />
67
- * <CollectionTemplate labels={STORE_LOCALE.store} />
68
- * <CategoryTemplate labels={STORE_LOCALE.store} />
69
- * <ProductTemplate labels={STORE_LOCALE.products} /> // + the related strip
70
- * <OrderCompletedTemplate labels={STORE_LOCALE.order} />
71
- *
72
- * The cart drawer and the reviews family were listed here until 2026-09-14.
73
- * They are client components, so they now read the mounted language
74
- * themselves (`useLocaleArea` in ./context); their `labels` prop is an
75
- * override, never a requirement.
76
- */
77
- export type PropLabelAreas = Pick<StorefrontLocale, "products" | "store" | "order">
1
+ import type { CartDrawerLabels } from "../cart-drawer/labels"
2
+ import type { CheckoutLabels } from "../checkout/labels"
3
+ import type { OrderLabels } from "../order/labels"
4
+ import type { ProductLabels } from "../products/labels"
5
+ import type { ReviewsUiLabels } from "../reviews-ui/labels"
6
+ import type { StoreLabels } from "../store/labels"
7
+
8
+ /**
9
+ * A LOCALE IS ONE OBJECT COVERING THE WHOLE STOREFRONT.
10
+ *
11
+ * Before this (2026-09-13) every area shipped its own English defaults and
12
+ * its own Bulgarian file, so localizing a store meant importing six packs
13
+ * and mounting four separate providers, and a global package shipped
14
+ * Bulgarian copy to every merchant on earth. Alexander's ruling: the
15
+ * library is international ENGLISH, and a language is a pack the store
16
+ * opts into.
17
+ *
18
+ * So: English is the library's own default and lives in each area's
19
+ * `labels.ts` beside its type. Every other language is a locale pack
20
+ * imported by subpath — `@cartbase/storefront/locales/es`,
21
+ * `/locales/bg` — and is typed against these six shapes, which means a
22
+ * missing translation is a COMPILE ERROR rather than a silent fall back to
23
+ * English in the middle of a Spanish checkout.
24
+ *
25
+ * Adding a language is one file in `src/locales/` plus its export path.
26
+ * Nothing else in the package changes, and no component knows a language
27
+ * exists.
28
+ */
29
+ export interface StorefrontLocale {
30
+ /** BCP 47 code, for the app's own persistence and for `<html lang>`. */
31
+ code: string
32
+ /** The language's own name, for a switcher that does not want Intl. */
33
+ name: string
34
+ products: ProductLabels
35
+ store: StoreLabels
36
+ cartDrawer: CartDrawerLabels
37
+ checkout: CheckoutLabels
38
+ order: OrderLabels
39
+ reviews: ReviewsUiLabels
40
+ }
41
+
42
+ /**
43
+ * THE AREAS WHOSE PACK THE APP MUST HAND OVER AS A PROP, and the prop is
44
+ * REQUIRED.
45
+ *
46
+ * Not a style choice and not a gap in this layer: a React SERVER component
47
+ * cannot read a client context, and these areas are rendered on the server.
48
+ * `StorefrontLocaleProvider` therefore reaches the client components and
49
+ * nothing else, and a server-rendered heading would stay English however
50
+ * many providers were mounted above it.
51
+ *
52
+ * Since 2026-09-14 the page-level templates of these areas REQUIRE the pack
53
+ * (`labels: StoreLabels`, never `labels?`), so a page that forgets it fails
54
+ * to compile instead of shipping silent English. That was the defect: on
55
+ * 2026-09-13 evoo, a Bulgarian store, ended a product page in the English
56
+ * "Related products / You might also want to check out these products", and
57
+ * its search page and order confirmation stayed English, with no error, no
58
+ * warning and no failing test. English is not a special case: an English
59
+ * store passes `en.store`. The scaffold declares `STORE_LOCALE` once in its
60
+ * config and every page reads its area from it.
61
+ *
62
+ * Hand the pack to each page-level template once and everything inside it
63
+ * follows:
64
+ *
65
+ * <StoreTemplate labels={STORE_LOCALE.store} />
66
+ * <SearchTemplate labels={STORE_LOCALE.store} />
67
+ * <CollectionTemplate labels={STORE_LOCALE.store} />
68
+ * <CategoryTemplate labels={STORE_LOCALE.store} />
69
+ * <ProductTemplate labels={STORE_LOCALE.products} /> // + the related strip
70
+ * <OrderCompletedTemplate labels={STORE_LOCALE.order} />
71
+ *
72
+ * The cart drawer and the reviews family were listed here until 2026-09-14.
73
+ * They are client components, so they now read the mounted language
74
+ * themselves (`useLocaleArea` in ./context); their `labels` prop is an
75
+ * override, never a requirement.
76
+ */
77
+ export type PropLabelAreas = Pick<StorefrontLocale, "products" | "store" | "order">
@@ -1,62 +1,62 @@
1
- /**
2
- * @cartbase/storefront/order — order confirmation + account order views.
3
- * Ported from `@1click/ui/src/order` (v2.3.1) with Cartbase data seams; see
4
- * per-module JSDoc and docs/storefront/components.md for the contracts.
5
- */
6
- export { OrderLabelsProvider, useOrderLabels } from "./context"
7
- export { defaultOrderLabels, type OrderLabels } from "./labels"
8
-
9
- export {
10
- OrderConfirmationHeader,
11
- type OrderConfirmationHeaderProps,
12
- type OrderHeaderData,
13
- } from "./order-confirmation-header"
14
- export {
15
- OrderItem,
16
- displayItemFromOrderItem,
17
- displayItemFromCartLine,
18
- variantLabelFrom,
19
- type OrderItemProps,
20
- type OrderDisplayItem,
21
- type CartLineLike,
22
- } from "./order-item"
23
- export { OrderItemsList, type OrderItemsListProps } from "./order-items-list"
24
- export {
25
- OrderTotals,
26
- selectOrderTotalsRows,
27
- orderTotalsFromSummary,
28
- type OrderTotalsProps,
29
- type OrderTotalsSource,
30
- type OrderTotalsRow,
31
- } from "./order-totals"
32
- export {
33
- OrderAddressCard,
34
- type OrderAddressCardProps,
35
- type OrderContactData,
36
- } from "./order-address-card"
37
- export {
38
- OrderDeliveryCard,
39
- pickTrackingLabels,
40
- type OrderDeliveryCardProps,
41
- type OrderDeliveryData,
42
- type ShippingMethodDisplay,
43
- type TrackingLabel,
44
- } from "./order-delivery-card"
45
- export {
46
- OrderPaymentCard,
47
- resolvePaymentTitle,
48
- type OrderPaymentCardProps,
49
- } from "./order-payment-card"
50
- export {
51
- OrderTimeline,
52
- deriveFulfillmentStatus,
53
- type OrderTimelineProps,
54
- } from "./order-timeline"
55
- export {
56
- OrderHelpSection,
57
- type OrderHelpSectionProps,
58
- } from "./order-help-section"
59
- export {
60
- OrderCompletedTemplate,
61
- type OrderCompletedTemplateProps,
62
- } from "./order-completed-template"
1
+ /**
2
+ * @cartbase/storefront/order — order confirmation + account order views.
3
+ * Ported from `@1click/ui/src/order` (v2.3.1) with Cartbase data seams; see
4
+ * per-module JSDoc and docs/storefront/components.md for the contracts.
5
+ */
6
+ export { OrderLabelsProvider, useOrderLabels } from "./context"
7
+ export { defaultOrderLabels, type OrderLabels } from "./labels"
8
+
9
+ export {
10
+ OrderConfirmationHeader,
11
+ type OrderConfirmationHeaderProps,
12
+ type OrderHeaderData,
13
+ } from "./order-confirmation-header"
14
+ export {
15
+ OrderItem,
16
+ displayItemFromOrderItem,
17
+ displayItemFromCartLine,
18
+ variantLabelFrom,
19
+ type OrderItemProps,
20
+ type OrderDisplayItem,
21
+ type CartLineLike,
22
+ } from "./order-item"
23
+ export { OrderItemsList, type OrderItemsListProps } from "./order-items-list"
24
+ export {
25
+ OrderTotals,
26
+ selectOrderTotalsRows,
27
+ orderTotalsFromSummary,
28
+ type OrderTotalsProps,
29
+ type OrderTotalsSource,
30
+ type OrderTotalsRow,
31
+ } from "./order-totals"
32
+ export {
33
+ OrderAddressCard,
34
+ type OrderAddressCardProps,
35
+ type OrderContactData,
36
+ } from "./order-address-card"
37
+ export {
38
+ OrderDeliveryCard,
39
+ pickTrackingLabels,
40
+ type OrderDeliveryCardProps,
41
+ type OrderDeliveryData,
42
+ type ShippingMethodDisplay,
43
+ type TrackingLabel,
44
+ } from "./order-delivery-card"
45
+ export {
46
+ OrderPaymentCard,
47
+ resolvePaymentTitle,
48
+ type OrderPaymentCardProps,
49
+ } from "./order-payment-card"
50
+ export {
51
+ OrderTimeline,
52
+ deriveFulfillmentStatus,
53
+ type OrderTimelineProps,
54
+ } from "./order-timeline"
55
+ export {
56
+ OrderHelpSection,
57
+ type OrderHelpSectionProps,
58
+ } from "./order-help-section"
59
+ export {
60
+ OrderCompletedTemplate,
61
+ type OrderCompletedTemplateProps,
62
+ } from "./order-completed-template"
@@ -1,79 +1,79 @@
1
- /**
2
- * Order family label pack. Ported from `@1click/ui/src/order/labels.ts`
3
- * (v2.3.1) unchanged, plus `tracking` — new in the Cartbase port because the
4
- * Cartbase order surface exposes fulfillment tracking labels
5
- * (`StoreOrderDetail.fulfillments[].fulfillment.labels`) that
6
- * `OrderDeliveryCard` now renders.
7
- */
8
- export type OrderLabels = {
9
- orderConfirmed: string
10
- confirmationSent: string
11
- orderNumber: string
12
- orderDate: string
13
- summary: string
14
- subtotal: string
15
- shipping: string
16
- discount: string
17
- tax: string
18
- total: string
19
- /** Default label for the cash-on-delivery fee row. Used as the third-
20
- * level fallback when neither a per-store override nor the server's
21
- * `payment_method_fee_label` / fee line title is available. */
22
- paymentMethodFee: string
23
- contactInfo: string
24
- delivery: string
25
- paymentMethod: string
26
- paymentMethodTitles: {
27
- card: string
28
- cod: string
29
- /** Offline manual payments (pp_manual) — NOT cash on delivery. */
30
- manual: string
31
- paypal: string
32
- }
33
- needHelp: string
34
- contactUs: string
35
- returnsExchanges: string
36
- orderPlaced: string
37
- processing: string
38
- shipped: string
39
- delivered: string
40
- free: string
41
- continueShopping: string
42
- qty: string
43
- /** Heading for the fulfillment tracking-numbers block (Cartbase addition). */
44
- tracking: string
45
- }
46
-
47
- export const defaultOrderLabels: OrderLabels = {
48
- orderConfirmed: "Order confirmed",
49
- confirmationSent: "We sent a confirmation to",
50
- orderNumber: "Order",
51
- orderDate: "Date",
52
- summary: "Order summary",
53
- subtotal: "Subtotal",
54
- shipping: "Shipping",
55
- discount: "Discount",
56
- tax: "Tax",
57
- total: "Total",
58
- paymentMethodFee: "Payment method fee",
59
- contactInfo: "Contact info",
60
- delivery: "Delivery",
61
- paymentMethod: "Payment method",
62
- paymentMethodTitles: {
63
- card: "Credit / debit card",
64
- cod: "Cash on delivery",
65
- manual: "Manual payment",
66
- paypal: "PayPal",
67
- },
68
- needHelp: "Need help?",
69
- contactUs: "Contact us",
70
- returnsExchanges: "Returns & exchanges",
71
- orderPlaced: "Placed",
72
- processing: "Processing",
73
- shipped: "Shipped",
74
- delivered: "Delivered",
75
- free: "FREE",
76
- continueShopping: "Continue shopping",
77
- qty: "qty.",
78
- tracking: "Tracking",
79
- }
1
+ /**
2
+ * Order family label pack. Ported from `@1click/ui/src/order/labels.ts`
3
+ * (v2.3.1) unchanged, plus `tracking` — new in the Cartbase port because the
4
+ * Cartbase order surface exposes fulfillment tracking labels
5
+ * (`StoreOrderDetail.fulfillments[].fulfillment.labels`) that
6
+ * `OrderDeliveryCard` now renders.
7
+ */
8
+ export type OrderLabels = {
9
+ orderConfirmed: string
10
+ confirmationSent: string
11
+ orderNumber: string
12
+ orderDate: string
13
+ summary: string
14
+ subtotal: string
15
+ shipping: string
16
+ discount: string
17
+ tax: string
18
+ total: string
19
+ /** Default label for the cash-on-delivery fee row. Used as the third-
20
+ * level fallback when neither a per-store override nor the server's
21
+ * `payment_method_fee_label` / fee line title is available. */
22
+ paymentMethodFee: string
23
+ contactInfo: string
24
+ delivery: string
25
+ paymentMethod: string
26
+ paymentMethodTitles: {
27
+ card: string
28
+ cod: string
29
+ /** Offline manual payments (pp_manual) — NOT cash on delivery. */
30
+ manual: string
31
+ paypal: string
32
+ }
33
+ needHelp: string
34
+ contactUs: string
35
+ returnsExchanges: string
36
+ orderPlaced: string
37
+ processing: string
38
+ shipped: string
39
+ delivered: string
40
+ free: string
41
+ continueShopping: string
42
+ qty: string
43
+ /** Heading for the fulfillment tracking-numbers block (Cartbase addition). */
44
+ tracking: string
45
+ }
46
+
47
+ export const defaultOrderLabels: OrderLabels = {
48
+ orderConfirmed: "Order confirmed",
49
+ confirmationSent: "We sent a confirmation to",
50
+ orderNumber: "Order",
51
+ orderDate: "Date",
52
+ summary: "Order summary",
53
+ subtotal: "Subtotal",
54
+ shipping: "Shipping",
55
+ discount: "Discount",
56
+ tax: "Tax",
57
+ total: "Total",
58
+ paymentMethodFee: "Payment method fee",
59
+ contactInfo: "Contact info",
60
+ delivery: "Delivery",
61
+ paymentMethod: "Payment method",
62
+ paymentMethodTitles: {
63
+ card: "Credit / debit card",
64
+ cod: "Cash on delivery",
65
+ manual: "Manual payment",
66
+ paypal: "PayPal",
67
+ },
68
+ needHelp: "Need help?",
69
+ contactUs: "Contact us",
70
+ returnsExchanges: "Returns & exchanges",
71
+ orderPlaced: "Placed",
72
+ processing: "Processing",
73
+ shipped: "Shipped",
74
+ delivered: "Delivered",
75
+ free: "FREE",
76
+ continueShopping: "Continue shopping",
77
+ qty: "qty.",
78
+ tracking: "Tracking",
79
+ }