@kapiuara/ui 0.4.0 → 0.5.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.
@@ -13,8 +13,16 @@ export type KapiFacet = {
13
13
  key: string;
14
14
  label: string;
15
15
  kind: KapiFacetKind;
16
- /** Opciones de una faceta `list`. */
16
+ /** Opciones de una faceta `list`, cuando se conocen de antemano. */
17
17
  options?: ReadonlyArray<KapiFacetOption> | undefined;
18
+ /**
19
+ * Carga de opciones según lo tipeado, para una faceta `list` cuyos valores vive en el servidor.
20
+ * REEMPLAZA al filtro local: lo que devuelve se muestra tal cual, porque el que filtró fue el
21
+ * servidor. Se aborta con `signal` cuando empieza otro pedido, al cerrar el menú o al desmontar.
22
+ */
23
+ loadOptions?: ((query: string, context: {
24
+ signal: AbortSignal;
25
+ }) => Promise<ReadonlyArray<KapiFacetOption>>) | undefined;
18
26
  /**
19
27
  * Recibe el valor elegido: el `value` de la opción, la fecha como `yyyy-mm-dd`, el rango como
20
28
  * `yyyy-mm-dd/yyyy-mm-dd` (ver `parseDateRangeValue`) o `"true"` (flag).
@@ -42,7 +50,9 @@ export type KapiFacetMenuItem = {
42
50
  * Con una faceta `list` pendiente: sus opciones que coinciden. Con una `date` o `dateRange`: nada (decide
43
51
  * el calendario).
44
52
  */
45
- export declare function facetMenuItems(facets: ReadonlyArray<KapiFacet>, pending: KapiFacet | null, input: string): KapiFacetMenuItem[];
53
+ export declare function facetMenuItems(facets: ReadonlyArray<KapiFacet>, pending: KapiFacet | null, input: string,
54
+ /** Opciones ya cargadas para la faceta pendiente. Si vienen, NO se filtran de nuevo: filtró el servidor. */
55
+ loaded?: ReadonlyArray<KapiFacetOption> | undefined): KapiFacetMenuItem[];
46
56
  /** Mueve el ítem activo con vuelta; desde `-1` entra por el extremo según la dirección. */
47
57
  export declare const moveActive: (index: number, count: number, delta: 1 | -1) => number;
48
58
  export type KapiFacetKeyAction = "next" | "prev" | "select" | "text" | "cancel" | "close" | "dropPending" | "removeLast";
@@ -1,21 +1,24 @@
1
1
  import { normalizeFilterText as e } from "../data/tableLogic.js";
2
2
  //#region src/components/inputs/facetedSearchLogic.ts
3
3
  var t = (t, n) => !n || e(t).includes(n);
4
- function n(n, r, i) {
5
- let a = e(i);
6
- if (r) return r.kind === "list" ? (r.options ?? []).filter((e) => t(e.label, a)).map((e) => ({
4
+ function n(n, r, i, a) {
5
+ let o = e(i);
6
+ if (r) return r.kind === "list" ? a ? a.map((e) => ({
7
+ type: "option",
8
+ option: e
9
+ })) : (r.options ?? []).filter((e) => t(e.label, o)).map((e) => ({
7
10
  type: "option",
8
11
  option: e
9
12
  })) : [];
10
- let o = i.trim(), s = o ? [{
13
+ let s = i.trim(), c = s ? [{
11
14
  type: "text",
12
- text: o
15
+ text: s
13
16
  }] : [];
14
- for (let e of n) t(e.label, a) && s.push({
17
+ for (let e of n) t(e.label, o) && c.push({
15
18
  type: "facet",
16
19
  facet: e
17
20
  });
18
- return s;
21
+ return c;
19
22
  }
20
23
  var r = (e, t, n) => t === 0 ? -1 : e < 0 ? n > 0 ? 0 : t - 1 : (e + n + t) % t;
21
24
  function i(e, t) {