@a4ui/core 0.18.0 → 0.20.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.
@@ -1,407 +0,0 @@
1
- import { spread as y, mergeProps as b, insert as f, createComponent as p, template as g, effect as h, className as v, use as $, delegateEvents as k, setAttribute as C } from "solid-js/web";
2
- import { splitProps as x, Show as P, createSignal as _, createEffect as K, untrack as F, onCleanup as E, onMount as S, For as T } from "solid-js";
3
- import { c as m } from "./cn-B6yFEsav.js";
4
- import { animate as L, inView as Q } from "motion";
5
- import { Star as B } from "lucide-solid";
6
- var q = /* @__PURE__ */ g('<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__ */ g("<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, r] = x(t, ["tone", "class", "children", "pulse"]);
16
- return (() => {
17
- var n = J();
18
- return y(n, b({
19
- get class() {
20
- return m(Z, W[e.tone ?? "neutral"], e.class);
21
- }
22
- }, r), !1, !0), f(n, p(P, {
23
- get when() {
24
- return e.pulse;
25
- },
26
- get children() {
27
- return q();
28
- }
29
- }), null), f(n, () => e.children, null), n;
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 _e() {
56
- return z;
57
- }
58
- function ne() {
59
- return !z();
60
- }
61
- function Ee(t) {
62
- var e;
63
- (e = Y()) == null || e.setItem(I, t ? "1" : "0"), N(t), te(t);
64
- }
65
- const re = "(prefers-reduced-motion: reduce)";
66
- function oe() {
67
- return typeof window > "u" || typeof window.matchMedia != "function" ? !1 : window.matchMedia(re).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 D;
78
- const [R, ae] = _(((D = j()) == null ? void 0 : D.getItem(X)) === "1");
79
- typeof document < "u" && document.documentElement.classList.toggle("force-motion", F(R));
80
- function Ce() {
81
- return R;
82
- }
83
- function ke(t) {
84
- var e;
85
- (e = j()) == null || e.setItem(X, t ? "1" : "0"), typeof document < "u" && document.documentElement.classList.toggle("force-motion", t), ae(t);
86
- }
87
- function w() {
88
- return ne() || oe() && !R();
89
- }
90
- function Se(t, e = 600) {
91
- const [r, n] = _(0);
92
- let o;
93
- return K(() => {
94
- const a = t();
95
- if (o == null || o.stop(), w()) {
96
- n(a);
97
- return;
98
- }
99
- const l = F(r);
100
- l !== a && (o = L(l, a, {
101
- duration: e / 1e3,
102
- ease: "easeOut",
103
- onUpdate: (u) => n(u)
104
- }));
105
- }), E(() => o == null ? void 0 : o.stop()), r;
106
- }
107
- function Le(t, e = {}) {
108
- w() || L(
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 Re(t, e = {}) {
115
- if (w()) return () => {
116
- };
117
- t.style.opacity = "0";
118
- let r = !1;
119
- return Q(
120
- t,
121
- () => {
122
- r || (r = !0, L(
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__ */ g("<span>");
132
- function G(t, e, r = {}) {
133
- if (w()) return;
134
- const n = t.getBoundingClientRect(), o = e.clientX - n.left, a = e.clientY - n.top, l = 2 * Math.max(Math.hypot(o, a), Math.hypot(n.width - o, a), Math.hypot(o, n.height - a), Math.hypot(n.width - o, n.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: `${l}px`,
140
- height: `${l}px`,
141
- borderRadius: "9999px",
142
- background: r.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(r.opacity ?? 0.3)
149
- }, {
150
- transform: "translate(-50%,-50%) scale(1)",
151
- opacity: "0"
152
- }], {
153
- duration: 600,
154
- easing: "ease-out"
155
- }), i = () => u.remove();
156
- s.finished.then(i).catch(i);
157
- }
158
- function Me(t) {
159
- let e;
160
- const r = (n) => {
161
- e && G(e, n, {
162
- color: t.color,
163
- opacity: t.opacity
164
- });
165
- };
166
- return (() => {
167
- var n = ie();
168
- n.$$pointerdown = r;
169
- var o = e;
170
- return typeof o == "function" ? $(o, n) : e = n, f(n, () => t.children), h(() => v(n, m("relative inline-block overflow-hidden", t.class))), n;
171
- })();
172
- }
173
- k(["pointerdown"]);
174
- var le = /* @__PURE__ */ g("<button>");
175
- const se = {
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
- }, ce = "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 Ae(t) {
182
- const [e, r] = x(t, ["variant", "class", "type", "children", "ripple", "onPointerDown"]), n = (o) => {
183
- e.ripple && G(o.currentTarget, o, {
184
- opacity: 0.35
185
- });
186
- const a = e.onPointerDown;
187
- typeof a == "function" ? a(o) : a && a[0](a[1], o);
188
- };
189
- return (() => {
190
- var o = le();
191
- return o.$$pointerdown = n, y(o, b({
192
- get type() {
193
- return e.type ?? "button";
194
- },
195
- get class() {
196
- return m(ce, se[e.variant ?? "primary"], e.ripple && "relative overflow-hidden", e.class);
197
- }
198
- }, r), !1, !0), f(o, () => e.children), o;
199
- })();
200
- }
201
- k(["pointerdown"]);
202
- var ue = /* @__PURE__ */ g("<div>");
203
- function V(t, e = {}) {
204
- if (w()) return () => {
205
- };
206
- const r = document.createElement("span");
207
- r.setAttribute("aria-hidden", "true"), r.className = "pointer-events-none absolute inset-0 opacity-0 transition-opacity duration-300", t.appendChild(r);
208
- const n = e.size ?? 180, o = e.color ?? "hsl(var(--primary))", a = (i, c) => {
209
- r.style.background = `radial-gradient(${n}px circle at ${i}px ${c}px, color-mix(in srgb, ${o} 30%, transparent), transparent 70%)`;
210
- }, l = (i) => {
211
- const c = t.getBoundingClientRect();
212
- a(i.clientX - c.left, i.clientY - c.top);
213
- }, u = () => {
214
- r.style.opacity = "1";
215
- }, s = () => {
216
- r.style.opacity = "0";
217
- };
218
- return t.addEventListener("pointermove", l), t.addEventListener("pointerenter", u), t.addEventListener("pointerleave", s), () => {
219
- t.removeEventListener("pointermove", l), t.removeEventListener("pointerenter", u), t.removeEventListener("pointerleave", s), r.remove();
220
- };
221
- }
222
- function Oe(t) {
223
- let e;
224
- return S(() => {
225
- const r = V(e, {
226
- color: t.color,
227
- size: t.size
228
- });
229
- E(r);
230
- }), (() => {
231
- var r = ue(), n = e;
232
- return typeof n == "function" ? $(n, r) : e = r, f(r, () => t.children), h(() => v(r, m("relative overflow-hidden", t.class))), r;
233
- })();
234
- }
235
- var de = /* @__PURE__ */ g("<div style=perspective:800px><div style=transform-style:preserve-3d>");
236
- function H(t, e, r = {}) {
237
- if (w()) return () => {
238
- };
239
- e.style.willChange = "transform";
240
- const n = (a) => {
241
- const l = t.getBoundingClientRect(), u = (a.clientX - l.left) / l.width - 0.5, s = (a.clientY - l.top) / l.height - 0.5, i = r.max ?? 10;
242
- e.style.transition = "transform 0.15s ease-out", e.style.transform = `perspective(800px) rotateX(${(s * -2 * i).toFixed(2)}deg) rotateY(${(u * 2 * i).toFixed(2)}deg) scale(1.02)`;
243
- }, o = () => {
244
- e.style.transition = "transform 0.4s ease", e.style.transform = "perspective(800px) rotateX(0deg) rotateY(0deg) scale(1)";
245
- };
246
- return t.addEventListener("pointermove", n), t.addEventListener("pointerleave", o), () => {
247
- t.removeEventListener("pointermove", n), t.removeEventListener("pointerleave", o), e.style.transform = "", e.style.transition = "", e.style.willChange = "";
248
- };
249
- }
250
- function Te(t) {
251
- let e, r;
252
- return S(() => {
253
- const n = H(e, r, {
254
- max: t.max
255
- });
256
- E(n);
257
- }), (() => {
258
- var n = de(), o = n.firstChild, a = e;
259
- typeof a == "function" ? $(a, n) : e = n;
260
- var l = r;
261
- return typeof l == "function" ? $(l, o) : r = o, f(o, () => t.children), h(() => v(n, m("inline-block", t.class))), n;
262
- })();
263
- }
264
- var M = /* @__PURE__ */ g("<div>"), fe = /* @__PURE__ */ g("<h2>");
265
- function Be(t) {
266
- const [e, r] = x(t, ["class", "children", "glass", "glow", "tilt", "spotlight"]), n = () => (e.glow ?? e.glass) === !0;
267
- let o;
268
- return S(() => {
269
- const a = [e.tilt && o ? H(o, o) : null, e.spotlight && o ? V(o) : null].filter((l) => l !== null);
270
- E(() => a.forEach((l) => l()));
271
- }), (() => {
272
- var a = M(), l = o;
273
- return typeof l == "function" ? $(l, a) : o = a, y(a, b({
274
- get class() {
275
- return m(e.glass ? "card rounded-xl text-card-foreground" : "rounded-xl border border-border bg-card text-card-foreground shadow-sm", n() && "glow-edge", e.spotlight && "relative overflow-hidden", e.tilt && "will-change-transform", e.class);
276
- }
277
- }, r), !1, !0), f(a, () => e.children), a;
278
- })();
279
- }
280
- function De(t) {
281
- const [e, r] = x(t, ["class", "children"]);
282
- return (() => {
283
- var n = M();
284
- return y(n, b({
285
- get class() {
286
- return m("flex flex-col space-y-1.5 p-6", e.class);
287
- }
288
- }, r), !1, !0), f(n, () => e.children), n;
289
- })();
290
- }
291
- function Pe(t) {
292
- const [e, r] = x(t, ["class", "children"]);
293
- return (() => {
294
- var n = fe();
295
- return y(n, b({
296
- get class() {
297
- return m("text-lg font-semibold leading-none tracking-tight", e.class);
298
- }
299
- }, r), !1, !0), f(n, () => e.children), n;
300
- })();
301
- }
302
- function Fe(t) {
303
- const [e, r] = x(t, ["class", "children"]);
304
- return (() => {
305
- var n = M();
306
- return y(n, b({
307
- get class() {
308
- return m("p-6 pt-0", e.class);
309
- }
310
- }, r), !1, !0), f(n, () => e.children), n;
311
- })();
312
- }
313
- var me = /* @__PURE__ */ g("<div role=radiogroup>"), ge = /* @__PURE__ */ g("<div role=img>"), he = /* @__PURE__ */ g('<button type=button role=radio class="rounded outline-none focus-visible:ring-2 focus-visible:ring-ring/40">');
314
- function Ie(t) {
315
- const [e, r] = _(0), n = () => t.max ?? 5, o = () => Array.from({
316
- length: n()
317
- }, (s, i) => i + 1), a = () => e() > 0 ? e() : t.value, l = (s) => {
318
- var i;
319
- t.readonly || (i = t.onChange) == null || i.call(t, s);
320
- }, u = (s) => m("h-5 w-5 transition-colors", s <= a() ? "fill-primary text-primary" : "fill-transparent text-muted-foreground");
321
- return p(P, {
322
- get when() {
323
- return !t.readonly;
324
- },
325
- get fallback() {
326
- return (() => {
327
- var s = ge();
328
- return f(s, p(T, {
329
- get each() {
330
- return o();
331
- },
332
- children: (i) => p(B, {
333
- get class() {
334
- return u(i);
335
- },
336
- "aria-hidden": "true"
337
- })
338
- })), h((i) => {
339
- var c = m("inline-flex items-center gap-1", t.class), d = `Rating ${t.value} of ${n()}`;
340
- return c !== i.e && v(s, i.e = c), d !== i.t && C(s, "aria-label", i.t = d), i;
341
- }, {
342
- e: void 0,
343
- t: void 0
344
- }), s;
345
- })();
346
- },
347
- get children() {
348
- var s = me();
349
- return s.addEventListener("mouseleave", () => r(0)), f(s, p(T, {
350
- get each() {
351
- return o();
352
- },
353
- children: (i) => (() => {
354
- var c = he();
355
- return c.$$keydown = (d) => {
356
- d.key === "ArrowRight" || d.key === "ArrowUp" ? (d.preventDefault(), l(Math.min(t.value + 1, n()))) : (d.key === "ArrowLeft" || d.key === "ArrowDown") && (d.preventDefault(), l(Math.max(t.value - 1, 0)));
357
- }, c.$$click = () => l(i), c.addEventListener("blur", () => r(0)), c.addEventListener("focus", () => r(i)), c.addEventListener("mouseenter", () => r(i)), f(c, p(B, {
358
- get class() {
359
- return u(i);
360
- },
361
- "aria-hidden": "true"
362
- })), h((d) => {
363
- var A = t.value === i, O = `Rate ${i} of ${n()}`;
364
- return A !== d.e && C(c, "aria-checked", d.e = A), O !== d.t && C(c, "aria-label", d.t = O), d;
365
- }, {
366
- e: void 0,
367
- t: void 0
368
- }), c;
369
- })()
370
- })), h(() => v(s, m("inline-flex items-center gap-1", t.class))), s;
371
- }
372
- });
373
- }
374
- k(["click", "keydown"]);
375
- var pe = /* @__PURE__ */ g('<label><input type=checkbox class="h-4 w-4 rounded border-input accent-primary">');
376
- function Ye(t) {
377
- return (() => {
378
- var e = pe(), r = e.firstChild;
379
- return r.addEventListener("change", (n) => t.onChange(n.currentTarget.checked)), f(e, () => t.label, null), h(() => v(e, m("inline-flex items-center gap-2 text-sm text-foreground", t.class))), h(() => r.checked = t.checked), e;
380
- })();
381
- }
382
- export {
383
- $e as B,
384
- Be as C,
385
- Ie as R,
386
- Oe as S,
387
- Te as T,
388
- Ae as a,
389
- Ye as b,
390
- Se as c,
391
- Fe as d,
392
- Le as e,
393
- De as f,
394
- Pe as g,
395
- Ee as h,
396
- Me as i,
397
- V as j,
398
- H as k,
399
- ne as l,
400
- w as m,
401
- ke as n,
402
- Ce as o,
403
- oe as p,
404
- Re as r,
405
- G as s,
406
- _e as u
407
- };