@kapiuara/ui 0.4.0 → 0.6.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 +54 -1
- package/dist/components/chat/KapiChatDivider.d.ts +15 -0
- package/dist/components/chat/KapiChatDivider.js +17 -0
- package/dist/components/chat/KapiChatList.d.ts +57 -0
- package/dist/components/chat/KapiChatList.js +71 -0
- package/dist/components/chat/KapiChatThread.d.ts +35 -0
- package/dist/components/chat/KapiChatThread.js +85 -0
- package/dist/components/chat/KapiComposer.d.ts +60 -0
- package/dist/components/chat/KapiComposer.js +89 -0
- package/dist/components/chat/KapiMessageBubble.d.ts +43 -0
- package/dist/components/chat/KapiMessageBubble.js +67 -0
- package/dist/components/chat/KapiTypingIndicator.d.ts +27 -0
- package/dist/components/chat/KapiTypingIndicator.js +34 -0
- package/dist/components/chat/chatLogic.d.ts +76 -0
- package/dist/components/chat/chatLogic.js +34 -0
- package/dist/components/chat/index.d.ts +14 -0
- package/dist/components/display/KapiCommentComposer.d.ts +4 -0
- package/dist/components/display/KapiCommentComposer.js +43 -46
- package/dist/components/display/commentLogic.d.ts +9 -2
- package/dist/components/display/commentLogic.js +1 -1
- package/dist/components/display/index.d.ts +1 -0
- package/dist/components/inputs/KapiFacetedSearch.d.ts +14 -1
- package/dist/components/inputs/KapiFacetedSearch.js +172 -110
- package/dist/components/inputs/KapiSelect.d.ts +7 -0
- package/dist/components/inputs/KapiSelect.js +233 -229
- package/dist/components/inputs/facetedSearchLogic.d.ts +12 -2
- package/dist/components/inputs/facetedSearchLogic.js +10 -7
- package/dist/components/layout/KapiPanelParts.js +9 -9
- package/dist/components/layout/KapiRail.js +8 -8
- package/dist/components/locale/labelRegistry.d.ts +10 -0
- package/dist/components/navigation/KapiContextPanel.js +86 -86
- package/dist/components/navigation/KapiPanelGroup.js +18 -18
- package/dist/components/navigation/KapiTabs.js +1 -1
- package/dist/components/navigation/MiniNavItem.js +1 -1
- package/dist/hooks/dateFormat.d.ts +7 -0
- package/dist/hooks/dateFormat.js +16 -2
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/useSubmitDraft.d.ts +34 -0
- package/dist/hooks/useSubmitDraft.js +28 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +83 -76
- package/dist/kapi.css +1 -1
- package/dist/kapi.layered.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
3
|
+
import { joinClasses as t } from "../rootProps.js";
|
|
4
|
+
import { typingText as n } from "./chatLogic.js";
|
|
5
|
+
/* empty css */
|
|
6
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/chat/KapiTypingIndicator.tsx
|
|
8
|
+
var a = {
|
|
9
|
+
one: "{name} está escribiendo…",
|
|
10
|
+
many: "{count} personas están escribiendo…",
|
|
11
|
+
someone: "Alguien está escribiendo…"
|
|
12
|
+
}, o = ({ names: o, labels: s, ref: c, className: l, ...u }) => {
|
|
13
|
+
let d = e("typingIndicator", a, s), f = n(o, d);
|
|
14
|
+
return f === null ? null : /* @__PURE__ */ i("div", {
|
|
15
|
+
"aria-live": "polite",
|
|
16
|
+
...u,
|
|
17
|
+
ref: c,
|
|
18
|
+
className: t("kapi-typing", l),
|
|
19
|
+
children: [/* @__PURE__ */ i("span", {
|
|
20
|
+
className: "kapi-typing__dots",
|
|
21
|
+
"aria-hidden": "true",
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ r("span", { className: "kapi-typing__dot" }),
|
|
24
|
+
/* @__PURE__ */ r("span", { className: "kapi-typing__dot" }),
|
|
25
|
+
/* @__PURE__ */ r("span", { className: "kapi-typing__dot" })
|
|
26
|
+
]
|
|
27
|
+
}), /* @__PURE__ */ r("span", {
|
|
28
|
+
className: "kapi-typing__text",
|
|
29
|
+
children: f
|
|
30
|
+
})]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { a as DEFAULT_TYPING_INDICATOR_LABELS, o as KapiTypingIndicator };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** Estado de entrega de un mensaje propio. */
|
|
2
|
+
export type KapiChatStatus = "sending" | "sent" | "delivered" | "read" | "failed";
|
|
3
|
+
/** Mínimo que necesita la lógica de un mensaje; el consumidor lo extiende con su contenido. */
|
|
4
|
+
export type KapiChatMessage<Id extends string = string> = {
|
|
5
|
+
/** Identificador estable del mensaje; también es su `key`. */
|
|
6
|
+
id: Id;
|
|
7
|
+
/** Quién lo escribió; se compara con `meId` para saber si es saliente. */
|
|
8
|
+
authorId: string;
|
|
9
|
+
/** Momento en que se envió. */
|
|
10
|
+
at: Date;
|
|
11
|
+
/** Estado de entrega (solo tiene sentido en mensajes salientes). */
|
|
12
|
+
status?: KapiChatStatus | undefined;
|
|
13
|
+
};
|
|
14
|
+
/** Posición de un mensaje dentro de una corrida del mismo autor. */
|
|
15
|
+
export type KapiChatGrouping = "single" | "first" | "middle" | "last";
|
|
16
|
+
/** Un renglón del hilo: separador de día, marcador de no leídos o mensaje. */
|
|
17
|
+
export type KapiChatEntry<Id extends string = string, M extends KapiChatMessage<Id> = KapiChatMessage<Id>> = {
|
|
18
|
+
kind: "day";
|
|
19
|
+
key: string;
|
|
20
|
+
at: Date;
|
|
21
|
+
} | {
|
|
22
|
+
kind: "unread";
|
|
23
|
+
key: string;
|
|
24
|
+
count: number;
|
|
25
|
+
} | {
|
|
26
|
+
kind: "message";
|
|
27
|
+
key: string;
|
|
28
|
+
message: M;
|
|
29
|
+
outgoing: boolean;
|
|
30
|
+
grouping: KapiChatGrouping;
|
|
31
|
+
};
|
|
32
|
+
/** Opciones de `groupChatMessages`. */
|
|
33
|
+
export type KapiChatGroupOptions<Id extends string = string> = {
|
|
34
|
+
/** Id del usuario actual: sus mensajes son salientes. */
|
|
35
|
+
meId: string;
|
|
36
|
+
/** Hueco máximo, en milisegundos, para agrupar dos mensajes seguidos del mismo autor. @default 300000 */
|
|
37
|
+
groupGapMs?: number | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* Id del primer mensaje no leído; antes de él se emite el marcador de no leídos. Va en `NoInfer`
|
|
40
|
+
* para que `Id` salga sólo de los mensajes: si participara de la inferencia, pasarle un literal
|
|
41
|
+
* (`"m7"`) lo ancla a ese literal y obliga al consumidor a escribir el argumento de tipo a mano.
|
|
42
|
+
*/
|
|
43
|
+
firstUnreadId?: NoInfer<Id> | null | undefined;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Convierte los mensajes en los renglones del hilo: separadores de día, marcador de no leídos y mensajes
|
|
47
|
+
* con su posición dentro de la corrida del mismo autor. Espera los mensajes en orden cronológico
|
|
48
|
+
* ascendente y NO los ordena.
|
|
49
|
+
*
|
|
50
|
+
* Un mensaje se agrupa con el anterior solo si tiene el mismo autor, no hay entre ellos un separador de
|
|
51
|
+
* día ni el marcador de no leídos, y los separan como mucho `groupGapMs`. El `count` del marcador son los
|
|
52
|
+
* mensajes entrantes desde `firstUnreadId` (inclusive) hasta el final; si ese id no está, no hay marcador.
|
|
53
|
+
*/
|
|
54
|
+
export declare const groupChatMessages: <Id extends string, M extends KapiChatMessage<Id>>(messages: readonly M[], options: KapiChatGroupOptions<Id>) => KapiChatEntry<Id, M>[];
|
|
55
|
+
/**
|
|
56
|
+
* Si el usuario está al fondo, un mensaje nuevo lo sigue. Si subió a leer algo viejo NO se le mueve el
|
|
57
|
+
* scroll (se le avisa con la píldora); pero un mensaje propio siempre baja, porque lo acaba de enviar.
|
|
58
|
+
* Saber si está al fondo no se calcula acá: sale de `useScrollEdges` (`edges.end === false` es "al fondo").
|
|
59
|
+
*/
|
|
60
|
+
export declare const shouldFollowBottom: (state: {
|
|
61
|
+
atBottom: boolean;
|
|
62
|
+
outgoing: boolean;
|
|
63
|
+
}) => boolean;
|
|
64
|
+
/** Textos que necesita `typingText`; estructuralmente son los de `KapiTypingIndicatorLabels`. */
|
|
65
|
+
type TypingTextLabels = {
|
|
66
|
+
one: string;
|
|
67
|
+
many: string;
|
|
68
|
+
someone: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Texto del indicador de escritura, o `null` si no escribe nadie. Una persona con nombre usa `one`
|
|
72
|
+
* (`{name}`); dos o más usan `many` (`{count}` con la cantidad de personas); un nombre vacío o de solo
|
|
73
|
+
* espacios es una persona sin nombre y usa `someone`.
|
|
74
|
+
*/
|
|
75
|
+
export declare const typingText: (names: readonly string[] | undefined, labels: TypingTextLabels) => string | null;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/components/chat/chatLogic.ts
|
|
2
|
+
var e = (e) => String(e).padStart(2, "0"), t = (t) => `${t.getFullYear()}-${e(t.getMonth() + 1)}-${e(t.getDate())}`, n = (e, n) => {
|
|
3
|
+
let { meId: r, groupGapMs: i = 3e5, firstUnreadId: a = null } = n, o = [], s = a === null ? -1 : e.findIndex((e) => e.id === a), c = s < 0 ? 0 : e.slice(s).filter((e) => e.authorId !== r).length, l = [], u = () => {
|
|
4
|
+
l.forEach((e, t) => {
|
|
5
|
+
let n = o[e];
|
|
6
|
+
n?.kind === "message" && (n.grouping = l.length === 1 ? "single" : t === 0 ? "first" : t === l.length - 1 ? "last" : "middle");
|
|
7
|
+
}), l = [];
|
|
8
|
+
}, d;
|
|
9
|
+
return e.forEach((e, n) => {
|
|
10
|
+
let a = d === void 0 || t(d.at) !== t(e.at), f = n === s;
|
|
11
|
+
a && o.push({
|
|
12
|
+
kind: "day",
|
|
13
|
+
key: t(e.at),
|
|
14
|
+
at: e.at
|
|
15
|
+
}), f && o.push({
|
|
16
|
+
kind: "unread",
|
|
17
|
+
key: "unread",
|
|
18
|
+
count: c
|
|
19
|
+
}), d !== void 0 && !a && !f && d.authorId === e.authorId && e.at.getTime() - d.at.getTime() <= i || u(), l.push(o.length), o.push({
|
|
20
|
+
kind: "message",
|
|
21
|
+
key: e.id,
|
|
22
|
+
message: e,
|
|
23
|
+
outgoing: e.authorId === r,
|
|
24
|
+
grouping: "single"
|
|
25
|
+
}), d = e;
|
|
26
|
+
}), u(), o;
|
|
27
|
+
}, r = (e) => e.atBottom || e.outgoing, i = (e, t) => {
|
|
28
|
+
if (e === void 0 || e.length === 0) return null;
|
|
29
|
+
if (e.length > 1) return t.many.replaceAll("{count}", () => String(e.length));
|
|
30
|
+
let n = (e[0] ?? "").trim();
|
|
31
|
+
return n === "" ? t.someone : t.one.replaceAll("{name}", () => n);
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { n as groupChatMessages, r as shouldFollowBottom, i as typingText };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { groupChatMessages, shouldFollowBottom, typingText } from "./chatLogic";
|
|
2
|
+
export { KapiChatDivider } from "./KapiChatDivider";
|
|
3
|
+
export { DEFAULT_CHAT_LIST_LABELS, KapiChatList } from "./KapiChatList";
|
|
4
|
+
export { DEFAULT_COMPOSER_LABELS, KapiComposer } from "./KapiComposer";
|
|
5
|
+
export { DEFAULT_CHAT_THREAD_LABELS, KapiChatThread } from "./KapiChatThread";
|
|
6
|
+
export { DEFAULT_MESSAGE_BUBBLE_LABELS, KapiMessageBubble } from "./KapiMessageBubble";
|
|
7
|
+
export { DEFAULT_TYPING_INDICATOR_LABELS, KapiTypingIndicator } from "./KapiTypingIndicator";
|
|
8
|
+
export type { KapiChatEntry, KapiChatGroupOptions, KapiChatGrouping, KapiChatMessage, KapiChatStatus } from "./chatLogic";
|
|
9
|
+
export type { KapiChatDividerProps, KapiChatDividerTone } from "./KapiChatDivider";
|
|
10
|
+
export type { KapiChatConversation, KapiChatListLabels, KapiChatListProps } from "./KapiChatList";
|
|
11
|
+
export type { KapiChatThreadLabels, KapiChatThreadProps } from "./KapiChatThread";
|
|
12
|
+
export type { KapiComposerLabels, KapiComposerProps } from "./KapiComposer";
|
|
13
|
+
export type { KapiMessageBubbleLabels, KapiMessageBubbleProps } from "./KapiMessageBubble";
|
|
14
|
+
export type { KapiTypingIndicatorLabels, KapiTypingIndicatorProps } from "./KapiTypingIndicator";
|
|
@@ -45,5 +45,9 @@ export type KapiCommentComposerProps = Omit<TextareaHTMLAttributes<HTMLTextAreaE
|
|
|
45
45
|
/** Ref al `<textarea>`. */
|
|
46
46
|
ref?: Ref<HTMLTextAreaElement>;
|
|
47
47
|
};
|
|
48
|
+
/**
|
|
49
|
+
* Compositor de comentarios: textarea que crece con el texto + botón de envío. Ctrl/Cmd+Enter envía,
|
|
50
|
+
* Enter solo hace salto de línea; el botón queda deshabilitado mientras no haya texto.
|
|
51
|
+
*/
|
|
48
52
|
export declare const KapiCommentComposer: ({ value: valueProp, defaultValue, onChange, onSubmit, loading, invalid, required, disabled, className, style, labels, ref, placeholder, onKeyDown, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, "aria-describedby": ariaDescribedBy, ...rest }: KapiCommentComposerProps) => import("react").JSX.Element;
|
|
49
53
|
export {};
|
|
@@ -6,71 +6,68 @@ import { useLabels as i } from "../locale/KapiLocaleProvider.js";
|
|
|
6
6
|
import { joinClasses as a } from "../rootProps.js";
|
|
7
7
|
import { KapiTextarea as o } from "../inputs/KapiTextarea.js";
|
|
8
8
|
/* empty css */
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
9
|
+
import { isSubmitShortcut as s } from "./commentLogic.js";
|
|
10
|
+
import { useSubmitDraft as c } from "../../hooks/useSubmitDraft.js";
|
|
11
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
12
|
+
import { useId as d } from "react";
|
|
12
13
|
//#region src/components/display/KapiCommentComposer.tsx
|
|
13
|
-
var
|
|
14
|
+
var f = {
|
|
14
15
|
label: "Comentario",
|
|
15
16
|
placeholder: "Escribe un comentario…",
|
|
16
17
|
submit: "Comentar",
|
|
17
18
|
shortcut: "Ctrl o ⌘ + Enter para enviar"
|
|
18
|
-
},
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
_ === void 0 && R((t) => c(t, e));
|
|
29
|
-
}, (e) => console.error(e)).finally(() => U(!1))) : _ === void 0 && R("");
|
|
30
|
-
}, J = (e) => {
|
|
31
|
-
A?.(e), !e.defaultPrevented && l({
|
|
19
|
+
}, p = ({ value: p, defaultValue: m, onChange: h, onSubmit: g, loading: _ = !1, invalid: v, required: y, disabled: b, className: x, style: S, labels: C, ref: w, placeholder: T, onKeyDown: E, "aria-label": D, "aria-labelledby": O, "aria-describedby": k, ...A }) => {
|
|
20
|
+
let j = i("commentComposer", f, C), M = r(), N = d(), { text: P, setText: F, submit: I, busy: L, canSubmit: R, boxRef: z } = c({
|
|
21
|
+
value: p,
|
|
22
|
+
defaultValue: m,
|
|
23
|
+
onChange: h,
|
|
24
|
+
onSubmit: g,
|
|
25
|
+
disabled: b,
|
|
26
|
+
loading: _
|
|
27
|
+
}), B = (e) => {
|
|
28
|
+
E?.(e), !e.defaultPrevented && s({
|
|
32
29
|
...e,
|
|
33
30
|
isComposing: e.nativeEvent.isComposing
|
|
34
|
-
}) && (e.preventDefault(),
|
|
35
|
-
},
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
className: a("kapi-composer",
|
|
38
|
-
style:
|
|
39
|
-
children: [/* @__PURE__ */
|
|
40
|
-
...
|
|
31
|
+
}) && (e.preventDefault(), I());
|
|
32
|
+
}, V = D !== void 0 || O !== void 0 || M !== null;
|
|
33
|
+
return /* @__PURE__ */ u("div", {
|
|
34
|
+
className: a("kapi-composer", x),
|
|
35
|
+
style: S,
|
|
36
|
+
children: [/* @__PURE__ */ l(o, {
|
|
37
|
+
...A,
|
|
41
38
|
ref: (e) => {
|
|
42
|
-
|
|
39
|
+
z.current = e, t(w, e);
|
|
43
40
|
},
|
|
44
41
|
className: "kapi-composer__input",
|
|
45
42
|
autosize: !0,
|
|
46
43
|
maxRows: 8,
|
|
47
44
|
rows: 2,
|
|
48
|
-
value:
|
|
49
|
-
disabled:
|
|
50
|
-
placeholder:
|
|
51
|
-
"aria-label":
|
|
52
|
-
"aria-labelledby":
|
|
53
|
-
"aria-describedby": n(
|
|
54
|
-
...
|
|
55
|
-
...
|
|
56
|
-
onChange: (e) =>
|
|
57
|
-
onKeyDown:
|
|
58
|
-
}), /* @__PURE__ */
|
|
45
|
+
value: P,
|
|
46
|
+
disabled: b,
|
|
47
|
+
placeholder: T ?? j.placeholder,
|
|
48
|
+
"aria-label": V ? D : j.label,
|
|
49
|
+
"aria-labelledby": O,
|
|
50
|
+
"aria-describedby": n(k, N),
|
|
51
|
+
...y === void 0 ? {} : { required: y },
|
|
52
|
+
...v ? { status: "err" } : {},
|
|
53
|
+
onChange: (e) => F(e.target.value),
|
|
54
|
+
onKeyDown: B
|
|
55
|
+
}), /* @__PURE__ */ u("div", {
|
|
59
56
|
className: "kapi-composer__foot",
|
|
60
|
-
children: [/* @__PURE__ */
|
|
61
|
-
id:
|
|
57
|
+
children: [/* @__PURE__ */ l("span", {
|
|
58
|
+
id: N,
|
|
62
59
|
className: "kapi-composer__hint",
|
|
63
|
-
children:
|
|
64
|
-
}), /* @__PURE__ */
|
|
60
|
+
children: j.shortcut
|
|
61
|
+
}), /* @__PURE__ */ l(e, {
|
|
65
62
|
variant: "primary",
|
|
66
63
|
size: "sm",
|
|
67
|
-
disabled: !
|
|
68
|
-
"aria-busy":
|
|
69
|
-
onClick:
|
|
70
|
-
children:
|
|
64
|
+
disabled: !R,
|
|
65
|
+
"aria-busy": L || void 0,
|
|
66
|
+
onClick: I,
|
|
67
|
+
children: j.submit
|
|
71
68
|
})]
|
|
72
69
|
})]
|
|
73
70
|
});
|
|
74
71
|
};
|
|
75
72
|
//#endregion
|
|
76
|
-
export {
|
|
73
|
+
export { f as DEFAULT_COMMENT_COMPOSER_LABELS, p as KapiCommentComposer };
|
|
@@ -3,13 +3,20 @@ export declare const canSubmitComment: (text: string, { disabled, loading }?: {
|
|
|
3
3
|
disabled?: boolean | undefined;
|
|
4
4
|
loading?: boolean | undefined;
|
|
5
5
|
}) => boolean;
|
|
6
|
-
/** Ctrl+Enter o
|
|
6
|
+
/** Atajo que envía: `"modifier"` (Ctrl/Cmd+Enter) o `"enter"` (Enter solo). */
|
|
7
|
+
export type KapiSubmitShortcut = "modifier" | "enter";
|
|
8
|
+
/**
|
|
9
|
+
* Decide si una tecla envía. Con `"modifier"` (default) envían Ctrl+Enter y Cmd+Enter, y Enter solo es
|
|
10
|
+
* salto de línea. Con `"enter"` envía Enter; Shift+Enter, Ctrl+Enter y Cmd+Enter son salto de línea.
|
|
11
|
+
* En ambos modos, nunca en medio de una composición (IME).
|
|
12
|
+
*/
|
|
7
13
|
export declare const isSubmitShortcut: (e: {
|
|
8
14
|
key: string;
|
|
9
15
|
ctrlKey: boolean;
|
|
10
16
|
metaKey: boolean;
|
|
17
|
+
shiftKey?: boolean | undefined;
|
|
11
18
|
isComposing?: boolean | undefined;
|
|
12
|
-
}) => boolean;
|
|
19
|
+
}, mode?: KapiSubmitShortcut) => boolean;
|
|
13
20
|
/**
|
|
14
21
|
* Borrador que queda después de un envío que resolvió: lo enviado se quita del principio (lo escrito
|
|
15
22
|
* mientras el envío corría se conserva, sin repetir lo que ya se publicó); si el borrador cambió de otra
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
//#region src/components/display/commentLogic.ts
|
|
2
|
-
var e = (e, { disabled: t = !1, loading: n = !1 } = {}) => !t && !n && e.trim().length > 0, t = (e) => e.key
|
|
2
|
+
var e = (e, { disabled: t = !1, loading: n = !1 } = {}) => !t && !n && e.trim().length > 0, t = (e, t = "modifier") => e.key !== "Enter" || e.isComposing ? !1 : t === "enter" ? !e.ctrlKey && !e.metaKey && !e.shiftKey : e.ctrlKey || e.metaKey, n = (e, t) => {
|
|
3
3
|
let n = e.trimStart(), r = n.slice(t.length);
|
|
4
4
|
return !n.startsWith(t) || /^[\p{L}\p{N}]/u.test(r) ? e : r.trimStart();
|
|
5
5
|
};
|
|
@@ -38,3 +38,4 @@ export type { KapiCommentProps } from "./KapiComment";
|
|
|
38
38
|
export { KapiCommentComposer, DEFAULT_COMMENT_COMPOSER_LABELS } from "./KapiCommentComposer";
|
|
39
39
|
export type { KapiCommentComposerLabels, KapiCommentComposerProps } from "./KapiCommentComposer";
|
|
40
40
|
export { canSubmitComment, isSubmitShortcut } from "./commentLogic";
|
|
41
|
+
export type { KapiSubmitShortcut } from "./commentLogic";
|
|
@@ -20,6 +20,10 @@ export type KapiFacetedSearchLabels = {
|
|
|
20
20
|
valueOf: string;
|
|
21
21
|
/** Botón que quita todos los filtros (con `onClearAll`). */
|
|
22
22
|
clearAll: string;
|
|
23
|
+
/** Mientras `loadOptions` de la faceta está resolviendo. */
|
|
24
|
+
loading: string;
|
|
25
|
+
/** Cuando `loadOptions` falla: el menú lo dice en vez de quedar vacío, que parece "sin datos". */
|
|
26
|
+
loadError: string;
|
|
23
27
|
};
|
|
24
28
|
export declare const DEFAULT_FACETED_SEARCH_LABELS: KapiFacetedSearchLabels;
|
|
25
29
|
/** Atributos nativos (`id`, `style`, `data-*`…) van a la región `role="search"` (el rol es propio). */
|
|
@@ -30,6 +34,15 @@ export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "child
|
|
|
30
34
|
chips: ReadonlyArray<KapiFacetChip>;
|
|
31
35
|
/** Texto libre confirmado con Enter. */
|
|
32
36
|
onText: (text: string) => void;
|
|
37
|
+
/** Espera tras la última tecla antes de llamar a `loadOptions` de la faceta, en ms. @default 300 */
|
|
38
|
+
loadDelay?: number;
|
|
39
|
+
/**
|
|
40
|
+
* Cambiar este valor tira el resultado cacheado y vuelve a pedir. Es la única forma de refrescar
|
|
41
|
+
* lo que cargó `loadOptions`, porque ese estado vive adentro del componente y el consumidor no
|
|
42
|
+
* lo puede alcanzar. Los datos que el consumidor YA tiene (filas, opciones estáticas) se
|
|
43
|
+
* refrescan pasando props nuevas: para eso no hace falta esto.
|
|
44
|
+
*/
|
|
45
|
+
reloadKey?: unknown;
|
|
33
46
|
/**
|
|
34
47
|
* Con esta prop, la barra muestra "Limpiar todo" mientras haya algún chip; al tocarlo se llama una
|
|
35
48
|
* sola vez (la pantalla vacía sus filtros de una, sin quitar chip por chip).
|
|
@@ -45,4 +58,4 @@ export type KapiFacetedSearchProps = Omit<HTMLAttributes<HTMLDivElement>, "child
|
|
|
45
58
|
* Teclado: flechas y Enter en el desplegable, Backspace con el campo vacío suelta la faceta pendiente
|
|
46
59
|
* y después el último chip, Escape cancela la faceta pendiente.
|
|
47
60
|
*/
|
|
48
|
-
export declare function KapiFacetedSearch({ facets, chips, onText, onClearAll, labels, className, onMouseDown, "aria-label": ariaLabel, ...rest }: KapiFacetedSearchProps): import("react").JSX.Element;
|
|
61
|
+
export declare function KapiFacetedSearch({ facets, chips, onText, onClearAll, loadDelay, reloadKey, labels, className, onMouseDown, "aria-label": ariaLabel, ...rest }: KapiFacetedSearchProps): import("react").JSX.Element;
|