@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
@@ -2,13 +2,13 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { ModelCell } from "./modelCells.js";
3
3
  import { fieldLabel, isNumericType, } from "../search/model.js";
4
4
  import { formatDuration } from "../../primitives/field/duration.js";
5
- /** Los campos que las columnas declaradas ya contestan.
5
+ /** The fields the declared columns already answer.
6
6
  *
7
7
  * in [{id:"rows", field:"row_count"}, {id:"name"}]
8
8
  * out Set {"row_count", "name"}
9
9
  *
10
- * El `id` cuenta como reclamo cuando coincide con el nombre del campo: la
11
- * mayoría de las columnas se llaman como lo que muestran. */
10
+ * The `id` counts as a claim when it matches the field's name: most
11
+ * columns are named after what they show. */
12
12
  export function claimedFields(columns) {
13
13
  const claimed = new Set();
14
14
  for (const column of columns) {
@@ -18,17 +18,17 @@ export function claimedFields(columns) {
18
18
  }
19
19
  return claimed;
20
20
  }
21
- /** Un valor del registro, en algo que una celda pueda ordenar y dibujar.
21
+ /** A record value, into something a cell can sort and draw.
22
22
  *
23
- * in ["edad","sexo"] un `text[]`
23
+ * in ["edad","sexo"] a `text[]`
24
24
  * out "edad, sexo"
25
- * in [] una lista vacía no es un texto vacío
26
- * out null la tabla dibuja «—»
25
+ * in [] an empty list is not an empty text
26
+ * out null the table draws «—»
27
27
  * in "2026-09-13T04:17:00"
28
28
  * out "2026-09-13T04:17:00"
29
29
  *
30
- * Las fechas se dejan como vienen —ISO— porque en ISO el orden alfabético ES
31
- * el cronológico, y así la columna ordena bien sin parsear nada. */
30
+ * Dates are left as they come —ISO— because in ISO alphabetical order IS
31
+ * chronological, and so the column sorts well without parsing anything. */
32
32
  export function readModelValue(raw) {
33
33
  if (raw === null || raw === undefined)
34
34
  return null;
@@ -71,8 +71,8 @@ export function modelCellKind(type) {
71
71
  return "number";
72
72
  return KIND_OF_TYPE[type.toLowerCase()] ?? "text";
73
73
  }
74
- /** Cuánto ancho merece un campo, por su tipo. Una huella son 64 caracteres y
75
- * una cuenta son seis: darles el mismo ancho arruina las dos. */
74
+ /** How much width a field deserves, by its type. A fingerprint is 64 characters and
75
+ * an account is six: giving them the same width ruins both. */
76
76
  function widthFor(kind) {
77
77
  if (kind === "number" || kind === "duration")
78
78
  return 120;
@@ -83,23 +83,23 @@ function widthFor(kind) {
83
83
  return 260;
84
84
  }
85
85
  /**
86
- * Las columnas declaradas, más una por cada campo del modelo que ninguna
87
- * contestaba.
86
+ * The declared columns, plus one for each model field that none
87
+ * answered.
88
88
  *
89
- * in model el `model_meta_data` de `account.move` — 12 campos
90
- * in declared 6 columnas escritas a mano en la vista
91
- * out las 6, y detrás `journal_id`, `currency_id`, `invoice_origin`,
89
+ * in model the `model_meta_data` of `account.move` — 12 fields
90
+ * in declared 6 columns written by hand in the view
91
+ * out the 6, and behind them `journal_id`, `currency_id`, `invoice_origin`,
92
92
  * `payment_reference`, `fiscal_position_id`, `company_id`,
93
- * `move_type`, todas apagadas
93
+ * `move_type`, all switched off
94
94
  *
95
- * El rótulo de las agregadas sale de `model.translations` en el idioma pedido —el mismo
96
- * `translations()` que el modelo publica para todo lo demás—, con el `default` que ese mismo
97
- * modelo declaró si el idioma no está, y el nombre del campo tal cual sólo si el modelo no
98
- * dijo ninguna palabra sobre él. Nunca puede desincronizarse con el motor porque sale de la
99
- * MISMA respuesta que nombra el campo — a diferencia de un diccionario mantenido acá.
95
+ * The label of the added ones comes from `model.translations` in the requested language —the same
96
+ * `translations()` the model publishes for everything else—, with the `default` that same
97
+ * model declared if the language is missing, and the field's name as is only if the model
98
+ * said no word about it. It can never get out of sync with the engine because it comes from the
99
+ * SAME answer that names the field — unlike a dictionary maintained here.
100
100
  *
101
- * `model === null` —todavía no llegó la definición— devuelve las declaradas sin
102
- * tocar, que es exactamente lo que había antes.
101
+ * `model === null` —the definition has not arrived yet— returns the declared ones
102
+ * untouched, which is exactly what there was before.
103
103
  */
104
104
  export function columnsFromModel(declared, model, locale = "default") {
105
105
  if (model === null || model === undefined)
@@ -47,10 +47,10 @@ export function usePagination(items, options = {}) {
47
47
  setPageSize(clampSize(next));
48
48
  setPage(1);
49
49
  },
50
- /* Se mueve desde `current` y no desde `page`, que es el que puede haber
51
- quedado alto: si estabas en la 3 y un filtro dejó dos páginas, `page`
52
- sigue en 3 mientras se muestra la 2, y `p - 1` volvía a 2 — o sea que
53
- «anterior» no hacía nada hasta el segundo clic. */
50
+ /* It moves from `current` and not from `page`, which may have been left
51
+ too high: if you were on 3 and a filter left two pages, `page` stays
52
+ at 3 while 2 is shown, and `p - 1` went back to 2 — so «previous»
53
+ did nothing until the second click. */
54
54
  ...(current > 1 ? { onPrev: () => setPage(current - 1) } : {}),
55
55
  ...(current < pages ? { onNext: () => setPage(current + 1) } : {}),
56
56
  },
@@ -14,26 +14,26 @@ import { type Pages } from "./pages.js";
14
14
  * reset the page size). Uncontrolled when the screen is the only owner.
15
15
  */
16
16
  /**
17
- * Las maneras de mirar un conjunto. **Vive acá y no en el arquetipo** porque
18
- * son dos los que preguntan lo mismo —una lista y un marco— y la definición
19
- * tiene que ser una sola.
17
+ * The ways of looking at a set. **It lives here and not in the archetype** because
18
+ * two of them ask the same thing —a list and a frame— and the definition
19
+ * has to be only one.
20
20
  *
21
- * Era dos: `ListPresent` en `archetype/ListView.tsx` y esta copia. Mientras las
22
- * dos decían `rows | table | board` nadie lo notaba; agregar `sheet` a una dejó
23
- * cuatro vistas sin compilar, que es exactamente lo que pasa cuando la misma
24
- * idea está escrita dos veces.
21
+ * There were two: `ListPresent` in `archetype/ListView.tsx` and this copy. While the
22
+ * two said `rows | table | board` nobody noticed; adding `sheet` to one left
23
+ * four views not compiling, which is exactly what happens when the same
24
+ * idea is written twice.
25
25
  *
26
- * rows / board no hay columnas: nombre, fichas y meta.
27
- * table las columnas las DECLARA el código.
28
- * sheet las columnas salen del ARCHIVO — puede haber cuarenta y un
29
- * millón de filas, así que va virtualizada.
30
- * report columnas de período y filas en JERARQUÍA que termina en
31
- * totales. No se ordena: el orden ES el informe.
32
- * pivot dos EJES a la vez. Una fila es un montón y una columna
33
- * también; lo que se lee está en el cruce. Tampoco se
34
- * ordena: el orden de cada eje es el de sus claves.
35
- * chart el mismo pivote, dibujado: barras, líneas o torta. El
36
- * primer agrupado es el eje y el segundo, las series.
26
+ * rows / board no columns: name, cards and meta.
27
+ * table the columns are DECLARED by the code.
28
+ * sheet the columns come from the FILE — there may be forty-one
29
+ * million rows, so it is virtualised.
30
+ * report period columns and rows in a HIERARCHY that ends in
31
+ * totals. It is not sorted: the order IS the report.
32
+ * pivot two AXES at once. A row is a heap and so is a column;
33
+ * what is read is at the crossing. It is not
34
+ * sorted either: the order of each axis is that of its keys.
35
+ * chart the same pivot, drawn: bars, lines or pie. The
36
+ * first grouping is the axis and the second, the series.
37
37
  */
38
38
  export type BuiltInPresent = "rows" | "table" | "board" | "sheet" | "report" | "pivot" | "chart" | "calendar" | "gantt" | "timeline";
39
39
  /** A presentation of a list: one the package draws, or the `id` of a `List.Present` the
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { AriaLocale } from "../../foundations/aria.js";
4
4
  import { useUiCopy } from "../../foundations/copy.js";
5
5
  import { focusRing, tv } from "../../foundations/variants.js";
6
+ import { Count } from "../../primitives/tag/Count.js";
6
7
  import { ChevronRight } from "lucide-react";
7
8
  import { useMemo } from "react";
8
9
  import { Button as AriaButton, Link, NavigationTree as AriaNavigationTree, NavigationTreeItem as AriaNavigationTreeItem, NavigationTreeItemContent, RouterProvider, } from "react-aria-components";
@@ -54,7 +55,6 @@ function pathTo(items, id) {
54
55
  */
55
56
  export function NavigationTree({ items, current, onNavigate, defaultExpanded = [], label, }) {
56
57
  const copy = useUiCopy();
57
- const number = useMemo(() => new Intl.NumberFormat(copy.locale), [copy.locale]);
58
58
  const expanded = useMemo(() => [...new Set([...defaultExpanded, ...pathTo(items, current)])],
59
59
  // The initial state only: React Aria owns the expansion after the first render.
60
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -73,7 +73,7 @@ export function NavigationTree({ items, current, onNavigate, defaultExpanded = [
73
73
  : undefined;
74
74
  return (_jsxs(AriaNavigationTreeItem, { id: item.id, textValue: item.label, ...(module ? {} : { href: item.id }), className: ({ isCurrent, isFocusVisible }) => row({ isCurrent, isFocusVisible }), children: [_jsx(NavigationTreeItemContent, { children: ({ isCurrent, isCurrentAncestor, isExpanded }) => (_jsxs(_Fragment, { children: [isCurrent ? _jsx("span", { "aria-hidden": true, className: marker }) : null, _jsxs(Link, { className: link({ isModule: module }), style: indent, children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-md) shrink-0 ${isCurrent || (isCurrentAncestor && !isExpanded)
75
75
  ? "text-primary"
76
- : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: `min-w-0 flex-1 truncate ${isCurrentAncestor && !isExpanded ? "text-primary" : ""}`, children: item.label }), item.count === undefined || item.count <= 0 ? null : (_jsx("span", { className: `shrink-0 rounded-pill px-1.5 text-micro leading-normal font-medium tabular-nums ${isCurrent ? "bg-primary/12 text-primary" : "bg-ink/6 text-muted"}`, children: number.format(item.count) }))] }), module ? (_jsx(AriaButton, { slot: "chevron", className: ({ isFocusVisible }) => chevronButton({ isFocusVisible }), children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-quick) ease-(--ease-out) ${isExpanded ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }) })) : null] })) }), children.map((child) => render(child, level + 1))] }, item.id));
76
+ : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: `min-w-0 flex-1 truncate ${isCurrentAncestor && !isExpanded ? "text-primary" : ""}`, children: item.label }), item.count === undefined ? null : (_jsx(Count, { value: item.count, current: isCurrent }))] }), module ? (_jsx(AriaButton, { slot: "chevron", className: ({ isFocusVisible }) => chevronButton({ isFocusVisible }), children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-quick) ease-(--ease-out) ${isExpanded ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }) })) : null] })) }), children.map((child) => render(child, level + 1))] }, item.id));
77
77
  };
78
78
  return (_jsx(AriaLocale, { children: _jsx(RouterProvider, { navigate: (id) => onNavigate?.(id), useHref: (id) => `#${id}`, children: _jsx(AriaNavigationTree, { "aria-label": label ?? copy.shell.menus, selectedRoute: current ?? null, defaultExpandedKeys: expanded, className: "flex w-full min-w-0 flex-col gap-px p-2 outline-0", children: items.map((item) => render(item, 1)) }) }) }));
79
79
  }
@@ -1,3 +1,3 @@
1
- /* LA NAVEGACIÓN — el árbol lateral de una aplicación. La paleta de comandos (⌘K) es del
2
- espacio de trabajo (composer), no de acá. */
1
+ /* NAVIGATION — an application's side tree. The command palette (⌘K) belongs to the
2
+ workspace (composer), not here. */
3
3
  export { NavigationTree, } from "./NavigationTree.js";
@@ -2,15 +2,15 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { byDensity, useDensity } from "../../foundations/density.js";
4
4
  /* ==================================================================== *
5
- * LA FICHA, MIENTRAS LLEGA.
5
+ * THE RECORD'S SHEET, WHILE IT ARRIVES.
6
6
  *
7
- * Factura y cliente contestaban la espera con `Empty`: «Cargando…» en el
8
- * medio de la página. Eso es la frase de «no hay nada», y el registro sí
9
- * está — todavía no llegó. La silueta es la de la ficha: el riel, el nombre,
10
- * los cuatro hechos, las solapas y el cuerpo. Cuando el registro aparece,
11
- * cae en el mismo lugar.
7
+ * Invoice and customer answered the wait with `Empty`: «Cargando…» in the
8
+ * middle of the page. That is the phrase for «there is nothing», and the record
9
+ * does exist — it has not arrived yet. The silhouette is the sheet's: the rail, the name,
10
+ * the four facts, the tabs and the body. When the record appears,
11
+ * it lands in the same place.
12
12
  *
13
- * Sin brillo. Un pulso ya quiere decir «este estado está vivo».
13
+ * No shimmer. A pulse already means «this state is alive».
14
14
  * ==================================================================== */
15
15
  const HECHOS = ["w-16", "w-12", "w-20", "w-24"];
16
16
  const SOLAPAS = ["w-14", "w-16", "w-20"];
@@ -4,23 +4,23 @@ export interface BuiltSort {
4
4
  field: string;
5
5
  descending?: boolean;
6
6
  }
7
- /** Un nivel de agrupado, como el `Level` de criteria: el campo y, si es fecha, el grano. */
7
+ /** A grouping level, like criteria's `Level`: the field and, if it is a date, the grain. */
8
8
  export interface BuiltLevel {
9
9
  field: string;
10
10
  grain?: string | null;
11
11
  }
12
12
  /**
13
- * Un número que cada montón contesta, como el `Measure` de criteria:
14
- * `{ function: "sum", field: "row_count" }`. Partes con nombre y no un par, igual que una
15
- * condición viaja como `{field, operator, value}`.
13
+ * A number that each heap answers, like criteria's `Measure`:
14
+ * `{ function: "sum", field: "row_count" }`. Named parts and not a pair, just as a
15
+ * condition travels as `{field, operator, value}`.
16
16
  */
17
17
  export interface BuiltMeasure {
18
18
  function: string;
19
19
  field: string;
20
- /** Lo que la función necesita además del campo. Sólo `percentile`: la fracción del corte. */
20
+ /** What the function needs besides the field. Only `percentile`: the cut's fraction. */
21
21
  argument?: number;
22
22
  }
23
- /** Desde dónde empieza una página de montones — la misma forma que la paginación de filas. */
23
+ /** From where a page of heaps starts — the same shape as the rows' pagination. */
24
24
  export type BuiltPageStrategy = {
25
25
  token: string | null;
26
26
  } | {
@@ -30,23 +30,23 @@ export interface BuiltGroupPagination {
30
30
  limit?: number;
31
31
  strategy?: BuiltPageStrategy;
32
32
  }
33
- /** El agrupado tal como lo declara `@sincpro/criteria` 2.0, clave por clave. */
33
+ /** The grouping as `@sincpro/criteria` 2.0 declares it, key by key. */
34
34
  export interface BuiltGrouping {
35
- /** Los niveles, en orden: no se suman, se anidan. */
35
+ /** The levels, in order: they are not added, they nest. */
36
36
  group_by?: BuiltLevel[];
37
- /** Los números que cada montón contesta, cada uno bajo un nombre elegido. */
37
+ /** The numbers each heap answers, each under a chosen name. */
38
38
  measures?: Record<string, BuiltMeasure>;
39
- /** Un filtro sobre lo que los montones midieron, no sobre las filas: `count > 10`. Los
40
- * nombres que admite son los de `measures`, más `"count"`. */
39
+ /** A filter on what the heaps measured, not on the rows: `count > 10`. The
40
+ * names it admits are those of `measures`, plus `"count"`. */
41
41
  where_measures?: BuiltFilter;
42
- /** En qué orden vuelven los montones: por el propio campo del nivel, por un nombre de
43
- * `measures`, o por `count`. */
42
+ /** In what order the heaps come back: by the level's own field, by a name from
43
+ * `measures`, or by `count`. */
44
44
  order?: BuiltSort[];
45
- /** Cuántos montones del primer nivel vuelven, y desde dónde. Ausente es todos. */
45
+ /** How many heaps of the first level come back, and from where. Absent is all of them. */
46
46
  pagination?: BuiltGroupPagination;
47
47
  }
48
- /** La criteria tal como la declara el motor. Es lo que este componente arma y devuelve, y lo
49
- * que el editor de código muestra. */
48
+ /** The criteria as the engine declares it. It is what this component builds and returns, and what
49
+ * the code editor shows. */
50
50
  export interface BuiltCriteria {
51
51
  selection?: BuiltFilter;
52
52
  order?: BuiltSort[];
@@ -55,15 +55,15 @@ export interface BuiltCriteria {
55
55
  }
56
56
  export declare function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }: {
57
57
  model: ModelDefinition;
58
- /** La criteria que ya estaba puesta. Reabrir tiene que seguir donde quedó. */
58
+ /** The criteria that was already set. Reopening has to continue where it was left. */
59
59
  initial?: BuiltCriteria;
60
60
  /**
61
- * El campo de la condición que hay que mostrar primero: la ficha que alguien
62
- * tocó en la barra.
61
+ * The condition's field to show first: the chip somebody
62
+ * touched in the bar.
63
63
  *
64
- * Sin esto, tocar un recorte abría el constructor en la regla uno y había que
65
- * buscar entre doce la que uno venía mirando — que es la manera más rápida de
66
- * editar la equivocada.
64
+ * Without this, touching a cut opened the builder on rule one and you had to
65
+ * search among twelve for the one you were looking at — which is the quickest way to
66
+ * edit the wrong one.
67
67
  */
68
68
  focus?: string;
69
69
  onApply: (criteria: BuiltCriteria | undefined) => void;
@@ -12,22 +12,22 @@ import { Tags } from "../../primitives/tag/Tags.js";
12
12
  import { Plus, Trash2 } from "lucide-react";
13
13
  import { Fragment, useMemo, useState } from "react";
14
14
  /**
15
- * Los cortes de una fecha, de GRUESO a fino, con `null` adelante: sin corte, un
16
- * campo de fecha parte por instante y cada fila termina en su propio montón.
15
+ * A date's cuts, from COARSE to fine, with `null` first: with no cut, a
16
+ * date field splits by instant and every row ends up in its own heap.
17
17
  *
18
- * El orden no es una preferencia — un día entero vive adentro de un solo mes— y
19
- * es el mismo que `GRAIN_ORDER` publica para la barra: una sola dirección para
20
- * las dos pantallas. La ficha de un nivel rota por esta lista.
18
+ * The order is not a preference — a whole day lives inside a single month— and
19
+ * it is the same one `GRAIN_ORDER` publishes for the bar: a single direction for
20
+ * both screens. A level's chip rotates through this list.
21
21
  */
22
22
  const GRAINS = [null, ...GRAIN_ORDER];
23
- /** Qué tipos admiten un grano: recortar un texto por mes no significa nada. */
23
+ /** Which types admit a grain: cutting a text by month means nothing. */
24
24
  const DATE_TYPES = new Set(["date", "datetime"]);
25
- /** Los operadores que una medida —siempre un número— o `count` admiten en un
26
- * `where_measures`: los mismos que la definición del modelo publica para un campo numérico,
27
- * `is null` aparte, que no significa nada sobre un número que el propio motor calculó. */
25
+ /** The operators that a measure —always a number— or `count` admit in a
26
+ * `where_measures`: the same ones the model definition publishes for a numeric field,
27
+ * `is null` aside, which means nothing on a number the engine itself computed. */
28
28
  const COMPARABLE = ["=", "!=", ">", ">=", "<", "<=", "between"];
29
- /** Las funciones que una medida puede pedir acá, cerradas del lado del servidor porque el
30
- * nombre llega a SQL. */
29
+ /** The functions a measure can ask for here, closed on the server side because the
30
+ * name reaches SQL. */
31
31
  const MEASURE_FUNCTIONS = ["sum", "avg", "min", "max", "count"];
32
32
  function isEmpty(criteria) {
33
33
  return (criteria.selection === undefined &&
@@ -36,8 +36,8 @@ function isEmpty(criteria) {
36
36
  Object.keys(criteria.grouping?.measures ?? {}).length === 0 &&
37
37
  Object.keys(criteria.specification ?? {}).length === 0);
38
38
  }
39
- /** El árbol del editor de `where_measures`: lo leído, envuelto en un grupo si es una sola
40
- * condición, o uno en blanco sobre `count` si no hay nada que leer. */
39
+ /** The `where_measures` editor's tree: what was read, wrapped in a group if it is a single
40
+ * condition, or a blank one over `count` if there is nothing to read. */
41
41
  function measuresTreeOf(filter, model) {
42
42
  const node = filter === undefined ? null : treeFromFilter(filter);
43
43
  if (node === null)
@@ -45,12 +45,12 @@ function measuresTreeOf(filter, model) {
45
45
  return node.kind === "group" ? node : { kind: "group", join: "all", children: [node] };
46
46
  }
47
47
  /**
48
- * LA FICHA QUE AGREGA: un «+» que abre la lista de lo que se puede elegir.
48
+ * THE CHIP THAT ADDS: a «+» that opens the list of what can be chosen.
49
49
  *
50
- * Es lo mismo que hace el numeral en la barra, y por la misma razón: elegir
51
- * entre veinte campos es elegir de una LISTA, no desplegar un `<select>` que ya
52
- * viene con uno puesto y que hay que cambiar. Con el `<select>`, agregar un
53
- * nivel ponía el primer campo del modelo aunque nadie lo hubiera pedido.
50
+ * It is the same as what the hash sign does in the bar, and for the same reason: choosing
51
+ * among twenty fields is choosing from a LIST, not unfolding a `<select>` that already
52
+ * comes with one set and has to be changed. With the `<select>`, adding a
53
+ * level put the model's first field even though nobody had asked for it.
54
54
  */
55
55
  function AddTag({ label, options, onPick, }) {
56
56
  const [open, setOpen] = useState(false);
@@ -65,7 +65,7 @@ function AddTag({ label, options, onPick, }) {
65
65
  },
66
66
  })) }) })) : null] }));
67
67
  }
68
- /** El corte siguiente, y vuelta a empezar. */
68
+ /** The next cut, and back to the start. */
69
69
  function nextGrain(grain) {
70
70
  const at = GRAINS.indexOf(grain ?? null);
71
71
  return GRAINS[(at + 1) % GRAINS.length] ?? null;
@@ -73,8 +73,8 @@ function nextGrain(grain) {
73
73
  export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
74
74
  const surface = useSurface();
75
75
  const names = Object.keys(model.fields).sort();
76
- /* Nunca un relacional ni un valor-objeto: ninguno de los dos tiene una comparación propia
77
- (`ops` vacío), así que ninguno sirve de blanco para un filtro, un orden o un nivel. */
76
+ /* Never a relational nor a value-object: neither has a comparison of its own
77
+ (empty `ops`), so neither serves as a target for a filter, an order or a level. */
78
78
  const scalarNames = filterableNames(model);
79
79
  const sortable = names.filter((name) => model.fields[name]?.sortable === true);
80
80
  const decomposed = initial?.selection === undefined ? null : treeFromFilter(initial.selection);
@@ -90,10 +90,10 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
90
90
  const [measures, setMeasures] = useState(initial?.grouping?.measures ?? {});
91
91
  const [groupOrder, setGroupOrder] = useState(initial?.grouping?.order ?? []);
92
92
  const [groupLimit, setGroupLimit] = useState(initial?.grouping?.pagination?.limit);
93
- /* `where_measures` es un filtro como cualquier otro, sobre un modelo sintético cuyos únicos
94
- campos son los nombres que admite: los de `measures`, más `count`. Reutilizar
95
- `SelectionTree` sobre ese modelo es más simple y más correcto que armar un editor de
96
- condiciones aparte. */
93
+ /* `where_measures` is a filter like any other, over a synthetic model whose only
94
+ fields are the names it admits: those of `measures`, plus `count`. Reusing
95
+ `SelectionTree` over that model is simpler and more correct than building a separate
96
+ conditions editor. */
97
97
  const measuresModel = useMemo(() => ({
98
98
  aggregate: "where_measures",
99
99
  identity: "count",
@@ -109,7 +109,7 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
109
109
  const [fields, setFields] = useState(Object.keys(initial?.specification ?? {}));
110
110
  const [rawText, setRawText] = useState(() => initial === undefined ? "" : JSON.stringify(initial, null, 2));
111
111
  const [rawError, setRawError] = useState(null);
112
- /** Lo que los controles dicen, junto: es lo que se aplica y lo que el JSON muestra. */
112
+ /** What the controls say, together: it is what is applied and what the JSON shows. */
113
113
  function assemble(next) {
114
114
  const selection = next.locked ?? lockedSelection ?? treeToFilter(next.tree ?? tree);
115
115
  const sorts = next.order ?? order;
@@ -119,9 +119,9 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
119
119
  const groupSorts = next.groupOrder ?? groupOrder;
120
120
  const limit = "groupLimit" in next ? next.groupLimit : groupLimit;
121
121
  const chosen = next.fields ?? fields;
122
- /* Sin niveles no hay qué medir, qué filtrar entre montones ni en qué orden o página
123
- volverían — una medida, un `where_measures` o una página puestos y luego vaciados de
124
- niveles no tienen que sobrevivir sueltos en la criteria que se manda. */
122
+ /* Without levels there is nothing to measure, nothing to filter between heaps, nor in what order or page
123
+ they would come back — a measure, a `where_measures` or a page set and then emptied of
124
+ levels must not survive loose in the criteria that is sent. */
125
125
  const grouping = groupBy.length === 0
126
126
  ? {}
127
127
  : {
@@ -142,7 +142,7 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
142
142
  }),
143
143
  };
144
144
  }
145
- /* Tocar cualquier control reescribe el JSON entero: las dos vistas son la misma criteria. */
145
+ /* Touching any control rewrites the whole JSON: the two views are the same criteria. */
146
146
  function push(next) {
147
147
  if (next.tree !== undefined)
148
148
  setTree(next.tree);
@@ -166,7 +166,7 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
166
166
  setRawText(isEmpty(built) ? "" : JSON.stringify(built, null, 2));
167
167
  setRawError(null);
168
168
  }
169
- /* Escribir el JSON rehace los controles, mientras lo escrito sea una criteria. */
169
+ /* Writing the JSON rebuilds the controls, as long as what was written is a criteria. */
170
170
  function updateRaw(text) {
171
171
  setRawText(text);
172
172
  if (text.trim() === "") {
@@ -1,22 +1,22 @@
1
1
  import { type CriteriaJoin, type CriteriaPath, type SearchCriteria } from "./criteria.js";
2
2
  import type { Surface } from "../../foundations/types.js";
3
3
  export type CriteriaChipsProps = {
4
- /** Lo que la barra tiene puesto. Grupos y filtros mezclados: acá se separan. */
4
+ /** What the bar has set. Groups and filters mixed: here they are separated. */
5
5
  criteria: readonly SearchCriteria[];
6
- /** Abrir el constructor sobre una instancia. */
6
+ /** Open the builder on an instance. */
7
7
  onOpen?: (path: CriteriaPath) => void;
8
- /** Cambiar cómo se juntan los de un nodo. */
8
+ /** Change how a node's ones are joined. */
9
9
  onJoin?: (path: CriteriaPath, join: CriteriaJoin) => void;
10
- /** Sacar una instancia, o una rama entera. */
10
+ /** Remove an instance, or a whole branch. */
11
11
  onRemove?: (path: CriteriaPath) => void;
12
- /** Sacar varias de una vez: the × of the grouping chain drops every level. */
12
+ /** Remove several at once: the × of the grouping chain drops every level. */
13
13
  onRemoveMany?: (paths: readonly CriteriaPath[]) => void;
14
14
  /**
15
- * Cuál nodo está ABIERTO: dónde va a caer lo próximo que se escriba.
15
+ * Which node is OPEN: where the next thing written will land.
16
16
  *
17
- * Se marca porque si no, escribir `#and` y después una condición la mete en un
18
- * lugar que nadie eligió mirando: el grupo existe, la condición entra, y el
19
- * único que sabía dónde era el que la escribió.
17
+ * It is marked because otherwise, writing `#and` and then a condition puts it in a
18
+ * place nobody chose by looking: the group exists, the condition goes in, and the
19
+ * only one who knew where it was is the one who wrote it.
20
20
  */
21
21
  open?: CriteriaPath;
22
22
  /** How many facets show before the rest fold into «+N» (the grouping chain counts as one).
@@ -12,9 +12,9 @@ export function CriteriaChips({ criteria, onOpen, onJoin, onRemove, onRemoveMany
12
12
  const [expanded, setExpanded] = useState(false);
13
13
  const groups = groupsOf(criteria);
14
14
  const filters = filtersOf(criteria);
15
- /* La ruta se cuenta sobre la lista ENTERA y no sobre la mitad dibujada: es la
16
- identidad de la instancia, y una identidad que cambia según de qué lado se
17
- la mire no identifica nada. */
15
+ /* The path is counted over the WHOLE list and not over the drawn half: it is the
16
+ instance's identity, and an identity that changes depending on which side
17
+ you look at it from identifies nothing. */
18
18
  const pathOf = (one) => [
19
19
  criteria.findIndex((each) => each.id === one.id),
20
20
  ];
@@ -81,26 +81,26 @@ function GroupChain({ groups, onOpen, onRemoveMany, surface, }) {
81
81
  function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
82
82
  const copy = useUiCopy();
83
83
  if (node.kind !== "join") {
84
- /* Una instancia que no lleva expresión no tiene qué editar: el constructor
85
- edita lo que VIAJA, y ésta la contesta quien la declaró. Se ve y se saca
86
- como cualquiera; lo que no hace es prometer una puerta que da a nada. */
84
+ /* An instance that carries no expression has nothing to edit: the builder
85
+ edits what TRAVELS, and this one is answered by whoever declared it. It is seen and removed
86
+ like any other; what it does not do is promise a door that opens onto nothing. */
87
87
  const editable = node.kind === "group" || node.selection !== undefined;
88
88
  return (_jsx(Chip, { label: node.label, path: path, ...(onOpen === undefined || !editable ? {} : { onOpen }), ...(onRemove === undefined ? {} : { onRemove }), surface: surface }));
89
89
  }
90
- /* El nodo abierto se marca: es donde va a caer lo próximo. Un anillo y no un
91
- fondo, porque adentro hay fichas que ya tienen el suyo. */
90
+ /* The open node is marked: it is where the next thing will land. A ring and not a
91
+ background, because inside there are chips that already have their own. */
92
92
  const isOpen = open !== undefined && open.join(".") === path.join(".");
93
93
  return (_jsxs("span", { className: `inline-flex min-w-0 flex-wrap items-center gap-1 rounded-control border px-1.5 py-0.5 ${bySurface(surface, "border-line bg-ink/4", "border-chrome-ink/25 bg-chrome-ink/8")} ${isOpen ? "ring-1 ring-primary/60" : ""}`, children: [_jsx(JoinWord, { join: node.join, ...(onJoin === undefined ? {} : { onChange: (next) => onJoin(path, next) }), surface: surface }), node.of.length === 0 ? (
94
- /* Un nodo recién abierto no tiene nada adentro, y un corchete vacío se
95
- lee como un error. Dice que está esperando. */
94
+ /* A newly opened node has nothing inside, and an empty bracket reads
95
+ as an error. It says it is waiting. */
96
96
  _jsx("span", { className: `shrink-0 text-micro italic ${bySurface(surface, "text-muted", "text-chrome-muted")}`, children: copy.search.landsHere })) : null, node.of.map((child, at) => (_jsx(Node, { node: child, path: [...path, at], ...(onOpen === undefined ? {} : { onOpen }), ...(onJoin === undefined ? {} : { onJoin }), ...(onRemove === undefined ? {} : { onRemove }), ...(open === undefined ? {} : { open }), surface: surface }, child.id)))] }));
97
97
  }
98
98
  function Chip({ label, path, onOpen, onRemove, surface, }) {
99
99
  const copy = useUiCopy();
100
100
  const shell = `inline-flex min-w-0 max-w-(--container-facet) items-center gap-1 rounded-pill border py-0.5 text-micro ${bySurface(surface, "border-accent/40 bg-accent/18 text-ink", "border-chrome-link/35 bg-chrome-link/18 text-chrome-link")} ${onRemove === undefined ? "px-2" : "pr-0.5 pl-2"}`;
101
101
  const remove = onRemove === undefined ? null : (_jsx("button", { type: "button", onClick: (event) => {
102
- /* Sin esto, sacarla también la abre: el click llega acá y después
103
- sube. */
102
+ /* Without this, removing it also opens it: the click arrives here and then
103
+ bubbles up. */
104
104
  event.stopPropagation();
105
105
  onRemove(path);
106
106
  }, "aria-label": copy.search.removeFilter.replace("{label}", label), className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-primary/20", "hover:bg-chrome-link/25")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }));