@kapiuara/ui 0.6.0 → 0.8.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 +115 -5
- package/dist/components/chat/KapiComposer.d.ts +2 -2
- package/dist/components/chat/KapiComposer.js +47 -45
- package/dist/components/data/KapiTable.d.ts +58 -1
- package/dist/components/data/KapiTable.js +399 -358
- package/dist/components/data/datasetSelectionLogic.d.ts +22 -0
- package/dist/components/data/datasetSelectionLogic.js +5 -0
- package/dist/components/data/index.d.ts +2 -1
- package/dist/components/data/tableLogic.d.ts +7 -0
- package/dist/components/data/tableLogic.js +21 -16
- package/dist/components/display/KapiTruncate.d.ts +32 -0
- package/dist/components/display/KapiTruncate.js +43 -0
- package/dist/components/display/index.d.ts +3 -0
- package/dist/components/display/truncateLogic.d.ts +6 -0
- package/dist/components/display/truncateLogic.js +4 -0
- package/dist/components/inputs/KapiButton.d.ts +9 -2
- package/dist/components/inputs/KapiButton.js +25 -15
- package/dist/components/inputs/KapiFacetedSearch.d.ts +29 -5
- package/dist/components/inputs/KapiFacetedSearch.js +161 -119
- package/dist/components/inputs/KapiSegmented.d.ts +9 -2
- package/dist/components/inputs/KapiSegmented.js +46 -44
- package/dist/components/inputs/facetedSearchLogic.d.ts +40 -9
- package/dist/components/inputs/facetedSearchLogic.js +38 -20
- package/dist/components/inputs/index.d.ts +2 -2
- package/dist/components/layout/KapiRail.d.ts +1 -1
- package/dist/components/layout/KapiRail.js +57 -50
- package/dist/components/layout/KapiShell.d.ts +27 -4
- package/dist/components/layout/KapiShell.js +23 -22
- package/dist/components/navigation/KapiTabs.d.ts +3 -1
- package/dist/components/navigation/KapiTabs.js +47 -46
- package/dist/components/overlays/KapiCanvasForm.js +2 -6
- package/dist/components/overlays/KapiConfirm.js +1 -6
- package/dist/hooks/colorLogic.d.ts +26 -0
- package/dist/hooks/colorLogic.js +53 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/numberFormatLogic.d.ts +6 -0
- package/dist/hooks/numberFormatLogic.js +7 -0
- package/dist/hooks/rightClick.d.ts +10 -0
- package/dist/hooks/rightClick.js +10 -4
- package/dist/hooks/themeColorsLogic.d.ts +11 -0
- package/dist/hooks/themeColorsLogic.js +37 -0
- package/dist/hooks/themeContrastLogic.d.ts +23 -0
- package/dist/hooks/themeContrastLogic.js +46 -0
- package/dist/hooks/themeDeriveLogic.d.ts +52 -0
- package/dist/hooks/themeDeriveLogic.js +103 -0
- package/dist/hooks/useDragScroll.js +26 -23
- package/dist/hooks/useGlobalRightClick.js +28 -25
- package/dist/hooks/useKapiTheme.d.ts +28 -4
- package/dist/hooks/useKapiTheme.js +82 -50
- package/dist/index.js +132 -126
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { SelectionState } from "./tableLogic";
|
|
2
|
+
export type DatasetNoticeState = "none" | "offer" | "selected";
|
|
3
|
+
/**
|
|
4
|
+
* Qué aviso corresponde: ninguno, la oferta de extender, o el de ya extendido.
|
|
5
|
+
* Una selección parcial nunca ofrece: no se puede extrapolar al dataset.
|
|
6
|
+
*/
|
|
7
|
+
export declare const datasetNoticeState: (input: {
|
|
8
|
+
/** Estado del checkbox de la cabecera. */
|
|
9
|
+
headerState: SelectionState;
|
|
10
|
+
/** Filas seleccionables que la tabla tiene. */
|
|
11
|
+
shown: number;
|
|
12
|
+
/** Filas del dataset completo. */
|
|
13
|
+
total: number;
|
|
14
|
+
/** El consumidor ya extendió la selección. */
|
|
15
|
+
selected: boolean;
|
|
16
|
+
}) => DatasetNoticeState;
|
|
17
|
+
/** Aviso de oferta: «Seleccionaste las 10 de esta página.» («filas» es femenino). */
|
|
18
|
+
export declare const datasetHintLabel: (shown: number) => string;
|
|
19
|
+
/** Acción que extiende (sólo se ofrece con más de una fila, así que va siempre en plural): «Seleccionar las 1.234 del total». */
|
|
20
|
+
export declare const datasetActionLabel: (total: number) => string;
|
|
21
|
+
/** Aviso ya extendido: «Están seleccionadas las 1.234 del total.». */
|
|
22
|
+
export declare const datasetSelectedLabel: (total: number) => string;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { formatCount as e } from "../../hooks/numberFormatLogic.js";
|
|
2
|
+
//#region src/components/data/datasetSelectionLogic.ts
|
|
3
|
+
var t = (e) => e.selected ? "selected" : e.headerState === "all" && e.shown > 0 && e.total > e.shown ? "offer" : "none", n = (t) => t === 1 ? "Seleccionaste la única de esta página." : `Seleccionaste las ${e(t)} de esta página.`, r = (t) => `Seleccionar las ${e(t)} del total`, i = (t) => t === 1 ? "Está seleccionada la única del total." : `Están seleccionadas las ${e(t)} del total.`;
|
|
4
|
+
//#endregion
|
|
5
|
+
export { r as datasetActionLabel, n as datasetHintLabel, t as datasetNoticeState, i as datasetSelectedLabel };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { KapiTable, DEFAULT_TABLE_LABELS } from "./KapiTable";
|
|
2
|
-
export type { KapiTableColumn, KapiTableCellValue, KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, KapiTableCsvOptions, KapiTableLabels, KapiTableProps } from "./KapiTable";
|
|
2
|
+
export type { KapiTableColumn, KapiTableCellValue, KapiTableSortDirection, KapiTableSortState, KapiTableSortValue, KapiTableCsvOptions, KapiTableDataset, KapiTableLabels, KapiTableProps, KapiTableSelectionPreset } from "./KapiTable";
|
|
3
|
+
export { datasetNoticeState, datasetHintLabel, datasetActionLabel, datasetSelectedLabel } from "./datasetSelectionLogic";
|
|
3
4
|
export { KapiTableFilter, DEFAULT_TABLE_FILTER_LABELS } from "./KapiTableFilter";
|
|
4
5
|
export type { KapiTableFilterProps, KapiTableFilterLabels } from "./KapiTableFilter";
|
|
5
6
|
export { KapiPagination } from "./KapiPagination";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Ancho de la columna de checkboxes (px). Las columnas sticky arrancan después de ésta. */
|
|
2
2
|
export declare const CHECKBOX_COL_WIDTH = 46;
|
|
3
|
+
/** Ancho de la columna de selección cuando la cabecera suma el menú de condiciones (`selectionPresets`). */
|
|
4
|
+
export declare const CHECKBOX_PRESETS_COL_WIDTH = 80;
|
|
3
5
|
/** Ancho de la columna del expansor de fila (px). Las columnas sticky arrancan después de ésta. */
|
|
4
6
|
export declare const EXPANDER_COL_WIDTH = 44;
|
|
5
7
|
/** Ancho asumido para una columna sticky sin `width`. */
|
|
@@ -113,6 +115,11 @@ export declare const toggleAllIds: <K>(selected: ReadonlySet<K>, rowIds: Readonl
|
|
|
113
115
|
export declare const rangeBetween: <K>(ids: ReadonlyArray<K>, anchorId: K, targetId: K) => K[];
|
|
114
116
|
/** Suma (`select`) o quita el tramo `rangeIds` de la selección, sin mutar. Respeta los ids fuera del tramo. */
|
|
115
117
|
export declare const applyRangeSelection: <K>(selected: ReadonlySet<K>, rangeIds: ReadonlyArray<K>, select: boolean) => Set<K>;
|
|
118
|
+
/**
|
|
119
|
+
* Selection after picking a condition: inside `rowIds` (what the table knows) the selection becomes
|
|
120
|
+
* exactly `nextIds`; ids of `selected` outside `rowIds` are kept. Does not mutate.
|
|
121
|
+
*/
|
|
122
|
+
export declare const selectOnlyWithin: <K>(selected: ReadonlySet<K>, rowIds: ReadonlyArray<K>, nextIds: ReadonlyArray<K>) => Set<K>;
|
|
116
123
|
/** Mapa `key → mostrada`. Una clave ausente cuenta como visible. */
|
|
117
124
|
export type KapiTableColumnVisibility = Record<string, boolean>;
|
|
118
125
|
/** Columnas que se muestran: todas salvo las marcadas explícitamente con `false`. */
|
|
@@ -106,33 +106,38 @@ var e = (e, t = 0, n = 170) => {
|
|
|
106
106
|
}, y = (e, t, n) => {
|
|
107
107
|
let r = new Set(e);
|
|
108
108
|
return t.forEach((e) => n ? r.add(e) : r.delete(e)), r;
|
|
109
|
-
}, b = (e, t
|
|
109
|
+
}, b = (e, t, n) => {
|
|
110
|
+
let r = new Set(t), i = /* @__PURE__ */ new Set();
|
|
111
|
+
return e.forEach((e) => {
|
|
112
|
+
r.has(e) || i.add(e);
|
|
113
|
+
}), n.forEach((e) => i.add(e)), i;
|
|
114
|
+
}, x = (e, t) => e.filter((e) => t?.[e.key] !== !1), S = (e, t) => ({
|
|
110
115
|
...e,
|
|
111
116
|
[t]: e?.[t] === !1
|
|
112
|
-
}),
|
|
117
|
+
}), C = (e, t = 60) => Math.max(t, Math.round(e)), w = (e, t) => t?.[e.key] ?? e.width, T = (e, t, n, r, i = 60) => ({
|
|
113
118
|
...e,
|
|
114
|
-
[t]:
|
|
115
|
-
}),
|
|
119
|
+
[t]: C(n + r, i)
|
|
120
|
+
}), E = (e) => e.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase().trim(), D = (e) => E(e).split(/\s+/).filter(Boolean), O = (e) => e == null ? "" : e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : E(String(e)), k = (e, t) => {
|
|
116
121
|
if (t.length === 0) return !0;
|
|
117
|
-
let n = e.map(
|
|
122
|
+
let n = e.map(O);
|
|
118
123
|
return t.every((e) => n.some((t) => t.includes(e)));
|
|
119
|
-
},
|
|
120
|
-
let r =
|
|
121
|
-
return r.length === 0 ? e : e.filter((e) =>
|
|
122
|
-
},
|
|
124
|
+
}, A = (e, t, n) => {
|
|
125
|
+
let r = D(n);
|
|
126
|
+
return r.length === 0 ? e : e.filter((e) => k(t(e), r));
|
|
127
|
+
}, j = (e) => D(e.text).length > 0, M = (e, t) => {
|
|
123
128
|
let n = e.filter((e) => e.filterable !== !1), r = t === null ? void 0 : n.find((e) => e.key === t);
|
|
124
129
|
return r ? [r] : n;
|
|
125
|
-
},
|
|
130
|
+
}, N = /^[+-]?\d+([.,]\d+)?$/, P = /^[=+\-@\t\r]/, F = (e, t = ",") => {
|
|
126
131
|
if (e == null) return "";
|
|
127
132
|
let n;
|
|
128
|
-
return n = e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : String(e), typeof e == "string" &&
|
|
129
|
-
},
|
|
133
|
+
return n = e instanceof Date ? Number.isNaN(e.getTime()) ? "" : e.toISOString() : String(e), typeof e == "string" && P.test(n) && !N.test(n) && (n = `'${n}`), n.includes("\"") || n.includes(t) || /[\r\n]/.test(n) ? `"${n.replace(/"/g, "\"\"")}"` : n;
|
|
134
|
+
}, I = (e, t, n = ",") => [e, ...t].map((e) => e.map((e) => F(e, n)).join(n)).join("\r\n"), L = (e) => typeof e.label == "string" || typeof e.label == "number" ? String(e.label) : e.key, R = (e) => {
|
|
130
135
|
let t = e?.trim() || "tabla";
|
|
131
136
|
return /\.csv$/i.test(t) ? t : `${t}.csv`;
|
|
132
|
-
},
|
|
137
|
+
}, z = (e) => M(e, null).map((e) => ({
|
|
133
138
|
value: e.key,
|
|
134
|
-
label:
|
|
135
|
-
})),
|
|
139
|
+
label: L(e)
|
|
140
|
+
})), B = (e, t, n, r, i) => {
|
|
136
141
|
let a;
|
|
137
142
|
if (i) a = i(e);
|
|
138
143
|
else {
|
|
@@ -142,4 +147,4 @@ var e = (e, t = 0, n = 170) => {
|
|
|
142
147
|
return a?.trim() ? `${r.selectRowNamed} ${a.trim()}` : `${r.selectRow} ${n}`;
|
|
143
148
|
};
|
|
144
149
|
//#endregion
|
|
145
|
-
export { y as applyRangeSelection,
|
|
150
|
+
export { y as applyRangeSelection, I as buildCsv, C as clampColumnWidth, l as compareSortValues, i as computePagination, e as computeStickyOffsets, n as computeVisibleRange, F as csvCell, R as csvFileName, L as csvHeaderOf, w as effectiveColumnWidth, z as filterColumnOptions, A as filterRows, M as filterSearchColumns, D as filterTerms, j as isFilterActive, t as lastStickyIndex, r as nextScrollWindow, m as nextSortState, E as normalizeFilterText, p as paginateRows, v as rangeBetween, d as readCell, T as resizeColumn, k as rowMatchesFilter, B as rowSelectLabel, c as safeLocale, b as selectOnlyWithin, h as selectionState, u as sortRows, f as sortRowsByColumn, _ as toggleAllIds, S as toggleColumnVisibility, g as toggleId, x as visibleColumnsOf };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type HTMLAttributes, type Ref } from "react";
|
|
2
|
+
import { type KapiTooltipSide } from "../overlays/KapiTooltip";
|
|
3
|
+
import "./KapiTruncate.css";
|
|
4
|
+
/** Atributos nativos (`id`, `style`, `data-*`…) van al contenedor; el texto va por `text`. */
|
|
5
|
+
export type KapiTruncateProps = Omit<HTMLAttributes<HTMLSpanElement>, "children"> & {
|
|
6
|
+
/** Texto a mostrar. Es `string` y no `ReactNode` porque el mismo valor es la etiqueta del tooltip. */
|
|
7
|
+
text: string;
|
|
8
|
+
/** Lado preferido del tooltip: se respeta si entra, si no va al opuesto. */
|
|
9
|
+
prefer?: KapiTooltipSide | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Suma el texto al orden de tabulación para que el tooltip se pueda abrir con teclado. Default `false`:
|
|
12
|
+
* el texto completo ya está en el árbol de accesibilidad, así que un lector de pantalla lo lee entero;
|
|
13
|
+
* el salto de tabulación es sólo para quien ve la pantalla y navega con teclado, y uno por celda
|
|
14
|
+
* inundaría el orden de tabulación de una tabla.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
focusable?: boolean | undefined;
|
|
18
|
+
/** Ref al contenedor. */
|
|
19
|
+
ref?: Ref<HTMLSpanElement> | undefined;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Texto de una línea con ellipsis que muestra el texto completo en un tooltip **sólo si de verdad quedó
|
|
23
|
+
* cortado**: sin esa condición el tooltip repetiría algo que ya se lee, que es ruido.
|
|
24
|
+
*
|
|
25
|
+
* Por qué hay dos elementos y se mide cruzado: `KapiTooltip` envuelve a su disparador en un
|
|
26
|
+
* `<span class="kapi-tip">` que es `inline-flex`, o sea shrink-to-fit. Si se midiera el elemento del
|
|
27
|
+
* texto contra su propio padre, montar el tooltip cambiaría el ancho disponible y el resultado se
|
|
28
|
+
* invertiría: truncado → envuelvo → ya no truncado → desenvuelvo → truncado, en bucle. Acá el ancho
|
|
29
|
+
* disponible se lee del contenedor externo (que nunca cambia de forma) y el del contenido es el
|
|
30
|
+
* `scrollWidth` del texto (intrínseco, no depende del padre), así que la medición es estable.
|
|
31
|
+
*/
|
|
32
|
+
export declare const KapiTruncate: ({ text, prefer, focusable, className, ref, ...rest }: KapiTruncateProps) => import("react").JSX.Element;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { joinClasses as e } from "../rootProps.js";
|
|
3
|
+
import { KapiTooltip as t } from "../overlays/KapiTooltip.js";
|
|
4
|
+
import { isTruncated as n } from "./truncateLogic.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
7
|
+
import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
|
|
8
|
+
//#region src/components/display/KapiTruncate.tsx
|
|
9
|
+
var c = ({ text: c, prefer: l = "top", focusable: u = !1, className: d, ref: f, ...p }) => {
|
|
10
|
+
let m = o(null), h = o(null), [g, _] = s(!1), v = i(() => {
|
|
11
|
+
let e = m.current, t = h.current;
|
|
12
|
+
e && t && _(n(t.scrollWidth, e.clientWidth));
|
|
13
|
+
}, []);
|
|
14
|
+
a(() => {
|
|
15
|
+
v();
|
|
16
|
+
let e = m.current;
|
|
17
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
18
|
+
let t = new ResizeObserver(v);
|
|
19
|
+
return t.observe(e), () => t.disconnect();
|
|
20
|
+
}, [v, c]);
|
|
21
|
+
let y = /* @__PURE__ */ r("span", {
|
|
22
|
+
className: "kapi-truncate__text",
|
|
23
|
+
ref: h,
|
|
24
|
+
...u ? { tabIndex: 0 } : {},
|
|
25
|
+
children: c
|
|
26
|
+
});
|
|
27
|
+
return /* @__PURE__ */ r("span", {
|
|
28
|
+
...p,
|
|
29
|
+
ref: (e) => {
|
|
30
|
+
m.current = e, typeof f == "function" ? f(e) : f && (f.current = e);
|
|
31
|
+
},
|
|
32
|
+
className: e("kapi-truncate", d),
|
|
33
|
+
"data-truncated": g || void 0,
|
|
34
|
+
children: g ? /* @__PURE__ */ r(t, {
|
|
35
|
+
label: c,
|
|
36
|
+
prefer: l,
|
|
37
|
+
className: "kapi-truncate__tip",
|
|
38
|
+
children: y
|
|
39
|
+
}) : y
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { c as KapiTruncate };
|
|
@@ -39,3 +39,6 @@ export { KapiCommentComposer, DEFAULT_COMMENT_COMPOSER_LABELS } from "./KapiComm
|
|
|
39
39
|
export type { KapiCommentComposerLabels, KapiCommentComposerProps } from "./KapiCommentComposer";
|
|
40
40
|
export { canSubmitComment, isSubmitShortcut } from "./commentLogic";
|
|
41
41
|
export type { KapiSubmitShortcut } from "./commentLogic";
|
|
42
|
+
export { KapiTruncate } from "./KapiTruncate";
|
|
43
|
+
export type { KapiTruncateProps } from "./KapiTruncate";
|
|
44
|
+
export { isTruncated } from "./truncateLogic";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `true` cuando el contenido no entra en el ancho disponible y por lo tanto el ellipsis está cortando.
|
|
3
|
+
* `contentWidth` es el ancho intrínseco del texto (`scrollWidth` del elemento con `overflow: hidden`) y
|
|
4
|
+
* `availableWidth` el del contenedor que le impone el límite (`clientWidth`).
|
|
5
|
+
*/
|
|
6
|
+
export declare const isTruncated: (contentWidth: number, availableWidth: number) => boolean;
|
|
@@ -14,10 +14,17 @@ export type KapiButtonProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, "chi
|
|
|
14
14
|
icon?: ReactNode;
|
|
15
15
|
/** Texto del botón (va a la derecha del `icon`). */
|
|
16
16
|
children?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Acción en curso: deshabilita el botón (`disabled` nativo, así que tampoco manda el formulario con Enter),
|
|
19
|
+
* marca `aria-busy` y dibuja un spinner centrado sin cambiar el ancho. El botón pierde el foco al
|
|
20
|
+
* deshabilitarse, por eso el anuncio del estado pertenece a una región viva de la app, no al botón.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
loading?: boolean;
|
|
17
24
|
/** Ref al `<button>` nativo. */
|
|
18
25
|
ref?: Ref<HTMLButtonElement>;
|
|
19
26
|
};
|
|
20
27
|
/** Clases de un botón. Pura y exportada: es lo que se testea (no el markup). */
|
|
21
|
-
export declare const buttonClasses: ({ variant, size, iconOnly, bordered, className }?: Pick<KapiButtonProps, "variant" | "size" | "iconOnly" | "bordered" | "className">) => string;
|
|
28
|
+
export declare const buttonClasses: ({ variant, size, iconOnly, bordered, loading, className }?: Pick<KapiButtonProps, "variant" | "size" | "iconOnly" | "bordered" | "loading" | "className">) => string;
|
|
22
29
|
/** Botón base: variantes de color, tamaños, sólo ícono y borde. Acepta los atributos nativos de `<button>`. */
|
|
23
|
-
export declare const KapiButton: ({ variant, size, iconOnly, bordered, icon, className, type, children, ref, ...rest }: KapiButtonProps) => import("react").JSX.Element;
|
|
30
|
+
export declare const KapiButton: ({ variant, size, iconOnly, bordered, icon, loading, disabled, className, type, children, ref, ...rest }: KapiButtonProps) => import("react").JSX.Element;
|
|
@@ -1,25 +1,35 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { Fragment as e, jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
3
|
//#region src/components/inputs/KapiButton.tsx
|
|
4
|
-
var
|
|
4
|
+
var r = ({ variant: e = "default", size: t = "md", iconOnly: n = !1, bordered: r = !1, loading: i = !1, className: a = "" } = {}) => [
|
|
5
5
|
"kapi-btn",
|
|
6
6
|
e !== "default" && `kapi-btn--${e}`,
|
|
7
7
|
t !== "md" && `kapi-btn--${t}`,
|
|
8
8
|
n && "kapi-btn--iconbtn",
|
|
9
9
|
r && "kapi-btn--bordered",
|
|
10
|
-
i
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
i && "is-loading",
|
|
11
|
+
a
|
|
12
|
+
].filter(Boolean).join(" "), i = ({ variant: i = "default", size: a = "md", iconOnly: o = !1, bordered: s = !1, icon: c, loading: l = !1, disabled: u, className: d, type: f = "button", children: p, ref: m, ...h }) => /* @__PURE__ */ t("button", {
|
|
13
|
+
ref: m,
|
|
14
|
+
type: f,
|
|
15
|
+
className: r({
|
|
16
|
+
variant: i,
|
|
17
|
+
size: a,
|
|
18
|
+
iconOnly: o,
|
|
19
|
+
bordered: s,
|
|
20
|
+
loading: l,
|
|
21
|
+
className: d
|
|
20
22
|
}),
|
|
21
|
-
...
|
|
22
|
-
|
|
23
|
+
...h,
|
|
24
|
+
disabled: l || u,
|
|
25
|
+
...l ? { "aria-busy": !0 } : {},
|
|
26
|
+
children: l ? /* @__PURE__ */ n(e, { children: [/* @__PURE__ */ t("span", {
|
|
27
|
+
className: "kapi-spinner kapi-btn__spinner",
|
|
28
|
+
"aria-hidden": "true"
|
|
29
|
+
}), /* @__PURE__ */ n("span", {
|
|
30
|
+
className: "kapi-btn__content",
|
|
31
|
+
children: [c, p]
|
|
32
|
+
})] }) : /* @__PURE__ */ n(e, { children: [c, p] })
|
|
23
33
|
});
|
|
24
34
|
//#endregion
|
|
25
|
-
export {
|
|
35
|
+
export { i as KapiButton, r as buttonClasses };
|
|
@@ -11,8 +11,10 @@ export type KapiFacetedSearchLabels = {
|
|
|
11
11
|
placeholder: string;
|
|
12
12
|
/** "Buscar “texto”" en el desplegable. */
|
|
13
13
|
searchFor: string;
|
|
14
|
-
/** Pista al lado de las facetas que piden valor. */
|
|
14
|
+
/** Pista al lado de las facetas que piden elegir un valor. */
|
|
15
15
|
pickValue: string;
|
|
16
|
+
/** Pista al lado de las facetas de texto (`kind: "text"`), que piden escribirlo. */
|
|
17
|
+
typeValue: string;
|
|
16
18
|
empty: string;
|
|
17
19
|
/** Prefijo del botón × de cada chip ("Quitar Estado: Pendiente"). */
|
|
18
20
|
remove: string;
|
|
@@ -24,15 +26,35 @@ export type KapiFacetedSearchLabels = {
|
|
|
24
26
|
loading: string;
|
|
25
27
|
/** Cuando `loadOptions` falla: el menú lo dice en vez de quedar vacío, que parece "sin datos". */
|
|
26
28
|
loadError: string;
|
|
29
|
+
/** Nombre accesible del desplegable mientras se elige la comparación ("Estado: Cómo comparar"). */
|
|
30
|
+
pickOperator: string;
|
|
31
|
+
/** Comparación `eq`. */
|
|
32
|
+
operatorEq: string;
|
|
33
|
+
/** Comparación `ne`. */
|
|
34
|
+
operatorNe: string;
|
|
35
|
+
/** Comparación `contains`. */
|
|
36
|
+
operatorContains: string;
|
|
37
|
+
/** Comparación `startsWith`. */
|
|
38
|
+
operatorStartsWith: string;
|
|
39
|
+
/** Comparación `endsWith`. */
|
|
40
|
+
operatorEndsWith: string;
|
|
41
|
+
/** Comparación `gt`. */
|
|
42
|
+
operatorGt: string;
|
|
43
|
+
/** Comparación `gte`. */
|
|
44
|
+
operatorGte: string;
|
|
45
|
+
/** Comparación `lt`. */
|
|
46
|
+
operatorLt: string;
|
|
47
|
+
/** Comparación `lte`. */
|
|
48
|
+
operatorLte: string;
|
|
27
49
|
};
|
|
28
50
|
export declare const DEFAULT_FACETED_SEARCH_LABELS: KapiFacetedSearchLabels;
|
|
29
51
|
/** Atributos nativos (`id`, `style`, `data-*`…) van a la región `role="search"` (el rol es propio). */
|
|
30
52
|
export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "children" | "role"> & {
|
|
31
|
-
/** Facetas que se pueden elegir (lista, fecha o flag), cada una con su `apply`. */
|
|
53
|
+
/** Facetas que se pueden elegir (lista, texto, fecha o flag), cada una con su `apply`. */
|
|
32
54
|
facets: ReadonlyArray<KapiFacet>;
|
|
33
55
|
/** Filtros activos, como chips removibles (el estado lo tiene la pantalla). */
|
|
34
56
|
chips: ReadonlyArray<KapiFacetChip>;
|
|
35
|
-
/** Texto libre confirmado con Enter. */
|
|
57
|
+
/** Texto libre confirmado con Enter, sin campo elegido. Con una faceta `text` pendiente va a su `apply`. */
|
|
36
58
|
onText: (text: string) => void;
|
|
37
59
|
/** Espera tras la última tecla antes de llamar a `loadOptions` de la faceta, en ms. @default 300 */
|
|
38
60
|
loadDelay?: number;
|
|
@@ -55,7 +77,9 @@ export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "child
|
|
|
55
77
|
* Búsqueda facetada (patrón Gmail/Jira): un solo campo donde se tipea texto libre (Enter) o se elige
|
|
56
78
|
* una faceta y su valor; cada filtro activo queda como chip removible. Tonta a propósito: recibe las
|
|
57
79
|
* facetas y los chips, y avisa con `onText` y el `apply` de cada faceta; no sabe de tablas ni backends.
|
|
58
|
-
*
|
|
59
|
-
*
|
|
80
|
+
* Una faceta `text` es búsqueda libre sobre un campo elegido: el texto va a su `apply`, no a `onText`.
|
|
81
|
+
* Si la faceta declara `operators` (dos o más), antes del valor se elige cómo comparar.
|
|
82
|
+
* Teclado: flechas y Enter en el desplegable, Backspace con el campo vacío suelta el operador elegido,
|
|
83
|
+
* después la faceta pendiente y después el último chip, Escape cancela la faceta pendiente.
|
|
60
84
|
*/
|
|
61
85
|
export declare function KapiFacetedSearch({ facets, chips, onText, onClearAll, loadDelay, reloadKey, labels, className, onMouseDown, "aria-label": ariaLabel, ...rest }: KapiFacetedSearchProps): import("react").JSX.Element;
|