@nivaro/react 0.3.32 → 0.3.34

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 (31) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +89 -8
  4. package/dist/index.js +338 -328
  5. package/dist/shared/components/ForceReloadBanner.js +56 -46
  6. package/dist/shared/components/ItemEditForm.js +5637 -5442
  7. package/dist/shared/components/ProfileView.js +46 -44
  8. package/dist/shared/components/ReportView.js +208 -205
  9. package/dist/shared/components/SearchHighlight.js +30 -0
  10. package/dist/shared/components/TipLayer.js +39 -37
  11. package/dist/shared/components/item-edit/CatalogPickerField.js +1484 -1232
  12. package/dist/shared/components/item-edit/FieldAffordances.js +370 -203
  13. package/dist/shared/components/item-edit/FieldRow.js +396 -354
  14. package/dist/shared/components/item-edit/PersonalDefaultPill.js +50 -0
  15. package/dist/shared/components/item-edit/RelationCombobox.js +42 -41
  16. package/dist/shared/components/item-edit/catalog-search.js +34 -0
  17. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +34 -34
  18. package/dist/shared/components/item-edit/personal-default-checks.js +134 -0
  19. package/dist/shared/components/item-edit/usePersonalDefaults.js +358 -0
  20. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +130 -111
  21. package/dist/shared/components/layout-editor/inspector/RulesTab.js +76 -75
  22. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  23. package/dist/shared/components/profile/MyDefaultsCard.js +667 -0
  24. package/dist/shared/components/profile/PersonProfile.js +42 -40
  25. package/dist/shared/components/profile/my-defaults-labels.js +76 -0
  26. package/dist/shared/components/profile/primitives.js +72 -67
  27. package/dist/shared/lib/personal-defaults.js +76 -0
  28. package/dist/shared/lib/request-gate.js +78 -76
  29. package/dist/shared/lib/search-text.js +111 -0
  30. package/dist/shared/lib/unsaved-work.js +86 -38
  31. package/package.json +1 -1
@@ -1,41 +1,51 @@
1
- import { jsxs as c, jsx as s, Fragment as x } from "react/jsx-runtime";
2
- import { PauseCircle as N, RotateCw as F } from "lucide-react";
3
- import { useState as h, useRef as w, useEffect as k } from "react";
4
- import { markReloadFor as E } from "../lib/client-version.js";
5
- import { shouldObeyForceReload as j, thisTabForReload as T } from "../lib/force-reload.js";
6
- import { subscribeUnsavedWork as C, unsavedWorkLabels as D } from "../lib/unsaved-work.js";
7
- const L = "nvr:force-refresh";
8
- function W() {
9
- const [e, R] = h(null), [y, b] = h(() => Date.now()), [g, l] = h([]), o = w(!1), m = w(!1), p = w(/* @__PURE__ */ new Set());
10
- k(() => {
11
- const i = (r) => {
12
- const t = r.detail ?? {}, n = typeof t.id == "string" && t.id ? t.id : null;
13
- if (n && p.current.has(n) || !j(t, T())) return;
14
- n && p.current.add(n), m.current = !1, l([]);
15
- const d = Math.max(5, Number(t.seconds) || 30), a = Date.now();
16
- R({ deadline: a + d * 1e3, message: String(t.message ?? ""), id: n }), b(a);
1
+ import { jsxs as c, jsx as d, Fragment as k } from "react/jsx-runtime";
2
+ import { PauseCircle as T, RotateCw as C } from "lucide-react";
3
+ import { useState as p, useRef as b, useEffect as E } from "react";
4
+ import { markReloadFor as R } from "../lib/client-version.js";
5
+ import { shouldObeyForceReload as D, thisTabForReload as M } from "../lib/force-reload.js";
6
+ import { subscribeUnsavedWork as O, prepareForReload as y, beginReloadForUpdate as L, unsavedWorkLabels as S } from "../lib/unsaved-work.js";
7
+ const F = "nvr:force-refresh";
8
+ function B() {
9
+ const [r, N] = p(null), [j, g] = p(() => Date.now()), [w, l] = p([]), n = b(!1), m = b(!1), v = b(/* @__PURE__ */ new Set());
10
+ E(() => {
11
+ const o = (s) => {
12
+ const e = s.detail ?? {}, t = typeof e.id == "string" && e.id ? e.id : null;
13
+ if (t && v.current.has(t) || !D(e, M())) return;
14
+ t && v.current.add(t), m.current = !1, l([]);
15
+ const h = Math.max(5, Number(e.seconds) || 30), i = Date.now();
16
+ N({ deadline: i + h * 1e3, message: String(e.message ?? ""), id: t }), g(i);
17
17
  };
18
- return window.addEventListener(L, i), () => window.removeEventListener(L, i);
19
- }, []), k(() => {
20
- if (!e) return;
21
- const i = () => {
22
- o.current || (o.current = !0, e.id && E(e.id), window.location.reload(), setTimeout(() => {
23
- o.current = !1, m.current = !0, l(["unsaved changes on this page"]);
18
+ return window.addEventListener(F, o), () => window.removeEventListener(F, o);
19
+ }, []), E(() => {
20
+ if (!r) return;
21
+ const o = () => {
22
+ n.current || (n.current = !0, r.id && R(r.id), window.location.reload(), setTimeout(() => {
23
+ n.current = !1, m.current = !0, l(["unsaved changes on this page"]);
24
24
  }, 1500));
25
- }, r = () => {
26
- const d = Date.now();
27
- if (b(d), d < e.deadline || o.current || m.current) return;
28
- const a = D();
29
- l((v) => v.join("|") === a.join("|") ? v : a), a.length === 0 && i();
30
- }, t = setInterval(r, 1e3);
31
- document.addEventListener("visibilitychange", r), window.addEventListener("focus", r), window.addEventListener("pageshow", r);
32
- const n = C(() => setTimeout(r, 0));
25
+ };
26
+ let s = !1;
27
+ const e = () => {
28
+ const i = Date.now();
29
+ if (g(i), !(i < r.deadline || n.current || m.current || s)) {
30
+ if (S().length === 0) {
31
+ l((a) => a.length ? [] : a), o();
32
+ return;
33
+ }
34
+ s = !0, y().then((a) => {
35
+ l((x) => x.join("|") === a.join("|") ? x : a), a.length === 0 && (L(), o());
36
+ }).finally(() => {
37
+ s = !1;
38
+ });
39
+ }
40
+ }, t = setInterval(e, 1e3);
41
+ document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), window.addEventListener("pageshow", e);
42
+ const h = O(() => setTimeout(e, 0));
33
43
  return () => {
34
- clearInterval(t), document.removeEventListener("visibilitychange", r), window.removeEventListener("focus", r), window.removeEventListener("pageshow", r), n();
44
+ clearInterval(t), document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e), window.removeEventListener("pageshow", e), h();
35
45
  };
36
- }, [e]);
37
- const u = e ? Math.max(0, Math.ceil((e.deadline - y) / 1e3)) : 0, f = u === 0 && g.length > 0;
38
- return e ? /* @__PURE__ */ c(
46
+ }, [r]);
47
+ const u = r ? Math.max(0, Math.ceil((r.deadline - j) / 1e3)) : 0, f = u === 0 && w.length > 0;
48
+ return r ? /* @__PURE__ */ c(
39
49
  "div",
40
50
  {
41
51
  role: "alert",
@@ -44,27 +54,27 @@ function W() {
44
54
  "data-nvr-recording-hide": !0,
45
55
  className: "fixed inset-x-0 top-0 z-[150] flex items-center justify-center gap-3 border-b border-amber-300 bg-amber-50 px-4 py-2.5 text-[13px] text-amber-900 dark:border-amber-500/40 dark:bg-[#3a2e10] dark:text-amber-200",
46
56
  children: [
47
- f ? /* @__PURE__ */ s(N, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ s(F, { className: "h-4 w-4 shrink-0 animate-spin" }),
48
- /* @__PURE__ */ s("span", { children: f ? /* @__PURE__ */ c(x, { children: [
49
- /* @__PURE__ */ s("span", { className: "font-semibold", children: "A reload is waiting" }),
57
+ f ? /* @__PURE__ */ d(T, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ d(C, { className: "h-4 w-4 shrink-0 animate-spin" }),
58
+ /* @__PURE__ */ d("span", { children: f ? /* @__PURE__ */ c(k, { children: [
59
+ /* @__PURE__ */ d("span", { className: "font-semibold", children: "A reload is waiting" }),
50
60
  " — save or discard your changes (",
51
- g.join(", ").toLowerCase(),
61
+ w.join(", ").toLowerCase(),
52
62
  ") and the page reloads."
53
- ] }) : /* @__PURE__ */ c(x, { children: [
63
+ ] }) : /* @__PURE__ */ c(k, { children: [
54
64
  /* @__PURE__ */ c("span", { className: "font-semibold", children: [
55
65
  "This page will reload in ",
56
66
  u,
57
67
  "s"
58
68
  ] }),
59
- e.message ? ` — ${e.message}` : " — an administrator pushed an update."
69
+ r.message ? ` — ${r.message}` : " — an administrator pushed an update."
60
70
  ] }) }),
61
- /* @__PURE__ */ s(
71
+ /* @__PURE__ */ d(
62
72
  "button",
63
73
  {
64
74
  type: "button",
65
- onClick: () => {
66
- o.current = !0, e.id && E(e.id), window.location.reload(), setTimeout(() => {
67
- o.current = !1;
75
+ onClick: async () => {
76
+ n.current = !0, r.id && R(r.id), (await y()).length === 0 && L(), window.location.reload(), setTimeout(() => {
77
+ n.current = !1;
68
78
  }, 1500);
69
79
  },
70
80
  className: "shrink-0 rounded-md border border-amber-400 bg-white px-2.5 py-1 text-[12px] font-medium text-amber-800 hover:bg-amber-100 dark:bg-transparent dark:text-amber-200",
@@ -76,6 +86,6 @@ function W() {
76
86
  ) : null;
77
87
  }
78
88
  export {
79
- L as FORCE_RELOAD_EVENT,
80
- W as ForceReloadBanner
89
+ F as FORCE_RELOAD_EVENT,
90
+ B as ForceReloadBanner
81
91
  };