@apliteni/apliteni-ui 0.180.0 → 0.184.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.
@@ -477,7 +477,7 @@ import { useId as useId4 } from "react";
477
477
 
478
478
  // src/tip.ts
479
479
  var TIP_GAP = 8;
480
- function placeTip(host, mark, tip, bound, placement = "top") {
480
+ function placeTip(host, mark, tip, placement = "top") {
481
481
  const mrect = mark.getBoundingClientRect();
482
482
  const view = host.ownerDocument.documentElement;
483
483
  const declared = parseFloat(getComputedStyle(tip).getPropertyValue("--ui-tip-gap"));
@@ -496,13 +496,6 @@ function placeTip(host, mark, tip, bound, placement = "top") {
496
496
  clip.right = Math.min(clip.right, left2 + el.clientWidth);
497
497
  clip.bottom = Math.min(clip.bottom, top + el.clientHeight);
498
498
  }
499
- if (bound) {
500
- const edge = bound.getBoundingClientRect();
501
- clip.top = Math.max(clip.top, edge.top);
502
- clip.left = Math.max(clip.left, edge.left);
503
- clip.right = Math.min(clip.right, edge.right);
504
- clip.bottom = Math.min(clip.bottom, edge.bottom);
505
- }
506
499
  const above = mrect.top - clip.top;
507
500
  const below = clip.bottom - mrect.bottom;
508
501
  const prefersBelow = placement === "bottom";
@@ -619,7 +612,7 @@ function Tooltip({ text: text2, label = text2, value, detail: detail2, placement
619
612
  const target = active.current;
620
613
  if (!h || !t || !target) return;
621
614
  const anchor = target.querySelector("[data-tip-anchor]") || target;
622
- placeTip(h, anchor, t, void 0, placement);
615
+ placeTip(h, anchor, t, placement);
623
616
  }
624
617
  useLayoutEffect2(() => {
625
618
  const t = tip.current;
@@ -2257,6 +2250,28 @@ function DataTable({
2257
2250
  measure();
2258
2251
  return () => observer.disconnect();
2259
2252
  }, [pagerHost, columns, rows]);
2253
+ const frame = useRef13(null);
2254
+ const [overflows, setOverflows] = useState10(true);
2255
+ useEffect11(() => {
2256
+ const box = frame.current;
2257
+ const el = table.current;
2258
+ if (!box || !el || typeof ResizeObserver === "undefined") return;
2259
+ const read = () => setOverflows(
2260
+ box.scrollWidth > box.clientWidth || box.scrollHeight > box.clientHeight
2261
+ );
2262
+ const observer = new ResizeObserver(read);
2263
+ observer.observe(box);
2264
+ observer.observe(el);
2265
+ read();
2266
+ return () => observer.disconnect();
2267
+ }, [scrollable]);
2268
+ const pressed = useRef13(false);
2269
+ const reveal = (e) => {
2270
+ if (!pressed.current) e.target.scrollIntoView?.({ block: "nearest", inline: "nearest" });
2271
+ };
2272
+ const press = (down) => () => {
2273
+ pressed.current = down;
2274
+ };
2260
2275
  const [localSort, setLocalSort] = useState10(
2261
2276
  { key: columns.find((c) => c.sortable)?.key, dir: -1 }
2262
2277
  );
@@ -2311,7 +2326,7 @@ function DataTable({
2311
2326
  const pageAllOn = selectable && slice.length > 0 && slice.every((r) => selected.has(r.name));
2312
2327
  const pageSomeOn = selectable && !pageAllOn && slice.some((r) => selected.has(r.name));
2313
2328
  return /* @__PURE__ */ jsxs19(Fragment12, { children: [
2314
- /* @__PURE__ */ jsx23(Wrap, { ...scrollable ? { className: "ui-table-scroll", role: "region", "aria-label": scrollLabel, tabIndex: 0 } : {}, children: /* @__PURE__ */ jsxs19(
2329
+ /* @__PURE__ */ jsx23(Wrap, { ...scrollable ? { ref: frame, className: "ui-table-scroll", role: "region", "aria-label": scrollLabel, tabIndex: overflows ? 0 : void 0, onFocus: reveal, onPointerDown: press(true), onPointerUp: press(false), onPointerCancel: press(false) } : {}, children: /* @__PURE__ */ jsxs19(
2315
2330
  "table",
2316
2331
  {
2317
2332
  ref: table,
@@ -3201,6 +3216,7 @@ function Dropdown({
3201
3216
  const uid = id ?? auto;
3202
3217
  const inField = useContext3(FieldContext);
3203
3218
  const fieldName = inField && id === inField.id && !(ariaLabel && triggerContent != null) ? { id: `${uid}-trigger`, labelId: inField.labelId, labelledBy: `${inField.labelId} ${uid}-trigger` } : null;
3219
+ const byContent = !fieldName && !ariaLabel && triggerContent != null ? `${uid}-trigger` : void 0;
3204
3220
  const setOpen = useCallback6((next) => {
3205
3221
  if (openProp === void 0) setSelfOpen(next);
3206
3222
  onOpenChange?.(next);
@@ -3630,7 +3646,7 @@ function Dropdown({
3630
3646
  disabled: disabled || void 0,
3631
3647
  "aria-haspopup": sx ? "dialog" : listRole,
3632
3648
  "aria-expanded": open,
3633
- id: fieldName?.id,
3649
+ id: fieldName?.id ?? byContent,
3634
3650
  "aria-label": ariaLabel && triggerContent != null ? ariaLabel : void 0,
3635
3651
  title,
3636
3652
  "aria-labelledby": fieldName?.labelledBy,
@@ -3665,7 +3681,7 @@ function Dropdown({
3665
3681
  "data-dropdown-panel": "",
3666
3682
  role: sx ? "dialog" : listRole,
3667
3683
  "aria-label": sx ? name : ariaLabel,
3668
- "aria-labelledby": !sx && !ariaLabel ? fieldName?.labelId : void 0,
3684
+ "aria-labelledby": !sx && !ariaLabel ? fieldName?.labelId ?? byContent : void 0,
3669
3685
  style: sx ? void 0 : cap,
3670
3686
  ref: panel,
3671
3687
  onClick: (e) => e.stopPropagation(),
@@ -4982,7 +4998,6 @@ function AccountMenu({ account, items, onSelect, withTheme, inPlace, away }) {
4982
4998
  align: "start",
4983
4999
  chevron: true,
4984
5000
  open,
4985
- ariaLabel: `Signed in as ${account.name}, ${account.email}`,
4986
5001
  triggerClass: "ui-app__user-trigger",
4987
5002
  panelClass: `ui-app__user-panel${sub && inPlace ? " is-sub" : ""}`,
4988
5003
  onOpenChange: (next) => {
@@ -4990,8 +5005,9 @@ function AccountMenu({ account, items, onSelect, withTheme, inPlace, away }) {
4990
5005
  if (!next) setSub(false);
4991
5006
  },
4992
5007
  triggerContent: /* @__PURE__ */ jsxs36(Fragment18, { children: [
5008
+ /* @__PURE__ */ jsx40("span", { className: "ui-sr", children: `Signed in as ${account.name}, ${account.email}` }),
4993
5009
  /* @__PURE__ */ jsx40("span", { className: "ui-app__av", "aria-hidden": "true", children: /* @__PURE__ */ jsx40(Avatar, { personKey: account.email || account.name, name: account.name, size: 32 }) }),
4994
- /* @__PURE__ */ jsxs36("span", { className: "ui-app__who", children: [
5010
+ /* @__PURE__ */ jsxs36("span", { className: "ui-app__who", "aria-hidden": "true", children: [
4995
5011
  /* @__PURE__ */ jsx40("b", { children: account.name }),
4996
5012
  /* @__PURE__ */ jsx40("span", { children: account.email })
4997
5013
  ] })
@@ -5269,11 +5285,13 @@ function AppShell({
5269
5285
  variant: "menu",
5270
5286
  align: "end",
5271
5287
  chevron: false,
5272
- ariaLabel: `Signed in as ${account.name}, ${account.email}`,
5273
5288
  title: `Signed in as ${account.name}, ${account.email}`,
5274
5289
  triggerClass: "ui-app__user-trigger",
5275
5290
  panelClass: "ui-app__user-panel",
5276
- triggerContent: /* @__PURE__ */ jsx41("span", { className: "ui-app__av", "aria-hidden": "true", children: /* @__PURE__ */ jsx41(Avatar, { personKey: account.email || account.name, name: account.name, size: 32 }) }),
5291
+ triggerContent: /* @__PURE__ */ jsxs37(Fragment19, { children: [
5292
+ /* @__PURE__ */ jsx41("span", { className: "ui-sr", children: `Signed in as ${account.name}, ${account.email}` }),
5293
+ /* @__PURE__ */ jsx41("span", { className: "ui-app__av", "aria-hidden": "true", children: /* @__PURE__ */ jsx41(Avatar, { personKey: account.email || account.name, name: account.name, size: 32 }) })
5294
+ ] }),
5277
5295
  header: /* @__PURE__ */ jsxs37("div", { className: "ui-dropdown__head", children: [
5278
5296
  /* @__PURE__ */ jsx41("b", { children: account.name }),
5279
5297
  /* @__PURE__ */ jsx41("span", { children: account.email })
@@ -5387,12 +5405,57 @@ function Footer({
5387
5405
  ] }) });
5388
5406
  }
5389
5407
 
5408
+ // src/ThemeChoice.tsx
5409
+ import { useId as useId16 } from "react";
5410
+ import { jsx as jsx44, jsxs as jsxs40 } from "react/jsx-runtime";
5411
+ var OPTIONS = [
5412
+ { value: "auto", name: "System" },
5413
+ { value: "light", name: "Light" },
5414
+ { value: "dark", name: "Dark" }
5415
+ ];
5416
+ var Scene = ({ theme }) => /* @__PURE__ */ jsxs40("span", { className: `ui-theme-choice__scene ui-theme-choice__scene--${theme}`, children: [
5417
+ /* @__PURE__ */ jsxs40("span", { className: "ui-theme-choice__rail", children: [
5418
+ /* @__PURE__ */ jsx44("span", {}),
5419
+ /* @__PURE__ */ jsx44("span", {}),
5420
+ /* @__PURE__ */ jsx44("span", {})
5421
+ ] }),
5422
+ /* @__PURE__ */ jsxs40("span", { className: "ui-theme-choice__main", children: [
5423
+ /* @__PURE__ */ jsx44("span", { className: "ui-theme-choice__title" }),
5424
+ /* @__PURE__ */ jsxs40("span", { className: "ui-theme-choice__card", children: [
5425
+ /* @__PURE__ */ jsx44("span", {}),
5426
+ /* @__PURE__ */ jsx44("span", {})
5427
+ ] })
5428
+ ] })
5429
+ ] });
5430
+ function ThemeChoice({ label = "Theme" }) {
5431
+ const { theme, set } = useThemeChoice();
5432
+ const name = useId16();
5433
+ return /* @__PURE__ */ jsx44("div", { className: "ui-theme-choice", role: "radiogroup", "aria-label": label, children: OPTIONS.map(({ value, name: text2 }) => /* @__PURE__ */ jsxs40("label", { className: "ui-theme-choice__option", children: [
5434
+ /* @__PURE__ */ jsx44(
5435
+ "input",
5436
+ {
5437
+ type: "radio",
5438
+ className: "ui-theme-choice__input ui-sr",
5439
+ name,
5440
+ value,
5441
+ checked: theme === value,
5442
+ onChange: () => set(value)
5443
+ }
5444
+ ),
5445
+ /* @__PURE__ */ jsxs40("span", { className: "ui-theme-choice__pic", "aria-hidden": "true", children: [
5446
+ value === "dark" ? /* @__PURE__ */ jsx44(Scene, { theme: "dark" }) : /* @__PURE__ */ jsx44(Scene, { theme: "light" }),
5447
+ value === "auto" && /* @__PURE__ */ jsx44(Scene, { theme: "dark" })
5448
+ ] }),
5449
+ /* @__PURE__ */ jsx44("span", { className: "ui-theme-choice__name", children: text2 })
5450
+ ] }, value)) });
5451
+ }
5452
+
5390
5453
  // src/Success.tsx
5391
5454
  import { forwardRef as forwardRef11, useEffect as useEffect20, useRef as useRef24, useState as useState20 } from "react";
5392
- import { jsx as jsx44, jsxs as jsxs40 } from "react/jsx-runtime";
5455
+ import { jsx as jsx45, jsxs as jsxs41 } from "react/jsx-runtime";
5393
5456
  var SuccessCheck = forwardRef11(function SuccessCheck2({ variant = "line", className, ...rest }, ref) {
5394
5457
  const circled = variant === "circled";
5395
- return /* @__PURE__ */ jsxs40(
5458
+ return /* @__PURE__ */ jsxs41(
5396
5459
  "svg",
5397
5460
  {
5398
5461
  ...rest,
@@ -5404,18 +5467,18 @@ var SuccessCheck = forwardRef11(function SuccessCheck2({ variant = "line", class
5404
5467
  "aria-hidden": "true",
5405
5468
  focusable: "false",
5406
5469
  children: [
5407
- circled && /* @__PURE__ */ jsx44("path", { className: "ui-sx__circle", d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
5408
- /* @__PURE__ */ jsx44("path", { className: "ui-sx__tick", d: circled ? "M22 4L12 14.01l-3-3" : "M20 6L9 17l-5-5" })
5470
+ circled && /* @__PURE__ */ jsx45("path", { className: "ui-sx__circle", d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
5471
+ /* @__PURE__ */ jsx45("path", { className: "ui-sx__tick", d: circled ? "M22 4L12 14.01l-3-3" : "M20 6L9 17l-5-5" })
5409
5472
  ]
5410
5473
  }
5411
5474
  );
5412
5475
  });
5413
5476
  var SuccessPanel = forwardRef11(function SuccessPanel2({ title = "Done", sub, check = "line", className, ...rest }, ref) {
5414
5477
  const circled = check === "circled";
5415
- return /* @__PURE__ */ jsxs40("div", { ...rest, ref, className: ["ui-success", className].filter(Boolean).join(" "), children: [
5416
- /* @__PURE__ */ jsx44("div", { className: ["ui-success__check", circled && "ui-success__check--circled"].filter(Boolean).join(" "), children: /* @__PURE__ */ jsx44(SuccessCheck, { variant: circled ? "circled" : "line" }) }),
5417
- /* @__PURE__ */ jsx44("div", { className: "ui-success__title", children: title }),
5418
- sub && /* @__PURE__ */ jsx44("div", { className: "ui-success__sub", children: sub })
5478
+ return /* @__PURE__ */ jsxs41("div", { ...rest, ref, className: ["ui-success", className].filter(Boolean).join(" "), children: [
5479
+ /* @__PURE__ */ jsx45("div", { className: ["ui-success__check", circled && "ui-success__check--circled"].filter(Boolean).join(" "), children: /* @__PURE__ */ jsx45(SuccessCheck, { variant: circled ? "circled" : "line" }) }),
5480
+ /* @__PURE__ */ jsx45("div", { className: "ui-success__title", children: title }),
5481
+ sub && /* @__PURE__ */ jsx45("div", { className: "ui-success__sub", children: sub })
5419
5482
  ] });
5420
5483
  });
5421
5484
  var pieces = [
@@ -5452,12 +5515,12 @@ function Countdown({ seconds, label = "Redirecting", onDone }) {
5452
5515
  }, 1e3);
5453
5516
  return () => clearInterval(timer);
5454
5517
  }, [seconds]);
5455
- return /* @__PURE__ */ jsxs40("div", { className: "ui-sx__count", "data-sx-count": "", style: { "--sx-secs": `${seconds}s` }, children: [
5456
- /* @__PURE__ */ jsx44("span", { className: "ui-sx__count-ring", "aria-hidden": "true" }),
5457
- /* @__PURE__ */ jsxs40("span", { className: "ui-sx__count-text", children: [
5518
+ return /* @__PURE__ */ jsxs41("div", { className: "ui-sx__count", "data-sx-count": "", style: { "--sx-secs": `${seconds}s` }, children: [
5519
+ /* @__PURE__ */ jsx45("span", { className: "ui-sx__count-ring", "aria-hidden": "true" }),
5520
+ /* @__PURE__ */ jsxs41("span", { className: "ui-sx__count-text", children: [
5458
5521
  label,
5459
5522
  " in ",
5460
- /* @__PURE__ */ jsx44("b", { "data-sx-num": "", children: remaining }),
5523
+ /* @__PURE__ */ jsx45("b", { "data-sx-num": "", children: remaining }),
5461
5524
  "s"
5462
5525
  ] })
5463
5526
  ] });
@@ -5484,7 +5547,7 @@ var Success = forwardRef11(function Success2({
5484
5547
  const seconds = countdown?.seconds;
5485
5548
  const duration = seconds != null && Number.isFinite(seconds) && seconds >= 1 ? Math.floor(seconds) : 5;
5486
5549
  const mark = check === "circled" ? "circled" : "line";
5487
- return /* @__PURE__ */ jsxs40(
5550
+ return /* @__PURE__ */ jsxs41(
5488
5551
  "div",
5489
5552
  {
5490
5553
  role: "status",
@@ -5493,16 +5556,16 @@ var Success = forwardRef11(function Success2({
5493
5556
  ref,
5494
5557
  className: ["ui-sx", `ui-sx--${layout}`, `ui-sx--check-${mark}`, confetti && "ui-sx--confetti", className].filter(Boolean).join(" "),
5495
5558
  children: [
5496
- confetti && /* @__PURE__ */ jsx44("div", { className: "ui-sx__confetti", "aria-hidden": "true", children: pieces.map(
5497
- ([x, d, r, t, s], index) => /* @__PURE__ */ jsx44("i", { className: `ui-sx__piece ui-sx__piece--${t}`, style: { left: `${x}%`, "--sx-d": `${d}s`, "--sx-r": `${r}deg`, "--sx-s": s } }, index)
5559
+ confetti && /* @__PURE__ */ jsx45("div", { className: "ui-sx__confetti", "aria-hidden": "true", children: pieces.map(
5560
+ ([x, d, r, t, s], index) => /* @__PURE__ */ jsx45("i", { className: `ui-sx__piece ui-sx__piece--${t}`, style: { left: `${x}%`, "--sx-d": `${d}s`, "--sx-r": `${r}deg`, "--sx-s": s } }, index)
5498
5561
  ) }),
5499
- /* @__PURE__ */ jsxs40("div", { className: "ui-sx__inner", children: [
5500
- /* @__PURE__ */ jsx44("div", { className: "ui-sx__visual", children: /* @__PURE__ */ jsx44(SuccessCheck, { variant: mark }) }),
5501
- /* @__PURE__ */ jsxs40("div", { className: "ui-sx__content", children: [
5502
- /* @__PURE__ */ jsx44(Heading, { className: "ui-sx__title", children: title }),
5503
- body && /* @__PURE__ */ jsx44("p", { className: "ui-sx__body", children: body }),
5504
- hasActions && /* @__PURE__ */ jsx44("div", { className: "ui-sx__actions", children: actions }),
5505
- countdown && /* @__PURE__ */ jsx44(Countdown, { seconds: duration, label: countdown.label, onDone: onCountdownEnd }, duration)
5562
+ /* @__PURE__ */ jsxs41("div", { className: "ui-sx__inner", children: [
5563
+ /* @__PURE__ */ jsx45("div", { className: "ui-sx__visual", children: /* @__PURE__ */ jsx45(SuccessCheck, { variant: mark }) }),
5564
+ /* @__PURE__ */ jsxs41("div", { className: "ui-sx__content", children: [
5565
+ /* @__PURE__ */ jsx45(Heading, { className: "ui-sx__title", children: title }),
5566
+ body && /* @__PURE__ */ jsx45("p", { className: "ui-sx__body", children: body }),
5567
+ hasActions && /* @__PURE__ */ jsx45("div", { className: "ui-sx__actions", children: actions }),
5568
+ countdown && /* @__PURE__ */ jsx45(Countdown, { seconds: duration, label: countdown.label, onDone: onCountdownEnd }, duration)
5506
5569
  ] })
5507
5570
  ] })
5508
5571
  ]
@@ -5515,7 +5578,7 @@ import {
5515
5578
  useCallback as useCallback8,
5516
5579
  useContext as useContext5,
5517
5580
  useEffect as useEffect21,
5518
- useId as useId16,
5581
+ useId as useId17,
5519
5582
  useLayoutEffect as useLayoutEffect5,
5520
5583
  useMemo as useMemo6,
5521
5584
  useRef as useRef25,
@@ -5525,7 +5588,7 @@ import { createPortal as createPortal8 } from "react-dom";
5525
5588
  import { CHART_FLOOR, bridgeWalk, chartScale, pointTarget } from "@apliteni/apliteni-ui";
5526
5589
 
5527
5590
  // src/chart-looks.tsx
5528
- import { Fragment as Fragment20, jsx as jsx45, jsxs as jsxs41 } from "react/jsx-runtime";
5591
+ import { Fragment as Fragment20, jsx as jsx46, jsxs as jsxs42 } from "react/jsx-runtime";
5529
5592
  var LOOK_DEFAULT = {
5530
5593
  line: "thin",
5531
5594
  area: "stacked",
@@ -5747,7 +5810,7 @@ function linesDrawing(g, open) {
5747
5810
  const [a, b] = [run[0], run[run.length - 1]];
5748
5811
  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`;
5749
5812
  }).join("");
5750
- return d && /* @__PURE__ */ jsx45(
5813
+ return d && /* @__PURE__ */ jsx46(
5751
5814
  "path",
5752
5815
  {
5753
5816
  className: cx8("ui-chart__area", tone(layer.tone)),
@@ -5757,7 +5820,7 @@ function linesDrawing(g, open) {
5757
5820
  `fill-${layer.id}`
5758
5821
  );
5759
5822
  }
5760
- return /* @__PURE__ */ jsx45(
5823
+ return /* @__PURE__ */ jsx46(
5761
5824
  "path",
5762
5825
  {
5763
5826
  className: cx8(look.share ? "ui-chart__segment" : "ui-chart__area", tone(layer.tone)),
@@ -5767,7 +5830,7 @@ function linesDrawing(g, open) {
5767
5830
  `fill-${layer.id}`
5768
5831
  );
5769
5832
  });
5770
- const edges = curves ? look.layers.flatMap((layer, k) => layer.to.slice(1).map((_, i) => finite(layer, i) && finite(layer, i + 1) ? /* @__PURE__ */ jsx45(
5833
+ const edges = curves ? look.layers.flatMap((layer, k) => layer.to.slice(1).map((_, i) => finite(layer, i) && finite(layer, i + 1) ? /* @__PURE__ */ jsx46(
5771
5834
  "path",
5772
5835
  {
5773
5836
  className: cx8(
@@ -5778,7 +5841,7 @@ function linesDrawing(g, open) {
5778
5841
  d: `M${px(centre(i))} ${px(y(at(layer, i)))}${bend(k, i)}`
5779
5842
  },
5780
5843
  `edge-${layer.id}-${i}`
5781
- ) : null)) : !look.share && look.layers.flatMap((layer) => layer.to.slice(1).map((_, k) => finite(layer, k) && finite(layer, k + 1) ? /* @__PURE__ */ jsx45(
5844
+ ) : null)) : !look.share && look.layers.flatMap((layer) => layer.to.slice(1).map((_, k) => finite(layer, k) && finite(layer, k + 1) ? /* @__PURE__ */ jsx46(
5782
5845
  "line",
5783
5846
  {
5784
5847
  className: cx8(
@@ -5800,7 +5863,7 @@ function linesDrawing(g, open) {
5800
5863
  const shown = i === open || points || lonely && !look.share;
5801
5864
  if (!shown || look.share && i !== open) return null;
5802
5865
  if (look.share && layer !== look.layers[look.layers.length - 1]) return null;
5803
- return /* @__PURE__ */ jsx45(
5866
+ return /* @__PURE__ */ jsx46(
5804
5867
  "circle",
5805
5868
  {
5806
5869
  className: cx8("ui-chart__dot", tone(layer.tone)),
@@ -5828,8 +5891,8 @@ function linesDrawing(g, open) {
5828
5891
  base = at2 + Math.max(drop, fall + gap + ascent);
5829
5892
  }
5830
5893
  }
5831
- return /* @__PURE__ */ jsxs41("g", { children: [
5832
- /* @__PURE__ */ jsx45(
5894
+ return /* @__PURE__ */ jsxs42("g", { children: [
5895
+ /* @__PURE__ */ jsx46(
5833
5896
  "circle",
5834
5897
  {
5835
5898
  className: cx8("ui-chart__dot", tone(layer.tone)),
@@ -5838,7 +5901,7 @@ function linesDrawing(g, open) {
5838
5901
  r: "4"
5839
5902
  }
5840
5903
  ),
5841
- /* @__PURE__ */ jsx45(
5904
+ /* @__PURE__ */ jsx46(
5842
5905
  "text",
5843
5906
  {
5844
5907
  className: "ui-chart__text ui-chart__text--strong",
@@ -5850,8 +5913,8 @@ function linesDrawing(g, open) {
5850
5913
  )
5851
5914
  ] }, `end-${layer.id}`);
5852
5915
  });
5853
- return /* @__PURE__ */ jsxs41(Fragment20, { children: [
5854
- ramps.some(Boolean) && /* @__PURE__ */ jsx45("defs", { children: ramps.map((ramp) => ramp && /* @__PURE__ */ jsxs41(
5916
+ return /* @__PURE__ */ jsxs42(Fragment20, { children: [
5917
+ ramps.some(Boolean) && /* @__PURE__ */ jsx46("defs", { children: ramps.map((ramp) => ramp && /* @__PURE__ */ jsxs42(
5855
5918
  "linearGradient",
5856
5919
  {
5857
5920
  id: ramp.id,
@@ -5862,14 +5925,14 @@ function linesDrawing(g, open) {
5862
5925
  y1: px(y(ramp.lo)),
5863
5926
  y2: px(y(ramp.hi)),
5864
5927
  children: [
5865
- /* @__PURE__ */ jsx45("stop", { className: curves ? "ui-chart__wash-floor" : "ui-chart__fade-base", offset: "0" }),
5866
- /* @__PURE__ */ jsx45("stop", { className: curves ? "ui-chart__wash-top" : "ui-chart__fade-end", offset: "1" })
5928
+ /* @__PURE__ */ jsx46("stop", { className: curves ? "ui-chart__wash-floor" : "ui-chart__fade-base", offset: "0" }),
5929
+ /* @__PURE__ */ jsx46("stop", { className: curves ? "ui-chart__wash-top" : "ui-chart__fade-end", offset: "1" })
5867
5930
  ]
5868
5931
  },
5869
5932
  ramp.id
5870
5933
  )) }),
5871
5934
  fills,
5872
- open !== null && /* @__PURE__ */ jsx45(
5935
+ open !== null && /* @__PURE__ */ jsx46(
5873
5936
  "line",
5874
5937
  {
5875
5938
  className: "ui-chart__cross",
@@ -5894,7 +5957,7 @@ function columnsDrawing(g) {
5894
5957
  const y1 = y(layer.to[i]);
5895
5958
  const x = centre(i) - w / 2;
5896
5959
  const d = layer === filled[filled.length - 1] ? topRounded(x, y1, w, y0 - y1, 4) : square(x, y1, w, y0 - y1);
5897
- return /* @__PURE__ */ jsx45(
5960
+ return /* @__PURE__ */ jsx46(
5898
5961
  "path",
5899
5962
  {
5900
5963
  className: cx8("ui-chart__segment", tone(layer.tone), label.estimated && "is-estimated"),
@@ -5909,10 +5972,10 @@ function rowsDrawing(g, pick) {
5909
5972
  const { look, labels, format, formatAxis, scale } = g;
5910
5973
  const rows = rowsOf(g);
5911
5974
  const bottom = rows.row * labels.length;
5912
- return /* @__PURE__ */ jsxs41(Fragment20, { children: [
5913
- pick !== null && pick >= 0 && pick < labels.length && /* @__PURE__ */ jsx45("rect", { className: "ui-chart__band", x: "0", width: px(rows.w), y: px(pick * rows.row), height: px(rows.row) }),
5914
- scale.ticks.map((tick) => /* @__PURE__ */ jsxs41("g", { children: [
5915
- /* @__PURE__ */ jsx45(
5975
+ return /* @__PURE__ */ jsxs42(Fragment20, { children: [
5976
+ pick !== null && pick >= 0 && pick < labels.length && /* @__PURE__ */ jsx46("rect", { className: "ui-chart__band", x: "0", width: px(rows.w), y: px(pick * rows.row), height: px(rows.row) }),
5977
+ scale.ticks.map((tick) => /* @__PURE__ */ jsxs42("g", { children: [
5978
+ /* @__PURE__ */ jsx46(
5916
5979
  "line",
5917
5980
  {
5918
5981
  className: tick === 0 ? "ui-chart__zero" : "ui-chart__grid",
@@ -5922,7 +5985,7 @@ function rowsDrawing(g, pick) {
5922
5985
  y2: px(bottom)
5923
5986
  }
5924
5987
  ),
5925
- /* @__PURE__ */ jsx45(
5988
+ /* @__PURE__ */ jsx46(
5926
5989
  "text",
5927
5990
  {
5928
5991
  className: "ui-chart__caption",
@@ -5937,8 +6000,8 @@ function rowsDrawing(g, pick) {
5937
6000
  labels.map((label, i) => {
5938
6001
  const top = rows.top(i);
5939
6002
  const filled = look.layers.filter((l) => l.to[i] > l.from[i]);
5940
- return /* @__PURE__ */ jsxs41("g", { children: [
5941
- /* @__PURE__ */ jsx45(
6003
+ return /* @__PURE__ */ jsxs42("g", { children: [
6004
+ /* @__PURE__ */ jsx46(
5942
6005
  "text",
5943
6006
  {
5944
6007
  className: "ui-chart__caption",
@@ -5953,7 +6016,7 @@ function rowsDrawing(g, pick) {
5953
6016
  const x0 = rows.x(layer.from[i]);
5954
6017
  const x1 = rows.x(layer.to[i]);
5955
6018
  const d = layer === filled[filled.length - 1] ? rightRounded(x0, top, x1 - x0, ROW_BAR, 4) : square(x0, top, x1 - x0, ROW_BAR);
5956
- return /* @__PURE__ */ jsx45(
6019
+ return /* @__PURE__ */ jsx46(
5957
6020
  "path",
5958
6021
  {
5959
6022
  d,
@@ -5962,7 +6025,7 @@ function rowsDrawing(g, pick) {
5962
6025
  `seg-${layer.id}`
5963
6026
  );
5964
6027
  }),
5965
- /* @__PURE__ */ jsx45(
6028
+ /* @__PURE__ */ jsx46(
5966
6029
  "text",
5967
6030
  {
5968
6031
  className: "ui-chart__text",
@@ -5980,8 +6043,8 @@ function ringDrawing(g) {
5980
6043
  const { look, format } = g;
5981
6044
  const ring = ringOf(g);
5982
6045
  const total = look.totals[0];
5983
- return /* @__PURE__ */ jsxs41(Fragment20, { children: [
5984
- look.layers.filter((s) => s.to[0] > s.from[0]).map((slice) => /* @__PURE__ */ jsx45(
6046
+ return /* @__PURE__ */ jsxs42(Fragment20, { children: [
6047
+ look.layers.filter((s) => s.to[0] > s.from[0]).map((slice) => /* @__PURE__ */ jsx46(
5985
6048
  "path",
5986
6049
  {
5987
6050
  className: cx8("ui-chart__segment", tone(slice.tone)),
@@ -5989,42 +6052,42 @@ function ringDrawing(g) {
5989
6052
  },
5990
6053
  `slice-${slice.id}`
5991
6054
  )),
5992
- look.look === "thin" && /* @__PURE__ */ jsxs41("g", { "aria-hidden": "true", children: [
5993
- /* @__PURE__ */ jsx45("text", { className: "ui-chart__total", textAnchor: "middle", x: px(ring.x), y: px(ring.y + 2), children: format(total) }),
5994
- /* @__PURE__ */ jsx45("text", { className: "ui-chart__caption", textAnchor: "middle", x: px(ring.x), y: px(ring.y + 22), children: look.totalLabel })
6055
+ look.look === "thin" && /* @__PURE__ */ jsxs42("g", { "aria-hidden": "true", children: [
6056
+ /* @__PURE__ */ jsx46("text", { className: "ui-chart__total", textAnchor: "middle", x: px(ring.x), y: px(ring.y + 2), children: format(total) }),
6057
+ /* @__PURE__ */ jsx46("text", { className: "ui-chart__caption", textAnchor: "middle", x: px(ring.x), y: px(ring.y + 22), children: look.totalLabel })
5995
6058
  ] }),
5996
6059
  look.look === "labels" && look.layers.filter((s) => s.to[0] > s.from[0]).map((slice) => {
5997
6060
  const mid = angle((slice.from[0] + slice.to[0]) / 2);
5998
6061
  const x = ring.x + (ring.r + 14) * Math.cos(mid);
5999
6062
  const y = ring.y + (ring.r + 14) * Math.sin(mid);
6000
6063
  const anchor = Math.cos(mid) >= 0 ? "start" : "end";
6001
- return /* @__PURE__ */ jsxs41("g", { "aria-hidden": "true", children: [
6002
- /* @__PURE__ */ jsx45("text", { className: "ui-chart__text ui-chart__text--strong", textAnchor: anchor, x: px(x), y: px(y - 2), children: slice.name }),
6003
- /* @__PURE__ */ jsx45("text", { className: "ui-chart__text", textAnchor: anchor, x: px(x), y: px(y + 13), children: `${format(slice.values[0])} ${pct(slice.to[0] - slice.from[0])}` })
6064
+ return /* @__PURE__ */ jsxs42("g", { "aria-hidden": "true", children: [
6065
+ /* @__PURE__ */ jsx46("text", { className: "ui-chart__text ui-chart__text--strong", textAnchor: anchor, x: px(x), y: px(y - 2), children: slice.name }),
6066
+ /* @__PURE__ */ jsx46("text", { className: "ui-chart__text", textAnchor: anchor, x: px(x), y: px(y + 13), children: `${format(slice.values[0])} ${pct(slice.to[0] - slice.from[0])}` })
6004
6067
  ] }, `label-${slice.id}`);
6005
6068
  })
6006
6069
  ] });
6007
6070
  }
6008
6071
  function Shares({ look, format, swatch }) {
6009
6072
  const total = look.totals[0];
6010
- return /* @__PURE__ */ jsxs41("ul", { className: "ui-chart__shares", "aria-hidden": "true", children: [
6011
- look.layers.map((slice) => /* @__PURE__ */ jsxs41("li", { className: tone(slice.tone), children: [
6073
+ return /* @__PURE__ */ jsxs42("ul", { className: "ui-chart__shares", "aria-hidden": "true", children: [
6074
+ look.layers.map((slice) => /* @__PURE__ */ jsxs42("li", { className: tone(slice.tone), children: [
6012
6075
  swatch,
6013
- /* @__PURE__ */ jsx45("span", { children: slice.name }),
6014
- /* @__PURE__ */ jsx45("span", { className: "ui-chart__shares-value", children: format(slice.values[0]) }),
6015
- /* @__PURE__ */ jsx45("span", { className: "ui-chart__shares-pct", children: total > 0 ? pct(slice.to[0] - slice.from[0]) : MISSING })
6076
+ /* @__PURE__ */ jsx46("span", { children: slice.name }),
6077
+ /* @__PURE__ */ jsx46("span", { className: "ui-chart__shares-value", children: format(slice.values[0]) }),
6078
+ /* @__PURE__ */ jsx46("span", { className: "ui-chart__shares-pct", children: total > 0 ? pct(slice.to[0] - slice.from[0]) : MISSING })
6016
6079
  ] }, slice.id)),
6017
- /* @__PURE__ */ jsxs41("li", { className: "ui-chart__shares-total", children: [
6018
- /* @__PURE__ */ jsx45("span", {}),
6019
- /* @__PURE__ */ jsx45("span", { children: look.totalLabel }),
6020
- /* @__PURE__ */ jsx45("span", { className: "ui-chart__shares-value", children: format(total) }),
6021
- /* @__PURE__ */ jsx45("span", { className: "ui-chart__shares-pct", children: "100%" })
6080
+ /* @__PURE__ */ jsxs42("li", { className: "ui-chart__shares-total", children: [
6081
+ /* @__PURE__ */ jsx46("span", {}),
6082
+ /* @__PURE__ */ jsx46("span", { children: look.totalLabel }),
6083
+ /* @__PURE__ */ jsx46("span", { className: "ui-chart__shares-value", children: format(total) }),
6084
+ /* @__PURE__ */ jsx46("span", { className: "ui-chart__shares-pct", children: "100%" })
6022
6085
  ] })
6023
6086
  ] });
6024
6087
  }
6025
6088
 
6026
6089
  // src/Chart.tsx
6027
- import { Fragment as Fragment21, jsx as jsx46, jsxs as jsxs42 } from "react/jsx-runtime";
6090
+ import { Fragment as Fragment21, jsx as jsx47, jsxs as jsxs43 } from "react/jsx-runtime";
6028
6091
  var HEIGHT = { months: 216, bridge: 216, spark: 32, line: 216, area: 216, stacked: 216, donut: 216 };
6029
6092
  var PAD = 2;
6030
6093
  var ZERO_INSET = 1.5;
@@ -6035,6 +6098,17 @@ var FALLBACK_COL = 48;
6035
6098
  var BAR_SHARE = 0.5;
6036
6099
  var BAR_MAX = 12;
6037
6100
  var BAR_MAX_BRIDGE = 22;
6101
+ var FIT_SHARE = 2 / 3;
6102
+ var FIT_MAX = 48;
6103
+ var FIT_CORNER = 6;
6104
+ var TEXT_GAP = 4;
6105
+ var LABEL_GAP = 8;
6106
+ var TEXT_SIZE = 12;
6107
+ var VALUE_ROOM = Math.ceil(TEXT_SIZE * 1.45) + TEXT_GAP;
6108
+ var GROUP_ROOM = 32;
6109
+ var GROUP_BASELINE = 16;
6110
+ var BOUNDARY_TOP = 24;
6111
+ var GROUP_WORDS = "Not final";
6038
6112
  var LANE_GAP = 2;
6039
6113
  var MISSING2 = "\u2014";
6040
6114
  function fadeOf(uid, m, bridge) {
@@ -6044,19 +6118,22 @@ function fadeOf(uid, m, bridge) {
6044
6118
  }
6045
6119
  var cx9 = (...parts) => parts.filter(Boolean).join(" ");
6046
6120
  var px2 = (n) => Math.round(n * 10) / 10;
6121
+ var STATE_WORD = { incomplete: "Incomplete", projected: "Projected" };
6047
6122
  var columnOf = (p, fallback) => ({
6048
6123
  label: p.label,
6049
6124
  short: p.short || fallback,
6050
6125
  estimated: Boolean(p.estimated),
6051
- note: p.note
6126
+ note: p.note,
6127
+ compare: !("compare" in p) || p.compare !== false,
6128
+ state: !p.estimated ? void 0 : p.estimated === true ? "Estimated" : STATE_WORD[p.estimated]
6052
6129
  });
6053
6130
  function onPrevious(value, previous, when) {
6054
6131
  if (previous === void 0 || previous === 0 || !Number.isFinite(previous) || !when) return "";
6055
6132
  const pct2 = (value - previous) / Math.abs(previous) * 100;
6056
6133
  return `${pct2 < 0 ? "\u2212" : "+"}${Math.abs(pct2).toFixed(1)}% on ${when}`;
6057
6134
  }
6058
- function barPath(m) {
6059
- const r = Math.min(m.w / 2, m.h / (m.foot ? 1 : 4));
6135
+ function barPath(m, corner = m.w / 2) {
6136
+ const r = Math.min(corner, m.w / 2, m.h / (m.foot ? 1 : 4));
6060
6137
  const { x, y: top, w, h } = m;
6061
6138
  const bottom = top + h;
6062
6139
  const arc2 = (dx, dy, sweep) => `a${px2(r)} ${px2(r)} 0 0 ${sweep} ${px2(dx)} ${px2(dy)}`;
@@ -6077,9 +6154,42 @@ function useTapFloor() {
6077
6154
  }, []);
6078
6155
  return floor;
6079
6156
  }
6157
+ function useTextWidth(host) {
6158
+ const [face, setFace] = useState21(null);
6159
+ const [loaded, setLoaded] = useState21(0);
6160
+ useEffect21(() => {
6161
+ const el = host.current;
6162
+ if (!el || typeof OffscreenCanvas === "undefined") return;
6163
+ const style = getComputedStyle(el);
6164
+ const font = (weight) => `${weight} ${TEXT_SIZE}px ${style.fontFamily}`;
6165
+ setFace({ regular: font(style.fontWeight), medium: font(style.getPropertyValue("--weight-medium").trim() || "500") });
6166
+ let live = true;
6167
+ el.ownerDocument.fonts?.ready.then(() => {
6168
+ if (live) setLoaded((n) => n + 1);
6169
+ });
6170
+ return () => {
6171
+ live = false;
6172
+ };
6173
+ }, [host]);
6174
+ return useMemo6(() => {
6175
+ void loaded;
6176
+ const ctx = face ? new OffscreenCanvas(1, 1).getContext("2d") : null;
6177
+ return (text2, medium = false) => {
6178
+ if (!ctx || !face) return text2.length * TEXT_SIZE * 0.62;
6179
+ ctx.font = medium ? face.medium : face.regular;
6180
+ return Math.ceil(ctx.measureText(text2).width);
6181
+ };
6182
+ }, [face, loaded]);
6183
+ }
6184
+ function barValue(bar) {
6185
+ return bar.band === "down" ? bar.from - bar.to : bar.to - bar.from;
6186
+ }
6187
+ function printsBelow(bar) {
6188
+ return bar.to < bar.from;
6189
+ }
6080
6190
  function stateOf(column) {
6081
- if (!column?.estimated) return "";
6082
- return column.note ? `Estimated \u2014 ${column.note}` : "Estimated";
6191
+ if (!column?.state) return "";
6192
+ return column.note ? `${column.state} \u2014 ${column.note}` : column.state;
6083
6193
  }
6084
6194
  function seriesFrame(periods, series, spark, format) {
6085
6195
  const columns = periods.map((p) => columnOf(p, p.label.split(" ")[0]));
@@ -6112,7 +6222,7 @@ function seriesFrame(periods, series, spark, format) {
6112
6222
  column: i,
6113
6223
  from: 0,
6114
6224
  to: below ? -value : value,
6115
- detail: onPrevious(value, s.values[i - 1], columns[i - 1]?.short ?? ""),
6225
+ detail: columns[i].compare ? onPrevious(value, s.values[i - 1], columns[i - 1]?.short ?? "") : "",
6116
6226
  band,
6117
6227
  lane,
6118
6228
  lanes
@@ -6245,7 +6355,7 @@ function donutFrame(look, slices, totalLabel, format) {
6245
6355
  to: [total > 0 ? at / total : 0]
6246
6356
  };
6247
6357
  });
6248
- const columns = slices.map((s) => ({ label: s.name, short: s.name, estimated: false }));
6358
+ const columns = slices.map((s) => ({ label: s.name, short: s.name, estimated: false, compare: false }));
6249
6359
  return {
6250
6360
  columns,
6251
6361
  scale: { min: 0, max: 1, step: 1, ticks: [] },
@@ -6275,9 +6385,9 @@ function donutFrame(look, slices, totalLabel, format) {
6275
6385
  }
6276
6386
  function KeyMark({ shape }) {
6277
6387
  if (shape === "line") {
6278
- return /* @__PURE__ */ jsx46("svg", { className: "ui-chart__key-mark", width: "18", height: "12", viewBox: "0 0 18 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx46("path", { className: "ui-chart__key-line", d: "M1 9 L6 5 L12 7 L17 3" }) });
6388
+ return /* @__PURE__ */ jsx47("svg", { className: "ui-chart__key-mark", width: "18", height: "12", viewBox: "0 0 18 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx47("path", { className: "ui-chart__key-line", d: "M1 9 L6 5 L12 7 L17 3" }) });
6279
6389
  }
6280
- return /* @__PURE__ */ jsx46("svg", { className: "ui-chart__key-mark", width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: shape === "fill" ? /* @__PURE__ */ jsx46("rect", { className: "ui-chart__key-swatch", x: "1", y: "1", width: "10", height: "10", rx: "2.5" }) : /* @__PURE__ */ jsx46(
6390
+ return /* @__PURE__ */ jsx47("svg", { className: "ui-chart__key-mark", width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: shape === "fill" ? /* @__PURE__ */ jsx47("rect", { className: "ui-chart__key-swatch", x: "1", y: "1", width: "10", height: "10", rx: "2.5" }) : /* @__PURE__ */ jsx47(
6281
6391
  "path",
6282
6392
  {
6283
6393
  className: "ui-chart__key-swatch",
@@ -6300,11 +6410,13 @@ function Chart(props) {
6300
6410
  } = props;
6301
6411
  const variant = props.variant ?? "months";
6302
6412
  const spark = variant === "spark";
6413
+ const fit = variant === "months";
6414
+ const showValues = fit && "values" in props && props.values === true;
6303
6415
  const plotHeight = height ?? HEIGHT[variant];
6304
6416
  const showTable = table ?? !spark;
6305
6417
  const [view, setView] = useState21("chart");
6306
6418
  const asTable = showTable && view === "table";
6307
- const uid = useId16().replace(/[^\w-]/g, "");
6419
+ const uid = useId17().replace(/[^\w-]/g, "");
6308
6420
  const frameEl = useRef25(null);
6309
6421
  const card = useContext5(CardTools);
6310
6422
  const claim = card?.claim;
@@ -6320,7 +6432,9 @@ function Chart(props) {
6320
6432
  const opening = useRef25(false);
6321
6433
  const pointerFocus = useRef25(false);
6322
6434
  const floor = useTapFloor();
6435
+ const textWidth = useTextWidth(frameEl);
6323
6436
  const [width, setWidth] = useState21(0);
6437
+ const [boxWidth, setBoxWidth] = useState21(0);
6324
6438
  const [overflows, setOverflows] = useState21(false);
6325
6439
  const [openId, setOpenId] = useState21(null);
6326
6440
  const [rawCursor, setCursor] = useState21(0);
@@ -6349,20 +6463,33 @@ function Chart(props) {
6349
6463
  const boxHeight = Math.max(plotHeight, floor);
6350
6464
  const boxTop = -(boxHeight - plotHeight) / 2;
6351
6465
  const span = scale.max - scale.min || 1;
6466
+ const groupFrom = fit ? columns.findIndex((c) => c.estimated) : -1;
6467
+ const lanes = Math.max(1, ...frame.bars.map((b) => b.lanes));
6468
+ const cap = fit ? FIT_MAX : variant === "bridge" ? BAR_MAX_BRIDGE : BAR_MAX;
6469
+ const groupWidth = fit ? Math.max(lanes * 2, Math.min(colWidth * FIT_SHARE, cap * lanes + LANE_GAP * (lanes - 1))) : Math.max(4, Math.min(colWidth * BAR_SHARE, colWidth - 6, cap * lanes + LANE_GAP * (lanes - 1)));
6470
+ const barWidth = Math.max(1, (groupWidth - LANE_GAP * (lanes - 1)) / lanes);
6471
+ const centre = useCallback8((column) => column * colWidth + colWidth / 2, [colWidth]);
6472
+ const barX = useCallback8((bar) => centre(bar.column) - (bar.lanes * barWidth + LANE_GAP * (bar.lanes - 1)) / 2 + bar.lane * (barWidth + LANE_GAP), [centre, barWidth]);
6473
+ const under = useMemo6(() => new Set(frame.bars.filter(printsBelow).map((b) => b.id)), [frame.bars]);
6474
+ const printed = useMemo6(() => {
6475
+ const out = /* @__PURE__ */ new Set();
6476
+ if (!showValues) return out;
6477
+ const at = frame.bars.map((bar) => ({ bar, x: barX(bar) + barWidth / 2 }));
6478
+ for (const { bar, x } of at) {
6479
+ const side = at.filter((o) => o.bar !== bar && under.has(o.bar.id) === under.has(bar.id));
6480
+ const left = Math.min(2 * x, ...side.filter((o) => o.x <= x).map((o) => x - o.x));
6481
+ const right = Math.min(2 * (plotWidth - x), ...side.filter((o) => o.x > x).map((o) => o.x - x));
6482
+ if (textWidth(formatAxis(barValue(bar))) + TEXT_GAP <= Math.min(left, right)) out.add(bar.id);
6483
+ }
6484
+ return out;
6485
+ }, [showValues, frame.bars, under, barX, barWidth, plotWidth, textWidth, formatAxis]);
6486
+ const roomTop = (groupFrom >= 0 ? GROUP_ROOM : 0) + ([...printed].some((id) => !under.has(id)) ? VALUE_ROOM : 0);
6487
+ const roomBottom = [...printed].some((id) => under.has(id)) ? VALUE_ROOM : 0;
6352
6488
  const y = useCallback8(
6353
- (value) => PAD + (scale.max - value) / span * (plotHeight - PAD * 2),
6354
- [scale.max, span, plotHeight]
6489
+ (value) => PAD + roomTop + (scale.max - value) / span * (plotHeight - PAD * 2 - roomTop - roomBottom),
6490
+ [scale.max, span, plotHeight, roomTop, roomBottom]
6355
6491
  );
6356
6492
  const zero = y(Math.min(Math.max(0, scale.min), scale.max));
6357
- const lanes = Math.max(1, ...frame.bars.map((b) => b.lanes));
6358
- const cap = variant === "bridge" ? BAR_MAX_BRIDGE : BAR_MAX;
6359
- const groupWidth = Math.max(4, Math.min(
6360
- colWidth * BAR_SHARE,
6361
- colWidth - 6,
6362
- cap * lanes + LANE_GAP * (lanes - 1)
6363
- ));
6364
- const barWidth = (groupWidth - LANE_GAP * (lanes - 1)) / lanes;
6365
- const centre = useCallback8((column) => column * colWidth + colWidth / 2, [colWidth]);
6366
6493
  const axisFormat = look?.share ? pct : formatAxis;
6367
6494
  const geometry = useMemo6(() => look ? {
6368
6495
  look,
@@ -6402,7 +6529,7 @@ function Chart(props) {
6402
6529
  column: bar.column,
6403
6530
  name: bar.name,
6404
6531
  tone: bar.tone,
6405
- value: bar.band === "down" ? bar.from - bar.to : bar.to - bar.from,
6532
+ value: barValue(bar),
6406
6533
  detail: bar.detail,
6407
6534
  kind: "bar",
6408
6535
  band: bar.band,
@@ -6413,7 +6540,7 @@ function Chart(props) {
6413
6540
  // the lanes it actually has: a chart with two series above the line and
6414
6541
  // one below puts the single one in the middle of its column rather than
6415
6542
  // in the left half of a group it does not fill.
6416
- x: centre(bar.column) - (bar.lanes * barWidth + LANE_GAP * (bar.lanes - 1)) / 2 + bar.lane * (barWidth + LANE_GAP),
6543
+ x: barX(bar),
6417
6544
  y: top,
6418
6545
  w: barWidth,
6419
6546
  h: Math.max(bottom - top, 1),
@@ -6430,7 +6557,7 @@ function Chart(props) {
6430
6557
  name: keys.find((k) => k.id === line.id)?.name ?? line.id,
6431
6558
  tone: line.tone,
6432
6559
  value,
6433
- detail: onPrevious(value, line.values[i - 1], columns[i - 1]?.short ?? ""),
6560
+ detail: columns[i]?.compare ? onPrevious(value, line.values[i - 1], columns[i - 1]?.short ?? "") : "",
6434
6561
  kind: "dot",
6435
6562
  band: "full",
6436
6563
  foot: null,
@@ -6453,9 +6580,10 @@ function Chart(props) {
6453
6580
  );
6454
6581
  }
6455
6582
  return [...out, ...dots];
6456
- }, [geometry, frame, lines, keys, columns, centre, barWidth, groupWidth, y, floor, colWidth, plotWidth, boxTop, boxHeight]);
6583
+ }, [geometry, frame, lines, keys, columns, centre, barX, barWidth, groupWidth, y, floor, colWidth, plotWidth, boxTop, boxHeight]);
6457
6584
  const byId = useMemo6(() => new Map(marks.map((m) => [m.id, m])), [marks]);
6458
- 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]);
6585
+ const fadeFor = useCallback8((m) => fit ? null : fadeOf(uid, m, variant === "bridge"), [fit, uid, variant]);
6586
+ const fades = useMemo6(() => new Map(marks.filter((m) => m.kind === "bar").map(fadeFor).filter((f) => f !== null).map((f) => [f.id, f])), [marks, fadeFor]);
6459
6587
  const lead = useCallback8((column) => marks.find((m) => m.column === column), [marks]);
6460
6588
  const open = openId ? byId.get(openId) : void 0;
6461
6589
  useEffect21(() => {
@@ -6464,6 +6592,7 @@ function Chart(props) {
6464
6592
  if (!el || !box2) return;
6465
6593
  const read = () => {
6466
6594
  setWidth(el.clientWidth);
6595
+ setBoxWidth(box2.clientWidth);
6467
6596
  setOverflows(box2.scrollWidth > box2.clientWidth);
6468
6597
  };
6469
6598
  read();
@@ -6473,15 +6602,15 @@ function Chart(props) {
6473
6602
  observer.observe(box2);
6474
6603
  return () => observer.disconnect();
6475
6604
  }, []);
6476
- const opensAtEnd = variant === "line" && lookName === "labels";
6605
+ const opensAtEnd = Boolean(periods);
6477
6606
  useLayoutEffect5(() => {
6478
6607
  const el = scroller.current;
6479
6608
  if (opensAtEnd && el) el.scrollLeft = el.scrollWidth - el.clientWidth;
6480
- }, [opensAtEnd, plotWidth, count]);
6609
+ }, [opensAtEnd, plotWidth, boxWidth, count]);
6481
6610
  useLayoutEffect5(() => {
6482
6611
  if (!openId || !frameEl.current || !tipEl.current || !svgEl.current) return;
6483
- const anchor = [...svgEl.current.querySelectorAll("[data-anchor]")].find((el) => el.getAttribute("data-anchor") === openId);
6484
- if (anchor) placeTip(frameEl.current, anchor, tipEl.current, frameEl.current);
6612
+ const anchor2 = [...svgEl.current.querySelectorAll("[data-anchor]")].find((el) => el.getAttribute("data-anchor") === openId);
6613
+ if (anchor2) placeTip(frameEl.current, anchor2, tipEl.current);
6485
6614
  }, [openId, plotWidth, plotHeight]);
6486
6615
  useEffect21(() => {
6487
6616
  if (!openId) return;
@@ -6522,6 +6651,16 @@ function Chart(props) {
6522
6651
  const state = stateOf(where);
6523
6652
  setSaid(`${where.label}. ${values}.${state ? ` ${state}.` : ""}${picked === column ? " Selected." : ""}`);
6524
6653
  }, [columns, marks, format, pick, totalLabel]);
6654
+ const inView = (column) => {
6655
+ const el = scroller.current;
6656
+ if (!el || el.scrollWidth <= el.clientWidth || !colWidth) return column;
6657
+ const first = Math.min(count - 1, Math.max(0, Math.ceil(el.scrollLeft / colWidth - 0.01)));
6658
+ const last = Math.max(first, Math.min(
6659
+ count - 1,
6660
+ Math.floor((el.scrollLeft + el.clientWidth) / colWidth + 0.01) - 1
6661
+ ));
6662
+ return Math.min(Math.max(column, first), last);
6663
+ };
6525
6664
  const step = (next) => {
6526
6665
  const column = Math.max(0, Math.min(next, count - 1));
6527
6666
  setCursor(column);
@@ -6556,21 +6695,13 @@ function Chart(props) {
6556
6695
  announce(cursor, cursor);
6557
6696
  }
6558
6697
  };
6559
- const estimated = columns.filter((c) => c.estimated);
6560
- const estimatedTone = marks.find((m) => m.estimated && m.kind === "bar")?.tone ?? keys[0]?.tone ?? "neutral";
6561
6698
  const hitBand = (band) => band === "up" ? { y: PAD, h: Math.max(zero - PAD, TARGET) } : band === "down" ? { y: zero, h: Math.max(plotHeight - PAD - zero, TARGET) } : { y: PAD, h: Math.max(plotHeight - PAD * 2, TARGET) };
6562
6699
  const legendFirst = !(look?.variant === "donut" && look.look !== "labels");
6563
- const legend = keyed && !asTable && keys.length > 0 && !(look?.variant === "donut" && look.look === "table") && /* @__PURE__ */ jsxs42("ul", { className: "ui-chart__legend", children: [
6564
- keys.map((key) => /* @__PURE__ */ jsxs42("li", { className: cx9("ui-chart__key", `ui-chart__tone--${key.tone}`), children: [
6565
- /* @__PURE__ */ jsx46(KeyMark, { shape: key.shape }),
6566
- key.name
6567
- ] }, key.id)),
6568
- estimated.length > 0 && /* @__PURE__ */ jsxs42("li", { className: cx9("ui-chart__key", `ui-chart__tone--${estimatedTone}`), children: [
6569
- /* @__PURE__ */ jsx46("svg", { className: "ui-chart__key-mark", width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx46("rect", { className: "ui-chart__key-estimated", x: "1.5", y: "1.5", width: "9", height: "9", rx: "2.5" }) }),
6570
- "Estimated"
6571
- ] })
6572
- ] });
6573
- const viewSwitch = showTable && /* @__PURE__ */ jsx46(
6700
+ const legend = keyed && !asTable && keys.length > 0 && !(look?.variant === "donut" && look.look === "table") && /* @__PURE__ */ jsx47("ul", { className: "ui-chart__legend", children: keys.map((key) => /* @__PURE__ */ jsxs43("li", { className: cx9("ui-chart__key", `ui-chart__tone--${key.tone}`), children: [
6701
+ /* @__PURE__ */ jsx47(KeyMark, { shape: key.shape }),
6702
+ key.name
6703
+ ] }, key.id)) });
6704
+ const viewSwitch = showTable && /* @__PURE__ */ jsx47(
6574
6705
  Segmented,
6575
6706
  {
6576
6707
  size: "sm",
@@ -6584,7 +6715,16 @@ function Chart(props) {
6584
6715
  }
6585
6716
  );
6586
6717
  const noun = look?.layout === "ring" ? "slices" : look?.layout === "rows" ? "rows" : "columns";
6587
- return /* @__PURE__ */ jsxs42(
6718
+ const labelRoom = Math.max(0, ...columns.map((c) => textWidth(c.short))) + LABEL_GAP;
6719
+ const every = labelRoom > colWidth ? Math.ceil(labelRoom / colWidth) : 1;
6720
+ const anchor = groupFrom >= 0 ? groupFrom : count - 1;
6721
+ const labelled = (i) => ((anchor - i) % every + every) % every === 0;
6722
+ const edgeOf = (i) => {
6723
+ const half = textWidth(columns[i].short) / 2;
6724
+ return centre(i) - half < 0 ? "is-start" : centre(i) + half > plotWidth ? "is-end" : null;
6725
+ };
6726
+ const groupX = groupFrom >= 0 ? Math.min(Math.max(groupFrom * colWidth, 1), plotWidth - 1) : 0;
6727
+ return /* @__PURE__ */ jsxs43(
6588
6728
  "div",
6589
6729
  {
6590
6730
  className: cx9(
@@ -6598,15 +6738,17 @@ function Chart(props) {
6598
6738
  "--ui-chart-h": `${plotHeight}px`,
6599
6739
  "--ui-chart-box": `${px2(boxHeight)}px`,
6600
6740
  "--ui-chart-cols": count,
6601
- "--ui-chart-pad": `${PAD}px`
6741
+ "--ui-chart-pad": `${PAD}px`,
6742
+ "--ui-chart-top": `${PAD + roomTop}px`,
6743
+ "--ui-chart-bottom": `${PAD + roomBottom}px`
6602
6744
  },
6603
6745
  children: [
6604
6746
  toCard && createPortal8(viewSwitch, toCard),
6605
- (showTable && !toCard || legendFirst && legend) && /* @__PURE__ */ jsxs42("div", { className: "ui-chart__head", children: [
6747
+ (showTable && !toCard || legendFirst && legend) && /* @__PURE__ */ jsxs43("div", { className: "ui-chart__head", children: [
6606
6748
  legendFirst && legend,
6607
6749
  !toCard && viewSwitch
6608
6750
  ] }),
6609
- /* @__PURE__ */ jsxs42(
6751
+ /* @__PURE__ */ jsxs43(
6610
6752
  "div",
6611
6753
  {
6612
6754
  ref: frameEl,
@@ -6622,17 +6764,20 @@ function Chart(props) {
6622
6764
  pointerFocus.current = false;
6623
6765
  return;
6624
6766
  }
6625
- show(lead(cursor)?.id);
6626
- announce(cursor);
6767
+ const column = inView(cursor);
6768
+ setCursor(column);
6769
+ show(lead(column)?.id);
6770
+ announce(column);
6627
6771
  },
6628
6772
  onBlur: (event) => {
6629
6773
  if (event.target !== event.currentTarget) return;
6774
+ if (pointerFocus.current) return;
6630
6775
  setOpenId(null);
6631
6776
  setSaid("");
6632
6777
  },
6633
6778
  children: [
6634
- !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)) }),
6635
- /* @__PURE__ */ jsx46(
6779
+ !spark && columnsLayout && scale.ticks.length > 0 && /* @__PURE__ */ jsx47("div", { className: "ui-chart__axis", "aria-hidden": "true", children: [...scale.ticks].reverse().map((tick) => /* @__PURE__ */ jsx47("span", { className: "ui-chart__tick", children: axisFormat(tick) }, tick)) }),
6780
+ /* @__PURE__ */ jsx47(
6636
6781
  "div",
6637
6782
  {
6638
6783
  ref: scroller,
@@ -6641,15 +6786,15 @@ function Chart(props) {
6641
6786
  role: overflows ? "region" : void 0,
6642
6787
  "aria-label": overflows ? `${title}. Scroll for more ${noun}.` : void 0,
6643
6788
  onScroll: () => {
6644
- const anchor = [...svgEl.current?.querySelectorAll("[data-anchor]") ?? []].find((el) => el.getAttribute("data-anchor") === openId);
6645
- if (!anchor || !scroller.current || !frameEl.current || !tipEl.current) return;
6646
- const mark = anchor.getBoundingClientRect();
6789
+ const anchor2 = [...svgEl.current?.querySelectorAll("[data-anchor]") ?? []].find((el) => el.getAttribute("data-anchor") === openId);
6790
+ if (!anchor2 || !scroller.current || !frameEl.current || !tipEl.current) return;
6791
+ const mark = anchor2.getBoundingClientRect();
6647
6792
  const view2 = scroller.current.getBoundingClientRect();
6648
6793
  if (mark.right <= view2.left || mark.left >= view2.right) setOpenId(null);
6649
- else placeTip(frameEl.current, anchor, tipEl.current, frameEl.current);
6794
+ else placeTip(frameEl.current, anchor2, tipEl.current);
6650
6795
  },
6651
- children: /* @__PURE__ */ jsxs42("div", { ref: plot, className: "ui-chart__plot", children: [
6652
- /* @__PURE__ */ jsxs42(
6796
+ children: /* @__PURE__ */ jsxs43("div", { ref: plot, className: "ui-chart__plot", children: [
6797
+ /* @__PURE__ */ jsxs43(
6653
6798
  "svg",
6654
6799
  {
6655
6800
  ref: svgEl,
@@ -6687,7 +6832,8 @@ function Chart(props) {
6687
6832
  opening.current = false;
6688
6833
  setOpenId(null);
6689
6834
  } else {
6690
- opening.current = Boolean(id) && dismissed.current !== id;
6835
+ dismissed.current = null;
6836
+ opening.current = Boolean(id);
6691
6837
  show(id);
6692
6838
  }
6693
6839
  },
@@ -6710,7 +6856,7 @@ function Chart(props) {
6710
6856
  announce(mark.column, selectable ? mark.column : pick);
6711
6857
  },
6712
6858
  children: [
6713
- !spark && columnsLayout && pick !== null && pick >= 0 && pick < count && /* @__PURE__ */ jsx46(
6859
+ !spark && columnsLayout && pick !== null && pick >= 0 && pick < count && /* @__PURE__ */ jsx47(
6714
6860
  "rect",
6715
6861
  {
6716
6862
  className: "ui-chart__band",
@@ -6723,7 +6869,7 @@ function Chart(props) {
6723
6869
  frame.links && frame.bars.slice(0, -1).map((bar, i) => {
6724
6870
  const from = byId.get(bar.id);
6725
6871
  const to = byId.get(frame.bars[i + 1].id);
6726
- return from && to ? /* @__PURE__ */ jsx46(
6872
+ return from && to ? /* @__PURE__ */ jsx47(
6727
6873
  "line",
6728
6874
  {
6729
6875
  className: "ui-chart__carry",
@@ -6735,7 +6881,7 @@ function Chart(props) {
6735
6881
  `carry-${bar.id}`
6736
6882
  ) : null;
6737
6883
  }),
6738
- !spark && columnsLayout && scale.ticks.filter((tick) => tick !== 0).map((tick) => /* @__PURE__ */ jsx46(
6884
+ !spark && columnsLayout && scale.ticks.filter((tick) => tick !== 0).map((tick) => /* @__PURE__ */ jsx47(
6739
6885
  "line",
6740
6886
  {
6741
6887
  className: "ui-chart__grid",
@@ -6746,7 +6892,7 @@ function Chart(props) {
6746
6892
  },
6747
6893
  `grid-${tick}`
6748
6894
  )),
6749
- !spark && columnsLayout && scale.ticks.includes(0) && /* @__PURE__ */ jsx46(
6895
+ !spark && columnsLayout && scale.ticks.includes(0) && /* @__PURE__ */ jsx47(
6750
6896
  "line",
6751
6897
  {
6752
6898
  className: "ui-chart__zero",
@@ -6756,7 +6902,28 @@ function Chart(props) {
6756
6902
  y2: px2(y(0))
6757
6903
  }
6758
6904
  ),
6759
- fades.size > 0 && /* @__PURE__ */ jsx46("defs", { children: [...fades.values()].map((fade) => /* @__PURE__ */ jsxs42(
6905
+ groupFrom >= 0 && /* @__PURE__ */ jsxs43(Fragment21, { children: [
6906
+ /* @__PURE__ */ jsx47(
6907
+ "line",
6908
+ {
6909
+ className: "ui-chart__boundary",
6910
+ x1: px2(groupX),
6911
+ x2: px2(groupX),
6912
+ y1: BOUNDARY_TOP,
6913
+ y2: px2(plotHeight - PAD)
6914
+ }
6915
+ ),
6916
+ /* @__PURE__ */ jsx47(
6917
+ "text",
6918
+ {
6919
+ className: "ui-chart__text ui-chart__group",
6920
+ y: GROUP_BASELINE,
6921
+ x: px2(Math.max(0, Math.min(groupX + TEXT_GAP, plotWidth - textWidth(GROUP_WORDS, true)))),
6922
+ children: GROUP_WORDS
6923
+ }
6924
+ )
6925
+ ] }),
6926
+ fades.size > 0 && /* @__PURE__ */ jsx47("defs", { children: [...fades.values()].map((fade) => /* @__PURE__ */ jsxs43(
6760
6927
  "linearGradient",
6761
6928
  {
6762
6929
  id: fade.id,
@@ -6766,15 +6933,15 @@ function Chart(props) {
6766
6933
  y1: fade.up ? "1" : "0",
6767
6934
  y2: fade.up ? "0" : "1",
6768
6935
  children: [
6769
- /* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-base", offset: "0" }),
6770
- /* @__PURE__ */ jsx46("stop", { className: "ui-chart__fade-end", offset: "1" })
6936
+ /* @__PURE__ */ jsx47("stop", { className: "ui-chart__fade-base", offset: "0" }),
6937
+ /* @__PURE__ */ jsx47("stop", { className: "ui-chart__fade-end", offset: "1" })
6771
6938
  ]
6772
6939
  },
6773
6940
  fade.id
6774
6941
  )) }),
6775
6942
  marks.filter((m) => m.kind === "bar").map((mark) => {
6776
- const fade = fadeOf(uid, mark, variant === "bridge");
6777
- return /* @__PURE__ */ jsx46(
6943
+ const fade = fadeFor(mark);
6944
+ return /* @__PURE__ */ jsx47(
6778
6945
  "path",
6779
6946
  {
6780
6947
  className: cx9(
@@ -6783,13 +6950,27 @@ function Chart(props) {
6783
6950
  mark.estimated && "is-estimated"
6784
6951
  ),
6785
6952
  style: fade ? { "--ui-chart-paint": `url(#${fade.id})` } : void 0,
6786
- d: barPath(mark)
6953
+ d: fit ? barPath(mark, px2(Math.min(FIT_CORNER, mark.w / 4))) : barPath(mark)
6787
6954
  },
6788
6955
  `bar-${mark.id}`
6789
6956
  );
6790
6957
  }),
6958
+ marks.filter((m) => m.kind === "bar" && printed.has(m.id)).map((mark) => {
6959
+ const text2 = formatAxis(mark.value);
6960
+ const below = under.has(mark.id);
6961
+ return /* @__PURE__ */ jsx47(
6962
+ "text",
6963
+ {
6964
+ className: cx9("ui-chart__text", "ui-chart__value", below && "ui-chart__value--below"),
6965
+ x: px2(mark.x + mark.w / 2),
6966
+ y: px2(below ? mark.y + mark.h + TEXT_GAP : mark.y - TEXT_GAP),
6967
+ children: text2
6968
+ },
6969
+ `value-${mark.id}`
6970
+ );
6971
+ }),
6791
6972
  ["casing", "stroke"].map((layer) => lines.flatMap(
6792
- (line) => line.values.slice(1).map((value, i) => Number.isFinite(value) && Number.isFinite(line.values[i]) ? /* @__PURE__ */ jsx46(
6973
+ (line) => line.values.slice(1).map((value, i) => Number.isFinite(value) && Number.isFinite(line.values[i]) ? /* @__PURE__ */ jsx47(
6793
6974
  "line",
6794
6975
  {
6795
6976
  className: layer === "casing" ? "ui-chart__line-casing" : cx9(
@@ -6805,7 +6986,7 @@ function Chart(props) {
6805
6986
  `${line.id}-${layer}-${i}`
6806
6987
  ) : null)
6807
6988
  )),
6808
- 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(
6989
+ lines.flatMap((line) => line.values.map((value, i) => Number.isFinite(value) && !Number.isFinite(line.values[i - 1]) && !Number.isFinite(line.values[i + 1]) ? /* @__PURE__ */ jsx47(
6809
6990
  "circle",
6810
6991
  {
6811
6992
  className: cx9("ui-chart__isolated", `ui-chart__tone--${line.tone}`),
@@ -6816,8 +6997,8 @@ function Chart(props) {
6816
6997
  `isolated-${line.id}-${i}`
6817
6998
  ) : null)),
6818
6999
  geometry && lookDrawing(geometry, open?.column ?? null, pick),
6819
- marks.map((mark) => /* @__PURE__ */ jsxs42("g", { "data-mark": mark.id, children: [
6820
- mark.hitPath ? /* @__PURE__ */ jsx46("path", { className: "ui-chart__hit", d: mark.hitPath }) : mark.kind === "bar" ? /* @__PURE__ */ jsx46(
7000
+ marks.map((mark) => /* @__PURE__ */ jsxs43("g", { "data-mark": mark.id, children: [
7001
+ mark.hitPath ? /* @__PURE__ */ jsx47("path", { className: "ui-chart__hit", d: mark.hitPath }) : mark.kind === "bar" ? /* @__PURE__ */ jsx47(
6821
7002
  "rect",
6822
7003
  {
6823
7004
  className: "ui-chart__hit",
@@ -6826,7 +7007,7 @@ function Chart(props) {
6826
7007
  y: px2(hitBand(mark.band).y),
6827
7008
  height: px2(hitBand(mark.band).h)
6828
7009
  }
6829
- ) : /* @__PURE__ */ jsx46(
7010
+ ) : /* @__PURE__ */ jsx47(
6830
7011
  "rect",
6831
7012
  {
6832
7013
  className: "ui-chart__hit",
@@ -6836,7 +7017,7 @@ function Chart(props) {
6836
7017
  height: px2(mark.hit?.h ?? TARGET)
6837
7018
  }
6838
7019
  ),
6839
- /* @__PURE__ */ jsx46(
7020
+ /* @__PURE__ */ jsx47(
6840
7021
  "rect",
6841
7022
  {
6842
7023
  "data-anchor": mark.id,
@@ -6851,58 +7032,58 @@ function Chart(props) {
6851
7032
  ]
6852
7033
  }
6853
7034
  ),
6854
- look?.variant === "donut" && look.look === "table" && /* @__PURE__ */ jsx46(Shares, { look, format, swatch: /* @__PURE__ */ jsx46(KeyMark, { shape: "fill" }) }),
6855
- !spark && columnsLayout && /* @__PURE__ */ jsx46("div", { className: "ui-chart__periods", "aria-hidden": "true", children: columns.map((column, i) => /* @__PURE__ */ jsx46(
7035
+ look?.variant === "donut" && look.look === "table" && /* @__PURE__ */ jsx47(Shares, { look, format, swatch: /* @__PURE__ */ jsx47(KeyMark, { shape: "fill" }) }),
7036
+ !spark && columnsLayout && /* @__PURE__ */ jsx47("div", { className: cx9("ui-chart__periods", every > 1 && "ui-chart__periods--step"), "aria-hidden": "true", children: columns.map((column, i) => /* @__PURE__ */ jsx47(
6856
7037
  "span",
6857
7038
  {
6858
- className: cx9("ui-chart__period", pick === i && "is-selected"),
6859
- children: column.short
7039
+ className: cx9("ui-chart__period", pick === i && "is-selected", every > 1 && edgeOf(i)),
7040
+ children: labelled(i) ? column.short : null
6860
7041
  },
6861
7042
  `${column.label}-${i}`
6862
7043
  )) })
6863
7044
  ] })
6864
7045
  }
6865
7046
  ),
6866
- /* @__PURE__ */ jsx46("span", { ref: tipEl, className: cx9("ui-tip", openId && "is-open"), role: open ? "tooltip" : void 0, children: open && /* @__PURE__ */ jsxs42(Fragment21, { children: [
6867
- /* @__PURE__ */ jsx46("span", { className: "ui-tip__label", children: spark || look ? columns[open.column]?.label : `${open.name}, ${columns[open.column]?.label}` }),
6868
- open.rows ? /* @__PURE__ */ jsxs42(Fragment21, { children: [
6869
- open.rows.map((row) => /* @__PURE__ */ jsxs42("span", { className: "ui-tip__value ui-chart__row", children: [
6870
- /* @__PURE__ */ jsxs42("span", { className: cx9("ui-chart__key", `ui-chart__tone--${row.tone}`), children: [
6871
- /* @__PURE__ */ jsx46(KeyMark, { shape: row.shape }),
7047
+ /* @__PURE__ */ jsx47("span", { ref: tipEl, className: cx9("ui-tip", openId && "is-open"), role: open ? "tooltip" : void 0, children: open && /* @__PURE__ */ jsxs43(Fragment21, { children: [
7048
+ /* @__PURE__ */ jsx47("span", { className: "ui-tip__label", children: spark || look ? columns[open.column]?.label : `${open.name}, ${columns[open.column]?.label}` }),
7049
+ open.rows ? /* @__PURE__ */ jsxs43(Fragment21, { children: [
7050
+ open.rows.map((row) => /* @__PURE__ */ jsxs43("span", { className: "ui-tip__value ui-chart__row", children: [
7051
+ /* @__PURE__ */ jsxs43("span", { className: cx9("ui-chart__key", `ui-chart__tone--${row.tone}`), children: [
7052
+ /* @__PURE__ */ jsx47(KeyMark, { shape: row.shape }),
6872
7053
  row.name
6873
7054
  ] }),
6874
- /* @__PURE__ */ jsx46("span", { children: row.text })
7055
+ /* @__PURE__ */ jsx47("span", { children: row.text })
6875
7056
  ] }, row.name)),
6876
- open.total && /* @__PURE__ */ jsxs42("span", { className: "ui-tip__value ui-chart__row", children: [
6877
- /* @__PURE__ */ jsx46("span", { children: totalLabel }),
6878
- /* @__PURE__ */ jsx46("span", { children: open.total })
7057
+ open.total && /* @__PURE__ */ jsxs43("span", { className: "ui-tip__value ui-chart__row", children: [
7058
+ /* @__PURE__ */ jsx47("span", { children: totalLabel }),
7059
+ /* @__PURE__ */ jsx47("span", { children: open.total })
6879
7060
  ] })
6880
- ] }) : /* @__PURE__ */ jsx46("span", { className: "ui-tip__value", children: format(open.value) }),
6881
- (stateOf(columns[open.column]) || open.detail) && /* @__PURE__ */ jsx46("span", { className: "ui-tip__detail", children: stateOf(columns[open.column]) || open.detail })
7061
+ ] }) : /* @__PURE__ */ jsx47("span", { className: "ui-tip__value", children: format(open.value) }),
7062
+ (stateOf(columns[open.column]) || open.detail) && /* @__PURE__ */ jsx47("span", { className: "ui-tip__detail", children: stateOf(columns[open.column]) || open.detail })
6882
7063
  ] }) })
6883
7064
  ]
6884
7065
  }
6885
7066
  ),
6886
7067
  !legendFirst && legend,
6887
- /* @__PURE__ */ jsx46("div", { className: "ui-sr", role: "status", children: said }),
6888
- asTable && /* @__PURE__ */ jsx46("div", { className: "ui-chart__data", children: /* @__PURE__ */ jsx46(
7068
+ /* @__PURE__ */ jsx47("div", { className: "ui-sr", role: "status", children: said }),
7069
+ asTable && /* @__PURE__ */ jsx47("div", { className: "ui-chart__data", children: /* @__PURE__ */ jsx47(
6889
7070
  "div",
6890
7071
  {
6891
7072
  className: "ui-table-scroll",
6892
7073
  role: "region",
6893
7074
  tabIndex: 0,
6894
7075
  "aria-label": `${title}, as a table. Scroll for more columns.`,
6895
- children: /* @__PURE__ */ jsxs42("table", { className: "ui-table", "aria-label": title, children: [
6896
- /* @__PURE__ */ jsx46("thead", { children: /* @__PURE__ */ jsx46("tr", { children: tableHead.map((head, i) => /* @__PURE__ */ jsx46("th", { scope: "col", className: cx9(i > 0 && "ui-table__num"), children: head }, head)) }) }),
6897
- /* @__PURE__ */ jsx46("tbody", { children: tableRows.map((row, i) => /* @__PURE__ */ jsxs42("tr", { "aria-current": pick === i ? true : void 0, children: [
6898
- /* @__PURE__ */ jsxs42("th", { scope: "row", children: [
7076
+ children: /* @__PURE__ */ jsxs43("table", { className: "ui-table", "aria-label": title, children: [
7077
+ /* @__PURE__ */ jsx47("thead", { children: /* @__PURE__ */ jsx47("tr", { children: tableHead.map((head, i) => /* @__PURE__ */ jsx47("th", { scope: "col", className: cx9(i > 0 && "ui-table__num"), children: head }, head)) }) }),
7078
+ /* @__PURE__ */ jsx47("tbody", { children: tableRows.map((row, i) => /* @__PURE__ */ jsxs43("tr", { "aria-current": pick === i ? true : void 0, children: [
7079
+ /* @__PURE__ */ jsxs43("th", { scope: "row", children: [
6899
7080
  row.column.label,
6900
- row.column.estimated && /* @__PURE__ */ jsxs42(Fragment21, { children: [
7081
+ row.column.estimated && /* @__PURE__ */ jsxs43(Fragment21, { children: [
6901
7082
  " ",
6902
- /* @__PURE__ */ jsx46("span", { className: "ui-chart__state", children: stateOf(row.column) })
7083
+ /* @__PURE__ */ jsx47("span", { className: "ui-chart__state", children: stateOf(row.column) })
6903
7084
  ] })
6904
7085
  ] }),
6905
- row.cells.map((cell, j) => /* @__PURE__ */ jsx46("td", { className: "ui-table__num", children: cell }, tableHead[j + 1]))
7086
+ row.cells.map((cell, j) => /* @__PURE__ */ jsx47("td", { className: "ui-table__num", children: cell }, tableHead[j + 1]))
6906
7087
  ] }, `${row.column.label}-${i}`)) })
6907
7088
  ] })
6908
7089
  }
@@ -6915,7 +7096,7 @@ function Chart(props) {
6915
7096
  // src/AccentPicker.tsx
6916
7097
  import { forwardRef as forwardRef12 } from "react";
6917
7098
  import { ACCENTS, accentSwatchStyle } from "@apliteni/apliteni-ui";
6918
- import { jsx as jsx47 } from "react/jsx-runtime";
7099
+ import { jsx as jsx48 } from "react/jsx-runtime";
6919
7100
  var AccentPicker = forwardRef12(function AccentPicker2({
6920
7101
  value,
6921
7102
  onChange,
@@ -6924,7 +7105,7 @@ var AccentPicker = forwardRef12(function AccentPicker2({
6924
7105
  "aria-label": label = "Accent",
6925
7106
  ...rest
6926
7107
  }, ref) {
6927
- return /* @__PURE__ */ jsx47(
7108
+ return /* @__PURE__ */ jsx48(
6928
7109
  "div",
6929
7110
  {
6930
7111
  ...rest,
@@ -6935,7 +7116,7 @@ var AccentPicker = forwardRef12(function AccentPicker2({
6935
7116
  "aria-label": label,
6936
7117
  children: options.map((accent) => {
6937
7118
  const title = accent.charAt(0).toUpperCase() + accent.slice(1);
6938
- return /* @__PURE__ */ jsx47(
7119
+ return /* @__PURE__ */ jsx48(
6939
7120
  "button",
6940
7121
  {
6941
7122
  type: "button",
@@ -6956,7 +7137,7 @@ var AccentPicker = forwardRef12(function AccentPicker2({
6956
7137
  // src/TopBar.tsx
6957
7138
  import { Fragment as Fragment22 } from "react";
6958
7139
  import { prism as prism3, safeUrl as safeUrl6, icon as icon8, ACCOUNT_NAV } from "@apliteni/apliteni-ui";
6959
- import { Fragment as Fragment23, jsx as jsx48, jsxs as jsxs43 } from "react/jsx-runtime";
7140
+ import { Fragment as Fragment23, jsx as jsx49, jsxs as jsxs44 } from "react/jsx-runtime";
6960
7141
  function TopBar({
6961
7142
  brand,
6962
7143
  word = "Strategy",
@@ -6968,20 +7149,20 @@ function TopBar({
6968
7149
  className,
6969
7150
  ...rest
6970
7151
  }) {
6971
- return /* @__PURE__ */ jsx48("header", { ...rest, className: ["topbar", className].filter(Boolean).join(" "), children: /* @__PURE__ */ jsxs43("div", { className: "topbar__in", children: [
6972
- brand ?? /* @__PURE__ */ jsxs43("a", { className: "brand", href: safeUrl6(brandHref), "aria-label": `Apliteni ${word}`, children: [
6973
- /* @__PURE__ */ jsx48("span", { "aria-hidden": "true", dangerouslySetInnerHTML: { __html: prism3("tb-mark", 22) } }),
6974
- /* @__PURE__ */ jsx48("span", { children: word })
7152
+ return /* @__PURE__ */ jsx49("header", { ...rest, className: ["topbar", className].filter(Boolean).join(" "), children: /* @__PURE__ */ jsxs44("div", { className: "topbar__in", children: [
7153
+ brand ?? /* @__PURE__ */ jsxs44("a", { className: "brand", href: safeUrl6(brandHref), "aria-label": `Apliteni ${word}`, children: [
7154
+ /* @__PURE__ */ jsx49("span", { "aria-hidden": "true", dangerouslySetInnerHTML: { __html: prism3("tb-mark", 22) } }),
7155
+ /* @__PURE__ */ jsx49("span", { children: word })
6975
7156
  ] }),
6976
7157
  view,
6977
- /* @__PURE__ */ jsx48("span", { className: "spacer" }),
7158
+ /* @__PURE__ */ jsx49("span", { className: "spacer" }),
6978
7159
  version,
6979
7160
  theme,
6980
7161
  account
6981
7162
  ] }) });
6982
7163
  }
6983
7164
  function ViewSwitch({ items, active, label = "View", renderLink }) {
6984
- return /* @__PURE__ */ jsx48("div", { className: "dtsw on", role: "group", "aria-label": label, children: items.map((item) => {
7165
+ return /* @__PURE__ */ jsx49("div", { className: "dtsw on", role: "group", "aria-label": label, children: items.map((item) => {
6985
7166
  const current = item.id === active;
6986
7167
  const linkProps = {
6987
7168
  className: current ? "cur" : void 0,
@@ -6990,13 +7171,13 @@ function ViewSwitch({ items, active, label = "View", renderLink }) {
6990
7171
  "aria-current": current ? "page" : void 0,
6991
7172
  children: item.label
6992
7173
  };
6993
- return /* @__PURE__ */ jsx48(Fragment22, { children: renderLink ? renderLink(item, linkProps) : /* @__PURE__ */ jsx48("a", { ...linkProps }) }, item.id);
7174
+ return /* @__PURE__ */ jsx49(Fragment22, { children: renderLink ? renderLink(item, linkProps) : /* @__PURE__ */ jsx49("a", { ...linkProps }) }, item.id);
6994
7175
  }) });
6995
7176
  }
6996
7177
  var BADGE = { live: "Live", archive: "Archive" };
6997
7178
  function VersionSwitcher({ versions, value, onChange, label = "Version", defaultOpen }) {
6998
7179
  const current = versions.find((v) => v.value === value);
6999
- return /* @__PURE__ */ jsx48("div", { className: "vsw", children: /* @__PURE__ */ jsx48(
7180
+ return /* @__PURE__ */ jsx49("div", { className: "vsw", children: /* @__PURE__ */ jsx49(
7000
7181
  Dropdown,
7001
7182
  {
7002
7183
  variant: "select",
@@ -7007,9 +7188,9 @@ function VersionSwitcher({ versions, value, onChange, label = "Version", default
7007
7188
  chevron: false,
7008
7189
  defaultOpen,
7009
7190
  ariaLabel: `${label} \u2014 ${current?.label ?? ""}`,
7010
- triggerContent: /* @__PURE__ */ jsxs43(Fragment23, { children: [
7011
- /* @__PURE__ */ jsx48("span", { className: "cur", children: current?.label }),
7012
- /* @__PURE__ */ jsx48("span", { className: "car", "aria-hidden": "true" })
7191
+ triggerContent: /* @__PURE__ */ jsxs44(Fragment23, { children: [
7192
+ /* @__PURE__ */ jsx49("span", { className: "cur", children: current?.label }),
7193
+ /* @__PURE__ */ jsx49("span", { className: "car", "aria-hidden": "true" })
7013
7194
  ] }),
7014
7195
  items: versions.map((v) => ({
7015
7196
  label: v.label,
@@ -7017,10 +7198,10 @@ function VersionSwitcher({ versions, value, onChange, label = "Version", default
7017
7198
  badge: BADGE[v.badge ?? "archive"],
7018
7199
  selected: v.value === value
7019
7200
  })),
7020
- row: (item, props) => /* @__PURE__ */ jsxs43("div", { ...props, className: `${props.className} vopt`, children: [
7021
- /* @__PURE__ */ jsx48("span", { className: "vname", children: item.label }),
7022
- /* @__PURE__ */ jsx48("span", { className: `vbadge ${item.badge === "Live" ? "live" : "arch"}`, children: String(item.badge) }),
7023
- /* @__PURE__ */ jsx48("span", { className: "vtick", "aria-hidden": "true", dangerouslySetInnerHTML: { __html: icon8("check") } })
7201
+ row: (item, props) => /* @__PURE__ */ jsxs44("div", { ...props, className: `${props.className} vopt`, children: [
7202
+ /* @__PURE__ */ jsx49("span", { className: "vname", children: item.label }),
7203
+ /* @__PURE__ */ jsx49("span", { className: `vbadge ${item.badge === "Live" ? "live" : "arch"}`, children: String(item.badge) }),
7204
+ /* @__PURE__ */ jsx49("span", { className: "vtick", "aria-hidden": "true", dangerouslySetInnerHTML: { __html: icon8("check") } })
7024
7205
  ] }),
7025
7206
  onSelect: (picked) => {
7026
7207
  if (picked != null) onChange?.(String(picked));
@@ -7049,7 +7230,7 @@ function AccountMenu2({
7049
7230
  defaultOpen
7050
7231
  }) {
7051
7232
  const mark = initialsOf(name, email);
7052
- return /* @__PURE__ */ jsx48("div", { className: "acct on", children: /* @__PURE__ */ jsx48(
7233
+ return /* @__PURE__ */ jsx49("div", { className: "acct on", children: /* @__PURE__ */ jsx49(
7053
7234
  Dropdown,
7054
7235
  {
7055
7236
  variant: "menu",
@@ -7060,22 +7241,22 @@ function AccountMenu2({
7060
7241
  defaultOpen,
7061
7242
  ariaLabel: "Account",
7062
7243
  triggerContent: mark,
7063
- header: /* @__PURE__ */ jsxs43("div", { className: "ahead", children: [
7064
- /* @__PURE__ */ jsx48("span", { className: "avatar", children: mark }),
7065
- /* @__PURE__ */ jsxs43("span", { className: "aw", children: [
7066
- /* @__PURE__ */ jsx48("span", { className: "anm", children: name }),
7067
- /* @__PURE__ */ jsx48("span", { className: "aem", title: email, children: email })
7244
+ header: /* @__PURE__ */ jsxs44("div", { className: "ahead", children: [
7245
+ /* @__PURE__ */ jsx49("span", { className: "avatar", children: mark }),
7246
+ /* @__PURE__ */ jsxs44("span", { className: "aw", children: [
7247
+ /* @__PURE__ */ jsx49("span", { className: "anm", children: name }),
7248
+ /* @__PURE__ */ jsx49("span", { className: "aem", title: email, children: email })
7068
7249
  ] })
7069
7250
  ] }),
7070
7251
  items: [...items, "---", { label: "Sign out", icon: "logout", value: "sign-out", href: signOutHref }],
7071
- row: (item, props) => /* @__PURE__ */ jsxs43(
7252
+ row: (item, props) => /* @__PURE__ */ jsxs44(
7072
7253
  "a",
7073
7254
  {
7074
7255
  ...props,
7075
7256
  href: item.disabled ? void 0 : item.href ? safeUrl6(item.href) : item.value === "sign-out" && onSignOut ? void 0 : safeUrl6(item.value === "sign-out" ? "#logout" : `#${item.value}`),
7076
7257
  className: [props.className, !item.disabled && item.value === current && "cur", item.value === "sign-out" && "aout"].filter(Boolean).join(" "),
7077
7258
  children: [
7078
- item.icon && /* @__PURE__ */ jsx48("span", { "aria-hidden": "true", dangerouslySetInnerHTML: { __html: icon8(item.icon) } }),
7259
+ item.icon && /* @__PURE__ */ jsx49("span", { "aria-hidden": "true", dangerouslySetInnerHTML: { __html: icon8(item.icon) } }),
7079
7260
  item.label
7080
7261
  ]
7081
7262
  }
@@ -7150,6 +7331,7 @@ export {
7150
7331
  Tabs,
7151
7332
  TextArea,
7152
7333
  TextField,
7334
+ ThemeChoice,
7153
7335
  ThemeToggle,
7154
7336
  Timeline,
7155
7337
  Toast,