vlite3 1.4.4 → 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 (58) hide show
  1. package/components/AppShell/AppShellLayoutStorefront.vue.js +2 -2
  2. package/components/Cart/Cart.vue.js +242 -0
  3. package/components/Cart/Cart.vue2.js +4 -0
  4. package/components/Cart/CartCouponInput.vue.js +176 -0
  5. package/components/Cart/CartCouponInput.vue2.js +4 -0
  6. package/components/Cart/CartEmptyState.vue.js +48 -0
  7. package/components/Cart/CartEmptyState.vue2.js +4 -0
  8. package/components/Cart/CartLineItem.vue.js +341 -0
  9. package/components/Cart/CartLineItem.vue2.js +4 -0
  10. package/components/Cart/CartSummary.vue.js +157 -0
  11. package/components/Cart/CartSummary.vue2.js +4 -0
  12. package/components/Cart/CartVariant1.vue.js +156 -0
  13. package/components/Cart/CartVariant1.vue2.js +4 -0
  14. package/components/Cart/CartVariant2.vue.js +154 -0
  15. package/components/Cart/CartVariant2.vue2.js +4 -0
  16. package/components/Cart/CartVariant3.vue.js +192 -0
  17. package/components/Cart/CartVariant3.vue2.js +4 -0
  18. package/components/Cart/CartVariant4.vue.js +145 -0
  19. package/components/Cart/CartVariant4.vue2.js +4 -0
  20. package/components/Cart/composables/useCart.d.ts +46 -0
  21. package/components/Cart/composables/useCart.js +110 -0
  22. package/components/Cart/composables/useCartCalculation.js +145 -0
  23. package/components/Cart/index.d.ts +2 -0
  24. package/components/CategoryManager/CategoryManager.vue.js +3 -3
  25. package/components/CategoryManager/CategoryManager.vue2.js +224 -248
  26. package/components/CategoryManager/utils.d.ts +3 -0
  27. package/components/CategoryManager/utils.js +31 -0
  28. package/components/CategoryMenu/CategoryMenu.vue.d.ts +2 -0
  29. package/components/CategoryMenu/CategoryMenu.vue.js +46 -40
  30. package/components/CategoryMenu/CategoryMenuVariant1.vue.d.ts +5 -1
  31. package/components/CategoryMenu/CategoryMenuVariant1.vue.js +5 -144
  32. package/components/CategoryMenu/CategoryMenuVariant1.vue2.js +220 -2
  33. package/components/CategoryMenu/CategoryMenuVariant2.vue.d.ts +5 -1
  34. package/components/CategoryMenu/CategoryMenuVariant2.vue.js +5 -160
  35. package/components/CategoryMenu/CategoryMenuVariant2.vue2.js +235 -2
  36. package/components/CategoryMenu/types.d.ts +5 -2
  37. package/components/Dropdown/Dropdown.vue.d.ts +1 -0
  38. package/components/Dropdown/Dropdown.vue.js +31 -29
  39. package/components/FilePicker/FilePicker.vue.js +278 -202
  40. package/components/Form/CustomFields.vue.d.ts +4 -0
  41. package/components/Form/CustomFields.vue.js +2 -2
  42. package/components/Form/CustomFields.vue2.js +349 -145
  43. package/components/Form/FormField.vue.js +1 -1
  44. package/components/Form/types.d.ts +3 -0
  45. package/components/Modal.vue.d.ts +2 -0
  46. package/components/Modal.vue.js +1 -1
  47. package/components/Modal.vue2.js +30 -28
  48. package/components/Screen/ScreenFilter.vue.js +3 -2
  49. package/components/SidePanel.vue.d.ts +2 -0
  50. package/components/SidePanel.vue.js +1 -1
  51. package/components/SidePanel.vue2.js +25 -23
  52. package/components/SidebarMenu/SidebarMenu.vue.js +145 -128
  53. package/components/index.d.ts +1 -0
  54. package/core/config.d.ts +6 -6
  55. package/index.d.ts +1 -0
  56. package/index.js +327 -306
  57. package/package.json +1 -1
  58. package/style.css +1 -1
@@ -0,0 +1,154 @@
1
+ import { defineComponent as z, computed as r, openBlock as a, createElementBlock as s, normalizeClass as o, createElementVNode as n, createBlock as p, createCommentVNode as d, toDisplayString as v, Fragment as L, renderList as N, createVNode as k, withCtx as C, createTextVNode as w } from "vue";
2
+ import q from "../Icon.vue.js";
3
+ import S from "../Button.vue.js";
4
+ import B from "./CartLineItem.vue.js";
5
+ import A from "./CartSummary.vue.js";
6
+ import D from "./CartCouponInput.vue.js";
7
+ import E from "./CartEmptyState.vue.js";
8
+ const I = { class: "flex items-center justify-center gap-1.5" }, R = { class: "flex-1 min-h-0 overflow-y-auto" }, j = { class: "divide-y divide-dashed divide-border" }, F = {
9
+ key: 0,
10
+ class: "shrink-0"
11
+ }, T = {
12
+ key: 1,
13
+ class: "grid grid-cols-2 gap-2"
14
+ }, P = /* @__PURE__ */ z({
15
+ __name: "CartVariant2",
16
+ props: {
17
+ data: {},
18
+ actions: {},
19
+ features: {},
20
+ labels: {},
21
+ compact: { type: Boolean, default: !1 },
22
+ variant: { default: "Variant2" },
23
+ containerClass: {}
24
+ },
25
+ emits: ["update:quantity", "remove", "clear", "apply-coupon", "remove-coupon", "coupon-change", "continue", "continue-shopping"],
26
+ setup(e, { emit: $ }) {
27
+ const b = e, u = $, c = r(() => b.data), y = r(() => b.labels || {}), l = r(() => b.actions || {}), m = r(() => b.features || {}), f = r(() => c.value.empty || !c.value.items || c.value.items.length === 0), x = r(
28
+ () => c.value.totals.itemCount ?? c.value.items?.reduce((h, t) => h + (t.quantity || 0), 0) ?? 0
29
+ );
30
+ return (h, t) => (a(), s("div", {
31
+ class: o(["v-cart v-cart-v2 flex flex-col bg-background text-foreground border border-border max-w-md mx-auto overflow-hidden h-full", [e.containerClass, e.compact ? "rounded-sm" : "rounded-md"]])
32
+ }, [
33
+ n("div", {
34
+ class: o(["text-center border-b border-dashed border-border shrink-0", e.compact ? "p-3" : "p-4"])
35
+ }, [
36
+ n("div", I, [
37
+ c.value.brandLogo ? (a(), p(q, {
38
+ key: 0,
39
+ icon: c.value.brandLogo,
40
+ class: o(e.compact ? "w-5 h-5" : "w-6 h-6")
41
+ }, null, 8, ["icon", "class"])) : d("", !0),
42
+ n("p", {
43
+ class: o(["font-bold text-foreground tracking-wide", e.compact ? "text-sm" : "text-base"])
44
+ }, v(c.value.brandName || c.value.title || y.value.cart || "Cart"), 3)
45
+ ]),
46
+ f.value ? d("", !0) : (a(), s("p", {
47
+ key: 0,
48
+ class: o(["text-muted-foreground tabular-nums font-semibold uppercase tracking-wider", e.compact ? "text-[10px] mt-0.5" : "text-xs mt-1"])
49
+ }, v(x.value) + " " + v(x.value === 1 ? "item" : "items"), 3))
50
+ ], 2),
51
+ n("div", R, [
52
+ f.value ? (a(), p(E, {
53
+ key: 0,
54
+ labels: e.labels,
55
+ compact: e.compact,
56
+ onContinueShopping: t[0] || (t[0] = (i) => u("continue-shopping"))
57
+ }, null, 8, ["labels", "compact"])) : (a(), s("div", {
58
+ key: 1,
59
+ class: o(e.compact ? "px-3 py-2" : "px-4 py-3")
60
+ }, [
61
+ n("div", {
62
+ class: o(["flex items-center text-muted-foreground font-semibold uppercase tracking-wider pb-1 border-b border-dashed border-border", e.compact ? "text-[9px] gap-1" : "text-[10px] gap-2"])
63
+ }, [...t[8] || (t[8] = [
64
+ n("span", { class: "flex-1" }, "Item", -1),
65
+ n("span", { class: "w-20 text-right" }, "Amount", -1)
66
+ ])], 2),
67
+ n("ul", j, [
68
+ (a(!0), s(L, null, N(e.data.items, (i) => (a(), s("li", {
69
+ key: i.id
70
+ }, [
71
+ k(B, {
72
+ item: i,
73
+ features: e.features,
74
+ labels: e.labels,
75
+ compact: e.compact,
76
+ readonly: e.data.readonly,
77
+ layout: "compact",
78
+ "onUpdate:quantity": t[1] || (t[1] = (g, V) => u("update:quantity", g, V)),
79
+ onRemove: t[2] || (t[2] = (g) => u("remove", g))
80
+ }, null, 8, ["item", "features", "labels", "compact", "readonly"])
81
+ ]))), 128))
82
+ ])
83
+ ], 2))
84
+ ]),
85
+ f.value ? d("", !0) : (a(), s("div", F, [
86
+ n("div", {
87
+ class: o(["border-t border-dashed border-border", e.compact ? "mx-3" : "mx-4"])
88
+ }, null, 2),
89
+ n("div", {
90
+ class: o(e.compact ? "px-3 py-2" : "px-4 py-3")
91
+ }, [
92
+ k(A, {
93
+ totals: e.data.totals,
94
+ features: e.features,
95
+ labels: e.labels,
96
+ compact: e.compact,
97
+ coupon: e.data.coupon,
98
+ variant: "Variant2"
99
+ }, null, 8, ["totals", "features", "labels", "compact", "coupon"])
100
+ ], 2),
101
+ n("div", {
102
+ class: o(["border-t border-dashed border-border", e.compact ? "mx-3" : "mx-4"])
103
+ }, null, 2),
104
+ n("div", {
105
+ class: o(e.compact ? "px-3 py-2.5 space-y-2.5" : "px-4 py-3 space-y-3")
106
+ }, [
107
+ e.features.coupon ? (a(), p(D, {
108
+ key: 0,
109
+ coupon: e.data.coupon,
110
+ labels: e.labels,
111
+ compact: e.compact,
112
+ readonly: e.data.readonly,
113
+ onApply: t[3] || (t[3] = (i) => u("apply-coupon", i)),
114
+ onRemove: t[4] || (t[4] = (i) => u("remove-coupon")),
115
+ onChange: t[5] || (t[5] = (i) => u("coupon-change", i))
116
+ }, null, 8, ["coupon", "labels", "compact", "readonly"])) : d("", !0),
117
+ l.value.showContinue && m.value.continue || l.value.showContinueShopping && m.value.continueShopping ? (a(), s("div", T, [
118
+ l.value.showContinueShopping && m.value.continueShopping ? (a(), p(S, {
119
+ key: 0,
120
+ variant: "outline",
121
+ size: e.compact ? "sm" : "md",
122
+ icon: l.value.continueShoppingIcon || "lucide:plus",
123
+ disabled: l.value.continueShoppingDisabled,
124
+ onClick: t[6] || (t[6] = (i) => u("continue-shopping"))
125
+ }, {
126
+ default: C(() => [
127
+ w(v(l.value.continueShoppingLabel || y.value.continueShopping || "Add more"), 1)
128
+ ]),
129
+ _: 1
130
+ }, 8, ["size", "icon", "disabled"])) : d("", !0),
131
+ l.value.showContinue && m.value.continue ? (a(), p(S, {
132
+ key: 1,
133
+ variant: "primary",
134
+ size: e.compact ? "sm" : "md",
135
+ icon: l.value.continueIcon || "lucide:credit-card",
136
+ "icon-right": void 0,
137
+ disabled: l.value.continueDisabled || f.value,
138
+ class: o(l.value.showContinueShopping && m.value.continueShopping ? "" : "col-span-2"),
139
+ onClick: t[7] || (t[7] = (i) => u("continue"))
140
+ }, {
141
+ default: C(() => [
142
+ w(v(l.value.continueLabel || y.value.continue || "Checkout"), 1)
143
+ ]),
144
+ _: 1
145
+ }, 8, ["size", "icon", "disabled", "class"])) : d("", !0)
146
+ ])) : d("", !0)
147
+ ], 2)
148
+ ]))
149
+ ], 2));
150
+ }
151
+ });
152
+ export {
153
+ P as default
154
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./CartVariant2.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,192 @@
1
+ import { defineComponent as B, computed as v, openBlock as a, createElementBlock as i, normalizeClass as o, createElementVNode as n, toDisplayString as d, createCommentVNode as s, createBlock as g, withCtx as y, createTextVNode as k, Fragment as $, renderList as V, createVNode as h } from "vue";
2
+ import N from "../Icon.vue.js";
3
+ import C from "../Button.vue.js";
4
+ import D from "./CartLineItem.vue.js";
5
+ import E from "./CartSummary.vue.js";
6
+ import L from "./CartCouponInput.vue.js";
7
+ import I from "./CartEmptyState.vue.js";
8
+ const P = {
9
+ key: 1,
10
+ class: "rounded-lg border border-border overflow-hidden"
11
+ }, R = { class: "divide-y divide-border" }, T = {
12
+ key: 0,
13
+ class: "space-y-2 mt-4"
14
+ }, j = { class: "font-medium text-foreground" }, J = /* @__PURE__ */ B({
15
+ __name: "CartVariant3",
16
+ props: {
17
+ data: {},
18
+ actions: {},
19
+ features: {},
20
+ labels: {},
21
+ compact: { type: Boolean, default: !1 },
22
+ variant: { default: "Variant3" },
23
+ containerClass: {}
24
+ },
25
+ emits: ["update:quantity", "remove", "clear", "apply-coupon", "remove-coupon", "coupon-change", "continue", "continue-shopping"],
26
+ setup(e, { emit: z }) {
27
+ const b = e, u = z, r = v(() => b.data), x = v(() => b.labels || {}), c = v(() => b.actions || {}), p = v(() => b.features || {}), m = v(() => r.value.empty || !r.value.items || r.value.items.length === 0), w = v(
28
+ () => r.value.totals.itemCount ?? r.value.items?.reduce((S, t) => S + (t.quantity || 0), 0) ?? 0
29
+ );
30
+ return (S, t) => (a(), i("div", {
31
+ class: o(["v-cart v-cart-v3 w-full bg-background text-foreground", e.containerClass])
32
+ }, [
33
+ n("div", {
34
+ class: o(["flex flex-col sm:flex-row sm:items-end sm:justify-between gap-3 border-b border-border", e.compact ? "pb-3 mb-4" : "pb-4 mb-6"])
35
+ }, [
36
+ n("div", null, [
37
+ n("h1", {
38
+ class: o(["font-extrabold tracking-tight text-foreground", e.compact ? "text-xl" : "text-3xl"])
39
+ }, d(r.value.title || x.value.cart || "Shopping Cart"), 3),
40
+ m.value ? s("", !0) : (a(), i("p", {
41
+ key: 0,
42
+ class: o(["text-muted-foreground mt-0.5", e.compact ? "text-xs" : "text-sm"])
43
+ }, d(w.value) + " " + d(w.value === 1 ? "item" : "items") + " in your cart ", 3))
44
+ ]),
45
+ e.features.clearable && !m.value && !e.data.readonly ? (a(), g(C, {
46
+ key: 0,
47
+ variant: "ghost",
48
+ size: "sm",
49
+ icon: "lucide:trash-2",
50
+ class: "self-start",
51
+ onClick: t[0] || (t[0] = (l) => u("clear"))
52
+ }, {
53
+ default: y(() => [
54
+ k(d(x.value.clearCart || "Clear cart"), 1)
55
+ ]),
56
+ _: 1
57
+ })) : s("", !0)
58
+ ], 2),
59
+ n("div", {
60
+ class: o(["grid gap-6", [
61
+ m.value ? "grid-cols-1" : "grid-cols-1 lg:grid-cols-[1fr_360px] xl:grid-cols-[1fr_400px]",
62
+ e.compact ? "gap-4" : "gap-6"
63
+ ]])
64
+ }, [
65
+ n("div", null, [
66
+ m.value ? (a(), g(I, {
67
+ key: 0,
68
+ labels: e.labels,
69
+ compact: e.compact,
70
+ onContinueShopping: t[1] || (t[1] = (l) => u("continue-shopping"))
71
+ }, null, 8, ["labels", "compact"])) : (a(), i("div", P, [
72
+ n("div", {
73
+ class: o(["bg-muted/40 border-b border-border text-muted-foreground uppercase tracking-wider font-bold flex items-center", [e.compact ? "px-3 py-2 text-[10px]" : "px-4 py-2.5 text-xs"]])
74
+ }, [
75
+ t[9] || (t[9] = n("span", { class: "flex-1" }, "Product", -1)),
76
+ n("span", {
77
+ class: o(e.compact ? "w-14 text-right" : "w-20 text-right")
78
+ }, "Qty", 2),
79
+ n("span", {
80
+ class: o(e.compact ? "w-20 text-right" : "w-28 text-right")
81
+ }, "Total", 2)
82
+ ], 2),
83
+ n("ul", R, [
84
+ (a(!0), i($, null, V(e.data.items, (l) => (a(), i("li", {
85
+ key: l.id
86
+ }, [
87
+ h(D, {
88
+ item: l,
89
+ features: e.features,
90
+ labels: e.labels,
91
+ compact: e.compact,
92
+ readonly: e.data.readonly,
93
+ layout: "card",
94
+ "onUpdate:quantity": t[2] || (t[2] = (f, q) => u("update:quantity", f, q)),
95
+ onRemove: t[3] || (t[3] = (f) => u("remove", f))
96
+ }, null, 8, ["item", "features", "labels", "compact", "readonly"])
97
+ ]))), 128))
98
+ ])
99
+ ]))
100
+ ]),
101
+ m.value ? s("", !0) : (a(), i("aside", {
102
+ key: 0,
103
+ class: o(["lg:sticky lg:top-4 self-start", e.compact ? "space-y-3" : "space-y-4"])
104
+ }, [
105
+ n("div", {
106
+ class: o(["rounded-lg border border-border overflow-hidden", e.compact ? "p-4" : "p-5"])
107
+ }, [
108
+ n("h3", {
109
+ class: o(["font-bold text-foreground uppercase tracking-widest text-muted-foreground", e.compact ? "text-[10px] mb-2" : "text-xs mb-3"])
110
+ }, " Order Summary ", 2),
111
+ n("div", {
112
+ class: o(e.compact ? "space-y-3" : "space-y-4")
113
+ }, [
114
+ e.features.coupon ? (a(), g(L, {
115
+ key: 0,
116
+ coupon: e.data.coupon,
117
+ labels: e.labels,
118
+ compact: e.compact,
119
+ readonly: e.data.readonly,
120
+ onApply: t[4] || (t[4] = (l) => u("apply-coupon", l)),
121
+ onRemove: t[5] || (t[5] = (l) => u("remove-coupon")),
122
+ onChange: t[6] || (t[6] = (l) => u("coupon-change", l))
123
+ }, null, 8, ["coupon", "labels", "compact", "readonly"])) : s("", !0),
124
+ n("div", {
125
+ class: o(["border-t border-border", e.compact ? "pt-2" : "pt-3"])
126
+ }, [
127
+ h(E, {
128
+ totals: e.data.totals,
129
+ features: e.features,
130
+ labels: e.labels,
131
+ compact: e.compact,
132
+ coupon: e.data.coupon,
133
+ variant: "Variant3"
134
+ }, null, 8, ["totals", "features", "labels", "compact", "coupon"])
135
+ ], 2)
136
+ ], 2),
137
+ c.value.showContinue && p.value.continue || c.value.showContinueShopping && p.value.continueShopping ? (a(), i("div", T, [
138
+ c.value.showContinue && p.value.continue ? (a(), g(C, {
139
+ key: 0,
140
+ variant: "primary",
141
+ size: e.compact ? "md" : "lg",
142
+ block: !0,
143
+ icon: c.value.continueIcon || "lucide:lock",
144
+ disabled: c.value.continueDisabled || m.value,
145
+ class: "w-full",
146
+ onClick: t[7] || (t[7] = (l) => u("continue"))
147
+ }, {
148
+ default: y(() => [
149
+ k(d(c.value.continueLabel || x.value.continue || "Proceed to checkout"), 1)
150
+ ]),
151
+ _: 1
152
+ }, 8, ["size", "icon", "disabled"])) : s("", !0),
153
+ c.value.showContinueShopping && p.value.continueShopping ? (a(), g(C, {
154
+ key: 1,
155
+ variant: "ghost",
156
+ size: e.compact ? "sm" : "md",
157
+ block: !0,
158
+ icon: c.value.continueShoppingIcon || "lucide:arrow-left",
159
+ disabled: c.value.continueShoppingDisabled,
160
+ class: "w-full",
161
+ onClick: t[8] || (t[8] = (l) => u("continue-shopping"))
162
+ }, {
163
+ default: y(() => [
164
+ k(d(c.value.continueShoppingLabel || x.value.continueShopping || "Continue shopping"), 1)
165
+ ]),
166
+ _: 1
167
+ }, 8, ["size", "icon", "disabled"])) : s("", !0)
168
+ ])) : s("", !0)
169
+ ], 2),
170
+ p.value.trustSignals && r.value.trustSignals?.length ? (a(), i("div", {
171
+ key: 0,
172
+ class: o(["rounded-lg border border-border bg-muted/30", e.compact ? "p-3 space-y-2" : "p-4 space-y-2.5"])
173
+ }, [
174
+ (a(!0), i($, null, V(r.value.trustSignals, (l, f) => (a(), i("div", {
175
+ key: f,
176
+ class: o(["flex items-center gap-2", e.compact ? "text-xs" : "text-sm"])
177
+ }, [
178
+ h(N, {
179
+ icon: l.icon,
180
+ class: "w-4 h-4 text-muted-foreground"
181
+ }, null, 8, ["icon"]),
182
+ n("span", j, d(l.text), 1)
183
+ ], 2))), 128))
184
+ ], 2)) : s("", !0)
185
+ ], 2))
186
+ ], 2)
187
+ ], 2));
188
+ }
189
+ });
190
+ export {
191
+ J as default
192
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./CartVariant3.vue.js";
2
+ export {
3
+ f as default
4
+ };
@@ -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
+ };