@nextblock-cms/ecom 0.8.1 → 0.8.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 (71) hide show
  1. package/AddToCartButton-DsSEH9yp.cjs +1 -0
  2. package/AddToCartButton-ffE0DhHu.js +59 -0
  3. package/CouponForm-BI_5SBHQ.js +152 -0
  4. package/CouponForm-D_uu2bLP.cjs +1 -0
  5. package/CurrencyProvider-Cg-Q6ucj.cjs +1 -0
  6. package/CurrencyProvider-OzlRN96V.js +120 -0
  7. package/CurrencyProvider.cjs.js +1 -0
  8. package/CurrencyProvider.es.js +10 -0
  9. package/ProductDetailsLayout-BxJH_BxR.cjs +1 -0
  10. package/ProductDetailsLayout-Dg8dRTYp.js +530 -0
  11. package/ProductGrid-BdL7iglO.cjs +1 -0
  12. package/ProductGrid-D3AWM8sr.js +130 -0
  13. package/actions-AHmBrS5e.cjs +48 -0
  14. package/actions-j5fuSZX-.js +820 -0
  15. package/cart-store.cjs.js +1 -0
  16. package/cart-store.es.js +116 -0
  17. package/components/Cart.cjs.js +1 -0
  18. package/components/Cart.es.js +259 -0
  19. package/components/CartDrawer.cjs.js +1 -0
  20. package/components/CartDrawer.es.js +118 -0
  21. package/components/CartIcon.cjs.js +1 -0
  22. package/components/CartIcon.es.js +33 -0
  23. package/components/Checkout.cjs.js +1 -0
  24. package/components/Checkout.es.js +1020 -0
  25. package/components/CurrencySwitcher.cjs.js +1 -0
  26. package/components/CurrencySwitcher.es.js +17 -0
  27. package/components/FeaturedProduct.cjs.js +1 -0
  28. package/components/FeaturedProduct.es.js +71 -0
  29. package/components/ProductDetailsLayout.cjs.js +1 -0
  30. package/components/ProductDetailsLayout.es.js +19 -0
  31. package/components/ProductGrid.cjs.js +1 -0
  32. package/components/ProductGrid.es.js +6 -0
  33. package/components/SimpleTiptapRenderer.cjs.js +1 -0
  34. package/components/SimpleTiptapRenderer.es.js +187 -0
  35. package/coupon-server-C9ySm3I5.cjs +1 -0
  36. package/coupon-server-DUKVtyYs.js +248 -0
  37. package/currency-constants.cjs.js +1 -0
  38. package/currency-constants.es.js +4 -0
  39. package/currency.cjs.js +1 -0
  40. package/currency.es.js +312 -0
  41. package/customer-C-UPvrYN.cjs +1 -0
  42. package/customer-C3xccjUg.js +57 -0
  43. package/index.cjs.js +1 -1
  44. package/index.es.js +414 -3105
  45. package/invoice-ui-CAnJPu6n.cjs +29 -0
  46. package/invoice-ui-DtpbTJE1.js +2886 -0
  47. package/package.json +10 -5
  48. package/product-actions-CONBF8i6.cjs +251 -0
  49. package/product-actions-DjlIWCMH.js +691 -0
  50. package/resolver-Fz_FKsfX.cjs +7 -0
  51. package/resolver-cfrCaHpE.js +128 -0
  52. package/server-actions/product-actions.cjs.js +1 -0
  53. package/server-actions/product-actions.es.js +15 -0
  54. package/server.cjs.js +27 -27
  55. package/server.es.js +478 -463
  56. package/shipping-actions-BnHjlo2q.js +25 -0
  57. package/shipping-actions-D6zt20gg.cjs +1 -0
  58. package/states-CWYRxV4B.cjs +1 -0
  59. package/states-DlHJezQ1.js +200 -0
  60. package/tax-calculation-Dab89aHd.js +181 -0
  61. package/tax-calculation-MkDKOEkL.cjs +1 -0
  62. package/trials-DvZaOtNy.cjs +1 -0
  63. package/trials-RDcRAZKx.js +29 -0
  64. package/types.cjs.js +1 -0
  65. package/types.es.js +33 -0
  66. package/use-cart.cjs.js +1 -0
  67. package/use-cart.es.js +43 -0
  68. package/variation-utils.cjs.js +1 -0
  69. package/variation-utils.es.js +246 -0
  70. package/invoice-ui-BJZfedDd.cjs +0 -332
  71. package/invoice-ui-GJ1ADAjn.js +0 -5759
package/currency.es.js ADDED
@@ -0,0 +1,312 @@
1
+ import { normalizeCurrencyCode as u, getCurrencyMinorUnitFactor as g, majorUnitAmountToMinor as x, formatPrice as _, minorUnitAmountToMajor as N } from "@nextblock-cms/utils";
2
+ const R = [
3
+ "none",
4
+ "nearest",
5
+ "up",
6
+ "down",
7
+ "charm"
8
+ ], E = {
9
+ AU: "AUD",
10
+ CA: "CAD",
11
+ CH: "CHF",
12
+ CZ: "CZK",
13
+ DE: "EUR",
14
+ DK: "DKK",
15
+ ES: "EUR",
16
+ EU: "EUR",
17
+ FI: "EUR",
18
+ FR: "EUR",
19
+ GB: "GBP",
20
+ IE: "EUR",
21
+ IN: "INR",
22
+ IT: "EUR",
23
+ JP: "JPY",
24
+ MX: "MXN",
25
+ NL: "EUR",
26
+ NO: "NOK",
27
+ NZ: "NZD",
28
+ PL: "PLN",
29
+ PT: "EUR",
30
+ SE: "SEK",
31
+ SG: "SGD",
32
+ US: "USD"
33
+ };
34
+ function y(n) {
35
+ return typeof n == "number" && Number.isFinite(n);
36
+ }
37
+ function P(n, e = 1) {
38
+ const r = typeof n == "string" ? Number.parseInt(n, 10) : n;
39
+ return typeof r == "number" && Number.isFinite(r) && r > 0 ? Math.max(1, Math.round(r)) : e;
40
+ }
41
+ function F(n) {
42
+ const e = typeof n == "string" ? Number.parseInt(n, 10) : n;
43
+ return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.round(e) : null;
44
+ }
45
+ function z(n) {
46
+ if (typeof n == "string") {
47
+ const e = n.trim().toLowerCase();
48
+ if (R.includes(e))
49
+ return e;
50
+ }
51
+ return "none";
52
+ }
53
+ function l(n) {
54
+ const e = n || {}, r = u(
55
+ typeof e.code == "string" ? e.code : null
56
+ ), t = e.is_default === !0;
57
+ return {
58
+ code: r,
59
+ symbol: typeof e.symbol == "string" && e.symbol.trim() ? e.symbol.trim() : r,
60
+ exchange_rate: t ? 1 : y(e.exchange_rate) && e.exchange_rate > 0 ? e.exchange_rate : 1,
61
+ is_default: t,
62
+ is_active: e.is_active !== !1,
63
+ auto_sync_product_prices: t ? !1 : e.auto_sync_product_prices === !0,
64
+ rounding_mode: z(e.rounding_mode),
65
+ rounding_increment: P(e.rounding_increment, 1),
66
+ rounding_charm_amount: F(e.rounding_charm_amount),
67
+ auto_update_exchange_rate: t ? !1 : e.auto_update_exchange_rate !== !1,
68
+ exchange_rate_source: typeof e.exchange_rate_source == "string" && e.exchange_rate_source.trim() ? e.exchange_rate_source.trim() : null,
69
+ exchange_rate_updated_at: typeof e.exchange_rate_updated_at == "string" && e.exchange_rate_updated_at.trim() ? e.exchange_rate_updated_at : null
70
+ };
71
+ }
72
+ function C(n) {
73
+ return !n || typeof n != "object" || Array.isArray(n) ? {} : Object.entries(n).reduce(
74
+ (e, [r, t]) => {
75
+ const c = u(r), o = typeof t == "string" ? Number.parseFloat(t) : t;
76
+ return y(o) && o >= 0 && (e[c] = Math.round(o)), e;
77
+ },
78
+ {}
79
+ );
80
+ }
81
+ function U(n) {
82
+ return !n || typeof n != "object" || Array.isArray(n) ? {} : Object.entries(n).reduce(
83
+ (e, [r, t]) => {
84
+ const c = u(r), o = typeof t == "string" ? Number.parseFloat(t) : t;
85
+ return o === null ? (e[c] = null, e) : (y(o) && o >= 0 && (e[c] = Math.round(o)), e);
86
+ },
87
+ {}
88
+ );
89
+ }
90
+ function f(n) {
91
+ return n.map(l).find((e) => e.is_default) ?? l(n[0]) ?? l({
92
+ code: "USD",
93
+ symbol: "$",
94
+ exchange_rate: 1,
95
+ is_default: !0,
96
+ is_active: !0
97
+ });
98
+ }
99
+ function h(n) {
100
+ return n.reduce((e, r) => {
101
+ const t = l(r);
102
+ return e[t.code] = t, e;
103
+ }, {});
104
+ }
105
+ function O(n, e) {
106
+ const r = u(e), t = f(n);
107
+ return h(n)[r]?.exchange_rate ?? (r === t.code, 1);
108
+ }
109
+ function A(n) {
110
+ const { amount: e, currencies: r } = n, t = u(n.fromCurrencyCode), c = u(n.toCurrencyCode);
111
+ if (!Number.isFinite(e))
112
+ return 0;
113
+ if (t === c)
114
+ return Math.round(e);
115
+ const o = h(r), i = f(r), a = o[t]?.exchange_rate ?? (t === i.code ? 1 : i.exchange_rate), d = o[c]?.exchange_rate ?? (c === i.code ? 1 : i.exchange_rate), M = e / g(t) / a * d, p = x(M, c);
116
+ return n.applyRounding ? S({
117
+ amount: p,
118
+ currencyCode: c,
119
+ currencies: r
120
+ }) : p;
121
+ }
122
+ function S(n) {
123
+ const e = Math.max(0, Math.round(n.amount)), r = u(n.currencyCode), c = h(n.currencies)[r] ?? l(f(n.currencies)), o = P(c.rounding_increment, 1);
124
+ if (c.rounding_mode === "nearest")
125
+ return Math.round(e / o) * o;
126
+ if (c.rounding_mode === "up")
127
+ return Math.ceil(e / o) * o;
128
+ if (c.rounding_mode === "down")
129
+ return Math.floor(e / o) * o;
130
+ if (c.rounding_mode === "charm") {
131
+ const i = g(c.code), a = Math.min(
132
+ Math.max(c.rounding_charm_amount ?? 0, 0),
133
+ Math.max(i - 1, 0)
134
+ );
135
+ let s = Math.floor(e / i) * i + a;
136
+ return s < e && (s += i), s;
137
+ }
138
+ return e;
139
+ }
140
+ function T(n) {
141
+ const e = l(n);
142
+ if (e.rounding_mode === "nearest")
143
+ return `Nearest ${_(
144
+ e.rounding_increment ?? 1,
145
+ e.code
146
+ )}`;
147
+ if (e.rounding_mode === "up")
148
+ return `Round up to ${_(
149
+ e.rounding_increment ?? 1,
150
+ e.code
151
+ )}`;
152
+ if (e.rounding_mode === "down")
153
+ return `Round down to ${_(
154
+ e.rounding_increment ?? 1,
155
+ e.code
156
+ )}`;
157
+ if (e.rounding_mode === "charm") {
158
+ const r = e.rounding_charm_amount ?? 0;
159
+ return `Charm ending ${_(r, e.code)}`;
160
+ }
161
+ return `Exact conversion (${N(1, e.code).toFixed(
162
+ g(e.code) === 1 ? 0 : 2
163
+ )} step)`;
164
+ }
165
+ function k(n, e) {
166
+ const r = f(e);
167
+ return n[r.code] !== void 0 ? r.code : Object.keys(n)[0] ?? r.code;
168
+ }
169
+ function b(n) {
170
+ const { amountMap: e, fallbackAmount: r, currencies: t } = n, c = u(n.currencyCode), o = C(e);
171
+ if (o[c] !== void 0)
172
+ return o[c];
173
+ if (Object.keys(o).length > 0) {
174
+ const i = k(o, t), a = o[i];
175
+ if (a !== void 0)
176
+ return A({
177
+ amount: a,
178
+ fromCurrencyCode: i,
179
+ toCurrencyCode: c,
180
+ currencies: t,
181
+ applyRounding: !0
182
+ });
183
+ }
184
+ if (typeof r == "number" && Number.isFinite(r)) {
185
+ const i = f(t);
186
+ return A({
187
+ amount: r,
188
+ fromCurrencyCode: i.code,
189
+ toCurrencyCode: c,
190
+ currencies: t,
191
+ applyRounding: !0
192
+ });
193
+ }
194
+ return 0;
195
+ }
196
+ function D(n) {
197
+ const {
198
+ prices: e = {},
199
+ salePrices: r = {},
200
+ fallbackPrice: t,
201
+ fallbackSalePrice: c,
202
+ currencies: o
203
+ } = n, i = u(n.currencyCode), a = C(e), d = U(r), s = b({
204
+ amountMap: a,
205
+ fallbackAmount: t,
206
+ currencyCode: i,
207
+ currencies: o
208
+ }), m = b({
209
+ amountMap: C(d),
210
+ fallbackAmount: c,
211
+ currencyCode: i,
212
+ currencies: o
213
+ });
214
+ return {
215
+ currencyCode: i,
216
+ price: s,
217
+ sale_price: m > 0 && m <= s ? m : null
218
+ };
219
+ }
220
+ function w(n) {
221
+ const e = (n.now ?? /* @__PURE__ */ new Date()).getTime();
222
+ if (n.saleStartAt) {
223
+ const r = new Date(n.saleStartAt).getTime();
224
+ if (Number.isFinite(r) && e < r)
225
+ return !1;
226
+ }
227
+ if (n.saleEndAt) {
228
+ const r = new Date(n.saleEndAt).getTime();
229
+ if (Number.isFinite(r) && e >= r)
230
+ return !1;
231
+ }
232
+ return !0;
233
+ }
234
+ function j(n) {
235
+ if (!n.scheduledPriceAt)
236
+ return !1;
237
+ const e = new Date(n.scheduledPriceAt).getTime();
238
+ return Number.isFinite(e) ? (n.now ?? /* @__PURE__ */ new Date()).getTime() >= e : !1;
239
+ }
240
+ function v(n) {
241
+ const e = n.now ?? /* @__PURE__ */ new Date(), r = j({
242
+ scheduledPriceAt: n.scheduledPriceAt,
243
+ now: e
244
+ }), t = r ? n.scheduledPrices : n.prices, c = r ? n.scheduledPrice : n.fallbackPrice, o = w({
245
+ saleStartAt: n.saleStartAt,
246
+ saleEndAt: n.saleEndAt,
247
+ now: e
248
+ });
249
+ return D({
250
+ prices: t,
251
+ salePrices: o ? n.salePrices : null,
252
+ fallbackPrice: c,
253
+ fallbackSalePrice: o ? n.fallbackSalePrice : null,
254
+ currencyCode: n.currencyCode,
255
+ currencies: n.currencies
256
+ });
257
+ }
258
+ function L(n) {
259
+ const e = n.entries.map(
260
+ (r) => v({
261
+ prices: r.prices,
262
+ salePrices: r.sale_prices,
263
+ fallbackPrice: r.price,
264
+ fallbackSalePrice: r.sale_price,
265
+ saleStartAt: r.sale_start_at,
266
+ saleEndAt: r.sale_end_at,
267
+ scheduledPrice: r.scheduled_price,
268
+ scheduledPrices: r.scheduled_prices,
269
+ scheduledPriceAt: r.scheduled_price_at,
270
+ currencyCode: n.currencyCode,
271
+ currencies: n.currencies,
272
+ now: n.now
273
+ })
274
+ ).map((r) => r.sale_price ?? r.price).filter((r) => Number.isFinite(r));
275
+ return e.length ? {
276
+ min: Math.min(...e),
277
+ max: Math.max(...e)
278
+ } : null;
279
+ }
280
+ function K(n, e) {
281
+ const r = f(e), t = n?.trim();
282
+ if (!t)
283
+ return r.code;
284
+ const o = t.replace("_", "-").split("-").map((d) => d.toUpperCase())[1];
285
+ if (!o)
286
+ return r.code;
287
+ const i = E[o];
288
+ return i && new Set(e.map((d) => u(d.code))).has(i) ? i : r.code;
289
+ }
290
+ function $(n) {
291
+ return n.map(l).sort((e, r) => e.is_default !== r.is_default ? e.is_default ? -1 : 1 : u(e.code).localeCompare(u(r.code)));
292
+ }
293
+ export {
294
+ R as CURRENCY_ROUNDING_MODES,
295
+ S as applyCurrencyRounding,
296
+ A as convertMinorUnitAmount,
297
+ T as describeCurrencyRoundingRule,
298
+ h as getCurrencyLookup,
299
+ f as getDefaultCurrency,
300
+ O as getExchangeRateForCurrency,
301
+ K as inferCurrencyCodeFromLocale,
302
+ w as isSaleWindowActive,
303
+ j as isScheduledPriceDue,
304
+ l as normalizeCurrencyRecord,
305
+ z as normalizeCurrencyRoundingMode,
306
+ C as normalizePriceMap,
307
+ U as normalizeSalePriceMap,
308
+ v as resolveEffectivePriceForCurrency,
309
+ D as resolvePriceForCurrency,
310
+ L as resolvePriceRangeForCurrency,
311
+ $ as sortCurrencies
312
+ };
@@ -0,0 +1 @@
1
+ "use strict";const c=require("./states-CWYRxV4B.cjs"),a=()=>({company_name:"",recipient_name:"",line1:"",line2:"",city:"",state:"",postal_code:"",country_code:"CA"});function t(e){const n=e?.trim();return n||null}function o(e){if(!e)return null;const n={company_name:t(e.company_name),recipient_name:t(e.recipient_name),line1:t(e.line1),line2:t(e.line2),city:t(e.city),postal_code:t(e.postal_code),country_code:c.normalizeCountryCode(e.country_code)};return n.state=c.normalizeSubdivisionCode(n.country_code,t(e.state)),Object.values(n).some(Boolean)?n:null}function m(e){const n=o(e);return n?!!(n.recipient_name&&n.line1&&n.city&&n.postal_code&&n.country_code&&(!c.countryUsesStructuredStates(n.country_code)||n.state)):!1}function u(e){const n=o(e.billing),i=o(e.shipping),r=t(e.email)?.toLowerCase()??null,s=t(e.phone),l=t(e.name)??n?.recipient_name??i?.recipient_name??null;return{email:r,name:l,phone:s,billing:n,shipping:i}}function d(e,n){const i=o(e),r=o(n);return JSON.stringify(i)===JSON.stringify(r)}exports.addressesMatch=d;exports.emptyCustomerAddress=a;exports.isCustomerAddressComplete=m;exports.normalizeCustomerAddress=o;exports.normalizeOrderCustomerDetails=u;
@@ -0,0 +1,57 @@
1
+ import { a as l, n as s, b as m } from "./states-DlHJezQ1.js";
2
+ const y = () => ({
3
+ company_name: "",
4
+ recipient_name: "",
5
+ line1: "",
6
+ line2: "",
7
+ city: "",
8
+ state: "",
9
+ postal_code: "",
10
+ country_code: "CA"
11
+ });
12
+ function o(n) {
13
+ const e = n?.trim();
14
+ return e || null;
15
+ }
16
+ function i(n) {
17
+ if (!n)
18
+ return null;
19
+ const e = {
20
+ company_name: o(n.company_name),
21
+ recipient_name: o(n.recipient_name),
22
+ line1: o(n.line1),
23
+ line2: o(n.line2),
24
+ city: o(n.city),
25
+ postal_code: o(n.postal_code),
26
+ country_code: s(n.country_code)
27
+ };
28
+ return e.state = m(
29
+ e.country_code,
30
+ o(n.state)
31
+ ), Object.values(e).some(Boolean) ? e : null;
32
+ }
33
+ function p(n) {
34
+ const e = i(n);
35
+ return e ? !!(e.recipient_name && e.line1 && e.city && e.postal_code && e.country_code && (!l(e.country_code) || e.state)) : !1;
36
+ }
37
+ function _(n) {
38
+ const e = i(n.billing), t = i(n.shipping), c = o(n.email)?.toLowerCase() ?? null, r = o(n.phone), a = o(n.name) ?? e?.recipient_name ?? t?.recipient_name ?? null;
39
+ return {
40
+ email: c,
41
+ name: a,
42
+ phone: r,
43
+ billing: e,
44
+ shipping: t
45
+ };
46
+ }
47
+ function d(n, e) {
48
+ const t = i(n), c = i(e);
49
+ return JSON.stringify(t) === JSON.stringify(c);
50
+ }
51
+ export {
52
+ d as a,
53
+ _ as b,
54
+ y as e,
55
+ p as i,
56
+ i as n
57
+ };