@sincpro/web-ui 2.0.0 → 2.1.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 (119) hide show
  1. package/dist/components/activity/Activity.d.ts +13 -14
  2. package/dist/components/activity/Activity.js +1 -1
  3. package/dist/components/activity/Messages.d.ts +5 -5
  4. package/dist/components/activity/Messages.js +8 -8
  5. package/dist/components/form/Form.js +6 -6
  6. package/dist/components/form/index.js +2 -2
  7. package/dist/components/frame/FrameView.d.ts +5 -5
  8. package/dist/components/frame/FrameView.js +4 -4
  9. package/dist/components/listing/GroupingLevels.d.ts +22 -22
  10. package/dist/components/listing/GroupingLevels.js +9 -9
  11. package/dist/components/listing/Listing.d.ts +11 -11
  12. package/dist/components/listing/Listing.js +11 -11
  13. package/dist/components/listing/ListingBar.js +11 -11
  14. package/dist/components/listing/Row.d.ts +19 -19
  15. package/dist/components/listing/Row.js +25 -25
  16. package/dist/components/listing/SortMenu.d.ts +36 -36
  17. package/dist/components/listing/SortMenu.js +6 -6
  18. package/dist/components/listing/grouping.d.ts +16 -16
  19. package/dist/components/listing/grouping.js +6 -6
  20. package/dist/components/listing/index.js +1 -1
  21. package/dist/components/listing/modelColumns.d.ts +25 -25
  22. package/dist/components/listing/modelColumns.js +24 -24
  23. package/dist/components/listing/pages.js +4 -4
  24. package/dist/components/listing/set.d.ts +18 -18
  25. package/dist/components/navigation/index.js +2 -2
  26. package/dist/components/record/RecordSkeleton.js +7 -7
  27. package/dist/components/search/CriteriaBuilder.d.ts +22 -22
  28. package/dist/components/search/CriteriaBuilder.js +31 -31
  29. package/dist/components/search/CriteriaChips.d.ts +9 -9
  30. package/dist/components/search/CriteriaChips.js +12 -12
  31. package/dist/components/search/FilterBuilder.d.ts +67 -67
  32. package/dist/components/search/FilterBuilder.js +104 -104
  33. package/dist/components/search/JoinWord.d.ts +1 -1
  34. package/dist/components/search/JoinWord.js +14 -14
  35. package/dist/components/search/JsonEditor.d.ts +8 -8
  36. package/dist/components/search/JsonEditor.js +16 -16
  37. package/dist/components/search/SearchBar.d.ts +34 -34
  38. package/dist/components/search/SearchBar.js +110 -110
  39. package/dist/components/search/criteria.d.ts +61 -61
  40. package/dist/components/search/criteria.js +39 -39
  41. package/dist/components/search/datePeriods.d.ts +47 -48
  42. package/dist/components/search/datePeriods.js +29 -29
  43. package/dist/components/search/dateRanges.d.ts +27 -27
  44. package/dist/components/search/dateRanges.js +16 -16
  45. package/dist/components/search/index.js +13 -13
  46. package/dist/components/search/model.d.ts +28 -28
  47. package/dist/components/search/model.js +21 -21
  48. package/dist/components/search/query.d.ts +71 -71
  49. package/dist/components/search/query.js +119 -119
  50. package/dist/components/shell/AppFrame.js +3 -3
  51. package/dist/components/shell/index.js +1 -1
  52. package/dist/foundations/calendar.d.ts +27 -27
  53. package/dist/foundations/calendar.js +72 -72
  54. package/dist/foundations/chart.d.ts +57 -57
  55. package/dist/foundations/chart.js +27 -27
  56. package/dist/foundations/copy.d.ts +96 -94
  57. package/dist/foundations/copy.es.js +1 -0
  58. package/dist/foundations/copy.js +1 -0
  59. package/dist/foundations/grouping.d.ts +175 -175
  60. package/dist/foundations/grouping.js +0 -0
  61. package/dist/foundations/index.d.ts +1 -1
  62. package/dist/foundations/index.js +21 -21
  63. package/dist/foundations/pivot.d.ts +133 -131
  64. package/dist/foundations/pivot.js +54 -54
  65. package/dist/foundations/pivotSheet.d.ts +36 -36
  66. package/dist/foundations/pivotSheet.js +0 -0
  67. package/dist/foundations/slots.d.ts +38 -38
  68. package/dist/foundations/slots.js +18 -18
  69. package/dist/foundations/sticky.d.ts +28 -28
  70. package/dist/foundations/sticky.js +59 -59
  71. package/dist/foundations/xlsx.d.ts +47 -47
  72. package/dist/foundations/xlsx.js +0 -0
  73. package/dist/primitives/block/Line.d.ts +4 -4
  74. package/dist/primitives/block/Line.js +28 -28
  75. package/dist/primitives/block/index.js +2 -2
  76. package/dist/primitives/cell/index.js +2 -2
  77. package/dist/primitives/choice/index.js +3 -3
  78. package/dist/primitives/date/Calendar.d.ts +7 -1
  79. package/dist/primitives/date/Calendar.js +13 -3
  80. package/dist/primitives/date/DatePicker.d.ts +4 -1
  81. package/dist/primitives/date/DatePicker.js +2 -2
  82. package/dist/primitives/date/index.js +3 -3
  83. package/dist/primitives/disclosure/index.js +1 -1
  84. package/dist/primitives/menu/Menu.d.ts +3 -3
  85. package/dist/primitives/notice/Callout.d.ts +30 -30
  86. package/dist/primitives/notice/Callout.js +6 -6
  87. package/dist/primitives/overlay/index.js +3 -3
  88. package/dist/primitives/picker/Picker.d.ts +6 -0
  89. package/dist/primitives/picker/Picker.js +27 -4
  90. package/dist/primitives/picker/index.js +2 -2
  91. package/dist/primitives/table/DataTable.d.ts +32 -32
  92. package/dist/primitives/table/DataTable.js +24 -24
  93. package/dist/primitives/table/EditableTable.d.ts +10 -10
  94. package/dist/primitives/table/EditableTable.js +9 -9
  95. package/dist/primitives/table/ReportTable.js +7 -7
  96. package/dist/primitives/table/SheetTable.d.ts +13 -13
  97. package/dist/primitives/table/SheetTable.js +14 -14
  98. package/dist/primitives/table/Table.js +8 -8
  99. package/dist/primitives/tabs/Tabs.d.ts +46 -46
  100. package/dist/primitives/tabs/Tabs.js +7 -7
  101. package/dist/primitives/tag/index.js +2 -2
  102. package/dist/primitives/toolbar/index.js +1 -1
  103. package/dist/primitives/value/Copyable.d.ts +22 -22
  104. package/dist/primitives/value/Copyable.js +9 -9
  105. package/dist/tokens.css +17 -17
  106. package/dist/views/list/List.d.ts +36 -36
  107. package/dist/views/list/List.js +19 -19
  108. package/dist/views/list/ListView.js +74 -74
  109. package/dist/views/list/columns.d.ts +10 -10
  110. package/dist/views/list/columns.js +10 -10
  111. package/dist/views/list/derive.d.ts +30 -30
  112. package/dist/views/list/derive.js +49 -49
  113. package/dist/views/list/index.js +2 -2
  114. package/dist/views/list/presentations.js +3 -3
  115. package/dist/views/list/types.d.ts +109 -109
  116. package/dist/views/record/Record.d.ts +14 -14
  117. package/dist/views/record/Record.js +24 -24
  118. package/dist/views/record/index.js +1 -1
  119. package/package.json +1 -1
@@ -1,49 +1,49 @@
1
1
  import { currentCopy, currentCopyLocale, fillCopy } from "./copy.js";
2
2
  /**
3
- * EL CALENDARIO: de una fecha a una CLAVE, y de una clave a un RÓTULO.
3
+ * THE CALENDAR: from a date to a KEY, and from a key to a LABEL.
4
4
  *
5
- * Context: un montón de fecha tiene dos textos y no son el mismo. «2026-09» es
6
- * lo que el motor escribe —lo que identifica al montón, lo que se compara con lo
7
- * que contó el servidor, lo que se guarda plegado— y «Septiembre» es lo que se
8
- * lee. Escribir uno solo obliga a elegir cuál se pierde: con la clave a la vista
9
- * la interfaz habla en máquina, y con el rótulo por identidad dos septiembres de
10
- * años distintos se funden en un montón que no existe.
5
+ * Context: a date bucket has two texts and they are not the same. «2026-09» is
6
+ * what the engine writes —what identifies the bucket, what is compared with what
7
+ * the server counted, what is stored folded— and «Septiembre» is what is
8
+ * read. Writing only one forces a choice of which one is lost: with the key in view
9
+ * the interface speaks machine, and with the label as identity two Septembers of
10
+ * different years melt into a bucket that does not exist.
11
11
  *
12
- * Por eso son dos funciones y no una:
12
+ * That is why there are two functions and not one:
13
13
  *
14
- * dateKey(when, "month") → «2026-09» la identidad, en un solo idioma
15
- * dateLabel("2026-09", …) → «Septiembre» el rótulo, en el idioma activo
14
+ * dateKey(when, "month") → «2026-09» the identity, in a single language
15
+ * dateLabel("2026-09", …) → «Septiembre» the label, in the active language
16
16
  *
17
- * ── El idioma no se traduce: se PIDE ────────────────────────────────
17
+ * ── The language is not translated: it is ASKED for ─────────────────
18
18
  *
19
- * Los meses y los días de la semana los dice `Intl` con el `locale` que la copia
20
- * tiene puesto, así que no hay acá ninguna tabla de doce meses en español ni en
21
- * inglés — ni la habría que escribir para un tercer idioma. Lo único que sí es
22
- * copia son la semana y el trimestre, porque ningún calendario los nombra: «W38»
23
- * no es una palabra y `Intl` no la tiene.
19
+ * The months and the days of the week are said by `Intl` with the `locale` the copy
20
+ * has set, so there is no table of twelve months here, in Spanish or in
21
+ * English — nor would one have to be written for a third language. The only things that
22
+ * are copy are the week and the quarter, because no calendar names them: «W38»
23
+ * is not a word and `Intl` does not have it.
24
24
  *
25
- * ── Un rótulo dice lo que el de arriba NO dijo ──────────────────────
25
+ * ── A label says what the one above did NOT say ─────────────────────
26
26
  *
27
- * Un árbol de fechas se lee de arriba hacia abajo, y repetir el año en cada mes
28
- * y el mes en cada día llena la sangría de texto que ya está dos renglones más
29
- * arriba:
27
+ * A tree of dates is read from top to bottom, and repeating the year in every month
28
+ * and the month in every day fills the indentation with text that is already two lines
29
+ * above:
30
30
  *
31
- * 2026 ← el año lo dice una vez
32
- * Septiembre ← no «Septiembre de 2026»
33
- * Semana 38 ← no «Semana 38 de 2026»
34
- * Martes ← no «martes, 15 sept 2026»
31
+ * 2026 ← the year is said once
32
+ * Septiembre ← not «Septiembre de 2026»
33
+ * Semana 38 ← not «Semana 38 de 2026»
34
+ * Martes ← not «martes, 15 sept 2026»
35
35
  *
36
- * De eso se ocupa `within`: los granos que los montones de arriba —del mismo
37
- * campo— ya dijeron. Sin nadie arriba, el rótulo se planta solo y dice la fecha
38
- * entera, porque un «Martes» suelto no es ningún día.
36
+ * `within` takes care of that: the grains that the buckets above —of the same
37
+ * field— already said. With nobody above, the label stands alone and says the whole
38
+ * date, because a bare «Martes» is not a day.
39
39
  */
40
40
  /**
41
- * La forma de la clave de cada grano. Es `GroupGrain` entero: un grano que el
42
- * calendario no supiera cortar sería un nivel que no parte nada.
41
+ * The shape of each grain's key. It is the whole `GroupGrain`: a grain the
42
+ * calendar could not cut would be a level that splits nothing.
43
43
  *
44
- * Los rangos van en la expresión y no en un `if` porque `new Date(2026, 12, 1)`
45
- * no falla: se corre a enero de 2027. Una clave «2026-13» dibujada como «Enero»
46
- * es un mes que nadie contó, y eso es peor que un rótulo ilegible.
44
+ * The ranges go in the expression and not in an `if` because `new Date(2026, 12, 1)`
45
+ * does not fail: it rolls over to January 2027. A key «2026-13» drawn as «Enero»
46
+ * is a month nobody counted, and that is worse than an unreadable label.
47
47
  */
48
48
  const KEY_SHAPES = {
49
49
  year: /^(\d{4})$/,
@@ -53,13 +53,13 @@ const KEY_SHAPES = {
53
53
  day: /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$/,
54
54
  };
55
55
  /**
56
- * Una fecha recortada a la CLAVE de su grano.
56
+ * A date cut down to the KEY of its grain.
57
57
  *
58
- * El texto es el que produce el motor —«2026», «2026-Q3», «2026-09», «2026-W38»,
59
- * «2026-09-15»—, y que los dos lados lo escriban igual es lo que deja comparar
60
- * un agrupado hecho en el navegador con uno contado a mil kilómetros. Sin fecha
61
- * la clave es vacía: un montón que existe —el de los que no tienen— y que se
62
- * dibuja con las palabras de la copia.
58
+ * The text is the one the engine produces —«2026», «2026-Q3», «2026-09», «2026-W38»,
59
+ * «2026-09-15»—, and both sides writing it the same is what lets a grouping
60
+ * made in the browser be compared with one counted a thousand kilometres away. Without a date
61
+ * the key is empty: a bucket that exists —the one for those that have none— and that is
62
+ * drawn with the words of the copy.
63
63
  */
64
64
  export function dateKey(when, grain) {
65
65
  if (when === null || when === undefined || when === "")
@@ -90,13 +90,13 @@ export function dateKey(when, grain) {
90
90
  return `${year}-${pad(month)}-${pad(date.getDate())}`;
91
91
  }
92
92
  /**
93
- * El RÓTULO de una clave de fecha, en el idioma activo.
93
+ * The LABEL of a date key, in the active language.
94
94
  *
95
- * `within` son los granos que los montones de arriba ya dijeron: con el año
96
- * arriba, un mes es «Septiembre» y no «Septiembre de 2026». Una clave que no
97
- * tiene la forma de su grano se dibuja TAL CUAL —es lo que hace que un montón
98
- * contado afuera, con una clave que esta capa no escribió, siga siendo legible
99
- * en vez de desaparecer detrás de una fecha inventada.
95
+ * `within` are the grains the buckets above already said: with the year
96
+ * above, a month is «Septiembre» and not «Septiembre de 2026». A key that does not
97
+ * have the shape of its grain is drawn AS IS —that is what keeps a bucket
98
+ * counted elsewhere, with a key this layer did not write, readable
99
+ * instead of vanishing behind an invented date.
100
100
  */
101
101
  export function dateLabel(key, grain, within = []) {
102
102
  const copy = currentCopy();
@@ -118,8 +118,8 @@ export function dateLabel(key, grain, within = []) {
118
118
  }
119
119
  if (grain === "week") {
120
120
  const week = Number(parts[2]);
121
- /* El mes también alcanza: una semana adentro de septiembre ya sabe de qué
122
- año es, porque el mes lo dijo. */
121
+ /* The month is enough too: a week inside September already knows which
122
+ year it is, because the month said so. */
123
123
  return said("year") || said("quarter") || said("month")
124
124
  ? fillCopy(copy.calendar.week, { n: week })
125
125
  : fillCopy(copy.calendar.weekOfYear, { n: week, year });
@@ -132,13 +132,13 @@ export function dateLabel(key, grain, within = []) {
132
132
  }
133
133
  const day = Number(parts[3]);
134
134
  const when = new Date(year, Number(parts[2]) - 1, day);
135
- /* El 31 de febrero tiene la forma de un día y no es ninguno: `Date` lo corre
136
- al 3 de marzo en vez de quejarse, así que se pregunta si volvió el mismo. */
135
+ /* 31 February has the shape of a day and is none: `Date` rolls it over
136
+ to 3 March instead of complaining, so we ask whether the same day came back. */
137
137
  if (when.getDate() !== day)
138
138
  return key;
139
- /* Adentro de una semana, el día es su NOMBRE: son siete y ninguno se repite,
140
- así que «Martes» alcanza y el número de día sería ruido. Afuera no: un
141
- «Martes» suelto no dice cuál de los cincuenta y dos. */
139
+ /* Inside a week, the day is its NAME: there are seven and none repeats,
140
+ so «Martes» is enough and the day number would be noise. Outside it is not: a bare
141
+ «Martes» does not say which of the fifty-two. */
142
142
  if (said("week"))
143
143
  return capitalized(format(locale, { weekday: "long" }).format(when));
144
144
  return capitalized(format(locale, {
@@ -149,9 +149,9 @@ export function dateLabel(key, grain, within = []) {
149
149
  }).format(when));
150
150
  }
151
151
  /**
152
- * La clave SIGUIENTE en el mismo grano: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
153
- * «2026-W52» → la semana ISO que sigue. `null` si la clave no tiene la forma de su grano —
154
- * una contada afuera, que esta capa no escribió y entonces no puede continuar.
152
+ * The NEXT key in the same grain: «2026-09» → «2026-10», «2026-Q4» → «2027-Q1»,
153
+ * «2026-W52» → the ISO week that follows. `null` if the key does not have the shape of its grain —
154
+ * one counted elsewhere, which this layer did not write and so cannot continue.
155
155
  */
156
156
  export function nextDateKey(key, grain) {
157
157
  const parts = KEY_SHAPES[grain].exec(key);
@@ -179,12 +179,12 @@ export function nextDateKey(key, grain) {
179
179
  return dateKey(date, "day");
180
180
  }
181
181
  /**
182
- * Todas las claves de un grano entre dos, las dos incluidas: el EJE de tiempo entero.
182
+ * All the keys of a grain between two, both included: the whole time AXIS.
183
183
  *
184
- * Un eje que salta el mes en que no pasó nada miente sobre el tiempo —agosto pegado a
185
- * octubre se lee como un mes— y ese hueco suele ser justo lo que alguien busca. `null` si
186
- * alguna clave no se puede continuar o si serían más de `max`: un eje por día de diez años
187
- * no es un gráfico.
184
+ * An axis that skips the month where nothing happened lies about time —August stuck to
185
+ * October reads as one month— and that gap is often exactly what someone is looking for. `null` if
186
+ * some key cannot be continued or if there would be more than `max`: an axis by day over ten years
187
+ * is not a chart.
188
188
  */
189
189
  export function dateKeysBetween(first, last, grain, max = 1000) {
190
190
  const out = [first];
@@ -198,24 +198,24 @@ export function dateKeysBetween(first, last, grain, max = 1000) {
198
198
  }
199
199
  return key === last ? out : null;
200
200
  }
201
- /** El nombre de un mes —1 a 12— en el idioma activo. Lo usa el que ofrece meses
202
- * sin tener ninguna fecha en la mano, como el recorte por período. */
201
+ /** The name of a month —1 to 12— in the active language. Used by whoever offers months
202
+ * without holding any date, like the cut by period. */
203
203
  export function monthName(month) {
204
204
  return capitalized(format(currentCopyLocale(), { month: "long" }).format(new Date(2000, month - 1, 1)));
205
205
  }
206
- /** Cómo se llama un GRANO —«día», «semana»—, que es distinto de cómo se llama un
207
- * montón suyo: el grano nombra el corte y el rótulo nombra lo cortado. Sale de
208
- * la copia, que es donde ya viven las unidades de tiempo en singular. */
206
+ /** What a GRAIN is called —«día», «semana»—, which is different from what a bucket
207
+ * of it is called: the grain names the cut and the label names what was cut. It comes from
208
+ * the copy, which is where the time units in the singular already live. */
209
209
  export function grainName(grain) {
210
210
  return capitalized(currentCopy().dates[grain]);
211
211
  }
212
212
  /**
213
- * El año y la semana ISO de una fecha.
213
+ * The ISO year and week of a date.
214
214
  *
215
- * La semana 1 es la que tiene el primer jueves del año, así que se calcula con
216
- * el jueves de la semana del dato: es él quien decide a qué año pertenece, y por
217
- * eso una semana de fin de diciembre puede ser la 1 del año siguiente. El año
218
- * que sale de acá es el de ESA semana y no el de la fecha.
215
+ * Week 1 is the one holding the first Thursday of the year, so it is computed with
216
+ * the Thursday of the datum's week: it decides which year it belongs to, and that is
217
+ * why a week at the end of December can be week 1 of the next year. The year
218
+ * that comes out of here is that of THAT week and not that of the date.
219
219
  */
220
220
  function isoWeek(date) {
221
221
  const thursday = new Date(date.getFullYear(), date.getMonth(), date.getDate());
@@ -229,9 +229,9 @@ function isoWeek(date) {
229
229
  function format(locale, options) {
230
230
  return new Intl.DateTimeFormat(locale, options);
231
231
  }
232
- /** Un rótulo encabeza un montón, y en español `Intl` devuelve «septiembre» con
233
- * minúscula. Se sube la primera letra con el idioma activo, que es el que sabe
234
- * cuál es la mayúscula de esa letra. */
232
+ /** A label heads a bucket, and in Spanish `Intl` returns «septiembre» in
233
+ * lowercase. The first letter is raised with the active language, which is the one that knows
234
+ * what the capital of that letter is. */
235
235
  function capitalized(text) {
236
236
  const first = text.charAt(0);
237
237
  return first === "" ? text : first.toLocaleUpperCase(currentCopyLocale()) + text.slice(1);
@@ -1,46 +1,46 @@
1
1
  import { type Pivot, type PivotKey } from "./pivot.js";
2
2
  /**
3
- * EL GRÁFICO: un pivote leído como marcas.
3
+ * THE CHART: a pivot read as marks.
4
4
  *
5
- * Context: un gráfico de un ERP —el de Odoo, el de cualquiera— contesta la misma pregunta
6
- * que un pivote: el conjunto partido por un campo (el eje), a veces por otro más (las
7
- * series), y en cada cruce un número plegado. Por eso esto NO trae otra manera de plegar:
8
- * lee un `Pivot`. Y como un `Pivot` lo arma igual quien tiene los registros en la mano
9
- * (`pivotFrom`), quien lo plegó en el servidor (`pivotOf`) o quien lo armó desde las celdas
10
- * de un archivo, el mismo gráfico sirve para registros, para un dataset y para lo agrupado
11
- * a mil kilómetros. Un diccionario o un `SeriesBar[]` entran por sus dos helpers de abajo.
5
+ * Context: an ERP chart —Odoo's, anyone's— answers the same question
6
+ * as a pivot: the set split by one field (the axis), sometimes by another (the
7
+ * series), and at each crossing a folded number. That is why this brings NO other way to fold:
8
+ * it reads a `Pivot`. And since a `Pivot` is built the same by whoever holds the records in hand
9
+ * (`pivotFrom`), whoever folded it on the server (`pivotOf`) or whoever built it from the cells
10
+ * of a file, the same chart serves records, a dataset and what is grouped
11
+ * a thousand kilometres away. A dictionary or a `SeriesBar[]` come in through the two helpers below.
12
12
  *
13
- * ── Las filas del pivote son el EJE; sus columnas, las SERIES ───────
13
+ * ── The pivot's rows are the AXIS; its columns, the SERIES ──────────
14
14
  *
15
- * Igual que en Odoo: el primer agrupado va abajo y el segundo se apila o se pone al lado.
15
+ * As in Odoo: the first grouping goes below and the second is stacked or set beside it.
16
16
  *
17
- * ── Tres reglas que vienen del pivote, y siguen valiendo ────────────
17
+ * ── Three rules that come from the pivot, and still hold ────────────
18
18
  *
19
- * 1. **Un agujero no es un cero.** `null` es «ahí no hay filas»: la barra no se dibuja y
20
- * la línea se corta. Un cero es una barra a ras del eje.
21
- * 2. **No se inventan sumas.** Juntar la cola en «otros» o acumular una línea es sumar, y
22
- * sólo se hace si la medida se suma (`additive`; el conteo siempre). Si no, la cola se
23
- * deja afuera y se DICE (`hiddenSeries`): un promedio de promedios no es un promedio.
24
- * 3. **El color sigue a la serie, no a su puesto.** Las series que quedan conservan el
25
- * orden del pivote; ordenar por tamaño ordena el EJE, nunca repinta.
19
+ * 1. **A hole is not a zero.** `null` is «there are no rows there»: the bar is not drawn and
20
+ * the line breaks. A zero is a bar flush with the axis.
21
+ * 2. **Sums are not invented.** Gathering the tail into «otros» or accumulating a line is summing, and
22
+ * it is only done if the measure sums (`additive`; the count always). Otherwise the tail is
23
+ * left out and SAID (`hiddenSeries`): an average of averages is not an average.
24
+ * 3. **Colour follows the series, not its position.** The remaining series keep the
25
+ * pivot's order; sorting by size sorts the AXIS, never repaints.
26
26
  */
27
27
  export type ChartKind = "bar" | "line" | "pie";
28
28
  export type ChartOrder = "asc" | "desc";
29
- /** El conteo de filas de cada cruce, ofrecido como una medida más: es la única que
30
- * siempre se puede contestar. */
29
+ /** The row count of each crossing, offered as one more measure: it is the only one that
30
+ * can always be answered. */
31
31
  export declare const COUNT_MEASURE = "__count";
32
- /** Cuántas series se distinguen por color. Es el largo de la paleta (`--color-series-*`):
33
- * una novena serie sería un color generado, y bajo daltonismo ése se confunde con otro. */
32
+ /** How many series are told apart by colour. It is the palette's length (`--color-series-*`):
33
+ * a ninth series would be a generated colour, and under colour blindness that one gets confused with another. */
34
34
  export declare const SERIES_COLORS = 8;
35
- /** Una clave de un eje del gráfico: su ruta en el pivote y cómo se lee. */
35
+ /** A key of a chart axis: its path in the pivot and how it reads. */
36
36
  export type ChartPoint = {
37
37
  key: PivotKey;
38
- /** `pathKey(key)`: la identidad estable para React y para el color. */
38
+ /** `pathKey(key)`: the stable identity for React and for colour. */
39
39
  id: string;
40
40
  label: string;
41
- /** La cola juntada en una: «otros (12)». Se dibuja más callada y no se abre. */
41
+ /** The tail gathered into one: «otros (12)». Drawn quieter and does not open. */
42
42
  rest?: boolean;
43
- /** El período anterior de una comparación: se dibuja callado, detrás del actual. */
43
+ /** The previous period of a comparison: drawn quiet, behind the current one. */
44
44
  previous?: boolean;
45
45
  };
46
46
  export type ChartMeasure = {
@@ -52,72 +52,72 @@ export type ChartMeasure = {
52
52
  export type ChartData = {
53
53
  categories: readonly ChartPoint[];
54
54
  series: readonly ChartPoint[];
55
- /** `values[categoría][serie]`; `null` es un agujero. */
55
+ /** `values[category][series]`; `null` is a hole. */
56
56
  values: readonly (readonly (number | null)[])[];
57
- /** Lo que da cada categoría entera, plegado de la base cuando el pivote lo trae. Es lo
58
- * que mide una torta y lo que ordena el eje. */
57
+ /** What each whole category gives, folded from the base when the pivot brings it. It is what
58
+ * a pie measures and what orders the axis. */
59
59
  totals: readonly (number | null)[];
60
60
  measure: ChartMeasure;
61
- /** Cómo se llaman los cortes: «sucursal», «año · forma de pago». */
61
+ /** What the cuts are called: «sucursal», «año · forma de pago». */
62
62
  categoryTitle: string;
63
63
  seriesTitle: string;
64
- /** Series que no entraron y no se pudieron juntar en «otros» (la medida no se suma). */
64
+ /** Series that did not make it and could not be gathered into «otros» (the measure does not sum). */
65
65
  hiddenSeries: number;
66
- /** Lo mismo, para las categorías que una torta no puede mostrar. */
66
+ /** The same, for the categories a pie cannot show. */
67
67
  hiddenCategories: number;
68
- /** Las dos series son el período actual y el anterior (`chartCompare`). */
68
+ /** The two series are the current and the previous period (`chartCompare`). */
69
69
  compare?: boolean;
70
70
  };
71
71
  export type ChartReading = {
72
- /** El id de la medida, o `COUNT_MEASURE`. Por defecto la primera del pivote. */
72
+ /** The measure's id, or `COUNT_MEASURE`. By default the pivot's first. */
73
73
  measure?: string;
74
- /** Ordena el EJE por lo que da cada categoría. Sin esto, el orden de sus claves. */
74
+ /** Sorts the AXIS by what each category gives. Without this, the order of its keys. */
75
75
  order?: ChartOrder;
76
- /** Cada punto suma los anteriores: «cuánto llevamos». Sólo con una medida que se suma. */
76
+ /** Each point adds the previous ones: «how much we have so far». Only with a measure that sums. */
77
77
  cumulative?: boolean;
78
- /** Más series que esto se juntan en «otros». Por defecto, los colores de la paleta. */
78
+ /** More series than this are gathered into «otros». By default, the palette's colours. */
79
79
  maxSeries?: number;
80
- /** Más categorías que esto se juntan en «otros». Una torta pide seis. */
80
+ /** More categories than this are gathered into «otros». A pie asks for six. */
81
81
  maxCategories?: number;
82
82
  /**
83
- * Con un solo nivel de FECHA en el eje, completa los períodos en que no pasó nada:
84
- * agosto no queda pegado a octubre. El conteo de un período vacío es 0; cualquier otra
85
- * medida es un agujero (`null`), como cualquier cruce sin filas. Encendido por defecto.
83
+ * With a single DATE level on the axis, fills in the periods where nothing happened:
84
+ * August is not left stuck to October. The count of an empty period is 0; any other
85
+ * measure is a hole (`null`), like any crossing without rows. On by default.
86
86
  */
87
87
  fillDates?: boolean;
88
88
  };
89
- /** Las medidas que se pueden graficar de un pivote: el conteo y las suyas. */
89
+ /** The measures that can be charted from a pivot: the count and its own. */
90
90
  export declare function chartMeasures(pivot: Pivot): ChartMeasure[];
91
91
  /**
92
- * El pivote como gráfico: las filas son el eje, las columnas las series, y en cada cruce
93
- * el número de la medida elegida.
92
+ * The pivot as a chart: the rows are the axis, the columns the series, and at each crossing
93
+ * the number of the chosen measure.
94
94
  */
95
95
  export declare function chartFromPivot(pivot: Pivot, reading?: ChartReading): ChartData;
96
96
  /**
97
- * Ordena el EJE de un gráfico ya armado por lo que da cada categoría. La cola juntada
98
- * («otros») queda al final. Es lo mismo que `order` en `chartFromPivot`, para un gráfico
99
- * que se armó de otra manera —una comparación, un diccionario—.
97
+ * Sorts the AXIS of an already built chart by what each category gives. The gathered tail
98
+ * («otros») stays last. It is the same as `order` in `chartFromPivot`, for a chart
99
+ * that was built another way —a comparison, a dictionary—.
100
100
  */
101
101
  export declare function orderChart(data: ChartData, order: ChartOrder | undefined): ChartData;
102
102
  /**
103
- * EL PERÍODO ANTERIOR al lado del actual — el «comparar con» de Odoo.
103
+ * THE PREVIOUS PERIOD beside the current one — Odoo's «comparar con».
104
104
  *
105
- * Cada gráfico se arma por su lado (`chartFromPivot` sobre los registros de cada período)
106
- * y esto los junta en dos series: el actual y el anterior, que se dibuja callado. Lo que se
107
- * compara es lo que da cada categoría entera.
105
+ * Each chart is built on its own (`chartFromPivot` over each period's records)
106
+ * and this joins them into two series: the current and the previous, which is drawn quiet. What is
107
+ * compared is what each whole category gives.
108
108
  *
109
- * `by` dice cómo se encuentran: por CLAVE cuando el eje es una cosa —La Paz con La Paz— y
110
- * por POSICIÓN cuando es tiempo —el primer mes con el primer mes—, porque «2026-09» y
111
- * «2025-09» son claves distintas y lo que se compara es «el mismo momento del período».
112
- * Una categoría del anterior que no está en el actual no se dibuja: el eje es el de ahora.
109
+ * `by` says how they are matched: by KEY when the axis is a thing —La Paz with La Paz— and
110
+ * by POSITION when it is time —the first month with the first month—, because «2026-09» and
111
+ * «2025-09» are different keys and what is compared is «the same moment of the period».
112
+ * A category of the previous that is not in the current is not drawn: the axis is today's.
113
113
  */
114
114
  export declare function chartCompare(current: ChartData, previous: ChartData, labels: {
115
115
  current: string;
116
116
  previous: string;
117
117
  }, by?: "key" | "position"): ChartData;
118
118
  /**
119
- * Un DICCIONARIO como gráfico: `{ "La Paz": 120, "Oruro": 40 }`, o sus pares. Es lo que
120
- * devuelve un endpoint de resumen, y no hace falta armarle un pivote.
119
+ * A DICTIONARY as a chart: `{ "La Paz": 120, "Oruro": 40 }`, or its pairs. It is what
120
+ * a summary endpoint returns, and there is no need to build a pivot for it.
121
121
  */
122
122
  export declare function chartFromRecord(entries: Readonly<Record<string, number | null>> | readonly (readonly [string, number | null])[], measure: {
123
123
  header: string;
@@ -2,13 +2,13 @@ import { dateKeysBetween } 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";
5
- /** El conteo de filas de cada cruce, ofrecido como una medida más: es la única que
6
- * siempre se puede contestar. */
5
+ /** The row count of each crossing, offered as one more measure: it is the only one that
6
+ * can always be answered. */
7
7
  export const COUNT_MEASURE = "__count";
8
- /** Cuántas series se distinguen por color. Es el largo de la paleta (`--color-series-*`):
9
- * una novena serie sería un color generado, y bajo daltonismo ése se confunde con otro. */
8
+ /** How many series are told apart by colour. It is the palette's length (`--color-series-*`):
9
+ * a ninth series would be a generated colour, and under colour blindness that one gets confused with another. */
10
10
  export const SERIES_COLORS = 8;
11
- /** Las medidas que se pueden graficar de un pivote: el conteo y las suyas. */
11
+ /** The measures that can be charted from a pivot: the count and its own. */
12
12
  export function chartMeasures(pivot) {
13
13
  return [
14
14
  { id: COUNT_MEASURE, header: currentCopy().chart.count, additive: true },
@@ -63,8 +63,8 @@ function keep(totals, max, additive) {
63
63
  };
64
64
  }
65
65
  /**
66
- * El pivote como gráfico: las filas son el eje, las columnas las series, y en cada cruce
67
- * el número de la medida elegida.
66
+ * The pivot as a chart: the rows are the axis, the columns the series, and at each crossing
67
+ * the number of the chosen measure.
68
68
  */
69
69
  export function chartFromPivot(pivot, reading = {}) {
70
70
  const words = currentCopy();
@@ -79,11 +79,11 @@ export function chartFromPivot(pivot, reading = {}) {
79
79
  let categories = pivot.rows.keys.map((key) => pointOf(pivot.rows, key, words.pivot.total));
80
80
  let series = pivot.columns.keys.map((key) => pointOf(pivot.columns, key, measure.header));
81
81
  let values = categories.map((row) => series.map((column) => read(pivot.cell(row.key, column.key))));
82
- /* Los márgenes salen de la BASE cuando el pivote los trae; sumar celdas es la salida
83
- honesta sólo cuando la medida se suma. */
82
+ /* The margins come from the BASE when the pivot brings them; summing cells is the honest
83
+ way out only when the measure sums. */
84
84
  const margin = (cell, inside) => cell !== undefined ? read(cell) : measure.additive ? sum(inside) : null;
85
85
  let totals = categories.map((row, at) => margin(pivot.rowTotal?.(row.key), values[at] ?? []));
86
- /* 0 · El tiempo entero: los períodos vacíos entre el primero y el último. */
86
+ /* 0 · The whole time span: the empty periods between the first and the last. */
87
87
  const grain = pivot.rows.levels.length === 1 ? pivot.rows.levels[0]?.grain : undefined;
88
88
  if (grain !== undefined && reading.fillDates !== false) {
89
89
  const dated = categories
@@ -122,7 +122,7 @@ export function chartFromPivot(pivot, reading = {}) {
122
122
  totals = filled.map((one) => one.total);
123
123
  }
124
124
  }
125
- /* 1 · Las series que no entran en la paleta. */
125
+ /* 1 · The series that do not fit in the palette. */
126
126
  let hiddenSeries = 0;
127
127
  const seriesTotals = series.map((column, at) => margin(pivot.columnTotal?.(column.key), values.map((row) => row[at] ?? null)));
128
128
  const seriesCut = keep(seriesTotals, reading.maxSeries ?? SERIES_COLORS, measure.additive);
@@ -149,7 +149,7 @@ export function chartFromPivot(pivot, reading = {}) {
149
149
  values = values.map((row) => kept.map((at) => row[at] ?? null));
150
150
  }
151
151
  }
152
- /* 2 · Las categorías que no entran (una torta). */
152
+ /* 2 · The categories that do not fit (a pie). */
153
153
  let hiddenCategories = 0;
154
154
  let restCategory = null;
155
155
  if (reading.maxCategories !== undefined) {
@@ -175,7 +175,7 @@ export function chartFromPivot(pivot, reading = {}) {
175
175
  totals = cut.kept.map((at) => totals[at] ?? null);
176
176
  }
177
177
  }
178
- /* 3 · El orden del eje. La cola juntada va siempre al final: no es una categoría más. */
178
+ /* 3 · The axis order. The gathered tail always goes last: it is not one more category. */
179
179
  if (reading.order !== undefined) {
180
180
  const at = categories.map((_, index) => index).sort(byTotal(totals, reading.order));
181
181
  categories = at.map((index) => categories[index]);
@@ -187,7 +187,7 @@ export function chartFromPivot(pivot, reading = {}) {
187
187
  values = [...values, restCategory.values];
188
188
  totals = [...totals, restCategory.total];
189
189
  }
190
- /* 4 · Acumulado: un agujero arrastra lo que se llevaba, no lo corta. */
190
+ /* 4 · Cumulative: a hole carries over what was running, it does not cut it. */
191
191
  if (reading.cumulative === true && measure.additive) {
192
192
  const running = series.map(() => null);
193
193
  values = values.map((row) => row.map((value, s) => {
@@ -215,9 +215,9 @@ export function chartFromPivot(pivot, reading = {}) {
215
215
  };
216
216
  }
217
217
  /**
218
- * Ordena el EJE de un gráfico ya armado por lo que da cada categoría. La cola juntada
219
- * («otros») queda al final. Es lo mismo que `order` en `chartFromPivot`, para un gráfico
220
- * que se armó de otra manera —una comparación, un diccionario—.
218
+ * Sorts the AXIS of an already built chart by what each category gives. The gathered tail
219
+ * («otros») stays last. It is the same as `order` in `chartFromPivot`, for a chart
220
+ * that was built another way —a comparison, a dictionary—.
221
221
  */
222
222
  export function orderChart(data, order) {
223
223
  if (order === undefined)
@@ -238,16 +238,16 @@ export function orderChart(data, order) {
238
238
  };
239
239
  }
240
240
  /**
241
- * EL PERÍODO ANTERIOR al lado del actual — el «comparar con» de Odoo.
241
+ * THE PREVIOUS PERIOD beside the current one — Odoo's «comparar con».
242
242
  *
243
- * Cada gráfico se arma por su lado (`chartFromPivot` sobre los registros de cada período)
244
- * y esto los junta en dos series: el actual y el anterior, que se dibuja callado. Lo que se
245
- * compara es lo que da cada categoría entera.
243
+ * Each chart is built on its own (`chartFromPivot` over each period's records)
244
+ * and this joins them into two series: the current and the previous, which is drawn quiet. What is
245
+ * compared is what each whole category gives.
246
246
  *
247
- * `by` dice cómo se encuentran: por CLAVE cuando el eje es una cosa —La Paz con La Paz— y
248
- * por POSICIÓN cuando es tiempo —el primer mes con el primer mes—, porque «2026-09» y
249
- * «2025-09» son claves distintas y lo que se compara es «el mismo momento del período».
250
- * Una categoría del anterior que no está en el actual no se dibuja: el eje es el de ahora.
247
+ * `by` says how they are matched: by KEY when the axis is a thing —La Paz with La Paz— and
248
+ * by POSITION when it is time —the first month with the first month—, because «2026-09» and
249
+ * «2025-09» are different keys and what is compared is «the same moment of the period».
250
+ * A category of the previous that is not in the current is not drawn: the axis is today's.
251
251
  */
252
252
  export function chartCompare(current, previous, labels, by = "key") {
253
253
  const whole = (data, at) => data.series.length === 1 ? (data.values[at]?.[0] ?? null) : (data.totals[at] ?? null);
@@ -271,8 +271,8 @@ export function chartCompare(current, previous, labels, by = "key") {
271
271
  };
272
272
  }
273
273
  /**
274
- * Un DICCIONARIO como gráfico: `{ "La Paz": 120, "Oruro": 40 }`, o sus pares. Es lo que
275
- * devuelve un endpoint de resumen, y no hace falta armarle un pivote.
274
+ * A DICTIONARY as a chart: `{ "La Paz": 120, "Oruro": 40 }`, or its pairs. It is what
275
+ * a summary endpoint returns, and there is no need to build a pivot for it.
276
276
  */
277
277
  export function chartFromRecord(entries, measure) {
278
278
  const pairs = Array.isArray(entries)