@shoplix-ai/block-kit 4.6.0 → 5.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 (115) hide show
  1. package/README.md +116 -10
  2. package/dist/account-links.d.ts +96 -0
  3. package/dist/account-links.d.ts.map +1 -0
  4. package/dist/account-links.js +121 -0
  5. package/dist/account-links.js.map +1 -0
  6. package/dist/address-list.d.ts +58 -0
  7. package/dist/address-list.d.ts.map +1 -0
  8. package/dist/address-list.js +57 -0
  9. package/dist/address-list.js.map +1 -0
  10. package/dist/buy-box.d.ts +8 -0
  11. package/dist/buy-box.d.ts.map +1 -1
  12. package/dist/buy-box.js +8 -0
  13. package/dist/buy-box.js.map +1 -1
  14. package/dist/capabilities.d.ts +12 -2
  15. package/dist/capabilities.d.ts.map +1 -1
  16. package/dist/capabilities.js.map +1 -1
  17. package/dist/category-grid.d.ts +92 -0
  18. package/dist/category-grid.d.ts.map +1 -0
  19. package/dist/category-grid.js +123 -0
  20. package/dist/category-grid.js.map +1 -0
  21. package/dist/color-choice.d.ts +4 -0
  22. package/dist/color-choice.d.ts.map +1 -0
  23. package/dist/color-choice.js +11 -0
  24. package/dist/color-choice.js.map +1 -0
  25. package/dist/content-direction.d.ts +10 -0
  26. package/dist/content-direction.d.ts.map +1 -0
  27. package/dist/content-direction.js +20 -0
  28. package/dist/content-direction.js.map +1 -0
  29. package/dist/contract.d.ts +20 -14
  30. package/dist/contract.d.ts.map +1 -1
  31. package/dist/contract.js +3 -2
  32. package/dist/contract.js.map +1 -1
  33. package/dist/description.d.ts +60 -0
  34. package/dist/description.d.ts.map +1 -0
  35. package/dist/description.js +332 -0
  36. package/dist/description.js.map +1 -0
  37. package/dist/hero-banner.d.ts +10 -1
  38. package/dist/hero-banner.d.ts.map +1 -1
  39. package/dist/hero-banner.js +17 -0
  40. package/dist/hero-banner.js.map +1 -1
  41. package/dist/index.d.ts +32 -11
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +19 -8
  44. package/dist/index.js.map +1 -1
  45. package/dist/listing-filters.d.ts +114 -0
  46. package/dist/listing-filters.d.ts.map +1 -0
  47. package/dist/listing-filters.js +195 -0
  48. package/dist/listing-filters.js.map +1 -0
  49. package/dist/listing-toolbar.d.ts +117 -0
  50. package/dist/listing-toolbar.d.ts.map +1 -0
  51. package/dist/listing-toolbar.js +130 -0
  52. package/dist/listing-toolbar.js.map +1 -0
  53. package/dist/money.d.ts +7 -0
  54. package/dist/money.d.ts.map +1 -1
  55. package/dist/money.js +15 -0
  56. package/dist/money.js.map +1 -1
  57. package/dist/navigation.d.ts +10 -2
  58. package/dist/navigation.d.ts.map +1 -1
  59. package/dist/orders.d.ts +162 -0
  60. package/dist/orders.d.ts.map +1 -0
  61. package/dist/orders.js +302 -0
  62. package/dist/orders.js.map +1 -0
  63. package/dist/product-card.d.ts +4 -0
  64. package/dist/product-card.d.ts.map +1 -1
  65. package/dist/product-card.js +4 -0
  66. package/dist/product-card.js.map +1 -1
  67. package/dist/product-gallery.d.ts +3 -0
  68. package/dist/product-gallery.d.ts.map +1 -1
  69. package/dist/product-gallery.js +3 -0
  70. package/dist/product-gallery.js.map +1 -1
  71. package/dist/product-specs.d.ts +33 -2
  72. package/dist/product-specs.d.ts.map +1 -1
  73. package/dist/product-specs.js +51 -2
  74. package/dist/product-specs.js.map +1 -1
  75. package/dist/product-summary.d.ts +12 -1
  76. package/dist/product-summary.d.ts.map +1 -1
  77. package/dist/product-summary.js +29 -0
  78. package/dist/product-summary.js.map +1 -1
  79. package/dist/profile-header.d.ts +30 -0
  80. package/dist/profile-header.d.ts.map +1 -0
  81. package/dist/profile-header.js +36 -0
  82. package/dist/profile-header.js.map +1 -0
  83. package/dist/promo-banner.d.ts +11 -1
  84. package/dist/promo-banner.d.ts.map +1 -1
  85. package/dist/promo-banner.js +24 -0
  86. package/dist/promo-banner.js.map +1 -1
  87. package/dist/section-header.d.ts +5 -1
  88. package/dist/section-header.d.ts.map +1 -1
  89. package/dist/section-header.js +5 -1
  90. package/dist/section-header.js.map +1 -1
  91. package/dist/sign-in.d.ts +28 -0
  92. package/dist/sign-in.d.ts.map +1 -0
  93. package/dist/sign-in.js +27 -0
  94. package/dist/sign-in.js.map +1 -0
  95. package/dist/store-header.d.ts +49 -6
  96. package/dist/store-header.d.ts.map +1 -1
  97. package/dist/store-header.js +59 -5
  98. package/dist/store-header.js.map +1 -1
  99. package/dist/variant-choice.d.ts +14 -0
  100. package/dist/variant-choice.d.ts.map +1 -1
  101. package/dist/variant-choice.js +36 -0
  102. package/dist/variant-choice.js.map +1 -1
  103. package/dist/variant-rows.d.ts +33 -0
  104. package/dist/variant-rows.d.ts.map +1 -0
  105. package/dist/variant-rows.js +52 -0
  106. package/dist/variant-rows.js.map +1 -0
  107. package/dist/version.d.ts +2 -2
  108. package/dist/version.d.ts.map +1 -1
  109. package/dist/version.js +2 -2
  110. package/dist/version.js.map +1 -1
  111. package/dist/words.d.ts +185 -0
  112. package/dist/words.d.ts.map +1 -1
  113. package/dist/words.js +530 -4
  114. package/dist/words.js.map +1 -1
  115. package/package.json +2 -2
@@ -1,4 +1,8 @@
1
+ import { componentTokenValue, SEARCH_BAR_DEFAULTS, searchBarOfHeader, } from '@shoplix-ai/sdui-schema';
2
+ import { colorChoiceOf } from './color-choice.js';
3
+ import { readable } from './locale.js';
1
4
  import { partColors } from './part-colors.js';
5
+ import { platformWords } from './words.js';
2
6
  /** The parts of the store header, each with the theme role it draws unless a component token names another. */
3
7
  const STORE_HEADER_ROLES = {
4
8
  bar: 'elevated',
@@ -13,16 +17,29 @@ const STORE_HEADER_ROLES = {
13
17
  drawer_ink: 'text',
14
18
  drawer_subtle: 'subtle',
15
19
  drawer_divider: 'border',
16
- scrim: 'overlay',
20
+ drawer_group: 'sunken',
17
21
  };
22
+ /** The dim behind the open menu: dark, the way the Cart Drawer dims, and no theme role, since a theme's overlay is a wash. */
23
+ export const STORE_MENU_DIM = 'rgba(0, 0, 0, 0.35)';
18
24
  /**
19
25
  * Every colour the store header draws, one per part, with `store_header.<part>`
20
- * as the escape hatch over each theme role. The phone's header and its web twin
21
- * read this one table, so the chrome a merchant sees on the canvas and the
22
- * chrome their shopper sees cannot disagree.
26
+ * as the escape hatch over each theme role, and over the dark dim behind the
27
+ * open menu. The phone's header and its web twin read this one table, so the
28
+ * chrome a merchant sees on the canvas and the chrome their shopper sees cannot
29
+ * disagree.
23
30
  */
24
31
  export function storeHeaderColors(theme) {
25
- return partColors(theme, 'store_header', STORE_HEADER_ROLES);
32
+ return {
33
+ ...partColors(theme, 'store_header', STORE_HEADER_ROLES),
34
+ scrim: componentTokenValue(theme, 'store_header.scrim', STORE_MENU_DIM),
35
+ };
36
+ }
37
+ /** The menu's rows as the theme sizes them, 48 points tall with 16 point words where it names nothing. */
38
+ export function storeMenuMetrics(theme) {
39
+ return {
40
+ rowHeight: componentTokenValue(theme, 'store_header.menu_row_height', 48),
41
+ labelSize: componentTokenValue(theme, 'store_header.menu_text_size', 16),
42
+ };
26
43
  }
27
44
  /** Past this the badge stops counting and says so, because a wider badge covers the glyph under it. */
28
45
  const BADGE_CEILING = 99;
@@ -36,4 +53,41 @@ export function cartBadgeCount(totalQuantity) {
36
53
  return null;
37
54
  return totalQuantity > BADGE_CEILING ? `${BADGE_CEILING}+` : String(totalQuantity);
38
55
  }
56
+ /**
57
+ * The search bar's words in the buyer's language, the one rule the phone and
58
+ * its canvas twin read. Typing off, or no hint in the buyer's language or the
59
+ * Shop's default, holds the placeholder.
60
+ */
61
+ export function searchBarWords(settings, language, defaultLanguage) {
62
+ const placeholder = platformWords(language, defaultLanguage).merchantOr(settings.placeholder, 'search.placeholder');
63
+ const wordsOf = (text) => text === undefined ? '' : (readable(text, language, defaultLanguage) ?? '').trim();
64
+ const lead = wordsOf(settings.hintLead);
65
+ const line = (typed) => (lead === '' ? typed : typed === '' ? lead : `${lead} ${typed}`);
66
+ const hints = settings.typeHints === true
67
+ ? (settings.hints ?? []).map((hint) => wordsOf(hint.text)).filter((hint) => hint !== '')
68
+ : [];
69
+ const first = hints[0];
70
+ return { lead, hints, label: first === undefined ? placeholder : line(first), line };
71
+ }
72
+ /** The store header's search entry in the buyer's language, read by the rule of the search bar. */
73
+ export function searchEntryWords(settings, language, defaultLanguage) {
74
+ return searchBarWords(searchBarOfHeader(settings), language, defaultLanguage);
75
+ }
76
+ /**
77
+ * The search entry's box as the merchant set it on the search bar, and the
78
+ * entry the store header drew for every part they left out, so a search moved
79
+ * out of the header draws as it drew there, on the header's band. The
80
+ * header's entry is this box with nothing set.
81
+ */
82
+ export function searchEntryBox(theme, settings = {}) {
83
+ const colors = storeHeaderColors(theme);
84
+ return {
85
+ height: settings.height ?? SEARCH_BAR_DEFAULTS.height,
86
+ radius: settings.radius ?? SEARCH_BAR_DEFAULTS.radius,
87
+ surface: colorChoiceOf(theme, settings.surface) ?? colors.search,
88
+ stroke: colorChoiceOf(theme, settings.stroke) ?? colors.search_border,
89
+ ink: colorChoiceOf(theme, settings.ink) ?? colors.search_ink,
90
+ band: colors.bar,
91
+ };
92
+ }
39
93
  //# sourceMappingURL=store-header.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"store-header.js","sourceRoot":"","sources":["../src/store-header.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,+GAA+G;AAC/G,MAAM,kBAAkB,GAAG;IACzB,GAAG,EAAE,UAAU;IACf,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,QAAQ;IAChB,KAAK,EAAE,QAAQ;IACf,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,QAAQ;IAChB,aAAa,EAAE,QAAQ;IACvB,UAAU,EAAE,QAAQ;IACpB,MAAM,EAAE,UAAU;IAClB,UAAU,EAAE,MAAM;IAClB,aAAa,EAAE,QAAQ;IACvB,cAAc,EAAE,QAAQ;IACxB,KAAK,EAAE,SAAS;CAC6C,CAAC;AAMhE;;;;;GAKG;AACH,MAAM,UAAU,iBA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CAAC,MAAM;QAChE,MAAM,EAAE,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,aAAa;QACrE,GAAG,EAAE,aAAa,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC,IAAI,MAAM,CAAC,UAAU;QAC5D,IAAI,EAAE,MAAM,CAAC,GAAG;KACjB,CAAC;AACJ,CAAC"}
@@ -11,4 +11,18 @@ export declare function effectiveSelections(product: ProductDisplay, chosen: Opt
11
11
  export declare function selectedVariant(product: ProductDisplay, selections: OptionSelections): ProductVariantDisplay | null;
12
12
  /** Whether choosing this value, keeping the other choices, can still be bought. */
13
13
  export declare function valueAvailable(product: ProductDisplay, selections: OptionSelections, optionName: string, value: string): boolean;
14
+ /**
15
+ * The values of one option that any variant offers together with the choices
16
+ * made in the options before it: a later option shows only what the earlier
17
+ * ones leave possible, so a weight the chosen box never comes in is not drawn.
18
+ * The first option shows all its values.
19
+ */
20
+ export declare function valuesAfterEarlierChoices(product: ProductDisplay, selections: OptionSelections, optionName: string): string[];
21
+ /**
22
+ * The choices after the shopper picks one value: theirs where they name a
23
+ * variant for sale, else those of the first variant for sale that keeps the
24
+ * pick and every choice before it, so a pick never leaves the box without a
25
+ * variant while one can be bought.
26
+ */
27
+ export declare function choicesAfterPick(product: ProductDisplay, selections: OptionSelections, optionName: string, value: string): OptionSelections;
14
28
  //# sourceMappingURL=variant-choice.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variant-choice.d.ts","sourceRoot":"","sources":["../src/variant-choice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAErF;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEhE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB,CAS3E;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gB,CAC9B,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,gBAAgB,CAelB"}
@@ -21,4 +21,40 @@ export function valueAvailable(product, selections, optionName, value) {
21
21
  const asked = { ...selections, [optionName]: value };
22
22
  return (product.variants ?? []).some((variant) => variant.available && matches(variant, asked));
23
23
  }
24
+ /**
25
+ * The values of one option that any variant offers together with the choices
26
+ * made in the options before it: a later option shows only what the earlier
27
+ * ones leave possible, so a weight the chosen box never comes in is not drawn.
28
+ * The first option shows all its values.
29
+ */
30
+ export function valuesAfterEarlierChoices(product, selections, optionName) {
31
+ const options = product.options ?? [];
32
+ const at = options.findIndex((option) => option.name === optionName);
33
+ const values = options[at]?.values ?? [];
34
+ const variants = product.variants ?? [];
35
+ if (at <= 0 || variants.length === 0)
36
+ return [...values];
37
+ const earlier = options.slice(0, at).map((option) => option.name);
38
+ return values.filter((value) => variants.some((variant) => variant.selectedOptions.some((pair) => pair.name === optionName && pair.value === value) &&
39
+ earlier.every((name) => variant.selectedOptions.some((pair) => pair.name === name && pair.value === selections[name]))));
40
+ }
41
+ /**
42
+ * The choices after the shopper picks one value: theirs where they name a
43
+ * variant for sale, else those of the first variant for sale that keeps the
44
+ * pick and every choice before it, so a pick never leaves the box without a
45
+ * variant while one can be bought.
46
+ */
47
+ export function choicesAfterPick(product, selections, optionName, value) {
48
+ const asked = { ...selections, [optionName]: value };
49
+ const exact = selectedVariant(product, asked);
50
+ if (exact?.available === true)
51
+ return asked;
52
+ const names = (product.options ?? []).map((option) => option.name);
53
+ const kept = names.slice(0, names.indexOf(optionName) + 1);
54
+ const fits = (product.variants ?? []).filter((variant) => kept.every((name) => variant.selectedOptions.some((pair) => pair.name === name && pair.value === asked[name])));
55
+ const variant = fits.find((candidate) => candidate.available) ?? exact ?? fits[0];
56
+ return variant === undefined
57
+ ? asked
58
+ : Object.fromEntries(variant.selectedOptions.map((pair) => [pair.name, pair.value]));
59
+ }
24
60
  //# sourceMappingURL=variant-choice.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"variant-choice.js","sourceRoot":"","sources":["../src/variant-choice.ts"],"names":[],"mappings":"AASA,MAAM,UAAU,iBAAiB,CAAC,OAAuB;IACvD,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC;IACxC,MAAM,KAAK,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC;IAC3E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC1F,CAAC;IACD,OAAO,MAAM,CAAC,WAAW,CACvB,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAC1E,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,OAAuB,EACvB,MAAwB;IAExB,OAAO,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC;AACtD,CAAC;AAED,SAAS,OAAO,CAAC,OAA8B,EAAE,UAA4B;IAC3E,OAAO,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC;AACvF,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,eAAe,CAC7B,OA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4
+ readonly compareAt?: DisplayMoney;
5
+ }
6
+ /**
7
+ * What the chosen variant costs, and what it cost before, where that saves
8
+ * anything or where the two cannot be told apart: the variant's own price
9
+ * where the Provider answered one, the product's while it answered none. The
10
+ * product's own price is the cheapest variant's, so a summary that read it
11
+ * quoted a box the shopper had not chosen.
12
+ */
13
+ export declare function chosenPrice(product: ProductDisplay, variant: ProductVariantDisplay | null): ChosenPrice;
14
+ export interface VariantRow {
15
+ readonly variant: ProductVariantDisplay;
16
+ readonly name: string;
17
+ readonly detail: string;
18
+ readonly price: DisplayMoney;
19
+ readonly compareAtPrice?: DisplayMoney;
20
+ readonly available: boolean;
21
+ }
22
+ /**
23
+ * One row per variant, for a buy box that offers the variants as a priced
24
+ * list: the first option's value names it, the others follow it, and each
25
+ * carries its own price. A product the merchant gave no choice offers none.
26
+ */
27
+ export declare function variantRows(product: ProductDisplay): VariantRow[];
28
+ /**
29
+ * A variant in one line, its last option's value first: the size or the weight
30
+ * that tells it from its siblings stays in view where the line is cut short.
31
+ */
32
+ export declare function variantLabel(product: ProductDisplay, variant: ProductVariantDisplay): string;
33
+ //# sourceMappingURL=variant-rows.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant-rows.d.ts","sourceRoot":"","sources":["../src/variant-rows.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAInG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;CACnC;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,cAAc,EACvB,OAAO,EAAE,qBAAqB,GAAG,IAAI,GACpC,WAAW,CAOb;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC;IACvC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAQD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,UAAU,EAAE,CAcjE;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,qBAAqB,GAAG,MAAM,CAE5F"}
@@ -0,0 +1,52 @@
1
+ import { productChoices } from './buy-box.js';
2
+ import { moneyAmount } from './money.js';
3
+ /**
4
+ * What the chosen variant costs, and what it cost before, where that saves
5
+ * anything or where the two cannot be told apart: the variant's own price
6
+ * where the Provider answered one, the product's while it answered none. The
7
+ * product's own price is the cheapest variant's, so a summary that read it
8
+ * quoted a box the shopper had not chosen.
9
+ */
10
+ export function chosenPrice(product, variant) {
11
+ const price = variant?.price ?? product.price;
12
+ const compare = variant?.price === undefined ? product.compareAtPrice : variant.compareAtPrice;
13
+ if (compare === undefined || compare.currencyCode !== price.currencyCode)
14
+ return { price };
15
+ const now = moneyAmount(price);
16
+ const then = moneyAmount(compare);
17
+ return now !== null && then !== null && then <= now ? { price } : { price, compareAt: compare };
18
+ }
19
+ function valuesOf(product, variant) {
20
+ return productChoices(product)
21
+ .map((group) => variant.selectedOptions.find((pair) => pair.name === group.name)?.value)
22
+ .filter((value) => value !== undefined && value !== '');
23
+ }
24
+ /**
25
+ * One row per variant, for a buy box that offers the variants as a priced
26
+ * list: the first option's value names it, the others follow it, and each
27
+ * carries its own price. A product the merchant gave no choice offers none.
28
+ */
29
+ export function variantRows(product) {
30
+ if (productChoices(product).length === 0)
31
+ return [];
32
+ return (product.variants ?? []).map((variant) => {
33
+ const values = valuesOf(product, variant);
34
+ const { price, compareAt } = chosenPrice(product, variant);
35
+ return {
36
+ variant,
37
+ name: values[0] ?? variant.title,
38
+ detail: values.slice(1).join(' · '),
39
+ price,
40
+ ...(compareAt === undefined ? {} : { compareAtPrice: compareAt }),
41
+ available: variant.available,
42
+ };
43
+ });
44
+ }
45
+ /**
46
+ * A variant in one line, its last option's value first: the size or the weight
47
+ * that tells it from its siblings stays in view where the line is cut short.
48
+ */
49
+ export function variantLabel(product, variant) {
50
+ return valuesOf(product, variant).reverse().join(' · ');
51
+ }
52
+ //# sourceMappingURL=variant-rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variant-rows.js","sourceRoot":"","sources":["../src/variant-rows.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAOzC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,OAAuB,EACvB,OAAqC;IAErC,MAAM,KAAK,GAAG,OAAO,EAAE,KAAK,IAAI,OAAO,CAAC,KAAK,CAAC;IAC9C,MAAM,OAAO,GAAG,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC;IAC/F,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,YAAY,KAAK,KAAK,CAAC,YAAY;QAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC3F,MAAM,GAAG,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,OAAO,GAAG,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAClG,CAAC;AAWD,SAAS,QAAQ,CAAC,OA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,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC1D,CAAC"}
package/dist/version.d.ts CHANGED
@@ -4,6 +4,6 @@
4
4
  * The major is the compatibility line: a Shop package built against another
5
5
  * major never meets this runtime, and a major bump is an announced event.
6
6
  */
7
- export declare const CONTRACT_VERSION = "4.6.0";
8
- export declare const CONTRACT_MAJOR = 4;
7
+ export declare const CONTRACT_VERSION = "5.16.0";
8
+ export declare const CONTRACT_MAJOR = 5;
9
9
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,eAAO,MAAM,cAAc,IAAI,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,WAAW,CAAC;AAEzC,eAAO,MAAM,cAAc,IAAI,CAAC"}
package/dist/version.js CHANGED
@@ -4,6 +4,6 @@
4
4
  * The major is the compatibility line: a Shop package built against another
5
5
  * major never meets this runtime, and a major bump is an announced event.
6
6
  */
7
- export const CONTRACT_VERSION = '4.6.0';
8
- export const CONTRACT_MAJOR = 4;
7
+ export const CONTRACT_VERSION = '5.16.0';
8
+ export const CONTRACT_MAJOR = 5;
9
9
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC;AAExC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC"}
package/dist/words.d.ts CHANGED
@@ -51,6 +51,7 @@ declare const ENGLISH_WORDS: {
51
51
  readonly 'product.add_failed': "Could not add";
52
52
  readonly 'product.add_to_cart_compact': "Add to cart";
53
53
  readonly 'product.added_compact': "Added ✓";
54
+ readonly 'product.adding': "Adding";
54
55
  readonly 'product.notify_me': "Notify me";
55
56
  readonly 'product.notify_me_done': "We will tell you ✓";
56
57
  readonly 'product.quantity': "Quantity";
@@ -68,12 +69,25 @@ declare const ENGLISH_WORDS: {
68
69
  readonly 'reviews.count': "{count} reviews";
69
70
  readonly 'product.brand': "Brand";
70
71
  readonly 'product.type': "Type";
72
+ readonly 'product.choose_option': "Choose an option";
71
73
  readonly 'section.show_all': "Show all";
72
74
  readonly 'header.menu': "Menu";
73
75
  readonly 'header.close': "Close";
74
76
  readonly 'header.categories': "Categories";
75
77
  readonly 'header.language_country': "Language & country";
78
+ readonly 'announcement.copy_code': "Copy code";
79
+ readonly 'announcement.copied': "Copied";
76
80
  readonly 'promo.promotion': "Promotion";
81
+ readonly 'promo.card_of': "Promotion {position} of {count}";
82
+ readonly 'promo.card_named': "{label}, {position} of {count}";
83
+ readonly 'promo.cards_zero': "No promotions";
84
+ readonly 'promo.cards_one': "1 promotion";
85
+ readonly 'promo.cards_two': "{count} promotions";
86
+ readonly 'promo.cards_few': "{count} promotions";
87
+ readonly 'promo.cards_many': "{count} promotions";
88
+ readonly 'promo.cards_other': "{count} promotions";
89
+ readonly 'hero.page_of': "Page {page} of {pages}";
90
+ readonly 'rail.scroll_hint': "Scroll sideways for more";
77
91
  readonly 'shipping.remaining': "Add {amount} more and your shipping is free";
78
92
  readonly 'shipping.reached': "Your shipping is free";
79
93
  readonly 'shipping.fee': "Shipping is {amount} until you do";
@@ -81,6 +95,7 @@ declare const ENGLISH_WORDS: {
81
95
  readonly 'search.placeholder': "Search";
82
96
  readonly 'search.prompt': "Search the shop for a product";
83
97
  readonly 'search.no_results': "Nothing matched your search";
98
+ readonly 'search.searching': "Searching";
84
99
  readonly 'countdown.days': "Days";
85
100
  readonly 'countdown.hours': "Hours";
86
101
  readonly 'countdown.minutes': "Minutes";
@@ -92,6 +107,7 @@ declare const ENGLISH_WORDS: {
92
107
  readonly 'notifications.on': "On";
93
108
  readonly 'notifications.off': "Off";
94
109
  readonly 'screen.back': "Back";
110
+ readonly 'screen.share': "Share";
95
111
  readonly 'screen.unavailable': "Not available";
96
112
  readonly 'screen.unavailable_body': "This page is not part of the shop any more.";
97
113
  readonly 'screen.unreachable': "The shop could not be reached.";
@@ -107,12 +123,168 @@ declare const ENGLISH_WORDS: {
107
123
  readonly 'account.notifications': "Notifications";
108
124
  readonly 'account.privacy': "Privacy";
109
125
  readonly 'account.share_diagnostics': "Share app diagnostics";
126
+ readonly 'account.sign_in': "Sign in";
127
+ readonly 'account.signed_out_title': "Welcome";
128
+ readonly 'account.signed_out_subtitle': "Sign in to see your orders, addresses and profile.";
129
+ readonly 'account.sign_out': "Log out";
130
+ readonly 'account.email': "Email";
131
+ readonly 'account.continue': "Continue";
132
+ readonly 'account.code_note': "Shopify will email you a code on the next step.";
133
+ readonly 'account.greeting': "Hello, {name}";
134
+ readonly 'account.session_ended': "Your session ended. Sign in again when you need your account.";
135
+ readonly 'account.sign_in_failed': "Could not sign in. Please try again.";
136
+ readonly 'account.settings': "Settings";
137
+ readonly 'account.settings_close': "Close";
138
+ readonly 'account.privacy_policy': "Privacy policy";
139
+ readonly 'account.email_invalid': "Enter a valid email address.";
140
+ readonly 'account.edit_profile': "Edit profile";
141
+ readonly 'account.orders': "Orders";
142
+ readonly 'account.addresses': "Addresses";
143
+ readonly 'account.profile': "Profile";
144
+ readonly 'account.delete_account': "Delete account";
145
+ readonly 'account.complete_profile': "Tell us about you";
146
+ readonly 'account.profile_save': "Save";
147
+ readonly 'account.profile_answer_needed': "This answer is needed.";
148
+ readonly 'account.profile_failed': "Could not save your profile. Please try again.";
149
+ readonly 'account.profile_marketing': "Email me offers and news";
150
+ readonly 'account.manage_contact': "Manage email and phone";
151
+ readonly 'account.profile_choose': "Choose";
152
+ readonly 'account.profile_title': "Profile";
153
+ readonly 'account.date_clear': "Clear";
154
+ readonly 'account.deletion_title': "Delete your account";
155
+ readonly 'account.deletion_erased': "Your profile, your name and your saved addresses are erased.";
156
+ readonly 'account.deletion_orders_kept': "Your orders stay with the store, because the law requires it to keep them.";
157
+ readonly 'account.deletion_delay': "Shopify erases your data 10 days after this request.";
158
+ readonly 'account.deletion_confirm': "Delete my account";
159
+ readonly 'account.deletion_keep': "Keep my account";
160
+ readonly 'account.deletion_failed': "Could not delete your account. Please try again.";
161
+ readonly 'account.log_out_title': "Log out?";
162
+ readonly 'account.log_out_body': "You will need to sign in again to see your orders and addresses.";
163
+ readonly 'account.log_out_confirm': "Log out";
164
+ readonly 'account.log_out_stay': "Stay signed in";
165
+ readonly 'order.empty': "No orders yet";
166
+ readonly 'order.open': "Open order";
167
+ readonly 'order.items': "Items";
168
+ readonly 'order.tax': "Tax";
169
+ readonly 'order.shipping_address': "Shipping address";
170
+ readonly 'order.delivery_status': "Delivery status";
171
+ readonly 'order.shipment': "Shipment";
172
+ readonly 'order.shipment_failed': "Shipment failed";
173
+ readonly 'order.tracking': "Tracking number";
174
+ readonly 'order.track': "Track with the carrier";
175
+ readonly 'order.expected': "Expected {date}";
176
+ readonly 'order.buy_again': "Buy again";
177
+ readonly 'order.nothing_to_buy': "These items are no longer available";
178
+ readonly 'order.more': "More about this order";
179
+ readonly 'order.details': "Order details";
180
+ readonly 'order.track_order': "Track order";
181
+ readonly 'order.item_count_zero': "No items";
182
+ readonly 'order.item_count_one': "1 item";
183
+ readonly 'order.item_count_two': "{count} items";
184
+ readonly 'order.item_count_few': "{count} items";
185
+ readonly 'order.item_count_many': "{count} items";
186
+ readonly 'order.item_count_other': "{count} items";
187
+ readonly 'order.more_lines': "{count} more";
188
+ readonly 'order.subtotal_items': "Subtotal ({items})";
189
+ readonly 'order.not_shipped': "This order has not shipped yet";
190
+ readonly 'order.cancelled': "Cancelled";
191
+ readonly 'order.delivered': "Delivered";
192
+ readonly 'order.fulfillment.unfulfilled': "Processing";
193
+ readonly 'order.fulfillment.partially_fulfilled': "Partly shipped";
194
+ readonly 'order.fulfillment.fulfilled': "Shipped";
195
+ readonly 'order.fulfillment.in_progress': "In progress";
196
+ readonly 'order.fulfillment.on_hold': "On hold";
197
+ readonly 'order.fulfillment.open': "Open";
198
+ readonly 'order.fulfillment.pending_fulfillment': "Pending";
199
+ readonly 'order.fulfillment.restocked': "Restocked";
200
+ readonly 'order.fulfillment.scheduled': "Scheduled";
201
+ readonly 'order.payment.authorized': "Authorized";
202
+ readonly 'order.payment.expired': "Expired";
203
+ readonly 'order.payment.paid': "Paid";
204
+ readonly 'order.payment.partially_paid': "Partly paid";
205
+ readonly 'order.payment.partially_refunded': "Partly refunded";
206
+ readonly 'order.payment.pending': "Payment pending";
207
+ readonly 'order.payment.refunded': "Refunded";
208
+ readonly 'order.payment.voided': "Voided";
209
+ readonly 'order.event.attempted_delivery': "Delivery attempted";
210
+ readonly 'order.event.carrier_picked_up': "Picked up by the carrier";
211
+ readonly 'order.event.confirmed': "Confirmed";
212
+ readonly 'order.event.delayed': "Delayed";
213
+ readonly 'order.event.failure': "Delivery failed";
214
+ readonly 'order.event.in_transit': "In transit";
215
+ readonly 'order.event.label_printed': "Label printed";
216
+ readonly 'order.event.label_purchased': "Label purchased";
217
+ readonly 'order.event.out_for_delivery': "Out for delivery";
218
+ readonly 'order.event.picked_up': "Picked up";
219
+ readonly 'order.event.ready_for_pickup': "Ready for pickup";
220
+ readonly 'address.default': "Default";
221
+ readonly 'address.edit': "Edit";
222
+ readonly 'address.delete': "Delete";
223
+ readonly 'address.set_default': "Set as default";
224
+ readonly 'address.default_before_delete': "Make another address the default before you delete this one.";
225
+ readonly 'address.delete_confirm': "Delete this address?";
226
+ readonly 'address.keep': "Keep";
227
+ readonly 'address.empty': "No saved addresses yet";
228
+ readonly 'address.change_failed': "Could not update your addresses";
229
+ readonly 'address.add_title': "Add an address";
230
+ readonly 'address.edit_title': "Edit address";
231
+ readonly 'address.save': "Save address";
232
+ readonly 'address.save_failed': "Could not save the address";
233
+ readonly 'address.load_failed': "Could not load this address";
234
+ readonly 'address.choose': "Choose";
235
+ readonly 'address.country': "Country/region";
236
+ readonly 'address.first_name': "First name";
237
+ readonly 'address.last_name': "Last name";
238
+ readonly 'address.company': "Company (optional)";
239
+ readonly 'address.address1': "Address";
240
+ readonly 'address.address2': "Apartment, suite, etc (optional)";
241
+ readonly 'address.city': "City";
242
+ readonly 'address.zone': "Region";
243
+ readonly 'address.zip': "Postal code";
244
+ readonly 'address.phone': "Phone (optional)";
245
+ readonly 'listing.products_zero': "products";
246
+ readonly 'listing.products_one': "product";
247
+ readonly 'listing.products_two': "products";
248
+ readonly 'listing.products_few': "products";
249
+ readonly 'listing.products_many': "products";
250
+ readonly 'listing.products_other': "products";
251
+ readonly 'listing.grid': "Grid view";
252
+ readonly 'listing.list': "List view";
253
+ readonly 'listing.sort_by': "Sort by";
254
+ readonly 'listing.close': "Close";
255
+ readonly 'listing.sort.collection_default': "Featured";
256
+ readonly 'listing.sort.best_selling': "Best selling";
257
+ readonly 'listing.sort.newest': "Newest";
258
+ readonly 'listing.sort.oldest': "Oldest";
259
+ readonly 'listing.sort.price_asc': "Price: low to high";
260
+ readonly 'listing.sort.price_desc': "Price: high to low";
261
+ readonly 'listing.sort.title': "Name: A to Z";
262
+ readonly 'listing.sort.title_desc': "Name: Z to A";
263
+ readonly 'listing.filter': "Filter";
264
+ readonly 'listing.filter_title': "Filter results";
265
+ readonly 'listing.filter_apply': "Show results";
266
+ readonly 'listing.filter_clear': "Clear";
267
+ readonly 'listing.filter_clear_all': "Clear all";
268
+ readonly 'listing.filter_remove': "Remove";
269
+ readonly 'listing.filter_on': "{count} on";
270
+ readonly 'listing.filter_none': "No products match these filters.";
271
+ readonly 'listing.filter_min': "Min";
272
+ readonly 'listing.filter_max': "Max";
273
+ readonly 'listing.filter_in_stock': "In stock only";
274
+ readonly 'listing.filter_in_stock_hint': "Hide products that are sold out";
110
275
  };
111
276
  export type WordKey = keyof typeof ENGLISH_WORDS;
112
277
  /** Every functional word key, for a caller that walks the catalog. */
113
278
  export declare const WORD_KEYS: readonly WordKey[];
114
279
  /** The languages the catalog answers in its own right. */
115
280
  export declare const CATALOG_LANGUAGES: readonly LocaleCode[];
281
+ /**
282
+ * The three facts the Deletion Sheet draws under the merchant's own words, in
283
+ * the order it draws them: what is erased, what the store keeps and when
284
+ * Shopify acts. The merchant edits the tone above them and never this list, so
285
+ * every reader of the sheet says the same three things.
286
+ */
287
+ export declare const DELETION_FACTS: readonly ["account.deletion_erased", "account.deletion_orders_kept", "account.deletion_delay"];
116
288
  export interface PlatformWords {
117
289
  /** The platform's own word for this key, in the buyer's language. */
118
290
  own(key: WordKey): string;
@@ -122,12 +294,25 @@ export interface PlatformWords {
122
294
  */
123
295
  merchantOr(text: LocalizedText | undefined, key: WordKey): string;
124
296
  }
297
+ /** A number written in the form the buyer's language counts it in, over the six forms a counted word carries. */
298
+ export declare function countedWord(stem: 'cart.items' | 'promo.cards' | 'order.item_count' | 'listing.products', count: number, language: LocaleCode, defaultLanguage: LocaleCode): string;
125
299
  /**
126
300
  * How many items a cart holds, written in the form the buyer's language counts
127
301
  * that number in. English and Turkish read no item count for an empty cart as
128
302
  * a plural of nothing, which is why the zero form is in the catalog too.
129
303
  */
130
304
  export declare function cartItemCount(count: number, language: LocaleCode, defaultLanguage: LocaleCode): string;
305
+ /**
306
+ * How many items an order holds, written in the form the buyer's language
307
+ * counts that number in. A cart and an order count their items apart, so the
308
+ * order's word is the catalog's own and never the cart's.
309
+ */
310
+ export declare function orderItemCount(count: number, language: LocaleCode, defaultLanguage: LocaleCode): string;
311
+ /**
312
+ * The subtotal row of an order that says how many items the order holds,
313
+ * "Subtotal (2 items)", the count in the form the buyer's language counts it in.
314
+ */
315
+ export declare function orderSubtotalLabel(count: number, language: LocaleCode, defaultLanguage: LocaleCode): string;
131
316
  /**
132
317
  * The catalog bound to one buyer: their language for the platform's own words,
133
318
  * their language and the Shop's default for a merchant's override of one.
@@ -1 +1 @@
1
- {"version":3,"file":"words.d.ts","sourceRoot":"","sources":["../src/words.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGzE;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGT,CAAC;AAEX,MAAM,MAAM,OAAO,GAAG,MAAM,OAAO,aAAa,CAAC;AA8MjD,sEAAsE;AACtE,eAAO,MAAM,SAAS,EAAE,SAAS,OAAO,EAA4C,CAAC;AAErF,0DAA0D;AAC1D,eAAO,MAAM,iBAAiB,EAAE,SAAS,UAAU,EAAyB,CAAC;AAE7E,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,GAAG,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B;;;OAGG;IACH,UAAU,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC;CACnE;AA4BD;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,UAAU,EACpB,eAAe,EAAE,UAAU,GAC1B,MAAM,CAKR;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,GAAG,aAAa,CAO9F"}
1
+ {"version":3,"file":"words.d.ts","sourceRoot":"","sources":["../src/words.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGzE;;;;;;;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