@sincpro/web-ui 2.4.0 → 2.6.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.
Files changed (69) hide show
  1. package/README.md +75 -8
  2. package/dist/components/activity/Activity.d.ts +28 -2
  3. package/dist/components/activity/Activity.js +53 -11
  4. package/dist/components/activity/Messages.d.ts +4 -0
  5. package/dist/components/activity/index.d.ts +1 -1
  6. package/dist/components/attachments/Attachments.d.ts +1 -28
  7. package/dist/components/attachments/Attachments.js +5 -24
  8. package/dist/components/attachments/FileList.d.ts +28 -0
  9. package/dist/components/attachments/FileList.js +91 -0
  10. package/dist/components/attachments/FileThumb.d.ts +13 -0
  11. package/dist/components/attachments/FileThumb.js +34 -0
  12. package/dist/components/attachments/download.d.ts +9 -0
  13. package/dist/components/attachments/download.js +36 -0
  14. package/dist/components/attachments/files.d.ts +28 -0
  15. package/dist/components/attachments/index.d.ts +4 -2
  16. package/dist/components/attachments/index.js +4 -1
  17. package/dist/components/board/Board.d.ts +74 -2
  18. package/dist/components/board/Board.js +65 -2
  19. package/dist/components/board/index.d.ts +1 -1
  20. package/dist/components/board/index.js +1 -1
  21. package/dist/components/calendar/RecordCalendar.d.ts +2 -1
  22. package/dist/components/calendar/RecordCalendar.js +4 -1
  23. package/dist/components/calendar/calendar.css +37 -0
  24. package/dist/components/canvas/canvas.css +6 -1
  25. package/dist/components/chat/ChatThread.d.ts +8 -1
  26. package/dist/components/chat/ChatThread.js +9 -4
  27. package/dist/components/chat/model.d.ts +4 -0
  28. package/dist/components/form/Form.js +11 -0
  29. package/dist/components/form/FormIndex.d.ts +11 -0
  30. package/dist/components/form/FormIndex.js +96 -0
  31. package/dist/components/form/Sheet.js +5 -0
  32. package/dist/components/gantt/RecordGantt.d.ts +9 -1
  33. package/dist/components/gantt/RecordGantt.js +16 -3
  34. package/dist/components/gantt/gantt.css +52 -0
  35. package/dist/components/listing/ChartExplorer.js +10 -5
  36. package/dist/components/record/DirtyActions.d.ts +10 -1
  37. package/dist/components/record/DirtyActions.js +77 -6
  38. package/dist/components/record/RecordHeader.js +17 -11
  39. package/dist/foundations/calendar.d.ts +12 -0
  40. package/dist/foundations/calendar.js +50 -0
  41. package/dist/foundations/chart.d.ts +10 -1
  42. package/dist/foundations/chart.js +17 -1
  43. package/dist/foundations/copy.d.ts +26 -0
  44. package/dist/foundations/copy.es.js +12 -0
  45. package/dist/foundations/copy.js +12 -0
  46. package/dist/foundations/form.d.ts +6 -0
  47. package/dist/foundations/form.js +7 -0
  48. package/dist/foundations/index.d.ts +2 -2
  49. package/dist/foundations/index.js +2 -2
  50. package/dist/foundations/pivot.d.ts +6 -0
  51. package/dist/foundations/pivot.js +1 -0
  52. package/dist/primitives/button/Button.d.ts +5 -1
  53. package/dist/primitives/button/Button.js +9 -2
  54. package/dist/primitives/chart/BarList.d.ts +30 -0
  55. package/dist/primitives/chart/BarList.js +27 -0
  56. package/dist/primitives/chart/Chart.d.ts +13 -0
  57. package/dist/primitives/chart/Chart.js +71 -19
  58. package/dist/primitives/chart/Sparkline.d.ts +30 -0
  59. package/dist/primitives/chart/Sparkline.js +53 -0
  60. package/dist/primitives/chart/index.d.ts +2 -0
  61. package/dist/primitives/chart/index.js +2 -0
  62. package/dist/primitives/field/Field.d.ts +6 -2
  63. package/dist/primitives/field/Field.js +35 -6
  64. package/dist/primitives/value/Markdown.d.ts +1 -0
  65. package/dist/primitives/value/Markdown.js +1 -0
  66. package/dist/primitives/value/Metric.d.ts +7 -0
  67. package/dist/primitives/value/Metric.js +5 -2
  68. package/dist/tokens.css +59 -87
  69. package/package.json +1 -1
@@ -0,0 +1,96 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { createContext, useContext, useEffect, useId, useMemo, useState, useSyncExternalStore, } from "react";
5
+ function createRegistry() {
6
+ let entries = [];
7
+ const listeners = new Set();
8
+ const emit = () => {
9
+ for (const listener of listeners)
10
+ listener();
11
+ };
12
+ return {
13
+ register(entry) {
14
+ entries = [...entries.filter((one) => one.id !== entry.id), entry];
15
+ emit();
16
+ return () => {
17
+ entries = entries.filter((one) => one.id !== entry.id);
18
+ emit();
19
+ };
20
+ },
21
+ subscribe(listener) {
22
+ listeners.add(listener);
23
+ return () => listeners.delete(listener);
24
+ },
25
+ snapshot: () => entries,
26
+ };
27
+ }
28
+ const NONE = [];
29
+ const IndexContext = createContext(null);
30
+ /** Where a form's sections register: the sheet of a «settings» form. */
31
+ export function FormIndexScope({ children }) {
32
+ const [registry] = useState(createRegistry);
33
+ return _jsx(IndexContext, { value: registry, children: children });
34
+ }
35
+ /** A section's place in the index: the id to give its element, or `undefined` when it is not
36
+ * listed — no title, or no index around it. */
37
+ export function useFormIndexEntry(title) {
38
+ const registry = useContext(IndexContext);
39
+ const id = useId();
40
+ useEffect(() => {
41
+ if (registry === null || title === undefined)
42
+ return;
43
+ return registry.register({ id, title });
44
+ }, [registry, id, title]);
45
+ return registry === null || title === undefined ? undefined : id;
46
+ }
47
+ function inDocumentOrder(entries) {
48
+ return [...entries].sort((a, b) => {
49
+ const first = document.getElementById(a.id);
50
+ const second = document.getElementById(b.id);
51
+ if (first === null || second === null)
52
+ return 0;
53
+ return first.compareDocumentPosition(second) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
54
+ });
55
+ }
56
+ /** The index itself: the sections' titles, the current one marked, each bringing its
57
+ * section into view. Drawn by `Sheet` in the «settings» style. */
58
+ export function FormIndex() {
59
+ const copy = useUiCopy();
60
+ const registry = useContext(IndexContext);
61
+ const entries = useSyncExternalStore(registry?.subscribe ?? (() => () => undefined), registry?.snapshot ?? (() => NONE), () => NONE);
62
+ const ordered = useMemo(() => inDocumentOrder(entries), [entries]);
63
+ const [current, setCurrent] = useState(undefined);
64
+ /* The section being read is the first one crossing the top two fifths of the screen:
65
+ the one whose title just went by is still the one being read until the next arrives. */
66
+ useEffect(() => {
67
+ if (ordered.length < 2 || typeof IntersectionObserver === "undefined")
68
+ return;
69
+ const seen = new Set();
70
+ const observer = new IntersectionObserver((changes) => {
71
+ for (const change of changes) {
72
+ if (change.isIntersecting)
73
+ seen.add(change.target.id);
74
+ else
75
+ seen.delete(change.target.id);
76
+ }
77
+ const first = ordered.find((entry) => seen.has(entry.id));
78
+ if (first !== undefined)
79
+ setCurrent(first.id);
80
+ }, { rootMargin: "0px 0px -60% 0px" });
81
+ for (const entry of ordered) {
82
+ const element = document.getElementById(entry.id);
83
+ if (element !== null)
84
+ observer.observe(element);
85
+ }
86
+ return () => observer.disconnect();
87
+ }, [ordered]);
88
+ if (ordered.length < 2)
89
+ return null;
90
+ const marked = current ?? ordered[0]?.id;
91
+ return (_jsx("nav", { "aria-label": copy.field.sections, "data-ui": "form.index", className: "hidden w-(--container-form-index) shrink-0 @3xl/form:block", children: _jsx("ul", { className: "sticky top-3 flex flex-col gap-0.5", children: ordered.map((entry) => (_jsx("li", { children: _jsx("a", { href: `#${entry.id}`, ...(entry.id === marked ? { "aria-current": "location" } : {}), onClick: (event) => {
92
+ event.preventDefault();
93
+ document.getElementById(entry.id)?.scrollIntoView({ block: "start" });
94
+ setCurrent(entry.id);
95
+ }, className: "block truncate rounded-ui-nav px-2.5 py-1.5 text-meta text-muted transition-colors duration-(--duration-instant) outline-0 hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-primary aria-[current]:bg-ui-nav-current aria-[current]:font-medium aria-[current]:text-ink", children: entry.title }) }, entry.id))) }) }));
96
+ }
@@ -1,6 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { FormIndex, FormIndexScope } from "./FormIndex.js";
3
4
  import { byDensity, useDensity } from "../../foundations/density.js";
5
+ import { useFormStyle } from "../../foundations/form.js";
4
6
  import { FieldLayoutProvider, } from "../../primitives/field/layout.js";
5
7
  import { NoteCard, NoteFlag } from "../../primitives/field/note.js";
6
8
  import { Hint } from "../../primitives/hint/Hint.js";
@@ -46,10 +48,13 @@ function Facts({ fields, columns, layout, }) {
46
48
  }
47
49
  export function Sheet({ fields, columns = 2, layout = "stacked", head, children, }) {
48
50
  const d = useDensity();
51
+ const settings = useFormStyle() === "settings";
49
52
  const facts = fields !== undefined && fields.length > 0;
50
53
  if (!facts && head === undefined && children === undefined)
51
54
  return null;
52
55
  const top = facts || head !== undefined ? (_jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-4", "gap-3")}`, children: [facts ? _jsx(Facts, { fields: fields, columns: columns, layout: layout }) : null, head] })) : null;
56
+ if (settings)
57
+ return (_jsx(FieldLayoutProvider, { value: layout, children: _jsx(FormIndexScope, { children: _jsx("div", { className: "@container/form min-w-0", children: _jsxs("div", { className: "flex min-w-0 gap-6", children: [_jsx(FormIndex, {}), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-4", children: [top, children] })] }) }) }) }));
53
58
  return (_jsx(FieldLayoutProvider, { value: layout, children: _jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-(--spacing-block)", "gap-2.5")}`, children: [top, children] }) }));
54
59
  }
55
60
  /** A row of columns on the paper. The paper is the sheet; a group is not a
@@ -1,3 +1,4 @@
1
+ import "@sincpro/web-ui/components/gantt/gantt.css";
1
2
  /** A dependency between two records: «B starts when A ends» (`e2s`, the usual one). */
2
3
  export type GanttLink = {
3
4
  id: string;
@@ -35,7 +36,14 @@ export type RecordGanttProps<T> = {
35
36
  * Records on a timeline — Odoo's Gantt view: projects, tasks, manufacturing orders.
36
37
  *
37
38
  * Context: drawn by SVAR React Gantt (MIT core: move, resize, progress, dependencies, zoom),
38
- * dressed by `tokens.css` (its Willow theme's `--wx-*` variables point at web-ui's tokens).
39
+ * dressed by `gantt.css` — SVAR's stylesheet and its Willow theme's `--wx-*` variables pointed
40
+ * at web-ui's tokens —, imported here so it travels in the Gantt's chunk.
41
+ *
42
+ * The chart is drawn in the browser only: SVAR paints its grid with a canvas, which a server
43
+ * does not have, so a server-rendered chart (Next.js) would not match the browser's first
44
+ * render. The server — and the hydrating pass — draw the skeleton; the chart comes right
45
+ * after. An SPA, which does not hydrate, draws the chart at once.
46
+ *
39
47
  * The chart keeps its own state while dragging; every finished change is reported (`onMove`,
40
48
  * `onProgress`) and the app passes the saved `items` back, which the chart re-reads. Without
41
49
  * `onMove` / `onProgress` it is read-only. Auto-scheduling, critical path and resource load are
@@ -1,9 +1,14 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import "@sincpro/web-ui/components/gantt/gantt.css";
3
4
  import { TimelineToolbar } from "../timeline/TimelineToolbar.js";
4
5
  import { useUiCopy } from "../../foundations/copy.js";
6
+ import { Skeleton } from "../../primitives/notice/Notice.js";
5
7
  import { Gantt, Willow } from "@svar-ui/react-gantt";
6
- import { useEffect, useMemo, useRef, useState } from "react";
8
+ import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
9
+ /* Nothing to listen to: the answer («is this a browser?») never changes after the first
10
+ render. Only the hydrating pass reads the server's `false`. */
11
+ const subscribe = () => () => { };
7
12
  /* The two rows of the time scale per zoom, written with `Intl` in the system's language
8
13
  (SVAR's own format strings would ignore it), and how wide one cell of the finer row is. */
9
14
  function scalesOf(zoom, locale) {
@@ -40,7 +45,14 @@ function scalesOf(zoom, locale) {
40
45
  * Records on a timeline — Odoo's Gantt view: projects, tasks, manufacturing orders.
41
46
  *
42
47
  * Context: drawn by SVAR React Gantt (MIT core: move, resize, progress, dependencies, zoom),
43
- * dressed by `tokens.css` (its Willow theme's `--wx-*` variables point at web-ui's tokens).
48
+ * dressed by `gantt.css` — SVAR's stylesheet and its Willow theme's `--wx-*` variables pointed
49
+ * at web-ui's tokens —, imported here so it travels in the Gantt's chunk.
50
+ *
51
+ * The chart is drawn in the browser only: SVAR paints its grid with a canvas, which a server
52
+ * does not have, so a server-rendered chart (Next.js) would not match the browser's first
53
+ * render. The server — and the hydrating pass — draw the skeleton; the chart comes right
54
+ * after. An SPA, which does not hydrate, draws the chart at once.
55
+ *
44
56
  * The chart keeps its own state while dragging; every finished change is reported (`onMove`,
45
57
  * `onProgress`) and the app passes the saved `items` back, which the chart re-reads. Without
46
58
  * `onMove` / `onProgress` it is read-only. Auto-scheduling, critical path and resource load are
@@ -77,6 +89,7 @@ export function RecordGantt({ items, keyOf, titleOf, startOf, endOf, progressOf,
77
89
  };
78
90
  });
79
91
  const editable = onMove !== undefined || onProgress !== undefined;
92
+ const inBrowser = useSyncExternalStore(subscribe, () => true, () => false);
80
93
  /* The chart reports through its store's actions: `update-task` for a move, a stretch or the
81
94
  progress handle — the finished one, not every pixel of the drag (`inProgress`). */
82
95
  const init = (api) => {
@@ -106,5 +119,5 @@ export function RecordGantt({ items, keyOf, titleOf, startOf, endOf, progressOf,
106
119
  void root.current?.requestFullscreen?.();
107
120
  else if (document.fullscreenElement !== null)
108
121
  void document.exitFullscreen();
109
- } }), _jsx("div", { className: "min-h-0 flex-1", children: _jsx(Willow, { fonts: false, children: _jsx(Gantt, { tasks: tasks, links: links.map((link) => ({ ...link, type: link.type ?? "e2s" })), scales: time.scales, cellWidth: cellWidth, readonly: !editable, columns: [{ id: "text", header: nameHeader ?? "", width: 260 }], init: init }) }) })] }));
122
+ } }), _jsx("div", { className: "min-h-0 flex-1", children: inBrowser ? (_jsx(Willow, { fonts: false, children: _jsx(Gantt, { tasks: tasks, links: links.map((link) => ({ ...link, type: link.type ?? "e2s" })), scales: time.scales, cellWidth: cellWidth, readonly: !editable, columns: [{ id: "text", header: nameHeader ?? "", width: 260 }], init: init }) })) : (_jsx(Skeleton, { label: copy.failed.loading })) })] }));
110
123
  }
@@ -0,0 +1,52 @@
1
+ /* ====================================================================
2
+ * THE RECORD GANTT (SVAR, Willow theme) in these tokens.
3
+ *
4
+ * Context: SVAR's stylesheet (~160 KB, Willow included), then its variables pointed at
5
+ * web-ui's tokens. It comes with `RecordGantt` — imported by the component, not by
6
+ * `tokens.css` — so it travels in the Gantt's chunk: a screen that never opens a Gantt never
7
+ * downloads it.
8
+ *
9
+ * Willow DECLARES its `--wx-*` on `.wx-willow-theme`; redeclared on the same class here, after
10
+ * its import in the same file, they win — whenever the chunk arrives. Bars are the navy of the
11
+ * system, a summary the ink, a milestone the info tone; the type is the system's. Aliases:
12
+ * they flip with the theme.
13
+ * ==================================================================== */
14
+ @import "@svar-ui/react-gantt/all.css";
15
+
16
+ .wx-willow-theme {
17
+ --wx-color-primary: var(--color-primary);
18
+ --wx-color-primary-selected: color-mix(in srgb, var(--color-primary) 14%, transparent);
19
+ --wx-color-primary-font: var(--color-surface);
20
+ --wx-color-secondary-hover: color-mix(in srgb, var(--color-primary) 10%, transparent);
21
+ --wx-color-success: var(--color-good);
22
+ --wx-color-warning: var(--color-warn);
23
+ --wx-color-info: var(--color-info);
24
+ --wx-color-danger: var(--color-danger);
25
+ --wx-color-font: var(--color-ink);
26
+ --wx-color-font-alt: var(--color-muted);
27
+ --wx-background: var(--color-surface);
28
+ --wx-background-alt: var(--color-ground);
29
+ --wx-background-hover: color-mix(in srgb, var(--color-ink) 5%, transparent);
30
+ --wx-font-family: inherit;
31
+ --wx-font-size: var(--text-meta);
32
+ --wx-font-size-sm: var(--text-micro);
33
+ --wx-icon-color: var(--color-muted);
34
+ --wx-border-color: var(--color-line);
35
+ --wx-border-radius: var(--radius-control);
36
+ --wx-radius-major: var(--radius-box);
37
+ --wx-gantt-border-color: var(--color-line);
38
+ --wx-gantt-task-color: var(--color-primary);
39
+ --wx-gantt-task-fill-color: var(--color-primary-hover);
40
+ --wx-gantt-task-border-color: var(--color-primary-hover);
41
+ --wx-gantt-task-font-color: var(--color-surface);
42
+ --wx-gantt-summary-color: var(--color-line-strong);
43
+ --wx-gantt-summary-fill-color: color-mix(in srgb, var(--color-ink) 45%, transparent);
44
+ --wx-gantt-summary-border-color: var(--color-line-strong);
45
+ --wx-gantt-summary-font-color: var(--color-ink);
46
+ --wx-gantt-milestone-color: var(--color-info);
47
+ --wx-gantt-select-color: color-mix(in srgb, var(--color-primary) 10%, transparent);
48
+ --wx-gantt-link-color: var(--color-muted);
49
+ --wx-gantt-link-color-hovered: var(--color-ink);
50
+ --wx-gantt-holiday-background: var(--color-ground);
51
+ --wx-gantt-holiday-color: var(--color-muted);
52
+ }
@@ -9,9 +9,14 @@ import { Button, IconButton } from "../../primitives/button/Button.js";
9
9
  import { Chart } from "../../primitives/chart/Chart.js";
10
10
  import { SegmentedControl } from "../../primitives/choice/SegmentedControl.js";
11
11
  import { Menu } from "../../primitives/menu/Menu.js";
12
- import { ArrowDownWideNarrow, ArrowUpNarrowWide, ChartColumnBig, ChartLine, ChartPie, Download, GitCompareArrows, Layers, Sigma, TrendingUp, } from "lucide-react";
12
+ import { ArrowDownWideNarrow, ArrowUpNarrowWide, ChartArea, ChartColumnBig, ChartLine, ChartPie, Download, GitCompareArrows, Layers, Sigma, TrendingUp, } from "lucide-react";
13
13
  import { useMemo, useState } from "react";
14
- const KIND_ICON = { bar: ChartColumnBig, line: ChartLine, pie: ChartPie };
14
+ const KIND_ICON = {
15
+ bar: ChartColumnBig,
16
+ line: ChartLine,
17
+ area: ChartArea,
18
+ pie: ChartPie,
19
+ };
15
20
  /**
16
21
  * Odoo's GRAPH view, for any set: bars, lines or a pie; which measures; split by what along
17
22
  * the axis and by what into series; stacked, cumulative, ordered; against the previous
@@ -64,7 +69,7 @@ export function ChartExplorer({ folded, items, of, fields = [], labelOf: outerLa
64
69
  return measuresShown.map((measure) => {
65
70
  const reading = {
66
71
  measure: measure.id,
67
- cumulative: kind === "line" && cumulative,
72
+ cumulative: (kind === "line" || kind === "area") && cumulative,
68
73
  ...(kind === "pie" ? { maxCategories: 7 } : {}),
69
74
  };
70
75
  const current = chartFromPivot(pivot, reading);
@@ -92,7 +97,7 @@ export function ChartExplorer({ folded, items, of, fields = [], labelOf: outerLa
92
97
  /* The last one stays: a chart of no measure is no chart. */
93
98
  setChosen(!on.includes(id) ? [...on, id] : on.length === 1 ? on : on.filter((one) => one !== id));
94
99
  };
95
- return (_jsxs("div", { className: "flex min-w-0 flex-col gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-5 gap-y-2", children: [_jsx(SegmentedControl, { "aria-label": words.kind, size: "sm", value: kind, onChange: (next) => setKind(next), options: ["bar", "line", "pie"].map((one) => ({
100
+ return (_jsxs("div", { className: "flex min-w-0 flex-col gap-4", children: [_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-5 gap-y-2", children: [_jsx(SegmentedControl, { "aria-label": words.kind, size: "sm", value: kind, onChange: (next) => setKind(next), options: ["bar", "line", "area", "pie"].map((one) => ({
96
101
  value: one,
97
102
  label: words[one],
98
103
  icon: KIND_ICON[one],
@@ -105,7 +110,7 @@ export function ChartExplorer({ folded, items, of, fields = [], labelOf: outerLa
105
110
  checked: measuresShown.some((on) => on.id === one.id),
106
111
  })),
107
112
  },
108
- ], onSelect: toggleMeasure }), folded === undefined ? (_jsxs(_Fragment, { children: [_jsx(AxisLevels, { name: words.categoriesAxis, levels: categories, onChange: following ? null : setOwnCategories, fields: fields, used: series, labelOf: labelOf }), kind === "pie" || (following && series.length === 0) ? null : (_jsx(AxisLevels, { name: words.seriesAxis, levels: series, onChange: following ? null : setOwnSeries, fields: fields, used: categories, labelOf: labelOf }))] })) : null, _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [canCompare ? (_jsx(IconButton, { icon: GitCompareArrows, label: fillCopy(words.compareWith, { name: compare.previous }), "aria-pressed": comparing, onClick: () => setComparing((now) => !now) })) : null, kind !== "pie" && manySeries ? (_jsx(IconButton, { icon: Layers, label: words.stacked, "aria-pressed": stacked, onClick: () => setStacked((now) => !now) })) : null, kind === "line" ? (_jsx(IconButton, { icon: TrendingUp, label: words.cumulative, "aria-pressed": cumulative && additive, disabled: !additive, onClick: () => setCumulative((now) => !now) })) : null, _jsx(IconButton, { icon: ArrowDownWideNarrow, label: words.descending, "aria-pressed": order === "desc", onClick: () => toggleOrder("desc") }), _jsx(IconButton, { icon: ArrowUpNarrowWide, label: words.ascending, "aria-pressed": order === "asc", onClick: () => toggleOrder("asc") }), pivot === undefined ? null : (_jsx(Button, { role: "ghost", size: "sm", icon: Download, onClick: () => downloadPivot(pivot, fileName === undefined ? {} : { name: fileName }), children: copy.pivot.download }))] })] }), charts.map((data) => (_jsxs("section", { className: "flex min-w-0 flex-col gap-2", children: [charts.length > 1 ? (_jsx("h3", { className: "text-meta font-semibold text-ink", children: data.measure.header })) : null, _jsx(Chart, { data: data, kind: kind, stacked: stacked, label: charts.length > 1
113
+ ], onSelect: toggleMeasure }), folded === undefined ? (_jsxs(_Fragment, { children: [_jsx(AxisLevels, { name: words.categoriesAxis, levels: categories, onChange: following ? null : setOwnCategories, fields: fields, used: series, labelOf: labelOf }), kind === "pie" || (following && series.length === 0) ? null : (_jsx(AxisLevels, { name: words.seriesAxis, levels: series, onChange: following ? null : setOwnSeries, fields: fields, used: categories, labelOf: labelOf }))] })) : null, _jsxs("div", { className: "ml-auto flex items-center gap-1", children: [canCompare ? (_jsx(IconButton, { icon: GitCompareArrows, label: fillCopy(words.compareWith, { name: compare.previous }), "aria-pressed": comparing, onClick: () => setComparing((now) => !now) })) : null, kind !== "pie" && manySeries ? (_jsx(IconButton, { icon: Layers, label: words.stacked, "aria-pressed": stacked, onClick: () => setStacked((now) => !now) })) : null, kind === "line" || kind === "area" ? (_jsx(IconButton, { icon: TrendingUp, label: words.cumulative, "aria-pressed": cumulative && additive, disabled: !additive, onClick: () => setCumulative((now) => !now) })) : null, _jsx(IconButton, { icon: ArrowDownWideNarrow, label: words.descending, "aria-pressed": order === "desc", onClick: () => toggleOrder("desc") }), _jsx(IconButton, { icon: ArrowUpNarrowWide, label: words.ascending, "aria-pressed": order === "asc", onClick: () => toggleOrder("asc") }), pivot === undefined ? null : (_jsx(Button, { role: "ghost", size: "sm", icon: Download, onClick: () => downloadPivot(pivot, fileName === undefined ? {} : { name: fileName }), children: copy.pivot.download }))] })] }), charts.map((data) => (_jsxs("section", { className: "flex min-w-0 flex-col gap-2", children: [charts.length > 1 ? (_jsx("h3", { className: "text-meta font-semibold text-ink", children: data.measure.header })) : null, _jsx(Chart, { data: data, kind: kind, stacked: stacked, label: charts.length > 1
109
114
  ? describe(data.measure.header, label ?? data.categoryTitle)
110
115
  : (label ?? describe(data.measure.header, data.categoryTitle)), ...(onPoint === undefined ? {} : { onPoint }), ...(height === undefined ? {} : { height }) })] }, data.measure.id)))] }));
111
116
  }
@@ -26,7 +26,12 @@ export interface DirtyState {
26
26
  * two was noise beside the one action that matters. The only thing written here is what
27
27
  * the buttons cannot say — WHY it cannot be saved yet (`blocked`). The count of changes
28
28
  * still reaches a screen reader, as the Save button's description. */
29
- export declare function DirtyActions({ onSave, onDiscard, saving, label, blocked, changes, }: DirtyState): import("react").JSX.Element;
29
+ export declare function DirtyActions({ onSave, onDiscard, saving, label, blocked, changes, floating, }: DirtyState & {
30
+ /** In the floating bar (`DirtyBar`): the count is WRITTEN — the changed fields may be far
31
+ * up a long form, out of sight, and their marks with them — and Discard is the quiet
32
+ * ghost, so the bar reads «what is pending · undo · save» and not two equal boxes. */
33
+ floating?: boolean;
34
+ }): import("react").JSX.Element;
30
35
  /**
31
36
  * Whether the record has JUST been saved: `dirty` went from saving straight to gone.
32
37
  *
@@ -40,3 +45,7 @@ export declare function useJustSaved(dirty: DirtyState | undefined): boolean;
40
45
  export declare function SavedMark({ saved }: {
41
46
  saved: boolean;
42
47
  }): import("react").JSX.Element;
48
+ export declare function DirtyBar({ dirty, saved, }: {
49
+ dirty: DirtyState | undefined;
50
+ saved: boolean;
51
+ }): import("react").JSX.Element;
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
- import { bySurface, useSurface } from "../../foundations/surface.js";
4
+ import { bySurface, SurfaceProvider, useSurface } from "../../foundations/surface.js";
5
5
  import { Button } from "../../primitives/button/Button.js";
6
6
  import { Check, Save, Undo2 } from "lucide-react";
7
7
  import { useEffect, useId, useRef, useState } from "react";
@@ -16,7 +16,7 @@ import { useEffect, useId, useRef, useState } from "react";
16
16
  * two was noise beside the one action that matters. The only thing written here is what
17
17
  * the buttons cannot say — WHY it cannot be saved yet (`blocked`). The count of changes
18
18
  * still reaches a screen reader, as the Save button's description. */
19
- export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked, changes, }) {
19
+ export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked, changes, floating = false, }) {
20
20
  const copy = useUiCopy();
21
21
  const blockedId = useId();
22
22
  const changesId = useId();
@@ -28,9 +28,15 @@ export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked
28
28
  ...(blocked === undefined ? [] : [blockedId]),
29
29
  ...(counted ? [changesId] : []),
30
30
  ].join(" ");
31
- return (_jsxs(_Fragment, { children: [blocked === undefined ? null : (_jsx("span", { id: blockedId, "data-ui": "dirty.blocked", className: `inline-flex h-(--size-control-md) min-w-0 shrink items-center gap-1.5 truncate rounded-control px-2.5 text-meta font-medium ${bySurface(surface, "bg-warn/12 text-warn", "bg-chrome-warn/15 text-chrome-warn")}`, children: blocked })), counted ? (_jsx("span", { id: changesId, hidden: true, children: fillCopy(changes === 1 ? copy.record.unsavedOne : copy.record.unsavedMany, {
31
+ return (_jsxs(_Fragment, { children: [blocked === undefined ? null : (_jsx("span", { id: blockedId, "data-ui": "dirty.blocked", className: `inline-flex h-(--size-control-md) min-w-0 shrink items-center gap-1.5 truncate rounded-control px-2.5 text-meta font-medium ${bySurface(surface, "bg-warn/12 text-warn", "bg-chrome-warn/15 text-chrome-warn")}`, children: blocked })), counted ? (_jsx("span", { id: changesId, ...(floating
32
+ ? {
33
+ /* One row on a phone too: the count gives way (it truncates), never the
34
+ buttons — a pill broken in two rows is a blob. */
35
+ className: `min-w-0 shrink! truncate px-2.5 text-meta ${bySurface(surface, "text-muted", "text-chrome-muted")}`,
36
+ }
37
+ : { hidden: true }), children: fillCopy(changes === 1 ? copy.record.unsavedOne : copy.record.unsavedMany, {
32
38
  count: changes.toLocaleString(copy.locale),
33
- }) })) : null, _jsx(Button, { surface: surface, onClick: onDiscard, disabled: saving, icon: Undo2, children: copy.record.discard }), _jsx(Button, { role: "primary", surface: surface, onClick: onSave, busy: saving, disabled: blocked !== undefined, icon: Save, ...(describedBy === "" ? {} : { "aria-describedby": describedBy }), children: saving ? copy.record.saving : (label ?? copy.record.save) })] }));
39
+ }) })) : null, _jsx(Button, { ...(floating ? { role: "ghost" } : {}), surface: surface, onClick: onDiscard, disabled: saving, icon: Undo2, children: copy.record.discard }), _jsx(Button, { role: "primary", surface: surface, onClick: onSave, busy: saving, disabled: blocked !== undefined, icon: Save, ...(describedBy === "" ? {} : { "aria-describedby": describedBy }), children: saving ? copy.record.saving : (label ?? copy.record.save) })] }));
34
40
  }
35
41
  /** The one action a view leads with: the element written with `role="primary"` — the
36
42
  * same prop that paints it gold and that `make smoke` counts, so there is no second way to
@@ -69,10 +75,75 @@ export function useJustSaved(dirty) {
69
75
  }, [saving, present]);
70
76
  return saved;
71
77
  }
78
+ /** The «✓ Guardado» chip itself, without its live region: what is SEEN. */
79
+ function SavedChip() {
80
+ const copy = useUiCopy();
81
+ const surface = useSurface();
82
+ return (_jsxs("span", { "aria-hidden": true, className: `inline-flex h-(--size-control-md) shrink-0 items-center gap-1.5 rounded-ui-button px-2.5 text-meta font-medium transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) starting:-translate-y-0.5 starting:opacity-0 ${bySurface(surface, "bg-good/12 text-good", "bg-chrome-good/15 text-chrome-good")}`, children: [_jsx(Check, { className: "size-(--size-icon-sm)", strokeWidth: 2.5 }), copy.record.saved] }));
83
+ }
72
84
  /** «✓ Guardado», where Save was, for a moment. The live region is always there — a region
73
85
  * inserted together with its words is not reliably announced. */
74
86
  export function SavedMark({ saved }) {
75
87
  const copy = useUiCopy();
76
- const surface = useSurface();
77
- return (_jsxs(_Fragment, { children: [_jsx("span", { role: "status", className: "sr-only", children: saved ? copy.record.saved : "" }), saved ? (_jsxs("span", { "aria-hidden": true, className: `inline-flex h-(--size-control-md) shrink-0 items-center gap-1.5 rounded-control px-2.5 text-meta font-medium transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) starting:-translate-y-0.5 starting:opacity-0 ${bySurface(surface, "bg-good/12 text-good", "bg-chrome-good/15 text-chrome-good")}`, children: [_jsx(Check, { className: "size-(--size-icon-sm)", strokeWidth: 2.5 }), copy.record.saved] })) : null] }));
88
+ return (_jsxs(_Fragment, { children: [_jsx("span", { role: "status", className: "sr-only", children: saved ? copy.record.saved : "" }), saved ? _jsx(SavedChip, {}) : null] }));
89
+ }
90
+ /**
91
+ * Save and Discard FLOATING at the bottom of the screen, centred — the «settings» form
92
+ * style's (`FormStyleProvider`), in place of the rail and the thumb bar.
93
+ *
94
+ * Context: a settings form is long and read top to bottom; the rail is left behind with the
95
+ * first card, and the last field changed is near the bottom. The bar appears with the first
96
+ * change, in the dark band (the chrome) so it reads apart from the cards, and says «Guardado»
97
+ * for a moment where Save was. Sticky and last in the record, as the thumb bar: at the end of
98
+ * the form it settles under the last card and covers nothing.
99
+ *
100
+ * ── It never covers the field being typed into ──────────────────────
101
+ *
102
+ * The bar appears with the first keystroke, and on a phone the field being typed into is
103
+ * often the one at the bottom of the screen — right where the bar lands. So while the bar is
104
+ * up, the field that has the focus (when the bar appears, and each time the focus moves) is
105
+ * scrolled up out from under it: a form that hides what you are writing is broken, however
106
+ * nice the bar.
107
+ *
108
+ * ── Its shape ─────────────────────────────────────────────────────────
109
+ *
110
+ * A pill holds pills: the buttons inside take the pill's radius (`--ui-button-radius`), or a
111
+ * full-round bar around 8 px corners reads as two boxes in a tube. On the dark theme the
112
+ * chrome is as dark as the ground, so the bar carries the chrome's hairline (`chrome-edge`) —
113
+ * invisible on light, where the chrome already stands apart by luminance.
114
+ */
115
+ const PILL = { "--ui-button-radius": "var(--radius-pill)" };
116
+ /** Scrolls `field` up from under `bar` when they overlap, with a little air above the bar. */
117
+ function clearOf(bar, field) {
118
+ if (!(field instanceof HTMLElement) || field === document.body || bar.contains(field))
119
+ return;
120
+ const over = bar.getBoundingClientRect();
121
+ const under = field.getBoundingClientRect();
122
+ if (over.height === 0 || under.bottom <= over.top || under.top >= over.bottom)
123
+ return;
124
+ const before = field.style.scrollMarginBottom;
125
+ field.style.scrollMarginBottom = `${String(Math.ceil(over.height + 12))}px`;
126
+ field.scrollIntoView({ block: "nearest" });
127
+ field.style.scrollMarginBottom = before;
128
+ }
129
+ export function DirtyBar({ dirty, saved, }) {
130
+ const copy = useUiCopy();
131
+ const shown = dirty !== undefined || saved;
132
+ const ref = useRef(null);
133
+ useEffect(() => {
134
+ const bar = ref.current;
135
+ if (!shown || bar === null)
136
+ return;
137
+ /* After the bar has its height: the frame it was drawn in. */
138
+ const frame = requestAnimationFrame(() => clearOf(bar, document.activeElement));
139
+ const onFocus = (event) => clearOf(bar, event.target);
140
+ document.addEventListener("focusin", onFocus);
141
+ return () => {
142
+ cancelAnimationFrame(frame);
143
+ document.removeEventListener("focusin", onFocus);
144
+ };
145
+ }, [shown]);
146
+ /* Always mounted, so «Guardado» is announced (see `SavedMark`); with nothing to say it has
147
+ no height and covers nothing. */
148
+ return (_jsxs("div", { ref: ref, "data-ui": "dirty.bar", className: `pointer-events-none sticky bottom-0 z-20 mt-auto flex justify-center px-3 ${shown ? "pt-3 safe-bottom" : ""}`, children: [_jsx("span", { role: "status", className: "sr-only", children: saved ? copy.record.saved : "" }), shown ? (_jsx(SurfaceProvider, { value: "chrome", children: _jsx("div", { style: PILL, className: "pointer-events-auto flex max-w-full min-w-0 items-center gap-1 rounded-pill border border-chrome-edge bg-chrome p-1.5 shadow-float *:shrink-0", children: dirty === undefined ? _jsx(SavedChip, {}) : _jsx(DirtyActions, { ...dirty, floating: true }) }) })) : null] }));
78
149
  }
@@ -1,18 +1,24 @@
1
1
  "use client";
2
2
  import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { Breadcrumb } from "./Breadcrumb.js";
4
- import { DirtyActions, SavedMark, useJustSaved, } from "./DirtyActions.js";
4
+ import { DirtyActions, DirtyBar, SavedMark, useJustSaved, } from "./DirtyActions.js";
5
5
  import { isPrimary, ThumbBar, thumbPlan } from "./ThumbBar.js";
6
6
  import { byDensity, useDensity } from "../../foundations/density.js";
7
+ import { useFormStyle } from "../../foundations/form.js";
7
8
  import { SurfaceProvider } from "../../foundations/surface.js";
8
9
  import { Line } from "../../primitives/block/Line.js";
9
10
  import { Tag } from "../../primitives/tag/Tag.js";
10
11
  import { useEffect, useRef } from "react";
11
12
  export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface = "canvas", smart, aspects, dirty, activity, activityLayout = "auto", width = "reading", ribbon, blocking, indicator, paper: onPaper, children, }) {
12
13
  const d = useDensity();
14
+ /* The «settings» form style (`FormStyleProvider`): Save and Discard float at the bottom
15
+ (`DirtyBar`) instead of taking the rail and the thumb bar, and the record has no white
16
+ sheet of its own — its sections are the cards, on the ground. */
17
+ const floating = useFormStyle() === "settings";
13
18
  /* «Guardado» is said where Save was; a record whose rail exists only while it has changes
14
19
  keeps it for that moment, or the answer would leave with the question. */
15
20
  const saved = useJustSaved(dirty);
21
+ const railDirty = floating ? undefined : dirty;
16
22
  /* Save is gone the moment it has saved, and the focus that was on it fell to the page —
17
23
  a keyboard was left at the top of the document. It comes back to the record's name:
18
24
  where reading the record starts, and announced together with «Guardado». */
@@ -24,12 +30,12 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
24
30
  if (lost)
25
31
  nameRef.current?.focus({ preventScroll: true });
26
32
  }, [saved]);
27
- const hasRail = saved ||
33
+ const hasRail = (saved && !floating) ||
28
34
  crumbs !== undefined ||
29
35
  pager !== undefined ||
30
36
  actions !== undefined ||
31
37
  status !== undefined ||
32
- dirty !== undefined;
38
+ railDirty !== undefined;
33
39
  /* In compact the rail goes away ENTIRELY, and it is not for room: in a
34
40
  preview, the breadcrumbs and the pager belong to the surface that opened it
35
41
  —the list behind is still there— and the actions are already in the
@@ -42,7 +48,7 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
42
48
  /* The activity column at the RIGHT of the sheet when the page is wide (THE PAGE). */
43
49
  const beside = activity !== undefined && activityLayout === "auto";
44
50
  /* The thumb bar's content (see THE THUMB BAR in `ThumbBar`): dirty first, else the primary. */
45
- const { rail: railActions, primaries, mode: thumb, } = thumbPlan({ withRail, actions, dirty });
51
+ const { rail: railActions, primaries, mode: thumb, } = thumbPlan({ withRail, actions, dirty: railDirty });
46
52
  /* In compact the TITLE is not drawn either, for the same reason as in
47
53
  `Listing`: the surface header already says it. Drawing it here showed it
48
54
  twice in the same 480 px drawer — and the name of a customer in this product
@@ -92,15 +98,15 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
92
98
  it. The line wraps on a phone, so it is never pushed out of reach. */
93
99
  smart === undefined && indicator === undefined ? undefined : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center justify-center gap-2", children: [smart, indicator] })), end: pager }), actions === undefined &&
94
100
  status === undefined &&
95
- dirty === undefined &&
96
- !saved ? null : (
101
+ railDirty === undefined &&
102
+ (!saved || floating) ? null : (
97
103
  /* Row 2 — WHAT I CAN DO and WHERE IT IS AT: actions stuck to the
98
104
  left edge, the history and the state stuck to the right one. No
99
105
  `flex-wrap`: wrapping split the row in two and the state ended up
100
106
  below the actions, which is another hierarchy. */
101
- _jsxs("div", { className: "flex min-w-0 items-start gap-x-4", children: [dirty !== undefined ? (_jsx("div", { className: "flex shrink-0 items-center gap-1.5 @max-handheld/record:hidden", children: _jsx(DirtyActions, { ...dirty }) })) : actions === undefined ? (_jsx(SavedMark, { saved: saved })) : (_jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [primaries.length === 0
107
+ _jsxs("div", { className: "flex min-w-0 items-start gap-x-4", children: [railDirty !== undefined ? (_jsx("div", { className: "flex shrink-0 items-center gap-1.5 @max-handheld/record:hidden", children: _jsx(DirtyActions, { ...railDirty }) })) : actions === undefined ? (floating ? null : (_jsx(SavedMark, { saved: saved }))) : (_jsxs("div", { className: "flex shrink-0 items-center gap-1.5", children: [primaries.length === 0
102
108
  ? actions
103
- : railActions.map((node) => isPrimary(node) ? (_jsx("span", { "data-thumb-moves": "", className: "contents @max-handheld/record:hidden", children: node }, node.key)) : (node)), _jsx(SavedMark, { saved: saved })] })), status === undefined ? null : (_jsx("div", { className: "ml-auto flex min-w-0 flex-col items-end gap-1.5", children: status }))] }))] }) }) }) })) : null, paper ? (
109
+ : railActions.map((node) => isPrimary(node) ? (_jsx("span", { "data-thumb-moves": "", className: "contents @max-handheld/record:hidden", children: node }, node.key)) : (node)), floating ? null : _jsx(SavedMark, { saved: saved })] })), status === undefined ? null : (_jsx("div", { className: "ml-auto flex min-w-0 flex-col items-end gap-1.5", children: status }))] }))] }) }) }) })) : null, paper ? (
104
110
  /* ==================================================================== *
105
111
  * THE PAGE — [sheet | Actividad], on the ground.
106
112
  *
@@ -128,14 +134,14 @@ export function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Ico
128
134
  * the application bar.
129
135
  * ==================================================================== */
130
136
  _jsx("div", { className: "bg-ground px-3 pt-3 pb-3", children: _jsx("div", { className: "@container/page", children: _jsxs("div", { className: `flex min-w-0 flex-col gap-3 ${column} ${beside
131
- ? "@beside/page:flex-row @beside/page:items-stretch @beside/page:justify-center @beside/page:gap-0"
137
+ ? `@beside/page:flex-row @beside/page:items-stretch @beside/page:justify-center ${floating ? "@beside/page:gap-4" : "@beside/page:gap-0"}`
132
138
  : ""}`, children: [_jsxs("div", { className: `flex min-w-0 flex-1 flex-col gap-3 ${beside && width === "reading"
133
139
  ? "mx-auto w-full max-w-(--container-sheet) @beside/page:mx-0"
134
- : ""}`, children: [blocking, _jsxs("div", { className: `relative flex min-w-0 flex-col overflow-clip rounded-box border border-line bg-surface ${beside ? "@beside/page:rounded-r-none" : ""}`, children: [ribbon, identity, children] }), activity !== undefined && activityLayout === "below" ? activity : null] }), beside ? (
140
+ : ""}`, children: [blocking, _jsxs("div", { className: `relative flex min-w-0 flex-col overflow-clip ${floating ? "" : "rounded-box border border-line bg-surface"} ${beside && !floating ? "@beside/page:rounded-r-none" : ""}`, children: [ribbon, identity, children] }), activity !== undefined && activityLayout === "below" ? activity : null] }), beside ? (
135
141
  /* After the sheet: the record first, what is around it second — in the
136
142
  reading order and on screen. */
137
143
  _jsx("div", { className: "mx-auto w-full max-w-(--container-sheet) min-w-0 @beside/page:mx-0 @beside/page:flex @beside/page:w-auto @beside/page:max-w-none @beside/page:shrink-0", children: activity })) : null] }) }) })) : (
138
144
  /* No paper (a modal, a drawer): one surface, no ground beside
139
145
  it — the band first, the record, and the activity below. */
140
- _jsxs("div", { className: "relative flex min-w-0 flex-1 flex-col overflow-clip bg-surface", children: [ribbon, blocking === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pt-3.5", "pb-2"), children: blocking })), identity, children, activity === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pb-4", "pb-2"), children: activity }))] })), thumb === null ? null : _jsx(ThumbBar, { mode: thumb, dirty: dirty, primaries: primaries })] }));
146
+ _jsxs("div", { className: "relative flex min-w-0 flex-1 flex-col overflow-clip bg-surface", children: [ribbon, blocking === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pt-3.5", "pb-2"), children: blocking })), identity, children, activity === undefined ? null : (_jsx("div", { className: byDensity(d, "px-4 pb-4", "pb-2"), children: activity }))] })), thumb === null ? null : (_jsx(ThumbBar, { mode: thumb, dirty: railDirty, primaries: primaries })), floating ? _jsx(DirtyBar, { dirty: dirty, saved: saved }) : null] }));
141
147
  }
@@ -21,6 +21,18 @@ export declare function dateKey(when: Date | string | number | null | undefined,
21
21
  * instead of vanishing behind an invented date.
22
22
  */
23
23
  export declare function dateLabel(key: string, grain: GroupGrain, within?: readonly GroupGrain[]): string;
24
+ /**
25
+ * The SHORT label of a date key: what an axis writes under its tick — «ene», «T1», «18 nov».
26
+ *
27
+ * Context: the axis used to write «Enero de 2025» under each month. Twelve of those do not fit
28
+ * side by side, so the chart dropped whichever collided and the axis read «Enero, Marzo,
29
+ * Abril, Mayo, Julio» — uneven, as if months were missing. A tick only has to tell its
30
+ * neighbours apart; the full label stays in the tooltip. `withYear` is for an axis that
31
+ * crosses a new year: then «ene 26» beside «dic 25».
32
+ */
33
+ export declare function dateTick(key: string, grain: GroupGrain, withYear?: boolean): string;
34
+ /** The year a date key of `grain` falls in, or `null` if the key does not have its shape. */
35
+ export declare function dateKeyYear(key: string, grain: GroupGrain): number | null;
24
36
  /**
25
37
  * The NEXT key in the same grain: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
26
38
  * «2026-W52» → the ISO week that follows. `null` if the key does not have the shape of its grain —
@@ -148,6 +148,56 @@ export function dateLabel(key, grain, within = []) {
148
148
  ...(said("year") ? {} : { year: "numeric" }),
149
149
  }).format(when));
150
150
  }
151
+ /**
152
+ * The SHORT label of a date key: what an axis writes under its tick — «ene», «T1», «18 nov».
153
+ *
154
+ * Context: the axis used to write «Enero de 2025» under each month. Twelve of those do not fit
155
+ * side by side, so the chart dropped whichever collided and the axis read «Enero, Marzo,
156
+ * Abril, Mayo, Julio» — uneven, as if months were missing. A tick only has to tell its
157
+ * neighbours apart; the full label stays in the tooltip. `withYear` is for an axis that
158
+ * crosses a new year: then «ene 26» beside «dic 25».
159
+ */
160
+ export function dateTick(key, grain, withYear = false) {
161
+ const copy = currentCopy();
162
+ if (key === "")
163
+ return copy.time.noDate;
164
+ const parts = KEY_SHAPES[grain].exec(key);
165
+ if (parts === null)
166
+ return key;
167
+ const locale = currentCopyLocale();
168
+ const year = Number(parts[1]);
169
+ const short = pad(year % 100);
170
+ if (grain === "year")
171
+ return String(year);
172
+ if (grain === "quarter") {
173
+ const quarter = fillCopy(copy.calendar.quarter, { n: Number(parts[2]) });
174
+ return withYear ? `${quarter} ${short}` : quarter;
175
+ }
176
+ if (grain === "week") {
177
+ const week = fillCopy(copy.calendar.weekShort, { n: Number(parts[2]) });
178
+ return withYear ? `${week} ${short}` : week;
179
+ }
180
+ /* `Intl`'s short month carries a dot in Spanish («ene.»): under a tick it is noise. */
181
+ const bare = (text) => text.replace(".", "");
182
+ if (grain === "month") {
183
+ const month = bare(format(locale, { month: "short" }).format(new Date(year, Number(parts[2]) - 1, 1)));
184
+ return withYear ? `${month} ${short}` : month;
185
+ }
186
+ const day = Number(parts[3]);
187
+ const when = new Date(year, Number(parts[2]) - 1, day);
188
+ if (when.getDate() !== day)
189
+ return key;
190
+ return bare(format(locale, {
191
+ day: "numeric",
192
+ month: "short",
193
+ ...(withYear ? { year: "2-digit" } : {}),
194
+ }).format(when));
195
+ }
196
+ /** The year a date key of `grain` falls in, or `null` if the key does not have its shape. */
197
+ export function dateKeyYear(key, grain) {
198
+ const parts = KEY_SHAPES[grain].exec(key);
199
+ return parts === null ? null : Number(parts[1]);
200
+ }
151
201
  /**
152
202
  * The NEXT key in the same grain: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
153
203
  * «2026-W52» → the ISO week that follows. `null` if the key does not have the shape of its grain —