@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.3
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/README.md +27 -20
- package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
- package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
- package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
- package/dist/AP7HFJJL-CymCmW14.js +9214 -0
- package/dist/IconPicker-B1rWC-Ex.js +59 -0
- package/dist/IconPicker-DREyo007.cjs +1 -0
- package/dist/WDYDFRGG-BUVnbAci.js +33 -0
- package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
- package/dist/active-in-another-tab-CyjngVA6.js +34 -0
- package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
- package/dist/add-new-language-page-WmlCnytQ.js +401 -0
- package/dist/add-new-page-VW2wAYZp.js +31 -0
- package/dist/add-new-page-soZ8GAkN.cjs +1 -0
- package/dist/ai-panel-content-7zCil042.cjs +1 -0
- package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
- package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
- package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
- package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
- package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
- package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
- package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
- package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/code-display-BnqzqzoP.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
- package/dist/code-editor-DRIAnNbb.js +50 -0
- package/dist/code-editor-o3___nu2.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
- package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
- package/dist/delete-design-token-BRZZiWtQ.js +40 -0
- package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
- package/dist/delete-page-BzyX9TN-.js +70 -0
- package/dist/delete-page-DxX7PFIE.cjs +1 -0
- package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
- package/dist/design-token-usage-xQs6SlaJ.js +113 -0
- package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
- package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
- package/dist/duplicate-page-BR7Dlo9d.js +133 -0
- package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
- package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DV8kUKhl.js +108 -0
- package/dist/image-editor-G-K28aTS.cjs +1 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-Ct7ElCGK.js +19069 -0
- package/dist/index-DF5DEvqb.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-WQwzsC7A.cjs +5 -0
- package/dist/index-ZuacEL1j.js +4732 -0
- package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
- package/dist/json-diff-viewer-krslPepD.js +258 -0
- package/dist/lang-panel-BwIewMyw.js +215 -0
- package/dist/lang-panel-DT96k1xg.cjs +1 -0
- package/dist/manage-design-tokens-Caz_20VK.js +240 -0
- package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
- package/dist/mark-as-template-D295ZQtU.js +156 -0
- package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
- package/dist/no-language-page-content-BvqRBP6y.js +42 -0
- package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
- package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
- package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
- package/dist/page-creator-C4gc5NSC.cjs +1 -0
- package/dist/page-creator-DiOITEMw.js +795 -0
- package/dist/page-lock-BdYmCks0.cjs +1 -0
- package/dist/page-lock-Bfbs6RgL.js +30 -0
- package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
- package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
- package/dist/page-manager-new-CHDueBDk.cjs +1 -0
- package/dist/page-manager-new-CzX22g2n.js +394 -0
- package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
- package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
- package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +491 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-D9aixMN5.js +178 -0
- package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
- package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
- package/dist/save-to-lib-eiOc_SSN.js +422 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-BgRY82CT.cjs +16 -0
- package/dist/selected-block-display-CBFePS19.js +319 -0
- package/dist/seo-panel-C1-iMOR1.js +798 -0
- package/dist/seo-panel-DfAb8U7W.cjs +2 -0
- package/dist/shared-json-ld-B4PxAM_0.js +565 -0
- package/dist/shared-json-ld-DzG398hr.cjs +1 -0
- package/dist/slug-input-AwNJs9im.js +86 -0
- package/dist/slug-input-C_ijLQ_X.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-BNxcjY2j.cjs +1 -0
- package/dist/take-over-request-C4FeDtN_.js +63 -0
- package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
- package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
- package/dist/translation-warning-modal-B64YqlbI.js +26 -0
- package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
- package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
- package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
- package/dist/unpublish-page-D4VwOlxc.js +27 -0
- package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +248 -241
- package/dist/web-preview-Cio70gk5.cjs +1 -0
- package/dist/web-preview-Djy6WIyj.js +73 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-WQwzsC7A.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-BNxcjY2j.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-B1FAtK92.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-B47YjQGN.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-CtMYsk-A.cjs"))),s=n=>u.jsx(r.Suspense,{children:u.jsx(n,{})}),A=({isFetchingPageData:n})=>{e.useChaibuilderRealtime();const{pageStatus:t}=e.usePageLockStatus(),{pageLockMeta:a}=e.usePageLockMeta(),T=E.useQueryClient(),i=r.useRef(t);if(r.useEffect(()=>{t===e.PAGE_STATUS.EDITING&&i.current!==e.PAGE_STATUS.TAKE_OVER_REQUESTED&&T.invalidateQueries({queryKey:[e.ACTIONS.GET_DRAFT_PAGE]}),i.current=t},[t,T]),n)return null;switch(t){case e.PAGE_STATUS.EDITING:case e.PAGE_STATUS.CHECKING:case e.PAGE_STATUS.FORCE_TAKE_OVER:return a.type===e.EVENT.CONTINUE_EDITING_IN_THIS_CLIENT?s(S):null;case e.PAGE_STATUS.LOCKED:return s(o);case e.PAGE_STATUS.TAKE_OVER_REQUESTED:return s(c);case e.PAGE_STATUS.ACTIVE_IN_ANOTHER_TAB:return s(l);case e.PAGE_STATUS.CONNECTION_LOST:return u.jsx(e.BlurContainer,{children:null});default:return null}};exports.default=A;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-ZuacEL1j.js";
|
|
3
|
+
import { useQueryClient as C } from "@tanstack/react-query";
|
|
4
|
+
import { useRef as p, useEffect as N, Suspense as A, lazy as s } from "react";
|
|
5
|
+
const m = s(() => import("./take-over-request-C4FeDtN_.js")), f = s(() => import("./page-locked-dialog-B6MKTRfY.js")), O = s(() => import("./active-in-another-tab-CyjngVA6.js")), S = s(() => import("./continue-editing-in-this-client-CS2aQ7yY.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
|
|
6
|
+
E();
|
|
7
|
+
const { pageStatus: t } = c(), { pageLockMeta: o } = T(), u = C(), i = p(t);
|
|
8
|
+
if (N(() => {
|
|
9
|
+
t === e.EDITING && i.current !== e.TAKE_OVER_REQUESTED && u.invalidateQueries({ queryKey: [l.GET_DRAFT_PAGE] }), i.current = t;
|
|
10
|
+
}, [t, u]), a) return null;
|
|
11
|
+
switch (t) {
|
|
12
|
+
case e.EDITING:
|
|
13
|
+
case e.CHECKING:
|
|
14
|
+
case e.FORCE_TAKE_OVER:
|
|
15
|
+
return o.type === _.CONTINUE_EDITING_IN_THIS_CLIENT ? r(S) : null;
|
|
16
|
+
case e.LOCKED:
|
|
17
|
+
return r(f);
|
|
18
|
+
case e.TAKE_OVER_REQUESTED:
|
|
19
|
+
return r(m);
|
|
20
|
+
case e.ACTIVE_IN_ANOTHER_TAB:
|
|
21
|
+
return r(O);
|
|
22
|
+
case e.CONNECTION_LOST:
|
|
23
|
+
return /* @__PURE__ */ n(I, { children: null });
|
|
24
|
+
default:
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
L as default
|
|
30
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),r=require("./index-DF5DEvqb.cjs"),t=require("./index-WQwzsC7A.cjs"),c=require("lucide-react"),o=require("react"),C=require("react-i18next"),O=()=>{const m=t.useCurrentPageOwner(),p=t.useSendRealtimeEvent(),{setPageStatus:T}=t.usePageLockStatus(),{data:s,isFetching:j}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:d,setPageLockMeta:f}=t.usePageLockMeta(),{t:a}=C.useTranslation(),[u,i]=o.useState(""),[n,g]=o.useState({}),[N,v]=o.useState(!1),l=o.useRef(null);o.useEffect(()=>{d!=null&&d.type&&(l.current&&clearTimeout(l.current),g(d),f({}),i(""))},[d,f]);const k=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),p(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},b=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),p(t.EVENT.FORCE_TAKE_OVER_REQUEST),T(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},R=()=>{g({}),l.current&&clearTimeout(l.current),i("")},x=j?"Loading...":(s==null?void 0:s.name)||"Current editor",h=u===t.EVENT.TAKE_OVER_REQUEST,E=u===t.EVENT.FORCE_TAKE_OVER_REQUEST;return e.jsx(t.BlurContainer,{children:e.jsxs(r.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(r.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(r.CardTitle,{className:"flex items-center gap-2 text-xl",children:[e.jsx(c.LockKeyhole,{className:"h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500"}),e.jsx("span",{children:a("Page Locked for Editing")})]})}),e.jsxs(r.CardContent,{className:"space-y-4 p-4",children:[e.jsxs("div",{className:"relative 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:"Current Editor"}),e.jsxs("div",{className:"flex items-center space-x-4 p-1",children:[s!=null&&s.avatar?e.jsx("img",{src:s.avatar,alt:s.name,className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}):e.jsx(c.UserIcon,{className:"h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"}),e.jsxs("div",{className:"flex-1 space-y-0",children:[e.jsx("div",{className:"truncate font-medium leading-tight text-black",children:x}),(s==null?void 0:s.email)&&e.jsx("p",{className:"truncate text-sm leading-tight text-muted-foreground",children:s.email})]})]})]}),((n==null?void 0:n.type)===t.EVENT.TAKE_OVER_REJECTED||(n==null?void 0:n.type)===t.EVENT.FORCE_TAKE_OVER_REQUEST)&&e.jsx("section",{className:"space-y-2",children:e.jsxs("div",{className:"flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500",children:[e.jsxs("div",{className:"flex items-start gap-x-2",children:[e.jsx(c.AlertCircleIcon,{className:"mt-px flex h-4 w-4 shrink-0"}),e.jsxs("div",{className:"font-light leading-tight",children:[e.jsx("span",{className:"font-medium",children:(s==null?void 0:s.name)||"The current editor"}),(n==null?void 0:n.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(r.Button,{size:"icon",variant:"ghost",onClick:R,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(r.CardFooter,{className:"flex flex-col gap-3 border-t pt-3",children:e.jsxs("section",{className:"space-y-2",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-wide text-muted-foreground",children:a("Take Over Options")}),e.jsxs("div",{className:"rounded-md border bg-muted/40 p-3",children:[e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"text-sm font-medium",children:a("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:a("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(r.Button,{disabled:h,variant:"default",onClick:k,className:"mt-3 w-full gap-2",children:[e.jsx(c.Edit,{className:"h-4 w-4"}),h?"Take over request sent":"Send Take Over Request"]}),h&&e.jsx("p",{className:"mt-2 text-xs text-muted-foreground",children:a("Request sent. If no response, try again or use force take over.")})]}),e.jsx(r.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(r.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(r.AccordionTrigger,{className:"px-3 py-2 hover:no-underline",children:e.jsx("div",{className:"flex items-center gap-2 text-left",children:e.jsxs("div",{children:[e.jsxs("p",{className:"flex items-center gap-x-2 text-sm font-medium text-destructive",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4 text-destructive"}),a("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:a("Immediately take control (use with caution)")})]})})}),e.jsx(r.AccordionContent,{className:"px-3 pb-3",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2",children:[e.jsx("input",{type:"checkbox",id:"force-takeover",checked:N,onChange:y=>v(y.target.checked),className:"mt-0.5 h-4 w-4 rounded border-gray-300"}),e.jsx("label",{htmlFor:"force-takeover",className:"flex-1 text-xs text-muted-foreground",children:a("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(r.Button,{disabled:!N||E,variant:"destructive",onClick:b,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),a(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:a("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=O;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import { W as O, X as w, Y as A, Z as S, B as p, _ as F, $ as K, a0 as I, a1 as U, a2 as V } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { aq as q, ao as Q, a as P, ap as j, b as B, B as D, E as a, P as L } from "./index-ZuacEL1j.js";
|
|
4
|
+
import { LockKeyhole as G, UserIcon as H, AlertCircleIcon as J, X, Edit as z, ShieldAlert as v } from "lucide-react";
|
|
5
|
+
import { useState as f, useRef as W, useEffect as Y } from "react";
|
|
6
|
+
import { useTranslation as Z } from "react-i18next";
|
|
7
|
+
const ae = () => {
|
|
8
|
+
const o = q(), x = Q(), { setPageStatus: T } = P(), { data: r, isFetching: k } = j((o == null ? void 0 : o.userId) || ""), { pageLockMeta: l, setPageLockMeta: E } = B(), { t: s } = Z(), [d, c] = f(""), [n, g] = f({}), [N, b] = f(!1), i = W(null);
|
|
9
|
+
Y(() => {
|
|
10
|
+
l != null && l.type && (i.current && clearTimeout(i.current), g(l), E({}), c(""));
|
|
11
|
+
}, [l, E]);
|
|
12
|
+
const R = () => {
|
|
13
|
+
d !== a.TAKE_OVER_REQUEST && (c(a.TAKE_OVER_REQUEST), x(a.TAKE_OVER_REQUEST), i.current = setTimeout(() => c(""), 2e4));
|
|
14
|
+
}, C = () => {
|
|
15
|
+
d !== a.FORCE_TAKE_OVER_REQUEST && (c(a.FORCE_TAKE_OVER_REQUEST), x(a.FORCE_TAKE_OVER_REQUEST), T(L.CHECKING), i.current = setTimeout(() => c(""), 2e4));
|
|
16
|
+
}, _ = () => {
|
|
17
|
+
g({}), i.current && clearTimeout(i.current), c("");
|
|
18
|
+
}, m = k ? "Loading..." : (r == null ? void 0 : r.name) || "Current editor", u = d === a.TAKE_OVER_REQUEST, h = d === a.FORCE_TAKE_OVER_REQUEST;
|
|
19
|
+
return /* @__PURE__ */ e(D, { children: /* @__PURE__ */ t(O, { className: "mx-auto w-full max-w-md", children: [
|
|
20
|
+
/* @__PURE__ */ e(w, { className: "space-y-1 border-b pb-3", children: /* @__PURE__ */ t(A, { className: "flex items-center gap-2 text-xl", children: [
|
|
21
|
+
/* @__PURE__ */ e(G, { className: "h-8 w-8 rounded-md bg-sky-500/20 p-1.5 text-sky-500" }),
|
|
22
|
+
/* @__PURE__ */ e("span", { children: s("Page Locked for Editing") })
|
|
23
|
+
] }) }),
|
|
24
|
+
/* @__PURE__ */ t(S, { className: "space-y-4 p-4", children: [
|
|
25
|
+
/* @__PURE__ */ t("div", { className: "relative rounded-md border border-green-500 px-2 pb-2 pt-4", children: [
|
|
26
|
+
/* @__PURE__ */ e("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: "Current Editor" }),
|
|
27
|
+
/* @__PURE__ */ t("div", { className: "flex items-center space-x-4 p-1", children: [
|
|
28
|
+
r != null && r.avatar ? /* @__PURE__ */ e(
|
|
29
|
+
"img",
|
|
30
|
+
{
|
|
31
|
+
src: r.avatar,
|
|
32
|
+
alt: r.name,
|
|
33
|
+
className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white"
|
|
34
|
+
}
|
|
35
|
+
) : /* @__PURE__ */ e(H, { className: "h-12 w-12 flex-shrink-0 rounded-full bg-black p-3 text-white" }),
|
|
36
|
+
/* @__PURE__ */ t("div", { className: "flex-1 space-y-0", children: [
|
|
37
|
+
/* @__PURE__ */ e("div", { className: "truncate font-medium leading-tight text-black", children: m }),
|
|
38
|
+
(r == null ? void 0 : r.email) && /* @__PURE__ */ e("p", { className: "truncate text-sm leading-tight text-muted-foreground", children: r.email })
|
|
39
|
+
] })
|
|
40
|
+
] })
|
|
41
|
+
] }),
|
|
42
|
+
((n == null ? void 0 : n.type) === a.TAKE_OVER_REJECTED || (n == null ? void 0 : n.type) === a.FORCE_TAKE_OVER_REQUEST) && /* @__PURE__ */ e("section", { className: "space-y-2", children: /* @__PURE__ */ t("div", { className: "flex items-center justify-between gap-x-2 rounded border border-red-500 bg-red-500/10 py-2 pl-3 pr-2 text-sm font-medium text-red-500", children: [
|
|
43
|
+
/* @__PURE__ */ t("div", { className: "flex items-start gap-x-2", children: [
|
|
44
|
+
/* @__PURE__ */ e(J, { className: "mt-px flex h-4 w-4 shrink-0" }),
|
|
45
|
+
/* @__PURE__ */ t("div", { className: "font-light leading-tight", children: [
|
|
46
|
+
/* @__PURE__ */ e("span", { className: "font-medium", children: (r == null ? void 0 : r.name) || "The current editor" }),
|
|
47
|
+
(n == null ? void 0 : n.type) === a.TAKE_OVER_REJECTED ? " rejected your take over request." : " forcefully took over this page."
|
|
48
|
+
] })
|
|
49
|
+
] }),
|
|
50
|
+
/* @__PURE__ */ e(p, { size: "icon", variant: "ghost", onClick: _, className: "flex-shrink-0", children: /* @__PURE__ */ e(X, { className: "h-4 w-4" }) })
|
|
51
|
+
] }) })
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ e(F, { className: "flex flex-col gap-3 border-t pt-3", children: /* @__PURE__ */ t("section", { className: "space-y-2", children: [
|
|
54
|
+
/* @__PURE__ */ e("h3", { className: "text-xs font-semibold uppercase tracking-wide text-muted-foreground", children: s("Take Over Options") }),
|
|
55
|
+
/* @__PURE__ */ t("div", { className: "rounded-md border bg-muted/40 p-3", children: [
|
|
56
|
+
/* @__PURE__ */ t("div", { className: "mb-2", children: [
|
|
57
|
+
/* @__PURE__ */ e("p", { className: "text-sm font-medium", children: s("Take Over Request:") }),
|
|
58
|
+
/* @__PURE__ */ e("p", { className: "mt-1 text-xs text-muted-foreground", children: s(
|
|
59
|
+
"Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",
|
|
60
|
+
{ currentEditorName: m }
|
|
61
|
+
) })
|
|
62
|
+
] }),
|
|
63
|
+
/* @__PURE__ */ t(
|
|
64
|
+
p,
|
|
65
|
+
{
|
|
66
|
+
disabled: u,
|
|
67
|
+
variant: "default",
|
|
68
|
+
onClick: R,
|
|
69
|
+
className: "mt-3 w-full gap-2",
|
|
70
|
+
children: [
|
|
71
|
+
/* @__PURE__ */ e(z, { className: "h-4 w-4" }),
|
|
72
|
+
u ? "Take over request sent" : "Send Take Over Request"
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
),
|
|
76
|
+
u && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-muted-foreground", children: s("Request sent. If no response, try again or use force take over.") })
|
|
77
|
+
] }),
|
|
78
|
+
/* @__PURE__ */ e(K, { type: "single", collapsible: !0, className: "w-full", children: /* @__PURE__ */ t(
|
|
79
|
+
I,
|
|
80
|
+
{
|
|
81
|
+
value: "force-takeover",
|
|
82
|
+
className: "rounded-md border border-destructive/40 bg-destructive/5",
|
|
83
|
+
children: [
|
|
84
|
+
/* @__PURE__ */ e(U, { className: "px-3 py-2 hover:no-underline", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2 text-left", children: /* @__PURE__ */ t("div", { children: [
|
|
85
|
+
/* @__PURE__ */ t("p", { className: "flex items-center gap-x-2 text-sm font-medium text-destructive", children: [
|
|
86
|
+
/* @__PURE__ */ e(v, { className: "h-4 w-4 text-destructive" }),
|
|
87
|
+
s("Force Take Over")
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ e("p", { className: "pl-6 text-xs font-normal leading-tight text-muted-foreground", children: s("Immediately take control (use with caution)") })
|
|
90
|
+
] }) }) }),
|
|
91
|
+
/* @__PURE__ */ e(V, { className: "px-3 pb-3", children: /* @__PURE__ */ t("div", { className: "space-y-3", children: [
|
|
92
|
+
/* @__PURE__ */ t("div", { className: "flex items-start gap-2 rounded-md border border-destructive/40 bg-background p-2", children: [
|
|
93
|
+
/* @__PURE__ */ e(
|
|
94
|
+
"input",
|
|
95
|
+
{
|
|
96
|
+
type: "checkbox",
|
|
97
|
+
id: "force-takeover",
|
|
98
|
+
checked: N,
|
|
99
|
+
onChange: (y) => b(y.target.checked),
|
|
100
|
+
className: "mt-0.5 h-4 w-4 rounded border-gray-300"
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ e("label", { htmlFor: "force-takeover", className: "flex-1 text-xs text-muted-foreground", children: s(
|
|
104
|
+
"I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",
|
|
105
|
+
{ currentEditorName: m }
|
|
106
|
+
) })
|
|
107
|
+
] }),
|
|
108
|
+
/* @__PURE__ */ t(
|
|
109
|
+
p,
|
|
110
|
+
{
|
|
111
|
+
disabled: !N || h,
|
|
112
|
+
variant: "destructive",
|
|
113
|
+
onClick: C,
|
|
114
|
+
className: "w-full gap-2",
|
|
115
|
+
children: [
|
|
116
|
+
/* @__PURE__ */ e(v, { className: "h-4 w-4" }),
|
|
117
|
+
s(h ? "Take over page..." : "Force Take Over")
|
|
118
|
+
]
|
|
119
|
+
}
|
|
120
|
+
),
|
|
121
|
+
h && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: s(
|
|
122
|
+
"Attempting to forcefully take over this page. Please wait while we update the editing session."
|
|
123
|
+
) })
|
|
124
|
+
] }) })
|
|
125
|
+
]
|
|
126
|
+
}
|
|
127
|
+
) })
|
|
128
|
+
] }) })
|
|
129
|
+
] }) });
|
|
130
|
+
};
|
|
131
|
+
export {
|
|
132
|
+
ae as default
|
|
133
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),$=require("./index-DF5DEvqb.cjs"),f=require("./index-WQwzsC7A.cjs"),O=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),R=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),Y=(e,n)=>!e||!Array.isArray(e)?[]:r.isEmpty(n)?e:r.compact(r.filter(e,a=>{const s=r.toLower(n);return r.includes(r.toLower((a==null?void 0:a.name)||""),s)||r.includes(r.toLower((a==null?void 0:a.slug)||""),s)})),re=(e,n)=>{const a=new Set,s=r.keyBy(e,"id");return n.forEach(c=>{let o=c;for(;o.parent&&s[o.parent];)a.add(o.parent),o=s[o.parent]}),Array.from(a).map(c=>s[c])},B=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?B(s.children,n,a):[]};const c=s.children&&s.children.some(o=>r.includes(r.toLower(o.name||""),r.toLower(n))||r.includes(r.toLower(o.slug||""),r.toLower(n)));return{...s,shouldExpandOnSearch:c,children:s.children?B(s.children,n,a):[]}}),ae=e=>{if(!e||!e.length)return[];const n={};e.forEach(s=>{n[s.id]={...s,children:[]}});const a=[];return Object.values(n).forEach(s=>{s.parent&&n[s.parent]?n[s.parent].children.push(s):a.push(s)}),a},J=e=>!e||!e.length?[]:[...e].sort((a,s)=>(a.name||"").localeCompare(s.name||"")).map(a=>({...a,children:a.children?J(a.children):[]})),le=(e,n,a,s)=>{if(!e||!e.length)return[];let c=e;if(a!=="all"&&(c=r.compact(r.filter(e,{pageType:a}))),r.isEmpty(n))c=Y(c,n);else{const x=Y(c,n),u=re(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(ae(c)),p=B(o,n,s),v=r.filter(p,x=>s(x.pageType)).sort((x,u)=>(x.name||"").localeCompare(u.name||"")),d=r.filter(p,x=>!s(x.pageType));let y=[];if(a==="all"){const x=r.keyBy(d,"pageType");y=Object.values(r.mapValues(x,(u,g)=>({...u,id:g,name:r.startCase(g),isPartialGroup:!0,children:p.filter(w=>w.pageType===g)})))}else y=d.sort((x,u)=>(x.name||"").localeCompare(u.name||""));return[...v,...y]},oe=R.atom({pageId:null,position:{x:0,y:0}}),ie=({pageId:e,children:n})=>{const[a,s]=R.useAtom(oe),c=l.useRef(null),o=a.pageId===e;l.useEffect(()=>{const d=()=>s({pageId:null,position:{x:0,y:0}});if(o)return document.addEventListener("click",d),()=>document.removeEventListener("click",d)},[o,s]);const p=d=>{d.preventDefault(),d.stopPropagation(),s({pageId:e,position:{x:d.clientX,y:d.clientY}})},v=()=>{const d=`${window.location.pathname}?page=${e}`;window.open(d,"_blank"),s({pageId:null,position:{x:0,y:0}})};return t.jsxs(t.Fragment,{children:[t.jsx("span",{onContextMenu:p,children:n}),o&&t.jsx("div",{ref:c,className:"fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",style:{top:a.position.y,left:a.position.x},children:t.jsx("div",{className:"",children:t.jsxs($.Button,{variant:"ghost",onClick:v,className:"w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",children:[t.jsx(b.ExternalLink,{className:"h-4 w-4"}),"Open in new tab"]})})})]})},ce=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=O.usePageExpandManager(e==null?void 0:e.id);return t.jsx("button",{onClick:o=>{o.stopPropagation(),a()},disabled:!((s=e==null?void 0:e.children)!=null&&s.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:t.jsx(b.ChevronRight,{size:12,className:`stroke-[4] transition-transform duration-200 ${n?"rotate-90":""}`})})},de=({page:e,pageType:n})=>t.jsx("div",{className:"flex h-full items-center justify-center gap-x-1",children:e.dynamic?t.jsx(b.StarsIcon,{size:12,className:"text-yellow-400"}):n!=null&&n.icon?t.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:n.icon}}):n!=null&&n.hasSlug?t.jsx(b.File,{size:12,className:"stroke-[1] text-slate-500"}):t.jsx(b.Hash,{size:12,className:"stroke-[1] text-slate-500"})}),ue=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),me=({page:e,pageTypes:n,currentPage:a,onClickAction:s,languagePages:c,selectedLanguage:o,showUntranslatedPages:p})=>{const v=f.useUserId(),{pageToUser:d}=f.usePageToUser(),y=r.get(d,[e==null?void 0:e.id,"userId"]),{data:x}=f.useChaiUserInfo(y),u=x&&v!==y?x==null?void 0:x.name:null,g=f.useFallbackLang(),w=a===e.id,I=!!e.isTemplate,j=l.useMemo(()=>r.find(n,{key:e.pageType}),[n,e.pageType]);let h=r.get(c,e==null?void 0:e.id);h=r.get(h,"lang")===o?h:null;const E=o===g||!!h,L=(h==null?void 0:h.name)||(e==null?void 0:e.name)||"No name";let k=(h==null?void 0:h.slug)||(e==null?void 0:e.slug)||"";const C=k+(e!=null&&e.dynamic?`/${j==null?void 0:j.dynamicSlug}`:"")+(e!=null&&e.dynamicSlugCustom?`${e.dynamicSlugCustom}`:"");if(k.startsWith("/")&&!p){const m=k.split("/").pop();k=k.endsWith(m)&&e.dynamic?"":`/${m}`}const M=l.useMemo(()=>{const m="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]",T=`${w?"border-primary/30 bg-primary/5":"border-transparent hover:border-gray-200 hover:bg-gray-100"}`;return E?`${m} ${T} ${u?"opacity-60":""}`:`${m} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`},[E,w,u]);return t.jsxs("div",{className:"group relative",children:[t.jsx(ie,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(ce,{page:e}),!e.isPartialGroup&&t.jsx(ue,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(de,{page:e,pageType:j}),t.jsx(f.Tooltip,{content:L,side:"top",showTooltip:L.length>35,children:t.jsx("span",{className:"max-w-[40%] truncate font-medium text-black",children:L})}),(k||e.dynamic)&&t.jsx(f.Tooltip,{content:C,side:"top",showTooltip:!0,children:t.jsxs("span",{className:"max-w-[40%] truncate font-mono text-xs text-muted-foreground",children:[k,e.dynamic&&(j==null?void 0:j.dynamicSlug)&&t.jsxs("span",{className:"text-xs text-gray-500",children:["/",j==null?void 0:j.dynamicSlug,e.dynamicSlugCustom]})]})}),I&&t.jsx(f.Tooltip,{content:"Template",side:"top",children:t.jsx("span",{className:"text-blue-500",children:t.jsx(b.NotepadText,{size:16})})}),!e.isPartialGroup&&E&&!u?t.jsx("div",{className:"duration absolute right-0.5 top-[3px]",children:t.jsx(f.PageActionsDropdown,{isLanguagePage:!!h,page:h||e,setDuplicatePage:m=>s("duplicate",m),setAddEditPage:m=>s("edit",h||m),setUnpublishPage:m=>s("unpublish",m),setDeletePage:m=>s("delete",h||m),setMarkAsTemplate:m=>s("markAsTemplate",m),setUnmarkAsTemplate:m=>s("unmarkAsTemplate",m),children:t.jsx("div",{className:"m-0 cursor-pointer rounded border border-transparent p-0.5 duration-100 hover:border-gray-400 hover:bg-white",children:t.jsx(b.MoreHorizontal,{className:"h-4 w-4",onClick:m=>m.stopPropagation()})})})}):u?t.jsx("span",{className:"duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500",children:t.jsx(b.Lock,{className:"h-3.5 w-3.5 fill-red-200 text-red-500"})}):null]})}),t.jsx(t.Fragment,{children:u&&t.jsxs("button",{className:"absolute right-px top-1/2 flex h-6 -translate-y-1/2 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:[t.jsx(b.Edit,{size:12,className:"stroke-[3]"})," ",t.jsx("span",{className:"font-medium",children:u})," is editing this page"]})}),t.jsx(t.Fragment,{children:!E&&!e.isPartialGroup&&!u&&t.jsxs("button",{onClick:m=>{m.stopPropagation(),s("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:[t.jsx(b.Plus,{size:12,className:"stroke-[3]"})," ",t.jsxs("span",{className:"text-[10px]",children:["Add ",r.get(f.LANGUAGES,o)," Page"]})]})})]})},K=({pages:e,tier:n,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})=>{const{expandedPages:d}=O.usePageExpandManager();return t.jsx("div",{className:"space-y-0.5",style:{paddingLeft:`${n*10}px`},children:e.map(y=>t.jsxs(t.Fragment,{children:[t.jsx(me,{page:y,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v}),y.children&&y.children.length>0&&(d==null?void 0:d.includes(y.id))&&t.jsx(K,{pages:y.children,tier:n+1,pageTypes:a,currentPage:s,onClickAction:c,languagePages:o,selectedLanguage:p,showUntranslatedPages:v})]},y.id))})},xe=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-DkkRIH86.cjs"))),he=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-soZ8GAkN.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-DxX7PFIE.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CaNAbXwV.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-W3LmpiqN.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-EVvk0vmp.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-bdSmwAVQ.cjs"))),je=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=$.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=O.usePageExpandManager(null),u=f.useFallbackLang(),g=v.get("page"),[w,I]=l.useState(""),[j,h]=l.useState(null),[E,L]=l.useState(null),[k,C]=l.useState(null),[M,m]=l.useState(null),[T,F]=l.useState(""),[G,D]=l.useState(null),[W,_]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),H=R.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),Q=l.useCallback(P=>{var i;return(i=r.find(c,{key:P}))==null?void 0:i.hasSlug},[c]),N=l.useMemo(()=>o?q?r.filter(o,P=>!(A!=null&&A[P.id])):le(o,w,T,Q):[],[o,Q,w,T,A,q]);l.useEffect(()=>{s(u)},[u,s]),l.useEffect(()=>{if(!r.isEmpty(T))return;const P=sessionStorage.getItem("pageTypeFilter")||"all";!r.isEmpty(c)&&P&&(r.find(c,{key:P})?F(P):F("all"))},[c,T]),l.useEffect(()=>{if(g&&!p&&!r.find(o,{id:g})){const i=r.find(o,{slug:"/"});if(i){const z=new URLSearchParams({page:i.id});f.navigateToPage(z,d)}else f.navigateToPage(new URLSearchParams({}),d,!0)}},[o,g,p,d]),l.useEffect(()=>{g&&!p&&!r.isEmpty(N)&&y(N,g)},[g,p,N,y]),l.useEffect(()=>{!r.isEmpty(w)&&!r.isEmpty(N)&&x(N)},[w,N,x]);const{setSelectedLang:U}=$.useLanguages(),V=l.useCallback(P=>{const i=new URLSearchParams({page:P});S!==u?(i.set("lang",S),U(S)):U(""),f.navigateToPage(i,d),e()},[e,d,U,S,u]),X=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":V(i);break;case"edit":S!==u?H({edit:!0,id:i==null?void 0:i.id,primaryPage:i==null?void 0:i.primaryPage}):L(i);break;case"delete":h(i);break;case"unpublish":C(i);break;case"markAsTemplate":m(i);break;case"unmarkAsTemplate":_(i);break;case"duplicate":D(i);break;case"addLanguagePage":H({edit:!1,primaryPage:((z=i==null?void 0:i.page)==null?void 0:z.id)||"",preselectedLang:(i==null?void 0:i.language)||S});break}};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex h-full flex-col justify-between",children:[t.jsx(l.Suspense,{children:t.jsx(xe,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>X("add",P),showUntranslatedPages:q,setShowUntranslatedPages:te})}),t.jsx("div",{className:"flex-1 overflow-y-auto px-4 pb-6 pt-2",children:p||se?t.jsx("div",{className:"space-y-2",children:r.map([...Array(15).keys()],P=>t.jsx("div",{className:"h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200"},P))}):r.isEmpty(N)?t.jsxs("div",{className:"flex h-[70vh] flex-col items-center justify-center gap-y-1 text-sm font-medium text-slate-500",children:[t.jsx(b.File,{className:"h-6 w-6 stroke-[1]"}),n("Empty List!"),t.jsx("span",{className:"font-light",children:n("Add new page to start")})]}):t.jsx(K,{tier:0,pages:N,pageTypes:c,currentPage:g||"",onClickAction:X,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(he,{closePanel:e,editPage:V,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(fe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:M,onClose:()=>m(null)})}),W&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:W,onClose:()=>_(null)})}),G&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:G,onClose:()=>D(null),closePanel:e})})]})};exports.default=je;
|
|
@@ -0,0 +1,394 @@
|
|
|
1
|
+
import { jsxs as y, Fragment as z, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { B as ye, n as ae } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { aA as be, aB as ge, ap as ke, k as ie, T as q, aQ as we, L as Ne, m as ve, g as Se, c as Le, av as Ae, aR as Te, aS as Q } from "./index-ZuacEL1j.js";
|
|
4
|
+
import { u as Y } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
5
|
+
import { compact as ce, filter as B, isEmpty as S, uniqBy as Ce, keyBy as de, mapValues as Ee, startCase as Me, toLower as E, includes as D, get as R, find as $, map as Ie } from "lodash-es";
|
|
6
|
+
import { atom as Ue, useAtom as $e, useSetAtom as Be } from "jotai";
|
|
7
|
+
import { ExternalLink as ze, NotepadText as Fe, MoreHorizontal as Oe, Lock as je, Edit as Ge, Plus as Re, ChevronRight as De, StarsIcon as We, Hash as _e, File as ue } from "lucide-react";
|
|
8
|
+
import { useRef as He, useEffect as I, useMemo as V, useState as N, useCallback as oe, Suspense as C, lazy as M } from "react";
|
|
9
|
+
import { useTranslation as qe } from "react-i18next";
|
|
10
|
+
const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
|
|
11
|
+
B(e, (r) => {
|
|
12
|
+
const n = E(s);
|
|
13
|
+
return D(E((r == null ? void 0 : r.name) || ""), n) || D(E((r == null ? void 0 : r.slug) || ""), n);
|
|
14
|
+
})
|
|
15
|
+
), Qe = (e, s) => {
|
|
16
|
+
const r = /* @__PURE__ */ new Set(), n = de(e, "id");
|
|
17
|
+
return s.forEach((l) => {
|
|
18
|
+
let a = l;
|
|
19
|
+
for (; a.parent && n[a.parent]; )
|
|
20
|
+
r.add(a.parent), a = n[a.parent];
|
|
21
|
+
}), Array.from(r).map((l) => n[l]);
|
|
22
|
+
}, X = (e, s, r) => S(s) ? e : e.map((n) => {
|
|
23
|
+
if (!r(n.pageType))
|
|
24
|
+
return {
|
|
25
|
+
...n,
|
|
26
|
+
shouldExpandOnSearch: !0,
|
|
27
|
+
children: n.children ? X(n.children, s, r) : []
|
|
28
|
+
};
|
|
29
|
+
const l = n.children && n.children.some(
|
|
30
|
+
(a) => D(E(a.name || ""), E(s)) || D(E(a.slug || ""), E(s))
|
|
31
|
+
);
|
|
32
|
+
return {
|
|
33
|
+
...n,
|
|
34
|
+
shouldExpandOnSearch: l,
|
|
35
|
+
children: n.children ? X(n.children, s, r) : []
|
|
36
|
+
};
|
|
37
|
+
}), Ve = (e) => {
|
|
38
|
+
if (!e || !e.length) return [];
|
|
39
|
+
const s = {};
|
|
40
|
+
e.forEach((n) => {
|
|
41
|
+
s[n.id] = { ...n, children: [] };
|
|
42
|
+
});
|
|
43
|
+
const r = [];
|
|
44
|
+
return Object.values(s).forEach((n) => {
|
|
45
|
+
n.parent && s[n.parent] ? s[n.parent].children.push(n) : r.push(n);
|
|
46
|
+
}), r;
|
|
47
|
+
}, me = (e) => !e || !e.length ? [] : [...e].sort(
|
|
48
|
+
(r, n) => (r.name || "").localeCompare(n.name || "")
|
|
49
|
+
).map((r) => ({
|
|
50
|
+
...r,
|
|
51
|
+
children: r.children ? me(r.children) : []
|
|
52
|
+
})), Xe = (e, s, r, n) => {
|
|
53
|
+
if (!e || !e.length) return [];
|
|
54
|
+
let l = e;
|
|
55
|
+
if (r !== "all" && (l = ce(B(e, { pageType: r }))), S(s))
|
|
56
|
+
l = le(l, s);
|
|
57
|
+
else {
|
|
58
|
+
const u = le(l, s), c = Qe(e, u);
|
|
59
|
+
l = Ce([...u, ...c], "id");
|
|
60
|
+
}
|
|
61
|
+
const a = me(Ve(l)), h = X(a, s, n), b = B(h, (u) => n(u.pageType)).sort((u, c) => (u.name || "").localeCompare(c.name || "")), i = B(h, (u) => !n(u.pageType));
|
|
62
|
+
let f = [];
|
|
63
|
+
if (r === "all") {
|
|
64
|
+
const u = de(i, "pageType");
|
|
65
|
+
f = Object.values(
|
|
66
|
+
Ee(u, (c, p) => ({
|
|
67
|
+
...c,
|
|
68
|
+
id: p,
|
|
69
|
+
name: Me(p),
|
|
70
|
+
isPartialGroup: !0,
|
|
71
|
+
children: h.filter((g) => g.pageType === p)
|
|
72
|
+
}))
|
|
73
|
+
);
|
|
74
|
+
} else
|
|
75
|
+
f = i.sort((u, c) => (u.name || "").localeCompare(c.name || ""));
|
|
76
|
+
return [...b, ...f];
|
|
77
|
+
}, Ye = Ue({
|
|
78
|
+
pageId: null,
|
|
79
|
+
position: { x: 0, y: 0 }
|
|
80
|
+
}), Je = ({ pageId: e, children: s }) => {
|
|
81
|
+
const [r, n] = $e(Ye), l = He(null), a = r.pageId === e;
|
|
82
|
+
I(() => {
|
|
83
|
+
const i = () => n({ pageId: null, position: { x: 0, y: 0 } });
|
|
84
|
+
if (a)
|
|
85
|
+
return document.addEventListener("click", i), () => document.removeEventListener("click", i);
|
|
86
|
+
}, [a, n]);
|
|
87
|
+
const h = (i) => {
|
|
88
|
+
i.preventDefault(), i.stopPropagation(), n({ pageId: e, position: { x: i.clientX, y: i.clientY } });
|
|
89
|
+
}, b = () => {
|
|
90
|
+
const i = `${window.location.pathname}?page=${e}`;
|
|
91
|
+
window.open(i, "_blank"), n({ pageId: null, position: { x: 0, y: 0 } });
|
|
92
|
+
};
|
|
93
|
+
return /* @__PURE__ */ y(z, { children: [
|
|
94
|
+
/* @__PURE__ */ t("span", { onContextMenu: h, children: s }),
|
|
95
|
+
a && /* @__PURE__ */ t(
|
|
96
|
+
"div",
|
|
97
|
+
{
|
|
98
|
+
ref: l,
|
|
99
|
+
className: "fixed z-[9999] max-w-[160px] rounded-md border border-gray-200 bg-white",
|
|
100
|
+
style: { top: r.position.y, left: r.position.x },
|
|
101
|
+
children: /* @__PURE__ */ t("div", { className: "", children: /* @__PURE__ */ y(
|
|
102
|
+
ye,
|
|
103
|
+
{
|
|
104
|
+
variant: "ghost",
|
|
105
|
+
onClick: b,
|
|
106
|
+
className: "w-full px-2.5 py-1 text-start text-sm text-gray-700 hover:bg-gray-100",
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ t(ze, { className: "h-4 w-4" }),
|
|
109
|
+
"Open in new tab"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
) })
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] });
|
|
116
|
+
}, Ke = ({ page: e }) => {
|
|
117
|
+
var n, l;
|
|
118
|
+
const { isExpanded: s, toggleExpanded: r } = Y(e == null ? void 0 : e.id);
|
|
119
|
+
return /* @__PURE__ */ t(
|
|
120
|
+
"button",
|
|
121
|
+
{
|
|
122
|
+
onClick: (a) => {
|
|
123
|
+
a.stopPropagation(), r();
|
|
124
|
+
},
|
|
125
|
+
disabled: !((n = e == null ? void 0 : e.children) != null && n.length),
|
|
126
|
+
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 ${(l = e == null ? void 0 : e.children) != null && l.length ? "hover:text-blue-400" : "opacity-0"}`,
|
|
127
|
+
children: /* @__PURE__ */ t(
|
|
128
|
+
De,
|
|
129
|
+
{
|
|
130
|
+
size: 12,
|
|
131
|
+
className: `stroke-[4] transition-transform duration-200 ${s ? "rotate-90" : ""}`
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
}, Ze = ({ page: e, pageType: s }) => /* @__PURE__ */ t("div", { className: "flex h-full items-center justify-center gap-x-1", children: e.dynamic ? /* @__PURE__ */ t(We, { size: 12, className: "text-yellow-400" }) : s != null && s.icon ? /* @__PURE__ */ t(
|
|
137
|
+
"div",
|
|
138
|
+
{
|
|
139
|
+
className: "flex h-4 max-h-4 w-4 max-w-4 items-center justify-center stroke-[1] text-slate-500",
|
|
140
|
+
dangerouslySetInnerHTML: { __html: s.icon }
|
|
141
|
+
}
|
|
142
|
+
) : s != null && s.hasSlug ? /* @__PURE__ */ t(ue, { size: 12, className: "stroke-[1] text-slate-500" }) : /* @__PURE__ */ t(_e, { size: 12, className: "stroke-[1] text-slate-500" }) }), et = ({ isOnline: e }) => /* @__PURE__ */ t("div", { className: `h-2 w-2 rounded-full ${e ? "bg-green-300" : "bg-gray-300"}` }), tt = ({
|
|
143
|
+
page: e,
|
|
144
|
+
pageTypes: s,
|
|
145
|
+
currentPage: r,
|
|
146
|
+
onClickAction: n,
|
|
147
|
+
languagePages: l,
|
|
148
|
+
selectedLanguage: a,
|
|
149
|
+
showUntranslatedPages: h
|
|
150
|
+
}) => {
|
|
151
|
+
const b = be(), { pageToUser: i } = ge(), f = R(i, [e == null ? void 0 : e.id, "userId"]), { data: u } = ke(f), c = u && b !== f ? u == null ? void 0 : u.name : null, p = ie(), g = r === e.id, W = !!e.isTemplate, P = V(() => $(s, { key: e.pageType }), [s, e.pageType]);
|
|
152
|
+
let m = R(l, e == null ? void 0 : e.id);
|
|
153
|
+
m = R(m, "lang") === a ? m : null;
|
|
154
|
+
const L = a === p || !!m, A = (m == null ? void 0 : m.name) || (e == null ? void 0 : e.name) || "No name";
|
|
155
|
+
let k = (m == null ? void 0 : m.slug) || (e == null ? void 0 : e.slug) || "";
|
|
156
|
+
const F = k + (e != null && e.dynamic ? `/${P == null ? void 0 : P.dynamicSlug}` : "") + (e != null && e.dynamicSlugCustom ? `${e.dynamicSlugCustom}` : "");
|
|
157
|
+
if (k.startsWith("/") && !h) {
|
|
158
|
+
const d = k.split("/").pop();
|
|
159
|
+
k = k.endsWith(d) && e.dynamic ? "" : `/${d}`;
|
|
160
|
+
}
|
|
161
|
+
const O = V(() => {
|
|
162
|
+
const d = "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]", T = `${g ? "border-primary/30 bg-primary/5" : "border-transparent hover:border-gray-200 hover:bg-gray-100"}`;
|
|
163
|
+
return L ? `${d} ${T} ${c ? "opacity-60" : ""}` : `${d} bg-gray-100 opacity-50 group-hover:border-gray-200 border-transparent group-hover:bg-blue-100`;
|
|
164
|
+
}, [L, g, c]);
|
|
165
|
+
return /* @__PURE__ */ y("div", { className: "group relative", children: [
|
|
166
|
+
/* @__PURE__ */ t(Je, { pageId: e.id, children: /* @__PURE__ */ y(
|
|
167
|
+
"div",
|
|
168
|
+
{
|
|
169
|
+
onClick: () => !e.isPartialGroup && L && n("select", e == null ? void 0 : e.id),
|
|
170
|
+
className: O,
|
|
171
|
+
children: [
|
|
172
|
+
/* @__PURE__ */ t(Ke, { page: e }),
|
|
173
|
+
!e.isPartialGroup && /* @__PURE__ */ t(et, { isOnline: m ? m.online : e.online }),
|
|
174
|
+
!e.isPartialGroup && /* @__PURE__ */ t(Ze, { page: e, pageType: P }),
|
|
175
|
+
/* @__PURE__ */ t(q, { content: A, side: "top", showTooltip: A.length > 35, children: /* @__PURE__ */ t("span", { className: "max-w-[40%] truncate font-medium text-black", children: A }) }),
|
|
176
|
+
(k || e.dynamic) && /* @__PURE__ */ t(q, { content: F, side: "top", showTooltip: !0, children: /* @__PURE__ */ y("span", { className: "max-w-[40%] truncate font-mono text-xs text-muted-foreground", children: [
|
|
177
|
+
k,
|
|
178
|
+
e.dynamic && (P == null ? void 0 : P.dynamicSlug) && /* @__PURE__ */ y("span", { className: "text-xs text-gray-500", children: [
|
|
179
|
+
"/",
|
|
180
|
+
P == null ? void 0 : P.dynamicSlug,
|
|
181
|
+
e.dynamicSlugCustom
|
|
182
|
+
] })
|
|
183
|
+
] }) }),
|
|
184
|
+
W && /* @__PURE__ */ t(q, { content: "Template", side: "top", children: /* @__PURE__ */ t("span", { className: "text-blue-500", children: /* @__PURE__ */ t(Fe, { size: 16 }) }) }),
|
|
185
|
+
!e.isPartialGroup && L && !c ? /* @__PURE__ */ t("div", { className: "duration absolute right-0.5 top-[3px]", children: /* @__PURE__ */ t(
|
|
186
|
+
we,
|
|
187
|
+
{
|
|
188
|
+
isLanguagePage: !!m,
|
|
189
|
+
page: m || e,
|
|
190
|
+
setDuplicatePage: (d) => n("duplicate", d),
|
|
191
|
+
setAddEditPage: (d) => n("edit", m || d),
|
|
192
|
+
setUnpublishPage: (d) => n("unpublish", d),
|
|
193
|
+
setDeletePage: (d) => n("delete", m || d),
|
|
194
|
+
setMarkAsTemplate: (d) => n("markAsTemplate", d),
|
|
195
|
+
setUnmarkAsTemplate: (d) => n("unmarkAsTemplate", d),
|
|
196
|
+
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(Oe, { className: "h-4 w-4", onClick: (d) => d.stopPropagation() }) })
|
|
197
|
+
}
|
|
198
|
+
) }) : c ? /* @__PURE__ */ t("span", { className: "duration absolute right-1.5 top-1/2 -translate-y-1/2 text-xs text-gray-500", children: /* @__PURE__ */ t(je, { className: "h-3.5 w-3.5 fill-red-200 text-red-500" }) }) : null
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
) }),
|
|
202
|
+
/* @__PURE__ */ t(z, { children: c && /* @__PURE__ */ y("button", { className: "absolute right-px top-1/2 flex h-6 -translate-y-1/2 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: [
|
|
203
|
+
/* @__PURE__ */ t(Ge, { size: 12, className: "stroke-[3]" }),
|
|
204
|
+
" ",
|
|
205
|
+
/* @__PURE__ */ t("span", { className: "font-medium", children: c }),
|
|
206
|
+
" is editing this page"
|
|
207
|
+
] }) }),
|
|
208
|
+
/* @__PURE__ */ t(z, { children: !L && !e.isPartialGroup && !c && /* @__PURE__ */ y(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
onClick: (d) => {
|
|
212
|
+
d.stopPropagation(), n("addLanguagePage", { language: a, page: e });
|
|
213
|
+
},
|
|
214
|
+
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",
|
|
215
|
+
children: [
|
|
216
|
+
/* @__PURE__ */ t(Re, { size: 12, className: "stroke-[3]" }),
|
|
217
|
+
" ",
|
|
218
|
+
/* @__PURE__ */ y("span", { className: "text-[10px]", children: [
|
|
219
|
+
"Add ",
|
|
220
|
+
R(Ne, a),
|
|
221
|
+
" Page"
|
|
222
|
+
] })
|
|
223
|
+
]
|
|
224
|
+
}
|
|
225
|
+
) })
|
|
226
|
+
] });
|
|
227
|
+
}, he = ({
|
|
228
|
+
pages: e,
|
|
229
|
+
tier: s,
|
|
230
|
+
pageTypes: r,
|
|
231
|
+
currentPage: n,
|
|
232
|
+
onClickAction: l,
|
|
233
|
+
languagePages: a,
|
|
234
|
+
selectedLanguage: h,
|
|
235
|
+
showUntranslatedPages: b
|
|
236
|
+
}) => {
|
|
237
|
+
const { expandedPages: i } = Y();
|
|
238
|
+
return /* @__PURE__ */ t("div", { className: "space-y-0.5", style: { paddingLeft: `${s * 10}px` }, children: e.map((f) => /* @__PURE__ */ y(z, { children: [
|
|
239
|
+
/* @__PURE__ */ t(
|
|
240
|
+
tt,
|
|
241
|
+
{
|
|
242
|
+
page: f,
|
|
243
|
+
pageTypes: r,
|
|
244
|
+
currentPage: n,
|
|
245
|
+
onClickAction: l,
|
|
246
|
+
languagePages: a,
|
|
247
|
+
selectedLanguage: h,
|
|
248
|
+
showUntranslatedPages: b
|
|
249
|
+
}
|
|
250
|
+
),
|
|
251
|
+
f.children && f.children.length > 0 && (i == null ? void 0 : i.includes(f.id)) && /* @__PURE__ */ t(
|
|
252
|
+
he,
|
|
253
|
+
{
|
|
254
|
+
pages: f.children,
|
|
255
|
+
tier: s + 1,
|
|
256
|
+
pageTypes: r,
|
|
257
|
+
currentPage: n,
|
|
258
|
+
onClickAction: l,
|
|
259
|
+
languagePages: a,
|
|
260
|
+
selectedLanguage: h,
|
|
261
|
+
showUntranslatedPages: b
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
] }, f.id)) });
|
|
265
|
+
}, nt = M(() => import("./page-manager-search-and-filter-CM0UMb6U.js")), st = M(() => import("./add-new-page-VW2wAYZp.js")), rt = M(() => import("./delete-page-BzyX9TN-.js")), at = M(() => import("./duplicate-page-BR7Dlo9d.js")), ot = M(() => import("./mark-as-template-D295ZQtU.js")), lt = M(() => import("./unmark-as-template-CZ9sQp_P.js")), it = M(() => import("./unpublish-page-D4VwOlxc.js")), yt = ({ close: e }) => {
|
|
266
|
+
const { t: s } = qe(), { languages: r, setSelectedLang: n } = ae(), { data: l } = ve(), { data: a, isFetching: h } = Se(), [b, i] = Le(), { updateForSelectedPage: f, expandPagesOnSearch: u } = Y(null), c = ie(), p = b.get("page"), [g, W] = N(""), [P, m] = N(null), [L, A] = N(null), [k, F] = N(null), [O, d] = N(null), [T, _] = N(""), [J, K] = N(null), [Z, ee] = N(null), [w, fe] = N(c), [xe, pe] = N(!1), te = Be(Ae), j = xe && w !== c, { data: U, isFetching: Pe } = Te(w), ne = oe(
|
|
267
|
+
(x) => {
|
|
268
|
+
var o;
|
|
269
|
+
return (o = $(l, { key: x })) == null ? void 0 : o.hasSlug;
|
|
270
|
+
},
|
|
271
|
+
[l]
|
|
272
|
+
), v = V(() => a ? j ? B(a, (x) => !(U != null && U[x.id])) : Xe(a, g, T, ne) : [], [a, ne, g, T, U, j]);
|
|
273
|
+
I(() => {
|
|
274
|
+
n(c);
|
|
275
|
+
}, [c, n]), I(() => {
|
|
276
|
+
if (!S(T)) return;
|
|
277
|
+
const x = sessionStorage.getItem("pageTypeFilter") || "all";
|
|
278
|
+
!S(l) && x && ($(l, { key: x }) ? _(x) : _("all"));
|
|
279
|
+
}, [l, T]), I(() => {
|
|
280
|
+
if (p && !h && !$(a, { id: p })) {
|
|
281
|
+
const o = $(a, { slug: "/" });
|
|
282
|
+
if (o) {
|
|
283
|
+
const G = new URLSearchParams({ page: o.id });
|
|
284
|
+
Q(G, i);
|
|
285
|
+
} else
|
|
286
|
+
Q(new URLSearchParams({}), i, !0);
|
|
287
|
+
}
|
|
288
|
+
}, [a, p, h, i]), I(() => {
|
|
289
|
+
p && !h && !S(v) && f(v, p);
|
|
290
|
+
}, [p, h, v, f]), I(() => {
|
|
291
|
+
!S(g) && !S(v) && u(v);
|
|
292
|
+
}, [g, v, u]);
|
|
293
|
+
const { setSelectedLang: H } = ae(), se = oe(
|
|
294
|
+
(x) => {
|
|
295
|
+
const o = new URLSearchParams({ page: x });
|
|
296
|
+
w !== c ? (o.set("lang", w), H(w)) : H(""), Q(o, i), e();
|
|
297
|
+
},
|
|
298
|
+
[e, i, H, w, c]
|
|
299
|
+
), re = (x, o) => {
|
|
300
|
+
var G;
|
|
301
|
+
if (o)
|
|
302
|
+
switch (x) {
|
|
303
|
+
case "add":
|
|
304
|
+
A(o);
|
|
305
|
+
break;
|
|
306
|
+
case "select":
|
|
307
|
+
se(o);
|
|
308
|
+
break;
|
|
309
|
+
case "edit":
|
|
310
|
+
w !== c ? te({
|
|
311
|
+
edit: !0,
|
|
312
|
+
id: o == null ? void 0 : o.id,
|
|
313
|
+
primaryPage: o == null ? void 0 : o.primaryPage
|
|
314
|
+
}) : A(o);
|
|
315
|
+
break;
|
|
316
|
+
case "delete":
|
|
317
|
+
m(o);
|
|
318
|
+
break;
|
|
319
|
+
case "unpublish":
|
|
320
|
+
F(o);
|
|
321
|
+
break;
|
|
322
|
+
case "markAsTemplate":
|
|
323
|
+
d(o);
|
|
324
|
+
break;
|
|
325
|
+
case "unmarkAsTemplate":
|
|
326
|
+
ee(o);
|
|
327
|
+
break;
|
|
328
|
+
case "duplicate":
|
|
329
|
+
K(o);
|
|
330
|
+
break;
|
|
331
|
+
case "addLanguagePage":
|
|
332
|
+
te({
|
|
333
|
+
edit: !1,
|
|
334
|
+
primaryPage: ((G = o == null ? void 0 : o.page) == null ? void 0 : G.id) || "",
|
|
335
|
+
preselectedLang: (o == null ? void 0 : o.language) || w
|
|
336
|
+
});
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
return /* @__PURE__ */ y(z, { children: [
|
|
341
|
+
/* @__PURE__ */ y("div", { className: "flex h-full flex-col justify-between", children: [
|
|
342
|
+
/* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
|
|
343
|
+
nt,
|
|
344
|
+
{
|
|
345
|
+
pages: v,
|
|
346
|
+
search: g,
|
|
347
|
+
setSearch: W,
|
|
348
|
+
languages: [c, ...r],
|
|
349
|
+
selectedLanguage: w,
|
|
350
|
+
setSelectedLanguage: fe,
|
|
351
|
+
selectedPageType: T,
|
|
352
|
+
setSelectedPageType: _,
|
|
353
|
+
onAddPage: (x) => re("add", x),
|
|
354
|
+
showUntranslatedPages: j,
|
|
355
|
+
setShowUntranslatedPages: pe
|
|
356
|
+
}
|
|
357
|
+
) }),
|
|
358
|
+
/* @__PURE__ */ t("div", { className: "flex-1 overflow-y-auto px-4 pb-6 pt-2", children: h || Pe ? /* @__PURE__ */ t("div", { className: "space-y-2", children: Ie([...Array(15).keys()], (x) => /* @__PURE__ */ t("div", { className: "h-7 w-full animate-pulse rounded border border-gray-300 bg-gray-200" }, x)) }) : 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: [
|
|
359
|
+
/* @__PURE__ */ t(ue, { className: "h-6 w-6 stroke-[1]" }),
|
|
360
|
+
s("Empty List!"),
|
|
361
|
+
/* @__PURE__ */ t("span", { className: "font-light", children: s("Add new page to start") })
|
|
362
|
+
] }) : /* @__PURE__ */ t(
|
|
363
|
+
he,
|
|
364
|
+
{
|
|
365
|
+
tier: 0,
|
|
366
|
+
pages: v,
|
|
367
|
+
pageTypes: l,
|
|
368
|
+
currentPage: p || "",
|
|
369
|
+
onClickAction: re,
|
|
370
|
+
languagePages: U,
|
|
371
|
+
selectedLanguage: w,
|
|
372
|
+
showUntranslatedPages: j
|
|
373
|
+
}
|
|
374
|
+
) })
|
|
375
|
+
] }),
|
|
376
|
+
L && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(
|
|
377
|
+
st,
|
|
378
|
+
{
|
|
379
|
+
closePanel: e,
|
|
380
|
+
editPage: se,
|
|
381
|
+
addEditPage: L,
|
|
382
|
+
setAddEditPage: A
|
|
383
|
+
}
|
|
384
|
+
) }),
|
|
385
|
+
P && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(rt, { page: P, onClose: () => m(null) }) }),
|
|
386
|
+
k && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(it, { page: k, onClose: () => F(null) }) }),
|
|
387
|
+
O && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(ot, { page: O, onClose: () => d(null) }) }),
|
|
388
|
+
Z && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(lt, { page: Z, onClose: () => ee(null) }) }),
|
|
389
|
+
J && /* @__PURE__ */ t(C, { children: /* @__PURE__ */ t(at, { page: J, onClose: () => K(null), closePanel: e }) })
|
|
390
|
+
] });
|
|
391
|
+
};
|
|
392
|
+
export {
|
|
393
|
+
yt as default
|
|
394
|
+
};
|