@shoppexio/storefront-react 0.0.0 → 0.1.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 (60) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/LICENSE +21 -0
  3. package/README.md +215 -0
  4. package/dist/account.css +1171 -0
  5. package/dist/account.d.ts +23 -0
  6. package/dist/account.js +12685 -0
  7. package/dist/account.js.map +1 -0
  8. package/dist/chunk-D6XKDVAV.js +181 -0
  9. package/dist/chunk-D6XKDVAV.js.map +1 -0
  10. package/dist/index.d.ts +3087 -0
  11. package/dist/index.js +2801 -0
  12. package/dist/index.js.map +1 -0
  13. package/eject/account/account-availability.ts +171 -0
  14. package/eject/account/account-downloads.ts +118 -0
  15. package/eject/account/account-favorites.ts +99 -0
  16. package/eject/account/account-loyalty.ts +241 -0
  17. package/eject/account/account-page.tsx +410 -0
  18. package/eject/account/account-payment-method.ts +99 -0
  19. package/eject/account/account-referrals.ts +68 -0
  20. package/eject/account/account-reseller-invite.ts +88 -0
  21. package/eject/account/account-reseller.ts +685 -0
  22. package/eject/account/account-rewards.ts +104 -0
  23. package/eject/account/account-settings.ts +181 -0
  24. package/eject/account/account-signin-link.ts +122 -0
  25. package/eject/account/account-subscriptions.ts +130 -0
  26. package/eject/account/account-support.ts +155 -0
  27. package/eject/account/account-warranties.ts +118 -0
  28. package/eject/account/customer-account.ts +93 -0
  29. package/eject/account/dashboard.tsx +139 -0
  30. package/eject/account/downloads.tsx +343 -0
  31. package/eject/account/favorites.tsx +201 -0
  32. package/eject/account/i18n.ts +175 -0
  33. package/eject/account/icons.tsx +218 -0
  34. package/eject/account/login.tsx +253 -0
  35. package/eject/account/messages/ar.json +464 -0
  36. package/eject/account/messages/de.json +464 -0
  37. package/eject/account/messages/en.json +464 -0
  38. package/eject/account/messages/es.json +464 -0
  39. package/eject/account/messages/fi.json +464 -0
  40. package/eject/account/messages/fr.json +464 -0
  41. package/eject/account/messages/hi.json +464 -0
  42. package/eject/account/messages/it.json +464 -0
  43. package/eject/account/messages/lt.json +464 -0
  44. package/eject/account/messages/nl.json +464 -0
  45. package/eject/account/messages/pl.json +464 -0
  46. package/eject/account/messages/pt.json +464 -0
  47. package/eject/account/messages/ru.json +464 -0
  48. package/eject/account/messages/tr.json +464 -0
  49. package/eject/account/messages/uk.json +464 -0
  50. package/eject/account/messages/zh.json +464 -0
  51. package/eject/account/orders.tsx +791 -0
  52. package/eject/account/overview.tsx +147 -0
  53. package/eject/account/referrals.tsx +327 -0
  54. package/eject/account/reseller.tsx +1365 -0
  55. package/eject/account/rewards.tsx +641 -0
  56. package/eject/account/settings.tsx +699 -0
  57. package/eject/account/shared.tsx +398 -0
  58. package/eject/account/subscriptions.tsx +421 -0
  59. package/eject/account/support.tsx +453 -0
  60. package/package.json +79 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## 0.1.1
4
+
5
+ - README rewritten for theme developers: install, quick start, theming,
6
+ eject and links. Package metadata: support contact and keywords.
7
+
8
+ ## 0.1.0
9
+
10
+ - First release. The commerce layer of the Shoppex code templates (SDK access,
11
+ payload parsing, storefront context, cart and quotes, catalog and product
12
+ models, checkout fields, reviews, shop pages, menus, contact, merchant HTML)
13
+ and the customer account (`@shoppexio/storefront-react/account`) with its
14
+ message catalogs for sixteen locales. The account is styled only through the
15
+ host theme's `--sx-*` custom properties and ships as plain CSS
16
+ (`@shoppexio/storefront-react/account.css`). See ADR-0068.
17
+ - Physical products: `PHYSICAL` product type, `resolveDeliveryPromise()`
18
+ (`shipped` / `timed` / `instant`), `requiresShipping` on the cart context
19
+ from the quote's `requires_shipping`, and copy for the
20
+ `errors.checkout.shop_does_not_ship` refusal.
21
+ - `formatMoney` drops zero cents on whole amounts (`$49`, `$49.50`); a
22
+ currency's own decimals are kept for every other amount.
23
+ - Shop reviews carry `productTitle` and `verified`; `reviewsForProduct()`
24
+ narrows the feed to one product by title (the public feed has no product
25
+ ids, so the result is a sample, never a count).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shoppex
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,215 @@
1
+ # @shoppexio/storefront-react
2
+
3
+ React hooks, models and a ready-made customer account for Shoppex code
4
+ storefronts. A code storefront is a shop front you write yourself in React and
5
+ Vite; Shoppex builds it, serves it on the shop's domain and runs checkout. This
6
+ package handles the commerce part (catalog, product pages, cart, reviews, the
7
+ signed-in customer area), so your code is the design.
8
+
9
+ ## Install
10
+
11
+ ```sh
12
+ npm install @shoppexio/storefront-react
13
+ bun add @shoppexio/storefront-react
14
+ pnpm add @shoppexio/storefront-react
15
+ ```
16
+
17
+ Peer dependencies: `react` and `react-dom` 19.2, `react-router-dom` 7.18.
18
+
19
+ The package reads what Shoppex puts on the page before your bundle runs: the
20
+ Storefront SDK as `window.shoppex` (a script tag in your `index.html`) and the
21
+ shop's catalog and settings as `window.__SHOPPEX_INITIAL__`. It does not bundle
22
+ the SDK, and it throws a clear error when either is missing.
23
+
24
+ ## Quick start
25
+
26
+ ```tsx
27
+ // main.tsx
28
+ import { createRoot } from 'react-dom/client';
29
+ import { BrowserRouter, Route, Routes } from 'react-router-dom';
30
+ import {
31
+ ACCOUNT_PATH,
32
+ CartProvider,
33
+ formatMoney,
34
+ readStorefrontData,
35
+ StorefrontProvider,
36
+ useCart,
37
+ useStorefront,
38
+ } from '@shoppexio/storefront-react';
39
+ import { AccountPage } from '@shoppexio/storefront-react/account';
40
+ import '@shoppexio/storefront-react/account.css';
41
+
42
+ function Shelf() {
43
+ const { catalog } = useStorefront();
44
+ const { add, count, busy } = useCart();
45
+ return (
46
+ <main>
47
+ <p>{count} in cart</p>
48
+ {catalog.products.map((product) => (
49
+ <button
50
+ key={product.id}
51
+ disabled={busy}
52
+ onClick={() => add(product, product.priceVariants[0] ?? null, product.quantityMin)}
53
+ >
54
+ {product.name}, {formatMoney(product.price, product.currency)}
55
+ </button>
56
+ ))}
57
+ </main>
58
+ );
59
+ }
60
+
61
+ createRoot(document.getElementById('root')!).render(
62
+ <StorefrontProvider data={readStorefrontData()}>
63
+ <CartProvider>
64
+ <BrowserRouter>
65
+ <Routes>
66
+ <Route path="/" element={<Shelf />} />
67
+ <Route path={`${ACCOUNT_PATH}/*`} element={<AccountPage frame={({ children }) => <>{children}</>} notFound={<p>Not found</p>} />} />
68
+ </Routes>
69
+ </BrowserRouter>
70
+ </CartProvider>
71
+ </StorefrontProvider>,
72
+ );
73
+ ```
74
+
75
+ `useCart()` also gives you line updates, coupons, the live quote and
76
+ `checkout()`, which sends the buyer to Shoppex checkout. Load the account with
77
+ `import()` in a real theme so it stays out of your main bundle.
78
+
79
+ ## Features
80
+
81
+ - Catalog: product and bundle cards, categories, sorting, filtering, paging.
82
+ - Product pages: options, pricing per quantity, stock, badges, videos, the
83
+ rating breakdown.
84
+ - Cart: add, update, remove, coupons, quotes from the server, checkout
85
+ hand-off, per-product checkout fields.
86
+ - Reviews, shop pages, navigation menus and the contact form, from the SDK.
87
+ - Merchant rich text, sanitized before you render it.
88
+ - The customer account: sign-in, orders, downloads and keys, subscriptions,
89
+ rewards, referrals, reseller, support tickets and settings, in sixteen
90
+ languages.
91
+ - Money formatting: `$49`, `$49.50`, `¥1,200`.
92
+
93
+ ## Theming the account
94
+
95
+ The account has no look of its own. `account.css` reads your theme's `--sx-*`
96
+ custom properties, so it takes your colours, type, radii and shadows in light
97
+ and dark mode. Define the tokens once:
98
+
99
+ ```css
100
+ :root {
101
+ --sx-bg: #0a0b0e;
102
+ --sx-surface: #111318;
103
+ --sx-accent: #3b5bf0;
104
+ --sx-on-accent: #ffffff;
105
+ --sx-radius-card: 16px;
106
+ /* the full list is below */
107
+ }
108
+ ```
109
+
110
+ To change one part, target its `sx-account-*` hook under `.sx-account`. Two
111
+ classes beat the account's one-class utilities:
112
+
113
+ ```css
114
+ .sx-account .sx-account-card { border-radius: 0; box-shadow: none; }
115
+ .sx-account .sx-account-nav-link[aria-current='page'] { text-decoration: underline; }
116
+ ```
117
+
118
+ The account's own classes carry an `sxa:` prefix, so they never collide with
119
+ yours, and nothing in the stylesheet selects your elements.
120
+
121
+ ## Eject
122
+
123
+ When tokens and hooks are not enough and you want to own the account's markup,
124
+ copy it into your project:
125
+
126
+ 1. Copy `node_modules/@shoppexio/storefront-react/eject/account/` to
127
+ `src/account/`. Its imports already point at `@shoppexio/storefront-react`.
128
+ 2. Import `AccountPage` from `./account/account-page` instead of
129
+ `@shoppexio/storefront-react/account`.
130
+ 3. Keep importing `@shoppexio/storefront-react/account.css`; it styles the
131
+ classes the copied markup carries.
132
+
133
+ From then on the account is yours, and package updates no longer change it.
134
+ Most themes never need this.
135
+
136
+ ## Links
137
+
138
+ - Docs: [Code storefront development](https://docs.shoppex.io/storefront/code-storefront-development),
139
+ [Customer accounts](https://docs.shoppex.io/storefront/code-storefront-accounts)
140
+ - Example: the ForkMe template, a complete storefront built on this package.
141
+ Create a storefront from it in the Shoppex dashboard under
142
+ **Store → Storefronts**; see [Code storefronts](https://docs.shoppex.io/storefront/code-storefronts).
143
+ - [Changelog](./CHANGELOG.md)
144
+ - License: MIT
145
+
146
+ ## Reference
147
+
148
+ ### Entries
149
+
150
+ | Import | What it is |
151
+ |---|---|
152
+ | `@shoppexio/storefront-react` | Logic, renders nothing (see the map below) |
153
+ | `@shoppexio/storefront-react/account` | `AccountPage`, the whole customer account |
154
+ | `@shoppexio/storefront-react/account.css` | The account's stylesheet, plain CSS |
155
+
156
+ #### The root: where to start
157
+
158
+ | Module | Use it for | Start with |
159
+ |---|---|---|
160
+ | SDK access | The SDK global, fail-fast when it is missing, affiliate capture | `getShoppex()`, `getBuyerCurrency()`, `SERVING_CONTEXT_HINT` |
161
+ | Payload | Parsing the injected payload: products, groups, categories, shop, settings, stock, licence terms | `getProducts()`, `getStorefrontShop()`, `getStorefrontSettings()`, `hasInjectedStorefrontData()` |
162
+ | Context | One parse at boot, read anywhere | `readStorefrontData()`, `<StorefrontProvider>`, `useStorefront()`, `useOnlineUserCount()` |
163
+ | Catalog | Cards, sort, filter, pagination, money | `buildStorefrontCatalog()`, `sortCatalogCards()`, `filterCatalogCards()`, `formatMoney()` |
164
+ | Product | The product page model: variants, rating, pricing, quantity bounds, badges, videos | `buildProductDetail()`, `calculateLinePricing()`, `badgesForProductPage()` |
165
+ | Cart | Cart state, quotes, coupons, checkout hand-off | `<CartProvider>`, `useCart()`, `buildCartView()`, `buildCartTotals()` |
166
+ | Checkout fields | Per-product fields a buyer fills before checkout | `resolveCheckoutFields()`, `readCheckoutNeedsDetails()` |
167
+ | Reviews, pages, menus, contact | SDK-backed hooks | `useShopReviews()`, `loadShopPage()`, `useNavigationLinks()`, `submitContactTicket()` |
168
+ | Merchant HTML | Sanitizing and flattening merchant rich text | `sanitizeMerchantHtml()`, `flattenMerchantHtmlToText()` |
169
+ | Account routing | Mounting the account and its lazy chunk | `ACCOUNT_PATH`, `ACCOUNT_PATH_ALIAS`, `accountRouteMessage()`, `ACCOUNT_STOREFRONT_ROUTES`, `ACCOUNT_ARTIFACT_CAPABILITIES` |
170
+
171
+ The `.d.ts` files next to the JS are the reference; every export carries its
172
+ contract in its doc comment.
173
+
174
+ ### Account routing
175
+
176
+ - Mount the account under `${ACCOUNT_PATH}/*` and `${ACCOUNT_PATH_ALIAS}/*`.
177
+ - Route every path in `ACCOUNT_STOREFRONT_ROUTES`; the account links to them.
178
+ - List every entry of `ACCOUNT_ARTIFACT_CAPABILITIES` in
179
+ `public/shoppex.capabilities.json`.
180
+ - The account reads its language from `<html lang>`, which Shoppex sets.
181
+
182
+ ### Account hooks
183
+
184
+ Hooks carry no styles:
185
+
186
+ `sx-account` (root), `sx-account-header`, `sx-account-title`,
187
+ `sx-account-signout`, `sx-account-nav`, `sx-account-nav-link`,
188
+ `sx-account-panel` (with `data-sx-account-view="<tab>"`), `sx-account-card`,
189
+ `sx-account-section-title`, `sx-account-empty`, `sx-account-error`,
190
+ `sx-account-notice`, `sx-account-skeleton`, `sx-account-back`,
191
+ `sx-account-button`, `sx-account-cta`, `sx-account-copy`, `sx-account-chip`,
192
+ `sx-account-status`, `sx-account-field`, `sx-account-label`,
193
+ `sx-account-field-error`.
194
+
195
+ `.sx-account` also scopes a zero-specificity baseline (box sizing, border
196
+ reset, heading font) for themes without a CSS reset. The stylesheet uses no
197
+ cascade layer: a one-class `sxa:` rule beats your element resets, and a rule of
198
+ yours scoped under `.sx-account` beats it.
199
+
200
+ ### CSS custom properties
201
+
202
+ A theme defines every one of these.
203
+
204
+ <!-- css-contract:start -->
205
+
206
+ | Group | Properties |
207
+ |---|---|
208
+ | Colour | `--sx-bg`, `--sx-surface`, `--sx-surface-raised`, `--sx-heading`, `--sx-text`, `--sx-muted`, `--sx-line`, `--sx-accent`, `--sx-accent-hover`, `--sx-accent-line`, `--sx-on-accent`, `--sx-success`, `--sx-warning`, `--sx-error` |
209
+ | Type | `--sx-font-heading`, `--sx-font-mono`, `--sx-text-h1`, `--sx-text-h2`, `--sx-text-h3`, `--sx-text-body`, `--sx-text-small`, `--sx-text-micro` |
210
+ | Shape | `--sx-radius-card`, `--sx-radius-input`, `--sx-radius-badge`, `--sx-radius-button`, `--sx-border-w`, `--sx-shadow-card`, `--sx-shadow-button` |
211
+ | Motion | `--sx-dur`, `--sx-ease` |
212
+
213
+ <!-- css-contract:end -->
214
+
215
+ Body text inherits the page's own font and colour.