@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
@@ -8,23 +8,23 @@ import { bySurface, useSurface } from "../../foundations/surface.js";
8
8
  import { Tags } from "../../primitives/tag/Tags.js";
9
9
  import { ChevronRight, CornerDownRight, ListFilter, Search, SlidersHorizontal, X, } from "lucide-react";
10
10
  import { Fragment, useEffect, useId, useRef, useState } from "react";
11
- import { useOverlay } from "react-aria";
11
+ import { mergeProps, Overlay, useOverlay, useOverlayPosition } from "react-aria";
12
12
  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,36 @@ 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
+ /* Which edge of the field the panel hangs from. It is wider than the field when the
38
+ field is narrow, so it opens toward the side of the screen with room: from the start
39
+ of a field on the left of a page, from its end on the right. */
40
+ const [panelSide, setPanelSide] = useState("end");
41
+ /** The step the question being written is at: no field, with a field, or
42
+ * with a field and operator. */
39
43
  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. */
44
+ /** Which of the offered is marked. It starts on the first, which is the one
45
+ * Enter takes without going down even once. */
42
46
  const [active, setActive] = useState(0);
43
47
  /**
44
- * El grupo ABIERTO: dónde cae lo próximo que se escriba.
48
+ * The OPEN group: where the next thing written lands.
45
49
  *
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.
50
+ * `null` is «at the end of the list», which is the normal case. It is opened with `#and` and
51
+ * closed with Escape or by choosing another — a group that cannot be closed is a
52
+ * trap in which everything written afterwards ends up inside without anybody
53
+ * having asked for it.
50
54
  */
51
55
  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. */
56
+ /* Which node is open is DERIVED from the path and the tree, and is not stored
57
+ apart: stored, the day somebody changes its conjunction from the chip
58
+ there are two truths about the same thing. */
55
59
  const openNode = openGroup === null ? undefined : at(criteria, openGroup);
56
60
  const openJoin = openNode?.kind === "join" ? openNode.join : undefined;
57
61
  /**
58
- * Cerrar el nodo abierto: lo que siga vuelve a caer afuera.
62
+ * Close the open node: what follows lands outside again.
59
63
  *
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.
64
+ * If it was left EMPTY it is removed. Opening it and putting nothing leaves a bracket that does not
65
+ * group anything, and somebody would have to discover that it is removed with the × of a
66
+ * chip that says nothing inside.
63
67
  */
64
68
  function closeGroup() {
65
69
  if (openGroup !== null && openNode?.kind === "join" && openNode.of.length === 0) {
@@ -68,9 +72,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
68
72
  setOpenGroup(null);
69
73
  input.current?.focus();
70
74
  }
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. */
75
+ /* How many things are set, for the funnel's number. The ones on TOP are counted and not the leaves:
76
+ «three» has to be what is seen in the bar, and what
77
+ is seen is a group, not its two conditions. */
74
78
  const puestos = criteria.length;
75
79
  const input = useRef(null);
76
80
  const box = useRef(null);
@@ -83,50 +87,50 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
83
87
  const listId = useId();
84
88
  const optionId = (at) => `${listId}-${at}`;
85
89
  /**
86
- * Los campos por los que se puede preguntar.
90
+ * The fields that can be asked about.
87
91
  *
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.
92
+ * With a model, they come from it with their type, their operators and their relations —and
93
+ * then the bar knows that «total» accepts «menor que» and «estado» only
94
+ * three values. Without a model, a facet is a text field and nothing more: it is
95
+ * exactly what a list could declare until now, drawn through the
96
+ * same path. Two paths would be two bars.
93
97
  */
94
98
  const fields = model === undefined
95
99
  ? facets.map((facet) => ({
96
100
  field: facet.id,
97
101
  label: facet.label,
98
102
  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. */
103
+ /* The three that can be asked of a text without knowing anything more about
104
+ it. With only one —«contiene»— the comparison step offered a
105
+ button and nothing to choose, which is worse than not having the step. A model
106
+ publishes its own and these are not used. */
103
107
  ops: ["like", "=", "!="],
104
108
  }))
105
109
  : 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. */
110
+ /* What is marked goes back to the first when what is offered changes: leaving the mark on the
111
+ fourth row while you keep writing makes Enter take something that is no
112
+ longer what the screen says. */
109
113
  const suggestions = suggest({
110
114
  ...(step.field === undefined ? {} : { field: step.field }),
111
115
  ...(step.op === undefined ? {} : { op: step.op }),
112
116
  text,
113
117
  }, 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. */
118
+ /* What was typed, already read: needed here to know whether an
119
+ ATTRIBUTE is being chosen —what starts with `#`— and to draw chips instead of rows. */
116
120
  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. */
121
+ /* It opens when there is something to offer AND somebody has started: typing, or
122
+ choosing a field, which is already having started. */
119
123
  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. */
124
+ /* CHIPS are chosen when what is chosen is an attribute or a comparison, and
125
+ rows when what is chosen is a whole question. */
122
126
  const asTags = asked.attribute === true || (step.field !== undefined && step.op === undefined);
123
127
  const shown = suggestions.map((one) => one.id).join("\u0000");
124
128
  useEffect(() => {
125
129
  setActive(0);
126
130
  }, [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. */
131
+ /** A column with no options is not a column: the trigger would appear and the
132
+ * panel would open blank. Passing `[]` is what whoever has a list that
133
+ * declares no cut does, and it has to read the same as passing nothing. */
130
134
  const withOptions = (groups) => groups.some((group) => group.options.length > 0);
131
135
  const columns = [
132
136
  ...(filters === undefined || !withOptions(filters)
@@ -161,6 +165,20 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
161
165
  isDismissable: true,
162
166
  shouldCloseOnInteractOutside: (element) => box.current?.contains(element) !== true,
163
167
  }, panelBox);
168
+ /* The panel floats in the page's overlay layer (`Overlay`, a portal React Aria stacks with
169
+ dialogs), placed against the field: a list's bar clips its search box sideways
170
+ (`ListingBar`, so the field never paints over «1–80») and a page may clip its card, and a
171
+ panel drawn inside them was cut wherever it outgrew the field. Placed this way it is as
172
+ wide as `--container-cuts`, inside the screen, toward the side with room. */
173
+ const { overlayProps: positionProps } = useOverlayPosition({
174
+ targetRef: box,
175
+ overlayRef: panelBox,
176
+ placement: panelSide === "start" ? "bottom start" : "bottom end",
177
+ offset: 4,
178
+ containerPadding: 16,
179
+ shouldFlip: false,
180
+ isOpen: panel,
181
+ });
164
182
  /* With the focus still in the bar (the input, the button) and the panel open, Escape is
165
183
  the panel's too — used up the same way, so it does not reach the dialog either. With the
166
184
  panel closed, Escape is not the bar's and goes on to whoever owns it. */
@@ -173,11 +191,11 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
173
191
  toolsButton.current?.focus();
174
192
  };
175
193
  /**
176
- * UNA PREGUNTA ENTERA entra como instancia, y la barra vuelve al principio.
194
+ * A WHOLE QUESTION enters as an instance, and the bar goes back to the start.
177
195
  *
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.
196
+ * It lands inside the OPEN group if there is one —what `#and` does— and at the end of
197
+ * the list if not. It is the only thing the bar decides about where things go:
198
+ * the rest is decided by whoever has the list.
181
199
  */
182
200
  /** A finished instance, where the next one goes: the end, or the group left open. */
183
201
  function put(one) {
@@ -190,13 +208,13 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
190
208
  }
191
209
  function commit(field, op, value) {
192
210
  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 "". */
211
+ /* The one that takes no value travels with `true`, which is what the engine expects of
212
+ «está vacío»: sending it the empty string would be asking for the field that
213
+ is "". */
196
214
  { field: field.field, operator: op, value: withoutValue(op) ? true : value }, describeCondition(field, op, value));
197
215
  put(one);
198
216
  }
199
- /** Lo elegido en el desplegable, según de qué clase sea. */
217
+ /** What was chosen in the dropdown, depending on what kind it is. */
200
218
  function pick(suggestion) {
201
219
  if (suggestion.kind === "field") {
202
220
  setStep({ field: suggestion.field });
@@ -210,10 +228,10 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
210
228
  return;
211
229
  }
212
230
  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». */
231
+ /* Opening a group is putting an EMPTY node and remembering that what comes lands
232
+ inside. Empty and not with the previous stuff forced in: whoever writes
233
+ `#and` is saying «what follows goes together», not «group what I already
234
+ put». */
217
235
  const node = {
218
236
  id: criteriaId("n"),
219
237
  kind: "join",
@@ -235,7 +253,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
235
253
  }
236
254
  commit(suggestion.field, suggestion.op, suggestion.value);
237
255
  }
238
- /** El nodo con una instancia más adentro. */
256
+ /** The node with one more instance inside. */
239
257
  function addTo(node, one) {
240
258
  return node === undefined || node.kind !== "join"
241
259
  ? one
@@ -247,12 +265,12 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
247
265
  magnifier, a word of input and the buttons; a narrower container scrolls, it does
248
266
  not stack controls on top of each other. */
249
267
  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. */
268
+ /* On the chrome what defines the field is the BORDER, not the fill. The
269
+ blue is already almost black, so sinking it gives no contrast (1.05:1) and
270
+ raising it gives 1.21:1 — in both cases the field does not read as a
271
+ field, which was «it does not draw attention». Ink at 45 % is the first
272
+ border that passes 3:1 against the fill AND against the chrome, which is what
273
+ 1.4.11 asks of a control. */
256
274
  "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
275
  /* From the deepest index up, so each removal leaves the next path valid. */
258
276
  const sorted = [...paths].sort((a, b) => (b[0] ?? 0) - (a[0] ?? 0));
@@ -264,17 +282,17 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
264
282
  onCriteriaChange(replaceAt(criteria, path, { ...node, join }));
265
283
  }, onRemove: (path) => {
266
284
  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. */
285
+ /* If what was removed was the open group, it stops being so: writing
286
+ inside something that no longer exists is writing into the air. */
269
287
  if (openGroup !== null && path.join(".") === openGroup.join(".")) {
270
288
  setOpenGroup(null);
271
289
  }
272
290
  } }), _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. */
291
+ /* INSIDE WHAT is being written, first: it is what wraps
292
+ the rest of the draft, and it is the only chip that is removed to
293
+ CLOSE rather than to undo a step. Without it, `#and` opened
294
+ a group and the only thing that said so was that the next question
295
+ appeared in a place nobody chose by looking. */
278
296
  ...(openJoin === undefined
279
297
  ? []
280
298
  : [
@@ -322,50 +340,50 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
322
340
  ] }), _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
341
  ? { "aria-activedescendant": optionId(active) }
324
342
  : {}), 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. */
343
+ /* Backspace with the field empty removes the LAST instance: the gesture
344
+ that already exists in any chip field and the only one that is
345
+ discovered without anybody explaining it. The last and not the last of
346
+ its kind — now they are a single list, so there is no order of
347
+ preference to remember. */
330
348
  if (e.key === "Backspace" && text === "") {
331
349
  if (criteria.length > 0) {
332
350
  onCriteriaChange(removeAt(criteria, [criteria.length - 1]));
333
351
  }
334
352
  return;
335
353
  }
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. */
354
+ /* The arrows TRAVERSE what is offered and Enter takes what is
355
+ marked. Without this, typing «#nom» and going down did nothing: the
356
+ list was seen and could not be touched without the mouse, which is
357
+ precisely what a search bar cannot ask for. */
340
358
  if (e.key === "ArrowDown" || e.key === "ArrowUp") {
341
359
  if (suggestions.length === 0)
342
360
  return;
343
361
  e.preventDefault();
344
362
  setActive((current) => {
345
363
  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. */
364
+ /* It wraps around: with five fields, going down six times returns to the
365
+ first instead of getting stuck on the last. */
348
366
  return (next + suggestions.length) % suggestions.length;
349
367
  });
350
368
  return;
351
369
  }
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. */
370
+ /* Enter takes what is MARKED, which starts out being the first — and the
371
+ first is the most likely: with «test» the first text field,
372
+ with «<= 100» the only one that can answer it. */
355
373
  if (e.key === "Enter") {
356
374
  e.preventDefault();
357
375
  const chosen = suggestions[active] ?? suggestions[0];
358
376
  if (chosen !== undefined)
359
377
  pick(chosen);
360
378
  }
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.
379
+ /* Escape UNDOES, one step at a time and always the last: first what is
380
+ written, then the comparison, then the field. Whoever
381
+ got the field wrong wants to change it, not start over — and
382
+ whoever is not building anything does not expect anything to happen.
365
383
 
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. */
384
+ Before, it only dismantled the step when a field had already been chosen,
385
+ so with «vent» half-written it did nothing: the key that
386
+ everybody presses to undo did not undo. */
369
387
  if (e.key === "Escape") {
370
388
  if (text !== "") {
371
389
  e.preventDefault();
@@ -385,8 +403,8 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
385
403
  setStep({});
386
404
  return;
387
405
  }
388
- /* Y al final, el grupo: lo último que se abrió es lo último que
389
- se deshace. */
406
+ /* And at the end, the group: the last thing opened is the last thing
407
+ undone. */
390
408
  if (openGroup !== null) {
391
409
  e.preventDefault();
392
410
  e.stopPropagation();
@@ -399,24 +417,29 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
399
417
  : criteria.length === 0
400
418
  ? (placeholder ?? copy.search.placeholder)
401
419
  : "",
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.
420
+ /* WITH A FIELD CHOSEN, what is written is the VALUE — and it is drawn
421
+ as the chip it will become, behind the other two. It is not an
422
+ ornament: the draft is read whole —«nombre · contiene · vent▌»—
423
+ before existing as a cut, so you see what it will end up as
424
+ before it ends up. And it is still the input: nothing is duplicated, and
425
+ nothing becomes a filter until somebody presses Enter or
426
+ chooses from the list.
409
427
 
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. */
428
+ The width is asked for by the CONTENT —`field-sizing`— so the chip
429
+ grows with what is written instead of reserving an empty band. Where it
430
+ is not available, the input stretches as always. */
413
431
  style: step.field === undefined ? undefined : { fieldSizing: "content" }, className: step.field === undefined
414
432
  ? `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
433
  : `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: () => {
416
434
  onCriteriaChange([]);
417
435
  setOpenGroup(null);
418
436
  input.current?.focus();
419
- }, "aria-label": copy.search.clearAll, title: copy.search.clearAll, className: `my-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center rounded-control px-1.5 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:bg-ink/5 hover:text-ink", "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }) })), columns.length === 0 && onOpenBuilder === undefined ? null : (_jsxs("button", { ref: toolsButton, type: "button", onClick: () => setPanel((v) => !v), "aria-expanded": panel, "aria-controls": panel ? id : undefined, "aria-label": puestos === 0
437
+ }, "aria-label": copy.search.clearAll, title: copy.search.clearAll, className: `my-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center rounded-control px-1.5 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:bg-ink/5 hover:text-ink", "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }) })), columns.length === 0 && onOpenBuilder === undefined ? null : (_jsxs("button", { ref: toolsButton, type: "button", onClick: () => {
438
+ const rect = box.current?.getBoundingClientRect();
439
+ if (!panel && rect !== undefined)
440
+ setPanelSide(window.innerWidth - rect.left >= rect.right ? "start" : "end");
441
+ setPanel((v) => !v);
442
+ }, "aria-expanded": panel, "aria-controls": panel ? id : undefined, "aria-label": puestos === 0
420
443
  ? copy.search.tools
421
444
  : fillCopy(puestos === 1 ? copy.search.toolsSetOne : copy.search.toolsSetMany, {
422
445
  label: copy.search.tools,
@@ -424,9 +447,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
424
447
  }), 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
448
  ? bySurface(sup, "border-accent/40 bg-accent/18 text-ink", "border-chrome-link/35 bg-chrome-link/15 text-chrome-link")
426
449
  : 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. */
450
+ /* A LIST, not a strip. You are CHOOSING: the eye goes down a
451
+ column and so does the keyboard. Twelve attributes folded into three
452
+ rows are twelve things to sweep in zigzag to find one. */
430
453
  _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
454
  id: one.id,
432
455
  label: one.label,
@@ -439,9 +462,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
439
462
  onSelect: () => pick(one),
440
463
  })) }) })) : (_jsx("div", { id: listId, role: "listbox", "aria-label": copy.search.suggestions, className: "p-1", children: suggestions.map((one, at) => (_jsxs("div", { id: optionId(at), role: "option", "aria-selected": at === active,
441
464
  /* The input keeps the focus: pressing an option must not take it. */
442
- onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-control px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-primary/8" : "hover:bg-ink/4"}`, children: [_jsx("span", { className: "shrink-0 font-medium text-ink", children: one.label }), one.kind === "condition" || one.kind === "literal" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-muted", children: ":" }), _jsx("span", { className: "min-w-0 truncate font-mono text-micro text-ink", children: one.hint })] })) : one.kind === "field" && one.hint !== undefined ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro text-muted", children: one.hint })) : null] }, one.id))) }))] })) : null, panel && (columns.length > 0 || onOpenBuilder !== undefined) ? (_jsxs("div", { ...overlayProps, ref: panelBox, id: id, className: "absolute top-full right-0 z-30 mt-1 flex w-max max-w-full flex-wrap overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float", children: [columns.map((c, i) => (_jsxs("div", { className: `flex min-w-48 flex-1 flex-col ${i === 0 ? "" : "border-t border-line sm:border-t-0 sm:border-l"}`, children: [_jsx("div", { className: "border-b border-line px-2.5 py-1.5 text-micro font-medium text-muted", children: c.title }), _jsx("div", { className: "flex flex-col gap-0.5 p-1", children: c.content ??
443
- c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, onSelect: c.onSelect }, g.label ?? gi))) })] }, c.title))), onOpenBuilder === undefined ? null : (_jsx("div", { className: "w-full border-t border-line p-1", children: _jsxs("button", { type: "button", onClick: () => {
444
- onOpenBuilder();
445
- setPanel(false);
446
- }, className: "flex w-full items-center gap-2 rounded-control px-1.5 py-1 text-left text-meta text-ink transition-colors duration-(--duration-instant) hover:bg-primary/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(SlidersHorizontal, { className: "size-(--size-icon-sm)", strokeWidth: 2 }), copy.search.openBuilder] }) }))] })) : null] }));
465
+ onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-control px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-primary/8" : "hover:bg-ink/4"}`, children: [_jsx("span", { className: "shrink-0 font-medium text-ink", children: one.label }), one.kind === "condition" || one.kind === "literal" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-muted", children: ":" }), _jsx("span", { className: "min-w-0 truncate font-mono text-micro text-ink", children: one.hint })] })) : one.kind === "field" && one.hint !== undefined ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro text-muted", children: one.hint })) : null] }, one.id))) }))] })) : null, panel && (columns.length > 0 || onOpenBuilder !== undefined) ? (_jsx(Overlay, { children: _jsxs("div", { ...mergeProps(overlayProps, positionProps), ref: panelBox, id: id, "data-react-aria-top-layer": "", className: "z-30 flex w-max max-w-(--container-cuts) flex-wrap overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float", children: [columns.map((c, i) => (_jsxs("div", { className: `flex min-w-48 flex-1 flex-col ${i === 0 ? "" : "border-t border-line sm:border-t-0 sm:border-l"}`, children: [_jsx("div", { className: "border-b border-line px-2.5 py-1.5 text-micro font-medium text-muted", children: c.title }), _jsx("div", { className: "flex max-h-96 flex-col gap-0.5 overflow-y-auto p-1", children: c.content ??
466
+ c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, onSelect: c.onSelect }, g.label ?? gi))) })] }, c.title))), onOpenBuilder === undefined ? null : (_jsx("div", { className: "w-full border-t border-line p-1", children: _jsxs("button", { type: "button", onClick: () => {
467
+ onOpenBuilder();
468
+ setPanel(false);
469
+ }, className: "flex w-full items-center gap-2 rounded-control px-1.5 py-1 text-left text-meta text-ink transition-colors duration-(--duration-instant) hover:bg-primary/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(SlidersHorizontal, { className: "size-(--size-icon-sm)", strokeWidth: 2 }), copy.search.openBuilder] }) }))] }) })) : null] }));
447
470
  }