asta-ui 0.9.6 → 0.9.7

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/css/asta.js CHANGED
@@ -439,7 +439,7 @@
439
439
  else boot();
440
440
  document.addEventListener("htmx:afterSettle", (e) => scan(e.detail?.elt?.parentElement || document));
441
441
 
442
- window.asta = { toast, open: (id) => open(byId(id)), close: (id) => close(byId(id)), version: "0.9.6" };
442
+ window.asta = { toast, open: (id) => open(byId(id)), close: (id) => close(byId(id)), version: "0.9.7" };
443
443
  })();
444
444
 
445
445
  /* ---- runtime/agent.js ---- */
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  Navbar,
4
4
  navbar_default
5
- } from "../chunk-2EBWWZPS.js";
5
+ } from "../chunk-DWPGFNNF.js";
6
6
  import "../chunk-WSL4JGEA.js";
7
7
  export {
8
8
  Navbar,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  Sidebar,
4
4
  sidebar_default
5
- } from "../chunk-MVE7RJJ6.js";
5
+ } from "../chunk-SUWA7DM6.js";
6
6
  import "../chunk-IVCHYE55.js";
7
7
  export {
8
8
  Sidebar,
package/dist/base.js CHANGED
@@ -35,7 +35,7 @@ import {
35
35
  } from "./chunk-TXC6CCSA.js";
36
36
  import {
37
37
  Navbar
38
- } from "./chunk-2EBWWZPS.js";
38
+ } from "./chunk-DWPGFNNF.js";
39
39
  import {
40
40
  CookieConsent,
41
41
  DEFAULT_CONSENT_CATEGORIES
@@ -60,7 +60,7 @@ import {
60
60
  } from "./chunk-NPVUFQGC.js";
61
61
  import {
62
62
  Sidebar
63
- } from "./chunk-MVE7RJJ6.js";
63
+ } from "./chunk-SUWA7DM6.js";
64
64
  import {
65
65
  Kanban
66
66
  } from "./chunk-DPLH3EGO.js";
@@ -63,7 +63,26 @@ function Tile({ tile, big }) {
63
63
  }
64
64
  );
65
65
  }
66
+ function List({ links }) {
67
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5 p-1.5", children: links.map((l) => /* @__PURE__ */ jsxs(
68
+ "a",
69
+ {
70
+ href: l.href,
71
+ "data-kit-nav-link": true,
72
+ className: "group/item flex items-start gap-3 rounded-lg px-2.5 py-2 outline-none transition-colors duration-150 hover:bg-paper-2 focus-visible:bg-paper-2",
73
+ children: [
74
+ l.icon && /* @__PURE__ */ jsx("span", { className: cx("mt-px flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-paper text-mute transition-colors duration-150 group-hover/item:text-ink [&_svg]:h-3.5 [&_svg]:w-3.5", RING), children: l.icon }),
75
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
76
+ /* @__PURE__ */ jsx("span", { className: "text-[13.5px] font-medium text-ink", children: l.title }),
77
+ l.description && /* @__PURE__ */ jsx("span", { className: "text-[12px] leading-snug text-mute", children: l.description })
78
+ ] })
79
+ ]
80
+ },
81
+ l.title
82
+ )) });
83
+ }
66
84
  function Panel({ menu }) {
85
+ if (menu.list) return /* @__PURE__ */ jsx(List, { links: menu.list });
67
86
  const tiles = menu.tiles ?? [];
68
87
  const big = tiles.some((t) => t.preview);
69
88
  return /* @__PURE__ */ jsxs("div", { className: "group/menu flex flex-col gap-2 p-2", children: [
@@ -109,13 +128,14 @@ function Panel({ menu }) {
109
128
  ] })
110
129
  ] });
111
130
  }
112
- var flat = (m) => [...m.tiles ?? [], ...m.columns?.flatMap((c) => c.links) ?? []];
131
+ var flat = (m) => [...m.list ?? [], ...m.tiles ?? [], ...m.columns?.flatMap((c) => c.links) ?? []];
113
132
  function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, className }) {
114
133
  const [open, setOpen] = useState(null);
115
134
  const [dir, setDir] = useState(1);
116
135
  const [last, setLast] = useState(null);
117
136
  const [slide, setSlide] = useState(false);
118
137
  const [size, setSize] = useState({ w: 0, h: 0 });
138
+ const [anchor, setAnchor] = useState({ left: 0, bar: 0 });
119
139
  const [scrolled, setScrolled] = useState(false);
120
140
  const [sheet, setSheet] = useState(false);
121
141
  const [section, setSection] = useState(null);
@@ -135,17 +155,22 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
135
155
  const moving = i !== null && cur !== null && i !== cur;
136
156
  if (moving) setDir(i > cur ? 1 : -1);
137
157
  setSlide(moving);
138
- if (i !== null) setLast(i);
158
+ if (i !== null) {
159
+ setLast(i);
160
+ const t = triggers.current[i];
161
+ const bar = t?.closest("[data-kit-nav-bar]");
162
+ if (t && bar) setAnchor({ left: t.getBoundingClientRect().left - bar.getBoundingClientRect().left, bar: bar.offsetWidth });
163
+ }
139
164
  setOpen(i);
140
165
  }, []);
141
166
  const enter = (i) => {
142
167
  clearTimeout(timer.current);
143
- if (openRef.current === null) timer.current = setTimeout(() => show(i), 110);
168
+ if (openRef.current === null) timer.current = setTimeout(() => show(i), 80);
144
169
  else show(i);
145
170
  };
146
171
  const leave = () => {
147
172
  clearTimeout(timer.current);
148
- timer.current = setTimeout(() => show(null), 180);
173
+ timer.current = setTimeout(() => show(null), 150);
149
174
  };
150
175
  const stay = () => clearTimeout(timer.current);
151
176
  useLayoutEffect(() => {
@@ -194,6 +219,7 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
194
219
  }, [show]);
195
220
  useEffect(() => () => clearTimeout(timer.current), []);
196
221
  const menu = shown !== null ? items[shown]?.menu : void 0;
222
+ const panelX = menu?.list ? Math.max(12, Math.min(anchor.left - 6, anchor.bar - size.w - 12)) : (anchor.bar - size.w) / 2;
197
223
  const trigger = "flex h-8 items-center gap-1 rounded-md px-2.5 text-[13.5px] font-medium text-ink-2 outline-none transition-colors duration-200 hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50 aria-expanded:bg-paper-2 aria-expanded:text-ink";
198
224
  return /* @__PURE__ */ jsxs(
199
225
  "header",
@@ -206,11 +232,11 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
206
232
  ),
207
233
  children: [
208
234
  /* @__PURE__ */ jsx("style", { href: "asta-navbar", precedence: "asta", children: `
209
- @keyframes kit-nav-in { from { opacity: 0; transform: translateX(calc(var(--kit-dir) * 36px)); } to { opacity: 1; transform: none; } }
235
+ @keyframes kit-nav-in { from { opacity: 0; transform: translateX(calc(var(--kit-dir) * 14px)); } to { opacity: 1; transform: none; } }
210
236
  @keyframes kit-nav-pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
211
237
  @media (prefers-reduced-motion: reduce) { .kit-nav-motion, .kit-nav-motion * { animation: none !important; transition-duration: 0s !important; } }
212
238
  ` }),
213
- /* @__PURE__ */ jsxs("div", { className: "kit-nav-motion relative flex h-14 items-center gap-3 px-4", children: [
239
+ /* @__PURE__ */ jsxs("div", { "data-kit-nav-bar": true, className: "kit-nav-motion relative flex h-14 items-center gap-3 px-4", children: [
214
240
  /* @__PURE__ */ jsx("a", { href: brandHref, className: "flex flex-1 items-center gap-2 text-[15px] font-semibold tracking-[-0.02em] text-ink outline-none focus-visible:ring-2 focus-visible:ring-brand/50 rounded-md", children: brand }),
215
241
  /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "hidden @min-[560px]:block", onPointerLeave: leave, onPointerEnter: stay, children: /* @__PURE__ */ jsx("ul", { className: "flex items-center gap-0.5", children: items.map((it, i) => /* @__PURE__ */ jsx("li", { children: it.menu ? /* @__PURE__ */ jsxs(
216
242
  "button",
@@ -280,9 +306,12 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
280
306
  onPointerEnter: stay,
281
307
  onPointerLeave: leave,
282
308
  className: cx(
283
- "absolute left-1/2 top-[calc(100%-2px)] hidden -translate-x-1/2 @min-[560px]:block",
309
+ "absolute left-0 top-[calc(100%-2px)] hidden @min-[560px]:block",
310
+ size.w > 0 && "transition-transform duration-300",
311
+ EASE,
284
312
  open === null && "pointer-events-none"
285
313
  ),
314
+ style: { transform: `translateX(${Math.round(panelX)}px)` },
286
315
  children: /* @__PURE__ */ jsx(
287
316
  "div",
288
317
  {
@@ -299,8 +328,8 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
299
328
  className: "w-max",
300
329
  style: {
301
330
  "--kit-dir": dir,
302
- width: `min(${menu.width ?? 560}px, calc(100cqw - 24px))`,
303
- animation: slide ? "kit-nav-in .38s cubic-bezier(.16,1,.3,1) both" : void 0
331
+ width: `min(${menu.width ?? (menu.list ? 300 : 560)}px, calc(100cqw - 24px))`,
332
+ animation: slide ? "kit-nav-in .28s cubic-bezier(.16,1,.3,1) both" : void 0
304
333
  },
305
334
  children: /* @__PURE__ */ jsx(Panel, { menu })
306
335
  },
@@ -63,7 +63,26 @@ function Tile({ tile, big }) {
63
63
  }
64
64
  );
65
65
  }
66
+ function List({ links }) {
67
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-0.5 p-1.5", children: links.map((l) => /* @__PURE__ */ jsxs(
68
+ "a",
69
+ {
70
+ href: l.href,
71
+ "data-kit-nav-link": true,
72
+ className: "group/item flex items-start gap-3 rounded-lg px-2.5 py-2 outline-none transition-colors duration-150 hover:bg-paper-2 focus-visible:bg-paper-2",
73
+ children: [
74
+ l.icon && /* @__PURE__ */ jsx("span", { className: cx("mt-px flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-paper text-mute transition-colors duration-150 group-hover/item:text-ink [&_svg]:h-3.5 [&_svg]:w-3.5", RING), children: l.icon }),
75
+ /* @__PURE__ */ jsxs("span", { className: "flex min-w-0 flex-col", children: [
76
+ /* @__PURE__ */ jsx("span", { className: "text-[13.5px] font-medium text-ink", children: l.title }),
77
+ l.description && /* @__PURE__ */ jsx("span", { className: "text-[12px] leading-snug text-mute", children: l.description })
78
+ ] })
79
+ ]
80
+ },
81
+ l.title
82
+ )) });
83
+ }
66
84
  function Panel({ menu }) {
85
+ if (menu.list) return /* @__PURE__ */ jsx(List, { links: menu.list });
67
86
  const tiles = menu.tiles ?? [];
68
87
  const big = tiles.some((t) => t.preview);
69
88
  return /* @__PURE__ */ jsxs("div", { className: "group/menu flex flex-col gap-2 p-2", children: [
@@ -109,13 +128,14 @@ function Panel({ menu }) {
109
128
  ] })
110
129
  ] });
111
130
  }
112
- var flat = (m) => [...m.tiles ?? [], ...m.columns?.flatMap((c) => c.links) ?? []];
131
+ var flat = (m) => [...m.list ?? [], ...m.tiles ?? [], ...m.columns?.flatMap((c) => c.links) ?? []];
113
132
  function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, className }) {
114
133
  const [open, setOpen] = useState(null);
115
134
  const [dir, setDir] = useState(1);
116
135
  const [last, setLast] = useState(null);
117
136
  const [slide, setSlide] = useState(false);
118
137
  const [size, setSize] = useState({ w: 0, h: 0 });
138
+ const [anchor, setAnchor] = useState({ left: 0, bar: 0 });
119
139
  const [scrolled, setScrolled] = useState(false);
120
140
  const [sheet, setSheet] = useState(false);
121
141
  const [section, setSection] = useState(null);
@@ -135,17 +155,22 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
135
155
  const moving = i !== null && cur !== null && i !== cur;
136
156
  if (moving) setDir(i > cur ? 1 : -1);
137
157
  setSlide(moving);
138
- if (i !== null) setLast(i);
158
+ if (i !== null) {
159
+ setLast(i);
160
+ const t = triggers.current[i];
161
+ const bar = t?.closest("[data-kit-nav-bar]");
162
+ if (t && bar) setAnchor({ left: t.getBoundingClientRect().left - bar.getBoundingClientRect().left, bar: bar.offsetWidth });
163
+ }
139
164
  setOpen(i);
140
165
  }, []);
141
166
  const enter = (i) => {
142
167
  clearTimeout(timer.current);
143
- if (openRef.current === null) timer.current = setTimeout(() => show(i), 110);
168
+ if (openRef.current === null) timer.current = setTimeout(() => show(i), 80);
144
169
  else show(i);
145
170
  };
146
171
  const leave = () => {
147
172
  clearTimeout(timer.current);
148
- timer.current = setTimeout(() => show(null), 180);
173
+ timer.current = setTimeout(() => show(null), 150);
149
174
  };
150
175
  const stay = () => clearTimeout(timer.current);
151
176
  useLayoutEffect(() => {
@@ -194,6 +219,7 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
194
219
  }, [show]);
195
220
  useEffect(() => () => clearTimeout(timer.current), []);
196
221
  const menu = shown !== null ? items[shown]?.menu : void 0;
222
+ const panelX = menu?.list ? Math.max(12, Math.min(anchor.left - 6, anchor.bar - size.w - 12)) : (anchor.bar - size.w) / 2;
197
223
  const trigger = "flex h-8 items-center gap-1 rounded-md px-2.5 text-[13.5px] font-medium text-ink-2 outline-none transition-colors duration-200 hover:bg-paper-2 hover:text-ink focus-visible:ring-2 focus-visible:ring-brand/50 aria-expanded:bg-paper-2 aria-expanded:text-ink";
198
224
  return /* @__PURE__ */ jsxs(
199
225
  "header",
@@ -206,11 +232,11 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
206
232
  ),
207
233
  children: [
208
234
  /* @__PURE__ */ jsx("style", { href: "asta-navbar", precedence: "asta", children: `
209
- @keyframes kit-nav-in { from { opacity: 0; transform: translateX(calc(var(--kit-dir) * 36px)); } to { opacity: 1; transform: none; } }
235
+ @keyframes kit-nav-in { from { opacity: 0; transform: translateX(calc(var(--kit-dir) * 14px)); } to { opacity: 1; transform: none; } }
210
236
  @keyframes kit-nav-pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: none; } }
211
237
  @media (prefers-reduced-motion: reduce) { .kit-nav-motion, .kit-nav-motion * { animation: none !important; transition-duration: 0s !important; } }
212
238
  ` }),
213
- /* @__PURE__ */ jsxs("div", { className: "kit-nav-motion relative flex h-14 items-center gap-3 px-4", children: [
239
+ /* @__PURE__ */ jsxs("div", { "data-kit-nav-bar": true, className: "kit-nav-motion relative flex h-14 items-center gap-3 px-4", children: [
214
240
  /* @__PURE__ */ jsx("a", { href: brandHref, className: "flex flex-1 items-center gap-2 text-[15px] font-semibold tracking-[-0.02em] text-ink outline-none focus-visible:ring-2 focus-visible:ring-brand/50 rounded-md", children: brand }),
215
241
  /* @__PURE__ */ jsx("nav", { "aria-label": "Main", className: "hidden @min-[560px]:block", onPointerLeave: leave, onPointerEnter: stay, children: /* @__PURE__ */ jsx("ul", { className: "flex items-center gap-0.5", children: items.map((it, i) => /* @__PURE__ */ jsx("li", { children: it.menu ? /* @__PURE__ */ jsxs(
216
242
  "button",
@@ -280,9 +306,12 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
280
306
  onPointerEnter: stay,
281
307
  onPointerLeave: leave,
282
308
  className: cx(
283
- "absolute left-1/2 top-[calc(100%-2px)] hidden -translate-x-1/2 @min-[560px]:block",
309
+ "absolute left-0 top-[calc(100%-2px)] hidden @min-[560px]:block",
310
+ size.w > 0 && "transition-transform duration-300",
311
+ EASE,
284
312
  open === null && "pointer-events-none"
285
313
  ),
314
+ style: { transform: `translateX(${Math.round(panelX)}px)` },
286
315
  children: /* @__PURE__ */ jsx(
287
316
  "div",
288
317
  {
@@ -299,8 +328,8 @@ function Navbar({ brand, brandHref = "/", items, docs, cta, scrollRoot, classNam
299
328
  className: "w-max",
300
329
  style: {
301
330
  "--kit-dir": dir,
302
- width: `min(${menu.width ?? 560}px, calc(100cqw - 24px))`,
303
- animation: slide ? "kit-nav-in .38s cubic-bezier(.16,1,.3,1) both" : void 0
331
+ width: `min(${menu.width ?? (menu.list ? 300 : 560)}px, calc(100cqw - 24px))`,
332
+ animation: slide ? "kit-nav-in .28s cubic-bezier(.16,1,.3,1) both" : void 0
304
333
  },
305
334
  children: /* @__PURE__ */ jsx(Panel, { menu })
306
335
  },