@nivaro/react 0.3.107 → 0.3.108

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.
@@ -0,0 +1,213 @@
1
+ import { jsxs as o, jsx as e, Fragment as B } from "react/jsx-runtime";
2
+ import { MoreHorizontal as G, Rows3 as H, ExternalLink as K, StarOff as U, Star as q, PinOff as A, Pin as D, ArrowUp as J, ArrowDown as Q, FolderInput as V, ChevronRight as W, Copy as X, ArrowLeft as Y, Check as S } from "lucide-react";
3
+ import { useState as O } from "react";
4
+ import { toast as P } from "sonner";
5
+ import { useNavigation as Z } from "../../context.js";
6
+ import { cn as M } from "../../lib/utils.js";
7
+ import { Command as I, CommandList as R, CommandGroup as i, CommandItem as t, CommandSeparator as h, CommandInput as ee } from "../ui/command.js";
8
+ import { Popover as ae, PopoverTrigger as oe, PopoverContent as te } from "../ui/popover.js";
9
+ import { recordCollectionOpen as _ } from "./directory-data.js";
10
+ const n = "gap-2 text-[12px] [&_svg]:size-3.5 [&_svg]:text-slate-400 dark:[&_svg]:text-slate-500";
11
+ function he({
12
+ col: s,
13
+ displayName: $,
14
+ isAdmin: c,
15
+ recordsPath: u,
16
+ extra: d,
17
+ favorite: g,
18
+ onToggleFavorite: j,
19
+ pinnedForAll: f = !1,
20
+ onTogglePinned: v,
21
+ onMoveUp: k,
22
+ onMoveDown: y,
23
+ folders: N,
24
+ onMove: l,
25
+ className: L
26
+ }) {
27
+ const { navigate: b } = Z(), [T, z] = O(!1), [E, p] = O("main"), m = s.collection, x = (a) => {
28
+ z(a), a || p("main");
29
+ }, r = (a) => () => {
30
+ x(!1), a();
31
+ }, F = () => {
32
+ var C;
33
+ const a = () => P.success(`Copied ${m}`), w = () => P.error("Could not copy to the clipboard");
34
+ if (!((C = navigator.clipboard) != null && C.writeText)) return w();
35
+ navigator.clipboard.writeText(m).then(a, w);
36
+ };
37
+ return /* @__PURE__ */ o(ae, { open: T, onOpenChange: x, children: [
38
+ /* @__PURE__ */ e(oe, { asChild: !0, children: /* @__PURE__ */ e(
39
+ "button",
40
+ {
41
+ type: "button",
42
+ "aria-label": `More actions for ${$}`,
43
+ "data-tip": "More actions",
44
+ "data-cdr": "",
45
+ onClick: (a) => a.stopPropagation(),
46
+ className: M(
47
+ "flex h-6 w-6 shrink-0 items-center justify-center rounded text-slate-400 transition-opacity hover:bg-slate-100 hover:text-slate-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan/50 data-[state=open]:bg-slate-100 data-[state=open]:text-slate-700 motion-reduce:transition-none dark:text-slate-500 dark:hover:bg-white/10 dark:hover:text-slate-300 dark:data-[state=open]:bg-white/10 dark:data-[state=open]:text-slate-200",
48
+ L
49
+ ),
50
+ children: /* @__PURE__ */ e(G, { className: "h-3.5 w-3.5" })
51
+ }
52
+ ) }),
53
+ /* @__PURE__ */ e(
54
+ te,
55
+ {
56
+ align: "end",
57
+ sideOffset: 4,
58
+ collisionPadding: 8,
59
+ className: "w-56 p-0",
60
+ onClick: (a) => a.stopPropagation(),
61
+ children: E === "main" ? /* @__PURE__ */ e(I, { loop: !0, children: /* @__PURE__ */ o(R, { className: "max-h-[min(70vh,480px)]", children: [
62
+ /* @__PURE__ */ o(i, { children: [
63
+ /* @__PURE__ */ o(
64
+ t,
65
+ {
66
+ value: "open-records",
67
+ className: n,
68
+ onSelect: r(() => {
69
+ _(m), b(u);
70
+ }),
71
+ children: [
72
+ /* @__PURE__ */ e(H, {}),
73
+ "Open records"
74
+ ]
75
+ }
76
+ ),
77
+ /* @__PURE__ */ o(
78
+ t,
79
+ {
80
+ value: "open-new-tab",
81
+ className: n,
82
+ onSelect: r(() => {
83
+ _(m), window.open(u, "_blank", "noopener");
84
+ }),
85
+ children: [
86
+ /* @__PURE__ */ e(K, {}),
87
+ "Open in new tab"
88
+ ]
89
+ }
90
+ )
91
+ ] }),
92
+ d && d.items.length > 0 && /* @__PURE__ */ o(B, { children: [
93
+ /* @__PURE__ */ e(h, {}),
94
+ /* @__PURE__ */ e(i, { heading: d.heading, children: d.items.map((a) => /* @__PURE__ */ o(
95
+ t,
96
+ {
97
+ value: `extra-${a.key}`,
98
+ className: n,
99
+ onSelect: r(() => b(a.path)),
100
+ children: [
101
+ a.icon,
102
+ a.label
103
+ ]
104
+ },
105
+ a.key
106
+ )) })
107
+ ] }),
108
+ /* @__PURE__ */ e(h, {}),
109
+ /* @__PURE__ */ o(i, { children: [
110
+ /* @__PURE__ */ o(
111
+ t,
112
+ {
113
+ value: "toggle-favorite",
114
+ className: n,
115
+ onSelect: r(j),
116
+ children: [
117
+ g ? /* @__PURE__ */ e(U, {}) : /* @__PURE__ */ e(q, {}),
118
+ g ? "Remove from my favorites" : "Add to my favorites"
119
+ ]
120
+ }
121
+ ),
122
+ c && v && /* @__PURE__ */ o(
123
+ t,
124
+ {
125
+ value: "toggle-pinned",
126
+ className: n,
127
+ onSelect: r(v),
128
+ children: [
129
+ f ? /* @__PURE__ */ e(A, {}) : /* @__PURE__ */ e(D, {}),
130
+ f ? "Unpin for everyone" : "Pin for everyone"
131
+ ]
132
+ }
133
+ ),
134
+ c && k && /* @__PURE__ */ o(t, { value: "pin-move-up", className: n, onSelect: r(k), children: [
135
+ /* @__PURE__ */ e(J, {}),
136
+ "Move up"
137
+ ] }),
138
+ c && y && /* @__PURE__ */ o(t, { value: "pin-move-down", className: n, onSelect: r(y), children: [
139
+ /* @__PURE__ */ e(Q, {}),
140
+ "Move down"
141
+ ] }),
142
+ c && l && /* @__PURE__ */ o(
143
+ t,
144
+ {
145
+ value: "move-to-folder",
146
+ className: n,
147
+ onSelect: () => p("folders"),
148
+ children: [
149
+ /* @__PURE__ */ e(V, {}),
150
+ "Move to folder",
151
+ /* @__PURE__ */ e(W, { className: "ml-auto" })
152
+ ]
153
+ }
154
+ ),
155
+ /* @__PURE__ */ o(t, { value: "copy-key", className: n, onSelect: r(F), children: [
156
+ /* @__PURE__ */ e(X, {}),
157
+ "Copy key"
158
+ ] })
159
+ ] })
160
+ ] }) }) : /* @__PURE__ */ o(I, { loop: !0, children: [
161
+ N.length > 7 && /* @__PURE__ */ e(ee, { placeholder: "Find a folder…", className: "h-9 text-[12px]" }),
162
+ /* @__PURE__ */ o(R, { className: "max-h-[320px]", children: [
163
+ /* @__PURE__ */ e(i, { children: /* @__PURE__ */ o(t, { value: "back", className: n, onSelect: () => p("main"), children: [
164
+ /* @__PURE__ */ e(Y, {}),
165
+ "Back"
166
+ ] }) }),
167
+ /* @__PURE__ */ e(h, {}),
168
+ /* @__PURE__ */ o(i, { heading: "Move to folder", children: [
169
+ /* @__PURE__ */ o(
170
+ t,
171
+ {
172
+ value: "folder-none",
173
+ keywords: ["No folder"],
174
+ className: n,
175
+ onSelect: r(() => s.group != null && (l == null ? void 0 : l(null))),
176
+ children: [
177
+ /* @__PURE__ */ e("span", { className: "h-2 w-2 shrink-0 rounded-full border border-slate-300 dark:border-slate-600" }),
178
+ "No folder",
179
+ s.group == null && /* @__PURE__ */ e(S, { className: "ml-auto !text-nvr-cyan" })
180
+ ]
181
+ }
182
+ ),
183
+ N.map((a) => /* @__PURE__ */ o(
184
+ t,
185
+ {
186
+ value: `folder-${a.key}`,
187
+ keywords: [a.label],
188
+ className: n,
189
+ onSelect: r(() => s.group !== a.key && (l == null ? void 0 : l(a.key))),
190
+ children: [
191
+ /* @__PURE__ */ e(
192
+ "span",
193
+ {
194
+ className: "h-2 w-2 shrink-0 rounded-full bg-slate-300 dark:bg-slate-600",
195
+ style: a.color ? { backgroundColor: a.color } : void 0
196
+ }
197
+ ),
198
+ /* @__PURE__ */ e("span", { className: "truncate", children: a.label }),
199
+ s.group === a.key && /* @__PURE__ */ e(S, { className: "ml-auto !text-nvr-cyan" })
200
+ ]
201
+ },
202
+ a.key
203
+ ))
204
+ ] })
205
+ ] })
206
+ ] })
207
+ }
208
+ )
209
+ ] });
210
+ }
211
+ export {
212
+ he as CollectionRowMenu
213
+ };