@apliteni/apliteni-ui 0.198.0 → 0.199.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.
@@ -302,7 +302,8 @@ put it in an `AppShell` page, because a page has one band.
302
302
  ```
303
303
 
304
304
  Each slot is optional. A bar with no account is the signed-out bar. On a phone the bar has two rows.
305
- The current view in `ViewSwitch` has the accent fill. The version button shows only the chosen
305
+ The current view in `ViewSwitch` has the neutral selected fill: the strong ink on the surface,
306
+ never the accent. The version button shows only the chosen
306
307
  name, and its menu shows each name with its badge and a tick on the chosen one. They follow
307
308
  `value` until you change it. `AccountMenu` marks the page named by `current` in accent ink.
308
309
 
@@ -731,13 +732,20 @@ fit on one row. Use [`Tabs`](#tabs) when each choice shows a different panel. Se
731
732
  options={[{ value: 'm', label: 'Month' }, { value: 'q', label: 'Quarter' }, { value: 'y', label: 'Year' }]} />
732
733
  ```
733
734
 
734
- `appearance` is `pill`, the default, or `underline`. `size="sm"` makes the pill smaller, and in
735
- the underline appearance it changes only the type size. `block` fills the row. An option's `icon`
735
+ `appearance` is `pill`, the default, or `underline`. `size="sm"` makes the pill smaller. The
736
+ underline keeps one 13px type size in both sizes, so `size` does not change it. `block` fills the
737
+ row. Every control draws the neutral form by default: the chosen option is the strong ink on the
738
+ surface. `accent` asks for the accent fill when a product needs it; in vanilla CSS the class is `.ui-seg--accent`. `neutral` is a deprecated
739
+ no-op kept for compatibility, and goes away at the next major. An option's `icon`
736
740
  draws a glyph before its label. With `iconOnly`, the glyph is the whole button and the label is
737
- its name and its hover title.
738
-
739
- **What the user sees.** The chosen pill has the accent fill of a primary button. The chosen
740
- underline tab is its label with a 2px accent bar under it, and no box. Hover changes only the
741
+ its name and its hover title; the wordless choice draws a 32px pill around the 20px view icon — larger
742
+ than a labelled option's 16px lead — and below the phone step keeps a 44px tap zone outside the
743
+ pill, the way the back link and theme switch do.
744
+
745
+ **What the user sees.** The chosen pill has the strong ink on the surface, with no accent. With
746
+ `accent`, the chosen pill has the accent fill of a primary button. The chosen
747
+ underline tab is its label with a 2px strong bar under it, and no box; with `accent` the bar is
748
+ the accent. Hover changes only the
741
749
  ink. When the options do not fit, they wrap onto more rows, so the strip never makes the column
742
750
  wider. A long label wraps inside its own option.
743
751
 
@@ -1409,7 +1417,7 @@ chart has the title. `format` prints exact values in the readout, the live regio
1409
1417
 
1410
1418
  | `variant` | Data | `look` values | Default look |
1411
1419
  | --- | --- | --- | --- |
1412
- | `months` | `periods`, `series` | none: columns per period with a line across them, fitted to the card | |
1420
+ | `months` | `periods`, `series` | none: columns per period with a line across them | |
1413
1421
  | `bridge` | `steps` | none: one period from a start total to a result | |
1414
1422
  | `spark` | `periods`, `series` | none: one series at text size, for a stat band `trend` | |
1415
1423
  | `line` | `periods`, `series` | `thin`; `points`, a point on each value; `labels`, the last value at the line's end | `thin` |
@@ -1432,10 +1440,17 @@ values and hangs them under the line.
1432
1440
  `good`, `bad` and `neutral`. The product accent does not change them. Each full tone is at least
1433
1441
  3:1 on the card and the page in both themes.
1434
1442
 
1435
- **What the user sees.** In `months`, every period shares the card's width, so the plot never
1436
- scrolls. A bar is one flat fill of its tone. It takes two thirds of its column, and at most 48px.
1437
- Where the period labels do not fit, the chart prints every second, third or later label, counted
1438
- from the first period that is not final, or from the latest period. Set `values` to print each
1443
+ **What the user sees.** In `months`, when the card is too narrow for every bar's name, the plot
1444
+ scrolls sideways so every bar keeps its name. A bar is one flat tone — the full tone of its series
1445
+ — with a small corner at its measured end: --radius-xs or a quarter of the bar's width, whichever is
1446
+ smaller. Its foot stays square on the zero line. It takes two thirds of its column, and at most 48px.
1447
+ In `months` and `bridge`, the
1448
+ chart prints every bar's `short` name under its bar, and a short name that does not fit its column
1449
+ wraps at a word break. Give each bar a distinct `short` name, never one cut to a fixed length. Where
1450
+ one word alone is wider than the column, the plot scrolls so that word still fits, and every bar
1451
+ keeps its name. In the other variants, where the period labels do not fit, the chart prints every
1452
+ second, third or later label, counted from the first period that is not final, or from the latest
1453
+ period. The readout and the table keep the full name. Set `values` to print each
1439
1454
  bar's value past its end, in `formatAxis`: over a bar that grows up from zero, and under a bar
1440
1455
  that grows down. A value takes at most half the space to the next value,
1441
1456
  at the 12px text size, and stays inside the plot. A value that does not fit there is left out.
@@ -1451,7 +1466,7 @@ the period before it. Set `compare: false` on a period to show its value with no
1451
1466
  A switch at the top right
1452
1467
  shows the same numbers as a chart or as a table. In a titled `Card`, the switch stands in the
1453
1468
  card's title row. `table={false}` removes the switch and the table. `selectable` with `selected`
1454
- and `onSelect` lets the user pick a column, which gets a band behind it. In the other variants, at
1469
+ and `onSelect` lets the user pick a column, which gets a band behind it. At
1455
1470
  phone widths the plot scrolls and the value axis stays. A chart of periods that is wider than its
1456
1471
  card opens at its latest period. A bridge opens at its opening total.
1457
1472
 
@@ -322,8 +322,11 @@ fill, because a reader never writes in one. Its ink clears 4.5:1 on that fill, w
322
322
  lowest value 5.22:1.
323
323
 
324
324
  **A selected item is the one exception.** Selection is marked by a background highlight. An
325
- enabled chosen segmented pill takes the primary button's pair, `--accent-strong` with
326
- `--accent-contrast` ink, and a 1px `--accent` edge. Where the fill is under 3:1 on the track, as
325
+ enabled chosen segmented pill marks its choice with the strong ink on the surface, `--strong`
326
+ with `--surface` text — the neutral form is the default, so a view switch, a filter and a setting
327
+ all stay off the page's accent button. Only a product that asks for the accent form takes the
328
+ primary button's pair, `--accent-strong` with `--accent-contrast` ink, and a 1px `--accent` edge.
329
+ Where the fill is under 3:1 on the track, as
327
330
  under the default accent in dark, the edge is the mark. A disabled chosen pill and an underline tab
328
331
  take no edge. A disabled chosen pill keeps `--surface-3` and the disabled
329
332
  ink.
@@ -38,7 +38,7 @@
38
38
 
39
39
  **Don't:** Use `--accent` as ground.
40
40
 
41
- **Except:** Only Nebula gives the two tokens different values. A dark selected Segmented pill adds an `--accent` edge to its `--accent-strong` ground (#832).
41
+ **Except:** Only Nebula gives the two tokens different values. A dark accent-form Segmented pill adds an `--accent` edge to its `--accent-strong` ground (#832).
42
42
 
43
43
  <!-- rule: accent-strong -->
44
44
 
@@ -46,16 +46,28 @@
46
46
 
47
47
  <!-- rule: selection-accent -->
48
48
 
49
- **Rule:** Limit selected navigation to one accent signal: a Segmented pill's fill or an underline tab's bar.
49
+ **Rule:** Limit selected navigation to one accent signal: a Segmented pill's fill in the accent form, or an underline tab's bar.
50
50
 
51
51
  **Why:** Two accent marks on one item imply two states.
52
52
 
53
- **Do:** Use contrasting ink on Segmented pills and strong ink above underline bars. See Keep text off grey fills for SidebarNav.
53
+ **Do:** Use contrasting ink on Segmented pills and strong ink above underline bars. See Keep text off grey fills.
54
54
 
55
55
  **Don't:** Add a second accent mark, such as an accent counter, to a selected tab.
56
56
 
57
57
  **Except:** NavTabs pills keep accent ink on soft fill, as fill alone is too faint (#429). A Segmented pill's edge belongs to its fill.
58
58
 
59
+ ## Draw Segmented controls in the neutral form
60
+
61
+ <!-- rule: neutral-selection -->
62
+
63
+ **Rule:** Draw every Segmented control in the neutral form; ask for the accent form only when needed.
64
+
65
+ **Why:** An accent fill competes with the page's main button wherever it sits.
66
+
67
+ **Do:** Switch between chart and table, and filter a ledger, with the neutral form.
68
+
69
+ **Don't:** Give a view switch, a filter or a setting the accent fill.
70
+
59
71
  ## Theme checks
60
72
 
61
73
  **Rule:** Check both themes and two accents before a PR.
@@ -135,3 +135,17 @@
135
135
  **Do:** Spend against Estimated, then revenue against expenses on a second chart.
136
136
 
137
137
  **Don't:** All four lines on one chart.
138
+
139
+ ## Keep every bar labelled
140
+
141
+ <!-- rule: bar-labels-distinct -->
142
+
143
+ **Rule:** Give each bar a distinct short name, never cut to a fixed length.
144
+
145
+ **Why:** A bar without a name loses meaning.
146
+
147
+ **Do:** Short names under every bar, full names in readout and table.
148
+
149
+ **Don't:** Names that repeat North and South, so the bars read alike.
150
+
151
+ **Except:** Where one word is wider than its column, the plot scrolls sideways so every bar keeps its name.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apliteni/apliteni-ui",
3
- "version": "0.198.0",
3
+ "version": "0.199.0",
4
4
  "workspaces": [
5
5
  "react"
6
6
  ],
@@ -56,9 +56,22 @@
56
56
  }
57
57
  .ui-seg {
58
58
  row-gap: var(--tap-gap) !important;
59
- --tap-clear-x: var(--space-1, 4px);
60
59
  --tap-clear-y: var(--tap-gap);
61
60
  }
61
+ .ui-seg:not(:has(button.ui-seg--icon)) {
62
+ --tap-clear-x: var(--space-1, 4px);
63
+ }
64
+ .ui-seg button.ui-seg--icon:first-child::after {
65
+ left: calc(-1 * (var(--space-1) / 2 + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
66
+ width: min(var(--tap-min), calc(100% + var(--space-1) + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
67
+ transform: translateY(-50%);
68
+ }
69
+ .ui-seg button.ui-seg--icon:last-child::after {
70
+ right: calc(-1 * (var(--space-1) / 2 + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
71
+ left: auto;
72
+ width: min(var(--tap-min), calc(100% + var(--space-1) + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
73
+ transform: translateY(-50%);
74
+ }
62
75
  .ui-seg--underline {
63
76
  row-gap: var(--space-1, 4px) !important;
64
77
  --tap-clear-y: var(--space-1, 4px);
@@ -157,6 +170,9 @@
157
170
  .ui-datepicker__panel {
158
171
  --ui-dropdown-max: 100dvh;
159
172
  }
173
+ .ui-drawer:has(.ui-datepicker__body.is-sheet) {
174
+ --drawer-h: 72vh;
175
+ }
160
176
  .ui-datepicker__head {
161
177
  --tap-clear-x: var(--tap-gap-bordered);
162
178
  --tap-clear-y: var(--tap-gap-bordered);
@@ -721,8 +721,11 @@ type SegmentedProps = {
721
721
  size?: 'sm';
722
722
  block?: boolean;
723
723
  disabled?: boolean;
724
+ accent?: boolean; /** @deprecated The neutral form is the default now. Ask for the accent with `accent`. */
725
+ neutral?: boolean;
724
726
  };
725
- declare function Segmented({ options, value, onChange, label, appearance, size, block, disabled }: SegmentedProps): react.JSX.Element;
727
+ /** Every control draws the neutral form by default; `accent` asks for the accent fill. */
728
+ declare function Segmented({ options, value, onChange, label, appearance, size, block, disabled, accent }: SegmentedProps): react.JSX.Element;
726
729
 
727
730
  type Filter = {
728
731
  id: string;
@@ -1325,7 +1328,8 @@ type ChartPeriod = {
1325
1328
  /**
1326
1329
  * The period is not final. `incomplete` is the period still running,
1327
1330
  * `projected` a future one, and `true` any other estimate. The readout and
1328
- * the table name the state; the chart at rest prints none.
1331
+ * the table name the state; the chart at rest prints only the group's
1332
+ * `Not final` label above the unfinished group, not a word per period.
1329
1333
  */
1330
1334
  estimated?: ChartEstimate;
1331
1335
  /** Why it is not final. Printed in the readout and in the table. */
@@ -3828,16 +3828,16 @@ function RowIdentity({ symbol, name, logo, href }) {
3828
3828
  // src/Segmented.tsx
3829
3829
  import { segmentedNextIndex } from "@apliteni/apliteni-ui";
3830
3830
  import { jsx as jsx29, jsxs as jsxs25 } from "react/jsx-runtime";
3831
- function Segmented({ options, value, onChange, label, appearance = "pill", size, block = false, disabled = false }) {
3831
+ function Segmented({ options, value, onChange, label, appearance = "pill", size, block = false, disabled = false, accent = false }) {
3832
3832
  const enabled = options.filter((o) => !o.disabled);
3833
3833
  const tabValue = enabled.some((o) => o.value === value) ? value : enabled[0]?.value;
3834
- return /* @__PURE__ */ jsx29("div", { className: `ui-seg${size === "sm" ? " ui-seg--sm" : ""}${block ? " ui-seg--block" : ""}${appearance === "underline" ? " ui-seg--underline" : ""}`, role: "toolbar", "aria-label": label, children: options.map((option) => /* @__PURE__ */ jsxs25(
3834
+ return /* @__PURE__ */ jsx29("div", { className: `ui-seg${size === "sm" ? " ui-seg--sm" : ""}${block ? " ui-seg--block" : ""}${appearance === "underline" ? " ui-seg--underline" : ""}${accent ? " ui-seg--accent" : ""}`, role: "toolbar", "aria-label": label, children: options.map((option) => /* @__PURE__ */ jsxs25(
3835
3835
  "button",
3836
3836
  {
3837
3837
  type: "button",
3838
3838
  "data-value": option.value,
3839
3839
  disabled: disabled || option.disabled,
3840
- className: value === option.value ? "is-active" : void 0,
3840
+ className: [value === option.value ? "is-active" : null, option.icon && option.iconOnly ? "ui-seg--icon" : null].filter(Boolean).join(" ") || void 0,
3841
3841
  "aria-label": option.ariaLabel ?? (option.icon && option.iconOnly ? option.label : void 0),
3842
3842
  title: option.icon && option.iconOnly ? option.label : void 0,
3843
3843
  "aria-pressed": value === option.value,
@@ -5865,6 +5865,8 @@ var RING = {
5865
5865
  };
5866
5866
  var END_LABEL = { rise: 10, ascent: 10, drop: 20, gap: 4 };
5867
5867
  var STACK_BAR = { columns: 12, share: 20 };
5868
+ var BAR_CORNER = 6;
5869
+ var barCorner = (w) => Math.min(BAR_CORNER, w / 4);
5868
5870
  function arc(x, y, r0, r1, a0, a1) {
5869
5871
  const p = (r, a) => `${px(x + r * Math.cos(a))} ${px(y + r * Math.sin(a))}`;
5870
5872
  if (a1 - a0 >= Math.PI * 2 - 1e-9) {
@@ -6209,7 +6211,7 @@ function columnsDrawing(g) {
6209
6211
  const y0 = y(layer.from[i]);
6210
6212
  const y1 = y(layer.to[i]);
6211
6213
  const x = centre(i) - w / 2;
6212
- const d = layer === filled[filled.length - 1] ? topRounded(x, y1, w, y0 - y1, 4) : square(x, y1, w, y0 - y1);
6214
+ const d = layer === filled[filled.length - 1] ? topRounded(x, y1, w, y0 - y1, barCorner(w)) : square(x, y1, w, y0 - y1);
6213
6215
  return /* @__PURE__ */ jsx48(
6214
6216
  "path",
6215
6217
  {
@@ -6268,7 +6270,7 @@ function rowsDrawing(g, pick) {
6268
6270
  filled.map((layer) => {
6269
6271
  const x0 = rows.x(layer.from[i]);
6270
6272
  const x1 = rows.x(layer.to[i]);
6271
- const d = layer === filled[filled.length - 1] ? rightRounded(x0, top, x1 - x0, ROW_BAR, 4) : square(x0, top, x1 - x0, ROW_BAR);
6273
+ const d = layer === filled[filled.length - 1] ? rightRounded(x0, top, x1 - x0, ROW_BAR, barCorner(ROW_BAR)) : square(x0, top, x1 - x0, ROW_BAR);
6272
6274
  return /* @__PURE__ */ jsx48(
6273
6275
  "path",
6274
6276
  {
@@ -6341,20 +6343,47 @@ function Shares({ look, format, swatch }) {
6341
6343
 
6342
6344
  // src/Chart.tsx
6343
6345
  import { Fragment as Fragment22, jsx as jsx49, jsxs as jsxs45 } from "react/jsx-runtime";
6346
+ function anchorScreenBox(mark) {
6347
+ const x = Number(mark.getAttribute("x")) || 0;
6348
+ const y = Number(mark.getAttribute("y")) || 0;
6349
+ const w = Number(mark.getAttribute("width")) || 0;
6350
+ const svg = mark.closest("svg");
6351
+ const [vbX = 0, vbY = 0, vbW = 0, vbH = 0] = (svg?.getAttribute("viewBox")?.split(/\s+/) ?? []).map(Number);
6352
+ const rect = svg?.getBoundingClientRect();
6353
+ if (rect && vbW > 0 && vbH > 0 && rect.width > 0 && rect.height > 0) {
6354
+ return {
6355
+ left: rect.left + (x - vbX) * (rect.width / vbW),
6356
+ top: rect.top + (y - vbY) * (rect.height / vbH),
6357
+ width: w * (rect.width / vbW)
6358
+ };
6359
+ }
6360
+ const fallback = mark.getBoundingClientRect();
6361
+ return { left: fallback.left, top: fallback.top, width: fallback.width };
6362
+ }
6344
6363
  function placeChartTip(mark, tip) {
6345
- const rect = mark.getBoundingClientRect();
6364
+ const rect = anchorScreenBox(mark);
6346
6365
  const view = tip.ownerDocument.documentElement;
6347
6366
  const gap = parseFloat(getComputedStyle(tip).getPropertyValue("--ui-tip-gap")) || 8;
6348
6367
  const above = rect.top;
6349
- const below = view.clientHeight - rect.bottom;
6368
+ const below = view.clientHeight - rect.top;
6369
+ const card = mark.closest(".ui-card");
6370
+ const box = card ? cardContentBox(card, view) : { left: 0, right: view.clientWidth };
6371
+ tip.style.maxWidth = `min(var(--prose-caption), ${box.right - box.left}px)`;
6350
6372
  const isBelow = above < tip.offsetHeight + gap && below > above;
6351
6373
  tip.classList.toggle("is-below", isBelow);
6352
6374
  const ideal = rect.left + rect.width / 2 - tip.offsetWidth / 2;
6353
- const left = Math.max(0, Math.min(ideal, view.clientWidth - tip.offsetWidth));
6375
+ const left = Math.max(box.left, Math.min(ideal, box.right - tip.offsetWidth));
6354
6376
  tip.style.setProperty("--ui-tip-x", `${rect.left + rect.width / 2}px`);
6355
- tip.style.setProperty("--ui-tip-y", `${isBelow ? rect.bottom : rect.top}px`);
6377
+ tip.style.setProperty("--ui-tip-y", `${rect.top}px`);
6356
6378
  tip.style.setProperty("--ui-tip-shift", `${left - ideal}px`);
6357
6379
  }
6380
+ function cardContentBox(card, view) {
6381
+ const rect = card.getBoundingClientRect();
6382
+ const style = getComputedStyle(card);
6383
+ const left = rect.left + (parseFloat(style.borderLeftWidth) || 0) + (parseFloat(style.paddingLeft) || 0);
6384
+ const right = rect.right - (parseFloat(style.borderRightWidth) || 0) - (parseFloat(style.paddingRight) || 0);
6385
+ return { left: Math.max(0, left), right: Math.min(view.clientWidth, right) };
6386
+ }
6358
6387
  var HEIGHT = { months: 216, bridge: 216, spark: 32, line: 216, area: 216, stacked: 216, donut: 216 };
6359
6388
  var PAD = 2;
6360
6389
  var ZERO_INSET = 1.5;
@@ -6365,6 +6394,7 @@ var FALLBACK_COL = 48;
6365
6394
  var BAR_SHARE = 0.5;
6366
6395
  var BAR_MAX = 12;
6367
6396
  var BAR_MAX_BRIDGE = 22;
6397
+ var BRIDGE_COL = 88;
6368
6398
  var FIT_SHARE = 2 / 3;
6369
6399
  var FIT_MAX = 48;
6370
6400
  var FIT_CORNER = 6;
@@ -6378,11 +6408,6 @@ var BOUNDARY_TOP = 24;
6378
6408
  var GROUP_WORDS = "Not final";
6379
6409
  var LANE_GAP = 2;
6380
6410
  var MISSING2 = "\u2014";
6381
- function fadeOf(uid, m, bridge) {
6382
- if (!bridge && !m.foot) return null;
6383
- const up = bridge ? m.value >= 0 : m.foot === "bottom";
6384
- return { id: `${uid}-fade-${m.tone}-${up ? "up" : "down"}`, tone: m.tone, up };
6385
- }
6386
6411
  var cx9 = (...parts) => parts.filter(Boolean).join(" ");
6387
6412
  var px2 = (n) => Math.round(n * 10) / 10;
6388
6413
  var STATE_WORD = { incomplete: "Incomplete", projected: "Projected" };
@@ -6399,8 +6424,8 @@ function onPrevious(value, previous, when) {
6399
6424
  const pct2 = (value - previous) / Math.abs(previous) * 100;
6400
6425
  return `${pct2 < 0 ? "\u2212" : "+"}${Math.abs(pct2).toFixed(1)}% on ${when}`;
6401
6426
  }
6402
- function barPath(m, corner = m.w / 2) {
6403
- const r = Math.min(corner, m.w / 2, m.h / (m.foot ? 1 : 4));
6427
+ function barPath(m, corner = Math.min(FIT_CORNER, m.w / 4)) {
6428
+ const r = px2(Math.min(corner, m.w / 2, m.h / (m.foot ? 1 : 4)));
6404
6429
  const { x, y: top, w, h } = m;
6405
6430
  const bottom = top + h;
6406
6431
  const arc2 = (dx, dy, sweep) => `a${px2(r)} ${px2(r)} 0 0 ${sweep} ${px2(dx)} ${px2(dy)}`;
@@ -6703,6 +6728,7 @@ function Chart(props) {
6703
6728
  const [width, setWidth] = useState23(0);
6704
6729
  const [boxWidth, setBoxWidth] = useState23(0);
6705
6730
  const [overflows, setOverflows] = useState23(false);
6731
+ const [scrolled, setScrolled] = useState23(0);
6706
6732
  const [openId, setOpenId] = useState23(null);
6707
6733
  const [rawCursor, setCursor] = useState23(0);
6708
6734
  const [said, setSaid] = useState23("");
@@ -6850,8 +6876,6 @@ function Chart(props) {
6850
6876
  return [...out, ...dots];
6851
6877
  }, [geometry, frame, lines, keys, columns, centre, barX, barWidth, groupWidth, y, floor, colWidth, plotWidth, boxTop, boxHeight]);
6852
6878
  const byId = useMemo6(() => new Map(marks.map((m) => [m.id, m])), [marks]);
6853
- const fadeFor = useCallback8((m) => fit ? null : fadeOf(uid, m, variant === "bridge"), [fit, uid, variant]);
6854
- const fades = useMemo6(() => new Map(marks.filter((m) => m.kind === "bar").map(fadeFor).filter((f) => f !== null).map((f) => [f.id, f])), [marks, fadeFor]);
6855
6879
  const lead = useCallback8((column) => marks.find((m) => m.column === column), [marks]);
6856
6880
  const open = openId ? byId.get(openId) : void 0;
6857
6881
  useEffect23(() => {
@@ -6873,7 +6897,10 @@ function Chart(props) {
6873
6897
  const opensAtEnd = Boolean(periods);
6874
6898
  useLayoutEffect6(() => {
6875
6899
  const el = scroller.current;
6876
- if (opensAtEnd && el) el.scrollLeft = el.scrollWidth - el.clientWidth;
6900
+ if (opensAtEnd && el) {
6901
+ el.scrollLeft = el.scrollWidth - el.clientWidth;
6902
+ setScrolled(el.scrollLeft);
6903
+ }
6877
6904
  }, [opensAtEnd, plotWidth, boxWidth, count]);
6878
6905
  useLayoutEffect6(() => {
6879
6906
  const tip = tipEl.current;
@@ -6895,7 +6922,10 @@ function Chart(props) {
6895
6922
  const doc = frameEl.current?.ownerDocument;
6896
6923
  const view2 = doc?.defaultView;
6897
6924
  if (!doc || !view2) return;
6898
- const hide = () => setOpenId(null);
6925
+ const hide = (event) => {
6926
+ if (event?.target === scroller.current) return;
6927
+ setOpenId(null);
6928
+ };
6899
6929
  const escape = (event) => {
6900
6930
  if (event.key !== "Escape") return;
6901
6931
  dismissed.current = openId;
@@ -6995,14 +7025,23 @@ function Chart(props) {
6995
7025
  }
6996
7026
  );
6997
7027
  const noun = look?.layout === "ring" ? "slices" : look?.layout === "rows" ? "rows" : "columns";
7028
+ const wrapAtWords = variant === "months" || variant === "bridge";
6998
7029
  const labelRoom = Math.max(0, ...columns.map((c) => textWidth(c.short))) + LABEL_GAP;
6999
- const every = labelRoom > colWidth ? Math.ceil(labelRoom / colWidth) : 1;
7030
+ const widestWord = wrapAtWords ? Math.max(0, ...columns.flatMap((c) => c.short.split(/\s+/).map((word) => textWidth(word)))) + LABEL_GAP : labelRoom;
7031
+ const every = widestWord <= colWidth ? 1 : Math.ceil(labelRoom / colWidth);
7032
+ const floorCol = fit ? Math.ceil(widestWord) : variant === "bridge" ? Math.max(BRIDGE_COL, Math.ceil(widestWord)) : null;
7000
7033
  const anchor = groupFrom >= 0 ? groupFrom : count - 1;
7001
7034
  const labelled = (i) => ((anchor - i) % every + every) % every === 0;
7002
7035
  const edgeOf = (i) => {
7003
7036
  const half = textWidth(columns[i].short) / 2;
7004
7037
  return centre(i) - half < 0 ? "is-start" : centre(i) + half > plotWidth ? "is-end" : null;
7005
7038
  };
7039
+ const whole = (i) => {
7040
+ if (!overflows) return true;
7041
+ const left = i * colWidth;
7042
+ const right = left + colWidth;
7043
+ return left >= scrolled - 0.5 && right <= scrolled + boxWidth + 0.5;
7044
+ };
7006
7045
  const groupX = groupFrom >= 0 ? Math.min(Math.max(groupFrom * colWidth, 1), plotWidth - 1) : 0;
7007
7046
  return /* @__PURE__ */ jsxs45(
7008
7047
  "div",
@@ -7018,6 +7057,7 @@ function Chart(props) {
7018
7057
  "--ui-chart-h": `${plotHeight}px`,
7019
7058
  "--ui-chart-box": `${px2(boxHeight)}px`,
7020
7059
  "--ui-chart-cols": count,
7060
+ "--ui-chart-col": floorCol === null ? void 0 : `${floorCol}px`,
7021
7061
  "--ui-chart-pad": `${PAD}px`,
7022
7062
  "--ui-chart-top": `${PAD + roomTop}px`,
7023
7063
  "--ui-chart-bottom": `${PAD + roomBottom}px`
@@ -7066,11 +7106,13 @@ function Chart(props) {
7066
7106
  role: overflows ? "region" : void 0,
7067
7107
  "aria-label": overflows ? `${title}. Scroll for more ${noun}.` : void 0,
7068
7108
  onScroll: () => {
7109
+ setScrolled(scroller.current?.scrollLeft ?? 0);
7069
7110
  const anchor2 = [...svgEl.current?.querySelectorAll("[data-anchor]") ?? []].find((el) => el.getAttribute("data-anchor") === openId);
7070
7111
  if (!anchor2 || !scroller.current || !frameEl.current || !tipEl.current) return;
7071
- const mark = anchor2.getBoundingClientRect();
7112
+ const mark = anchorScreenBox(anchor2);
7072
7113
  const view2 = scroller.current.getBoundingClientRect();
7073
- if (mark.right <= view2.left || mark.left >= view2.right) setOpenId(null);
7114
+ if (mark.left + mark.width <= view2.left || mark.left >= view2.right) setOpenId(null);
7115
+ else if (topLayer) placeChartTip(anchor2, tipEl.current);
7074
7116
  else placeTip(frameEl.current, anchor2, tipEl.current);
7075
7117
  },
7076
7118
  children: /* @__PURE__ */ jsxs45("div", { ref: plot, className: "ui-chart__plot", children: [
@@ -7203,38 +7245,18 @@ function Chart(props) {
7203
7245
  }
7204
7246
  )
7205
7247
  ] }),
7206
- fades.size > 0 && /* @__PURE__ */ jsx49("defs", { children: [...fades.values()].map((fade) => /* @__PURE__ */ jsxs45(
7207
- "linearGradient",
7248
+ marks.filter((m) => m.kind === "bar").map((mark) => /* @__PURE__ */ jsx49(
7249
+ "path",
7208
7250
  {
7209
- id: fade.id,
7210
- className: `ui-chart__tone--${fade.tone}`,
7211
- x1: "0",
7212
- x2: "0",
7213
- y1: fade.up ? "1" : "0",
7214
- y2: fade.up ? "0" : "1",
7215
- children: [
7216
- /* @__PURE__ */ jsx49("stop", { className: "ui-chart__fade-base", offset: "0" }),
7217
- /* @__PURE__ */ jsx49("stop", { className: "ui-chart__fade-end", offset: "1" })
7218
- ]
7251
+ className: cx9(
7252
+ "ui-chart__bar",
7253
+ `ui-chart__tone--${mark.tone}`,
7254
+ mark.estimated && "is-estimated"
7255
+ ),
7256
+ d: barPath(mark)
7219
7257
  },
7220
- fade.id
7221
- )) }),
7222
- marks.filter((m) => m.kind === "bar").map((mark) => {
7223
- const fade = fadeFor(mark);
7224
- return /* @__PURE__ */ jsx49(
7225
- "path",
7226
- {
7227
- className: cx9(
7228
- "ui-chart__bar",
7229
- `ui-chart__tone--${mark.tone}`,
7230
- mark.estimated && "is-estimated"
7231
- ),
7232
- style: fade ? { "--ui-chart-paint": `url(#${fade.id})` } : void 0,
7233
- d: fit ? barPath(mark, px2(Math.min(FIT_CORNER, mark.w / 4))) : barPath(mark)
7234
- },
7235
- `bar-${mark.id}`
7236
- );
7237
- }),
7258
+ `bar-${mark.id}`
7259
+ )),
7238
7260
  marks.filter((m) => m.kind === "bar" && printed.has(m.id)).map((mark) => {
7239
7261
  const text2 = formatAxis(mark.value);
7240
7262
  const below = under.has(mark.id);
@@ -7317,7 +7339,7 @@ function Chart(props) {
7317
7339
  "span",
7318
7340
  {
7319
7341
  className: cx9("ui-chart__period", pick === i && "is-selected", every > 1 && edgeOf(i)),
7320
- children: labelled(i) ? column.short : null
7342
+ children: labelled(i) && (wrapAtWords ? whole(i) : true) ? column.short : null
7321
7343
  },
7322
7344
  `${column.label}-${i}`
7323
7345
  )) })
@@ -7325,7 +7347,7 @@ function Chart(props) {
7325
7347
  }
7326
7348
  ),
7327
7349
  /* @__PURE__ */ jsx49("span", { ref: tipEl, ...topLayer && { popover: "manual" }, className: cx9("ui-tip", openId && "is-open"), role: open ? "tooltip" : void 0, children: open && /* @__PURE__ */ jsxs45(Fragment22, { children: [
7328
- /* @__PURE__ */ jsx49("span", { className: "ui-tip__label", children: spark || look ? columns[open.column]?.label : `${open.name}, ${columns[open.column]?.label}` }),
7350
+ /* @__PURE__ */ jsx49("span", { className: "ui-tip__label", children: spark || look || variant === "bridge" ? columns[open.column]?.label : `${open.name}, ${columns[open.column]?.label}` }),
7329
7351
  open.rows ? /* @__PURE__ */ jsxs45(Fragment22, { children: [
7330
7352
  open.rows.map((row) => /* @__PURE__ */ jsxs45("span", { className: "ui-tip__value ui-chart__row", children: [
7331
7353
  /* @__PURE__ */ jsxs45("span", { className: cx9("ui-chart__key", `ui-chart__tone--${row.tone}`), children: [
@@ -108,8 +108,6 @@
108
108
  }
109
109
 
110
110
  .ui-chart__plot { min-width: calc(var(--ui-chart-col) * var(--ui-chart-cols, 1)); }
111
- /* The months chart's periods share the card's width, so it never scrolls. */
112
- .ui-chart--months .ui-chart__plot { min-width: 0; }
113
111
  .ui-chart__svg { display: block; }
114
112
 
115
113
  .ui-chart__periods {
@@ -129,6 +127,13 @@
129
127
  line-height: 1.45;
130
128
  overflow-wrap: anywhere;
131
129
  }
130
+ /* The months and bridge charts print every bar's short name and wrap it at a
131
+ word break, so a word is never cut. Where one word alone is wider than its
132
+ column, the component steps the labels instead. */
133
+ .ui-chart--months .ui-chart__period,
134
+ .ui-chart--bridge .ui-chart__period {
135
+ overflow-wrap: normal;
136
+ }
132
137
  /* The picked column's label: the body ink the rest of the row gives up, at the
133
138
  weight a reader who separates no colours still reads. Selection is otherwise
134
139
  the band behind the column and the band alone — the outline the chart draws
@@ -172,15 +177,15 @@
172
177
  .ui-chart__band { fill: var(--surface-3); }
173
178
 
174
179
  .ui-chart__bar {
175
- /* A bar fades from a tint of its tone at the base to the full tone at the data
176
- end. The fade is allowed because it carries no value: the strong data end, the
177
- zero line and the base hold the bar's length, and the data end alone clears
178
- 3:1. The component names the ramp per bar as --ui-chart-paint. A bridge bar
179
- fades from the previous running total to the new one. */
180
- fill: var(--ui-chart-paint, var(--ui-chart-tone));
180
+ /* One flat tone: the full tone of the bar's own series, which clears 3:1 on the
181
+ card and the page. The measured end carries a small corner of --radius-xs or a
182
+ quarter of the bar, whichever is smaller, and the foot on the zero line stays
183
+ square, so the bar's length reads off the one rule the chart draws. */
184
+ fill: var(--ui-chart-tone);
181
185
  stroke: none;
182
186
  }
183
- /* The ramp's two stops. Each reads the tone of the gradient that holds it. */
187
+ /* The ramp's two stops, which an area uses to fade over its own values. Each
188
+ stop reads the tone of the gradient that holds it. */
184
189
  .ui-chart__fade-base { stop-color: var(--ui-chart-fade); }
185
190
  .ui-chart__fade-end { stop-color: var(--ui-chart-tone); }
186
191
 
@@ -230,8 +235,8 @@
230
235
  .ui-chart--pick [data-mark] { cursor: pointer; }
231
236
 
232
237
  /* The tones. A series names one, and each is the kit's own pair of tokens: the
233
- tone, which is the data end and every line, legend key and dot, and its fade,
234
- which is a bar's base. Both are fixed steps in each theme, so a chart does not
238
+ tone, which is every bar, line, legend key and dot, and its fade, which fills
239
+ an area's base. Both are fixed steps in each theme, so a chart does not
235
240
  follow the product accent and accent-soft is not a mix towards the ground. */
236
241
  .ui-chart__tone--accent { --ui-chart-tone: var(--chart-accent); --ui-chart-fade: var(--chart-accent-fade); }
237
242
  .ui-chart__tone--accent-soft { --ui-chart-tone: var(--chart-accent-soft); --ui-chart-fade: var(--chart-accent-soft-fade); }
@@ -40,19 +40,31 @@
40
40
  .ui-seg button:hover { color: var(--strong); }
41
41
  /* aria-pressed is what segmented() emits now; aria-selected is kept so markup
42
42
  copied from an older release keeps painting its active pill. */
43
- /* Selection uses the accent fill. The outline marks keyboard focus only.
43
+ /* Selection uses the strong ink on the surface — the neutral form is the default.
44
+ The outline marks keyboard focus only.
44
45
  why: docs/foundations.md#the-focus-ring */
45
46
  .ui-seg button.is-active,
46
47
  .ui-seg button[aria-pressed="true"],
47
48
  .ui-seg button[aria-selected="true"] {
48
- /* The primary button's pair, so a selection and the main action share one fill. The
49
- edge carries the 3:1 mark where that fill is faint on the track, as under the default accent in dark. #832 */
49
+ color: var(--surface);
50
+ background: var(--strong);
51
+ box-shadow: none;
52
+ }
53
+
54
+ /* The accent form, only when a product asks for it: the primary button's pair, so a
55
+ selection and the main action share one fill. The edge carries the 3:1 mark where
56
+ that fill is faint on the track, as under the default accent in dark. #832 */
57
+ .ui-seg--accent button.is-active,
58
+ .ui-seg--accent button[aria-pressed="true"],
59
+ .ui-seg--accent button[aria-selected="true"] {
50
60
  color: var(--accent-contrast);
51
61
  background: var(--accent-strong);
52
62
  box-shadow: inset 0 0 0 1px var(--accent);
53
63
  }
64
+ /* The accent underline bar. */
65
+ .ui-seg--accent.ui-seg--underline button::before { background: var(--accent); }
54
66
 
55
- /* A disabled selection stays readable without the active accent fill. */
67
+ /* A disabled selection stays readable without the selected fill. */
56
68
  .ui-seg button.is-active:where(:disabled),
57
69
  .ui-seg button[aria-pressed="true"]:where(:disabled),
58
70
  .ui-seg button[aria-selected="true"]:where(:disabled) {
@@ -60,15 +72,26 @@
60
72
  box-shadow: none; /* No edge: on a control that takes no focus it reads as a ring. #832 */
61
73
  }
62
74
 
63
- /* Standard pills tighten on phones so six short month names fit one row. */
75
+ /* Standard pills tighten on phones so six short month names fit one row. The
76
+ wordless option is excluded: it has no label to fit, and its 32px pill is the
77
+ owner's decision (d54). */
64
78
  @media (max-width: 560px) {
65
- .ui-seg:not(.ui-seg--sm):not(.ui-seg--underline) button { padding: var(--space-2) var(--space-3); }
79
+ .ui-seg:not(.ui-seg--sm):not(.ui-seg--underline) button:not(.ui-seg--icon) { padding: var(--space-2) var(--space-3); }
66
80
  }
67
81
 
68
82
  /* A segment with a glyph centres it on the word, or stands alone when the glyph is
69
83
  the whole label. The glyph keeps the button glyph's size and line. */
70
84
  .ui-seg button:has(> span > svg) { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); }
71
85
  .ui-seg button svg { display: block; width: 16px; height: 16px; flex: none; stroke-width: 2.4; }
86
+ /* A wordless option is all glyph: the 20px view icon the owner chose (d54),
87
+ larger than a labelled option's 16px lead.
88
+ The button is a 24px square — 20px icon plus 2px inside — so the track's 4px
89
+ padding makes a 32px pill, and below the phone step
90
+ its 44px tap zone reaches past the pill, the way the 32px back link and the
91
+ 34px theme switch do. The 1.8 stroke keeps the 1.5 CSS px line at 20px in
92
+ the 24-unit box. */
93
+ .ui-seg button.ui-seg--icon { padding: 2px; }
94
+ .ui-seg button.ui-seg--icon svg { width: 20px; height: 20px; stroke-width: 1.8; }
72
95
 
73
96
  .ui-seg--sm button { min-height: var(--space-6); padding: var(--space-1) var(--space-3); font-size: var(--text-sm); line-height: var(--leading-tight); }
74
97
  .ui-seg--block { display: flex; align-self: stretch; justify-self: stretch; }
@@ -153,7 +176,7 @@
153
176
  left: var(--space-3); right: var(--space-3); bottom: 3px;
154
177
  height: 2px;
155
178
  border-radius: 2px;
156
- background: var(--accent);
179
+ background: var(--strong);
157
180
  opacity: 0;
158
181
  transform: scaleX(0.4);
159
182
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
@@ -176,7 +199,7 @@
176
199
  color: HighlightText;
177
200
  --ring: var(--ring-width) solid CanvasText;
178
201
  }
179
- /* The fill is the one mark, so the underline bar, which would paint the accent inside it, is gone. */
202
+ /* The fill is the one mark, so the underline bar, which would paint a second mark inside it, is gone. */
180
203
  .ui-seg--underline button.is-active::before,
181
204
  .ui-seg--underline button[aria-pressed="true"]::before,
182
205
  .ui-seg--underline button[aria-selected="true"]::before { display: none; /* motion: still — the bar is not drawn while the fill marks the choice */ }
@@ -110,12 +110,34 @@
110
110
  * ships this sheet without those sheets, where order is the consumer's. */
111
111
 
112
112
  /* A strip keeps its pills packed across — that tight track IS the control —
113
- and opens down, where the room is free until it wraps. */
113
+ and opens down, where the room is free until it wraps. The 4px gap between
114
+ options is the horizontal clearance while every option is labelled; a
115
+ wordless strip reads its OUTER container's clearance instead, so its
116
+ options stop where the outer room stops. */
114
117
  .ui-seg {
115
118
  row-gap: var(--tap-gap) !important;
116
- --tap-clear-x: var(--space-1, 4px);
117
119
  --tap-clear-y: var(--tap-gap);
118
120
  }
121
+ .ui-seg:not(:has(button.ui-seg--icon)) { --tap-clear-x: var(--space-1, 4px); }
122
+
123
+ /* A wordless switch keeps its 32px pill, and each option still owns a 44px
124
+ target without crossing the shared middle: the left option reaches left
125
+ past the pill's edge, the right option reaches right, the way the 32px
126
+ back link does. Each takes 2px toward the middle (half the gap) and,
127
+ outward, half the track's 4px padding plus what the outer container clears
128
+ — 16px where it clears --tap-gap, 0 where it clears nothing, so a packed
129
+ toolbar's switch stays 28px instead of stealing a neighbour's pixel. */
130
+ .ui-seg button.ui-seg--icon:first-child::after {
131
+ left: calc(-1 * (var(--space-1) / 2 + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
132
+ width: min(var(--tap-min), calc(100% + var(--space-1) + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
133
+ transform: translateY(-50%);
134
+ }
135
+ .ui-seg button.ui-seg--icon:last-child::after {
136
+ right: calc(-1 * (var(--space-1) / 2 + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
137
+ left: auto;
138
+ width: min(var(--tap-min), calc(100% + var(--space-1) + min(calc(var(--tap-min) - 100% - var(--space-1)), var(--tap-clear-x))));
139
+ transform: translateY(-50%);
140
+ }
119
141
 
120
142
  /* The underline appearance keeps the gap it draws, at every width and under
121
143
  both pointers, so a wrapped strip reads as one block. It can because the tab
@@ -180,7 +202,8 @@
180
202
  button: across, the room beside it is title text, and down, the row opens
181
203
  to 12px, because the layer reaches 10px under it and the title gap is 8.
182
204
  Between two tools the gap opens to --tap-gap, so neither layer reaches the
183
- other. A chart's switch there keeps the clearance .ui-seg declares. */
205
+ other. A chart's wordless switch reads this clearance for its outer edge,
206
+ so it reaches 44px past the pill. */
184
207
  .ui-card__head { margin-bottom: var(--space-3, 12px) !important; }
185
208
  .ui-card__tools { column-gap: var(--tap-gap) !important; --tap-clear-x: var(--tap-gap); --tap-clear-y: var(--tap-gap); }
186
209
  /* The page's title row holds small tools the same way: the room beside them is title
@@ -236,6 +259,10 @@
236
259
  /* The opened rows outgrow the menu's 300px cap, whose scroll edge cut the last
237
260
  week's tap layers in a phone popover. The panel keeps the viewport and edge limits. */
238
261
  .ui-datepicker__panel { --ui-dropdown-max: 100dvh; }
262
+ /* The same cut in the sheet: the opened grid outgrows the md drawer (45vh), so
263
+ its body scrolls and the scroll edge clips the last week's layers. The lg
264
+ step (72vh) fits the six weeks and the shortcuts. */
265
+ .ui-drawer:has(.ui-datepicker__body.is-sheet) { --drawer-h: 72vh; }
239
266
 
240
267
  /* Neither axis is opened: the room is already there, a hundred pixels to the
241
268
  caption and twelve to the grid, which is how `.ui-tabs__list` declares its
@@ -69,8 +69,9 @@
69
69
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
70
70
  }
71
71
  .dtsw a:hover { color: var(--strong); }
72
- .dtsw a.cur { color: var(--accent-contrast); background: var(--accent); }
73
- :where(:root[data-theme="dark"]) .dtsw a.cur { color: var(--signal-contrast); }
72
+ /* The current view is a view switch, so it takes the neutral selected fill:
73
+ the strong ink on the surface, never the accent. */
74
+ .dtsw a.cur { color: var(--surface); background: var(--strong); }
74
75
  @media (forced-colors: active) {
75
76
  .dtsw a.cur { forced-color-adjust: none; background: Highlight; color: HighlightText; --ring: var(--ring-width) solid CanvasText; }
76
77
  }