@nivaro/react 0.3.107 → 0.3.109
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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +149 -0
- package/dist/index.js +742 -738
- package/dist/layout-editor.d.ts +4 -0
- package/dist/shared/components/CollectionBrowserView.js +410 -416
- package/dist/shared/components/ItemEditForm.js +2413 -2384
- package/dist/shared/components/collections-directory/CollectionHoverCard.js +177 -0
- package/dist/shared/components/collections-directory/CollectionRow.js +359 -0
- package/dist/shared/components/collections-directory/CollectionRowMenu.js +213 -0
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +543 -0
- package/dist/shared/components/collections-directory/CollectionsToolbar.js +287 -0
- package/dist/shared/components/collections-directory/PinnedSection.js +97 -0
- package/dist/shared/components/collections-directory/directory-data.js +159 -0
- package/dist/shared/components/collections-directory/page-model.js +122 -0
- package/dist/shared/components/collections-directory/sections.js +108 -0
- package/dist/shared/components/collections-directory/shared-pins.js +70 -0
- package/dist/shared/components/imports/CollectionImportPanel.js +631 -595
- package/dist/shared/components/imports/import-picker-options.js +44 -0
- package/dist/shared/components/item-edit/InlineTableField.js +441 -438
- package/dist/shared/components/item-edit/NestedRelationEditor.js +36 -36
- package/dist/shared/components/item-edit/RelationCombobox.js +1 -1
- package/dist/shared/components/item-edit/StepsBar.js +24 -23
- package/dist/shared/components/item-edit/form-density.js +1 -0
- package/dist/shared/components/item-edit/section-rows.js +39 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +88 -66
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/lib/activity-sentence.js +4 -4
- package/dist/shared/lib/layout-ops.js +24 -22
- package/dist/shared/lib/template-paths.js +17 -0
- package/package.json +1 -1
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import { useSortable as x } from "@dnd-kit/sortable";
|
|
3
|
+
import { CSS as p } from "@dnd-kit/utilities";
|
|
4
|
+
import { GripVertical as b, FolderOpen as f, ChevronRight as u, ChevronDown as g } from "lucide-react";
|
|
5
|
+
import { cn as h } from "../../lib/utils.js";
|
|
6
|
+
function S({
|
|
7
|
+
id: r,
|
|
8
|
+
label: t,
|
|
9
|
+
children: a
|
|
10
|
+
}) {
|
|
11
|
+
const { attributes: o, listeners: c, setNodeRef: l, transform: d, transition: n, isDragging: i } = x({
|
|
12
|
+
id: r
|
|
13
|
+
}), m = /* @__PURE__ */ e(
|
|
14
|
+
"button",
|
|
15
|
+
{
|
|
16
|
+
type: "button",
|
|
17
|
+
...o,
|
|
18
|
+
...c,
|
|
19
|
+
"aria-label": t ? `Drag to reorder ${t}` : "Drag to reorder",
|
|
20
|
+
"data-tip": "Drag to reorder (or focus and press Space, then the arrow keys)",
|
|
21
|
+
className: "flex w-7 shrink-0 cursor-grab touch-none items-center justify-center self-stretch rounded text-slate-400 hover:text-slate-600 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-nvr-cyan/50 dark:text-slate-500 dark:hover:text-slate-300",
|
|
22
|
+
children: /* @__PURE__ */ e(b, { className: "h-3.5 w-3.5" })
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
return /* @__PURE__ */ e(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
ref: l,
|
|
29
|
+
style: { transform: p.Transform.toString(d), transition: n },
|
|
30
|
+
className: h("relative", i && "z-10 opacity-50"),
|
|
31
|
+
children: a(m)
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
function D({
|
|
36
|
+
folder: r,
|
|
37
|
+
count: t,
|
|
38
|
+
hiddenCount: a,
|
|
39
|
+
collapsed: o,
|
|
40
|
+
onToggle: c,
|
|
41
|
+
dragHandle: l,
|
|
42
|
+
icon: d,
|
|
43
|
+
hint: n
|
|
44
|
+
}) {
|
|
45
|
+
const i = r.color ?? "#94a3b8";
|
|
46
|
+
return /* @__PURE__ */ s(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: "sticky z-[5] flex items-stretch border-b border-slate-200 bg-slate-50 dark:border-white/[0.08] dark:bg-[#141f2a]",
|
|
50
|
+
style: { top: "var(--cl-toolbar-h, 0px)" },
|
|
51
|
+
children: [
|
|
52
|
+
l,
|
|
53
|
+
/* @__PURE__ */ s(
|
|
54
|
+
"button",
|
|
55
|
+
{
|
|
56
|
+
type: "button",
|
|
57
|
+
onClick: c,
|
|
58
|
+
"aria-expanded": !o,
|
|
59
|
+
className: h(
|
|
60
|
+
"flex flex-1 items-center gap-2.5 py-1.5 pr-4 text-left transition-colors hover:bg-slate-100 dark:hover:bg-white/[0.04]",
|
|
61
|
+
!l && "pl-4"
|
|
62
|
+
),
|
|
63
|
+
children: [
|
|
64
|
+
/* @__PURE__ */ e(
|
|
65
|
+
"span",
|
|
66
|
+
{
|
|
67
|
+
className: "flex h-5 w-5 shrink-0 items-center justify-center rounded",
|
|
68
|
+
style: { backgroundColor: `${i}22` },
|
|
69
|
+
children: d ?? /* @__PURE__ */ e(f, { className: "h-3 w-3", style: { color: i } })
|
|
70
|
+
}
|
|
71
|
+
),
|
|
72
|
+
/* @__PURE__ */ s("span", { className: "flex min-w-0 flex-1 items-baseline gap-2", children: [
|
|
73
|
+
/* @__PURE__ */ e("span", { className: "truncate text-[12px] font-semibold text-slate-700 dark:text-slate-200", children: r.label }),
|
|
74
|
+
n && /* @__PURE__ */ e("span", { className: "truncate text-[11.5px] text-slate-500 dark:text-slate-400", children: n })
|
|
75
|
+
] }),
|
|
76
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] tabular-nums text-slate-500 dark:text-slate-400", children: [
|
|
77
|
+
t,
|
|
78
|
+
t != null && a > 0 && /* @__PURE__ */ s("span", { "data-tip": "Hidden collections in this folder — turn on Show hidden collections to list them", children: [
|
|
79
|
+
" ",
|
|
80
|
+
"· ",
|
|
81
|
+
a,
|
|
82
|
+
" hidden"
|
|
83
|
+
] })
|
|
84
|
+
] }),
|
|
85
|
+
o ? /* @__PURE__ */ e(u, { className: "h-3.5 w-3.5 text-slate-400 dark:text-slate-500" }) : /* @__PURE__ */ e(g, { className: "h-3.5 w-3.5 text-slate-400 dark:text-slate-500" })
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
)
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
function j({ id: r, children: t }) {
|
|
94
|
+
return /* @__PURE__ */ e(
|
|
95
|
+
"section",
|
|
96
|
+
{
|
|
97
|
+
id: r,
|
|
98
|
+
className: "rounded-lg border border-slate-200 bg-white dark:border-white/[0.08] dark:bg-white/[0.03]",
|
|
99
|
+
style: { scrollMarginTop: "calc(var(--cl-toolbar-h, 0px) + 12px)" },
|
|
100
|
+
children: t
|
|
101
|
+
}
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
export {
|
|
105
|
+
D as FolderHeader,
|
|
106
|
+
j as Section,
|
|
107
|
+
S as SortableRow
|
|
108
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useQueryClient as E, useQuery as U } from "@tanstack/react-query";
|
|
2
|
+
import { useRef as y, useCallback as a } from "react";
|
|
3
|
+
import { toast as v } from "sonner";
|
|
4
|
+
import { useNivaroClient as K } from "../../context.js";
|
|
5
|
+
import { get as N, put as S } from "../../lib/commands.js";
|
|
6
|
+
import { toastError as _ } from "../../lib/error-toast.js";
|
|
7
|
+
const n = ["collection-pins"], g = 24;
|
|
8
|
+
function k(f = !0) {
|
|
9
|
+
const l = K(), r = E(), c = U({
|
|
10
|
+
queryKey: n,
|
|
11
|
+
queryFn: () => l.request(N("/collection-pins")).then((e) => {
|
|
12
|
+
var t;
|
|
13
|
+
return ((t = e.data) == null ? void 0 : t.collections) ?? [];
|
|
14
|
+
}),
|
|
15
|
+
enabled: f,
|
|
16
|
+
staleTime: 3e4,
|
|
17
|
+
retry: 1
|
|
18
|
+
}), d = y(Promise.resolve()), i = y(0), p = y([]), s = a(
|
|
19
|
+
(e, t) => {
|
|
20
|
+
const o = r.getQueryData(n) ?? [];
|
|
21
|
+
i.current === 0 && (p.current = o), i.current++, r.cancelQueries({ queryKey: n }), r.setQueryData(n, e);
|
|
22
|
+
const u = d.current.then(async () => {
|
|
23
|
+
var m;
|
|
24
|
+
try {
|
|
25
|
+
const Q = ((m = (await l.request(
|
|
26
|
+
S("/collection-pins", { collections: e })
|
|
27
|
+
)).data) == null ? void 0 : m.collections) ?? e;
|
|
28
|
+
p.current = Q, i.current === 1 && r.setQueryData(n, Q), t && v.success(t);
|
|
29
|
+
} catch (h) {
|
|
30
|
+
r.setQueryData(n, p.current), _(h, "Could not save the pinned collections");
|
|
31
|
+
} finally {
|
|
32
|
+
i.current--;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return d.current = u, u;
|
|
36
|
+
},
|
|
37
|
+
[l, r]
|
|
38
|
+
), P = c.data ?? [], q = a(
|
|
39
|
+
(e, t) => {
|
|
40
|
+
const o = r.getQueryData(n) ?? [];
|
|
41
|
+
return o.includes(e) ? Promise.resolve() : o.length >= g ? (v.error(`Up to ${g} collections can be pinned`, {
|
|
42
|
+
description: "Unpin one first."
|
|
43
|
+
}), Promise.resolve()) : s([...o, e], `Pinned ${t} for everyone`);
|
|
44
|
+
},
|
|
45
|
+
[r, s]
|
|
46
|
+
), D = a(
|
|
47
|
+
(e, t) => {
|
|
48
|
+
const o = r.getQueryData(n) ?? [];
|
|
49
|
+
return s(
|
|
50
|
+
o.filter((u) => u !== e),
|
|
51
|
+
`Unpinned ${t}`
|
|
52
|
+
);
|
|
53
|
+
},
|
|
54
|
+
[r, s]
|
|
55
|
+
), C = a((e) => s(e), [s]);
|
|
56
|
+
return {
|
|
57
|
+
pins: P,
|
|
58
|
+
status: c.isPending && f ? "loading" : c.isError ? "error" : "ready",
|
|
59
|
+
error: c.error,
|
|
60
|
+
refetch: c.refetch,
|
|
61
|
+
pin: q,
|
|
62
|
+
unpin: D,
|
|
63
|
+
reorder: C
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
g as MAX_PINS,
|
|
68
|
+
n as PINS_QUERY_KEY,
|
|
69
|
+
k as useSharedPins
|
|
70
|
+
};
|