@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
@@ -1,12 +1,12 @@
1
1
  import { fieldLabel, isFilterable, isNumericType, } from "./model.js";
2
2
  import { currentCopy, fillCopy } from "../../foundations/copy.js";
3
3
  /**
4
- * Las palabras que, después del numeral, abren un GRUPO en vez de nombrar un
5
- * atributo.
4
+ * The words that, after the hash sign, open a GROUP instead of naming an
5
+ * attribute.
6
6
  *
7
- * Se escriben como se piensan —`#and`, `#or`, `#not`— y también como se leen en
8
- * la barra —`#todas`, `#cualquiera`, `#ninguna`—, porque son la misma cosa dicha
9
- * de dos maneras y obligar a una sola es obligar a aprenderla.
7
+ * They are written as they are thought —`#and`, `#or`, `#not`— and also as they are read in
8
+ * the bar —`#todas`, `#cualquiera`, `#ninguna`—, because they are the same thing said
9
+ * in two ways and forcing only one is forcing people to learn it.
10
10
  */
11
11
  const OPENS = {
12
12
  and: "all",
@@ -19,55 +19,55 @@ const OPENS = {
19
19
  none: "not",
20
20
  ninguna: "not",
21
21
  };
22
- /* Los operadores que se pueden escribir adelante del valor, de más largo a más
23
- corto: si `<` se probara antes que `<=`, «<=100» se leería como «< =100». */
22
+ /* The operators that can be written in front of the value, from longest to
23
+ shortest: if `<` were tried before `<=`, «<=100» would be read as «< =100». */
24
24
  const WRITTEN_OPS = ["<=", ">=", "!=", "<", ">", "="];
25
25
  /**
26
- * Los que ORDENAN. Sólo los puede contestar algo que tenga orden —un número, una
27
- * fecha—, y no porque el campo no publique el operador: «mayor que» sobre un
28
- * texto es una comparación alfabética que nadie pidió nunca y que da resultados
29
- * que no se pueden explicar.
26
+ * Those that ORDER. Only something that has an order can answer them —a number, a
27
+ * date—, and not because the field does not publish the operator: «mayor que» on a
28
+ * text is an alphabetical comparison nobody ever asked for and that gives results
29
+ * that cannot be explained.
30
30
  */
31
31
  const ORDERING = new Set([">", ">=", "<", "<="]);
32
32
  /**
33
- * Los que sólo comparan IGUALDAD. Estos no discriminan por tipo: todo se puede
34
- * comparar contra sí mismo, así que escribir `=` abre la lista entera en vez de
35
- * adivinar de qué clase es lo que todavía no se escribió.
33
+ * Those that only compare EQUALITY. These do not discriminate by type: anything can be
34
+ * compared against itself, so writing `=` opens the whole list instead of
35
+ * guessing what kind of thing has not been written yet.
36
36
  */
37
37
  const EQUALITY = new Set(["=", "!="]);
38
- /** Qué clases tienen orden. Un enum no: sus valores son palabras aunque se
39
- * escriban con números. */
38
+ /** Which kinds have an order. An enum does not: its values are words even if
39
+ * they are written with numbers. */
40
40
  const ORDERED = new Set(["number", "date"]);
41
41
  const NUMBER = /^-?\d+([.,]\d+)?$/;
42
42
  const DATE = /^\d{4}-\d{2}(-\d{2})?$/;
43
43
  /**
44
- * Lee lo que alguien escribió: el operador que trae adelante, el valor, y de qué
45
- * forma es.
44
+ * Reads what somebody wrote: the operator it brings in front, the value, and what
45
+ * shape it is.
46
46
  *
47
- * Un molde —`*.csv`, `ventas_*`— es distinto de un texto: se busca con `like` y
48
- * el `*` se traduce al comodín del motor. Un texto suelto NO es un molde
49
- * implícito: quien escribe `test` está pidiendo lo que contenga «test», y quien
50
- * escribe `*.csv` está pidiendo lo que TERMINE en «.csv», que es otra pregunta.
47
+ * A pattern —`*.csv`, `ventas_*`— is different from a text: it is searched with `like` and
48
+ * the `*` is translated to the engine's wildcard. A loose text is NOT an implicit
49
+ * pattern: whoever writes `test` is asking for what contains «test», and whoever
50
+ * writes `*.csv` is asking for what ENDS in «.csv», which is another question.
51
51
  */
52
52
  export function readTyped(text) {
53
53
  const clean = text.trim();
54
54
  if (clean === "")
55
55
  return { value: "", shape: "empty" };
56
- /* `#` es «elegí el atributo»: lo que sigue no es un valor, es el nombre del
57
- campo por el que se va a preguntar. Existe porque las dos intenciones se
58
- escriben con las mismas letras —«nombre» puede ser el campo o el texto que
59
- se busca— y hasta acá había que confiar en que la barra adivinara cuál. Con
60
- el numeral no hay nada que adivinar. */
56
+ /* `#` is «choose the attribute»: what follows is not a value, it is the name of the
57
+ field to be asked about. It exists because the two intentions are
58
+ written with the same letters —«nombre» can be the field or the text being
59
+ searched— and until now you had to trust the bar to guess which. With
60
+ the hash sign there is nothing to guess. */
61
61
  if (clean.startsWith("#")) {
62
62
  const rest = clean.slice(1).trim();
63
63
  const opens = OPENS[rest.toLowerCase()];
64
- /* `#and` no es un atributo que se llame «and»: es la orden de abrir un
65
- grupo. Se mira primero porque un modelo podría tener un campo llamado
66
- `and`, y entre las dos lecturas gana la que alguien escribió a propósito
67
- —nadie tipea el numeral para buscar la palabra «or». */
68
- /* `#` a secas es «elegí el atributo» sin haber empezado a nombrarlo: la forma
69
- es «vacío», como en cualquier otro lado. Decir «texto» de una cadena vacía
70
- es mentir sobre lo que hay escrito. */
64
+ /* `#and` is not an attribute called «and»: it is the order to open a
65
+ group. It is looked at first because a model could have a field called
66
+ `and`, and between the two readings the one somebody wrote on purpose wins
67
+ —nobody types the hash sign to search for the word «or». */
68
+ /* A bare `#` is «choose the attribute» without having started to name it: the shape
69
+ is «empty», as anywhere else. Saying «text» of an empty string is
70
+ lying about what is written. */
71
71
  const shape = rest === "" ? "empty" : "text";
72
72
  if (opens !== undefined)
73
73
  return { value: rest, shape, attribute: true, opens };
@@ -92,12 +92,12 @@ export function readTyped(text) {
92
92
  : "text";
93
93
  return { ...(written === undefined ? {} : { op: written }), value, shape };
94
94
  }
95
- /** El molde, con el comodín que entiende el motor. `*` es lo que la gente
96
- * escribe —y lo que escribe una terminal— y `%` es lo que entiende un `like`. */
95
+ /** The pattern, with the wildcard the engine understands. `*` is what people
96
+ * write —and what a terminal writes— and `%` is what a `like` understands. */
97
97
  export function globToLike(value) {
98
98
  return value.replace(/\*/g, "%");
99
99
  }
100
- /** Qué clase de valor es un campo, leída del tipo que publica el modelo. */
100
+ /** What kind of value a field is, read from the type the model publishes. */
101
101
  function kindOf(definition) {
102
102
  if (definition.kind === "relation")
103
103
  return "relation";
@@ -115,18 +115,18 @@ function kindOf(definition) {
115
115
  return "text";
116
116
  }
117
117
  /**
118
- * Los campos por los que la barra puede preguntar, sacados del modelo.
118
+ * The fields the bar can ask about, taken from the model.
119
119
  *
120
- * Un relacional entra por la columna que lo IDENTIFICA y con el rótulo de la
121
- * relación: preguntar «el cliente se llama Ferretería» es una pregunta sobre el
122
- * cliente aunque por dentro compare su nombre. Un relacional sin `identifiedBy`
123
- * no entra: no hay nada contra qué comparar, y ofrecerlo sería ofrecer una
124
- * pregunta que no se puede contestar.
120
+ * A relational enters through the column that IDENTIFIES it and with the relation's
121
+ * label: asking «el cliente se llama Ferretería» is a question about the
122
+ * customer even if inside it compares its name. A relational without `identifiedBy`
123
+ * does not enter: there is nothing to compare against, and offering it would be offering a
124
+ * question that cannot be answered.
125
125
  */
126
126
  export function queryFields(model, locale) {
127
- /* Las columnas que ya nombran a una relación no se ofrecen por su cuenta: son
128
- la misma pregunta con dos rótulos —«proyecto» y «nombre del proyecto»— y la
129
- que se entiende es la de la relación. */
127
+ /* The columns that already name a relation are not offered on their own: they are
128
+ the same question with two labels —«proyecto» and «nombre del proyecto»— and the
129
+ one that is understood is the relation's. */
130
130
  const naming = new Set(Object.values(model.fields)
131
131
  .filter((one) => one.kind === "relation")
132
132
  .map((one) => one.identifiedBy)
@@ -165,25 +165,25 @@ export function queryFields(model, locale) {
165
165
  return out;
166
166
  }
167
167
  /**
168
- * Si un campo puede contestar lo que se escribió.
168
+ * Whether a field can answer what was written.
169
169
  *
170
- * Manda el OPERADOR cuando se escribió uno, porque es lo que dice qué clase de
171
- * pregunta es:
170
+ * The OPERATOR rules when one was written, because it is what says what kind of
171
+ * question it is:
172
172
  *
173
- * = / != todo. Cualquier cosa se compara contra sí misma, así que
174
- * escribir `=` abre la lista entera en vez de adivinar de qué
175
- * clase es un valor que todavía no se escribió.
176
- * > >= < <= sólo lo ORDENADO —un número, una fecha—. «Mayor que» sobre
177
- * un texto es una comparación alfabética que nadie pidió.
173
+ * = / != everything. Anything is compared against itself, so
174
+ * writing `=` opens the whole list instead of guessing what
175
+ * kind a value that has not been written yet is.
176
+ * > >= < <= only what is ORDERED —a number, a date—. «Mayor que» on
177
+ * a text is an alphabetical comparison nobody asked for.
178
178
  *
179
- * Sin operador escrito manda la FORMA del valor: `*.csv` es un molde y sólo lo
180
- * contesta algo con letras; `100` sólo algo con números. Ofrecer «filas» para
181
- * `*.csv` es ofrecer una pregunta que da cero.
179
+ * With no operator written the value's SHAPE rules: `*.csv` is a pattern and only
180
+ * something with letters answers it; `100` only something with numbers. Offering «filas» for
181
+ * `*.csv` is offering a question that gives zero.
182
182
  */
183
183
  export function answers(field, typed) {
184
- /* El operador se mira ANTES que el valor, y no después: escribir `>` ya
185
- descarta los textos aunque todavía no se haya escrito contra qué. Al revés,
186
- la barra ofrecía las cinco columnas hasta que se tipeaba el primer dígito. */
184
+ /* The operator is looked at BEFORE the value, and not after: writing `>` already
185
+ discards the texts even though what to compare against has not been written yet. The other way round,
186
+ the bar offered the five columns until the first digit was typed. */
187
187
  if (typed.op !== undefined) {
188
188
  if (!field.ops.includes(typed.op))
189
189
  return false;
@@ -202,18 +202,18 @@ export function answers(field, typed) {
202
202
  case "glob":
203
203
  return field.kind === "text" || field.kind === "relation";
204
204
  default:
205
- /* Un texto lo contesta lo que tiene letras adentro, y también un enum: sus
206
- valores son palabras. Un número no —«test» no es un número— y una fecha
207
- tampoco. */
205
+ /* A text is answered by what has letters inside, and also an enum: its
206
+ values are words. A number does not —«test» is not a number— and a date
207
+ neither. */
208
208
  return field.kind === "text" || field.kind === "relation" || field.kind === "choice";
209
209
  }
210
210
  }
211
211
  /**
212
- * Con qué operador se pregunta, cuando nadie lo eligió.
212
+ * Which operator to ask with, when nobody chose one.
213
213
  *
214
- * El que se escribió gana. Si no, el que la forma pide: un molde se pregunta con
215
- * `like`, un texto con `like` si el campo lo acepta —«contiene» es lo que quiere
216
- * quien escribe media palabra— y todo lo demás con `=`.
214
+ * The one written wins. Otherwise, the one the shape asks for: a pattern is asked with
215
+ * `like`, a text with `like` if the field accepts it —«contiene» is what whoever
216
+ * writes half a word wants— and everything else with `=`.
217
217
  */
218
218
  export function defaultOp(field, typed) {
219
219
  if (typed.op !== undefined && field.ops.includes(typed.op))
@@ -224,29 +224,29 @@ export function defaultOp(field, typed) {
224
224
  return "like";
225
225
  return field.ops.includes("=") ? "=" : (field.ops[0] ?? "=");
226
226
  }
227
- /** El valor tal como viaja: un molde se traduce al comodín del motor, y lo demás
228
- * va como se escribió. */
227
+ /** The value as it travels: a pattern is translated to the engine's wildcard, and the rest
228
+ * goes as it was written. */
229
229
  export function valueFor(op, typed) {
230
230
  return op === "like" && typed.shape === "glob" ? globToLike(typed.value) : typed.value;
231
231
  }
232
- /** Cómo se llama un operador para quien lo lee. Sale de la copia, así que un
233
- * operador que el servidor agregue aparece con su símbolo hasta que alguien le
234
- * ponga palabra — y no desaparece. */
232
+ /** What an operator is called for whoever reads it. It comes from the copy, so an
233
+ * operator the server adds appears with its symbol until somebody gives it
234
+ * a word — and does not disappear. */
235
235
  export function opLabel(op) {
236
236
  return currentCopy().ops[op] ?? op;
237
237
  }
238
- /** Si el operador no lleva valor: preguntar si algo está vacío no necesita que
239
- * se escriba nada. */
238
+ /** Whether the operator takes no value: asking whether something is empty needs nothing
239
+ * to be written. */
240
240
  export function withoutValue(op) {
241
241
  return op === "is null" || op === "is not null";
242
242
  }
243
243
  /**
244
- * Si el operador compara contra DOS valores.
244
+ * Whether the operator compares against TWO values.
245
245
  *
246
- * La barra escribe UNO —es una línea, no un formulario— así que éstos no se
247
- * ofrecen acá: elegir «está entre» y escribir un número arma medio rango, que
248
- * no es una pregunta más laxa sino una que el motor no puede contestar. Se
249
- * preguntan en el constructor, que tiene los dos campos.
246
+ * The bar writes ONE —it is a line, not a form— so these are not
247
+ * offered here: choosing «está entre» and writing a number builds half a range, which
248
+ * is not a laxer question but one the engine cannot answer. They are
249
+ * asked in the builder, which has both fields.
250
250
  */
251
251
  export function withTwoValues(op) {
252
252
  return op === "between";
@@ -258,14 +258,14 @@ function matches(field, text) {
258
258
  return (field.label.toLowerCase().includes(needle) || field.field.toLowerCase().includes(needle));
259
259
  }
260
260
  /**
261
- * Qué se ofrece ahora mismo.
261
+ * What is offered right now.
262
262
  *
263
- * Es una sola lista y no tres pantallas: en el primer paso conviven los campos
264
- * que se llaman como lo tipeado —«nombr» → «nombre»— con las preguntas enteras
265
- * que lo tipeado ya permite armar —«test» en el nombre—. Quien escribe el nombre
266
- * de un campo quiere seguir por ahí; quien escribe un valor quiere preguntarlo
267
- * ya. Las dos intenciones se escriben igual, así que se ofrecen las dos, con los
268
- * campos primero: es el paso que todavía no decidió nada.
263
+ * It is a single list and not three screens: in the first step the fields
264
+ * named like what was typed coexist —«nombr» → «nombre»— with the whole questions
265
+ * that what was typed already allows building —«test» en el nombre—. Whoever writes a field's
266
+ * name wants to continue that way; whoever writes a value wants to ask it
267
+ * right away. The two intentions are written the same, so both are offered, with the
268
+ * fields first: it is the step that has not decided anything yet.
269
269
  */
270
270
  /**
271
271
  * Whether the MODEL reads what was typed as a question of its own: an operator written in
@@ -286,13 +286,13 @@ export function suggest(draft, fields,
286
286
  /** The set has a literal search (`SearchBar literal`): offer it for free text. */
287
287
  options = {}) {
288
288
  const typed = readTyped(draft.text);
289
- /* Paso 3 — el campo y el operador ya están: falta el valor. */
289
+ /* Step 3 — the field and the operator are already there: the value is missing. */
290
290
  if (draft.field !== undefined && draft.op !== undefined) {
291
291
  const field = draft.field;
292
- /* Escribir un molde CAMBIA la comparación: «igual a ventas_*» busca un
293
- nombre que termine en asterisco, que no existe y que nadie quiso pedir.
294
- Sólo pisa la igualdad —quien eligió «mayor que» y escribió un `*` está
295
- escribiendo cualquier otra cosa— y sólo si el campo publica `like`. */
292
+ /* Writing a pattern CHANGES the comparison: «igual a ventas_*» searches for a
293
+ name that ends in an asterisk, which does not exist and nobody meant to ask for.
294
+ It only overrides equality —whoever chose «mayor que» and wrote a `*` is
295
+ writing something else entirely— and only if the field publishes `like`. */
296
296
  const op = typed.shape === "glob" && EQUALITY.has(draft.op) && field.ops.includes("like")
297
297
  ? "like"
298
298
  : draft.op;
@@ -321,17 +321,17 @@ options = {}) {
321
321
  }
322
322
  return ready;
323
323
  }
324
- /* Paso 2 — el campo ya está: se ofrecen SUS operadores. El que la forma de lo
325
- tipeado pide va primero, porque escribir «100» después de elegir «filas» es
326
- casi siempre «igual a 100». */
324
+ /* Step 2 — the field is already there: ITS operators are offered. The one the shape of what was
325
+ typed asks for goes first, because writing «100» after choosing «filas» is
326
+ almost always «igual a 100». */
327
327
  if (draft.field !== undefined) {
328
328
  const field = draft.field;
329
329
  const first = defaultOp(field, typed);
330
330
  const ops = [first, ...field.ops.filter((one) => one !== first)].filter((op) => !withTwoValues(op));
331
331
  return ops.map((op) =>
332
- /* El que NO lleva valor es una pregunta entera apenas se elige: mandarlo
333
- al paso del valor dejaba al que eligió «está vacío» tipeando algo que no
334
- significa nada, con una lista vacía abajo y Enter sin hacer nada. */
332
+ /* The one that takes NO value is a whole question as soon as it is chosen: sending it
333
+ to the value step left whoever chose «está vacío» typing something that
334
+ means nothing, with an empty list below and Enter doing nothing. */
335
335
  withoutValue(op)
336
336
  ? {
337
337
  kind: "condition",
@@ -344,8 +344,8 @@ options = {}) {
344
344
  }
345
345
  : { kind: "op", id: `op:${op}`, label: opLabel(op), op });
346
346
  }
347
- /* `#and`, `#or`, `#not`: lo que se pidió es abrir un grupo, no elegir un
348
- campo. Se ofrece ESO solo — quien lo escribió ya sabe lo que quiere. */
347
+ /* `#and`, `#or`, `#not`: what was asked for is to open a group, not to choose a
348
+ field. ONLY THAT is offered — whoever wrote it already knows what they want. */
349
349
  if (typed.opens !== undefined) {
350
350
  const join = typed.opens;
351
351
  return [
@@ -357,9 +357,9 @@ options = {}) {
357
357
  },
358
358
  ];
359
359
  }
360
- /* Con `#` a secas se está eligiendo el ATRIBUTO, así que se ofrecen los campos
361
- —y los tres abridores de grupo, porque también se piden con el numeral y
362
- esconderlos sería tener una notación que nadie descubre. */
360
+ /* With a bare `#` the ATTRIBUTE is being chosen, so the fields are offered
361
+ —and the three group openers, because they are also asked for with the hash sign and
362
+ hiding them would be having a notation nobody discovers. */
363
363
  if (typed.attribute === true) {
364
364
  const opening = typed.value === ""
365
365
  ? ["all", "any", "not"].map((join) => ({
@@ -382,7 +382,7 @@ options = {}) {
382
382
  })),
383
383
  ];
384
384
  }
385
- /* Paso 1 — todavía no se eligió nada. */
385
+ /* Step 1 — nothing has been chosen yet. */
386
386
  const byName = typed.shape === "empty"
387
387
  ? []
388
388
  : fields
@@ -408,10 +408,10 @@ options = {}) {
408
408
  value: valueFor(op, typed),
409
409
  };
410
410
  });
411
- /* Sin VALOR todavía no hay ninguna pregunta que armar —una pregunta sin valor
412
- no es una pregunta— así que se ofrecen campos. Pero si ya se escribió el
413
- operador, eso solo recorta: `>` deja los que tienen orden y saca los textos
414
- antes de que se escriba el primer dígito. */
411
+ /* Without a VALUE there is no question to build yet —a question without a value
412
+ is not a question— so fields are offered. But if the operator was already written,
413
+ that alone narrows: `>` keeps those that have an order and drops the texts
414
+ before the first digit is written. */
415
415
  if (typed.shape === "empty") {
416
416
  return fields
417
417
  .filter((field) => answers(field, typed))
@@ -423,10 +423,10 @@ options = {}) {
423
423
  field,
424
424
  }));
425
425
  }
426
- /* Un campo que se llama como lo tipeado no se ofrece dos veces: si «nombre»
427
- aparece arriba para seguir por él, abajo ya no hace falta como pregunta
428
- hecha — salvo que lo tipeado sea también un valor razonable, que es
429
- justamente el caso de «test». */
426
+ /* A field named like what was typed is not offered twice: if «nombre»
427
+ appears above to continue by it, below it is no longer needed as a
428
+ question already made — unless what was typed is also a reasonable value, which is
429
+ precisely the case of «test». */
430
430
  const named = new Set(byName.map((one) => (one.kind === "field" ? one.field.field : "")));
431
431
  const byModel = [
432
432
  ...byName,
@@ -447,22 +447,22 @@ options = {}) {
447
447
  return readByModel(typed, byName, fields) ? [...byModel, literal] : [literal, ...byModel];
448
448
  }
449
449
  /**
450
- * CÓMO SE LEE UNA CONDICIÓN, en un solo lugar.
450
+ * HOW A CONDITION IS READ, in one place.
451
451
  *
452
- * La usan la barra —para la ficha de lo que alguien acaba de preguntar— y el
453
- * constructor —para la ficha y para el árbol de lo que ya está armado—. Una
454
- * sola, porque la misma condición escrita de dos maneras se lee distinta en dos
455
- * pantallas y nadie sabe cuál de las dos es la que filtra.
452
+ * It is used by the bar —for the chip of what somebody just asked— and the
453
+ * builder —for the chip and for the tree of what is already built—. Only
454
+ * one, because the same condition written two ways reads differently on two
455
+ * screens and nobody knows which of the two is the one that filters.
456
456
  *
457
- * Toma el RÓTULO ya resuelto y no el campo: quién sabe cómo se llama
458
- * `row_count` es el modelo, y esto sólo sabe armar la frase.
457
+ * It takes the label ALREADY resolved and not the field: who knows what
458
+ * `row_count` is called is the model, and this only knows how to build the sentence.
459
459
  */
460
460
  export function sayCondition(label, op, value) {
461
461
  return withoutValue(op)
462
462
  ? `${label} ${opLabel(op)}`
463
463
  : fillCopy(currentCopy().search.condition, { field: label, op: opLabel(op), value });
464
464
  }
465
- /** Cómo se lee una pregunta ya hecha, para la ficha: «el nombre contiene test». */
465
+ /** How an already-made question reads, for the chip: «el nombre contiene test». */
466
466
  export function describeCondition(field, op, value) {
467
467
  return sayCondition(field.label, op, value);
468
468
  }
@@ -5,10 +5,17 @@ menu,
5
5
  /** The band at the bottom. It goes AFTER the content, not pinned to the
6
6
  * floor of the window — pinning left a hole between it and a short view. */
7
7
  status,
8
- /** The module's navigation, on the left of the view: a `NavigationTree`. */
9
- sidebar, children, }: {
8
+ /** The module's navigation, on the left of the view: a `NavigationTree`, or a `Sidebar`
9
+ * around one when there is no `menu` and the sidebar is the application's chrome. On a
10
+ * phone it opens as a drawer. */
11
+ sidebar,
12
+ /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
13
+ * drawer and something has to open it — a `TopBar` with the product's name, which draws
14
+ * the button first. A bare `TopBar` by default. */
15
+ narrowMenu, children, }: {
10
16
  menu?: ReactNode;
11
17
  status?: ReactNode;
12
18
  sidebar?: ReactNode;
19
+ narrowMenu?: ReactNode;
13
20
  children: ReactNode;
14
21
  }): import("react").JSX.Element;
@@ -1,8 +1,15 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { HeaderSlotContext } from "./headerSlot.js";
4
+ import { SidebarDrawerContext } from "./sidebarDrawer.js";
5
+ import { TopBar } from "./TopBar.js";
6
+ import { useUiCopy } from "../../foundations/copy.js";
7
+ import { HANDHELD_WIDTH } from "../../foundations/layout.js";
4
8
  import { stickyTop, useStickyLayer } from "../../foundations/sticky.js";
5
- import { useState } from "react";
9
+ import { IconButton } from "../../primitives/button/Button.js";
10
+ import { X } from "lucide-react";
11
+ import { useEffect, useId, useMemo, useState } from "react";
12
+ import { Dialog as AriaDialog, Modal, ModalOverlay } from "react-aria-components";
6
13
  /* ==================================================================== *
7
14
  * THE APPLICATION FRAME — the three bands, and nothing between them.
8
15
  *
@@ -52,29 +59,110 @@ import { useState } from "react";
52
59
  * is left of the window and scrolls on its own, so a long module never takes
53
60
  * the page with it. The page still scrolls as a whole — only the view moves.
54
61
  * Without a `sidebar` the frame is exactly what it was.
62
+ *
63
+ * ── The sidebar AS the chrome: no `menu` ────────────────────────────
64
+ *
65
+ * ┌──────────┬────────────────────────────────────────────┐
66
+ * │ brand │ view │
67
+ * │ user │ …its own header sticks at the top… │
68
+ * │ sections │ │
69
+ * │ ──────── │ │
70
+ * │ sign out │ │
71
+ * └──────────┴────────────────────────────────────────────┘
72
+ *
73
+ * A back office whose navigation is all in the sidebar has no bar on top: the
74
+ * sidebar is as tall as the window and holds the brand and the user itself
75
+ * (`Sidebar`). A view's header then stays in the view's column — there is no
76
+ * bar for it to hang under, and spanning above the sidebar it would push the
77
+ * brand down from the top-left, which is the brand's place.
78
+ *
79
+ * ── On a phone the sidebar is a drawer ──────────────────────────────
80
+ *
81
+ * Below `sm` a 15 rem column is two thirds of the screen. The sidebar is hidden
82
+ * and the SAME content opens as a drawer from the start edge: from a button the
83
+ * `TopBar` draws first, or — with no `menu` — from the bar the frame draws for
84
+ * the phone alone (`narrowMenu`, a bare `TopBar` by default). Following a link
85
+ * in it closes it: the person went where they were going.
55
86
  * ==================================================================== */
87
+ /* Following a link closes the drawer. On the CAPTURE phase: React Aria's links stop the
88
+ click from bubbling, and a keyboard Enter on one reaches here as the click it dispatches. */
89
+ function closeOnLink(close) {
90
+ return (event) => {
91
+ if (event.target.closest("a[href]") !== null)
92
+ close();
93
+ };
94
+ }
95
+ /** The sidebar as a drawer, for a phone: modal (the page behind is inert and dimmed, the
96
+ * focus is kept inside and returns to the button), dismissed by the scrim, Escape, its ×
97
+ * or a link followed. */
98
+ function SidebarDrawerPanel({ id, open, onClose, children, }) {
99
+ const copy = useUiCopy();
100
+ return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: (next) => {
101
+ if (!next)
102
+ onClose();
103
+ }, isDismissable: true, className: ({ isEntering, isExiting }) => `fixed inset-0 z-50 bg-scrim/40 transition-opacity duration-(--duration-quick) ease-(--ease-out) sm:hidden ${isEntering || isExiting ? "opacity-0" : ""}`, children: _jsx(Modal, { className: ({ isEntering, isExiting }) => `fixed inset-y-0 start-0 flex w-(--container-drawer) flex-col border-e border-line-strong bg-ground shadow-window outline-0 transition-[translate] duration-(--duration-panel) ease-(--ease-out) ${isEntering || isExiting ? "-translate-x-full rtl:translate-x-full" : ""}`, children: _jsxs(AriaDialog, { id: id, "aria-label": copy.shell.navigation, className: "flex min-h-0 flex-1 flex-col outline-0", children: [_jsx("div", { className: "flex shrink-0 justify-end px-2 pt-2", children: _jsx(IconButton, { icon: X, label: copy.shell.close, onClick: onClose }) }), _jsx("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto", onClickCapture: closeOnLink(onClose), children: children })] }) }) }));
104
+ }
56
105
  export function AppFrame({
57
106
  /** The bar at the top. It stays in view while scrolling. */
58
107
  menu,
59
108
  /** The band at the bottom. It goes AFTER the content, not pinned to the
60
109
  * floor of the window — pinning left a hole between it and a short view. */
61
110
  status,
62
- /** The module's navigation, on the left of the view: a `NavigationTree`. */
63
- sidebar, children, }) {
64
- /* La barra de arriba MIDE lo que ocupa y se lo pasa a lo de abajo: la barra
65
- de una lista se pega debajo de ella, y el encabezado de una tabla debajo de
66
- las dos. Ninguna de las tres tiene alto fijo — ver `system/sticky.tsx`. */
111
+ /** The module's navigation, on the left of the view: a `NavigationTree`, or a `Sidebar`
112
+ * around one when there is no `menu` and the sidebar is the application's chrome. On a
113
+ * phone it opens as a drawer. */
114
+ sidebar,
115
+ /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
116
+ * drawer and something has to open it — a `TopBar` with the product's name, which draws
117
+ * the button first. A bare `TopBar` by default. */
118
+ narrowMenu, children, }) {
119
+ /* The top bar MEASURES what it takes and passes it to what is below: a list's
120
+ bar sticks beneath it, and a table's header beneath the other two. None of the
121
+ three has a fixed height — see `system/sticky.tsx`. */
67
122
  const bar = useStickyLayer();
68
123
  /* The slot for a view's header (see `headerSlot.ts`): full width, stuck under the
69
124
  application bar, and it pushes the stack down for the sidebar and the table header. */
70
125
  const [slot, setSlot] = useState(null);
71
126
  const head = useStickyLayer();
72
- return (
73
- /* The frame owns the page: its background and its full height. A screen built inside
74
- it is only composition — before, every page had to wrap itself in a `div` with the
75
- ground color and `min-h-dvh`, and the one that forgot ended where its content did. */
76
- _jsxs("div", { className: "relative flex min-h-dvh min-w-0 flex-col bg-ground", children: [menu === undefined ? null : (_jsx("div", { ref: bar.ref, className: "sticky top-0 z-40", children: menu })), sidebar === undefined ? (_jsx("main", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: children })) : (_jsx(HeaderSlotContext, { value: slot, children: _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: [_jsx("div", { ref: (node) => {
77
- head.ref.current = node;
78
- setSlot(node);
79
- }, className: "sticky z-30 min-w-0", style: head.self }), _jsxs("div", { className: "flex min-w-0 flex-1 items-start", style: head.below, children: [_jsx("aside", { className: "sticky w-(--container-sidebar) shrink-0 self-start overflow-y-auto overscroll-contain border-r border-line bg-ground", style: { ...stickyTop, height: "calc(100dvh - var(--sticky-top, 0px))" }, children: sidebar }), _jsx("main", { className: "flex min-w-0 flex-1 flex-col self-stretch", children: children })] })] }) })), status] }));
127
+ const hasSidebar = sidebar !== undefined;
128
+ const [drawerOpen, setDrawerOpen] = useState(false);
129
+ const drawerId = useId();
130
+ const drawer = useMemo(() => hasSidebar
131
+ ? {
132
+ isOpen: drawerOpen,
133
+ open: () => setDrawerOpen(true),
134
+ close: () => setDrawerOpen(false),
135
+ id: drawerId,
136
+ }
137
+ : null, [hasSidebar, drawerOpen, drawerId]);
138
+ /* A window widened past the phone while the drawer was open (a tablet turned): the
139
+ sidebar is back beside the view, and a modal drawer left open would keep the page inert
140
+ behind a panel CSS has already hidden. */
141
+ useEffect(() => {
142
+ if (!drawerOpen)
143
+ return;
144
+ const wide = window.matchMedia(`(min-width: ${HANDHELD_WIDTH}px)`);
145
+ const close = () => {
146
+ if (wide.matches)
147
+ setDrawerOpen(false);
148
+ };
149
+ close();
150
+ wide.addEventListener("change", close);
151
+ return () => wide.removeEventListener("change", close);
152
+ }, [drawerOpen]);
153
+ /* With no `menu` the sidebar is the chrome: on a wide screen nothing is on top of it, and
154
+ on a phone a bar appears to open it. */
155
+ const sidebarIsChrome = hasSidebar && menu === undefined;
156
+ const top = sidebarIsChrome ? (narrowMenu ?? _jsx(TopBar, {})) : menu;
157
+ /* The sidebar sits on the ground tone, the content on the paper (surface): the same white
158
+ for both made the navigation read as part of the list bar. On a phone it is hidden: the
159
+ drawer shows it. */
160
+ const aside = sidebar === undefined ? null : (_jsx("aside", { className: "sticky w-(--container-sidebar) shrink-0 self-start overflow-y-auto overscroll-contain border-r border-line bg-ground max-sm:hidden", style: { ...stickyTop, height: "calc(100dvh - var(--sticky-top, 0px))" }, children: sidebar }));
161
+ return (_jsx(SidebarDrawerContext, { value: drawer, children: _jsxs("div", { className: "relative flex min-h-dvh min-w-0 flex-col bg-ground", children: [top === undefined ? null : (
162
+ /* Hidden on a wide screen when it is only the phone's bar: it measures 0 there, so
163
+ nothing below is pushed down by it. */
164
+ _jsx("div", { ref: bar.ref, className: `sticky top-0 z-40 ${sidebarIsChrome ? "sm:hidden" : ""}`, children: top })), sidebar === undefined ? (_jsx("main", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: children })) : sidebarIsChrome ? (_jsxs("div", { className: "flex min-w-0 flex-1 items-start", style: bar.below, children: [aside, _jsx("main", { className: "flex min-w-0 flex-1 flex-col self-stretch", children: children })] })) : (_jsx(HeaderSlotContext, { value: slot, children: _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: [_jsx("div", { ref: (node) => {
165
+ head.ref.current = node;
166
+ setSlot(node);
167
+ }, className: "sticky z-30 min-w-0", style: head.self }), _jsxs("div", { className: "flex min-w-0 flex-1 items-start", style: head.below, children: [aside, _jsx("main", { className: "flex min-w-0 flex-1 flex-col self-stretch", children: children })] })] }) })), status, sidebar === undefined ? null : (_jsx(SidebarDrawerPanel, { id: drawerId, open: drawerOpen, onClose: () => setDrawerOpen(false), children: sidebar }))] }) }));
80
168
  }