@chaibuilder/sdk 4.0.0-beta.7 → 4.0.0-beta.8
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 +1 -3
- package/dist/{2SSKDMRQ-DDOgISWg.cjs → 2SSKDMRQ-DHv4u_0i.cjs} +1 -1
- package/dist/{2SSKDMRQ-hL7THuKW.js → 2SSKDMRQ-DewwiCoQ.js} +2 -2
- package/dist/{AP7HFJJL-BsLQ13V_.js → AP7HFJJL-ComnZw7J.js} +1 -1
- package/dist/{AP7HFJJL-tcAhVllC.cjs → AP7HFJJL-cz754qhG.cjs} +1 -1
- package/dist/{IconPicker-FLSVAZxx.js → IconPicker-2H9IGKMS.js} +2 -2
- package/dist/{IconPicker-J1KLNrSB.cjs → IconPicker-U0Z2dWeR.cjs} +1 -1
- package/dist/{WDYDFRGG-BTj8AXV6.cjs → WDYDFRGG-BfRX3M58.cjs} +1 -1
- package/dist/{WDYDFRGG-Yi0eNS2V.js → WDYDFRGG-vy7nMYD4.js} +2 -2
- package/dist/{active-in-another-tab-Dozn833d.js → active-in-another-tab-5hn17Jeq.js} +3 -3
- package/dist/{active-in-another-tab-BtAiatqq.cjs → active-in-another-tab-ijahI5qu.cjs} +1 -1
- package/dist/{add-new-language-page-DD-CAoAQ.js → add-new-language-page-DmOyPy0u.js} +4 -4
- package/dist/{add-new-language-page-9AMizlES.cjs → add-new-language-page-vmNKNx-e.cjs} +1 -1
- package/dist/{add-new-page-uZKCk9eB.js → add-new-page-NHScAQn8.js} +2 -2
- package/dist/{add-new-page-BS9vPnFG.cjs → add-new-page-XDuCkOyb.cjs} +1 -1
- package/dist/{ai-panel-content-PovaKJaj.cjs → ai-panel-content-BDqW16AW.cjs} +1 -1
- package/dist/{ai-panel-content-CK4XOkEh.js → ai-panel-content-CHJ0JcQI.js} +4 -4
- package/dist/{ai-panel-default-lang-BtLjUl9d.js → ai-panel-default-lang-BIomgsN0.js} +4 -4
- package/dist/{ai-panel-default-lang-B37k5ADH.cjs → ai-panel-default-lang-HeYWpbMu.cjs} +2 -2
- package/dist/{ai-panel-other-lang-CdQmASqv.cjs → ai-panel-other-lang-BMelEs3p.cjs} +1 -1
- package/dist/{ai-panel-other-lang-Dp1MNaLi.js → ai-panel-other-lang-CbAgG-qX.js} +3 -3
- package/dist/{ai-prompt-input-BT-mEdTX.js → ai-prompt-input-BH8LOVT4.js} +2 -2
- package/dist/{ai-prompt-input-Dtym4w8J.cjs → ai-prompt-input-C_GG6nwq.cjs} +1 -1
- package/dist/{ai-translation-prompt-B-lH7emI.cjs → ai-translation-prompt-CkHaFv5I.cjs} +1 -1
- package/dist/{ai-translation-prompt-B17GK1QR.js → ai-translation-prompt-DxsNw8YR.js} +2 -2
- package/dist/{code-display-DloSPyPr.cjs → code-display-9Onx6RCq.cjs} +1 -1
- package/dist/{code-display-Ck81Id9K.js → code-display-oa1j0ri7.js} +1 -1
- package/dist/{code-editor-EZT2pMsU.js → code-editor-CGBAc-A6.js} +1 -1
- package/dist/{code-editor-CUeNiMzA.cjs → code-editor-GV8ibQ4h.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-DMZOc36k.cjs → continue-editing-in-this-client-DKHP0pq8.cjs} +1 -1
- package/dist/{continue-editing-in-this-client-CS7C6h9Q.js → continue-editing-in-this-client-Da8ab_9d.js} +3 -3
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +1 -90
- package/dist/core.js +22 -34
- package/dist/css-import-modal-B4j26_cO.cjs +13 -0
- package/dist/{css-import-modal-s7t5gZQo.js → css-import-modal-CcZVLsF9.js} +5 -4
- package/dist/{delete-design-token-Mbw_6sYI.cjs → delete-design-token-3-WwqXMO.cjs} +1 -1
- package/dist/{delete-design-token-C1smbx4E.js → delete-design-token-DzINIVtO.js} +1 -1
- package/dist/{delete-page-B7J3t0FN.cjs → delete-page-B7ODELqM.cjs} +1 -1
- package/dist/{delete-page-2GfBi8Iv.js → delete-page-DwZDMwfI.js} +3 -3
- package/dist/{design-token-usage-DyO3xM-F.js → design-token-usage-DQf180Lg.js} +2 -2
- package/dist/{design-token-usage-BoGOULG8.cjs → design-token-usage-Dy08kcIc.cjs} +1 -1
- package/dist/{digital-asset-manager-DDk2ucTE.cjs → digital-asset-manager-C7subULa.cjs} +1 -1
- package/dist/{digital-asset-manager-Cz3Nlrzl.js → digital-asset-manager-CDy9kHZO.js} +4 -4
- package/dist/{duplicate-page-Dw3U4wTT.cjs → duplicate-page-CWQ9aMd9.cjs} +1 -1
- package/dist/{duplicate-page-BwAY4Ssm.js → duplicate-page-DTnSztlr.js} +4 -4
- package/dist/{dynamic-page-selector-CvBFyX2F.cjs → dynamic-page-selector-DJuxLcsM.cjs} +1 -1
- package/dist/{dynamic-page-selector-sViJuQlU.js → dynamic-page-selector-DYW3ov_u.js} +3 -3
- package/dist/{image-editor-AIsccrqC.cjs → image-editor-C4H3AkZK.cjs} +1 -1
- package/dist/{image-editor-BgGQuESa.js → image-editor-DLeSST0K.js} +1 -1
- package/dist/{index-RYr8kQdI.js → index-BK0xWO1z.js} +5132 -5602
- package/dist/{index-BwH1mRm_.cjs → index-BRJCj7c_.cjs} +2 -2
- package/dist/index-Bm8iS2OH.cjs +160 -0
- package/dist/{index-B7eWP_hB.js → index-D5d4QDq7.js} +19 -21
- package/dist/{json-diff-viewer-Svw-kbhe.js → json-diff-viewer-BYHieVod.js} +3 -3
- package/dist/{json-diff-viewer-B2A78udz.cjs → json-diff-viewer-g6SY62bl.cjs} +1 -1
- package/dist/{lang-panel-Bnc-9wkM.js → lang-panel-BG1GMn-1.js} +4 -4
- package/dist/{lang-panel-AmEkoWid.cjs → lang-panel-Dm1eOO2J.cjs} +1 -1
- package/dist/{manage-design-tokens-BBkh1t4w.js → manage-design-tokens-BdWQUHhw.js} +3 -3
- package/dist/{manage-design-tokens-B2fG80bi.cjs → manage-design-tokens-XWs_B6jo.cjs} +1 -1
- package/dist/{mark-as-template-0CPzZnk-.js → mark-as-template-D2XxagVO.js} +3 -3
- package/dist/{mark-as-template-CE6tRoQy.cjs → mark-as-template-DUFnfVM3.cjs} +1 -1
- package/dist/{nested-path-selector-content-SmfjElr-.cjs → nested-path-selector-content-CQOx2L9C.cjs} +1 -1
- package/dist/{nested-path-selector-content-kGznHufl.js → nested-path-selector-content-Wd6-Eql0.js} +2 -2
- package/dist/{no-language-page-content-DXsAPDZd.js → no-language-page-content-BOv6TZIk.js} +3 -3
- package/dist/{no-language-page-content-B4bQLc4K.cjs → no-language-page-content-C11uF6hs.cjs} +1 -1
- package/dist/{no-language-page-dialog-BC8NHzK2.cjs → no-language-page-dialog-CY5XhXsC.cjs} +1 -1
- package/dist/{no-language-page-dialog-BpPqmw9a.js → no-language-page-dialog-DIXyKRJq.js} +2 -2
- package/dist/{page-creator-Bazn6yH4.js → page-creator-WX9lMrJY.js} +4 -4
- package/dist/{page-creator-82qTbBj4.cjs → page-creator-zSUFF4eT.cjs} +1 -1
- package/dist/{page-lock-CRFyqKZE.js → page-lock-D9miLZjm.js} +2 -2
- package/dist/{page-lock-D2iFZDUK.cjs → page-lock-DGhR_url.cjs} +1 -1
- package/dist/{page-locked-dialog-GKfQEOmk.js → page-locked-dialog-CNCUCcvH.js} +3 -3
- package/dist/{page-locked-dialog-xLqvKzax.cjs → page-locked-dialog-DTLnbfuP.cjs} +1 -1
- package/dist/{page-manager-new-DItY2hjd.js → page-manager-new-BFFOLh-l.js} +4 -4
- package/dist/{page-manager-new-Bn2QKjbf.cjs → page-manager-new-Dd2c-Q_O.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-Dc4ky-qV.cjs → page-manager-search-and-filter-BKdQUJ2W.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-CPa8IXdd.js → page-manager-search-and-filter-C1IWF_4d.js} +3 -3
- package/dist/page-revisions-content-D0cflnj1.cjs +1 -0
- package/dist/{page-revisions-content-CH-PZK0O.js → page-revisions-content-DHapiLck.js} +75 -67
- package/dist/pages.cjs +1 -1
- package/dist/pages.d.ts +2 -1
- package/dist/pages.js +1 -1
- package/dist/{publish-pages-content-CSJCFElu.js → publish-pages-content-Bd2zJHtK.js} +4 -4
- package/dist/{publish-pages-content-BzJDObqr.cjs → publish-pages-content-BqLcnKry.cjs} +1 -1
- package/dist/{register-chai-top-bar-ESJHs5s-.js → register-chai-top-bar-CX_JkRJn.js} +78 -78
- package/dist/register-chai-top-bar-DWTuRU53.cjs +1 -0
- package/dist/render.d.ts +2 -1
- package/dist/{rte-widget-modal-BfXcA7OP.cjs → rte-widget-modal-DiB5BjH1.cjs} +1 -1
- package/dist/{rte-widget-modal-5T81P_hg.js → rte-widget-modal-RS8PMKOn.js} +7 -7
- package/dist/runtime-client.cjs +1 -0
- package/dist/runtime-client.d.ts +158 -0
- package/dist/runtime-client.js +32 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +1 -163
- package/dist/runtime.js +71 -72
- package/dist/{save-to-lib-MtWKSVeN.js → save-to-lib--6ZXHEbC.js} +3 -3
- package/dist/{save-to-lib-DGAdSa-0.cjs → save-to-lib-BXJvaC1N.cjs} +1 -1
- package/dist/{selected-block-display-DLt_nMn9.cjs → selected-block-display-BfpJda4h.cjs} +1 -1
- package/dist/{selected-block-display-CB1-hVR5.js → selected-block-display-CUnCqXQw.js} +3 -3
- package/dist/{seo-panel-CRzzw4FW.js → seo-panel-Bs-FcY1A.js} +3 -3
- package/dist/{seo-panel-_kGXE9MC.cjs → seo-panel-CQITMfZ6.cjs} +1 -1
- package/dist/{shared-json-ld-CXukkDeS.js → shared-json-ld-7EujD341.js} +3 -3
- package/dist/{shared-json-ld-DoRgzDPC.cjs → shared-json-ld-DDXXi-Mj.cjs} +1 -1
- package/dist/{slug-input-Dp187Tiy.cjs → slug-input-CsVJAr7r.cjs} +1 -1
- package/dist/{slug-input-CeEQ0zyv.js → slug-input-DoEIq5rs.js} +2 -2
- package/dist/{take-over-request-C9J3_rev.js → take-over-request-C14kJ356.js} +3 -3
- package/dist/{take-over-request-CXuakFBm.cjs → take-over-request-D5Oo3MPo.cjs} +1 -1
- package/dist/{theme-panel-footer-DvwsyHNQ.js → theme-panel-footer-Dvknelm8.js} +3 -3
- package/dist/{theme-panel-footer-CWZ0qs13.cjs → theme-panel-footer-Eeibz2JA.cjs} +1 -1
- package/dist/{translation-warning-modal-DEt_ExQp.cjs → translation-warning-modal-CPzdHzqq.cjs} +1 -1
- package/dist/{translation-warning-modal-_aBp5ZZQ.js → translation-warning-modal-YlzP2XoO.js} +2 -2
- package/dist/{unmark-as-template-BYL5naYx.cjs → unmark-as-template-BGDwuCnv.cjs} +1 -1
- package/dist/{unmark-as-template-JN-cDUV_.js → unmark-as-template-CPJvQk7L.js} +3 -3
- package/dist/{unpublish-page-B06iZEIO.cjs → unpublish-page-BMowW5wT.cjs} +1 -1
- package/dist/{unpublish-page-DqwBY2yI.js → unpublish-page-DlFHLlmI.js} +3 -3
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +43 -43
- package/dist/{web-preview-h39D3TUh.js → web-preview-BUnv3jIc.js} +2 -2
- package/dist/{web-preview-wRgRY3Tv.cjs → web-preview-D8GQHCjs.cjs} +1 -1
- package/package.json +8 -7
- package/dist/css-import-modal-kHB0ramf.cjs +0 -13
- package/dist/index-B-rSiAp_.cjs +0 -1
- package/dist/index-Dxfyt4d4.js +0 -39
- package/dist/index-xYnNKovy.cjs +0 -160
- package/dist/page-revisions-content-CcLFI4YK.cjs +0 -1
- package/dist/register-chai-top-bar-BqwKw4uy.cjs +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
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-
|
|
2
|
+
import { u as E, a as c, b as T, P as e, A as l, B as I, E as _ } from "./index-D5d4QDq7.js";
|
|
3
3
|
import { useQueryClient as C } from "@tanstack/react-query";
|
|
4
4
|
import { useRef as p, useEffect as N, Suspense as A, lazy as s } from "react";
|
|
5
|
-
const m = s(() => import("./take-over-request-
|
|
5
|
+
const m = s(() => import("./take-over-request-C14kJ356.js")), f = s(() => import("./page-locked-dialog-CNCUCcvH.js")), O = s(() => import("./active-in-another-tab-5hn17Jeq.js")), S = s(() => import("./continue-editing-in-this-client-Da8ab_9d.js")), r = (a) => /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(a, {}) }), L = ({ isFetchingPageData: a }) => {
|
|
6
6
|
E();
|
|
7
7
|
const { pageStatus: t } = c(), { pageLockMeta: o } = T(), u = C(), i = p(t);
|
|
8
8
|
if (N(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),e=require("./index-BRJCj7c_.cjs"),E=require("@tanstack/react-query"),r=require("react"),c=r.lazy(()=>Promise.resolve().then(()=>require("./take-over-request-D5Oo3MPo.cjs"))),o=r.lazy(()=>Promise.resolve().then(()=>require("./page-locked-dialog-DTLnbfuP.cjs"))),l=r.lazy(()=>Promise.resolve().then(()=>require("./active-in-another-tab-ijahI5qu.cjs"))),S=r.lazy(()=>Promise.resolve().then(()=>require("./continue-editing-in-this-client-DKHP0pq8.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;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import { R as O, U as w, V as A, W as S, X as F, Y as K, Z as U, _ as V, $ as I } from "./index-
|
|
3
|
-
import { B as p } from "./register-chai-top-bar-
|
|
4
|
-
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-
|
|
2
|
+
import { R as O, U as w, V as A, W as S, X as F, Y as K, Z as U, _ as V, $ as I } from "./index-BK0xWO1z.js";
|
|
3
|
+
import { B as p } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
4
|
+
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-D5d4QDq7.js";
|
|
5
5
|
import { LockKeyhole as G, UserIcon as H, AlertCircleIcon as J, X, Edit as z, ShieldAlert as v } from "lucide-react";
|
|
6
6
|
import { useState as f, useRef as W, useEffect as Y, startTransition as Z } from "react";
|
|
7
7
|
import { useTranslation as $ } from "react-i18next";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("./index-Bm8iS2OH.cjs"),p=require("./register-chai-top-bar-DWTuRU53.cjs"),t=require("./index-BRJCj7c_.cjs"),c=require("lucide-react"),d=require("react"),O=require("react-i18next"),_=()=>{const m=t.useCurrentPageOwner(),f=t.useSendRealtimeEvent(),{setPageStatus:j}=t.usePageLockStatus(),{data:s,isFetching:v}=t.useChaiUserInfo((m==null?void 0:m.userId)||""),{pageLockMeta:o,setPageLockMeta:g}=t.usePageLockMeta(),{t:r}=O.useTranslation(),[u,i]=d.useState(""),[a,N]=d.useState({}),[T,k]=d.useState(!1),l=d.useRef(null);d.useEffect(()=>{o!=null&&o.type&&(l.current&&clearTimeout(l.current),d.startTransition(()=>{N(o),g({}),i("")}))},[o,g]);const b=()=>{u!==t.EVENT.TAKE_OVER_REQUEST&&(i(t.EVENT.TAKE_OVER_REQUEST),f(t.EVENT.TAKE_OVER_REQUEST),l.current=setTimeout(()=>i(""),2e4))},R=()=>{u!==t.EVENT.FORCE_TAKE_OVER_REQUEST&&(i(t.EVENT.FORCE_TAKE_OVER_REQUEST),f(t.EVENT.FORCE_TAKE_OVER_REQUEST),j(t.PAGE_STATUS.CHECKING),l.current=setTimeout(()=>i(""),2e4))},y=()=>{N({}),l.current&&clearTimeout(l.current),i("")},x=v?"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(n.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(n.CardHeader,{className:"space-y-1 border-b pb-3",children:e.jsxs(n.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:r("Page Locked for Editing")})]})}),e.jsxs(n.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})]})]})]}),((a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED||(a==null?void 0:a.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"}),(a==null?void 0:a.type)===t.EVENT.TAKE_OVER_REJECTED?" rejected your take over request.":" forcefully took over this page."]})]}),e.jsx(p.Button,{size:"icon",variant:"ghost",onClick:y,className:"flex-shrink-0",children:e.jsx(c.X,{className:"h-4 w-4"})})]})})]}),e.jsx(n.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:r("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:r("Take Over Request:")}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:r("Send a request to {{currentEditorName}} asking them to release the page. They can accept or decline your request.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:h,variant:"default",onClick:b,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:r("Request sent. If no response, try again or use force take over.")})]}),e.jsx(n.Accordion,{type:"single",collapsible:!0,className:"w-full",children:e.jsxs(n.AccordionItem,{value:"force-takeover",className:"rounded-md border border-destructive/40 bg-destructive/5",children:[e.jsx(n.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"}),r("Force Take Over")]}),e.jsx("p",{className:"pl-6 text-xs font-normal leading-tight text-muted-foreground",children:r("Immediately take control (use with caution)")})]})})}),e.jsx(n.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:T,onChange:C=>k(C.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:r("I understand this will immediately close the editor for {{currentEditorName}}. I am using this option with caution.",{currentEditorName:x})})]}),e.jsxs(p.Button,{disabled:!T||E,variant:"destructive",onClick:R,className:"w-full gap-2",children:[e.jsx(c.ShieldAlert,{className:"h-4 w-4"}),r(E?"Take over page...":"Force Take Over")]}),E&&e.jsx("p",{className:"text-xs text-muted-foreground",children:r("Attempting to forcefully take over this page. Please wait while we update the editing session.")})]})})]})})]})})]})})};exports.default=_;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsxs as y, Fragment as z, jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { n as ae } from "./index-
|
|
3
|
-
import { aA as ye, aB as be, ap as ge, k as ie, T as q, aQ as ke, L as we, m as Ne, g as ve, c as Se, av as Le, aR as Ae, aS as Q } from "./index-
|
|
2
|
+
import { n as ae } from "./index-BK0xWO1z.js";
|
|
3
|
+
import { aA as ye, aB as be, ap as ge, k as ie, T as q, aQ as ke, L as we, m as Ne, g as ve, c as Se, av as Le, aR as Ae, aS as Q } from "./index-D5d4QDq7.js";
|
|
4
4
|
import { u as Y } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
5
5
|
import { compact as ce, filter as B, isEmpty as S, uniqBy as Te, keyBy as de, mapValues as Ce, startCase as Ee, toLower as E, includes as D, get as R, find as $, map as Me } from "lodash-es";
|
|
6
6
|
import { atom as Ie, useAtom as Ue, useSetAtom as $e } from "jotai";
|
|
7
7
|
import { ExternalLink as Be, NotepadText as ze, MoreHorizontal as Fe, Lock as Oe, Edit as je, Plus as Ge, ChevronRight as Re, StarsIcon as De, Hash as We, File as ue } from "lucide-react";
|
|
8
8
|
import { useRef as _e, useEffect as I, useMemo as V, useState as N, useCallback as oe, Suspense as C, lazy as M } from "react";
|
|
9
9
|
import { useTranslation as He } from "react-i18next";
|
|
10
|
-
import { B as qe } from "./register-chai-top-bar-
|
|
10
|
+
import { B as qe } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
11
11
|
const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
|
|
12
12
|
B(e, (r) => {
|
|
13
13
|
const n = E(s);
|
|
@@ -263,7 +263,7 @@ const le = (e, s) => !e || !Array.isArray(e) ? [] : S(s) ? e : ce(
|
|
|
263
263
|
}
|
|
264
264
|
)
|
|
265
265
|
] }, f.id)) });
|
|
266
|
-
}, nt = M(() => import("./page-manager-search-and-filter-
|
|
266
|
+
}, nt = M(() => import("./page-manager-search-and-filter-C1IWF_4d.js")), st = M(() => import("./add-new-page-NHScAQn8.js")), rt = M(() => import("./delete-page-DwZDMwfI.js")), at = M(() => import("./duplicate-page-DTnSztlr.js")), ot = M(() => import("./mark-as-template-D2XxagVO.js")), lt = M(() => import("./unmark-as-template-CPJvQk7L.js")), it = M(() => import("./unpublish-page-DlFHLlmI.js")), bt = ({ close: e }) => {
|
|
267
267
|
const { t: s } = He(), { languages: r, setSelectedLang: n } = ae(), { data: l } = Ne(), { data: a, isFetching: h } = ve(), [b, i] = Se(), { 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 = $e(Le), j = xe && w !== c, { data: U, isFetching: Pe } = Ae(w), ne = oe(
|
|
268
268
|
(x) => {
|
|
269
269
|
var o;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),X=require("./index-xYnNKovy.cjs"),f=require("./index-BwH1mRm_.cjs"),B=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),O=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),re=require("./register-chai-top-bar-BqwKw4uy.cjs"),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)})),ae=(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])},$=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?$(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?$(s.children,n,a):[]}}),le=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):[]})),oe=(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=ae(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(le(c)),p=$(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]},ie=O.atom({pageId:null,position:{x:0,y:0}}),ce=({pageId:e,children:n})=>{const[a,s]=O.useAtom(ie),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(re.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"]})})})]})},de=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=B.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":""}`})})},ue=({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"})}),me=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({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(ce,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(de,{page:e}),!e.isPartialGroup&&t.jsx(me,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(ue,{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}=B.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(xe,{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))})},he=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-Dc4ky-qV.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-BS9vPnFG.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-B7J3t0FN.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-Dw3U4wTT.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-CE6tRoQy.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BYL5naYx.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-B06iZEIO.cjs"))),be=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=X.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=B.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(""),[R,G]=l.useState(null),[D,W]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),_=O.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),H=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])):oe(o,w,T,H):[],[o,H,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}=X.useLanguages(),Q=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]),V=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":Q(i);break;case"edit":S!==u?_({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":W(i);break;case"duplicate":G(i);break;case"addLanguagePage":_({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(he,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>V("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:V,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(fe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(je,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:M,onClose:()=>m(null)})}),D&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null)})}),R&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:R,onClose:()=>G(null),closePanel:e})})]})};exports.default=be;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),X=require("./index-Bm8iS2OH.cjs"),f=require("./index-BRJCj7c_.cjs"),B=require("./use-page-expand-manager-B6XTvk0E.cjs"),r=require("lodash-es"),O=require("jotai"),b=require("lucide-react"),l=require("react"),ne=require("react-i18next"),re=require("./register-chai-top-bar-DWTuRU53.cjs"),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)})),ae=(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])},$=(e,n,a)=>r.isEmpty(n)?e:e.map(s=>{if(!a(s.pageType))return{...s,shouldExpandOnSearch:!0,children:s.children?$(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?$(s.children,n,a):[]}}),le=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):[]})),oe=(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=ae(e,x);c=r.uniqBy([...x,...u],"id")}const o=J(le(c)),p=$(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]},ie=O.atom({pageId:null,position:{x:0,y:0}}),ce=({pageId:e,children:n})=>{const[a,s]=O.useAtom(ie),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(re.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"]})})})]})},de=({page:e})=>{var s,c;const{isExpanded:n,toggleExpanded:a}=B.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":""}`})})},ue=({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"})}),me=({isOnline:e})=>t.jsx("div",{className:`h-2 w-2 rounded-full ${e?"bg-green-300":"bg-gray-300"}`}),xe=({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(ce,{pageId:e.id,children:t.jsxs("div",{onClick:()=>!e.isPartialGroup&&E&&s("select",e==null?void 0:e.id),className:M,children:[t.jsx(de,{page:e}),!e.isPartialGroup&&t.jsx(me,{isOnline:h?h.online:e.online}),!e.isPartialGroup&&t.jsx(ue,{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}=B.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(xe,{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))})},he=l.lazy(()=>Promise.resolve().then(()=>require("./page-manager-search-and-filter-BKdQUJ2W.cjs"))),fe=l.lazy(()=>Promise.resolve().then(()=>require("./add-new-page-XDuCkOyb.cjs"))),pe=l.lazy(()=>Promise.resolve().then(()=>require("./delete-page-B7ODELqM.cjs"))),ye=l.lazy(()=>Promise.resolve().then(()=>require("./duplicate-page-CWQ9aMd9.cjs"))),Pe=l.lazy(()=>Promise.resolve().then(()=>require("./mark-as-template-DUFnfVM3.cjs"))),ge=l.lazy(()=>Promise.resolve().then(()=>require("./unmark-as-template-BGDwuCnv.cjs"))),je=l.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-BMowW5wT.cjs"))),be=({close:e})=>{const{t:n}=ne.useTranslation(),{languages:a,setSelectedLang:s}=X.useLanguages(),{data:c}=f.usePageTypes(),{data:o,isFetching:p}=f.useWebsitePages(),[v,d]=f.useSearchParams(),{updateForSelectedPage:y,expandPagesOnSearch:x}=B.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(""),[R,G]=l.useState(null),[D,W]=l.useState(null),[S,Z]=l.useState(u),[ee,te]=l.useState(!1),_=O.useSetAtom(f.addNewLangAtom),q=ee&&S!==u,{data:A,isFetching:se}=f.useWebsiteLanguagePages(S),H=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])):oe(o,w,T,H):[],[o,H,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}=X.useLanguages(),Q=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]),V=(P,i)=>{var z;if(i)switch(P){case"add":L(i);break;case"select":Q(i);break;case"edit":S!==u?_({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":W(i);break;case"duplicate":G(i);break;case"addLanguagePage":_({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(he,{pages:N,search:w,setSearch:I,languages:[u,...a],selectedLanguage:S,setSelectedLanguage:Z,selectedPageType:T,setSelectedPageType:F,onAddPage:P=>V("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:V,languagePages:A,selectedLanguage:S,showUntranslatedPages:q})})]}),E&&t.jsx(l.Suspense,{children:t.jsx(fe,{closePanel:e,editPage:Q,addEditPage:E,setAddEditPage:L})}),j&&t.jsx(l.Suspense,{children:t.jsx(pe,{page:j,onClose:()=>h(null)})}),k&&t.jsx(l.Suspense,{children:t.jsx(je,{page:k,onClose:()=>C(null)})}),M&&t.jsx(l.Suspense,{children:t.jsx(Pe,{page:M,onClose:()=>m(null)})}),D&&t.jsx(l.Suspense,{children:t.jsx(ge,{page:D,onClose:()=>W(null)})}),R&&t.jsx(l.Suspense,{children:t.jsx(ye,{page:R,onClose:()=>G(null),closePanel:e})})]})};exports.default=be;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("./register-chai-top-bar-DWTuRU53.cjs"),n=require("./index-Bm8iS2OH.cjs"),f=require("./index-BRJCj7c_.cjs"),w=require("./use-page-expand-manager-B6XTvk0E.cjs"),C=require("@tanstack/react-query"),s=require("lodash-es"),d=require("lucide-react"),S=require("react"),g=require("react-i18next"),k=({selectedPageType:l,setSelectedPageType:i})=>{const{t:a}=g.useTranslation(),[r,o]=S.useState(""),{data:c}=f.usePageTypes(),u=t=>{if(!r)return!0;const x=r.toLowerCase(),m=j=>String(s.get(t,j,"")).toLowerCase().includes(x);return m("name")||m("key")},p=c.find(t=>t.key===l);return e.jsxs(n.Select,{onValueChange:i,value:l,children:[e.jsx(n.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:(p==null?void 0:p.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(n.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(h.Input,{placeholder:a("Search page types..."),className:"h-8 w-full rounded border pl-8 text-xs shadow-none",value:r,onChange:t=>o(t.target.value),onKeyDown:t=>t.stopPropagation()})]})}),e.jsx(n.SelectItem,{value:"all",children:a("All")}),!s.isEmpty(s.filter(c,t=>t.hasSlug&&u(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")}),s.map([...s.filter(c,t=>t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),!s.isEmpty(s.filter(c,t=>!t.hasSlug&&u(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")}),s.map([...s.filter(c,t=>!t.hasSlug&&u(t))].sort((t,x)=>s.get(t,"name","").localeCompare(s.get(x,"name",""))),t=>e.jsx(n.SelectItem,{value:s.get(t,"key"),children:s.get(t,"name")},s.get(t,"key")))]}),s.isEmpty(s.filter(c,u))&&e.jsx("div",{className:"px-3 py-2 text-center text-sm text-gray-500",children:a("No matching page types found")})]})]})},T=({search:l,setSearch:i})=>{const{t:a}=g.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(h.Input,{id:"page-search-input",placeholder:a("Search pages"),value:l,onChange:r=>i(r.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"})]})},E=({pages:l})=>{const{t:i}=g.useTranslation(),{expandAll:a,collapseAll:r,expandedPages:o}=w.usePageExpandManager(null);return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"outline",size:"icon",onClick:()=>a(l),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsUpDown,{})})}),e.jsx(n.TooltipContent,{children:i("Expand All")})]}),e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{disabled:o.length===0,variant:"outline",size:"icon",onClick:()=>r(),className:"rounded p-1 text-gray-500",children:e.jsx(d.ChevronsDownUp,{})})}),e.jsx(n.TooltipContent,{children:i("Collapse All")})]})]})},b=({languages:l,selectedLanguage:i,setSelectedLanguage:a})=>{const r=f.useFallbackLang();return e.jsx("div",{className:"scrollbar-hide flex gap-1 overflow-x-auto pb-1",children:l.map(o=>e.jsxs(h.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===r&&e.jsx(d.Star,{size:4,className:`p-0.5 ${i===r?"fill-white":"fill-black"}`}),f.LANGUAGES[o]||""]},o))})},y=()=>{const{t:l}=g.useTranslation(),i=C.useQueryClient();return e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{size:"sm",variant:"ghost",onClick:()=>i.invalidateQueries({queryKey:[f.ACTIONS.GET_WEBSITE_PAGES]}),className:"mt-1 h-6 w-6",children:e.jsx(d.RefreshCw,{})})}),e.jsx(n.TooltipContent,{side:"bottom",children:l("Refresh pages list")})]})},q=({pages:l,search:i,setSearch:a,languages:r,onAddPage:o,selectedLanguage:c,setSelectedLanguage:u,selectedPageType:p,setSelectedPageType:t,showUntranslatedPages:x,setShowUntranslatedPages:m})=>{const{t:j}=g.useTranslation(),v=r.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(k,{selectedPageType:p,setSelectedPageType:t}),e.jsx(T,{search:i,setSearch:a}),e.jsx(E,{pages:l}),e.jsxs(h.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:j("Add Page")})]}),!v&&e.jsx(y,{})]}),v?e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx(b,{languages:r,selectedLanguage:c,setSelectedLanguage:N=>{u(N),m(x&&(r==null?void 0:r[0])!==c)}}),e.jsxs("div",{className:"flex items-center gap-x-2",children:[(r==null?void 0:r[0])!==c&&e.jsxs(n.Tooltip,{children:[e.jsx(n.TooltipTrigger,{asChild:!0,children:e.jsx(h.Button,{variant:"ghost",onClick:()=>m(!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(n.TooltipContent,{side:"bottom",children:j("Toggle Untranslated Pages")})]}),e.jsx(y,{})]})]}):e.jsx("div",{className:"flex items-center justify-between gap-2"})]})};exports.LanguageSelector=b;exports.default=q;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as a, Fragment as k } from "react/jsx-runtime";
|
|
2
|
-
import { B as m, z as E } from "./register-chai-top-bar-
|
|
3
|
-
import { w as g, x as b, y, S as L, z as F, A as I, B as w } from "./index-
|
|
4
|
-
import { k as j, L as T, m as $, A as B } from "./index-
|
|
2
|
+
import { B as m, z as E } from "./register-chai-top-bar-CX_JkRJn.js";
|
|
3
|
+
import { w as g, x as b, y, S as L, z as F, A as I, B as w } from "./index-BK0xWO1z.js";
|
|
4
|
+
import { k as j, L as T, m as $, A as B } from "./index-D5d4QDq7.js";
|
|
5
5
|
import { u as G } from "./use-page-expand-manager-Cf4MUEJw.js";
|
|
6
6
|
import { useQueryClient as D } from "@tanstack/react-query";
|
|
7
7
|
import { isEmpty as N, filter as x, map as S, get as o } from "lodash-es";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),N=require("./register-chai-top-bar-DWTuRU53.cjs"),i=require("./index-Bm8iS2OH.cjs"),c=require("./index-BRJCj7c_.cjs"),y=require("@tanstack/react-query"),v=require("date-fns"),B=require("lodash-es"),p=require("lucide-react"),g=require("react");function L(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(n,t,l.get?l:{enumerable:!0,get:()=>s[t]})}}return n.default=s,Object.freeze(n)}const S=L(g);function Q(s){const n=c.useApiUrl(),t=c.useFetch();return y.useQuery({queryKey:[c.ACTIONS.GET_PAGE_REVISIONS,s],queryFn:async()=>await t(n,{action:c.ACTIONS.GET_PAGE_REVISIONS,data:{pageId:s}}),enabled:!!s,refetchOnMount:!0})}const z=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async l=>await n(s,{action:c.ACTIONS.DELETE_PAGE_REVISION,data:{revisionId:l}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},H=()=>{const s=c.useApiUrl(),n=c.useFetch(),t=y.useQueryClient();return y.useMutation({mutationFn:async({revisionId:l,discardCurrent:r,pageId:d})=>await n(s,{action:c.ACTIONS.RESTORE_PAGE_REVISION,data:{revisionId:l,discardCurrent:r,...d&&{pageId:d}}}),onSuccess:()=>{t.invalidateQueries({queryKey:["revisions"]})}})},$=g.lazy(()=>Promise.resolve().then(()=>require("./json-diff-viewer-g6SY62bl.cjs"))),b=({tag:s})=>s==="draft"?e.jsxs("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:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-amber-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-amber-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Draft"})]}):s==="live"?e.jsxs("span",{className:"flex items-center gap-1 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:[e.jsxs("span",{className:"relative flex h-2 w-2",children:[e.jsx("span",{className:"absolute inline-flex h-full w-full animate-ping rounded-full bg-green-400 opacity-75"}),e.jsx("span",{className:"relative inline-flex h-2 w-2 rounded-full bg-green-500"})]}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Live"})]}):s==="published"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-green-500/10 px-1.5 py-0.5 text-xs text-green-600",children:[e.jsx(p.Rocket,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Published"})]}):s==="unsaved"?e.jsxs("div",{className:"flex items-center gap-1 rounded-full bg-red-500/10 px-1.5 py-0.5 text-xs text-red-600",children:[e.jsx(p.Save,{className:"h-3 w-3"}),e.jsx("span",{className:"text-[11px] leading-tight",children:"Unsaved changes"})]}):e.jsx("span",{className:"rounded bg-purple-500/10 px-1.5 py-0.5 font-mono text-xs font-bold text-purple-600",children:s});function J({compare:s,setCompare:n}){const{data:t}=c.useChaiCurrentPage(),{saveState:l}=i.useSavePage(),[r]=c.usePageEditInfo();if(!t)return null;const d=!!s.find(x=>{var a;return(a=x==null?void 0:x.uid)==null?void 0:a.startsWith("draft:")}),u=s.length>=2&&!d,m=l==="UNSAVED";return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border bg-primary/5 p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium leading-none",children:[e.jsx(b,{tag:"draft"}),e.jsx("span",{className:"text-xs font-bold",children:"Currently editing"})]})}),e.jsx("div",{className:"flex items-center pl-2 text-[11px] text-muted-foreground",children:!B.isEmpty(r.lastSaved)&&e.jsxs("span",{children:["Last updated"," ",v.formatDistanceToNow(new Date(r.lastSaved),{addSuffix:!0})]})}),e.jsx("div",{className:"flex items-center gap-2 pt-0.5",children:m?e.jsx(b,{tag:"unsaved"}):null})]}),e.jsx(A,{checked:d,disabled:u,onChange:()=>{n(d?s.filter(x=>x.uid!==`draft:${t==null?void 0:t.id}`):[...s,{uid:`draft:${t==null?void 0:t.id}`,label:"draft",item:{createdAt:Date.now()}}])}})]})}function K(){return e.jsx("div",{className:"mt-2 space-y-2",children:Array.from({length:5}).map((s,n)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-md border p-2",children:[e.jsxs("div",{className:"flex-1 space-y-1",children:[e.jsx(i.Skeleton,{className:"h-4 w-3/4"}),e.jsx(i.Skeleton,{className:"h-3 w-1/2"}),e.jsx(i.Skeleton,{className:"mt-1 h-5 w-20"})]}),e.jsx(i.Skeleton,{className:"h-8 w-8 rounded-full"})]},n))})}function O({revision:s,isLatest:n,onRestore:t,onDelete:l,revisionNumber:r,compare:d,setCompare:u,pageId:m}){const{data:x}=c.useChaiUserInfo(s.currentEditor),a=(x==null?void 0:x.name)||"Unknown",f=!!d.find(h=>{var j;return n?(j=h==null?void 0:h.uid)==null?void 0:j.startsWith("live"):(h==null?void 0:h.uid)===s.uid}),w=d.length>=2&&!f;return e.jsxs("div",{className:"relative flex items-start gap-3 rounded-md border p-2 hover:bg-accent/50",children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("p",{className:"flex items-center gap-1 text-xs leading-none",children:[e.jsx(b,{tag:n?"live":`#${r}`}),s.type==="published"?"Published":"Draft"," by ",e.jsx("span",{className:"text-xs font-bold",children:a})]})}),e.jsxs("div",{className:"flex items-center gap-x-3",children:[e.jsx("div",{className:"flex items-center gap-2",children:s.type==="published"?e.jsx(b,{tag:"published"}):e.jsx(b,{tag:"draft"})}),e.jsx("div",{className:"flex items-center text-[10px] text-muted-foreground",children:e.jsx("span",{className:"leading-tight",children:v.format(s.createdAt,"MMM d, h:mm a")})})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(c.PermissionChecker,{permissions:[c.PAGES_PERMISSIONS.RESTORE_REVISION,c.PAGES_PERMISSIONS.DELETE_REVISION],children:e.jsx(Y,{revision:s,onRestore:t,onDelete:l})})}),e.jsx(A,{checked:f,disabled:w,onChange:()=>{u(f?d.filter(h=>n?h.uid!==`live:${m}`:h.uid!==s.uid):[...d,{uid:n?`live:${m}`:s.uid,label:n?"live":`#${r}`,item:s}].sort((h,j)=>new Date(h.item.createdAt).getTime()-new Date(j.item.createdAt).getTime()))}})]})}function W({compare:s,setCompare:n,pageId:t}){const[l,r]=g.useState(!1),[d,u]=s;if(s.length===0)return null;const m=({tab:x})=>e.jsxs("span",{className:"flex items-center justify-between rounded border border-blue-100 p-1 font-medium",children:[e.jsx(b,{tag:x.label}),e.jsx("button",{className:"z-0 flex h-4 w-4 items-center justify-center rounded-full text-gray-400 hover:text-red-500",style:{lineHeight:1},onClick:()=>n(s.filter(a=>a.uid!==x.uid)),"aria-label":"Remove selection 1",children:e.jsx(p.X,{className:"h-3 w-3"})})]});return e.jsxs("div",{className:"mb-2 flex w-full max-w-md flex-col gap-1 rounded border bg-accent/60 p-2 shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-xs",children:[e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"Compare"}),d&&e.jsx(m,{tab:d}),e.jsx("span",{className:"font-medium leading-tight text-gray-600",children:"with"}),u?e.jsx(m,{tab:u}):e.jsx("span",{className:"rounded border px-1 text-xs text-muted-foreground",children:"Choose another"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pb-0.5 pt-2",children:[e.jsx(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none text-gray-500",variant:"outline",onClick:()=>n([]),children:e.jsx("span",{children:" Clear"})}),e.jsxs(N.Button,{size:"sm",className:"h-6 gap-1 rounded px-2 text-xs leading-none",variant:"default",onClick:()=>r(!0),disabled:s.length<2,children:[e.jsx(p.FileJson,{className:"h-2.5 w-2.5"}),e.jsx("span",{className:"pt-0.5",children:"Show JSON Diff"})]})]}),l&&(s==null?void 0:s.length)>1&&t&&e.jsx(g.Suspense,{fallback:e.jsx("div",{className:"flex items-center justify-center p-4",children:e.jsx("span",{className:"text-sm",children:"Loading diff viewer..."})}),children:e.jsx($,{open:l,onOpenChange:r,compare:s})})]})}function A({checked:s,disabled:n,onChange:t,label:l="Compare"}){return e.jsx("div",{className:"absolute bottom-2 right-2",children:e.jsxs("label",{className:`flex cursor-pointer items-center gap-x-1 text-[11px] ${n?"opacity-50":""}`,children:[e.jsx("input",{type:"checkbox",className:"h-3 w-3 cursor-pointer rounded focus:ring-0 focus:ring-offset-0",checked:s,disabled:n,onChange:t}),e.jsx("span",{className:"select-none leading-tight",children:l})]})})}function Y({revision:s,onRestore:n,onDelete:t}){return e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(N.Button,{variant:"ghost",size:"icon",className:"h-5 w-5",children:[e.jsx(p.MoreHorizontal,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"More options"})]})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"text-xs",children:[e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.RESTORE_REVISION,children:e.jsxs(i.DropdownMenuItem,{onClick:n,className:"cursor-pointer text-sm",children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Restore this version"})]})}),e.jsx(c.PermissionChecker,{permission:c.PAGES_PERMISSIONS.DELETE_REVISION,children:s.uid!=="current"&&e.jsxs(e.Fragment,{children:[e.jsx(i.DropdownMenuSeparator,{}),e.jsxs(i.DropdownMenuItem,{onClick:t,className:"cursor-pointer text-destructive",children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),e.jsx("span",{children:"Delete this version"})]})]})})]})]})}function X({open:s,onOpenChange:n,revision:t,onRestore:l,isRestoring:r}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Restore Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to restore to revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"How would you like to handle your current edits?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>l(!1),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Saving as draft..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.CloudOff,{className:"mr-2 h-4 w-4"}),"Save as draft"]})}),e.jsx(N.Button,{variant:"default",className:"sm:flex-1",onClick:()=>l(!0),disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Discarding current..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Undo2,{className:"mr-2 h-4 w-4"}),"Discard current"]})})]})]})}):null}function Z({open:s,onOpenChange:n,revision:t,onDelete:l,isDeleting:r}){const{data:d}=c.useChaiUserInfo((t==null?void 0:t.currentEditor)||""),u=(d==null?void 0:d.name)||"Unknown";return t?e.jsx(i.Dialog,{open:s,onOpenChange:m=>{r||n(m)},children:e.jsxs(i.DialogContent,{className:"sm:max-w-md",children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:"Delete Revision"}),e.jsxs(i.DialogDescription,{children:["You are about to delete revision ",t.uid.substring(0,8)," from"," ",v.format(t.createdAt,"MMM d, yyyy 'at' h:mm a")," by ",u]})]}),e.jsx("div",{className:"py-2",children:e.jsx("p",{className:"text-sm text-muted-foreground",children:"This action cannot be undone. Are you sure you want to proceed?"})}),e.jsxs(i.DialogFooter,{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(N.Button,{variant:"outline",className:"sm:flex-1",onClick:()=>n(!1),disabled:r,children:"Cancel"}),e.jsx(N.Button,{variant:"destructive",className:"sm:flex-1",onClick:l,disabled:r,children:r?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"mr-2 h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Deleting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Trash,{className:"mr-2 h-4 w-4"}),"Delete Revision"]})})]})]})}):null}function ee({isOpen:s}){var R,I;const[n,t]=S.useState([]),[l,r]=S.useState(null),[d,u]=S.useState(!1),[m,x]=S.useState(!1),{data:a}=c.useChaiCurrentPage(),{data:f,isFetching:w,error:h,refetch:j}=Q(a==null?void 0:a.id),{mutate:T,isPending:M}=z(),{mutate:k,isPending:F}=H(),_=y.useQueryClient(),{selectedLang:q,fallbackLang:P}=i.useLanguages(),U=q||P;g.useEffect(()=>{g.startTransition(()=>t([]))},[a==null?void 0:a.id]);const G=o=>{l&&k({revisionId:l.uid,discardCurrent:o,...l.uid==="current"&&(a==null?void 0:a.id)&&{pageId:a.id}},{onSuccess:()=>{u(!1),r(null),_.invalidateQueries({queryKey:[c.ACTIONS.GET_DRAFT_PAGE]})}})},C=o=>{r(o),u(!0)},E=o=>{r(o),x(!0)},V=()=>{l&&T(l.uid,{onSuccess:()=>{x(!1),r(null)}})};return g.useEffect(()=>{s&&j()},[s,j]),e.jsxs(e.Fragment,{children:[e.jsxs(i.SheetHeader,{children:[e.jsx(i.SheetTitle,{children:"Revision History"}),(a==null?void 0:a.createdAt)&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Page created on ",v.format(new Date(a.createdAt),"MMM d, yyyy 'at' h:mm a")]})]}),w?e.jsx(K,{}):h?e.jsx("div",{className:"p-4 text-center text-sm text-muted-foreground",children:"Failed to load revisions. Please try again."}):e.jsxs("div",{className:"mt-2 flex h-full min-h-0 flex-1 flex-col space-y-2",children:[e.jsx(W,{lang:U,compare:n,setCompare:t,pageId:a==null?void 0:a.id}),e.jsx(J,{compare:n,setCompare:t}),(R=f==null?void 0:f.filter(o=>o.uid==="current"))==null?void 0:R.map((o,D)=>e.jsx(O,{pageId:a==null?void 0:a.id,revision:o,isLatest:!0,onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D,compare:n,setCompare:t},o.uid)),e.jsx(i.ScrollArea,{className:"min-h-0 flex-1",children:e.jsx("div",{className:"space-y-2",children:(I=f==null?void 0:f.filter(o=>o.uid!=="current"))==null?void 0:I.map((o,D)=>e.jsx(O,{pageId:a==null?void 0:a.id,revision:o,isLatest:o.uid==="current",onRestore:()=>C(o),onDelete:()=>E(o),revisionNumber:D+1,compare:n,setCompare:t},o.uid))})})]}),e.jsx(X,{open:d,onOpenChange:u,revision:l,onRestore:G,isRestoring:F}),e.jsx(Z,{open:m,onOpenChange:x,revision:l,onDelete:V,isDeleting:M})]})}exports.default=ee;
|