@nivaro/react 0.3.33 → 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 (29) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +79 -5
  4. package/dist/index.js +338 -329
  5. package/dist/shared/components/ItemEditForm.js +5494 -5302
  6. package/dist/shared/components/ProfileView.js +46 -44
  7. package/dist/shared/components/ReportView.js +208 -205
  8. package/dist/shared/components/SearchHighlight.js +30 -0
  9. package/dist/shared/components/TipLayer.js +39 -37
  10. package/dist/shared/components/item-edit/CatalogPickerField.js +1484 -1232
  11. package/dist/shared/components/item-edit/FieldAffordances.js +370 -203
  12. package/dist/shared/components/item-edit/FieldRow.js +396 -354
  13. package/dist/shared/components/item-edit/PersonalDefaultPill.js +50 -0
  14. package/dist/shared/components/item-edit/RelationCombobox.js +42 -41
  15. package/dist/shared/components/item-edit/catalog-search.js +34 -0
  16. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +34 -34
  17. package/dist/shared/components/item-edit/personal-default-checks.js +134 -0
  18. package/dist/shared/components/item-edit/usePersonalDefaults.js +358 -0
  19. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +130 -111
  20. package/dist/shared/components/layout-editor/inspector/RulesTab.js +76 -75
  21. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  22. package/dist/shared/components/profile/MyDefaultsCard.js +667 -0
  23. package/dist/shared/components/profile/PersonProfile.js +42 -40
  24. package/dist/shared/components/profile/my-defaults-labels.js +76 -0
  25. package/dist/shared/components/profile/primitives.js +72 -67
  26. package/dist/shared/lib/personal-defaults.js +76 -0
  27. package/dist/shared/lib/request-gate.js +78 -76
  28. package/dist/shared/lib/search-text.js +111 -0
  29. package/package.json +1 -1
@@ -0,0 +1,30 @@
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { useMemo as c, Fragment as p } from "react";
3
+ import { highlightParts as s } from "../lib/search-text.js";
4
+ import { cn as d } from "../lib/utils.js";
5
+ function x({
6
+ text: e,
7
+ query: i,
8
+ synonyms: h,
9
+ className: m,
10
+ markClassName: o
11
+ }) {
12
+ const n = c(() => s(e, i, { synonyms: h }), [e, i, h]);
13
+ return n.some((r) => r.match) ? /* @__PURE__ */ t("span", { className: m, children: n.map(
14
+ (r, a) => r.match ? /* @__PURE__ */ t(
15
+ "mark",
16
+ {
17
+ "data-search-hit": !0,
18
+ className: d("rounded-sm bg-nvr-cyan/20 px-0 text-inherit", o),
19
+ children: r.text
20
+ },
21
+ a
22
+ ) : (
23
+ // biome-ignore lint/suspicious/noArrayIndexKey: parts are positional and never reorder
24
+ /* @__PURE__ */ t(p, { children: r.text }, a)
25
+ )
26
+ ) }) : /* @__PURE__ */ t("span", { className: m, children: e ?? "" });
27
+ }
28
+ export {
29
+ x as SearchHighlight
30
+ };
@@ -1,38 +1,40 @@
1
- import { jsx as x } from "react/jsx-runtime";
2
- import { useState as m, useRef as g, useEffect as v, useLayoutEffect as h } from "react";
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import { useState as m, useRef as v, useEffect as h, useLayoutEffect as x } from "react";
3
3
  import { createPortal as b } from "react-dom";
4
- let l = 0;
5
- function O() {
6
- const [e, i] = m(null), [t, d] = m(!1), s = g(null);
7
- return v(() => (l += 1, d(l === 1), () => {
8
- l -= 1;
9
- }), []), v(() => {
4
+ const u = [];
5
+ function R() {
6
+ const [e, o] = m(null), [t, s] = m(!1), d = v(null);
7
+ return h(() => (u.push(s), u[0] === s && s(!0), () => {
8
+ var n;
9
+ const r = u.indexOf(s);
10
+ r < 0 || (u.splice(r, 1), r === 0 && ((n = u[0]) == null || n.call(u, !0)));
11
+ }), []), h(() => {
10
12
  if (!t) return;
11
- const o = (u) => {
12
- var c, w;
13
- const n = (w = (c = u.target) == null ? void 0 : c.closest) == null ? void 0 : w.call(c, "[data-tip]"), a = n == null ? void 0 : n.getAttribute("data-tip");
14
- if (!n || !a || n.getAttribute("aria-expanded") === "true") {
15
- i((p) => p && null);
13
+ const r = (c) => {
14
+ var l, p;
15
+ const i = (p = (l = c.target) == null ? void 0 : l.closest) == null ? void 0 : p.call(l, "[data-tip]"), f = i == null ? void 0 : i.getAttribute("data-tip");
16
+ if (!i || !f || i.getAttribute("aria-expanded") === "true") {
17
+ o((w) => w && null);
16
18
  return;
17
19
  }
18
- const f = n.getBoundingClientRect();
19
- i({ x: f.left, y: f.bottom + 4, text: a });
20
- }, r = () => i(null);
21
- return window.addEventListener("mouseover", o), window.addEventListener("pointerdown", r, !0), window.addEventListener("scroll", r, !0), () => {
22
- window.removeEventListener("mouseover", o), window.removeEventListener("pointerdown", r, !0), window.removeEventListener("scroll", r, !0);
20
+ const a = i.getBoundingClientRect();
21
+ o({ x: a.left, y: a.bottom + 4, text: f });
22
+ }, n = () => o(null);
23
+ return window.addEventListener("mouseover", r), window.addEventListener("pointerdown", n, !0), window.addEventListener("scroll", n, !0), () => {
24
+ window.removeEventListener("mouseover", r), window.removeEventListener("pointerdown", n, !0), window.removeEventListener("scroll", n, !0);
23
25
  };
24
- }, [t]), h(() => {
26
+ }, [t]), x(() => {
25
27
  if (!e) return;
26
- const o = s.current;
27
- if (!o) return;
28
- const r = o.getBoundingClientRect();
29
- let { x: u, y: n } = e;
30
- r.right > window.innerWidth - 8 && (u = Math.max(8, window.innerWidth - r.width - 8)), r.bottom > window.innerHeight - 8 && (n = Math.max(8, e.y - r.height - 30)), (u !== e.x || n !== e.y) && i({ ...e, x: u, y: n });
28
+ const r = d.current;
29
+ if (!r) return;
30
+ const n = r.getBoundingClientRect();
31
+ let { x: c, y: i } = e;
32
+ n.right > window.innerWidth - 8 && (c = Math.max(8, window.innerWidth - n.width - 8)), n.bottom > window.innerHeight - 8 && (i = Math.max(8, e.y - n.height - 30)), (c !== e.x || i !== e.y) && o({ ...e, x: c, y: i });
31
33
  }, [e]), !t || !e ? null : b(
32
- /* @__PURE__ */ x(
34
+ /* @__PURE__ */ g(
33
35
  "div",
34
36
  {
35
- ref: s,
37
+ ref: d,
36
38
  style: { position: "fixed", left: e.x, top: e.y, zIndex: 120 },
37
39
  className: "pointer-events-none max-w-[340px] whitespace-pre-wrap break-words rounded-md bg-[#0f172a] px-2 py-1 text-[11px] font-medium leading-snug text-white shadow-lg dark:bg-[#334155]",
38
40
  children: e.text
@@ -41,20 +43,20 @@ function O() {
41
43
  document.body
42
44
  );
43
45
  }
44
- function R(e) {
45
- const i = g(null);
46
- return h(() => {
47
- const t = i.current;
46
+ function O(e) {
47
+ const o = v(null);
48
+ return x(() => {
49
+ const t = o.current;
48
50
  if (!t) return;
49
- const d = () => {
51
+ const s = () => {
50
52
  (t.scrollWidth > t.clientWidth + 1 || t.scrollHeight > t.clientHeight + 1) && e ? t.setAttribute("data-tip", e) : t.removeAttribute("data-tip");
51
53
  };
52
- if (d(), typeof ResizeObserver > "u") return;
53
- const s = new ResizeObserver(d);
54
- return s.observe(t), () => s.disconnect();
55
- }, [e]), i;
54
+ if (s(), typeof ResizeObserver > "u") return;
55
+ const d = new ResizeObserver(s);
56
+ return d.observe(t), () => d.disconnect();
57
+ }, [e]), o;
56
58
  }
57
59
  export {
58
- O as TipLayer,
59
- R as useOverflowTip
60
+ R as TipLayer,
61
+ O as useOverflowTip
60
62
  };