@nivaro/react 0.3.17 → 0.3.19

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 (27) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +54 -1
  4. package/dist/index.js +243 -240
  5. package/dist/shared/components/CollectionBrowserView.js +439 -438
  6. package/dist/shared/components/ItemEditForm.js +3758 -3708
  7. package/dist/shared/components/ProfileView.js +38 -23
  8. package/dist/shared/components/RecordReadView.js +452 -430
  9. package/dist/shared/components/bulk/BulkActionButtons.js +113 -106
  10. package/dist/shared/components/chat/ChannelArchive.js +16 -17
  11. package/dist/shared/components/chat/ChatPanel.js +992 -930
  12. package/dist/shared/components/chat/Composer.js +307 -303
  13. package/dist/shared/components/chat/chat-core.js +8 -4
  14. package/dist/shared/components/chat/chat-drafts.js +60 -43
  15. package/dist/shared/components/help-videos/api.js +3 -0
  16. package/dist/shared/components/help-videos/library/HelpVideoLibrary.js +225 -177
  17. package/dist/shared/components/item-edit/InlineTableField.js +159 -158
  18. package/dist/shared/components/item-edit/RecordLiveSync.js +169 -155
  19. package/dist/shared/components/item-edit/RelationCombobox.js +274 -247
  20. package/dist/shared/components/item-edit/RowHistorySheet.js +62 -62
  21. package/dist/shared/components/item-edit/picker-search.js +28 -0
  22. package/dist/shared/components/panels/RevisionsPanel.js +268 -260
  23. package/dist/shared/components/profile/BrowserPushCard.js +135 -89
  24. package/dist/shared/components/profile/push-failure.js +76 -0
  25. package/dist/shared/lib/display-prefs.js +90 -0
  26. package/dist/shared/lib/theme-accents.js +21 -16
  27. package/package.json +1 -1
@@ -564,13 +564,17 @@ function ot(e, t = {}) {
564
564
  t.sender && (n.sender = t.sender), t.room && (n.room = t.room), t.from && (n.from = t.from), t.to && (n.to = t.to), t.has_attachment && (n.has_attachment = "1"), t.mentions_me && (n.mentions_me = "1");
565
565
  const o = Object.keys(n).length > 1, { data: r, isLoading: a } = y({
566
566
  queryKey: ["nvr-chat-search", n],
567
- queryFn: async () => (await s.request(
568
- g("/chat/search", n)
569
- )).data ?? [],
567
+ queryFn: async () => {
568
+ var c;
569
+ const i = await s.request(
570
+ g("/chat/search", n)
571
+ );
572
+ return { hits: i.data ?? [], meaning: ((c = i.meta) == null ? void 0 : c.meaning) ?? null };
573
+ },
570
574
  enabled: e.trim().length >= 2 || o,
571
575
  staleTime: 15e3
572
576
  });
573
- return { hits: r ?? [], loading: a };
577
+ return { hits: (r == null ? void 0 : r.hits) ?? [], meaning: (r == null ? void 0 : r.meaning) ?? null, loading: a };
574
578
  }
575
579
  function at() {
576
580
  const e = m(), t = v();
@@ -1,59 +1,76 @@
1
- import { useQueryClient as C, useQuery as I } from "@tanstack/react-query";
2
- import { useEffect as f, useRef as h } from "react";
3
- import { useNivaroClient as R } from "../../context.js";
4
- import { get as E, put as Q, del as S } from "../../lib/commands.js";
5
- import { useOptionalRealtime as D } from "../../lib/realtime.js";
6
- const U = 1500, l = Math.random().toString(36).slice(2, 12);
7
- function M(t = !0) {
8
- const r = R(), e = D(), a = C(), { data: s } = I({
1
+ import { useQueryClient as D, useQuery as U } from "@tanstack/react-query";
2
+ import { useEffect as d, useRef as f } from "react";
3
+ import { useNivaroClient as I } from "../../context.js";
4
+ import { get as Q, put as $, del as g } from "../../lib/commands.js";
5
+ import { useOptionalRealtime as S } from "../../lib/realtime.js";
6
+ const K = 1500, h = Math.random().toString(36).slice(2, 12);
7
+ function x(e = !0) {
8
+ const r = I(), n = S(), l = D(), { data: s } = U({
9
9
  queryKey: ["nvr-chat-drafts"],
10
- queryFn: () => r.request(E("/chat/drafts")).then((u) => (u.data ?? []).map((d) => d.room)),
11
- enabled: t,
10
+ queryFn: () => r.request(Q("/chat/drafts")).then((i) => (i.data ?? []).map((m) => m.room)),
11
+ enabled: e,
12
12
  staleTime: 6e4
13
13
  });
14
- return f(() => {
15
- if (!(!t || !e))
16
- return e.on(
14
+ return d(() => {
15
+ if (!(!e || !n))
16
+ return n.on(
17
17
  "chat:draft",
18
- () => void a.invalidateQueries({ queryKey: ["nvr-chat-drafts"] })
18
+ () => void l.invalidateQueries({ queryKey: ["nvr-chat-drafts"] })
19
19
  );
20
- }, [t, e, a]), new Set(s ?? []);
20
+ }, [e, n, l]), new Set(s ?? []);
21
21
  }
22
- function N(t, r, e, a) {
23
- const s = R(), u = D(), d = C(), c = h(""), p = h(e);
24
- p.current = e;
25
- const m = h(!1), q = async (n) => {
26
- var o;
22
+ function B(e, r, n, l) {
23
+ const s = I(), i = S(), m = D(), c = f(""), v = f(n);
24
+ v.current = n;
25
+ const y = f(!1), q = async (t) => {
26
+ var u;
27
27
  try {
28
- const i = ((o = (await s.request(
29
- E(`/chat/drafts/${encodeURIComponent(t)}`)
30
- )).data) == null ? void 0 : o.body) ?? "", y = p.current;
31
- (n ? y === "" : y === c.current) ? (c.current = i, i !== y && a(i)) : n && (c.current = i);
28
+ const a = ((u = (await s.request(
29
+ Q(`/chat/drafts/${encodeURIComponent(e)}`)
30
+ )).data) == null ? void 0 : u.body) ?? "", p = v.current;
31
+ (t ? p === "" : p === c.current) ? (c.current = a, a !== p && l(a)) : t && (c.current = a);
32
32
  } catch {
33
33
  } finally {
34
- m.current = !0;
34
+ y.current = !0;
35
35
  }
36
36
  };
37
- f(() => {
38
- r && (m.current = !1, c.current = "", q(!0));
39
- }, [t, r]), f(() => {
40
- if (!(!r || !u))
41
- return u.on("chat:draft", (n) => {
42
- !n || n.room !== t || n.device === l || q(!1);
37
+ d(() => {
38
+ r && (y.current = !1, c.current = "", q(!0));
39
+ }, [e, r]), d(() => {
40
+ if (!(!r || !i))
41
+ return i.on("chat:draft", (t) => {
42
+ !t || t.room !== e || t.device === h || q(!1);
43
43
  });
44
- }, [r, u, t]), f(() => {
45
- if (!r || !m.current || e === c.current) return;
46
- const n = setTimeout(() => {
47
- const o = e, v = () => {
48
- c.current = o, d.invalidateQueries({ queryKey: ["nvr-chat-drafts"] });
44
+ }, [r, i, e]);
45
+ const C = (t, u) => {
46
+ const E = () => {
47
+ t === R.current && (c.current = u), m.invalidateQueries({ queryKey: ["nvr-chat-drafts"] });
48
+ };
49
+ (u.trim() ? s.request($(`/chat/drafts/${encodeURIComponent(t)}`, { body: u, device: h })) : s.request(g(`/chat/drafts/${encodeURIComponent(t)}?device=${h}`))).then(E).catch(() => {
50
+ });
51
+ }, R = f(e);
52
+ R.current = e;
53
+ const o = f(null);
54
+ d(() => {
55
+ if (!r || !y.current) return;
56
+ if (n === c.current) {
57
+ o.current = null;
58
+ return;
59
+ }
60
+ o.current = { room: e, body: n };
61
+ const t = setTimeout(() => {
62
+ o.current = null, C(e, n);
63
+ }, K);
64
+ return () => clearTimeout(t);
65
+ }, [n, e, r]), d(() => {
66
+ if (r)
67
+ return () => {
68
+ const t = o.current;
69
+ o.current = null, t && t.room === e && C(t.room, t.body);
49
70
  };
50
- (o.trim() ? s.request(Q(`/chat/drafts/${encodeURIComponent(t)}`, { body: o, device: l })) : s.request(S(`/chat/drafts/${encodeURIComponent(t)}?device=${l}`))).then(v).catch(() => {
51
- });
52
- }, U);
53
- return () => clearTimeout(n);
54
- }, [e, t, r]);
71
+ }, [e, r]);
55
72
  }
56
73
  export {
57
- M as useDraftRooms,
58
- N as useDraftSync
74
+ x as useDraftRooms,
75
+ B as useDraftSync
59
76
  };
@@ -249,6 +249,9 @@ function $(s) {
249
249
  setContexts: (e, t) => a(c(`/help-videos/${e}/contexts`, { contexts: t })),
250
250
  setRequirements: (e, t) => a(c(`/help-videos/${e}/requirements`, { role_ids: t })),
251
251
  archive: (e) => a(p(`/help-videos/${e}`)),
252
+ /** Back to draft: viewers stop seeing it; the published version is kept, so `publish` puts the
253
+ * same cut back with no new render. 409 HELP_VIDEO_NOT_PUBLISHED unless it is published. */
254
+ unpublish: (e) => a(i(`/help-videos/${e}/unpublish`, {})).then((t) => t.data),
252
255
  /** Deletes the video, its versions, files, views and requirements for good. Administrators
253
256
  * only (403 ADMIN_ONLY otherwise); 404 when it is already gone. */
254
257
  purge: (e) => a(p(`/help-videos/${e}?purge=1`)),