@chaibuilder/pages 0.15.3 → 0.15.6
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/{2AITGKQY-o6FgGSqg.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
- package/dist/{2AITGKQY-DhC0sF1x.js → 2AITGKQY-tXLat8E2.js} +2 -2
- package/dist/{NCMVHL6D-D7HU3akD.js → NCMVHL6D-BwDANa-N.js} +2 -2
- package/dist/{NCMVHL6D-BPM6RHYa.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Cr1v3giV.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
- package/dist/{ZDWCUMSJ-NVCxv9uE.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
- package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
- package/dist/add-new-language-page-DZhjVBBf.js +401 -0
- package/dist/add-new-page-DWHANcUx.cjs +1 -0
- package/dist/add-new-page-DYuuentN.js +31 -0
- package/dist/delete-page-1dSWwUBg.js +40 -0
- package/dist/delete-page-m-Cuz7rG.cjs +1 -0
- package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
- package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
- package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
- package/dist/duplicate-page-fUuBTAs7.js +133 -0
- package/dist/{dynamic-page-selector-CF9nb6i_.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
- package/dist/{dynamic-page-selector-DTk4oull.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
- package/dist/image-editor-CeSSNbFY.js +108 -0
- package/dist/image-editor-CnDnY97s.cjs +1 -0
- package/dist/index-0cMGDekp.cjs +5 -0
- package/dist/{index-BuXZJnGo.js → index-Bk8tPO5R.js} +1605 -1571
- package/dist/index.cjs +1 -1
- package/dist/index.js +8 -8
- package/dist/{json-diff-viewer-zBoPBSd3.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
- package/dist/{json-diff-viewer-oyxMD3Hc.js → json-diff-viewer-Cm84g19X.js} +1 -1
- package/dist/lang-panel-CaSKOJ8G.js +225 -0
- package/dist/lang-panel-CkSfJqr8.cjs +1 -0
- package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
- package/dist/mark-as-template-CwsW86Zv.js +153 -0
- package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
- package/dist/no-language-page-content-DDz81nqg.js +42 -0
- package/dist/{page-creator-BG2hc82u.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
- package/dist/{page-creator-y6kl3nw5.js → page-creator-Dr566_Yf.js} +2 -2
- package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
- package/dist/page-lock-request-ECxkQMdS.js +75 -0
- package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
- package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
- package/dist/page-manager-new-DLMvOata.cjs +1 -0
- package/dist/page-manager-new-DkqNLZ5C.js +354 -0
- package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
- package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
- package/dist/{page-revisions-content-BaTqBnko.js → page-revisions-content-CBQPYFZI.js} +18 -18
- package/dist/{page-revisions-content-Tb3T6zvU.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
- package/dist/{publish-pages-content-C9CgEWo0.js → publish-pages-content-BF5yMo_L.js} +6 -6
- package/dist/{publish-pages-content-BGkEZ3GK.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
- package/dist/{save-to-lib-DNK4GPNw.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
- package/dist/{save-to-lib-DGtyTG6H.js → save-to-lib-SpilaoOL.js} +1 -1
- package/dist/{seo-panel-CrK7z4bR.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
- package/dist/{seo-panel-DESVAQM5.js → seo-panel-sbYoo746.js} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +96 -96
- package/dist/shared-json-ld-CEUgLAev.cjs +1 -0
- package/dist/shared-json-ld-D_YyVPk3.js +565 -0
- package/dist/{slug-input-DMYhARDW.cjs → slug-input-Cqj9EBju.cjs} +1 -1
- package/dist/{slug-input-DfAsMPg8.js → slug-input-Df-BG6xl.js} +1 -1
- package/dist/theme-panel-footer-B6leVWSV.js +25 -0
- package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
- package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
- package/dist/unmark-as-template-Cho9B4RN.js +39 -0
- package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
- package/dist/unpublish-page-Dr4qbwUx.js +27 -0
- package/dist/{web-preview-DNgPjdgZ.js → web-preview-Cq82TNaS.js} +1 -1
- package/dist/{web-preview-BcULgiw_.cjs → web-preview-ued-fdxs.cjs} +1 -1
- package/package.json +3 -4
- package/dist/add-new-language-page-8q4Ku3eg.js +0 -390
- package/dist/add-new-language-page-D3PSLiUv.cjs +0 -1
- package/dist/add-new-page-BpvpSM4X.js +0 -30
- package/dist/add-new-page-YpzILOYq.cjs +0 -1
- package/dist/delete-page-CXRJjJ4o.js +0 -38
- package/dist/delete-page-w64MO7db.cjs +0 -1
- package/dist/digital-asset-manager-B2m5T22s.js +0 -1001
- package/dist/digital-asset-manager-BGyKKd_6.cjs +0 -1
- package/dist/duplicate-page-CSQs2MOp.js +0 -120
- package/dist/duplicate-page-DB_c7V2t.cjs +0 -1
- package/dist/image-editor-D9MPdtxC.js +0 -107
- package/dist/image-editor-Da6lrqkL.cjs +0 -1
- package/dist/index-Cds1vIhw.cjs +0 -5
- package/dist/lang-panel-B_HcsPPo.js +0 -218
- package/dist/lang-panel-D2YUMeJZ.cjs +0 -1
- package/dist/mark-as-template-C4wH4UKf.cjs +0 -1
- package/dist/mark-as-template-CPEPYXg7.js +0 -146
- package/dist/no-language-page-content-CVyOpT9h.js +0 -35
- package/dist/no-language-page-content-ECt0SxFX.cjs +0 -1
- package/dist/page-lock-request-DC62b588.js +0 -64
- package/dist/page-lock-request-fGZbOFTp.cjs +0 -1
- package/dist/page-locked-by-dialog-BIC-c0Jl.cjs +0 -1
- package/dist/page-locked-by-dialog-D-vXaoga.js +0 -63
- package/dist/page-manager-new-CUfjlMed.cjs +0 -1
- package/dist/page-manager-new-Cto2r7Va.js +0 -354
- package/dist/page-manager-search-and-filter-sVnGlF46.js +0 -197
- package/dist/page-manager-search-and-filter-z2b4sgvb.cjs +0 -1
- package/dist/shared-json-ld-BMfQzOWc.js +0 -650
- package/dist/shared-json-ld-_ozYsSHn.cjs +0 -1
- package/dist/theme-panel-footer-Bj2yHtxO.cjs +0 -1
- package/dist/theme-panel-footer-RrxiDGoD.js +0 -25
- package/dist/unmark-as-template-BjetSrYF.js +0 -38
- package/dist/unmark-as-template-C8hTjRVk.cjs +0 -1
- package/dist/unpublish-page-BTPEVAkv.js +0 -26
- package/dist/unpublish-page-gtGfNOAq.cjs +0 -1
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { jsxs as y, jsx as t, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { at as be, f as ie, ai as ye, T as _, aC as ge, L as ke, h as Ne, b as we, i as ve, ao as Se, aD as Ae, aE as q } from "./index-Bk8tPO5R.js";
|
|
3
|
+
import { u as K } from "./use-page-expand-manager-D6T75I11.js";
|
|
4
|
+
import { compact as ce, filter as F, isEmpty as S, uniqBy as Le, keyBy as de, mapValues as Te, startCase as Ce, toLower as T, includes as R, find as z, get as Q, map as Ee } from "lodash-es";
|
|
5
|
+
import { useTranslation as Ue, useLanguages as ae } from "@chaibuilder/sdk";
|
|
6
|
+
import { useAtom as $e } from "jotai";
|
|
7
|
+
import { NotepadText as Me, MoreHorizontal as ze, Lock as Fe, Edit as je, Plus as Be, ChevronRight as Ie, StarsIcon as Ge, Hash as De, File as ue } from "lucide-react";
|
|
8
|
+
import { useMemo as V, lazy as C, useState as N, useCallback as le, useEffect as M, Suspense as L } from "react";
|
|
9
|
+
const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
10
|
+
F(e, (r) => {
|
|
11
|
+
const s = T(n);
|
|
12
|
+
return R(T((r == null ? void 0 : r.name) || ""), s) || R(T((r == null ? void 0 : r.slug) || ""), s);
|
|
13
|
+
})
|
|
14
|
+
), Oe = (e, n) => {
|
|
15
|
+
const r = /* @__PURE__ */ new Set(), s = de(e, "id");
|
|
16
|
+
return n.forEach((o) => {
|
|
17
|
+
let l = o;
|
|
18
|
+
for (; l.parent && s[l.parent]; )
|
|
19
|
+
r.add(l.parent), l = s[l.parent];
|
|
20
|
+
}), Array.from(r).map((o) => s[o]);
|
|
21
|
+
}, J = (e, n, r) => S(n) ? e : e.map((s) => {
|
|
22
|
+
if (!r(s.pageType))
|
|
23
|
+
return {
|
|
24
|
+
...s,
|
|
25
|
+
shouldExpandOnSearch: !0,
|
|
26
|
+
children: s.children ? J(s.children, n, r) : []
|
|
27
|
+
};
|
|
28
|
+
const o = s.children && s.children.some(
|
|
29
|
+
(l) => R(T(l.name || ""), T(n)) || R(T(l.slug || ""), T(n))
|
|
30
|
+
);
|
|
31
|
+
return {
|
|
32
|
+
...s,
|
|
33
|
+
shouldExpandOnSearch: o,
|
|
34
|
+
children: s.children ? J(s.children, n, r) : []
|
|
35
|
+
};
|
|
36
|
+
}), Re = (e) => {
|
|
37
|
+
if (!e || !e.length) return [];
|
|
38
|
+
const n = {};
|
|
39
|
+
e.forEach((s) => {
|
|
40
|
+
n[s.id] = { ...s, children: [] };
|
|
41
|
+
});
|
|
42
|
+
const r = [];
|
|
43
|
+
return Object.values(n).forEach((s) => {
|
|
44
|
+
s.parent && n[s.parent] ? n[s.parent].children.push(s) : r.push(s);
|
|
45
|
+
}), r;
|
|
46
|
+
}, me = (e) => !e || !e.length ? [] : [...e].sort(
|
|
47
|
+
(r, s) => (r.name || "").localeCompare(s.name || "")
|
|
48
|
+
).map((r) => ({
|
|
49
|
+
...r,
|
|
50
|
+
children: r.children ? me(r.children) : []
|
|
51
|
+
})), We = (e, n, r, s) => {
|
|
52
|
+
if (!e || !e.length) return [];
|
|
53
|
+
let o = e;
|
|
54
|
+
if (r !== "all" && (o = ce(F(e, { pageType: r }))), S(n))
|
|
55
|
+
o = oe(o, n);
|
|
56
|
+
else {
|
|
57
|
+
const u = oe(o, n), i = Oe(e, u);
|
|
58
|
+
o = Le([...u, ...i], "id");
|
|
59
|
+
}
|
|
60
|
+
const l = me(Re(o)), f = J(l, n, s), g = F(f, (u) => s(u.pageType)).sort((u, i) => (u.name || "").localeCompare(i.name || "")), P = F(f, (u) => !s(u.pageType));
|
|
61
|
+
let m = [];
|
|
62
|
+
if (r === "all") {
|
|
63
|
+
const u = de(P, "pageType");
|
|
64
|
+
m = Object.values(
|
|
65
|
+
Te(u, (i, x) => ({
|
|
66
|
+
...i,
|
|
67
|
+
id: x,
|
|
68
|
+
name: Ce(x),
|
|
69
|
+
isPartialGroup: !0,
|
|
70
|
+
children: f.filter((p) => p.pageType === x)
|
|
71
|
+
}))
|
|
72
|
+
);
|
|
73
|
+
} else
|
|
74
|
+
m = P.sort((u, i) => (u.name || "").localeCompare(i.name || ""));
|
|
75
|
+
return [...g, ...m];
|
|
76
|
+
}, He = ({ page: e }) => {
|
|
77
|
+
var s, o;
|
|
78
|
+
const { isExpanded: n, toggleExpanded: r } = K(e == null ? void 0 : e.id);
|
|
79
|
+
return /* @__PURE__ */ t(
|
|
80
|
+
"button",
|
|
81
|
+
{
|
|
82
|
+
onClick: (l) => {
|
|
83
|
+
l.stopPropagation(), r();
|
|
84
|
+
},
|
|
85
|
+
disabled: !((s = e == null ? void 0 : e.children) != null && s.length),
|
|
86
|
+
className: `flex h-[calc(100%-2px)] w-5 items-center justify-center rounded text-gray-400 transition-colors hover:bg-gray-200 hover:px-1 hover:text-gray-500 ${(o = e == null ? void 0 : e.children) != null && o.length ? "hover:text-blue-400" : "opacity-0"}`,
|
|
87
|
+
children: /* @__PURE__ */ t(
|
|
88
|
+
Ie,
|
|
89
|
+
{
|
|
90
|
+
size: 12,
|
|
91
|
+
className: `stroke-[4] transition-transform duration-200 ${n ? "rotate-90" : ""}`
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
);
|
|
96
|
+
}, _e = ({ page: e, pageType: n }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(Ge, { size: 12, className: "text-yellow-400" }) : n != null && n.icon ? /* @__PURE__ */ t(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
|
|
100
|
+
dangerouslySetInnerHTML: { __html: n.icon }
|
|
101
|
+
}
|
|
102
|
+
) : n != null && n.hasSlug ? /* @__PURE__ */ t(ue, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(De, { size: 12, className: "stroke-[1] text-slate-500" }) }), qe = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), Qe = ({
|
|
103
|
+
page: e,
|
|
104
|
+
pageTypes: n,
|
|
105
|
+
currentPage: r,
|
|
106
|
+
onClickAction: s,
|
|
107
|
+
languagePages: o,
|
|
108
|
+
selectedLanguage: l,
|
|
109
|
+
showUntranslatedPages: f
|
|
110
|
+
}) => {
|
|
111
|
+
const [g] = be(), P = ie(), m = r === e.id, u = !!e.isTemplate, i = V(() => z(n, { key: e.pageType }), [n, e.pageType]), x = g == null ? void 0 : g[e.id], { data: p } = ye(x), w = p ? p == null ? void 0 : p.name : null;
|
|
112
|
+
let d = Q(o, e == null ? void 0 : e.id);
|
|
113
|
+
d = Q(d, "lang") === l ? d : null;
|
|
114
|
+
const A = l === P || !!d, E = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
|
|
115
|
+
let b = (d == null ? void 0 : d.slug) || (e == null ? void 0 : e.slug) || "";
|
|
116
|
+
const j = b + (e != null && e.dynamic ? `/${i == null ? void 0 : i.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
117
|
+
if (b.startsWith("/") && !f) {
|
|
118
|
+
const c = b.split("/").pop();
|
|
119
|
+
b = b.endsWith(c) && e.dynamic ? "" : `/${c}`;
|
|
120
|
+
}
|
|
121
|
+
const B = V(() => {
|
|
122
|
+
const c = "flex h-7 min-w-0 flex-1 cursor-pointer select-none items-center gap-x-1.5 rounded px-px text-xs duration-300 border-[1px]", I = `${m ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
|
|
123
|
+
return A ? `${c} ${I} ${w ? "opacity-60" : ""}` : `${c} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
|
|
124
|
+
}, [A, m, w]);
|
|
125
|
+
return /* @__PURE__ */ y("div", { className: "group relative", children: [
|
|
126
|
+
/* @__PURE__ */ y(
|
|
127
|
+
"div",
|
|
128
|
+
{
|
|
129
|
+
onClick: () => !e.isPartialGroup && A && s("select", e == null ? void 0 : e.id),
|
|
130
|
+
className: B,
|
|
131
|
+
children: [
|
|
132
|
+
/* @__PURE__ */ t(He, { page: e }),
|
|
133
|
+
!e.isPartialGroup && /* @__PURE__ */ t(qe, { isOnline: d ? d.online : e.online }),
|
|
134
|
+
!e.isPartialGroup && /* @__PURE__ */ t(_e, { page: e, pageType: i }),
|
|
135
|
+
/* @__PURE__ */ t(_, { content: E, side: "top", showTooltip: E.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: E }) }),
|
|
136
|
+
(b || e.dynamic) && /* @__PURE__ */ t(_, { content: j, side: "top", showTooltip: !0, children: /* @__PURE__ */ y("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
137
|
+
b,
|
|
138
|
+
e.dynamic && (i == null ? void 0 : i.dynamicSlug) && /* @__PURE__ */ y("span", { className: "text-xs text-gray-500", children: [
|
|
139
|
+
"/",
|
|
140
|
+
i == null ? void 0 : i.dynamicSlug,
|
|
141
|
+
e.dynamicSlugCustom
|
|
142
|
+
] })
|
|
143
|
+
] }) }),
|
|
144
|
+
u && /* @__PURE__ */ t(_, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(Me, { size: 16 }) }) }),
|
|
145
|
+
!e.isPartialGroup && A && !w ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
|
|
146
|
+
ge,
|
|
147
|
+
{
|
|
148
|
+
isLanguagePage: !!d,
|
|
149
|
+
page: d || e,
|
|
150
|
+
setDuplicatePage: (c) => s("duplicate", c),
|
|
151
|
+
setAddEditPage: (c) => s("edit", d || c),
|
|
152
|
+
setUnpublishPage: (c) => s("unpublish", c),
|
|
153
|
+
setDeletePage: (c) => s("delete", d || c),
|
|
154
|
+
setMarkAsTemplate: (c) => s("markAsTemplate", c),
|
|
155
|
+
setUnmarkAsTemplate: (c) => s("unmarkAsTemplate", c),
|
|
156
|
+
children: /* @__PURE__ */ t("div", { className: "m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white", children: /* @__PURE__ */ t(ze, { className: "h-4 w-4", onClick: (c) => c.stopPropagation() }) })
|
|
157
|
+
}
|
|
158
|
+
) }) : w ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(Fe, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
|
|
159
|
+
]
|
|
160
|
+
}
|
|
161
|
+
),
|
|
162
|
+
/* @__PURE__ */ t(O, { children: w && /* @__PURE__ */ y("button", { className: "absolute right-0 top-0 flex h-full items-center gap-x-1 rounded bg-red-50 px-2 py-0.5 text-xs font-light text-red-500 opacity-0 group-hover:opacity-100", children: [
|
|
163
|
+
/* @__PURE__ */ t(je, { size: 12, className: "stroke-[3]" }),
|
|
164
|
+
" ",
|
|
165
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: w }),
|
|
166
|
+
" is editing this page"
|
|
167
|
+
] }) }),
|
|
168
|
+
/* @__PURE__ */ t(O, { children: !A && !e.isPartialGroup && !w && /* @__PURE__ */ y(
|
|
169
|
+
"button",
|
|
170
|
+
{
|
|
171
|
+
onClick: (c) => {
|
|
172
|
+
c.stopPropagation(), s("addLanguagePage", { language: l, page: e });
|
|
173
|
+
},
|
|
174
|
+
className: "absolute left-1/2 top-1 flex -translate-x-1/2 items-center gap-x-1 rounded bg-blue-500 px-2 py-0.5 text-xs text-white opacity-0 duration-200 hover:bg-blue-700 group-hover:opacity-100",
|
|
175
|
+
children: [
|
|
176
|
+
/* @__PURE__ */ t(Be, { size: 12, className: "stroke-[3]" }),
|
|
177
|
+
" ",
|
|
178
|
+
/* @__PURE__ */ y("span", { className: "text-[10px]", children: [
|
|
179
|
+
"Add ",
|
|
180
|
+
Q(ke, l),
|
|
181
|
+
" Page"
|
|
182
|
+
] })
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
) })
|
|
186
|
+
] });
|
|
187
|
+
}, he = ({
|
|
188
|
+
pages: e,
|
|
189
|
+
tier: n,
|
|
190
|
+
pageTypes: r,
|
|
191
|
+
currentPage: s,
|
|
192
|
+
onClickAction: o,
|
|
193
|
+
languagePages: l,
|
|
194
|
+
selectedLanguage: f,
|
|
195
|
+
showUntranslatedPages: g
|
|
196
|
+
}) => {
|
|
197
|
+
const { expandedPages: P } = K();
|
|
198
|
+
return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${n * 10}px` }, children: e.map((m) => /* @__PURE__ */ y(O, { children: [
|
|
199
|
+
/* @__PURE__ */ t(
|
|
200
|
+
Qe,
|
|
201
|
+
{
|
|
202
|
+
page: m,
|
|
203
|
+
pageTypes: r,
|
|
204
|
+
currentPage: s,
|
|
205
|
+
onClickAction: o,
|
|
206
|
+
languagePages: l,
|
|
207
|
+
selectedLanguage: f,
|
|
208
|
+
showUntranslatedPages: g
|
|
209
|
+
}
|
|
210
|
+
),
|
|
211
|
+
m.children && m.children.length > 0 && (P == null ? void 0 : P.includes(m.id)) && /* @__PURE__ */ t(
|
|
212
|
+
he,
|
|
213
|
+
{
|
|
214
|
+
pages: m.children,
|
|
215
|
+
tier: n + 1,
|
|
216
|
+
pageTypes: r,
|
|
217
|
+
currentPage: s,
|
|
218
|
+
onClickAction: o,
|
|
219
|
+
languagePages: l,
|
|
220
|
+
selectedLanguage: f,
|
|
221
|
+
showUntranslatedPages: g
|
|
222
|
+
}
|
|
223
|
+
)
|
|
224
|
+
] }, m.id)) });
|
|
225
|
+
}, Ve = C(() => import("./page-manager-search-and-filter-B98nz9xS.js")), Je = C(() => import("./add-new-page-DYuuentN.js")), Ke = C(() => import("./delete-page-1dSWwUBg.js")), Xe = C(() => import("./duplicate-page-fUuBTAs7.js")), Ye = C(() => import("./mark-as-template-CwsW86Zv.js")), Ze = C(() => import("./unmark-as-template-Cho9B4RN.js")), et = C(() => import("./unpublish-page-Dr4qbwUx.js")), ct = ({ close: e }) => {
|
|
226
|
+
const { t: n } = Ue(), { languages: r, setSelectedLang: s } = ae(), { data: o } = Ne(), { data: l, isFetching: f } = we(), [g, P] = ve(), { updateForSelectedPage: m, expandPagesOnSearch: u } = K(null), i = ie(), x = g.get("page"), [p, w] = N(""), [d, A] = N(null), [E, b] = N(null), [j, B] = N(null), [c, I] = N(null), [U, W] = N(""), [X, Y] = N(null), [Z, ee] = N(null), [k, fe] = N(i), [Pe, xe] = N(!1), [, te] = $e(Se), G = Pe && k !== i, { data: $, isFetching: pe } = Ae(k), se = le(
|
|
227
|
+
(h) => {
|
|
228
|
+
var a;
|
|
229
|
+
return (a = z(o, { key: h })) == null ? void 0 : a.hasSlug;
|
|
230
|
+
},
|
|
231
|
+
[o]
|
|
232
|
+
), v = V(() => l ? G ? F(l, (h) => !($ != null && $[h.id])) : We(l, p, U, se) : [], [l, se, p, U, $, G]);
|
|
233
|
+
M(() => {
|
|
234
|
+
s(i);
|
|
235
|
+
}, [i, s]), M(() => {
|
|
236
|
+
if (!S(U)) return;
|
|
237
|
+
const h = sessionStorage.getItem("pageTypeFilter") || "all";
|
|
238
|
+
!S(o) && h && (z(o, { key: h }) ? W(h) : W("all"));
|
|
239
|
+
}, [o, U]), M(() => {
|
|
240
|
+
if (x && !f && !z(l, { id: x })) {
|
|
241
|
+
const a = z(l, { slug: "/" });
|
|
242
|
+
if (a) {
|
|
243
|
+
const D = new URLSearchParams({ page: a.id });
|
|
244
|
+
q(D, P);
|
|
245
|
+
} else
|
|
246
|
+
q(new URLSearchParams({}), P, !0);
|
|
247
|
+
}
|
|
248
|
+
}, [l, x, f, P]), M(() => {
|
|
249
|
+
x && !f && !S(v) && m(v, x);
|
|
250
|
+
}, [x, f, v, m]), M(() => {
|
|
251
|
+
!S(p) && !S(v) && u(v);
|
|
252
|
+
}, [p, v, u]);
|
|
253
|
+
const { setSelectedLang: H } = ae(), ne = le(
|
|
254
|
+
(h) => {
|
|
255
|
+
const a = new URLSearchParams({ page: h });
|
|
256
|
+
k !== i ? (a.set("lang", k), H(k)) : H(""), q(a, P), e();
|
|
257
|
+
},
|
|
258
|
+
[e, P, H, k, i]
|
|
259
|
+
), re = (h, a) => {
|
|
260
|
+
var D;
|
|
261
|
+
if (a)
|
|
262
|
+
switch (h) {
|
|
263
|
+
case "add":
|
|
264
|
+
b(a);
|
|
265
|
+
break;
|
|
266
|
+
case "select":
|
|
267
|
+
ne(a);
|
|
268
|
+
break;
|
|
269
|
+
case "edit":
|
|
270
|
+
k !== i ? te({
|
|
271
|
+
edit: !0,
|
|
272
|
+
id: a == null ? void 0 : a.id,
|
|
273
|
+
primaryPage: a == null ? void 0 : a.primaryPage
|
|
274
|
+
}) : b(a);
|
|
275
|
+
break;
|
|
276
|
+
case "delete":
|
|
277
|
+
A(a);
|
|
278
|
+
break;
|
|
279
|
+
case "unpublish":
|
|
280
|
+
B(a);
|
|
281
|
+
break;
|
|
282
|
+
case "markAsTemplate":
|
|
283
|
+
I(a);
|
|
284
|
+
break;
|
|
285
|
+
case "unmarkAsTemplate":
|
|
286
|
+
ee(a);
|
|
287
|
+
break;
|
|
288
|
+
case "duplicate":
|
|
289
|
+
Y(a);
|
|
290
|
+
break;
|
|
291
|
+
case "addLanguagePage":
|
|
292
|
+
te({
|
|
293
|
+
edit: !1,
|
|
294
|
+
primaryPage: ((D = a == null ? void 0 : a.page) == null ? void 0 : D.id) || "",
|
|
295
|
+
preselectedLang: (a == null ? void 0 : a.language) || k
|
|
296
|
+
});
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
return /* @__PURE__ */ y(O, { children: [
|
|
301
|
+
/* @__PURE__ */ y("div", { className: "flex h-full flex-col justify-between", children: [
|
|
302
|
+
/* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(
|
|
303
|
+
Ve,
|
|
304
|
+
{
|
|
305
|
+
pages: v,
|
|
306
|
+
search: p,
|
|
307
|
+
setSearch: w,
|
|
308
|
+
languages: [i, ...r],
|
|
309
|
+
selectedLanguage: k,
|
|
310
|
+
setSelectedLanguage: fe,
|
|
311
|
+
selectedPageType: U,
|
|
312
|
+
setSelectedPageType: W,
|
|
313
|
+
onAddPage: (h) => re("add", h),
|
|
314
|
+
showUntranslatedPages: G,
|
|
315
|
+
setShowUntranslatedPages: xe
|
|
316
|
+
}
|
|
317
|
+
) }),
|
|
318
|
+
/* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: f || pe ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ee([...Array(15).keys()], (h) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, h)) }) : S(v) ? /* @__PURE__ */ y("div", { className: "flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500", children: [
|
|
319
|
+
/* @__PURE__ */ t(ue, { className: "h-6 w-6 stroke-[1]" }),
|
|
320
|
+
n("Empty List!"),
|
|
321
|
+
/* @__PURE__ */ t("span", { className: "font-light", children: n("Add new page to start") })
|
|
322
|
+
] }) : /* @__PURE__ */ t(
|
|
323
|
+
he,
|
|
324
|
+
{
|
|
325
|
+
tier: 0,
|
|
326
|
+
pages: v,
|
|
327
|
+
pageTypes: o,
|
|
328
|
+
currentPage: x || "",
|
|
329
|
+
onClickAction: re,
|
|
330
|
+
languagePages: $,
|
|
331
|
+
selectedLanguage: k,
|
|
332
|
+
showUntranslatedPages: G
|
|
333
|
+
}
|
|
334
|
+
) })
|
|
335
|
+
] }),
|
|
336
|
+
E && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(
|
|
337
|
+
Je,
|
|
338
|
+
{
|
|
339
|
+
closePanel: e,
|
|
340
|
+
editPage: ne,
|
|
341
|
+
addEditPage: E,
|
|
342
|
+
setAddEditPage: b
|
|
343
|
+
}
|
|
344
|
+
) }),
|
|
345
|
+
d && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ke, { page: d, onClose: () => A(null) }) }),
|
|
346
|
+
j && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(et, { page: j, onClose: () => B(null) }) }),
|
|
347
|
+
c && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ye, { page: c, onClose: () => I(null) }) }),
|
|
348
|
+
Z && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ze, { page: Z, onClose: () => ee(null) }) }),
|
|
349
|
+
X && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Xe, { page: X, onClose: () => Y(null), closePanel: e }) })
|
|
350
|
+
] });
|
|
351
|
+
};
|
|
352
|
+
export {
|
|
353
|
+
ct as default
|
|
354
|
+
};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { jsx as e, jsxs as n, Fragment as k } from "react/jsx-runtime";
|
|
2
|
+
import { f as F, L as I, h as z, A as j } from "./index-Bk8tPO5R.js";
|
|
3
|
+
import { u as T } from "./use-page-expand-manager-D6T75I11.js";
|
|
4
|
+
import { useTranslation as f } from "@chaibuilder/sdk";
|
|
5
|
+
import { Button as m, Tooltip as g, TooltipTrigger as b, TooltipContent as y, Select as $, SelectTrigger as G, SelectContent as D, Input as E, SelectItem as N } from "@chaibuilder/sdk/ui";
|
|
6
|
+
import { useQueryClient as M } from "@tanstack/react-query";
|
|
7
|
+
import { isEmpty as w, filter as x, map as S, get as o } from "lodash-es";
|
|
8
|
+
import { Star as R, Plus as W, FilterXIcon as q, Filter as B, ListFilter as K, Search as P, ChevronsUpDown as Q, ChevronsDownUp as _, RefreshCw as O } from "lucide-react";
|
|
9
|
+
import { useState as U } from "react";
|
|
10
|
+
const V = ({ selectedPageType: a, setSelectedPageType: i }) => {
|
|
11
|
+
const { t: l } = f(), [r, s] = U(""), { data: c } = z(), h = (t) => {
|
|
12
|
+
if (!r) return !0;
|
|
13
|
+
const d = r.toLowerCase(), u = (v) => String(o(t, v, "")).toLowerCase().includes(d);
|
|
14
|
+
return u("name") || u("key");
|
|
15
|
+
}, p = c.find((t) => t.key === a);
|
|
16
|
+
return /* @__PURE__ */ n($, { onValueChange: i, value: a, children: [
|
|
17
|
+
/* @__PURE__ */ e(
|
|
18
|
+
G,
|
|
19
|
+
{
|
|
20
|
+
className: `${a === "all" ? "bg-gray-100/30 hover:bg-gray-100" : "gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,
|
|
21
|
+
children: /* @__PURE__ */ n("div", { className: "flex w-full items-center justify-between gap-x-1.5", children: [
|
|
22
|
+
/* @__PURE__ */ e("span", { className: "max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight", children: (p == null ? void 0 : p.name) || l("All") }),
|
|
23
|
+
/* @__PURE__ */ e(
|
|
24
|
+
K,
|
|
25
|
+
{
|
|
26
|
+
className: `${a !== "all" ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`
|
|
27
|
+
}
|
|
28
|
+
)
|
|
29
|
+
] })
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
/* @__PURE__ */ n(D, { children: [
|
|
33
|
+
/* @__PURE__ */ e("div", { className: "sticky top-0 z-10 bg-white pb-2", children: /* @__PURE__ */ n("div", { className: "relative", children: [
|
|
34
|
+
/* @__PURE__ */ e(P, { strokeWidth: 2, className: "absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400" }),
|
|
35
|
+
/* @__PURE__ */ e(
|
|
36
|
+
E,
|
|
37
|
+
{
|
|
38
|
+
placeholder: l("Search page types..."),
|
|
39
|
+
className: "h-8 w-full rounded border pl-8 text-xs shadow-none",
|
|
40
|
+
value: r,
|
|
41
|
+
onChange: (t) => s(t.target.value),
|
|
42
|
+
onKeyDown: (t) => t.stopPropagation()
|
|
43
|
+
}
|
|
44
|
+
)
|
|
45
|
+
] }) }),
|
|
46
|
+
/* @__PURE__ */ e(N, { value: "all", children: l("All") }),
|
|
47
|
+
!w(x(c, (t) => t.hasSlug && h(t))) && /* @__PURE__ */ n(k, { children: [
|
|
48
|
+
/* @__PURE__ */ e("div", { className: "mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500", children: l("Pages") }),
|
|
49
|
+
S(
|
|
50
|
+
[...x(c, (t) => t.hasSlug && h(t))].sort(
|
|
51
|
+
(t, d) => o(t, "name", "").localeCompare(o(d, "name", ""))
|
|
52
|
+
),
|
|
53
|
+
(t) => /* @__PURE__ */ e(N, { value: o(t, "key"), children: o(t, "name") }, o(t, "key"))
|
|
54
|
+
)
|
|
55
|
+
] }),
|
|
56
|
+
!w(x(c, (t) => !t.hasSlug && h(t))) && /* @__PURE__ */ n(k, { children: [
|
|
57
|
+
/* @__PURE__ */ e("div", { className: "mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500", children: l("Partials") }),
|
|
58
|
+
S(
|
|
59
|
+
[...x(c, (t) => !t.hasSlug && h(t))].sort(
|
|
60
|
+
(t, d) => o(t, "name", "").localeCompare(o(d, "name", ""))
|
|
61
|
+
),
|
|
62
|
+
(t) => /* @__PURE__ */ e(N, { value: o(t, "key"), children: o(t, "name") }, o(t, "key"))
|
|
63
|
+
)
|
|
64
|
+
] }),
|
|
65
|
+
w(x(c, h)) && /* @__PURE__ */ e("div", { className: "px-3 py-2 text-center text-sm text-gray-500", children: l("No matching page types found") })
|
|
66
|
+
] })
|
|
67
|
+
] });
|
|
68
|
+
}, X = ({ search: a, setSearch: i }) => {
|
|
69
|
+
const { t: l } = f();
|
|
70
|
+
return /* @__PURE__ */ n("div", { className: "relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5", children: [
|
|
71
|
+
/* @__PURE__ */ e("label", { htmlFor: "page-search-input", className: "sr-only", children: l("Search Pages") }),
|
|
72
|
+
/* @__PURE__ */ e(
|
|
73
|
+
P,
|
|
74
|
+
{
|
|
75
|
+
className: `${a ? "fill-sky-50 text-sky-500" : ""} pointer-events-none h-4 w-4 text-muted-foreground`,
|
|
76
|
+
"aria-hidden": "true"
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ e(
|
|
80
|
+
E,
|
|
81
|
+
{
|
|
82
|
+
id: "page-search-input",
|
|
83
|
+
placeholder: l("Search pages"),
|
|
84
|
+
value: a,
|
|
85
|
+
onChange: (r) => i(r.target.value),
|
|
86
|
+
className: "border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",
|
|
87
|
+
autoComplete: "off"
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
] });
|
|
91
|
+
}, H = ({ pages: a }) => {
|
|
92
|
+
const { t: i } = f(), { expandAll: l, collapseAll: r, expandedPages: s } = T(null);
|
|
93
|
+
return /* @__PURE__ */ n("div", { className: "flex gap-1", children: [
|
|
94
|
+
/* @__PURE__ */ n(g, { children: [
|
|
95
|
+
/* @__PURE__ */ e(b, { asChild: !0, children: /* @__PURE__ */ e(m, { variant: "outline", size: "icon", onClick: () => l(a), className: "rounded p-1 text-gray-500", children: /* @__PURE__ */ e(Q, {}) }) }),
|
|
96
|
+
/* @__PURE__ */ e(y, { children: i("Expand All") })
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ n(g, { children: [
|
|
99
|
+
/* @__PURE__ */ e(b, { asChild: !0, children: /* @__PURE__ */ e(
|
|
100
|
+
m,
|
|
101
|
+
{
|
|
102
|
+
disabled: s.length === 0,
|
|
103
|
+
variant: "outline",
|
|
104
|
+
size: "icon",
|
|
105
|
+
onClick: () => r(),
|
|
106
|
+
className: "rounded p-1 text-gray-500",
|
|
107
|
+
children: /* @__PURE__ */ e(_, {})
|
|
108
|
+
}
|
|
109
|
+
) }),
|
|
110
|
+
/* @__PURE__ */ e(y, { children: i("Collapse All") })
|
|
111
|
+
] })
|
|
112
|
+
] });
|
|
113
|
+
}, J = ({ languages: a, selectedLanguage: i, setSelectedLanguage: l }) => {
|
|
114
|
+
const r = F();
|
|
115
|
+
return /* @__PURE__ */ e("div", { className: "scrollbar-hide flex gap-1 overflow-x-auto pb-1", children: a.map((s) => /* @__PURE__ */ n(
|
|
116
|
+
m,
|
|
117
|
+
{
|
|
118
|
+
variant: i === s ? "default" : "outline",
|
|
119
|
+
size: "sm",
|
|
120
|
+
className: `h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i === s ? "bg-black text-white hover:bg-black" : "text-gray-500"}`,
|
|
121
|
+
onClick: () => l(s.toLowerCase()),
|
|
122
|
+
children: [
|
|
123
|
+
s === r && /* @__PURE__ */ e(R, { size: 4, className: `p-0.5 ${i === r ? "fill-white" : "fill-black"}` }),
|
|
124
|
+
I[s] || ""
|
|
125
|
+
]
|
|
126
|
+
},
|
|
127
|
+
s
|
|
128
|
+
)) });
|
|
129
|
+
}, A = () => {
|
|
130
|
+
const { t: a } = f(), i = M();
|
|
131
|
+
return /* @__PURE__ */ n(g, { children: [
|
|
132
|
+
/* @__PURE__ */ e(b, { asChild: !0, children: /* @__PURE__ */ e(
|
|
133
|
+
m,
|
|
134
|
+
{
|
|
135
|
+
size: "sm",
|
|
136
|
+
variant: "ghost",
|
|
137
|
+
onClick: () => i.invalidateQueries({ queryKey: [j.GET_WEBSITE_PAGES] }),
|
|
138
|
+
className: "mt-1 h-6 w-6",
|
|
139
|
+
children: /* @__PURE__ */ e(O, {})
|
|
140
|
+
}
|
|
141
|
+
) }),
|
|
142
|
+
/* @__PURE__ */ e(y, { side: "bottom", children: a("Refresh pages list") })
|
|
143
|
+
] });
|
|
144
|
+
}, se = ({
|
|
145
|
+
pages: a,
|
|
146
|
+
search: i,
|
|
147
|
+
setSearch: l,
|
|
148
|
+
languages: r,
|
|
149
|
+
onAddPage: s,
|
|
150
|
+
selectedLanguage: c,
|
|
151
|
+
setSelectedLanguage: h,
|
|
152
|
+
selectedPageType: p,
|
|
153
|
+
setSelectedPageType: t,
|
|
154
|
+
showUntranslatedPages: d,
|
|
155
|
+
setShowUntranslatedPages: u
|
|
156
|
+
}) => {
|
|
157
|
+
const { t: v } = f(), C = r.length > 1;
|
|
158
|
+
return /* @__PURE__ */ n("div", { className: "space-y-3 border-b border-b-gray-200 px-4 pb-1", children: [
|
|
159
|
+
/* @__PURE__ */ n("div", { className: "flex items-center gap-x-2", children: [
|
|
160
|
+
/* @__PURE__ */ e(V, { selectedPageType: p, setSelectedPageType: t }),
|
|
161
|
+
/* @__PURE__ */ e(X, { search: i, setSearch: l }),
|
|
162
|
+
/* @__PURE__ */ e(H, { pages: a }),
|
|
163
|
+
/* @__PURE__ */ n(m, { variant: "default", onClick: s, className: "rounded px-3 font-normal", children: [
|
|
164
|
+
/* @__PURE__ */ e(W, { strokeWidth: 2, className: "stroke-white stroke-[3]" }),
|
|
165
|
+
/* @__PURE__ */ e("span", { className: "font-normal text-white", children: v("Add Page") })
|
|
166
|
+
] }),
|
|
167
|
+
!C && /* @__PURE__ */ e(A, {})
|
|
168
|
+
] }),
|
|
169
|
+
C ? /* @__PURE__ */ n("div", { className: "flex items-center justify-between gap-2", children: [
|
|
170
|
+
/* @__PURE__ */ e(
|
|
171
|
+
J,
|
|
172
|
+
{
|
|
173
|
+
languages: r,
|
|
174
|
+
selectedLanguage: c,
|
|
175
|
+
setSelectedLanguage: (L) => {
|
|
176
|
+
h(L), u(d && (r == null ? void 0 : r[0]) !== c);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
),
|
|
180
|
+
/* @__PURE__ */ n("div", { className: "flex items-center gap-x-2", children: [
|
|
181
|
+
(r == null ? void 0 : r[0]) !== c && /* @__PURE__ */ n(g, { children: [
|
|
182
|
+
/* @__PURE__ */ e(b, { asChild: !0, children: /* @__PURE__ */ e(
|
|
183
|
+
m,
|
|
184
|
+
{
|
|
185
|
+
variant: "ghost",
|
|
186
|
+
onClick: () => u(!d),
|
|
187
|
+
className: "h-6 rounded px-3 py-1 text-xs font-normal",
|
|
188
|
+
children: d ? /* @__PURE__ */ e(q, {}) : /* @__PURE__ */ e(B, {})
|
|
189
|
+
}
|
|
190
|
+
) }),
|
|
191
|
+
/* @__PURE__ */ e(y, { side: "bottom", children: v("Toggle Untranslated Pages") })
|
|
192
|
+
] }),
|
|
193
|
+
/* @__PURE__ */ e(A, {})
|
|
194
|
+
] })
|
|
195
|
+
] }) : /* @__PURE__ */ e("div", { className: "flex items-center justify-between gap-2" })
|
|
196
|
+
] });
|
|
197
|
+
};
|
|
198
|
+
export {
|
|
199
|
+
J as LanguageSelector,
|
|
200
|
+
se as default
|
|
201
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-0cMGDekp.cjs"),N=require("./use-page-expand-manager-2KjeYfVS.cjs"),m=require("@chaibuilder/sdk"),s=require("@chaibuilder/sdk/ui"),w=require("@tanstack/react-query"),r=require("lodash-es"),d=require("lucide-react"),C=require("react"),S=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=m.useTranslation(),[n,o]=C.useState(""),{data:c}=j.usePageTypes(),h=t=>{if(!n)return!0;const x=n.toLowerCase(),p=g=>String(r.get(t,g,"")).toLowerCase().includes(x);return p("name")||p("key")},u=c.find(t=>t.key===l);return e.jsxs(s.Select,{onValueChange:i,value:l,children:[e.jsx(s.SelectTrigger,{className:`${l==="all"?"bg-gray-100/30 hover:bg-gray-100":"gap-x-1 border bg-gray-100/30 hover:bg-gray-100"} h-9 w-max min-w-[150px] overflow-hidden whitespace-nowrap rounded p-0 px-2 py-1 text-xs text-gray-600 shadow-none ring-0 focus:ring-0 [&>svg]:hidden`,children:e.jsxs("div",{className:"flex w-full items-center justify-between gap-x-1.5",children:[e.jsx("span",{className:"max-w-[150px] overflow-hidden truncate whitespace-nowrap font-medium leading-tight",children:(u==null?void 0:u.name)||a("All")}),e.jsx(d.ListFilter,{className:`${l!=="all"?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground hover:bg-blue-300`})]})}),e.jsxs(s.SelectContent,{children:[e.jsx("div",{className:"sticky top-0 z-10 bg-white pb-2",children:e.jsxs("div",{className:"relative",children:[e.jsx(d.Search,{strokeWidth:2,className:"absolute left-2 top-2.5 h-3.5 w-3.5 text-gray-400"}),e.jsx(s.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:n,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(s.SelectItem,{value:"all",children:a("All")}),!r.isEmpty(r.filter(c,t=>t.hasSlug&&h(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Pages")}),r.map([...r.filter(c,t=>t.hasSlug&&h(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),!r.isEmpty(r.filter(c,t=>!t.hasSlug&&h(t)))&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mt-2 border-t px-2 py-1.5 pt-2 text-xs font-semibold text-gray-500",children:a("Partials")}),r.map([...r.filter(c,t=>!t.hasSlug&&h(t))].sort((t,x)=>r.get(t,"name","").localeCompare(r.get(x,"name",""))),t=>e.jsx(s.SelectItem,{value:r.get(t,"key"),children:r.get(t,"name")},r.get(t,"key")))]}),r.isEmpty(r.filter(c,h))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},k=({search:l,setSearch:i})=>{const{t:a}=m.useTranslation();return e.jsxs("div",{className:"relative flex h-9 flex-1 items-center gap-2 rounded-md border px-2.5",children:[e.jsx("label",{htmlFor:"page-search-input",className:"sr-only",children:a("Search Pages")}),e.jsx(d.Search,{className:`${l?"fill-sky-50 text-sky-500":""} pointer-events-none h-4 w-4 text-muted-foreground`,"aria-hidden":"true"}),e.jsx(s.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:n=>i(n.target.value),className:"border-none px-1.5 shadow-none outline-none ring-0 transition-none focus:outline-none focus:ring-0 focus-visible:ring-0",autoComplete:"off"})]})},T=({pages:l})=>{const{t:i}=m.useTranslation(),{expandAll:a,collapseAll:n,expandedPages:o}=N.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(s.TooltipContent,{children:i("Expand All")})]}),e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>n(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(s.TooltipContent,{children:i("Collapse All")})]})]})},y=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const n=j.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(s.Button,{variant:i===o?"default":"outline",size:"sm",className:`h-6 flex-shrink-0 whitespace-nowrap rounded px-3 text-xs font-normal ${i===o?"bg-black text-white hover:bg-black":"text-gray-500"}`,onClick:()=>a(o.toLowerCase()),children:[o===n&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===n?"fill-white":"fill-black"}`}),j.LANGUAGES[o]||""]},o))})},v=()=>{const{t:l}=m.useTranslation(),i=w.useQueryClient();return e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[j.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},E=({pages:l,search:i,setSearch:a,languages:n,onAddPage:o,selectedLanguage:c,setSelectedLanguage:h,selectedPageType:u,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:p})=>{const{t:g}=m.useTranslation(),f=n.length>1;return e.jsxs("div",{className:"space-y-3 border-b border-b-gray-200 px-4 pb-1",children:[e.jsxs("div",{className:"flex items-center gap-x-2",children:[e.jsx(S,{selectedPageType:u,setSelectedPageType:t}),e.jsx(k,{search:i,setSearch:a}),e.jsx(T,{pages:l}),e.jsxs(s.Button,{variant:"default",onClick:o,className:"rounded px-3 font-normal",children:[e.jsx(d.Plus,{strokeWidth:2,className:"stroke-white stroke-[3]"}),e.jsx("span",{className:"font-normal text-white",children:g("Add Page")})]}),!f&&e.jsx(v,{})]}),f?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(y,{languages:n,selectedLanguage:c,setSelectedLanguage:b=>{h(b),p(x&&(n==null?void 0:n[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(n==null?void 0:n[0])!==c&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",onClick:()=>p(!x),className:"h-6 rounded px-3 py-1 text-xs font-normal",children:x?e.jsx(d.FilterXIcon,{}):e.jsx(d.Filter,{})})}),e.jsx(s.TooltipContent,{side:"bottom",children:g("Toggle Untranslated Pages")})]}),e.jsx(v,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=y;exports.default=E;
|