@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
@@ -12,43 +12,43 @@ import { Button } from "../../primitives/button/index.js";
12
12
  import { FolderTree, Plus, Trash2 } from "lucide-react";
13
13
  import { useState } from "react";
14
14
  /* ====================================================================== *
15
- * UN FILTRO QUE ALGUIEN ARMA, DE LO QUE EL MODELO DICE QUE ACEPTA.
15
+ * A FILTER SOMEBODY BUILDS, FROM WHAT THE MODEL SAYS IT ACCEPTS.
16
16
  *
17
- * Los recortes con nombre de al lado —«vencidas», «con entregas pendientes»— son las
18
- * preguntas que alguien ya pensó. Esto es para las demás: elegir un campo, un
19
- * operador, escribir un valor — agruparlos con Y o con O, anidar un grupo
20
- * adentro de otro tantas veces como haga falta, o escribir directamente el
21
- * JSON para copiar o pegar una criteria entera.
17
+ * The named cuts alongside —«vencidas», «con entregas pendientes»— are the
18
+ * questions somebody already thought of. This is for the rest: choose a field, an
19
+ * operator, write a value — group them with AND or with OR, nest a group
20
+ * inside another as many times as needed, or write the
21
+ * JSON directly to copy or paste a whole criteria.
22
22
  *
23
- * **Nada acá está escrito a mano.** Los campos salen de la definición del
24
- * modelo que manda el servidor, y también los operadores de cada uno: un
25
- * campo de texto ofrece «contiene», uno numérico ofrece «>», uno que admite
26
- * vacío ofrece «está vacío». Agregar una columna la hace aparecer acá, con
27
- * sus operadores correctos, sin tocar este archivo.
23
+ * **Nothing here is written by hand.** The fields come from the model
24
+ * definition the server sends, and so do each one's operators: a
25
+ * text field offers «contiene», a numeric one offers «>», one that admits
26
+ * empty offers «está vacío». Adding a column makes it appear here, with
27
+ * its correct operators, without touching this file.
28
28
  *
29
- * **Un árbol, no una lista.** Cada grupo —la raíz incluida— tiene su propio
30
- * «todas / cualquiera» y sus propios hijos: una condición, o otro grupo
31
- * anidado adentro. El ícono del árbol agrega un grupo nuevo al lado de la
32
- * fila que se tocó; el `+` agrega otra condición.
29
+ * **A tree, not a list.** Each group —the root included— has its own
30
+ * «todas / cualquiera» and its own children: a condition, or another group
31
+ * nested inside. The tree icon adds a new group beside the
32
+ * row that was touched; the `+` adds another condition.
33
33
  *
34
- * **Un solo componente renderiza y construye — y siempre hay un JSON al
35
- * lado.** El árbol y el editor de código son dos vistas de la MISMA
36
- * criteria, sincronizadas en las dos direcciones: tocar el árbol reescribe
37
- * el JSON, y escribir un JSON reconocible rehace el árbol. Lo único que el
38
- * árbol no sabe construir ni mostrar es un NOT: si el filtro trae uno en
39
- * cualquier nivel, se dibuja de sólo lectura con `ExpressionView` en su
40
- * lugar, y el JSON sigue siendo la manera de tocarlo.
34
+ * **One component renders and builds — and there is always a JSON
35
+ * beside it.** The tree and the code editor are two views of the SAME
36
+ * criteria, synchronised in both directions: touching the tree rewrites
37
+ * the JSON, and writing a recognisable JSON rebuilds the tree. The only thing the
38
+ * tree does not know how to build or show is a NOT: if the filter brings one at
39
+ * any level, it is drawn read-only with `ExpressionView` in its
40
+ * place, and the JSON remains the way to touch it.
41
41
  * ====================================================================== */
42
- /* Cómo se llama un operador para quien lo lee: `copy.ops`, que es la MISMA tabla que usa la
43
- barra al armar la pregunta. Dos tablas es que la misma comparación se llame de dos maneras
44
- en la misma pantalla. */
45
- /** Qué operadores no llevan valor: preguntar si algo está vacío no necesita escribir nada. */
42
+ /* What an operator is called for whoever reads it: `copy.ops`, which is the SAME table the
43
+ bar uses when building the question. Two tables means the same comparison is called two ways
44
+ on the same screen. */
45
+ /** Which operators take no value: asking whether something is empty needs nothing written. */
46
46
  const WITHOUT_VALUE = new Set(["is null"]);
47
- /** Qué operadores comparan contra DOS valores. «Entre el 1 y el 31» es la pregunta que todo
48
- * el mundo hace sobre fechas, y escribirla como dos reglas sueltas es la forma de
49
- * equivocarse con uno de los dos extremos. */
47
+ /** Which operators compare against TWO values. «Entre el 1 y el 31» is the question everybody
48
+ * asks about dates, and writing it as two loose rules is the way to
49
+ * get one of the two ends wrong. */
50
50
  const WITH_RANGE = new Set(["between"]);
51
- /** Qué clase de input pide un valor, leído del tipo del campo. */
51
+ /** What kind of input asks for a value, read from the field's type. */
52
52
  function inputType(type) {
53
53
  if (type === "integer" || type === "number")
54
54
  return "number";
@@ -66,10 +66,10 @@ function isCondition(value) {
66
66
  typeof value.operator === "string" &&
67
67
  "value" in value);
68
68
  }
69
- /** Si esto es una de las formas que el filtro reconoce — condición, o grupo `all`/`any`/
70
- * `negate`. Un JSON válido que no es ninguna de éstas —`{}`, `{"foo": 1}`, un array suelto—
71
- * no es un filtro que este componente sepa dibujar, y se trata como error de forma en vez de
72
- * intentar mostrar cualquier cosa. */
69
+ /** Whether this is one of the shapes the filter recognises — condition, or `all`/`any`/
70
+ * `negate` group. A valid JSON that is none of these —`{}`, `{"foo": 1}`, a loose array—
71
+ * is not a filter this component knows how to draw, and is treated as a shape error instead of
72
+ * trying to show anything at all. */
73
73
  export function isRecognizedFilter(value) {
74
74
  if (isCondition(value))
75
75
  return true;
@@ -147,18 +147,18 @@ export function blankCondition(model, first) {
147
147
  export function blankGroup(model, first) {
148
148
  return { kind: "group", join: "all", children: [blankCondition(model, first)] };
149
149
  }
150
- /** El árbol como el filtro que viaja.
150
+ /** The tree as the filter that travels.
151
151
  *
152
- * in condición sola
153
- * out esa condición, sin envolver
152
+ * in a lone condition
153
+ * out that condition, unwrapped
154
154
  *
155
- * in grupo con dos hijos, join «any»
155
+ * in group with two children, join «any»
156
156
  * out {any: [ … , … ]}
157
157
  *
158
- * Un grupo de un solo hijo no se envuelve —es ese hijo—, y un grupo sin hijos desaparece: ni
159
- * «todas» ni «cualquiera» vacío es un filtro que alguien pidió. La regla vale en cualquier
160
- * nivel, no sólo en la raíz, así que anidar un grupo de una condición sola es lo mismo que no
161
- * haberlo anidado. */
158
+ * A group with a single child is not wrapped —it is that child—, and a group with no children disappears: neither
159
+ * an empty «todas» nor «cualquiera» is a filter anybody asked for. The rule holds at any
160
+ * level, not only at the root, so nesting a single-condition group is the same as not
161
+ * having nested it. */
162
162
  export function treeToFilter(node) {
163
163
  if (node.kind === "condition") {
164
164
  const leaf = conditionToFilter(node);
@@ -179,17 +179,17 @@ function conditionToFilter(node) {
179
179
  return { field: node.field, operator: node.operator, value: true };
180
180
  }
181
181
  if (WITH_RANGE.has(node.operator)) {
182
- /* Un rango a medio escribir no es medio rango: mientras falte un extremo, la regla no
183
- viaja. */
182
+ /* A half-written range is not half a range: while one end is missing, the rule does not
183
+ travel. */
184
184
  if (node.value === "" || (node.upper ?? "") === "")
185
185
  return undefined;
186
186
  return { field: node.field, operator: node.operator, value: [node.value, node.upper] };
187
187
  }
188
- /* **Una regla sin valor no filtra.** Viajaba con `value: ""`, y eso no es «todavía no
189
- escribí nada»: contra un `=` es «el campo es la cadena vacía», que vacía la lista
190
- mientras alguien sigue tipeando, y contra un `like` es «contiene nada», que la deja
191
- igual. Para preguntar por lo que está vacío está el operador «está vacío», que el
192
- modelo publica en los campos que lo admiten — explícito, y no por omisión. */
188
+ /* **A rule with no value does not filter.** It used to travel with `value: ""`, and that is not «not
189
+ written anything yet»: against an `=` it is «the field is the empty string», which empties the list
190
+ while somebody is still typing, and against a `like` it is «contains nothing», which leaves it
191
+ the same. To ask for what is empty there is the «está vacío» operator, which the
192
+ model publishes on the fields that admit it — explicit, and not by omission. */
193
193
  if (node.value === "")
194
194
  return undefined;
195
195
  return { field: node.field, operator: node.operator, value: node.value };
@@ -201,9 +201,9 @@ function groupToFilter(node) {
201
201
  .filter((one) => one !== undefined);
202
202
  if (kept.length === 0)
203
203
  return undefined;
204
- /* «Ninguna» niega el grupo ENTERO y no cada hijo por su cuenta: «ni vencida ni
205
- grande» es `no (vencida o grande)`. Y un grupo de uno tampoco se desarma
206
- acá —desarmarlo perdería la negación—, que es lo mismo que hace la barra. */
204
+ /* «Ninguna» negates the WHOLE group and not each child on its own: «ni vencida ni
205
+ grande» is `not (vencida or grande)`. And a group of one is not dismantled
206
+ here either —dismantling it would lose the negation—, which is what the bar does. */
207
207
  if (node.join === "not") {
208
208
  return { negate: kept.length === 1 ? kept[0] : { any: kept } };
209
209
  }
@@ -211,8 +211,8 @@ function groupToFilter(node) {
211
211
  return kept[0];
212
212
  return node.join === "any" ? { any: kept } : { all: kept };
213
213
  }
214
- /** Una condición de vuelta a una fila editable: el valor vuelve a texto, que es lo único que
215
- * un `<input>` sabe mostrar. Una lista —el valor de un `in`— se escribe separada por comas. */
214
+ /** A condition back to an editable row: the value goes back to text, which is the only thing
215
+ * an `<input>` knows how to show. A list —an `in`'s value— is written separated by commas. */
216
216
  function conditionToTree(condition) {
217
217
  if (WITH_RANGE.has(condition.operator) && Array.isArray(condition.value)) {
218
218
  const [from, to] = condition.value;
@@ -235,22 +235,22 @@ function conditionToTree(condition) {
235
235
  : String(condition.value ?? ""),
236
236
  };
237
237
  }
238
- /** El filtro leído de vuelta a un árbol.
238
+ /** The filter read back into a tree.
239
239
  *
240
240
  * in {field: "name", operator: "=", value: "labs"}
241
241
  * out TreeCondition
242
242
  *
243
- * in {any: [{all: [cond1, cond2]}, cond3]} grupo adentro de grupo
244
- * out TreeGroup(any) con un TreeGroup(all) y una condición como hijos
243
+ * in {any: [{all: [cond1, cond2]}, cond3]} group inside a group
244
+ * out TreeGroup(any) with a TreeGroup(all) and a condition as children
245
245
  *
246
246
  * in {negate: {any: [cond1, cond2]}}
247
- * out TreeGroup(not) con las dos condiciones como hijos
247
+ * out TreeGroup(not) with the two conditions as children
248
248
  *
249
- * El `negate` de un `any` se abre en el grupo «ninguna» y no queda como un grupo
250
- * adentro de otro: es lo que `treeToFilter` vuelve a escribir, así que ida y
251
- * vuelta dan lo mismo. Lo que NO se puede leer —un objeto que no es ni una
252
- * condición ni ninguna de las tres formas— devuelve `null`, y ahí el componente
253
- * lo muestra de sólo lectura sin dejar de poder tocarlo como JSON.
249
+ * An `any`'s `negate` opens into the «ninguna» group and does not stay as a group
250
+ * inside another: it is what `treeToFilter` writes back, so there and
251
+ * back give the same. What can NOT be read —an object that is neither a
252
+ * condition nor any of the three shapes— returns `null`, and there the component
253
+ * shows it read-only while still letting you touch it as JSON.
254
254
  */
255
255
  export function treeFromFilter(filter) {
256
256
  if (isCondition(filter))
@@ -274,8 +274,8 @@ export function treeFromFilter(filter) {
274
274
  const record = filter;
275
275
  if ("negate" in record) {
276
276
  const inside = record.negate;
277
- /* Un `negate` de un `any` son los hijos del grupo negado; cualquier otra cosa
278
- es un solo hijo. */
277
+ /* An `any`'s `negate` is the negated group's children; anything else
278
+ is a single child. */
279
279
  const raws = typeof inside === "object" &&
280
280
  inside !== null &&
281
281
  Array.isArray(inside.any)
@@ -294,8 +294,8 @@ export function treeFromFilter(filter) {
294
294
  const children = readChildren(record[join]);
295
295
  return children === null ? null : { kind: "group", join, children };
296
296
  }
297
- /** Los hijos de un grupo, o `null` si alguno no se puede leer: medio árbol es
298
- * peor que ninguno, porque dibuja algo que no es lo que filtra. */
297
+ /** A group's children, or `null` if any cannot be read: half a tree is
298
+ * worse than none, because it draws something that is not what filters. */
299
299
  function readChildren(raws) {
300
300
  const children = [];
301
301
  for (const raw of raws) {
@@ -309,8 +309,8 @@ function readChildren(raws) {
309
309
  function stringifyFilter(filter) {
310
310
  return filter === undefined ? "" : JSON.stringify(filter, null, 2);
311
311
  }
312
- /** Un valor de condición, legible: una lista se junta con comas, y lo que no tiene nada se
313
- * dice en palabras en vez de mostrar `true`/`undefined` sueltos. */
312
+ /** A condition value, legible: a list is joined with commas, and what has nothing is
313
+ * said in words instead of showing a bare `true`/`undefined`. */
314
314
  function describeValue(value, operator) {
315
315
  const copy = currentCopy();
316
316
  if (Array.isArray(value)) {
@@ -318,15 +318,15 @@ function describeValue(value, operator) {
318
318
  ? value.join(` ${copy.search.and} `)
319
319
  : value.join(", ");
320
320
  }
321
- /* Las mismas dos palabras que la tabla pone en una celda booleana: un `sí` que
322
- no es el `sí` de al lado es una segunda manera de decir lo mismo. */
321
+ /* The same two words the table puts in a boolean cell: a `sí` that
322
+ is not the `sí` next door is a second way of saying the same thing. */
323
323
  if (typeof value === "boolean")
324
324
  return value ? copy.table.yes : copy.table.no;
325
325
  return String(value ?? "");
326
326
  }
327
- /** El filtro dicho en una línea, para una ficha o un rótulo.
327
+ /** The filter said in one line, for a chip or a label.
328
328
  *
329
- * in {field: "row_count", operator: ">", value: 1000}, con el modelo
329
+ * in {field: "row_count", operator: ">", value: 1000}, with the model
330
330
  * out 'filas mayor que 1000'
331
331
  *
332
332
  * in {all: [cond1, cond2]}
@@ -335,17 +335,17 @@ function describeValue(value, operator) {
335
335
  * in {any: [cond1, cond2]}
336
336
  * out 'el nombre es a o el nombre es b'
337
337
  *
338
- * Cada condición la dice `sayCondition`, que es la misma que usa la barra: sin
339
- * eso, lo escrito en la barra y lo armado en el diálogo se leen distinto aunque
340
- * filtren igual, y nadie sabe cuál de las dos frases es la que manda.
338
+ * Each condition is said by `sayCondition`, which is the same one the bar uses: without
339
+ * that, what is written in the bar and what is built in the dialog read differently even though
340
+ * they filter the same, and nobody knows which of the two phrases is the one in charge.
341
341
  *
342
- * **El modelo es el que sabe cómo se llama un campo.** Sin él queda el nombre
343
- * crudo —`row_count`—, que es lo mejor que se puede decir sin preguntarle a
344
- * nadie.
342
+ * **The model is the one that knows what a field is called.** Without it the raw
343
+ * name remains —`row_count`—, which is the best that can be said without asking
344
+ * anybody.
345
345
  *
346
- * Un grupo anidado se encierra entre paréntesis, que es lo que evita que «a y (b o c)» se
347
- * lea como «(a y b) o c». Para más de tres condiciones se corta: una ficha que no entra en
348
- * la barra no dice nada — para eso está abrir el constructor y verlo entero. */
346
+ * A nested group is enclosed in parentheses, which is what keeps «a y (b o c)» from being
347
+ * read as «(a y b) o c». Past three conditions it is cut: a chip that does not fit in
348
+ * the bar says nothing — that is what opening the builder and seeing it whole is for. */
349
349
  export function describeFilter(node, model,
350
350
  /** The model at the end of a path of relations, when it already arrived: it names the
351
351
  * fields of a `through`. Without it they keep their raw names. */
@@ -387,11 +387,11 @@ function say(node, model, depth, at, modelAt) {
387
387
  const label = model === undefined ? node.field : fieldLabel(model, node.field, copy.locale);
388
388
  return sayCondition(label, node.operator, describeValue(node.value, node.operator));
389
389
  }
390
- /** El filtro dibujado tal como es, recursivo: una condición es una línea, `all`/`any` son un
391
- * grupo con su rótulo y sus hijos adentro, `negate` es «no» envolviendo al que niega.
390
+ /** The filter drawn as it is, recursive: a condition is a line, `all`/`any` are a
391
+ * group with its label and its children inside, `negate` is «no» wrapping the one it negates.
392
392
  *
393
- * Es la mitad de sólo lectura de este archivo, y también sirve sola: mostrar qué dice un
394
- * filtro que ya está puesto no necesita abrir el constructor. */
393
+ * It is the read-only half of this file, and it also works alone: showing what a
394
+ * filter that is already set says does not need opening the builder. */
395
395
  export function ExpressionView({ node, model, depth = 0, modelAt, at = [], }) {
396
396
  const surface = useSurface();
397
397
  const copy = useUiCopy();
@@ -407,9 +407,9 @@ export function ExpressionView({ node, model, depth = 0, modelAt, at = [], }) {
407
407
  : `${copy.fieldPath.match[crossed.match]} · ${relation}` }), _jsx(ExpressionView, { node: crossed.selection, ...(inner === undefined ? {} : { model: inner }), ...(modelAt === undefined ? {} : { modelAt }), at: next, depth: depth + 1 })] }));
408
408
  }
409
409
  if ("all" in node || "any" in node) {
410
- /* LAS MISMAS TRES PALABRAS QUE LA BARRA. Un grupo que acá se llama «coincide
411
- con alguna» y en la ficha «cualquiera» son dos vocabularios para una sola
412
- cosa, y el que los lee tiene que aprender los dos. */
410
+ /* THE SAME THREE WORDS AS THE BAR. A group that is called «coincide
411
+ con alguna» here and «cualquiera» on the chip is two vocabularies for one
412
+ thing, and whoever reads them has to learn both. */
413
413
  const label = "all" in node ? copy.search.joins.all : copy.search.joins.any;
414
414
  const items = "all" in node ? node.all : node.any;
415
415
  return (_jsxs("div", { className: `flex flex-col gap-1 border-l-2 pl-2 ${box} ${indent}`, children: [_jsx("p", { className: "text-micro text-muted", children: label }), items.map((child, index) => (_jsx(ExpressionView, { node: child, ...(model === undefined ? {} : { model }), ...(modelAt === undefined ? {} : { modelAt }), at: at, depth: depth + 1 }, index)))] }));
@@ -417,11 +417,11 @@ export function ExpressionView({ node, model, depth = 0, modelAt, at = [], }) {
417
417
  if ("negate" in node) {
418
418
  return (_jsxs("div", { className: `flex flex-col gap-1 border-l-2 pl-2 ${box} ${indent}`, children: [_jsx("p", { className: "text-micro text-muted", children: copy.search.joins.none }), _jsx(ExpressionView, { node: node.negate, ...(model === undefined ? {} : { model }), ...(modelAt === undefined ? {} : { modelAt }), at: at, depth: depth + 1 })] }));
419
419
  }
420
- /* Y la misma frase que la ficha: una condición se lee igual esté donde esté. */
420
+ /* And the same phrase as the chip: a condition reads the same wherever it is. */
421
421
  return _jsx("p", { className: `text-meta ${indent}`, children: describeFilter(node, model) });
422
422
  }
423
423
  /* ---------------------------------------------------------------------- *
424
- * UN GRUPO, DIBUJADO — la pieza que se llama a sí misma para anidar.
424
+ * A GROUP, DRAWN — the piece that calls itself to nest.
425
425
  * ---------------------------------------------------------------------- */
426
426
  export function SelectionTree({ model, group, onChange, depth = 0, focus, loadModel, models: shared, }) {
427
427
  const names = filterableNames(model);
@@ -463,16 +463,16 @@ export function SelectionTree({ model, group, onChange, depth = 0, focus, loadMo
463
463
  return (_jsxs("div", { className: `flex min-w-0 flex-col gap-2 rounded-control border p-2 ${box}`, children: [_jsxs("p", { className: "flex flex-wrap items-baseline gap-1 text-meta", children: [copy.search.askJoin, _jsx(JoinWord, { join: group.join, onChange: (join) => onChange({ ...group, join }) })] }), group.children.map((child, index) => child.kind === "group" ? (_jsxs("div", { className: "flex min-w-0 items-start gap-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(SelectionTree, { model: model, group: child, onChange: (next) => setChild(index, next), depth: depth + 1, models: models, ...(focus === undefined ? {} : { focus }) }) }), _jsx("button", { type: "button", "aria-label": copy.builder.dropGroup, disabled: group.children.length === 1, onClick: () => removeAt(index), className: "mt-2 text-muted disabled:opacity-30", children: _jsx(Trash2, { className: "size-4" }) })] }, index)) : (_jsx(ConditionRow, { model: model, models: models, child: child, box: box, focused: focus !== undefined && child.field === focus, onChange: (next) => setChild(index, next), actions: _jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-2", children: [_jsx("button", { type: "button", "aria-label": copy.builder.addRule, onClick: () => addConditionAfter(index), className: "text-muted hover:text-ink", children: _jsx(Plus, { className: "size-4" }) }), _jsx("button", { type: "button", "aria-label": copy.builder.addNested, onClick: () => addGroupAfter(index), className: "text-muted hover:text-ink", children: _jsx(FolderTree, { className: "size-4" }) }), _jsx("button", { type: "button", "aria-label": copy.builder.dropRule, disabled: group.children.length === 1, onClick: () => removeAt(index), className: "text-muted disabled:opacity-30", children: _jsx(Trash2, { className: "size-4" }) })] }) }, index)))] }));
464
464
  }
465
465
  /* ---------------------------------------------------------------------- *
466
- * UNA REGLA — el camino hasta el campo, cuántos de cada relación, el operador y el valor.
466
+ * A RULE — the path to the field, how many of each relation, the operator and the value.
467
467
  * ---------------------------------------------------------------------- */
468
468
  function ConditionRow({ model, models, child, box, focused, onChange, actions, }) {
469
469
  const copy = useUiCopy();
470
470
  const hops = child.through ?? [];
471
471
  const path = child.field === "" ? [] : [...hops.map((hop) => hop.field), child.field];
472
472
  const steps = useFieldPathSteps(models, path);
473
- /* El operador y el valor salen del ÚLTIMO campo del camino: «Monto», alcanzado por dos
474
- relaciones, se compara como un número y no como la relación por la que se llegó. Una
475
- regla de la raíz lo sabe sin esperar a nadie. */
473
+ /* The operator and the value come from the path's LAST field: «Monto», reached through two
474
+ relations, is compared as a number and not as the relation it was reached through. A
475
+ root rule knows it without waiting for anybody. */
476
476
  const leaf = steps?.at(-1)?.field ?? (hops.length === 0 ? model.fields[child.field] : undefined);
477
477
  const ops = leaf?.ops ?? [];
478
478
  const type = leaf?.type ?? "text";
@@ -482,7 +482,7 @@ function ConditionRow({ model, models, child, box, focused, onChange, actions, }
482
482
  return;
483
483
  const nextHops = found.slice(0, -1).map((step, at) => ({
484
484
  field: step.name,
485
- /* Cambiar el campo final no reinicia la ficha de una relación que sigue en el camino. */
485
+ /* Changing the final field does not reset the chip of a relation that remains in the path. */
486
486
  match: hops[at]?.field === step.name ? hops[at].match : "any",
487
487
  }));
488
488
  onChange({
@@ -501,8 +501,8 @@ function ConditionRow({ model, models, child, box, focused, onChange, actions, }
501
501
  });
502
502
  }
503
503
  return (_jsxs("div", {
504
- /* La que se vino a ver se marca y se trae a la vista. El anillo y no
505
- un fondo: el fondo compite con el `select` que hay que tocar. */
504
+ /* The one that was come to see is marked and brought into view. A ring and not
505
+ a background: the background competes with the `select` that has to be touched. */
506
506
  ref: focused ? (node) => node?.scrollIntoView({ block: "nearest" }) : undefined, className: `flex min-w-0 flex-wrap items-center gap-2 rounded-control ${focused ? "-m-1 p-1 ring-1 ring-primary/60" : ""}`, children: [_jsx(FieldPath, { model: model, models: models, value: path, label: copy.builder.ruleField, filter: (field) => isFilterable(field), onChange: choosePath }), hops.map((hop, at) => {
507
507
  const step = steps?.[at];
508
508
  const many = step !== undefined && isToMany(step.field);
@@ -524,18 +524,18 @@ export function FilterBuilder({ model, initial, onApply, onCancel, loadModel, mo
524
524
  const [lockedView, setLockedView] = useState(initial !== undefined && decomposed === null ? initial : null);
525
525
  const [rawText, setRawText] = useState(() => stringifyFilter(initial ?? treeToFilter(tree)));
526
526
  const [rawError, setRawError] = useState(null);
527
- /* Tocar el árbol reescribe el JSON para que muestre exactamente lo que el árbol ahora dice,
528
- y suelta cualquier vista de sólo lectura que hubiera quedado. */
527
+ /* Touching the tree rewrites the JSON so it shows exactly what the tree now says,
528
+ and drops any read-only view that may have been left. */
529
529
  function updateTree(next) {
530
530
  setTree(next);
531
531
  setLockedView(null);
532
532
  setRawText(stringifyFilter(treeToFilter(next)));
533
533
  setRawError(null);
534
534
  }
535
- /* Escribir en el JSON intenta lo mismo al revés: si lo tipeado no trae un `negate` en
536
- ningún nivel, el árbol se rehace para mostrarlo — Y y O, a cualquier profundidad. Si trae
537
- uno, se dibuja de sólo lectura, pero el JSON sigue siendo lo que se va a aplicar. Si no
538
- es ninguna de las dos —a medio escribir, o no es un filtro— no se toca lo que ya había. */
535
+ /* Writing in the JSON tries the same the other way round: if what was typed brings no `negate` at
536
+ any level, the tree is rebuilt to show it — AND and OR, at any depth. If it brings
537
+ one, it is drawn read-only, but the JSON remains what will be applied. If it is
538
+ neither —half-written, or not a filter— what was there is not touched. */
539
539
  function updateRaw(text) {
540
540
  setRawText(text);
541
541
  if (text.trim() === "") {
@@ -2,7 +2,7 @@ import type { CriteriaJoin } from "./criteria.js";
2
2
  import type { Surface } from "../../foundations/types.js";
3
3
  export declare function JoinWord({ join, onChange, surface, }: {
4
4
  join: CriteriaJoin;
5
- /** Sin esto la palabra es un valor: dice cómo junta, y no se toca. */
5
+ /** Without this the word is a value: it says how it joins, and is not touched. */
6
6
  onChange?: (next: CriteriaJoin) => void;
7
7
  surface?: Surface;
8
8
  }): import("react").JSX.Element;
@@ -5,26 +5,26 @@ import { bySurface, useSurface } from "../../foundations/surface.js";
5
5
  import { Tags } from "../../primitives/tag/Tags.js";
6
6
  import { useState } from "react";
7
7
  /* ==================================================================== *
8
- * CÓMO SE JUNTA UN NODO, en una palabra que se toca.
8
+ * HOW A NODE IS JOINED, in a word you touch.
9
9
  *
10
- * Todas, cualquiera, ninguna. Son las tres y no dos: sin «ninguna», negar algo
11
- * sólo se podía escribir en el JSON, y una pregunta que el editor no sabe
12
- * construir es una pregunta que la mayoría no va a hacer.
10
+ * All, any, none. They are three and not two: without «ninguna», negating something
11
+ * could only be written in the JSON, and a question the editor does not know how to
12
+ * build is a question most people will not ask.
13
13
  *
14
- * ── Una palabra, no un símbolo ──────────────────────────────────────
14
+ * ── A word, not a symbol ────────────────────────────────────────────
15
15
  *
16
- * «Y» y «O» son de quien escribe consultas; «todas» y «cualquiera» son de quien
17
- * busca. Y son las de la copia, así que cambiarlas las cambia en los dos lados
18
- * a la vez.
16
+ * «Y» and «O» belong to whoever writes queries; «todas» and «cualquiera» belong to whoever
17
+ * searches. And they are the copy's, so changing them changes them on both sides
18
+ * at once.
19
19
  *
20
- * ── Se abre en sus opciones, no rota ────────────────────────────────
20
+ * ── It opens into its options, it does not rotate ──────────────────────
21
21
  *
22
- * Con tres, un botón que alterna no dice cuáles hay ni cuál está puesta: hay
23
- * que apretarlo para averiguarlo, y averiguarlo cambia lo que filtra.
22
+ * With three, a toggling button says neither which there are nor which is set: you
23
+ * have to press it to find out, and finding out changes what it filters.
24
24
  *
25
- * Vive acá y no adentro de la barra porque el constructor pregunta lo mismo. Un
26
- * `<select>` allá y una lista acá son dos controles para una decisión, y el que
27
- * aprendió uno no reconoce el otro.
25
+ * It lives here and not inside the bar because the builder asks the same. A
26
+ * `<select>` there and a list here are two controls for one decision, and whoever
27
+ * learned one does not recognise the other.
28
28
  * ==================================================================== */
29
29
  const OPTIONS = ["all", "any", "not"];
30
30
  export function JoinWord({ join, onChange, surface, }) {
@@ -1,19 +1,19 @@
1
- /** Un JSON acomodado, o el mismo texto si todavía no se puede leer.
1
+ /** A JSON laid out, or the same text if it cannot be read yet.
2
2
  *
3
3
  * in '{"all":[{"field":"a","operator":"=","value":1}]}'
4
- * out el mismo, con sangría de dos espacios y un campo por línea
4
+ * out the same, indented by two spaces and one field per line
5
5
  *
6
- * Separado del componente para que se pueda probar sin dibujar nada, que es lo único que
7
- * tiene lógica acá adentro. */
6
+ * Separated from the component so it can be tested without drawing anything, which is the only thing
7
+ * with logic in here. */
8
8
  export declare function formatJson(text: string): string;
9
9
  export declare function JsonEditor({ value, onChange, error, height, label, }: {
10
10
  value: string;
11
11
  onChange: (next: string) => void;
12
- /** Qué está mal con lo escrito más allá de la sintaxis — que sea JSON válido pero no un
13
- * filtro, por ejemplo. Los errores de sintaxis los marca el editor, en su lugar exacto. */
12
+ /** What is wrong with what was written beyond the syntax — that it is valid JSON but not a
13
+ * filter, for example. Syntax errors are marked by the editor, at their exact place. */
14
14
  error?: string | null;
15
15
  height?: string;
16
- /** Cómo se llama este editor. Sin esto dice sólo que es un editor de código,
17
- * que es lo único que se puede decir sin saber qué se escribe adentro. */
16
+ /** What this editor is called. Without this it says only that it is a code editor,
17
+ * which is the only thing that can be said without knowing what is written inside. */
18
18
  label?: string;
19
19
  }): import("react").JSX.Element;
@@ -10,26 +10,26 @@ import CodeMirror, { EditorView, Prec } from "@uiw/react-codemirror";
10
10
  import { Wand2 } from "lucide-react";
11
11
  import { useId } from "react";
12
12
  /* ====================================================================== *
13
- * UN JSON QUE SE ESCRIBE A MANO, EN UN EDITOR DE VERDAD.
13
+ * A JSON WRITTEN BY HAND, IN A REAL EDITOR.
14
14
  *
15
- * CodeMirror y no un `<textarea>` con colores encima: eso último llegó hasta
16
- * donde llegan cincuenta líneas —pintar las comillas— y se quedaba corto en
17
- * todo lo demás, que es lo que hace usable escribir un filtro a mano:
18
- * números de línea para saber dónde está el error, plegado para no perderse
19
- * en un `all` de seis condiciones, y el subrayado en el carácter exacto
20
- * donde el JSON se rompe en vez de un cartel que dice que algo está mal.
15
+ * CodeMirror and not a `<textarea>` with colours on top: the latter got as far
16
+ * as fifty lines go —painting the quotes— and fell short on
17
+ * everything else, which is what makes writing a filter by hand usable:
18
+ * line numbers to know where the error is, folding so you do not get lost
19
+ * in an `all` of six conditions, and the underline on the exact character
20
+ * where the JSON breaks instead of a sign saying something is wrong.
21
21
  *
22
- * El `linter` de abajo es el del propio paquete de JSON: marca el error
23
- * mientras se escribe. El aviso de afuera —`error`— sigue existiendo porque
24
- * dice otra cosa: que el JSON está bien escrito pero no es un filtro.
22
+ * The `linter` below is the JSON package's own: it marks the error
23
+ * as you type. The outer notice —`error`— still exists because it
24
+ * says something else: that the JSON is well written but is not a filter.
25
25
  * ====================================================================== */
26
- /** Un JSON acomodado, o el mismo texto si todavía no se puede leer.
26
+ /** A JSON laid out, or the same text if it cannot be read yet.
27
27
  *
28
28
  * in '{"all":[{"field":"a","operator":"=","value":1}]}'
29
- * out el mismo, con sangría de dos espacios y un campo por línea
29
+ * out the same, indented by two spaces and one field per line
30
30
  *
31
- * Separado del componente para que se pueda probar sin dibujar nada, que es lo único que
32
- * tiene lógica acá adentro. */
31
+ * Separated from the component so it can be tested without drawing anything, which is the only thing
32
+ * with logic in here. */
33
33
  export function formatJson(text) {
34
34
  try {
35
35
  return JSON.stringify(JSON.parse(text), null, 2);
@@ -77,8 +77,8 @@ export function JsonEditor({ value, onChange, error, height = "16rem", label, })
77
77
  foldGutter: true,
78
78
  highlightActiveLine: true,
79
79
  autocompletion: false,
80
- /* El resaltado del par de llaves es lo que hace legible un filtro anidado: sin él,
81
- en un `any` adentro de un `all` hay que contar corchetes con el dedo. */
80
+ /* Highlighting the pair of braces is what makes a nested filter legible: without it,
81
+ in an `any` inside an `all` you have to count brackets with your finger. */
82
82
  bracketMatching: true,
83
83
  closeBrackets: true,
84
84
  } }) }), error == null ? null : _jsx("p", { className: "text-micro text-danger", children: error })] }));