@chaibuilder/pages 0.15.3 → 0.15.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{2AITGKQY-o6FgGSqg.cjs → 2AITGKQY-BnzAO102.cjs} +1 -1
- package/dist/{2AITGKQY-DhC0sF1x.js → 2AITGKQY-tXLat8E2.js} +2 -2
- package/dist/{NCMVHL6D-D7HU3akD.js → NCMVHL6D-BwDANa-N.js} +2 -2
- package/dist/{NCMVHL6D-BPM6RHYa.cjs → NCMVHL6D-DooF4Fqf.cjs} +1 -1
- package/dist/{ZDWCUMSJ-Cr1v3giV.js → ZDWCUMSJ-DWeYRRkj.js} +1 -1
- package/dist/{ZDWCUMSJ-NVCxv9uE.cjs → ZDWCUMSJ-DiH9kc7o.cjs} +1 -1
- package/dist/add-new-language-page-BCUrfgTy.cjs +1 -0
- package/dist/add-new-language-page-DZhjVBBf.js +401 -0
- package/dist/add-new-page-DWHANcUx.cjs +1 -0
- package/dist/add-new-page-DYuuentN.js +31 -0
- package/dist/delete-page-1dSWwUBg.js +40 -0
- package/dist/delete-page-m-Cuz7rG.cjs +1 -0
- package/dist/digital-asset-manager-BWZlrwFf.js +913 -0
- package/dist/digital-asset-manager-By_JTIbb.cjs +1 -0
- package/dist/duplicate-page-Dzs8ya8l.cjs +1 -0
- package/dist/duplicate-page-fUuBTAs7.js +133 -0
- package/dist/{dynamic-page-selector-CF9nb6i_.cjs → dynamic-page-selector-CwhL4z6F.cjs} +1 -1
- package/dist/{dynamic-page-selector-DTk4oull.js → dynamic-page-selector-X2qgdiNQ.js} +1 -1
- package/dist/image-editor-CeSSNbFY.js +108 -0
- package/dist/image-editor-CnDnY97s.cjs +1 -0
- package/dist/index-0cMGDekp.cjs +5 -0
- package/dist/{index-BuXZJnGo.js → index-Bk8tPO5R.js} +1605 -1571
- package/dist/index.cjs +1 -1
- package/dist/index.js +8 -8
- package/dist/{json-diff-viewer-zBoPBSd3.cjs → json-diff-viewer-Cfa9BjZ6.cjs} +1 -1
- package/dist/{json-diff-viewer-oyxMD3Hc.js → json-diff-viewer-Cm84g19X.js} +1 -1
- package/dist/lang-panel-CaSKOJ8G.js +225 -0
- package/dist/lang-panel-CkSfJqr8.cjs +1 -0
- package/dist/mark-as-template-Ci82hbOm.cjs +1 -0
- package/dist/mark-as-template-CwsW86Zv.js +153 -0
- package/dist/no-language-page-content-CPt4aPy9.cjs +1 -0
- package/dist/no-language-page-content-DDz81nqg.js +42 -0
- package/dist/{page-creator-BG2hc82u.cjs → page-creator-Cd2LrG4u.cjs} +1 -1
- package/dist/{page-creator-y6kl3nw5.js → page-creator-Dr566_Yf.js} +2 -2
- package/dist/page-lock-request-Bw_Wye1t.cjs +1 -0
- package/dist/page-lock-request-ECxkQMdS.js +75 -0
- package/dist/page-locked-by-dialog-AbutJT_V.cjs +1 -0
- package/dist/page-locked-by-dialog-CnkVUpjt.js +68 -0
- package/dist/page-manager-new-DLMvOata.cjs +1 -0
- package/dist/page-manager-new-DkqNLZ5C.js +354 -0
- package/dist/page-manager-search-and-filter-B98nz9xS.js +201 -0
- package/dist/page-manager-search-and-filter-CfEfWFeo.cjs +1 -0
- package/dist/{page-revisions-content-BaTqBnko.js → page-revisions-content-CBQPYFZI.js} +18 -18
- package/dist/{page-revisions-content-Tb3T6zvU.cjs → page-revisions-content-D12GEp8C.cjs} +1 -1
- package/dist/{publish-pages-content-C9CgEWo0.js → publish-pages-content-BF5yMo_L.js} +6 -6
- package/dist/{publish-pages-content-BGkEZ3GK.cjs → publish-pages-content-LNCr9tKv.cjs} +1 -1
- package/dist/{save-to-lib-DNK4GPNw.cjs → save-to-lib-C1B6tWEF.cjs} +1 -1
- package/dist/{save-to-lib-DGtyTG6H.js → save-to-lib-SpilaoOL.js} +1 -1
- package/dist/{seo-panel-CrK7z4bR.cjs → seo-panel-DkgkJUT6.cjs} +1 -1
- package/dist/{seo-panel-DESVAQM5.js → seo-panel-sbYoo746.js} +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.js +96 -96
- package/dist/shared-json-ld-CEUgLAev.cjs +1 -0
- package/dist/shared-json-ld-D_YyVPk3.js +565 -0
- package/dist/{slug-input-DMYhARDW.cjs → slug-input-Cqj9EBju.cjs} +1 -1
- package/dist/{slug-input-DfAsMPg8.js → slug-input-Df-BG6xl.js} +1 -1
- package/dist/theme-panel-footer-B6leVWSV.js +25 -0
- package/dist/theme-panel-footer-Ca1UF5DA.cjs +1 -0
- package/dist/unmark-as-template-BOE-nKOb.cjs +1 -0
- package/dist/unmark-as-template-Cho9B4RN.js +39 -0
- package/dist/unpublish-page-BcxxZ8pr.cjs +1 -0
- package/dist/unpublish-page-Dr4qbwUx.js +27 -0
- package/dist/{web-preview-DNgPjdgZ.js → web-preview-Cq82TNaS.js} +1 -1
- package/dist/{web-preview-BcULgiw_.cjs → web-preview-ued-fdxs.cjs} +1 -1
- package/package.json +3 -4
- package/dist/add-new-language-page-8q4Ku3eg.js +0 -390
- package/dist/add-new-language-page-D3PSLiUv.cjs +0 -1
- package/dist/add-new-page-BpvpSM4X.js +0 -30
- package/dist/add-new-page-YpzILOYq.cjs +0 -1
- package/dist/delete-page-CXRJjJ4o.js +0 -38
- package/dist/delete-page-w64MO7db.cjs +0 -1
- package/dist/digital-asset-manager-B2m5T22s.js +0 -1001
- package/dist/digital-asset-manager-BGyKKd_6.cjs +0 -1
- package/dist/duplicate-page-CSQs2MOp.js +0 -120
- package/dist/duplicate-page-DB_c7V2t.cjs +0 -1
- package/dist/image-editor-D9MPdtxC.js +0 -107
- package/dist/image-editor-Da6lrqkL.cjs +0 -1
- package/dist/index-Cds1vIhw.cjs +0 -5
- package/dist/lang-panel-B_HcsPPo.js +0 -218
- package/dist/lang-panel-D2YUMeJZ.cjs +0 -1
- package/dist/mark-as-template-C4wH4UKf.cjs +0 -1
- package/dist/mark-as-template-CPEPYXg7.js +0 -146
- package/dist/no-language-page-content-CVyOpT9h.js +0 -35
- package/dist/no-language-page-content-ECt0SxFX.cjs +0 -1
- package/dist/page-lock-request-DC62b588.js +0 -64
- package/dist/page-lock-request-fGZbOFTp.cjs +0 -1
- package/dist/page-locked-by-dialog-BIC-c0Jl.cjs +0 -1
- package/dist/page-locked-by-dialog-D-vXaoga.js +0 -63
- package/dist/page-manager-new-CUfjlMed.cjs +0 -1
- package/dist/page-manager-new-Cto2r7Va.js +0 -354
- package/dist/page-manager-search-and-filter-sVnGlF46.js +0 -197
- package/dist/page-manager-search-and-filter-z2b4sgvb.cjs +0 -1
- package/dist/shared-json-ld-BMfQzOWc.js +0 -650
- package/dist/shared-json-ld-_ozYsSHn.cjs +0 -1
- package/dist/theme-panel-footer-Bj2yHtxO.cjs +0 -1
- package/dist/theme-panel-footer-RrxiDGoD.js +0 -25
- package/dist/unmark-as-template-BjetSrYF.js +0 -38
- package/dist/unmark-as-template-C8hTjRVk.cjs +0 -1
- package/dist/unpublish-page-BTPEVAkv.js +0 -26
- package/dist/unpublish-page-gtGfNOAq.cjs +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as o, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { l as u } from "./index-Bk8tPO5R.js";
|
|
3
|
+
import { useTranslation as a } from "@chaibuilder/sdk";
|
|
4
|
+
import { Dialog as h, DialogContent as d, DialogHeader as m, DialogTitle as b, DialogDescription as D, DialogFooter as f, Button as s } from "@chaibuilder/sdk/ui";
|
|
5
|
+
const g = ({ page: n, onClose: t }) => {
|
|
6
|
+
const { t: i } = a(), { mutate: e, isPending: r } = u(), c = async () => {
|
|
7
|
+
e(n, { onSuccess: t });
|
|
8
|
+
};
|
|
9
|
+
return /* @__PURE__ */ o(h, { open: !!n, onOpenChange: t, children: /* @__PURE__ */ l(d, { children: [
|
|
10
|
+
/* @__PURE__ */ l(m, { children: [
|
|
11
|
+
/* @__PURE__ */ o(b, { children: i("Confirm action") }),
|
|
12
|
+
/* @__PURE__ */ l(D, { children: [
|
|
13
|
+
i("Are you sure you want to unpublish"),
|
|
14
|
+
" ",
|
|
15
|
+
/* @__PURE__ */ o("b", { children: (n == null ? void 0 : n.name) ?? (n == null ? void 0 : n.slug) }),
|
|
16
|
+
"?"
|
|
17
|
+
] })
|
|
18
|
+
] }),
|
|
19
|
+
/* @__PURE__ */ l(f, { children: [
|
|
20
|
+
/* @__PURE__ */ o(s, { variant: "outline", onClick: t, children: i("Cancel") }),
|
|
21
|
+
/* @__PURE__ */ o(s, { variant: "destructive", disabled: r, onClick: c, children: i(r ? "Updating..." : "Unpublish") })
|
|
22
|
+
] })
|
|
23
|
+
] }) });
|
|
24
|
+
};
|
|
25
|
+
export {
|
|
26
|
+
g as default
|
|
27
|
+
};
|
|
@@ -4,7 +4,7 @@ import { Button as s } from "@chaibuilder/sdk/ui";
|
|
|
4
4
|
import { useAtom as h } from "jotai";
|
|
5
5
|
import { map as p } from "lodash-es";
|
|
6
6
|
import { Smartphone as w, Tablet as f, Laptop as u, LaptopMinimal as x } from "lucide-react";
|
|
7
|
-
import { p as v, T as _ } from "./index-
|
|
7
|
+
import { p as v, T as _ } from "./index-Bk8tPO5R.js";
|
|
8
8
|
const b = [
|
|
9
9
|
{
|
|
10
10
|
title: "mobile_xs_title",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react"),a=require("@chaibuilder/sdk/ui"),h=require("jotai"),x=require("lodash-es"),n=require("lucide-react"),c=require("./index-0cMGDekp.cjs"),m=[{title:"mobile_xs_title",content:"mobile_xs_content",icon:e.jsx(n.Smartphone,{className:"h-4 w-4"}),width:400},{title:"tablet_md_title",content:"tablet_md_content",icon:e.jsx(n.Tablet,{className:"h-4 w-4"}),width:800},{title:"desktop_xl_title",content:"desktop_xl_content",icon:e.jsx(n.Laptop,{className:"h-4 w-4"}),width:1200},{title:"large_desktop_2xl_title",content:"large_desktop_2xl_content",icon:e.jsx(n.LaptopMinimal,{className:"h-4 w-4"}),width:1600}],w=({currentWidth:t,width:s,icon:l,setIframeWidth:i})=>e.jsx(a.Button,{className:"px-3 py-3",onClick:()=>i(s),variant:s===t?"default":"ghost",children:l}),p=()=>{const[t,s]=o.useState(1200),l=r=>s(r),[i,d]=h.useAtom(c.previewUrlAtom);if(!i)return null;const u=()=>{d("")};return e.jsxs("div",{className:"absolute inset-0 z-[999999] flex h-screen w-screen flex-col overflow-hidden bg-gray-100",children:[e.jsxs("div",{className:"flex h-[50px] items-center justify-center border-b border-gray-200 px-4 shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-center rounded-md border border-gray-300",children:x.map(m,r=>o.createElement(w,{...r,setIframeWidth:l,key:r.title,currentWidth:t}))})," ",e.jsx(c.Tooltip,{content:"Exit Preview",delayDuration:0,children:e.jsx(a.Button,{variant:"destructive",size:"sm",onClick:u,children:e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M2 3C2 2.44772 2.44772 2 3 2H12C12.5523 2 13 2.44772 13 3V12C13 12.5523 12.5523 13 12 13H3C2.44772 13 2 12.5523 2 12V3ZM12 3H3V12H12V3Z",fill:"currentColor","fill-rule":"evenodd","clip-rule":"evenodd"})})})})]}),e.jsx("iframe",{style:{width:`${t}px`,transition:"width 0.3s ease-in-out"},className:"no-scrollbar mx-auto h-full overflow-y-auto border bg-white",src:i})]})};exports.default=p;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "Suraj Air",
|
|
4
4
|
"license": "Private",
|
|
5
5
|
"homepage": "https://chaibuilder.com",
|
|
6
|
-
"version": "0.15.
|
|
6
|
+
"version": "0.15.6",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist"
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"@chaibuilder/runtime": "2.2.0",
|
|
68
|
-
"@chaibuilder/sdk": "3.0.
|
|
68
|
+
"@chaibuilder/sdk": "3.0.10",
|
|
69
69
|
"@types/react": "*",
|
|
70
70
|
"@types/react-dom": "*",
|
|
71
71
|
"jotai": "2.14.0",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
},
|
|
83
83
|
"dependencies": {
|
|
84
84
|
"@chaibuilder/runtime": "2.2.0",
|
|
85
|
-
"@chaibuilder/sdk": "3.0.
|
|
85
|
+
"@chaibuilder/sdk": "3.0.10",
|
|
86
86
|
"@mhsdesign/jit-browser-tailwindcss": "^0.4.2",
|
|
87
87
|
"@radix-ui/react-icons": "^1.3.2",
|
|
88
88
|
"@supabase/supabase-js": "2.50.3",
|
|
@@ -137,7 +137,6 @@
|
|
|
137
137
|
"fs": "0.0.1-security",
|
|
138
138
|
"global-jsdom": "^26.0.0",
|
|
139
139
|
"globals": "^15.14.0",
|
|
140
|
-
"jotai-devtools": "^0.12.0",
|
|
141
140
|
"jsdom": "^26.0.0",
|
|
142
141
|
"msw": "^2.7.0",
|
|
143
142
|
"nodemon": "^3.1.9",
|
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
import { jsx as t, jsxs as h, Fragment as rn } from "react/jsx-runtime";
|
|
2
|
-
import { p as hn, r as fn, S as An } from "./slug-input-DfAsMPg8.js";
|
|
3
|
-
import { b as Nn, c as mn, d as En, e as Sn, f as gn, g as K, h as xn, i as Gn, L, C as f } from "./index-BuXZJnGo.js";
|
|
4
|
-
import { useLanguages as vn, useSidebarActivePanel as Ln } from "@chaibuilder/sdk";
|
|
5
|
-
import { Dialog as Dn, DialogContent as _n, DialogHeader as Un, DialogTitle as pn, DialogDescription as Fn, Label as k, Input as Tn, Alert as X, DialogFooter as wn, Button as Cn } from "@chaibuilder/sdk/ui";
|
|
6
|
-
import { filter as $n, find as In, startsWith as Rn } from "lodash-es";
|
|
7
|
-
import { Loader as kn } from "lucide-react";
|
|
8
|
-
import { useMemo as F, useState as T, useEffect as Q } from "react";
|
|
9
|
-
const Z = ({
|
|
10
|
-
edit: u,
|
|
11
|
-
lang: r,
|
|
12
|
-
languages: l,
|
|
13
|
-
name: i,
|
|
14
|
-
setLang: e,
|
|
15
|
-
setName: c,
|
|
16
|
-
primaryPageObject: o
|
|
17
|
-
}) => /* @__PURE__ */ h("div", { className: "space-y-1", children: [
|
|
18
|
-
/* @__PURE__ */ t(k, { htmlFor: "lang", children: f.LANGUAGE }),
|
|
19
|
-
/* @__PURE__ */ h(
|
|
20
|
-
"select",
|
|
21
|
-
{
|
|
22
|
-
value: u ? "" : r,
|
|
23
|
-
disabled: u || !l.length,
|
|
24
|
-
onChange: (n) => {
|
|
25
|
-
const a = n.target.value;
|
|
26
|
-
e(a), !u && (Rn(i, o == null ? void 0 : o.name) || i.length === 0) && c(`${o == null ? void 0 : o.name} - ${L[a]}`);
|
|
27
|
-
},
|
|
28
|
-
className: "col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
29
|
-
children: [
|
|
30
|
-
/* @__PURE__ */ t("option", { value: "", disabled: !0, children: u ? L[r] || r : l.length ? f.CHOOSE_LANGUAGE : f.ALL_AVAILABLE_LANGUAGE_PAGE }),
|
|
31
|
-
l.map((n) => /* @__PURE__ */ t("option", { value: n, children: L[n] || n }, n))
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
] }), b = ({ lang: u, name: r, setName: l, parentHasSelectedLanguagePage: i }) => /* @__PURE__ */ h("div", { className: "space-y-1", children: [
|
|
36
|
-
/* @__PURE__ */ t(k, { htmlFor: "name", children: f.PAGE_NAME }),
|
|
37
|
-
/* @__PURE__ */ t(
|
|
38
|
-
Tn,
|
|
39
|
-
{
|
|
40
|
-
id: "name",
|
|
41
|
-
value: u ? r : "",
|
|
42
|
-
onChange: (e) => l(e.target.value),
|
|
43
|
-
required: !0,
|
|
44
|
-
placeholder: u ? f.ENTER_PAGE_NAME : f.CHOOSE_LANGUAGE_TO_ADD_SLUG,
|
|
45
|
-
disabled: !i || !u
|
|
46
|
-
}
|
|
47
|
-
)
|
|
48
|
-
] }), Wn = ({
|
|
49
|
-
dynamic: u,
|
|
50
|
-
isNonSlugPageType: r,
|
|
51
|
-
isRootPage: l,
|
|
52
|
-
lang: i,
|
|
53
|
-
useLanguagePrefix: e,
|
|
54
|
-
setUseLanguagePrefix: c,
|
|
55
|
-
isHomePage: o,
|
|
56
|
-
parentSlug: n,
|
|
57
|
-
parentHasSelectedLanguagePage: a,
|
|
58
|
-
slug: A,
|
|
59
|
-
setSlug: d,
|
|
60
|
-
setIsSlugValid: E,
|
|
61
|
-
getSlug: N
|
|
62
|
-
}) => r ? null : /* @__PURE__ */ h("div", { className: "space-y-1", children: [
|
|
63
|
-
l && i && /* @__PURE__ */ h("div", { className: "flex items-center space-x-2 pb-1", children: [
|
|
64
|
-
/* @__PURE__ */ t(
|
|
65
|
-
"input",
|
|
66
|
-
{
|
|
67
|
-
type: "checkbox",
|
|
68
|
-
id: "useLanguagePrefix",
|
|
69
|
-
checked: e,
|
|
70
|
-
onChange: (S) => c(S.target.checked),
|
|
71
|
-
className: "rounded border-gray-300"
|
|
72
|
-
}
|
|
73
|
-
),
|
|
74
|
-
/* @__PURE__ */ h(k, { htmlFor: "useLanguagePrefix", className: "text-sm font-normal leading-tight", children: [
|
|
75
|
-
"Add language code (",
|
|
76
|
-
/* @__PURE__ */ h("span", { className: "font-mono text-gray-900", children: [
|
|
77
|
-
"/",
|
|
78
|
-
i
|
|
79
|
-
] }),
|
|
80
|
-
") as slug prefix"
|
|
81
|
-
] })
|
|
82
|
-
] }),
|
|
83
|
-
/* @__PURE__ */ t(k, { htmlFor: "slug", children: f.SLUG }),
|
|
84
|
-
u ? /* @__PURE__ */ t(X, { variant: "default", className: "p-2 text-xs font-medium italic text-muted-foreground", children: "This page will use dynamic slug as defined in primary page" }) : /* @__PURE__ */ t(
|
|
85
|
-
An,
|
|
86
|
-
{
|
|
87
|
-
disabled: !i || !a,
|
|
88
|
-
value: A,
|
|
89
|
-
onChange: d,
|
|
90
|
-
placeholder: i ? o && e ? "Leave empty for home page" : f.ENTER_PAGE_SLUG : f.CHOOSE_LANGUAGE_TO_ADD_SLUG,
|
|
91
|
-
parentSlug: n,
|
|
92
|
-
onValidationChange: E,
|
|
93
|
-
fullSlug: N()
|
|
94
|
-
}
|
|
95
|
-
)
|
|
96
|
-
] }), y = ({
|
|
97
|
-
parentHasSelectedLanguagePage: u,
|
|
98
|
-
name: r,
|
|
99
|
-
lang: l,
|
|
100
|
-
slug: i,
|
|
101
|
-
edit: e,
|
|
102
|
-
id: c,
|
|
103
|
-
primaryPageObject: o,
|
|
104
|
-
pages: n,
|
|
105
|
-
isNonSlugPageType: a,
|
|
106
|
-
isHomePage: A,
|
|
107
|
-
useLanguagePrefix: d,
|
|
108
|
-
isSlugValid: E,
|
|
109
|
-
isPending: N
|
|
110
|
-
}) => {
|
|
111
|
-
const S = N || !r || !l || n.some((m) => (e ? m.id !== c : !0) && m.parent === (o == null ? void 0 : o.id) && m.lang === l) || !a && !(A && d) && (!E || !i);
|
|
112
|
-
return /* @__PURE__ */ t(wn, { children: u ? /* @__PURE__ */ h(rn, { children: [
|
|
113
|
-
/* @__PURE__ */ t(Cn, { type: "submit", disabled: S && !o.dynamic, children: N ? /* @__PURE__ */ h("span", { className: "flex items-center gap-2", children: [
|
|
114
|
-
/* @__PURE__ */ t("span", { className: "loader mr-2" }),
|
|
115
|
-
e ? f.UPDATING : f.ADDING
|
|
116
|
-
] }) : e ? f.UPDATE : f.ADD_NEW_LANGUAGE }),
|
|
117
|
-
n.some(
|
|
118
|
-
(m) => (e ? m.id !== c : !0) && m.parent === (o == null ? void 0 : o.id) && m.lang === l
|
|
119
|
-
) && /* @__PURE__ */ t("p", { className: "mt-2 text-xs text-red-500", children: "A page for this language already exists." })
|
|
120
|
-
] }) : l && /* @__PURE__ */ t(X, { variant: "destructive", children: /* @__PURE__ */ h("p", { className: "mx-auto w-5/6 text-center", children: [
|
|
121
|
-
"You need to create the ",
|
|
122
|
-
/* @__PURE__ */ t("span", { className: "font-medium", children: L[l] }),
|
|
123
|
-
" page in the parent to add here."
|
|
124
|
-
] }) }) });
|
|
125
|
-
}, Bn = ({
|
|
126
|
-
onSubmit: u,
|
|
127
|
-
edit: r,
|
|
128
|
-
lang: l,
|
|
129
|
-
languages: i,
|
|
130
|
-
name: e,
|
|
131
|
-
setLang: c,
|
|
132
|
-
setName: o,
|
|
133
|
-
primaryPageObject: n,
|
|
134
|
-
parentHasSelectedLanguagePage: a,
|
|
135
|
-
id: A,
|
|
136
|
-
pages: d,
|
|
137
|
-
isNonSlugPageType: E,
|
|
138
|
-
isHomePage: N,
|
|
139
|
-
useLanguagePrefix: S,
|
|
140
|
-
slug: m,
|
|
141
|
-
isSlugValid: U,
|
|
142
|
-
isPending: g
|
|
143
|
-
}) => /* @__PURE__ */ h("form", { onSubmit: u, children: [
|
|
144
|
-
/* @__PURE__ */ h("div", { className: "grid gap-4 py-4", children: [
|
|
145
|
-
/* @__PURE__ */ t(
|
|
146
|
-
Z,
|
|
147
|
-
{
|
|
148
|
-
edit: r,
|
|
149
|
-
lang: l,
|
|
150
|
-
languages: i,
|
|
151
|
-
name: e,
|
|
152
|
-
setLang: c,
|
|
153
|
-
setName: o,
|
|
154
|
-
primaryPageObject: n
|
|
155
|
-
}
|
|
156
|
-
),
|
|
157
|
-
/* @__PURE__ */ t(
|
|
158
|
-
b,
|
|
159
|
-
{
|
|
160
|
-
lang: l,
|
|
161
|
-
name: e,
|
|
162
|
-
setName: o,
|
|
163
|
-
parentHasSelectedLanguagePage: a
|
|
164
|
-
}
|
|
165
|
-
)
|
|
166
|
-
] }),
|
|
167
|
-
/* @__PURE__ */ t(
|
|
168
|
-
y,
|
|
169
|
-
{
|
|
170
|
-
parentHasSelectedLanguagePage: a,
|
|
171
|
-
name: e,
|
|
172
|
-
lang: l,
|
|
173
|
-
slug: m,
|
|
174
|
-
edit: r,
|
|
175
|
-
id: A,
|
|
176
|
-
primaryPageObject: n,
|
|
177
|
-
pages: d,
|
|
178
|
-
isNonSlugPageType: E,
|
|
179
|
-
isHomePage: N,
|
|
180
|
-
useLanguagePrefix: S,
|
|
181
|
-
isSlugValid: U,
|
|
182
|
-
isPending: g
|
|
183
|
-
}
|
|
184
|
-
)
|
|
185
|
-
] }), Mn = ({
|
|
186
|
-
loading: u,
|
|
187
|
-
onSubmit: r,
|
|
188
|
-
edit: l,
|
|
189
|
-
lang: i,
|
|
190
|
-
languages: e,
|
|
191
|
-
name: c,
|
|
192
|
-
setLang: o,
|
|
193
|
-
setName: n,
|
|
194
|
-
primaryPageObject: a,
|
|
195
|
-
parentHasSelectedLanguagePage: A,
|
|
196
|
-
isNonSlugPageType: d,
|
|
197
|
-
isRootPage: E,
|
|
198
|
-
useLanguagePrefix: N,
|
|
199
|
-
setUseLanguagePrefix: S,
|
|
200
|
-
isHomePage: m,
|
|
201
|
-
parentSlug: U,
|
|
202
|
-
slug: g,
|
|
203
|
-
setSlug: w,
|
|
204
|
-
isSlugValid: p,
|
|
205
|
-
setIsSlugValid: W,
|
|
206
|
-
getSlug: B,
|
|
207
|
-
isPending: C,
|
|
208
|
-
id: $,
|
|
209
|
-
pages: v
|
|
210
|
-
}) => u ? /* @__PURE__ */ t("div", { className: "flex h-80 items-center justify-center", children: /* @__PURE__ */ t(kn, { className: "animate-spin" }) }) : d ? /* @__PURE__ */ t(
|
|
211
|
-
Bn,
|
|
212
|
-
{
|
|
213
|
-
onSubmit: r,
|
|
214
|
-
edit: l,
|
|
215
|
-
lang: i,
|
|
216
|
-
languages: e,
|
|
217
|
-
name: c,
|
|
218
|
-
setLang: o,
|
|
219
|
-
setName: n,
|
|
220
|
-
primaryPageObject: a,
|
|
221
|
-
parentHasSelectedLanguagePage: A,
|
|
222
|
-
id: $,
|
|
223
|
-
pages: v,
|
|
224
|
-
isNonSlugPageType: d,
|
|
225
|
-
isHomePage: m,
|
|
226
|
-
useLanguagePrefix: N,
|
|
227
|
-
slug: g,
|
|
228
|
-
isSlugValid: p,
|
|
229
|
-
isPending: C
|
|
230
|
-
}
|
|
231
|
-
) : /* @__PURE__ */ h("form", { onSubmit: r, children: [
|
|
232
|
-
/* @__PURE__ */ h("div", { className: "grid gap-4 py-4", children: [
|
|
233
|
-
/* @__PURE__ */ t(
|
|
234
|
-
Z,
|
|
235
|
-
{
|
|
236
|
-
edit: l,
|
|
237
|
-
lang: i,
|
|
238
|
-
languages: e,
|
|
239
|
-
name: c,
|
|
240
|
-
setLang: o,
|
|
241
|
-
setName: n,
|
|
242
|
-
primaryPageObject: a
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
/* @__PURE__ */ t(
|
|
246
|
-
b,
|
|
247
|
-
{
|
|
248
|
-
lang: i,
|
|
249
|
-
name: c,
|
|
250
|
-
setName: n,
|
|
251
|
-
parentHasSelectedLanguagePage: A
|
|
252
|
-
}
|
|
253
|
-
),
|
|
254
|
-
/* @__PURE__ */ t(
|
|
255
|
-
Wn,
|
|
256
|
-
{
|
|
257
|
-
dynamic: a == null ? void 0 : a.dynamic,
|
|
258
|
-
isNonSlugPageType: d,
|
|
259
|
-
isRootPage: E,
|
|
260
|
-
lang: i,
|
|
261
|
-
useLanguagePrefix: N,
|
|
262
|
-
setUseLanguagePrefix: S,
|
|
263
|
-
isHomePage: m,
|
|
264
|
-
parentSlug: U,
|
|
265
|
-
parentHasSelectedLanguagePage: A,
|
|
266
|
-
slug: g,
|
|
267
|
-
setSlug: w,
|
|
268
|
-
isSlugValid: p,
|
|
269
|
-
setIsSlugValid: W,
|
|
270
|
-
getSlug: B
|
|
271
|
-
}
|
|
272
|
-
)
|
|
273
|
-
] }),
|
|
274
|
-
/* @__PURE__ */ t(
|
|
275
|
-
y,
|
|
276
|
-
{
|
|
277
|
-
parentHasSelectedLanguagePage: A,
|
|
278
|
-
name: c,
|
|
279
|
-
lang: i,
|
|
280
|
-
slug: g,
|
|
281
|
-
edit: l,
|
|
282
|
-
id: $,
|
|
283
|
-
primaryPageObject: a,
|
|
284
|
-
pages: v,
|
|
285
|
-
isNonSlugPageType: d,
|
|
286
|
-
isHomePage: m,
|
|
287
|
-
useLanguagePrefix: N,
|
|
288
|
-
isSlugValid: p,
|
|
289
|
-
isPending: C
|
|
290
|
-
}
|
|
291
|
-
)
|
|
292
|
-
] }), Xn = ({
|
|
293
|
-
id: u,
|
|
294
|
-
isOpen: r,
|
|
295
|
-
onClose: l,
|
|
296
|
-
primaryPage: i,
|
|
297
|
-
edit: e = !1,
|
|
298
|
-
preselectedLang: c
|
|
299
|
-
}) => {
|
|
300
|
-
const { data: o = [] } = Nn(), n = F(() => o.find((s) => s.id === i), [o, i]), [a, A] = T(""), [d, E] = T(""), [N, S] = T(""), [m, U] = T(!0), [g, w] = T(!0), { mutate: p, isPending: W } = mn(), { mutate: B, isPending: C } = En(), $ = W || C, { data: v, isFetching: P } = Sn(), q = gn(), { data: D, isFetching: O } = K(i), { data: G = [], isFetching: j } = K(
|
|
301
|
-
n == null ? void 0 : n.parent
|
|
302
|
-
), { data: Y = [], isFetching: nn } = xn(), { setSelectedLang: sn } = vn(), [, en] = Gn(), [, tn] = Ln(), on = P || O || j || nn, _ = F(() => $n(v == null ? void 0 : v.languages, (s) => !In(D, { lang: s })), [v, D]), M = F(
|
|
303
|
-
() => Y.find((s) => s.key === (n == null ? void 0 : n.pageType)),
|
|
304
|
-
[Y, n == null ? void 0 : n.pageType]
|
|
305
|
-
), z = !(M != null && M.hasSlug), V = (n == null ? void 0 : n.slug) === "/";
|
|
306
|
-
Q(() => {
|
|
307
|
-
if (!e && n && c && (E(c), A(`${n.name} - ${L[c]}`)), !e || !n) return;
|
|
308
|
-
const s = D == null ? void 0 : D.find((cn) => cn.id === u);
|
|
309
|
-
if (!s) return;
|
|
310
|
-
A(s.name), E(s.lang);
|
|
311
|
-
const x = s.slug || "", { initSlug: R, prefix: un } = hn(x, n);
|
|
312
|
-
S(R), w(un);
|
|
313
|
-
}, [e, u, D, n, c]), Q(() => {
|
|
314
|
-
if (c)
|
|
315
|
-
E(c);
|
|
316
|
-
else if ((_ == null ? void 0 : _.length) === 1 && !e) {
|
|
317
|
-
const s = _[0];
|
|
318
|
-
if (!s || !L[s]) return;
|
|
319
|
-
E(s), (!a || a === (n == null ? void 0 : n.name)) && A(`${n == null ? void 0 : n.name} - ${L[s]}`);
|
|
320
|
-
}
|
|
321
|
-
}, [c, _, e, a, n]);
|
|
322
|
-
const { parentSlug: H, isRootPage: I } = F(() => {
|
|
323
|
-
if (V || !d)
|
|
324
|
-
return { parentSlug: void 0, isRootPage: !(n != null && n.parent) };
|
|
325
|
-
if (!(n != null && n.parent))
|
|
326
|
-
return {
|
|
327
|
-
parentSlug: g ? `/${d}` : void 0,
|
|
328
|
-
isRootPage: !0
|
|
329
|
-
};
|
|
330
|
-
const s = G == null ? void 0 : G.find((x) => x.lang === d);
|
|
331
|
-
return { parentSlug: s == null ? void 0 : s.slug, isRootPage: !1 };
|
|
332
|
-
}, [n == null ? void 0 : n.parent, G, g, d, V]), ln = F(() => I ? !0 : !!(G != null && G.some((s) => (s == null ? void 0 : s.lang) === d)), [d, G, I]), J = () => {
|
|
333
|
-
let s = "";
|
|
334
|
-
return I ? s = `/${g ? [d, N].filter(Boolean).join("/") : N}` : s = `${fn(H)}/${N}`, s.replace(/\/{2,}/g, "/").replace(/\/$/, "");
|
|
335
|
-
}, dn = (s) => {
|
|
336
|
-
const x = new URLSearchParams(window.location.search);
|
|
337
|
-
q && s === q ? x.delete("lang") : x.set("lang", s), en(x), window.dispatchEvent(new PopStateEvent("popstate"));
|
|
338
|
-
}, an = (s) => {
|
|
339
|
-
s.preventDefault();
|
|
340
|
-
const x = {
|
|
341
|
-
name: a,
|
|
342
|
-
lang: d,
|
|
343
|
-
primaryPage: n == null ? void 0 : n.id,
|
|
344
|
-
slug: z ? "" : J(),
|
|
345
|
-
pageType: n == null ? void 0 : n.pageType,
|
|
346
|
-
...e && { id: u }
|
|
347
|
-
}, R = () => {
|
|
348
|
-
!e && d && (sn(d), dn(d)), tn("outline"), l();
|
|
349
|
-
};
|
|
350
|
-
e ? B(x, { onSuccess: R }) : p(x, { onSuccess: R });
|
|
351
|
-
};
|
|
352
|
-
return /* @__PURE__ */ t(Dn, { open: r, onOpenChange: l, children: r && /* @__PURE__ */ h(_n, { className: "text-slate-600 sm:max-w-[425px]", children: [
|
|
353
|
-
/* @__PURE__ */ h(Un, { children: [
|
|
354
|
-
/* @__PURE__ */ t(pn, { children: e ? f.EDIT_LANGUAGE : f.ADD_NEW_LANGUAGE }),
|
|
355
|
-
/* @__PURE__ */ t(Fn, { className: "font-light", children: f.ENTER_LANGUAGE_DETAILS })
|
|
356
|
-
] }),
|
|
357
|
-
/* @__PURE__ */ t(
|
|
358
|
-
Mn,
|
|
359
|
-
{
|
|
360
|
-
id: u,
|
|
361
|
-
pages: o,
|
|
362
|
-
loading: on,
|
|
363
|
-
onSubmit: an,
|
|
364
|
-
edit: e,
|
|
365
|
-
lang: d,
|
|
366
|
-
languages: _,
|
|
367
|
-
name: a,
|
|
368
|
-
setLang: E,
|
|
369
|
-
setName: A,
|
|
370
|
-
primaryPageObject: n,
|
|
371
|
-
parentHasSelectedLanguagePage: ln,
|
|
372
|
-
isNonSlugPageType: z,
|
|
373
|
-
isRootPage: I,
|
|
374
|
-
useLanguagePrefix: g,
|
|
375
|
-
setUseLanguagePrefix: w,
|
|
376
|
-
isHomePage: V,
|
|
377
|
-
parentSlug: H,
|
|
378
|
-
slug: N,
|
|
379
|
-
setSlug: S,
|
|
380
|
-
isSlugValid: m,
|
|
381
|
-
setIsSlugValid: U,
|
|
382
|
-
getSlug: J,
|
|
383
|
-
isPending: $
|
|
384
|
-
}
|
|
385
|
-
)
|
|
386
|
-
] }) });
|
|
387
|
-
};
|
|
388
|
-
export {
|
|
389
|
-
Xn as default
|
|
390
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),M=require("./slug-input-DMYhARDW.cjs"),t=require("./index-Cds1vIhw.cjs"),H=require("@chaibuilder/sdk"),E=require("@chaibuilder/sdk/ui"),W=require("lodash-es"),us=require("lucide-react"),T=require("react"),J=({edit:a,lang:h,languages:i,name:u,setLang:o,setName:r,primaryPageObject:l})=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(E.Label,{htmlFor:"lang",children:t.CONTENT.LANGUAGE}),e.jsxs("select",{value:a?"":h,disabled:a||!i.length,onChange:s=>{const c=s.target.value;o(c),!a&&(W.startsWith(u,l==null?void 0:l.name)||u.length===0)&&r(`${l==null?void 0:l.name} - ${t.LANGUAGES[c]}`)},className:"col-span-3 flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx("option",{value:"",disabled:!0,children:a?t.LANGUAGES[h]||h:i.length?t.CONTENT.CHOOSE_LANGUAGE:t.CONTENT.ALL_AVAILABLE_LANGUAGE_PAGE}),i.map(s=>e.jsx("option",{value:s,children:t.LANGUAGES[s]||s},s))]})]}),K=({lang:a,name:h,setName:i,parentHasSelectedLanguagePage:u})=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(E.Label,{htmlFor:"name",children:t.CONTENT.PAGE_NAME}),e.jsx(E.Input,{id:"name",value:a?h:"",onChange:o=>i(o.target.value),required:!0,placeholder:a?t.CONTENT.ENTER_PAGE_NAME:t.CONTENT.CHOOSE_LANGUAGE_TO_ADD_SLUG,disabled:!u||!a})]}),ds=({dynamic:a,isNonSlugPageType:h,isRootPage:i,lang:u,useLanguagePrefix:o,setUseLanguagePrefix:r,isHomePage:l,parentSlug:s,parentHasSelectedLanguagePage:c,slug:N,setSlug:d,setIsSlugValid:A,getSlug:x})=>h?null:e.jsxs("div",{className:"space-y-1",children:[i&&u&&e.jsxs("div",{className:"flex items-center space-x-2 pb-1",children:[e.jsx("input",{type:"checkbox",id:"useLanguagePrefix",checked:o,onChange:S=>r(S.target.checked),className:"rounded border-gray-300"}),e.jsxs(E.Label,{htmlFor:"useLanguagePrefix",className:"text-sm font-normal leading-tight",children:["Add language code (",e.jsxs("span",{className:"font-mono text-gray-900",children:["/",u]}),") as slug prefix"]})]}),e.jsx(E.Label,{htmlFor:"slug",children:t.CONTENT.SLUG}),a?e.jsx(E.Alert,{variant:"default",className:"p-2 text-xs font-medium italic text-muted-foreground",children:"This page will use dynamic slug as defined in primary page"}):e.jsx(M.SlugInput,{disabled:!u||!c,value:N,onChange:d,placeholder:u?l&&o?"Leave empty for home page":t.CONTENT.ENTER_PAGE_SLUG:t.CONTENT.CHOOSE_LANGUAGE_TO_ADD_SLUG,parentSlug:s,onValidationChange:A,fullSlug:x()})]}),Q=({parentHasSelectedLanguagePage:a,name:h,lang:i,slug:u,edit:o,id:r,primaryPageObject:l,pages:s,isNonSlugPageType:c,isHomePage:N,useLanguagePrefix:d,isSlugValid:A,isPending:x})=>{const S=x||!h||!i||s.some(f=>(o?f.id!==r:!0)&&f.parent===(l==null?void 0:l.id)&&f.lang===i)||!c&&!(N&&d)&&(!A||!u);return e.jsx(E.DialogFooter,{children:a?e.jsxs(e.Fragment,{children:[e.jsx(E.Button,{type:"submit",disabled:S&&!l.dynamic,children:x?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"loader mr-2"}),o?t.CONTENT.UPDATING:t.CONTENT.ADDING]}):o?t.CONTENT.UPDATE:t.CONTENT.ADD_NEW_LANGUAGE}),s.some(f=>(o?f.id!==r:!0)&&f.parent===(l==null?void 0:l.id)&&f.lang===i)&&e.jsx("p",{className:"mt-2 text-xs text-red-500",children:"A page for this language already exists."})]}):i&&e.jsx(E.Alert,{variant:"destructive",children:e.jsxs("p",{className:"mx-auto w-5/6 text-center",children:["You need to create the ",e.jsx("span",{className:"font-medium",children:t.LANGUAGES[i]})," page in the parent to add here."]})})})},cs=({onSubmit:a,edit:h,lang:i,languages:u,name:o,setLang:r,setName:l,primaryPageObject:s,parentHasSelectedLanguagePage:c,id:N,pages:d,isNonSlugPageType:A,isHomePage:x,useLanguagePrefix:S,slug:f,isSlugValid:U,isPending:G})=>e.jsxs("form",{onSubmit:a,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(J,{edit:h,lang:i,languages:u,name:o,setLang:r,setName:l,primaryPageObject:s}),e.jsx(K,{lang:i,name:o,setName:l,parentHasSelectedLanguagePage:c})]}),e.jsx(Q,{parentHasSelectedLanguagePage:c,name:o,lang:i,slug:f,edit:h,id:N,primaryPageObject:s,pages:d,isNonSlugPageType:A,isHomePage:x,useLanguagePrefix:S,isSlugValid:U,isPending:G})]}),as=({loading:a,onSubmit:h,edit:i,lang:u,languages:o,name:r,setLang:l,setName:s,primaryPageObject:c,parentHasSelectedLanguagePage:N,isNonSlugPageType:d,isRootPage:A,useLanguagePrefix:x,setUseLanguagePrefix:S,isHomePage:f,parentSlug:U,slug:G,setSlug:_,isSlugValid:D,setIsSlugValid:$,getSlug:I,isPending:F,id:w,pages:v})=>a?e.jsx("div",{className:"flex h-80 items-center justify-center",children:e.jsx(us.Loader,{className:"animate-spin"})}):d?e.jsx(cs,{onSubmit:h,edit:i,lang:u,languages:o,name:r,setLang:l,setName:s,primaryPageObject:c,parentHasSelectedLanguagePage:N,id:w,pages:v,isNonSlugPageType:d,isHomePage:f,useLanguagePrefix:x,slug:G,isSlugValid:D,isPending:F}):e.jsxs("form",{onSubmit:h,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsx(J,{edit:i,lang:u,languages:o,name:r,setLang:l,setName:s,primaryPageObject:c}),e.jsx(K,{lang:u,name:r,setName:s,parentHasSelectedLanguagePage:N}),e.jsx(ds,{dynamic:c==null?void 0:c.dynamic,isNonSlugPageType:d,isRootPage:A,lang:u,useLanguagePrefix:x,setUseLanguagePrefix:S,isHomePage:f,parentSlug:U,parentHasSelectedLanguagePage:N,slug:G,setSlug:_,isSlugValid:D,setIsSlugValid:$,getSlug:I})]}),e.jsx(Q,{parentHasSelectedLanguagePage:N,name:r,lang:u,slug:G,edit:i,id:w,primaryPageObject:c,pages:v,isNonSlugPageType:d,isHomePage:f,useLanguagePrefix:x,isSlugValid:D,isPending:F})]}),rs=({id:a,isOpen:h,onClose:i,primaryPage:u,edit:o=!1,preselectedLang:r})=>{const{data:l=[]}=t.useWebsitePages(),s=T.useMemo(()=>l.find(n=>n.id===u),[l,u]),[c,N]=T.useState(""),[d,A]=T.useState(""),[x,S]=T.useState(""),[f,U]=T.useState(!0),[G,_]=T.useState(!0),{mutate:D,isPending:$}=t.useCreatePage(),{mutate:I,isPending:F}=t.useUpdatePage(),w=$||F,{data:v,isFetching:X}=t.useWebsiteSetting(),B=t.useFallbackLang(),{data:m,isFetching:Z}=t.useLanguagePages(u),{data:L=[],isFetching:b}=t.useLanguagePages(s==null?void 0:s.parent),{data:V=[],isFetching:y}=t.usePageTypes(),{setSelectedLang:O}=H.useLanguages(),[,P]=t.useSearchParams(),[,ss]=H.useSidebarActivePanel(),es=X||Z||b||y,C=T.useMemo(()=>W.filter(v==null?void 0:v.languages,n=>!W.find(m,{lang:n})),[v,m]),q=T.useMemo(()=>V.find(n=>n.key===(s==null?void 0:s.pageType)),[V,s==null?void 0:s.pageType]),Y=!(q!=null&&q.hasSlug),k=(s==null?void 0:s.slug)==="/";T.useEffect(()=>{if(!o&&s&&r&&(A(r),N(`${s.name} - ${t.LANGUAGES[r]}`)),!o||!s)return;const n=m==null?void 0:m.find(is=>is.id===a);if(!n)return;N(n.name),A(n.lang);const g=n.slug||"",{initSlug:R,prefix:ls}=M.parseSlugForEdit(g,s);S(R),_(ls)},[o,a,m,s,r]),T.useEffect(()=>{if(r)A(r);else if((C==null?void 0:C.length)===1&&!o){const n=C[0];if(!n||!t.LANGUAGES[n])return;A(n),(!c||c===(s==null?void 0:s.name))&&N(`${s==null?void 0:s.name} - ${t.LANGUAGES[n]}`)}},[r,C,o,c,s]);const{parentSlug:j,isRootPage:p}=T.useMemo(()=>{if(k||!d)return{parentSlug:void 0,isRootPage:!(s!=null&&s.parent)};if(!(s!=null&&s.parent))return{parentSlug:G?`/${d}`:void 0,isRootPage:!0};const n=L==null?void 0:L.find(g=>g.lang===d);return{parentSlug:n==null?void 0:n.slug,isRootPage:!1}},[s==null?void 0:s.parent,L,G,d,k]),ns=T.useMemo(()=>p?!0:!!(L!=null&&L.some(n=>(n==null?void 0:n.lang)===d)),[d,L,p]),z=()=>{let n="";return p?n=`/${G?[d,x].filter(Boolean).join("/"):x}`:n=`${M.removeSlugExtension(j)}/${x}`,n.replace(/\/{2,}/g,"/").replace(/\/$/,"")},ts=n=>{const g=new URLSearchParams(window.location.search);B&&n===B?g.delete("lang"):g.set("lang",n),P(g),window.dispatchEvent(new PopStateEvent("popstate"))},os=n=>{n.preventDefault();const g={name:c,lang:d,primaryPage:s==null?void 0:s.id,slug:Y?"":z(),pageType:s==null?void 0:s.pageType,...o&&{id:a}},R=()=>{!o&&d&&(O(d),ts(d)),ss("outline"),i()};o?I(g,{onSuccess:R}):D(g,{onSuccess:R})};return e.jsx(E.Dialog,{open:h,onOpenChange:i,children:h&&e.jsxs(E.DialogContent,{className:"text-slate-600 sm:max-w-[425px]",children:[e.jsxs(E.DialogHeader,{children:[e.jsx(E.DialogTitle,{children:o?t.CONTENT.EDIT_LANGUAGE:t.CONTENT.ADD_NEW_LANGUAGE}),e.jsx(E.DialogDescription,{className:"font-light",children:t.CONTENT.ENTER_LANGUAGE_DETAILS})]}),e.jsx(as,{id:a,pages:l,loading:es,onSubmit:os,edit:o,lang:d,languages:C,name:c,setLang:A,setName:N,primaryPageObject:s,parentHasSelectedLanguagePage:ns,isNonSlugPageType:Y,isRootPage:p,useLanguagePrefix:G,setUseLanguagePrefix:_,isHomePage:k,parentSlug:j,slug:x,setSlug:S,isSlugValid:f,setIsSlugValid:U,getSlug:z,isPending:w})]})})};exports.default=rs;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { jsx as o, jsxs as n } from "react/jsx-runtime";
|
|
2
|
-
import { Dialog as c, DialogContent as a, DialogHeader as t, DialogTitle as p, DialogDescription as m } from "@chaibuilder/sdk/ui";
|
|
3
|
-
import { lazy as h, Suspense as D } from "react";
|
|
4
|
-
const f = h(() => import("./page-creator-y6kl3nw5.js")), N = ({
|
|
5
|
-
addEditPage: e,
|
|
6
|
-
setAddEditPage: r,
|
|
7
|
-
closePanel: s
|
|
8
|
-
}) => {
|
|
9
|
-
const l = !!(e != null && e.id), i = !!e;
|
|
10
|
-
return /* @__PURE__ */ o(c, { open: i, onOpenChange: () => r(void 0), children: i && /* @__PURE__ */ n(a, { className: "sm:max-w-[425px]", children: [
|
|
11
|
-
/* @__PURE__ */ n(t, { children: [
|
|
12
|
-
/* @__PURE__ */ n(p, { children: [
|
|
13
|
-
l ? "Edit" : "Add New",
|
|
14
|
-
" "
|
|
15
|
-
] }),
|
|
16
|
-
/* @__PURE__ */ o(m, { children: l ? "Update your page name" : "Enter details to create a new page" })
|
|
17
|
-
] }),
|
|
18
|
-
/* @__PURE__ */ o(D, { fallback: /* @__PURE__ */ o("div", { className: "min-h-40" }), children: /* @__PURE__ */ o(
|
|
19
|
-
f,
|
|
20
|
-
{
|
|
21
|
-
closePanel: s,
|
|
22
|
-
addEditPage: e,
|
|
23
|
-
close: () => r(void 0)
|
|
24
|
-
}
|
|
25
|
-
) })
|
|
26
|
-
] }) });
|
|
27
|
-
};
|
|
28
|
-
export {
|
|
29
|
-
N as default
|
|
30
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),n=require("@chaibuilder/sdk/ui"),l=require("react"),t=l.lazy(()=>Promise.resolve().then(()=>require("./page-creator-BG2hc82u.cjs"))),a=({addEditPage:s,setAddEditPage:o,closePanel:c})=>{const r=!!(s!=null&&s.id),i=!!s;return e.jsx(n.Dialog,{open:i,onOpenChange:()=>o(void 0),children:i&&e.jsxs(n.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(n.DialogHeader,{children:[e.jsxs(n.DialogTitle,{children:[r?"Edit":"Add New"," "]}),e.jsx(n.DialogDescription,{children:r?"Update your page name":"Enter details to create a new page"})]}),e.jsx(l.Suspense,{fallback:e.jsx("div",{className:"min-h-40"}),children:e.jsx(t,{closePanel:c,addEditPage:s,close:()=>o(void 0)})})]})})};exports.default=a;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { jsx as n, jsxs as i } from "react/jsx-runtime";
|
|
2
|
-
import { i as D, m as f, h as w, L as y } from "./index-BuXZJnGo.js";
|
|
3
|
-
import { useLanguages as S, useSidebarActivePanel as v } from "@chaibuilder/sdk";
|
|
4
|
-
import { Dialog as L, DialogContent as x, DialogHeader as A, DialogTitle as k, DialogDescription as C, DialogFooter as N, Button as o } from "@chaibuilder/sdk/ui";
|
|
5
|
-
import { get as g } from "lodash-es";
|
|
6
|
-
function b({ page: e, onClose: r }) {
|
|
7
|
-
const [, s] = D(), { mutate: c, isPending: a } = f(), { data: l } = w(), { setSelectedLang: d, fallbackLang: m } = S(), [, u] = v(), h = () => {
|
|
8
|
-
a || c(e, {
|
|
9
|
-
onSuccess: () => {
|
|
10
|
-
e != null && e.primaryPage ? (window.history.replaceState({}, "", `/?page=${e.primaryPage}`), s(new URLSearchParams({ page: e.primaryPage }))) : (window.history.replaceState({}, "", "/"), s(new URLSearchParams())), window.dispatchEvent(new PopStateEvent("popstate")), d(m), u("outline"), r();
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
}, t = l == null ? void 0 : l.find((P) => P.key === (e == null ? void 0 : e.pageType));
|
|
14
|
-
return /* @__PURE__ */ n(L, { open: !!e, onOpenChange: r, children: /* @__PURE__ */ i(x, { children: [
|
|
15
|
-
/* @__PURE__ */ i(A, { children: [
|
|
16
|
-
/* @__PURE__ */ n(k, { children: "Confirm Deletion" }),
|
|
17
|
-
/* @__PURE__ */ i(C, { className: "py-4 text-slate-500", children: [
|
|
18
|
-
/* @__PURE__ */ i("div", { children: [
|
|
19
|
-
"Are you sure you want to remove ",
|
|
20
|
-
/* @__PURE__ */ n("b", { children: (e == null ? void 0 : e.name) ?? (e == null ? void 0 : e.slug) }),
|
|
21
|
-
" ",
|
|
22
|
-
t != null && t.hasSlug ? (t == null ? void 0 : t.name) + "?" : `page? ${e != null && e.primaryPage ? "" : "This will also delete all associated language pages."}`
|
|
23
|
-
] }),
|
|
24
|
-
e.lang && /* @__PURE__ */ i("div", { className: "py-2 text-sm", children: [
|
|
25
|
-
"Language: ",
|
|
26
|
-
/* @__PURE__ */ n("span", { className: "font-medium text-gray-500", children: g(y, e.lang, e.lang) })
|
|
27
|
-
] })
|
|
28
|
-
] })
|
|
29
|
-
] }),
|
|
30
|
-
/* @__PURE__ */ i(N, { children: [
|
|
31
|
-
/* @__PURE__ */ n(o, { variant: "outline", onClick: r, children: "Cancel" }),
|
|
32
|
-
/* @__PURE__ */ n(o, { variant: "destructive", disabled: a, onClick: h, children: a ? "Deleting..." : "Delete" })
|
|
33
|
-
] })
|
|
34
|
-
] }) });
|
|
35
|
-
}
|
|
36
|
-
export {
|
|
37
|
-
b as default
|
|
38
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("./index-Cds1vIhw.cjs"),c=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),D=require("lodash-es");function y({page:e,onClose:r}){const[,o]=i.useSearchParams(),{mutate:d,isPending:l}=i.useDeletePage(),{data:a}=i.usePageTypes(),{setSelectedLang:u,fallbackLang:h}=c.useLanguages(),[,m]=c.useSidebarActivePanel(),x=()=>{l||d(e,{onSuccess:()=>{e!=null&&e.primaryPage?(window.history.replaceState({},"",`/?page=${e.primaryPage}`),o(new URLSearchParams({page:e.primaryPage}))):(window.history.replaceState({},"","/"),o(new URLSearchParams)),window.dispatchEvent(new PopStateEvent("popstate")),u(h),m("outline"),r()}})},s=a==null?void 0:a.find(P=>P.key===(e==null?void 0:e.pageType));return n.jsx(t.Dialog,{open:!!e,onOpenChange:r,children:n.jsxs(t.DialogContent,{children:[n.jsxs(t.DialogHeader,{children:[n.jsx(t.DialogTitle,{children:"Confirm Deletion"}),n.jsxs(t.DialogDescription,{className:"py-4 text-slate-500",children:[n.jsxs("div",{children:["Are you sure you want to remove ",n.jsx("b",{children:(e==null?void 0:e.name)??(e==null?void 0:e.slug)})," ",s!=null&&s.hasSlug?(s==null?void 0:s.name)+"?":`page? ${e!=null&&e.primaryPage?"":"This will also delete all associated language pages."}`]}),e.lang&&n.jsxs("div",{className:"py-2 text-sm",children:["Language: ",n.jsx("span",{className:"font-medium text-gray-500",children:D.get(i.LANGUAGES,e.lang,e.lang)})]})]})]}),n.jsxs(t.DialogFooter,{children:[n.jsx(t.Button,{variant:"outline",onClick:r,children:"Cancel"}),n.jsx(t.Button,{variant:"destructive",disabled:l,onClick:x,children:l?"Deleting...":"Delete"})]})]})})}exports.default=y;
|