@chaibuilder/pages 0.15.24 → 0.16.1
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-wLnL_T-W.cjs → 2AITGKQY-CD9A6oc6.cjs} +1 -1
- package/dist/{2AITGKQY-B6ojx8vV.js → 2AITGKQY-Z1XcJ6Q7.js} +2 -2
- package/dist/{NCMVHL6D-DGH2CRR6.cjs → NCMVHL6D-CkpM-3og.cjs} +1 -1
- package/dist/{NCMVHL6D-vsNnIwmV.js → NCMVHL6D-DoK0XoIo.js} +4 -4
- package/dist/{ZDWCUMSJ-3BnFdOH2.cjs → ZDWCUMSJ-D32swpGV.cjs} +1 -1
- package/dist/{ZDWCUMSJ-CoYx1TP5.js → ZDWCUMSJ-hGXNxbOK.js} +1 -1
- package/dist/{add-new-language-page-d0-cAxlt.js → add-new-language-page-BZPoqdX-.js} +2 -2
- package/dist/{add-new-language-page-VDZSKD95.cjs → add-new-language-page-D65TpIwK.cjs} +1 -1
- package/dist/{add-new-page-D4IkZL8h.cjs → add-new-page-CQ0aj4RJ.cjs} +1 -1
- package/dist/{add-new-page-Bcoxw6U5.js → add-new-page-DK25Y0zS.js} +1 -1
- package/dist/ai-panel-content-BSGJqnTM.cjs +1 -0
- package/dist/ai-panel-content-DYRZnMgV.js +52 -0
- package/dist/ai-panel-default-lang-BOZrL5Xe.cjs +1 -0
- package/dist/ai-panel-default-lang-DZUqC79y.js +173 -0
- package/dist/ai-panel-message-bubble-Bl-aUeU4.cjs +1 -0
- package/dist/ai-panel-message-bubble-DPAaAMAZ.js +38 -0
- package/dist/ai-panel-other-lang-CCyiE6ha.js +145 -0
- package/dist/ai-panel-other-lang-CNtlT5dM.cjs +1 -0
- package/dist/ai-panel-quick-prompts-DeS7L1f0.cjs +1 -0
- package/dist/ai-panel-quick-prompts-Ds0Ndz7g.js +46 -0
- package/dist/ai-prompt-input-Ch_PLEPN.js +133 -0
- package/dist/ai-prompt-input-Zg6lN1Lo.cjs +1 -0
- package/dist/ai-translation-prompt-BUFjo_om.cjs +1 -0
- package/dist/ai-translation-prompt-BiJ5B_an.js +28 -0
- package/dist/{delete-page-KS6p6b8f.js → delete-page-B95T2Prd.js} +1 -1
- package/dist/{delete-page-DeKAD4Ld.cjs → delete-page-BSop1jNg.cjs} +1 -1
- package/dist/{digital-asset-manager-Dfe9SS09.js → digital-asset-manager-BQNSwfKs.js} +1 -1
- package/dist/{digital-asset-manager-C9gYL2SF.cjs → digital-asset-manager-Bn58WzM6.cjs} +1 -1
- package/dist/{duplicate-page-CKr-HNs-.cjs → duplicate-page-BLxkSiug.cjs} +1 -1
- package/dist/{duplicate-page-vCgYnw4H.js → duplicate-page-CrzzObAj.js} +9 -9
- package/dist/{dynamic-page-selector-A4fqWqZZ.js → dynamic-page-selector-D6wQnNfH.js} +1 -1
- package/dist/{dynamic-page-selector-C7w3TOdK.cjs → dynamic-page-selector-D8UZ63LW.cjs} +1 -1
- package/dist/index-W0r4o5Ro.cjs +5 -0
- package/dist/{index-NSqs69Op.js → index-yhKyIbgs.js} +1035 -1031
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +7 -7
- package/dist/{json-diff-viewer-7TGemUrn.js → json-diff-viewer-ISJS7lHK.js} +1 -1
- package/dist/{json-diff-viewer-nLLX6kJK.cjs → json-diff-viewer-ZeJ3Rp2y.cjs} +1 -1
- package/dist/{lang-panel-C6KxjKn_.js → lang-panel-Bj11IL7k.js} +33 -33
- package/dist/{lang-panel-dc9uBMtE.cjs → lang-panel-DqN_J3vz.cjs} +1 -1
- package/dist/{mark-as-template-CJ9SiEBl.cjs → mark-as-template-CcwAAdrd.cjs} +1 -1
- package/dist/{mark-as-template-CRUOQ_FZ.js → mark-as-template-CmCCMaQg.js} +1 -1
- package/dist/{no-language-page-content--8a37nsW.cjs → no-language-page-content-BXm1k1Aa.cjs} +1 -1
- package/dist/{no-language-page-content-ByHFQjkV.js → no-language-page-content-Cme-zo4R.js} +1 -1
- package/dist/{page-creator-CzUQicdh.cjs → page-creator-ByhjXyHP.cjs} +1 -1
- package/dist/{page-creator-J_CNgdj5.js → page-creator-Zbv4d4H8.js} +2 -2
- package/dist/{page-lock-request-BE9-Oego.cjs → page-lock-request-Cln-EE6Z.cjs} +1 -1
- package/dist/{page-lock-request-CD93n5pq.js → page-lock-request-DDQJb8IA.js} +10 -10
- package/dist/{page-locked-by-dialog-1Lm9dcT6.cjs → page-locked-by-dialog-BIXYITEu.cjs} +1 -1
- package/dist/{page-locked-by-dialog-noDLCQWF.js → page-locked-by-dialog-Csn56a3n.js} +1 -1
- package/dist/{page-manager-new-BoTBCqZF.cjs → page-manager-new-BJaTBpih.cjs} +1 -1
- package/dist/{page-manager-new-D-U4B9y9.js → page-manager-new-BrRxZDfT.js} +67 -67
- package/dist/{page-manager-search-and-filter-BJmETYq-.cjs → page-manager-search-and-filter-Bk3PUjha.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-h-YzJVcH.js → page-manager-search-and-filter-_Hvk3bU3.js} +1 -1
- package/dist/{page-revisions-content-C7DXjFls.js → page-revisions-content-B6fRCBX_.js} +10 -10
- package/dist/{page-revisions-content-BNBb2qYh.cjs → page-revisions-content-C_Ha3tFu.cjs} +1 -1
- package/dist/prompt-helper-Csgu8Rfb.js +187 -0
- package/dist/prompt-helper-DgI1lgGV.cjs +51 -0
- package/dist/{publish-pages-content-DAKh_sSW.js → publish-pages-content-CFEIxKQD.js} +2 -2
- package/dist/{publish-pages-content-DsOVOiBD.cjs → publish-pages-content-DQDNxwHD.cjs} +1 -1
- package/dist/{save-to-lib-BR1Qhw3Q.cjs → save-to-lib-Bl22umTa.cjs} +1 -1
- package/dist/{save-to-lib-BPR_--qN.js → save-to-lib-YyYkF6c6.js} +1 -1
- package/dist/{seo-panel-C7XC-XRg.js → seo-panel-BZlMea1L.js} +1 -1
- package/dist/{seo-panel-CUqtdGoF.cjs → seo-panel-BhxikAkG.cjs} +1 -1
- package/dist/server.cjs +241 -1
- package/dist/server.d.ts +50 -6
- package/dist/server.js +10327 -290
- package/dist/{shared-json-ld-CDffP4G3.cjs → shared-json-ld-BfkH76U3.cjs} +1 -1
- package/dist/{shared-json-ld-0JD8sokD.js → shared-json-ld-E4Ckwlbr.js} +41 -41
- package/dist/{slug-input-BYH90lv1.cjs → slug-input--VmQG0S1.cjs} +1 -1
- package/dist/{slug-input-CvIDihGn.js → slug-input-CKKkqGj4.js} +1 -1
- package/dist/{theme-panel-footer-DPpLzCDu.js → theme-panel-footer-2ERfMsET.js} +1 -1
- package/dist/{theme-panel-footer-CUSfduTK.cjs → theme-panel-footer-CagxEZEO.cjs} +1 -1
- package/dist/{unmark-as-template-CjqRfFDL.js → unmark-as-template-BJ5CTNAe.js} +1 -1
- package/dist/{unmark-as-template-Bxw4t_Xi.cjs → unmark-as-template-CeWpo9wD.cjs} +1 -1
- package/dist/{unpublish-page-BjiB3d7l.cjs → unpublish-page-DmZSVxFj.cjs} +1 -1
- package/dist/{unpublish-page-CKKU1St1.js → unpublish-page-DvOWVBIf.js} +1 -1
- package/dist/{web-preview-D0OpieXz.js → web-preview-DTkIggV7.js} +1 -1
- package/dist/{web-preview-CNMYCWxW.cjs → web-preview-DlSKpPUZ.cjs} +1 -1
- package/package.json +3 -3
- package/dist/ai-panel-content-Cn3SA_Sr.cjs +0 -46
- package/dist/ai-panel-content-qmOJKjkE.js +0 -524
- package/dist/index-LfuCMBwI.cjs +0 -5
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as e, jsxs as r, Fragment as o } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { ak as w, al as T, B as m } from "./index-yhKyIbgs.js";
|
|
3
3
|
import { useTranslation as x } from "@chaibuilder/sdk";
|
|
4
4
|
import { Card as b, CardHeader as v, CardTitle as y, CardContent as B, CardFooter as q, Button as u } from "@chaibuilder/sdk/ui";
|
|
5
|
-
import { Loader as f, TableIcon as _, CheckCircle as
|
|
6
|
-
import { useState as
|
|
7
|
-
const
|
|
5
|
+
import { Loader as f, TableIcon as _, CheckCircle as A, Target as I, Edit as g, Check as O, X as j } from "lucide-react";
|
|
6
|
+
import { useState as k, useEffect as E } from "react";
|
|
7
|
+
const R = ({ userId: c }) => {
|
|
8
8
|
const { data: n } = w(c);
|
|
9
9
|
return (n == null ? void 0 : n.name) || "Unknown";
|
|
10
10
|
}, X = ({
|
|
@@ -12,16 +12,16 @@ const k = ({ userId: c }) => {
|
|
|
12
12
|
lockingStatus: n,
|
|
13
13
|
onContinue: p
|
|
14
14
|
}) => {
|
|
15
|
-
const { t } = x(), [d, h] =
|
|
15
|
+
const { t } = x(), [d, h] = k(!1), i = n === "page_is_active_in_other_tab", s = (n == null ? void 0 : n.length) > 0, { pageLock: a, acceptTakeOver: l, rejectTakeOver: C } = T(), N = () => {
|
|
16
16
|
h(!0), s || i ? p() : l(), setTimeout(() => {
|
|
17
17
|
h(!1);
|
|
18
18
|
}, 3e3);
|
|
19
19
|
};
|
|
20
|
-
return
|
|
20
|
+
return E(() => {
|
|
21
21
|
(a == null ? void 0 : a.requestedBy) === "ANOTHER_TAB" && l();
|
|
22
22
|
}, [a, l]), (a == null ? void 0 : a.requestedBy) === "ANOTHER_TAB" ? null : c ? /* @__PURE__ */ e(m, { children: /* @__PURE__ */ e(f, { className: "h-5 w-5 animate-spin text-primary" }) }) : /* @__PURE__ */ e(m, { children: /* @__PURE__ */ r(b, { className: "mx-auto w-full max-w-md", children: [
|
|
23
23
|
/* @__PURE__ */ e(v, { className: "space-y-1", children: /* @__PURE__ */ r(y, { className: "flex items-center gap-2 text-xl font-medium", children: [
|
|
24
|
-
d ? /* @__PURE__ */ e(f, { className: "h-6 w-6 animate-spin text-gray-500" }) : i ? /* @__PURE__ */ e(_, { className: "h-6 w-6 text-green-500" }) : s ? /* @__PURE__ */ e(
|
|
24
|
+
d ? /* @__PURE__ */ e(f, { className: "h-6 w-6 animate-spin text-gray-500" }) : i ? /* @__PURE__ */ e(_, { className: "h-6 w-6 text-green-500" }) : s ? /* @__PURE__ */ e(A, { className: "h-6 w-6 text-green-500" }) : /* @__PURE__ */ e(I, { className: "h-6 w-6 text-green-500" }),
|
|
25
25
|
t(i ? "Page is active in other tab" : s ? "You can edit the page now." : "Page take over request")
|
|
26
26
|
] }) }),
|
|
27
27
|
/* @__PURE__ */ e(B, { className: "grid gap-4", children: /* @__PURE__ */ e("div", { children: i ? /* @__PURE__ */ r("p", { children: [
|
|
@@ -32,7 +32,7 @@ const k = ({ userId: c }) => {
|
|
|
32
32
|
] }) : s ? /* @__PURE__ */ e("p", { children: t("This page is released by other user you can continue editing now.") }) : /* @__PURE__ */ r("p", { children: [
|
|
33
33
|
/* @__PURE__ */ r("b", { children: [
|
|
34
34
|
" ",
|
|
35
|
-
/* @__PURE__ */ e(
|
|
35
|
+
/* @__PURE__ */ e(R, { userId: a == null ? void 0 : a.requestedBy })
|
|
36
36
|
] }),
|
|
37
37
|
" ",
|
|
38
38
|
t("has requested to take over this page."),
|
|
@@ -56,14 +56,14 @@ const k = ({ userId: c }) => {
|
|
|
56
56
|
" ",
|
|
57
57
|
t("Continue to edit")
|
|
58
58
|
] }) : /* @__PURE__ */ r(o, { children: [
|
|
59
|
-
/* @__PURE__ */ e(
|
|
59
|
+
/* @__PURE__ */ e(O, { className: "h-5 w-5" }),
|
|
60
60
|
" ",
|
|
61
61
|
t("Accept")
|
|
62
62
|
] })
|
|
63
63
|
}
|
|
64
64
|
),
|
|
65
65
|
!s && /* @__PURE__ */ r(u, { variant: "outline", onClick: C, children: [
|
|
66
|
-
/* @__PURE__ */ e(
|
|
66
|
+
/* @__PURE__ */ e(j, { className: "h-5 w-5" }),
|
|
67
67
|
" ",
|
|
68
68
|
t("Reject")
|
|
69
69
|
] })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),j=require("date-fns"),a=require("lucide-react"),p=require("react"),f=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),j=require("date-fns"),a=require("lucide-react"),p=require("react"),f=require("./index-W0r4o5Ro.cjs");function g({avatar:l,name:d,email:n,lastSaved:c,onTakeOver:x,isRequestRejected:i,isFetchingUserInfo:r}){const{t:s}=h.useTranslation(),[o,u]=p.useState(!1),m=()=>{u(!0),setTimeout(()=>{u(!1)},15e3),x()};return e.jsx(f.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(a.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),s("Page is locked for editing")]})}),e.jsx(t.CardContent,{className:"w-md grid w-full pt-2",children:e.jsxs("div",{children:[e.jsxs("div",{className:"relative mx-auto flex w-96 items-center space-x-4 rounded-md border border-green-500 px-2 pb-2 pt-4",children:[e.jsx("div",{className:"absolute -top-2.5 left-3 w-max rounded-full bg-green-500 px-3 py-1 text-xs font-medium leading-3 text-white",children:s("Locked By")}),l&&!r?e.jsx("img",{src:l,alt:d,className:"h-14 w-14 rounded-full border border-gray-300"}):e.jsx(a.UserIcon,{className:"h-14 w-14 flex-shrink-0 rounded-full bg-gradient-to-br from-purple-400 to-pink-500 p-2 text-white"}),e.jsxs("div",{className:r?"space-y-1.5":"space-y-0",children:[r?e.jsx(t.Skeleton,{className:"h-4 w-40 rounded"}):e.jsx("span",{className:"truncate font-medium text-black",children:d}),n&&!r?e.jsx("p",{className:"truncate text-sm text-muted-foreground",children:n}):e.jsx(t.Skeleton,{className:"h-4 w-60 rounded"}),c&&!r?e.jsxs("p",{className:"text-sm text-muted-foreground",children:[s("Last saved"),":"," ",j.formatDistanceToNow(new Date(c),{addSuffix:!0})]}):e.jsx(t.Skeleton,{className:"h-4 w-40 rounded"})]})]}),e.jsx("div",{className:"mt-4 text-sm",children:e.jsxs("p",{className:"py-4 text-center text-gray-600",children:[s("This page is currently being edited by")," ",e.jsx("span",{className:"font-bold",children:d}),".",e.jsx("br",{}),e.jsx("br",{})," ",s("You can either wait until they finish editing or request to take over the page.")]})}),i&&e.jsxs("div",{className:"mt-4 flex w-full items-center justify-center gap-x-2 rounded border border-red-500 bg-red-50 p-2 text-center font-medium text-red-500",children:[e.jsx(a.Info,{className:"h-5 w-5"})," ",s("Page take over request is rejected")]})]})}),e.jsx(t.CardFooter,{children:e.jsxs(t.Button,{disabled:o,onClick:m,className:"w-full",variant:"destructive",children:[e.jsx(a.KeyIcon,{className:"h-5 w-5"}),s(o?"Page take is requested.":i?"Request take over again":"Request take over")]})})]})})}exports.default=g;
|
|
@@ -4,7 +4,7 @@ import { Card as x, CardHeader as h, CardTitle as N, CardContent as g, Skeleton
|
|
|
4
4
|
import { formatDistanceToNow as k } from "date-fns";
|
|
5
5
|
import { LockKeyhole as y, UserIcon as v, Info as C, KeyIcon as T } from "lucide-react";
|
|
6
6
|
import { useState as B } from "react";
|
|
7
|
-
import { B as D } from "./index-
|
|
7
|
+
import { B as D } from "./index-yhKyIbgs.js";
|
|
8
8
|
function O({
|
|
9
9
|
avatar: l,
|
|
10
10
|
name: s,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),x=require("./index-LfuCMBwI.cjs"),G=require("./use-page-expand-manager-2KjeYfVS.cjs"),n=require("lodash-es"),B=require("@chaibuilder/sdk"),te=require("jotai"),v=require("lucide-react"),l=require("react"),J=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const t=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),t)||n.includes(n.toLower((a==null?void 0:a.slug)||""),t)})),ne=(e,r)=>{const a=new Set,t=n.keyBy(e,"id");return r.forEach(c=>{let o=c;for(;o.parent&&t[o.parent];)a.add(o.parent),o=t[o.parent]}),Array.from(a).map(c=>t[c])},I=(e,r,a)=>n.isEmpty(r)?e:e.map(t=>{if(!a(t.pageType))return{...t,shouldExpandOnSearch:!0,children:t.children?I(t.children,r,a):[]};const c=t.children&&t.children.some(o=>n.includes(n.toLower(o.name||""),n.toLower(r))||n.includes(n.toLower(o.slug||""),n.toLower(r)));return{...t,shouldExpandOnSearch:c,children:t.children?I(t.children,r,a):[]}}),re=e=>{if(!e||!e.length)return[];const r={};e.forEach(t=>{r[t.id]={...t,children:[]}});const a=[];return Object.values(r).forEach(t=>{t.parent&&r[t.parent]?r[t.parent].children.push(t):a.push(t)}),a},K=e=>!e||!e.length?[]:[...e].sort((a,t)=>(a.name||"").localeCompare(t.name||"")).map(a=>({...a,children:a.children?K(a.children):[]})),ae=(e,r,a,t)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=J(c,r);else{const h=J(c,r),d=ne(e,h);c=n.uniqBy([...h,...d],"id")}const o=K(re(c)),y=I(o,r,t),S=n.filter(y,h=>t(h.pageType)).sort((h,d)=>(h.name||"").localeCompare(d.name||"")),p=n.filter(y,h=>!t(h.pageType));let f=[];if(a==="all"){const h=n.keyBy(p,"pageType");f=Object.values(n.mapValues(h,(d,j)=>({...d,id:j,name:n.startCase(j),isPartialGroup:!0,children:y.filter(b=>b.pageType===j)})))}else f=p.sort((h,d)=>(h.name||"").localeCompare(d.name||""));return[...S,...f]},le=({page:e})=>{var t,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return s.jsx("button",{onClick:o=>{o.stopPropagation(),a()},disabled:!((t=e==null?void 0:e.children)!=null&&t.length),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 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:s.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},ie=({page:e,pageType:r})=>s.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?s.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?s.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?s.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):s.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),oe=({isOnline:e})=>s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ce=({page:e,pageTypes:r,currentPage:a,onClickAction:t,languagePages:c,selectedLanguage:o,showUntranslatedPages:y})=>{const[S]=x.usePageUserMapping(),p=x.useFallbackLang(),f=a===e.id,h=!!e.isTemplate,d=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]),j=S==null?void 0:S[e.id],{data:b}=x.useChaiUserInfo(j),w=b?b==null?void 0:b.name:null;let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===o?m:null;const E=o===p||!!m,L=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let g=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const C=g+(e!=null&&e.dynamic?`/${d==null?void 0:d.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(g.startsWith("/")&&!y){const u=g.split("/").pop();g=g.endsWith(u)&&e.dynamic?"":`/${u}`}const q=l.useMemo(()=>{const u="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]",M=`${f?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${u} ${M} ${w?"opacity-60":""}`:`${u} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,f,w]);return s.jsxs("div",{className:"group relative",children:[s.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&t("select",e==null?void 0:e.id),className:q,children:[s.jsx(le,{page:e}),!e.isPartialGroup&&s.jsx(oe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&s.jsx(ie,{page:e,pageType:d}),s.jsx(x.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:s.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(g||e.dynamic)&&s.jsx(x.Tooltip,{content:C,side:"top",showTooltip:!0,children:s.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[g,e.dynamic&&(d==null?void 0:d.dynamicSlug)&&s.jsxs("span",{className:"text-xs text-gray-500",children:["/",d==null?void 0:d.dynamicSlug,e.dynamicSlugCustom]})]})}),h&&s.jsx(x.Tooltip,{content:"Template",side:"top",children:s.jsx("span",{className:"text-blue-500",children:s.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!w?s.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:s.jsx(x.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:u=>t("duplicate",u),setAddEditPage:u=>t("edit",m||u),setUnpublishPage:u=>t("unpublish",u),setDeletePage:u=>t("delete",m||u),setMarkAsTemplate:u=>t("markAsTemplate",u),setUnmarkAsTemplate:u=>t("unmarkAsTemplate",u),children:s.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:s.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:u=>u.stopPropagation()})})})}):w?s.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:s.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]}),s.jsx(s.Fragment,{children:w&&s.jsxs("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:[s.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",s.jsx("span",{className:"font-medium",children:w})," is editing this page"]})}),s.jsx(s.Fragment,{children:!E&&!e.isPartialGroup&&!w&&s.jsxs("button",{onClick:u=>{u.stopPropagation(),t("addLanguagePage",{language:o,page:e})},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",children:[s.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",s.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(x.LANGUAGES,o)," Page"]})]})})]})},X=({pages:e,tier:r,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S})=>{const{expandedPages:p}=G.usePageExpandManager();return s.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(f=>s.jsxs(s.Fragment,{children:[s.jsx(ce,{page:f,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S}),f.children&&f.children.length>0&&(p==null?void 0:p.includes(f.id))&&s.jsx(X,{pages:f.children,tier:r+1,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S})]},f.id))})},de=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-BJmETYq-.cjs"))),ue=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-D4IkZL8h.cjs"))),me=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DeKAD4Ld.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CKr-HNs-.cjs"))),xe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CJ9SiEBl.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-Bxw4t_Xi.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BjiB3d7l.cjs"))),ye=({close:e})=>{const{t:r}=B.useTranslation(),{languages:a,setSelectedLang:t}=B.useLanguages(),{data:c}=x.usePageTypes(),{data:o,isFetching:y}=x.useWebsitePages(),[S,p]=x.useSearchParams(),{updateForSelectedPage:f,expandPagesOnSearch:h}=G.usePageExpandManager(null),d=x.useFallbackLang(),j=S.get("page"),[b,w]=l.useState(""),[m,E]=l.useState(null),[L,g]=l.useState(null),[C,q]=l.useState(null),[u,M]=l.useState(null),[T,U]=l.useState(""),[O,R]=l.useState(null),[D,W]=l.useState(null),[k,Y]=l.useState(d),[Z,ee]=l.useState(!1),[,H]=te.useAtom(x.addNewLangAtom),z=Z&&k!==d,{data:A,isFetching:se}=x.useWebsiteLanguagePages(k),_=l.useCallback(P=>{var i;return(i=n.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?z?n.filter(o,P=>!(A!=null&&A[P.id])):ae(o,b,T,_):[],[o,_,b,T,A,z]);l.useEffect(()=>{t(d)},[d,t]),l.useEffect(()=>{if(!n.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&P&&(n.find(c,{key:P})?U(P):U("all"))},[c,T]),l.useEffect(()=>{if(j&&!y&&!n.find(o,{id:j})){const i=n.find(o,{slug:"/"});if(i){const F=new URLSearchParams({page:i.id});x.navigateToPage(F,p)}else x.navigateToPage(new URLSearchParams({}),p,!0)}},[o,j,y,p]),l.useEffect(()=>{j&&!y&&!n.isEmpty(N)&&f(N,j)},[j,y,N,f]),l.useEffect(()=>{!n.isEmpty(b)&&!n.isEmpty(N)&&h(N)},[b,N,h]);const{setSelectedLang:$}=B.useLanguages(),Q=l.useCallback(P=>{const i=new URLSearchParams({page:P});k!==d?(i.set("lang",k),$(k)):$(""),x.navigateToPage(i,p),e()},[e,p,$,k,d]),V=(P,i)=>{var F;if(i)switch(P){case"add":g(i);break;case"select":Q(i);break;case"edit":k!==d?H({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):g(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":M(i);break;case"unmarkAsTemplate":W(i);break;case"duplicate":R(i);break;case"addLanguagePage":H({edit:!1,primaryPage:((F=i==null?void 0:i.page)==null?void 0:F.id)||"",preselectedLang:(i==null?void 0:i.language)||k});break}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(l.Suspense,{children:s.jsx(de,{pages:N,search:b,setSearch:w,languages:[d,...a],selectedLanguage:k,setSelectedLanguage:Y,selectedPageType:T,setSelectedPageType:U,onAddPage:P=>V("add",P),showUntranslatedPages:z,setShowUntranslatedPages:ee})}),s.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||se?s.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],P=>s.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):n.isEmpty(N)?s.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[s.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),s.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):s.jsx(X,{tier:0,pages:N,pageTypes:c,currentPage:j||"",onClickAction:V,languagePages:A,selectedLanguage:k,showUntranslatedPages:z})})]}),L&&s.jsx(l.Suspense,{children:s.jsx(ue,{closePanel:e,editPage:Q,addEditPage:L,setAddEditPage:g})}),m&&s.jsx(l.Suspense,{children:s.jsx(me,{page:m,onClose:()=>E(null)})}),C&&s.jsx(l.Suspense,{children:s.jsx(Pe,{page:C,onClose:()=>q(null)})}),u&&s.jsx(l.Suspense,{children:s.jsx(xe,{page:u,onClose:()=>M(null)})}),D&&s.jsx(l.Suspense,{children:s.jsx(fe,{page:D,onClose:()=>W(null)})}),O&&s.jsx(l.Suspense,{children:s.jsx(he,{page:O,onClose:()=>R(null),closePanel:e})})]})};exports.default=ye;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),x=require("./index-W0r4o5Ro.cjs"),G=require("./use-page-expand-manager-2KjeYfVS.cjs"),n=require("lodash-es"),B=require("@chaibuilder/sdk"),te=require("jotai"),v=require("lucide-react"),l=require("react"),J=(e,r)=>!e||!Array.isArray(e)?[]:n.isEmpty(r)?e:n.compact(n.filter(e,a=>{const t=n.toLower(r);return n.includes(n.toLower((a==null?void 0:a.name)||""),t)||n.includes(n.toLower((a==null?void 0:a.slug)||""),t)})),ne=(e,r)=>{const a=new Set,t=n.keyBy(e,"id");return r.forEach(c=>{let o=c;for(;o.parent&&t[o.parent];)a.add(o.parent),o=t[o.parent]}),Array.from(a).map(c=>t[c])},I=(e,r,a)=>n.isEmpty(r)?e:e.map(t=>{if(!a(t.pageType))return{...t,shouldExpandOnSearch:!0,children:t.children?I(t.children,r,a):[]};const c=t.children&&t.children.some(o=>n.includes(n.toLower(o.name||""),n.toLower(r))||n.includes(n.toLower(o.slug||""),n.toLower(r)));return{...t,shouldExpandOnSearch:c,children:t.children?I(t.children,r,a):[]}}),re=e=>{if(!e||!e.length)return[];const r={};e.forEach(t=>{r[t.id]={...t,children:[]}});const a=[];return Object.values(r).forEach(t=>{t.parent&&r[t.parent]?r[t.parent].children.push(t):a.push(t)}),a},K=e=>!e||!e.length?[]:[...e].sort((a,t)=>(a.name||"").localeCompare(t.name||"")).map(a=>({...a,children:a.children?K(a.children):[]})),ae=(e,r,a,t)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=n.compact(n.filter(e,{pageType:a}))),n.isEmpty(r))c=J(c,r);else{const h=J(c,r),d=ne(e,h);c=n.uniqBy([...h,...d],"id")}const o=K(re(c)),y=I(o,r,t),S=n.filter(y,h=>t(h.pageType)).sort((h,d)=>(h.name||"").localeCompare(d.name||"")),p=n.filter(y,h=>!t(h.pageType));let f=[];if(a==="all"){const h=n.keyBy(p,"pageType");f=Object.values(n.mapValues(h,(d,j)=>({...d,id:j,name:n.startCase(j),isPartialGroup:!0,children:y.filter(b=>b.pageType===j)})))}else f=p.sort((h,d)=>(h.name||"").localeCompare(d.name||""));return[...S,...f]},le=({page:e})=>{var t,c;const{isExpanded:r,toggleExpanded:a}=G.usePageExpandManager(e==null?void 0:e.id);return s.jsx("button",{onClick:o=>{o.stopPropagation(),a()},disabled:!((t=e==null?void 0:e.children)!=null&&t.length),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 ${(c=e==null?void 0:e.children)!=null&&c.length?"hover:text-blue-400":"opacity-0"}`,children:s.jsx(v.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${r?"rotate-90":""}`})})},ie=({page:e,pageType:r})=>s.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?s.jsx(v.StarsIcon,{size:12,className:"text-yellow-400"}):r!=null&&r.icon?s.jsx("div",{className:"flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",dangerouslySetInnerHTML:{__html:r.icon}}):r!=null&&r.hasSlug?s.jsx(v.File,{size:12,className:"stroke-[1] text-slate-500"}):s.jsx(v.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),oe=({isOnline:e})=>s.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),ce=({page:e,pageTypes:r,currentPage:a,onClickAction:t,languagePages:c,selectedLanguage:o,showUntranslatedPages:y})=>{const[S]=x.usePageUserMapping(),p=x.useFallbackLang(),f=a===e.id,h=!!e.isTemplate,d=l.useMemo(()=>n.find(r,{key:e.pageType}),[r,e.pageType]),j=S==null?void 0:S[e.id],{data:b}=x.useChaiUserInfo(j),w=b?b==null?void 0:b.name:null;let m=n.get(c,e==null?void 0:e.id);m=n.get(m,"lang")===o?m:null;const E=o===p||!!m,L=(m==null?void 0:m.name)||(e==null?void 0:e.name)||"No name";let g=(m==null?void 0:m.slug)||(e==null?void 0:e.slug)||"";const C=g+(e!=null&&e.dynamic?`/${d==null?void 0:d.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(g.startsWith("/")&&!y){const u=g.split("/").pop();g=g.endsWith(u)&&e.dynamic?"":`/${u}`}const q=l.useMemo(()=>{const u="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]",M=`${f?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${u} ${M} ${w?"opacity-60":""}`:`${u} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,f,w]);return s.jsxs("div",{className:"group relative",children:[s.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&t("select",e==null?void 0:e.id),className:q,children:[s.jsx(le,{page:e}),!e.isPartialGroup&&s.jsx(oe,{isOnline:m?m.online:e.online}),!e.isPartialGroup&&s.jsx(ie,{page:e,pageType:d}),s.jsx(x.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:s.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(g||e.dynamic)&&s.jsx(x.Tooltip,{content:C,side:"top",showTooltip:!0,children:s.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[g,e.dynamic&&(d==null?void 0:d.dynamicSlug)&&s.jsxs("span",{className:"text-xs text-gray-500",children:["/",d==null?void 0:d.dynamicSlug,e.dynamicSlugCustom]})]})}),h&&s.jsx(x.Tooltip,{content:"Template",side:"top",children:s.jsx("span",{className:"text-blue-500",children:s.jsx(v.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!w?s.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:s.jsx(x.PageActionsDropdown,{isLanguagePage:!!m,page:m||e,setDuplicatePage:u=>t("duplicate",u),setAddEditPage:u=>t("edit",m||u),setUnpublishPage:u=>t("unpublish",u),setDeletePage:u=>t("delete",m||u),setMarkAsTemplate:u=>t("markAsTemplate",u),setUnmarkAsTemplate:u=>t("unmarkAsTemplate",u),children:s.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:s.jsx(v.MoreHorizontal,{className:"h-4 w-4",onClick:u=>u.stopPropagation()})})})}):w?s.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:s.jsx(v.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]}),s.jsx(s.Fragment,{children:w&&s.jsxs("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:[s.jsx(v.Edit,{size:12,className:"stroke-[3]"})," ",s.jsx("span",{className:"font-medium",children:w})," is editing this page"]})}),s.jsx(s.Fragment,{children:!E&&!e.isPartialGroup&&!w&&s.jsxs("button",{onClick:u=>{u.stopPropagation(),t("addLanguagePage",{language:o,page:e})},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",children:[s.jsx(v.Plus,{size:12,className:"stroke-[3]"})," ",s.jsxs("span",{className:"text-[10px]",children:["Add ",n.get(x.LANGUAGES,o)," Page"]})]})})]})},X=({pages:e,tier:r,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S})=>{const{expandedPages:p}=G.usePageExpandManager();return s.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${r*10}px`},children:e.map(f=>s.jsxs(s.Fragment,{children:[s.jsx(ce,{page:f,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S}),f.children&&f.children.length>0&&(p==null?void 0:p.includes(f.id))&&s.jsx(X,{pages:f.children,tier:r+1,pageTypes:a,currentPage:t,onClickAction:c,languagePages:o,selectedLanguage:y,showUntranslatedPages:S})]},f.id))})},de=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-Bk3PUjha.cjs"))),ue=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-CQ0aj4RJ.cjs"))),me=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-BSop1jNg.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-BLxkSiug.cjs"))),xe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CcwAAdrd.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-CeWpo9wD.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-DmZSVxFj.cjs"))),ye=({close:e})=>{const{t:r}=B.useTranslation(),{languages:a,setSelectedLang:t}=B.useLanguages(),{data:c}=x.usePageTypes(),{data:o,isFetching:y}=x.useWebsitePages(),[S,p]=x.useSearchParams(),{updateForSelectedPage:f,expandPagesOnSearch:h}=G.usePageExpandManager(null),d=x.useFallbackLang(),j=S.get("page"),[b,w]=l.useState(""),[m,E]=l.useState(null),[L,g]=l.useState(null),[C,q]=l.useState(null),[u,M]=l.useState(null),[T,U]=l.useState(""),[O,R]=l.useState(null),[D,W]=l.useState(null),[k,Y]=l.useState(d),[Z,ee]=l.useState(!1),[,H]=te.useAtom(x.addNewLangAtom),z=Z&&k!==d,{data:A,isFetching:se}=x.useWebsiteLanguagePages(k),_=l.useCallback(P=>{var i;return(i=n.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?z?n.filter(o,P=>!(A!=null&&A[P.id])):ae(o,b,T,_):[],[o,_,b,T,A,z]);l.useEffect(()=>{t(d)},[d,t]),l.useEffect(()=>{if(!n.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!n.isEmpty(c)&&P&&(n.find(c,{key:P})?U(P):U("all"))},[c,T]),l.useEffect(()=>{if(j&&!y&&!n.find(o,{id:j})){const i=n.find(o,{slug:"/"});if(i){const F=new URLSearchParams({page:i.id});x.navigateToPage(F,p)}else x.navigateToPage(new URLSearchParams({}),p,!0)}},[o,j,y,p]),l.useEffect(()=>{j&&!y&&!n.isEmpty(N)&&f(N,j)},[j,y,N,f]),l.useEffect(()=>{!n.isEmpty(b)&&!n.isEmpty(N)&&h(N)},[b,N,h]);const{setSelectedLang:$}=B.useLanguages(),Q=l.useCallback(P=>{const i=new URLSearchParams({page:P});k!==d?(i.set("lang",k),$(k)):$(""),x.navigateToPage(i,p),e()},[e,p,$,k,d]),V=(P,i)=>{var F;if(i)switch(P){case"add":g(i);break;case"select":Q(i);break;case"edit":k!==d?H({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):g(i);break;case"delete":E(i);break;case"unpublish":q(i);break;case"markAsTemplate":M(i);break;case"unmarkAsTemplate":W(i);break;case"duplicate":R(i);break;case"addLanguagePage":H({edit:!1,primaryPage:((F=i==null?void 0:i.page)==null?void 0:F.id)||"",preselectedLang:(i==null?void 0:i.language)||k});break}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex h-full flex-col justify-between",children:[s.jsx(l.Suspense,{children:s.jsx(de,{pages:N,search:b,setSearch:w,languages:[d,...a],selectedLanguage:k,setSelectedLanguage:Y,selectedPageType:T,setSelectedPageType:U,onAddPage:P=>V("add",P),showUntranslatedPages:z,setShowUntranslatedPages:ee})}),s.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:y||se?s.jsx("div",{className:"space-y-2",children:n.map([...Array(15).keys()],P=>s.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):n.isEmpty(N)?s.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[s.jsx(v.File,{className:"h-6 w-6 stroke-[1]"}),r("Empty List!"),s.jsx("span",{className:"font-light",children:r("Add new page to start")})]}):s.jsx(X,{tier:0,pages:N,pageTypes:c,currentPage:j||"",onClickAction:V,languagePages:A,selectedLanguage:k,showUntranslatedPages:z})})]}),L&&s.jsx(l.Suspense,{children:s.jsx(ue,{closePanel:e,editPage:Q,addEditPage:L,setAddEditPage:g})}),m&&s.jsx(l.Suspense,{children:s.jsx(me,{page:m,onClose:()=>E(null)})}),C&&s.jsx(l.Suspense,{children:s.jsx(Pe,{page:C,onClose:()=>q(null)})}),u&&s.jsx(l.Suspense,{children:s.jsx(xe,{page:u,onClose:()=>M(null)})}),D&&s.jsx(l.Suspense,{children:s.jsx(fe,{page:D,onClose:()=>W(null)})}),O&&s.jsx(l.Suspense,{children:s.jsx(he,{page:O,onClose:()=>R(null),closePanel:e})})]})};exports.default=ye;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { jsxs as y, jsx as t, Fragment as
|
|
2
|
-
import {
|
|
1
|
+
import { jsxs as y, jsx as t, Fragment as D } from "react/jsx-runtime";
|
|
2
|
+
import { av as be, f as ie, ak as ye, T as H, aE as ge, L as ke, h as Ne, b as ve, i as we, aq as Se, aF as Ae, aG as _ } from "./index-yhKyIbgs.js";
|
|
3
3
|
import { u as K } from "./use-page-expand-manager-D6T75I11.js";
|
|
4
|
-
import { compact as ce, filter as
|
|
4
|
+
import { compact as ce, filter as z, isEmpty as S, uniqBy as Le, keyBy as de, mapValues as Te, startCase as Ee, toLower as T, includes as R, find as M, get as Q, map as Ce } from "lodash-es";
|
|
5
5
|
import { useTranslation as Ue, useLanguages as ae } from "@chaibuilder/sdk";
|
|
6
6
|
import { useAtom as $e } from "jotai";
|
|
7
|
-
import { NotepadText as
|
|
8
|
-
import { useMemo as V, lazy as
|
|
7
|
+
import { NotepadText as Fe, MoreHorizontal as Me, Lock as ze, Edit as je, Plus as Be, ChevronRight as Ge, StarsIcon as Ie, Hash as Oe, File as ue } from "lucide-react";
|
|
8
|
+
import { useMemo as V, lazy as E, useState as N, useCallback as le, useEffect as F, Suspense as L } from "react";
|
|
9
9
|
const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
10
|
-
|
|
10
|
+
z(e, (r) => {
|
|
11
11
|
const s = T(n);
|
|
12
12
|
return R(T((r == null ? void 0 : r.name) || ""), s) || R(T((r == null ? void 0 : r.slug) || ""), s);
|
|
13
13
|
})
|
|
14
|
-
),
|
|
14
|
+
), De = (e, n) => {
|
|
15
15
|
const r = /* @__PURE__ */ new Set(), s = de(e, "id");
|
|
16
16
|
return n.forEach((o) => {
|
|
17
17
|
let l = o;
|
|
@@ -51,13 +51,13 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
51
51
|
})), We = (e, n, r, s) => {
|
|
52
52
|
if (!e || !e.length) return [];
|
|
53
53
|
let o = e;
|
|
54
|
-
if (r !== "all" && (o = ce(
|
|
54
|
+
if (r !== "all" && (o = ce(z(e, { pageType: r }))), S(n))
|
|
55
55
|
o = oe(o, n);
|
|
56
56
|
else {
|
|
57
|
-
const u = oe(o, n), i =
|
|
57
|
+
const u = oe(o, n), i = De(e, u);
|
|
58
58
|
o = Le([...u, ...i], "id");
|
|
59
59
|
}
|
|
60
|
-
const l = me(Re(o)), f = J(l, n, s), g =
|
|
60
|
+
const l = me(Re(o)), f = J(l, n, s), g = z(f, (u) => s(u.pageType)).sort((u, i) => (u.name || "").localeCompare(i.name || "")), P = z(f, (u) => !s(u.pageType));
|
|
61
61
|
let m = [];
|
|
62
62
|
if (r === "all") {
|
|
63
63
|
const u = de(P, "pageType");
|
|
@@ -65,7 +65,7 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
65
65
|
Te(u, (i, x) => ({
|
|
66
66
|
...i,
|
|
67
67
|
id: x,
|
|
68
|
-
name:
|
|
68
|
+
name: Ee(x),
|
|
69
69
|
isPartialGroup: !0,
|
|
70
70
|
children: f.filter((p) => p.pageType === x)
|
|
71
71
|
}))
|
|
@@ -73,7 +73,7 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
73
73
|
} else
|
|
74
74
|
m = P.sort((u, i) => (u.name || "").localeCompare(i.name || ""));
|
|
75
75
|
return [...g, ...m];
|
|
76
|
-
},
|
|
76
|
+
}, qe = ({ page: e }) => {
|
|
77
77
|
var s, o;
|
|
78
78
|
const { isExpanded: n, toggleExpanded: r } = K(e == null ? void 0 : e.id);
|
|
79
79
|
return /* @__PURE__ */ t(
|
|
@@ -85,7 +85,7 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
85
85
|
disabled: !((s = e == null ? void 0 : e.children) != null && s.length),
|
|
86
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
87
|
children: /* @__PURE__ */ t(
|
|
88
|
-
|
|
88
|
+
Ge,
|
|
89
89
|
{
|
|
90
90
|
size: 12,
|
|
91
91
|
className: `stroke-[4] transition-transform duration-200 ${n ? "rotate-90" : ""}`
|
|
@@ -93,13 +93,13 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
93
93
|
)
|
|
94
94
|
}
|
|
95
95
|
);
|
|
96
|
-
},
|
|
96
|
+
}, He = ({ page: e, pageType: n }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(Ie, { size: 12, className: "text-yellow-400" }) : n != null && n.icon ? /* @__PURE__ */ t(
|
|
97
97
|
"div",
|
|
98
98
|
{
|
|
99
99
|
className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
|
|
100
100
|
dangerouslySetInnerHTML: { __html: n.icon }
|
|
101
101
|
}
|
|
102
|
-
) : n != null && n.hasSlug ? /* @__PURE__ */ t(ue, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(
|
|
102
|
+
) : n != null && n.hasSlug ? /* @__PURE__ */ t(ue, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(Oe, { size: 12, className: "stroke-[1] text-slate-500" }) }), _e = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), Qe = ({
|
|
103
103
|
page: e,
|
|
104
104
|
pageTypes: n,
|
|
105
105
|
currentPage: r,
|
|
@@ -108,10 +108,10 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
108
108
|
selectedLanguage: l,
|
|
109
109
|
showUntranslatedPages: f
|
|
110
110
|
}) => {
|
|
111
|
-
const [g] = be(), P = ie(), m = r === e.id, u = !!e.isTemplate, i = V(() =>
|
|
111
|
+
const [g] = be(), P = ie(), m = r === e.id, u = !!e.isTemplate, i = V(() => M(n, { key: e.pageType }), [n, e.pageType]), x = g == null ? void 0 : g[e.id], { data: p } = ye(x), v = p ? p == null ? void 0 : p.name : null;
|
|
112
112
|
let d = Q(o, e == null ? void 0 : e.id);
|
|
113
113
|
d = Q(d, "lang") === l ? d : null;
|
|
114
|
-
const A = l === P || !!d,
|
|
114
|
+
const A = l === P || !!d, C = (d == null ? void 0 : d.name) || (e == null ? void 0 : e.name) || "No name";
|
|
115
115
|
let b = (d == null ? void 0 : d.slug) || (e == null ? void 0 : e.slug) || "";
|
|
116
116
|
const j = b + (e != null && e.dynamic ? `/${i == null ? void 0 : i.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
117
117
|
if (b.startsWith("/") && !f) {
|
|
@@ -119,9 +119,9 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
119
119
|
b = b.endsWith(c) && e.dynamic ? "" : `/${c}`;
|
|
120
120
|
}
|
|
121
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]",
|
|
123
|
-
return A ? `${c} ${
|
|
124
|
-
}, [A, m,
|
|
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]", G = `${m ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
|
|
123
|
+
return A ? `${c} ${G} ${v ? "opacity-60" : ""}` : `${c} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
|
|
124
|
+
}, [A, m, v]);
|
|
125
125
|
return /* @__PURE__ */ y("div", { className: "group relative", children: [
|
|
126
126
|
/* @__PURE__ */ y(
|
|
127
127
|
"div",
|
|
@@ -129,11 +129,11 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
129
129
|
onClick: () => !e.isPartialGroup && A && s("select", e == null ? void 0 : e.id),
|
|
130
130
|
className: B,
|
|
131
131
|
children: [
|
|
132
|
-
/* @__PURE__ */ t(
|
|
133
|
-
!e.isPartialGroup && /* @__PURE__ */ t(
|
|
134
|
-
!e.isPartialGroup && /* @__PURE__ */ t(
|
|
135
|
-
/* @__PURE__ */ t(
|
|
136
|
-
(b || e.dynamic) && /* @__PURE__ */ t(
|
|
132
|
+
/* @__PURE__ */ t(qe, { page: e }),
|
|
133
|
+
!e.isPartialGroup && /* @__PURE__ */ t(_e, { isOnline: d ? d.online : e.online }),
|
|
134
|
+
!e.isPartialGroup && /* @__PURE__ */ t(He, { page: e, pageType: i }),
|
|
135
|
+
/* @__PURE__ */ t(H, { content: C, side: "top", showTooltip: C.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: C }) }),
|
|
136
|
+
(b || e.dynamic) && /* @__PURE__ */ t(H, { content: j, side: "top", showTooltip: !0, children: /* @__PURE__ */ y("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
137
137
|
b,
|
|
138
138
|
e.dynamic && (i == null ? void 0 : i.dynamicSlug) && /* @__PURE__ */ y("span", { className: "text-xs text-gray-500", children: [
|
|
139
139
|
"/",
|
|
@@ -141,8 +141,8 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
141
141
|
e.dynamicSlugCustom
|
|
142
142
|
] })
|
|
143
143
|
] }) }),
|
|
144
|
-
u && /* @__PURE__ */ t(
|
|
145
|
-
!e.isPartialGroup && A && !
|
|
144
|
+
u && /* @__PURE__ */ t(H, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(Fe, { size: 16 }) }) }),
|
|
145
|
+
!e.isPartialGroup && A && !v ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
|
|
146
146
|
ge,
|
|
147
147
|
{
|
|
148
148
|
isLanguagePage: !!d,
|
|
@@ -153,19 +153,19 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
153
153
|
setDeletePage: (c) => s("delete", d || c),
|
|
154
154
|
setMarkAsTemplate: (c) => s("markAsTemplate", c),
|
|
155
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(
|
|
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(Me, { className: "h-4 w-4", onClick: (c) => c.stopPropagation() }) })
|
|
157
157
|
}
|
|
158
|
-
) }) :
|
|
158
|
+
) }) : v ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(ze, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
|
|
159
159
|
]
|
|
160
160
|
}
|
|
161
161
|
),
|
|
162
|
-
/* @__PURE__ */ t(
|
|
162
|
+
/* @__PURE__ */ t(D, { children: v && /* @__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
163
|
/* @__PURE__ */ t(je, { size: 12, className: "stroke-[3]" }),
|
|
164
164
|
" ",
|
|
165
|
-
/* @__PURE__ */ t("span", { className: "font-medium", children:
|
|
165
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: v }),
|
|
166
166
|
" is editing this page"
|
|
167
167
|
] }) }),
|
|
168
|
-
/* @__PURE__ */ t(
|
|
168
|
+
/* @__PURE__ */ t(D, { children: !A && !e.isPartialGroup && !v && /* @__PURE__ */ y(
|
|
169
169
|
"button",
|
|
170
170
|
{
|
|
171
171
|
onClick: (c) => {
|
|
@@ -195,7 +195,7 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
195
195
|
showUntranslatedPages: g
|
|
196
196
|
}) => {
|
|
197
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(
|
|
198
|
+
return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${n * 10}px` }, children: e.map((m) => /* @__PURE__ */ y(D, { children: [
|
|
199
199
|
/* @__PURE__ */ t(
|
|
200
200
|
Qe,
|
|
201
201
|
{
|
|
@@ -222,42 +222,42 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
222
222
|
}
|
|
223
223
|
)
|
|
224
224
|
] }, m.id)) });
|
|
225
|
-
}, Ve =
|
|
226
|
-
const { t: n } = Ue(), { languages: r, setSelectedLang: s } = ae(), { data: o } = Ne(), { data: l, isFetching: f } =
|
|
225
|
+
}, Ve = E(() => import("./page-manager-search-and-filter-_Hvk3bU3.js")), Je = E(() => import("./add-new-page-DK25Y0zS.js")), Ke = E(() => import("./delete-page-B95T2Prd.js")), Xe = E(() => import("./duplicate-page-CrzzObAj.js")), Ye = E(() => import("./mark-as-template-CmCCMaQg.js")), Ze = E(() => import("./unmark-as-template-BJ5CTNAe.js")), et = E(() => import("./unpublish-page-DvOWVBIf.js")), ct = ({ close: e }) => {
|
|
226
|
+
const { t: n } = Ue(), { languages: r, setSelectedLang: s } = ae(), { data: o } = Ne(), { data: l, isFetching: f } = ve(), [g, P] = we(), { updateForSelectedPage: m, expandPagesOnSearch: u } = K(null), i = ie(), x = g.get("page"), [p, v] = N(""), [d, A] = N(null), [C, b] = N(null), [j, B] = N(null), [c, G] = N(null), [U, W] = N(""), [X, Y] = N(null), [Z, ee] = N(null), [k, fe] = N(i), [Pe, xe] = N(!1), [, te] = $e(Se), I = Pe && k !== i, { data: $, isFetching: pe } = Ae(k), se = le(
|
|
227
227
|
(h) => {
|
|
228
228
|
var a;
|
|
229
|
-
return (a =
|
|
229
|
+
return (a = M(o, { key: h })) == null ? void 0 : a.hasSlug;
|
|
230
230
|
},
|
|
231
231
|
[o]
|
|
232
|
-
),
|
|
233
|
-
|
|
232
|
+
), w = V(() => l ? I ? z(l, (h) => !($ != null && $[h.id])) : We(l, p, U, se) : [], [l, se, p, U, $, I]);
|
|
233
|
+
F(() => {
|
|
234
234
|
s(i);
|
|
235
|
-
}, [i, s]),
|
|
235
|
+
}, [i, s]), F(() => {
|
|
236
236
|
if (!S(U)) return;
|
|
237
237
|
const h = sessionStorage.getItem("pageTypeFilter") || "all";
|
|
238
|
-
!S(o) && h && (
|
|
239
|
-
}, [o, U]),
|
|
240
|
-
if (x && !f && !
|
|
241
|
-
const a =
|
|
238
|
+
!S(o) && h && (M(o, { key: h }) ? W(h) : W("all"));
|
|
239
|
+
}, [o, U]), F(() => {
|
|
240
|
+
if (x && !f && !M(l, { id: x })) {
|
|
241
|
+
const a = M(l, { slug: "/" });
|
|
242
242
|
if (a) {
|
|
243
|
-
const
|
|
244
|
-
|
|
243
|
+
const O = new URLSearchParams({ page: a.id });
|
|
244
|
+
_(O, P);
|
|
245
245
|
} else
|
|
246
|
-
|
|
246
|
+
_(new URLSearchParams({}), P, !0);
|
|
247
247
|
}
|
|
248
|
-
}, [l, x, f, P]),
|
|
249
|
-
x && !f && !S(
|
|
250
|
-
}, [x, f,
|
|
251
|
-
!S(p) && !S(
|
|
252
|
-
}, [p,
|
|
253
|
-
const { setSelectedLang:
|
|
248
|
+
}, [l, x, f, P]), F(() => {
|
|
249
|
+
x && !f && !S(w) && m(w, x);
|
|
250
|
+
}, [x, f, w, m]), F(() => {
|
|
251
|
+
!S(p) && !S(w) && u(w);
|
|
252
|
+
}, [p, w, u]);
|
|
253
|
+
const { setSelectedLang: q } = ae(), ne = le(
|
|
254
254
|
(h) => {
|
|
255
255
|
const a = new URLSearchParams({ page: h });
|
|
256
|
-
k !== i ? (a.set("lang", k),
|
|
256
|
+
k !== i ? (a.set("lang", k), q(k)) : q(""), _(a, P), e();
|
|
257
257
|
},
|
|
258
|
-
[e, P,
|
|
258
|
+
[e, P, q, k, i]
|
|
259
259
|
), re = (h, a) => {
|
|
260
|
-
var
|
|
260
|
+
var O;
|
|
261
261
|
if (a)
|
|
262
262
|
switch (h) {
|
|
263
263
|
case "add":
|
|
@@ -280,7 +280,7 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
280
280
|
B(a);
|
|
281
281
|
break;
|
|
282
282
|
case "markAsTemplate":
|
|
283
|
-
|
|
283
|
+
G(a);
|
|
284
284
|
break;
|
|
285
285
|
case "unmarkAsTemplate":
|
|
286
286
|
ee(a);
|
|
@@ -291,31 +291,31 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
291
291
|
case "addLanguagePage":
|
|
292
292
|
te({
|
|
293
293
|
edit: !1,
|
|
294
|
-
primaryPage: ((
|
|
294
|
+
primaryPage: ((O = a == null ? void 0 : a.page) == null ? void 0 : O.id) || "",
|
|
295
295
|
preselectedLang: (a == null ? void 0 : a.language) || k
|
|
296
296
|
});
|
|
297
297
|
break;
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
|
-
return /* @__PURE__ */ y(
|
|
300
|
+
return /* @__PURE__ */ y(D, { children: [
|
|
301
301
|
/* @__PURE__ */ y("div", { className: "flex h-full flex-col justify-between", children: [
|
|
302
302
|
/* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(
|
|
303
303
|
Ve,
|
|
304
304
|
{
|
|
305
|
-
pages:
|
|
305
|
+
pages: w,
|
|
306
306
|
search: p,
|
|
307
|
-
setSearch:
|
|
307
|
+
setSearch: v,
|
|
308
308
|
languages: [i, ...r],
|
|
309
309
|
selectedLanguage: k,
|
|
310
310
|
setSelectedLanguage: fe,
|
|
311
311
|
selectedPageType: U,
|
|
312
312
|
setSelectedPageType: W,
|
|
313
313
|
onAddPage: (h) => re("add", h),
|
|
314
|
-
showUntranslatedPages:
|
|
314
|
+
showUntranslatedPages: I,
|
|
315
315
|
setShowUntranslatedPages: xe
|
|
316
316
|
}
|
|
317
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:
|
|
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: Ce([...Array(15).keys()], (h) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, h)) }) : S(w) ? /* @__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
319
|
/* @__PURE__ */ t(ue, { className: "h-6 w-6 stroke-[1]" }),
|
|
320
320
|
n("Empty List!"),
|
|
321
321
|
/* @__PURE__ */ t("span", { className: "font-light", children: n("Add new page to start") })
|
|
@@ -323,28 +323,28 @@ const oe = (e, n) => !e || !Array.isArray(e) ? [] : S(n) ? e : ce(
|
|
|
323
323
|
he,
|
|
324
324
|
{
|
|
325
325
|
tier: 0,
|
|
326
|
-
pages:
|
|
326
|
+
pages: w,
|
|
327
327
|
pageTypes: o,
|
|
328
328
|
currentPage: x || "",
|
|
329
329
|
onClickAction: re,
|
|
330
330
|
languagePages: $,
|
|
331
331
|
selectedLanguage: k,
|
|
332
|
-
showUntranslatedPages:
|
|
332
|
+
showUntranslatedPages: I
|
|
333
333
|
}
|
|
334
334
|
) })
|
|
335
335
|
] }),
|
|
336
|
-
|
|
336
|
+
C && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(
|
|
337
337
|
Je,
|
|
338
338
|
{
|
|
339
339
|
closePanel: e,
|
|
340
340
|
editPage: ne,
|
|
341
|
-
addEditPage:
|
|
341
|
+
addEditPage: C,
|
|
342
342
|
setAddEditPage: b
|
|
343
343
|
}
|
|
344
344
|
) }),
|
|
345
345
|
d && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ke, { page: d, onClose: () => A(null) }) }),
|
|
346
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: () =>
|
|
347
|
+
c && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ye, { page: c, onClose: () => G(null) }) }),
|
|
348
348
|
Z && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Ze, { page: Z, onClose: () => ee(null) }) }),
|
|
349
349
|
X && /* @__PURE__ */ t(L, { children: /* @__PURE__ */ t(Xe, { page: X, onClose: () => Y(null), closePanel: e }) })
|
|
350
350
|
] });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("./index-W0r4o5Ro.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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
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-
|
|
2
|
+
import { f as F, L as I, h as z, A as j } from "./index-yhKyIbgs.js";
|
|
3
3
|
import { u as T } from "./use-page-expand-manager-D6T75I11.js";
|
|
4
4
|
import { useTranslation as f } from "@chaibuilder/sdk";
|
|
5
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";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsxs as n, Fragment as p, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useQuery as re, useQueryClient as k, useMutation as
|
|
2
|
+
import { am as C, an as A, A as b, ar as G, au as le, ak as I, as as R, at as w } from "./index-yhKyIbgs.js";
|
|
3
|
+
import { useQuery as re, useQueryClient as k, useMutation as j } from "@tanstack/react-query";
|
|
4
4
|
import { useLanguages as ie, useSavePage as de } from "@chaibuilder/sdk";
|
|
5
|
-
import { SheetHeader as ce, SheetTitle as oe, ScrollArea as ue, Skeleton as y, Button as g, DropdownMenu as me, DropdownMenuTrigger as he, DropdownMenuContent as fe, DropdownMenuItem as U, DropdownMenuSeparator as pe, Dialog as
|
|
5
|
+
import { SheetHeader as ce, SheetTitle as oe, ScrollArea as ue, Skeleton as y, Button as g, DropdownMenu as me, DropdownMenuTrigger as he, DropdownMenuContent as fe, DropdownMenuItem as U, DropdownMenuSeparator as pe, Dialog as q, DialogContent as L, DialogHeader as P, DialogTitle as $, DialogDescription as z, DialogFooter as H } from "@chaibuilder/sdk/ui";
|
|
6
6
|
import { format as D, formatDistanceToNow as xe } from "date-fns";
|
|
7
7
|
import { isEmpty as ge } from "lodash-es";
|
|
8
8
|
import { FileJson as Ne, MoreHorizontal as be, Undo2 as J, Trash as Q, CloudOff as ye, Rocket as ve, Save as we, X as De } from "lucide-react";
|
|
@@ -22,7 +22,7 @@ function Ce(t) {
|
|
|
22
22
|
}
|
|
23
23
|
const Ae = () => {
|
|
24
24
|
const t = C(), s = A(), a = k();
|
|
25
|
-
return
|
|
25
|
+
return j({
|
|
26
26
|
mutationFn: async (i) => await s(t, {
|
|
27
27
|
action: b.DELETE_PAGE_REVISION,
|
|
28
28
|
data: { revisionId: i }
|
|
@@ -35,7 +35,7 @@ const Ae = () => {
|
|
|
35
35
|
});
|
|
36
36
|
}, Ie = () => {
|
|
37
37
|
const t = C(), s = A(), a = k();
|
|
38
|
-
return
|
|
38
|
+
return j({
|
|
39
39
|
mutationFn: async ({ revisionId: i, discardCurrent: l }) => await s(t, {
|
|
40
40
|
action: b.RESTORE_PAGE_REVISION,
|
|
41
41
|
data: { revisionId: i, discardCurrent: l }
|
|
@@ -46,7 +46,7 @@ const Ae = () => {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
});
|
|
49
|
-
}, ke = Se(() => import("./json-diff-viewer-
|
|
49
|
+
}, ke = Se(() => import("./json-diff-viewer-ISJS7lHK.js")), N = ({ tag: t }) => t === "draft" ? /* @__PURE__ */ n("div", { className: "flex items-center gap-1 rounded-full bg-amber-500/10 px-1.5 py-0.5 text-xs text-amber-600", children: [
|
|
50
50
|
/* @__PURE__ */ n("span", { className: "relative flex h-2 w-2", children: [
|
|
51
51
|
/* @__PURE__ */ e("span", { className: "absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75" }),
|
|
52
52
|
/* @__PURE__ */ e("span", { className: "relative inline-flex h-2 w-2 rounded-full bg-amber-500" })
|
|
@@ -66,7 +66,7 @@ const Ae = () => {
|
|
|
66
66
|
/* @__PURE__ */ e("span", { className: "text-[11px] leading-tight", children: "Unsaved changes" })
|
|
67
67
|
] }) : /* @__PURE__ */ e("span", { className: "rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600", children: t });
|
|
68
68
|
function Oe({ compare: t, setCompare: s }) {
|
|
69
|
-
const { data: a } =
|
|
69
|
+
const { data: a } = G(), { saveState: i } = de(), [l] = le();
|
|
70
70
|
if (!a) return null;
|
|
71
71
|
const d = !!t.find((o) => {
|
|
72
72
|
var r;
|
|
@@ -264,7 +264,7 @@ function Ue({
|
|
|
264
264
|
}) {
|
|
265
265
|
const { data: d } = I((a == null ? void 0 : a.currentEditor) || ""), u = (d == null ? void 0 : d.name) || "Unknown";
|
|
266
266
|
return a ? /* @__PURE__ */ e(
|
|
267
|
-
|
|
267
|
+
q,
|
|
268
268
|
{
|
|
269
269
|
open: t,
|
|
270
270
|
onOpenChange: (m) => {
|
|
@@ -313,7 +313,7 @@ function Fe({
|
|
|
313
313
|
}) {
|
|
314
314
|
const { data: d } = I((a == null ? void 0 : a.currentEditor) || ""), u = (d == null ? void 0 : d.name) || "Unknown";
|
|
315
315
|
return a ? /* @__PURE__ */ e(
|
|
316
|
-
|
|
316
|
+
q,
|
|
317
317
|
{
|
|
318
318
|
open: t,
|
|
319
319
|
onOpenChange: (m) => {
|
|
@@ -349,7 +349,7 @@ function Fe({
|
|
|
349
349
|
}
|
|
350
350
|
function Je({ isOpen: t }) {
|
|
351
351
|
var T, _;
|
|
352
|
-
const [s, a] = v.useState([]), [i, l] = v.useState(null), [d, u] = v.useState(!1), [m, o] = v.useState(!1), { data: r } =
|
|
352
|
+
const [s, a] = v.useState([]), [i, l] = v.useState(null), [d, u] = v.useState(!1), [m, o] = v.useState(!1), { data: r } = G(), { data: f, isFetching: S, error: h, refetch: x } = Ce(r == null ? void 0 : r.id), { mutate: W, isPending: Y } = Ae(), { mutate: B, isPending: X } = Ie(), Z = k(), { selectedLang: ee, fallbackLang: te } = ie(), ne = ee || te;
|
|
353
353
|
F(() => a([]), [r == null ? void 0 : r.id]);
|
|
354
354
|
const ae = (c) => {
|
|
355
355
|
i && B(
|