@nextblock-cms/ecom 0.8.0 → 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
@@ -0,0 +1,128 @@
1
+ import { getSsgSupabaseClient as v } from "@nextblock-cms/db/server";
2
+ import { normalizePriceMap as l, convertMinorUnitAmount as O, getDefaultCurrency as M } from "./currency.es.js";
3
+ import { normalizeCurrencyCode as y } from "@nextblock-cms/utils";
4
+ import { resolveTranslatedText as S } from "./variation-utils.es.js";
5
+ const k = ["auto", "manual"];
6
+ function h(e) {
7
+ if (typeof e == "string") {
8
+ const r = e.trim().toLowerCase();
9
+ if (k.includes(
10
+ r
11
+ ))
12
+ return r;
13
+ }
14
+ return "auto";
15
+ }
16
+ function C(e, r = 0) {
17
+ return typeof e == "number" && Number.isFinite(e) && e >= 0 ? Math.round(e) : r;
18
+ }
19
+ function A(e) {
20
+ const r = y(
21
+ e.sourceCurrencyCode
22
+ ), t = l(e.amountMap);
23
+ if (t[r] !== void 0)
24
+ return r;
25
+ const c = Object.keys(t)[0];
26
+ return c ? y(c) : M(e.currencies).code;
27
+ }
28
+ function q(e) {
29
+ const r = h(e.mode), t = l(e.costAmounts), c = l(e.minOrderAmounts), o = A({
30
+ amountMap: Object.keys(t).length > 0 ? t : c,
31
+ sourceCurrencyCode: e.sourceCurrencyCode,
32
+ currencies: e.currencies
33
+ }), u = t[o] ?? C(e.fallbackCostAmount), i = c[o] ?? C(e.fallbackMinOrderAmount);
34
+ if (r === "auto")
35
+ return {
36
+ mode: r,
37
+ sourceCurrencyCode: o,
38
+ costAmounts: {
39
+ [o]: u
40
+ },
41
+ minOrderAmounts: {
42
+ [o]: i
43
+ }
44
+ };
45
+ const d = Object.keys(t).length > 0 ? { ...t } : { [o]: u }, a = Object.keys(c).length > 0 ? { ...c } : { [o]: i };
46
+ return d[o] === void 0 && (d[o] = u), a[o] === void 0 && (a[o] = i), {
47
+ mode: r,
48
+ sourceCurrencyCode: o,
49
+ costAmounts: d,
50
+ minOrderAmounts: a
51
+ };
52
+ }
53
+ function g(e) {
54
+ const r = h(e.mode), t = l(e.amountMap), c = y(e.currencyCode);
55
+ if (r === "manual" && t[c] !== void 0)
56
+ return t[c];
57
+ const o = A({
58
+ amountMap: t,
59
+ sourceCurrencyCode: e.sourceCurrencyCode,
60
+ currencies: e.currencies
61
+ }), u = t[o] ?? C(e.fallbackAmount);
62
+ return c === o ? u : O({
63
+ amount: u,
64
+ fromCurrencyCode: o,
65
+ toCurrencyCode: c,
66
+ currencies: e.currencies
67
+ });
68
+ }
69
+ async function I(e, r, t, c) {
70
+ const o = v(), { data: u } = await o.from("currencies").select(
71
+ "code, symbol, exchange_rate, is_default, is_active, auto_sync_product_prices, auto_update_exchange_rate, exchange_rate_source, exchange_rate_updated_at, rounding_mode, rounding_increment, rounding_charm_amount"
72
+ ).eq("is_active", !0).order("code", { ascending: !0 }), i = u ?? [], d = M(i), a = c || d.code, { data: _, error: z } = await o.from("shipping_zone_locations").select(`
73
+ zone_id,
74
+ country_code,
75
+ state_code,
76
+ postal_code,
77
+ shipping_zones!inner(priority_order)
78
+ `).eq("country_code", r.country).order("shipping_zones(priority_order)", { ascending: !0 });
79
+ if (z || !_ || _.length === 0)
80
+ return [];
81
+ let m = null;
82
+ if (r.state) {
83
+ const n = _.find((s) => s.state_code === r.state);
84
+ n && (m = n.zone_id);
85
+ }
86
+ if (!m) {
87
+ const n = _.find((s) => !s.state_code && !s.postal_code);
88
+ n && (m = n.zone_id);
89
+ }
90
+ m || (m = _[0].zone_id);
91
+ const { data: f, error: b } = await o.from("shipping_zone_methods").select("id, zone_id, method_type, cost_amount, cost_amounts, cost_currency, currency_pricing_mode, min_order_amount, min_order_amounts, name, name_translations").eq("zone_id", m);
92
+ if (b || !f)
93
+ return [];
94
+ const p = f.filter((n) => {
95
+ const s = g({
96
+ amountMap: n.min_order_amounts || {},
97
+ fallbackAmount: n.min_order_amount || 0,
98
+ sourceCurrencyCode: n.cost_currency || d.code,
99
+ mode: n.currency_pricing_mode,
100
+ currencyCode: a,
101
+ currencies: i
102
+ });
103
+ return e >= s;
104
+ }).map((n) => ({
105
+ id: n.id,
106
+ name: S(
107
+ n.name,
108
+ n.name_translations || null,
109
+ t
110
+ ),
111
+ amount: g({
112
+ amountMap: n.cost_amounts || {},
113
+ fallbackAmount: n.cost_amount || 0,
114
+ sourceCurrencyCode: n.cost_currency || d.code,
115
+ mode: n.currency_pricing_mode,
116
+ currencyCode: a,
117
+ currencies: i
118
+ }),
119
+ currency: a,
120
+ type: n.method_type
121
+ })).sort((n, s) => n.amount - s.amount)[0];
122
+ return p ? [p] : [];
123
+ }
124
+ export {
125
+ h as n,
126
+ I as r,
127
+ q as s
128
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@nextblock-cms/db/server"),u=require("../product-actions-CONBF8i6.cjs");async function d(t,e,o=[],a=[]){const n=c.createClient(),{data:s,error:r}=await u.fetchTranslatedProductsForCartInternal(n,t,e,o,a);return r?(console.error("[getTranslatedProductsForCart] Error:",r),[]):s||[]}exports.getTranslatedProductsForCart=d;
@@ -0,0 +1,15 @@
1
+ import { createClient as c } from "@nextblock-cms/db/server";
2
+ import { f as d } from "../product-actions-DjlIWCMH.js";
3
+ async function i(t, a, o = [], e = []) {
4
+ const n = c(), { data: s, error: r } = await d(
5
+ n,
6
+ t,
7
+ a,
8
+ o,
9
+ e
10
+ );
11
+ return r ? (console.error("[getTranslatedProductsForCart] Error:", r), []) : s || [];
12
+ }
13
+ export {
14
+ i as getTranslatedProductsForCart
15
+ };