vlite3 1.4.3 → 1.4.5

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 (77) hide show
  1. package/components/AppShell/AppShellLayoutStorefront.vue.js +2 -2
  2. package/components/AvatarUploader/AvatarUploader.vue.d.ts +2 -2
  3. package/components/Cart/Cart.vue.d.ts +27 -0
  4. package/components/Cart/Cart.vue.js +242 -0
  5. package/components/Cart/Cart.vue2.js +4 -0
  6. package/components/Cart/CartCouponInput.vue.d.ts +32 -0
  7. package/components/Cart/CartCouponInput.vue.js +176 -0
  8. package/components/Cart/CartCouponInput.vue2.js +4 -0
  9. package/components/Cart/CartEmptyState.vue.d.ts +17 -0
  10. package/components/Cart/CartEmptyState.vue.js +48 -0
  11. package/components/Cart/CartEmptyState.vue2.js +4 -0
  12. package/components/Cart/CartLineItem.vue.d.ts +29 -0
  13. package/components/Cart/CartLineItem.vue.js +341 -0
  14. package/components/Cart/CartLineItem.vue2.js +4 -0
  15. package/components/Cart/CartSummary.vue.d.ts +29 -0
  16. package/components/Cart/CartSummary.vue.js +157 -0
  17. package/components/Cart/CartSummary.vue2.js +4 -0
  18. package/components/Cart/CartVariant1.vue.d.ts +42 -0
  19. package/components/Cart/CartVariant1.vue.js +156 -0
  20. package/components/Cart/CartVariant1.vue2.js +4 -0
  21. package/components/Cart/CartVariant2.vue.d.ts +42 -0
  22. package/components/Cart/CartVariant2.vue.js +154 -0
  23. package/components/Cart/CartVariant2.vue2.js +4 -0
  24. package/components/Cart/CartVariant3.vue.d.ts +41 -0
  25. package/components/Cart/CartVariant3.vue.js +192 -0
  26. package/components/Cart/CartVariant3.vue2.js +4 -0
  27. package/components/Cart/CartVariant4.vue.d.ts +41 -0
  28. package/components/Cart/CartVariant4.vue.js +145 -0
  29. package/components/Cart/CartVariant4.vue2.js +4 -0
  30. package/components/Cart/composables/useCart.d.ts +46 -0
  31. package/components/Cart/composables/useCart.js +110 -0
  32. package/components/Cart/composables/useCartCalculation.d.ts +91 -0
  33. package/components/Cart/composables/useCartCalculation.js +145 -0
  34. package/components/Cart/index.d.ts +9 -0
  35. package/components/Cart/types.d.ts +391 -0
  36. package/components/CategoryManager/CategoryManager.vue.d.ts +2 -2
  37. package/components/CategoryManager/CategoryManager.vue.js +3 -3
  38. package/components/CategoryManager/CategoryManager.vue2.js +224 -248
  39. package/components/CategoryManager/utils.d.ts +3 -0
  40. package/components/CategoryManager/utils.js +31 -0
  41. package/components/CategoryMenu/CategoryMenu.vue.d.ts +2 -0
  42. package/components/CategoryMenu/CategoryMenu.vue.js +46 -40
  43. package/components/CategoryMenu/CategoryMenuVariant1.vue.d.ts +5 -1
  44. package/components/CategoryMenu/CategoryMenuVariant1.vue.js +5 -144
  45. package/components/CategoryMenu/CategoryMenuVariant1.vue2.js +220 -2
  46. package/components/CategoryMenu/CategoryMenuVariant2.vue.d.ts +5 -1
  47. package/components/CategoryMenu/CategoryMenuVariant2.vue.js +5 -160
  48. package/components/CategoryMenu/CategoryMenuVariant2.vue2.js +235 -2
  49. package/components/CategoryMenu/types.d.ts +5 -2
  50. package/components/Clipboard.vue.d.ts +2 -2
  51. package/components/Dropdown/Dropdown.vue.d.ts +1 -0
  52. package/components/Dropdown/Dropdown.vue.js +31 -29
  53. package/components/FilePicker/FilePicker.vue.d.ts +2 -2
  54. package/components/FilePicker/FilePicker.vue.js +278 -202
  55. package/components/Form/CustomFields.vue.d.ts +4 -0
  56. package/components/Form/CustomFields.vue.js +2 -2
  57. package/components/Form/CustomFields.vue2.js +349 -145
  58. package/components/Form/FormField.vue.d.ts +1 -1
  59. package/components/Form/FormField.vue.js +1 -1
  60. package/components/Form/types.d.ts +3 -0
  61. package/components/Modal.vue.d.ts +2 -0
  62. package/components/Modal.vue.js +1 -1
  63. package/components/Modal.vue2.js +30 -28
  64. package/components/OTPInput/OTPInput.vue.d.ts +1 -1
  65. package/components/Rating/Rating.vue.d.ts +1 -1
  66. package/components/Screen/ScreenFilter.vue.js +3 -2
  67. package/components/SidePanel.vue.d.ts +2 -0
  68. package/components/SidePanel.vue.js +1 -1
  69. package/components/SidePanel.vue2.js +25 -23
  70. package/components/SidebarMenu/SidebarMenu.vue.js +145 -128
  71. package/components/index.d.ts +1 -0
  72. package/core/config.d.ts +128 -0
  73. package/index.d.ts +1 -0
  74. package/index.js +327 -306
  75. package/package.json +1 -1
  76. package/style.css +1 -1
  77. package/types/config.type.d.ts +2 -0
@@ -0,0 +1,145 @@
1
+ import { defineComponent as q, computed as c, openBlock as a, createElementBlock as i, normalizeClass as r, createElementVNode as m, createVNode as v, toDisplayString as b, createCommentVNode as u, unref as z, createBlock as y, Fragment as B, renderList as N, withCtx as k, createTextVNode as C } from "vue";
2
+ import D from "../Icon.vue.js";
3
+ import E from "../Price/Price.vue.js";
4
+ import w from "../Button.vue.js";
5
+ import L from "./CartLineItem.vue.js";
6
+ import j from "./CartSummary.vue.js";
7
+ import I from "./CartCouponInput.vue.js";
8
+ import R from "./CartEmptyState.vue.js";
9
+ const T = { class: "flex items-center gap-2 min-w-0" }, A = {
10
+ key: 0,
11
+ class: "inline-flex items-center justify-center px-1.5 h-5 rounded-full bg-primary/10 text-primary text-[10px] font-bold tabular-nums"
12
+ }, F = {
13
+ key: 0,
14
+ class: "text-xs text-muted-foreground"
15
+ }, U = { class: "font-semibold text-foreground" }, G = { class: "flex-1 min-h-0 overflow-y-auto" }, H = {
16
+ key: 1,
17
+ class: "space-y-1.5 pt-0.5"
18
+ }, Y = /* @__PURE__ */ q({
19
+ __name: "CartVariant4",
20
+ props: {
21
+ data: {},
22
+ actions: {},
23
+ features: {},
24
+ labels: {},
25
+ compact: { type: Boolean, default: !1 },
26
+ variant: { default: "Variant4" },
27
+ containerClass: {}
28
+ },
29
+ emits: ["update:quantity", "remove", "clear", "apply-coupon", "remove-coupon", "coupon-change", "continue", "continue-shopping"],
30
+ setup(e, { emit: $ }) {
31
+ const p = e, l = $, s = c(() => p.data), g = c(() => p.labels || {}), o = c(() => p.actions || {}), f = c(() => p.features || {}), d = c(() => s.value.empty || !s.value.items || s.value.items.length === 0), S = c(
32
+ () => s.value.totals.itemCount ?? s.value.items?.reduce((h, t) => h + (t.quantity || 0), 0) ?? 0
33
+ );
34
+ return (h, t) => (a(), i("div", {
35
+ class: r(["v-cart v-cart-v4 flex flex-col bg-background text-foreground border border-border rounded-lg overflow-hidden w-full h-full", [e.containerClass, e.compact ? "max-w-xs" : "max-w-sm"]])
36
+ }, [
37
+ m("div", {
38
+ class: r(["flex items-center justify-between gap-2 border-b border-border shrink-0", e.compact ? "px-3 py-2" : "px-4 py-2.5"])
39
+ }, [
40
+ m("div", T, [
41
+ v(D, {
42
+ icon: "lucide:shopping-bag",
43
+ class: r(e.compact ? "w-4 h-4" : "w-4.5 h-4.5")
44
+ }, null, 8, ["class"]),
45
+ m("p", {
46
+ class: r(["font-bold text-foreground truncate", (e.compact, "text-sm")])
47
+ }, b(s.value.title || g.value.cart || "Cart"), 3),
48
+ d.value ? u("", !0) : (a(), i("span", A, b(S.value), 1))
49
+ ]),
50
+ !d.value && !e.compact ? (a(), i("p", F, [
51
+ m("span", U, [
52
+ v(z(E), {
53
+ value: e.data.totals.grandTotal,
54
+ class: "text-foreground font-semibold"
55
+ }, null, 8, ["value"])
56
+ ])
57
+ ])) : u("", !0)
58
+ ], 2),
59
+ m("div", G, [
60
+ d.value ? (a(), y(R, {
61
+ key: 0,
62
+ labels: e.labels,
63
+ compact: !0,
64
+ onContinueShopping: t[0] || (t[0] = (n) => l("continue-shopping"))
65
+ }, null, 8, ["labels"])) : (a(), i("ul", {
66
+ key: 1,
67
+ class: r(["divide-y divide-border", e.compact ? "px-3" : "px-4"])
68
+ }, [
69
+ (a(!0), i(B, null, N(e.data.items, (n) => (a(), i("li", {
70
+ key: n.id
71
+ }, [
72
+ v(L, {
73
+ item: n,
74
+ features: e.features,
75
+ labels: e.labels,
76
+ compact: e.compact,
77
+ readonly: e.data.readonly,
78
+ layout: "mini",
79
+ "onUpdate:quantity": t[1] || (t[1] = (x, V) => l("update:quantity", x, V)),
80
+ onRemove: t[2] || (t[2] = (x) => l("remove", x))
81
+ }, null, 8, ["item", "features", "labels", "compact", "readonly"])
82
+ ]))), 128))
83
+ ], 2))
84
+ ]),
85
+ d.value ? u("", !0) : (a(), i("div", {
86
+ key: 0,
87
+ class: r(["border-t border-border bg-muted/30 shrink-0", e.compact ? "p-3 space-y-2" : "p-4 space-y-3"])
88
+ }, [
89
+ v(j, {
90
+ totals: e.data.totals,
91
+ features: e.features,
92
+ labels: e.labels,
93
+ compact: e.compact,
94
+ coupon: e.data.coupon,
95
+ variant: "Variant4"
96
+ }, null, 8, ["totals", "features", "labels", "compact", "coupon"]),
97
+ e.features.coupon ? (a(), y(I, {
98
+ key: 0,
99
+ coupon: e.data.coupon,
100
+ labels: e.labels,
101
+ compact: e.compact,
102
+ readonly: e.data.readonly,
103
+ onApply: t[3] || (t[3] = (n) => l("apply-coupon", n)),
104
+ onRemove: t[4] || (t[4] = (n) => l("remove-coupon")),
105
+ onChange: t[5] || (t[5] = (n) => l("coupon-change", n))
106
+ }, null, 8, ["coupon", "labels", "compact", "readonly"])) : u("", !0),
107
+ o.value.showContinue && f.value.continue || o.value.showContinueShopping && f.value.continueShopping ? (a(), i("div", H, [
108
+ o.value.showContinue && f.value.continue ? (a(), y(w, {
109
+ key: 0,
110
+ variant: "primary",
111
+ size: e.compact ? "sm" : "md",
112
+ block: !0,
113
+ icon: o.value.continueIcon || "lucide:arrow-right",
114
+ disabled: o.value.continueDisabled || d.value,
115
+ class: "w-full",
116
+ onClick: t[6] || (t[6] = (n) => l("continue"))
117
+ }, {
118
+ default: k(() => [
119
+ C(b(o.value.continueLabel || g.value.continue || "Checkout"), 1)
120
+ ]),
121
+ _: 1
122
+ }, 8, ["size", "icon", "disabled"])) : u("", !0),
123
+ o.value.showContinueShopping && f.value.continueShopping ? (a(), y(w, {
124
+ key: 1,
125
+ variant: "ghost",
126
+ size: "sm",
127
+ block: !0,
128
+ icon: o.value.continueShoppingIcon || "lucide:arrow-left",
129
+ disabled: o.value.continueShoppingDisabled,
130
+ class: "w-full",
131
+ onClick: t[7] || (t[7] = (n) => l("continue-shopping"))
132
+ }, {
133
+ default: k(() => [
134
+ C(b(o.value.continueShoppingLabel || g.value.continueShopping || "Continue shopping"), 1)
135
+ ]),
136
+ _: 1
137
+ }, 8, ["icon", "disabled"])) : u("", !0)
138
+ ])) : u("", !0)
139
+ ], 2))
140
+ ], 2));
141
+ }
142
+ });
143
+ export {
144
+ Y as default
145
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./CartVariant4.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,46 @@
1
+ import { ComputedRef, Ref } from 'vue';
2
+ import { CartCoupon, CartData, CartItem, CartTotals } from '../types';
3
+ export type CartItemId = CartItem['id'];
4
+ export interface UseCartOptions extends Partial<Omit<CartData, 'items' | 'coupon' | 'totals'>> {
5
+ /** Initial line items */
6
+ items?: CartItem[];
7
+ /** Initial applied coupon */
8
+ coupon?: CartCoupon | null;
9
+ /** Server-provided totals. When omitted, useCart calculates totals locally. */
10
+ totals?: CartTotals;
11
+ }
12
+ export interface UseCartReturn {
13
+ /** Reactive line items */
14
+ items: Ref<CartItem[]>;
15
+ /** Reactive applied coupon */
16
+ coupon: Ref<CartCoupon | null>;
17
+ /** Totals produced by the same calculator used by the Cart component */
18
+ totals: ComputedRef<CartTotals>;
19
+ /** Ready-to-pass CartData object for `<Cart :data="cart.data" />` */
20
+ data: ComputedRef<CartData>;
21
+ /** Total quantity across all line items */
22
+ itemCount: ComputedRef<number>;
23
+ /** Whether the cart currently has no line items */
24
+ isEmpty: ComputedRef<boolean>;
25
+ /** Add a line item, merging quantity with an existing item that has the same id. */
26
+ addToCart: (item: CartItem, quantity?: number) => void;
27
+ /** Remove a line item entirely, or subtract a quantity when provided. */
28
+ removeFromCart: (itemId: CartItemId, quantity?: number) => void;
29
+ /** Set a line item's quantity. Quantities <= 0 remove the item. */
30
+ updateQuantity: (itemId: CartItemId, quantity: number) => void;
31
+ /** Increase a line item's quantity. */
32
+ incrementQuantity: (itemId: CartItemId, amount?: number) => void;
33
+ /** Decrease a line item's quantity, removing it at zero. */
34
+ decrementQuantity: (itemId: CartItemId, amount?: number) => void;
35
+ /** Replace all cart items. */
36
+ setItems: (nextItems: CartItem[]) => void;
37
+ /** Clear all line items. */
38
+ clearCart: () => void;
39
+ /** Set or clear the applied coupon. */
40
+ setCoupon: (nextCoupon: CartCoupon | null) => void;
41
+ /** Get the current quantity for a line item id. */
42
+ getQuantity: (itemId: CartItemId) => number;
43
+ /** Get a shallow-copied snapshot of the current cart items. */
44
+ getCartItems: () => CartItem[];
45
+ }
46
+ export declare function useCart(options?: UseCartOptions): UseCartReturn;
@@ -0,0 +1,110 @@
1
+ import { ref as Q, computed as v } from "vue";
2
+ import { calculateCartTotals as w } from "./useCartCalculation.js";
3
+ function s(u, o) {
4
+ if (!Number.isFinite(u)) return 0;
5
+ const d = Math.max(0, Math.floor(u));
6
+ return typeof o == "number" && Number.isFinite(o) ? Math.min(d, Math.max(0, Math.floor(o))) : d;
7
+ }
8
+ function f(u, o = u.quantity) {
9
+ return {
10
+ ...u,
11
+ quantity: s(o, u.maxQuantity)
12
+ };
13
+ }
14
+ function D(u = {}) {
15
+ const {
16
+ items: o = [],
17
+ coupon: d = null,
18
+ totals: h,
19
+ ...m
20
+ } = u, n = Q(o.map((t) => f(t))), p = Q(d), l = Q(h), g = v(() => w({
21
+ items: n.value,
22
+ tax: m.tax,
23
+ shipping: m.shipping,
24
+ coupon: p.value,
25
+ currency: m.currency
26
+ }).totals), C = v(() => l.value ?? g.value), M = v(() => n.value.reduce((t, e) => t + s(e.quantity), 0)), q = v(() => n.value.length === 0), T = v(() => ({
27
+ ...m,
28
+ items: n.value,
29
+ coupon: p.value ?? void 0,
30
+ totals: C.value
31
+ }));
32
+ function y(t) {
33
+ return s(n.value.find((e) => e.id === t)?.quantity ?? 0);
34
+ }
35
+ function b(t) {
36
+ n.value = t.map((e) => f(e)), l.value = void 0;
37
+ }
38
+ function F(t, e = t.quantity || 1) {
39
+ const a = s(e, t.maxQuantity);
40
+ if (a <= 0) return;
41
+ const r = n.value.findIndex((i) => i.id === t.id);
42
+ if (r === -1)
43
+ n.value = [...n.value, f(t, a)];
44
+ else {
45
+ const i = n.value[r], c = t.maxQuantity ?? i.maxQuantity, k = f(
46
+ {
47
+ ...i,
48
+ ...t,
49
+ maxQuantity: c
50
+ },
51
+ s(i.quantity + a, c)
52
+ );
53
+ n.value = [...n.value.slice(0, r), k, ...n.value.slice(r + 1)];
54
+ }
55
+ l.value = void 0;
56
+ }
57
+ function x(t, e) {
58
+ const a = n.value.findIndex((c) => c.id === t);
59
+ if (a === -1) return;
60
+ const r = n.value[a], i = s(e, r.maxQuantity);
61
+ i <= 0 ? n.value = n.value.filter((c) => c.id !== t) : n.value = [
62
+ ...n.value.slice(0, a),
63
+ f(r, i),
64
+ ...n.value.slice(a + 1)
65
+ ], l.value = void 0;
66
+ }
67
+ function z(t, e) {
68
+ if (e === void 0) {
69
+ n.value = n.value.filter((a) => a.id !== t), l.value = void 0;
70
+ return;
71
+ }
72
+ x(t, y(t) - e);
73
+ }
74
+ function N(t, e = 1) {
75
+ x(t, y(t) + e);
76
+ }
77
+ function O(t, e = 1) {
78
+ x(t, y(t) - e);
79
+ }
80
+ function E() {
81
+ n.value = [], l.value = void 0;
82
+ }
83
+ function I(t) {
84
+ p.value = t, l.value = void 0;
85
+ }
86
+ function j() {
87
+ return n.value.map((t) => ({ ...t }));
88
+ }
89
+ return {
90
+ items: n,
91
+ coupon: p,
92
+ totals: C,
93
+ data: T,
94
+ itemCount: M,
95
+ isEmpty: q,
96
+ addToCart: F,
97
+ removeFromCart: z,
98
+ updateQuantity: x,
99
+ incrementQuantity: N,
100
+ decrementQuantity: O,
101
+ setItems: b,
102
+ clearCart: E,
103
+ setCoupon: I,
104
+ getQuantity: y,
105
+ getCartItems: j
106
+ };
107
+ }
108
+ export {
109
+ D as useCart
110
+ };
@@ -0,0 +1,91 @@
1
+ import { CartItem, CartTotals, CartTaxConfig, CartShippingConfig, CartCoupon } from '../types';
2
+ /** Sum of (price × quantity) for items that are taxable (or all, if item.taxable is undefined). */
3
+ export declare function sumLineTotals(items: CartItem[], onlyTaxable?: boolean): number;
4
+ /** Sum of (originalPrice × quantity) − (price × quantity) across all items. */
5
+ export declare function sumSavings(items: CartItem[]): number;
6
+ export declare function sumItemCount(items: CartItem[]): number;
7
+ /**
8
+ * Compute the discount amount a coupon would apply to a given subtotal.
9
+ * Returns 0 if the coupon doesn't qualify (expired / min-spend not met / etc).
10
+ */
11
+ export declare function computeCouponDiscount(coupon: CartCoupon | null | undefined, subtotal: number, currency?: string): number;
12
+ export interface TaxBreakdownLine {
13
+ /** Human label, e.g. "Sales Tax" or "VAT (20%)" */
14
+ label: string;
15
+ /** Computed tax amount */
16
+ amount: number;
17
+ /** Rate used (in percent), when applicable */
18
+ rate?: number;
19
+ }
20
+ export interface TaxResult {
21
+ /** Total tax across all breakdown lines */
22
+ total: number;
23
+ /** Per-line breakdown (single line for `rate`/`flat`, no lines for `exempt`) */
24
+ breakdown: TaxBreakdownLine[];
25
+ }
26
+ /**
27
+ * Compute tax on a given taxable subtotal using a `CartTaxConfig`.
28
+ * - `mode: 'rate'` → percent-based tax (e.g. 8.75% sales tax)
29
+ * - `mode: 'flat'` → fixed tax amount regardless of cart value
30
+ * - `mode: 'exempt'` → no tax
31
+ * - `mode: 'inclusive'`→ tax is already inside the price (display only)
32
+ */
33
+ export declare function computeTax(taxableSubtotal: number, tax: CartTaxConfig | undefined, roundToCents?: number): TaxResult;
34
+ export interface ShippingResult {
35
+ /** Final shipping cost the customer pays */
36
+ cost: number;
37
+ /** True when the cost is 0 because the user crossed a free-shipping threshold */
38
+ isFree: boolean;
39
+ /** Human-readable reason, e.g. "Free over $50" or "Standard" */
40
+ label: string;
41
+ /** For UI: "Add $X more for free shipping" — null when already free / no rule */
42
+ freeShippingProgress: {
43
+ /** Amount left to spend to unlock free shipping (0 when already unlocked) */
44
+ remaining: number;
45
+ /** The threshold itself */
46
+ threshold: number;
47
+ } | null;
48
+ }
49
+ /**
50
+ * Compute shipping cost using a `CartShippingConfig`.
51
+ * - `mode: 'flat'` → fixed cost
52
+ * - `mode: 'free'` → always free
53
+ * - `mode: 'freeOver'` → free when subtotal ≥ cost-free threshold
54
+ * - `mode: 'tiered'` → lookup table; first row whose `minSubtotal ≤ subtotal` wins
55
+ * - `mode: 'function'` → caller-provided (subtotal, items) => cost
56
+ * - `mode: 'pickup'` → no shipping (in-store pickup)
57
+ */
58
+ export declare function computeShipping(subtotal: number, shipping: CartShippingConfig | undefined, items: CartItem[]): ShippingResult;
59
+ export interface CalculateInput {
60
+ items: CartItem[];
61
+ tax?: CartTaxConfig;
62
+ shipping?: CartShippingConfig;
63
+ /** The applied coupon (with optional `definition` for internal math) */
64
+ coupon?: CartCoupon | null;
65
+ /** Override rounding precision (default 2) */
66
+ roundToCents?: number;
67
+ /** Currency code — propagated to the result */
68
+ currency?: string;
69
+ }
70
+ export interface CalculateOutput {
71
+ /** The full `CartTotals` object the cart renders */
72
+ totals: CartTotals;
73
+ /** Per-line tax breakdown (empty array for `exempt` / no tax) */
74
+ taxBreakdown: TaxBreakdownLine[];
75
+ /** Free-shipping progress hint for the UI ("Add $X more…") */
76
+ freeShippingProgress: ShippingResult['freeShippingProgress'];
77
+ }
78
+ /**
79
+ * The single entry point used by the Cart. Pure: same input → same output.
80
+ *
81
+ * items = [{ price: 100, quantity: 2 }, { price: 50, quantity: 1, taxable: false }]
82
+ * tax = { mode: 'rate', rate: 8.75 }
83
+ * shipping = { mode: 'freeOver', cost: 9.99, freeOver: 50 }
84
+ * coupon = { code: 'WELCOME10', state: 'applied', definition: { type: 'percentage', value: 10, minSubtotal: 100 } }
85
+ *
86
+ * → { subtotal: 250, discount: 25, taxableSubtotal: 200, estimatedTax: 17.50,
87
+ * shipping: 0, grandTotal: 242.50, itemCount: 3, ... }
88
+ */
89
+ export declare function calculateCartTotals(input: CalculateInput): CalculateOutput;
90
+ /** Convenience helper for the most common case: just items + configs. */
91
+ export declare function useCartCalculation(input: () => CalculateInput): CalculateOutput;
@@ -0,0 +1,145 @@
1
+ const n = (o, e = 0) => {
2
+ const r = Number(o);
3
+ return Number.isFinite(r) ? r : e;
4
+ }, u = (o, e = 2) => {
5
+ const r = Math.pow(10, e);
6
+ return Math.round((o + Number.EPSILON) * r) / r;
7
+ };
8
+ function h(o, e = !1) {
9
+ return o.reduce((r, t) => {
10
+ const a = n(t.price), i = Math.max(0, Math.floor(n(t.quantity))), c = a * i;
11
+ return e && t.taxable === !1 ? r : r + c;
12
+ }, 0);
13
+ }
14
+ function M(o) {
15
+ return o.reduce((e, r) => {
16
+ const t = n(r.originalPrice), a = n(r.price), i = Math.max(0, Math.floor(n(r.quantity)));
17
+ return t > a ? e + (t - a) * i : e;
18
+ }, 0);
19
+ }
20
+ function S(o) {
21
+ return o.reduce((e, r) => e + Math.max(0, Math.floor(n(r.quantity))), 0);
22
+ }
23
+ function y(o, e, r) {
24
+ if (!o) return 0;
25
+ const t = o.definition;
26
+ if (!t)
27
+ return Math.max(0, n(o.discountAmount));
28
+ if (t.currency && r && t.currency !== r) return 0;
29
+ if (t.expiresAt) {
30
+ const i = t.expiresAt instanceof Date ? t.expiresAt : new Date(t.expiresAt);
31
+ if (!Number.isNaN(i.getTime()) && i.getTime() < Date.now()) return 0;
32
+ }
33
+ if (t.minSubtotal !== void 0 && e < n(t.minSubtotal)) return 0;
34
+ let a = 0;
35
+ if (t.type === "percentage")
36
+ a = e * n(t.value) / 100;
37
+ else if (t.type === "fixed")
38
+ a = n(t.value);
39
+ else
40
+ return 0;
41
+ return t.maxDiscount !== void 0 && a > n(t.maxDiscount) && (a = n(t.maxDiscount)), a > e && (a = e), Math.max(0, a);
42
+ }
43
+ function k(o, e, r = 2) {
44
+ if (!e || e.mode === "exempt")
45
+ return { total: 0, breakdown: [] };
46
+ if (e.mode === "flat") {
47
+ const t = Math.max(0, n(e.amount));
48
+ return {
49
+ total: u(t, r),
50
+ breakdown: [{ label: e.label || "Tax", amount: u(t, r) }]
51
+ };
52
+ }
53
+ if (e.mode === "rate" || e.mode === "inclusive") {
54
+ const t = n(e.rate);
55
+ if (t <= 0) return { total: 0, breakdown: [] };
56
+ const a = u(o * t / 100, r), i = e.label || (e.mode === "inclusive" ? `VAT (${t}%)` : `Tax (${t}%)`);
57
+ return { total: a, breakdown: [{ label: i, amount: a, rate: t }] };
58
+ }
59
+ return { total: 0, breakdown: [] };
60
+ }
61
+ function g(o, e, r) {
62
+ if (!e || e.mode === "free" || e.mode === "pickup")
63
+ return {
64
+ cost: 0,
65
+ isFree: !0,
66
+ label: e?.label || (e?.mode === "pickup" ? "In-store pickup" : "Free shipping"),
67
+ freeShippingProgress: null
68
+ };
69
+ let t = 0, a = !1, i = e.label || "Shipping", c = 0, s = 0;
70
+ switch (e.mode) {
71
+ case "flat": {
72
+ t = Math.max(0, n(e.cost)), i = e.label || "Shipping";
73
+ break;
74
+ }
75
+ case "freeOver": {
76
+ c = n(e.freeOver), o >= c && c > 0 ? (t = 0, a = !0, i = e.label || `Free (orders over ${c})`) : (t = Math.max(0, n(e.cost)), i = e.label || "Shipping", s = c > 0 ? Math.max(0, c - o) : 0);
77
+ break;
78
+ }
79
+ case "tiered": {
80
+ const l = (e.tiers || []).slice().sort((m, d) => m.minSubtotal - d.minSubtotal);
81
+ let f;
82
+ for (const m of l)
83
+ if (o >= n(m.minSubtotal)) f = m;
84
+ else break;
85
+ !f && l.length && (f = l[0]), f && (t = Math.max(0, n(f.cost)), f.cost === 0 && (a = !0), i = f.label || e.label || "Shipping");
86
+ break;
87
+ }
88
+ case "function": {
89
+ if (typeof e.calculate == "function") {
90
+ const l = e.calculate(o, r);
91
+ t = Math.max(0, n(l?.cost)), l?.isFree && (a = !0), l?.label && (i = l.label);
92
+ }
93
+ break;
94
+ }
95
+ }
96
+ return {
97
+ cost: u(t, 2),
98
+ isFree: a,
99
+ label: i,
100
+ freeShippingProgress: e.mode === "freeOver" && c > 0 && !a ? { remaining: u(s, 2), threshold: c } : null
101
+ };
102
+ }
103
+ function T(o) {
104
+ const { items: e, tax: r, shipping: t, coupon: a, currency: i } = o, c = o.roundToCents ?? 2, s = u(h(e, !1), c);
105
+ u(h(e, !0), c);
106
+ const l = u(M(e), c), f = S(e), m = u(y(a, s, i), c), d = u(Math.max(0, s - m), c);
107
+ let x = d;
108
+ r?.applyTo === "subtotal" && (x = s), r?.applyTo === "original" && (x = s);
109
+ const b = k(x, r, c), p = g(
110
+ r?.applyTo === "original" ? s : d,
111
+ t,
112
+ e
113
+ ), v = u(
114
+ Math.max(0, d + b.total + p.cost),
115
+ c
116
+ );
117
+ return {
118
+ totals: {
119
+ subtotal: s,
120
+ discount: m > 0 ? m : void 0,
121
+ estimatedTax: b.total > 0 ? b.total : void 0,
122
+ taxRate: r?.mode === "rate" || r?.mode === "inclusive" ? r.rate : void 0,
123
+ shipping: p.cost,
124
+ grandTotal: v,
125
+ itemCount: f,
126
+ totalSavings: l > 0 ? l : void 0,
127
+ currency: i || r?.currency || t?.currency
128
+ },
129
+ taxBreakdown: b.breakdown,
130
+ freeShippingProgress: p.freeShippingProgress
131
+ };
132
+ }
133
+ function w(o) {
134
+ return T(o());
135
+ }
136
+ export {
137
+ T as calculateCartTotals,
138
+ y as computeCouponDiscount,
139
+ g as computeShipping,
140
+ k as computeTax,
141
+ S as sumItemCount,
142
+ h as sumLineTotals,
143
+ M as sumSavings,
144
+ w as useCartCalculation
145
+ };
@@ -0,0 +1,9 @@
1
+ export { default as Cart } from './Cart.vue';
2
+ export { default as CartLineItem } from './CartLineItem.vue';
3
+ export { default as CartSummary } from './CartSummary.vue';
4
+ export { default as CartCouponInput } from './CartCouponInput.vue';
5
+ export { default as CartEmptyState } from './CartEmptyState.vue';
6
+ export { useCart } from './composables/useCart';
7
+ export type { CartItemId, UseCartOptions, UseCartReturn } from './composables/useCart';
8
+ export * from './composables/useCartCalculation';
9
+ export * from './types';