@sincpro/web-ui 2.0.0 → 2.2.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 (143) hide show
  1. package/README.md +45 -0
  2. package/dist/components/activity/Activity.d.ts +13 -14
  3. package/dist/components/activity/Activity.js +1 -1
  4. package/dist/components/activity/Messages.d.ts +5 -5
  5. package/dist/components/activity/Messages.js +8 -8
  6. package/dist/components/attachments/Attachments.d.ts +7 -1
  7. package/dist/components/attachments/Attachments.js +8 -2
  8. package/dist/components/board/Board.d.ts +32 -2
  9. package/dist/components/board/Board.js +27 -4
  10. package/dist/components/board/index.d.ts +1 -1
  11. package/dist/components/board/index.js +2 -1
  12. package/dist/components/form/Form.js +6 -6
  13. package/dist/components/form/index.js +2 -2
  14. package/dist/components/frame/FrameView.d.ts +5 -5
  15. package/dist/components/frame/FrameView.js +4 -4
  16. package/dist/components/listing/GroupingLevels.d.ts +22 -22
  17. package/dist/components/listing/GroupingLevels.js +9 -9
  18. package/dist/components/listing/Listing.d.ts +11 -11
  19. package/dist/components/listing/Listing.js +11 -11
  20. package/dist/components/listing/ListingBar.js +11 -11
  21. package/dist/components/listing/Row.d.ts +19 -19
  22. package/dist/components/listing/Row.js +27 -27
  23. package/dist/components/listing/SortMenu.d.ts +36 -36
  24. package/dist/components/listing/SortMenu.js +6 -6
  25. package/dist/components/listing/grouping.d.ts +16 -16
  26. package/dist/components/listing/grouping.js +6 -6
  27. package/dist/components/listing/index.js +1 -1
  28. package/dist/components/listing/modelColumns.d.ts +25 -25
  29. package/dist/components/listing/modelColumns.js +24 -24
  30. package/dist/components/listing/pages.js +4 -4
  31. package/dist/components/listing/set.d.ts +18 -18
  32. package/dist/components/navigation/NavigationTree.js +2 -2
  33. package/dist/components/navigation/index.js +2 -2
  34. package/dist/components/record/RecordSkeleton.js +7 -7
  35. package/dist/components/search/CriteriaBuilder.d.ts +22 -22
  36. package/dist/components/search/CriteriaBuilder.js +31 -31
  37. package/dist/components/search/CriteriaChips.d.ts +9 -9
  38. package/dist/components/search/CriteriaChips.js +12 -12
  39. package/dist/components/search/FilterBuilder.d.ts +67 -67
  40. package/dist/components/search/FilterBuilder.js +104 -104
  41. package/dist/components/search/JoinWord.d.ts +1 -1
  42. package/dist/components/search/JoinWord.js +14 -14
  43. package/dist/components/search/JsonEditor.d.ts +8 -8
  44. package/dist/components/search/JsonEditor.js +16 -16
  45. package/dist/components/search/SearchBar.d.ts +34 -34
  46. package/dist/components/search/SearchBar.js +140 -117
  47. package/dist/components/search/criteria.d.ts +61 -61
  48. package/dist/components/search/criteria.js +39 -39
  49. package/dist/components/search/datePeriods.d.ts +47 -48
  50. package/dist/components/search/datePeriods.js +29 -29
  51. package/dist/components/search/dateRanges.d.ts +27 -27
  52. package/dist/components/search/dateRanges.js +16 -16
  53. package/dist/components/search/index.js +13 -13
  54. package/dist/components/search/model.d.ts +28 -28
  55. package/dist/components/search/model.js +21 -21
  56. package/dist/components/search/query.d.ts +71 -71
  57. package/dist/components/search/query.js +119 -119
  58. package/dist/components/shell/AppFrame.d.ts +9 -2
  59. package/dist/components/shell/AppFrame.js +102 -14
  60. package/dist/components/shell/Sidebar.d.ts +34 -0
  61. package/dist/components/shell/Sidebar.js +32 -0
  62. package/dist/components/shell/TopBar.d.ts +2 -0
  63. package/dist/components/shell/TopBar.js +13 -9
  64. package/dist/components/shell/index.d.ts +2 -0
  65. package/dist/components/shell/index.js +5 -1
  66. package/dist/components/shell/sidebarDrawer.d.ts +26 -0
  67. package/dist/components/shell/sidebarDrawer.js +22 -0
  68. package/dist/foundations/calendar.d.ts +27 -27
  69. package/dist/foundations/calendar.js +72 -72
  70. package/dist/foundations/chart.d.ts +57 -57
  71. package/dist/foundations/chart.js +27 -27
  72. package/dist/foundations/copy.d.ts +109 -94
  73. package/dist/foundations/copy.es.js +10 -2
  74. package/dist/foundations/copy.js +10 -2
  75. package/dist/foundations/grouping.d.ts +175 -175
  76. package/dist/foundations/grouping.js +0 -0
  77. package/dist/foundations/index.d.ts +1 -1
  78. package/dist/foundations/index.js +21 -21
  79. package/dist/foundations/pivot.d.ts +133 -131
  80. package/dist/foundations/pivot.js +54 -54
  81. package/dist/foundations/pivotSheet.d.ts +36 -36
  82. package/dist/foundations/pivotSheet.js +0 -0
  83. package/dist/foundations/slots.d.ts +38 -38
  84. package/dist/foundations/slots.js +18 -18
  85. package/dist/foundations/sticky.d.ts +28 -28
  86. package/dist/foundations/sticky.js +59 -59
  87. package/dist/foundations/xlsx.d.ts +47 -47
  88. package/dist/foundations/xlsx.js +0 -0
  89. package/dist/primitives/block/Line.d.ts +4 -4
  90. package/dist/primitives/block/Line.js +28 -28
  91. package/dist/primitives/block/index.js +2 -2
  92. package/dist/primitives/cell/index.js +2 -2
  93. package/dist/primitives/choice/index.js +3 -3
  94. package/dist/primitives/date/Calendar.d.ts +7 -1
  95. package/dist/primitives/date/Calendar.js +13 -3
  96. package/dist/primitives/date/DatePicker.d.ts +4 -1
  97. package/dist/primitives/date/DatePicker.js +2 -2
  98. package/dist/primitives/date/index.js +3 -3
  99. package/dist/primitives/disclosure/index.js +1 -1
  100. package/dist/primitives/field/DropZone.d.ts +22 -3
  101. package/dist/primitives/field/DropZone.js +33 -12
  102. package/dist/primitives/menu/Menu.d.ts +10 -6
  103. package/dist/primitives/menu/Menu.js +4 -3
  104. package/dist/primitives/notice/Callout.d.ts +30 -30
  105. package/dist/primitives/notice/Callout.js +6 -6
  106. package/dist/primitives/overlay/index.js +3 -3
  107. package/dist/primitives/picker/Picker.d.ts +6 -0
  108. package/dist/primitives/picker/Picker.js +27 -4
  109. package/dist/primitives/picker/index.js +2 -2
  110. package/dist/primitives/table/DataTable.d.ts +32 -32
  111. package/dist/primitives/table/DataTable.js +24 -24
  112. package/dist/primitives/table/EditableTable.d.ts +10 -10
  113. package/dist/primitives/table/EditableTable.js +9 -9
  114. package/dist/primitives/table/ReportTable.js +7 -7
  115. package/dist/primitives/table/SheetTable.d.ts +13 -13
  116. package/dist/primitives/table/SheetTable.js +14 -14
  117. package/dist/primitives/table/Table.js +8 -8
  118. package/dist/primitives/tabs/Tabs.d.ts +46 -46
  119. package/dist/primitives/tabs/Tabs.js +4 -30
  120. package/dist/primitives/tag/Count.d.ts +23 -0
  121. package/dist/primitives/tag/Count.js +59 -0
  122. package/dist/primitives/tag/index.d.ts +1 -0
  123. package/dist/primitives/tag/index.js +5 -2
  124. package/dist/primitives/toolbar/index.js +1 -1
  125. package/dist/primitives/value/Copyable.d.ts +22 -22
  126. package/dist/primitives/value/Copyable.js +9 -9
  127. package/dist/primitives/value/Metric.d.ts +7 -2
  128. package/dist/primitives/value/Metric.js +12 -4
  129. package/dist/tokens.css +164 -57
  130. package/dist/views/list/List.d.ts +36 -36
  131. package/dist/views/list/List.js +19 -19
  132. package/dist/views/list/ListView.js +74 -74
  133. package/dist/views/list/columns.d.ts +10 -10
  134. package/dist/views/list/columns.js +10 -10
  135. package/dist/views/list/derive.d.ts +30 -30
  136. package/dist/views/list/derive.js +49 -49
  137. package/dist/views/list/index.js +2 -2
  138. package/dist/views/list/presentations.js +3 -3
  139. package/dist/views/list/types.d.ts +109 -109
  140. package/dist/views/record/Record.d.ts +14 -14
  141. package/dist/views/record/Record.js +24 -24
  142. package/dist/views/record/index.js +1 -1
  143. package/package.json +1 -1
@@ -92,15 +92,15 @@ const FEATURES = tableFeatures({
92
92
  aggregationFns,
93
93
  });
94
94
  /**
95
- * El agregado de una columna sobre un conjunto de filas.
95
+ * The aggregate of a column over a set of rows.
96
96
  *
97
- * Vive afuera del componente porque lo preguntan tres lugares: el pie de la
98
- * tabla, la banda de un montón en la planilla, y la línea de un informe armado
99
- * a partir de los montones. Tres implementaciones de «cuánto suma esto» es que
100
- * el pie diga un número y el montón otro.
97
+ * It lives outside the component because three places ask for it: the table's
98
+ * foot, a pile's band in the sheet, and the line of a report built
99
+ * from the piles. Three implementations of «how much does this add up to» means
100
+ * the foot says one number and the pile another.
101
101
  *
102
- * `null` cuando la columna no declaró agregado, no es numérica, o no hay ningún
103
- * número que sumar — que es distinto de sumar cero.
102
+ * `null` when the column declared no aggregate, is not numeric, or there is no
103
+ * number to add — which is not the same as adding zero.
104
104
  */
105
105
  export function aggregateOf(column, rows) {
106
106
  if (column.aggregate === undefined || column.numeric !== true)
@@ -214,22 +214,22 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
214
214
  id: c.id,
215
215
  header: c.header,
216
216
  enableSorting: c.sortable !== false,
217
- /* Ninguna columna agrupa. Lo que parte el conjunto son los NIVELES, y
218
- cada uno entra como una columna suya —abajo— que existe sólo para
219
- eso: nadie la dibuja y nadie la ordena. */
217
+ /* No column groups. What splits the set are the LEVELS, and
218
+ each one comes in as a column of its own —below— that exists only for
219
+ that: nobody draws it and nobody sorts it. */
220
220
  enableGrouping: false,
221
221
  aggregationFn: c.aggregate ?? "count",
222
222
  })),
223
- /* Una columna por NIVEL, no por campo. Es la única forma de que «por mes y
224
- adentro por día» sea dos cortes: con el id de la columna, los dos niveles
225
- de `registered_at` eran el mismo id repetido, y un mismo id no se puede
226
- agrupar dos veces.
223
+ /* One column per LEVEL, not per field. It is the only way for «by month and
224
+ inside it by day» to be two cuts: with the column's id, the two levels
225
+ of `registered_at` were the same id repeated, and one id cannot be
226
+ grouped twice.
227
227
 
228
- Y la clave la pone el nivel, no la columna: `value` es la clave de
229
- ORDEN —para una fecha, los milisegundos— y agrupar por ella deja un
230
- montón por instante, con «1789294903895» de rótulo. Acá entra la misma
231
- clave que arman las otras cinco presentaciones, así que los montones de
232
- la tabla son LOS MISMOS y lo plegado vale para todas. */
228
+ And the key is set by the level, not the column: `value` is the SORT
229
+ key —for a date, the milliseconds— and grouping by it leaves one
230
+ pile per instant, with «1789294903895» as its label. Here goes the same
231
+ key the other five presentations build, so the table's piles
232
+ are THE SAME ones and what is folded holds for all. */
233
233
  ...(levels ?? []).map((level) => helper.accessor((row) => level.keyOf(row), {
234
234
  id: level.id,
235
235
  header: level.label,
@@ -316,8 +316,8 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
316
316
  const key = pathKey(path);
317
317
  const depth = path.length - 1;
318
318
  const level = levels?.find((one) => one.id === row.groupingColumnId);
319
- /* La CLAVE del montón —la del motor— y el rótulo, que lo pone el nivel: son dos
320
- textos y sólo el segundo cambia con el idioma. */
319
+ /* The pile's KEY —the engine's— and the label, which the level sets: they are two
320
+ texts and only the second changes with the language. */
321
321
  const value = path[depth] ?? key;
322
322
  return {
323
323
  kind: "pile",
@@ -325,9 +325,9 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
325
325
  depth,
326
326
  level: level?.label,
327
327
  label: level === undefined ? value : level.labelOf(value),
328
- /* Las FILAS de adentro, no los subgrupos: `subRows` de un montón con niveles
329
- abajo son los montones del nivel siguiente, y contarlos decía «2» donde hay
330
- cuarenta filas. */
328
+ /* The rows INSIDE, not the subgroups: `subRows` of a pile with levels
329
+ below are the piles of the next level, and counting them said «2» where there are
330
+ forty rows. */
331
331
  count: row.getLeafRows().filter((leaf) => leaf.subRows.length === 0).length,
332
332
  detail: undefined,
333
333
  open: collapsed === undefined ? row.getIsExpanded() : !collapsed.includes(key),
@@ -167,9 +167,9 @@ export declare function EditableTable<T>({ rows, columns, getRowId, onChange, on
167
167
  * knows what adding up means in their domain —a percentage is not summed, it
168
168
  * is averaged. */
169
169
  totals, empty, grouping,
170
- /** El total de una columna DENTRO de un montón, ya formateado. Lo calcula quien
171
- * compone, por el mismo motivo que `totals`: sumar significa cosas distintas
172
- * según el dominio, y un porcentaje se promedia, no se suma. */
170
+ /** A column's total INSIDE a pile, already formatted. Whoever composes
171
+ * computes it, for the same reason as `totals`: adding up means different things
172
+ * depending on the domain, and a percentage is averaged, not added. */
173
173
  groupTotal, height, layout, onOpen, onDiscard, bands, adds, flag, onReorder, cellState, rowState, }: {
174
174
  rows: readonly T[];
175
175
  columns: readonly EditColumn<T>[];
@@ -188,14 +188,14 @@ groupTotal, height, layout, onOpen, onDiscard, bands, adds, flag, onReorder, cel
188
188
  totals?: readonly (ReactNode | null)[];
189
189
  empty?: string;
190
190
  /**
191
- * El agrupado, con el mismo contrato que el resto de las vistas de datos.
191
+ * Grouping, with the same contract as the rest of the data views.
192
192
  *
193
- * Editar y agrupar no se estorban: la fila que se edita sigue siendo una fila,
194
- * y el montón sólo decide dónde cae. Lo que no se hereda es el orden — las
195
- * filas de un montón quedan juntas, así que agregar una fila nueva la pone al
196
- * final de todo y no adentro del montón que estabas mirando, que es el
197
- * comportamiento honesto: todavía no tiene valor en el campo por el que se
198
- * agrupa.
193
+ * Editing and grouping do not get in each other's way: the row being edited is still a row,
194
+ * and the pile only decides where it lands. What is not inherited is the order — the
195
+ * rows of a pile stay together, so adding a new row puts it at the
196
+ * end of everything and not inside the pile you were looking at, which is the
197
+ * honest behaviour: it does not have a value yet in the field it is
198
+ * grouped by.
199
199
  */
200
200
  grouping?: Grouping<T>;
201
201
  groupTotal?: (column: EditColumn<T>, rows: readonly T[]) => ReactNode | null;
@@ -280,9 +280,9 @@ export function EditableTable({ rows, columns, getRowId, onChange, onRemove, onA
280
280
  * knows what adding up means in their domain —a percentage is not summed, it
281
281
  * is averaged. */
282
282
  totals, empty, grouping,
283
- /** El total de una columna DENTRO de un montón, ya formateado. Lo calcula quien
284
- * compone, por el mismo motivo que `totals`: sumar significa cosas distintas
285
- * según el dominio, y un porcentaje se promedia, no se suma. */
283
+ /** A column's total INSIDE a pile, already formatted. Whoever composes
284
+ * computes it, for the same reason as `totals`: adding up means different things
285
+ * depending on the domain, and a percentage is averaged, not added. */
286
286
  groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReorder, cellState, rowState, }) {
287
287
  const copy = useUiCopy();
288
288
  const bandOf = (row) => bands?.kind(row) ?? null;
@@ -367,8 +367,8 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
367
367
  const [arriving, setArriving] = useState(null);
368
368
  const addButton = useRef(null);
369
369
  const rowById = useMemo(() => new Map(rows.map((row) => [getRowId(row), row])), [rows, getRowId]);
370
- /* La secuencia que se dibuja: montones y filas intercalados. Sin agrupado, las
371
- filas tal cual — una tabla que no agrupa no paga nada por poder hacerlo. */
370
+ /* The sequence that gets drawn: piles and rows interleaved. Without grouping, the
371
+ rows as they are — a table that does not group pays nothing for being able to. */
372
372
  const drawn = useMemo(() => {
373
373
  const piles = pilesOf(rows, grouping);
374
374
  if (piles === null)
@@ -852,10 +852,10 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
852
852
  const inside = pile.piles.length === 0 ? pile.items : pileItems(pile.piles);
853
853
  return [
854
854
  gap,
855
- /* La banda respeta la cuadrícula: el rótulo en la primera
856
- columna y cada total bajo la suya. Un total en un rincón
857
- obliga a buscar de qué columna es; alineado no hay nada que
858
- buscar. */
855
+ /* The band respects the grid: the label in the first
856
+ column and each total under its own. A total in a corner
857
+ forces you to look for which column it belongs to; aligned there is nothing to
858
+ look for. */
859
859
  _jsxs("tr", { ...windowed, children: [reorderable ? _jsx("td", { className: "w-0 bg-ground" }) : null, columns.map((c, ci) => (_jsx("td", { className: `bg-ground text-meta ${cell} ${c.numeric === true ? "text-right tabular-nums" : ""}`, style: ci === 0 && pile.depth > 0
860
860
  ? {
861
861
  paddingLeft: `calc(var(--spacing-indent) * ${pile.depth} + 0.625rem)`,
@@ -97,12 +97,12 @@ defaultOpen, caption, height, }) {
97
97
  });
98
98
  }
99
99
  return (
100
- /* Misma decisión que las otras dos tablas, en el mismo lugar: con alto la
101
- caja scrollea y la pila arranca de cero adentro; sin alto y entrando, no
102
- hay caja y el encabezado se pega debajo de la barra de la lista. Antes
103
- esto era `overflow-auto` siempre, así que el encabezado heredaba el
104
- desplazamiento de la barra y quedaba empujado 68 px hacia adentro de su
105
- propia caja — banda en blanco arriba y títulos de columna cayendo entre
106
- las filas. */
100
+ /* Same decision as the other two tables, in the same place: with a height the
101
+ box scrolls and the stack starts from zero inside; without a height and fitting, there is no
102
+ box and the header sticks below the list's bar. This used
103
+ to be `overflow-auto` always, so the header inherited the
104
+ bar's offset and ended up pushed 68 px into its
105
+ own box — a blank band on top and column titles falling between
106
+ the rows. */
107
107
  _jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsxs("table", { className: "w-full border-collapse px-1", children: [caption === undefined ? null : (_jsx("caption", { className: `text-left text-meta text-muted ${byDensity(d, "px-3 pb-2", "px-2 pb-1.5")}`, children: caption })), _jsx("thead", { className: "sticky z-20 bg-ground", style: stickyTop, children: _jsxs("tr", { className: "border-b border-line-strong", children: [_jsx("th", { className: `sticky left-0 z-10 bg-ground text-left ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: _jsx("span", { className: "sr-only", children: copy.report.concept }) }), columns.map((c) => (_jsx("th", { scope: "col", className: `text-right ${HEADER_TEXT} ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: c.header }, c.id))), _jsx("td", { className: "w-0" })] }) }), _jsx("tbody", { children: rows.map((r) => (_jsx(ReportLine, { row: r, columns: columns, open: open, onToggle: toggle, compact: compact }, r.id))) })] }) }));
108
108
  }
@@ -31,16 +31,16 @@ note, height, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRo
31
31
  height?: number | "auto";
32
32
  rowLabel?: (row: number) => string;
33
33
  /**
34
- * Esta fila no es una fila: es la cabecera del montón que empieza acá.
34
+ * This row is not a row: it is the header of the pile that begins here.
35
35
  *
36
- * Agrupar sin perder la virtualización es esto — **una banda es una fila
37
- * más, de otra clase**. La alternativa era una planilla por montón, y eso
38
- * son N cuadrículas con N encabezados y N scrolls para un solo conjunto.
36
+ * Grouping without losing virtualisation is this — **a band is one more
37
+ * row, of another kind**. The alternative was one sheet per pile, and that is
38
+ * N grids with N headers and N scrolls for a single set.
39
39
  *
40
- * `depth` es cuán adentro está el montón. La planilla no puede recibir un
41
- * árbol —está virtualizada por índice, y un índice es una posición en una
42
- * secuencia—, así que la jerarquía la dice la sangría de cada banda y no el
43
- * anidamiento del marcado.
40
+ * `depth` is how deep the pile is. The sheet cannot take a
41
+ * tree —it is virtualised by index, and an index is a position in a
42
+ * sequence—, so the hierarchy is told by each band's indentation and not by the
43
+ * nesting of the markup.
44
44
  */
45
45
  band?: (row: number) => {
46
46
  field?: string;
@@ -49,12 +49,12 @@ note, height, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRo
49
49
  open: boolean;
50
50
  depth?: number;
51
51
  /**
52
- * Lo que el montón suma EN CADA COLUMNA, en la posición de esa columna.
52
+ * What the pile adds up IN EACH COLUMN, at that column's position.
53
53
  *
54
- * Una banda que pone su total en un rincón obliga a buscar a qué columna
55
- * corresponde el número. Alineado bajo su columna no hay nada que buscar:
56
- * la cuadrícula ya dice qué significa, que es para lo que existe una
57
- * cuadrícula. `null` en una columna que no suma — que es la mayoría.
54
+ * A band that puts its total in a corner forces you to look for which column
55
+ * the number belongs to. Aligned under its column there is nothing to look for:
56
+ * the grid already says what it means, which is what a
57
+ * grid is for. `null` in a column that does not add up — which is most of them.
58
58
  */
59
59
  total?: (column: SheetColumn, columnIndex: number) => string | number | null;
60
60
  } | undefined;
@@ -29,11 +29,11 @@ tone,
29
29
  note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRow, }) {
30
30
  const copy = useUiCopy();
31
31
  const labelOf = rowLabel ?? ((i) => (i + 1).toLocaleString(copy.locale));
32
- /* `"auto"` es para un conjunto que ya vino CORTADO —una página de ochenta— y
33
- deja de virtualizar de hecho: sin scroll propio, la ventana visible es la
34
- caja entera y se dibujan todas las filas. Para los datos crudos —donde son
35
- un millón— hay que declarar un alto, y ahí sí se dibujan las ~30 que se
36
- ven. Cuándo la caja es un contenedor de scroll lo decide `useScrollBox`. */
32
+ /* `"auto"` is for a set that already came CUT —a page of eighty— and
33
+ in effect stops virtualising: with no scroll of its own, the visible window is the
34
+ whole box and every row is drawn. For raw data —where there are
35
+ a million— a height must be declared, and then only the ~30 in
36
+ view are drawn. When the box is a scroll container is decided by `useScrollBox`. */
37
37
  const caja = useScrollBox(height === "auto" ? {} : { height });
38
38
  const v = useVirtualizer({
39
39
  count: rows,
@@ -173,16 +173,16 @@ note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, o
173
173
  }, children: [_jsxs("div", { className: "sticky z-20 flex border-b border-line-strong bg-ground", style: stickyTop, role: "row", children: [_jsx("div", { className: "sticky left-0 z-30 shrink-0 border-r border-line bg-ground", style: { width: ROW_LABEL_WIDTH } }), columns.map((c) => (_jsxs("div", { role: "columnheader", style: { width: c.width ?? WIDTH }, className: `flex shrink-0 flex-col justify-center gap-0.5 border-r border-line px-2.5 py-1.5 ${c.numeric === true ? "items-end" : "items-start"}`, children: [_jsx("span", { className: "max-w-full truncate text-meta font-medium text-ink", title: c.header, children: c.header }), c.type === undefined ? null : (_jsx("span", { className: "max-w-full truncate font-mono text-micro text-muted", children: c.type }))] }, c.id))), _jsx("div", { className: "flex-1" })] }), _jsx("div", { style: { height: v.getTotalSize(), position: "relative" }, children: items.map((item) => {
174
174
  const montón = band?.(item.index);
175
175
  if (montón !== undefined) {
176
- /* La banda queda pegada a la IZQUIERDA como el número de fila:
177
- con cuarenta columnas, un rótulo que se va con el scroll
178
- horizontal deja de decir en qué montón estás justo cuando
179
- más lejos estás de él. */
176
+ /* The band sticks to the LEFT like the row number:
177
+ with forty columns, a label that goes away with the horizontal
178
+ scroll stops saying which pile you are in just when
179
+ you are furthest from it. */
180
180
  return (
181
- /* La banda RESPETA la cuadrícula: rótulo en la columna fija de
182
- la izquierda, y después una celda por columna —vacía, salvo
183
- que esa columna sume algo—. Antes era un rótulo suelto que
184
- ignoraba las columnas, y entonces un total quedaba en un
185
- rincón sin decir de qué columna era. */
181
+ /* The band RESPECTS the grid: label in the fixed column on
182
+ the left, and then one cell per column —empty, unless
183
+ that column adds something up—. It used to be a loose label that
184
+ ignored the columns, and then a total sat in a
185
+ corner without saying which column it was. */
186
186
  _jsxs("div", { role: "row", "aria-rowindex": item.index + 1, className: "absolute top-0 left-0 flex w-full border-b border-line-strong bg-ground", style: { height: item.size, transform: `translateY(${item.start}px)` }, children: [_jsx("div", { role: "gridcell", className: "sticky left-0 z-10 shrink-0 border-r border-line bg-ground", style: { height: "100%", width: ROW_LABEL_WIDTH }, children: onBandToggle === undefined ? null : (_jsx("button", { type: "button", onClick: () => onBandToggle(item.index), "aria-expanded": montón.open, "aria-label": fillCopy(montón.open ? copy.report.close : copy.report.open, {
187
187
  name: montón.label,
188
188
  }), className: "flex h-full w-full min-w-0 items-center gap-1.5 px-2.5 text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary", style: montón.depth === undefined || montón.depth === 0
@@ -47,10 +47,10 @@ export function Table({ children,
47
47
  height, rowCount, }) {
48
48
  const caja = useScrollBox(height === undefined ? {} : { height });
49
49
  return (
50
- /* Cuándo esta caja es un contenedor de scroll y cuándo no lo decide
51
- `useScrollBox`: ahí vive el dilema entero y ahí vive su explicación. Las
52
- tres tablas del sistema lo resolvían con tres copias de la misma
53
- medición. */
50
+ /* When this box is a scroll container and when it is not is decided by
51
+ `useScrollBox`: the whole dilemma lives there, and so does its explanation. The
52
+ three tables of the system solved it with three copies of the same
53
+ measurement. */
54
54
  _jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsx("table", { "aria-rowcount": rowCount, className: "w-full border-separate border-spacing-0 px-1 text-left", children: children }) }));
55
55
  }
56
56
  /** The text of a column header, shared by every table of the family. Ink and semibold, not
@@ -58,10 +58,10 @@ height, rowCount, }) {
58
58
  export const HEADER_TEXT = "text-meta font-semibold whitespace-nowrap text-ink";
59
59
  export function THead({ children, rowIndex, }) {
60
60
  return (
61
- /* Se pega DEBAJO de lo que ya esté pegado —la barra de la aplicación y la
62
- de la lista— y no en `top: 0`, que lo metía atrás de las dos. Sin alto en
63
- `Table` el que scrollea es la página, y ahí la diferencia es justamente
64
- la que hacía desaparecer los nombres de columna. Ver `system/sticky.tsx`. */
61
+ /* It sticks BELOW whatever is already stuck —the application bar and the
62
+ list's— and not at `top: 0`, which tucked it behind both. Without a height on
63
+ `Table` the page is what scrolls, and there the difference is exactly
64
+ what made the column names disappear. See `system/sticky.tsx`. */
65
65
  _jsx("thead", { className: "sticky z-10 bg-ground", style: stickyTop, children: _jsx("tr", { "aria-rowindex": rowIndex, children: children }) }));
66
66
  }
67
67
  /** A column. If it gets a `sortKey`, it can be sorted.
@@ -2,78 +2,78 @@ import type { Tone } from "../../foundations/types.js";
2
2
  import type { LucideIcon } from "lucide-react";
3
3
  import { type ReactNode } from "react";
4
4
  /**
5
- * UNA TIRA DE PESTAÑAS. La misma en todo el sistema.
5
+ * A STRIP OF TABS. The same across the whole system.
6
6
  *
7
- * Context: esto vivía adentro del encabezado del registro y se llamaba
8
- * `Aspects`, así que la actividad —que necesita exactamente lo mismo— no podía
9
- * usarlo: un contexto no importa de otro contexto. El resultado era una tira de
10
- * pestañas de segunda mano, con el activo marcado de otra manera, en la misma
11
- * pantalla que la buena.
7
+ * Context: this lived inside the record's header and was called
8
+ * `Aspects`, so the activity —which needs exactly the same— could not
9
+ * use it: a context does not import from another context. The result was a second-hand
10
+ * strip of tabs, with the active one marked differently, on the same
11
+ * screen as the good one.
12
12
  *
13
- * Es una primitiva porque no sabe qué está separando: las caras de un registro,
14
- * las dos fuentes de una historia, o lo que venga.
13
+ * It is a primitive because it does not know what it is separating: a record's
14
+ * faces, the two sources of a history, or whatever comes.
15
15
  *
16
- * ── Por qué el activo es una PESTAÑA de carpeta ─────────────────────
16
+ * ── Why the active one is a folder TAB ──────────────────────────────
17
17
  *
18
- * Y no un subrayado. Un subrayado dice «esto está elegido»; una pestaña que sale
19
- * del borde y tapa la línea dice «esto está ABIERTO y lo de abajo es su
20
- * contenido», que es la relación real. La diferencia importa cuando hay tres y
21
- * el contenido de abajo no cambia de forma al cambiar de una a otra.
18
+ * And not an underline. An underline says «this is chosen»; a tab that sticks out
19
+ * of the border and covers the line says «this is OPEN and what is below is its
20
+ * content», which is the real relationship. The difference matters when there are three and
21
+ * the content below does not change shape when switching from one to another.
22
22
  *
23
- * ── El contador apagado en cero ─────────────────────────────────────
23
+ * ── The counter muted at zero ───────────────────────────────────────
24
24
  *
25
- * Un cero se dibuja, y apagado. Esconderlo obliga a abrir la pestaña para
26
- * descubrir que está vacía; pintarlo como los demás la hace parecer que tiene
27
- * algo. «No hay ninguna» es información y se dice.
25
+ * A zero is drawn, and muted. Hiding it forces you to open the tab to
26
+ * find out it is empty; painting it like the others makes it look as if it has
27
+ * something. «There are none» is information and it is said.
28
28
  *
29
- * ── El contador y la NOTIFICACIÓN son dos cosas ─────────────────────
29
+ * ── The counter and the NOTIFICATION are two things ─────────────────
30
30
  *
31
- * El contador dice CUÁNTAS cosas hay detrás, y es neutro: «pagos 0» es una
32
- * respuesta tan válida como «pagos 5». La notificación dice que algo de ahí
33
- * PIDE que lo mires —falló, cambió, llegó— y por eso tiene color y por eso un
34
- * cero no se dibuja: no hay nada que pedir.
31
+ * The counter says HOW MANY things are behind, and is neutral: «pagos 0» is an
32
+ * answer as valid as «pagos 5». The notification says that something in there
33
+ * ASKS you to look —it failed, changed, arrived— and that is why it has colour and why a
34
+ * zero is not drawn: there is nothing to ask.
35
35
  *
36
- * Confundirlos se ve así: una pestaña con «3» al lado y nadie sabe si son tres
37
- * cosas o tres problemas. Son dos marcas porque son dos preguntas.
36
+ * Confusing them looks like this: a tab with «3» beside it and nobody knows whether it is three
37
+ * things or three problems. They are two marks because they are two questions.
38
38
  */
39
39
  /**
40
- * ALGO DE ESTA PESTAÑA PIDE ATENCIÓN.
40
+ * SOMETHING IN THIS TAB ASKS FOR ATTENTION.
41
41
  *
42
- * No es un conteo: un conteo dice cuántas cosas hay y esto dice que hay algo que
43
- * mirar. Por eso tiene color, por eso no se dibuja en cero, y por eso puede
44
- * convivir con el contador — «pagos 4 ⬤» es cuatro cosas, una de ellas
45
- * rechazada.
42
+ * It is not a count: a count says how many things there are and this says there is something to
43
+ * look at. That is why it has colour, why it is not drawn at zero, and why it can
44
+ * live alongside the counter — «pagos 4 ⬤» is four things, one of them
45
+ * rejected.
46
46
  */
47
47
  export type TabNotice = {
48
48
  /**
49
- * Qué es lo que pide atención, en la voz del producto: «3 sin leer», «la
49
+ * What asks for attention, in the product's voice: «3 sin leer», «la
50
50
  * factura no se pudo enviar».
51
51
  *
52
- * Obligatorio, y por la misma razón que en `StatusDot`: un punto de color sin
53
- * su palabra al lado obliga a aprender una leyenda que no está escrita en
54
- * ningún lado, y no le dice nada a quien no distingue el rojo del verde. Acá
55
- * la marca acelera el barrido y la palabra informa — se lee al pasar por
56
- * encima y la lee un lector de pantalla.
52
+ * Required, and for the same reason as in `StatusDot`: a coloured dot without
53
+ * its word beside it forces learning a legend that is written nowhere,
54
+ * and tells nothing to someone who cannot tell red from green. Here
55
+ * the mark speeds up scanning and the word informs — it is read on hover
56
+ * and a screen reader reads it.
57
57
  */
58
58
  label: string;
59
- /** Cuántas cosas lo piden. Sin esto es un punto, que es lo que se pone cuando
60
- * llegó algo nuevo y contarlo no agrega nada. Un `0` no dibuja nada: no hay
61
- * nada que pedir. */
59
+ /** How many things ask for it. Without this it is a dot, which is what is used when
60
+ * something new arrived and counting it adds nothing. A `0` draws nothing: there is
61
+ * nothing to ask. */
62
62
  count?: number;
63
- /** De qué clase: `bad` algo falló, `warn` algo avisa, `accent` o `info` algo
64
- * llegó. Sin esto, `bad` — que es el caso por el que esto existe. */
63
+ /** Of what kind: `bad` something failed, `warn` something warns, `accent` or `info` something
64
+ * arrived. Without this, `bad` — which is the case this exists for. */
65
65
  tone?: Tone;
66
66
  };
67
67
  export type TabItem = {
68
68
  id: string;
69
69
  label: string;
70
- /** La marca de la pestaña. Con tres o más, el ícono es lo que se reconoce sin
71
- * leer — y en una tira angosta es lo único que sobrevive al truncado. */
70
+ /** The tab's mark. With three or more, the icon is what is recognised without
71
+ * reading — and in a narrow strip it is the only thing that survives truncation. */
72
72
  icon?: LucideIcon;
73
- /** Cuántas cosas hay detrás. `undefined` = no se cuenta; `0` se dibuja
74
- * apagado, que es distinto de no contar. */
73
+ /** How many things are behind. `undefined` = not counted; `0` is drawn
74
+ * muted, which is different from not counting. */
75
75
  count?: number;
76
- /** Que algo de acá pide que lo mires. Aparte del contador: ver `TabNotice`. */
76
+ /** That something in here asks you to look. Apart from the counter: see `TabNotice`. */
77
77
  notice?: TabNotice;
78
78
  };
79
79
  /**
@@ -104,6 +104,6 @@ export declare function Tabs({ tabs, current, onSelect, label, }: {
104
104
  tabs: readonly TabItem[];
105
105
  current: string;
106
106
  onSelect?: (id: string) => void;
107
- /** El rótulo accesible de la tira. Sin esto, «las caras del registro». */
107
+ /** The strip's accessible label. Without this, «las caras del registro». */
108
108
  label?: string;
109
109
  }): import("react").JSX.Element;
@@ -1,26 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useUiCopy } from "../../foundations/copy.js";
4
+ import { Count } from "../tag/Count.js";
4
5
  import { createContext, useContext, useId, useRef, } from "react";
5
- /* El color de la notificación. Estático y en una tabla porque Tailwind no puede
6
- componer una clase con un pedazo variable: `bg-${tone}/12` no existe en la
7
- hoja. */
8
- const NOTICE_TONE = {
9
- neutral: "bg-ink/8 text-muted",
10
- info: "bg-info/12 text-info",
11
- good: "bg-good/12 text-good",
12
- warn: "bg-warn/14 text-warn",
13
- bad: "bg-bad/12 text-bad",
14
- accent: "bg-accent/14 text-accent",
15
- };
16
- const NOTICE_DOT = {
17
- neutral: "bg-muted",
18
- info: "bg-info",
19
- good: "bg-good",
20
- warn: "bg-warn",
21
- bad: "bg-bad",
22
- accent: "bg-accent",
23
- };
24
6
  /**
25
7
  * The strip only: what each tab opens is drawn by whoever uses it (`Record`, `Activity`).
26
8
  *
@@ -89,22 +71,14 @@ export function Tabs({ tabs, current, onSelect, label, }) {
89
71
  };
90
72
  return (_jsx("div", { ref: strip, role: "tablist", "aria-label": label ?? copy.record.faces, onKeyDown: onKeyDown, className: "flex min-w-0 flex-wrap items-end gap-1", children: tabs.map((a) => {
91
73
  const Icon = a.icon;
92
- const empty = a.count === 0;
93
- /* Un cero no pide nada, así que no se dibuja. Es la diferencia con el
94
- contador, donde «0» es una respuesta. */
74
+ /* A zero asks for nothing, so it is not drawn. That is the difference from the
75
+ counter, where «0» is an answer. */
95
76
  const notice = a.notice?.count === 0 ? undefined : a.notice;
96
77
  const isSelected = a.id === current;
97
78
  return (_jsx("button", { type: "button", role: "tab", "data-tab": a.id, "aria-selected": isSelected, tabIndex: isSelected ? 0 : -1, ...(base === null
98
79
  ? {}
99
80
  : { id: tabIdOf(base, a.id), "aria-controls": panelIdOf(base, a.id) }), onClick: () => onSelect?.(a.id), className: `inline-flex shrink-0 cursor-default items-center px-3 py-2 text-meta outline-0 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${isSelected
100
81
  ? "-mb-px rounded-t-control border border-b-0 border-line-strong bg-surface font-medium text-ink"
101
- : "border border-transparent text-muted hover:text-ink"}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.count === undefined ? null : (_jsx("span", { className: `rounded-pill px-1.5 text-micro tabular-nums ${empty
102
- ? "bg-ink/5 text-muted"
103
- : isSelected
104
- ? "bg-ink/8 text-ink"
105
- : "bg-ink/8 text-muted"}`, children: a.count.toLocaleString(copy.locale) })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : notice.count === undefined ? (
106
- /* Sin número, un punto. La palabra no se dibuja pero está: en el
107
- `title` y en el nombre accesible de la pestaña. */
108
- _jsx("span", { className: `size-1.5 shrink-0 rounded-pill ${NOTICE_DOT[notice.tone ?? "bad"]}`, "aria-hidden": true })) : (_jsx("span", { className: `rounded-pill px-1.5 text-micro font-medium tabular-nums ${NOTICE_TONE[notice.tone ?? "bad"]}`, "aria-hidden": true, children: notice.count.toLocaleString(copy.locale) }))] }) }, a.id));
82
+ : "border border-transparent text-muted hover:text-ink"}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.count === undefined ? null : (_jsx(Count, { value: a.count, showZero: true, current: isSelected })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : (_jsx(Count, { ...(notice.count === undefined ? {} : { value: notice.count }), tone: notice.tone ?? "bad", "aria-hidden": true }))] }) }, a.id));
109
83
  }) }));
110
84
  }
@@ -0,0 +1,23 @@
1
+ import type { Surface, Tone } from "../../foundations/types.js";
2
+ export type CountProps = {
3
+ /** How many. Without it the count is a dot: something is there, not counted. */
4
+ value?: number;
5
+ /** `neutral` counts; any other tone says that something asks for attention. */
6
+ tone?: Tone;
7
+ /** Filled: the badge over an icon (a bell, a cart), which has to read on its own. */
8
+ solid?: boolean;
9
+ /** Past this it reads «99+». Without it every number is written in full. */
10
+ max?: number;
11
+ /** Draw the zero, fainter: where «0» is an answer and not noise (a tab). */
12
+ showZero?: boolean;
13
+ /** The thing it counts is the current one — the count takes its host's colour. */
14
+ current?: boolean;
15
+ surface?: Surface;
16
+ /** When the host already says the number in its name (`aria-label`), the count is only
17
+ * seen: hidden from assistive technology so it is not read twice. */
18
+ "aria-hidden"?: boolean;
19
+ };
20
+ /** The text of a count: formatted for the locale, and «99+» past `max`. Exported for the
21
+ * hosts that also need it in words — a button's `aria-label`, a `title`. */
22
+ export declare function countText(value: number, format: (n: number) => string, max?: number): string;
23
+ export declare function Count({ value, tone, solid, max, showZero, current, surface, "aria-hidden": hidden, }: CountProps): import("react").JSX.Element | null;