@eldrajs/theme-cli 0.2.4 → 0.2.6

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 (167) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +6 -0
  3. package/dist/cli.js +8 -2
  4. package/dist/index.d.ts +6 -0
  5. package/dist/index.js +1 -1
  6. package/dist/{validate-FjQ-5_ne.js → validate-CC6Mp5i_.js} +2 -1
  7. package/package.json +3 -3
  8. package/template/.eldra/block-types.d.ts +1 -1
  9. package/template/.eldra/manifest.json +30 -2
  10. package/template/.eldra/previews.json +35 -35
  11. package/template/README.md +3 -1
  12. package/template/app/app.vue +16 -3
  13. package/template/app/assets/main.css +13 -15
  14. package/template/app/components/ui/UiImage.vue +29 -17
  15. package/template/app/components/ui/__tests__/UiImage.spec.ts +24 -15
  16. package/template/app/composables/useStorefront.ts +7 -2
  17. package/template/app/pages/[...slug].vue +1 -1
  18. package/template/app/plugins/eldra-storefront.ts +9 -0
  19. package/template/app/storefront/analytics.ts +15 -7
  20. package/template/app/storefront/cart.ts +228 -51
  21. package/template/app/storefront/commerce.ts +8 -2
  22. package/template/app/storefront/currency.ts +205 -0
  23. package/template/app/storefront/demo.ts +10 -2
  24. package/template/app/storefront/feedback.ts +2 -0
  25. package/template/app/storefront/gateway.ts +153 -35
  26. package/template/app/storefront/money.ts +6 -18
  27. package/template/app/storefront/structuredData.ts +16 -5
  28. package/template/app/storefront/toProductCard.ts +14 -14
  29. package/template/app/storefront/types.ts +13 -0
  30. package/template/app/storefront/volatile.ts +4 -0
  31. package/template/app/utils/seoInput.ts +4 -3
  32. package/template/blocks/announcement-bar/Block.vue +3 -2
  33. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +1 -1
  34. package/template/blocks/announcement-bar/preview.png +0 -0
  35. package/template/blocks/article/Block.vue +3 -4
  36. package/template/blocks/article/preview.png +0 -0
  37. package/template/blocks/article-list/Block.vue +18 -9
  38. package/template/blocks/article-list/preview.png +0 -0
  39. package/template/blocks/breadcrumbs/Block.vue +1 -1
  40. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +9 -9
  41. package/template/blocks/breadcrumbs/preview.png +0 -0
  42. package/template/blocks/cart/Block.vue +42 -23
  43. package/template/blocks/cart/__tests__/Block.spec.ts +2 -3
  44. package/template/blocks/cart/__tests__/loadFailed.spec.ts +135 -0
  45. package/template/blocks/cart/__tests__/notSold.spec.ts +109 -0
  46. package/template/blocks/cart/parts/CartLines.vue +16 -3
  47. package/template/blocks/cart/parts/CheckoutButton.vue +45 -0
  48. package/template/blocks/cart/parts/LoadFailed.vue +37 -0
  49. package/template/blocks/cart/parts/NotSoldNotice.vue +69 -0
  50. package/template/blocks/cart/parts/ShippingBar.vue +1 -1
  51. package/template/blocks/cart/parts/Summary.vue +14 -30
  52. package/template/blocks/cart/parts/notSold.ts +19 -0
  53. package/template/blocks/cart/preview.png +0 -0
  54. package/template/blocks/collection-grid/Block.vue +26 -16
  55. package/template/blocks/collection-grid/__tests__/Block.spec.ts +26 -14
  56. package/template/blocks/collection-grid/preview.png +0 -0
  57. package/template/blocks/collection-header/Block.vue +5 -5
  58. package/template/blocks/collection-header/preview.png +0 -0
  59. package/template/blocks/contact/Block.vue +1 -1
  60. package/template/blocks/contact/__tests__/Block.spec.ts +2 -2
  61. package/template/blocks/contact/preview.png +0 -0
  62. package/template/blocks/cta/Block.vue +16 -18
  63. package/template/blocks/cta/__tests__/Block.spec.ts +8 -12
  64. package/template/blocks/cta/preview.png +0 -0
  65. package/template/blocks/faq/Block.vue +3 -13
  66. package/template/blocks/faq/__tests__/Block.spec.ts +2 -2
  67. package/template/blocks/faq/preview.png +0 -0
  68. package/template/blocks/feature-grid/Block.vue +1 -1
  69. package/template/blocks/feature-grid/__tests__/Block.spec.ts +1 -1
  70. package/template/blocks/feature-grid/preview.png +0 -0
  71. package/template/blocks/footer/Block.vue +33 -55
  72. package/template/blocks/footer/__tests__/Block.spec.ts +5 -5
  73. package/template/blocks/footer/preview.png +0 -0
  74. package/template/blocks/form/Block.vue +1 -1
  75. package/template/blocks/form/preview.png +0 -0
  76. package/template/blocks/gallery/__tests__/Block.spec.ts +1 -1
  77. package/template/blocks/gallery/preview.png +0 -0
  78. package/template/blocks/hero/Block.vue +8 -11
  79. package/template/blocks/hero/__tests__/Block.spec.ts +9 -7
  80. package/template/blocks/hero/preview.png +0 -0
  81. package/template/blocks/image/Block.vue +4 -4
  82. package/template/blocks/image/__tests__/Block.spec.ts +5 -6
  83. package/template/blocks/image/preview.png +0 -0
  84. package/template/blocks/logo-cloud/__tests__/Block.spec.ts +1 -1
  85. package/template/blocks/logo-cloud/preview.png +0 -0
  86. package/template/blocks/navigation/Block.vue +55 -29
  87. package/template/blocks/navigation/__tests__/Block.spec.ts +22 -20
  88. package/template/blocks/navigation/preview.png +0 -0
  89. package/template/blocks/newsletter/__tests__/Block.spec.ts +1 -1
  90. package/template/blocks/newsletter/preview.png +0 -0
  91. package/template/blocks/order-status/Block.vue +23 -15
  92. package/template/blocks/order-status/__tests__/Block.spec.ts +1 -2
  93. package/template/blocks/order-status/preview.png +0 -0
  94. package/template/blocks/pricing-table/__tests__/Block.spec.ts +1 -1
  95. package/template/blocks/pricing-table/preview.png +0 -0
  96. package/template/blocks/product-carousel/Block.vue +11 -8
  97. package/template/blocks/product-carousel/__tests__/Block.spec.ts +26 -8
  98. package/template/blocks/product-carousel/preview.png +0 -0
  99. package/template/blocks/product-detail/Block.vue +54 -18
  100. package/template/blocks/product-detail/__tests__/Block.spec.ts +79 -2
  101. package/template/blocks/product-detail/parts/Gallery.vue +1 -1
  102. package/template/blocks/product-detail/preview.png +0 -0
  103. package/template/blocks/quote/Block.vue +1 -1
  104. package/template/blocks/quote/__tests__/Block.spec.ts +7 -4
  105. package/template/blocks/quote/preview.png +0 -0
  106. package/template/blocks/rich-text/preview.png +0 -0
  107. package/template/blocks/search/Block.vue +10 -4
  108. package/template/blocks/search/PopularChips.vue +1 -1
  109. package/template/blocks/search/TypeSection.vue +8 -2
  110. package/template/blocks/search/preview.png +0 -0
  111. package/template/blocks/search/results.ts +5 -2
  112. package/template/blocks/split-content/Block.vue +2 -3
  113. package/template/blocks/split-content/__tests__/Block.spec.ts +2 -2
  114. package/template/blocks/split-content/preview.png +0 -0
  115. package/template/blocks/stats/__tests__/Block.spec.ts +1 -1
  116. package/template/blocks/stats/preview.png +0 -0
  117. package/template/blocks/tabs/Block.vue +4 -5
  118. package/template/blocks/tabs/__tests__/Block.spec.ts +2 -2
  119. package/template/blocks/tabs/preview.png +0 -0
  120. package/template/blocks/team/preview.png +0 -0
  121. package/template/blocks/testimonials/Block.vue +10 -9
  122. package/template/blocks/testimonials/__tests__/Block.spec.ts +1 -1
  123. package/template/blocks/testimonials/preview.png +0 -0
  124. package/template/blocks/timeline/__tests__/Block.spec.ts +2 -2
  125. package/template/blocks/timeline/preview.png +0 -0
  126. package/template/blocks/trust-strip/Block.vue +1 -1
  127. package/template/blocks/trust-strip/__tests__/Block.spec.ts +1 -1
  128. package/template/blocks/trust-strip/preview.png +0 -0
  129. package/template/blocks/video-embed/Block.vue +3 -3
  130. package/template/blocks/video-embed/__tests__/Block.spec.ts +1 -1
  131. package/template/blocks/video-embed/preview.png +0 -0
  132. package/template/blocks/wishlist/Block.vue +6 -2
  133. package/template/blocks/wishlist/preview.png +0 -0
  134. package/template/i18n/en-US.json +19 -3
  135. package/template/i18n/is-IS.json +19 -3
  136. package/template/nuxt.config.ts +5 -4
  137. package/template/package.json +1 -0
  138. package/template/stories/pages/article.stories.ts +2 -3
  139. package/template/stories/pages/cart.stories.ts +2 -3
  140. package/template/stories/pages/category.stories.ts +2 -3
  141. package/template/stories/pages/collection.stories.ts +2 -3
  142. package/template/stories/pages/home.stories.ts +2 -3
  143. package/template/stories/pages/product.stories.ts +3 -4
  144. package/template/stories/pages/products.stories.ts +2 -3
  145. package/template/stories/pages/search.stories.ts +2 -3
  146. package/template/stories/pages/wishlist.stories.ts +2 -3
  147. package/template/test/carouselKeyboard.spec.ts +2 -2
  148. package/template/test/carouselRing.browser.spec.ts +2 -2
  149. package/template/test/carouselSlideWidth.browser.spec.ts +9 -9
  150. package/template/test/currencyPicker.spec.ts +66 -0
  151. package/template/test/eldraIcon.spec.ts +1 -1
  152. package/template/test/mainCss.spec.ts +7 -0
  153. package/template/test/pages/article.spec.ts +5 -5
  154. package/template/test/pages/collection.spec.ts +5 -5
  155. package/template/test/pages/hydration.spec.ts +10 -10
  156. package/template/test/prerenderRefresh.browser.spec.ts +1 -1
  157. package/template/test/seoInput.spec.ts +22 -0
  158. package/template/test/storefront/analytics.spec.ts +15 -0
  159. package/template/test/storefront/cart.spec.ts +4 -4
  160. package/template/test/storefront/currency.spec.ts +549 -0
  161. package/template/test/storefront/currencyStore.spec.ts +845 -0
  162. package/template/test/storefront/gateway.spec.ts +22 -0
  163. package/template/test/storefront/money.spec.ts +2 -8
  164. package/template/test/storefront/structuredData.spec.ts +45 -0
  165. package/template/test/storefront/toProductCard.spec.ts +1 -1
  166. package/template/test/storefront/volatile.spec.ts +11 -0
  167. package/template/test/support/mountPage.ts +2 -3
@@ -1597,6 +1597,28 @@ describe('createGatewayStorefront', () => {
1597
1597
  expect(product?.stock).toBe('in');
1598
1598
  });
1599
1599
 
1600
+ it('reads a variant the store does not track as in stock with no count, not sold out', async () => {
1601
+ // The public contract (web-gateway 6.18.0, `POST /inventory/v1/stock/availability`) answers an
1602
+ // untracked variant with `tracked: false`, `available: true` and `availableQuantity: 0`.
1603
+ const untracked = productClient(
1604
+ {
1605
+ items: [
1606
+ {
1607
+ variantId: 'var-only',
1608
+ available: true,
1609
+ allowBackorder: false,
1610
+ availableQuantity: 0,
1611
+ tracked: false,
1612
+ },
1613
+ ],
1614
+ },
1615
+ { variants: [{ id: 'var-only', status: 'ACTIVE', price: 96 }] }
1616
+ );
1617
+ const product = await read(untracked.client);
1618
+ expect(product?.inventory).toBeNull();
1619
+ expect(product?.stock).toBe('in');
1620
+ });
1621
+
1600
1622
  it('reads sold out for a published variant with nothing on the shelf', async () => {
1601
1623
  const { client } = productClient({
1602
1624
  items: [
@@ -1,12 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { formatCurrency } from '@eldrajs/ui';
3
- import {
4
- currencyLabel,
5
- DEFAULT_LOCALE,
6
- formatMoney,
7
- roundMoney,
8
- toMinorUnits,
9
- } from '../../app/storefront/money';
2
+ import { formatCurrency, toMinorUnits } from '@eldrajs/ui';
3
+ import { currencyLabel, DEFAULT_LOCALE, formatMoney, roundMoney } from '../../app/storefront/money';
10
4
 
11
5
  describe('formatMoney', () => {
12
6
  it('formats a major-unit amount as itself', () => {
@@ -154,6 +154,51 @@ describe('pageStructuredData', () => {
154
154
  expect(offers.offers[1].availability).toBe('https://schema.org/OutOfStock');
155
155
  });
156
156
 
157
+ it('sends the priceCurrency of the price the page shows, never the store currency over it', () => {
158
+ const entries = pageStructuredData(
159
+ parts({
160
+ kind: 'product',
161
+ currency: 'ISK',
162
+ product: product({
163
+ price: { amount: 19.9, compareAt: null, currency: 'EUR' },
164
+ variants: [
165
+ { sku: 'S', barcode: null, price: 19.9, compareAt: null, currency: 'EUR', stock: 'in' },
166
+ {
167
+ sku: 'L',
168
+ barcode: null,
169
+ price: 3400,
170
+ compareAt: null,
171
+ currency: 'ISK',
172
+ soldInCurrency: false,
173
+ stock: 'in',
174
+ },
175
+ ],
176
+ }),
177
+ })
178
+ );
179
+ const offers = entries[1]!.node.offers as Record<string, any>;
180
+ expect(offers).toMatchObject({ '@type': 'Offer', price: 19.9, priceCurrency: 'EUR', sku: 'S' });
181
+ });
182
+
183
+ it('4662896736: writes no offer for a product not sold in the shown currency', () => {
184
+ const node = pageStructuredData(
185
+ parts({
186
+ kind: 'product',
187
+ product: product({
188
+ price: { amount: 2800, compareAt: null, currency: 'ISK', soldInCurrency: false },
189
+ }),
190
+ })
191
+ )[1]!.node as Record<string, unknown>;
192
+ expect(node.offers).toBeUndefined();
193
+ });
194
+
195
+ it('keeps the store currency for a price that carries none', () => {
196
+ const offers = pageStructuredData(
197
+ parts({ kind: 'product', currency: 'ISK', product: product() })
198
+ )[1]!.node.offers as Record<string, any>;
199
+ expect(offers.priceCurrency).toBe('ISK');
200
+ });
201
+
157
202
  it('writes an ItemList on a listing page only when it shows products', () => {
158
203
  const listing = (items: PageLdParts['items']) =>
159
204
  types(pageStructuredData(parts({ kind: 'collection', items })));
@@ -1,5 +1,5 @@
1
1
  import { describe, expect, it } from 'vitest';
2
- import { toMinorUnits } from '../../app/storefront/money';
2
+ import { toMinorUnits } from '@eldrajs/ui';
3
3
  import { toProductCard, toProductCardEntries } from '../../app/storefront/toProductCard';
4
4
  import type { StorefrontProductListItem } from '../../app/storefront/types';
5
5
 
@@ -282,3 +282,14 @@ describe('chunkIds', () => {
282
282
  expect(VOLATILE_CHUNK_SIZE).toBe(50);
283
283
  });
284
284
  });
285
+
286
+ describe('applyVolatileSnapshots across currencies', () => {
287
+ it('takes a price in another currency whole, so an amount never keeps the old currency', () => {
288
+ const card = listItem({ price: { amount: 2900, compareAt: null, from: true } });
289
+ const [next] = applyVolatileSnapshots(
290
+ [card],
291
+ [snapshot({ price: { amount: 19.9, compareAt: null, currency: 'EUR' } })]
292
+ );
293
+ expect(next!.price).toEqual({ amount: 19.9, compareAt: null, currency: 'EUR' });
294
+ });
295
+ });
@@ -91,9 +91,8 @@ export async function mountPageWithSkipLink(
91
91
  href: '#main',
92
92
  as: EldraRouterLink,
93
93
  variant: 'standalone',
94
- classes: {
95
- root: 'bg-primary text-primary-contrast rounded-md sr-only px-4 py-2 focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50',
96
- },
94
+ class:
95
+ 'bg-primary text-primary-contrast rounded-md sr-only px-4 py-2 focus:not-sr-only focus:fixed focus:top-4 focus:left-4 focus:z-50',
97
96
  },
98
97
  () => t('nav.skipToContent')
99
98
  ),