@a4ui/core 0.16.0 → 0.18.0

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 (40) hide show
  1. package/dist/{Checkbox-B5Gb3h5J.js → Checkbox-BZjX1GMG.js} +153 -146
  2. package/dist/commerce/ProductCard.d.ts +10 -0
  3. package/dist/commerce/createCart.d.ts +53 -0
  4. package/dist/commerce/index.d.ts +1 -0
  5. package/dist/commerce.js +160 -133
  6. package/dist/elements.css +244 -0
  7. package/dist/elements.iife.js +3 -3
  8. package/dist/elements.js +590 -583
  9. package/dist/full.css +244 -0
  10. package/dist/index.d.ts +5 -1
  11. package/dist/index.js +3090 -2798
  12. package/dist/layout/ActionBar.d.ts +53 -0
  13. package/dist/layout/Section.d.ts +31 -0
  14. package/dist/styles.css +66 -0
  15. package/dist/ui/Badge.d.ts +6 -0
  16. package/dist/ui/BeforeAfter.d.ts +34 -0
  17. package/dist/ui/Carousel.d.ts +6 -0
  18. package/dist/ui/FloatingActionButton.d.ts +6 -0
  19. package/dist/ui/Image.d.ts +6 -0
  20. package/dist/ui/List.d.ts +5 -0
  21. package/dist/ui/PricingTable.d.ts +60 -0
  22. package/dist/ui/Skeleton.d.ts +10 -3
  23. package/package.json +1 -1
  24. package/src/commerce/ProductCard.tsx +26 -2
  25. package/src/commerce/createCart.ts +102 -0
  26. package/src/commerce/index.ts +1 -0
  27. package/src/index.ts +5 -1
  28. package/src/layout/ActionBar.tsx +121 -0
  29. package/src/layout/Section.tsx +69 -0
  30. package/src/ui/Accordion.tsx +3 -1
  31. package/src/ui/Badge.tsx +14 -2
  32. package/src/ui/BeforeAfter.tsx +162 -0
  33. package/src/ui/Carousel.tsx +48 -3
  34. package/src/ui/Collapse.tsx +13 -4
  35. package/src/ui/FloatingActionButton.tsx +16 -1
  36. package/src/ui/Image.tsx +29 -1
  37. package/src/ui/List.tsx +10 -2
  38. package/src/ui/PricingTable.tsx +196 -0
  39. package/src/ui/Skeleton.tsx +17 -5
  40. package/src/ui/SpeedDial.tsx +3 -1
package/dist/commerce.js CHANGED
@@ -1,125 +1,131 @@
1
- import { insert as n, createComponent as c, memo as A, effect as v, className as b, template as o, delegateEvents as y, setAttribute as x } from "solid-js/web";
2
- import { Show as g, For as C } from "solid-js";
3
- import { c as h } from "./cn-B6yFEsav.js";
4
- import { B as T, C as N, R as E, a as S, b as I } from "./Checkbox-B5Gb3h5J.js";
5
- import { Minus as R, Plus as F, Trash2 as U } from "lucide-solid";
6
- var j = /* @__PURE__ */ o('<span class="text-muted-foreground line-through">'), q = /* @__PURE__ */ o("<div><span>");
7
- const B = {
1
+ import { insert as l, createComponent as d, memo as I, effect as b, className as $, template as g, delegateEvents as S, setAttribute as y } from "solid-js/web";
2
+ import { Show as h, For as k, createSignal as N, createMemo as C } from "solid-js";
3
+ import { c as x } from "./cn-B6yFEsav.js";
4
+ import { B as q, C as E, R, a as A, b as F } from "./Checkbox-BZjX1GMG.js";
5
+ import { Minus as M, Plus as P, Trash2 as U } from "lucide-solid";
6
+ var j = /* @__PURE__ */ g('<span class="text-muted-foreground line-through">'), B = /* @__PURE__ */ g("<div><span>");
7
+ const D = {
8
8
  sm: "text-sm",
9
9
  md: "text-lg",
10
10
  lg: "text-2xl"
11
11
  };
12
- function k(e) {
13
- const r = (u) => new Intl.NumberFormat(e.locale ?? "en-US", {
12
+ function T(e) {
13
+ const n = (a) => new Intl.NumberFormat(e.locale ?? "en-US", {
14
14
  style: "currency",
15
15
  currency: e.currency ?? "USD"
16
- }).format(u), l = () => (e.compareAt ?? 0) > e.amount, t = () => Math.round((1 - e.amount / e.compareAt) * 100);
16
+ }).format(a), r = () => (e.compareAt ?? 0) > e.amount, t = () => Math.round((1 - e.amount / e.compareAt) * 100);
17
17
  return (() => {
18
- var u = q(), d = u.firstChild;
19
- return n(d, () => r(e.amount)), n(u, c(g, {
18
+ var a = B(), o = a.firstChild;
19
+ return l(o, () => n(e.amount)), l(a, d(h, {
20
20
  get when() {
21
- return l();
21
+ return r();
22
22
  },
23
23
  get children() {
24
24
  return [(() => {
25
- var i = j();
26
- return n(i, () => r(e.compareAt)), i;
27
- })(), c(T, {
25
+ var u = j();
26
+ return l(u, () => n(e.compareAt)), u;
27
+ })(), d(q, {
28
28
  tone: "danger",
29
29
  get children() {
30
- return ["-", A(() => t()), "%"];
30
+ return ["-", I(() => t()), "%"];
31
31
  }
32
32
  })];
33
33
  }
34
- }), null), v((i) => {
35
- var a = h("inline-flex items-center gap-2", e.class), m = h("font-bold text-foreground", B[e.size ?? "md"]);
36
- return a !== i.e && b(u, i.e = a), m !== i.t && b(d, i.t = m), i;
34
+ }), null), b((u) => {
35
+ var c = x("inline-flex items-center gap-2", e.class), s = x("font-bold text-foreground", D[e.size ?? "md"]);
36
+ return c !== u.e && $(a, u.e = c), s !== u.t && $(o, u.t = s), u;
37
37
  }, {
38
38
  e: void 0,
39
39
  t: void 0
40
- }), u;
40
+ }), a;
41
41
  })();
42
42
  }
43
- var M = /* @__PURE__ */ o('<div><button type=button aria-label="Decrease quantity"class="grid h-8 w-8 place-items-center hover:bg-muted disabled:opacity-40"></button><span class="grid min-w-[2.5rem] place-items-center tabular-nums"></span><button type=button aria-label="Increase quantity"class="grid h-8 w-8 place-items-center hover:bg-muted disabled:opacity-40">');
44
- function P(e) {
45
- const r = () => e.min ?? 0, l = () => e.max ?? Number.MAX_SAFE_INTEGER, t = (i) => Math.min(l(), Math.max(r(), i)), u = () => e.onChange(t(e.value - 1)), d = () => e.onChange(t(e.value + 1));
43
+ var L = /* @__PURE__ */ g('<div><button type=button aria-label="Decrease quantity"class="grid h-8 w-8 place-items-center hover:bg-muted disabled:opacity-40"></button><span class="grid min-w-[2.5rem] place-items-center tabular-nums"></span><button type=button aria-label="Increase quantity"class="grid h-8 w-8 place-items-center hover:bg-muted disabled:opacity-40">');
44
+ function z(e) {
45
+ const n = () => e.min ?? 0, r = () => e.max ?? Number.MAX_SAFE_INTEGER, t = (u) => Math.min(r(), Math.max(n(), u)), a = () => e.onChange(t(e.value - 1)), o = () => e.onChange(t(e.value + 1));
46
46
  return (() => {
47
- var i = M(), a = i.firstChild, m = a.nextSibling, f = m.nextSibling;
48
- return a.$$click = u, n(a, c(R, {
47
+ var u = L(), c = u.firstChild, s = c.nextSibling, f = s.nextSibling;
48
+ return c.$$click = a, l(c, d(M, {
49
49
  class: "h-4 w-4"
50
- })), n(m, () => e.value), f.$$click = d, n(f, c(F, {
50
+ })), l(s, () => e.value), f.$$click = o, l(f, d(P, {
51
51
  class: "h-4 w-4"
52
- })), v((s) => {
53
- var $ = h("inline-flex items-stretch rounded-md border border-input", e.class), _ = e.disabled || e.value <= r(), w = e.disabled || e.value >= l();
54
- return $ !== s.e && b(i, s.e = $), _ !== s.t && (a.disabled = s.t = _), w !== s.a && (f.disabled = s.a = w), s;
52
+ })), b((i) => {
53
+ var m = x("inline-flex items-stretch rounded-md border border-input", e.class), v = e.disabled || e.value <= n(), _ = e.disabled || e.value >= r();
54
+ return m !== i.e && $(u, i.e = m), v !== i.t && (c.disabled = i.t = v), _ !== i.a && (f.disabled = i.a = _), i;
55
55
  }, {
56
56
  e: void 0,
57
57
  t: void 0,
58
58
  a: void 0
59
- }), i;
59
+ }), u;
60
60
  })();
61
61
  }
62
- y(["click"]);
63
- var D = /* @__PURE__ */ o("<span>"), L = /* @__PURE__ */ o('<div class="relative aspect-square overflow-hidden rounded-lg bg-muted"><img loading=lazy class="h-full w-full object-cover">', !0, !1, !1), z = /* @__PURE__ */ o('<span class="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">'), G = /* @__PURE__ */ o('<span class="w-fit rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground">'), O = /* @__PURE__ */ o('<div class="mt-3 flex flex-1 flex-col gap-1.5"><p class="line-clamp-1 font-medium text-foreground">');
64
- const Q = {
62
+ S(["click"]);
63
+ var G = /* @__PURE__ */ g("<span>"), O = /* @__PURE__ */ g('<div class="relative aspect-square overflow-hidden rounded-lg bg-muted"><img loading=lazy class="h-full w-full object-cover">', !0, !1, !1), Q = /* @__PURE__ */ g('<span class="text-[11px] font-medium uppercase tracking-wide text-muted-foreground">'), X = /* @__PURE__ */ g('<span class="w-fit rounded bg-muted px-1.5 py-0.5 text-[11px] text-muted-foreground">'), Z = /* @__PURE__ */ g('<div class="mt-3 flex flex-1 flex-col gap-1.5"><p class="line-clamp-1 font-medium text-foreground">');
64
+ const H = {
65
65
  sale: "bg-destructive text-destructive-foreground",
66
66
  new: "bg-primary text-primary-foreground",
67
67
  featured: "bg-accent text-accent-foreground"
68
68
  };
69
- function X(e, r) {
70
- if (r) return r;
71
- const l = (e ?? "").toLowerCase();
72
- return /sale|off|%|deal/.test(l) ? "sale" : /new/.test(l) ? "new" : "featured";
69
+ function J(e, n) {
70
+ if (n) return n;
71
+ const r = (e ?? "").toLowerCase();
72
+ return /sale|off|%|deal/.test(r) ? "sale" : /new/.test(r) ? "new" : "featured";
73
73
  }
74
- function ue(e) {
75
- return c(N, {
74
+ function de(e) {
75
+ return d(E, {
76
76
  glass: !0,
77
77
  glow: !0,
78
+ get tilt() {
79
+ return e.tilt;
80
+ },
81
+ get spotlight() {
82
+ return e.spotlight;
83
+ },
78
84
  get class() {
79
- return h("flex h-full flex-col overflow-hidden p-4", e.class);
85
+ return x("flex h-full flex-col overflow-hidden p-4", e.class);
80
86
  },
81
87
  get children() {
82
88
  return [(() => {
83
- var r = L(), l = r.firstChild;
84
- return n(r, c(g, {
89
+ var n = O(), r = n.firstChild;
90
+ return l(n, d(h, {
85
91
  get when() {
86
92
  return e.badge;
87
93
  },
88
94
  get children() {
89
- var t = D();
90
- return n(t, () => e.badge), v(() => b(t, h("absolute -right-9 top-3.5 w-32 rotate-45 py-1 text-center text-[11px] font-semibold uppercase tracking-wide shadow-md", Q[X(e.badge, e.badgeTone)]))), t;
95
+ var t = G();
96
+ return l(t, () => e.badge), b(() => $(t, x("absolute -right-9 top-3.5 w-32 rotate-45 py-1 text-center text-[11px] font-semibold uppercase tracking-wide shadow-md", H[J(e.badge, e.badgeTone)]))), t;
91
97
  }
92
- }), null), v((t) => {
93
- var u = e.image, d = e.title;
94
- return u !== t.e && x(l, "src", t.e = u), d !== t.t && x(l, "alt", t.t = d), t;
98
+ }), null), b((t) => {
99
+ var a = e.image, o = e.title;
100
+ return a !== t.e && y(r, "src", t.e = a), o !== t.t && y(r, "alt", t.t = o), t;
95
101
  }, {
96
102
  e: void 0,
97
103
  t: void 0
98
- }), r;
104
+ }), n;
99
105
  })(), (() => {
100
- var r = O(), l = r.firstChild;
101
- return n(r, c(g, {
106
+ var n = Z(), r = n.firstChild;
107
+ return l(n, d(h, {
102
108
  get when() {
103
109
  return e.brand;
104
110
  },
105
111
  get children() {
106
- var t = z();
107
- return n(t, () => e.brand), t;
112
+ var t = Q();
113
+ return l(t, () => e.brand), t;
108
114
  }
109
- }), l), n(l, () => e.title), n(r, c(g, {
115
+ }), r), l(r, () => e.title), l(n, d(h, {
110
116
  get when() {
111
117
  return e.category;
112
118
  },
113
119
  get children() {
114
- var t = G();
115
- return n(t, () => e.category), t;
120
+ var t = X();
121
+ return l(t, () => e.category), t;
116
122
  }
117
- }), null), n(r, c(g, {
123
+ }), null), l(n, d(h, {
118
124
  get when() {
119
125
  return e.rating !== void 0;
120
126
  },
121
127
  get children() {
122
- return c(E, {
128
+ return d(R, {
123
129
  get value() {
124
130
  return e.rating;
125
131
  },
@@ -127,7 +133,7 @@ function ue(e) {
127
133
  max: 5
128
134
  });
129
135
  }
130
- }), null), n(r, c(k, {
136
+ }), null), l(n, d(T, {
131
137
  get amount() {
132
138
  return e.price;
133
139
  },
@@ -140,55 +146,55 @@ function ue(e) {
140
146
  get locale() {
141
147
  return e.locale;
142
148
  }
143
- }), null), n(r, c(g, {
149
+ }), null), l(n, d(h, {
144
150
  get when() {
145
151
  return e.onAddToCart;
146
152
  },
147
153
  get children() {
148
- return c(S, {
154
+ return d(A, {
149
155
  class: "mt-auto w-full",
150
- onClick: () => {
151
- var t;
152
- return (t = e.onAddToCart) == null ? void 0 : t.call(e);
156
+ onClick: (t) => {
157
+ var a;
158
+ t.stopPropagation(), (a = e.onAddToCart) == null || a.call(e);
153
159
  },
154
160
  children: "Add to cart"
155
161
  });
156
162
  }
157
- }), null), r;
163
+ }), null), n;
158
164
  })()];
159
165
  }
160
166
  });
161
167
  }
162
- var Z = /* @__PURE__ */ o("<div>");
163
- function ce(e) {
168
+ var K = /* @__PURE__ */ g("<div>");
169
+ function oe(e) {
164
170
  return (() => {
165
- var r = Z();
166
- return n(r, () => e.children), v(() => b(r, h("grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4", e.class))), r;
171
+ var n = K();
172
+ return l(n, () => e.children), b(() => $(n, x("grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-4", e.class))), n;
167
173
  })();
168
174
  }
169
- var H = /* @__PURE__ */ o('<img class="h-16 w-16 shrink-0 rounded-md bg-muted object-cover">'), J = /* @__PURE__ */ o('<button type=button aria-label="Remove item"class="text-muted-foreground hover:text-foreground">'), K = /* @__PURE__ */ o('<div><div class="min-w-[8rem] flex-1"><p class="line-clamp-1 font-medium text-foreground"></p></div><span class="min-w-[4rem] text-right font-medium tabular-nums text-foreground">');
170
- function ie(e) {
171
- const r = () => e.price * e.quantity, l = (t) => new Intl.NumberFormat(e.locale ?? "en-US", {
175
+ var V = /* @__PURE__ */ g('<img class="h-16 w-16 shrink-0 rounded-md bg-muted object-cover">'), W = /* @__PURE__ */ g('<button type=button aria-label="Remove item"class="text-muted-foreground hover:text-foreground">'), Y = /* @__PURE__ */ g('<div><div class="min-w-[8rem] flex-1"><p class="line-clamp-1 font-medium text-foreground"></p></div><span class="min-w-[4rem] text-right font-medium tabular-nums text-foreground">');
176
+ function se(e) {
177
+ const n = () => e.price * e.quantity, r = (t) => new Intl.NumberFormat(e.locale ?? "en-US", {
172
178
  style: "currency",
173
179
  currency: e.currency ?? "USD"
174
180
  }).format(t);
175
181
  return (() => {
176
- var t = K(), u = t.firstChild, d = u.firstChild, i = u.nextSibling;
177
- return n(t, c(g, {
182
+ var t = Y(), a = t.firstChild, o = a.firstChild, u = a.nextSibling;
183
+ return l(t, d(h, {
178
184
  get when() {
179
185
  return e.image;
180
186
  },
181
187
  get children() {
182
- var a = H();
183
- return v((m) => {
184
- var f = e.image, s = e.title;
185
- return f !== m.e && x(a, "src", m.e = f), s !== m.t && x(a, "alt", m.t = s), m;
188
+ var c = V();
189
+ return b((s) => {
190
+ var f = e.image, i = e.title;
191
+ return f !== s.e && y(c, "src", s.e = f), i !== s.t && y(c, "alt", s.t = i), s;
186
192
  }, {
187
193
  e: void 0,
188
194
  t: void 0
189
- }), a;
195
+ }), c;
190
196
  }
191
- }), u), n(d, () => e.title), n(u, c(k, {
197
+ }), a), l(o, () => e.title), l(a, d(T, {
192
198
  get amount() {
193
199
  return e.price;
194
200
  },
@@ -199,108 +205,129 @@ function ie(e) {
199
205
  return e.locale;
200
206
  },
201
207
  size: "sm"
202
- }), null), n(t, c(P, {
208
+ }), null), l(t, d(z, {
203
209
  get value() {
204
210
  return e.quantity;
205
211
  },
206
- onChange: (a) => {
207
- var m;
208
- return (m = e.onQuantityChange) == null ? void 0 : m.call(e, a);
212
+ onChange: (c) => {
213
+ var s;
214
+ return (s = e.onQuantityChange) == null ? void 0 : s.call(e, c);
209
215
  },
210
216
  min: 1
211
- }), i), n(i, () => l(r())), n(t, c(g, {
217
+ }), u), l(u, () => r(n())), l(t, d(h, {
212
218
  get when() {
213
219
  return e.onRemove;
214
220
  },
215
221
  get children() {
216
- var a = J();
217
- return a.$$click = () => {
218
- var m;
219
- return (m = e.onRemove) == null ? void 0 : m.call(e);
220
- }, n(a, c(U, {
222
+ var c = W();
223
+ return c.$$click = () => {
224
+ var s;
225
+ return (s = e.onRemove) == null ? void 0 : s.call(e);
226
+ }, l(c, d(U, {
221
227
  class: "h-4 w-4"
222
- })), a;
228
+ })), c;
223
229
  }
224
- }), null), v(() => b(t, h("flex flex-wrap items-center gap-4", e.class))), t;
230
+ }), null), b(() => $(t, x("flex flex-wrap items-center gap-4", e.class))), t;
225
231
  })();
226
232
  }
227
- y(["click"]);
228
- var V = /* @__PURE__ */ o('<div><div class="my-3 border-t border-border"></div><div class="flex items-center justify-between text-base font-bold text-foreground"><span>Total</span><span class=tabular-nums>'), W = /* @__PURE__ */ o('<div class="flex items-center justify-between py-1 text-sm"><span class=text-muted-foreground></span><span class="tabular-nums text-foreground">');
229
- function de(e) {
230
- const r = (l) => new Intl.NumberFormat(e.locale ?? "en-US", {
233
+ S(["click"]);
234
+ var p = /* @__PURE__ */ g('<div><div class="my-3 border-t border-border"></div><div class="flex items-center justify-between text-base font-bold text-foreground"><span>Total</span><span class=tabular-nums>'), ee = /* @__PURE__ */ g('<div class="flex items-center justify-between py-1 text-sm"><span class=text-muted-foreground></span><span class="tabular-nums text-foreground">');
235
+ function me(e) {
236
+ const n = (r) => new Intl.NumberFormat(e.locale ?? "en-US", {
231
237
  style: "currency",
232
238
  currency: e.currency ?? "USD"
233
- }).format(l);
239
+ }).format(r);
234
240
  return (() => {
235
- var l = V(), t = l.firstChild, u = t.nextSibling, d = u.firstChild, i = d.nextSibling;
236
- return n(l, c(C, {
241
+ var r = p(), t = r.firstChild, a = t.nextSibling, o = a.firstChild, u = o.nextSibling;
242
+ return l(r, d(k, {
237
243
  get each() {
238
244
  return e.lines;
239
245
  },
240
- children: (a) => (() => {
241
- var m = W(), f = m.firstChild, s = f.nextSibling;
242
- return n(f, () => a.label), n(s, () => r(a.amount)), m;
246
+ children: (c) => (() => {
247
+ var s = ee(), f = s.firstChild, i = f.nextSibling;
248
+ return l(f, () => c.label), l(i, () => n(c.amount)), s;
243
249
  })()
244
- }), t), n(i, () => r(e.total)), n(l, c(g, {
250
+ }), t), l(u, () => n(e.total)), l(r, d(h, {
245
251
  get when() {
246
252
  return e.onCheckout;
247
253
  },
248
254
  get children() {
249
- return c(S, {
255
+ return d(A, {
250
256
  class: "mt-4 w-full",
251
257
  onClick: () => {
252
- var a;
253
- return (a = e.onCheckout) == null ? void 0 : a.call(e);
258
+ var c;
259
+ return (c = e.onCheckout) == null ? void 0 : c.call(e);
254
260
  },
255
261
  get children() {
256
262
  return e.checkoutLabel ?? "Checkout";
257
263
  }
258
264
  });
259
265
  }
260
- }), null), v(() => b(l, h("card glow-edge rounded-xl p-5 text-card-foreground", e.class))), l;
266
+ }), null), b(() => $(r, x("card glow-edge rounded-xl p-5 text-card-foreground", e.class))), r;
261
267
  })();
262
268
  }
263
- var Y = /* @__PURE__ */ o('<div><p class="text-sm font-semibold text-foreground"></p><div class=space-y-1.5>'), p = /* @__PURE__ */ o('<span class="text-xs text-muted-foreground">'), ee = /* @__PURE__ */ o('<div class="flex items-center justify-between gap-2">');
264
- function me(e) {
265
- const r = (l, t) => {
266
- const u = e.selected.slice(), d = u.indexOf(l);
267
- t ? d === -1 && u.push(l) : d !== -1 && u.splice(d, 1), e.onChange(u);
269
+ var te = /* @__PURE__ */ g('<div><p class="text-sm font-semibold text-foreground"></p><div class=space-y-1.5>'), ne = /* @__PURE__ */ g('<span class="text-xs text-muted-foreground">'), re = /* @__PURE__ */ g('<div class="flex items-center justify-between gap-2">');
270
+ function ge(e) {
271
+ const n = (r, t) => {
272
+ const a = e.selected.slice(), o = a.indexOf(r);
273
+ t ? o === -1 && a.push(r) : o !== -1 && a.splice(o, 1), e.onChange(a);
268
274
  };
269
275
  return (() => {
270
- var l = Y(), t = l.firstChild, u = t.nextSibling;
271
- return n(t, () => e.title), n(u, c(C, {
276
+ var r = te(), t = r.firstChild, a = t.nextSibling;
277
+ return l(t, () => e.title), l(a, d(k, {
272
278
  get each() {
273
279
  return e.options;
274
280
  },
275
- children: (d) => (() => {
276
- var i = ee();
277
- return n(i, c(I, {
281
+ children: (o) => (() => {
282
+ var u = re();
283
+ return l(u, d(F, {
278
284
  get checked() {
279
- return e.selected.includes(d.value);
285
+ return e.selected.includes(o.value);
280
286
  },
281
- onChange: (a) => r(d.value, a),
287
+ onChange: (c) => n(o.value, c),
282
288
  get label() {
283
- return d.label;
289
+ return o.label;
284
290
  }
285
- }), null), n(i, c(g, {
291
+ }), null), l(u, d(h, {
286
292
  get when() {
287
- return d.count != null;
293
+ return o.count != null;
288
294
  },
289
295
  get children() {
290
- var a = p();
291
- return n(a, () => d.count), a;
296
+ var c = ne();
297
+ return l(c, () => o.count), c;
292
298
  }
293
- }), null), i;
299
+ }), null), u;
294
300
  })()
295
- })), v(() => b(l, h("space-y-2", e.class))), l;
301
+ })), b(() => $(r, x("space-y-2", e.class))), r;
296
302
  })();
297
303
  }
304
+ function fe(e = []) {
305
+ const [n, r] = N(e), t = (i, m = 1) => {
306
+ r((v) => v.find((w) => w.product.id === i.id) ? v.map(
307
+ (w) => w.product.id === i.id ? { ...w, qty: w.qty + m } : w
308
+ ) : [...v, { product: i, qty: m }]);
309
+ }, a = (i) => {
310
+ r((m) => m.filter((v) => v.product.id !== i));
311
+ }, o = (i, m) => {
312
+ if (m <= 0) {
313
+ a(i);
314
+ return;
315
+ }
316
+ r((v) => v.map((_) => _.product.id === i ? { ..._, qty: m } : _));
317
+ }, u = () => {
318
+ r([]);
319
+ }, c = C(() => n().reduce((i, m) => i + m.qty, 0)), s = C(
320
+ () => n().reduce((i, m) => i + m.product.price * m.qty, 0)
321
+ );
322
+ return { items: n, add: t, remove: a, setQty: o, clear: u, count: c, subtotal: s, has: (i) => n().some((m) => m.product.id === i) };
323
+ }
298
324
  export {
299
- ie as CartLine,
300
- de as CartSummary,
301
- me as FilterGroup,
302
- k as PriceTag,
303
- ue as ProductCard,
304
- ce as ProductGrid,
305
- P as QuantityStepper
325
+ se as CartLine,
326
+ me as CartSummary,
327
+ ge as FilterGroup,
328
+ T as PriceTag,
329
+ de as ProductCard,
330
+ oe as ProductGrid,
331
+ z as QuantityStepper,
332
+ fe as createCart
306
333
  };