@apliteni/apliteni-ui 0.151.0 → 0.155.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.
@@ -282,22 +282,37 @@ var StatusDot = forwardRef5(function StatusDot2({
282
282
  });
283
283
 
284
284
  // src/primitives/Card.tsx
285
+ import { createContext, useCallback as useCallback2, useMemo, useState as useState2 } from "react";
285
286
  import { icon as kitIcon, safeUrl } from "@apliteni/apliteni-ui";
286
287
  import { Fragment, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
287
- function Card({ title, sub, level = 2, variant, pad: pad2, icon: icon9, href, className, children }) {
288
+ var CardTools = createContext(null);
289
+ function Card({ title, sub, level = 2, variant, pad: pad2, icon: icon9, href, tools, className, children }) {
290
+ const [claims, setClaims] = useState2([]);
291
+ const [slot, setSlot] = useState2(null);
292
+ const claim = useCallback2((id) => {
293
+ setClaims((held) => held.includes(id) ? held : [...held, id]);
294
+ return () => setClaims((held) => held.filter((h) => h !== id));
295
+ }, []);
296
+ const owner = claims[0] ?? null;
297
+ const offer = useMemo(() => ({ slot, owner, claim }), [slot, owner, claim]);
288
298
  const n = Number(level);
289
299
  const Heading = href != null ? "div" : `h${[2, 3, 4, 5, 6].includes(n) ? n : 2}`;
290
300
  const titled = title != null && title !== false && title !== "";
291
301
  const classes = ["ui-card", variant && `ui-card--${variant}`, pad2 && `ui-card--pad-${pad2}`, href != null && "ui-card--interactive", className].filter(Boolean).join(" ");
302
+ const withTools = titled && href == null;
303
+ const heading = titled && /* @__PURE__ */ jsxs5(Heading, { className: "ui-card__title", children: [
304
+ icon9 && /* @__PURE__ */ jsx9("span", { className: "ui-card__icon", "aria-hidden": "true", dangerouslySetInnerHTML: { __html: kitIcon(icon9) } }),
305
+ title
306
+ ] });
292
307
  const inner = /* @__PURE__ */ jsxs5(Fragment, { children: [
293
- titled && /* @__PURE__ */ jsxs5(Heading, { className: "ui-card__title", children: [
294
- icon9 && /* @__PURE__ */ jsx9("span", { className: "ui-card__icon", "aria-hidden": "true", dangerouslySetInnerHTML: { __html: kitIcon(icon9) } }),
295
- title
296
- ] }),
308
+ withTools && (tools != null || owner != null) ? /* @__PURE__ */ jsxs5("div", { className: "ui-card__head", children: [
309
+ heading,
310
+ /* @__PURE__ */ jsx9("div", { className: "ui-card__tools", ref: setSlot, children: tools })
311
+ ] }) : heading,
297
312
  sub != null && /* @__PURE__ */ jsx9("div", { className: "ui-card__sub", children: sub }),
298
313
  children
299
314
  ] });
300
- return href != null ? /* @__PURE__ */ jsx9("a", { className: classes, href: safeUrl(href), children: inner }) : /* @__PURE__ */ jsx9("div", { className: classes, children: inner });
315
+ return href != null ? /* @__PURE__ */ jsx9("a", { className: classes, href: safeUrl(href), children: inner }) : /* @__PURE__ */ jsx9("div", { className: classes, children: withTools ? /* @__PURE__ */ jsx9(CardTools.Provider, { value: offer, children: inner }) : inner });
301
316
  }
302
317
 
303
318
  // src/primitives/Callout.tsx
@@ -356,7 +371,7 @@ function placeTip(host, mark, tip, bound, placement = "top") {
356
371
  }
357
372
 
358
373
  // src/Tooltip.tsx
359
- import { useEffect, useId as useId2, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
374
+ import { useEffect, useId as useId2, useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState3 } from "react";
360
375
  import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
361
376
  var DOC_EVENTS = ["pointerdown", "pointercancel", "click", "keydown", "touchend"];
362
377
  var CAPTURED = /* @__PURE__ */ new Set(["pointerdown", "pointercancel"]);
@@ -399,7 +414,7 @@ function Tooltip({ text: text2, label = text2, value, detail: detail2, placement
399
414
  const pointerKind = useRef2("");
400
415
  const pendingClick = useRef2(null);
401
416
  const dismissed = useRef2(null);
402
- const [mark, setMark] = useState2(null);
417
+ const [mark, setMark] = useState3(null);
403
418
  const active = useRef2(null);
404
419
  active.current = mark;
405
420
  const open = mark !== null;
@@ -599,12 +614,12 @@ import { createPortal } from "react-dom";
599
614
 
600
615
  // src/dialog.ts
601
616
  import {
602
- createContext,
617
+ createContext as createContext2,
603
618
  useContext,
604
619
  useEffect as useEffect2,
605
620
  useLayoutEffect as useLayoutEffect3,
606
621
  useRef as useRef3,
607
- useState as useState3
622
+ useState as useState4
608
623
  } from "react";
609
624
  import { transitionMs } from "@apliteni/apliteni-ui";
610
625
  var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]), details > summary:first-of-type';
@@ -627,7 +642,7 @@ var dismissOnScrim = (onClose) => (e) => {
627
642
  onClose();
628
643
  };
629
644
  var useIsoLayoutEffect = typeof document === "undefined" ? useEffect2 : useLayoutEffect3;
630
- var DialogScope = createContext(null);
645
+ var DialogScope = createContext2(null);
631
646
  var stack = [];
632
647
  var leaving = /* @__PURE__ */ new Set();
633
648
  var marked = [];
@@ -726,8 +741,8 @@ function exit(entry) {
726
741
  }
727
742
  var EXIT_SLACK_MS = 50;
728
743
  function usePresence(open, root, panel) {
729
- const [present, setPresent] = useState3(open);
730
- const [entered, setEntered] = useState3(false);
744
+ const [present, setPresent] = useState4(open);
745
+ const [entered, setEntered] = useState4(false);
731
746
  if (open && !present) setPresent(true);
732
747
  const shown = open && entered;
733
748
  useIsoLayoutEffect(() => {
@@ -776,7 +791,7 @@ function usePresence(open, root, panel) {
776
791
  }
777
792
  function useDialog(active, { root, panel, body, initialFocus, fallbackFocus }, onClose) {
778
793
  const parent = useContext(DialogScope);
779
- const [scope] = useState3(() => ({ parent }));
794
+ const [scope] = useState4(() => ({ parent }));
780
795
  const close = useRef3(onClose);
781
796
  useIsoLayoutEffect(() => {
782
797
  close.current = onClose;
@@ -869,7 +884,7 @@ function Confirm({
869
884
  }
870
885
 
871
886
  // src/Feedback.tsx
872
- import { useEffect as useEffect3, useRef as useRef6, useState as useState4 } from "react";
887
+ import { useEffect as useEffect3, useRef as useRef6, useState as useState5 } from "react";
873
888
  import { createPortal as createPortal2 } from "react-dom";
874
889
  import { nearestSection } from "@apliteni/apliteni-ui";
875
890
  import { Fragment as Fragment5, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
@@ -888,14 +903,14 @@ function Feedback({
888
903
  placeholder = "What's off, missing, or worth adding here?",
889
904
  sentMessage = "Thanks, your note is sent."
890
905
  }) {
891
- const [pill, setPill] = useState4(null);
892
- const [open, setOpen] = useState4(false);
906
+ const [pill, setPill] = useState5(null);
907
+ const [open, setOpen] = useState5(false);
893
908
  const openRef = useRef6(false);
894
- const [note, setNote] = useState4("");
895
- const [state, setState] = useState4("ready");
896
- const [error, setError] = useState4("");
909
+ const [note, setNote] = useState5("");
910
+ const [state, setState] = useState5("ready");
911
+ const [error, setError] = useState5("");
897
912
  const pending = useRef6(null);
898
- const [view, setView] = useState4({ chip: "this page", quote: "" });
913
+ const [view, setView] = useState5({ chip: "this page", quote: "" });
899
914
  const mark = useRef6(null);
900
915
  const opening = useRef6(0);
901
916
  const pillRef = useRef6(null);
@@ -1109,7 +1124,7 @@ function Feedback({
1109
1124
  }
1110
1125
 
1111
1126
  // src/AccountWindow.tsx
1112
- import { useEffect as useEffect7, useId as useId7, useRef as useRef9, useState as useState6 } from "react";
1127
+ import { useEffect as useEffect7, useId as useId7, useRef as useRef9, useState as useState7 } from "react";
1113
1128
  import { createPortal as createPortal3 } from "react-dom";
1114
1129
  import { revealFocusedNav as revealFocusedNav2 } from "@apliteni/apliteni-ui";
1115
1130
 
@@ -1167,7 +1182,7 @@ var NavTabs = forwardRef6(function NavTabs2({
1167
1182
  });
1168
1183
 
1169
1184
  // src/SidebarNav.tsx
1170
- import { forwardRef as forwardRef7, useEffect as useEffect5, useId as useId5, useState as useState5 } from "react";
1185
+ import { forwardRef as forwardRef7, useEffect as useEffect5, useId as useId5, useState as useState6 } from "react";
1171
1186
  import { ENTRANCE_FALLBACK_MS } from "@apliteni/apliteni-ui/motion";
1172
1187
  import { Fragment as Fragment8, jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
1173
1188
  var badgeText = (badge) => typeof badge === "object" ? badge.text : badge;
@@ -1175,9 +1190,9 @@ function Row({ item, active, activeIs, collapsed, renderLink, sub }) {
1175
1190
  const uid = useId5();
1176
1191
  const group = !sub && !!item.items?.length;
1177
1192
  const childActive = group && item.items.some((child) => child.id === active);
1178
- const [expanded, setExpanded] = useState5();
1193
+ const [expanded, setExpanded] = useState6();
1179
1194
  const open = expanded ?? item.defaultOpen ?? childActive;
1180
- const [entering, setEntering] = useState5(false);
1195
+ const [entering, setEntering] = useState6(false);
1181
1196
  useEffect5(() => {
1182
1197
  if (!entering) return;
1183
1198
  const timer = setTimeout(() => setEntering(false), ENTRANCE_FALLBACK_MS);
@@ -1356,7 +1371,7 @@ function AccountWindow({
1356
1371
  const panel = useRef9(null);
1357
1372
  const body = useRef9(null);
1358
1373
  const tabs = useRef9(null);
1359
- const [own, setOwn] = useState6(defaultSection2 ?? sections[0]?.id);
1374
+ const [own, setOwn] = useState7(defaultSection2 ?? sections[0]?.id);
1360
1375
  const { mounted, shown } = usePresence(open, root, panel);
1361
1376
  const scope = useDialog(shown, { root, panel, body }, onClose);
1362
1377
  const currentId = section ?? own;
@@ -1502,7 +1517,7 @@ function Drawer({
1502
1517
  /* @__PURE__ */ jsx20(DialogScope.Provider, { value: scope, children: /* @__PURE__ */ jsxs16("div", { className: cls, ref: root, children: [
1503
1518
  /* @__PURE__ */ jsx20("div", { className: "ui-drawer__scrim", onMouseDown: dismissOnScrim(onClose) }),
1504
1519
  /* @__PURE__ */ jsxs16(
1505
- "aside",
1520
+ "div",
1506
1521
  {
1507
1522
  className: "ui-drawer__panel",
1508
1523
  role: "dialog",
@@ -1527,7 +1542,7 @@ function Drawer({
1527
1542
  }
1528
1543
 
1529
1544
  // src/CommandPalette.tsx
1530
- import { useCallback as useCallback2, useEffect as useEffect8, useId as useId9, useMemo, useRef as useRef11, useState as useState7 } from "react";
1545
+ import { useCallback as useCallback3, useEffect as useEffect8, useId as useId9, useMemo as useMemo2, useRef as useRef11, useState as useState8 } from "react";
1531
1546
  import { createPortal as createPortal5 } from "react-dom";
1532
1547
  import { rankGroups, icon as icon3 } from "@apliteni/apliteni-ui";
1533
1548
  import { jsx as jsx21, jsxs as jsxs17 } from "react/jsx-runtime";
@@ -1539,6 +1554,7 @@ function CommandPalette({
1539
1554
  onClose,
1540
1555
  groups,
1541
1556
  onSelect,
1557
+ onNavigate,
1542
1558
  label = "Command palette",
1543
1559
  placeholder = "Search or run a command\u2026",
1544
1560
  empty = "No matches",
@@ -1551,25 +1567,25 @@ function CommandPalette({
1551
1567
  const root = useRef11(null);
1552
1568
  const panel = useRef11(null);
1553
1569
  const search = useRef11(null);
1554
- const [query, setQuery] = useState7("");
1555
- const [at, setAt] = useState7(0);
1570
+ const [query, setQuery] = useState8("");
1571
+ const [at, setAt] = useState8(0);
1556
1572
  useEffect8(() => {
1557
1573
  if (open) {
1558
1574
  setQuery("");
1559
1575
  setAt(0);
1560
1576
  }
1561
1577
  }, [open]);
1562
- const shown = useMemo(
1578
+ const shown = useMemo2(
1563
1579
  () => (rank ? rankGroups(groups, query) : groups).filter((g) => g.items.length),
1564
1580
  [groups, query, rank]
1565
1581
  );
1566
- const rows = useMemo(() => shown.flatMap((g) => g.items).filter((it) => !isDisabled(it)), [shown]);
1582
+ const rows = useMemo2(() => shown.flatMap((g) => g.items).filter((it) => !isDisabled(it)), [shown]);
1567
1583
  const active = rows[Math.min(at, rows.length - 1)];
1568
1584
  useEffect8(() => {
1569
1585
  setAt(0);
1570
1586
  }, [query]);
1571
1587
  const scope = useDialog(open, { root, panel, body: search }, onClose);
1572
- const run = useCallback2((item, newTab) => {
1588
+ const run = useCallback3((item, newTab) => {
1573
1589
  if (isDisabled(item)) return;
1574
1590
  onSelect?.(item, { newTab });
1575
1591
  if (item.danger && item.onConfirm) {
@@ -1579,8 +1595,9 @@ function CommandPalette({
1579
1595
  onClose();
1580
1596
  if (!item.href) return;
1581
1597
  if (newTab) window.open(item.href, "_blank", "noopener");
1598
+ else if (onNavigate) onNavigate(item.href);
1582
1599
  else window.location.href = item.href;
1583
- }, [onClose, onSelect]);
1600
+ }, [onClose, onSelect, onNavigate]);
1584
1601
  const onKeyDown = (e) => {
1585
1602
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
1586
1603
  if (!rows.length) return;
@@ -1720,11 +1737,11 @@ function rowId(uid, groups, item) {
1720
1737
  }
1721
1738
 
1722
1739
  // src/DataTable.tsx
1723
- import { Fragment as Fragment10, useCallback as useCallback3, useEffect as useEffect10, useMemo as useMemo2, useRef as useRef13, useState as useState9 } from "react";
1740
+ import { Fragment as Fragment10, useCallback as useCallback4, useEffect as useEffect10, useMemo as useMemo3, useRef as useRef13, useState as useState10 } from "react";
1724
1741
  import { DEFAULT_PAGE_SIZE as DEFAULT_PAGE_SIZE2 } from "@apliteni/apliteni-ui";
1725
1742
 
1726
1743
  // src/Pagination.tsx
1727
- import { useEffect as useEffect9, useId as useId10, useRef as useRef12, useState as useState8 } from "react";
1744
+ import { useEffect as useEffect9, useId as useId10, useRef as useRef12, useState as useState9 } from "react";
1728
1745
  import { DEFAULT_PAGE_SIZE } from "@apliteni/apliteni-ui";
1729
1746
  import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
1730
1747
  var GHOST_SM = "ui-btn ui-btn--ghost ui-btn--sm";
@@ -1769,8 +1786,8 @@ function Pagination({
1769
1786
  onPageSizeChange
1770
1787
  }) {
1771
1788
  const auto = useId10();
1772
- const [draft, setDraft] = useState8("");
1773
- const [drafting, setDrafting] = useState8(false);
1789
+ const [draft, setDraft] = useState9("");
1790
+ const [drafting, setDrafting] = useState9(false);
1774
1791
  const nav = useRef12(null);
1775
1792
  const pressed = useRef12(null);
1776
1793
  const uid = id ?? auto;
@@ -1781,7 +1798,7 @@ function Pagination({
1781
1798
  const rows = counted ? Math.max(0, asRows) : null;
1782
1799
  const last = counted ? Math.max(1, Math.ceil(rows / size)) : null;
1783
1800
  const at = counted ? Math.min(Math.max(1, int(page, 1)), last) : Math.min(Math.max(1, int(page, 1)), CAP - 1);
1784
- const [draftFor, setDraftFor] = useState8(at);
1801
+ const [draftFor, setDraftFor] = useState9(at);
1785
1802
  if (draftFor !== at) {
1786
1803
  setDraftFor(at);
1787
1804
  setDraft("");
@@ -1991,12 +2008,12 @@ function DataTable({
1991
2008
  }) {
1992
2009
  const scrollable = stickyHeader || pinnedIdentity;
1993
2010
  const table = useRef13(null);
1994
- const [pagerHost, setPagerHost] = useState9(null);
1995
- const holdPagerBox = useCallback3(
2011
+ const [pagerHost, setPagerHost] = useState10(null);
2012
+ const holdPagerBox = useCallback4(
1996
2013
  (box) => setPagerHost(box?.parentElement ?? null),
1997
2014
  []
1998
2015
  );
1999
- const [strip2, setStrip] = useState9();
2016
+ const [strip2, setStrip] = useState10();
2000
2017
  useEffect10(() => {
2001
2018
  const el = table.current;
2002
2019
  const host = pagerHost;
@@ -2017,21 +2034,21 @@ function DataTable({
2017
2034
  measure();
2018
2035
  return () => observer.disconnect();
2019
2036
  }, [pagerHost, columns, rows]);
2020
- const [localSort, setLocalSort] = useState9(
2037
+ const [localSort, setLocalSort] = useState10(
2021
2038
  { key: columns.find((c) => c.sortable)?.key, dir: -1 }
2022
2039
  );
2023
2040
  const owned = controlledPage === void 0;
2024
2041
  const sort = controlledSort ?? (owned ? localSort : NO_SORT);
2025
2042
  const sortIsKnown = owned || controlledSort !== void 0;
2026
- const [localPage, setLocalPage] = useState9(1);
2027
- const [localSize, setLocalSize] = useState9(DEFAULT_PAGE_SIZE2);
2043
+ const [localPage, setLocalPage] = useState10(1);
2044
+ const [localSize, setLocalSize] = useState10(DEFAULT_PAGE_SIZE2);
2028
2045
  const size = sizeOf(pageSize, owned ? localSize : rows.length || DEFAULT_PAGE_SIZE2);
2029
- const [pagedSort, setPagedSort] = useState9(sort);
2046
+ const [pagedSort, setPagedSort] = useState10(sort);
2030
2047
  if (pagedSort.key !== sort.key || pagedSort.dir !== sort.dir) {
2031
2048
  setPagedSort(sort);
2032
2049
  setLocalPage(1);
2033
2050
  }
2034
- const ordered = useMemo2(
2051
+ const ordered = useMemo3(
2035
2052
  () => owned ? sortTableRows(rows, sort) : rows,
2036
2053
  [owned, rows, sort.key, sort.dir]
2037
2054
  );
@@ -2263,11 +2280,11 @@ function Denied({
2263
2280
 
2264
2281
  // src/DatePicker.tsx
2265
2282
  import {
2266
- useCallback as useCallback4,
2283
+ useCallback as useCallback5,
2267
2284
  useEffect as useEffect11,
2268
- useMemo as useMemo3,
2285
+ useMemo as useMemo4,
2269
2286
  useRef as useRef14,
2270
- useState as useState10
2287
+ useState as useState11
2271
2288
  } from "react";
2272
2289
  import { dropdownViewportFit } from "@apliteni/apliteni-ui";
2273
2290
  import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
@@ -2279,7 +2296,7 @@ var MONTH_RE = /^(\d{4})-(\d{2})$/;
2279
2296
  var DAY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
2280
2297
  var PHONE_MAX = 560;
2281
2298
  function usePhone() {
2282
- const [phone, setPhone] = useState10(false);
2299
+ const [phone, setPhone] = useState11(false);
2283
2300
  useEffect11(() => {
2284
2301
  const query = typeof window === "undefined" ? null : window.matchMedia?.(`(max-width: ${PHONE_MAX}px)`);
2285
2302
  if (!query) return;
@@ -2379,13 +2396,13 @@ function DatePicker({
2379
2396
  const trigger = useRef14(null);
2380
2397
  const grid = useRef14(null);
2381
2398
  const panel = useRef14(null);
2382
- const [selfOpen, setSelfOpen] = useState10(defaultOpen);
2399
+ const [selfOpen, setSelfOpen] = useState11(defaultOpen);
2383
2400
  const open = openProp ?? selfOpen;
2384
- const [selfValue, setSelfValue] = useState10(defaultValue);
2401
+ const [selfValue, setSelfValue] = useState11(defaultValue);
2385
2402
  const picked = value !== void 0 ? value : selfValue;
2386
- const [selfRange, setSelfRange] = useState10(defaultRange ?? { start: null, end: null });
2403
+ const [selfRange, setSelfRange] = useState11(defaultRange ?? { start: null, end: null });
2387
2404
  const span = range !== void 0 ? range : selfRange;
2388
- const names = useMemo3(() => ({
2405
+ const names = useMemo4(() => ({
2389
2406
  month: new Intl.DateTimeFormat(locale, { month: "long", timeZone: "UTC" }),
2390
2407
  monthShort: new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" }),
2391
2408
  monthYear: new Intl.DateTimeFormat(locale, { month: "long", year: "numeric", timeZone: "UTC" }),
@@ -2395,28 +2412,28 @@ function DatePicker({
2395
2412
  weekday: new Intl.DateTimeFormat(locale, { weekday: "long", timeZone: "UTC" }),
2396
2413
  weekdayShort: new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" })
2397
2414
  }), [locale]);
2398
- const monthLabels = useMemo3(() => evenMonthLabels(names.monthShort), [names]);
2399
- const at = useCallback4((index) => new Date(
2415
+ const monthLabels = useMemo4(() => evenMonthLabels(names.monthShort), [names]);
2416
+ const at = useCallback5((index) => new Date(
2400
2417
  grain === "month" ? Date.UTC(Math.floor(index / 12), index % 12, 1) : index * DAY_MS
2401
2418
  ), [grain]);
2402
2419
  const lo = toIndex(min, grain, "start");
2403
2420
  const hi = toIndex(max, grain, "end");
2404
- const blocked = useMemo3(() => (disabledPeriods ?? []).flatMap((period) => {
2421
+ const blocked = useMemo4(() => (disabledPeriods ?? []).flatMap((period) => {
2405
2422
  const from = toIndex(period, grain, "start");
2406
2423
  const to = toIndex(period, grain, "end");
2407
2424
  return from == null || to == null ? [] : [[from, to]];
2408
2425
  }), [disabledPeriods, grain]);
2409
2426
  const outOfBounds = (index) => lo != null && index < lo || hi != null && index > hi;
2410
2427
  const isBlocked = (index) => outOfBounds(index) || blocked.some(([from, to]) => index >= from && index <= to);
2411
- const todayIndex = useMemo3(() => {
2428
+ const todayIndex = useMemo4(() => {
2412
2429
  const given = toIndex(today, "day");
2413
2430
  const now = given ?? Math.floor(Date.now() / DAY_MS);
2414
2431
  return grain === "month" ? monthOf(now) : now;
2415
2432
  }, [today, grain]);
2416
2433
  const anchor = toIndex(picked, grain) ?? toIndex(picksRange ? span.start ?? span.end : null, grain) ?? todayIndex;
2417
- const [cursor, setCursor] = useState10(() => clamp(anchor, lo, hi));
2434
+ const [cursor, setCursor] = useState11(() => clamp(anchor, lo, hi));
2418
2435
  const land = useRef14(false);
2419
- const setOpen = useCallback4((next) => {
2436
+ const setOpen = useCallback5((next) => {
2420
2437
  if (openProp === void 0) setSelfOpen(next);
2421
2438
  onOpenChange?.(next);
2422
2439
  }, [openProp, onOpenChange]);
@@ -2474,11 +2491,11 @@ function DatePicker({
2474
2491
  const columns = grain === "month" ? 3 : 7;
2475
2492
  const page = grain === "month" ? Math.floor(cursor / 12) : monthOf(cursor);
2476
2493
  const caption = grain === "month" ? String(page) : names.monthYear.format(at(firstDayOf(page)));
2477
- const periodName = useCallback4((index) => grain === "month" ? names.monthYear.format(at(index)) : `${names.weekday.format(at(index))} ${names.day.format(at(index))}`, [grain, names, at]);
2494
+ const periodName = useCallback5((index) => grain === "month" ? names.monthYear.format(at(index)) : `${names.weekday.format(at(index))} ${names.day.format(at(index))}`, [grain, names, at]);
2478
2495
  const count = grain === "month" ? 12 : daysInMonth(page);
2479
2496
  const first = grain === "month" ? page * 12 : firstDayOf(page);
2480
2497
  const last = first + count - 1;
2481
- const cells = useMemo3(() => Array.from({ length: count }, (_, i) => {
2498
+ const cells = useMemo4(() => Array.from({ length: count }, (_, i) => {
2482
2499
  const index = first + i;
2483
2500
  const period = fromIndex(index, grain);
2484
2501
  return {
@@ -2572,7 +2589,7 @@ function DatePicker({
2572
2589
  dismiss();
2573
2590
  }
2574
2591
  }
2575
- const shown = useMemo3(() => {
2592
+ const shown = useMemo4(() => {
2576
2593
  if (picksRange) {
2577
2594
  const text2 = (period) => {
2578
2595
  const index2 = toIndex(period, grain);
@@ -2759,12 +2776,12 @@ function DatePicker({
2759
2776
  // src/Dropdown.tsx
2760
2777
  import {
2761
2778
  Fragment as Fragment12,
2762
- useCallback as useCallback5,
2779
+ useCallback as useCallback6,
2763
2780
  useContext as useContext2,
2764
2781
  useEffect as useEffect12,
2765
2782
  useId as useId11,
2766
2783
  useRef as useRef15,
2767
- useState as useState11
2784
+ useState as useState12
2768
2785
  } from "react";
2769
2786
  import {
2770
2787
  icon as icon4,
@@ -2782,8 +2799,8 @@ import {
2782
2799
  } from "@apliteni/apliteni-ui";
2783
2800
 
2784
2801
  // src/fieldContext.ts
2785
- import { createContext as createContext2 } from "react";
2786
- var FieldContext = createContext2(null);
2802
+ import { createContext as createContext3 } from "react";
2803
+ var FieldContext = createContext3(null);
2787
2804
 
2788
2805
  // src/Dropdown.tsx
2789
2806
  import { Fragment as Fragment13, jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
@@ -2853,11 +2870,11 @@ function Dropdown({
2853
2870
  onSelect,
2854
2871
  row
2855
2872
  }) {
2856
- const [selfOpen, setSelfOpen] = useState11(defaultOpen);
2873
+ const [selfOpen, setSelfOpen] = useState12(defaultOpen);
2857
2874
  const open = openProp ?? selfOpen;
2858
- const [pick, setPick] = useState11(null);
2859
- const [query, setQuery] = useState11(() => search && search !== true ? search.query || "" : "");
2860
- const [activeKey, setActiveKey] = useState11(null);
2875
+ const [pick, setPick] = useState12(null);
2876
+ const [query, setQuery] = useState12(() => search && search !== true ? search.query || "" : "");
2877
+ const [activeKey, setActiveKey] = useState12(null);
2861
2878
  const root = useRef15(null);
2862
2879
  const panel = useRef15(null);
2863
2880
  const trigger = useRef15(null);
@@ -2869,7 +2886,7 @@ function Dropdown({
2869
2886
  const uid = id ?? auto;
2870
2887
  const inField = useContext2(FieldContext);
2871
2888
  const fieldName = inField && id === inField.id && !(ariaLabel && triggerContent != null) ? { id: `${uid}-trigger`, labelId: inField.labelId, labelledBy: `${inField.labelId} ${uid}-trigger` } : null;
2872
- const setOpen = useCallback5((next) => {
2889
+ const setOpen = useCallback6((next) => {
2873
2890
  if (openProp === void 0) setSelfOpen(next);
2874
2891
  onOpenChange?.(next);
2875
2892
  }, [openProp, onOpenChange]);
@@ -3490,7 +3507,7 @@ function Segmented({ options, value, onChange, label, appearance = "pill", size,
3490
3507
  }
3491
3508
 
3492
3509
  // src/FilterBar.tsx
3493
- import { useRef as useRef16, useState as useState12 } from "react";
3510
+ import { useRef as useRef16, useState as useState13 } from "react";
3494
3511
  import { filterChipText, filterChipName, filterChipUnset, filterChipItems, focusNextStop } from "@apliteni/apliteni-ui";
3495
3512
  import { Fragment as Fragment14, jsx as jsx30, jsxs as jsxs26 } from "react/jsx-runtime";
3496
3513
  var SEARCH_AT = 10;
@@ -3499,8 +3516,8 @@ function FilterBar({ filters, label = "Filters", clearLabel = "Clear all", clear
3499
3516
  const bar = useRef16(null);
3500
3517
  const focused = useRef16(null);
3501
3518
  const landing = useRef16(null);
3502
- const [opened, setOpened] = useState12({});
3503
- const [adding, setAdding] = useState12(false);
3519
+ const [opened, setOpened] = useState13({});
3520
+ const [adding, setAdding] = useState13(false);
3504
3521
  const blocked = disabled || busy;
3505
3522
  const offer = (add || []).filter((entry) => !filters.some((filter) => filter.id === entry.id));
3506
3523
  const source = /* @__PURE__ */ new Map();
@@ -3656,10 +3673,10 @@ function DrawerSection({ title, headingLevel = 3, className, children, ...rest }
3656
3673
  }
3657
3674
 
3658
3675
  // src/Snippet.tsx
3659
- import { useEffect as useEffect13, useRef as useRef17, useState as useState13 } from "react";
3676
+ import { useEffect as useEffect13, useRef as useRef17, useState as useState14 } from "react";
3660
3677
  import { Fragment as Fragment15, jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
3661
3678
  function Snippet({ label = "shell", code = "", children, copy = true, reveal = false, copyLabel = "Copy code" }) {
3662
- const [status, setStatus] = useState13("idle");
3679
+ const [status, setStatus] = useState14("idle");
3663
3680
  const request = useRef17(0);
3664
3681
  const timer = useRef17(void 0);
3665
3682
  useEffect13(() => {
@@ -3755,7 +3772,7 @@ function Timeline({ events, className, ...rest }) {
3755
3772
  }
3756
3773
 
3757
3774
  // src/Field.tsx
3758
- import { forwardRef as forwardRef8, useEffect as useEffect15, useId as useId12, useRef as useRef19, useState as useState14 } from "react";
3775
+ import { forwardRef as forwardRef8, useEffect as useEffect15, useId as useId12, useRef as useRef19, useState as useState15 } from "react";
3759
3776
  import { esc, icon as icon5 } from "@apliteni/apliteni-ui";
3760
3777
  import { jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
3761
3778
  function messages(id, hint, error) {
@@ -3845,8 +3862,8 @@ function SelectField({ label, hint, error, required, className = "", children, .
3845
3862
  function FileField({ label, hint, error, required, disabled, onFileChange, className = "", ...props }) {
3846
3863
  const id = useId12();
3847
3864
  const input = useRef19(null);
3848
- const [file, setFile] = useState14(null);
3849
- const [dragging, setDragging] = useState14(false);
3865
+ const [file, setFile] = useState15(null);
3866
+ const [dragging, setDragging] = useState15(false);
3850
3867
  useEffect15(() => {
3851
3868
  const form = input.current?.form;
3852
3869
  const reset = () => {
@@ -3906,7 +3923,7 @@ function FileField({ label, hint, error, required, disabled, onFileChange, class
3906
3923
  }
3907
3924
 
3908
3925
  // src/FileDrop.tsx
3909
- import { useRef as useRef20, useState as useState15 } from "react";
3926
+ import { useRef as useRef20, useState as useState16 } from "react";
3910
3927
 
3911
3928
  // src/EmptyState.tsx
3912
3929
  import { icon as kitIcon3, illo } from "@apliteni/apliteni-ui";
@@ -3968,7 +3985,7 @@ function FileDrop({
3968
3985
  className
3969
3986
  }) {
3970
3987
  const input = useRef20(null);
3971
- const [over, setOver] = useState15(false);
3988
+ const [over, setOver] = useState16(false);
3972
3989
  const status = file?.status ?? "uploading";
3973
3990
  const word = status === "error" ? file?.error ?? WORDS.error : file?.state ?? WORDS[status];
3974
3991
  const [stem, ext] = splitName(file?.name ?? "");
@@ -4139,7 +4156,7 @@ var SearchField = forwardRef9(function SearchField2({ ariaLabel, className, ...p
4139
4156
  });
4140
4157
 
4141
4158
  // src/Toast.tsx
4142
- import { createContext as createContext3, useCallback as useCallback6, useContext as useContext3, useEffect as useEffect16, useLayoutEffect as useLayoutEffect4, useRef as useRef21, useState as useState16 } from "react";
4159
+ import { createContext as createContext4, useCallback as useCallback7, useContext as useContext3, useEffect as useEffect16, useLayoutEffect as useLayoutEffect4, useRef as useRef21, useState as useState17 } from "react";
4143
4160
  import { createPortal as createPortal6 } from "react-dom";
4144
4161
 
4145
4162
  // src/lib/toast-stack.ts
@@ -4250,8 +4267,8 @@ function watchToastPile(stack2) {
4250
4267
 
4251
4268
  // src/Toast.tsx
4252
4269
  import { jsx as jsx38, jsxs as jsxs34 } from "react/jsx-runtime";
4253
- var Context = createContext3(null);
4254
- var PileHoldContext = createContext3(false);
4270
+ var Context = createContext4(null);
4271
+ var PileHoldContext = createContext4(false);
4255
4272
  var glyphs = { success: "circleCheck", danger: "circleX", warn: "circleAlert", info: "info", neutral: "bolt" };
4256
4273
  function useToast() {
4257
4274
  const push = useContext3(Context);
@@ -4260,17 +4277,17 @@ function useToast() {
4260
4277
  }
4261
4278
  function Notice({ notice, remove }) {
4262
4279
  const root = useRef21(null);
4263
- const [leaving2, setLeaving] = useState16(false);
4280
+ const [leaving2, setLeaving] = useState17(false);
4264
4281
  const dismissed = useRef21(false);
4265
- const [hovered, setHovered] = useState16(false);
4266
- const [focused, setFocused] = useState16(false);
4282
+ const [hovered, setHovered] = useState17(false);
4283
+ const [focused, setFocused] = useState17(false);
4267
4284
  const pileHeld = useContext3(PileHoldContext);
4268
4285
  const paused = hovered || focused || pileHeld;
4269
4286
  const tone2 = notice.tone ?? "success";
4270
4287
  const timed = !notice.action && notice.timer !== false && notice.timer !== 0;
4271
4288
  const duration = typeof notice.timer === "number" ? notice.timer * 1e3 : 5e3;
4272
4289
  const remaining = useRef21(duration);
4273
- const dismiss = useCallback6(() => {
4290
+ const dismiss = useCallback7(() => {
4274
4291
  if (dismissed.current) return;
4275
4292
  dismissed.current = true;
4276
4293
  if (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches) remove();
@@ -4378,12 +4395,12 @@ function usePile(stack2, piled, count) {
4378
4395
  }, [stack2, piled, count]);
4379
4396
  }
4380
4397
  function Toast({ children, collapse = false }) {
4381
- const [entries, setEntries] = useState16([]);
4382
- const [pileHovered, setPileHovered] = useState16(false);
4383
- const [pileFocused, setPileFocused] = useState16(false);
4398
+ const [entries, setEntries] = useState17([]);
4399
+ const [pileHovered, setPileHovered] = useState17(false);
4400
+ const [pileFocused, setPileFocused] = useState17(false);
4384
4401
  const nextId = useRef21(0);
4385
4402
  const stack2 = useRef21(null);
4386
- const push = useCallback6((notice) => {
4403
+ const push = useCallback7((notice) => {
4387
4404
  const id = nextId.current++;
4388
4405
  const remove = () => setEntries((current) => current.filter((entry) => entry.id !== id));
4389
4406
  setEntries((current) => [...current, { id, notice, remove }]);
@@ -4419,7 +4436,7 @@ function Toast({ children, collapse = false }) {
4419
4436
  }
4420
4437
 
4421
4438
  // src/AppShell.tsx
4422
- import { useEffect as useEffect18, useId as useId13, useMemo as useMemo4, useRef as useRef23, useState as useState18 } from "react";
4439
+ import { useEffect as useEffect18, useId as useId13, useMemo as useMemo5, useRef as useRef23, useState as useState19 } from "react";
4423
4440
  import { prism } from "@apliteni/apliteni-ui";
4424
4441
 
4425
4442
  // src/lib/palette-hotkey.ts
@@ -4449,7 +4466,7 @@ function storeRailCollapsed(collapsed) {
4449
4466
  }
4450
4467
 
4451
4468
  // src/AccountMenu.tsx
4452
- import { useEffect as useEffect17, useRef as useRef22, useState as useState17 } from "react";
4469
+ import { useEffect as useEffect17, useRef as useRef22, useState as useState18 } from "react";
4453
4470
  import { createPortal as createPortal7 } from "react-dom";
4454
4471
  import { icon as icon7, themeIcon as themeIcon2, transitionMs as transitionMs3 } from "@apliteni/apliteni-ui";
4455
4472
 
@@ -4535,8 +4552,8 @@ var THEMES = [["auto", "Auto"], ["light", "Light"], ["dark", "Dark"]];
4535
4552
  var glyph = (svg, className) => /* @__PURE__ */ jsx40("span", { className, "aria-hidden": "true", dangerouslySetInnerHTML: { __html: svg } });
4536
4553
  function AccountMenu({ account, items, onSelect, withTheme, inPlace, away }) {
4537
4554
  const theme = useThemeChoice();
4538
- const [open, setOpen] = useState17(false);
4539
- const [sub, setSub] = useState17(false);
4555
+ const [open, setOpen] = useState18(false);
4556
+ const [sub, setSub] = useState18(false);
4540
4557
  const block = useRef22(null);
4541
4558
  const themeRow = useRef22(null);
4542
4559
  const list = useRef22(null);
@@ -4727,15 +4744,16 @@ function AppShell({
4727
4744
  searchLabel = "Search or run a command\u2026",
4728
4745
  defaultCollapsed = false,
4729
4746
  palette,
4747
+ onNavigate,
4730
4748
  renderLink
4731
4749
  }) {
4732
4750
  const uid = useId13();
4733
- const [collapsed, setCollapsed] = useState18(defaultCollapsed);
4734
- const [search, setSearch] = useState18(false);
4735
- const [menu, setMenu] = useState18(false);
4751
+ const [collapsed, setCollapsed] = useState19(defaultCollapsed);
4752
+ const [search, setSearch] = useState19(false);
4753
+ const [menu, setMenu] = useState19(false);
4736
4754
  const menuButton = useRef23(null);
4737
4755
  const menuBody = useRef23(null);
4738
- const firstRow = useMemo4(() => ({ get current() {
4756
+ const firstRow = useMemo5(() => ({ get current() {
4739
4757
  return menuBody.current?.querySelector(".ui-nav__item") ?? null;
4740
4758
  } }), []);
4741
4759
  const current = path(pathname);
@@ -4962,7 +4980,7 @@ function AppShell({
4962
4980
  ] })
4963
4981
  }
4964
4982
  ),
4965
- /* @__PURE__ */ jsx41(CommandPalette, { ...palette ?? { groups: [{ items: sections.map((section) => ({ id: section.href, ...section })) }] }, open: search, onClose: () => setSearch(false) })
4983
+ /* @__PURE__ */ jsx41(CommandPalette, { ...palette ?? { groups: [{ items: sections.map((section) => ({ id: section.href, ...section })) }] }, onNavigate: palette?.onNavigate ?? onNavigate, open: search, onClose: () => setSearch(false) })
4966
4984
  ] });
4967
4985
  }
4968
4986
 
@@ -5047,7 +5065,7 @@ function Footer({
5047
5065
  }
5048
5066
 
5049
5067
  // src/Success.tsx
5050
- import { forwardRef as forwardRef11, useEffect as useEffect19, useRef as useRef24, useState as useState19 } from "react";
5068
+ import { forwardRef as forwardRef11, useEffect as useEffect19, useRef as useRef24, useState as useState20 } from "react";
5051
5069
  import { jsx as jsx44, jsxs as jsxs40 } from "react/jsx-runtime";
5052
5070
  var SuccessCheck = forwardRef11(function SuccessCheck2({ variant = "line", className, ...rest }, ref) {
5053
5071
  const circled = variant === "circled";
@@ -5094,7 +5112,7 @@ var pieces = [
5094
5112
  [80, 0.36, -20, "c", 1.05]
5095
5113
  ];
5096
5114
  function Countdown({ seconds, label = "Redirecting", onDone }) {
5097
- const [remaining, setRemaining] = useState19(seconds);
5115
+ const [remaining, setRemaining] = useState20(seconds);
5098
5116
  const callback = useRef24(onDone);
5099
5117
  useEffect19(() => {
5100
5118
  callback.current = onDone;
@@ -5171,14 +5189,16 @@ var Success = forwardRef11(function Success2({
5171
5189
 
5172
5190
  // src/Chart.tsx
5173
5191
  import {
5174
- useCallback as useCallback7,
5192
+ useCallback as useCallback8,
5193
+ useContext as useContext4,
5175
5194
  useEffect as useEffect20,
5176
5195
  useId as useId15,
5177
5196
  useLayoutEffect as useLayoutEffect5,
5178
- useMemo as useMemo5,
5197
+ useMemo as useMemo6,
5179
5198
  useRef as useRef25,
5180
- useState as useState20
5199
+ useState as useState21
5181
5200
  } from "react";
5201
+ import { createPortal as createPortal8 } from "react-dom";
5182
5202
  import { CHART_FLOOR, bridgeWalk, chartScale, pointTarget } from "@apliteni/apliteni-ui";
5183
5203
 
5184
5204
  // src/chart-looks.tsx
@@ -5226,7 +5246,22 @@ function rightRounded(x, y, w, h, r) {
5226
5246
  return `M${px(x)} ${px(y)}H${px(x + w - k)}A${px(k)} ${px(k)} 0 0 1 ${px(x + w)} ${px(y + k)}V${px(y + h - k)}A${px(k)} ${px(k)} 0 0 1 ${px(x + w - k)} ${px(y + h)}H${px(x)}Z`;
5227
5247
  }
5228
5248
  var square = (x, y, w, h) => `M${px(x)} ${px(y)}h${px(w)}v${px(h)}h${px(-w)}Z`;
5229
- var keyShape = (look) => look.variant === "line" || look.variant === "area" && look.look === "flat" ? "line" : "fill";
5249
+ var overlaps = (look) => look === "flat" || look === "curves";
5250
+ var keyShape = (look) => look.variant === "line" || look.variant === "area" && overlaps(look.look) ? "line" : "fill";
5251
+ function monotone(xs, ys) {
5252
+ const s = xs.slice(1).map((x, k) => (ys[k + 1] - ys[k]) / (x - xs[k]));
5253
+ if (s.length < 2) return ys.map(() => s[0] ?? 0);
5254
+ const t = ys.map((_, i) => {
5255
+ if (i === 0 || i === ys.length - 1) return 0;
5256
+ const [s0, s1] = [s[i - 1], s[i]];
5257
+ const [h0, h1] = [xs[i] - xs[i - 1], xs[i + 1] - xs[i]];
5258
+ const p = (s0 * h1 + s1 * h0) / (h0 + h1);
5259
+ return (Math.sign(s0) + Math.sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), Math.abs(p) / 2);
5260
+ });
5261
+ t[0] = (3 * s[0] - t[1]) / 2;
5262
+ t[t.length - 1] = (3 * s[s.length - 1] - t[t.length - 2]) / 2;
5263
+ return t;
5264
+ }
5230
5265
  function columnRows(g, i) {
5231
5266
  const { look, format } = g;
5232
5267
  const shape = keyShape(look);
@@ -5317,7 +5352,7 @@ function lookMarks(g) {
5317
5352
  };
5318
5353
  });
5319
5354
  }
5320
- const lift = look.variant === "line" && look.look === "points" ? 6 : look.variant === "stacked" ? 2 : 4;
5355
+ const lift = look.variant === "line" && look.look === "points" || look.look === "curves" ? 6 : look.variant === "stacked" ? 2 : 4;
5321
5356
  return g.labels.map((label, i) => {
5322
5357
  const tops = look.layers.map((l) => l.to[i]).filter(Number.isFinite);
5323
5358
  const top = tops.length ? Math.max(...tops) : g.scale.min;
@@ -5353,16 +5388,52 @@ function linesDrawing(g, open) {
5353
5388
  const area = look.variant === "area";
5354
5389
  const finite = (layer, i) => Number.isFinite(look.stacked ? layer.to[i] : layer.values[i]);
5355
5390
  const at = (layer, i) => look.stacked ? layer.to[i] : layer.values[i];
5391
+ const curves = area && look.look === "curves";
5356
5392
  const ramps = area && !look.share ? look.layers.map((layer) => {
5357
5393
  const tops = layer.values.map((_, i) => at(layer, i)).filter(Number.isFinite);
5358
- const lo = Math.min(...tops);
5394
+ const lo = curves ? 0 : Math.min(...tops);
5359
5395
  const hi = Math.max(...tops);
5360
5396
  return tops.length && y(lo) - y(hi) >= 1 ? { id: `${g.uid}-ramp-${layer.id}`, layer, lo, hi } : null;
5361
5397
  }) : [];
5398
+ const runs = (layer) => [...Array(n).keys()].reduce((out, i) => {
5399
+ if (!finite(layer, i)) return out;
5400
+ if (finite(layer, i - 1)) out[out.length - 1].push(i);
5401
+ else out.push([i]);
5402
+ return out;
5403
+ }, []);
5404
+ const tangents = curves ? look.layers.map((layer) => {
5405
+ const t = new Array(n).fill(0);
5406
+ for (const run of runs(layer)) {
5407
+ monotone(run.map(centre), run.map((i) => y(at(layer, i)))).forEach((v, k) => {
5408
+ t[run[k]] = v;
5409
+ });
5410
+ }
5411
+ return t;
5412
+ }) : [];
5413
+ const bend = (k, i) => {
5414
+ const layer = look.layers[k];
5415
+ const h = (centre(i + 1) - centre(i)) / 3;
5416
+ return `C${px(centre(i) + h)} ${px(y(at(layer, i)) + h * tangents[k][i])} ${px(centre(i + 1) - h)} ${px(y(at(layer, i + 1)) - h * tangents[k][i + 1])} ${px(centre(i + 1))} ${px(y(at(layer, i + 1)))}`;
5417
+ };
5362
5418
  const fills = area && look.layers.map((layer, k) => {
5363
5419
  const up = layer.to.map((v, i) => `${i ? "L" : "M"}${px(centre(i))} ${px(y(Number.isFinite(v) ? v : layer.from[i]))}`);
5364
5420
  const down = layer.from.map((v, i) => `L${px(centre(i))} ${px(y(v))}`).reverse();
5365
5421
  const ramp = ramps[k];
5422
+ if (curves) {
5423
+ const d = runs(layer).filter((run) => run.length > 1).map((run) => {
5424
+ const [a, b] = [run[0], run[run.length - 1]];
5425
+ return `M${px(centre(a))} ${px(y(layer.from[a]))}L${px(centre(a))} ${px(y(at(layer, a)))}${run.slice(0, -1).map((i) => bend(k, i)).join("")}L${px(centre(b))} ${px(y(layer.from[b]))}Z`;
5426
+ }).join("");
5427
+ return d && /* @__PURE__ */ jsx45(
5428
+ "path",
5429
+ {
5430
+ className: cx8("ui-chart__area", tone(layer.tone)),
5431
+ style: ramp ? { "--ui-chart-paint": `url(#${ramp.id})` } : void 0,
5432
+ d
5433
+ },
5434
+ `fill-${layer.id}`
5435
+ );
5436
+ }
5366
5437
  return /* @__PURE__ */ jsx45(
5367
5438
  "path",
5368
5439
  {
@@ -5373,7 +5444,18 @@ function linesDrawing(g, open) {
5373
5444
  `fill-${layer.id}`
5374
5445
  );
5375
5446
  });
5376
- const edges = !look.share && look.layers.flatMap((layer) => layer.to.slice(1).map((_, k) => finite(layer, k) && finite(layer, k + 1) ? /* @__PURE__ */ jsx45(
5447
+ const edges = curves ? look.layers.flatMap((layer, k) => layer.to.slice(1).map((_, i) => finite(layer, i) && finite(layer, i + 1) ? /* @__PURE__ */ jsx45(
5448
+ "path",
5449
+ {
5450
+ className: cx8(
5451
+ "ui-chart__line",
5452
+ tone(layer.tone),
5453
+ (labels[i]?.estimated || labels[i + 1]?.estimated) && "is-estimated"
5454
+ ),
5455
+ d: `M${px(centre(i))} ${px(y(at(layer, i)))}${bend(k, i)}`
5456
+ },
5457
+ `edge-${layer.id}-${i}`
5458
+ ) : null)) : !look.share && look.layers.flatMap((layer) => layer.to.slice(1).map((_, k) => finite(layer, k) && finite(layer, k + 1) ? /* @__PURE__ */ jsx45(
5377
5459
  "line",
5378
5460
  {
5379
5461
  className: cx8(
@@ -5388,7 +5470,7 @@ function linesDrawing(g, open) {
5388
5470
  },
5389
5471
  `edge-${layer.id}-${k}`
5390
5472
  ) : null));
5391
- const points = look.variant === "line" && look.look === "points";
5473
+ const points = look.variant === "line" && look.look === "points" || curves;
5392
5474
  const dots = look.layers.flatMap((layer) => layer.to.map((_, i) => {
5393
5475
  if (!finite(layer, i)) return null;
5394
5476
  const lonely = !finite(layer, i - 1) && !finite(layer, i + 1);
@@ -5457,8 +5539,8 @@ function linesDrawing(g, open) {
5457
5539
  y1: px(y(ramp.lo)),
5458
5540
  y2: px(y(ramp.hi)),
5459
5541
  children: [
5460
- /* @__PURE__ */ jsx45("stop", { className: "ui-chart__fade-base", offset: "0" }),
5461
- /* @__PURE__ */ jsx45("stop", { className: "ui-chart__fade-end", offset: "1" })
5542
+ /* @__PURE__ */ jsx45("stop", { className: curves ? "ui-chart__wash-floor" : "ui-chart__fade-base", offset: "0" }),
5543
+ /* @__PURE__ */ jsx45("stop", { className: curves ? "ui-chart__wash-top" : "ui-chart__fade-end", offset: "1" })
5462
5544
  ]
5463
5545
  },
5464
5546
  ramp.id
@@ -5661,7 +5743,7 @@ function barPath(m) {
5661
5743
  return `M${px2(x)} ${px2(roundBottom ? bottom - r : bottom)}V${px2(roundTop ? top + r : top)}` + (roundTop ? `${arc2(r, -r, 1)}h${px2(w - r * 2)}${arc2(r, r, 1)}` : `h${px2(w)}`) + `V${px2(roundBottom ? bottom - r : bottom)}` + (roundBottom ? `${arc2(-r, r, 1)}h${px2(-(w - r * 2))}${arc2(-r, -r, 1)}` : `h${px2(-w)}`) + "z";
5662
5744
  }
5663
5745
  function useTapFloor() {
5664
- const [floor, setFloor] = useState20(TARGET);
5746
+ const [floor, setFloor] = useState21(TARGET);
5665
5747
  useEffect20(() => {
5666
5748
  const query = typeof window === "undefined" ? null : window.matchMedia?.(`(max-width: ${PHONE_MAX2}px) and (pointer: coarse)`);
5667
5749
  if (!query) return;
@@ -5775,7 +5857,7 @@ function noNegative(variant, values) {
5775
5857
  function lookFrame(variant, look, periods, series, format) {
5776
5858
  if (variant !== "line") noNegative(variant, series.flatMap((s) => s.values.map((value2) => ({ name: s.name, value: value2 }))));
5777
5859
  const columns = periods.map((p) => columnOf(p, p.label.split(" ")[0]));
5778
- const stacked = variant === "stacked" || look !== "flat" && variant === "area";
5860
+ const stacked = variant === "stacked" || variant === "area" && !overlaps(look);
5779
5861
  const share = look === "share";
5780
5862
  const n = columns.length;
5781
5863
  const value = (s, i) => Number.isFinite(s.values[i]) ? s.values[i] : Number.NaN;
@@ -5897,10 +5979,14 @@ function Chart(props) {
5897
5979
  const spark = variant === "spark";
5898
5980
  const plotHeight = height ?? HEIGHT[variant];
5899
5981
  const showTable = table ?? !spark;
5900
- const [view, setView] = useState20("chart");
5982
+ const [view, setView] = useState21("chart");
5901
5983
  const asTable = showTable && view === "table";
5902
5984
  const uid = useId15().replace(/[^\w-]/g, "");
5903
5985
  const frameEl = useRef25(null);
5986
+ const card = useContext4(CardTools);
5987
+ const claim = card?.claim;
5988
+ useLayoutEffect5(() => showTable && claim ? claim(uid) : void 0, [showTable, claim, uid]);
5989
+ const toCard = showTable && card?.owner === uid ? card.slot : null;
5904
5990
  const scroller = useRef25(null);
5905
5991
  const plot = useRef25(null);
5906
5992
  const tipEl = useRef25(null);
@@ -5911,11 +5997,12 @@ function Chart(props) {
5911
5997
  const opening = useRef25(false);
5912
5998
  const pointerFocus = useRef25(false);
5913
5999
  const floor = useTapFloor();
5914
- const [width, setWidth] = useState20(0);
5915
- const [openId, setOpenId] = useState20(null);
5916
- const [rawCursor, setCursor] = useState20(0);
5917
- const [said, setSaid] = useState20("");
5918
- const [ownPick, setOwnPick] = useState20(null);
6000
+ const [width, setWidth] = useState21(0);
6001
+ const [overflows, setOverflows] = useState21(false);
6002
+ const [openId, setOpenId] = useState21(null);
6003
+ const [rawCursor, setCursor] = useState21(0);
6004
+ const [said, setSaid] = useState21("");
6005
+ const [ownPick, setOwnPick] = useState21(null);
5919
6006
  const pick = selected === void 0 ? ownPick : selected;
5920
6007
  const steps = props.variant === "bridge" ? props.steps : void 0;
5921
6008
  const bridgeTones = props.variant === "bridge" ? props.tones : void 0;
@@ -5924,7 +6011,7 @@ function Chart(props) {
5924
6011
  const slices = props.variant === "donut" ? props.slices : void 0;
5925
6012
  const totalLabel = props.variant === "donut" ? props.totalLabel ?? "Total" : "Total";
5926
6013
  const lookName = props.variant === "line" || props.variant === "area" || props.variant === "stacked" || props.variant === "donut" ? props.look ?? LOOK_DEFAULT[props.variant] : void 0;
5927
- const frame = useMemo5(() => {
6014
+ const frame = useMemo6(() => {
5928
6015
  if (steps) return bridgeFrame(steps, bridgeTones, format);
5929
6016
  if (slices) return donutFrame(lookName, slices, totalLabel, format);
5930
6017
  if (lookName) return lookFrame(variant, lookName, periods ?? [], series ?? [], format);
@@ -5939,7 +6026,7 @@ function Chart(props) {
5939
6026
  const boxHeight = Math.max(plotHeight, floor);
5940
6027
  const boxTop = -(boxHeight - plotHeight) / 2;
5941
6028
  const span = scale.max - scale.min || 1;
5942
- const y = useCallback7(
6029
+ const y = useCallback8(
5943
6030
  (value) => PAD + (scale.max - value) / span * (plotHeight - PAD * 2),
5944
6031
  [scale.max, span, plotHeight]
5945
6032
  );
@@ -5952,9 +6039,9 @@ function Chart(props) {
5952
6039
  cap * lanes + LANE_GAP * (lanes - 1)
5953
6040
  ));
5954
6041
  const barWidth = (groupWidth - LANE_GAP * (lanes - 1)) / lanes;
5955
- const centre = useCallback7((column) => column * colWidth + colWidth / 2, [colWidth]);
6042
+ const centre = useCallback8((column) => column * colWidth + colWidth / 2, [colWidth]);
5956
6043
  const axisFormat = look?.share ? pct : formatAxis;
5957
- const geometry = useMemo5(() => look ? {
6044
+ const geometry = useMemo6(() => look ? {
5958
6045
  look,
5959
6046
  uid,
5960
6047
  labels: columns,
@@ -5971,7 +6058,7 @@ function Chart(props) {
5971
6058
  formatAxis: axisFormat
5972
6059
  } : null, [look, uid, columns, plotWidth, plotHeight, colWidth, floor, y, centre, scale, format, axisFormat]);
5973
6060
  const box = geometry ? lookBox(geometry) : null;
5974
- const marks = useMemo5(() => {
6061
+ const marks = useMemo6(() => {
5975
6062
  if (geometry) return lookMarks(geometry);
5976
6063
  const out = frame.bars.map((bar) => {
5977
6064
  let top = Math.min(y(bar.from), y(bar.to));
@@ -6044,18 +6131,23 @@ function Chart(props) {
6044
6131
  }
6045
6132
  return [...out, ...dots];
6046
6133
  }, [geometry, frame, lines, keys, columns, centre, barWidth, groupWidth, y, floor, colWidth, plotWidth, boxTop, boxHeight]);
6047
- const byId = useMemo5(() => new Map(marks.map((m) => [m.id, m])), [marks]);
6048
- const fades = useMemo5(() => new Map(marks.filter((m) => m.kind === "bar").map((m) => fadeOf(uid, m, variant === "bridge")).filter((f) => f !== null).map((f) => [f.id, f])), [marks, uid, variant]);
6049
- const lead = useCallback7((column) => marks.find((m) => m.column === column), [marks]);
6134
+ const byId = useMemo6(() => new Map(marks.map((m) => [m.id, m])), [marks]);
6135
+ const fades = useMemo6(() => new Map(marks.filter((m) => m.kind === "bar").map((m) => fadeOf(uid, m, variant === "bridge")).filter((f) => f !== null).map((f) => [f.id, f])), [marks, uid, variant]);
6136
+ const lead = useCallback8((column) => marks.find((m) => m.column === column), [marks]);
6050
6137
  const open = openId ? byId.get(openId) : void 0;
6051
6138
  useEffect20(() => {
6052
6139
  const el = plot.current;
6053
- if (!el) return;
6054
- const read = () => setWidth(el.clientWidth);
6140
+ const box2 = scroller.current;
6141
+ if (!el || !box2) return;
6142
+ const read = () => {
6143
+ setWidth(el.clientWidth);
6144
+ setOverflows(box2.scrollWidth > box2.clientWidth);
6145
+ };
6055
6146
  read();
6056
6147
  if (typeof ResizeObserver === "undefined") return;
6057
6148
  const observer = new ResizeObserver(read);
6058
6149
  observer.observe(el);
6150
+ observer.observe(box2);
6059
6151
  return () => observer.disconnect();
6060
6152
  }, []);
6061
6153
  const opensAtEnd = variant === "line" && lookName === "labels";
@@ -6096,7 +6188,7 @@ function Chart(props) {
6096
6188
  setOpenId(id);
6097
6189
  };
6098
6190
  const markAt = (target) => target.closest?.("[data-mark]")?.getAttribute("data-mark") ?? null;
6099
- const announce = useCallback7((column, picked = pick) => {
6191
+ const announce = useCallback8((column, picked = pick) => {
6100
6192
  const where = columns[column];
6101
6193
  if (!where) return;
6102
6194
  const values = marks.filter((m) => m.column === column).map((m) => {
@@ -6123,6 +6215,7 @@ function Chart(props) {
6123
6215
  onSelect?.(column);
6124
6216
  };
6125
6217
  const onKeyDown = (event) => {
6218
+ if (event.target !== event.currentTarget) return;
6126
6219
  const steps2 = {
6127
6220
  ArrowLeft: cursor - 1,
6128
6221
  ArrowRight: cursor + 1,
@@ -6154,6 +6247,19 @@ function Chart(props) {
6154
6247
  "Estimated"
6155
6248
  ] })
6156
6249
  ] });
6250
+ const viewSwitch = showTable && /* @__PURE__ */ jsx46(
6251
+ Segmented,
6252
+ {
6253
+ size: "sm",
6254
+ label: `${title}, view`,
6255
+ value: view,
6256
+ onChange: (next) => setView(next),
6257
+ options: [
6258
+ { value: "chart", label: "Chart", icon: "chart", iconOnly: true },
6259
+ { value: "table", label: "Table", icon: "table", iconOnly: true }
6260
+ ]
6261
+ }
6262
+ );
6157
6263
  const noun = look?.layout === "ring" ? "slices" : look?.layout === "rows" ? "rows" : "columns";
6158
6264
  return /* @__PURE__ */ jsxs42(
6159
6265
  "div",
@@ -6172,21 +6278,10 @@ function Chart(props) {
6172
6278
  "--ui-chart-pad": `${PAD}px`
6173
6279
  },
6174
6280
  children: [
6175
- (showTable || legendFirst && legend) && /* @__PURE__ */ jsxs42("div", { className: "ui-chart__head", children: [
6281
+ toCard && createPortal8(viewSwitch, toCard),
6282
+ (showTable && !toCard || legendFirst && legend) && /* @__PURE__ */ jsxs42("div", { className: "ui-chart__head", children: [
6176
6283
  legendFirst && legend,
6177
- showTable && /* @__PURE__ */ jsx46(
6178
- Segmented,
6179
- {
6180
- size: "sm",
6181
- label: `${title}, view`,
6182
- value: view,
6183
- onChange: (next) => setView(next),
6184
- options: [
6185
- { value: "chart", label: "Chart", icon: "chart", iconOnly: true },
6186
- { value: "table", label: "Table", icon: "table", iconOnly: true }
6187
- ]
6188
- }
6189
- )
6284
+ !toCard && viewSwitch
6190
6285
  ] }),
6191
6286
  /* @__PURE__ */ jsxs42(
6192
6287
  "div",
@@ -6214,226 +6309,237 @@ function Chart(props) {
6214
6309
  },
6215
6310
  children: [
6216
6311
  !spark && columnsLayout && scale.ticks.length > 0 && /* @__PURE__ */ jsx46("div", { className: "ui-chart__axis", "aria-hidden": "true", children: [...scale.ticks].reverse().map((tick) => /* @__PURE__ */ jsx46("span", { className: "ui-chart__tick", children: axisFormat(tick) }, tick)) }),
6217
- /* @__PURE__ */ jsx46("div", { ref: scroller, className: "ui-chart__scroll", tabIndex: -1, onScroll: () => {
6218
- const anchor = [...svgEl.current?.querySelectorAll("[data-anchor]") ?? []].find((el) => el.getAttribute("data-anchor") === openId);
6219
- if (!anchor || !scroller.current || !frameEl.current || !tipEl.current) return;
6220
- const mark = anchor.getBoundingClientRect();
6221
- const view2 = scroller.current.getBoundingClientRect();
6222
- if (mark.right <= view2.left || mark.left >= view2.right) setOpenId(null);
6223
- else placeTip(frameEl.current, anchor, tipEl.current, frameEl.current);
6224
- }, children: /* @__PURE__ */ jsxs42("div", { ref: plot, className: "ui-chart__plot", children: [
6225
- /* @__PURE__ */ jsxs42(
6226
- "svg",
6227
- {
6228
- ref: svgEl,
6229
- className: "ui-chart__svg",
6230
- width: px2(plotWidth),
6231
- height: px2(boxHeight),
6232
- viewBox: `0 ${px2(boxTop)} ${px2(plotWidth)} ${px2(boxHeight)}`,
6233
- ...box && { width: px2(box.w), height: px2(box.h), viewBox: `0 0 ${px2(box.w)} ${px2(box.h)}` },
6234
- role: "img",
6235
- "aria-label": spark && marks.length > 0 ? `${title}. ${format(marks[0].value)} to ${format(marks[marks.length - 1].value)}.` : title,
6236
- onMouseMove: (event) => {
6237
- if (Date.now() < ignoreMouseUntil.current) return;
6238
- show(markAt(event.target));
6239
- },
6240
- onMouseLeave: () => {
6241
- if (Date.now() < ignoreMouseUntil.current) return;
6242
- dismissed.current = null;
6243
- setOpenId(null);
6244
- },
6245
- onTouchStart: () => {
6246
- ignoreMouseUntil.current = Date.now() + 800;
6247
- touchMoved.current = false;
6248
- },
6249
- onTouchMove: () => {
6250
- touchMoved.current = true;
6251
- },
6252
- onTouchCancel: () => {
6253
- touchMoved.current = true;
6254
- },
6255
- onTouchEnd: (event) => {
6256
- ignoreMouseUntil.current = Date.now() + 800;
6257
- if (touchMoved.current) return;
6258
- const id = markAt(event.target);
6259
- if (id && id === openId) {
6260
- opening.current = false;
6261
- setOpenId(null);
6262
- } else {
6263
- opening.current = Boolean(id) && dismissed.current !== id;
6264
- show(id);
6265
- }
6266
- },
6267
- onPointerDown: () => {
6268
- pointerFocus.current = true;
6269
- },
6270
- onClick: (event) => {
6271
- frameEl.current?.focus();
6272
- pointerFocus.current = false;
6273
- const opened = opening.current;
6274
- opening.current = false;
6275
- const mark = byId.get(markAt(event.target) ?? "");
6276
- if (!mark) return;
6277
- setCursor(mark.column);
6278
- if (opened) {
6279
- announce(mark.column);
6280
- return;
6281
- }
6282
- choose(mark.column);
6283
- announce(mark.column, selectable ? mark.column : pick);
6284
- },
6285
- children: [
6286
- !spark && columnsLayout && pick !== null && pick >= 0 && pick < count && /* @__PURE__ */ jsx46(
6287
- "rect",
6288
- {
6289
- className: "ui-chart__band",
6290
- x: px2(pick * colWidth),
6291
- width: px2(colWidth),
6292
- y: "0",
6293
- height: px2(plotHeight)
6294
- }
6295
- ),
6296
- frame.links && frame.bars.slice(0, -1).map((bar, i) => {
6297
- const from = byId.get(bar.id);
6298
- const to = byId.get(frame.bars[i + 1].id);
6299
- return from && to ? /* @__PURE__ */ jsx46(
6300
- "line",
6301
- {
6302
- className: "ui-chart__carry",
6303
- x1: px2(from.x + from.w),
6304
- x2: px2(to.x),
6305
- y1: px2(y(bar.to)),
6306
- y2: px2(y(bar.to))
6307
- },
6308
- `carry-${bar.id}`
6309
- ) : null;
6310
- }),
6311
- !spark && columnsLayout && scale.ticks.filter((tick) => tick !== 0).map((tick) => /* @__PURE__ */ jsx46(
6312
- "line",
6313
- {
6314
- className: "ui-chart__grid",
6315
- x1: "0",
6316
- x2: px2(plotWidth),
6317
- y1: px2(y(tick)),
6318
- y2: px2(y(tick))
6312
+ /* @__PURE__ */ jsx46(
6313
+ "div",
6314
+ {
6315
+ ref: scroller,
6316
+ className: cx9("ui-chart__scroll", overflows && "ui-focusable"),
6317
+ tabIndex: overflows ? 0 : -1,
6318
+ role: overflows ? "region" : void 0,
6319
+ "aria-label": overflows ? `${title}. Scroll for more ${noun}.` : void 0,
6320
+ onScroll: () => {
6321
+ const anchor = [...svgEl.current?.querySelectorAll("[data-anchor]") ?? []].find((el) => el.getAttribute("data-anchor") === openId);
6322
+ if (!anchor || !scroller.current || !frameEl.current || !tipEl.current) return;
6323
+ const mark = anchor.getBoundingClientRect();
6324
+ const view2 = scroller.current.getBoundingClientRect();
6325
+ if (mark.right <= view2.left || mark.left >= view2.right) setOpenId(null);
6326
+ else placeTip(frameEl.current, anchor, tipEl.current, frameEl.current);
6327
+ },
6328
+ children: /* @__PURE__ */ jsxs42("div", { ref: plot, className: "ui-chart__plot", children: [
6329
+ /* @__PURE__ */ jsxs42(
6330
+ "svg",
6331
+ {
6332
+ ref: svgEl,
6333
+ className: "ui-chart__svg",
6334
+ width: px2(plotWidth),
6335
+ height: px2(boxHeight),
6336
+ viewBox: `0 ${px2(boxTop)} ${px2(plotWidth)} ${px2(boxHeight)}`,
6337
+ ...box && { width: px2(box.w), height: px2(box.h), viewBox: `0 0 ${px2(box.w)} ${px2(box.h)}` },
6338
+ role: "img",
6339
+ "aria-label": spark && marks.length > 0 ? `${title}. ${format(marks[0].value)} to ${format(marks[marks.length - 1].value)}.` : title,
6340
+ onMouseMove: (event) => {
6341
+ if (Date.now() < ignoreMouseUntil.current) return;
6342
+ show(markAt(event.target));
6319
6343
  },
6320
- `grid-${tick}`
6321
- )),
6322
- !spark && columnsLayout && scale.ticks.includes(0) && /* @__PURE__ */ jsx46(
6323
- "line",
6324
- {
6325
- className: "ui-chart__zero",
6326
- x1: "0",
6327
- x2: px2(plotWidth),
6328
- y1: px2(y(0)),
6329
- y2: px2(y(0))
6330
- }
6331
- ),
6332
- fades.size > 0 && /* @__PURE__ */ jsx46("defs", { children: [...fades.values()].map((fade) => /* @__PURE__ */ jsxs42(
6333
- "linearGradient",
6334
- {
6335
- id: fade.id,
6336
- className: `ui-chart__tone--${fade.tone}`,
6337
- x1: "0",
6338
- x2: "0",
6339
- y1: fade.up ? "1" : "0",
6340
- y2: fade.up ? "0" : "1",
6341
- children: [
6342
- /* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-base", offset: "0" }),
6343
- /* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-end", offset: "1" })
6344
- ]
6344
+ onMouseLeave: () => {
6345
+ if (Date.now() < ignoreMouseUntil.current) return;
6346
+ dismissed.current = null;
6347
+ setOpenId(null);
6345
6348
  },
6346
- fade.id
6347
- )) }),
6348
- marks.filter((m) => m.kind === "bar").map((mark) => {
6349
- const fade = fadeOf(uid, mark, variant === "bridge");
6350
- return /* @__PURE__ */ jsx46(
6351
- "path",
6352
- {
6353
- className: cx9(
6354
- "ui-chart__bar",
6355
- `ui-chart__tone--${mark.tone}`,
6356
- mark.estimated && "is-estimated"
6357
- ),
6358
- style: fade ? { "--ui-chart-paint": `url(#${fade.id})` } : void 0,
6359
- d: barPath(mark)
6360
- },
6361
- `bar-${mark.id}`
6362
- );
6363
- }),
6364
- ["casing", "stroke"].map((layer) => lines.flatMap(
6365
- (line) => line.values.slice(1).map((value, i) => Number.isFinite(value) && Number.isFinite(line.values[i]) ? /* @__PURE__ */ jsx46(
6366
- "line",
6367
- {
6368
- className: layer === "casing" ? "ui-chart__line-casing" : cx9(
6369
- "ui-chart__line",
6370
- `ui-chart__tone--${line.tone}`,
6371
- (columns[i]?.estimated || columns[i + 1]?.estimated) && "is-estimated"
6372
- ),
6373
- x1: px2(centre(i)),
6374
- y1: px2(y(line.values[i])),
6375
- x2: px2(centre(i + 1)),
6376
- y2: px2(y(value))
6377
- },
6378
- `${line.id}-${layer}-${i}`
6379
- ) : null)
6380
- )),
6381
- lines.flatMap((line) => line.values.map((value, i) => Number.isFinite(value) && !Number.isFinite(line.values[i - 1]) && !Number.isFinite(line.values[i + 1]) ? /* @__PURE__ */ jsx46(
6382
- "circle",
6383
- {
6384
- className: cx9("ui-chart__isolated", `ui-chart__tone--${line.tone}`),
6385
- cx: px2(centre(i)),
6386
- cy: px2(y(value)),
6387
- r: "2"
6349
+ onTouchStart: () => {
6350
+ ignoreMouseUntil.current = Date.now() + 800;
6351
+ touchMoved.current = false;
6388
6352
  },
6389
- `isolated-${line.id}-${i}`
6390
- ) : null)),
6391
- geometry && lookDrawing(geometry, open?.column ?? null, pick),
6392
- marks.map((mark) => /* @__PURE__ */ jsxs42("g", { "data-mark": mark.id, children: [
6393
- mark.hitPath ? /* @__PURE__ */ jsx46("path", { className: "ui-chart__hit", d: mark.hitPath }) : mark.kind === "bar" ? /* @__PURE__ */ jsx46(
6394
- "rect",
6395
- {
6396
- className: "ui-chart__hit",
6397
- x: px2(mark.column * colWidth + mark.lane * colWidth / mark.lanes),
6398
- width: px2(colWidth / mark.lanes),
6399
- y: px2(hitBand(mark.band).y),
6400
- height: px2(hitBand(mark.band).h)
6401
- }
6402
- ) : /* @__PURE__ */ jsx46(
6403
- "rect",
6404
- {
6405
- className: "ui-chart__hit",
6406
- x: px2(mark.hit?.x ?? mark.x),
6407
- y: px2(mark.hit?.y ?? mark.y),
6408
- width: px2(mark.hit?.w ?? TARGET),
6409
- height: px2(mark.hit?.h ?? TARGET)
6353
+ onTouchMove: () => {
6354
+ touchMoved.current = true;
6355
+ },
6356
+ onTouchCancel: () => {
6357
+ touchMoved.current = true;
6358
+ },
6359
+ onTouchEnd: (event) => {
6360
+ ignoreMouseUntil.current = Date.now() + 800;
6361
+ if (touchMoved.current) return;
6362
+ const id = markAt(event.target);
6363
+ if (id && id === openId) {
6364
+ opening.current = false;
6365
+ setOpenId(null);
6366
+ } else {
6367
+ opening.current = Boolean(id) && dismissed.current !== id;
6368
+ show(id);
6410
6369
  }
6411
- ),
6412
- /* @__PURE__ */ jsx46(
6413
- "rect",
6414
- {
6415
- "data-anchor": mark.id,
6416
- className: "ui-chart__anchor",
6417
- x: px2(mark.x),
6418
- y: px2(mark.y),
6419
- width: px2(mark.w),
6420
- height: "0"
6370
+ },
6371
+ onPointerDown: () => {
6372
+ pointerFocus.current = true;
6373
+ },
6374
+ onClick: (event) => {
6375
+ frameEl.current?.focus();
6376
+ pointerFocus.current = false;
6377
+ const opened = opening.current;
6378
+ opening.current = false;
6379
+ const mark = byId.get(markAt(event.target) ?? "");
6380
+ if (!mark) return;
6381
+ setCursor(mark.column);
6382
+ if (opened) {
6383
+ announce(mark.column);
6384
+ return;
6421
6385
  }
6422
- )
6423
- ] }, `hit-${mark.id}`))
6424
- ]
6425
- }
6426
- ),
6427
- look?.variant === "donut" && look.look === "table" && /* @__PURE__ */ jsx46(Shares, { look, format, swatch: /* @__PURE__ */ jsx46(KeyMark, { shape: "fill" }) }),
6428
- !spark && columnsLayout && /* @__PURE__ */ jsx46("div", { className: "ui-chart__periods", "aria-hidden": "true", children: columns.map((column, i) => /* @__PURE__ */ jsx46(
6429
- "span",
6430
- {
6431
- className: cx9("ui-chart__period", pick === i && "is-selected"),
6432
- children: column.short
6433
- },
6434
- `${column.label}-${i}`
6435
- )) })
6436
- ] }) }),
6386
+ choose(mark.column);
6387
+ announce(mark.column, selectable ? mark.column : pick);
6388
+ },
6389
+ children: [
6390
+ !spark && columnsLayout && pick !== null && pick >= 0 && pick < count && /* @__PURE__ */ jsx46(
6391
+ "rect",
6392
+ {
6393
+ className: "ui-chart__band",
6394
+ x: px2(pick * colWidth),
6395
+ width: px2(colWidth),
6396
+ y: "0",
6397
+ height: px2(plotHeight)
6398
+ }
6399
+ ),
6400
+ frame.links && frame.bars.slice(0, -1).map((bar, i) => {
6401
+ const from = byId.get(bar.id);
6402
+ const to = byId.get(frame.bars[i + 1].id);
6403
+ return from && to ? /* @__PURE__ */ jsx46(
6404
+ "line",
6405
+ {
6406
+ className: "ui-chart__carry",
6407
+ x1: px2(from.x + from.w),
6408
+ x2: px2(to.x),
6409
+ y1: px2(y(bar.to)),
6410
+ y2: px2(y(bar.to))
6411
+ },
6412
+ `carry-${bar.id}`
6413
+ ) : null;
6414
+ }),
6415
+ !spark && columnsLayout && scale.ticks.filter((tick) => tick !== 0).map((tick) => /* @__PURE__ */ jsx46(
6416
+ "line",
6417
+ {
6418
+ className: "ui-chart__grid",
6419
+ x1: "0",
6420
+ x2: px2(plotWidth),
6421
+ y1: px2(y(tick)),
6422
+ y2: px2(y(tick))
6423
+ },
6424
+ `grid-${tick}`
6425
+ )),
6426
+ !spark && columnsLayout && scale.ticks.includes(0) && /* @__PURE__ */ jsx46(
6427
+ "line",
6428
+ {
6429
+ className: "ui-chart__zero",
6430
+ x1: "0",
6431
+ x2: px2(plotWidth),
6432
+ y1: px2(y(0)),
6433
+ y2: px2(y(0))
6434
+ }
6435
+ ),
6436
+ fades.size > 0 && /* @__PURE__ */ jsx46("defs", { children: [...fades.values()].map((fade) => /* @__PURE__ */ jsxs42(
6437
+ "linearGradient",
6438
+ {
6439
+ id: fade.id,
6440
+ className: `ui-chart__tone--${fade.tone}`,
6441
+ x1: "0",
6442
+ x2: "0",
6443
+ y1: fade.up ? "1" : "0",
6444
+ y2: fade.up ? "0" : "1",
6445
+ children: [
6446
+ /* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-base", offset: "0" }),
6447
+ /* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-end", offset: "1" })
6448
+ ]
6449
+ },
6450
+ fade.id
6451
+ )) }),
6452
+ marks.filter((m) => m.kind === "bar").map((mark) => {
6453
+ const fade = fadeOf(uid, mark, variant === "bridge");
6454
+ return /* @__PURE__ */ jsx46(
6455
+ "path",
6456
+ {
6457
+ className: cx9(
6458
+ "ui-chart__bar",
6459
+ `ui-chart__tone--${mark.tone}`,
6460
+ mark.estimated && "is-estimated"
6461
+ ),
6462
+ style: fade ? { "--ui-chart-paint": `url(#${fade.id})` } : void 0,
6463
+ d: barPath(mark)
6464
+ },
6465
+ `bar-${mark.id}`
6466
+ );
6467
+ }),
6468
+ ["casing", "stroke"].map((layer) => lines.flatMap(
6469
+ (line) => line.values.slice(1).map((value, i) => Number.isFinite(value) && Number.isFinite(line.values[i]) ? /* @__PURE__ */ jsx46(
6470
+ "line",
6471
+ {
6472
+ className: layer === "casing" ? "ui-chart__line-casing" : cx9(
6473
+ "ui-chart__line",
6474
+ `ui-chart__tone--${line.tone}`,
6475
+ (columns[i]?.estimated || columns[i + 1]?.estimated) && "is-estimated"
6476
+ ),
6477
+ x1: px2(centre(i)),
6478
+ y1: px2(y(line.values[i])),
6479
+ x2: px2(centre(i + 1)),
6480
+ y2: px2(y(value))
6481
+ },
6482
+ `${line.id}-${layer}-${i}`
6483
+ ) : null)
6484
+ )),
6485
+ lines.flatMap((line) => line.values.map((value, i) => Number.isFinite(value) && !Number.isFinite(line.values[i - 1]) && !Number.isFinite(line.values[i + 1]) ? /* @__PURE__ */ jsx46(
6486
+ "circle",
6487
+ {
6488
+ className: cx9("ui-chart__isolated", `ui-chart__tone--${line.tone}`),
6489
+ cx: px2(centre(i)),
6490
+ cy: px2(y(value)),
6491
+ r: "2"
6492
+ },
6493
+ `isolated-${line.id}-${i}`
6494
+ ) : null)),
6495
+ geometry && lookDrawing(geometry, open?.column ?? null, pick),
6496
+ marks.map((mark) => /* @__PURE__ */ jsxs42("g", { "data-mark": mark.id, children: [
6497
+ mark.hitPath ? /* @__PURE__ */ jsx46("path", { className: "ui-chart__hit", d: mark.hitPath }) : mark.kind === "bar" ? /* @__PURE__ */ jsx46(
6498
+ "rect",
6499
+ {
6500
+ className: "ui-chart__hit",
6501
+ x: px2(mark.column * colWidth + mark.lane * colWidth / mark.lanes),
6502
+ width: px2(colWidth / mark.lanes),
6503
+ y: px2(hitBand(mark.band).y),
6504
+ height: px2(hitBand(mark.band).h)
6505
+ }
6506
+ ) : /* @__PURE__ */ jsx46(
6507
+ "rect",
6508
+ {
6509
+ className: "ui-chart__hit",
6510
+ x: px2(mark.hit?.x ?? mark.x),
6511
+ y: px2(mark.hit?.y ?? mark.y),
6512
+ width: px2(mark.hit?.w ?? TARGET),
6513
+ height: px2(mark.hit?.h ?? TARGET)
6514
+ }
6515
+ ),
6516
+ /* @__PURE__ */ jsx46(
6517
+ "rect",
6518
+ {
6519
+ "data-anchor": mark.id,
6520
+ className: "ui-chart__anchor",
6521
+ x: px2(mark.x),
6522
+ y: px2(mark.y),
6523
+ width: px2(mark.w),
6524
+ height: "0"
6525
+ }
6526
+ )
6527
+ ] }, `hit-${mark.id}`))
6528
+ ]
6529
+ }
6530
+ ),
6531
+ look?.variant === "donut" && look.look === "table" && /* @__PURE__ */ jsx46(Shares, { look, format, swatch: /* @__PURE__ */ jsx46(KeyMark, { shape: "fill" }) }),
6532
+ !spark && columnsLayout && /* @__PURE__ */ jsx46("div", { className: "ui-chart__periods", "aria-hidden": "true", children: columns.map((column, i) => /* @__PURE__ */ jsx46(
6533
+ "span",
6534
+ {
6535
+ className: cx9("ui-chart__period", pick === i && "is-selected"),
6536
+ children: column.short
6537
+ },
6538
+ `${column.label}-${i}`
6539
+ )) })
6540
+ ] })
6541
+ }
6542
+ ),
6437
6543
  /* @__PURE__ */ jsx46("span", { ref: tipEl, className: cx9("ui-tip", openId && "is-open"), role: open ? "tooltip" : void 0, children: open && /* @__PURE__ */ jsxs42(Fragment20, { children: [
6438
6544
  /* @__PURE__ */ jsx46("span", { className: "ui-tip__label", children: spark || look ? columns[open.column]?.label : `${open.name}, ${columns[open.column]?.label}` }),
6439
6545
  open.rows ? /* @__PURE__ */ jsxs42(Fragment20, { children: [