@cartbase/storefront 0.17.0 → 0.18.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.
Files changed (107) hide show
  1. package/LICENSE +21 -21
  2. package/package.json +258 -256
  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/products.ts +43 -1
  18. package/src/api/redirects.ts +37 -37
  19. package/src/api/regions.ts +200 -200
  20. package/src/api/reviews.ts +259 -259
  21. package/src/api/search.ts +163 -163
  22. package/src/api/store.ts +35 -35
  23. package/src/api/types.ts +91 -91
  24. package/src/cart-drawer/context.tsx +277 -164
  25. package/src/cart-drawer/cross-sell-carousel.tsx +211 -211
  26. package/src/cart-drawer/cross-sell-sidebar.tsx +158 -158
  27. package/src/cart-drawer/gift-wrap.tsx +82 -82
  28. package/src/cart-drawer/index.ts +71 -68
  29. package/src/cart-drawer/item/index.tsx +162 -162
  30. package/src/cart-drawer/item/quantity.tsx +8 -14
  31. package/src/cart-drawer/item/upsell.tsx +110 -110
  32. package/src/cart-drawer/labels.ts +123 -123
  33. package/src/cart-drawer/mutation-queue.ts +78 -0
  34. package/src/cart-drawer/notes.tsx +131 -131
  35. package/src/cart-drawer/sticky-footer.tsx +73 -73
  36. package/src/cart-drawer/summary-breakdown.tsx +197 -197
  37. package/src/checkout/address-error-copy.ts +117 -117
  38. package/src/checkout/boxnow-locker-selector.tsx +410 -410
  39. package/src/checkout/compare-addresses.ts +40 -40
  40. package/src/checkout/discount-section.tsx +218 -218
  41. package/src/checkout/error-copy-codes.ts +63 -63
  42. package/src/checkout/geocode.ts +154 -154
  43. package/src/checkout/gift-card-section.tsx +224 -224
  44. package/src/checkout/index.ts +72 -72
  45. package/src/checkout/labels.ts +495 -495
  46. package/src/checkout/payment-button.tsx +372 -372
  47. package/src/checkout/payment-error-copy.ts +154 -154
  48. package/src/checkout/promotion-error-copy.ts +91 -91
  49. package/src/checkout/use-checkout-orchestration.ts +1592 -1592
  50. package/src/common/country-flag.tsx +52 -52
  51. package/src/common/country-select.tsx +11 -11
  52. package/src/common/index.ts +20 -20
  53. package/src/common/market-select.tsx +57 -57
  54. package/src/index.ts +12 -12
  55. package/src/lib/country-name.ts +59 -59
  56. package/src/lib/get-product-price.ts +133 -133
  57. package/src/lib/media-image.tsx +39 -39
  58. package/src/lib/payment-constants.ts +53 -53
  59. package/src/lib/platform.ts +13 -13
  60. package/src/lib/price.tsx +39 -39
  61. package/src/lib/store-api-error.ts +36 -36
  62. package/src/lib/variant-caption.ts +32 -32
  63. package/src/locales/bg.ts +467 -467
  64. package/src/locales/context.ts +37 -37
  65. package/src/locales/en.ts +26 -26
  66. package/src/locales/es.ts +466 -466
  67. package/src/locales/index.ts +19 -19
  68. package/src/locales/provider.tsx +59 -59
  69. package/src/locales/types.ts +77 -77
  70. package/src/order/index.ts +62 -62
  71. package/src/order/labels.ts +79 -79
  72. package/src/order/order-totals.tsx +250 -250
  73. package/src/primitives/select-field.tsx +93 -93
  74. package/src/products/image-gallery.tsx +43 -43
  75. package/src/products/index.ts +68 -59
  76. package/src/products/option-select.tsx +67 -67
  77. package/src/products/product-actions-wrapper.tsx +63 -62
  78. package/src/products/product-actions.tsx +151 -150
  79. package/src/products/product-price.tsx +69 -69
  80. package/src/products/product-promises.tsx +61 -61
  81. package/src/products/product-specs.tsx +65 -65
  82. package/src/products/product-tabs.tsx +123 -123
  83. package/src/products/product-template.tsx +163 -162
  84. package/src/products/purchase-options.tsx +130 -130
  85. package/src/products/sets.ts +110 -0
  86. package/src/products/use-product-actions.ts +199 -164
  87. package/src/products/variant-matching.ts +71 -71
  88. package/src/products/variant-url.ts +74 -74
  89. package/src/reviews-ui/index.ts +73 -73
  90. package/src/store/category-template.tsx +136 -136
  91. package/src/store/index.ts +40 -40
  92. package/src/tracking/chatgpt-pixel.tsx +99 -99
  93. package/src/tracking/consent-init.tsx +62 -62
  94. package/src/tracking/events.ts +348 -348
  95. package/src/tracking/ga4.tsx +93 -93
  96. package/src/tracking/google-ads.ts +84 -84
  97. package/src/tracking/gtm.tsx +60 -60
  98. package/src/tracking/inline-script.ts +49 -49
  99. package/src/tracking/oaiq.ts +206 -206
  100. package/src/tracking/tiktok-pixel.tsx +91 -91
  101. package/src/tracking/track-init.tsx +56 -56
  102. package/src/tracking/track-order-purchase.tsx +122 -122
  103. package/src/tracking/ttq.ts +180 -180
  104. package/src/tracking/use-tracking-config.ts +54 -54
  105. package/theme/index.css +25 -25
  106. package/theme/theme.css +150 -150
  107. package/theme/tokens.css +106 -106
@@ -1,37 +1,37 @@
1
- "use client"
2
-
3
- import { createContext, useContext } from "react"
4
- import type { StorefrontLocale } from "./types"
5
-
6
- /**
7
- * THE MOUNTED LANGUAGE, as a context. Null outside `StorefrontLocaleProvider`.
8
- *
9
- * Its default is null and not `en` on purpose: `en` gathers every area's
10
- * English, and a client component that needs one area (the cart drawer, a
11
- * review card) must not bundle the other five to read it. Each reader hands
12
- * over its own area's English instead, through `useLocaleArea`, so a
13
- * component rendered with no language mounted behaves exactly as before.
14
- */
15
- export const StorefrontLocaleContext = createContext<StorefrontLocale | null>(null)
16
-
17
- /**
18
- * One area of the mounted language, for a CLIENT component that renders it.
19
- *
20
- * const l = { ...useLocaleArea("reviews", defaultReviewsUiLabels), ...labels }
21
- *
22
- * The pack the store mounted wins over the area's English; a `labels` prop
23
- * still wins over both, so a store can override one word without a pack.
24
- * Since 2026-09-14 this is how the cart drawer and the reviews family are
25
- * localized: mount the provider once and there is nothing left to forget.
26
- *
27
- * A SERVER component cannot call this, because a server component has no
28
- * context. That is why the store, product and order templates take their
29
- * pack as a REQUIRED prop instead (`PropLabelAreas` in ./types).
30
- */
31
- export function useLocaleArea<K extends keyof StorefrontLocale>(
32
- area: K,
33
- english: StorefrontLocale[K]
34
- ): StorefrontLocale[K] {
35
- const locale = useContext(StorefrontLocaleContext)
36
- return locale ? locale[area] : english
37
- }
1
+ "use client"
2
+
3
+ import { createContext, useContext } from "react"
4
+ import type { StorefrontLocale } from "./types"
5
+
6
+ /**
7
+ * THE MOUNTED LANGUAGE, as a context. Null outside `StorefrontLocaleProvider`.
8
+ *
9
+ * Its default is null and not `en` on purpose: `en` gathers every area's
10
+ * English, and a client component that needs one area (the cart drawer, a
11
+ * review card) must not bundle the other five to read it. Each reader hands
12
+ * over its own area's English instead, through `useLocaleArea`, so a
13
+ * component rendered with no language mounted behaves exactly as before.
14
+ */
15
+ export const StorefrontLocaleContext = createContext<StorefrontLocale | null>(null)
16
+
17
+ /**
18
+ * One area of the mounted language, for a CLIENT component that renders it.
19
+ *
20
+ * const l = { ...useLocaleArea("reviews", defaultReviewsUiLabels), ...labels }
21
+ *
22
+ * The pack the store mounted wins over the area's English; a `labels` prop
23
+ * still wins over both, so a store can override one word without a pack.
24
+ * Since 2026-09-14 this is how the cart drawer and the reviews family are
25
+ * localized: mount the provider once and there is nothing left to forget.
26
+ *
27
+ * A SERVER component cannot call this, because a server component has no
28
+ * context. That is why the store, product and order templates take their
29
+ * pack as a REQUIRED prop instead (`PropLabelAreas` in ./types).
30
+ */
31
+ export function useLocaleArea<K extends keyof StorefrontLocale>(
32
+ area: K,
33
+ english: StorefrontLocale[K]
34
+ ): StorefrontLocale[K] {
35
+ const locale = useContext(StorefrontLocaleContext)
36
+ return locale ? locale[area] : english
37
+ }
package/src/locales/en.ts CHANGED
@@ -1,26 +1,26 @@
1
- import { defaultCartDrawerLabels } from "../cart-drawer/labels"
2
- import { defaultCheckoutLabels } from "../checkout/labels"
3
- import { defaultOrderLabels } from "../order/labels"
4
- import { defaultProductLabels } from "../products/labels"
5
- import { defaultReviewsUiLabels } from "../reviews-ui/labels"
6
- import { defaultStoreLabels } from "../store/labels"
7
- import type { StorefrontLocale } from "./types"
8
-
9
- /**
10
- * ENGLISH — the library's own default, gathered into one locale object.
11
- *
12
- * It holds NO copy of its own: every field points at the defaults that
13
- * live beside each area's type, which are what a component renders when no
14
- * provider is mounted. So English cannot drift from the library, and a new
15
- * label added to any area appears here with no edit.
16
- */
17
- export const en: StorefrontLocale = {
18
- code: "en",
19
- name: "English",
20
- products: defaultProductLabels,
21
- store: defaultStoreLabels,
22
- cartDrawer: defaultCartDrawerLabels,
23
- checkout: defaultCheckoutLabels,
24
- order: defaultOrderLabels,
25
- reviews: defaultReviewsUiLabels,
26
- }
1
+ import { defaultCartDrawerLabels } from "../cart-drawer/labels"
2
+ import { defaultCheckoutLabels } from "../checkout/labels"
3
+ import { defaultOrderLabels } from "../order/labels"
4
+ import { defaultProductLabels } from "../products/labels"
5
+ import { defaultReviewsUiLabels } from "../reviews-ui/labels"
6
+ import { defaultStoreLabels } from "../store/labels"
7
+ import type { StorefrontLocale } from "./types"
8
+
9
+ /**
10
+ * ENGLISH — the library's own default, gathered into one locale object.
11
+ *
12
+ * It holds NO copy of its own: every field points at the defaults that
13
+ * live beside each area's type, which are what a component renders when no
14
+ * provider is mounted. So English cannot drift from the library, and a new
15
+ * label added to any area appears here with no edit.
16
+ */
17
+ export const en: StorefrontLocale = {
18
+ code: "en",
19
+ name: "English",
20
+ products: defaultProductLabels,
21
+ store: defaultStoreLabels,
22
+ cartDrawer: defaultCartDrawerLabels,
23
+ checkout: defaultCheckoutLabels,
24
+ order: defaultOrderLabels,
25
+ reviews: defaultReviewsUiLabels,
26
+ }