@shoppexio/storefront-react 0.0.0 → 0.1.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 (60) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/LICENSE +21 -0
  3. package/README.md +137 -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 +75 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ - First release. The commerce layer of the Shoppex code templates (SDK access,
6
+ payload parsing, storefront context, cart and quotes, catalog and product
7
+ models, checkout fields, reviews, shop pages, menus, contact, merchant HTML)
8
+ and the customer account (`@shoppexio/storefront-react/account`) with its
9
+ message catalogs for sixteen locales. The account is styled only through the
10
+ host theme's `--sx-*` custom properties and ships as plain CSS
11
+ (`@shoppexio/storefront-react/account.css`). See ADR-0068.
12
+ - Physical products: `PHYSICAL` product type, `resolveDeliveryPromise()`
13
+ (`shipped` / `timed` / `instant`), `requiresShipping` on the cart context
14
+ from the quote's `requires_shipping`, and copy for the
15
+ `errors.checkout.shop_does_not_ship` refusal.
16
+ - `formatMoney` drops zero cents on whole amounts (`$49`, `$49.50`); a
17
+ currency's own decimals are kept for every other amount.
18
+ - Shop reviews carry `productTitle` and `verified`; `reviewsForProduct()`
19
+ narrows the feed to one product by title (the public feed has no product
20
+ 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,137 @@
1
+ # @shoppexio/storefront-react
2
+
3
+ The commerce layer and the customer account of a Shoppex code storefront
4
+ (the Advanced lane). State, hooks, models and parsers from the package root;
5
+ the account UI from `@shoppexio/storefront-react/account`. Decision record:
6
+ ADR-0068.
7
+
8
+ It reads two things the Shoppex worker puts on the page before your bundle
9
+ runs: `window.shoppex` (the Storefront SDK, loaded as a CDN script by your
10
+ `index.html`) and `window.__SHOPPEX_INITIAL__` (the shop, the catalog, the
11
+ merchant's saved content). It never bundles the SDK.
12
+
13
+ ```sh
14
+ bun add @shoppexio/storefront-react
15
+ ```
16
+
17
+ Peer dependencies: `react` and `react-dom` 19.2, `react-router-dom` 7.18.
18
+
19
+ ## Entries
20
+
21
+ | Import | What it is |
22
+ |---|---|
23
+ | `@shoppexio/storefront-react` | Logic, renders nothing (see the map below) |
24
+ | `@shoppexio/storefront-react/account` | `AccountPage`, the whole customer account |
25
+ | `@shoppexio/storefront-react/account.css` | The account's stylesheet, plain CSS |
26
+
27
+ ### The root: where to start
28
+
29
+ | Module | Use it for | Start with |
30
+ |---|---|---|
31
+ | SDK access | The SDK global, fail-fast when it is missing, affiliate capture | `getShoppex()`, `getBuyerCurrency()`, `SERVING_CONTEXT_HINT` |
32
+ | Payload | Parsing the injected payload: products, groups, categories, shop, settings, stock, licence terms | `getProducts()`, `getStorefrontShop()`, `getStorefrontSettings()`, `hasInjectedStorefrontData()` |
33
+ | Context | One parse at boot, read anywhere | `readStorefrontData()`, `<StorefrontProvider>`, `useStorefront()`, `useOnlineUserCount()` |
34
+ | Catalog | Cards, sort, filter, pagination, money | `buildStorefrontCatalog()`, `sortCatalogCards()`, `filterCatalogCards()`, `formatMoney()` |
35
+ | Product | The product page model: variants, rating, pricing, quantity bounds, badges, videos | `buildProductDetail()`, `calculateLinePricing()`, `badgesForProductPage()` |
36
+ | Cart | Cart state, quotes, coupons, checkout hand-off | `<CartProvider>`, `useCart()`, `buildCartView()`, `buildCartTotals()` |
37
+ | Checkout fields | Per-product fields a buyer fills before checkout | `resolveCheckoutFields()`, `readCheckoutNeedsDetails()` |
38
+ | Reviews, pages, menus, contact | SDK-backed hooks | `useShopReviews()`, `loadShopPage()`, `useNavigationLinks()`, `submitContactTicket()` |
39
+ | Merchant HTML | Sanitizing and flattening merchant rich text | `sanitizeMerchantHtml()`, `flattenMerchantHtmlToText()` |
40
+ | Account routing | Mounting the account and its lazy chunk | `ACCOUNT_PATH`, `ACCOUNT_PATH_ALIAS`, `accountRouteMessage()`, `ACCOUNT_STOREFRONT_ROUTES`, `ACCOUNT_ARTIFACT_CAPABILITIES` |
41
+
42
+ The `.d.ts` files next to the JS are the reference; every export carries its
43
+ contract in its doc comment.
44
+
45
+ ## Mounting the account
46
+
47
+ ```tsx
48
+ // src/pages/account-page.tsx, loaded with import() behind ACCOUNT_PATH
49
+ import '@shoppexio/storefront-react/account.css';
50
+ import { AccountPage as ShoppexAccount } from '@shoppexio/storefront-react/account';
51
+ import { PageShell } from '../components/layout/page-shell';
52
+ import { NotFoundPage } from './not-found-page';
53
+
54
+ function Frame({ children }: { children: React.ReactNode }) {
55
+ return <PageShell page="account">{children}</PageShell>;
56
+ }
57
+
58
+ export function AccountPage() {
59
+ return <ShoppexAccount frame={Frame} notFound={<NotFoundPage />} />;
60
+ }
61
+ ```
62
+
63
+ - Mount it under `${ACCOUNT_PATH}/*` and `${ACCOUNT_PATH_ALIAS}/*`.
64
+ - Route every path in `ACCOUNT_STOREFRONT_ROUTES`; the account links to them.
65
+ - List every entry of `ACCOUNT_ARTIFACT_CAPABILITIES` in
66
+ `public/shoppex.capabilities.json`.
67
+ - The locale is read from `<html lang>`, which the Shoppex worker sets. All
68
+ sixteen storefront locales ship with the account.
69
+
70
+ ## Styling the account
71
+
72
+ The account has no look of its own. Every value in `account.css` is a read of
73
+ one of your theme's `--sx-*` custom properties, so it takes your palette, type,
74
+ radii and shadows, light and dark. Its utilities use the package-private `sxa:`
75
+ prefix, so they cannot collide with your classes, and nothing in it selects
76
+ your elements. It uses no cascade layer: a one-class `sxa:` rule beats your
77
+ element resets (`button { color: inherit }`), and a rule of yours scoped under
78
+ the root hook beats it.
79
+
80
+ To restyle a part, target its hook under `.sx-account`. Hooks carry no styles:
81
+
82
+ `sx-account` (root), `sx-account-header`, `sx-account-title`,
83
+ `sx-account-signout`, `sx-account-nav`, `sx-account-nav-link`,
84
+ `sx-account-panel` (with `data-sx-account-view="<tab>"`), `sx-account-card`,
85
+ `sx-account-section-title`, `sx-account-empty`, `sx-account-error`,
86
+ `sx-account-notice`, `sx-account-skeleton`, `sx-account-back`,
87
+ `sx-account-button`, `sx-account-cta`, `sx-account-copy`, `sx-account-chip`,
88
+ `sx-account-status`, `sx-account-field`, `sx-account-label`,
89
+ `sx-account-field-error`.
90
+
91
+ ```css
92
+ /* two classes beat the account's one-class utilities */
93
+ .sx-account .sx-account-card { border-radius: 0; box-shadow: none; }
94
+ .sx-account .sx-account-nav-link[aria-current='page'] { text-decoration: underline; }
95
+ ```
96
+
97
+ `.sx-account` also scopes a zero-specificity baseline (box sizing, border
98
+ reset, heading font) for themes without a CSS reset.
99
+
100
+ ### The CSS custom property contract
101
+
102
+ A theme defines every one of these. A package test pins this list against the
103
+ built stylesheet.
104
+
105
+ <!-- css-contract:start -->
106
+
107
+ | Group | Properties |
108
+ |---|---|
109
+ | 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` |
110
+ | 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` |
111
+ | Shape | `--sx-radius-card`, `--sx-radius-input`, `--sx-radius-badge`, `--sx-radius-button`, `--sx-border-w`, `--sx-shadow-card`, `--sx-shadow-button` |
112
+ | Motion | `--sx-dur`, `--sx-ease` |
113
+
114
+ <!-- css-contract:end -->
115
+
116
+ Body text inherits the page's own font and colour.
117
+
118
+ ## Ejecting the account
119
+
120
+ When restyling is not enough and you want to own the account's markup:
121
+
122
+ 1. Copy `node_modules/@shoppexio/storefront-react/eject/account/` into your
123
+ project as `src/account/`. Its imports of the package root already point
124
+ at `@shoppexio/storefront-react`.
125
+ 2. Import `AccountPage` from `./account/account-page` instead of
126
+ `@shoppexio/storefront-react/account`.
127
+ 3. Keep importing `@shoppexio/storefront-react/account.css`: it styles the
128
+ `sxa:` classes the copied markup carries. New markup uses your own classes.
129
+
130
+ From then on the account is yours and a package update no longer reaches it.
131
+ A CLI command for this is planned.
132
+
133
+ ## Versions
134
+
135
+ Official templates pin an exact version. Monorepo maintainers move every pin
136
+ at once with `bun run storefront-react:bump <version>` after publishing; see
137
+ `docs/runbooks/theme-runtime-release.md`.