@nivaro/react 0.3.104 → 0.3.106

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.
@@ -1,21 +1,21 @@
1
- import { jsxs as a, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as a, jsx as r } from "react/jsx-runtime";
2
2
  import { useQuery as b } from "@tanstack/react-query";
3
3
  import { Network as f, ChevronDown as h } from "lucide-react";
4
- import { useState as y } from "react";
5
- import { useNivaroClient as v, useItemNavigation as N, useDrilldown as g } from "../../context.js";
6
- import { get as k } from "../../lib/commands.js";
4
+ import { useNivaroClient as y, useItemNavigation as v, useDrilldown as N } from "../../context.js";
5
+ import { get as g } from "../../lib/commands.js";
6
+ import { useStartsOpen as k } from "../../lib/use-starts-open.js";
7
7
  function j({
8
8
  collection: o,
9
- itemId: r,
9
+ itemId: n,
10
10
  title: c,
11
11
  defaultExpanded: i = !0
12
12
  }) {
13
- const m = v(), { open: p } = N(), s = g(), [d, u] = y(i), { data: l = [] } = b({
14
- queryKey: ["referenced-by", o, r],
13
+ const m = y(), { open: p } = v(), s = N(), [d, u] = k(i, !0), { data: l = [] } = b({
14
+ queryKey: ["referenced-by", o, n],
15
15
  queryFn: () => m.request(
16
- k(`/referenced-by/${o}/${encodeURIComponent(r)}`)
16
+ g(`/referenced-by/${o}/${encodeURIComponent(n)}`)
17
17
  ).then((e) => e.data ?? []).catch(() => []),
18
- enabled: !!r,
18
+ enabled: !!n,
19
19
  staleTime: 6e4
20
20
  });
21
21
  if (l.length === 0) return null;
@@ -33,10 +33,10 @@ function j({
33
33
  onClick: () => u((e) => !e),
34
34
  className: "flex w-full items-center gap-2.5 px-5 py-3.5 text-left transition-colors hover:bg-slate-50/50 dark:hover:bg-white/[0.02]",
35
35
  children: [
36
- /* @__PURE__ */ n(f, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
37
- /* @__PURE__ */ n("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: c ?? "Referenced by" }),
38
- /* @__PURE__ */ n("span", { className: "rounded-full bg-slate-100 px-1.5 py-px text-[10.5px] font-semibold tabular-nums text-slate-500 dark:bg-muted dark:text-slate-400", children: x }),
39
- /* @__PURE__ */ n(
36
+ /* @__PURE__ */ r(f, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
37
+ /* @__PURE__ */ r("span", { className: "text-[13px] font-medium text-slate-800 dark:text-slate-200", children: c ?? "Referenced by" }),
38
+ /* @__PURE__ */ r("span", { className: "rounded-full bg-slate-100 px-1.5 py-px text-[10.5px] font-semibold tabular-nums text-slate-500 dark:bg-muted dark:text-slate-400", children: x }),
39
+ /* @__PURE__ */ r(
40
40
  h,
41
41
  {
42
42
  className: `ml-auto h-3.5 w-3.5 shrink-0 text-slate-400 transition-transform duration-150${d ? " rotate-180" : ""}`
@@ -45,13 +45,13 @@ function j({
45
45
  ]
46
46
  }
47
47
  ),
48
- d && /* @__PURE__ */ n("div", { className: "border-t border-slate-100 px-5 py-4 dark:border-border/60", children: l.map((e) => /* @__PURE__ */ a(
48
+ d && /* @__PURE__ */ r("div", { className: "border-t border-slate-100 px-5 py-4 dark:border-border/60", children: l.map((e) => /* @__PURE__ */ a(
49
49
  "div",
50
50
  {
51
51
  className: "border-b border-slate-100 py-1.5 last:border-0 dark:border-border/60",
52
52
  children: [
53
53
  /* @__PURE__ */ a("p", { className: "text-[12px] text-slate-700 dark:text-slate-300", children: [
54
- /* @__PURE__ */ n("span", { className: "font-semibold tabular-nums", children: e.count }),
54
+ /* @__PURE__ */ r("span", { className: "font-semibold tabular-nums", children: e.count }),
55
55
  " ",
56
56
  e.display_name ?? e.collection,
57
57
  /* @__PURE__ */ a("span", { className: "text-slate-400", children: [
@@ -60,7 +60,7 @@ function j({
60
60
  ] })
61
61
  ] }),
62
62
  e.samples.length > 0 && /* @__PURE__ */ a("div", { className: "mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5", children: [
63
- e.samples.map((t) => /* @__PURE__ */ n(
63
+ e.samples.map((t) => /* @__PURE__ */ r(
64
64
  "button",
65
65
  {
66
66
  type: "button",
@@ -3,29 +3,30 @@ import { useQueryClient as R, useQuery as y, useMutation as v } from "@tanstack/
3
3
  import { Link2 as F, ChevronDown as N, X as K, Plus as E } from "lucide-react";
4
4
  import { useState as l } from "react";
5
5
  import { toast as C } from "sonner";
6
- import { useNivaroClient as Q, useItemNavigation as j } from "../../context.js";
7
- import { get as w, post as O, del as U } from "../../lib/commands.js";
8
- import { RelationCombobox as A } from "../item-edit/RelationCombobox.js";
9
- import { Command as D, CommandInput as M, CommandList as W, CommandEmpty as X, CommandItem as Y } from "../ui/command.js";
10
- import { Popover as z, PopoverTrigger as B, PopoverContent as G } from "../ui/popover.js";
11
- import { SimpleSelect as H } from "../ui/SimpleSelect.js";
12
- const J = ["relates to", "supersedes", "duplicates", "blocks", "caused by"];
13
- function ce({
6
+ import { useNivaroClient as O, useItemNavigation as Q } from "../../context.js";
7
+ import { get as w, post as j, del as U } from "../../lib/commands.js";
8
+ import { useStartsOpen as A } from "../../lib/use-starts-open.js";
9
+ import { RelationCombobox as D } from "../item-edit/RelationCombobox.js";
10
+ import { Command as M, CommandInput as W, CommandList as X, CommandEmpty as Y, CommandItem as z } from "../ui/command.js";
11
+ import { Popover as B, PopoverTrigger as G, PopoverContent as H } from "../ui/popover.js";
12
+ import { SimpleSelect as J } from "../ui/SimpleSelect.js";
13
+ const V = ["relates to", "supersedes", "duplicates", "blocks", "caused by"];
14
+ function me({
14
15
  collection: a,
15
- itemId: i,
16
+ itemId: s,
16
17
  title: _,
17
18
  defaultExpanded: q = !1
18
19
  }) {
19
- const s = Q(), b = R(), { open: P } = j(), [x, L] = l(q), [d, m] = l(!1), [r, S] = l(a), [T, k] = l(!1), [p, u] = l(null), [f, $] = l("relates to"), { data: c = [] } = y({
20
- queryKey: ["record-links", a, i],
21
- queryFn: () => s.request(
22
- w(`/record-links/${a}/${encodeURIComponent(i)}`)
20
+ const i = O(), b = R(), { open: P } = Q(), [x, S] = A(q, !1), [d, m] = l(!1), [r, L] = l(a), [T, k] = l(!1), [p, u] = l(null), [f, $] = l("relates to"), { data: c = [] } = y({
21
+ queryKey: ["record-links", a, s],
22
+ queryFn: () => i.request(
23
+ w(`/record-links/${a}/${encodeURIComponent(s)}`)
23
24
  ).then((e) => e.data ?? []),
24
- enabled: !!i,
25
+ enabled: !!s,
25
26
  staleTime: 3e4
26
27
  }), { data: g = [] } = y({
27
28
  queryKey: ["record-links-collections"],
28
- queryFn: () => s.request(w("/collections")).then(
29
+ queryFn: () => i.request(w("/collections")).then(
29
30
  (e) => (e.data ?? []).filter(
30
31
  (o) => !o.hidden && !o.collection.toLowerCase().startsWith("nivaro_")
31
32
  )
@@ -33,10 +34,10 @@ function ce({
33
34
  enabled: d,
34
35
  staleTime: 5 * 6e4
35
36
  }), h = v({
36
- mutationFn: () => s.request(
37
- O("/record-links", {
37
+ mutationFn: () => i.request(
38
+ j("/record-links", {
38
39
  from_collection: a,
39
- from_item: String(i),
40
+ from_item: String(s),
40
41
  to_collection: r,
41
42
  to_item: String(p),
42
43
  link_type: f
@@ -50,7 +51,7 @@ function ce({
50
51
  return C.error(((o = e.response) == null ? void 0 : o.error) ?? "Could not link");
51
52
  }
52
53
  }), I = v({
53
- mutationFn: (e) => s.request(U(`/record-links/${e}`)),
54
+ mutationFn: (e) => i.request(U(`/record-links/${e}`)),
54
55
  onSuccess: () => void b.invalidateQueries({ queryKey: ["record-links"] })
55
56
  });
56
57
  return /* @__PURE__ */ n(
@@ -63,7 +64,7 @@ function ce({
63
64
  "button",
64
65
  {
65
66
  type: "button",
66
- onClick: () => L((e) => !e),
67
+ onClick: () => S((e) => !e),
67
68
  className: "flex w-full items-center gap-2.5 px-5 py-3.5 text-left transition-colors hover:bg-slate-50/50 dark:hover:bg-white/[0.02]",
68
69
  children: [
69
70
  /* @__PURE__ */ t(F, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
@@ -111,16 +112,16 @@ function ce({
111
112
  )) }),
112
113
  d ? /* @__PURE__ */ n("div", { className: "mt-2 space-y-1.5 rounded-md border border-slate-200 p-2 dark:border-border", children: [
113
114
  /* @__PURE__ */ t(
114
- H,
115
+ J,
115
116
  {
116
117
  value: f,
117
118
  onChange: $,
118
119
  ariaLabel: "Link type",
119
- options: J.map((e) => ({ value: e, label: e }))
120
+ options: V.map((e) => ({ value: e, label: e }))
120
121
  }
121
122
  ),
122
- /* @__PURE__ */ n(z, { open: T, onOpenChange: k, children: [
123
- /* @__PURE__ */ t(B, { asChild: !0, children: /* @__PURE__ */ n(
123
+ /* @__PURE__ */ n(B, { open: T, onOpenChange: k, children: [
124
+ /* @__PURE__ */ t(G, { asChild: !0, children: /* @__PURE__ */ n(
124
125
  "button",
125
126
  {
126
127
  type: "button",
@@ -135,20 +136,20 @@ function ce({
135
136
  ]
136
137
  }
137
138
  ) }),
138
- /* @__PURE__ */ t(G, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ n(D, { children: [
139
- /* @__PURE__ */ t(M, { placeholder: "Search collections…", className: "h-8 text-[12px]" }),
140
- /* @__PURE__ */ n(W, { children: [
141
- /* @__PURE__ */ t(X, { children: "No collection found." }),
139
+ /* @__PURE__ */ t(H, { className: "w-[240px] p-0", align: "start", children: /* @__PURE__ */ n(M, { children: [
140
+ /* @__PURE__ */ t(W, { placeholder: "Search collections…", className: "h-8 text-[12px]" }),
141
+ /* @__PURE__ */ n(X, { children: [
142
+ /* @__PURE__ */ t(Y, { children: "No collection found." }),
142
143
  [...g].sort(
143
144
  (e, o) => (e.display_name || e.collection).localeCompare(
144
145
  o.display_name || o.collection
145
146
  )
146
147
  ).map((e) => /* @__PURE__ */ t(
147
- Y,
148
+ z,
148
149
  {
149
150
  value: e.display_name || e.collection,
150
151
  onSelect: () => {
151
- S(e.collection), u(null), k(!1);
152
+ L(e.collection), u(null), k(!1);
152
153
  },
153
154
  children: e.display_name || e.collection.replace(/_/g, " ")
154
155
  },
@@ -158,7 +159,7 @@ function ce({
158
159
  ] }) })
159
160
  ] }),
160
161
  r && /* @__PURE__ */ t(
161
- A,
162
+ D,
162
163
  {
163
164
  collection: r,
164
165
  value: p,
@@ -205,5 +206,5 @@ function ce({
205
206
  );
206
207
  }
207
208
  export {
208
- ce as RelatedRecordsPanel
209
+ me as RelatedRecordsPanel
209
210
  };