@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
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLabels as e } from "../locale/KapiLocaleProvider.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { createLoadSequencer as t } from "./asyncSelectLogic.js";
|
|
4
|
+
import { joinClasses as n } from "../rootProps.js";
|
|
5
|
+
import { KapiDatePicker as r } from "./KapiDatePicker.js";
|
|
6
|
+
import { KapiDateRangePicker as i } from "./KapiDateRangePicker.js";
|
|
7
|
+
import { KapiTag as a } from "../display/KapiTag.js";
|
|
8
|
+
import { KapiPopover as o } from "../overlays/KapiPopover.js";
|
|
9
|
+
import { facetKeyAction as ee, facetMenuItems as te, facetOptionName as ne, isDateFacet as s, moveActive as re, toDateRangeValue as c, toDateValue as l } from "./facetedSearchLogic.js";
|
|
9
10
|
/* empty css */
|
|
10
|
-
import { Fragment as
|
|
11
|
-
import { useId as
|
|
12
|
-
import { Search as
|
|
11
|
+
import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
12
|
+
import { useEffect as p, useId as m, useRef as h, useState as g } from "react";
|
|
13
|
+
import { Search as ie } from "lucide-react";
|
|
13
14
|
//#region src/components/inputs/KapiFacetedSearch.tsx
|
|
14
|
-
var
|
|
15
|
+
var _ = {
|
|
15
16
|
input: "Buscar o filtrar",
|
|
16
17
|
region: "Búsqueda",
|
|
17
18
|
placeholder: "Buscar o filtrar…",
|
|
@@ -20,171 +21,232 @@ var b = {
|
|
|
20
21
|
empty: "Sin opciones",
|
|
21
22
|
remove: "Quitar",
|
|
22
23
|
valueOf: "Valor de",
|
|
23
|
-
clearAll: "Limpiar todo"
|
|
24
|
+
clearAll: "Limpiar todo",
|
|
25
|
+
loading: "Buscando…",
|
|
26
|
+
loadError: "No se pudieron cargar los valores"
|
|
24
27
|
};
|
|
25
|
-
function
|
|
26
|
-
let
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
function v({ facets: v, chips: y, onText: b, onClearAll: x, loadDelay: S = 300, reloadKey: C, labels: ae, className: oe, onMouseDown: se, "aria-label": ce, ...le }) {
|
|
29
|
+
let w = e("facetedSearch", _, ae), T = m(), E = `${T}-list`, D = h(null), O = h(null), k = h(null), [A, j] = g(""), [M, N] = g(null), [ue, P] = g(!1), [F, I] = g(-1), [L, R] = g(null), [z] = g(t), B = h(C);
|
|
30
|
+
p(() => {
|
|
31
|
+
Object.is(B.current, C) || (B.current = C, z.cancel(), R(null));
|
|
32
|
+
}, [C, z]);
|
|
33
|
+
let V = A.trim(), H = typeof M?.loadOptions == "function", U = H && L?.key === M?.key && L?.query === V ? L : null, W = H && !U, G = te(v, M, A, U && !U.error ? U.options : void 0), K = s(M), q = ue && !K, J = h(M?.loadOptions);
|
|
34
|
+
p(() => {
|
|
35
|
+
J.current = M?.loadOptions;
|
|
36
|
+
}), p(() => {
|
|
37
|
+
if (!H || !q || U) return;
|
|
38
|
+
let e = M?.key ?? "", t = setTimeout(() => {
|
|
39
|
+
let t = J.current;
|
|
40
|
+
if (!t) return;
|
|
41
|
+
let n = z.start(), r;
|
|
42
|
+
try {
|
|
43
|
+
r = t(V, { signal: n.signal });
|
|
44
|
+
} catch (e) {
|
|
45
|
+
r = Promise.reject(e);
|
|
46
|
+
}
|
|
47
|
+
r.then((t) => {
|
|
48
|
+
n.isCurrent() && (R({
|
|
49
|
+
key: e,
|
|
50
|
+
query: V,
|
|
51
|
+
options: t,
|
|
52
|
+
error: !1
|
|
53
|
+
}), I(-1));
|
|
54
|
+
}, () => {
|
|
55
|
+
n.isCurrent() && R({
|
|
56
|
+
key: e,
|
|
57
|
+
query: V,
|
|
58
|
+
options: [],
|
|
59
|
+
error: !0
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}, S);
|
|
63
|
+
return () => clearTimeout(t);
|
|
64
|
+
}, [
|
|
65
|
+
H,
|
|
66
|
+
q,
|
|
67
|
+
U,
|
|
68
|
+
V,
|
|
69
|
+
S,
|
|
70
|
+
M?.key,
|
|
71
|
+
z
|
|
72
|
+
]), p(() => ((!q || !M) && (z.cancel(), R((e) => e?.error ? null : e)), () => z.cancel()), [
|
|
73
|
+
q,
|
|
74
|
+
M,
|
|
75
|
+
z
|
|
76
|
+
]);
|
|
77
|
+
let Y = () => requestAnimationFrame(() => O.current?.focus()), X = () => {
|
|
78
|
+
j(""), N(null), I(-1);
|
|
79
|
+
}, Z = () => {
|
|
80
|
+
X(), P(!1), Y();
|
|
81
|
+
}, Q = (e) => {
|
|
82
|
+
e.type === "text" ? (b(e.text), Z()) : e.type === "option" ? (M?.apply(e.option.value), Z()) : e.facet.kind === "flag" ? (e.facet.apply("true"), Z()) : (N(e.facet), j(""), I(-1), P(!0), s(e.facet) ? requestAnimationFrame(() => k.current?.focus()) : Y());
|
|
83
|
+
}, de = (e) => {
|
|
84
|
+
let t = ee(e.key, {
|
|
85
|
+
input: A,
|
|
86
|
+
pending: !!M,
|
|
87
|
+
active: F,
|
|
88
|
+
open: q,
|
|
89
|
+
chips: y.length
|
|
39
90
|
});
|
|
40
91
|
if (t) switch (e.preventDefault(), t) {
|
|
41
92
|
case "next":
|
|
42
93
|
case "prev":
|
|
43
|
-
|
|
94
|
+
P(!0), I((e) => re(q ? e : -1, G.length, t === "next" ? 1 : -1));
|
|
44
95
|
break;
|
|
45
96
|
case "select": {
|
|
46
|
-
let e =
|
|
47
|
-
e &&
|
|
97
|
+
let e = G[F];
|
|
98
|
+
e && Q(e);
|
|
48
99
|
break;
|
|
49
100
|
}
|
|
50
101
|
case "text":
|
|
51
|
-
|
|
102
|
+
b(A.trim()), Z();
|
|
52
103
|
break;
|
|
53
104
|
case "cancel":
|
|
54
|
-
|
|
105
|
+
X();
|
|
55
106
|
break;
|
|
56
107
|
case "close":
|
|
57
|
-
|
|
108
|
+
P(!1), I(-1);
|
|
58
109
|
break;
|
|
59
110
|
case "dropPending":
|
|
60
|
-
|
|
111
|
+
N(null), I(-1);
|
|
61
112
|
break;
|
|
62
|
-
case "removeLast":
|
|
113
|
+
case "removeLast": y[y.length - 1]?.onRemove();
|
|
63
114
|
}
|
|
64
|
-
},
|
|
115
|
+
}, fe = (e) => {
|
|
65
116
|
let t = e.target.value === "";
|
|
66
|
-
(e.key === "Escape" || e.key === "Backspace" && t) && (e.preventDefault(),
|
|
67
|
-
}, $ = (e) => `${
|
|
68
|
-
return /* @__PURE__ */
|
|
69
|
-
...
|
|
70
|
-
ref:
|
|
71
|
-
className:
|
|
117
|
+
(e.key === "Escape" || e.key === "Backspace" && t) && (e.preventDefault(), X(), Y());
|
|
118
|
+
}, $ = (e) => `${T}-opt-${e}`;
|
|
119
|
+
return /* @__PURE__ */ f("div", {
|
|
120
|
+
...le,
|
|
121
|
+
ref: D,
|
|
122
|
+
className: n("kapi-facets", oe),
|
|
72
123
|
role: "search",
|
|
73
|
-
"aria-label":
|
|
124
|
+
"aria-label": ce ?? w.region,
|
|
74
125
|
onMouseDown: (e) => {
|
|
75
|
-
|
|
126
|
+
se?.(e), !e.defaultPrevented && e.target === e.currentTarget && (e.preventDefault(), O.current?.focus(), P(!0));
|
|
76
127
|
},
|
|
77
128
|
children: [
|
|
78
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */ d(ie, {
|
|
79
130
|
className: "kapi-facets__icon",
|
|
80
131
|
size: 15,
|
|
81
132
|
"aria-hidden": !0
|
|
82
133
|
}),
|
|
83
|
-
|
|
134
|
+
y.map((e) => /* @__PURE__ */ d(a, {
|
|
84
135
|
size: "sm",
|
|
85
136
|
onRemove: () => {
|
|
86
|
-
e.onRemove(),
|
|
137
|
+
e.onRemove(), Y();
|
|
87
138
|
},
|
|
88
|
-
removeLabel: `${
|
|
139
|
+
removeLabel: `${w.remove} ${e.label}`,
|
|
89
140
|
children: e.label
|
|
90
141
|
}, e.key)),
|
|
91
|
-
|
|
142
|
+
M && /* @__PURE__ */ f(a, {
|
|
92
143
|
size: "sm",
|
|
93
144
|
tone: "primary",
|
|
94
145
|
className: "kapi-facets__pending",
|
|
95
|
-
children: [
|
|
146
|
+
children: [M.label, ":"]
|
|
96
147
|
}),
|
|
97
|
-
|
|
148
|
+
K && M ? /* @__PURE__ */ d("span", {
|
|
98
149
|
className: "kapi-facets__date",
|
|
99
|
-
onKeyDown:
|
|
100
|
-
children:
|
|
101
|
-
ref:
|
|
102
|
-
"aria-label": `${
|
|
150
|
+
onKeyDown: fe,
|
|
151
|
+
children: M.kind === "dateRange" ? /* @__PURE__ */ d(i, {
|
|
152
|
+
ref: k,
|
|
153
|
+
"aria-label": `${w.valueOf} ${M.label}`,
|
|
103
154
|
onChange: ({ from: e, to: t }) => {
|
|
104
|
-
e && t && (
|
|
155
|
+
e && t && (M.apply(c(e, t)), Z());
|
|
105
156
|
}
|
|
106
|
-
}) : /* @__PURE__ */
|
|
107
|
-
ref:
|
|
108
|
-
"aria-label": `${
|
|
157
|
+
}) : /* @__PURE__ */ d(r, {
|
|
158
|
+
ref: k,
|
|
159
|
+
"aria-label": `${w.valueOf} ${M.label}`,
|
|
109
160
|
onChange: (e) => {
|
|
110
|
-
e && (
|
|
161
|
+
e && (M.apply(l(e)), Z());
|
|
111
162
|
}
|
|
112
163
|
})
|
|
113
|
-
}) : /* @__PURE__ */
|
|
114
|
-
ref:
|
|
164
|
+
}) : /* @__PURE__ */ d("input", {
|
|
165
|
+
ref: O,
|
|
115
166
|
className: "kapi-facets__input",
|
|
116
167
|
type: "text",
|
|
117
168
|
role: "combobox",
|
|
118
169
|
autoComplete: "off",
|
|
119
|
-
"aria-label":
|
|
120
|
-
"aria-expanded":
|
|
121
|
-
"aria-controls":
|
|
170
|
+
"aria-label": w.input,
|
|
171
|
+
"aria-expanded": q,
|
|
172
|
+
"aria-controls": E,
|
|
122
173
|
"aria-autocomplete": "list",
|
|
123
|
-
"aria-activedescendant":
|
|
124
|
-
placeholder:
|
|
125
|
-
value:
|
|
126
|
-
onFocus: () =>
|
|
127
|
-
onClick: () =>
|
|
174
|
+
"aria-activedescendant": q && F >= 0 ? $(F) : void 0,
|
|
175
|
+
placeholder: y.length === 0 && !M ? w.placeholder : void 0,
|
|
176
|
+
value: A,
|
|
177
|
+
onFocus: () => P(!0),
|
|
178
|
+
onClick: () => P(!0),
|
|
128
179
|
onBlur: (e) => {
|
|
129
180
|
let t = e.relatedTarget;
|
|
130
|
-
(!t || !
|
|
181
|
+
(!t || !D.current?.contains(t)) && P(!1);
|
|
131
182
|
},
|
|
132
183
|
onChange: (e) => {
|
|
133
|
-
|
|
184
|
+
j(e.target.value), P(!0), I(-1);
|
|
134
185
|
},
|
|
135
|
-
onKeyDown:
|
|
186
|
+
onKeyDown: de
|
|
136
187
|
}),
|
|
137
|
-
|
|
188
|
+
x && y.length > 0 && /* @__PURE__ */ d("button", {
|
|
138
189
|
type: "button",
|
|
139
190
|
className: "kapi-facets__clear",
|
|
140
191
|
onClick: () => {
|
|
141
|
-
|
|
192
|
+
x(), X(), Y();
|
|
142
193
|
},
|
|
143
|
-
children:
|
|
194
|
+
children: w.clearAll
|
|
144
195
|
}),
|
|
145
|
-
/* @__PURE__ */
|
|
146
|
-
open:
|
|
147
|
-
anchorRef:
|
|
148
|
-
onClose: () =>
|
|
196
|
+
/* @__PURE__ */ f(o, {
|
|
197
|
+
open: q,
|
|
198
|
+
anchorRef: D,
|
|
199
|
+
onClose: () => P(!1),
|
|
149
200
|
matchAnchorWidth: !0,
|
|
150
201
|
role: "listbox",
|
|
151
|
-
id:
|
|
152
|
-
"aria-label":
|
|
202
|
+
id: E,
|
|
203
|
+
"aria-label": M ? M.label : w.input,
|
|
153
204
|
closeOnEscape: !1,
|
|
154
205
|
restoreFocus: !1,
|
|
155
206
|
className: "kapi-facets__menu",
|
|
156
|
-
children: [
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
"
|
|
173
|
-
|
|
174
|
-
className: "kapi-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
207
|
+
children: [
|
|
208
|
+
W && /* @__PURE__ */ d("div", {
|
|
209
|
+
className: "kapi-facets__empty",
|
|
210
|
+
children: w.loading
|
|
211
|
+
}),
|
|
212
|
+
!W && U?.error && /* @__PURE__ */ d("div", {
|
|
213
|
+
className: "kapi-facets__empty kapi-facets__empty--err",
|
|
214
|
+
children: w.loadError
|
|
215
|
+
}),
|
|
216
|
+
!W && !U?.error && G.length === 0 && /* @__PURE__ */ d("div", {
|
|
217
|
+
className: "kapi-facets__empty",
|
|
218
|
+
children: w.empty
|
|
219
|
+
}),
|
|
220
|
+
!W && !U?.error && G.map((e, t) => /* @__PURE__ */ d("div", {
|
|
221
|
+
id: $(t),
|
|
222
|
+
role: "option",
|
|
223
|
+
"aria-selected": t === F,
|
|
224
|
+
"aria-label": e.type === "option" ? ne(e.option) : void 0,
|
|
225
|
+
className: `kapi-facets__opt${t === F ? " kapi-facets__opt--active" : ""}`,
|
|
226
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
227
|
+
onMouseEnter: () => I(t),
|
|
228
|
+
onClick: () => Q(e),
|
|
229
|
+
children: e.type === "text" ? /* @__PURE__ */ f("span", { children: [
|
|
230
|
+
w.searchFor,
|
|
231
|
+
" “",
|
|
232
|
+
e.text,
|
|
233
|
+
"”"
|
|
234
|
+
] }) : e.type === "option" ? /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("span", { children: e.option.label }), e.option.count !== void 0 && /* @__PURE__ */ d("span", {
|
|
235
|
+
className: "kapi-facets__count",
|
|
236
|
+
"aria-hidden": "true",
|
|
237
|
+
children: e.option.count
|
|
238
|
+
})] }) : /* @__PURE__ */ f("span", { children: [/* @__PURE__ */ d("span", {
|
|
239
|
+
className: "kapi-facets__facet",
|
|
240
|
+
children: e.facet.label
|
|
241
|
+
}), e.facet.kind !== "flag" && /* @__PURE__ */ f("span", {
|
|
242
|
+
className: "kapi-facets__hint",
|
|
243
|
+
children: [" · ", w.pickValue]
|
|
244
|
+
})] })
|
|
245
|
+
}, e.type === "facet" ? `f-${e.facet.key}` : e.type === "option" ? `o-${e.option.value}` : "t"))
|
|
246
|
+
]
|
|
185
247
|
})
|
|
186
248
|
]
|
|
187
249
|
});
|
|
188
250
|
}
|
|
189
251
|
//#endregion
|
|
190
|
-
export {
|
|
252
|
+
export { _ as DEFAULT_FACETED_SEARCH_LABELS, v as KapiFacetedSearch };
|
|
@@ -40,6 +40,13 @@ export interface KapiSelectBaseProps<T = unknown> {
|
|
|
40
40
|
}) => Promise<KapiSelectEntry<T>[]>;
|
|
41
41
|
/** Espera tras la última tecla antes de llamar a `loadOptions`, en ms. @default 300 */
|
|
42
42
|
loadDelay?: number;
|
|
43
|
+
/**
|
|
44
|
+
* Cambiar este valor tira el resultado cacheado y vuelve a pedir. Es la única forma de refrescar
|
|
45
|
+
* lo que cargó `loadOptions`, porque ese estado vive adentro del componente y el consumidor no
|
|
46
|
+
* lo puede alcanzar. Los datos que el consumidor YA tiene (filas, opciones estáticas) se
|
|
47
|
+
* refrescan pasando props nuevas: para eso no hace falta esto.
|
|
48
|
+
*/
|
|
49
|
+
reloadKey?: unknown;
|
|
43
50
|
/** Ofrece "Crear “texto”" si ninguna opción coincide exacto; si devuelve una opción, se elige. Una promesa debe terminar (resolver o rechazar): mientras está pendiente no se puede crear otra. */
|
|
44
51
|
onCreate?: (text: string) => KapiSelectOption<T> | void | Promise<KapiSelectOption<T> | void>;
|
|
45
52
|
/** Filtrar tipeando. Default `true`. */
|