@notis_ai/cli 0.2.30 → 0.2.31

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 (78) hide show
  1. package/README.md +1 -0
  2. package/dist/agent-hooks/notis-agent-hook.mjs +37890 -10794
  3. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  4. package/dist/base-skills/notis-cli/references/native-databases.md +1 -1
  5. package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
  6. package/dist/base-skills/notis-query/references/query.md +6 -4
  7. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  8. package/dist/base-skills/notis-spaces/SKILL.md +8 -3
  9. package/dist/base-skills/notis-spaces/references/architecture.md +4 -1
  10. package/dist/base-skills/notis-spaces/references/design.md +7 -1
  11. package/dist/base-skills/notis-spaces/references/fixtures.md +27 -2
  12. package/dist/base-skills/notis-spaces/references/sdk.md +90 -31
  13. package/dist/base-skills/notis-spaces/references/troubleshooting.md +3 -0
  14. package/dist/base-skills/notis-spaces/references/views.md +20 -0
  15. package/dist/sdk/src/hooks/useNativeDocuments.ts +50 -12
  16. package/dist/sdk/src/index.ts +1 -1
  17. package/dist/sdk/src/space.ts +3 -1
  18. package/dist/sdk/src/tailwind.ts +53 -3
  19. package/dist/sdk/src/ui/icons.tsx +1 -0
  20. package/dist/sdk/src/words/types.ts +28 -0
  21. package/dist/skill-sync/index.js +10 -90
  22. package/dist/skill-sync-worker.mjs +50 -93
  23. package/dist/space-harness/host.js +150 -81
  24. package/dist/space-sdk/dist/chunk-3DFOGU26.js +3 -0
  25. package/dist/space-sdk/dist/index.js +2 -2
  26. package/dist/space-sdk/dist/ui.js +12 -12
  27. package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +23 -0
  28. package/dist/space-sdk/src/index.d.ts +1 -1
  29. package/dist/space-sdk/src/space.ts +3 -1
  30. package/dist/space-sdk/src/tailwind-candidates.d.ts +273 -2
  31. package/dist/space-sdk/src/tailwind.ts +53 -3
  32. package/dist/space-sdk/src/ui/blocks/DataTable.d.ts +19 -4
  33. package/dist/space-sdk/src/ui/blocks/Meter.d.ts +12 -3
  34. package/dist/space-sdk/src/ui/blocks/Tabs.d.ts +7 -1
  35. package/dist/space-sdk/src/ui/blocks/index.d.ts +1 -1
  36. package/dist/space-sdk/src/ui/charts/CalendarHeatmap.d.ts +69 -0
  37. package/dist/space-sdk/src/ui/charts/Chart.d.ts +18 -3
  38. package/dist/space-sdk/src/ui/charts/chartData.d.ts +19 -0
  39. package/dist/space-sdk/src/ui/charts/heatmapData.d.ts +81 -0
  40. package/dist/space-sdk/src/ui/index.d.ts +4 -2
  41. package/dist/space-sdk/src/ui/list/Row.d.ts +11 -1
  42. package/dist/space-sdk/src/ui/period/dateFormat.d.ts +2 -0
  43. package/dist/space-sdk/src/ui/period/dateWords.d.ts +9 -0
  44. package/dist/space-sdk/src/ui/period/periods.d.ts +15 -2
  45. package/dist/space-sdk/src/words/types.ts +28 -0
  46. package/dist/view-renderer/dist/host.js +219 -150
  47. package/dist/view-renderer/src/dom.js +3 -2
  48. package/dist/view-renderer/src/errors.js +9 -0
  49. package/dist/view-renderer/src/host.tsx +12 -5
  50. package/dist/view-renderer/src/remote-broker.js +3 -1
  51. package/dist/view-renderer/src/renderer.js +63 -16
  52. package/dist/view-renderer/src/skeleton.js +70 -18
  53. package/package.json +5 -4
  54. package/skills/notis-query/cli.md +3 -0
  55. package/src/command-specs/spaces.js +71 -15
  56. package/src/command-specs/tools.js +3 -0
  57. package/src/runtime/api-hosts.generated.js +35 -0
  58. package/src/runtime/api-hosts.js +27 -10
  59. package/src/runtime/app-platform.js +68 -24
  60. package/src/runtime/http-agent.js +53 -0
  61. package/src/runtime/native-record-files.js +11 -0
  62. package/src/runtime/oauth.js +2 -1
  63. package/src/runtime/skill-sync/cloud-client.ts +0 -10
  64. package/src/runtime/skill-sync/index.ts +13 -15
  65. package/src/runtime/skill-sync/local-scanner.ts +0 -67
  66. package/src/runtime/skill-sync/types.ts +1 -0
  67. package/src/runtime/skill-sync/write-cloud-skill.ts +7 -23
  68. package/src/runtime/space-dependencies.js +66 -0
  69. package/src/runtime/space-fixture-broker.js +23 -8
  70. package/src/runtime/space-platform.js +47 -3
  71. package/src/runtime/space-source.js +10 -1
  72. package/src/runtime/space-test-server.js +105 -6
  73. package/src/runtime/space-verification.js +103 -43
  74. package/src/runtime/space-view-manifest.js +38 -5
  75. package/src/runtime/transport.js +19 -4
  76. package/src/runtime/view-render.js +4 -1
  77. package/template/tailwind.config.ts +2 -35
  78. package/dist/space-sdk/dist/chunk-6GJ2BS7B.js +0 -3
@@ -1,9 +1,41 @@
1
- /** Build-only SDK content discovery. Author configuration and PostCSS plugins stay intact. */
1
+ /**
2
+ * Build-only SDK content discovery and Notis theme colours. Author configuration and PostCSS plugins stay intact:
3
+ * a colour, theme value or opacity step the Space defines itself always wins over the defaults added here.
4
+ */
2
5
  import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
3
6
  import { tmpdir } from 'node:os';
4
7
  import { dirname, join, relative, resolve } from 'node:path';
5
8
  import { fileURLToPath } from 'node:url';
6
9
 
10
+ const tone = (name: string) => `hsl(var(--${name}))`;
11
+ const pair = (name: string) => ({ DEFAULT: tone(name), foreground: tone(`${name}-foreground`) });
12
+
13
+ /**
14
+ * The colours the Notis host sets on every Space page (light and dark), as Tailwind colours, so `bg-accent`,
15
+ * `text-chart-2` and opacity modifiers such as `bg-chart-2/40` or `bg-foreground/12` work in every Space.
16
+ */
17
+ export const NOTIS_THEME_COLORS = {
18
+ border: tone('border'), input: tone('input'), ring: tone('ring'),
19
+ background: tone('background'), foreground: tone('foreground'),
20
+ primary: pair('primary'), secondary: pair('secondary'), destructive: pair('destructive'), muted: pair('muted'),
21
+ accent: pair('accent'), popover: pair('popover'), card: pair('card'),
22
+ chart: { 1: tone('chart-1'), 2: tone('chart-2'), 3: tone('chart-3'), 4: tone('chart-4'), 5: tone('chart-5') },
23
+ } as const;
24
+
25
+ /** Tailwind 4 theme block: `default` keeps every colour a Space sets in its own `@theme` or `@config` first. */
26
+ const THEME_MARK = '/* notis-theme-colors */';
27
+ const themeBlock = () => {
28
+ const lines: string[] = [];
29
+ for (const [name, value] of Object.entries(NOTIS_THEME_COLORS)) {
30
+ if (typeof value === 'string') { lines.push(` --color-${name}: ${value};`); continue; }
31
+ for (const [key, shade] of Object.entries(value)) lines.push(` --color-${name}${key === 'DEFAULT' ? '' : `-${key}`}: ${shade};`);
32
+ }
33
+ return `${THEME_MARK}\n@theme default inline {\n${lines.join('\n')}\n}`;
34
+ };
35
+
36
+ /** Tailwind 3 only knows the opacity steps of its scale (5, 10, 15...): every whole percent works, as in Tailwind 4. */
37
+ const OPACITY_STEPS = Object.fromEntries(Array.from({ length: 101 }, (_, step) => [String(step), String(step / 100)]));
38
+
7
39
  export function notisTailwindContent() {
8
40
  let root = process.cwd();
9
41
  let temporary: string | undefined;
@@ -26,7 +58,8 @@ export function notisTailwindContent() {
26
58
  const sdkSource = dirname(fileURLToPath(import.meta.url));
27
59
  const relativeSource = './' + relative(dirname(stylesheet), sdkSource).replaceAll('\\', '/');
28
60
  const directive = `@source ${JSON.stringify(relativeSource)};`;
29
- return source.includes(directive) ? null : { code: `${source}\n${directive}\n`, map: null };
61
+ const added = [source.includes(directive) ? '' : `${directive}\n`, source.includes(THEME_MARK) ? '' : `${themeBlock()}\n`].join('');
62
+ return added ? { code: `${source}\n${added}`, map: null } : null;
30
63
  }
31
64
  if (!/@tailwind\s/.test(source)) return null;
32
65
  const explicit = source.match(/@config\s+(['"])(.*?)\1\s*;/);
@@ -41,11 +74,28 @@ export function notisTailwindContent() {
41
74
  const sdkGlob = join(dirname(fileURLToPath(import.meta.url)), '**/*.{ts,tsx}').replaceAll('\\', '/');
42
75
  writeFileSync(wrapper, `import config from ${JSON.stringify(config)};
43
76
  import { resolve } from 'node:path';
77
+ const defaults = ${JSON.stringify({ colors: NOTIS_THEME_COLORS, opacity: OPACITY_STEPS })};
78
+ const theme = config.theme || {};
79
+ const extend = theme.extend || {};
80
+ const presets = (config.presets || []).filter(preset => preset && typeof preset === 'object').map(preset => preset.theme || {});
81
+ // The Space's own colours and opacity steps win: a default fills only what the Space (or its presets) leaves unset,
82
+ // one level deep, so a Space's own card keeps the Notis card-foreground. A scale the Space replaces stays as it is.
83
+ const fill = (key) => {
84
+ if (typeof theme[key] === 'function' || (key === 'opacity' && theme.opacity)) return extend[key];
85
+ const own = [...presets.flatMap(t => [t[key], (t.extend || {})[key]]), theme[key], extend[key]].filter(v => v && typeof v === 'object');
86
+ const added = {};
87
+ for (const [name, value] of Object.entries(defaults[key])) {
88
+ const set = own.map(o => o[name]).filter(v => v !== undefined);
89
+ if (!set.length) added[name] = value;
90
+ else if (typeof value === 'object' && set.every(v => v && typeof v === 'object')) added[name] = Object.assign({}, value, ...set);
91
+ }
92
+ return typeof extend[key] === 'function' ? (utils) => ({ ...added, ...extend[key](utils) }) : { ...extend[key], ...added };
93
+ };
44
94
  const content = config.content || [];
45
95
  const files = Array.isArray(content) ? content : (content.files || []);
46
96
  const base = ${JSON.stringify(root)};
47
97
  const relativeBase = ${JSON.stringify(dirname(config))};
48
- export default { ...config, content: {
98
+ export default { ...config, theme: { ...theme, extend: { ...extend, colors: fill('colors'), opacity: fill('opacity') } }, content: {
49
99
  ...(Array.isArray(content) ? {} : content),
50
100
  relative: false,
51
101
  files: [...files.map(file => typeof file !== 'string' ? file :
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * DataTable: a read-only table for a dashboard `Section kind="data"` (machines, threads, jobs), styled like the
3
- * ChartTable: 40px rows with a hairline above each, a sticky 36px muted header, the edge cells 24px in. Cells never
4
- * wrap: they truncate. One primary column takes the room left, never under its `minWidth` (default 120 px); the others
3
+ * ChartTable: 40px rows with a hairline above each, a sticky 36px muted header, the edge cells 24px in. Cells
4
+ * truncate, unless a column wraps (`wrap`) or the headers do (`wrapHeaders`). One primary column takes the room left, never under its `minWidth` (default 120 px); the others
5
5
  * fit their content or a fixed width, and a column can hide under a container width so a phone never scrolls
6
6
  * sideways. When the columns kept still do not fit, the last ones hide on their own, so the primary text is never
7
7
  * crushed. A real table, so view Markdown reads it.
@@ -14,7 +14,7 @@ export interface DataTableColumn<R> {
14
14
  id: string;
15
15
  /** The header text. */
16
16
  label: Text;
17
- /** The cell of one row. Text truncates with an ellipsis; it never wraps. */
17
+ /** The cell of one row. Text truncates with an ellipsis, unless the column wraps. */
18
18
  cell: (row: R) => ReactNode;
19
19
  /** Default 'start'. Use 'end' for numbers. */
20
20
  align?: 'start' | 'end';
@@ -32,6 +32,11 @@ export interface DataTableColumn<R> {
32
32
  hideBelow?: number;
33
33
  /** On the primary column: the narrowest it gets, in px (padding excluded). Default 120. */
34
34
  minWidth?: number;
35
+ /**
36
+ * The column's cells and header wrap onto more lines instead of truncating (a note, a question), and their rows grow
37
+ * to fit. For long text the reader needs whole; keep figures, dates and ids on one line.
38
+ */
39
+ wrap?: boolean;
35
40
  }
36
41
  export interface DataTableGroup<R> {
37
42
  key: string;
@@ -47,12 +52,22 @@ export interface DataTableProps<R> {
47
52
  rowKey: (row: R) => string;
48
53
  /** Makes rows pressable: a button in the primary cell covers the row and takes Tab focus. */
49
54
  onRowPress?: (row: R) => void;
55
+ /**
56
+ * With `onRowPress`: whether this row opens anything. A row it returns false for is plain (no hover, no button, no
57
+ * press), so a row with nowhere to go never looks clickable. Default every row.
58
+ */
59
+ canPressRow?: (row: R) => boolean;
50
60
  /** The accessible name of a row's press target. Default the primary cell's text. */
51
61
  rowLabel?: (row: R) => string;
52
62
  /** The table's accessible name (the Section title, usually). */
53
63
  label?: Text;
54
64
  /** Shown in place of the rows when there are none. Default an EmptyState. */
55
65
  empty?: ReactNode;
66
+ /**
67
+ * Header labels wrap onto a second line instead of truncating (longer French headers over narrow figure columns).
68
+ * Default false: one line, with an ellipsis.
69
+ */
70
+ wrapHeaders?: boolean;
56
71
  className?: string;
57
72
  }
58
73
  /** Columns hidden because they did not fit, with the first and last columns still shown (they take the edge insets). */
@@ -79,7 +94,7 @@ export declare function dataTableHideCss(tableId: string, limits: readonly (numb
79
94
  * A read-only table: 40px rows, a sticky 36px header, cells that truncate, optional group headings with their
80
95
  * counts and pressable rows. Columns with `hideBelow` hide under that container width.
81
96
  */
82
- export declare function DataTable<R>({ columns, rows, groups, rowKey, onRowPress, rowLabel, label, empty, className }: DataTableProps<R>): React.JSX.Element;
97
+ export declare function DataTable<R>({ columns, rows, groups, rowKey, onRowPress, canPressRow, rowLabel, label, empty, wrapHeaders, className }: DataTableProps<R>): React.JSX.Element;
83
98
  export declare namespace DataTable {
84
99
  var displayName: string;
85
100
  }
@@ -1,11 +1,14 @@
1
1
  /**
2
2
  * Meter: how full something is (memory, disk, seats, a quota), as a label and its figure over a thin track. Flat:
3
- * no border, no coloured text. The fill is neutral until it reaches the optional limit, then the whole fill turns
4
- * destructive (state as a full fill, never by text colour).
3
+ * no border, no coloured text. The fill is neutral (or the `tone` given) until it reaches the optional limit, then the
4
+ * whole fill turns destructive (state as a full fill, never by text colour).
5
5
  */
6
6
  import type { ReactNode } from 'react';
7
7
  import { type Words } from '../../words/types';
8
+ import type { Tone } from '../list/Row';
8
9
  type Text = Words | string;
10
+ /** The fill colour of a Meter: neutral grey by default, or one of the toolkit's tones (the same tones Badge and Row labels take). */
11
+ export type MeterTone = Tone;
9
12
  export interface MeterProps {
10
13
  /** What is measured ("Memory"); also the meter's accessible name. */
11
14
  label: Text;
@@ -26,13 +29,19 @@ export interface MeterProps {
26
29
  limitLabel?: Text;
27
30
  /** A muted line under the track on the left ("4 apps running"). */
28
31
  hint?: Text;
32
+ /**
33
+ * The fill's colour, from the toolkit tones (the Badge ones): `success` for a goal met, `warning` for a goal near,
34
+ * `info` for one category among several. Default 'default', the neutral grey. A reached `limit` still turns it
35
+ * destructive.
36
+ */
37
+ tone?: MeterTone;
29
38
  className?: string;
30
39
  }
31
40
  /**
32
41
  * A label and its figure ("Memory 8.2 / 36") over a 6px rounded track with a neutral fill. With `limit`, a tick
33
42
  * marks it and the fill turns destructive once the value reaches it (`data-over`). role="meter", named by the label.
34
43
  */
35
- export declare function Meter({ label, value, max, valueText, limit, limitLabel, hint, className }: MeterProps): import("react").JSX.Element;
44
+ export declare function Meter({ label, value, max, valueText, limit, limitLabel, hint, tone, className }: MeterProps): import("react").JSX.Element;
36
45
  export declare namespace Meter {
37
46
  var displayName: string;
38
47
  }
@@ -78,6 +78,12 @@ export interface TabsProps<V extends string> {
78
78
  children?: ReactNode;
79
79
  /** Stable prefix for tab and panel ids. Default a generated one. */
80
80
  id?: string;
81
+ /**
82
+ * The tabs that do not fit wrap onto a next line instead of scrolling sideways (a phone page with five or six
83
+ * sections, every tab in sight). Default false: one line that scrolls. For a row over a list, TabRow folds the rest
84
+ * into a More menu instead.
85
+ */
86
+ wrap?: boolean;
81
87
  className?: string;
82
88
  panelClassName?: string;
83
89
  }
@@ -128,7 +134,7 @@ export declare function tabPanelProps(prefix: string, value: string): {
128
134
  /** The next enabled tab from `from` in `direction`, wrapping round. Null when no other tab is enabled. */
129
135
  export declare function stepTab<V extends string>(tabs: readonly TabItem<V>[], from: V, direction: 1 | -1): V | null;
130
136
  /** A strip of view pills whose choice switches the content below it, with its panel when `children` is given. */
131
- export declare function Tabs<V extends string>({ tabs, value, onChange, label, keys, activation, children, id, className, panelClassName, }: TabsProps<V>): import("react").JSX.Element;
137
+ export declare function Tabs<V extends string>({ tabs, value, onChange, label, keys, activation, children, id, wrap, className, panelClassName, }: TabsProps<V>): import("react").JSX.Element;
132
138
  /**
133
139
  * The 44px row of pills over a list or a page (TLB1, TLB2). Role 'tabs' switches the content below (tablist), role
134
140
  * 'filter' narrows one list (radiogroup); one look for both. It never wraps or scrolls: the pills its row has no room
@@ -3,7 +3,7 @@ export type { BadgeProps, ButtonProps, ButtonSize, ButtonVariant, EmptyStateProp
3
3
  export { TABROW_WORDS, TABS_WORDS, TabRow, Tabs, stepTab, tabIds, tabPanelProps } from './Tabs';
4
4
  export type { TabItem, TabRowItem, TabRowProps, TabsProps } from './Tabs';
5
5
  export { Meter } from './Meter';
6
- export type { MeterProps } from './Meter';
6
+ export type { MeterProps, MeterTone } from './Meter';
7
7
  export { DataTable } from './DataTable';
8
8
  export type { DataTableColumn, DataTableGroup, DataTableProps } from './DataTable';
9
9
  export { INFOTIP_WORDS, InfoTip } from './InfoTip';
@@ -0,0 +1,69 @@
1
+ /**
2
+ * CalendarHeatmap: one small cell per day, coloured by its value, weeks as columns and the seven weekdays as rows,
3
+ * month names on top and Mon, Wed, Fri on the left (a GitHub-style contribution grid). It fits its container: cells
4
+ * shrink to 10px, then the grid scrolls sideways inside itself with the latest week in view.
5
+ *
6
+ * A grid (role="grid"): the arrows move a day (up and down) or a week (left and right), Home and End go to the first
7
+ * and last day, and each cell says its value and day ("3 on Mon, Jun 15", with the year for a day of another year
8
+ * than today's), the same words as its tooltip. With `onSelect` the cells are buttons. The days with data also go to a hidden
9
+ * data table (RenderChartData) for view Markdown.
10
+ */
11
+ import * as React from 'react';
12
+ import { type Locale, type Words } from '../../words/types';
13
+ import type { Tone } from '../list/Row';
14
+ import { type HeatmapDay } from './heatmapData';
15
+ /** The day a cell stands for, given to `onSelect`. */
16
+ export type CalendarHeatmapDay = HeatmapDay;
17
+ export interface CalendarHeatmapProps {
18
+ /** One row per dated value (or per entry with `valueKey={null}`). Rows on the same day add up. */
19
+ data: readonly object[];
20
+ /** Field with the row's day: a Date, an ISO day ("2026-06-15"), an ISO time or a timestamp. Default `date`. */
21
+ dateKey?: string;
22
+ /** Field with the row's number. Default `value`. Null counts the rows instead (each dated row is 1). */
23
+ valueKey?: string | null;
24
+ /** First day drawn. Default the first of the month eleven months before `to` (the "Last 12 months" period). */
25
+ from?: Date | string | number;
26
+ /** Last day drawn. Default today. Days after it are not drawn. */
27
+ to?: Date | string | number;
28
+ /** A fixed clock for "today". */
29
+ today?: Date;
30
+ /**
31
+ * The colour of a sequential scale: the first chart colour by default, or a toolkit tone (`success` for a goal kept,
32
+ * `warning`, `danger`, `info`). Ignored by a diverging scale.
33
+ */
34
+ tone?: Tone;
35
+ /**
36
+ * `sequential` (default): from no colour to full colour as values grow. `diverging`: good to bad data around a
37
+ * `midpoint` (a mood, a balance), success colours above it and danger colours below (swapped with
38
+ * `higherIsBetter={false}`).
39
+ */
40
+ scale?: 'sequential' | 'diverging';
41
+ /** The diverging scale's neutral value. Default the middle of `domain`, else 0. */
42
+ midpoint?: number;
43
+ /** Diverging only: false when lower is better (above the midpoint draws in danger colours). Default true. */
44
+ higherIsBetter?: boolean;
45
+ /**
46
+ * A fixed value scale `[min, max]` (a mood from 1 to 5) instead of one that fits the data. With it every value takes
47
+ * a colour, the minimum included; without it a value at or below zero draws empty.
48
+ */
49
+ domain?: readonly [number, number];
50
+ /** Colour steps, the empty one included. Default 5 (2 to 9). */
51
+ levels?: number;
52
+ /** The value in the cell names, tooltips and data table. Default whole numbers (one decimal under 10). */
53
+ format?: (value: number, locale: Locale) => string;
54
+ /** Makes the cells buttons: a press, Enter or Space gives that day. */
55
+ onSelect?: (day: CalendarHeatmapDay) => void;
56
+ /** Accessible name of the grid and title of its data table. Default "Activity by day". */
57
+ title?: Words | string;
58
+ /** The Less ... More colour key under the grid. Default true. */
59
+ legend?: boolean;
60
+ /** The first day of a week column, 0 Sunday to 6 Saturday. Default 1, Monday. */
61
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
62
+ locale?: Locale;
63
+ className?: string;
64
+ }
65
+ /** A GitHub-style grid of days coloured by value, with a tooltip and a spoken name per day and a hidden data table. */
66
+ export declare function CalendarHeatmap({ data, dateKey: dateField, valueKey, from, to, today: todayProp, tone, scale: scaleKind, midpoint, higherIsBetter, domain, levels, format: formatProp, onSelect, title, legend, weekStartsOn, locale: localeProp, className, }: CalendarHeatmapProps): React.JSX.Element;
67
+ export declare namespace CalendarHeatmap {
68
+ var displayName: string;
69
+ }
@@ -143,7 +143,10 @@ export interface ChartSeries {
143
143
  /** Field of each row holding the value. */
144
144
  key: string;
145
145
  label: Words | string;
146
- /** Any CSS colour. Default the chart tokens in order (`--chart-1`, `--chart-2`...). */
146
+ /**
147
+ * Any CSS colour. Default the chart tokens in order (`--chart-1` to `--chart-5`, then again), so a sixth series
148
+ * needs its own colour here, such as `hsl(var(--chart-1) / .5)`.
149
+ */
147
150
  color?: string;
148
151
  }
149
152
  export interface ChartProps {
@@ -187,7 +190,8 @@ export interface ChartProps {
187
190
  labelFormat?: (value: number, locale: Locale) => string;
188
191
  /**
189
192
  * A fixed value scale `[min, max]`, such as `[0, 100]` for percentages, instead of one that fits the data. Values
190
- * outside it are clipped. Vertical charts only.
193
+ * outside it are clipped. Vertical charts only. Without it, a vertical chart with values under zero reaches below
194
+ * zero too (diverging bars: a balance, a net change), with a line at zero.
191
195
  */
192
196
  domain?: readonly [number, number];
193
197
  /**
@@ -200,6 +204,17 @@ export interface ChartProps {
200
204
  * hovered (deck period-r6). Default: true when the last row's `to` is today.
201
205
  */
202
206
  live?: boolean;
207
+ /**
208
+ * One series of bars: the bars that are not the live one or the hovered one draw lighter (default true). False
209
+ * draws every bar full colour, for bars that each stand alone (months of a budget, stages of a funnel).
210
+ */
211
+ dim?: boolean;
212
+ /**
213
+ * The colour of one bar, for bars of a series that differ by what their row is (a stage, a category, over or under a
214
+ * budget): any CSS colour, or undefined for the series colour. Called with the row, the series and the row's index.
215
+ * The legend keeps the series colours, so say what the colours mean in the section or the axis labels.
216
+ */
217
+ barColor?: (row: object, series: ChartSeries, index: number) => string | undefined;
203
218
  locale?: Locale;
204
219
  className?: string;
205
220
  }
@@ -208,7 +223,7 @@ export declare function seriesColor(series: ChartSeries, index: number): string;
208
223
  /** The hidden table of a chart: one row per point, the point name then each series value. */
209
224
  export declare function chartTableRows(data: readonly object[], series: readonly ChartSeries[], compare: ChartSeries | null, nameOf: (row: object) => string, format: (value: number) => string): Array<Array<string | null>>;
210
225
  /** A period chart (bars, a line or an area) with an optional dashed comparison; 140px bars or a 200px plot by default. */
211
- export declare function Chart({ kind, data, series: seriesProp, compare: compareProp, xKey: xKeyProp, labelKey, nameKey: nameKeyProp, title, height: heightProp, stacked, horizontal: horizontalProp, format: formatProp, labelFormat: labelFormatProp, domain: domainProp, valueAxis: valueAxisProp, live: liveProp, locale: localeProp, className, }: ChartProps): React.JSX.Element;
226
+ export declare function Chart({ kind, data, series: seriesProp, compare: compareProp, xKey: xKeyProp, labelKey, nameKey: nameKeyProp, title, height: heightProp, stacked, horizontal: horizontalProp, format: formatProp, labelFormat: labelFormatProp, domain: domainProp, valueAxis: valueAxisProp, live: liveProp, dim, barColor, locale: localeProp, className, }: ChartProps): React.JSX.Element;
212
227
  export declare namespace Chart {
213
228
  var displayName: string;
214
229
  }
@@ -28,6 +28,11 @@ export interface PeriodChartRow {
28
28
  value: number;
29
29
  compare: number | null;
30
30
  }
31
+ /**
32
+ * The bin of a range: hours for a day, days up to a month, weeks up to about six months, then months. A range
33
+ * that starts on the 1st and spans six calendar months or more (last 6 months, a year to date from June) is
34
+ * binned by month, so each bar is a whole month (and Compare previous moves back by whole months).
35
+ */
31
36
  export declare function binUnit(range: DateRange): BinUnit;
32
37
  /** The bins of a range. Weeks step seven days from the first day; the last week and month stop at the range end. */
33
38
  export declare function buildBins(range: DateRange, unit?: BinUnit): Bin[];
@@ -70,6 +75,10 @@ export declare function showAxisLabel(index: number, count: number, spacing?: nu
70
75
  export declare function edgeAnchor(x: number, left: number, right: number): 'start' | 'middle' | 'end';
71
76
  /** Top of the value axis: 10% above the highest value (this period or the comparison), never below 1. */
72
77
  export declare function chartMax(values: ReadonlyArray<number | null | undefined>): number;
78
+ /**
79
+ * Bottom of the value axis: 0 when no value is under zero, else 10% under the lowest one (diverging bars, a balance).
80
+ */
81
+ export declare function chartMin(values: ReadonlyArray<number | null | undefined>): number;
73
82
  /**
74
83
  * The top of a value axis drawn in quarters, raised from `max` so every quarter is a round number (110 gives 120:
75
84
  * 30, 60, 90, 120), never 27.5. With `integers` (counts) each quarter is a whole number too: 1.1 gives 4, never 1.2.
@@ -88,3 +97,13 @@ export declare function sparkPaths(values: readonly (number | null | undefined)[
88
97
  line: string;
89
98
  area: string;
90
99
  };
100
+ /**
101
+ * The scale of values on both sides of zero: one round step for both sides, so zero sits on a gridline and the
102
+ * labels stay evenly spaced however lopsided the values are (-3 and 1000 give -250 to 1000 in steps of 250).
103
+ * `min` is under zero; `max` at or under zero ends the scale at zero. At most six steps: the step doubles past that.
104
+ */
105
+ export declare function divergingScale(min: number, max: number, integers?: boolean): {
106
+ low: number;
107
+ high: number;
108
+ ticks: number[];
109
+ };
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Calendar heatmap math (CalendarHeatmap): the days of a range bucketed into week columns, the values summed per day,
3
+ * and each value's colour level. Pure: date-fns and Intl only, no React. Days are keyed by their local ISO day
4
+ * (`2026-06-15`), built with calendar arithmetic, so a daylight saving change never skips or repeats a day.
5
+ */
6
+ import type { Locale } from '../../words/types';
7
+ import { type DateInput } from '../calendar/calendarMath';
8
+ /** One day of the heatmap: its value (the sum of its rows), or null when no row falls on it. */
9
+ export interface HeatmapDay {
10
+ date: Date;
11
+ /** The local ISO day, `2026-06-15`. */
12
+ key: string;
13
+ value: number | null;
14
+ /** The data rows of that day, in data order. */
15
+ rows: readonly object[];
16
+ }
17
+ /** One week column: seven slots from the week's first day; a slot outside the range is null (not drawn). */
18
+ export interface HeatmapWeek {
19
+ start: Date;
20
+ days: readonly (HeatmapDay | null)[];
21
+ }
22
+ export interface HeatmapRange {
23
+ from: Date;
24
+ to: Date;
25
+ }
26
+ /**
27
+ * The days a heatmap covers: `to` defaults to today, `from` to the first of the month eleven months before `to` (the
28
+ * toolkit's "Last 12 months"). Swapped when given backwards.
29
+ */
30
+ export declare function heatmapRange(from: DateInput, to: DateInput, today: Date): HeatmapRange;
31
+ /**
32
+ * Sums the rows per local day. A row counts when its `dateKey` field is a day (a Date, an ISO day or time, a
33
+ * timestamp) and its `valueKey` field a finite number (or a string reading as one); with `valueKey` null every dated row counts 1, so a list of
34
+ * entries gives how many fell on each day.
35
+ */
36
+ export declare function bucketDays(data: readonly object[], dateKey: string, valueKey: string | null): Map<string, {
37
+ value: number;
38
+ rows: object[];
39
+ }>;
40
+ /**
41
+ * The week columns of a range: each starts on `weekStartsOn` (0 Sunday to 6 Saturday; Monday by default) and holds
42
+ * seven slots. Days before `from` and after `to` are null.
43
+ */
44
+ export declare function heatmapWeeks(range: HeatmapRange, byDay: ReadonlyMap<string, {
45
+ value: number;
46
+ rows: readonly object[];
47
+ }>, weekStartsOn?: number): HeatmapWeek[];
48
+ export type HeatmapScaleKind = 'sequential' | 'diverging';
49
+ export interface HeatmapScale {
50
+ kind: HeatmapScaleKind;
51
+ /** Colour steps, the empty one included (2 to 9). */
52
+ levels: number;
53
+ lo: number;
54
+ hi: number;
55
+ mid: number;
56
+ /** A `domain` was given: every value is placed on it, zero and below included. */
57
+ fixed: boolean;
58
+ }
59
+ export interface HeatmapScaleOptions {
60
+ kind?: HeatmapScaleKind;
61
+ levels?: number;
62
+ domain?: readonly [number, number];
63
+ midpoint?: number;
64
+ }
65
+ /** The scale of a set of values: by default from 0 to the largest value (sequential) or around 0 (diverging). */
66
+ export declare function heatmapScale(values: readonly number[], options?: HeatmapScaleOptions): HeatmapScale;
67
+ /**
68
+ * The colour level of a value. Sequential: 0 (the empty colour) to `levels - 1`; a value at or below zero is 0 unless a
69
+ * domain is fixed, the largest value is the top level, and equal values all take it. Diverging: from `-(levels - 1)`
70
+ * (furthest below the midpoint) to `levels - 1` (furthest above), 0 at the midpoint. No value (null) is 0.
71
+ */
72
+ export declare function heatmapLevel(value: number | null, scale: HeatmapScale): number;
73
+ /** The fill opacity of a level: a quarter for the first step up to full for the top one. */
74
+ export declare function heatmapAlpha(level: number, levels: number): number;
75
+ /** The month labels over the columns: a label where the first drawn day of a column starts a new month. */
76
+ export declare function heatmapMonths(weeks: readonly HeatmapWeek[]): Array<{
77
+ column: number;
78
+ month: Date;
79
+ }>;
80
+ /** A day as a cell names it: "Mon, Jun 15" / "lun. 15 juin" (French writes the first "1er"), with the year when asked. */
81
+ export declare function heatmapDayLabel(date: Date, locale: Locale, withYear?: boolean): string;
@@ -20,11 +20,11 @@ export * from './gallery';
20
20
  export { Icon, hasIcon, renderIcon } from './icons';
21
21
  export { adoptToolkitStyles, getToolkitStyleSheet, getToolkitStyleText, registerToolkitStyles, toolkitCascadeFor, TOOLKIT_CASCADE_LAYER } from './styles';
22
22
  export type { AdoptToolkitOptions, ToolkitCascade } from './styles';
23
- export { COMPARES, DEFAULT_COMPARE, DEFAULT_PRESET, PRESETS, compareRange, customPeriod, dayCount, formatPeriodParam, fromIsoDay, isCompareId, isPresetId, normalizePeriod, parsePeriodParam, periodRanges, presetRange, samePeriod, toIsoDay, } from './period/periods';
23
+ export { COMPARES, DEFAULT_COMPARE, DEFAULT_PRESET, EXTRA_PRESETS, PRESETS, compareRange, customPeriod, dayCount, formatPeriodParam, fromIsoDay, isCompareId, isPresetId, normalizePeriod, parsePeriodParam, periodRanges, presetRange, samePeriod, toIsoDay, } from './period/periods';
24
24
  export type { CompareId, DateRange as PeriodRange, Period, PresetId } from './period/periods';
25
25
  export { dayNumberLabel, formatDateRange, formatDayHeading, formatDelta, formatDuration, formatLongDay, formatMonthYear, formatNumber, formatShortDay, formatValue, intlLocale, weekdayNames, } from './period/dateFormat';
26
26
  export type { Delta, DeltaTone, FormatDurationOptions } from './period/dateFormat';
27
- export { CALENDAR_WORDS, CHART_WORDS, COMPARE_WORDS, PERIOD_WORDS, PRESET_WORDS, TIMELINE_WORDS, VS_WORDS, } from './period/dateWords';
27
+ export { CALENDAR_WORDS, CHART_WORDS, COMPARE_WORDS, HEATMAP_WORDS, PERIOD_WORDS, PRESET_WORDS, TIMELINE_WORDS, VS_WORDS, } from './period/dateWords';
28
28
  export { usePeriod } from './period/usePeriod';
29
29
  export type { UsePeriodOptions, UsePeriodResult } from './period/usePeriod';
30
30
  export { PERIOD_PICKER_TWO_MONTHS_MIN, PeriodPicker } from './period/PeriodPicker';
@@ -47,6 +47,8 @@ export { StatRow, metricView } from './charts/StatRow';
47
47
  export type { StatMetric, StatRowProps } from './charts/StatRow';
48
48
  export { ChartTable, Sparkline } from './charts/ChartTable';
49
49
  export type { ChartTableProps, SparklineProps } from './charts/ChartTable';
50
+ export { CalendarHeatmap } from './charts/CalendarHeatmap';
51
+ export type { CalendarHeatmapDay, CalendarHeatmapProps } from './charts/CalendarHeatmap';
50
52
  export { RenderChartData } from './charts/RenderChartData';
51
53
  export type { RenderChartDataProps } from './charts/RenderChartData';
52
54
  export { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, ComposedChart, LabelList, Legend, Line, LineChart, Pie, PieChart, ReferenceDot, ReferenceLine, ResponsiveContainer, Scatter, XAxis, YAxis, } from './charts/Chart';
@@ -36,11 +36,21 @@ export interface RowProps {
36
36
  icon?: ReactNode | {
37
37
  status: string;
38
38
  };
39
+ /**
40
+ * The lead's size in px, for a lead that is a picture (a meal photo, a cover, a logo) rather than an icon. Default 20;
41
+ * an icon glyph draws at 80% of it. The row grows to fit a lead taller than its title and meta.
42
+ */
43
+ iconSize?: number;
39
44
  title: ReactNode;
40
45
  /** The start of the muted line under the title (12/16); `labels` follow it after a " · ". */
41
46
  meta?: ReactNode;
42
47
  /** One clamped line (13/18). */
43
48
  snippet?: ReactNode;
49
+ /**
50
+ * The labels keep their whole width and the meta start truncates first, for labels that say where the row stands
51
+ * (a stage, a plan). Default false: the labels give way first, then the meta start.
52
+ */
53
+ keepLabels?: boolean;
44
54
  /**
45
55
  * Words on the meta line, as text joined by ", ". A warning or danger label (Overdue, Failed) comes first as a small
46
56
  * tinted pill: state is never shown by text colour alone.
@@ -153,4 +163,4 @@ export declare function Check(): import("react").JSX.Element;
153
163
  /** The dash of a partly checked select-all. */
154
164
  export declare function Dash(): import("react").JSX.Element;
155
165
  /** One list row: lead icon, a title over a meta line, then the trail (trailing, time, avatar, More). */
156
- export declare function Row({ icon, title, meta, snippet, labels, tags, owner, time, dateOnly, now, trailing, more, state, wrap, className, onPress, pressLabel, }: RowProps): import("react").JSX.Element;
166
+ export declare function Row({ icon, iconSize, title, meta, snippet, keepLabels, labels, tags, owner, time, dateOnly, now, trailing, more, state, wrap, className, onPress, pressLabel, }: RowProps): import("react").JSX.Element;
@@ -10,6 +10,8 @@ export declare function intlLocale(locale: Locale): string;
10
10
  export declare function dateFormat(locale: Locale, options: Intl.DateTimeFormatOptions): Intl.DateTimeFormat;
11
11
  /** The text with its first letter upper case ("lundi" reads "Lundi"). */
12
12
  export declare function upFirst(text: string): string;
13
+ /** A date through `fmt`, French writing the first of the month "1er". */
14
+ export declare function formatDay(fmt: Intl.DateTimeFormat, date: Date, locale: Locale): string;
13
15
  /**
14
16
  * A date range in words, never a dash: "May 17 to Jun 15, 2026" / "17 mai au 15 juin 2026". A month or year both days
15
17
  * share shows once ("Oct 1 to 15, 2026" / "1er au 15 oct. 2026"). One day reads as that day.
@@ -32,6 +32,15 @@ export declare const CHART_WORDS: Readonly<{
32
32
  stats: Words;
33
33
  noValue: Words;
34
34
  }>;
35
+ /** The calendar heatmap (CalendarHeatmap): a day's cell, its legend and its default name. */
36
+ export declare const HEATMAP_WORDS: Readonly<{
37
+ title: Words;
38
+ /** A day's cell and its tooltip: the value (through `format`), then the day. */
39
+ day: Words;
40
+ noData: Words;
41
+ less: Words;
42
+ more: Words;
43
+ }>;
35
44
  export declare const CALENDAR_WORDS: Readonly<{
36
45
  month: Words;
37
46
  week: Words;
@@ -10,7 +10,7 @@
10
10
  * `2026-01-01..2026-01-31~none` custom range
11
11
  * The comparison is left out when it equals the default, so links stay short.
12
12
  */
13
- export type PresetId = 'today' | 'yesterday' | 'last7' | 'last30' | 'last90' | 'thisMonth' | 'lastMonth' | 'thisQuarter' | 'thisYear' | 'custom';
13
+ export type PresetId = 'today' | 'yesterday' | 'last7' | 'last30' | 'last90' | 'thisMonth' | 'lastMonth' | 'thisQuarter' | 'thisYear' | 'last6Months' | 'last12Months' | 'custom';
14
14
  export type CompareId = 'prev' | 'year' | 'none';
15
15
  export interface Period {
16
16
  preset: PresetId;
@@ -25,6 +25,12 @@ export interface DateRange {
25
25
  to: Date;
26
26
  }
27
27
  export declare const PRESETS: readonly PresetId[];
28
+ /**
29
+ * Presets a picker can offer that the default list leaves out: trailing windows of whole months (this month and the 5
30
+ * or 11 before it), for monthly figures such as spending. Pass them in `presets`, such as
31
+ * `[...PRESETS.slice(0, -1), ...EXTRA_PRESETS, 'custom']`.
32
+ */
33
+ export declare const EXTRA_PRESETS: readonly PresetId[];
28
34
  export declare const COMPARES: readonly CompareId[];
29
35
  export declare const DEFAULT_PRESET: PresetId;
30
36
  export declare const DEFAULT_COMPARE: CompareId;
@@ -44,9 +50,16 @@ export declare function presetRange(preset: PresetId, now?: Date, custom?: {
44
50
  from?: string;
45
51
  to?: string;
46
52
  }): DateRange;
53
+ /**
54
+ * The calendar months a range spans when it is binned by month: it starts on the 1st and spans six months or more
55
+ * (Last 6 months, Last 12 months, a year to date from June). 0 otherwise.
56
+ */
57
+ export declare function monthSpan(range: DateRange): number;
47
58
  /**
48
59
  * The range a period is compared with.
49
- * - prev: the same number of days just before (`[from - n, from - 1]`).
60
+ * - prev: the same number of days just before (`[from - n, from - 1]`). A range binned by month (`monthSpan`: it
61
+ * starts on the 1st and spans six calendar months or more, such as Last 6 months) moves back by that many months
62
+ * instead, so each month is compared with a whole month; a range ending on a month's last day ends on one too.
50
63
  * - year: the same calendar days one year back (29 February lands on 28 February).
51
64
  * - none: no comparison.
52
65
  */
@@ -48,6 +48,34 @@ export function fillWords(words: Words, vars: Readonly<Record<string, string | n
48
48
  return { en: interpolate(words.en, vars), fr: interpolate(words.fr, vars) };
49
49
  }
50
50
 
51
+ const PLURAL_INTL = new Map<Locale, { rules: Intl.PluralRules; number: Intl.NumberFormat }>();
52
+ function pluralIntl(locale: Locale) {
53
+ let intl = PLURAL_INTL.get(locale);
54
+ if (!intl) {
55
+ const tag = locale === 'fr' ? 'fr-FR' : 'en-US';
56
+ intl = { rules: new Intl.PluralRules(tag), number: new Intl.NumberFormat(tag) };
57
+ PLURAL_INTL.set(locale, intl);
58
+ }
59
+ return intl;
60
+ }
61
+
62
+ /**
63
+ * The words for a count, in the grammar of each language: English "1 campaign" / "2 campaigns", French "1 campagne" /
64
+ * "2 campagnes" (French also uses the singular for 0 and 1.5). `forms` holds the singular (`one`) and the plural
65
+ * (`other`) of each language; `{n}` in them is the count as written in that locale ("1,250" / "1 250").
66
+ * `pluralWords(3, { one: w('{n} campaign', '{n} campagne'), other: w('{n} campaigns', '{n} campagnes') })`.
67
+ */
68
+ export function pluralWords(count: number, forms: { one: Words; other: Words }): Words {
69
+ const form = (locale: Locale) => {
70
+ const intl = pluralIntl(locale);
71
+ const rule = Number.isFinite(count) ? intl.rules.select(count) : 'other';
72
+ const words = rule === 'one' ? forms.one : forms.other;
73
+ const n = Number.isFinite(count) ? intl.number.format(count) : String(count);
74
+ return interpolate(locale === 'fr' ? words.fr : words.en, { n });
75
+ };
76
+ return { en: form('en'), fr: form('fr') };
77
+ }
78
+
51
79
  /** Shorthand for a Words pair. */
52
80
  export function w(en: string, fr: string): Words {
53
81
  return { en, fr };