@apliteni/apliteni-ui 0.151.0 → 0.154.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/TRADEMARK.md +22 -0
- package/docs/components.md +1384 -0
- package/docs/foundations.md +494 -0
- package/guidelines/dashboards-and-reports.md +14 -0
- package/package.json +5 -2
- package/react/dist/index.css +8 -0
- package/react/dist/index.d.ts +5 -3
- package/react/dist/index.js +464 -361
- package/src/styles/card.css +12 -0
- package/src/styles/chart.css +6 -0
- package/src/styles/tap-zone.css +8 -0
package/react/dist/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
|
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] =
|
|
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
|
|
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 =
|
|
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] =
|
|
730
|
-
const [entered, setEntered] =
|
|
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] =
|
|
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
|
|
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] =
|
|
892
|
-
const [open, setOpen] =
|
|
906
|
+
const [pill, setPill] = useState5(null);
|
|
907
|
+
const [open, setOpen] = useState5(false);
|
|
893
908
|
const openRef = useRef6(false);
|
|
894
|
-
const [note, setNote] =
|
|
895
|
-
const [state, setState] =
|
|
896
|
-
const [error, setError] =
|
|
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] =
|
|
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
|
|
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
|
|
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] =
|
|
1193
|
+
const [expanded, setExpanded] = useState6();
|
|
1179
1194
|
const open = expanded ?? item.defaultOpen ?? childActive;
|
|
1180
|
-
const [entering, setEntering] =
|
|
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] =
|
|
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
|
-
"
|
|
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
|
|
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";
|
|
@@ -1551,25 +1566,25 @@ function CommandPalette({
|
|
|
1551
1566
|
const root = useRef11(null);
|
|
1552
1567
|
const panel = useRef11(null);
|
|
1553
1568
|
const search = useRef11(null);
|
|
1554
|
-
const [query, setQuery] =
|
|
1555
|
-
const [at, setAt] =
|
|
1569
|
+
const [query, setQuery] = useState8("");
|
|
1570
|
+
const [at, setAt] = useState8(0);
|
|
1556
1571
|
useEffect8(() => {
|
|
1557
1572
|
if (open) {
|
|
1558
1573
|
setQuery("");
|
|
1559
1574
|
setAt(0);
|
|
1560
1575
|
}
|
|
1561
1576
|
}, [open]);
|
|
1562
|
-
const shown =
|
|
1577
|
+
const shown = useMemo2(
|
|
1563
1578
|
() => (rank ? rankGroups(groups, query) : groups).filter((g) => g.items.length),
|
|
1564
1579
|
[groups, query, rank]
|
|
1565
1580
|
);
|
|
1566
|
-
const rows =
|
|
1581
|
+
const rows = useMemo2(() => shown.flatMap((g) => g.items).filter((it) => !isDisabled(it)), [shown]);
|
|
1567
1582
|
const active = rows[Math.min(at, rows.length - 1)];
|
|
1568
1583
|
useEffect8(() => {
|
|
1569
1584
|
setAt(0);
|
|
1570
1585
|
}, [query]);
|
|
1571
1586
|
const scope = useDialog(open, { root, panel, body: search }, onClose);
|
|
1572
|
-
const run =
|
|
1587
|
+
const run = useCallback3((item, newTab) => {
|
|
1573
1588
|
if (isDisabled(item)) return;
|
|
1574
1589
|
onSelect?.(item, { newTab });
|
|
1575
1590
|
if (item.danger && item.onConfirm) {
|
|
@@ -1720,11 +1735,11 @@ function rowId(uid, groups, item) {
|
|
|
1720
1735
|
}
|
|
1721
1736
|
|
|
1722
1737
|
// src/DataTable.tsx
|
|
1723
|
-
import { Fragment as Fragment10, useCallback as
|
|
1738
|
+
import { Fragment as Fragment10, useCallback as useCallback4, useEffect as useEffect10, useMemo as useMemo3, useRef as useRef13, useState as useState10 } from "react";
|
|
1724
1739
|
import { DEFAULT_PAGE_SIZE as DEFAULT_PAGE_SIZE2 } from "@apliteni/apliteni-ui";
|
|
1725
1740
|
|
|
1726
1741
|
// src/Pagination.tsx
|
|
1727
|
-
import { useEffect as useEffect9, useId as useId10, useRef as useRef12, useState as
|
|
1742
|
+
import { useEffect as useEffect9, useId as useId10, useRef as useRef12, useState as useState9 } from "react";
|
|
1728
1743
|
import { DEFAULT_PAGE_SIZE } from "@apliteni/apliteni-ui";
|
|
1729
1744
|
import { jsx as jsx22, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1730
1745
|
var GHOST_SM = "ui-btn ui-btn--ghost ui-btn--sm";
|
|
@@ -1769,8 +1784,8 @@ function Pagination({
|
|
|
1769
1784
|
onPageSizeChange
|
|
1770
1785
|
}) {
|
|
1771
1786
|
const auto = useId10();
|
|
1772
|
-
const [draft, setDraft] =
|
|
1773
|
-
const [drafting, setDrafting] =
|
|
1787
|
+
const [draft, setDraft] = useState9("");
|
|
1788
|
+
const [drafting, setDrafting] = useState9(false);
|
|
1774
1789
|
const nav = useRef12(null);
|
|
1775
1790
|
const pressed = useRef12(null);
|
|
1776
1791
|
const uid = id ?? auto;
|
|
@@ -1781,7 +1796,7 @@ function Pagination({
|
|
|
1781
1796
|
const rows = counted ? Math.max(0, asRows) : null;
|
|
1782
1797
|
const last = counted ? Math.max(1, Math.ceil(rows / size)) : null;
|
|
1783
1798
|
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] =
|
|
1799
|
+
const [draftFor, setDraftFor] = useState9(at);
|
|
1785
1800
|
if (draftFor !== at) {
|
|
1786
1801
|
setDraftFor(at);
|
|
1787
1802
|
setDraft("");
|
|
@@ -1991,12 +2006,12 @@ function DataTable({
|
|
|
1991
2006
|
}) {
|
|
1992
2007
|
const scrollable = stickyHeader || pinnedIdentity;
|
|
1993
2008
|
const table = useRef13(null);
|
|
1994
|
-
const [pagerHost, setPagerHost] =
|
|
1995
|
-
const holdPagerBox =
|
|
2009
|
+
const [pagerHost, setPagerHost] = useState10(null);
|
|
2010
|
+
const holdPagerBox = useCallback4(
|
|
1996
2011
|
(box) => setPagerHost(box?.parentElement ?? null),
|
|
1997
2012
|
[]
|
|
1998
2013
|
);
|
|
1999
|
-
const [strip2, setStrip] =
|
|
2014
|
+
const [strip2, setStrip] = useState10();
|
|
2000
2015
|
useEffect10(() => {
|
|
2001
2016
|
const el = table.current;
|
|
2002
2017
|
const host = pagerHost;
|
|
@@ -2017,21 +2032,21 @@ function DataTable({
|
|
|
2017
2032
|
measure();
|
|
2018
2033
|
return () => observer.disconnect();
|
|
2019
2034
|
}, [pagerHost, columns, rows]);
|
|
2020
|
-
const [localSort, setLocalSort] =
|
|
2035
|
+
const [localSort, setLocalSort] = useState10(
|
|
2021
2036
|
{ key: columns.find((c) => c.sortable)?.key, dir: -1 }
|
|
2022
2037
|
);
|
|
2023
2038
|
const owned = controlledPage === void 0;
|
|
2024
2039
|
const sort = controlledSort ?? (owned ? localSort : NO_SORT);
|
|
2025
2040
|
const sortIsKnown = owned || controlledSort !== void 0;
|
|
2026
|
-
const [localPage, setLocalPage] =
|
|
2027
|
-
const [localSize, setLocalSize] =
|
|
2041
|
+
const [localPage, setLocalPage] = useState10(1);
|
|
2042
|
+
const [localSize, setLocalSize] = useState10(DEFAULT_PAGE_SIZE2);
|
|
2028
2043
|
const size = sizeOf(pageSize, owned ? localSize : rows.length || DEFAULT_PAGE_SIZE2);
|
|
2029
|
-
const [pagedSort, setPagedSort] =
|
|
2044
|
+
const [pagedSort, setPagedSort] = useState10(sort);
|
|
2030
2045
|
if (pagedSort.key !== sort.key || pagedSort.dir !== sort.dir) {
|
|
2031
2046
|
setPagedSort(sort);
|
|
2032
2047
|
setLocalPage(1);
|
|
2033
2048
|
}
|
|
2034
|
-
const ordered =
|
|
2049
|
+
const ordered = useMemo3(
|
|
2035
2050
|
() => owned ? sortTableRows(rows, sort) : rows,
|
|
2036
2051
|
[owned, rows, sort.key, sort.dir]
|
|
2037
2052
|
);
|
|
@@ -2263,11 +2278,11 @@ function Denied({
|
|
|
2263
2278
|
|
|
2264
2279
|
// src/DatePicker.tsx
|
|
2265
2280
|
import {
|
|
2266
|
-
useCallback as
|
|
2281
|
+
useCallback as useCallback5,
|
|
2267
2282
|
useEffect as useEffect11,
|
|
2268
|
-
useMemo as
|
|
2283
|
+
useMemo as useMemo4,
|
|
2269
2284
|
useRef as useRef14,
|
|
2270
|
-
useState as
|
|
2285
|
+
useState as useState11
|
|
2271
2286
|
} from "react";
|
|
2272
2287
|
import { dropdownViewportFit } from "@apliteni/apliteni-ui";
|
|
2273
2288
|
import { jsx as jsx25, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
@@ -2279,7 +2294,7 @@ var MONTH_RE = /^(\d{4})-(\d{2})$/;
|
|
|
2279
2294
|
var DAY_RE = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
2280
2295
|
var PHONE_MAX = 560;
|
|
2281
2296
|
function usePhone() {
|
|
2282
|
-
const [phone, setPhone] =
|
|
2297
|
+
const [phone, setPhone] = useState11(false);
|
|
2283
2298
|
useEffect11(() => {
|
|
2284
2299
|
const query = typeof window === "undefined" ? null : window.matchMedia?.(`(max-width: ${PHONE_MAX}px)`);
|
|
2285
2300
|
if (!query) return;
|
|
@@ -2379,13 +2394,13 @@ function DatePicker({
|
|
|
2379
2394
|
const trigger = useRef14(null);
|
|
2380
2395
|
const grid = useRef14(null);
|
|
2381
2396
|
const panel = useRef14(null);
|
|
2382
|
-
const [selfOpen, setSelfOpen] =
|
|
2397
|
+
const [selfOpen, setSelfOpen] = useState11(defaultOpen);
|
|
2383
2398
|
const open = openProp ?? selfOpen;
|
|
2384
|
-
const [selfValue, setSelfValue] =
|
|
2399
|
+
const [selfValue, setSelfValue] = useState11(defaultValue);
|
|
2385
2400
|
const picked = value !== void 0 ? value : selfValue;
|
|
2386
|
-
const [selfRange, setSelfRange] =
|
|
2401
|
+
const [selfRange, setSelfRange] = useState11(defaultRange ?? { start: null, end: null });
|
|
2387
2402
|
const span = range !== void 0 ? range : selfRange;
|
|
2388
|
-
const names =
|
|
2403
|
+
const names = useMemo4(() => ({
|
|
2389
2404
|
month: new Intl.DateTimeFormat(locale, { month: "long", timeZone: "UTC" }),
|
|
2390
2405
|
monthShort: new Intl.DateTimeFormat(locale, { month: "short", timeZone: "UTC" }),
|
|
2391
2406
|
monthYear: new Intl.DateTimeFormat(locale, { month: "long", year: "numeric", timeZone: "UTC" }),
|
|
@@ -2395,28 +2410,28 @@ function DatePicker({
|
|
|
2395
2410
|
weekday: new Intl.DateTimeFormat(locale, { weekday: "long", timeZone: "UTC" }),
|
|
2396
2411
|
weekdayShort: new Intl.DateTimeFormat(locale, { weekday: "short", timeZone: "UTC" })
|
|
2397
2412
|
}), [locale]);
|
|
2398
|
-
const monthLabels =
|
|
2399
|
-
const at =
|
|
2413
|
+
const monthLabels = useMemo4(() => evenMonthLabels(names.monthShort), [names]);
|
|
2414
|
+
const at = useCallback5((index) => new Date(
|
|
2400
2415
|
grain === "month" ? Date.UTC(Math.floor(index / 12), index % 12, 1) : index * DAY_MS
|
|
2401
2416
|
), [grain]);
|
|
2402
2417
|
const lo = toIndex(min, grain, "start");
|
|
2403
2418
|
const hi = toIndex(max, grain, "end");
|
|
2404
|
-
const blocked =
|
|
2419
|
+
const blocked = useMemo4(() => (disabledPeriods ?? []).flatMap((period) => {
|
|
2405
2420
|
const from = toIndex(period, grain, "start");
|
|
2406
2421
|
const to = toIndex(period, grain, "end");
|
|
2407
2422
|
return from == null || to == null ? [] : [[from, to]];
|
|
2408
2423
|
}), [disabledPeriods, grain]);
|
|
2409
2424
|
const outOfBounds = (index) => lo != null && index < lo || hi != null && index > hi;
|
|
2410
2425
|
const isBlocked = (index) => outOfBounds(index) || blocked.some(([from, to]) => index >= from && index <= to);
|
|
2411
|
-
const todayIndex =
|
|
2426
|
+
const todayIndex = useMemo4(() => {
|
|
2412
2427
|
const given = toIndex(today, "day");
|
|
2413
2428
|
const now = given ?? Math.floor(Date.now() / DAY_MS);
|
|
2414
2429
|
return grain === "month" ? monthOf(now) : now;
|
|
2415
2430
|
}, [today, grain]);
|
|
2416
2431
|
const anchor = toIndex(picked, grain) ?? toIndex(picksRange ? span.start ?? span.end : null, grain) ?? todayIndex;
|
|
2417
|
-
const [cursor, setCursor] =
|
|
2432
|
+
const [cursor, setCursor] = useState11(() => clamp(anchor, lo, hi));
|
|
2418
2433
|
const land = useRef14(false);
|
|
2419
|
-
const setOpen =
|
|
2434
|
+
const setOpen = useCallback5((next) => {
|
|
2420
2435
|
if (openProp === void 0) setSelfOpen(next);
|
|
2421
2436
|
onOpenChange?.(next);
|
|
2422
2437
|
}, [openProp, onOpenChange]);
|
|
@@ -2474,11 +2489,11 @@ function DatePicker({
|
|
|
2474
2489
|
const columns = grain === "month" ? 3 : 7;
|
|
2475
2490
|
const page = grain === "month" ? Math.floor(cursor / 12) : monthOf(cursor);
|
|
2476
2491
|
const caption = grain === "month" ? String(page) : names.monthYear.format(at(firstDayOf(page)));
|
|
2477
|
-
const periodName =
|
|
2492
|
+
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
2493
|
const count = grain === "month" ? 12 : daysInMonth(page);
|
|
2479
2494
|
const first = grain === "month" ? page * 12 : firstDayOf(page);
|
|
2480
2495
|
const last = first + count - 1;
|
|
2481
|
-
const cells =
|
|
2496
|
+
const cells = useMemo4(() => Array.from({ length: count }, (_, i) => {
|
|
2482
2497
|
const index = first + i;
|
|
2483
2498
|
const period = fromIndex(index, grain);
|
|
2484
2499
|
return {
|
|
@@ -2572,7 +2587,7 @@ function DatePicker({
|
|
|
2572
2587
|
dismiss();
|
|
2573
2588
|
}
|
|
2574
2589
|
}
|
|
2575
|
-
const shown =
|
|
2590
|
+
const shown = useMemo4(() => {
|
|
2576
2591
|
if (picksRange) {
|
|
2577
2592
|
const text2 = (period) => {
|
|
2578
2593
|
const index2 = toIndex(period, grain);
|
|
@@ -2759,12 +2774,12 @@ function DatePicker({
|
|
|
2759
2774
|
// src/Dropdown.tsx
|
|
2760
2775
|
import {
|
|
2761
2776
|
Fragment as Fragment12,
|
|
2762
|
-
useCallback as
|
|
2777
|
+
useCallback as useCallback6,
|
|
2763
2778
|
useContext as useContext2,
|
|
2764
2779
|
useEffect as useEffect12,
|
|
2765
2780
|
useId as useId11,
|
|
2766
2781
|
useRef as useRef15,
|
|
2767
|
-
useState as
|
|
2782
|
+
useState as useState12
|
|
2768
2783
|
} from "react";
|
|
2769
2784
|
import {
|
|
2770
2785
|
icon as icon4,
|
|
@@ -2782,8 +2797,8 @@ import {
|
|
|
2782
2797
|
} from "@apliteni/apliteni-ui";
|
|
2783
2798
|
|
|
2784
2799
|
// src/fieldContext.ts
|
|
2785
|
-
import { createContext as
|
|
2786
|
-
var FieldContext =
|
|
2800
|
+
import { createContext as createContext3 } from "react";
|
|
2801
|
+
var FieldContext = createContext3(null);
|
|
2787
2802
|
|
|
2788
2803
|
// src/Dropdown.tsx
|
|
2789
2804
|
import { Fragment as Fragment13, jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
@@ -2853,11 +2868,11 @@ function Dropdown({
|
|
|
2853
2868
|
onSelect,
|
|
2854
2869
|
row
|
|
2855
2870
|
}) {
|
|
2856
|
-
const [selfOpen, setSelfOpen] =
|
|
2871
|
+
const [selfOpen, setSelfOpen] = useState12(defaultOpen);
|
|
2857
2872
|
const open = openProp ?? selfOpen;
|
|
2858
|
-
const [pick, setPick] =
|
|
2859
|
-
const [query, setQuery] =
|
|
2860
|
-
const [activeKey, setActiveKey] =
|
|
2873
|
+
const [pick, setPick] = useState12(null);
|
|
2874
|
+
const [query, setQuery] = useState12(() => search && search !== true ? search.query || "" : "");
|
|
2875
|
+
const [activeKey, setActiveKey] = useState12(null);
|
|
2861
2876
|
const root = useRef15(null);
|
|
2862
2877
|
const panel = useRef15(null);
|
|
2863
2878
|
const trigger = useRef15(null);
|
|
@@ -2869,7 +2884,7 @@ function Dropdown({
|
|
|
2869
2884
|
const uid = id ?? auto;
|
|
2870
2885
|
const inField = useContext2(FieldContext);
|
|
2871
2886
|
const fieldName = inField && id === inField.id && !(ariaLabel && triggerContent != null) ? { id: `${uid}-trigger`, labelId: inField.labelId, labelledBy: `${inField.labelId} ${uid}-trigger` } : null;
|
|
2872
|
-
const setOpen =
|
|
2887
|
+
const setOpen = useCallback6((next) => {
|
|
2873
2888
|
if (openProp === void 0) setSelfOpen(next);
|
|
2874
2889
|
onOpenChange?.(next);
|
|
2875
2890
|
}, [openProp, onOpenChange]);
|
|
@@ -3490,7 +3505,7 @@ function Segmented({ options, value, onChange, label, appearance = "pill", size,
|
|
|
3490
3505
|
}
|
|
3491
3506
|
|
|
3492
3507
|
// src/FilterBar.tsx
|
|
3493
|
-
import { useRef as useRef16, useState as
|
|
3508
|
+
import { useRef as useRef16, useState as useState13 } from "react";
|
|
3494
3509
|
import { filterChipText, filterChipName, filterChipUnset, filterChipItems, focusNextStop } from "@apliteni/apliteni-ui";
|
|
3495
3510
|
import { Fragment as Fragment14, jsx as jsx30, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3496
3511
|
var SEARCH_AT = 10;
|
|
@@ -3499,8 +3514,8 @@ function FilterBar({ filters, label = "Filters", clearLabel = "Clear all", clear
|
|
|
3499
3514
|
const bar = useRef16(null);
|
|
3500
3515
|
const focused = useRef16(null);
|
|
3501
3516
|
const landing = useRef16(null);
|
|
3502
|
-
const [opened, setOpened] =
|
|
3503
|
-
const [adding, setAdding] =
|
|
3517
|
+
const [opened, setOpened] = useState13({});
|
|
3518
|
+
const [adding, setAdding] = useState13(false);
|
|
3504
3519
|
const blocked = disabled || busy;
|
|
3505
3520
|
const offer = (add || []).filter((entry) => !filters.some((filter) => filter.id === entry.id));
|
|
3506
3521
|
const source = /* @__PURE__ */ new Map();
|
|
@@ -3656,10 +3671,10 @@ function DrawerSection({ title, headingLevel = 3, className, children, ...rest }
|
|
|
3656
3671
|
}
|
|
3657
3672
|
|
|
3658
3673
|
// src/Snippet.tsx
|
|
3659
|
-
import { useEffect as useEffect13, useRef as useRef17, useState as
|
|
3674
|
+
import { useEffect as useEffect13, useRef as useRef17, useState as useState14 } from "react";
|
|
3660
3675
|
import { Fragment as Fragment15, jsx as jsx32, jsxs as jsxs28 } from "react/jsx-runtime";
|
|
3661
3676
|
function Snippet({ label = "shell", code = "", children, copy = true, reveal = false, copyLabel = "Copy code" }) {
|
|
3662
|
-
const [status, setStatus] =
|
|
3677
|
+
const [status, setStatus] = useState14("idle");
|
|
3663
3678
|
const request = useRef17(0);
|
|
3664
3679
|
const timer = useRef17(void 0);
|
|
3665
3680
|
useEffect13(() => {
|
|
@@ -3755,7 +3770,7 @@ function Timeline({ events, className, ...rest }) {
|
|
|
3755
3770
|
}
|
|
3756
3771
|
|
|
3757
3772
|
// src/Field.tsx
|
|
3758
|
-
import { forwardRef as forwardRef8, useEffect as useEffect15, useId as useId12, useRef as useRef19, useState as
|
|
3773
|
+
import { forwardRef as forwardRef8, useEffect as useEffect15, useId as useId12, useRef as useRef19, useState as useState15 } from "react";
|
|
3759
3774
|
import { esc, icon as icon5 } from "@apliteni/apliteni-ui";
|
|
3760
3775
|
import { jsx as jsx34, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
3761
3776
|
function messages(id, hint, error) {
|
|
@@ -3845,8 +3860,8 @@ function SelectField({ label, hint, error, required, className = "", children, .
|
|
|
3845
3860
|
function FileField({ label, hint, error, required, disabled, onFileChange, className = "", ...props }) {
|
|
3846
3861
|
const id = useId12();
|
|
3847
3862
|
const input = useRef19(null);
|
|
3848
|
-
const [file, setFile] =
|
|
3849
|
-
const [dragging, setDragging] =
|
|
3863
|
+
const [file, setFile] = useState15(null);
|
|
3864
|
+
const [dragging, setDragging] = useState15(false);
|
|
3850
3865
|
useEffect15(() => {
|
|
3851
3866
|
const form = input.current?.form;
|
|
3852
3867
|
const reset = () => {
|
|
@@ -3906,7 +3921,7 @@ function FileField({ label, hint, error, required, disabled, onFileChange, class
|
|
|
3906
3921
|
}
|
|
3907
3922
|
|
|
3908
3923
|
// src/FileDrop.tsx
|
|
3909
|
-
import { useRef as useRef20, useState as
|
|
3924
|
+
import { useRef as useRef20, useState as useState16 } from "react";
|
|
3910
3925
|
|
|
3911
3926
|
// src/EmptyState.tsx
|
|
3912
3927
|
import { icon as kitIcon3, illo } from "@apliteni/apliteni-ui";
|
|
@@ -3968,7 +3983,7 @@ function FileDrop({
|
|
|
3968
3983
|
className
|
|
3969
3984
|
}) {
|
|
3970
3985
|
const input = useRef20(null);
|
|
3971
|
-
const [over, setOver] =
|
|
3986
|
+
const [over, setOver] = useState16(false);
|
|
3972
3987
|
const status = file?.status ?? "uploading";
|
|
3973
3988
|
const word = status === "error" ? file?.error ?? WORDS.error : file?.state ?? WORDS[status];
|
|
3974
3989
|
const [stem, ext] = splitName(file?.name ?? "");
|
|
@@ -4139,7 +4154,7 @@ var SearchField = forwardRef9(function SearchField2({ ariaLabel, className, ...p
|
|
|
4139
4154
|
});
|
|
4140
4155
|
|
|
4141
4156
|
// src/Toast.tsx
|
|
4142
|
-
import { createContext as
|
|
4157
|
+
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
4158
|
import { createPortal as createPortal6 } from "react-dom";
|
|
4144
4159
|
|
|
4145
4160
|
// src/lib/toast-stack.ts
|
|
@@ -4250,8 +4265,8 @@ function watchToastPile(stack2) {
|
|
|
4250
4265
|
|
|
4251
4266
|
// src/Toast.tsx
|
|
4252
4267
|
import { jsx as jsx38, jsxs as jsxs34 } from "react/jsx-runtime";
|
|
4253
|
-
var Context =
|
|
4254
|
-
var PileHoldContext =
|
|
4268
|
+
var Context = createContext4(null);
|
|
4269
|
+
var PileHoldContext = createContext4(false);
|
|
4255
4270
|
var glyphs = { success: "circleCheck", danger: "circleX", warn: "circleAlert", info: "info", neutral: "bolt" };
|
|
4256
4271
|
function useToast() {
|
|
4257
4272
|
const push = useContext3(Context);
|
|
@@ -4260,17 +4275,17 @@ function useToast() {
|
|
|
4260
4275
|
}
|
|
4261
4276
|
function Notice({ notice, remove }) {
|
|
4262
4277
|
const root = useRef21(null);
|
|
4263
|
-
const [leaving2, setLeaving] =
|
|
4278
|
+
const [leaving2, setLeaving] = useState17(false);
|
|
4264
4279
|
const dismissed = useRef21(false);
|
|
4265
|
-
const [hovered, setHovered] =
|
|
4266
|
-
const [focused, setFocused] =
|
|
4280
|
+
const [hovered, setHovered] = useState17(false);
|
|
4281
|
+
const [focused, setFocused] = useState17(false);
|
|
4267
4282
|
const pileHeld = useContext3(PileHoldContext);
|
|
4268
4283
|
const paused = hovered || focused || pileHeld;
|
|
4269
4284
|
const tone2 = notice.tone ?? "success";
|
|
4270
4285
|
const timed = !notice.action && notice.timer !== false && notice.timer !== 0;
|
|
4271
4286
|
const duration = typeof notice.timer === "number" ? notice.timer * 1e3 : 5e3;
|
|
4272
4287
|
const remaining = useRef21(duration);
|
|
4273
|
-
const dismiss =
|
|
4288
|
+
const dismiss = useCallback7(() => {
|
|
4274
4289
|
if (dismissed.current) return;
|
|
4275
4290
|
dismissed.current = true;
|
|
4276
4291
|
if (typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches) remove();
|
|
@@ -4378,12 +4393,12 @@ function usePile(stack2, piled, count) {
|
|
|
4378
4393
|
}, [stack2, piled, count]);
|
|
4379
4394
|
}
|
|
4380
4395
|
function Toast({ children, collapse = false }) {
|
|
4381
|
-
const [entries, setEntries] =
|
|
4382
|
-
const [pileHovered, setPileHovered] =
|
|
4383
|
-
const [pileFocused, setPileFocused] =
|
|
4396
|
+
const [entries, setEntries] = useState17([]);
|
|
4397
|
+
const [pileHovered, setPileHovered] = useState17(false);
|
|
4398
|
+
const [pileFocused, setPileFocused] = useState17(false);
|
|
4384
4399
|
const nextId = useRef21(0);
|
|
4385
4400
|
const stack2 = useRef21(null);
|
|
4386
|
-
const push =
|
|
4401
|
+
const push = useCallback7((notice) => {
|
|
4387
4402
|
const id = nextId.current++;
|
|
4388
4403
|
const remove = () => setEntries((current) => current.filter((entry) => entry.id !== id));
|
|
4389
4404
|
setEntries((current) => [...current, { id, notice, remove }]);
|
|
@@ -4419,7 +4434,7 @@ function Toast({ children, collapse = false }) {
|
|
|
4419
4434
|
}
|
|
4420
4435
|
|
|
4421
4436
|
// src/AppShell.tsx
|
|
4422
|
-
import { useEffect as useEffect18, useId as useId13, useMemo as
|
|
4437
|
+
import { useEffect as useEffect18, useId as useId13, useMemo as useMemo5, useRef as useRef23, useState as useState19 } from "react";
|
|
4423
4438
|
import { prism } from "@apliteni/apliteni-ui";
|
|
4424
4439
|
|
|
4425
4440
|
// src/lib/palette-hotkey.ts
|
|
@@ -4449,7 +4464,7 @@ function storeRailCollapsed(collapsed) {
|
|
|
4449
4464
|
}
|
|
4450
4465
|
|
|
4451
4466
|
// src/AccountMenu.tsx
|
|
4452
|
-
import { useEffect as useEffect17, useRef as useRef22, useState as
|
|
4467
|
+
import { useEffect as useEffect17, useRef as useRef22, useState as useState18 } from "react";
|
|
4453
4468
|
import { createPortal as createPortal7 } from "react-dom";
|
|
4454
4469
|
import { icon as icon7, themeIcon as themeIcon2, transitionMs as transitionMs3 } from "@apliteni/apliteni-ui";
|
|
4455
4470
|
|
|
@@ -4535,8 +4550,8 @@ var THEMES = [["auto", "Auto"], ["light", "Light"], ["dark", "Dark"]];
|
|
|
4535
4550
|
var glyph = (svg, className) => /* @__PURE__ */ jsx40("span", { className, "aria-hidden": "true", dangerouslySetInnerHTML: { __html: svg } });
|
|
4536
4551
|
function AccountMenu({ account, items, onSelect, withTheme, inPlace, away }) {
|
|
4537
4552
|
const theme = useThemeChoice();
|
|
4538
|
-
const [open, setOpen] =
|
|
4539
|
-
const [sub, setSub] =
|
|
4553
|
+
const [open, setOpen] = useState18(false);
|
|
4554
|
+
const [sub, setSub] = useState18(false);
|
|
4540
4555
|
const block = useRef22(null);
|
|
4541
4556
|
const themeRow = useRef22(null);
|
|
4542
4557
|
const list = useRef22(null);
|
|
@@ -4730,12 +4745,12 @@ function AppShell({
|
|
|
4730
4745
|
renderLink
|
|
4731
4746
|
}) {
|
|
4732
4747
|
const uid = useId13();
|
|
4733
|
-
const [collapsed, setCollapsed] =
|
|
4734
|
-
const [search, setSearch] =
|
|
4735
|
-
const [menu, setMenu] =
|
|
4748
|
+
const [collapsed, setCollapsed] = useState19(defaultCollapsed);
|
|
4749
|
+
const [search, setSearch] = useState19(false);
|
|
4750
|
+
const [menu, setMenu] = useState19(false);
|
|
4736
4751
|
const menuButton = useRef23(null);
|
|
4737
4752
|
const menuBody = useRef23(null);
|
|
4738
|
-
const firstRow =
|
|
4753
|
+
const firstRow = useMemo5(() => ({ get current() {
|
|
4739
4754
|
return menuBody.current?.querySelector(".ui-nav__item") ?? null;
|
|
4740
4755
|
} }), []);
|
|
4741
4756
|
const current = path(pathname);
|
|
@@ -5047,7 +5062,7 @@ function Footer({
|
|
|
5047
5062
|
}
|
|
5048
5063
|
|
|
5049
5064
|
// src/Success.tsx
|
|
5050
|
-
import { forwardRef as forwardRef11, useEffect as useEffect19, useRef as useRef24, useState as
|
|
5065
|
+
import { forwardRef as forwardRef11, useEffect as useEffect19, useRef as useRef24, useState as useState20 } from "react";
|
|
5051
5066
|
import { jsx as jsx44, jsxs as jsxs40 } from "react/jsx-runtime";
|
|
5052
5067
|
var SuccessCheck = forwardRef11(function SuccessCheck2({ variant = "line", className, ...rest }, ref) {
|
|
5053
5068
|
const circled = variant === "circled";
|
|
@@ -5094,7 +5109,7 @@ var pieces = [
|
|
|
5094
5109
|
[80, 0.36, -20, "c", 1.05]
|
|
5095
5110
|
];
|
|
5096
5111
|
function Countdown({ seconds, label = "Redirecting", onDone }) {
|
|
5097
|
-
const [remaining, setRemaining] =
|
|
5112
|
+
const [remaining, setRemaining] = useState20(seconds);
|
|
5098
5113
|
const callback = useRef24(onDone);
|
|
5099
5114
|
useEffect19(() => {
|
|
5100
5115
|
callback.current = onDone;
|
|
@@ -5171,14 +5186,16 @@ var Success = forwardRef11(function Success2({
|
|
|
5171
5186
|
|
|
5172
5187
|
// src/Chart.tsx
|
|
5173
5188
|
import {
|
|
5174
|
-
useCallback as
|
|
5189
|
+
useCallback as useCallback8,
|
|
5190
|
+
useContext as useContext4,
|
|
5175
5191
|
useEffect as useEffect20,
|
|
5176
5192
|
useId as useId15,
|
|
5177
5193
|
useLayoutEffect as useLayoutEffect5,
|
|
5178
|
-
useMemo as
|
|
5194
|
+
useMemo as useMemo6,
|
|
5179
5195
|
useRef as useRef25,
|
|
5180
|
-
useState as
|
|
5196
|
+
useState as useState21
|
|
5181
5197
|
} from "react";
|
|
5198
|
+
import { createPortal as createPortal8 } from "react-dom";
|
|
5182
5199
|
import { CHART_FLOOR, bridgeWalk, chartScale, pointTarget } from "@apliteni/apliteni-ui";
|
|
5183
5200
|
|
|
5184
5201
|
// src/chart-looks.tsx
|
|
@@ -5226,7 +5243,22 @@ function rightRounded(x, y, w, h, r) {
|
|
|
5226
5243
|
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
5244
|
}
|
|
5228
5245
|
var square = (x, y, w, h) => `M${px(x)} ${px(y)}h${px(w)}v${px(h)}h${px(-w)}Z`;
|
|
5229
|
-
var
|
|
5246
|
+
var overlaps = (look) => look === "flat" || look === "curves";
|
|
5247
|
+
var keyShape = (look) => look.variant === "line" || look.variant === "area" && overlaps(look.look) ? "line" : "fill";
|
|
5248
|
+
function monotone(xs, ys) {
|
|
5249
|
+
const s = xs.slice(1).map((x, k) => (ys[k + 1] - ys[k]) / (x - xs[k]));
|
|
5250
|
+
if (s.length < 2) return ys.map(() => s[0] ?? 0);
|
|
5251
|
+
const t = ys.map((_, i) => {
|
|
5252
|
+
if (i === 0 || i === ys.length - 1) return 0;
|
|
5253
|
+
const [s0, s1] = [s[i - 1], s[i]];
|
|
5254
|
+
const [h0, h1] = [xs[i] - xs[i - 1], xs[i + 1] - xs[i]];
|
|
5255
|
+
const p = (s0 * h1 + s1 * h0) / (h0 + h1);
|
|
5256
|
+
return (Math.sign(s0) + Math.sign(s1)) * Math.min(Math.abs(s0), Math.abs(s1), Math.abs(p) / 2);
|
|
5257
|
+
});
|
|
5258
|
+
t[0] = (3 * s[0] - t[1]) / 2;
|
|
5259
|
+
t[t.length - 1] = (3 * s[s.length - 1] - t[t.length - 2]) / 2;
|
|
5260
|
+
return t;
|
|
5261
|
+
}
|
|
5230
5262
|
function columnRows(g, i) {
|
|
5231
5263
|
const { look, format } = g;
|
|
5232
5264
|
const shape = keyShape(look);
|
|
@@ -5317,7 +5349,7 @@ function lookMarks(g) {
|
|
|
5317
5349
|
};
|
|
5318
5350
|
});
|
|
5319
5351
|
}
|
|
5320
|
-
const lift = look.variant === "line" && look.look === "points" ? 6 : look.variant === "stacked" ? 2 : 4;
|
|
5352
|
+
const lift = look.variant === "line" && look.look === "points" || look.look === "curves" ? 6 : look.variant === "stacked" ? 2 : 4;
|
|
5321
5353
|
return g.labels.map((label, i) => {
|
|
5322
5354
|
const tops = look.layers.map((l) => l.to[i]).filter(Number.isFinite);
|
|
5323
5355
|
const top = tops.length ? Math.max(...tops) : g.scale.min;
|
|
@@ -5353,16 +5385,52 @@ function linesDrawing(g, open) {
|
|
|
5353
5385
|
const area = look.variant === "area";
|
|
5354
5386
|
const finite = (layer, i) => Number.isFinite(look.stacked ? layer.to[i] : layer.values[i]);
|
|
5355
5387
|
const at = (layer, i) => look.stacked ? layer.to[i] : layer.values[i];
|
|
5388
|
+
const curves = area && look.look === "curves";
|
|
5356
5389
|
const ramps = area && !look.share ? look.layers.map((layer) => {
|
|
5357
5390
|
const tops = layer.values.map((_, i) => at(layer, i)).filter(Number.isFinite);
|
|
5358
|
-
const lo = Math.min(...tops);
|
|
5391
|
+
const lo = curves ? 0 : Math.min(...tops);
|
|
5359
5392
|
const hi = Math.max(...tops);
|
|
5360
5393
|
return tops.length && y(lo) - y(hi) >= 1 ? { id: `${g.uid}-ramp-${layer.id}`, layer, lo, hi } : null;
|
|
5361
5394
|
}) : [];
|
|
5395
|
+
const runs = (layer) => [...Array(n).keys()].reduce((out, i) => {
|
|
5396
|
+
if (!finite(layer, i)) return out;
|
|
5397
|
+
if (finite(layer, i - 1)) out[out.length - 1].push(i);
|
|
5398
|
+
else out.push([i]);
|
|
5399
|
+
return out;
|
|
5400
|
+
}, []);
|
|
5401
|
+
const tangents = curves ? look.layers.map((layer) => {
|
|
5402
|
+
const t = new Array(n).fill(0);
|
|
5403
|
+
for (const run of runs(layer)) {
|
|
5404
|
+
monotone(run.map(centre), run.map((i) => y(at(layer, i)))).forEach((v, k) => {
|
|
5405
|
+
t[run[k]] = v;
|
|
5406
|
+
});
|
|
5407
|
+
}
|
|
5408
|
+
return t;
|
|
5409
|
+
}) : [];
|
|
5410
|
+
const bend = (k, i) => {
|
|
5411
|
+
const layer = look.layers[k];
|
|
5412
|
+
const h = (centre(i + 1) - centre(i)) / 3;
|
|
5413
|
+
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)))}`;
|
|
5414
|
+
};
|
|
5362
5415
|
const fills = area && look.layers.map((layer, k) => {
|
|
5363
5416
|
const up = layer.to.map((v, i) => `${i ? "L" : "M"}${px(centre(i))} ${px(y(Number.isFinite(v) ? v : layer.from[i]))}`);
|
|
5364
5417
|
const down = layer.from.map((v, i) => `L${px(centre(i))} ${px(y(v))}`).reverse();
|
|
5365
5418
|
const ramp = ramps[k];
|
|
5419
|
+
if (curves) {
|
|
5420
|
+
const d = runs(layer).filter((run) => run.length > 1).map((run) => {
|
|
5421
|
+
const [a, b] = [run[0], run[run.length - 1]];
|
|
5422
|
+
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`;
|
|
5423
|
+
}).join("");
|
|
5424
|
+
return d && /* @__PURE__ */ jsx45(
|
|
5425
|
+
"path",
|
|
5426
|
+
{
|
|
5427
|
+
className: cx8("ui-chart__area", tone(layer.tone)),
|
|
5428
|
+
style: ramp ? { "--ui-chart-paint": `url(#${ramp.id})` } : void 0,
|
|
5429
|
+
d
|
|
5430
|
+
},
|
|
5431
|
+
`fill-${layer.id}`
|
|
5432
|
+
);
|
|
5433
|
+
}
|
|
5366
5434
|
return /* @__PURE__ */ jsx45(
|
|
5367
5435
|
"path",
|
|
5368
5436
|
{
|
|
@@ -5373,7 +5441,18 @@ function linesDrawing(g, open) {
|
|
|
5373
5441
|
`fill-${layer.id}`
|
|
5374
5442
|
);
|
|
5375
5443
|
});
|
|
5376
|
-
const edges =
|
|
5444
|
+
const edges = curves ? look.layers.flatMap((layer, k) => layer.to.slice(1).map((_, i) => finite(layer, i) && finite(layer, i + 1) ? /* @__PURE__ */ jsx45(
|
|
5445
|
+
"path",
|
|
5446
|
+
{
|
|
5447
|
+
className: cx8(
|
|
5448
|
+
"ui-chart__line",
|
|
5449
|
+
tone(layer.tone),
|
|
5450
|
+
(labels[i]?.estimated || labels[i + 1]?.estimated) && "is-estimated"
|
|
5451
|
+
),
|
|
5452
|
+
d: `M${px(centre(i))} ${px(y(at(layer, i)))}${bend(k, i)}`
|
|
5453
|
+
},
|
|
5454
|
+
`edge-${layer.id}-${i}`
|
|
5455
|
+
) : null)) : !look.share && look.layers.flatMap((layer) => layer.to.slice(1).map((_, k) => finite(layer, k) && finite(layer, k + 1) ? /* @__PURE__ */ jsx45(
|
|
5377
5456
|
"line",
|
|
5378
5457
|
{
|
|
5379
5458
|
className: cx8(
|
|
@@ -5388,7 +5467,7 @@ function linesDrawing(g, open) {
|
|
|
5388
5467
|
},
|
|
5389
5468
|
`edge-${layer.id}-${k}`
|
|
5390
5469
|
) : null));
|
|
5391
|
-
const points = look.variant === "line" && look.look === "points";
|
|
5470
|
+
const points = look.variant === "line" && look.look === "points" || curves;
|
|
5392
5471
|
const dots = look.layers.flatMap((layer) => layer.to.map((_, i) => {
|
|
5393
5472
|
if (!finite(layer, i)) return null;
|
|
5394
5473
|
const lonely = !finite(layer, i - 1) && !finite(layer, i + 1);
|
|
@@ -5457,8 +5536,8 @@ function linesDrawing(g, open) {
|
|
|
5457
5536
|
y1: px(y(ramp.lo)),
|
|
5458
5537
|
y2: px(y(ramp.hi)),
|
|
5459
5538
|
children: [
|
|
5460
|
-
/* @__PURE__ */ jsx45("stop", { className: "ui-chart__fade-base", offset: "0" }),
|
|
5461
|
-
/* @__PURE__ */ jsx45("stop", { className: "ui-chart__fade-end", offset: "1" })
|
|
5539
|
+
/* @__PURE__ */ jsx45("stop", { className: curves ? "ui-chart__wash-floor" : "ui-chart__fade-base", offset: "0" }),
|
|
5540
|
+
/* @__PURE__ */ jsx45("stop", { className: curves ? "ui-chart__wash-top" : "ui-chart__fade-end", offset: "1" })
|
|
5462
5541
|
]
|
|
5463
5542
|
},
|
|
5464
5543
|
ramp.id
|
|
@@ -5661,7 +5740,7 @@ function barPath(m) {
|
|
|
5661
5740
|
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
5741
|
}
|
|
5663
5742
|
function useTapFloor() {
|
|
5664
|
-
const [floor, setFloor] =
|
|
5743
|
+
const [floor, setFloor] = useState21(TARGET);
|
|
5665
5744
|
useEffect20(() => {
|
|
5666
5745
|
const query = typeof window === "undefined" ? null : window.matchMedia?.(`(max-width: ${PHONE_MAX2}px) and (pointer: coarse)`);
|
|
5667
5746
|
if (!query) return;
|
|
@@ -5775,7 +5854,7 @@ function noNegative(variant, values) {
|
|
|
5775
5854
|
function lookFrame(variant, look, periods, series, format) {
|
|
5776
5855
|
if (variant !== "line") noNegative(variant, series.flatMap((s) => s.values.map((value2) => ({ name: s.name, value: value2 }))));
|
|
5777
5856
|
const columns = periods.map((p) => columnOf(p, p.label.split(" ")[0]));
|
|
5778
|
-
const stacked = variant === "stacked" ||
|
|
5857
|
+
const stacked = variant === "stacked" || variant === "area" && !overlaps(look);
|
|
5779
5858
|
const share = look === "share";
|
|
5780
5859
|
const n = columns.length;
|
|
5781
5860
|
const value = (s, i) => Number.isFinite(s.values[i]) ? s.values[i] : Number.NaN;
|
|
@@ -5897,10 +5976,14 @@ function Chart(props) {
|
|
|
5897
5976
|
const spark = variant === "spark";
|
|
5898
5977
|
const plotHeight = height ?? HEIGHT[variant];
|
|
5899
5978
|
const showTable = table ?? !spark;
|
|
5900
|
-
const [view, setView] =
|
|
5979
|
+
const [view, setView] = useState21("chart");
|
|
5901
5980
|
const asTable = showTable && view === "table";
|
|
5902
5981
|
const uid = useId15().replace(/[^\w-]/g, "");
|
|
5903
5982
|
const frameEl = useRef25(null);
|
|
5983
|
+
const card = useContext4(CardTools);
|
|
5984
|
+
const claim = card?.claim;
|
|
5985
|
+
useLayoutEffect5(() => showTable && claim ? claim(uid) : void 0, [showTable, claim, uid]);
|
|
5986
|
+
const toCard = showTable && card?.owner === uid ? card.slot : null;
|
|
5904
5987
|
const scroller = useRef25(null);
|
|
5905
5988
|
const plot = useRef25(null);
|
|
5906
5989
|
const tipEl = useRef25(null);
|
|
@@ -5911,11 +5994,12 @@ function Chart(props) {
|
|
|
5911
5994
|
const opening = useRef25(false);
|
|
5912
5995
|
const pointerFocus = useRef25(false);
|
|
5913
5996
|
const floor = useTapFloor();
|
|
5914
|
-
const [width, setWidth] =
|
|
5915
|
-
const [
|
|
5916
|
-
const [
|
|
5917
|
-
const [
|
|
5918
|
-
const [
|
|
5997
|
+
const [width, setWidth] = useState21(0);
|
|
5998
|
+
const [overflows, setOverflows] = useState21(false);
|
|
5999
|
+
const [openId, setOpenId] = useState21(null);
|
|
6000
|
+
const [rawCursor, setCursor] = useState21(0);
|
|
6001
|
+
const [said, setSaid] = useState21("");
|
|
6002
|
+
const [ownPick, setOwnPick] = useState21(null);
|
|
5919
6003
|
const pick = selected === void 0 ? ownPick : selected;
|
|
5920
6004
|
const steps = props.variant === "bridge" ? props.steps : void 0;
|
|
5921
6005
|
const bridgeTones = props.variant === "bridge" ? props.tones : void 0;
|
|
@@ -5924,7 +6008,7 @@ function Chart(props) {
|
|
|
5924
6008
|
const slices = props.variant === "donut" ? props.slices : void 0;
|
|
5925
6009
|
const totalLabel = props.variant === "donut" ? props.totalLabel ?? "Total" : "Total";
|
|
5926
6010
|
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 =
|
|
6011
|
+
const frame = useMemo6(() => {
|
|
5928
6012
|
if (steps) return bridgeFrame(steps, bridgeTones, format);
|
|
5929
6013
|
if (slices) return donutFrame(lookName, slices, totalLabel, format);
|
|
5930
6014
|
if (lookName) return lookFrame(variant, lookName, periods ?? [], series ?? [], format);
|
|
@@ -5939,7 +6023,7 @@ function Chart(props) {
|
|
|
5939
6023
|
const boxHeight = Math.max(plotHeight, floor);
|
|
5940
6024
|
const boxTop = -(boxHeight - plotHeight) / 2;
|
|
5941
6025
|
const span = scale.max - scale.min || 1;
|
|
5942
|
-
const y =
|
|
6026
|
+
const y = useCallback8(
|
|
5943
6027
|
(value) => PAD + (scale.max - value) / span * (plotHeight - PAD * 2),
|
|
5944
6028
|
[scale.max, span, plotHeight]
|
|
5945
6029
|
);
|
|
@@ -5952,9 +6036,9 @@ function Chart(props) {
|
|
|
5952
6036
|
cap * lanes + LANE_GAP * (lanes - 1)
|
|
5953
6037
|
));
|
|
5954
6038
|
const barWidth = (groupWidth - LANE_GAP * (lanes - 1)) / lanes;
|
|
5955
|
-
const centre =
|
|
6039
|
+
const centre = useCallback8((column) => column * colWidth + colWidth / 2, [colWidth]);
|
|
5956
6040
|
const axisFormat = look?.share ? pct : formatAxis;
|
|
5957
|
-
const geometry =
|
|
6041
|
+
const geometry = useMemo6(() => look ? {
|
|
5958
6042
|
look,
|
|
5959
6043
|
uid,
|
|
5960
6044
|
labels: columns,
|
|
@@ -5971,7 +6055,7 @@ function Chart(props) {
|
|
|
5971
6055
|
formatAxis: axisFormat
|
|
5972
6056
|
} : null, [look, uid, columns, plotWidth, plotHeight, colWidth, floor, y, centre, scale, format, axisFormat]);
|
|
5973
6057
|
const box = geometry ? lookBox(geometry) : null;
|
|
5974
|
-
const marks =
|
|
6058
|
+
const marks = useMemo6(() => {
|
|
5975
6059
|
if (geometry) return lookMarks(geometry);
|
|
5976
6060
|
const out = frame.bars.map((bar) => {
|
|
5977
6061
|
let top = Math.min(y(bar.from), y(bar.to));
|
|
@@ -6044,18 +6128,23 @@ function Chart(props) {
|
|
|
6044
6128
|
}
|
|
6045
6129
|
return [...out, ...dots];
|
|
6046
6130
|
}, [geometry, frame, lines, keys, columns, centre, barWidth, groupWidth, y, floor, colWidth, plotWidth, boxTop, boxHeight]);
|
|
6047
|
-
const byId =
|
|
6048
|
-
const fades =
|
|
6049
|
-
const lead =
|
|
6131
|
+
const byId = useMemo6(() => new Map(marks.map((m) => [m.id, m])), [marks]);
|
|
6132
|
+
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]);
|
|
6133
|
+
const lead = useCallback8((column) => marks.find((m) => m.column === column), [marks]);
|
|
6050
6134
|
const open = openId ? byId.get(openId) : void 0;
|
|
6051
6135
|
useEffect20(() => {
|
|
6052
6136
|
const el = plot.current;
|
|
6053
|
-
|
|
6054
|
-
|
|
6137
|
+
const box2 = scroller.current;
|
|
6138
|
+
if (!el || !box2) return;
|
|
6139
|
+
const read = () => {
|
|
6140
|
+
setWidth(el.clientWidth);
|
|
6141
|
+
setOverflows(box2.scrollWidth > box2.clientWidth);
|
|
6142
|
+
};
|
|
6055
6143
|
read();
|
|
6056
6144
|
if (typeof ResizeObserver === "undefined") return;
|
|
6057
6145
|
const observer = new ResizeObserver(read);
|
|
6058
6146
|
observer.observe(el);
|
|
6147
|
+
observer.observe(box2);
|
|
6059
6148
|
return () => observer.disconnect();
|
|
6060
6149
|
}, []);
|
|
6061
6150
|
const opensAtEnd = variant === "line" && lookName === "labels";
|
|
@@ -6096,7 +6185,7 @@ function Chart(props) {
|
|
|
6096
6185
|
setOpenId(id);
|
|
6097
6186
|
};
|
|
6098
6187
|
const markAt = (target) => target.closest?.("[data-mark]")?.getAttribute("data-mark") ?? null;
|
|
6099
|
-
const announce =
|
|
6188
|
+
const announce = useCallback8((column, picked = pick) => {
|
|
6100
6189
|
const where = columns[column];
|
|
6101
6190
|
if (!where) return;
|
|
6102
6191
|
const values = marks.filter((m) => m.column === column).map((m) => {
|
|
@@ -6123,6 +6212,7 @@ function Chart(props) {
|
|
|
6123
6212
|
onSelect?.(column);
|
|
6124
6213
|
};
|
|
6125
6214
|
const onKeyDown = (event) => {
|
|
6215
|
+
if (event.target !== event.currentTarget) return;
|
|
6126
6216
|
const steps2 = {
|
|
6127
6217
|
ArrowLeft: cursor - 1,
|
|
6128
6218
|
ArrowRight: cursor + 1,
|
|
@@ -6154,6 +6244,19 @@ function Chart(props) {
|
|
|
6154
6244
|
"Estimated"
|
|
6155
6245
|
] })
|
|
6156
6246
|
] });
|
|
6247
|
+
const viewSwitch = showTable && /* @__PURE__ */ jsx46(
|
|
6248
|
+
Segmented,
|
|
6249
|
+
{
|
|
6250
|
+
size: "sm",
|
|
6251
|
+
label: `${title}, view`,
|
|
6252
|
+
value: view,
|
|
6253
|
+
onChange: (next) => setView(next),
|
|
6254
|
+
options: [
|
|
6255
|
+
{ value: "chart", label: "Chart", icon: "chart", iconOnly: true },
|
|
6256
|
+
{ value: "table", label: "Table", icon: "table", iconOnly: true }
|
|
6257
|
+
]
|
|
6258
|
+
}
|
|
6259
|
+
);
|
|
6157
6260
|
const noun = look?.layout === "ring" ? "slices" : look?.layout === "rows" ? "rows" : "columns";
|
|
6158
6261
|
return /* @__PURE__ */ jsxs42(
|
|
6159
6262
|
"div",
|
|
@@ -6172,21 +6275,10 @@ function Chart(props) {
|
|
|
6172
6275
|
"--ui-chart-pad": `${PAD}px`
|
|
6173
6276
|
},
|
|
6174
6277
|
children: [
|
|
6175
|
-
|
|
6278
|
+
toCard && createPortal8(viewSwitch, toCard),
|
|
6279
|
+
(showTable && !toCard || legendFirst && legend) && /* @__PURE__ */ jsxs42("div", { className: "ui-chart__head", children: [
|
|
6176
6280
|
legendFirst && legend,
|
|
6177
|
-
|
|
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
|
-
)
|
|
6281
|
+
!toCard && viewSwitch
|
|
6190
6282
|
] }),
|
|
6191
6283
|
/* @__PURE__ */ jsxs42(
|
|
6192
6284
|
"div",
|
|
@@ -6214,226 +6306,237 @@ function Chart(props) {
|
|
|
6214
6306
|
},
|
|
6215
6307
|
children: [
|
|
6216
6308
|
!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(
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6224
|
-
|
|
6225
|
-
|
|
6226
|
-
|
|
6227
|
-
|
|
6228
|
-
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6244
|
-
|
|
6245
|
-
|
|
6246
|
-
|
|
6247
|
-
|
|
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))
|
|
6309
|
+
/* @__PURE__ */ jsx46(
|
|
6310
|
+
"div",
|
|
6311
|
+
{
|
|
6312
|
+
ref: scroller,
|
|
6313
|
+
className: cx9("ui-chart__scroll", overflows && "ui-focusable"),
|
|
6314
|
+
tabIndex: overflows ? 0 : -1,
|
|
6315
|
+
role: overflows ? "region" : void 0,
|
|
6316
|
+
"aria-label": overflows ? `${title}. Scroll for more ${noun}.` : void 0,
|
|
6317
|
+
onScroll: () => {
|
|
6318
|
+
const anchor = [...svgEl.current?.querySelectorAll("[data-anchor]") ?? []].find((el) => el.getAttribute("data-anchor") === openId);
|
|
6319
|
+
if (!anchor || !scroller.current || !frameEl.current || !tipEl.current) return;
|
|
6320
|
+
const mark = anchor.getBoundingClientRect();
|
|
6321
|
+
const view2 = scroller.current.getBoundingClientRect();
|
|
6322
|
+
if (mark.right <= view2.left || mark.left >= view2.right) setOpenId(null);
|
|
6323
|
+
else placeTip(frameEl.current, anchor, tipEl.current, frameEl.current);
|
|
6324
|
+
},
|
|
6325
|
+
children: /* @__PURE__ */ jsxs42("div", { ref: plot, className: "ui-chart__plot", children: [
|
|
6326
|
+
/* @__PURE__ */ jsxs42(
|
|
6327
|
+
"svg",
|
|
6328
|
+
{
|
|
6329
|
+
ref: svgEl,
|
|
6330
|
+
className: "ui-chart__svg",
|
|
6331
|
+
width: px2(plotWidth),
|
|
6332
|
+
height: px2(boxHeight),
|
|
6333
|
+
viewBox: `0 ${px2(boxTop)} ${px2(plotWidth)} ${px2(boxHeight)}`,
|
|
6334
|
+
...box && { width: px2(box.w), height: px2(box.h), viewBox: `0 0 ${px2(box.w)} ${px2(box.h)}` },
|
|
6335
|
+
role: "img",
|
|
6336
|
+
"aria-label": spark && marks.length > 0 ? `${title}. ${format(marks[0].value)} to ${format(marks[marks.length - 1].value)}.` : title,
|
|
6337
|
+
onMouseMove: (event) => {
|
|
6338
|
+
if (Date.now() < ignoreMouseUntil.current) return;
|
|
6339
|
+
show(markAt(event.target));
|
|
6319
6340
|
},
|
|
6320
|
-
|
|
6321
|
-
|
|
6322
|
-
|
|
6323
|
-
|
|
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
|
-
]
|
|
6341
|
+
onMouseLeave: () => {
|
|
6342
|
+
if (Date.now() < ignoreMouseUntil.current) return;
|
|
6343
|
+
dismissed.current = null;
|
|
6344
|
+
setOpenId(null);
|
|
6345
6345
|
},
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
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"
|
|
6346
|
+
onTouchStart: () => {
|
|
6347
|
+
ignoreMouseUntil.current = Date.now() + 800;
|
|
6348
|
+
touchMoved.current = false;
|
|
6388
6349
|
},
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6397
|
-
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
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)
|
|
6350
|
+
onTouchMove: () => {
|
|
6351
|
+
touchMoved.current = true;
|
|
6352
|
+
},
|
|
6353
|
+
onTouchCancel: () => {
|
|
6354
|
+
touchMoved.current = true;
|
|
6355
|
+
},
|
|
6356
|
+
onTouchEnd: (event) => {
|
|
6357
|
+
ignoreMouseUntil.current = Date.now() + 800;
|
|
6358
|
+
if (touchMoved.current) return;
|
|
6359
|
+
const id = markAt(event.target);
|
|
6360
|
+
if (id && id === openId) {
|
|
6361
|
+
opening.current = false;
|
|
6362
|
+
setOpenId(null);
|
|
6363
|
+
} else {
|
|
6364
|
+
opening.current = Boolean(id) && dismissed.current !== id;
|
|
6365
|
+
show(id);
|
|
6410
6366
|
}
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
|
|
6367
|
+
},
|
|
6368
|
+
onPointerDown: () => {
|
|
6369
|
+
pointerFocus.current = true;
|
|
6370
|
+
},
|
|
6371
|
+
onClick: (event) => {
|
|
6372
|
+
frameEl.current?.focus();
|
|
6373
|
+
pointerFocus.current = false;
|
|
6374
|
+
const opened = opening.current;
|
|
6375
|
+
opening.current = false;
|
|
6376
|
+
const mark = byId.get(markAt(event.target) ?? "");
|
|
6377
|
+
if (!mark) return;
|
|
6378
|
+
setCursor(mark.column);
|
|
6379
|
+
if (opened) {
|
|
6380
|
+
announce(mark.column);
|
|
6381
|
+
return;
|
|
6421
6382
|
}
|
|
6422
|
-
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6383
|
+
choose(mark.column);
|
|
6384
|
+
announce(mark.column, selectable ? mark.column : pick);
|
|
6385
|
+
},
|
|
6386
|
+
children: [
|
|
6387
|
+
!spark && columnsLayout && pick !== null && pick >= 0 && pick < count && /* @__PURE__ */ jsx46(
|
|
6388
|
+
"rect",
|
|
6389
|
+
{
|
|
6390
|
+
className: "ui-chart__band",
|
|
6391
|
+
x: px2(pick * colWidth),
|
|
6392
|
+
width: px2(colWidth),
|
|
6393
|
+
y: "0",
|
|
6394
|
+
height: px2(plotHeight)
|
|
6395
|
+
}
|
|
6396
|
+
),
|
|
6397
|
+
frame.links && frame.bars.slice(0, -1).map((bar, i) => {
|
|
6398
|
+
const from = byId.get(bar.id);
|
|
6399
|
+
const to = byId.get(frame.bars[i + 1].id);
|
|
6400
|
+
return from && to ? /* @__PURE__ */ jsx46(
|
|
6401
|
+
"line",
|
|
6402
|
+
{
|
|
6403
|
+
className: "ui-chart__carry",
|
|
6404
|
+
x1: px2(from.x + from.w),
|
|
6405
|
+
x2: px2(to.x),
|
|
6406
|
+
y1: px2(y(bar.to)),
|
|
6407
|
+
y2: px2(y(bar.to))
|
|
6408
|
+
},
|
|
6409
|
+
`carry-${bar.id}`
|
|
6410
|
+
) : null;
|
|
6411
|
+
}),
|
|
6412
|
+
!spark && columnsLayout && scale.ticks.filter((tick) => tick !== 0).map((tick) => /* @__PURE__ */ jsx46(
|
|
6413
|
+
"line",
|
|
6414
|
+
{
|
|
6415
|
+
className: "ui-chart__grid",
|
|
6416
|
+
x1: "0",
|
|
6417
|
+
x2: px2(plotWidth),
|
|
6418
|
+
y1: px2(y(tick)),
|
|
6419
|
+
y2: px2(y(tick))
|
|
6420
|
+
},
|
|
6421
|
+
`grid-${tick}`
|
|
6422
|
+
)),
|
|
6423
|
+
!spark && columnsLayout && scale.ticks.includes(0) && /* @__PURE__ */ jsx46(
|
|
6424
|
+
"line",
|
|
6425
|
+
{
|
|
6426
|
+
className: "ui-chart__zero",
|
|
6427
|
+
x1: "0",
|
|
6428
|
+
x2: px2(plotWidth),
|
|
6429
|
+
y1: px2(y(0)),
|
|
6430
|
+
y2: px2(y(0))
|
|
6431
|
+
}
|
|
6432
|
+
),
|
|
6433
|
+
fades.size > 0 && /* @__PURE__ */ jsx46("defs", { children: [...fades.values()].map((fade) => /* @__PURE__ */ jsxs42(
|
|
6434
|
+
"linearGradient",
|
|
6435
|
+
{
|
|
6436
|
+
id: fade.id,
|
|
6437
|
+
className: `ui-chart__tone--${fade.tone}`,
|
|
6438
|
+
x1: "0",
|
|
6439
|
+
x2: "0",
|
|
6440
|
+
y1: fade.up ? "1" : "0",
|
|
6441
|
+
y2: fade.up ? "0" : "1",
|
|
6442
|
+
children: [
|
|
6443
|
+
/* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-base", offset: "0" }),
|
|
6444
|
+
/* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-end", offset: "1" })
|
|
6445
|
+
]
|
|
6446
|
+
},
|
|
6447
|
+
fade.id
|
|
6448
|
+
)) }),
|
|
6449
|
+
marks.filter((m) => m.kind === "bar").map((mark) => {
|
|
6450
|
+
const fade = fadeOf(uid, mark, variant === "bridge");
|
|
6451
|
+
return /* @__PURE__ */ jsx46(
|
|
6452
|
+
"path",
|
|
6453
|
+
{
|
|
6454
|
+
className: cx9(
|
|
6455
|
+
"ui-chart__bar",
|
|
6456
|
+
`ui-chart__tone--${mark.tone}`,
|
|
6457
|
+
mark.estimated && "is-estimated"
|
|
6458
|
+
),
|
|
6459
|
+
style: fade ? { "--ui-chart-paint": `url(#${fade.id})` } : void 0,
|
|
6460
|
+
d: barPath(mark)
|
|
6461
|
+
},
|
|
6462
|
+
`bar-${mark.id}`
|
|
6463
|
+
);
|
|
6464
|
+
}),
|
|
6465
|
+
["casing", "stroke"].map((layer) => lines.flatMap(
|
|
6466
|
+
(line) => line.values.slice(1).map((value, i) => Number.isFinite(value) && Number.isFinite(line.values[i]) ? /* @__PURE__ */ jsx46(
|
|
6467
|
+
"line",
|
|
6468
|
+
{
|
|
6469
|
+
className: layer === "casing" ? "ui-chart__line-casing" : cx9(
|
|
6470
|
+
"ui-chart__line",
|
|
6471
|
+
`ui-chart__tone--${line.tone}`,
|
|
6472
|
+
(columns[i]?.estimated || columns[i + 1]?.estimated) && "is-estimated"
|
|
6473
|
+
),
|
|
6474
|
+
x1: px2(centre(i)),
|
|
6475
|
+
y1: px2(y(line.values[i])),
|
|
6476
|
+
x2: px2(centre(i + 1)),
|
|
6477
|
+
y2: px2(y(value))
|
|
6478
|
+
},
|
|
6479
|
+
`${line.id}-${layer}-${i}`
|
|
6480
|
+
) : null)
|
|
6481
|
+
)),
|
|
6482
|
+
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(
|
|
6483
|
+
"circle",
|
|
6484
|
+
{
|
|
6485
|
+
className: cx9("ui-chart__isolated", `ui-chart__tone--${line.tone}`),
|
|
6486
|
+
cx: px2(centre(i)),
|
|
6487
|
+
cy: px2(y(value)),
|
|
6488
|
+
r: "2"
|
|
6489
|
+
},
|
|
6490
|
+
`isolated-${line.id}-${i}`
|
|
6491
|
+
) : null)),
|
|
6492
|
+
geometry && lookDrawing(geometry, open?.column ?? null, pick),
|
|
6493
|
+
marks.map((mark) => /* @__PURE__ */ jsxs42("g", { "data-mark": mark.id, children: [
|
|
6494
|
+
mark.hitPath ? /* @__PURE__ */ jsx46("path", { className: "ui-chart__hit", d: mark.hitPath }) : mark.kind === "bar" ? /* @__PURE__ */ jsx46(
|
|
6495
|
+
"rect",
|
|
6496
|
+
{
|
|
6497
|
+
className: "ui-chart__hit",
|
|
6498
|
+
x: px2(mark.column * colWidth + mark.lane * colWidth / mark.lanes),
|
|
6499
|
+
width: px2(colWidth / mark.lanes),
|
|
6500
|
+
y: px2(hitBand(mark.band).y),
|
|
6501
|
+
height: px2(hitBand(mark.band).h)
|
|
6502
|
+
}
|
|
6503
|
+
) : /* @__PURE__ */ jsx46(
|
|
6504
|
+
"rect",
|
|
6505
|
+
{
|
|
6506
|
+
className: "ui-chart__hit",
|
|
6507
|
+
x: px2(mark.hit?.x ?? mark.x),
|
|
6508
|
+
y: px2(mark.hit?.y ?? mark.y),
|
|
6509
|
+
width: px2(mark.hit?.w ?? TARGET),
|
|
6510
|
+
height: px2(mark.hit?.h ?? TARGET)
|
|
6511
|
+
}
|
|
6512
|
+
),
|
|
6513
|
+
/* @__PURE__ */ jsx46(
|
|
6514
|
+
"rect",
|
|
6515
|
+
{
|
|
6516
|
+
"data-anchor": mark.id,
|
|
6517
|
+
className: "ui-chart__anchor",
|
|
6518
|
+
x: px2(mark.x),
|
|
6519
|
+
y: px2(mark.y),
|
|
6520
|
+
width: px2(mark.w),
|
|
6521
|
+
height: "0"
|
|
6522
|
+
}
|
|
6523
|
+
)
|
|
6524
|
+
] }, `hit-${mark.id}`))
|
|
6525
|
+
]
|
|
6526
|
+
}
|
|
6527
|
+
),
|
|
6528
|
+
look?.variant === "donut" && look.look === "table" && /* @__PURE__ */ jsx46(Shares, { look, format, swatch: /* @__PURE__ */ jsx46(KeyMark, { shape: "fill" }) }),
|
|
6529
|
+
!spark && columnsLayout && /* @__PURE__ */ jsx46("div", { className: "ui-chart__periods", "aria-hidden": "true", children: columns.map((column, i) => /* @__PURE__ */ jsx46(
|
|
6530
|
+
"span",
|
|
6531
|
+
{
|
|
6532
|
+
className: cx9("ui-chart__period", pick === i && "is-selected"),
|
|
6533
|
+
children: column.short
|
|
6534
|
+
},
|
|
6535
|
+
`${column.label}-${i}`
|
|
6536
|
+
)) })
|
|
6537
|
+
] })
|
|
6538
|
+
}
|
|
6539
|
+
),
|
|
6437
6540
|
/* @__PURE__ */ jsx46("span", { ref: tipEl, className: cx9("ui-tip", openId && "is-open"), role: open ? "tooltip" : void 0, children: open && /* @__PURE__ */ jsxs42(Fragment20, { children: [
|
|
6438
6541
|
/* @__PURE__ */ jsx46("span", { className: "ui-tip__label", children: spark || look ? columns[open.column]?.label : `${open.name}, ${columns[open.column]?.label}` }),
|
|
6439
6542
|
open.rows ? /* @__PURE__ */ jsxs42(Fragment20, { children: [
|