@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
@@ -24,7 +24,10 @@ import { type Pivot, type PivotKey } from "./pivot.js";
24
24
  * 3. **Colour follows the series, not its position.** The remaining series keep the
25
25
  * pivot's order; sorting by size sorts the AXIS, never repaints.
26
26
  */
27
- export type ChartKind = "bar" | "line" | "pie";
27
+ /** `area` is a line with its wash under it: one quantity over time read as an amount —memory
28
+ * in use, the stock on hand— where the filled area says «this much», and a bare line only
29
+ * says where it went. */
30
+ export type ChartKind = "bar" | "line" | "area" | "pie";
28
31
  export type ChartOrder = "asc" | "desc";
29
32
  /** The row count of each crossing, offered as one more measure: it is the only one that
30
33
  * can always be answered. */
@@ -38,6 +41,9 @@ export type ChartPoint = {
38
41
  /** `pathKey(key)`: the stable identity for React and for colour. */
39
42
  id: string;
40
43
  label: string;
44
+ /** What the axis writes under it when room is short: «ene» for «Enero de 2025». The
45
+ * tooltip keeps `label`. Absent, the axis writes the label. */
46
+ tick?: string;
41
47
  /** The tail gathered into one: «otros (12)». Drawn quieter and does not open. */
42
48
  rest?: boolean;
43
49
  /** The previous period of a comparison: drawn quiet, behind the current one. */
@@ -47,6 +53,8 @@ export type ChartMeasure = {
47
53
  id: string;
48
54
  header: string;
49
55
  format?: (value: number) => string;
56
+ /** The number where room is short: the axis ticks, a sparkline (`PivotMeasure.formatShort`). */
57
+ formatShort?: (value: number) => string;
50
58
  additive: boolean;
51
59
  };
52
60
  export type ChartData = {
@@ -122,5 +130,6 @@ export declare function chartCompare(current: ChartData, previous: ChartData, la
122
130
  export declare function chartFromRecord(entries: Readonly<Record<string, number | null>> | readonly (readonly [string, number | null])[], measure: {
123
131
  header: string;
124
132
  format?: (value: number) => string;
133
+ formatShort?: (value: number) => string;
125
134
  additive?: boolean;
126
135
  }): ChartData;
@@ -1,4 +1,4 @@
1
- import { dateKeysBetween } from "./calendar.js";
1
+ import { dateKeysBetween, dateKeyYear, dateTick } from "./calendar.js";
2
2
  import { currentCopy, fillCopy } from "./copy.js";
3
3
  import { pathKey } from "./grouping.js";
4
4
  import { axisLabels, } from "./pivot.js";
@@ -16,6 +16,7 @@ export function chartMeasures(pivot) {
16
16
  id: one.id,
17
17
  header: one.header,
18
18
  ...(one.format === undefined ? {} : { format: one.format }),
19
+ ...(one.formatShort === undefined ? {} : { formatShort: one.formatShort }),
19
20
  additive: one.additive === true,
20
21
  })),
21
22
  ];
@@ -122,6 +123,20 @@ export function chartFromPivot(pivot, reading = {}) {
122
123
  totals = filled.map((one) => one.total);
123
124
  }
124
125
  }
126
+ /* 0b · The ticks of a time axis: «ene» under the month, the full label in the tooltip. The
127
+ year joins the tick only when the axis crosses one. */
128
+ if (grain !== undefined) {
129
+ const years = new Set(categories
130
+ .map((point) => dateKeyYear(point.key[0] ?? "", grain))
131
+ .filter((year) => year !== null));
132
+ const withYear = years.size > 1;
133
+ categories = categories.map((point) => {
134
+ const key = point.key[0] ?? "";
135
+ return dateKeyYear(key, grain) === null
136
+ ? point
137
+ : { ...point, tick: dateTick(key, grain, withYear) };
138
+ });
139
+ }
125
140
  /* 1 · The series that do not fit in the palette. */
126
141
  let hiddenSeries = 0;
127
142
  const seriesTotals = series.map((column, at) => margin(pivot.columnTotal?.(column.key), values.map((row) => row[at] ?? null)));
@@ -287,6 +302,7 @@ export function chartFromRecord(entries, measure) {
287
302
  id: "value",
288
303
  header: measure.header,
289
304
  ...(measure.format === undefined ? {} : { format: measure.format }),
305
+ ...(measure.formatShort === undefined ? {} : { formatShort: measure.formatShort }),
290
306
  additive: measure.additive ?? true,
291
307
  },
292
308
  categoryTitle: "",
@@ -141,6 +141,11 @@ export type UiCopy = {
141
141
  /** The word next to a required label. The asterisk is the mark; this is
142
142
  * what a screen reader says, because a star is not a word. */
143
143
  required: string;
144
+ /** Beside the label of a field that may stay empty, in the «settings» form style: there
145
+ * every row says what it asks, and the asterisk alone left the rest unsaid. */
146
+ optional: string;
147
+ /** The accessible name of the index of a form's sections («settings» style). */
148
+ sections: string;
144
149
  /** The name of the button that opens a field's longer explanation. */
145
150
  help: string;
146
151
  /** What a field with no value says when it is read: an answer, not a blank. */
@@ -367,6 +372,15 @@ export type UiCopy = {
367
372
  yesterday: string;
368
373
  /** A filter that leaves nothing. */
369
374
  emptyFilter: string;
375
+ /** A field an edit left (or found) empty: a word, because «—» beside an arrow reads as a
376
+ * dash somebody typed. */
377
+ empty: string;
378
+ /** Said before the old and the new value of a change, for a screen reader: the strike and
379
+ * the weight carry it on screen. */
380
+ before: string;
381
+ after: string;
382
+ /** An edit of many fields shows three; this opens the rest. `{count}` is all of them. */
383
+ allChanges: string;
370
384
  /** A note in the timeline takes you to what it belongs to. `{owner}` is that field or
371
385
  * line. */
372
386
  goTo: string;
@@ -470,6 +484,8 @@ export type UiCopy = {
470
484
  */
471
485
  calendar: {
472
486
  week: string;
487
+ /** A week under a chart's tick, where «Semana 12» does not fit: «S12». */
488
+ weekShort: string;
473
489
  weekOfYear: string;
474
490
  quarter: string;
475
491
  quarterOfYear: string;
@@ -702,6 +718,7 @@ export type UiCopy = {
702
718
  kind: string;
703
719
  bar: string;
704
720
  line: string;
721
+ area: string;
705
722
  pie: string;
706
723
  measure: string;
707
724
  categoriesAxis: string;
@@ -781,6 +798,9 @@ export type UiCopy = {
781
798
  tileFailed: string;
782
799
  /** The board's own reading (its headline numbers) failed. */
783
800
  failed: string;
801
+ /** A stat tile whose figure has nothing to be computed from — no messages, so no share of
802
+ * clean ones. Said in words: «—» there reads as a broken tile. */
803
+ noData: string;
784
804
  emptyLane: string;
785
805
  moveHint: string;
786
806
  moved: string;
@@ -884,6 +904,12 @@ export type UiCopy = {
884
904
  /** A failed upload, when the server did not say why. */
885
905
  failed: string;
886
906
  retry: string;
907
+ /** The name of a `FileList` that has no title of its own. */
908
+ files: string;
909
+ /** Every file of a `FileList` at once (`onDownloadAll`). */
910
+ downloadAll: string;
911
+ /** A download by code (`onDownload`) failed. `{name}` is the file. */
912
+ downloadFailed: string;
887
913
  };
888
914
  /** The field picker that walks relations: «Líneas > Impuestos > Monto». */
889
915
  fieldPath: {
@@ -121,6 +121,8 @@ export const SPANISH_COPY = {
121
121
  fileUnreadable: "No pudimos leer el archivo",
122
122
  tryAnother: "Probá con otro",
123
123
  required: "obligatorio",
124
+ optional: "opcional",
125
+ sections: "Secciones del formulario",
124
126
  help: "Ayuda",
125
127
  unset: "sin definir",
126
128
  none: "Ninguna",
@@ -271,6 +273,10 @@ export const SPANISH_COPY = {
271
273
  today: "Hoy",
272
274
  yesterday: "Ayer",
273
275
  emptyFilter: "Todavía no hay nada de esto.",
276
+ empty: "vacío",
277
+ before: "antes:",
278
+ after: "ahora:",
279
+ allChanges: "Ver los {count} cambios",
274
280
  goTo: "Ir a {owner}",
275
281
  send: "Enviar",
276
282
  sending: "Enviando…",
@@ -326,6 +332,7 @@ export const SPANISH_COPY = {
326
332
  time: { justNow: "recién", invalid: "fecha inválida", noDate: "sin fecha" },
327
333
  calendar: {
328
334
  week: "Semana {n}",
335
+ weekShort: "S{n}",
329
336
  weekOfYear: "Semana {n} de {year}",
330
337
  quarter: "T{n}",
331
338
  quarterOfYear: "T{n} de {year}",
@@ -472,6 +479,7 @@ export const SPANISH_COPY = {
472
479
  kind: "Tipo de gráfico",
473
480
  bar: "Barras",
474
481
  line: "Líneas",
482
+ area: "Área",
475
483
  pie: "Torta",
476
484
  measure: "Medida",
477
485
  categoriesAxis: "Eje",
@@ -526,6 +534,7 @@ export const SPANISH_COPY = {
526
534
  board: {
527
535
  tileFailed: "No se pudo leer «{title}»",
528
536
  failed: "No se pudieron leer los números del tablero",
537
+ noData: "Sin datos",
529
538
  emptyLane: "Nada en esta etapa.",
530
539
  moveHint: "Arrastrala, o Alt + ← / → para pasarla a otra etapa",
531
540
  moved: "{name} pasó a {column}",
@@ -593,6 +602,9 @@ export const SPANISH_COPY = {
593
602
  cancelUpload: "Cancelar la subida",
594
603
  failed: "No se pudo subir el archivo.",
595
604
  retry: "Reintentar",
605
+ files: "Archivos",
606
+ downloadAll: "Descargar todo",
607
+ downloadFailed: "No se pudo descargar «{name}».",
596
608
  },
597
609
  fieldPath: {
598
610
  choose: "Elegir un campo",
@@ -97,6 +97,8 @@ export const ENGLISH_COPY = {
97
97
  fileUnreadable: "We could not read the file",
98
98
  tryAnother: "Try another one",
99
99
  required: "required",
100
+ optional: "optional",
101
+ sections: "Sections of the form",
100
102
  help: "Help",
101
103
  unset: "not set",
102
104
  none: "None",
@@ -219,6 +221,10 @@ export const ENGLISH_COPY = {
219
221
  today: "Today",
220
222
  yesterday: "Yesterday",
221
223
  emptyFilter: "Nothing of this kind yet.",
224
+ empty: "empty",
225
+ before: "before:",
226
+ after: "now:",
227
+ allChanges: "See the {count} changes",
222
228
  goTo: "Go to {owner}",
223
229
  send: "Send",
224
230
  sending: "Sending…",
@@ -303,6 +309,7 @@ export const ENGLISH_COPY = {
303
309
  },
304
310
  calendar: {
305
311
  week: "Week {n}",
312
+ weekShort: "W{n}",
306
313
  weekOfYear: "Week {n}, {year}",
307
314
  quarter: "Q{n}",
308
315
  quarterOfYear: "Q{n} {year}",
@@ -462,6 +469,7 @@ export const ENGLISH_COPY = {
462
469
  kind: "Chart type",
463
470
  bar: "Bars",
464
471
  line: "Lines",
472
+ area: "Area",
465
473
  pie: "Pie",
466
474
  measure: "Measure",
467
475
  categoriesAxis: "Axis",
@@ -516,6 +524,7 @@ export const ENGLISH_COPY = {
516
524
  board: {
517
525
  tileFailed: "«{title}» could not be read",
518
526
  failed: "The board's numbers could not be read",
527
+ noData: "No data",
519
528
  emptyLane: "Nothing in this stage.",
520
529
  moveHint: "Drag it, or Alt + ← / → to move it to another stage",
521
530
  moved: "{name} moved to {column}",
@@ -588,6 +597,9 @@ export const ENGLISH_COPY = {
588
597
  cancelUpload: "Cancel the upload",
589
598
  failed: "The file could not be uploaded.",
590
599
  retry: "Try again",
600
+ files: "Files",
601
+ downloadAll: "Download all",
602
+ downloadFailed: "«{name}» could not be downloaded.",
591
603
  },
592
604
  fieldPath: {
593
605
  choose: "Choose a field",
@@ -79,3 +79,9 @@ export declare function FormModeProvider({ value, children, }: {
79
79
  /** The mode of this field. The prop beats the context — a computed field stays
80
80
  * in read mode inside a form that is being edited. */
81
81
  export declare function useFormMode(explicit?: FormMode): FormMode;
82
+ export type FormStyle = "dense" | "settings";
83
+ export declare function FormStyleProvider({ value, children, }: {
84
+ value: FormStyle;
85
+ children: ReactNode;
86
+ }): import("react").JSX.Element;
87
+ export declare function useFormStyle(): FormStyle;
@@ -52,3 +52,10 @@ export function useFormMode(explicit) {
52
52
  const inherited = useContext(Ctx);
53
53
  return explicit ?? inherited;
54
54
  }
55
+ const StyleCtx = createContext("dense");
56
+ export function FormStyleProvider({ value, children, }) {
57
+ return _jsx(StyleCtx.Provider, { value: value, children: children });
58
+ }
59
+ export function useFormStyle() {
60
+ return useContext(StyleCtx);
61
+ }
@@ -1,7 +1,7 @@
1
1
  export { type CopyCatalog, type CopyOverride, createCopy, mergeCopyOver, } from "./catalog.js";
2
2
  export { currentCopy, currentCopyLocale, ENGLISH_COPY, fillCopy, installCopy, mergeCopy, type UiCopy, type UiCopyOverride, UiCopyProvider, useUiCopy, } from "./copy.js";
3
3
  export { byDensity, type Density, DensityProvider, useDensity, } from "./density.js";
4
- export { controlName, FieldBoundary, type FieldIds, type FormMode, FormModeProvider, useFieldIds, useFormMode, } from "./form.js";
4
+ export { controlName, FieldBoundary, type FieldIds, type FormMode, FormModeProvider, type FormStyle, FormStyleProvider, useFieldIds, useFormMode, useFormStyle, } from "./form.js";
5
5
  export { type KeyboardPlatform, type ModShortcut, modShortcut, useKeyboardPlatform, } from "./shortcut.js";
6
6
  export { bySurface, SurfaceProvider, useSurface } from "./surface.js";
7
7
  export { applyTheme, isTheme, type ResolvedTheme, resolveTheme, type Theme, THEME_ATTRIBUTE, ThemeProvider, type ThemeProviderProps, THEMES, useTheme, } from "./theme.js";
@@ -9,7 +9,7 @@ export type { OpenTarget, Size, Surface, Tone } from "./types.js";
9
9
  /** The system's Spanish, for whoever wants to install it whole. */
10
10
  export { SPANISH_COPY } from "./copy.es.js";
11
11
  export { flatten, loose, pick, pickAll, propsOf, slot, slotOf, type Slotted, } from "./slots.js";
12
- export { dateKey, dateKeysBetween, dateLabel, grainName, monthName, nextDateKey, } from "./calendar.js";
12
+ export { dateKey, dateKeysBetween, dateKeyYear, dateLabel, dateTick, grainName, monthName, nextDateKey, } from "./calendar.js";
13
13
  export { GRAIN_ORDER, type GroupableField, type GroupGrain, type Grouping, type GroupLevel, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, type Pile, pileCount, type PileFoot, pileFoot, pileIsOpen, pileItems, pileLabel, type PileLabelOf, type PileOf, pilesFrom, pilesOf, } from "./grouping.js";
14
14
  export { axisLabels, axisSpans, keyStarts, type Pivot, type PivotAxis, type PivotCell, type PivotCrossing, type PivotFold, pivotFrom, pivotIsEmpty, type PivotKey, type PivotLevel, type PivotMargin, type PivotMeasure, pivotOf, type PivotSource, type PivotSpec, } from "./pivot.js";
15
15
  export { chartCompare, type ChartData, chartFromPivot, chartFromRecord, type ChartKind, type ChartMeasure, chartMeasures, type ChartOrder, type ChartPoint, type ChartReading, COUNT_MEASURE, orderChart, SERIES_COLORS, } from "./chart.js";
@@ -5,7 +5,7 @@ export { currentCopy, currentCopyLocale, ENGLISH_COPY, fillCopy, installCopy, me
5
5
  export { byDensity, DensityProvider, useDensity, } from "./density.js";
6
6
  /* A CONTROL'S CONTRACT — the ids its `Field` gives it and whether it is viewed or written. The
7
7
  package's controls and the application's speak it alike. */
8
- export { controlName, FieldBoundary, FormModeProvider, useFieldIds, useFormMode, } from "./form.js";
8
+ export { controlName, FieldBoundary, FormModeProvider, FormStyleProvider, useFieldIds, useFormMode, useFormStyle, } from "./form.js";
9
9
  /* A SHORTCUT, drawn the way the person's keyboard says it: «⌘K» on a Mac, «Ctrl K» elsewhere. */
10
10
  export { modShortcut, useKeyboardPlatform, } from "./shortcut.js";
11
11
  /* THE THEME — light, dark or the operating system's. The palettes live in `tokens.css`; this
@@ -21,7 +21,7 @@ export { flatten, loose, pick, pickAll, propsOf, slot, slotOf, } from "./slots.j
21
21
  /* THE CALENDAR — from a date to a key and from a key to a label. The months
22
22
  and the days of the week are said by `Intl` with the copy's `locale`; the week
23
23
  and the quarter are the only two words that have to be written. */
24
- export { dateKey, dateKeysBetween, dateLabel, grainName, monthName, nextDateKey, } from "./calendar.js";
24
+ export { dateKey, dateKeysBetween, dateKeyYear, dateLabel, dateTick, grainName, monthName, nextDateKey, } from "./calendar.js";
25
25
  /* THE GROUPING — the vocabulary, which both layers speak: the list builds the
26
26
  tree of buckets and the table draws it. It lives here and not in `contexts/list`
27
27
  because a primitive cannot import from a context. */
@@ -92,6 +92,12 @@ export type PivotMeasure = {
92
92
  header: string;
93
93
  /** For a percentage or a variation, which are not read like an amount. */
94
94
  format?: (value: number) => string;
95
+ /**
96
+ * The same number where room is short — a chart's axis, beside a sparkline: «76 MB» for
97
+ * 79.691.776 bytes, «Bs 120 mil». Without it the axis writes the bare number, grouped, and
98
+ * compact from the millions.
99
+ */
100
+ formatShort?: (value: number) => string;
95
101
  /**
96
102
  * How the measure reads in a SPREADSHEET: the Excel format code,
97
103
  * `#,##0.00`, `0.0%`, `#,##0 "Bs."`.
@@ -132,6 +132,7 @@ export function pivotFrom(items, spec) {
132
132
  id: one.id,
133
133
  header: one.header,
134
134
  ...(one.format === undefined ? {} : { format: one.format }),
135
+ ...(one.formatShort === undefined ? {} : { formatShort: one.formatShort }),
135
136
  ...(one.numberFormat === undefined ? {} : { numberFormat: one.numberFormat }),
136
137
  ...(one.additive === undefined ? {} : { additive: one.additive }),
137
138
  })),
@@ -115,6 +115,10 @@ export type IconButtonProps = NativeProps<"button", "type" | "disabled" | "title
115
115
  /** The system's `Tooltip` with the `label`, on hover and focus. On by default; `false`
116
116
  * falls back to the native `title`. */
117
117
  tooltip?: boolean;
118
+ /** What it started is running — a download fetched by code. As `Button`'s: it keeps the
119
+ * focus, says so (`aria-busy`, a turning mark in place of the icon) and ignores presses
120
+ * until it is done — never `disabled`, which drops the focus to the page. */
121
+ busy?: boolean;
118
122
  };
119
123
  /** Only an icon, and that is why the label is mandatory even though it is not
120
124
  * drawn.
@@ -123,7 +127,7 @@ export type IconButtonProps = NativeProps<"button", "type" | "disabled" | "title
123
127
  * most frequent action of a row was the hardest one to hit. Here it has its
124
128
  * full control height and a background on hover — the target is the same as
125
129
  * that of a button with text, only without the text. */
126
- export declare function IconButton({ icon: Icon, label, size, surface: surfaceProp, tone, disabled, type, expanded, haspopup, tooltip, ref, ...native }: IconButtonProps): import("react").JSX.Element;
130
+ export declare function IconButton({ icon: Icon, label, size, surface: surfaceProp, tone, disabled, type, expanded, haspopup, tooltip, busy, ref, onClick, ...native }: IconButtonProps): import("react").JSX.Element;
127
131
  export type IconLinkProps = NativeProps<"a", "href" | "download" | "title" | "aria-label"> & {
128
132
  icon: LucideIcon;
129
133
  label: string;
@@ -226,10 +226,17 @@ function Labelled({ label, tooltip, children, }) {
226
226
  * most frequent action of a row was the hardest one to hit. Here it has its
227
227
  * full control height and a background on hover — the target is the same as
228
228
  * that of a button with text, only without the text. */
229
- export function IconButton({ icon: Icon, label, size = "sm", surface: surfaceProp, tone = "normal", disabled = false, type = "button", expanded, haspopup, tooltip = true, ref, ...native }) {
229
+ export function IconButton({ icon: Icon, label, size = "sm", surface: surfaceProp, tone = "normal", disabled = false, type = "button", expanded, haspopup, tooltip = true, busy = false, ref, onClick, ...native }) {
230
230
  const surface = useSurface(surfaceProp);
231
231
  const ic = ICON[size];
232
- return (_jsx(Labelled, { label: label, tooltip: tooltip, children: (title) => (_jsx("button", { ...native, ref: ref, type: type, title: title, "aria-label": label, disabled: disabled, ...popupAttrs(expanded, haspopup), "data-ui": "icon-button", "data-tone": tone, "data-size": size, "data-surface": surface, className: `${BOX} disabled:pointer-events-none disabled:opacity-45 ${SQUARE[size]} ${TONE[tone][surface]}`, children: _jsx(Icon, { className: ic.size, strokeWidth: ic.stroke, "aria-hidden": true }) })) }));
232
+ const Mark = busy ? LoaderCircle : Icon;
233
+ return (_jsx(Labelled, { label: label, tooltip: tooltip, children: (title) => (_jsx("button", { ...native, ref: ref, type: type, title: title, "aria-label": label, disabled: disabled, ...(busy ? { "aria-busy": true, "aria-disabled": true } : {}), onClick: (event) => {
234
+ if (busy) {
235
+ event.preventDefault();
236
+ return;
237
+ }
238
+ onClick?.(event);
239
+ }, ...popupAttrs(expanded, haspopup), "data-ui": "icon-button", "data-tone": tone, "data-size": size, "data-surface": surface, className: `${BOX} disabled:pointer-events-none disabled:opacity-45 ${SQUARE[size]} ${TONE[tone][surface]}${busy ? " cursor-progress" : ""}`, children: _jsx(Mark, { className: `${ic.size}${busy ? " motion-safe:animate-spin" : ""}`, strokeWidth: ic.stroke, "aria-hidden": true }) })) }));
233
240
  }
234
241
  /**
235
242
  * The same icon, but it is a real link.
@@ -0,0 +1,30 @@
1
+ import type { ChartData } from "../../foundations/chart.js";
2
+ import type { PivotKey } from "../../foundations/pivot.js";
3
+ /**
4
+ * A BAR LIST: a ranking read as a list — the name, a bar, the number — one row each.
5
+ *
6
+ * Context: «why were messages rejected» is six reasons and a count each. A bar chart answers
7
+ * it with two axes, a grid and the names tilted under thirty-pixel columns; a `Meter` answers
8
+ * a different question (a quantity against a known capacity, coloured by alarm). A ranking
9
+ * is a list whose bars only say «how much against the biggest», so that is what this draws:
10
+ * the name where the eye starts, a thin bar proportional to the largest value, and the
11
+ * number at the end — written, because the bar alone gives the shape and not the amount.
12
+ *
13
+ * It reads `ChartData`, the same thing a `Chart` draws — `chartFromPivot`, `chartFromRecord`
14
+ * — never a second way to fold. With one series it draws that series; with several it draws
15
+ * what each whole category gives (`totals`).
16
+ *
17
+ * - A zero is a row with an empty track, not a missing row: «0 spam» is an answer.
18
+ * - A hole (`null`) reads «—»: not counted is not zero.
19
+ * - The gathered tail («otros») draws in the de-emphasis grey and does not open.
20
+ * - Negative values have no length here (a ranking of magnitudes): their row writes the
21
+ * number with its sign and an empty track. A diverging reading is a `Chart`.
22
+ */
23
+ export type BarListProps = {
24
+ data: ChartData;
25
+ /** The accessible name: what is ranked. */
26
+ label: string;
27
+ /** A row was pressed: open what fell there. Absent, the rows only show. */
28
+ onPoint?: (category: PivotKey) => void;
29
+ };
30
+ export declare function BarList({ data, label, onPoint }: BarListProps): import("react").JSX.Element;
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { Empty } from "../notice/Notice.js";
5
+ import { useMemo } from "react";
6
+ export function BarList({ data, label, onPoint }) {
7
+ const copy = useUiCopy();
8
+ const number = useMemo(() => new Intl.NumberFormat(copy.locale, { maximumFractionDigits: 2 }), [copy.locale]);
9
+ const format = (value) => data.measure.format?.(value) ?? number.format(value);
10
+ const amounts = data.categories.map((_, at) => data.series.length === 1 ? (data.values[at]?.[0] ?? null) : (data.totals[at] ?? null));
11
+ const peak = Math.max(0, ...amounts.map((value) => value ?? 0));
12
+ const written = amounts.map((value) => (value === null ? "—" : format(value)));
13
+ /* One width for the numbers' column, the longest one's: they line up at the right edge
14
+ like a column of a table, whatever the measure writes. */
15
+ const column = `${String(Math.max(...written.map((text) => text.length), 1) + 1)}ch`;
16
+ if (data.categories.length === 0)
17
+ return _jsx(Empty, { sentence: copy.chart.empty, align: "start" });
18
+ return (_jsx("ul", { "aria-label": label, className: "flex min-w-0 flex-col gap-0.5", children: data.categories.map((category, at) => {
19
+ const value = amounts[at] ?? null;
20
+ const text = written[at] ?? "—";
21
+ const share = value === null || value <= 0 || peak === 0 ? 0 : (value / peak) * 100;
22
+ const rest = category.rest === true;
23
+ const row = (_jsxs(_Fragment, { children: [_jsx("span", { className: "w-1/3 min-w-0 shrink-0 truncate text-meta text-ink", children: category.label }), _jsx("span", { "aria-hidden": true, className: "h-2 min-w-0 flex-1 rounded-pill bg-ink/6", children: _jsx("span", { className: `block h-full rounded-pill ${rest ? "bg-muted" : "bg-data"}`, style: { width: `${String(share)}%` } }) }), _jsx("span", { className: "shrink-0 text-right text-meta whitespace-nowrap text-ink tabular-nums", style: { width: column }, children: text })] }));
24
+ const line = "flex w-full min-w-0 items-center gap-3 rounded-control px-1.5 py-1.5";
25
+ return (_jsx("li", { className: "min-w-0", children: onPoint === undefined || rest ? (_jsx("div", { className: line, children: row })) : (_jsx("button", { type: "button", onClick: () => onPoint(category.key), className: `${line} cursor-pointer text-left outline-0 transition-colors duration-(--duration-instant) hover:bg-ink/4 focus-visible:outline-2 focus-visible:outline-primary`, children: row })) }, category.id));
26
+ }) }));
27
+ }
@@ -17,6 +17,19 @@ import type { PivotKey } from "../../foundations/pivot.js";
17
17
  * for one series (`data`), the categorical palette only from two, a legend only from two,
18
18
  * and no animation: a chart that moves when it loads is decoration (MOTION in tokens.css).
19
19
  *
20
+ * ── What made it look unfinished, and the rule each fix keeps ─────────
21
+ *
22
+ * - A time axis writes the SHORT tick («ene», «T1», `ChartPoint.tick`) and spaces them
23
+ * evenly: «Enero de 2025» twelve times did not fit, and the axis dropped months at random.
24
+ * - A line has no dot on every value — the line IS the values; the hover says each one. A
25
+ * dot marks only what a line cannot draw: a value alone between two holes, and where the
26
+ * series ends (where it is now).
27
+ * - A hole is drawn as a hole WITH a mark: a faint dashed bridge across it, never the series
28
+ * colour. A bare gap read as a broken chart, not as «nothing was recorded here».
29
+ * - When every bar carries its number at the tip, the value axis and its grid go: they
30
+ * would say the same thing twice. The axis stays whenever any value is unlabelled.
31
+ * - The ticks read the measure's short form (`formatShort`: «76 MB»), not a bare number.
32
+ *
20
33
  * A primitive: it knows nothing about lists or toolbars. `ChartExplorer` puts the controls
21
34
  * around it; anyone can draw it alone with a `ChartData`.
22
35
  */
@@ -4,9 +4,11 @@ import { SERIES_COLORS, } from "../../foundations/chart.js";
4
4
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
5
5
  import { Empty } from "../notice/Notice.js";
6
6
  import { useMemo, useState } from "react";
7
- import { Area, AreaChart, Bar, BarChart, CartesianGrid, Cell, LabelList, Line, LineChart, Pie, PieChart, ReferenceLine, Tooltip, XAxis, YAxis, } from "recharts";
7
+ import { Area, Bar, BarChart, CartesianGrid, Cell, ComposedChart, LabelList, Line, Pie, PieChart, ReferenceLine, Tooltip, XAxis, YAxis, } from "recharts";
8
8
  const MAX_BAR = 24;
9
9
  const RADIUS = 4;
10
+ /* The wash under a line: the series hue at a tenth, never a saturated block. */
11
+ const WASH = 0.1;
10
12
  function colorOf(point, index, alone) {
11
13
  /* The tail and the previous period are context, not the subject: the de-emphasis grey. */
12
14
  if (point.rest === true || point.previous === true)
@@ -37,11 +39,16 @@ export function Chart({ data, kind = "bar", stacked: stackedProp = false, horizo
37
39
  const peak = Math.max(0, ...data.values.flatMap((row) => row.map((value) => Math.abs(value ?? 0))));
38
40
  const negative = data.values.some((row) => row.some((value) => (value ?? 0) < 0));
39
41
  /* In full up to the millions (7.000, 14.000), compact from there (2,5 M): Spanish compact
40
- thousands come out as «7 K» next to «14 k» on the same axis. */
41
- const tick = (value) => peak >= 1_000_000 ? compact.format(value) : number.format(value);
42
+ thousands come out as «7 K» next to «14 k» on the same axis. A measure that knows its
43
+ short form («76 MB») says it itself. */
44
+ const tick = (value) => data.measure.formatShort?.(value) ??
45
+ (peak >= 1_000_000 ? compact.format(value) : number.format(value));
42
46
  /* One object per category, the shape Recharts reads: `s0`, `s1`… per series. */
43
47
  const rows = useMemo(() => data.categories.map((category, c) => {
44
- const row = { label: category.label };
48
+ const row = {
49
+ label: category.label,
50
+ tick: category.tick ?? category.label,
51
+ };
45
52
  data.series.forEach((_, s) => {
46
53
  row[`s${String(s)}`] = data.values[c]?.[s] ?? null;
47
54
  });
@@ -113,7 +120,16 @@ export function Chart({ data, kind = "bar", stacked: stackedProp = false, horizo
113
120
  : horizontal
114
121
  ? { height: `${String(data.categories.length * (1 + perCategory * 0.75) + 3)}rem` }
115
122
  : {};
116
- const grid = (_jsx(CartesianGrid, { vertical: horizontal, horizontal: !horizontal, stroke: "var(--color-line)" }));
123
+ /* The value rides the tip of its bar when there is ONE series: the axis gives the scale,
124
+ the tip gives the number, and nobody has to hover thirty bars to read them. With
125
+ several series it would be a number on every mark, which is noise. */
126
+ const tips = kind === "bar" &&
127
+ !stacked &&
128
+ visible.length === 1 &&
129
+ (horizontal || data.categories.length <= 12);
130
+ /* Every bar says its number: the value axis and its grid would say it twice. */
131
+ const labelled = tips;
132
+ const grid = labelled ? null : (_jsx(CartesianGrid, { vertical: horizontal, horizontal: !horizontal, stroke: "var(--color-line)" }));
117
133
  const tickStyle = { fill: "currentColor" };
118
134
  const valueAxis = {
119
135
  type: "number",
@@ -121,21 +137,18 @@ export function Chart({ data, kind = "bar", stacked: stackedProp = false, horizo
121
137
  tick: tickStyle,
122
138
  tickLine: false,
123
139
  axisLine: false,
140
+ hide: labelled,
124
141
  };
125
142
  const categoryAxis = {
126
143
  type: "category",
127
- dataKey: "label",
144
+ dataKey: "tick",
128
145
  tick: tickStyle,
129
146
  tickLine: false,
130
147
  axisLine: { stroke: "var(--color-line-strong)" },
131
148
  };
132
- const axes = horizontal ? (_jsxs(_Fragment, { children: [_jsx(XAxis, { ...valueAxis }), _jsx(YAxis, { ...categoryAxis, width: "auto", interval: 0 })] })) : (_jsxs(_Fragment, { children: [_jsx(XAxis, { ...categoryAxis, interval: "preserveStartEnd", minTickGap: 8 }), _jsx(YAxis, { ...valueAxis, width: "auto" })] }));
149
+ const axes = horizontal ? (_jsxs(_Fragment, { children: [_jsx(XAxis, { ...valueAxis }), _jsx(YAxis, { ...categoryAxis, width: "auto", interval: 0 })] })) : (_jsxs(_Fragment, { children: ["/* Every Nth tick, the same N all along: an axis that skips unevenly reads as missing periods. */", _jsx(XAxis, { ...categoryAxis, interval: "equidistantPreserveStart", minTickGap: 12 }), _jsx(YAxis, { ...valueAxis, width: "auto" })] }));
133
150
  const zero = negative ? (_jsx(ReferenceLine, { ...(horizontal ? { x: 0 } : { y: 0 }), stroke: "var(--color-line-strong)" })) : null;
134
151
  const readout = (props) => (_jsx(Readout, { ...props, format: format, compare: data.compare === true }));
135
- /* The value rides the tip of its bar when there is ONE series: the axis gives the scale,
136
- the tip gives the number, and nobody has to hover thirty bars to read them. With
137
- several series it would be a number on every mark, which is noise. */
138
- const tips = !stacked && visible.length === 1 && (horizontal || data.categories.length <= 12);
139
152
  let plot;
140
153
  if (kind === "bar") {
141
154
  plot = (_jsxs(BarChart, { data: rows, layout: horizontal ? "vertical" : "horizontal", responsive: true, width: "100%", height: "100%", title: label, barGap: 2, barCategoryGap: "20%", margin: {
@@ -154,7 +167,6 @@ export function Chart({ data, kind = "bar", stacked: stackedProp = false, horizo
154
167
  : { onClick: (_, at) => open(at, one.index) }), children: tips ? (_jsx(LabelList, { dataKey: one.key, content: (props) => (_jsx(Tip, { viewBox: props.viewBox, value: props.value, horizontal: horizontal, format: format })) })) : null }, one.point.id)))] }));
155
168
  }
156
169
  else {
157
- const dots = rows.length <= 24;
158
170
  const common = {
159
171
  data: rows,
160
172
  responsive: true,
@@ -174,12 +186,49 @@ export function Chart({ data, kind = "bar", stacked: stackedProp = false, horizo
174
186
  }),
175
187
  };
176
188
  const ring = { r: 5, stroke: "var(--color-surface)", strokeWidth: 2 };
177
- const tooltip = (_jsx(Tooltip, { isAnimationActive: false, cursor: { stroke: "var(--color-line-strong)" }, content: readout }));
178
- plot = stacked ? (_jsxs(AreaChart, { ...common, stackOffset: negative ? "sign" : "none", children: [grid, axes, zero, tooltip, visible.map((one) => (_jsx(Area, { type: "monotone", dataKey: one.key, name: one.point.label, stackId: "stack", stroke: one.color, strokeWidth: 2, fill: one.color, fillOpacity: 0.12, dot: false, activeDot: { ...ring, fill: one.color }, isAnimationActive: false }, one.point.id)))] })) : (_jsxs(LineChart, { ...common, children: [grid, axes, zero, tooltip, visible.map((one) => (_jsx(Line, { type: "monotone", dataKey: one.key, name: one.point.label, stroke: one.color, strokeWidth: 2, dot: dots
179
- ? { r: 4, fill: one.color, stroke: "var(--color-surface)", strokeWidth: 2 }
180
- : false, activeDot: { ...ring, fill: one.color }, connectNulls: false, isAnimationActive: false }, one.point.id)))] }));
189
+ const filled = kind === "area" || stacked;
190
+ const valueAt = (s, c) => data.values[c]?.[s] ?? null;
191
+ /* A dot only where the line cannot draw: a value alone between two holes (or at an edge
192
+ next to one), and the last value of a series — where it stands now. */
193
+ const marked = (s, c) => {
194
+ if (valueAt(s, c) === null)
195
+ return false;
196
+ const before = c === 0 ? null : valueAt(s, c - 1);
197
+ const after = c === rows.length - 1 ? null : valueAt(s, c + 1);
198
+ const last = data.values.every((_, at) => at <= c || valueAt(s, at) === null);
199
+ return (before === null && after === null) || last;
200
+ };
201
+ /* A hole INSIDE a series: a null with a value somewhere before and after it. */
202
+ const holed = (s) => data.values.some((_, c) => valueAt(s, c) === null &&
203
+ data.values.some((__, at) => at < c && valueAt(s, at) !== null) &&
204
+ data.values.some((__, at) => at > c && valueAt(s, at) !== null));
205
+ plot = (_jsxs(ComposedChart, { ...common, stackOffset: negative ? "sign" : "none", children: [grid, axes, zero, _jsx(Tooltip, { isAnimationActive: false, cursor: { stroke: "var(--color-line-strong)" }, content: readout }), stacked
206
+ ? null
207
+ : visible
208
+ .filter((one) => holed(one.index))
209
+ .map((one) => (_jsx(Line, { type: "monotone", dataKey: one.key, stroke: "var(--color-line-strong)", strokeWidth: 1.5, strokeDasharray: "3 4", connectNulls: true, dot: false, activeDot: false, legendType: "none", tooltipType: "none", isAnimationActive: false }, `${one.point.id}\u0000gap`))), visible.map((one) => {
210
+ const dot = (props) => props.index !== undefined &&
211
+ props.cx !== undefined &&
212
+ props.cy !== undefined &&
213
+ marked(one.index, props.index) ? (_jsx("circle", { cx: props.cx, cy: props.cy, r: 4, fill: one.color, stroke: "var(--color-surface)", strokeWidth: 2 })) : null;
214
+ const shared = {
215
+ type: "monotone",
216
+ dataKey: one.key,
217
+ name: one.point.label,
218
+ stroke: one.color,
219
+ strokeWidth: 2,
220
+ dot,
221
+ activeDot: { ...ring, fill: one.color },
222
+ connectNulls: false,
223
+ isAnimationActive: false,
224
+ };
225
+ return filled ? (_jsx(Area, { ...shared, ...(stacked ? { stackId: "stack", dot: false } : {}), fill: one.color, fillOpacity: WASH }, one.point.id)) : (_jsx(Line, { ...shared }, one.point.id));
226
+ })] }));
181
227
  }
182
- return (_jsxs("figure", { "aria-label": label, className: "flex min-w-0 flex-col gap-3", children: [alone ? null : (_jsx("ul", { className: "flex min-w-0 flex-wrap items-center gap-x-1 gap-y-1", children: series.map((one) => (_jsx("li", { className: "min-w-0", children: _jsxs("button", { type: "button", "aria-pressed": one.shown, "aria-label": fillCopy(one.shown ? words.hideSeries : words.showSeries, {
228
+ return (_jsxs("figure", { "aria-label": label, className: "flex min-w-0 flex-col gap-3", children: [alone ? null : (
229
+ /* At the top right, where the eye ends the title: the key to the colours, out of
230
+ the way of the plot's own reading from the left. */
231
+ _jsx("ul", { className: "flex min-w-0 flex-wrap items-center justify-end gap-x-1 gap-y-1", children: series.map((one) => (_jsx("li", { className: "min-w-0", children: _jsxs("button", { type: "button", "aria-pressed": one.shown, "aria-label": fillCopy(one.shown ? words.hideSeries : words.showSeries, {
183
232
  name: one.point.label,
184
233
  }),
185
234
  /* The last one on cannot be turned off: a chart with nothing on it reads
@@ -191,7 +240,7 @@ export function Chart({ data, kind = "bar", stacked: stackedProp = false, horizo
191
240
  else
192
241
  next.add(one.point.id);
193
242
  return next;
194
- }), className: `inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-control px-1.5 py-0.5 text-meta transition-colors duration-(--duration-instant) outline-0 hover:bg-ink/5 focus-visible:outline-2 focus-visible:outline-primary ${one.shown ? "text-ink" : "text-muted line-through"}`, children: [_jsx(Swatch, { color: one.shown ? one.color : "var(--color-line-strong)", line: kind === "line" }), _jsx("span", { className: "truncate", children: one.point.label })] }) }, one.point.id))) })), _jsx("div", { className: `min-w-0 text-micro text-muted ${height === undefined && !horizontal ? "h-72" : ""}`, style: size, children: plot }), note] }));
243
+ }), className: `inline-flex max-w-full min-w-0 items-center gap-1.5 rounded-control px-1.5 py-0.5 text-meta transition-colors duration-(--duration-instant) outline-0 hover:bg-ink/5 focus-visible:outline-2 focus-visible:outline-primary ${one.shown ? "text-ink" : "text-muted line-through"}`, children: [_jsx(Swatch, { color: one.shown ? one.color : "var(--color-line-strong)", line: kind === "line" || kind === "area" }), _jsx("span", { className: "truncate", children: one.point.label })] }) }, one.point.id))) })), _jsx("div", { className: `min-w-0 text-micro text-muted ${height === undefined && !horizontal ? "h-72" : ""}`, style: size, children: plot }), note] }));
195
244
  }
196
245
  /**
197
246
  * The number at the tip of a bar, on ONE line. Recharts' own label wraps to the bar's
@@ -217,7 +266,10 @@ function Readout({ active, payload, label, format, compare = false, }) {
217
266
  }), [copy.locale]);
218
267
  if (active !== true || payload === undefined || payload.length === 0)
219
268
  return null;
220
- const heading = label ?? payload[0]?.name;
269
+ /* The full label of the category («Enero de 2025»), not the tick the axis wrote («ene»). */
270
+ const row = payload[0]?.payload;
271
+ const full = typeof row === "object" && row !== null && "label" in row ? String(row.label) : undefined;
272
+ const heading = full ?? label ?? payload[0]?.name;
221
273
  /* Now against before, said as a change: the number a comparison is asked for. */
222
274
  const now = payload[0]?.value;
223
275
  const before = payload[1]?.value;