@asanchez-sa/abby 0.3.0 → 0.5.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 (51) hide show
  1. package/dist/components/badge/badge.d.ts +3 -2
  2. package/dist/components/badge/badge.js +27 -11
  3. package/dist/components/calendar/calendar.d.ts +26 -5
  4. package/dist/components/calendar/calendar.js +387 -72
  5. package/dist/components/chart/chart.d.ts +7 -0
  6. package/dist/components/chart/chart.js +7 -0
  7. package/dist/components/chart/parts/bar.d.ts +32 -0
  8. package/dist/components/chart/parts/bar.js +348 -0
  9. package/dist/components/chart/parts/categories.d.ts +32 -0
  10. package/dist/components/chart/parts/categories.js +212 -0
  11. package/dist/components/chart/parts/legend.d.ts +16 -0
  12. package/dist/components/chart/parts/legend.js +82 -0
  13. package/dist/components/chart/parts/line.d.ts +43 -0
  14. package/dist/components/chart/parts/line.js +266 -0
  15. package/dist/components/chart/parts/scale.js +96 -0
  16. package/dist/components/chart/parts/scatter.d.ts +67 -0
  17. package/dist/components/chart/parts/scatter.js +157 -0
  18. package/dist/components/chart/parts/surface.d.ts +26 -0
  19. package/dist/components/chart/parts/surface.js +76 -0
  20. package/dist/components/chart/parts/table.js +105 -0
  21. package/dist/components/chart/parts/types.d.ts +44 -0
  22. package/dist/components/chart/parts/types.js +12 -0
  23. package/dist/components/filter-chip/filter-chip.d.ts +36 -0
  24. package/dist/components/filter-chip/filter-chip.js +97 -0
  25. package/dist/components/graph/graph.d.ts +151 -0
  26. package/dist/components/graph/graph.js +959 -0
  27. package/dist/components/model-selector/model-selector.d.ts +38 -3
  28. package/dist/components/model-selector/model-selector.js +331 -73
  29. package/dist/components/number-input/number-input.d.ts +14 -3
  30. package/dist/components/number-input/number-input.js +193 -34
  31. package/dist/components/spinner/spinner.d.ts +7 -1
  32. package/dist/components/spinner/spinner.js +86 -26
  33. package/dist/components/toast/toast.d.ts +19 -2
  34. package/dist/components/toast/toast.js +211 -49
  35. package/dist/components/toggle/toggle.d.ts +18 -4
  36. package/dist/components/toggle/toggle.js +167 -32
  37. package/dist/components/week-strip/week-strip.d.ts +27 -5
  38. package/dist/components/week-strip/week-strip.js +288 -134
  39. package/dist/styles/components.css +66 -0
  40. package/package.json +5 -1
  41. package/skills/agent-ready-ui/SKILL.md +1 -1
  42. package/skills/blocks/SKILL.md +1 -1
  43. package/skills/compose-screens/SKILL.md +48 -5
  44. package/skills/compose-screens/references/calendar-week.md +77 -0
  45. package/skills/compose-screens/references/charts-and-maps.md +298 -0
  46. package/skills/compose-screens/references/filter-chips.md +61 -0
  47. package/skills/compose-screens/references/number-units.md +52 -0
  48. package/skills/note-editor/SKILL.md +1 -1
  49. package/skills/note-status/SKILL.md +1 -1
  50. package/skills/setup/SKILL.md +1 -1
  51. package/skills/theming/SKILL.md +1 -1
@@ -130,6 +130,72 @@
130
130
  }
131
131
  }
132
132
 
133
+ /*
134
+ * A TanStack chart in abby's look. The library paints with SVG attributes and
135
+ * reads its palette and tooltip from `--ts-chart-*`; these rules win over the
136
+ * attributes, so any chart definition takes the theme without passing one:
137
+ * the palette is `chart-1` … `chart-5`, the grid and the axes are hairlines,
138
+ * a tick's label is `subtle`, and the tooltip is abby's `Tooltip`.
139
+ */
140
+ @utility chart-surface {
141
+ --ts-chart-1: var(--chart-1);
142
+ --ts-chart-2: var(--chart-2);
143
+ --ts-chart-3: var(--chart-3);
144
+ --ts-chart-4: var(--chart-4);
145
+ --ts-chart-5: var(--chart-5);
146
+ --ts-chart-6: var(--muted-foreground);
147
+ --ts-chart-focus-fill: var(--accent);
148
+ --ts-chart-crosshair-marker-fill: var(--background);
149
+ --ts-chart-crosshair-label-halo: var(--background);
150
+ --ts-chart-tooltip-background: var(--foreground);
151
+ --ts-chart-tooltip-color: var(--background);
152
+ --ts-chart-tooltip-border: 0;
153
+ --ts-chart-tooltip-border-radius: var(--radius-md);
154
+ --ts-chart-tooltip-padding: --spacing(1.5) --spacing(3);
155
+ --ts-chart-tooltip-font: var(--font-weight-normal) var(--text-xs) / var(--text-xs--line-height)
156
+ var(--font-sans);
157
+ --ts-chart-tooltip-shadow: none;
158
+ --ts-chart-tooltip-max-width: --spacing(80);
159
+ --ts-chart-tooltip-active-row-background: transparent;
160
+ --ts-chart-tooltip-active-row-shadow: none;
161
+ --ts-chart-tooltip-active-row-font-weight: var(--font-weight-medium);
162
+
163
+ & .ts-chart {
164
+ @apply focus-ring rounded-xs;
165
+ font-family: inherit;
166
+ font-variant-numeric: tabular-nums;
167
+ }
168
+
169
+ & .ts-chart > [data-ts-key="background"] {
170
+ fill: transparent;
171
+ }
172
+
173
+ & .ts-chart__grid,
174
+ & .ts-chart__axes line {
175
+ stroke: var(--border);
176
+ stroke-opacity: 1;
177
+ }
178
+
179
+ & .ts-chart__axes text {
180
+ fill: var(--subtle);
181
+ fill-opacity: 1;
182
+ }
183
+
184
+ /* A tick a chart sets in medium (the current day or week) reads in `foreground`. */
185
+ & .ts-chart__axes text[font-weight="500"] {
186
+ fill: var(--foreground);
187
+ }
188
+
189
+ & .ts-chart-tooltip__title {
190
+ font-weight: var(--font-weight-medium) !important;
191
+ }
192
+
193
+ & .ts-chart__axes text:is([data-ts-key="x-label"], [data-ts-key="y-label"]) {
194
+ fill: var(--muted-foreground);
195
+ font-weight: var(--font-weight-medium);
196
+ }
197
+ }
198
+
133
199
  /* The surface of a popup that floats over the page: a popover, a menu, a list of options. */
134
200
  @utility popup-surface {
135
201
  @apply bg-popover text-popover-foreground shadow-md ring-1 ring-border outline-none;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asanchez-sa/abby",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Sistema de diseño para React sobre ui-sdk y Tailwind CSS.",
5
5
  "keywords": [
6
6
  "agents",
@@ -67,6 +67,7 @@
67
67
  "./card": "./dist/components/card/card.js",
68
68
  "./carousel": "./dist/components/carousel/carousel.js",
69
69
  "./chain-of-thought": "./dist/components/chain-of-thought/chain-of-thought.js",
70
+ "./chart": "./dist/components/chart/chart.js",
70
71
  "./chat": "./dist/components/chat/chat.js",
71
72
  "./checkbox": "./dist/components/checkbox/checkbox.js",
72
73
  "./checkpoint": "./dist/components/checkpoint/checkpoint.js",
@@ -87,6 +88,8 @@
87
88
  "./field": "./dist/components/field/field.js",
88
89
  "./file-input": "./dist/components/file-input/file-input.js",
89
90
  "./file-tree": "./dist/components/file-tree/file-tree.js",
91
+ "./filter-chip": "./dist/components/filter-chip/filter-chip.js",
92
+ "./graph": "./dist/components/graph/graph.js",
90
93
  "./hover-card": "./dist/components/hover-card/hover-card.js",
91
94
  "./icon": "./dist/components/icon/icon.js",
92
95
  "./image-cropper": "./dist/components/image-cropper/image-cropper.js",
@@ -174,6 +177,7 @@
174
177
  "@fontsource-variable/geist-mono": "^5.3.0",
175
178
  "@hugeicons/core-free-icons": "^4.4.0",
176
179
  "@hugeicons/react": "^1.1.10",
180
+ "@tanstack/charts": "1.5.0",
177
181
  "@tiptap/core": "3.32.2",
178
182
  "@tiptap/extension-list": "3.32.2",
179
183
  "@tiptap/extension-unique-id": "3.32.2",
@@ -11,7 +11,7 @@ metadata:
11
11
  risky steps and the app keeping its rules.
12
12
  type: core
13
13
  library: abby
14
- library_version: 0.3.0
14
+ library_version: 0.5.0
15
15
  requires:
16
16
  - compose-screens
17
17
  sources:
@@ -11,7 +11,7 @@ metadata:
11
11
  agent reads.
12
12
  type: lifecycle
13
13
  library: abby
14
- library_version: 0.3.0
14
+ library_version: 0.5.0
15
15
  sources:
16
16
  - src/blocks/notes/notes-block.tsx
17
17
  - src/blocks/notes/adapters.ts
@@ -3,15 +3,19 @@ name: compose-screens
3
3
  description: "Use when building screens, forms, dialogs, menus or lists from
4
4
  abby components: parts and their composition, button looks on trigger parts,
5
5
  Icon and Link, sizes, Field for labels and errors, items for lists, controlled
6
- state, popups without portals. Takes precedence over generic ui-sdk or shadcn
7
- examples."
6
+ state, popups without portals, bar charts of counts by day or week (stacked
7
+ into parts, with their legend and notes), line charts of a trend by week,
8
+ scatter charts of rows by two numbers, charts of your own from TanStack
9
+ Charts, maps of nodes joined by lines, rows of filter chips, a chip that opens
10
+ a menu to narrow a list, a unit inside a number field. Takes precedence over
11
+ generic ui-sdk or shadcn examples."
8
12
  metadata:
9
13
  purpose: Shows how abby's styled components compose into screens, where they
10
14
  differ from shadcn and from raw ui-sdk, and which choices keep them
11
15
  accessible and usable by agents.
12
16
  type: core
13
17
  library: abby
14
- library_version: 0.3.0
18
+ library_version: 0.5.0
15
19
  requires:
16
20
  - setup
17
21
  sources:
@@ -294,6 +298,20 @@ export function Toasts() {
294
298
  }
295
299
  ```
296
300
 
301
+ `ToastProgress` is a thin bar on a toast's bottom edge that empties over its `duration`, so an Undo shows how long it has left. Compose it inside `Toast`, in the function child that `ToastRegion` renders for each toast; it reads the toast's duration and type, takes no props and is `aria-hidden`. It draws nothing for `duration: Infinity` or a `loading` toast, and it pauses while the pointer or focus is in the region, while the page is hidden and while the window is inactive.
302
+
303
+ ```tsx
304
+ <ToastRegion toaster={toast}>
305
+ {() => (
306
+ <Toast>
307
+ <ToastTitle />
308
+ <ToastAction variant="outline" />
309
+ <ToastProgress />
310
+ </Toast>
311
+ )}
312
+ </ToastRegion>
313
+ ```
314
+
297
315
  ### Show a budget or seats with `Meter`'s parts
298
316
 
299
317
  Inside `MeterTrack`, `MeterThreshold` marks a value (an alert at 80%), `MeterForecast` fills where the value is heading behind `MeterIndicator`, and `MeterSegment`s replace the indicator with stacked parts (`variant` `default`, `muted`, `empty`). `MeterTrack variant="segmented"` draws one cell per unit, like one per seat. A meter's content is presentational, so name the segments in a `MeterLegend` inside the `Meter` and give the threshold or the forecast a `label`: the meter reads them after its value. Give the meter the sum of the segments as its `value`.
@@ -329,6 +347,32 @@ export function Seats() {
329
347
  }
330
348
  ```
331
349
 
350
+ ### Put a unit at the end of a number field: `NumberInputUnit`
351
+
352
+ `NumberInputUnit` from `abby/number-input` draws a unit such as "USD" inside the field's edge, in gray, after `NumberInputControl` inside `NumberInputGroup`; `format` only formats the number. Read [the number unit reference](references/number-units.md) when you build one.
353
+
354
+ ### Filter with a row of chips: `Toggle` `variant="chip"`
355
+
356
+ For one choice in a row of filters, wrap `Toggle variant="chip" size="sm"` in a `ToggleGroup` with `deselectable={false}`, so one chip is always chosen. The chosen chip is white with a hairline edge and a heavier label; the others are gray with no fill. `ToggleCount` from `abby/toggle` puts a count after the name, in `subtle`. It is `aria-hidden` and becomes the chip's description, so the chip's name stays its own. The default `Toggle` fills its pressed state with ink: use it for on/off options, not for a filter row.
357
+
358
+ Read [the filter chip reference](references/filter-chips.md) for an example row.
359
+
360
+ ### Narrow a list with a `FilterChip` menu, not a `Select`
361
+
362
+ `FilterChip` from `abby/filter-chip` is a capsule that opens a menu of one choice to narrow a list on the same screen; a `Select` is for a form field whose value is saved. Its `items` are read as `Select`'s are, and `allValue` is the value that means no filter: the chip is active while the value is any other. Read [the filter chip reference](references/filter-chips.md) when you build one: its example, its active mark, `onClear` and refusing a choice.
363
+
364
+ ### Pick a whole week on a calendar: `Calendar` `mode="week"`
365
+
366
+ `Calendar` from `abby/calendar` with `mode="week"` picks a week in one press, and its value is always `[start, end]`: seven days from the calendar's first day of the week. `marks(date)` draws a dot or a check under each day, as `WeekStrip` does. Read [the calendar reference](references/calendar-week.md) when you build one: its value rules, its marks, and a week picker in a `Popover`.
367
+
368
+ ### Draw memories as a map with `Graph`
369
+
370
+ `Graph` from `abby/graph` places memories as nodes joined by labeled lines. The app gives each node its position, and the map never lays out, drags or pans. Read [the charts and maps reference](references/charts-and-maps.md) when you build one: its `nodes`, `edges`, selection, zoom and keyboard, with an example.
371
+
372
+ ### Show counts or trends by day or week with `BarChart` and `LineChart`
373
+
374
+ `BarChart` from `abby/chart` draws one column of bars per category, with a tooltip for each value and a table for screen readers. `LineChart` from the same entry draws one trend line over the categories, with reference lines and small charts that share a scale. Read [the charts and maps reference](references/charts-and-maps.md) when you build one: its `data`, `series`, `highlight`, forecast and colors, and its `LineChart` section for `mark`, `domain` and `size="sm"`. For bars made of parts that add up to a total (`stacked`, with `totals`, a `note` and `ChartLegend`), read its stacked section. `ScatterChart` plots the app's own rows by two numbers, sized and colored by two more, and `Chart` draws a TanStack Charts definition of your own in abby's look: each has its section there.
375
+
332
376
  ### Build a window with a rail and a column
333
377
 
334
378
  An app's shell with two levels, Alma's, is shadcn's nested sidebars: one `Sidebar variant="inset" collapsible="icon"` holds a `SidebarTitlebar` and, in a row under it, a rail and a column as panels with `collapsible="none"`. The provider's width is both. Collapsed, the rail stays; with `peek`, the column floats out over the page while the pointer rests on the sidebar, and Escape sends it away. The column keeps its width (no `flex-1`): opening, the sidebar's edge uncovers it instead of squeezing its rows.
@@ -391,8 +435,7 @@ export function Shell() {
391
435
  - A team's tile (its initials on its color, 36px with 10px corners) is `TeamMark` from `abby/team-mark`: `<TeamMark name="Casa Norte" color="#8b6a3e" />`. Without `color` it's Alma's neutral tile with ink letters, for a team whose color the app doesn't know, such as an invitation. It repeats the name beside it, so it's hidden from screen readers and agents. On the sidebar's paper set `--team-mark-surface` to `var(--sidebar)`, and inside a rail's button add `className="size-full"`.
392
436
  - A rail's button is `size="icon"`: a 36px circle whose name shows only in its tooltip. Its badge is `variant="dot"`: a dot while the column is open, the count once collapsed. Put what the badge says in the button's `aria-describedby`.
393
437
  - A two-line row (a name and a line under it) is `size="lg"`, 48px. A row that's a link takes `render={<a href="…" />}`: the button turns it into a link an agent follows, so don't pass `LinkPart` there.
394
- - `SidebarInsetHeader` is the page's top bar, lined up with the window's controls; while the sidebar is collapsed, put a `SidebarTrigger` first in it.
395
- - Collapsed to the rail, the trigger moves to the page's top bar: render a `SidebarTrigger` in `SidebarTitlebar` and another as the first child of `SidebarInsetHeader` while collapsed. The two glide as one button on their own.
438
+ - `SidebarInsetHeader` is the page's top bar, lined up with the window's controls. Collapsed to the rail, the trigger moves there: render a `SidebarTrigger` in `SidebarTitlebar` and another as the first child of `SidebarInsetHeader`. The two glide as one button on their own.
396
439
  - Collapsed to the rail, `SidebarTitlebar` folds to 8px: no empty band over the rail. In a desktop app, hide the window's controls while it's collapsed (the provider's `onOpenChange`).
397
440
  - The Shell block (see the blocks skill) is a whole window built this way.
398
441
 
@@ -0,0 +1,77 @@
1
+ # Picking a week on a calendar
2
+
3
+ Read this when you build a week picker with `Calendar` from `abby/calendar`, or a calendar with a mark under each day. The main skill points here from its "Pick a week on a calendar" section.
4
+
5
+ ## `mode="week"`
6
+
7
+ `mode="week"` makes one press pick the whole week: a click on any day, or Enter or Space on a focused day. Up and Down move the focus from week to week. The row under the pointer or the keyboard lights up before anything is chosen, and the chosen week is drawn as a soft band.
8
+
9
+ - `value` and `onValueChange` always carry `[start, end]`: seven days that start on the calendar's first day of the week. The value is the same whether it came from a press, a key, a controller or an agent.
10
+ - A range that isn't a week is fitted to the week of its first date when it is set from outside, such as `setValue` or `value`. A value with no valid date is refused.
11
+ - ui-sdk has no week mode, so Abby gives ui-sdk `mode="range"` and fixes the range itself. A calendar that doesn't pass `mode` keeps ui-sdk's `single`, `range` or `multiple`.
12
+ - `CalendarMode` from `abby/calendar` includes `"week"`.
13
+
14
+ ## `marks(date)`
15
+
16
+ `marks` takes the ISO date of a day and returns what it shows, the same type as `WeekStrip`'s marks. Under the day number it draws the first tone of `dots`, or the `check`. `label`, `corner` and `bar` are ignored here. The `description` is read by a screen reader after the date. Days without a mark return `undefined`.
17
+
18
+ ```tsx
19
+ import { Calendar } from "abby/calendar";
20
+
21
+ const closed = new Set(["2026-11-18"]);
22
+
23
+ export function ClosedDays() {
24
+ return (
25
+ <Calendar
26
+ mode="week"
27
+ aria-label="Week"
28
+ marks={(date) => (closed.has(date) ? { check: true, description: "Closed" } : undefined)}
29
+ />
30
+ );
31
+ }
32
+ ```
33
+
34
+ The legend that says what each tone means is the app's own. Compose it under the calendar, as the `WeekPopover` story does.
35
+
36
+ ## A week picker in a `Popover`
37
+
38
+ Put the calendar in `PopoverContent`, with the `PopoverTrigger` showing the chosen week. Shortcuts such as "This week" are plain `Button`s that drive the calendar through `createCalendarController()`, so they don't need a second source of truth. A button in the content is not a `Button` rendered into a part: it is a child of the popup.
39
+
40
+ ```tsx
41
+ import { useState } from "react";
42
+ import { Button } from "abby/button";
43
+ import { Calendar, createCalendarController } from "abby/calendar";
44
+ import { Popover, PopoverContent, PopoverTrigger } from "abby/popover";
45
+
46
+ export function WeekPicker() {
47
+ const [calendar] = useState(() => createCalendarController());
48
+ const [week, setWeek] = useState<[string, string]>(["2026-11-16", "2026-11-22"]);
49
+
50
+ return (
51
+ <Popover>
52
+ <PopoverTrigger variant="outline">16 – 22 Nov</PopoverTrigger>
53
+ <PopoverContent className="w-auto gap-2 p-2">
54
+ <Button
55
+ variant="ghost"
56
+ size="xs"
57
+ onClick={() => calendar.setValue(["2026-11-23", "2026-11-23"])}
58
+ >
59
+ This week
60
+ </Button>
61
+ <Calendar
62
+ mode="week"
63
+ aria-label="Week"
64
+ controller={calendar}
65
+ value={week}
66
+ onValueChange={(next) => setWeek(next as [string, string])}
67
+ marks={(date) =>
68
+ date === "2026-11-18" ? { dots: ["success"], description: "Closed" } : undefined
69
+ }
70
+ />
71
+ </PopoverContent>
72
+ </Popover>
73
+ );
74
+ }
75
+ ```
76
+
77
+ The stories that show it are the exports `Week` and `WeekPopover` in `src/components/calendar/calendar.stories.tsx`; `WeekKeyboard`, `WeekMarks`, `WeekBand`, `WeekFromOutside` and `AgentRefusedWeek` there test it.
@@ -0,0 +1,298 @@
1
+ # Charts and maps
2
+
3
+ Read this when you build a bar chart with `BarChart`, a line chart with `LineChart`, a scatter chart with `ScatterChart`, a chart of your own with `Chart`, or a map of nodes with `Graph`. The main skill points here from its "Show counts or trends by day or week" and "Draw memories as a map" sections.
4
+
5
+ Every chart in `abby/chart` is drawn by TanStack Charts (`@tanstack/charts`) in abby's look: the palette is `chart-1` to `chart-5`, the grid and the axes are hairlines, and the tooltip and the focus ring are abby's. The plot is one image named by the chart's `aria-label` or `aria-labelledby`, which is required (without one it throws in development). It is one tab stop: the arrows, Home and End move between points, and the tooltip announces each point it reaches. The presets also put a hidden table with every value under the plot.
6
+
7
+ ## Counts by day or week with `BarChart`
8
+
9
+ `BarChart` from `abby/chart` draws one column per category, one bar per series in that column, a Y axis with its ticks and grid, and x labels that thin out when there are many. Each bar is a point for the pointer and the arrows, and its tooltip names the category, the series and the value.
10
+
11
+ - `data`: one row per category, `{ label, id?, values }`. `label` is the x label; `values` holds one number per series key, and `null` or a missing key draws no bar.
12
+ - `series`: `{ key, name, color?, variant? }` in the order the bars are drawn. `key` reads `values`, `name` reads in the tooltip and the table.
13
+ - `highlight`: the `id` (or `label`) of the current category, today or this week. Its bars take the full color and the rest take their 20% tint.
14
+ - Colors: without `color`, series take `chart-1` to `chart-5` in order. `color` takes a token (`chart-1`…`chart-5`, `primary`, `muted`, `warning`, `success`, `destructive`) or any CSS color, such as `var(--area)`.
15
+ - `variant: "forecast"` draws what hasn't happened yet as a dashed outline in the first series' column. It is not a column of its own.
16
+ - `format` takes `Intl.NumberFormat` options for the axis, the tooltip and the table. `empty`, `categoryHeader` and `missing` replace the texts.
17
+ - `height` is the whole chart's, x labels included. `description` is read after the name: the units, the period.
18
+
19
+ ```tsx
20
+ import { BarChart } from "abby/chart";
21
+
22
+ const days = [
23
+ { label: "Mon", values: { uses: 12, forecast: null } },
24
+ { label: "Tue", values: { uses: 18, forecast: null } },
25
+ { label: "Wed", values: { uses: 9, forecast: null } },
26
+ { label: "Thu", values: { uses: 21, forecast: null } },
27
+ { label: "Fri", values: { uses: null, forecast: 14 } },
28
+ ];
29
+
30
+ export function MemoryUsage() {
31
+ return (
32
+ <BarChart
33
+ aria-label="Memory uses by day"
34
+ data={days}
35
+ series={[
36
+ { key: "uses", name: "Uses", color: "success" },
37
+ {
38
+ key: "forecast",
39
+ name: "Forecast",
40
+ variant: "forecast",
41
+ color: "var(--muted-foreground)",
42
+ },
43
+ ]}
44
+ highlight="Thu"
45
+ format={{ maximumFractionDigits: 0 }}
46
+ />
47
+ );
48
+ }
49
+ ```
50
+
51
+ ### Stacked bars: parts of a total
52
+
53
+ Read this part when each bar is made of parts that add up to its total, like the questions an area answered and missed each week, or what happened to what a memory learned.
54
+
55
+ - `stacked`: the series of each category pile into one bar, in the order of `series`, the first at the bottom, with 2px of air between segments. The scale fits the largest sum. A value of `null` or 0 draws no segment, and a value below 0 draws none and adds nothing to the sum. With one series, `stacked` draws the same as without it.
56
+ - `totals`: writes each category's sum over its bar. With `stacked` the table gets a Total column, and `totalHeader` (a text of the chart's texts, like `categoryHeader`) renames it. Each stack is one point for the tooltip and the arrow keys, and its tooltip names every segment and the sum.
57
+ - `note`: `{ category, text, color? }` writes a short text beside one bar, like "7 open". `category` is the `id` or `label` of that row; `color` defaults to `muted-foreground`.
58
+ - `highlight` with `stacked`: the current category's label and total go bold, and its segments keep their full color.
59
+ - `ChartLegend` from `abby/chart` lists each series with its swatch and name, in the order of `series`. Pass the same `series` array the chart gets. With `data` it also shows what each series adds up to over all the rows. `format`, `locale` and `className` work as on the chart. Put it where the screen wants it; it's plain text for a screen reader, and a forecast series draws a dashed swatch.
60
+
61
+ ```tsx
62
+ import { BarChart, ChartLegend } from "abby/chart";
63
+
64
+ const states = [
65
+ { key: "confirmed", name: "Confirmed", color: "success" },
66
+ {
67
+ key: "corrected",
68
+ name: "Corrected",
69
+ color: "color-mix(in srgb, var(--success) 45%, transparent)",
70
+ },
71
+ {
72
+ key: "dropped",
73
+ name: "Dropped",
74
+ color: "color-mix(in srgb, var(--foreground) 18%, transparent)",
75
+ },
76
+ { key: "open", name: "Open", color: "warning" },
77
+ ];
78
+
79
+ const weeks = [
80
+ { id: "w1", label: "3 Sep", values: { confirmed: 14, corrected: 3, dropped: 1, open: 2 } },
81
+ { id: "w2", label: "10 Sep", values: { confirmed: 11, corrected: 4, dropped: 0, open: 7 } },
82
+ { id: "w3", label: "17 Sep", values: { confirmed: 18, corrected: 2, dropped: 2, open: 0 } },
83
+ ];
84
+
85
+ export function MemoryStates() {
86
+ return (
87
+ <>
88
+ <ChartLegend series={states} data={weeks} />
89
+ <BarChart
90
+ aria-label="Memory states by week"
91
+ data={weeks}
92
+ series={states}
93
+ stacked
94
+ totals
95
+ highlight="w3"
96
+ note={{ category: "w2", text: "7 open", color: "warning" }}
97
+ />
98
+ </>
99
+ );
100
+ }
101
+ ```
102
+
103
+ ## Trends by week with `LineChart`
104
+
105
+ `LineChart` from `abby/chart` draws one line over one series, one point per category, like `BarChart`: a name, a tooltip on each point and a table for screen readers. Use it when the question is whether something rises or falls over time; use `BarChart` to compare counts with each other. Its `data` rows and `series` are `BarChart`'s, and the first series is the line.
106
+
107
+ - `mark`: which points get a dot and their value. `"ends"` (the default) marks the first and the last, `"last"` only the last. A small chart always marks only the last.
108
+ - `references`: `{ value, label?, color? }` horizontal lines to compare against, each labeled at the start. `color` defaults to a hairline.
109
+ - `labels="ends"`: labels only the first and last category under the plot, instead of every one.
110
+ - `size="sm"`: a chart to put side by side with others. It drops the axes and the grid and keeps the line, its last point and its value to the right.
111
+ - `domain`: `[min, max]`, the scale used exactly. Charts with the same `domain` and `height` draw the same value at the same height, so they share one scale. Without it the scale runs from 0 to a round number above the largest value.
112
+ - A `null` value breaks the line, and no dot leaves the plot.
113
+
114
+ ```tsx
115
+ import { LineChart } from "abby/chart";
116
+
117
+ const weeks = [
118
+ { label: "3 nov", values: { answers: 48 } },
119
+ { label: "10 nov", values: { answers: 71 } },
120
+ { label: "17 nov", values: { answers: 64 } },
121
+ { label: "24 nov", values: { answers: 92 } },
122
+ ];
123
+
124
+ export function AnswersPerWeek() {
125
+ return (
126
+ <LineChart
127
+ aria-label="Answers per week"
128
+ data={weeks}
129
+ series={[{ key: "answers", name: "Answers", color: "chart-1" }]}
130
+ mark="ends"
131
+ labels="ends"
132
+ references={[{ value: 80, label: "Goal" }]}
133
+ />
134
+ );
135
+ }
136
+ ```
137
+
138
+ ## Relationships with `ScatterChart`
139
+
140
+ `ScatterChart` from `abby/chart` plots the app's own rows by two numbers, to answer whether one thing goes with another (revenue and retention, size and cost). It keeps each row as it is: `onFocusChange(row)` and `onSelect(row)` hand back the app's row, typed, and `null` when the pointer or focus leaves.
141
+
142
+ - `data`: the rows, any shape. `x` and `y` name two number fields; `size` names a third, and the dot's area grows with it (a square-root scale from 0 to the largest value, so twice the value is twice the area). `color` names a text field, like a segment.
143
+ - `colors`: `{ [value]: color }`, the color of each `color` value and the legend's order. A value that isn't listed takes the next of `chart-1` to `chart-5`.
144
+ - `label(row)` is a row's name, the tooltip's title and the table's first column; `rowKey(row)` keeps a row's identity across updates.
145
+ - `xLabel`, `yLabel`, `sizeLabel`, `colorLabel` name the axes and the fields in the tooltip and the table; `xFormat`, `yFormat`, `sizeFormat` take `Intl.NumberFormat` options, with `locale`.
146
+ - `radius`: `[smallest, largest]` in px, `[3, 18]` by default. `sqrtRadius(largest, radius)` is the same scale, for a chart of your own. `legend={false}` hides the `ChartLegend` of the colors.
147
+
148
+ ```tsx
149
+ import { ScatterChart } from "abby/chart";
150
+
151
+ type Account = {
152
+ id: string;
153
+ name: string;
154
+ segment: "Enterprise" | "Mid-market" | "SMB";
155
+ monthlyRevenue: number;
156
+ retention: number;
157
+ seats: number;
158
+ };
159
+
160
+ const accounts: Account[] = [
161
+ {
162
+ id: "a1",
163
+ name: "Northwind",
164
+ segment: "Enterprise",
165
+ monthlyRevenue: 48000,
166
+ retention: 0.94,
167
+ seats: 420,
168
+ },
169
+ {
170
+ id: "a2",
171
+ name: "Fabrikam",
172
+ segment: "Mid-market",
173
+ monthlyRevenue: 14000,
174
+ retention: 0.81,
175
+ seats: 90,
176
+ },
177
+ { id: "a3", name: "Litware", segment: "SMB", monthlyRevenue: 2400, retention: 0.62, seats: 12 },
178
+ ];
179
+
180
+ export function AccountHealth({ onOpen }: { onOpen: (account: Account) => void }) {
181
+ return (
182
+ <ScatterChart
183
+ aria-label="Monthly revenue against retention by account, sized by seats"
184
+ data={accounts}
185
+ x="monthlyRevenue"
186
+ y="retention"
187
+ size="seats"
188
+ color="segment"
189
+ label={(account) => account.name}
190
+ rowKey={(account) => account.id}
191
+ xLabel="Monthly revenue"
192
+ yLabel="Retention"
193
+ sizeLabel="Seats"
194
+ colorLabel="Segment"
195
+ xFormat={{ style: "currency", currency: "USD", notation: "compact" }}
196
+ yFormat={{ style: "percent" }}
197
+ onSelect={(account) => {
198
+ if (account) onOpen(account);
199
+ }}
200
+ />
201
+ );
202
+ }
203
+ ```
204
+
205
+ ## A chart of your own with `Chart`
206
+
207
+ When no preset fits (a target line over bars, an area, a histogram), build the chart with TanStack's grammar and draw it with `Chart` from `abby/chart`, which gives it abby's look, name and focus. The marks, scales and tooltip come from `@tanstack/charts` itself: add it to the app at the exact version abby depends on, and follow TanStack's own skills for the grammar.
208
+
209
+ - `definition`: what `defineChart` returns. Build it in the component that renders the chart; React Compiler keeps it while its inputs stay the same.
210
+ - Scales: `scaleLinear` from `@tanstack/charts/scales/linear`, `scaleBand` and `scalePoint` for categories, passed as factories so TanStack infers the domain. Never set a pixel range.
211
+ - Colors: leave a mark's paint out and it takes the palette (`chart-1` …), or set `fill`/`stroke` to `var(--chart-2)`, `var(--warning)` and the like. No hex colors: the tokens carry dark mode.
212
+ - A mark that only labels (a total, a rule's text) takes `decorative()` from `@tanstack/charts/mark/decorative`, so the arrows skip it.
213
+ - `height`, `description`, `onFocusChange` and `onSelect` go on `Chart`; `children` draw under the plot: a `ChartLegend`, a table of the values.
214
+
215
+ ```tsx
216
+ import { barY, defineChart, ruleY } from "@tanstack/charts";
217
+ import { scaleBand } from "@tanstack/charts/scales/band";
218
+ import { scaleLinear } from "@tanstack/charts/scales/linear";
219
+ import { tooltip } from "@tanstack/charts/tooltip";
220
+ import { Chart } from "abby/chart";
221
+
222
+ const quarters = [
223
+ { quarter: "Q1", revenue: 42 },
224
+ { quarter: "Q2", revenue: 58 },
225
+ { quarter: "Q3", revenue: 51 },
226
+ { quarter: "Q4", revenue: 66 },
227
+ ];
228
+
229
+ export function RevenueAgainstTarget() {
230
+ const definition = defineChart({
231
+ marks: [
232
+ barY(quarters, { x: "quarter", y: "revenue", radius: 6 }),
233
+ ruleY([60], { stroke: "var(--warning)", strokeDasharray: "3 3" }),
234
+ ],
235
+ scales: {
236
+ x: { scale: () => scaleBand<string>().paddingInner(0.28).paddingOuter(0.14) },
237
+ y: { scale: scaleLinear, nice: true, grid: true },
238
+ },
239
+ tooltip,
240
+ });
241
+ return (
242
+ <Chart
243
+ aria-label="Revenue by quarter against a target of 60"
244
+ definition={definition}
245
+ height={220}
246
+ />
247
+ );
248
+ }
249
+ ```
250
+
251
+ ## Draw memories as a map with `Graph`
252
+
253
+ `Graph` from `abby/graph` draws nodes as buttons and the lines between them in SVG, with no layout of its own. The app places every node: `x` and `y` are its center in map units at zoom 1. The map never lays out, drags or pans. A node's `name` is its button's name; `meta` is the line under it, `current` widens it for the memory being read, `replaced` strikes it through, and `color` takes `chart-1` to `chart-5`.
254
+
255
+ - `edges` are `{ from, to, label?, weight?, variant? }`: `weight` sets the line's width, and `variant` is `solid`, `dashed` or `warning`. An edge to a missing node, a loop or a repeated node id is ignored.
256
+ - `selected`, `defaultSelected` and `onSelectedChange(id, details)` choose a node; `details.cancel()` refuses a change, an agent's included. The map is one tab stop: arrows move to the nearest node, Enter chooses it, and `+` and `−` zoom by 1.25 between 0.5 and 2.
257
+ - `label` names the map (`"Graph"` by default). `GraphLegend` names each line style and `GraphList` gives the same map as text for screen readers.
258
+
259
+ ```tsx
260
+ import { Graph, type GraphEdgeData, type GraphNodeData } from "abby/graph";
261
+
262
+ const nodes: GraphNodeData[] = [
263
+ {
264
+ id: "this",
265
+ name: "Suppliers are paid 45 days after the invoice",
266
+ x: 383,
267
+ y: 410,
268
+ color: "chart-4",
269
+ meta: "This memory",
270
+ current: true,
271
+ },
272
+ {
273
+ id: "old",
274
+ name: "Suppliers are paid at 30 days",
275
+ x: 137,
276
+ y: 230,
277
+ color: "chart-4",
278
+ replaced: true,
279
+ },
280
+ {
281
+ id: "contract",
282
+ name: "Kova framework contract 2026",
283
+ x: 645,
284
+ y: 288,
285
+ color: "chart-4",
286
+ meta: "Carmen Vidal · Oct 2",
287
+ },
288
+ ];
289
+
290
+ const edges: GraphEdgeData[] = [
291
+ { from: "this", to: "old", label: "Replaces", variant: "warning" },
292
+ { from: "this", to: "contract", label: "Based on", weight: 2 },
293
+ ];
294
+
295
+ export function MemoryMap() {
296
+ return <Graph label="Memory map" nodes={nodes} edges={edges} defaultSelected="this" />;
297
+ }
298
+ ```
@@ -0,0 +1,61 @@
1
+ # Filter chips
2
+
3
+ Read this when you build a `FilterChip` from `abby/filter-chip`. The main skill points here from its "Narrow a list with a `FilterChip` menu" and "Filter with a row of chips" sections.
4
+
5
+ `FilterChip` is a 28px capsule with a hairline edge that opens a menu of one choice. It is `Menu` over one radio group, so its options are data an agent can read once the menu is open. Its look is Alma's chip, and a row of them is the results row of a search, with an area, a person and a date each narrowing the list.
6
+
7
+ - `items`: the options, strings or `{ value, label, disabled? }`. A string is an option whose label and value match. Pass the list as `items`, as `Select` does, instead of writing the options as children.
8
+ - `value` and `defaultValue`, with `onValueChange(value, details)`. The chip keeps its own choice when uncontrolled. `details.cancel()` keeps the current value, and an agent's choice can be refused this way.
9
+ - `allValue`: the value that means "no filter", such as `"all"`. The chip is active while the value is any other.
10
+ - Active: the edge turns `ring` and the value takes a medium weight. That mark reads on its own at 3:1; a tint would not, so do not replace it with a background.
11
+ - `prefix`: what the filter is, in grey before the value ("Persona:"). Write its colon yourself. `chevron` draws a chevron after the value, to show that it opens.
12
+ - `color`: a CSS color, such as the area's, drawn as a small square before the value while the chip is active.
13
+ - `onClear` with `clearLabel`: an active chip shows a × beside the trigger. The × goes back to `allValue` whether the chip is controlled or not: it calls `onValueChange(allValue, details)` with `details.reason` `"clear-press"`, then `onClear` unless `details.cancel()` refused it. The × is its own button, so give each chip its own `clearLabel` when a page holds several.
14
+
15
+ ```tsx
16
+ import { FilterChip } from "abby/filter-chip";
17
+
18
+ export function AreaFilter() {
19
+ return (
20
+ <FilterChip
21
+ prefix="Area:"
22
+ chevron
23
+ allValue="all"
24
+ defaultValue="all"
25
+ items={[
26
+ { value: "all", label: "All areas" },
27
+ { value: "product", label: "Product" },
28
+ ]}
29
+ />
30
+ );
31
+ }
32
+ ```
33
+
34
+ Use `Select` instead when the value is a field of a form that is saved with it. Use `Toggle variant="chip"` (below) when the choice is one of a few options that are always shown.
35
+
36
+ ## A row of chips with `Toggle`
37
+
38
+ When the few options are always shown, wrap `Toggle variant="chip" size="sm"` in a `ToggleGroup` with `deselectable={false}`, so one chip is always chosen. `ToggleCount` puts a count after the name; it is `aria-hidden` and becomes the chip's description.
39
+
40
+ ```tsx
41
+ import { Toggle, ToggleCount, ToggleGroup } from "abby/toggle";
42
+
43
+ export function PaymentFilters() {
44
+ return (
45
+ <ToggleGroup aria-label="Sections" defaultValue={["payments"]} deselectable={false}>
46
+ <Toggle value="all" variant="chip" size="sm">
47
+ All
48
+ <ToggleCount>356</ToggleCount>
49
+ </Toggle>
50
+ <Toggle value="payments" variant="chip" size="sm">
51
+ Supplier payments
52
+ <ToggleCount>142</ToggleCount>
53
+ </Toggle>
54
+ <Toggle value="budgets" variant="chip" size="sm">
55
+ Budgets
56
+ <ToggleCount>96</ToggleCount>
57
+ </Toggle>
58
+ </ToggleGroup>
59
+ );
60
+ }
61
+ ```