@a4ui/core 0.17.0 → 0.19.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.
- package/dist/Checkbox-DIzLQltI.js +431 -0
- package/dist/commerce/createCart.d.ts +53 -0
- package/dist/commerce/index.d.ts +1 -0
- package/dist/commerce.js +154 -133
- package/dist/elements.css +137 -0
- package/dist/elements.iife.js +2 -2
- package/dist/elements.js +275 -251
- package/dist/full.css +137 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +3052 -2781
- package/dist/layout/ActionBar.d.ts +53 -0
- package/dist/layout/Section.d.ts +31 -0
- package/dist/ui/BeforeAfter.d.ts +34 -0
- package/dist/ui/Button.d.ts +10 -0
- package/dist/ui/PricingTable.d.ts +60 -0
- package/package.json +1 -1
- package/src/commerce/ProductCard.tsx +9 -1
- package/src/commerce/createCart.ts +102 -0
- package/src/commerce/index.ts +1 -0
- package/src/index.ts +5 -1
- package/src/layout/ActionBar.tsx +121 -0
- package/src/layout/Section.tsx +69 -0
- package/src/ui/BeforeAfter.tsx +162 -0
- package/src/ui/Button.tsx +51 -17
- package/src/ui/Carousel.tsx +12 -6
- package/src/ui/PricingTable.tsx +196 -0
- package/dist/Checkbox-DMx0y81E.js +0 -407
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
import { spread as v, mergeProps as y, insert as f, createComponent as p, template as m, effect as h, className as $, use as x, delegateEvents as k, setAttribute as C } from "solid-js/web";
|
|
2
|
+
import { splitProps as b, Show as S, createSignal as _, createEffect as K, untrack as F, onCleanup as E, onMount as L, For as B } from "solid-js";
|
|
3
|
+
import { c as g } from "./cn-B6yFEsav.js";
|
|
4
|
+
import { animate as R, inView as Q } from "motion";
|
|
5
|
+
import { Star as D } from "lucide-solid";
|
|
6
|
+
var q = /* @__PURE__ */ m('<span class="relative flex h-1.5 w-1.5"aria-hidden=true><span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-current opacity-75"></span><span class="relative inline-flex h-1.5 w-1.5 rounded-full bg-current">'), J = /* @__PURE__ */ m("<span>");
|
|
7
|
+
const W = {
|
|
8
|
+
neutral: "bg-muted text-muted-foreground ring-border",
|
|
9
|
+
success: "bg-emerald-500/15 text-emerald-600 ring-emerald-500/30",
|
|
10
|
+
warning: "bg-amber-500/15 text-amber-600 ring-amber-500/30",
|
|
11
|
+
danger: "bg-rose-500/15 text-rose-600 ring-rose-500/30",
|
|
12
|
+
info: "bg-sky-500/15 text-sky-600 ring-sky-500/30"
|
|
13
|
+
}, Z = "badge inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-semibold ring-1 ring-inset whitespace-nowrap";
|
|
14
|
+
function _e(t) {
|
|
15
|
+
const [e, n] = b(t, ["tone", "class", "children", "pulse"]);
|
|
16
|
+
return (() => {
|
|
17
|
+
var r = J();
|
|
18
|
+
return v(r, y({
|
|
19
|
+
get class() {
|
|
20
|
+
return g(Z, W[e.tone ?? "neutral"], e.class);
|
|
21
|
+
}
|
|
22
|
+
}, n), !1, !0), f(r, p(S, {
|
|
23
|
+
get when() {
|
|
24
|
+
return e.pulse;
|
|
25
|
+
},
|
|
26
|
+
get children() {
|
|
27
|
+
return q();
|
|
28
|
+
}
|
|
29
|
+
}), null), f(r, () => e.children, null), r;
|
|
30
|
+
})();
|
|
31
|
+
}
|
|
32
|
+
const I = "a4ui-effects";
|
|
33
|
+
function Y() {
|
|
34
|
+
try {
|
|
35
|
+
return window.localStorage;
|
|
36
|
+
} catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function ee() {
|
|
41
|
+
var e;
|
|
42
|
+
try {
|
|
43
|
+
if (new URLSearchParams(window.location.search).get("calm") === "1") return !1;
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
const t = (e = Y()) == null ? void 0 : e.getItem(I);
|
|
47
|
+
return t === null ? !0 : t === "1";
|
|
48
|
+
}
|
|
49
|
+
function N(t) {
|
|
50
|
+
typeof document > "u" || document.documentElement.classList.toggle("calm", !t);
|
|
51
|
+
}
|
|
52
|
+
const U = ee();
|
|
53
|
+
N(U);
|
|
54
|
+
const [z, te] = _(U);
|
|
55
|
+
function Ee() {
|
|
56
|
+
return z;
|
|
57
|
+
}
|
|
58
|
+
function re() {
|
|
59
|
+
return !z();
|
|
60
|
+
}
|
|
61
|
+
function Ce(t) {
|
|
62
|
+
var e;
|
|
63
|
+
(e = Y()) == null || e.setItem(I, t ? "1" : "0"), N(t), te(t);
|
|
64
|
+
}
|
|
65
|
+
const ne = "(prefers-reduced-motion: reduce)";
|
|
66
|
+
function ae() {
|
|
67
|
+
return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia(ne).matches;
|
|
68
|
+
}
|
|
69
|
+
const X = "a4ui-motion-forced";
|
|
70
|
+
function j() {
|
|
71
|
+
try {
|
|
72
|
+
return window.localStorage;
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
var P;
|
|
78
|
+
const [M, oe] = _(((P = j()) == null ? void 0 : P.getItem(X)) === "1");
|
|
79
|
+
typeof document < "u" && document.documentElement.classList.toggle("force-motion", F(M));
|
|
80
|
+
function ke() {
|
|
81
|
+
return M;
|
|
82
|
+
}
|
|
83
|
+
function Se(t) {
|
|
84
|
+
var e;
|
|
85
|
+
(e = j()) == null || e.setItem(X, t ? "1" : "0"), typeof document < "u" && document.documentElement.classList.toggle("force-motion", t), oe(t);
|
|
86
|
+
}
|
|
87
|
+
function w() {
|
|
88
|
+
return re() || ae() && !M();
|
|
89
|
+
}
|
|
90
|
+
function Le(t, e = 600) {
|
|
91
|
+
const [n, r] = _(0);
|
|
92
|
+
let o;
|
|
93
|
+
return K(() => {
|
|
94
|
+
const a = t();
|
|
95
|
+
if (o == null || o.stop(), w()) {
|
|
96
|
+
r(a);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const i = F(n);
|
|
100
|
+
i !== a && (o = R(i, a, {
|
|
101
|
+
duration: e / 1e3,
|
|
102
|
+
ease: "easeOut",
|
|
103
|
+
onUpdate: (u) => r(u)
|
|
104
|
+
}));
|
|
105
|
+
}), E(() => o == null ? void 0 : o.stop()), n;
|
|
106
|
+
}
|
|
107
|
+
function Re(t, e = {}) {
|
|
108
|
+
w() || R(
|
|
109
|
+
t,
|
|
110
|
+
{ opacity: [0, 1], y: [e.y ?? 8, 0] },
|
|
111
|
+
{ duration: e.duration ?? 0.32, delay: e.delay ?? 0, ease: "easeOut" }
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
function Me(t, e = {}) {
|
|
115
|
+
if (w()) return () => {
|
|
116
|
+
};
|
|
117
|
+
t.style.opacity = "0";
|
|
118
|
+
let n = !1;
|
|
119
|
+
return Q(
|
|
120
|
+
t,
|
|
121
|
+
() => {
|
|
122
|
+
n || (n = !0, R(
|
|
123
|
+
t,
|
|
124
|
+
{ opacity: [0, 1], y: [e.y ?? 16, 0] },
|
|
125
|
+
{ duration: e.duration ?? 0.5, ease: "easeOut" }
|
|
126
|
+
));
|
|
127
|
+
},
|
|
128
|
+
{ amount: e.amount ?? 0.2 }
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
var ie = /* @__PURE__ */ m("<span>");
|
|
132
|
+
function G(t, e, n = {}) {
|
|
133
|
+
if (w()) return;
|
|
134
|
+
const r = t.getBoundingClientRect(), o = e.clientX - r.left, a = e.clientY - r.top, i = 2 * Math.max(Math.hypot(o, a), Math.hypot(r.width - o, a), Math.hypot(o, r.height - a), Math.hypot(r.width - o, r.height - a)), u = document.createElement("span");
|
|
135
|
+
u.setAttribute("aria-hidden", "true"), Object.assign(u.style, {
|
|
136
|
+
position: "absolute",
|
|
137
|
+
left: `${o}px`,
|
|
138
|
+
top: `${a}px`,
|
|
139
|
+
width: `${i}px`,
|
|
140
|
+
height: `${i}px`,
|
|
141
|
+
borderRadius: "9999px",
|
|
142
|
+
background: n.color ?? "currentColor",
|
|
143
|
+
pointerEvents: "none",
|
|
144
|
+
transform: "translate(-50%,-50%) scale(0)"
|
|
145
|
+
}), t.appendChild(u);
|
|
146
|
+
const s = u.animate([{
|
|
147
|
+
transform: "translate(-50%,-50%) scale(0)",
|
|
148
|
+
opacity: String(n.opacity ?? 0.3)
|
|
149
|
+
}, {
|
|
150
|
+
transform: "translate(-50%,-50%) scale(1)",
|
|
151
|
+
opacity: "0"
|
|
152
|
+
}], {
|
|
153
|
+
duration: 600,
|
|
154
|
+
easing: "ease-out"
|
|
155
|
+
}), l = () => u.remove();
|
|
156
|
+
s.finished.then(l).catch(l);
|
|
157
|
+
}
|
|
158
|
+
function Ae(t) {
|
|
159
|
+
let e;
|
|
160
|
+
const n = (r) => {
|
|
161
|
+
e && G(e, r, {
|
|
162
|
+
color: t.color,
|
|
163
|
+
opacity: t.opacity
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
return (() => {
|
|
167
|
+
var r = ie();
|
|
168
|
+
r.$$pointerdown = n;
|
|
169
|
+
var o = e;
|
|
170
|
+
return typeof o == "function" ? x(o, r) : e = r, f(r, () => t.children), h(() => $(r, g("relative inline-block overflow-hidden", t.class))), r;
|
|
171
|
+
})();
|
|
172
|
+
}
|
|
173
|
+
k(["pointerdown"]);
|
|
174
|
+
var le = /* @__PURE__ */ m("<a>"), se = /* @__PURE__ */ m("<button>");
|
|
175
|
+
const ce = {
|
|
176
|
+
primary: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
177
|
+
secondary: "bg-muted text-foreground hover:bg-muted/70",
|
|
178
|
+
outline: "border border-border bg-transparent text-foreground hover:bg-muted",
|
|
179
|
+
ghost: "bg-transparent text-foreground hover:bg-muted"
|
|
180
|
+
}, ue = "inline-flex items-center justify-center rounded-md px-3 py-2 text-sm font-medium transition-[color,background-color,transform] duration-150 active:scale-[0.97] focus:outline-none focus:ring-2 focus:ring-ring disabled:pointer-events-none disabled:opacity-50";
|
|
181
|
+
function Oe(t) {
|
|
182
|
+
const [e, n] = b(t, ["variant", "class", "type", "children", "ripple", "onPointerDown", "href", "target", "rel"]), r = () => g(ue, ce[e.variant ?? "primary"], e.ripple && "relative overflow-hidden", e.class), o = (a) => {
|
|
183
|
+
e.ripple && G(a.currentTarget, a, {
|
|
184
|
+
opacity: 0.35
|
|
185
|
+
});
|
|
186
|
+
const i = e.onPointerDown;
|
|
187
|
+
typeof i == "function" ? i(a) : i && i[0](i[1], a);
|
|
188
|
+
};
|
|
189
|
+
return p(S, {
|
|
190
|
+
get when() {
|
|
191
|
+
return e.href !== void 0;
|
|
192
|
+
},
|
|
193
|
+
get fallback() {
|
|
194
|
+
return (() => {
|
|
195
|
+
var a = se();
|
|
196
|
+
return a.$$pointerdown = o, v(a, y({
|
|
197
|
+
get type() {
|
|
198
|
+
return e.type ?? "button";
|
|
199
|
+
},
|
|
200
|
+
get class() {
|
|
201
|
+
return r();
|
|
202
|
+
}
|
|
203
|
+
}, n), !1, !0), f(a, () => e.children), a;
|
|
204
|
+
})();
|
|
205
|
+
},
|
|
206
|
+
get children() {
|
|
207
|
+
var a = le();
|
|
208
|
+
return a.$$pointerdown = o, v(a, y({
|
|
209
|
+
get href() {
|
|
210
|
+
return e.href;
|
|
211
|
+
},
|
|
212
|
+
get target() {
|
|
213
|
+
return e.target;
|
|
214
|
+
},
|
|
215
|
+
get rel() {
|
|
216
|
+
return e.rel;
|
|
217
|
+
},
|
|
218
|
+
get class() {
|
|
219
|
+
return r();
|
|
220
|
+
}
|
|
221
|
+
}, n), !1, !0), f(a, () => e.children), a;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
k(["pointerdown"]);
|
|
226
|
+
var de = /* @__PURE__ */ m("<div>");
|
|
227
|
+
function V(t, e = {}) {
|
|
228
|
+
if (w()) return () => {
|
|
229
|
+
};
|
|
230
|
+
const n = document.createElement("span");
|
|
231
|
+
n.setAttribute("aria-hidden", "true"), n.className = "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300", t.appendChild(n);
|
|
232
|
+
const r = e.size ?? 180, o = e.color ?? "hsl(var(--primary))", a = (l, c) => {
|
|
233
|
+
n.style.background = `radial-gradient(${r}px circle at ${l}px ${c}px, color-mix(in srgb, ${o} 30%, transparent), transparent 70%)`;
|
|
234
|
+
}, i = (l) => {
|
|
235
|
+
const c = t.getBoundingClientRect();
|
|
236
|
+
a(l.clientX - c.left, l.clientY - c.top);
|
|
237
|
+
}, u = () => {
|
|
238
|
+
n.style.opacity = "1";
|
|
239
|
+
}, s = () => {
|
|
240
|
+
n.style.opacity = "0";
|
|
241
|
+
};
|
|
242
|
+
return t.addEventListener("pointermove", i), t.addEventListener("pointerenter", u), t.addEventListener("pointerleave", s), () => {
|
|
243
|
+
t.removeEventListener("pointermove", i), t.removeEventListener("pointerenter", u), t.removeEventListener("pointerleave", s), n.remove();
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
function Te(t) {
|
|
247
|
+
let e;
|
|
248
|
+
return L(() => {
|
|
249
|
+
const n = V(e, {
|
|
250
|
+
color: t.color,
|
|
251
|
+
size: t.size
|
|
252
|
+
});
|
|
253
|
+
E(n);
|
|
254
|
+
}), (() => {
|
|
255
|
+
var n = de(), r = e;
|
|
256
|
+
return typeof r == "function" ? x(r, n) : e = n, f(n, () => t.children), h(() => $(n, g("relative overflow-hidden", t.class))), n;
|
|
257
|
+
})();
|
|
258
|
+
}
|
|
259
|
+
var fe = /* @__PURE__ */ m("<div style=perspective:800px><div style=transform-style:preserve-3d>");
|
|
260
|
+
function H(t, e, n = {}) {
|
|
261
|
+
if (w()) return () => {
|
|
262
|
+
};
|
|
263
|
+
e.style.willChange = "transform";
|
|
264
|
+
const r = (a) => {
|
|
265
|
+
const i = t.getBoundingClientRect(), u = (a.clientX - i.left) / i.width - 0.5, s = (a.clientY - i.top) / i.height - 0.5, l = n.max ?? 10;
|
|
266
|
+
e.style.transition = "transform 0.15s ease-out", e.style.transform = `perspective(800px) rotateX(${(s * -2 * l).toFixed(2)}deg) rotateY(${(u * 2 * l).toFixed(2)}deg) scale(1.02)`;
|
|
267
|
+
}, o = () => {
|
|
268
|
+
e.style.transition = "transform 0.4s ease", e.style.transform = "perspective(800px) rotateX(0deg) rotateY(0deg) scale(1)";
|
|
269
|
+
};
|
|
270
|
+
return t.addEventListener("pointermove", r), t.addEventListener("pointerleave", o), () => {
|
|
271
|
+
t.removeEventListener("pointermove", r), t.removeEventListener("pointerleave", o), e.style.transform = "", e.style.transition = "", e.style.willChange = "";
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
function Be(t) {
|
|
275
|
+
let e, n;
|
|
276
|
+
return L(() => {
|
|
277
|
+
const r = H(e, n, {
|
|
278
|
+
max: t.max
|
|
279
|
+
});
|
|
280
|
+
E(r);
|
|
281
|
+
}), (() => {
|
|
282
|
+
var r = fe(), o = r.firstChild, a = e;
|
|
283
|
+
typeof a == "function" ? x(a, r) : e = r;
|
|
284
|
+
var i = n;
|
|
285
|
+
return typeof i == "function" ? x(i, o) : n = o, f(o, () => t.children), h(() => $(r, g("inline-block", t.class))), r;
|
|
286
|
+
})();
|
|
287
|
+
}
|
|
288
|
+
var A = /* @__PURE__ */ m("<div>"), ge = /* @__PURE__ */ m("<h2>");
|
|
289
|
+
function De(t) {
|
|
290
|
+
const [e, n] = b(t, ["class", "children", "glass", "glow", "tilt", "spotlight"]), r = () => (e.glow ?? e.glass) === !0;
|
|
291
|
+
let o;
|
|
292
|
+
return L(() => {
|
|
293
|
+
const a = [e.tilt && o ? H(o, o) : null, e.spotlight && o ? V(o) : null].filter((i) => i !== null);
|
|
294
|
+
E(() => a.forEach((i) => i()));
|
|
295
|
+
}), (() => {
|
|
296
|
+
var a = A(), i = o;
|
|
297
|
+
return typeof i == "function" ? x(i, a) : o = a, v(a, y({
|
|
298
|
+
get class() {
|
|
299
|
+
return g(e.glass ? "card rounded-xl text-card-foreground" : "rounded-xl border border-border bg-card text-card-foreground shadow-sm", r() && "glow-edge", e.spotlight && "relative overflow-hidden", e.tilt && "will-change-transform", e.class);
|
|
300
|
+
}
|
|
301
|
+
}, n), !1, !0), f(a, () => e.children), a;
|
|
302
|
+
})();
|
|
303
|
+
}
|
|
304
|
+
function Pe(t) {
|
|
305
|
+
const [e, n] = b(t, ["class", "children"]);
|
|
306
|
+
return (() => {
|
|
307
|
+
var r = A();
|
|
308
|
+
return v(r, y({
|
|
309
|
+
get class() {
|
|
310
|
+
return g("flex flex-col space-y-1.5 p-6", e.class);
|
|
311
|
+
}
|
|
312
|
+
}, n), !1, !0), f(r, () => e.children), r;
|
|
313
|
+
})();
|
|
314
|
+
}
|
|
315
|
+
function Fe(t) {
|
|
316
|
+
const [e, n] = b(t, ["class", "children"]);
|
|
317
|
+
return (() => {
|
|
318
|
+
var r = ge();
|
|
319
|
+
return v(r, y({
|
|
320
|
+
get class() {
|
|
321
|
+
return g("text-lg font-semibold leading-none tracking-tight", e.class);
|
|
322
|
+
}
|
|
323
|
+
}, n), !1, !0), f(r, () => e.children), r;
|
|
324
|
+
})();
|
|
325
|
+
}
|
|
326
|
+
function Ie(t) {
|
|
327
|
+
const [e, n] = b(t, ["class", "children"]);
|
|
328
|
+
return (() => {
|
|
329
|
+
var r = A();
|
|
330
|
+
return v(r, y({
|
|
331
|
+
get class() {
|
|
332
|
+
return g("p-6 pt-0", e.class);
|
|
333
|
+
}
|
|
334
|
+
}, n), !1, !0), f(r, () => e.children), r;
|
|
335
|
+
})();
|
|
336
|
+
}
|
|
337
|
+
var me = /* @__PURE__ */ m("<div role=radiogroup>"), he = /* @__PURE__ */ m("<div role=img>"), pe = /* @__PURE__ */ m('<button type=button role=radio class="rounded outline-none focus-visible:ring-2 focus-visible:ring-ring/40">');
|
|
338
|
+
function Ye(t) {
|
|
339
|
+
const [e, n] = _(0), r = () => t.max ?? 5, o = () => Array.from({
|
|
340
|
+
length: r()
|
|
341
|
+
}, (s, l) => l + 1), a = () => e() > 0 ? e() : t.value, i = (s) => {
|
|
342
|
+
var l;
|
|
343
|
+
t.readonly || (l = t.onChange) == null || l.call(t, s);
|
|
344
|
+
}, u = (s) => g("h-5 w-5 transition-colors", s <= a() ? "fill-primary text-primary" : "fill-transparent text-muted-foreground");
|
|
345
|
+
return p(S, {
|
|
346
|
+
get when() {
|
|
347
|
+
return !t.readonly;
|
|
348
|
+
},
|
|
349
|
+
get fallback() {
|
|
350
|
+
return (() => {
|
|
351
|
+
var s = he();
|
|
352
|
+
return f(s, p(B, {
|
|
353
|
+
get each() {
|
|
354
|
+
return o();
|
|
355
|
+
},
|
|
356
|
+
children: (l) => p(D, {
|
|
357
|
+
get class() {
|
|
358
|
+
return u(l);
|
|
359
|
+
},
|
|
360
|
+
"aria-hidden": "true"
|
|
361
|
+
})
|
|
362
|
+
})), h((l) => {
|
|
363
|
+
var c = g("inline-flex items-center gap-1", t.class), d = `Rating ${t.value} of ${r()}`;
|
|
364
|
+
return c !== l.e && $(s, l.e = c), d !== l.t && C(s, "aria-label", l.t = d), l;
|
|
365
|
+
}, {
|
|
366
|
+
e: void 0,
|
|
367
|
+
t: void 0
|
|
368
|
+
}), s;
|
|
369
|
+
})();
|
|
370
|
+
},
|
|
371
|
+
get children() {
|
|
372
|
+
var s = me();
|
|
373
|
+
return s.addEventListener("mouseleave", () => n(0)), f(s, p(B, {
|
|
374
|
+
get each() {
|
|
375
|
+
return o();
|
|
376
|
+
},
|
|
377
|
+
children: (l) => (() => {
|
|
378
|
+
var c = pe();
|
|
379
|
+
return c.$$keydown = (d) => {
|
|
380
|
+
d.key === "ArrowRight" || d.key === "ArrowUp" ? (d.preventDefault(), i(Math.min(t.value + 1, r()))) : (d.key === "ArrowLeft" || d.key === "ArrowDown") && (d.preventDefault(), i(Math.max(t.value - 1, 0)));
|
|
381
|
+
}, c.$$click = () => i(l), c.addEventListener("blur", () => n(0)), c.addEventListener("focus", () => n(l)), c.addEventListener("mouseenter", () => n(l)), f(c, p(D, {
|
|
382
|
+
get class() {
|
|
383
|
+
return u(l);
|
|
384
|
+
},
|
|
385
|
+
"aria-hidden": "true"
|
|
386
|
+
})), h((d) => {
|
|
387
|
+
var O = t.value === l, T = `Rate ${l} of ${r()}`;
|
|
388
|
+
return O !== d.e && C(c, "aria-checked", d.e = O), T !== d.t && C(c, "aria-label", d.t = T), d;
|
|
389
|
+
}, {
|
|
390
|
+
e: void 0,
|
|
391
|
+
t: void 0
|
|
392
|
+
}), c;
|
|
393
|
+
})()
|
|
394
|
+
})), h(() => $(s, g("inline-flex items-center gap-1", t.class))), s;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
k(["click", "keydown"]);
|
|
399
|
+
var ve = /* @__PURE__ */ m('<label><input type=checkbox class="h-4 w-4 rounded border-input accent-primary">');
|
|
400
|
+
function Ne(t) {
|
|
401
|
+
return (() => {
|
|
402
|
+
var e = ve(), n = e.firstChild;
|
|
403
|
+
return n.addEventListener("change", (r) => t.onChange(r.currentTarget.checked)), f(e, () => t.label, null), h(() => $(e, g("inline-flex items-center gap-2 text-sm text-foreground", t.class))), h(() => n.checked = t.checked), e;
|
|
404
|
+
})();
|
|
405
|
+
}
|
|
406
|
+
export {
|
|
407
|
+
_e as B,
|
|
408
|
+
De as C,
|
|
409
|
+
Ye as R,
|
|
410
|
+
Te as S,
|
|
411
|
+
Be as T,
|
|
412
|
+
Oe as a,
|
|
413
|
+
Ne as b,
|
|
414
|
+
Le as c,
|
|
415
|
+
Ie as d,
|
|
416
|
+
Re as e,
|
|
417
|
+
Pe as f,
|
|
418
|
+
Fe as g,
|
|
419
|
+
Ce as h,
|
|
420
|
+
Ae as i,
|
|
421
|
+
V as j,
|
|
422
|
+
H as k,
|
|
423
|
+
re as l,
|
|
424
|
+
w as m,
|
|
425
|
+
Se as n,
|
|
426
|
+
ke as o,
|
|
427
|
+
ae as p,
|
|
428
|
+
Me as r,
|
|
429
|
+
G as s,
|
|
430
|
+
Ee as u
|
|
431
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Accessor } from 'solid-js';
|
|
2
|
+
export interface CartProduct {
|
|
3
|
+
id: string | number;
|
|
4
|
+
price: number;
|
|
5
|
+
}
|
|
6
|
+
export interface CartEntry<T extends CartProduct> {
|
|
7
|
+
product: T;
|
|
8
|
+
qty: number;
|
|
9
|
+
}
|
|
10
|
+
export interface Cart<T extends CartProduct> {
|
|
11
|
+
/** Reactive list of cart entries. */
|
|
12
|
+
items: Accessor<CartEntry<T>[]>;
|
|
13
|
+
/** Add a product, or increment its `qty` if it's already in the cart. */
|
|
14
|
+
add: (product: T, qty?: number) => void;
|
|
15
|
+
/** Remove a product from the cart by id. */
|
|
16
|
+
remove: (id: T['id']) => void;
|
|
17
|
+
/** Set a product's quantity. `qty <= 0` removes the entry. */
|
|
18
|
+
setQty: (id: T['id'], qty: number) => void;
|
|
19
|
+
/** Empty the cart. */
|
|
20
|
+
clear: () => void;
|
|
21
|
+
/** Total number of units across all entries. */
|
|
22
|
+
count: () => number;
|
|
23
|
+
/** Sum of `price * qty` across all entries. */
|
|
24
|
+
subtotal: () => number;
|
|
25
|
+
/** Whether a product with this id is currently in the cart. */
|
|
26
|
+
has: (id: T['id']) => boolean;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Create a signal-backed shopping cart store, generic over the product type.
|
|
30
|
+
* `count()` and `subtotal()` are memoized and stay in sync with `items()`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* interface Product extends CartProduct {
|
|
35
|
+
* id: string
|
|
36
|
+
* price: number
|
|
37
|
+
* title: string
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* const cart = createCart<Product>()
|
|
41
|
+
*
|
|
42
|
+
* cart.add({ id: 'sku-1', price: 29.99, title: 'Wireless Mouse' })
|
|
43
|
+
* cart.add({ id: 'sku-1', price: 29.99, title: 'Wireless Mouse' }) // qty -> 2
|
|
44
|
+
* cart.setQty('sku-1', 3)
|
|
45
|
+
*
|
|
46
|
+
* cart.count() // 3
|
|
47
|
+
* cart.subtotal() // 89.97
|
|
48
|
+
*
|
|
49
|
+
* cart.remove('sku-1')
|
|
50
|
+
* cart.has('sku-1') // false
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function createCart<T extends CartProduct>(initial?: CartEntry<T>[]): Cart<T>;
|
package/dist/commerce/index.d.ts
CHANGED
|
@@ -5,3 +5,4 @@ export { ProductGrid, type ProductGridProps } from './ProductGrid';
|
|
|
5
5
|
export { CartLine, type CartLineProps } from './CartLine';
|
|
6
6
|
export { CartSummary, type CartSummaryProps, type CartSummaryItem } from './CartSummary';
|
|
7
7
|
export { FilterGroup, type FilterGroupProps, type FacetOption } from './FilterGroup';
|
|
8
|
+
export { createCart, type Cart, type CartProduct, type CartEntry } from './createCart';
|