@kapiuara/ui 0.5.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.
Files changed (38) hide show
  1. package/README.md +54 -1
  2. package/dist/components/chat/KapiChatDivider.d.ts +15 -0
  3. package/dist/components/chat/KapiChatDivider.js +17 -0
  4. package/dist/components/chat/KapiChatList.d.ts +57 -0
  5. package/dist/components/chat/KapiChatList.js +71 -0
  6. package/dist/components/chat/KapiChatThread.d.ts +35 -0
  7. package/dist/components/chat/KapiChatThread.js +85 -0
  8. package/dist/components/chat/KapiComposer.d.ts +60 -0
  9. package/dist/components/chat/KapiComposer.js +89 -0
  10. package/dist/components/chat/KapiMessageBubble.d.ts +43 -0
  11. package/dist/components/chat/KapiMessageBubble.js +67 -0
  12. package/dist/components/chat/KapiTypingIndicator.d.ts +27 -0
  13. package/dist/components/chat/KapiTypingIndicator.js +34 -0
  14. package/dist/components/chat/chatLogic.d.ts +76 -0
  15. package/dist/components/chat/chatLogic.js +34 -0
  16. package/dist/components/chat/index.d.ts +14 -0
  17. package/dist/components/display/KapiCommentComposer.d.ts +4 -0
  18. package/dist/components/display/KapiCommentComposer.js +43 -46
  19. package/dist/components/display/commentLogic.d.ts +9 -2
  20. package/dist/components/display/commentLogic.js +1 -1
  21. package/dist/components/display/index.d.ts +1 -0
  22. package/dist/components/layout/KapiPanelParts.js +9 -9
  23. package/dist/components/layout/KapiRail.js +8 -8
  24. package/dist/components/locale/labelRegistry.d.ts +10 -0
  25. package/dist/components/navigation/KapiContextPanel.js +86 -86
  26. package/dist/components/navigation/KapiPanelGroup.js +18 -18
  27. package/dist/components/navigation/KapiTabs.js +1 -1
  28. package/dist/components/navigation/MiniNavItem.js +1 -1
  29. package/dist/hooks/dateFormat.d.ts +7 -0
  30. package/dist/hooks/dateFormat.js +16 -2
  31. package/dist/hooks/index.d.ts +1 -1
  32. package/dist/hooks/useSubmitDraft.d.ts +34 -0
  33. package/dist/hooks/useSubmitDraft.js +28 -0
  34. package/dist/index.d.ts +1 -0
  35. package/dist/index.js +83 -76
  36. package/dist/kapi.css +1 -1
  37. package/dist/kapi.layered.css +1 -1
  38. package/package.json +1 -1
@@ -1,22 +1,22 @@
1
1
  "use client";
2
2
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
3
  import { joinClasses as t } from "../rootProps.js";
4
- import { canCollapse as n, clampCtxPanelWidth as r, ctxPanelClasses as i, ctxPanelWidthFromDrag as a, resolveCollapsed as o, stepCtxPanelWidth as s } from "./contextPanelLogic.js";
5
- import { activeIdIn as c } from "./activeItemLogic.js";
6
- import { CtxSlidingList as l } from "./CtxSlidingList.js";
7
- /* empty css */
8
- import { DEFAULT_LINK_LABELS as u } from "../locale/linkLabels.js";
9
4
  import "./navBadgeLogic.js";
10
- import { KapiNavBadge as d } from "./KapiNavBadge.js";
5
+ import { KapiNavBadge as n } from "./KapiNavBadge.js";
6
+ import { canCollapse as r, clampCtxPanelWidth as i, ctxPanelClasses as a, ctxPanelWidthFromDrag as o, resolveCollapsed as s, stepCtxPanelWidth as c } from "./contextPanelLogic.js";
7
+ import { activeIdIn as l } from "./activeItemLogic.js";
8
+ import { CtxSlidingList as u } from "./CtxSlidingList.js";
9
+ /* empty css */
10
+ import { DEFAULT_LINK_LABELS as d } from "../locale/linkLabels.js";
11
11
  import { KapiPanelMiniContext as f, useKapiPanelMini as p } from "./panelMini.js";
12
12
  import { MiniNavItem as m } from "./MiniNavItem.js";
13
13
  import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
14
- import { useLayoutEffect as ee, useRef as v, useState as y } from "react";
15
- import { ChevronsLeft as b, ChevronsRight as x, ExternalLink as S } from "lucide-react";
14
+ import { useLayoutEffect as v, useRef as y, useState as b } from "react";
15
+ import { ChevronsLeft as x, ChevronsRight as S, ExternalLink as C } from "lucide-react";
16
16
  //#region src/components/navigation/KapiContextPanel.tsx
17
- var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
18
- let { mini: i } = p(), a = e.detail !== void 0 || e.initials !== void 0, o = () => n?.(e.id);
19
- return i ? /* @__PURE__ */ g(m, {
17
+ var w = ({ item: e, active: t, onSelect: r, newTabLabel: i }) => {
18
+ let { mini: a } = p(), o = e.detail !== void 0 || e.initials !== void 0, s = () => r?.(e.id);
19
+ return a ? /* @__PURE__ */ g(m, {
20
20
  label: e.label,
21
21
  icon: e.icon,
22
22
  initials: e.initials,
@@ -25,17 +25,17 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
25
25
  badgeTone: e.badgeTone,
26
26
  badgeLabel: e.badgeLabel,
27
27
  disabled: e.disabled,
28
- ...!a && e.href !== void 0 ? {
28
+ ...!o && e.href !== void 0 ? {
29
29
  href: e.href,
30
30
  newTab: e.newTab,
31
- newTabLabel: r
32
- } : { onClick: o }
33
- }) : a ? /* @__PURE__ */ _("button", {
31
+ newTabLabel: i
32
+ } : { onClick: s }
33
+ }) : o ? /* @__PURE__ */ _("button", {
34
34
  type: "button",
35
35
  className: `kapi-ctxrec${t ? " kapi-ctxrec--on" : ""}`,
36
36
  "aria-current": t ? "page" : void 0,
37
37
  disabled: e.disabled,
38
- onClick: o,
38
+ onClick: s,
39
39
  children: [
40
40
  e.initials !== void 0 && /* @__PURE__ */ g("span", {
41
41
  className: "kapi-ctxrec__av kapi-ctxrec__av--tone",
@@ -51,7 +51,7 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
51
51
  children: e.detail
52
52
  })]
53
53
  }),
54
- /* @__PURE__ */ g(d, {
54
+ /* @__PURE__ */ g(n, {
55
55
  value: e.badge,
56
56
  tone: e.badgeTone,
57
57
  label: e.badgeLabel,
@@ -64,13 +64,13 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
64
64
  className: `kapi-ctxitem${t ? " kapi-ctxitem--on" : ""}`,
65
65
  "aria-current": t ? "page" : void 0,
66
66
  disabled: e.disabled,
67
- onClick: o,
67
+ onClick: s,
68
68
  children: [
69
69
  /* @__PURE__ */ _("span", {
70
70
  className: "kapi-ctxitem__main",
71
71
  children: [e.icon, e.label]
72
72
  }),
73
- /* @__PURE__ */ g(d, {
73
+ /* @__PURE__ */ g(n, {
74
74
  value: e.badge,
75
75
  tone: e.badgeTone,
76
76
  label: e.badgeLabel,
@@ -90,26 +90,26 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
90
90
  className: "kapi-ctxitem__main",
91
91
  children: [e.icon, e.label]
92
92
  }),
93
- /* @__PURE__ */ g(d, {
93
+ /* @__PURE__ */ g(n, {
94
94
  value: e.badge,
95
95
  tone: e.badgeTone,
96
96
  label: e.badgeLabel,
97
97
  max: 999
98
98
  }),
99
99
  e.trailing,
100
- e.external && /* @__PURE__ */ g(S, {
100
+ e.external && /* @__PURE__ */ g(C, {
101
101
  className: "kapi-ctxitem__ext",
102
102
  size: 14,
103
103
  "aria-hidden": "true"
104
104
  }),
105
105
  e.newTab && /* @__PURE__ */ g("span", {
106
106
  className: "kapi-ctxitem__sr",
107
- children: r
107
+ children: i
108
108
  })
109
109
  ]
110
110
  });
111
- }, w = ({ sections: t, activeId: n, onSelect: r, search: i, hint: a, labels: o }) => {
112
- let s = e("link", u, o);
111
+ }, T = ({ sections: t, activeId: n, onSelect: r, search: i, hint: a, labels: o }) => {
112
+ let s = e("link", d, o);
113
113
  return /* @__PURE__ */ _(h, { children: [
114
114
  i && /* @__PURE__ */ g("input", {
115
115
  type: "search",
@@ -127,9 +127,9 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
127
127
  className: "kapi-ct",
128
128
  children: e.label
129
129
  }),
130
- /* @__PURE__ */ g(l, {
131
- active: c(e.items, n),
132
- children: e.items.map((e) => /* @__PURE__ */ g(C, {
130
+ /* @__PURE__ */ g(u, {
131
+ active: l(e.items, n),
132
+ children: e.items.map((e) => /* @__PURE__ */ g(w, {
133
133
  item: e,
134
134
  active: e.id === n,
135
135
  onSelect: r,
@@ -143,48 +143,48 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
143
143
  children: a
144
144
  })
145
145
  ] });
146
- }, T = {
146
+ }, E = {
147
147
  resize: "Redimensionar panel",
148
148
  collapse: "Plegar panel",
149
149
  expand: "Desplegar panel",
150
150
  region: "Panel contextual"
151
- }, E = ({ title: c, actions: l, collapsed: u, defaultCollapsed: d, onCollapsedChange: p, collapseLabel: m, expandLabel: h, side: S = "left", collapsedMode: C = "hidden", resizable: E = !1, minWidth: D = 200, maxWidth: O = 420, "aria-label": k, labels: A, className: j, style: M, id: N, ...P }) => {
152
- let F = e("contextPanel", T, A), I = m ?? F.collapse, L = h ?? F.expand, R = k ?? F.region, [z, B] = y(d ?? !1), [V, H] = y(null), [U, W] = y(!1), G = v(null), K = v(null), q = o(u, z), J = v(null), [Y, X] = y(null);
153
- ee(() => {
154
- Y && (q === Y.next && J.current?.focus(), X(null));
155
- }, [Y, q]);
156
- let Z = (e) => {
157
- X({ next: e }), u === void 0 && B(e), p?.(e);
158
- }, te = S === "right" ? x : b, ne = S === "right" ? b : x, Q = () => V ?? K.current?.offsetWidth ?? 258, re = (e) => {
159
- e.button === 0 && (G.current = {
151
+ }, D = ({ title: n, actions: l, collapsed: u, defaultCollapsed: d, onCollapsedChange: p, collapseLabel: m, expandLabel: h, side: C = "left", collapsedMode: w = "hidden", resizable: D = !1, minWidth: O = 200, maxWidth: k = 420, "aria-label": A, labels: j, className: M, style: N, id: P, ...F }) => {
152
+ let I = e("contextPanel", E, j), ee = m ?? I.collapse, te = h ?? I.expand, L = A ?? I.region, [R, z] = b(d ?? !1), [B, V] = b(null), [H, U] = b(!1), W = y(null), G = y(null), K = s(u, R), q = y(null), [J, Y] = b(null);
153
+ v(() => {
154
+ J && (K === J.next && q.current?.focus(), Y(null));
155
+ }, [J, K]);
156
+ let X = (e) => {
157
+ Y({ next: e }), u === void 0 && z(e), p?.(e);
158
+ }, Z = C === "right" ? S : x, ne = C === "right" ? x : S, Q = () => B ?? G.current?.offsetWidth ?? 258, re = (e) => {
159
+ e.button === 0 && (W.current = {
160
160
  startX: e.clientX,
161
161
  startWidth: Q()
162
- }, e.currentTarget.setPointerCapture(e.pointerId), W(!0), e.preventDefault());
162
+ }, e.currentTarget.setPointerCapture(e.pointerId), U(!0), e.preventDefault());
163
163
  }, ie = (e) => {
164
- let t = G.current;
165
- t && H(a(S, t.startWidth, t.startX, e.clientX, D, O));
164
+ let t = W.current;
165
+ t && V(o(C, t.startWidth, t.startX, e.clientX, O, k));
166
166
  }, $ = (e) => {
167
- G.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), W(!1);
167
+ W.current = null, e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), U(!1);
168
168
  }, ae = (e) => {
169
- let t = s(S, Q(), e.key, D, O);
170
- t !== null && (e.preventDefault(), H(t));
169
+ let t = c(C, Q(), e.key, O, k);
170
+ t !== null && (e.preventDefault(), V(t));
171
171
  };
172
- if (q) {
173
- let e = C === "mini";
172
+ if (K) {
173
+ let e = w === "mini";
174
174
  return /* @__PURE__ */ _("aside", {
175
- id: N,
176
- className: t(i({
177
- side: S,
175
+ id: P,
176
+ className: t(a({
177
+ side: C,
178
178
  collapsed: !0
179
- }), e && "is-mini kapi-navmini", j),
180
- style: M,
181
- "aria-label": R,
179
+ }), e && "is-mini kapi-navmini", M),
180
+ style: N,
181
+ "aria-label": L,
182
182
  children: [/* @__PURE__ */ g("button", {
183
- ref: J,
183
+ ref: q,
184
184
  type: "button",
185
185
  className: "kapi-paneltoggle",
186
- onClick: () => Z(!1),
187
- "aria-label": L,
186
+ onClick: () => X(!1),
187
+ "aria-label": te,
188
188
  children: /* @__PURE__ */ g(ne, {
189
189
  size: 16,
190
190
  strokeWidth: 2,
@@ -193,38 +193,38 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
193
193
  }), e && /* @__PURE__ */ g(f.Provider, {
194
194
  value: {
195
195
  mini: !0,
196
- expand: () => Z(!1),
197
- tooltipSide: S === "right" ? "left" : "right"
196
+ expand: () => X(!1),
197
+ tooltipSide: C === "right" ? "left" : "right"
198
198
  },
199
- children: /* @__PURE__ */ g(w, {
200
- ...P,
201
- labels: A
199
+ children: /* @__PURE__ */ g(T, {
200
+ ...F,
201
+ labels: j
202
202
  })
203
203
  })]
204
204
  });
205
205
  }
206
206
  return /* @__PURE__ */ _("aside", {
207
- ref: K,
208
- id: N,
209
- className: t(i({
210
- side: S,
211
- resizing: U
212
- }), j),
213
- "aria-label": R,
214
- "data-resizable": E || void 0,
215
- style: E && V !== null ? {
216
- ...M,
217
- width: V
218
- } : M,
207
+ ref: G,
208
+ id: P,
209
+ className: t(a({
210
+ side: C,
211
+ resizing: H
212
+ }), M),
213
+ "aria-label": L,
214
+ "data-resizable": D || void 0,
215
+ style: D && B !== null ? {
216
+ ...N,
217
+ width: B
218
+ } : N,
219
219
  children: [
220
- E && /* @__PURE__ */ g("div", {
220
+ D && /* @__PURE__ */ g("div", {
221
221
  className: "kapi-ctxpanel__resize",
222
222
  role: "separator",
223
223
  "aria-orientation": "vertical",
224
- "aria-label": F.resize,
225
- "aria-valuemin": D,
226
- "aria-valuemax": O,
227
- "aria-valuenow": r(V ?? 258, D, O),
224
+ "aria-label": I.resize,
225
+ "aria-valuemin": O,
226
+ "aria-valuemax": k,
227
+ "aria-valuenow": i(B ?? 258, O, k),
228
228
  tabIndex: 0,
229
229
  onPointerDown: re,
230
230
  onPointerMove: ie,
@@ -234,19 +234,19 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
234
234
  }),
235
235
  /* @__PURE__ */ _("div", {
236
236
  className: "kapi-ctxpanel__head",
237
- children: [/* @__PURE__ */ g("span", { children: c }), /* @__PURE__ */ _("div", {
237
+ children: [/* @__PURE__ */ g("span", { children: n }), /* @__PURE__ */ _("div", {
238
238
  className: "kapi-ctxpanel__actions",
239
- children: [l, n({
239
+ children: [l, r({
240
240
  collapsed: u,
241
241
  defaultCollapsed: d,
242
242
  onCollapsedChange: p
243
243
  }) && /* @__PURE__ */ g("button", {
244
- ref: J,
244
+ ref: q,
245
245
  type: "button",
246
246
  className: "kapi-paneltoggle",
247
- onClick: () => Z(!0),
248
- "aria-label": I,
249
- children: /* @__PURE__ */ g(te, {
247
+ onClick: () => X(!0),
248
+ "aria-label": ee,
249
+ children: /* @__PURE__ */ g(Z, {
250
250
  size: 16,
251
251
  strokeWidth: 2,
252
252
  "aria-hidden": "true"
@@ -254,12 +254,12 @@ var C = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
254
254
  })]
255
255
  })]
256
256
  }),
257
- /* @__PURE__ */ g(w, {
258
- ...P,
259
- labels: A
257
+ /* @__PURE__ */ g(T, {
258
+ ...F,
259
+ labels: j
260
260
  })
261
261
  ]
262
262
  });
263
263
  };
264
264
  //#endregion
265
- export { T as DEFAULT_CONTEXT_PANEL_LABELS, E as KapiContextPanel, w as KapiContextSections };
265
+ export { E as DEFAULT_CONTEXT_PANEL_LABELS, D as KapiContextPanel, T as KapiContextSections };
@@ -1,11 +1,11 @@
1
1
  "use client";
2
2
  import { useLabels as e } from "../locale/KapiLocaleProvider.js";
3
- import { activeIdIn as t } from "./activeItemLogic.js";
4
- import { CtxSlidingList as n } from "./CtxSlidingList.js";
5
- /* empty css */
6
- import { DEFAULT_LINK_LABELS as r } from "../locale/linkLabels.js";
7
3
  import "./navBadgeLogic.js";
8
- import { KapiNavBadge as i } from "./KapiNavBadge.js";
4
+ import { KapiNavBadge as t } from "./KapiNavBadge.js";
5
+ import { activeIdIn as n } from "./activeItemLogic.js";
6
+ import { CtxSlidingList as r } from "./CtxSlidingList.js";
7
+ /* empty css */
8
+ import { DEFAULT_LINK_LABELS as i } from "../locale/linkLabels.js";
9
9
  import { useKapiPanelMini as a } from "./panelMini.js";
10
10
  import { MiniNavItem as o } from "./MiniNavItem.js";
11
11
  import { formatCount as s, panelGroupClasses as c, resolveOpen as l } from "./panelGroupLogic.js";
@@ -19,20 +19,20 @@ var g = ({ value: e }) => {
19
19
  className: "kapi-panelgroup__count",
20
20
  children: t
21
21
  });
22
- }, _ = ({ item: e, active: t, onSelect: n, newTabLabel: r }) => {
23
- let a = `kapi-ctxitem${t ? " kapi-ctxitem--on" : ""}`, o = /* @__PURE__ */ d("span", {
22
+ }, _ = ({ item: e, active: n, onSelect: r, newTabLabel: i }) => {
23
+ let a = `kapi-ctxitem${n ? " kapi-ctxitem--on" : ""}`, o = /* @__PURE__ */ d("span", {
24
24
  className: "kapi-ctxitem__main",
25
25
  children: [e.icon, e.label]
26
26
  });
27
27
  return e.href === void 0 ? /* @__PURE__ */ d("button", {
28
28
  type: "button",
29
29
  className: a,
30
- "aria-current": t ? "page" : void 0,
30
+ "aria-current": n ? "page" : void 0,
31
31
  disabled: e.disabled,
32
- onClick: () => n?.(e.id),
32
+ onClick: () => r?.(e.id),
33
33
  children: [
34
34
  o,
35
- /* @__PURE__ */ u(i, {
35
+ /* @__PURE__ */ u(t, {
36
36
  value: e.badge,
37
37
  tone: e.badgeTone,
38
38
  label: e.badgeLabel,
@@ -45,11 +45,11 @@ var g = ({ value: e }) => {
45
45
  href: e.disabled ? void 0 : e.href,
46
46
  rel: "noopener noreferrer",
47
47
  target: e.newTab ? "_blank" : void 0,
48
- "aria-current": t ? "page" : void 0,
48
+ "aria-current": n ? "page" : void 0,
49
49
  "aria-disabled": e.disabled || void 0,
50
50
  children: [
51
51
  o,
52
- /* @__PURE__ */ u(i, {
52
+ /* @__PURE__ */ u(t, {
53
53
  value: e.badge,
54
54
  tone: e.badgeTone,
55
55
  label: e.badgeLabel,
@@ -63,13 +63,13 @@ var g = ({ value: e }) => {
63
63
  }),
64
64
  e.newTab && /* @__PURE__ */ u("span", {
65
65
  className: "kapi-ctxitem__sr",
66
- children: r
66
+ children: i
67
67
  })
68
68
  ]
69
69
  });
70
70
  };
71
71
  function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x, items: S, activeId: C, onSelect: w, open: T, defaultOpen: E = !1, onOpenChange: D, className: O, style: k, id: A, "aria-label": j, labels: M }) {
72
- let N = e("link", r, M), P = f(), F = `${P}-body`, I = `${P}-head`, [L, R] = p(E), z = l(T, L), B = (e) => {
72
+ let N = e("link", i, M), P = f(), F = `${P}-body`, I = `${P}-head`, [L, R] = p(E), z = l(T, L), B = (e) => {
73
73
  T === void 0 && R(e), D?.(e);
74
74
  }, V = () => B(!z), { mini: H, expand: U } = a();
75
75
  return H ? /* @__PURE__ */ u("div", {
@@ -82,7 +82,7 @@ function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x,
82
82
  children: /* @__PURE__ */ u(o, {
83
83
  label: s,
84
84
  icon: x,
85
- active: t(S, C) !== null,
85
+ active: n(S, C) !== null,
86
86
  badge: v,
87
87
  badgeTone: y,
88
88
  badgeLabel: b,
@@ -109,7 +109,7 @@ function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x,
109
109
  className: "kapi-panelgroup__label",
110
110
  children: [x, s]
111
111
  }),
112
- /* @__PURE__ */ u(i, {
112
+ /* @__PURE__ */ u(t, {
113
113
  value: v,
114
114
  tone: y,
115
115
  label: b,
@@ -132,8 +132,8 @@ function v({ label: s, count: h, badge: v, badgeTone: y, badgeLabel: b, icon: x,
132
132
  inert: !z,
133
133
  children: /* @__PURE__ */ u("div", {
134
134
  className: "kapi-panelgroup__clip",
135
- children: /* @__PURE__ */ u(n, {
136
- active: t(S, C),
135
+ children: /* @__PURE__ */ u(r, {
136
+ active: n(S, C),
137
137
  children: S.map((e) => /* @__PURE__ */ u(_, {
138
138
  item: e,
139
139
  active: e.id === C,
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { joinClasses as e } from "../rootProps.js";
3
3
  import { useSlidingIndicator as t } from "../../hooks/useSlidingIndicator.js";
4
- /* empty css */
5
4
  import { useScrollEdges as n } from "../../hooks/useScrollEdges.js";
5
+ /* empty css */
6
6
  import { nextTabId as r, tabClasses as i, tabId as a, tabPanelId as o } from "./tabsLogic.js";
7
7
  import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
8
8
  import { useCallback as u, useId as d, useLayoutEffect as f, useRef as p } from "react";
@@ -1,9 +1,9 @@
1
1
  "use client";
2
2
  import { joinClasses as e } from "../rootProps.js";
3
3
  import { KapiTooltip as t } from "../overlays/KapiTooltip.js";
4
- /* empty css */
5
4
  import { navBadgeA11yText as n } from "./navBadgeLogic.js";
6
5
  import { KapiNavBadge as r } from "./KapiNavBadge.js";
6
+ /* empty css */
7
7
  import { useKapiPanelMini as i } from "./panelMini.js";
8
8
  import { miniInitial as a, miniTooltipLabel as o, nodeText as s } from "./panelMiniLogic.js";
9
9
  import { Fragment as c, jsx as l, jsxs as u } from "react/jsx-runtime";
@@ -5,6 +5,13 @@ export declare const isoDateTime: (date: Date | string) => string | null;
5
5
  * devuelve "". Trunca en vez de redondear: 59,5 minutos es "hace 59 minutos", nunca "hace 60 minutos".
6
6
  */
7
7
  export declare const formatRelativeTime: (date: Date | string, now?: Date, locale?: string) => string;
8
+ /**
9
+ * Etiqueta de un día para separadores de un hilo, según el día local respecto de `now`: hoy y ayer salen de
10
+ * `Intl.RelativeTimeFormat` con `numeric: "auto"` ("hoy", "ayer"); de 2 a 6 días atrás, el nombre del día
11
+ * ("miércoles"); más viejo, día y mes ("12 de marzo") y, de otro año, día, mes y año. Una fecha inválida
12
+ * devuelve "".
13
+ */
14
+ export declare const formatDayLabel: (date: Date, now?: Date, locale?: string) => string;
8
15
  /**
9
16
  * Fecha absoluta con `Intl.DateTimeFormat` (default `{ dateStyle: "medium" }`: "12 mar 2026").
10
17
  * Acepta `Date` o string parseable; una fecha inválida devuelve "".
@@ -7,9 +7,23 @@ var e = 6e4, t = 60 * e, n = 24 * t, r = 7 * n, i = 30 * n, a = 365 * n, o = /*
7
7
  if (!Number.isFinite(d)) return "";
8
8
  let f = d - l.getTime(), p = Math.abs(f), m = s(u);
9
9
  return p < e ? m.format(0, "second") : p < t ? m.format(Math.trunc(f / e), "minute") : p < n ? m.format(Math.trunc(f / t), "hour") : p < r ? m.format(Math.trunc(f / n), "day") : p < i ? m.format(Math.trunc(f / r), "week") : p < a ? m.format(Math.trunc(f / i), "month") : m.format(Math.trunc(f / a), "year");
10
- }, f = (e, t = "es", n = { dateStyle: "medium" }) => {
10
+ }, f = (e) => new Date(e.getFullYear(), e.getMonth(), e.getDate()).getTime(), p = (e, t = /* @__PURE__ */ new Date(), r = "es") => {
11
+ if (!Number.isFinite(e.getTime())) return "";
12
+ let i = Math.round((f(t) - f(e)) / n);
13
+ if (i >= 0 && i <= 1) return s(r).format(-i, "day");
14
+ if (i >= 2 && i <= 6) return new Intl.DateTimeFormat(r, { weekday: "long" }).format(e);
15
+ let a = e.getFullYear() === t.getFullYear();
16
+ return new Intl.DateTimeFormat(r, a ? {
17
+ day: "numeric",
18
+ month: "long"
19
+ } : {
20
+ day: "numeric",
21
+ month: "long",
22
+ year: "numeric"
23
+ }).format(e);
24
+ }, m = (e, t = "es", n = { dateStyle: "medium" }) => {
11
25
  let r = c(e);
12
26
  return Number.isFinite(r) ? new Intl.DateTimeFormat(t, n).format(r) : "";
13
27
  };
14
28
  //#endregion
15
- export { f as formatDate, d as formatRelativeTime, u as isoDateTime };
29
+ export { m as formatDate, p as formatDayLabel, d as formatRelativeTime, u as isoDateTime };
@@ -42,7 +42,7 @@ export type { OnlineEventTarget as KapiOnlineEventTarget, OnlineStatus as KapiOn
42
42
  export { useObjectUrl } from "./useObjectUrl";
43
43
  export { downloadBlob, fileKind, fileNameFromContentDisposition, fileNameFromUrl, formatFileSize } from "./downloadLogic";
44
44
  export type { KapiFileKind } from "./downloadLogic";
45
- export { formatDate, formatRelativeTime, isoDateTime } from "./dateFormat";
45
+ export { formatDate, formatDayLabel, formatRelativeTime, isoDateTime } from "./dateFormat";
46
46
  export { useScrollEdges } from "./useScrollEdges";
47
47
  export type { UseScrollEdgesOptions, UseScrollEdgesResult } from "./useScrollEdges";
48
48
  export { DEFAULT_PAGE_FRACTION, DEFAULT_SCROLL_EDGE_TOLERANCE, maxScroll, pageSize, pageTarget, revealTarget, sameScrollEdges, scrollEdges } from "./scrollEdgesLogic";
@@ -0,0 +1,34 @@
1
+ import { type RefObject } from "react";
2
+ export type UseSubmitDraftOptions = {
3
+ /** Texto (controlado). */
4
+ value?: string | undefined;
5
+ /** Texto inicial (no controlado). */
6
+ defaultValue?: string | undefined;
7
+ /** Cambio del texto, ya como string. */
8
+ onChange?: ((text: string) => void) | undefined;
9
+ /** Envío con el texto recortado; si devuelve una promesa, el borrador se quita sólo al resolver. */
10
+ onSubmit: (text: string) => void | PromiseLike<unknown>;
11
+ /** Bloquea el envío. */
12
+ disabled?: boolean | undefined;
13
+ /** Enviando: bloquea el envío y cuenta como ocupado. */
14
+ loading?: boolean | undefined;
15
+ };
16
+ export type UseSubmitDraftResult = {
17
+ /** Texto actual (la prop `value` si está controlado, el estado interno si no). */
18
+ text: string;
19
+ /** Escribe el texto: actualiza el estado interno sólo si no está controlado, y avisa con `onChange`. */
20
+ setText: (next: string) => void;
21
+ /** Envía el texto recortado si se puede; no hace nada si no. */
22
+ submit: () => void;
23
+ /** `loading` de la prop o envío en curso. */
24
+ busy: boolean;
25
+ /** Hay texto y no está deshabilitado ni ocupado. */
26
+ canSubmit: boolean;
27
+ /** Ref al enfocable, para devolverle el foco después de enviar. */
28
+ boxRef: RefObject<HTMLTextAreaElement | null>;
29
+ };
30
+ /**
31
+ * Borrador + envío de un compositor (`KapiComposer`, `KapiCommentComposer`): estado controlado o no, envío
32
+ * síncrono o asíncrono y el foco de vuelta al campo. Interno: no forma parte de la API pública.
33
+ */
34
+ export declare const useSubmitDraft: ({ value, defaultValue, onChange, onSubmit, disabled, loading }: UseSubmitDraftOptions) => UseSubmitDraftResult;
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { canSubmitComment as e, draftAfterSubmit as t } from "../components/display/commentLogic.js";
3
+ import { useRef as n, useState as r } from "react";
4
+ //#region src/hooks/useSubmitDraft.ts
5
+ var i = (e) => typeof e?.then == "function", a = ({ value: a, defaultValue: o, onChange: s, onSubmit: c, disabled: l, loading: u = !1 }) => {
6
+ let [d, f] = r(o ?? ""), p = a ?? d, m = n(null), [h, g] = r(!1), _ = u || h, v = e(p, {
7
+ disabled: l,
8
+ loading: _
9
+ });
10
+ return {
11
+ text: p,
12
+ setText: (e) => {
13
+ a === void 0 && f(e), s?.(e);
14
+ },
15
+ submit: () => {
16
+ if (!v) return;
17
+ let e = p.trim(), n = c(e);
18
+ m.current?.focus(), i(n) ? (g(!0), Promise.resolve(n).then(() => {
19
+ a === void 0 && f((n) => t(n, e));
20
+ }, (e) => console.error(e)).finally(() => g(!1))) : a === void 0 && f("");
21
+ },
22
+ busy: _,
23
+ canSubmit: v,
24
+ boxRef: m
25
+ };
26
+ };
27
+ //#endregion
28
+ export { a as useSubmitDraft };
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from "./components/inputs";
3
3
  export * from "./components/overlays";
4
4
  export * from "./components/data";
5
5
  export * from "./components/display";
6
+ export * from "./components/chat";
6
7
  export * from "./components/feedback";
7
8
  export * from "./components/navigation";
8
9
  export * from "./components/layout";