@usequeek/theme-kit 0.1.21 → 0.1.22

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 (81) hide show
  1. package/README.md +187 -117
  2. package/api/collections.ts +5 -5
  3. package/api/shop.ts +1 -1
  4. package/client.ts +2 -0
  5. package/components/checkout/checkout-contact.tsx +3 -3
  6. package/components/image.tsx +5 -5
  7. package/components/language-switcher.css +131 -0
  8. package/components/language-switcher.tsx +144 -0
  9. package/components/markdown.tsx +1 -1
  10. package/components/powered-by-queek.tsx +4 -4
  11. package/components/product-media-frame.tsx +1 -1
  12. package/components/product-metafields.tsx +2 -3
  13. package/components/variant-picker.tsx +6 -9
  14. package/demo.ts +10 -14
  15. package/design-token-preview.tsx +0 -2
  16. package/edit-mode-active.tsx +3 -4
  17. package/hooks/use-announcement.ts +1 -1
  18. package/hooks/use-auth-flow.tsx +1 -1
  19. package/hooks/use-locales.ts +107 -0
  20. package/hooks/use-posts.ts +1 -1
  21. package/hooks/use-product-detail.ts +1 -2
  22. package/hooks/use-product-sections.ts +4 -6
  23. package/hooks/use-products.ts +5 -8
  24. package/index.ts +13 -16
  25. package/locales/en.default.json +4 -0
  26. package/next-reference.d.ts +2 -4
  27. package/package.json +3 -2
  28. package/page-renderer.tsx +5 -6
  29. package/provider.tsx +22 -2
  30. package/scripts/verify-package.ts +6 -8
  31. package/sdk/client.ts +13 -12
  32. package/sdk/error-handler.ts +1 -1
  33. package/sdk/platform.ts +6 -8
  34. package/sdk/queek-client.ts +11 -12
  35. package/sdk/server-store-client.ts +13 -17
  36. package/shared-blocks/metaobjects.tsx +1 -1
  37. package/stores/cart-store.ts +2 -2
  38. package/stores/checkout-store.ts +1 -1
  39. package/stores/edit-preview-store.ts +5 -6
  40. package/stores/user-store.ts +4 -5
  41. package/strings/pseudo-locale.ts +3 -4
  42. package/strings/theme-strings.ts +9 -7
  43. package/tests/auth-email-errors.test.tsx +2 -2
  44. package/tests/currency-contract.test.ts +2 -3
  45. package/tests/display-format.test.ts +17 -25
  46. package/tests/fixtures/external-theme.tsx +18 -2
  47. package/tests/language-switcher.test.tsx +350 -0
  48. package/tests/list-pagination.test.tsx +8 -8
  49. package/tests/locale-switch.test.ts +197 -0
  50. package/tests/locale-transport.test.tsx +3 -3
  51. package/tests/markdown-render.test.ts +5 -6
  52. package/tests/orders-walk.test.ts +5 -5
  53. package/tests/page-renderer-signature.test.tsx +1 -1
  54. package/tests/powered-by-queek.test.tsx +3 -3
  55. package/tests/powered-by-url.test.ts +2 -2
  56. package/tests/public-surface.test.ts +1 -4
  57. package/tests/shopper-chrome-strings.test.tsx +5 -6
  58. package/tests/storefront-client-scope.test.ts +5 -5
  59. package/tests/theme-hook-placement.test.tsx +2 -2
  60. package/tests/theme-strings-client.test.tsx +5 -5
  61. package/tests/theme-strings-pseudo.test.tsx +1 -1
  62. package/tests/theme-strings-typed.test.tsx +1 -1
  63. package/tests/theme-strings.test.tsx +8 -11
  64. package/tests/use-shop-prefetch.test.tsx +1 -1
  65. package/theme-mount.tsx +6 -11
  66. package/types/block.ts +7 -7
  67. package/types/media.ts +8 -9
  68. package/types/product.ts +8 -12
  69. package/types/theme.ts +26 -25
  70. package/types/vendor.ts +10 -12
  71. package/utils/announcement.ts +3 -3
  72. package/utils/benefit-icon.tsx +9 -11
  73. package/utils/brand.ts +7 -10
  74. package/utils/format.ts +5 -7
  75. package/utils/image-srcset.ts +2 -2
  76. package/utils/locale-switch.ts +208 -0
  77. package/utils/locale.ts +10 -11
  78. package/utils/menu-link.ts +1 -1
  79. package/utils/product-media.ts +1 -1
  80. package/utils/product-normalizer.ts +2 -2
  81. package/utils/vendor-host.ts +7 -11
@@ -17,7 +17,7 @@ export function menuItemToHref(item: MenuItem, basePath: string = ''): string {
17
17
  const href = `${basePath}/${item.ref}`;
18
18
  const anchor = item.meta?.anchor;
19
19
  // href may already end in "/" (the home page's ref is normalized to
20
- // "/" — see MenuResource::normalizeHomeRefs) — never emit a doubled
20
+ // "/") — never emit a doubled
21
21
  // slash before the fragment.
22
22
  return anchor ? `${href.replace(/\/$/, '')}#${anchor}` : href;
23
23
  }
@@ -14,7 +14,7 @@ export interface MediaFrame {
14
14
 
15
15
  /**
16
16
  * Picks the largest tier a PDP hero should ever request. `view` is capped at
17
- * 1600px (queek_backend config/media.php) which covers every theme's hero box
17
+ * 1600px, which covers every theme's hero box
18
18
  * at DPR2 — the raw `original` is uncapped and unoptimized.
19
19
  */
20
20
  function heroUrl(variants: ImageVariants | null | undefined): string | null {
@@ -37,8 +37,8 @@ function toBool(value: unknown, fallback = false): boolean {
37
37
 
38
38
  /**
39
39
  * Same base/sale/compare-at shape as normalizePricing(), but a variant's own price lives on
40
- * FLAT fields (price/discount_price/compare_at_price/discount_amount — see
41
- * ProductResource::resolveShopVariants on the backend), never nested under a `pricing` key.
40
+ * FLAT fields (price/discount_price/compare_at_price/discount_amount), never nested
41
+ * under a `pricing` key.
42
42
  * Reading `variant.pricing?.sale_amount` (as this used to) is always undefined, so every
43
43
  * variant silently fell back to the base product's price — picking Denim vs Taupe never
44
44
  * changed what was shown, even though the backend had already computed the right number.
@@ -1,14 +1,11 @@
1
1
  /**
2
2
  * Vendor resolution from a hostname: which store is this request for?
3
3
  *
4
- * Lived at `app/middleware.ts` until core needed it — `lib/core/api/products.ts`
5
- * and `lib/core/sdk/server-store-client.ts` both import from here, which meant
6
- * core depended on the app. Nothing here is app-specific: it reads env and
7
- * resolves a slug. (The actual Next middleware is `proxy.ts`; the old filename
8
- * suggested otherwise and was never that.)
4
+ * Nothing here is app-specific: it reads env and resolves a slug, so the kit's
5
+ * server fetchers and a host app's proxy can both import it.
9
6
  */
10
7
 
11
- // Mirrors backend config/storefront.php `reserved_slugs`. Keep in sync.
8
+ // Mirrors the API's reserved store slugs. Keep in sync.
12
9
  // These are subdomains the storefront proxy must NOT treat as vendor slugs.
13
10
  export const RESERVED_VENDOR_SLUGS = new Set([
14
11
  // Live platform subdomains
@@ -24,11 +21,10 @@ export const RESERVED_VENDOR_SLUGS = new Set([
24
21
  'staff', 'team', 'queek', 'merchant', 'vendor', 'rider', 'customer',
25
22
  ]);
26
23
 
27
- // Every sluggable backend model (Vendor, Product, Category, Region, Service —
28
- // app/Models/*.php `getSlugOptions()`) is Spatie Sluggable output: lowercase
29
- // alphanumeric, optionally hyphen-separated, never a dot/underscore/uppercase.
30
- // Anything else cannot be a real slug of any kind, so reject it before any
31
- // backend round-trip instead of burning calls that all 404. This is what stops
24
+ // Every sluggable API model (Vendor, Product, Category, Region, Service)
25
+ // produces lowercase alphanumeric slugs, optionally hyphen-separated, never a
26
+ // dot/underscore/uppercase. Anything else cannot be a real slug of any kind, so
27
+ // reject it before any API round-trip instead of burning calls that all 404. This is what stops
32
28
  // scanners probing `.env`, `.ssh`, `docker-compose.yaml`, `*.php` etc —
33
29
  // RESERVED_VENDOR_SLUGS alone only covers known words, not the infinite space
34
30
  // of file-extension guesses.