@sincpro/web-framework 3.11.0 → 3.12.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.
package/README.md CHANGED
@@ -365,9 +365,9 @@ function InvoiceView({ api, resource }: ViewProps) {
365
365
  }
366
366
  ```
367
367
 
368
- How a record of an entity LOOKS — as a choice, a row, a card — is said once, around the entity,
369
- and every place that draws one uses it (`EntityPicker`, `EntityTags`, ⌘K, `EntityList`'s rows and
370
- board). Each size answers web-ui's props for it, over the default; give only what changes:
368
+ How a record of an entity LOOKS — as a choice, a row, a card, a tile — is said once, around the
369
+ entity, and every place that draws one uses it (`EntityPicker`, `EntityTags`, ⌘K, `EntityList`'s
370
+ rows, board and tiles). Each size answers web-ui's props for it, over the default; give only what changes:
371
371
 
372
372
  ```tsx
373
373
  export const customers = presented(
@@ -376,6 +376,7 @@ export const customers = presented(
376
376
  option: (c) => ({ meta: `NIT ${c.tax_id}`, aside: <Balance value={c.balance} /> }),
377
377
  row: (c) => (c.blocked ? { tags: <Tag tone="bad">Blocked</Tag> } : {}),
378
378
  card: (c) => ({ subtitle: c.city }),
379
+ tile: (c) => ({ media: { src: c.logo_url }, figure: <Balance value={c.balance} /> }),
379
380
  },
380
381
  );
381
382
  ```
@@ -405,7 +406,8 @@ import { browserTracer } from "@sincpro/web-framework/telemetry"; // optional
405
406
  const release = "my-app:1.0.0"; // <name>:<version>, the backend's APP_RELEASE
406
407
  configureProcess({
407
408
  identity: { release }, // + tenant, when the deployment serves one
408
- tracer: browserTracer({ endpoint: settings.otlp, release }),
409
+ // recordExceptions: false — a failure's message and stack stay in GlitchTip, not in every span
410
+ tracer: browserTracer({ endpoint: settings.otlp, release, recordExceptions: false }),
409
411
  reporter: glitchtipReporter({ dsn: settings.glitchtip, release }),
410
412
  });
411
413
  reportUncaught(); // optional: what nobody caught — a click handler, a promise nobody waited for
@@ -528,7 +530,13 @@ export async function register() {
528
530
  if (process.env.NEXT_RUNTIME !== "nodejs") return;
529
531
  const { registerServerTracing } = await import("@sincpro/web-framework/telemetry/server");
530
532
  const endpoint = process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT; // none: tracing stays off
531
- await registerServerTracing({ endpoint, release, environment, oneTreePerRequest: true });
533
+ await registerServerTracing({
534
+ endpoint,
535
+ release,
536
+ environment,
537
+ oneTreePerRequest: true,
538
+ recordExceptions: false, // the detail is the error tracker's
539
+ });
532
540
  }
533
541
 
534
542
  // where the server runs use cases — once per realm; in a browser it does nothing
@@ -543,6 +551,11 @@ unless the platform registered one first, and a use case with no parent of its o
543
551
  the active span (client-framework 2.5's `adoptActiveSpan`). Without it — the default — each use
544
552
  case's span starts a trace of its own, as before.
545
553
 
554
+ `recordExceptions: false` (both tracers, client-framework 2.6+) keeps a failed use case's span
555
+ to what the run says — `error.type`, `sincpro.outcome`, an ERROR status — without its exception:
556
+ where errors go to an error tracker with their trace id, the message and the stack are already
557
+ there, under its access rules, and a failure's message can name a customer. Default `true`.
558
+
546
559
  `registerServerTracing` also registers the W3C trace-context propagator (no baggage), unless the
547
560
  platform registered one: an SSR framework reads and writes `traceparent` only through it. With it
548
561
  and `oneTreePerRequest`, a request that arrives with a `traceparent` continues that trace, and
@@ -626,7 +639,7 @@ hook and draw your own, or go straight to the loose piece.
626
639
  | A value outside a model | — | `useTextOf` | `moneyTextOf`, `dayTextOf`, `instantTextOf`, `numberTextOf` |
627
640
  | A file or a photo it holds | `EntityList`, `RecordField`: by its widget, as a `FileValue` | — | `attachmentOf`, `storedFileOf`, `renditionUrl` |
628
641
  | What is a record, at any size? | `cardOf`, `relationOf` | `useSummaryOf` | `summaryOf` |
629
- | How does a record look? | `presented(entity, { option, row, card })` | — | `presentationOf` |
642
+ | How does a record look? | `presented(entity, { option, row, card, tile })` | — | `presentationOf` |
630
643
  | N records: search, filter, page | `EntityList`, `EntitySearchBar` | `useListing`, `useGroups` | `transport.list(route, criteria)` |
631
644
  | A named slice (to collect, …) | `defineList` + `listView` | `useListing(list)` | `scopeOf` |
632
645
  | A record's whole screen | `EntityRecord`, `entityView` without `record` | `useRecordScreen` | `formOf` |
@@ -640,7 +653,7 @@ hook and draw your own, or go straight to the loose piece.
640
653
  | Choose several (many2many) | `EntityTags` | `useLookup` (`values`) | `lookupOf` |
641
654
  | A relation, from the model alone | `RecordField name="customer_id"` | `useEntityFor` | `relationFieldOf`, `entityFor` |
642
655
  | Open it where it belongs | `RelatedRecord`, `entityView`, `EntityList openTargets` | — | `openIn`, `targetsFor`, `OpenInMenu` |
643
- | Look at the set several ways | `EntityList views` (table, rows, board, sheet) | — | web-ui's `List.*` |
656
+ | Look at the set several ways | `EntityList views` (table, rows, board, sheet, tiles) | — | web-ui's `List.*` |
644
657
  | Cross it by two fields | `EntityList pivot` | `usePivot` | `pivotOf` |
645
658
  | Order by several fields | the bar's criteria builder | `listing.orderBy([...])` | criteria's `order` |
646
659
  | Act on it (with a dry run) | `ServiceButton` (a use case), `CommandButton`, row commands | `useService`, `useCommand` | `transport.send` |
@@ -56,7 +56,7 @@ export type ListDefinition<T extends AnyRecord = AnyRecord> = {
56
56
  * Excel». Without it, the ones the entity's search template names, else its display. */
57
57
  facets?: readonly string[];
58
58
  /** The faces it offers, the first one shown. */
59
- views?: readonly ("table" | "rows" | "board" | "sheet" | "pivot")[];
59
+ views?: readonly ("table" | "rows" | "board" | "tiles" | "sheet" | "pivot")[];
60
60
  /** Grouped from the start — the server counts the groups. */
61
61
  groupBy?: readonly GroupLevel[];
62
62
  /** The fields «Group by» offers, in this order — among those the model lets split the set. */
@@ -6,7 +6,7 @@ import { type Attributes, type Tracer } from "@sincpro/client-framework";
6
6
  * // the application — domains/common/infrastructure/telemetry.ts
7
7
  * import { browserTracer } from "./index.js";
8
8
  * const release = "forge-web:1.4.0"; // the backend's APP_RELEASE
9
- * const tracer = browserTracer({ endpoint: settings.otlp, release });
9
+ * const tracer = browserTracer({ endpoint: settings.otlp, release, recordExceptions: false });
10
10
  * configureProcess({ identity: { release }, tracer, reporter }); // entrypoints/main.tsx
11
11
  *
12
12
  * Context: optional on every count. It is an entry of its own that nothing else in this package
@@ -42,6 +42,15 @@ export type BrowserTracerOptions = {
42
42
  sampling?: number;
43
43
  /** More resource attributes (`tenant.group`, …). */
44
44
  attributes?: Attributes;
45
+ /**
46
+ * Whether a failed use case's span carries its exception — type, message and stack — or only
47
+ * that it failed (`error.type`, `sincpro.outcome`, an ERROR status). `false` where errors go to
48
+ * an error tracker (`@sincpro/web-framework/errors`): the detail is there already, with the
49
+ * trace's id, under that tool's access; copied into every span it also reaches whatever stores
50
+ * traces, and in an ERP a failure's message can name a customer or an amount. Default `true`,
51
+ * as client-framework's (`openTelemetryTracer`'s `recordExceptions`, 2.6+; older ignore it).
52
+ */
53
+ recordExceptions?: boolean;
45
54
  };
46
55
  export type BrowserTracer = Tracer & {
47
56
  /** Sends what is buffered now. Called by itself when the page is hidden or left. */
@@ -44,7 +44,9 @@ export function browserTracer(options) {
44
44
  }),
45
45
  spanProcessors: [new BatchSpanProcessor({ exporter })],
46
46
  });
47
- ready = openTelemetryTracer(provider.getTracer(String(resource["service.name"])));
47
+ ready = openTelemetryTracer(provider.getTracer(String(resource["service.name"])), options.recordExceptions === undefined
48
+ ? {}
49
+ : { recordExceptions: options.recordExceptions });
48
50
  flush = () => provider.forceFlush();
49
51
  // A page that is hidden may never come back: what is buffered goes now.
50
52
  const leave = () => void flush().catch(() => undefined);
@@ -62,6 +62,15 @@ export type ServerTracingOptions = {
62
62
  * said once and the rest works as without it.
63
63
  */
64
64
  oneTreePerRequest?: boolean;
65
+ /**
66
+ * Whether a failed use case's span carries its exception — type, message and stack — or only
67
+ * that it failed (`error.type`, `sincpro.outcome`, an ERROR status). `false` where errors go to
68
+ * an error tracker (`@sincpro/web-framework/errors`): the detail is there already, with the
69
+ * trace's id, under that tool's access; copied into every span it also reaches whatever stores
70
+ * traces, and in an ERP a failure's message can name a customer or an amount. Default `true`,
71
+ * as client-framework's (`openTelemetryTracer`'s `recordExceptions`, 2.6+; older ignore it).
72
+ */
73
+ recordExceptions?: boolean;
65
74
  };
66
75
  /** The process's tracing, once registered. */
67
76
  export type ServerTracing = {
@@ -22,15 +22,21 @@ export function registerServerTracing(options) {
22
22
  if (shared.registered === undefined) {
23
23
  // Before the first page: every realm's tracer reads it when it is first asked for.
24
24
  shared.adoptActiveSpan = options.oneTreePerRequest === true;
25
+ if (options.recordExceptions !== undefined)
26
+ shared.recordExceptions = options.recordExceptions;
25
27
  shared.registered = started({ ...options, endpoint });
26
28
  }
27
29
  return shared.registered;
28
30
  }
29
31
  /** A tracer of client-framework's over OpenTelemetry's, as this process's registration asked. */
30
32
  function tracerOver(trace, overOpenTelemetry) {
31
- return (name) => overOpenTelemetry(trace.getTracer(name), {
32
- adoptActiveSpan: held().adoptActiveSpan === true,
33
- });
33
+ return (name) => {
34
+ const { adoptActiveSpan, recordExceptions } = held();
35
+ return overOpenTelemetry(trace.getTracer(name), {
36
+ adoptActiveSpan: adoptActiveSpan === true,
37
+ ...(recordExceptions === undefined ? {} : { recordExceptions }),
38
+ });
39
+ };
34
40
  }
35
41
  /**
36
42
  * What is active follows each request through its awaits: Node's AsyncLocalStorage, registered
@@ -5,12 +5,12 @@ export { attachmentOf } from "./files.js";
5
5
  export { BatchProgress } from "./list/BatchProgress.js";
6
6
  export { aggregateOf, type ColumnOptions, columnsOf, } from "./list/columns.js";
7
7
  export { actionsOf, type ScreenActions } from "./list/dock.js";
8
- export { type EntityFace, EntityList, type EntityListProps, type View, } from "./list/EntityList.js";
8
+ export { type EntityEmpty, type EntityFace, EntityList, type EntityListProps, type View, } from "./list/EntityList.js";
9
9
  export { EntitySearchBar } from "./list/EntitySearchBar.js";
10
10
  export { groupableOf, pilesOf } from "./list/groups.js";
11
11
  export { OpenInMenu } from "./list/openIn.js";
12
12
  export { pivotOf } from "./list/pivot.js";
13
- export { type CardLook, type ChoiceTones, type OptionLook, type PartLook, partLookOf, type PartLooks, type PartOf, type Presentation, presentationOf, type Presented, presented, type RowLook, tonesOver, } from "./list/presentation.js";
13
+ export { type CardLook, type ChoiceTones, type OptionLook, type PartLook, partLookOf, type PartLooks, type PartOf, type Presentation, presentationOf, type Presented, presented, type RowLook, type TileLook, tonesOver, } from "./list/presentation.js";
14
14
  export { type Choice, type Chooser, findChoices, type FrameworkReads, modelLoader, recordsBrowser, RecordsBrowserProvider, recordsSearch, refusalNotice, useLoadModel, useRecordsBrowser, useSearchRecords, } from "./list/records.js";
15
15
  export { type RowCommand, type RowCommands, useRowCommands, } from "./list/rowCommands.js";
16
16
  export { facetsOf, modelOf } from "./list/search.js";
@@ -6,7 +6,7 @@ import type { Listing } from "../../react/useListing.js";
6
6
  import { type ListSelection } from "../../react/useSelection.js";
7
7
  import { type ScreenActions } from "./dock.js";
8
8
  import { type RowCommand } from "./rowCommands.js";
9
- import { type ListCrumb, type ListPresentProps, type ListSet, type OpenTarget, type RowAction, type YesNoColumn } from "@sincpro/web-ui";
9
+ import { type ListCrumb, type ListEmpty, type ListPresentProps, type ListSet, type OpenTarget, type RowAction, type YesNoColumn } from "@sincpro/web-ui";
10
10
  import { type ReactNode } from "react";
11
11
  /**
12
12
  * A whole collection from a `Listing`: the bar, the search, the set in the views it offers,
@@ -53,10 +53,12 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
53
53
  yesNo?: Readonly<Partial<Record<string, YesNoColumn<T>>>>;
54
54
  /**
55
55
  * The ways to look at the set, the first one shown: `table` (columns), `rows` (a name and
56
- * its facts, what a narrow panel wants), `board` (cards) and `sheet` (a spreadsheet, every
57
- * cell a value — web-ui's, windowed). The same set, the same search, the same page in each.
58
- * Without it, a named list's; else all four on a screen, and the table (rows when narrow)
59
- * inside a record. The id of one of `faces` opens on that face.
56
+ * its facts, what a narrow panel wants), `board` (cards), `sheet` (a spreadsheet, every
57
+ * cell a value — web-ui's, windowed) and `tiles` (a grid of pictures — a till's products, a
58
+ * shop's items; asked for, never offered by itself: a set of invoices has no picture). The
59
+ * same set, the same search, the same page in each. Without it, a named list's; else the
60
+ * first four on a screen, and the table (rows when narrow) inside a record. The id of one
61
+ * of `faces` opens on that face.
60
62
  */
61
63
  views?: readonly (View | (string & {}))[];
62
64
  /**
@@ -91,14 +93,27 @@ export type EntityListProps<T extends AnyRecord, C extends CommandBodies = Comma
91
93
  openTargets?: readonly OpenTarget[];
92
94
  /** Open a row's record there — without `api`, how a screen (a one2many) places it. */
93
95
  onOpenIn?: (row: T, to: OpenTarget) => void;
94
- /** What an empty list says. */
95
- empty?: string;
96
+ /**
97
+ * What an empty list says. A text is its sentence; an object is web-ui's empty (2.14) — a
98
+ * `title`, an `icon` or the application's `illustration`, an `action` — for a list that IS the
99
+ * screen («Todavía no hay facturas» with a button to create one). What it leaves out is the
100
+ * framework's words, and `whenFiltered` is what it says when a search emptied it.
101
+ */
102
+ empty?: string | EntityEmpty;
96
103
  /**
97
104
  * `"bar"` (the default) is the full search bar with the criteria builder; `"box"` is one
98
105
  * text box over the entity's search template — a chooser, a narrow panel; `false` is none.
99
106
  * Both ask the server on Enter, never per keystroke: a table is searched on purpose.
100
107
  */
101
108
  search?: "bar" | "box" | false;
109
+ /**
110
+ * The bar remembers, in this browser, the last searches put on this list, and offers them
111
+ * when it takes the focus empty («Recientes»). `true` keeps them under the list's key (a
112
+ * named list's, else its entity's); a text, under that name — one per tenant, say. Off by
113
+ * default: what was searched may name a customer, and whether a browser may keep it is the
114
+ * application's call.
115
+ */
116
+ recent?: boolean | string;
102
117
  /** What each group adds up when the list is grouped — «Total 1.204.933,00» in its header,
103
118
  * summed by the server over every row of it. Without it, the figures the model computes
104
119
  * (read-only exact numbers, `sumsOf`); `false` adds nothing up. */
@@ -157,5 +172,12 @@ export type EntityFace<T> = {
157
172
  wide?: boolean;
158
173
  render: (set: ListSet<T>) => ReactNode;
159
174
  };
160
- export type View = "table" | "rows" | "board" | "sheet" | "pivot";
161
- export declare function EntityList<T extends AnyRecord, C extends CommandBodies = CommandBodies>({ listing, api, columns: askedColumns, cells, yesNo, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search, sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable, selection: held, selectionActions, embedded, create, commands, rowActions: askedRowActions, faces, }: EntityListProps<T, C>): import("react").JSX.Element;
175
+ /** An empty list as web-ui draws it (`ListEmpty`), every sentence optional: the copy's words. */
176
+ export type EntityEmpty = Omit<ListEmpty, "sentence" | "whenFiltered"> & {
177
+ sentence?: string;
178
+ whenFiltered?: Omit<NonNullable<ListEmpty["whenFiltered"]>, "sentence"> & {
179
+ sentence?: string;
180
+ };
181
+ };
182
+ export type View = "table" | "rows" | "board" | "tiles" | "sheet" | "pivot";
183
+ export declare function EntityList<T extends AnyRecord, C extends CommandBodies = CommandBodies>({ listing, api, columns: askedColumns, cells, yesNo, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search, recent: askedRecent, sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable, selection: held, selectionActions, embedded, create, commands, rowActions: askedRowActions, faces, }: EntityListProps<T, C>): import("react").JSX.Element;
@@ -20,7 +20,7 @@ import { EntitySearchBar } from "./EntitySearchBar.js";
20
20
  import { pilesOf } from "./groups.js";
21
21
  import { OpenInMenu, openOptions, targetsFor } from "./openIn.js";
22
22
  import { pivotOf } from "./pivot.js";
23
- import { over, presentationOf } from "./presentation.js";
23
+ import { over, presentationOf, } from "./presentation.js";
24
24
  import { RESTORE, useRowCommands, } from "./rowCommands.js";
25
25
  import { Button, Callout, List, Pagination, pathKey, RecordCard, SearchField, Tag, } from "@sincpro/web-ui";
26
26
  import { Plus, RotateCcw } from "lucide-react";
@@ -34,16 +34,33 @@ const NO_WORKSPACE = {
34
34
  };
35
35
  /** How many lists' trails are kept: the records opened from the last fifty lists page on. */
36
36
  const TRAILS = 50;
37
+ /** web-ui's empty for this list: what the screen said, over the framework's words. */
38
+ function emptyOf(asked, words) {
39
+ const own = typeof asked === "string" ? { sentence: asked } : (asked ?? {});
40
+ return {
41
+ ...own,
42
+ sentence: own.sentence ?? words.empty,
43
+ whenFiltered: {
44
+ ...own.whenFiltered,
45
+ sentence: own.whenFiltered?.sentence ?? words.emptyFiltered,
46
+ },
47
+ };
48
+ }
37
49
  /** No commands: one constant, so the hook is not handed a new array on every render. */
38
50
  const NO_COMMANDS = [];
39
51
  /** What a list offers when nobody said: every face that needs no configuration. */
40
52
  const EVERY_VIEW = ["table", "rows", "board", "sheet"];
41
- export function EntityList({ listing, api, columns: askedColumns, cells, yesNo, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search = "bar", sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable = false, selection: held, selectionActions, embedded = false, create = true, commands = NO_COMMANDS, rowActions: askedRowActions, faces, }) {
53
+ export function EntityList({ listing, api, columns: askedColumns, cells, yesNo, views: askedViews, title: askedTitle, description: askedDescription, crumbs, actions, onOpen, onPeek, openTargets, onOpenIn, pivot: pivotAsked, empty, search = "bar", recent: askedRecent = false, sums, filters: askedFilters, facets: askedFacets, groupable: askedGroupable, selectable = false, selection: held, selectionActions, embedded = false, create = true, commands = NO_COMMANDS, rowActions: askedRowActions, faces, }) {
42
54
  // A named list (`defineList`) brings its own columns, filters, faces and words; what the
43
55
  // screen passes wins.
44
56
  const definition = listing.definition;
45
- // The entity's own look (`presented`): its columns, the tones of its choices, its row and card.
57
+ // The entity's own look (`presented`): its columns, the tones of its choices, its row, card, tile.
46
58
  const look = presentationOf(listing.entity);
59
+ const recent = askedRecent === false
60
+ ? undefined
61
+ : askedRecent === true
62
+ ? (definition?.key ?? listing.entity.kind)
63
+ : askedRecent;
47
64
  const columns = askedColumns ?? definition?.columns ?? look.columns;
48
65
  const views = askedViews ??
49
66
  definition?.views ??
@@ -335,11 +352,11 @@ export function EntityList({ listing, api, columns: askedColumns, cells, yesNo,
335
352
  };
336
353
  })()),
337
354
  }, look.row?.(row));
338
- // Without a look of its own, the board's card is web-ui's, made of the row. With one, the
339
- // same card — the row's name, meta and tags — under it, and pressing it is still the list's:
340
- // web-ui (1.5) hands an own card the list's press rule (`ways.press`: open, or choose).
341
- const ownCard = look.card;
342
- const cardOfRow = ownCard === undefined
355
+ // Without a look of its own, the board's card — and the tile — is web-ui's, made of the row.
356
+ // With one, the same card — the row's name, meta and tags — under it, and pressing it is still
357
+ // the list's: web-ui (1.5) hands an own card the list's press rule (`ways.press`: open, or
358
+ // choose). A tile is the same card in its `tile` shape (web-ui 2.13), under its own look.
359
+ const cardFrom = (own, layout) => own === undefined
343
360
  ? undefined
344
361
  : (row, ways) => {
345
362
  const d = rowOf(row);
@@ -347,8 +364,10 @@ export function EntityList({ listing, api, columns: askedColumns, cells, yesNo,
347
364
  title: d.name,
348
365
  ...(d.tags === undefined ? {} : { tags: d.tags }),
349
366
  ...(d.meta === undefined ? {} : { meta: d.meta }),
350
- }, ownCard(row)), ...(ways.press === undefined ? {} : { onOpen: ways.press }) }));
367
+ }, own(row)), ...(layout === undefined ? {} : { layout }), ...(ways.press === undefined ? {} : { onOpen: ways.press }) }));
351
368
  };
369
+ const cardOfRow = cardFrom(look.card);
370
+ const tileOfRow = cardFrom(look.tile, "tile");
352
371
  // Grouped: the SERVER counts the groups; a group's rows are read when it is opened, so every
353
372
  // group starts closed. Every face of web-ui (1.4) draws these piles, the table included, and
354
373
  // each says what its next «more» brings (1.5).
@@ -458,15 +477,12 @@ export function EntityList({ listing, api, columns: askedColumns, cells, yesNo,
458
477
  error: failure === null
459
478
  ? null
460
479
  : [failure.heading, failure.sentence].filter(Boolean).join(". "),
461
- }, filtered: listing.selection !== undefined || listing.text !== "", empty: {
462
- sentence: empty ?? copy.empty,
463
- whenFiltered: { sentence: copy.emptyFiltered },
464
- }, ...(selection === undefined ? {} : { selection }), ...(opening === undefined ? {} : { onOpen: opening }), ...(peeking === undefined ? {} : { onPeek: peeking, rowClick: "open" }), ...(elsewhere.length === 0 || openingIn === undefined
480
+ }, filtered: listing.selection !== undefined || listing.text !== "", empty: emptyOf(empty, copy), ...(selection === undefined ? {} : { selection }), ...(opening === undefined ? {} : { onOpen: opening }), ...(peeking === undefined ? {} : { onPeek: peeking, rowClick: "open" }), ...(elsewhere.length === 0 || openingIn === undefined
465
481
  ? {}
466
482
  : {
467
483
  openTargets: elsewhere,
468
484
  onOpenIn: (row, to) => openingNow.current?.(row, to),
469
- }), children: [_jsxs(List.Bar, { children: [trail === undefined || trail.length === 0 ? null : _jsx(List.Crumbs, { crumbs: trail }), embedded ? null : (_jsx(List.Identity, { title: title ?? nameOf(meta, locale), ...(description === undefined ? {} : { description }) })), search === "bar" ? (_jsx(List.Search, { children: _jsx(EntitySearchBar, { listing: listing, filters: filters, groups: groups, ...(groupable === undefined ? {} : { groupable }), ...(facets === undefined ? {} : { facets }), ...(asked === "" ? {} : { seed: asked }) }) })) : null, search === "box" && meta?.search != null ? (_jsx(List.Search, { children: _jsx(SearchField, { value: draft, onChange: (next) => {
485
+ }), children: [_jsxs(List.Bar, { children: [trail === undefined || trail.length === 0 ? null : _jsx(List.Crumbs, { crumbs: trail }), embedded ? null : (_jsx(List.Identity, { title: title ?? nameOf(meta, locale), ...(description === undefined ? {} : { description }) })), search === "bar" ? (_jsx(List.Search, { children: _jsx(EntitySearchBar, { listing: listing, filters: filters, groups: groups, ...(groupable === undefined ? {} : { groupable }), ...(facets === undefined ? {} : { facets }), ...(asked === "" ? {} : { seed: asked }), ...(recent === undefined ? {} : { recentKey: recent }) }) })) : null, search === "box" && meta?.search != null ? (_jsx(List.Search, { children: _jsx(SearchField, { value: draft, onChange: (next) => {
470
486
  setDraft(next);
471
487
  // Emptied (or cleared with ×): the whole set again, at once.
472
488
  if (next === "" && listing.text !== "")
@@ -485,5 +501,5 @@ export function EntityList({ listing, api, columns: askedColumns, cells, yesNo,
485
501
  measures: [],
486
502
  meta,
487
503
  locale,
488
- }) })) : null, views.includes("board") ? (_jsx(List.Board, { ...(cardOfRow === undefined ? {} : { card: cardOfRow }) })) : null, (faces ?? []).map((face) => (_jsx(List.Present, { id: face.id, label: face.label, icon: face.icon, ...(face.wide === undefined ? {} : { wide: face.wide }), children: face.render }, face.id))), refused === null ? null : (_jsx(Callout, { tone: "bad", title: refused.heading, children: refused.sentence }))] }));
504
+ }) })) : null, views.includes("board") ? (_jsx(List.Board, { ...(cardOfRow === undefined ? {} : { card: cardOfRow }) })) : null, views.includes("tiles") ? (_jsx(List.Tiles, { ...(tileOfRow === undefined ? {} : { card: tileOfRow }) })) : null, (faces ?? []).map((face) => (_jsx(List.Present, { id: face.id, label: face.label, icon: face.icon, ...(face.wide === undefined ? {} : { wide: face.wide }), children: face.render }, face.id))), refused === null ? null : (_jsx(Callout, { tone: "bad", title: refused.heading, children: refused.sentence }))] }));
489
505
  }
@@ -33,7 +33,7 @@ import type { Listing } from "../../react/useListing.js";
33
33
  * <List.Search><EntitySearchBar listing={listing} filters={…} /></List.Search>
34
34
  */
35
35
  export type { NamedFilter };
36
- export declare function EntitySearchBar<T extends AnyRecord>({ listing, filters, groups, groupable: only, facets: named, seed, }: {
36
+ export declare function EntitySearchBar<T extends AnyRecord>({ listing, filters, groups, groupable: only, facets: named, seed, recentKey, }: {
37
37
  listing: Listing<T>;
38
38
  /** The cuts this set offers by name: «sólo pagadas», «vencidas». */
39
39
  filters?: readonly NamedFilter<T>[];
@@ -48,4 +48,9 @@ export declare function EntitySearchBar<T extends AnyRecord>({ listing, filters,
48
48
  /** A text to start on, put as the literal search chip — what was typed in a picker whose
49
49
  * «Buscar más…» opened this list. */
50
50
  seed?: string;
51
+ /** Under which name this bar remembers, in this browser, the last searches put — offered
52
+ * when the empty bar takes the focus («Recientes», web-ui 2.14). Without it nothing is
53
+ * remembered: what was searched may name a customer, and only the application knows
54
+ * whether its browsers may keep that. */
55
+ recentKey?: string;
51
56
  }): import("react").JSX.Element | null;
@@ -9,7 +9,7 @@ import { CriteriaBuilder, describeFilter, Dialog, fillCopy, filterCriteria, Grou
9
9
  import { useEffect, useMemo, useRef, useState } from "react";
10
10
  /** No grouping: one constant, so the control is not handed a new array on every render. */
11
11
  const NO_LEVELS = [];
12
- export function EntitySearchBar({ listing, filters = [], groups, groupable: only, facets: named, seed, }) {
12
+ export function EntitySearchBar({ listing, filters = [], groups, groupable: only, facets: named, seed, recentKey, }) {
13
13
  const copy = frameworkCopy().list;
14
14
  const { meta, locale } = listing;
15
15
  const [put, setPut] = useState([]);
@@ -80,7 +80,7 @@ export function EntitySearchBar({ listing, filters = [], groups, groupable: only
80
80
  },
81
81
  }), ...(groups === undefined || groupable.length === 0
82
82
  ? {}
83
- : { grouping: _jsx(GroupingLevels, { fields: groupable, control: control }) }), onOpenBuilder: () => setBuilding(true), ...(meta?.search == null
83
+ : { grouping: _jsx(GroupingLevels, { fields: groupable, control: control }) }), onOpenBuilder: () => setBuilding(true), ...(recentKey === undefined ? {} : { recentKey }), ...(meta?.search == null
84
84
  ? {}
85
85
  : {
86
86
  literal: (text) => matching(meta, text).selection ?? null,
@@ -16,6 +16,7 @@ import type { ComponentProps } from "react";
16
16
  * option: (c) => ({ meta: c.tax_id, aside: <Saldo value={c.balance} /> }),
17
17
  * row: (c) => ({ tags: c.blocked ? <Tag tone="bad">Bloqueado</Tag> : undefined }),
18
18
  * card: (c) => ({ subtitle: c.city, figure: <Saldo value={c.balance} /> }),
19
+ * tile: (c) => ({ media: { src: c.photo_url, person: true } }),
19
20
  * });
20
21
  *
21
22
  * Each size answers the PROPS of web-ui's piece for it (`PickerItem`, `RowOf`, `RecordCard`),
@@ -35,6 +36,9 @@ export type OptionLook = Partial<Omit<PickerItem, "id">>;
35
36
  export type RowLook = Partial<RowOf>;
36
37
  /** The board's card. Opening it stays the list's: `onOpen` is not the presentation's. */
37
38
  export type CardLook = Partial<Omit<ComponentProps<typeof RecordCard>, "onOpen">>;
39
+ /** A tile of the «tiles» face — web-ui's `RecordCard layout="tile"`: the picture on top
40
+ * (`media`), the name, the figure (a price). Its shape stays the tile's. */
41
+ export type TileLook = Omit<CardLook, "layout">;
38
42
  /** The colour of each value of a choice, by field and by value as text (the Meta's own keys):
39
43
  * `{ estado: { APROBADO: "good", RECHAZADO: "bad" } }`. */
40
44
  export type ChoiceTones<T> = Readonly<Partial<Record<keyof T & string, Readonly<Record<string, Tone>>>>>;
@@ -42,6 +46,16 @@ export type Presentation<T> = {
42
46
  option?: (record: T) => OptionLook;
43
47
  row?: (record: T) => RowLook;
44
48
  card?: (record: T) => CardLook;
49
+ /**
50
+ * A tile of the «tiles» face — a product on a till's or a shop's grid: `media` (its
51
+ * picture), `figure` (its price), `badge`, `disabled` (out of stock). Without it, the tile
52
+ * is web-ui's, made of the row.
53
+ *
54
+ * Context: a tile is not a card. A card is told apart by its facts (`fields`, a figure beside
55
+ * the name); a tile by its picture and its price, and the whole tile is pressed. One look for
56
+ * both put a board's facts on a shop's grid, or a product's photo on a pipeline.
57
+ */
58
+ tile?: (record: T) => TileLook;
45
59
  /**
46
60
  * The colour of each value of a choice — a state, a priority. Declared once here and used
47
61
  * wherever the framework draws the value: a table's cell, a row's and a card's tag, the tag of
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sincpro/web-framework",
3
- "version": "3.11.0",
3
+ "version": "3.12.0",
4
4
  "description": "The web client of sincpro_framework: entities, lists and records bound to the metadata the server publishes, drawn with @sincpro/web-ui and arranged with @sincpro/web-composer.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -55,7 +55,7 @@
55
55
  "@sincpro/criteria": "^2.4.0",
56
56
  "@sincpro/criteria-react": "^2.4.0",
57
57
  "@sincpro/web-composer": "^1.7.0",
58
- "@sincpro/web-ui": "^2.11.0",
58
+ "@sincpro/web-ui": "^2.14.0",
59
59
  "react": ">=19",
60
60
  "react-dom": ">=19"
61
61
  },
@@ -95,11 +95,11 @@
95
95
  "@opentelemetry/sdk-trace": "3.1.0",
96
96
  "@sentry/browser": "11.11.0",
97
97
  "@sentry/core": "11.11.0",
98
- "@sincpro/client-framework": "^2.5.0",
99
- "@sincpro/criteria": "^2.4.0",
100
- "@sincpro/criteria-react": "^2.4.0",
101
- "@sincpro/web-composer": "^1.8.0",
102
- "@sincpro/web-ui": "^2.11.0",
98
+ "@sincpro/client-framework": "^2.6.0",
99
+ "@sincpro/criteria": "^2.5.0",
100
+ "@sincpro/criteria-react": "^2.5.0",
101
+ "@sincpro/web-composer": "^1.9.0",
102
+ "@sincpro/web-ui": "^2.14.0",
103
103
  "@storybook/addon-a11y": "10.6.5",
104
104
  "@storybook/addon-docs": "10.6.5",
105
105
  "@storybook/addon-mcp": "10.6.5",