@nextblock-cms/ecom 0.19.0 → 0.19.2

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 (144) hide show
  1. package/index.cjs.js +1 -1
  2. package/index.es.js +26 -25
  3. package/lib/CurrencyProvider.cjs.js +1 -1
  4. package/lib/CurrencyProvider.es.js +41 -45
  5. package/lib/PaymentReadinessProvider.cjs.js +1 -1
  6. package/lib/PaymentReadinessProvider.es.js +15 -19
  7. package/lib/cart-store.cjs.js +1 -1
  8. package/lib/cart-store.d.ts +4 -0
  9. package/lib/cart-store.es.js +77 -69
  10. package/lib/components/AccountNavigationMenu.cjs.js +1 -1
  11. package/lib/components/AccountNavigationMenu.es.js +44 -62
  12. package/lib/components/AddToCartButton.cjs.js +1 -1
  13. package/lib/components/AddToCartButton.es.js +50 -78
  14. package/lib/components/Cart.cjs.js +1 -1
  15. package/lib/components/Cart.es.js +154 -381
  16. package/lib/components/CartDrawer.cjs.js +1 -1
  17. package/lib/components/CartDrawer.es.js +143 -297
  18. package/lib/components/CartIcon.cjs.js +1 -1
  19. package/lib/components/CartIcon.es.js +21 -47
  20. package/lib/components/Checkout.cjs.js +1 -1
  21. package/lib/components/Checkout.es.js +814 -1614
  22. package/lib/components/CouponForm.cjs.js +1 -1
  23. package/lib/components/CouponForm.es.js +104 -155
  24. package/lib/components/CurrencySwitcher.cjs.js +1 -1
  25. package/lib/components/CurrencySwitcher.es.js +14 -33
  26. package/lib/components/CustomerProfileForm.cjs.js +1 -1
  27. package/lib/components/CustomerProfileForm.es.js +264 -672
  28. package/lib/components/FeaturedProduct.cjs.js +1 -1
  29. package/lib/components/FeaturedProduct.es.js +46 -125
  30. package/lib/components/FreemiusLicensePanel.cjs.js +1 -1
  31. package/lib/components/FreemiusLicensePanel.es.js +45 -125
  32. package/lib/components/InvoiceDocument.cjs.js +1 -1
  33. package/lib/components/InvoiceDocument.es.js +148 -487
  34. package/lib/components/InvoiceViewerShell.cjs.js +2 -2
  35. package/lib/components/InvoiceViewerShell.d.ts +4 -1
  36. package/lib/components/InvoiceViewerShell.es.js +59 -142
  37. package/lib/components/ProductCard.cjs.js +1 -1
  38. package/lib/components/ProductCard.d.ts +3 -1
  39. package/lib/components/ProductCard.es.js +128 -242
  40. package/lib/components/ProductDetailsLayout.cjs.js +1 -1
  41. package/lib/components/ProductDetailsLayout.es.js +311 -652
  42. package/lib/components/ProductGallery.cjs.js +1 -1
  43. package/lib/components/ProductGallery.d.ts +2 -0
  44. package/lib/components/ProductGallery.es.js +37 -66
  45. package/lib/components/ProductGrid.cjs.js +1 -1
  46. package/lib/components/ProductGrid.es.js +23 -32
  47. package/lib/components/ShippingEstimator.cjs.js +1 -1
  48. package/lib/components/ShippingEstimator.es.js +118 -231
  49. package/lib/components/SimpleTiptapRenderer.cjs.js +1 -1
  50. package/lib/components/SimpleTiptapRenderer.es.js +111 -294
  51. package/lib/components/SubscriptionSelector.cjs.js +1 -1
  52. package/lib/components/SubscriptionSelector.es.js +120 -181
  53. package/lib/invoice.cjs.js +1 -1
  54. package/lib/invoice.d.ts +1 -1
  55. package/lib/invoice.es.js +6 -5
  56. package/lib/pages/cms/coupons/CouponEditorForm.cjs.js +1 -1
  57. package/lib/pages/cms/coupons/CouponEditorForm.es.js +115 -375
  58. package/lib/pages/cms/coupons/CouponsPage.cjs.js +2 -2
  59. package/lib/pages/cms/coupons/CouponsPage.es.js +116 -368
  60. package/lib/pages/cms/coupons/CreateCouponDialog.cjs.js +1 -1
  61. package/lib/pages/cms/coupons/CreateCouponDialog.es.js +26 -62
  62. package/lib/pages/cms/coupons/EditCouponPage.cjs.js +1 -1
  63. package/lib/pages/cms/coupons/EditCouponPage.es.js +35 -71
  64. package/lib/pages/cms/coupons/ProductScopePicker.cjs.js +1 -1
  65. package/lib/pages/cms/coupons/ProductScopePicker.es.js +72 -167
  66. package/lib/pages/cms/orders/ExportReportsDialog.cjs.js +1 -1
  67. package/lib/pages/cms/orders/ExportReportsDialog.es.js +87 -247
  68. package/lib/pages/cms/orders/OrderDetailPage.cjs.js +1 -1
  69. package/lib/pages/cms/orders/OrderDetailPage.es.js +95 -283
  70. package/lib/pages/cms/orders/OrderPrintButton.cjs.js +1 -1
  71. package/lib/pages/cms/orders/OrderPrintButton.es.js +9 -21
  72. package/lib/pages/cms/orders/OrderStatusForm.cjs.js +1 -1
  73. package/lib/pages/cms/orders/OrderStatusForm.es.js +46 -106
  74. package/lib/pages/cms/orders/OrdersPage.cjs.js +1 -1
  75. package/lib/pages/cms/orders/OrdersPage.es.js +78 -257
  76. package/lib/pages/cms/payments/PaymentsClient.cjs.js +1 -1
  77. package/lib/pages/cms/payments/PaymentsClient.es.js +192 -580
  78. package/lib/pages/cms/payments/PaymentsPage.cjs.js +1 -1
  79. package/lib/pages/cms/payments/PaymentsPage.es.js +14 -22
  80. package/lib/pages/cms/products/ProductsPage.cjs.js +1 -1
  81. package/lib/pages/cms/products/ProductsPage.es.js +47 -87
  82. package/lib/pages/cms/products/_id_/edit/EditProductPage.cjs.js +1 -1
  83. package/lib/pages/cms/products/_id_/edit/EditProductPage.es.js +97 -177
  84. package/lib/pages/cms/products/attributes/AttributeManagementPage.cjs.js +1 -1
  85. package/lib/pages/cms/products/attributes/AttributeManagementPage.es.js +40 -84
  86. package/lib/pages/cms/products/attributes/components/AttributeManager.cjs.js +1 -1
  87. package/lib/pages/cms/products/attributes/components/AttributeManager.es.js +192 -455
  88. package/lib/pages/cms/products/categories/CategoryManagementPage.cjs.js +1 -1
  89. package/lib/pages/cms/products/categories/CategoryManagementPage.es.js +28 -72
  90. package/lib/pages/cms/products/categories/components/CategoryManager.cjs.js +1 -1
  91. package/lib/pages/cms/products/categories/components/CategoryManager.es.js +183 -490
  92. package/lib/pages/cms/products/components/CopyProductFromLanguage.cjs.js +1 -1
  93. package/lib/pages/cms/products/components/CopyProductFromLanguage.es.js +69 -177
  94. package/lib/pages/cms/products/components/CurrencyPriceFields.cjs.js +1 -1
  95. package/lib/pages/cms/products/components/CurrencyPriceFields.es.js +102 -213
  96. package/lib/pages/cms/products/components/DeleteProductButton.cjs.js +1 -1
  97. package/lib/pages/cms/products/components/DeleteProductButton.es.js +25 -45
  98. package/lib/pages/cms/products/components/FreemiusPricingDashboard.cjs.js +1 -1
  99. package/lib/pages/cms/products/components/FreemiusPricingDashboard.es.js +58 -202
  100. package/lib/pages/cms/products/components/ProductCategorySelector.cjs.js +1 -1
  101. package/lib/pages/cms/products/components/ProductCategorySelector.es.js +89 -235
  102. package/lib/pages/cms/products/components/ProductForm.cjs.js +1 -1
  103. package/lib/pages/cms/products/components/ProductForm.es.js +526 -1110
  104. package/lib/pages/cms/products/components/ProductMediaManager.cjs.js +1 -1
  105. package/lib/pages/cms/products/components/ProductMediaManager.es.js +63 -154
  106. package/lib/pages/cms/products/components/ProductsBulkTable.cjs.js +1 -1
  107. package/lib/pages/cms/products/components/ProductsBulkTable.es.js +213 -544
  108. package/lib/pages/cms/products/components/SaleScheduleFields.cjs.js +1 -1
  109. package/lib/pages/cms/products/components/SaleScheduleFields.es.js +91 -207
  110. package/lib/pages/cms/products/components/SyncFreemiusButton.cjs.js +1 -1
  111. package/lib/pages/cms/products/components/SyncFreemiusButton.es.js +16 -28
  112. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.cjs.js +2 -2
  113. package/lib/pages/cms/products/components/SyncFreemiusPricingButton.es.js +25 -37
  114. package/lib/pages/cms/products/components/VariationsEditor.cjs.js +1 -1
  115. package/lib/pages/cms/products/components/VariationsEditor.es.js +261 -492
  116. package/lib/pages/cms/products/inventory/InventoryPage.cjs.js +1 -1
  117. package/lib/pages/cms/products/inventory/InventoryPage.es.js +12 -32
  118. package/lib/pages/cms/products/inventory/InventoryTableClient.cjs.js +2 -2
  119. package/lib/pages/cms/products/inventory/InventoryTableClient.es.js +145 -365
  120. package/lib/pages/cms/products/new/NewProductPage.cjs.js +1 -1
  121. package/lib/pages/cms/products/new/NewProductPage.es.js +30 -42
  122. package/lib/pages/cms/shipping/ShippingPage.cjs.js +2 -2
  123. package/lib/pages/cms/shipping/ShippingPage.es.js +155 -507
  124. package/lib/pages/cms/shipping/components/RateForm.cjs.js +1 -1
  125. package/lib/pages/cms/shipping/components/RateForm.es.js +334 -717
  126. package/lib/pages/cms/shipping/components/ZoneForm.cjs.js +1 -1
  127. package/lib/pages/cms/shipping/components/ZoneForm.es.js +158 -392
  128. package/lib/pages/cms/taxes/TaxesPage.cjs.js +1 -1
  129. package/lib/pages/cms/taxes/TaxesPage.es.js +119 -447
  130. package/lib/pages/cms/taxes/components/TaxRateForm.cjs.js +1 -1
  131. package/lib/pages/cms/taxes/components/TaxRateForm.es.js +52 -156
  132. package/lib/product-context.cjs.js +1 -1
  133. package/lib/product-context.es.js +10 -14
  134. package/lib/trials.cjs.js +1 -1
  135. package/lib/trials.d.ts +10 -3
  136. package/lib/trials.es.js +28 -21
  137. package/lib/types.d.ts +2 -0
  138. package/lib/use-price-formatter.cjs.js +1 -0
  139. package/lib/use-price-formatter.d.ts +11 -0
  140. package/lib/use-price-formatter.es.js +13 -0
  141. package/lib/variation-utils.cjs.js +1 -1
  142. package/lib/variation-utils.d.ts +10 -0
  143. package/lib/variation-utils.es.js +139 -123
  144. package/package.json +4 -4
@@ -1,72 +1,72 @@
1
- import { normalizeSalePriceMap as S, normalizePriceMap as g, isSaleWindowActive as E } from "./currency.es.js";
1
+ import { normalizeSalePriceMap as S, normalizePriceMap as g, isSaleWindowActive as B } from "./currency.es.js";
2
2
  function p(e) {
3
- return !e || typeof e != "object" || Array.isArray(e) ? null : Object.entries(e).reduce((r, [i, t]) => (typeof t == "string" && t.trim() && (r[i] = t.trim()), r), {});
3
+ return !e || typeof e != "object" || Array.isArray(e) ? null : Object.entries(e).reduce((n, [i, t]) => (typeof t == "string" && t.trim() && (n[i] = t.trim()), n), {});
4
4
  }
5
- function f(e, r, i) {
6
- return !i || !r ? e : r[i]?.trim() || e;
5
+ function f(e, n, i) {
6
+ return !i || !n ? e : n[i]?.trim() || e;
7
7
  }
8
- function j(e, r) {
9
- return f(e.name, e.name_translations, r);
8
+ function j(e, n) {
9
+ return f(e.name, e.name_translations, n);
10
10
  }
11
- function L(e, r) {
12
- return f(e.value, e.value_translations, r);
11
+ function L(e, n) {
12
+ return f(e.value, e.value_translations, n);
13
13
  }
14
- function B(e) {
14
+ function I(e) {
15
15
  return e ? e.startsWith("http") ? e : process.env.NEXT_PUBLIC_R2_BASE_URL ? `${process.env.NEXT_PUBLIC_R2_BASE_URL}/${e}` : process.env.NEXT_PUBLIC_SUPABASE_URL ? `${process.env.NEXT_PUBLIC_SUPABASE_URL}/storage/v1/object/public/media/${e}` : e : null;
16
16
  }
17
- function I(e) {
17
+ function M(e) {
18
18
  return e.toLowerCase().trim().replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "").replace(/-+/g, "-").replace(/^-|-$/g, "");
19
19
  }
20
20
  function y(e) {
21
21
  return [...e].sort().join("__");
22
22
  }
23
23
  function T(e) {
24
- return e.map((r) => r.term_value).join(" / ");
24
+ return e.map((n) => n.term_value).join(" / ");
25
25
  }
26
- function M(e) {
26
+ function U(e) {
27
27
  return e.length === 0 ? [] : e.reduce(
28
- (r, i) => r.flatMap((t) => i.map((s) => [...t, s])),
28
+ (n, i) => n.flatMap((t) => i.map((s) => [...t, s])),
29
29
  [[]]
30
30
  );
31
31
  }
32
32
  function P(e) {
33
33
  const {
34
- baseSku: r,
34
+ baseSku: n,
35
35
  basePrice: i,
36
36
  basePrices: t = {},
37
37
  baseSalePrice: s = null,
38
- baseSalePrices: n = {},
39
- selectedAttributes: u,
38
+ baseSalePrices: r = {},
39
+ selectedAttributes: a,
40
40
  previousVariants: c = []
41
41
  } = e;
42
- if (u.length === 0 || u.some((l) => l.terms.length === 0))
42
+ if (a.length === 0 || a.some((o) => o.terms.length === 0))
43
43
  return [];
44
- const o = new Map(
45
- c.map((l) => [l.combination_key, l])
46
- ), a = u.map(
47
- (l) => l.terms.map((d) => ({
48
- attribute_id: l.attribute_id,
49
- attribute_name: l.attribute_name,
44
+ const u = new Map(
45
+ c.map((o) => [o.combination_key, o])
46
+ ), l = a.map(
47
+ (o) => o.terms.map((d) => ({
48
+ attribute_id: o.attribute_id,
49
+ attribute_name: o.attribute_name,
50
50
  term: d
51
51
  }))
52
52
  );
53
- return M(a).map((l) => {
54
- const d = l.map(({ attribute_id: m, attribute_name: k, term: b }) => ({
53
+ return U(l).map((o) => {
54
+ const d = o.map(({ attribute_id: m, attribute_name: E, term: b }) => ({
55
55
  attribute_id: m,
56
- attribute_name: k,
56
+ attribute_name: E,
57
57
  term_id: b.id,
58
58
  term_value: b.value,
59
59
  term_slug: b.slug
60
- })), A = d.map((m) => m.term_id), h = y(A), _ = o.get(h), v = d.map((m) => (m.term_slug ? m.term_slug : I(m.term_value)).toUpperCase()).filter(Boolean).join("-");
60
+ })), h = d.map((m) => m.term_id), A = y(h), _ = u.get(A), v = d.map((m) => (m.term_slug ? m.term_slug : M(m.term_value)).toUpperCase()).filter(Boolean).join("-");
61
61
  return {
62
62
  id: _?.id,
63
- combination_key: h,
64
- sku: _?.sku || [r.trim(), v].filter(Boolean).join("-"),
63
+ combination_key: A,
64
+ sku: _?.sku || [n.trim(), v].filter(Boolean).join("-"),
65
65
  upc: _?.upc ?? null,
66
66
  price: _?.price ?? i,
67
67
  prices: _?.prices ?? g(t),
68
68
  sale_price: _?.sale_price ?? s,
69
- sale_prices: _?.sale_prices ?? S(n),
69
+ sale_prices: _?.sale_prices ?? S(r),
70
70
  // IMPORTANT (future agents): every per-variant field a user can edit MUST
71
71
  // be carried over from `previous` here. This function re-runs whenever the
72
72
  // variations editor mounts or attributes/base prices change, replacing the
@@ -78,151 +78,166 @@ function P(e) {
78
78
  stock_quantity: _?.stock_quantity ?? 0,
79
79
  main_media_id: _?.main_media_id ?? null,
80
80
  main_image_url: _?.main_image_url ?? null,
81
- attribute_term_ids: A,
81
+ attribute_term_ids: h,
82
82
  selected_options: d,
83
83
  label: T(d)
84
84
  };
85
85
  });
86
86
  }
87
- function N(e) {
88
- const r = {};
87
+ function V(e) {
88
+ const n = {};
89
89
  for (const i of e)
90
90
  for (const t of i.selected_options ?? []) {
91
- const s = new Set(r[t.attribute_id] ?? []);
92
- s.add(t.term_id), r[t.attribute_id] = [...s];
91
+ const s = new Set(n[t.attribute_id] ?? []);
92
+ s.add(t.term_id), n[t.attribute_id] = [...s];
93
93
  }
94
- return r;
94
+ return n;
95
95
  }
96
- function O(e, r) {
97
- const i = Object.values(r).filter(Boolean);
96
+ function N(e, n) {
97
+ const i = Object.values(n).filter(Boolean);
98
98
  return i.length === 0 ? null : e.find(
99
99
  (t) => t.attribute_term_ids.length === i.length && i.every((s) => t.attribute_term_ids.includes(s))
100
100
  ) ?? null;
101
101
  }
102
- function U(e, r, i) {
102
+ function k(e, n, i) {
103
103
  const t = /* @__PURE__ */ new Set();
104
104
  for (const s of e) {
105
- if (!Object.entries(i).every(([c, o]) => !o || c === r ? !0 : s.attribute_term_ids.includes(o)))
105
+ if (!Object.entries(i).every(([c, u]) => !u || c === n ? !0 : s.attribute_term_ids.includes(u)))
106
106
  continue;
107
- const u = s.selected_options.find((c) => c.attribute_id === r);
108
- u && t.add(u.term_id);
107
+ const a = s.selected_options.find((c) => c.attribute_id === n);
108
+ a && t.add(a.term_id);
109
109
  }
110
110
  return t;
111
111
  }
112
- function V(e, r) {
113
- const i = r.find((t) => t.stock_quantity > 0) ?? r[0] ?? null;
112
+ function O(e, n) {
113
+ const i = n.find((t) => t.stock_quantity > 0) ?? n[0] ?? null;
114
114
  return i ? i.selected_options.reduce((t, s) => (t[s.attribute_id] = s.term_id, t), {}) : e.reduce((t, s) => {
115
- const n = s.terms[0];
116
- return n && (t[s.id] = n.id), t;
115
+ const r = s.terms[0];
116
+ return r && (t[s.id] = r.id), t;
117
117
  }, {});
118
118
  }
119
- function w(e, r, i) {
119
+ function w(e, n, i, t, s) {
120
+ const r = { [t]: s };
121
+ for (const a of e) {
122
+ if (a.id === t)
123
+ continue;
124
+ const c = k(n, a.id, r), u = i[a.id];
125
+ if (u && c.has(u)) {
126
+ r[a.id] = u;
127
+ continue;
128
+ }
129
+ const l = a.terms.find((o) => c.has(o.id));
130
+ l && (r[a.id] = l.id);
131
+ }
132
+ return r;
133
+ }
134
+ function x(e, n, i) {
120
135
  const t = { ...i };
121
136
  for (const s of e) {
122
- const n = U(r, s.id, t);
123
- if (n.size === 0) {
137
+ const r = k(n, s.id, t);
138
+ if (r.size === 0) {
124
139
  delete t[s.id];
125
140
  continue;
126
141
  }
127
- const u = t[s.id];
128
- if (u && n.has(u))
142
+ const a = t[s.id];
143
+ if (a && r.has(a))
129
144
  continue;
130
- const c = s.terms.find((o) => n.has(o.id));
145
+ const c = s.terms.find((u) => r.has(u.id));
131
146
  c && (t[s.id] = c.id);
132
147
  }
133
148
  return t;
134
149
  }
135
- function x(e = [], r) {
136
- const i = /* @__PURE__ */ new Map(), t = e.map((n) => {
137
- const u = (n.variant_attribute_mapping || []).map((o) => {
138
- const a = o.product_attribute_terms, l = a?.product_attributes;
139
- if (!a || !l)
150
+ function z(e = [], n) {
151
+ const i = /* @__PURE__ */ new Map(), t = e.map((r) => {
152
+ const a = (r.variant_attribute_mapping || []).map((u) => {
153
+ const l = u.product_attribute_terms, o = l?.product_attributes;
154
+ if (!l || !o)
140
155
  return null;
141
- const d = i.get(l.id) || {
142
- id: l.id,
156
+ const d = i.get(o.id) || {
157
+ id: o.id,
143
158
  name: f(
144
- l.name,
145
- p(l.name_translations),
146
- r
159
+ o.name,
160
+ p(o.name_translations),
161
+ n
147
162
  ),
148
- slug: l.slug,
149
- name_translations: p(l.name_translations),
163
+ slug: o.slug,
164
+ name_translations: p(o.name_translations),
150
165
  terms: [],
151
166
  _termIds: /* @__PURE__ */ new Set()
152
167
  };
153
- return d._termIds.has(a.id) || (d.terms.push({
154
- id: a.id,
155
- attribute_id: a.attribute_id,
168
+ return d._termIds.has(l.id) || (d.terms.push({
169
+ id: l.id,
170
+ attribute_id: l.attribute_id,
156
171
  value: f(
157
- a.value,
158
- p(a.value_translations),
159
- r
172
+ l.value,
173
+ p(l.value_translations),
174
+ n
160
175
  ),
161
- slug: a.slug,
162
- sort_order: a.sort_order ?? null,
163
- value_translations: p(a.value_translations)
164
- }), d._termIds.add(a.id)), i.set(l.id, d), {
165
- attribute_id: l.id,
176
+ slug: l.slug,
177
+ sort_order: l.sort_order ?? null,
178
+ value_translations: p(l.value_translations)
179
+ }), d._termIds.add(l.id)), i.set(o.id, d), {
180
+ attribute_id: o.id,
166
181
  attribute_name: f(
167
- l.name,
168
- p(l.name_translations),
169
- r
182
+ o.name,
183
+ p(o.name_translations),
184
+ n
170
185
  ),
171
- term_id: a.id,
186
+ term_id: l.id,
172
187
  term_value: f(
173
- a.value,
174
- p(a.value_translations),
175
- r
188
+ l.value,
189
+ p(l.value_translations),
190
+ n
176
191
  ),
177
- term_slug: a.slug
192
+ term_slug: l.slug
178
193
  };
179
194
  }).filter(
180
- (o) => o !== null
195
+ (u) => u !== null
181
196
  ).sort(
182
- (o, a) => o.attribute_name.localeCompare(a.attribute_name)
183
- ), c = u.map((o) => o.term_id);
197
+ (u, l) => u.attribute_name.localeCompare(l.attribute_name)
198
+ ), c = a.map((u) => u.term_id);
184
199
  return {
185
- id: n.id,
200
+ id: r.id,
186
201
  combination_key: y(c),
187
- sku: n.sku,
188
- upc: n.upc ?? null,
189
- price: n.price ?? 0,
190
- prices: g(n.prices),
191
- sale_price: n.sale_price ?? null,
192
- sale_prices: S(n.sale_prices),
193
- sale_start_at: n.sale_start_at ?? null,
194
- sale_end_at: n.sale_end_at ?? null,
195
- scheduled_price: n.scheduled_price ?? null,
196
- scheduled_prices: g(n.scheduled_prices),
197
- scheduled_price_at: n.scheduled_price_at ?? null,
198
- stock_quantity: n.stock_quantity ?? 0,
199
- main_media_id: n.main_media_id ?? null,
200
- image_url: B(
201
- n.media?.file_path ?? n.media?.object_key ?? null
202
+ sku: r.sku,
203
+ upc: r.upc ?? null,
204
+ price: r.price ?? 0,
205
+ prices: g(r.prices),
206
+ sale_price: r.sale_price ?? null,
207
+ sale_prices: S(r.sale_prices),
208
+ sale_start_at: r.sale_start_at ?? null,
209
+ sale_end_at: r.sale_end_at ?? null,
210
+ scheduled_price: r.scheduled_price ?? null,
211
+ scheduled_prices: g(r.scheduled_prices),
212
+ scheduled_price_at: r.scheduled_price_at ?? null,
213
+ stock_quantity: r.stock_quantity ?? 0,
214
+ main_media_id: r.main_media_id ?? null,
215
+ image_url: I(
216
+ r.media?.file_path ?? r.media?.object_key ?? null
202
217
  ),
203
218
  attribute_term_ids: c,
204
- selected_options: u,
205
- label: T(u)
219
+ selected_options: a,
220
+ label: T(a)
206
221
  };
207
222
  });
208
- return { attributes: [...i.values()].map((n) => ({
209
- id: n.id,
210
- name: n.name,
211
- slug: n.slug,
212
- name_translations: n.name_translations,
213
- terms: [...n.terms].sort((u, c) => {
214
- const o = u.sort_order ?? Number.MAX_SAFE_INTEGER, a = c.sort_order ?? Number.MAX_SAFE_INTEGER;
215
- return o !== a ? o - a : u.value.localeCompare(c.value);
223
+ return { attributes: [...i.values()].map((r) => ({
224
+ id: r.id,
225
+ name: r.name,
226
+ slug: r.slug,
227
+ name_translations: r.name_translations,
228
+ terms: [...r.terms].sort((a, c) => {
229
+ const u = a.sort_order ?? Number.MAX_SAFE_INTEGER, l = c.sort_order ?? Number.MAX_SAFE_INTEGER;
230
+ return u !== l ? u - l : a.value.localeCompare(c.value);
216
231
  })
217
- })).sort((n, u) => n.name.localeCompare(u.name)), variants: t };
232
+ })).sort((r, a) => r.name.localeCompare(a.name)), variants: t };
218
233
  }
219
- function z(e, r) {
234
+ function C(e, n) {
220
235
  if (!e.length)
221
236
  return null;
222
- const i = e.map((t) => E({
237
+ const i = e.map((t) => B({
223
238
  saleStartAt: t.sale_start_at,
224
239
  saleEndAt: t.sale_end_at,
225
- now: r
240
+ now: n
226
241
  }) && typeof t.sale_price == "number" ? t.sale_price : t.price);
227
242
  return {
228
243
  min: Math.min(...i),
@@ -230,16 +245,17 @@ function z(e, r) {
230
245
  };
231
246
  }
232
247
  export {
248
+ w as applyVariantSelection,
233
249
  y as buildCombinationKey,
234
250
  T as buildVariantLabel,
235
- V as chooseInitialVariantSelections,
236
- N as extractSelectedTermsByAttribute,
237
- O as findMatchingVariant,
251
+ O as chooseInitialVariantSelections,
252
+ V as extractSelectedTermsByAttribute,
253
+ N as findMatchingVariant,
238
254
  P as generateVariantDrafts,
239
- U as getAvailableTermIdsForAttribute,
240
- z as getVariantEffectivePriceRange,
241
- x as mapRawVariantRelations,
242
- w as normalizeSelectionsToAvailableVariants,
255
+ k as getAvailableTermIdsForAttribute,
256
+ C as getVariantEffectivePriceRange,
257
+ z as mapRawVariantRelations,
258
+ x as normalizeSelectionsToAvailableVariants,
243
259
  j as resolveAttributeName,
244
260
  L as resolveTermValue,
245
261
  f as resolveTranslatedText
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nextblock-cms/ecom",
3
- "version": "0.19.0",
3
+ "version": "0.19.2",
4
4
  "license": "AGPL-3.0-or-later",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,9 +11,9 @@
11
11
  },
12
12
  "type": "module",
13
13
  "dependencies": {
14
- "@nextblock-cms/db": "^0.19.0",
15
- "@nextblock-cms/ui": "^0.19.0",
16
- "@nextblock-cms/utils": "^0.19.0",
14
+ "@nextblock-cms/db": "^0.19.2",
15
+ "@nextblock-cms/ui": "^0.19.2",
16
+ "@nextblock-cms/utils": "^0.19.2",
17
17
  "@freemius/checkout": "^1.4.1",
18
18
  "@freemius/sdk": "^0.3.0",
19
19
  "@hookform/resolvers": "^5.2.2",