@cartbase/storefront 0.14.0 → 0.16.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 (46) hide show
  1. package/README.md +9 -3
  2. package/package.json +4 -1
  3. package/src/api/customers.ts +9 -13
  4. package/src/api/products.ts +330 -310
  5. package/src/cart-drawer/context.tsx +11 -1
  6. package/src/cart-drawer/item/variant.tsx +8 -3
  7. package/src/checkout/checkout-client.tsx +10 -1
  8. package/src/checkout/line-item-card.tsx +5 -2
  9. package/src/checkout/order-summary.tsx +9 -5
  10. package/src/common/country-select.tsx +11 -65
  11. package/src/common/index.ts +2 -0
  12. package/src/common/market-select.tsx +57 -0
  13. package/src/lib/variant-caption.ts +32 -0
  14. package/src/locales/bg.ts +3 -0
  15. package/src/locales/context.ts +37 -0
  16. package/src/locales/es.ts +3 -0
  17. package/src/locales/provider.tsx +17 -21
  18. package/src/locales/types.ts +24 -21
  19. package/src/order/order-completed-template.tsx +10 -4
  20. package/src/order/order-item.tsx +4 -4
  21. package/src/products/index.ts +14 -0
  22. package/src/products/labels.ts +7 -0
  23. package/src/products/product-actions-wrapper.tsx +62 -58
  24. package/src/products/product-actions.tsx +104 -177
  25. package/src/products/product-info.tsx +10 -5
  26. package/src/products/product-template.tsx +162 -147
  27. package/src/products/related-products.tsx +9 -9
  28. package/src/products/use-product-actions.ts +164 -0
  29. package/src/products/variant-url.ts +74 -0
  30. package/src/reviews-ui/photo-upload.tsx +2 -1
  31. package/src/reviews-ui/review-list.tsx +4 -2
  32. package/src/reviews-ui/review-widget.tsx +4 -1
  33. package/src/reviews-ui/review-wizard.tsx +3 -2
  34. package/src/store/category-template.tsx +8 -1
  35. package/src/store/collection-template.tsx +8 -1
  36. package/src/store/paginated-products.tsx +3 -2
  37. package/src/store/search-template.tsx +10 -4
  38. package/src/store/store-template.tsx +10 -4
  39. package/src/tracking/chatgpt-pixel.tsx +17 -10
  40. package/src/tracking/consent-init.tsx +62 -44
  41. package/src/tracking/consent.ts +58 -7
  42. package/src/tracking/index.ts +2 -0
  43. package/src/tracking/meta-pixel.tsx +27 -15
  44. package/src/tracking/storefront-tags.tsx +14 -7
  45. package/src/tracking/tiktok-pixel.tsx +15 -7
  46. package/src/tracking/types.ts +5 -2
package/README.md CHANGED
@@ -42,6 +42,7 @@ NEXT_PUBLIC_CARTBASE_URL= # optional: only to point at a local or s
42
42
  | `@cartbase/storefront/store` | Listing pages: pagination, sorting, collection/category/search templates |
43
43
  | `@cartbase/storefront/order` | Order confirmation surfaces |
44
44
  | `@cartbase/storefront/tracking` | Consent banner and Consent Mode v2, every marketing tag the store configured mounted from its own config (Meta Pixel, TikTok, Google Analytics 4 and Google Ads on one tag, Google Tag Manager), and one call per commerce moment that fires all of them |
45
+ | `@cartbase/storefront/locales` | English built in; Spanish and Bulgarian as typed packs. One provider mounts the language for every client component; the server-rendered templates take their area of the pack as a required prop |
45
46
  | `@cartbase/storefront/theme` | The design system: token names plus a filled default set of values (Tailwind 4, CSS-first) |
46
47
 
47
48
  ### Tracking, in three lines
@@ -50,11 +51,16 @@ The merchant configures their pixels in the admin; the storefront mounts
50
51
  what they configured. Nothing per vendor:
51
52
 
52
53
  ```tsx
53
- <ConsentInit /> // first child of <body>, sets the consent defaults
54
- <StorefrontTags client={client} /> // every configured tag, gated by the above
55
- <TrackInit /> // captures UTMs + ad-click ids on the landing page
54
+ <ConsentInit required={consent.enabled} /> // first child of <body>, sets the consent defaults
55
+ <StorefrontTags client={client} /> // every configured tag, gated by the above
56
+ <TrackInit /> // captures UTMs + ad-click ids on the landing page
56
57
  ```
57
58
 
59
+ `consent.enabled` is the store's own switch (`GET /api/store/consent`): a
60
+ store that collects consent starts every visitor denied until they choose
61
+ on the banner; a store with the banner off starts them granted and the
62
+ pixels fire. The prop is required, so a layout cannot leave it out.
63
+
58
64
  Then one call per moment (`trackProductView`, `trackCartAdd`,
59
65
  `trackCheckoutStart`) and `<TrackOrderPurchase>` on the confirmation
60
66
  page. Purchase events dedupe against the platform's own server-side
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cartbase/storefront",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "Storefront SDK + UI component library for Cartbase stores: typed API client, checkout orchestration, cart drawer, product/catalog components, tracking. Source-shipped TypeScript — add it to transpilePackages.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -155,6 +155,8 @@
155
155
  "./products/product-price": "./src/products/product-price.tsx",
156
156
  "./products/option-select": "./src/products/option-select.tsx",
157
157
  "./products/image-gallery": "./src/products/image-gallery.tsx",
158
+ "./products/variant-url": "./src/products/variant-url.ts",
159
+ "./products/use-product-actions": "./src/products/use-product-actions.ts",
158
160
  "./products/product-actions": "./src/products/product-actions.tsx",
159
161
  "./products/mobile-actions": "./src/products/mobile-actions.tsx",
160
162
  "./products/product-tabs": "./src/products/product-tabs.tsx",
@@ -194,6 +196,7 @@
194
196
  "./common/cart-button-client": "./src/common/cart-button-client.tsx",
195
197
  "./common/delete-button": "./src/common/delete-button.tsx",
196
198
  "./common/country-flag": "./src/common/country-flag.tsx",
199
+ "./common/market-select": "./src/common/market-select.tsx",
197
200
  "./common/country-select": "./src/common/country-select.tsx",
198
201
  "./common/language-select": "./src/common/language-select.tsx",
199
202
  "./common/skeleton": "./src/common/skeleton.tsx",
@@ -18,10 +18,9 @@
18
18
  import type { StorefrontClient } from "./http"
19
19
  import type { IsoDateString, PaginationQuery } from "./types"
20
20
 
21
- /** One row of `customer.addresses` (barter_commerce.customer_addresses). */
21
+ /** One row of `customer.addresses` (barter_commerce.customer_addresses), as the store serves it. */
22
22
  export interface CustomerAddress {
23
23
  id: string
24
- client_id: string
25
24
  customer_id: string
26
25
  address_name: string | null
27
26
  first_name: string | null
@@ -39,18 +38,19 @@ export interface CustomerAddress {
39
38
  metadata: Record<string, unknown> | null
40
39
  created_at: IsoDateString
41
40
  updated_at: IsoDateString
42
- deleted_at: IsoDateString | null
43
41
  }
44
42
 
45
43
  /**
46
- * The customer payload (full barter_commerce.customers row + addresses).
44
+ * The customer payload: the customer's own row as the store serves it, plus
45
+ * addresses. Named columns since 2026-09-14: no tenant id, no soft-delete
46
+ * stamp, no staff identity, no provider account id, and no merchant tags
47
+ * (the labels a merchant puts on a customer are staff knowledge and never
48
+ * reach the shopper).
47
49
  * `account_status` (`pending` | `approved`) gates B2B storefront content
48
- * when the store's approval policy is on (b2b-v1). `tags` are admin-only
49
- * labels — readable here, never writable from the store surface.
50
+ * when the store's approval policy is on (b2b-v1).
50
51
  */
51
52
  export interface StoreCustomer {
52
53
  id: string
53
- client_id: string
54
54
  email: string | null
55
55
  first_name: string | null
56
56
  last_name: string | null
@@ -62,12 +62,9 @@ export interface StoreCustomer {
62
62
  has_account: boolean
63
63
  /** `pending` | `approved` — store approval policy (customer-accounts card). */
64
64
  account_status: string
65
- tags: string[]
66
65
  metadata: Record<string, unknown> | null
67
- created_by: string | null
68
66
  created_at: IsoDateString
69
67
  updated_at: IsoDateString
70
- deleted_at: IsoDateString | null
71
68
  addresses: CustomerAddress[]
72
69
  }
73
70
 
@@ -123,12 +120,11 @@ export interface UpdateCustomerInput {
123
120
  company_eik?: string | null
124
121
  vat_number?: string | null
125
122
  metadata?: Record<string, unknown>
126
- // NOTE: `tags` deliberately absent — admin-only; the server strips them.
127
123
  }
128
124
 
129
125
  /**
130
- * POST /api/store/customers/me — update own profile. Unknown keys (incl.
131
- * `tags`) are stripped server-side; returns the refreshed customer.
126
+ * POST /api/store/customers/me — update own profile. Unknown keys are
127
+ * stripped server-side; returns the refreshed customer.
132
128
  *
133
129
  * Auth: Bearer JWT (+ x-client-id).
134
130
  * Errors: 401 unauthenticated · 400 validation_failed.