@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
@@ -3,71 +3,71 @@ import type { ModelDefinition } from "./model.js";
3
3
  import type { Surface } from "../../foundations/types.js";
4
4
  import type { MenuGroup } from "../../primitives/menu/Menu.js";
5
5
  import { type ReactNode } from "react";
6
- /** Dónde se puede buscar. Lo declara el dominio, no esta pieza. */
6
+ /** Where you can search. The domain declares it, not this piece. */
7
7
  export interface SearchFacet {
8
8
  id: string;
9
- /** Cómo se lee en la sugerencia y en la ficha: «nombre», «columnas». */
9
+ /** How it reads in the suggestion and on the chip: «nombre», «columnas». */
10
10
  label: string;
11
11
  }
12
12
  /**
13
- * La CONJUNCIÓN entre dos recortes: «y» o «o».
13
+ * The CONJUNCTION between two cuts: «y» or «o».
14
14
  *
15
- * Con `onToggle` se puede tocar, y eso no es un adorno: «vencidas Y de este
16
- * mes» y «vencidas O de este mes» son dos listas completamente distintas, y
17
- * hasta acá cuál de las dos era estaba decidido por dentro y no se podía cambiar
18
- * sin abrir el constructor. Sin `onToggle` es una palabra y nada más — que es lo
19
- * correcto entre dos ejes, donde la Y no es una opción.
15
+ * With `onToggle` it can be touched, and that is no ornament: «vencidas Y de este
16
+ * mes» and «vencidas O de este mes» are two completely different lists, and
17
+ * until now which of the two it was was decided inside and could not be changed
18
+ * without opening the builder. Without `onToggle` it is a word and nothing more — which is
19
+ * right between two axes, where AND is not an option.
20
20
  */
21
21
  /**
22
- * Lo que la barra necesita. Está aparte de la función porque es el contrato: lo
23
- * que una lista tiene que darle para que la barra pregunte, y nada más.
22
+ * What the bar needs. It is apart from the function because it is the contract: what
23
+ * a list has to give it for the bar to ask, and nothing more.
24
24
  */
25
25
  export type SearchBarProps = {
26
26
  facets: readonly SearchFacet[];
27
27
  /**
28
- * El modelo, cuando la lista lo tiene.
28
+ * The model, when the list has it.
29
29
  *
30
- * Es lo que convierte la barra de «buscar un texto en un campo» a «hacer una
31
- * pregunta»: de acá salen el tipo de cada campo —y con él qué se le puede
32
- * escribir—, los operadores que acepta, sus valores posibles si es un enum, y
33
- * por qué columna se busca un relacional. Sin esto, `facets` sigue funcionando
34
- * como siempre: cada faceta es un campo de texto.
30
+ * It is what turns the bar from «search a text in a field» into «ask a
31
+ * question»: from here come each field's type —and with it what can be
32
+ * written to it—, the operators it accepts, its possible values if it is an enum, and
33
+ * by which column a relational is searched. Without this, `facets` keeps working
34
+ * as always: each facet is a text field.
35
35
  */
36
36
  model?: ModelDefinition;
37
37
  /**
38
- * TODO lo que la barra tiene puesto: los niveles de agrupado y los filtros, en
39
- * una sola lista de instancias.
38
+ * EVERYTHING the bar has set: the grouping levels and the filters, in
39
+ * a single list of instances.
40
40
  *
41
- * Una sola y no tres porque son lo mismo con clases distintas —ver
42
- * `criteria.ts`—: lo que entra por el numeral, lo que se escribe a mano, lo
43
- * que un filtro declarado trae con nombre y lo que sale del constructor son
44
- * todas instancias, y por eso todas se leen, se tocan y se sacan igual.
41
+ * A single one and not three because they are the same with different kinds —see
42
+ * `criteria.ts`—: what enters through the hash sign, what is written by hand, what
43
+ * a declared filter brings with a name and what comes out of the builder are
44
+ * all instances, and that is why they are all read, touched and removed the same.
45
45
  */
46
46
  criteria: readonly SearchCriteria[];
47
47
  onCriteriaChange: (next: SearchCriteria[]) => void;
48
48
  placeholder?: string;
49
- /** Lo que el panel OFRECE. Lo puesto no sale de acá: sale de `criteria`. */
49
+ /** What the panel OFFERS. What is set does not come from here: it comes from `criteria`. */
50
50
  filters?: readonly MenuGroup[];
51
51
  /**
52
- * El editor de niveles de agrupado: `<GroupingLevels …/>`.
52
+ * The grouping levels editor: `<GroupingLevels …/>`.
53
53
  *
54
- * Va en la MISMA columna del panel donde están los filtros, porque es la misma
55
- * pregunta —«qué parte de esto estoy mirando»— y separarlos obliga a abrir dos
56
- * cosas para armar un recorte sin poder ver los dos estados a la vez.
54
+ * It goes in the SAME panel column where the filters are, because it is the same
55
+ * question —«which part of this am I looking at»— and separating them forces opening two
56
+ * things to build a cut without being able to see both states at once.
57
57
  */
58
58
  grouping?: ReactNode;
59
59
  /**
60
- * Alguien escribió `#and`, `#or` o `#not` y la barra abrió un nodo: esto avisa
61
- * cuál, por si quien compone quiere hacer algo más con eso.
60
+ * Somebody wrote `#and`, `#or` or `#not` and the bar opened a node: this says
61
+ * which, in case whoever composes wants to do something more with it.
62
62
  */
63
63
  onOpenGroup?: (join: CriteriaJoin) => void;
64
64
  favorites?: readonly MenuGroup[];
65
65
  onFilterSelect?: (id: string) => void;
66
66
  onFavoriteSelect?: (id: string) => void;
67
67
  /**
68
- * Abre el constructor. Recibe la RUTA de la instancia que se tocó, cuando se
69
- * tocó una: el constructor abre ahí, en vez de abrir en la primera regla y
70
- * obligar a buscar la que uno venía mirando entre doce.
68
+ * Opens the builder. It receives the PATH of the instance that was touched, when one
69
+ * was touched: the builder opens there, instead of opening on the first rule and
70
+ * forcing you to search for the one you were looking at among twelve.
71
71
  */
72
72
  onOpenBuilder?: (path?: CriteriaPath) => void;
73
73
  /**
@@ -80,12 +80,12 @@ export type SearchBarProps = {
80
80
  * enum's value, a number a numeric field answers): then that goes first and this after it.
81
81
  */
82
82
  literal?: (text: string) => BuiltCondition | BuiltFilter | null;
83
- /** Lo que va pegado al campo, a su derecha. */
83
+ /** What goes stuck to the field, on its right. */
84
84
  trailing?: ReactNode;
85
85
  /** How many facets the bar shows before folding the rest into «+N»; the grouping chain
86
86
  * counts as one. On a narrow bar only the first shows. `Infinity` never folds. */
87
87
  collapseAfter?: number;
88
- /** Por default la hereda de la superficie que la envuelve. */
88
+ /** By default it inherits it from the surface that wraps it. */
89
89
  surface?: Surface;
90
90
  };
91
91
  export declare function SearchBar({ facets, model, criteria, onCriteriaChange, placeholder, filters, grouping, onOpenGroup, favorites, onFilterSelect, onFavoriteSelect, onOpenBuilder, literal, trailing, collapseAfter, surface, }: SearchBarProps): import("react").JSX.Element;
@@ -13,18 +13,18 @@ function Option({ o, onSelect }) {
13
13
  const Icon = o.icon;
14
14
  return (_jsxs("button", { type: "button", disabled: o.disabled, onClick: () => onSelect?.(o.id), className: `flex w-full items-start gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) disabled:pointer-events-none disabled:opacity-45 hover:bg-primary/8 ${o.checked === true ? "bg-primary/6" : ""}`, children: [_jsx("span", { className: "mt-0.5 flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: o.checked === true ? (_jsx("span", { className: "size-1.5 rounded-pill bg-primary" })) : Icon !== undefined ? (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2 })) : (_jsx("span", { className: "size-3 rounded-pill border border-line-strong" })) }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${o.checked === true ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-warn/30 bg-warn/10 px-2 py-0.5 text-micro text-warn", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] })] }));
15
15
  }
16
- /** Un grupo del panel. Plegable cuando lo pide —una fecha, que trae once
17
- * opciones— y abierto de entrada si ya tiene algo tildado: si no, lo puesto
18
- * queda escondido detrás de un chevron y hay que adivinar dónde está. */
16
+ /** A panel group. Collapsible when it asks —a date, which brings eleven
17
+ * options— and open from the start if it already has something ticked: otherwise what is set
18
+ * stays hidden behind a chevron and you have to guess where it is. */
19
19
  function Group({ group, first, onSelect, }) {
20
20
  const active = group.options.some((o) => o.checked === true);
21
21
  const [open, setOpen] = useState(active);
22
22
  const options = (_jsx(_Fragment, { children: group.options.map((o) => (_jsxs(Fragment, { children: [o.divider === true ? _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }) : null, _jsx(Option, { o: o, onSelect: onSelect })] }, o.id))) }));
23
23
  return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [first ? null : _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), group.label === undefined ? null : group.collapsible !== true ? (
24
- /* El rótulo del grupo va en la columna del TEXTO, no en la del borde.
25
- La banda de la columna ya es el título (medium, sobre la línea). Este
26
- es un escalón abajo: peso normal, y el mismo hueco de la marca para
27
- que «mostrar sólo» arranque donde arranca «traídos». */
24
+ /* The group's label goes in the TEXT column, not the edge one.
25
+ The column's band is already the title (medium, over the line). This
26
+ one is a step down: normal weight, and the same gap as the mark
27
+ so that «mostrar sólo» starts where «traídos» starts. */
28
28
  _jsxs("div", { className: "flex items-center gap-2 px-1.5 pt-1 pb-0.5 text-micro text-muted", children: [_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true }), group.label] })) : (_jsxs("button", { type: "button", onClick: () => setOpen(!open), "aria-expanded": open, className: "flex items-center gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-primary/8", children: [_jsx(ChevronRight, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-meta ${active ? "font-medium text-ink" : "text-ink"}`, children: group.label }), !active ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-accent/40 bg-accent/18 px-2 py-0.5 text-micro tabular-nums text-ink", children: group.options.filter((o) => o.checked === true).length }))] })), group.collapsible === true && !open ? null : (_jsx("div", { className: group.collapsible === true
29
29
  ? "flex flex-col gap-0.5 pl-(--spacing-indent)"
30
30
  : "flex flex-col gap-0.5", children: options }))] }));
@@ -34,32 +34,32 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
34
34
  const sup = useSurface(surface);
35
35
  const [text, setText] = useState("");
36
36
  const [panel, setPanel] = useState(false);
37
- /** El paso en el que está la pregunta que se escribe: sin campo, con campo, o
38
- * con campo y operador. */
37
+ /** The step the question being written is at: no field, with a field, or
38
+ * with a field and operator. */
39
39
  const [step, setStep] = useState({});
40
- /** Cuál de lo ofrecido está marcado. Arranca en el primero, que es el que
41
- * Enter toma sin bajar ni una vez. */
40
+ /** Which of the offered is marked. It starts on the first, which is the one
41
+ * Enter takes without going down even once. */
42
42
  const [active, setActive] = useState(0);
43
43
  /**
44
- * El grupo ABIERTO: dónde cae lo próximo que se escriba.
44
+ * The OPEN group: where the next thing written lands.
45
45
  *
46
- * `null` es «al final de la lista», que es lo normal. Se abre con `#and` y se
47
- * cierra con Escape o eligiendo otro — un grupo que no se puede cerrar es una
48
- * trampa en la que todo lo que se escriba después queda adentro sin que nadie
49
- * lo haya pedido.
46
+ * `null` is «at the end of the list», which is the normal case. It is opened with `#and` and
47
+ * closed with Escape or by choosing another — a group that cannot be closed is a
48
+ * trap in which everything written afterwards ends up inside without anybody
49
+ * having asked for it.
50
50
  */
51
51
  const [openGroup, setOpenGroup] = useState(null);
52
- /* Cuál es el nodo abierto se DERIVA de la ruta y del árbol, y no se guarda
53
- aparte: guardado, el día que alguien le cambia la conjunción desde la ficha
54
- quedan dos verdades sobre la misma cosa. */
52
+ /* Which node is open is DERIVED from the path and the tree, and is not stored
53
+ apart: stored, the day somebody changes its conjunction from the chip
54
+ there are two truths about the same thing. */
55
55
  const openNode = openGroup === null ? undefined : at(criteria, openGroup);
56
56
  const openJoin = openNode?.kind === "join" ? openNode.join : undefined;
57
57
  /**
58
- * Cerrar el nodo abierto: lo que siga vuelve a caer afuera.
58
+ * Close the open node: what follows lands outside again.
59
59
  *
60
- * Si quedó VACÍO se lo saca. Abrirlo y no poner nada deja un corchete que no
61
- * agrupa nada, y alguien tendría que descubrir que se saca con la × de una
62
- * ficha que no dice nada adentro.
60
+ * If it was left EMPTY it is removed. Opening it and putting nothing leaves a bracket that does not
61
+ * group anything, and somebody would have to discover that it is removed with the × of a
62
+ * chip that says nothing inside.
63
63
  */
64
64
  function closeGroup() {
65
65
  if (openGroup !== null && openNode?.kind === "join" && openNode.of.length === 0) {
@@ -68,9 +68,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
68
68
  setOpenGroup(null);
69
69
  input.current?.focus();
70
70
  }
71
- /* Cuántas cosas hay puestas, para el número del embudo. Se cuenta lo de
72
- ARRIBA y no las hojas: «tres» tiene que ser lo que se ve en la barra, y lo
73
- que se ve es un grupo, no sus dos condiciones. */
71
+ /* How many things are set, for the funnel's number. The ones on TOP are counted and not the leaves:
72
+ «three» has to be what is seen in the bar, and what
73
+ is seen is a group, not its two conditions. */
74
74
  const puestos = criteria.length;
75
75
  const input = useRef(null);
76
76
  const box = useRef(null);
@@ -83,50 +83,50 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
83
83
  const listId = useId();
84
84
  const optionId = (at) => `${listId}-${at}`;
85
85
  /**
86
- * Los campos por los que se puede preguntar.
86
+ * The fields that can be asked about.
87
87
  *
88
- * Con un modelo, salen de él con su tipo, sus operadores y sus relaciones —y
89
- * entonces la barra sabe que «total» acepta «menor que» y «estado» sólo
90
- * tres valores. Sin modelo, una faceta es un campo de texto y nada más: es
91
- * exactamente lo que una lista podía declarar hasta ahora, dibujado por el
92
- * mismo camino. Dos caminos serían dos barras.
88
+ * With a model, they come from it with their type, their operators and their relations —and
89
+ * then the bar knows that «total» accepts «menor que» and «estado» only
90
+ * three values. Without a model, a facet is a text field and nothing more: it is
91
+ * exactly what a list could declare until now, drawn through the
92
+ * same path. Two paths would be two bars.
93
93
  */
94
94
  const fields = model === undefined
95
95
  ? facets.map((facet) => ({
96
96
  field: facet.id,
97
97
  label: facet.label,
98
98
  kind: "text",
99
- /* Las tres que se le pueden hacer a un texto sin saber nada más de
100
- él. Con una sola —«contiene»— el paso de la comparación ofrecía un
101
- botón y nada que elegir, que es peor que no tener el paso. Un modelo
102
- publica las suyas y éstas no se usan. */
99
+ /* The three that can be asked of a text without knowing anything more about
100
+ it. With only one —«contiene»— the comparison step offered a
101
+ button and nothing to choose, which is worse than not having the step. A model
102
+ publishes its own and these are not used. */
103
103
  ops: ["like", "=", "!="],
104
104
  }))
105
105
  : queryFields(model, copy.locale);
106
- /* Lo marcado vuelve al primero cuando cambia lo ofrecido: dejar la marca en el
107
- cuarto renglón mientras se sigue escribiendo hace que Enter tome algo que ya
108
- no es lo que dice la pantalla. */
106
+ /* What is marked goes back to the first when what is offered changes: leaving the mark on the
107
+ fourth row while you keep writing makes Enter take something that is no
108
+ longer what the screen says. */
109
109
  const suggestions = suggest({
110
110
  ...(step.field === undefined ? {} : { field: step.field }),
111
111
  ...(step.op === undefined ? {} : { op: step.op }),
112
112
  text,
113
113
  }, fields, { literal: literal !== undefined });
114
- /* Lo escrito, ya leído: hace falta acá para saber si se está eligiendo un
115
- ATRIBUTO —lo que empieza con `#`— y dibujar fichas en vez de renglones. */
114
+ /* What was typed, already read: needed here to know whether an
115
+ ATTRIBUTE is being chosen —what starts with `#`— and to draw chips instead of rows. */
116
116
  const asked = readTyped(text);
117
- /* Se abre cuando hay algo que ofrecer Y alguien empezó: escribiendo, o
118
- eligiendo un campo, que ya es haber empezado. */
117
+ /* It opens when there is something to offer AND somebody has started: typing, or
118
+ choosing a field, which is already having started. */
119
119
  const open = suggestions.length > 0 && (text.trim() !== "" || step.field !== undefined);
120
- /* Se eligen FICHAS cuando lo que se elige es un atributo o una comparación, y
121
- renglones cuando lo que se elige es una pregunta entera. */
120
+ /* CHIPS are chosen when what is chosen is an attribute or a comparison, and
121
+ rows when what is chosen is a whole question. */
122
122
  const asTags = asked.attribute === true || (step.field !== undefined && step.op === undefined);
123
123
  const shown = suggestions.map((one) => one.id).join("\u0000");
124
124
  useEffect(() => {
125
125
  setActive(0);
126
126
  }, [shown]);
127
- /** Una columna sin opciones no es una columna: aparecería el disparador y el
128
- * panel abriría en blanco. Pasar `[]` es lo que hace quien tiene una lista que
129
- * no declara ningún recorte, y tiene que leerse igual que no pasar nada. */
127
+ /** A column with no options is not a column: the trigger would appear and the
128
+ * panel would open blank. Passing `[]` is what whoever has a list that
129
+ * declares no cut does, and it has to read the same as passing nothing. */
130
130
  const withOptions = (groups) => groups.some((group) => group.options.length > 0);
131
131
  const columns = [
132
132
  ...(filters === undefined || !withOptions(filters)
@@ -173,11 +173,11 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
173
173
  toolsButton.current?.focus();
174
174
  };
175
175
  /**
176
- * UNA PREGUNTA ENTERA entra como instancia, y la barra vuelve al principio.
176
+ * A WHOLE QUESTION enters as an instance, and the bar goes back to the start.
177
177
  *
178
- * Cae adentro del grupo ABIERTO si hay uno —lo que hace `#and`— y al final de
179
- * la lista si no. Es lo único que la barra decide sobre dónde van las cosas:
180
- * el resto lo decide quien tiene la lista.
178
+ * It lands inside the OPEN group if there is one —what `#and` does— and at the end of
179
+ * the list if not. It is the only thing the bar decides about where things go:
180
+ * the rest is decided by whoever has the list.
181
181
  */
182
182
  /** A finished instance, where the next one goes: the end, or the group left open. */
183
183
  function put(one) {
@@ -190,13 +190,13 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
190
190
  }
191
191
  function commit(field, op, value) {
192
192
  const one = filterCriteria(
193
- /* El que no lleva valor viaja con `true`, que es lo que el motor espera de
194
- «está vacío»: mandarle la cadena vacía sería preguntar por el campo que
195
- vale "". */
193
+ /* The one that takes no value travels with `true`, which is what the engine expects of
194
+ «está vacío»: sending it the empty string would be asking for the field that
195
+ is "". */
196
196
  { field: field.field, operator: op, value: withoutValue(op) ? true : value }, describeCondition(field, op, value));
197
197
  put(one);
198
198
  }
199
- /** Lo elegido en el desplegable, según de qué clase sea. */
199
+ /** What was chosen in the dropdown, depending on what kind it is. */
200
200
  function pick(suggestion) {
201
201
  if (suggestion.kind === "field") {
202
202
  setStep({ field: suggestion.field });
@@ -210,10 +210,10 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
210
210
  return;
211
211
  }
212
212
  if (suggestion.kind === "group") {
213
- /* Abrir un grupo es poner un nodo VACÍO y recordar que lo que venga cae
214
- adentro. Vacío y no con lo de antes metido a la fuerza: quien escribe
215
- `#and` está diciendo «lo que sigue va junto», no «agrupá lo que ya
216
- puse». */
213
+ /* Opening a group is putting an EMPTY node and remembering that what comes lands
214
+ inside. Empty and not with the previous stuff forced in: whoever writes
215
+ `#and` is saying «what follows goes together», not «group what I already
216
+ put». */
217
217
  const node = {
218
218
  id: criteriaId("n"),
219
219
  kind: "join",
@@ -235,7 +235,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
235
235
  }
236
236
  commit(suggestion.field, suggestion.op, suggestion.value);
237
237
  }
238
- /** El nodo con una instancia más adentro. */
238
+ /** The node with one more instance inside. */
239
239
  function addTo(node, one) {
240
240
  return node === undefined || node.kind !== "join"
241
241
  ? one
@@ -247,12 +247,12 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
247
247
  magnifier, a word of input and the buttons; a narrower container scrolls, it does
248
248
  not stack controls on top of each other. */
249
249
  className: "relative flex min-w-48 items-center gap-2", children: [_jsxs("div", { className: `@container/bar flex min-h-(--size-control-md) w-full min-w-0 items-start rounded-box border transition-colors duration-(--duration-instant) ${bySurface(sup, "border-line-strong bg-surface focus-within:border-primary/60",
250
- /* Sobre el cromo lo que define al campo es el BORDE, no el relleno. El
251
- azul ya es casi negro, así que hundirlo no da contraste (1,05:1) y
252
- levantarlo da 1,21:1 — en los dos casos el campo no se lee como un
253
- campo, que era «no llama la atención». La tinta al 45 % es el primer
254
- borde que pasa 3:1 contra el relleno Y contra el cromo, que es lo que
255
- 1.4.11 le pide a un control. */
250
+ /* On the chrome what defines the field is the BORDER, not the fill. The
251
+ blue is already almost black, so sinking it gives no contrast (1.05:1) and
252
+ raising it gives 1.21:1 — in both cases the field does not read as a
253
+ field, which was «it does not draw attention». Ink at 45 % is the first
254
+ border that passes 3:1 against the fill AND against the chrome, which is what
255
+ 1.4.11 asks of a control. */
256
256
  "border-chrome-ink/45 bg-chrome-ink/8 focus-within:border-chrome-link")}`, children: [_jsx("span", { className: "mt-0.75 flex h-7 shrink-0 items-center pr-1.5 pl-2.5", children: _jsx(Search, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2, "aria-hidden": true }) }), _jsxs("div", { className: "flex min-w-24 flex-1 flex-wrap items-center gap-1 py-0.75", children: [_jsx(CriteriaChips, { criteria: criteria, surface: sup, ...(openGroup === null ? {} : { open: openGroup }), ...(onOpenBuilder === undefined ? {} : { onOpen: onOpenBuilder }), ...(collapseAfter === undefined ? {} : { collapseAfter }), onRemoveMany: (paths) => {
257
257
  /* From the deepest index up, so each removal leaves the next path valid. */
258
258
  const sorted = [...paths].sort((a, b) => (b[0] ?? 0) - (a[0] ?? 0));
@@ -264,17 +264,17 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
264
264
  onCriteriaChange(replaceAt(criteria, path, { ...node, join }));
265
265
  }, onRemove: (path) => {
266
266
  onCriteriaChange(removeAt(criteria, path));
267
- /* Si lo que se sacó era el grupo abierto, deja de estarlo: escribir
268
- adentro de algo que ya no existe es escribir en el aire. */
267
+ /* If what was removed was the open group, it stops being so: writing
268
+ inside something that no longer exists is writing into the air. */
269
269
  if (openGroup !== null && path.join(".") === openGroup.join(".")) {
270
270
  setOpenGroup(null);
271
271
  }
272
272
  } }), _jsx(Tags, { surface: sup, items: [
273
- /* ADENTRO DE QUÉ se está escribiendo, primero: es lo que envuelve
274
- al resto del borrador, y es la única ficha que se saca para
275
- CERRAR en vez de para deshacer un paso. Sin ella, `#and` abría
276
- un grupo y lo único que lo decía era que la próxima pregunta
277
- aparecía en un lugar que nadie eligió mirando. */
273
+ /* INSIDE WHAT is being written, first: it is what wraps
274
+ the rest of the draft, and it is the only chip that is removed to
275
+ CLOSE rather than to undo a step. Without it, `#and` opened
276
+ a group and the only thing that said so was that the next question
277
+ appeared in a place nobody chose by looking. */
278
278
  ...(openJoin === undefined
279
279
  ? []
280
280
  : [
@@ -322,50 +322,50 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
322
322
  ] }), _jsx("input", { ref: input, "aria-label": copy.choice.search, role: "combobox", "aria-autocomplete": "list", "aria-expanded": open, ...(open ? { "aria-controls": listId } : {}), ...(open && !asTags && suggestions[active] !== undefined
323
323
  ? { "aria-activedescendant": optionId(active) }
324
324
  : {}), value: text, onChange: (e) => setText(e.target.value), onKeyDown: (e) => {
325
- /* Retroceso con el campo vacío saca la ÚLTIMA instancia: el gesto
326
- que ya existe en cualquier campo de fichas y el único que se
327
- descubre sin que nadie lo explique. La última y no la última de
328
- su clase — ahora son una sola lista, así que no hay un orden de
329
- preferencia que recordar. */
325
+ /* Backspace with the field empty removes the LAST instance: the gesture
326
+ that already exists in any chip field and the only one that is
327
+ discovered without anybody explaining it. The last and not the last of
328
+ its kind — now they are a single list, so there is no order of
329
+ preference to remember. */
330
330
  if (e.key === "Backspace" && text === "") {
331
331
  if (criteria.length > 0) {
332
332
  onCriteriaChange(removeAt(criteria, [criteria.length - 1]));
333
333
  }
334
334
  return;
335
335
  }
336
- /* Las flechas RECORREN lo ofrecido y Enter toma lo que esté
337
- marcado. Sin esto, escribir «#nom» y bajar no hacía nada: la
338
- lista se veía y no se podía tocar sin el mouse, que es
339
- justamente lo que una barra de búsqueda no puede pedir. */
336
+ /* The arrows TRAVERSE what is offered and Enter takes what is
337
+ marked. Without this, typing «#nom» and going down did nothing: the
338
+ list was seen and could not be touched without the mouse, which is
339
+ precisely what a search bar cannot ask for. */
340
340
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
341
341
  if (suggestions.length === 0)
342
342
  return;
343
343
  e.preventDefault();
344
344
  setActive((current) => {
345
345
  const next = e.key === "ArrowDown" ? current + 1 : current - 1;
346
- /* Da la vuelta: con cinco campos, bajar seis veces vuelve al
347
- primero en vez de quedarse trabado en el último. */
346
+ /* It wraps around: with five fields, going down six times returns to the
347
+ first instead of getting stuck on the last. */
348
348
  return (next + suggestions.length) % suggestions.length;
349
349
  });
350
350
  return;
351
351
  }
352
- /* Enter toma lo MARCADO, que arranca siendo lo primero — y lo
353
- primero es lo más probable: con «test» el primer campo de texto,
354
- con «<= 100» el único que puede contestarlo. */
352
+ /* Enter takes what is MARKED, which starts out being the first — and the
353
+ first is the most likely: with «test» the first text field,
354
+ with «<= 100» the only one that can answer it. */
355
355
  if (e.key === "Enter") {
356
356
  e.preventDefault();
357
357
  const chosen = suggestions[active] ?? suggestions[0];
358
358
  if (chosen !== undefined)
359
359
  pick(chosen);
360
360
  }
361
- /* Escape DESHACE, un paso por vez y siempre el último: primero lo
362
- escrito, después la comparación, después el campo. Quien se
363
- equivocó de campo quiere cambiarlo, no volver a empezar — y
364
- quien no está armando nada no espera que le pase nada.
361
+ /* Escape UNDOES, one step at a time and always the last: first what is
362
+ written, then the comparison, then the field. Whoever
363
+ got the field wrong wants to change it, not start over — and
364
+ whoever is not building anything does not expect anything to happen.
365
365
 
366
- Antes sólo desarmaba el paso cuando ya había un campo elegido,
367
- así que con «vent» a medio escribir no hacía nada: la tecla que
368
- todo el mundo aprieta para deshacer no deshacía. */
366
+ Before, it only dismantled the step when a field had already been chosen,
367
+ so with «vent» half-written it did nothing: the key that
368
+ everybody presses to undo did not undo. */
369
369
  if (e.key === "Escape") {
370
370
  if (text !== "") {
371
371
  e.preventDefault();
@@ -385,8 +385,8 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
385
385
  setStep({});
386
386
  return;
387
387
  }
388
- /* Y al final, el grupo: lo último que se abrió es lo último que
389
- se deshace. */
388
+ /* And at the end, the group: the last thing opened is the last thing
389
+ undone. */
390
390
  if (openGroup !== null) {
391
391
  e.preventDefault();
392
392
  e.stopPropagation();
@@ -399,17 +399,17 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
399
399
  : criteria.length === 0
400
400
  ? (placeholder ?? copy.search.placeholder)
401
401
  : "",
402
- /* CON UN CAMPO ELEGIDO, lo que se escribe es el VALOR — y se dibuja
403
- como la ficha que va a ser, atrás de las otras dos. No es un
404
- adorno: el borrador se lee entero —«nombre · contiene · vent▌»—
405
- antes de existir como recorte, así que se ve lo que va a quedar
406
- antes de que quede. Y sigue siendo el input: nada se duplica, y
407
- nada se convierte en filtro hasta que alguien aprieta Enter o
408
- elige de la lista.
402
+ /* WITH A FIELD CHOSEN, what is written is the VALUE — and it is drawn
403
+ as the chip it will become, behind the other two. It is not an
404
+ ornament: the draft is read whole —«nombre · contiene · vent▌»—
405
+ before existing as a cut, so you see what it will end up as
406
+ before it ends up. And it is still the input: nothing is duplicated, and
407
+ nothing becomes a filter until somebody presses Enter or
408
+ chooses from the list.
409
409
 
410
- El ancho lo pide el CONTENIDO —`field-sizing`— para que la ficha
411
- crezca con lo escrito en vez de reservar una banda vacía. Donde no
412
- esté, el input se estira como siempre. */
410
+ The width is asked for by the CONTENT —`field-sizing`— so the chip
411
+ grows with what is written instead of reserving an empty band. Where it
412
+ is not available, the input stretches as always. */
413
413
  style: step.field === undefined ? undefined : { fieldSizing: "content" }, className: step.field === undefined
414
414
  ? `h-7 ${criteria.length === 0 ? "min-w-24" : "min-w-16"} flex-1 bg-transparent text-meta outline-none ${bySurface(sup, "text-ink placeholder:text-muted", "text-chrome-ink placeholder:text-chrome-muted")}`
415
415
  : `min-w-16 rounded-pill px-2 py-0.5 text-micro outline-none ${bySurface(sup, "bg-accent/18 text-ink placeholder:text-muted", "bg-chrome-link/20 text-chrome-ink placeholder:text-chrome-muted")}` })] }), puestos === 0 ? null : (_jsx("button", { type: "button", onClick: () => {
@@ -424,9 +424,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
424
424
  }), title: copy.search.tools, className: `my-0.5 mr-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center gap-1 rounded-control border px-2 text-micro transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${puestos > 0 || panel
425
425
  ? bySurface(sup, "border-accent/40 bg-accent/18 text-ink", "border-chrome-link/35 bg-chrome-link/15 text-chrome-link")
426
426
  : bySurface(sup, "border-transparent text-muted hover:bg-ink/5 hover:text-ink", "border-transparent text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: [_jsx(ListFilter, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }), puestos > 0 ? _jsx("span", { className: "text-micro tabular-nums", children: puestos }) : null] }))] }), trailing, open ? (_jsxs("div", { className: `absolute top-full z-30 mt-1 overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float ${asTags ? "left-0 w-max max-w-full" : "right-0 left-0"}`, children: [openJoin === undefined ? null : (_jsxs("div", { className: "flex items-center gap-1.5 border-line border-b px-3 py-1.5 text-micro text-muted", children: [_jsx(CornerDownRight, { className: "size-3 shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: copy.search.landsHere }), _jsx("span", { className: "shrink-0 rounded-pill border border-accent/40 bg-accent/18 px-1.5 text-ink", children: copy.search.joins[openJoin === "not" ? "none" : openJoin] })] })), asTags ? (
427
- /* UNA LISTA, no una tira. Se está ELIGIENDO: el ojo baja por una
428
- columna y el teclado también. Doce atributos doblados en tres
429
- renglones son doce cosas que barrer en zigzag para encontrar una. */
427
+ /* A LIST, not a strip. You are CHOOSING: the eye goes down a
428
+ column and so does the keyboard. Twelve attributes folded into three
429
+ rows are twelve things to sweep in zigzag to find one. */
430
430
  _jsx("div", { id: listId, className: "max-h-72 overflow-y-auto p-1", children: _jsx(Tags, { stack: true, surface: "canvas", label: step.field !== undefined ? copy.search.askOp : copy.search.askAttribute, items: suggestions.map((one, at) => ({
431
431
  id: one.id,
432
432
  label: one.label,