@chaibuilder/pages 0.16.14 → 0.16.16
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-B9AnRLq_.cjs → 2AITGKQY-BV6JxIio.cjs} +1 -1
- package/dist/{2AITGKQY-B7xwscsX.js → 2AITGKQY-DmJ7FEya.js} +5 -5
- package/dist/{NCMVHL6D-CRMC-wXy.cjs → NCMVHL6D-B_AZmaGG.cjs} +1 -1
- package/dist/{NCMVHL6D-B1mwht0Q.js → NCMVHL6D-DsqUQxZK.js} +4 -4
- package/dist/{ZDWCUMSJ-BqqPEOij.cjs → ZDWCUMSJ-CQXWzREv.cjs} +1 -1
- package/dist/{ZDWCUMSJ-CxKNtXtp.js → ZDWCUMSJ-DusX6DXb.js} +1 -1
- package/dist/active-in-another-tab-CSNxota6.js +34 -0
- package/dist/active-in-another-tab-rGDvhc3f.cjs +1 -0
- package/dist/{add-new-language-page-DD0qvJJs.js → add-new-language-page-C1ekdWwV.js} +20 -20
- package/dist/{add-new-language-page-D2a6GK-7.cjs → add-new-language-page-DmQ_eB85.cjs} +1 -1
- package/dist/{add-new-page-01GDCaa4.cjs → add-new-page-BImvK_fV.cjs} +1 -1
- package/dist/{add-new-page-CYtuChN1.js → add-new-page-C6gW1_B-.js} +1 -1
- package/dist/{ai-panel-content-Ouz6pu_0.cjs → ai-panel-content-BGMRcgkl.cjs} +1 -1
- package/dist/{ai-panel-content-DfdnvlS8.js → ai-panel-content-BJoNy1Yk.js} +2 -2
- package/dist/{ai-panel-default-lang-Bi2fH1so.js → ai-panel-default-lang-BLE3cVLR.js} +3 -3
- package/dist/{ai-panel-default-lang-N1pb8rzQ.cjs → ai-panel-default-lang-CNTq97FU.cjs} +2 -2
- package/dist/{ai-panel-other-lang-2JPRSyO1.js → ai-panel-other-lang-DBBxinT6.js} +3 -3
- package/dist/{ai-panel-other-lang-BysU1464.cjs → ai-panel-other-lang-VRmIp9Qm.cjs} +1 -1
- package/dist/{ai-prompt-input-JeIqWZco.cjs → ai-prompt-input-5aMuJDep.cjs} +1 -1
- package/dist/{ai-prompt-input-DadL_cng.js → ai-prompt-input-BivmKxNH.js} +2 -2
- package/dist/{ai-translation-prompt-B0si-R0R.js → ai-translation-prompt-CkvGj9Zu.js} +1 -1
- package/dist/{ai-translation-prompt-CQb1L7NM.cjs → ai-translation-prompt-hp5Ey1Eq.cjs} +1 -1
- package/dist/continue-editing-in-this-client-BdjGzFLm.cjs +1 -0
- package/dist/continue-editing-in-this-client-Bdm_5BEM.js +24 -0
- package/dist/delete-page-BHu4rVNA.js +70 -0
- package/dist/delete-page-OGCRZzrG.cjs +1 -0
- package/dist/{digital-asset-manager-jfnmWRJj.js → digital-asset-manager-C7JEgxdI.js} +1 -1
- package/dist/{digital-asset-manager-B5FQGtGY.cjs → digital-asset-manager-CaF6tRHd.cjs} +1 -1
- package/dist/{duplicate-page-BNjfZ7Wd.cjs → duplicate-page-Co3QgE3M.cjs} +1 -1
- package/dist/{duplicate-page-CERjaPIW.js → duplicate-page-DZW5jpE3.js} +13 -13
- package/dist/{dynamic-page-selector-XEWV4iCf.js → dynamic-page-selector-C2vVfVwL.js} +1 -1
- package/dist/{dynamic-page-selector-Bpz_bvRu.cjs → dynamic-page-selector-CL-sCDkO.cjs} +1 -1
- package/dist/index-DOH-lluK.js +4820 -0
- package/dist/index-MzR4MaVE.cjs +5 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -34
- package/dist/index.js +21 -22
- package/dist/{json-diff-viewer-H-2DkGza.cjs → json-diff-viewer-C69tubC8.cjs} +1 -1
- package/dist/{json-diff-viewer-DyvKomxd.js → json-diff-viewer-DVB2glQZ.js} +6 -6
- package/dist/{lang-panel-BWP5A-FD.js → lang-panel-BDNMrT8U.js} +24 -24
- package/dist/{lang-panel-DcZ7u4em.cjs → lang-panel-DWj5wlfo.cjs} +1 -1
- package/dist/{mark-as-template-B_FyVRRO.cjs → mark-as-template-Br9qxjbc.cjs} +1 -1
- package/dist/{mark-as-template-1oVraE1x.js → mark-as-template-wKn7aI8D.js} +7 -7
- package/dist/{no-language-page-content-CEci_4j7.js → no-language-page-content-C7oVsIYu.js} +1 -1
- package/dist/{no-language-page-content-JO4YYUx7.cjs → no-language-page-content-CFVzHv_Y.cjs} +1 -1
- package/dist/no-language-page-dialog-5-cAE2F2.js +10 -0
- package/dist/no-language-page-dialog-BqrxzBfj.cjs +1 -0
- package/dist/{page-creator-DJJFl7px.js → page-creator-89jgn0Ao.js} +52 -52
- package/dist/{page-creator-BGgoOA92.cjs → page-creator-itnGYmd4.cjs} +1 -1
- package/dist/page-lock-BGnEhXCW.cjs +1 -0
- package/dist/page-lock-T6QScRbl.js +30 -0
- package/dist/page-locked-dialog-B39IqdJ9.cjs +1 -0
- package/dist/page-locked-dialog-Bo2JuCSN.js +133 -0
- package/dist/page-manager-new-CElobhjD.js +354 -0
- package/dist/page-manager-new-D44_zdpQ.cjs +1 -0
- package/dist/{page-manager-search-and-filter-Dgh8iyGp.cjs → page-manager-search-and-filter-DmXFyylC.cjs} +1 -1
- package/dist/{page-manager-search-and-filter-DbUoW8Di.js → page-manager-search-and-filter-VgVbeup1.js} +1 -1
- package/dist/{page-revisions-content-CxEJGxLY.js → page-revisions-content-C3GLr_sM.js} +19 -19
- package/dist/{page-revisions-content-CwoXXE53.cjs → page-revisions-content-CsxGDRzT.cjs} +1 -1
- package/dist/pages.css +1 -1
- package/dist/publish-pages-content-CdwZOxtG.cjs +1 -0
- package/dist/{publish-pages-content-CfAlmivf.js → publish-pages-content-Cj6sTZ-B.js} +88 -88
- package/dist/{save-to-lib-DpyJA0y1.cjs → save-to-lib-BjfzVByH.cjs} +1 -1
- package/dist/{save-to-lib-BCaBfh0I.js → save-to-lib-DtdHpuWg.js} +1 -1
- package/dist/{selected-block-display-CqnwyGRp.cjs → selected-block-display-B0yeKnWl.cjs} +1 -1
- package/dist/{selected-block-display-BmNhvYKu.js → selected-block-display-DVzQ888o.js} +1 -1
- package/dist/{seo-panel-D-nKfsRJ.cjs → seo-panel-CaXQTicZ.cjs} +1 -1
- package/dist/{seo-panel-BH8fcGqr.js → seo-panel-h6FQkwhv.js} +61 -61
- package/dist/{shared-json-ld-zTDoJzUv.js → shared-json-ld-B1HhFgk0.js} +39 -39
- package/dist/{shared-json-ld-m_OsVv8h.cjs → shared-json-ld-DcYfd7Sl.cjs} +1 -1
- package/dist/{slug-input-CumDDlCk.js → slug-input-Bq48cfWr.js} +1 -1
- package/dist/{slug-input-vzNtu37S.cjs → slug-input-DDDMhrBe.cjs} +1 -1
- package/dist/take-over-request-BC2Rh5wd.js +63 -0
- package/dist/take-over-request-Cpa9ooTw.cjs +1 -0
- package/dist/{theme-panel-footer-CdUmjB-e.js → theme-panel-footer-B4D33YEO.js} +4 -4
- package/dist/{theme-panel-footer-CKccBcd9.cjs → theme-panel-footer-DoFYuPy1.cjs} +1 -1
- package/dist/{unmark-as-template-BNFOsxIg.cjs → unmark-as-template-4A6kxi6r.cjs} +1 -1
- package/dist/{unmark-as-template-6ew-7bf8.js → unmark-as-template-fkt1rehy.js} +1 -1
- package/dist/{unpublish-page-BomE76Wg.js → unpublish-page-IQ4WTVMd.js} +9 -9
- package/dist/{unpublish-page-BZQpTpU3.cjs → unpublish-page-uIYo5nwG.cjs} +1 -1
- package/dist/{web-preview-C5QTX7bS.cjs → web-preview-BvfhE4ij.cjs} +1 -1
- package/dist/{web-preview-jo8lnpEx.js → web-preview-DYbA7jro.js} +1 -1
- package/package.json +3 -3
- package/dist/delete-page-C8Nt7IYF.cjs +0 -1
- package/dist/delete-page-_96Di9yN.js +0 -40
- package/dist/index-Pdb5tSRL.cjs +0 -5
- package/dist/index-e9WlBH0R.js +0 -4960
- package/dist/page-lock-request-BoYzkcyt.cjs +0 -1
- package/dist/page-lock-request-WzpcD2ZN.js +0 -75
- package/dist/page-locked-by-dialog-Djvjp2Hx.js +0 -68
- package/dist/page-locked-by-dialog-bvI27OZ6.cjs +0 -1
- package/dist/page-manager-new-CMfGorRQ.cjs +0 -1
- package/dist/page-manager-new-DmVX0qLk.js +0 -354
- package/dist/publish-pages-content-BRu7qwAo.cjs +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s, Fragment as M } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import { useTranslation as G, useLanguages as
|
|
4
|
-
import { Dialog as
|
|
5
|
-
import { find as z, startsWith as E, isEqual as
|
|
2
|
+
import { au as j, m as T, L as I, av as F, l as H, aw as O, j as W, ax as f, ay as o } from "./index-DOH-lluK.js";
|
|
3
|
+
import { useTranslation as G, useLanguages as B } from "@chaibuilder/sdk";
|
|
4
|
+
import { Dialog as q, DialogContent as R, DialogHeader as J, DialogTitle as K, DialogDescription as Q, Alert as V, Label as X, Input as Y, DialogFooter as Z, Button as A, DropdownMenu as ee, DropdownMenuTrigger as se, DropdownMenuContent as ne, DropdownMenuItem as w } from "@chaibuilder/sdk/ui";
|
|
5
|
+
import { find as z, startsWith as E, isEqual as le, filter as ae, get as D, map as te, isEmpty as ie } from "lodash-es";
|
|
6
6
|
import { AlertCircle as re, StarIcon as ce, MoreHorizontal as oe, PencilIcon as de, Power as me, TrashIcon as ue } from "lucide-react";
|
|
7
7
|
import { useState as S, lazy as U, useMemo as he, Suspense as L } from "react";
|
|
8
8
|
import { toast as ge } from "sonner";
|
|
@@ -11,7 +11,7 @@ const fe = ({
|
|
|
11
11
|
page: n,
|
|
12
12
|
onClose: g
|
|
13
13
|
}) => {
|
|
14
|
-
const { t } = G(), [i, v] = S(n.slug || ""), { mutate: N, isPending: y } = j(), { data:
|
|
14
|
+
const { t } = G(), [i, v] = S(n.slug || ""), { mutate: N, isPending: y } = j(), { data: a } = T(), r = z(a, { key: n == null ? void 0 : n.pageType }), x = (m) => {
|
|
15
15
|
if (m.preventDefault(), !(n != null && n.primaryPage) && Object.keys(I).some((p) => i === `/${p}` || E(i, `/${p}/`))) {
|
|
16
16
|
ge.error(t("Error"), {
|
|
17
17
|
description: t("Slugs cannot start with a language code for primary page")
|
|
@@ -20,7 +20,7 @@ const fe = ({
|
|
|
20
20
|
}
|
|
21
21
|
N({ ...n, slug: i }, { onSuccess: g });
|
|
22
22
|
}, d = (n == null ? void 0 : n.lang) || "";
|
|
23
|
-
return /* @__PURE__ */ e(
|
|
23
|
+
return /* @__PURE__ */ e(q, { open: !!n, onOpenChange: g, children: /* @__PURE__ */ s(R, { children: [
|
|
24
24
|
/* @__PURE__ */ s(J, { children: [
|
|
25
25
|
/* @__PURE__ */ e(K, { children: t("Change Slug") }),
|
|
26
26
|
/* @__PURE__ */ e(Q, { className: "text-xs", children: /* @__PURE__ */ s(V, { variant: "destructive", className: "mt-2", children: [
|
|
@@ -84,27 +84,27 @@ const fe = ({
|
|
|
84
84
|
A,
|
|
85
85
|
{
|
|
86
86
|
type: "submit",
|
|
87
|
-
disabled: y || !E(i, `/${d}`) ||
|
|
87
|
+
disabled: y || !E(i, `/${d}`) || le(n == null ? void 0 : n.slug, i),
|
|
88
88
|
children: t(y ? "Changing..." : "Change Slug")
|
|
89
89
|
}
|
|
90
90
|
) })
|
|
91
91
|
] })
|
|
92
92
|
] }) });
|
|
93
|
-
}, Ne = U(() => import("./delete-page-
|
|
94
|
-
const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } =
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
}, [r,
|
|
93
|
+
}, Ne = U(() => import("./delete-page-BHu4rVNA.js")), ye = U(() => import("./unpublish-page-IQ4WTVMd.js")), Pe = () => {
|
|
94
|
+
const { t: n } = G(), [, g] = pe(F), { selectedLang: t, fallbackLang: i, setSelectedLang: v } = B(), { data: N, isFetching: y } = H(), { data: a } = O(), { data: r } = T(), x = he(() => {
|
|
95
|
+
const l = r == null ? void 0 : r.find((h) => h.key === (a == null ? void 0 : a.pageType));
|
|
96
|
+
return a != null && a.dynamic ? l == null ? void 0 : l.dynamicSlug : "";
|
|
97
|
+
}, [r, a == null ? void 0 : a.pageType, a == null ? void 0 : a.dynamic]), [d, m] = S(null), [u, C] = S(null), [p, _] = S(null), { data: P } = W(), $ = ae(
|
|
98
98
|
D(P, "languages") || ["en"],
|
|
99
|
-
(
|
|
99
|
+
(l) => !z(N, { lang: l }) && l !== D(P, "fallbackLang")
|
|
100
100
|
);
|
|
101
101
|
return /* @__PURE__ */ s("div", { className: "space-y-4", children: [
|
|
102
102
|
/* @__PURE__ */ e("ul", { className: "space-y-2", children: y ? /* @__PURE__ */ s("div", { className: "w-full space-y-3 py-4", children: [
|
|
103
103
|
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
104
104
|
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" }),
|
|
105
105
|
/* @__PURE__ */ e("div", { className: "h-8 w-full animate-pulse rounded bg-gray-300" })
|
|
106
|
-
] }) : te(N, (
|
|
107
|
-
const h =
|
|
106
|
+
] }) : te(N, (l) => {
|
|
107
|
+
const h = l.lang, b = l.slug, k = !l.primaryPage;
|
|
108
108
|
return /* @__PURE__ */ s(M, { children: [
|
|
109
109
|
/* @__PURE__ */ s(
|
|
110
110
|
"li",
|
|
@@ -114,7 +114,7 @@ const fe = ({
|
|
|
114
114
|
children: [
|
|
115
115
|
/* @__PURE__ */ s("div", { className: "flex-1 gap-x-3", children: [
|
|
116
116
|
/* @__PURE__ */ s("div", { className: "flex items-center gap-x-2 text-[13px] text-slate-800", children: [
|
|
117
|
-
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${
|
|
117
|
+
/* @__PURE__ */ e("div", { className: `h-2.5 w-2.5 rounded-full ${l.online ? "bg-green-300" : "bg-gray-300"}` }),
|
|
118
118
|
D(I, k ? i : h, h)
|
|
119
119
|
] }),
|
|
120
120
|
/* @__PURE__ */ s("div", { children: [
|
|
@@ -126,7 +126,7 @@ const fe = ({
|
|
|
126
126
|
"Name:",
|
|
127
127
|
/* @__PURE__ */ s("b", { className: "font-medium", children: [
|
|
128
128
|
" ",
|
|
129
|
-
|
|
129
|
+
l.name,
|
|
130
130
|
" "
|
|
131
131
|
] })
|
|
132
132
|
] })
|
|
@@ -153,8 +153,8 @@ const fe = ({
|
|
|
153
153
|
onClick: (c) => {
|
|
154
154
|
c.stopPropagation(), g({
|
|
155
155
|
edit: !0,
|
|
156
|
-
id:
|
|
157
|
-
primaryPage:
|
|
156
|
+
id: l.id,
|
|
157
|
+
primaryPage: l.primaryPage
|
|
158
158
|
});
|
|
159
159
|
},
|
|
160
160
|
children: [
|
|
@@ -163,12 +163,12 @@ const fe = ({
|
|
|
163
163
|
]
|
|
164
164
|
}
|
|
165
165
|
) }),
|
|
166
|
-
/* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (
|
|
166
|
+
/* @__PURE__ */ e(f, { permissions: [o.UNPUBLISH_PAGE], children: (l == null ? void 0 : l.online) && /* @__PURE__ */ s(
|
|
167
167
|
w,
|
|
168
168
|
{
|
|
169
169
|
className: "flex cursor-pointer items-center gap-2",
|
|
170
170
|
onClick: (c) => {
|
|
171
|
-
c.stopPropagation(), C(
|
|
171
|
+
c.stopPropagation(), C(l);
|
|
172
172
|
},
|
|
173
173
|
children: [
|
|
174
174
|
/* @__PURE__ */ e(me, { className: "size-3" }),
|
|
@@ -181,7 +181,7 @@ const fe = ({
|
|
|
181
181
|
{
|
|
182
182
|
className: "flex cursor-pointer items-center gap-2",
|
|
183
183
|
onClick: (c) => {
|
|
184
|
-
c.stopPropagation(), m(
|
|
184
|
+
c.stopPropagation(), m(l);
|
|
185
185
|
},
|
|
186
186
|
children: [
|
|
187
187
|
/* @__PURE__ */ e(ue, { className: "size-3" }),
|
|
@@ -195,7 +195,7 @@ const fe = ({
|
|
|
195
195
|
) })
|
|
196
196
|
]
|
|
197
197
|
},
|
|
198
|
-
|
|
198
|
+
l.id
|
|
199
199
|
),
|
|
200
200
|
/* @__PURE__ */ e("div", { className: "h-1 w-full border-b" })
|
|
201
201
|
] });
|
|
@@ -208,7 +208,7 @@ const fe = ({
|
|
|
208
208
|
disabled: ie($),
|
|
209
209
|
onClick: () => {
|
|
210
210
|
g({
|
|
211
|
-
primaryPage:
|
|
211
|
+
primaryPage: a == null ? void 0 : a.id,
|
|
212
212
|
edit: !1
|
|
213
213
|
});
|
|
214
214
|
},
|
|
@@ -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-MzR4MaVE.cjs"),C=require("@chaibuilder/sdk"),i=require("@chaibuilder/sdk/ui"),r=require("lodash-es"),j=require("lucide-react"),c=require("react"),k=require("sonner"),G=require("jotai"),L=({page:s,onClose:S})=>{const{t:a}=C.useTranslation(),[o,E]=c.useState(s.slug||""),{mutate:N,isPending:y}=n.useChangeSlug(),{data:l}=n.usePageTypes(),d=r.find(l,{key:s==null?void 0:s.pageType}),f=h=>{if(h.preventDefault(),!(s!=null&&s.primaryPage)&&Object.keys(n.LANGUAGES).some(p=>o===`/${p}`||r.startsWith(o,`/${p}/`))){k.toast.error(a("Error"),{description:a("Slugs cannot start with a language code for primary page")});return}N({...s,slug:o},{onSuccess:S})},m=(s==null?void 0:s.lang)||"";return e.jsx(i.Dialog,{open:!!s,onOpenChange:S,children:e.jsxs(i.DialogContent,{children:[e.jsxs(i.DialogHeader,{children:[e.jsx(i.DialogTitle,{children:a("Change Slug")}),e.jsx(i.DialogDescription,{className:"text-xs",children:e.jsxs(i.Alert,{variant:"destructive",className:"mt-2",children:[e.jsx(j.AlertCircle,{className:"h-4 w-4"}),a("Changing the slug may have impact on your SEO. Please proceed with caution.")]})})]}),e.jsxs("form",{onSubmit:f,children:[e.jsxs("div",{className:"space-y-4 py-4 text-sm ",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{children:[e.jsxs("span",{children:[a("Type"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",(d==null?void 0:d.name)||(s==null?void 0:s.pageType)]})]}),e.jsxs("div",{children:[e.jsxs("span",{children:[a("Name"),":"]}),e.jsxs("span",{className:"font-medium text-gray-600",children:[" ",s.name]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(i.Label,{htmlFor:"slug",className:"text-right",children:[a("Slug")," ",e.jsxs("small",{className:"font-light text-gray-500",children:[a("Slug should start with")," /",m]})]}),e.jsx(i.Input,{id:"slug",value:o,onChange:h=>{const x=h.target.value;r.startsWith(x,`/${m}`)&&E(x)},className:"col-span-3",required:!0,pattern:"^/.*",title:a("Slug must start with /"),placeholder:a("Enter page slug")})]})]}),e.jsx(i.DialogFooter,{children:e.jsx(i.Button,{type:"submit",disabled:y||!r.startsWith(o,`/${m}`)||r.isEqual(s==null?void 0:s.slug,o),children:a(y?"Changing...":"Change Slug")})})]})]})})},M=c.lazy(()=>Promise.resolve().then(()=>require("./delete-page-OGCRZzrG.cjs"))),T=c.lazy(()=>Promise.resolve().then(()=>require("./unpublish-page-uIYo5nwG.cjs"))),_=()=>{const{t:s}=C.useTranslation(),[,S]=G.useAtom(n.addNewLangAtom),{selectedLang:a,fallbackLang:o,setSelectedLang:E}=C.useLanguages(),{data:N,isFetching:y}=n.useLanguagePages(),{data:l}=n.useCurrentPage(),{data:d}=n.usePageTypes(),f=c.useMemo(()=>{const t=d==null?void 0:d.find(g=>g.key===(l==null?void 0:l.pageType));return l!=null&&l.dynamic?t==null?void 0:t.dynamicSlug:""},[d,l==null?void 0:l.pageType,l==null?void 0:l.dynamic]),[m,h]=c.useState(null),[x,P]=c.useState(null),[p,A]=c.useState(null),{data:b}=n.useWebsiteSetting(),I=r.filter(r.get(b,"languages")||["en"],t=>!r.find(N,{lang:t})&&t!==r.get(b,"fallbackLang"));return e.jsxs("div",{className:"space-y-4",children:[e.jsx("ul",{className:"space-y-2",children:y?e.jsxs("div",{className:"w-full space-y-3 py-4",children:[e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"}),e.jsx("div",{className:"h-8 w-full animate-pulse rounded bg-gray-300"})]}):r.map(N,t=>{const g=t.lang,v=t.slug,w=!t.primaryPage,D=g===a;return e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:`flex w-full cursor-pointer items-center justify-between rounded p-2 text-slate-500 ${D?"bg-gray-200":"hover:bg-gray-100"}`,onClick:()=>E(g),children:[e.jsxs("div",{className:"flex-1 gap-x-3",children:[e.jsxs("div",{className:"flex items-center gap-x-2 text-[13px] text-slate-800",children:[e.jsx("div",{className:`h-2.5 w-2.5 rounded-full ${t.online?"bg-green-300":"bg-gray-300"}`}),r.get(n.LANGUAGES,w?o:g,g)]}),e.jsxs("div",{children:[v&&e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Slug: ",e.jsx("b",{className:"font-mono font-medium",children:f?`${v}/${f}`:v})]}),e.jsxs("div",{className:"text-[11px] font-light text-slate-600",children:["Name:",e.jsxs("b",{className:"font-medium",children:[" ",t.name," "]})]})]})]}),w?e.jsxs("div",{className:"flex items-center gap-x-1 text-[11px] text-orange-500",children:[e.jsx(j.StarIcon,{fill:"orange",className:"h-3 w-3"}),e.jsx("b",{children:" Primary"})]}):e.jsx("div",{className:"flex items-center gap-x-3",children:e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE,n.PAGES_PERMISSIONS.DELETE_PAGE,n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:e.jsxs(i.DropdownMenu,{children:[e.jsx(i.DropdownMenuTrigger,{asChild:!0,onClick:u=>u.stopPropagation(),children:e.jsx(i.Button,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",children:e.jsx(j.MoreHorizontal,{className:"h-4 w-4"})})}),e.jsxs(i.DropdownMenuContent,{align:"end",className:"z-[9999] text-sm",children:[e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.EDIT_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),S({edit:!0,id:t.id,primaryPage:t.primaryPage})},children:[e.jsx(j.PencilIcon,{className:"size-3"}),s("Edit")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.UNPUBLISH_PAGE],children:(t==null?void 0:t.online)&&e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),P(t)},children:[e.jsx(j.Power,{className:"size-3"}),s("Unpublish")]})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.DELETE_PAGE],children:e.jsxs(i.DropdownMenuItem,{className:"flex cursor-pointer items-center gap-2",onClick:u=>{u.stopPropagation(),h(t)},children:[e.jsx(j.TrashIcon,{className:"size-3"}),s("Delete")]})})]})]})})})]},t.id),e.jsx("div",{className:"h-1 w-full border-b"})]})})}),e.jsx(n.PermissionChecker,{permissions:[n.PAGES_PERMISSIONS.ADD_PAGE],children:e.jsx("div",{className:"flex w-full justify-center",children:e.jsx(i.Button,{variant:"default",size:"sm",disabled:r.isEmpty(I),onClick:()=>{S({primaryPage:l==null?void 0:l.id,edit:!1})},children:s("Add new language page")})})}),m&&e.jsx(c.Suspense,{children:e.jsx(M,{page:m,onClose:()=>h(null)})}),x&&e.jsx(c.Suspense,{children:e.jsx(T,{page:x,onClose:()=>P(null)})}),p&&e.jsx(c.Suspense,{children:e.jsx(L,{page:p,onClose:()=>A(null)})})]})};exports.default=_;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),b=require("./index-MzR4MaVE.cjs"),M=require("@chaibuilder/sdk"),a=require("@chaibuilder/sdk/ui"),y=require("lodash-es"),d=require("lucide-react"),l=require("react"),w=require("sonner"),q=1*1024*1024,A=({page:r,onClose:m})=>{const{t:s}=M.useTranslation(),[g,u]=l.useState(!1),[f,k]=l.useState(""),[c,j]=l.useState(""),[N,p]=l.useState(!1),i=l.useRef(null),T=b.useMarkAsTemplate(),{data:x}=b.usePageTypes(),h=x==null?void 0:x.find(t=>t.key===r.pageType),C=(h==null?void 0:h.name)||y.startCase(r.pageType),I=l.useCallback(t=>{var v;const o=(v=t.target.files)==null?void 0:v[0];if(o){if(o.size>q){w.toast.error(s("File too large"),{description:`${s("Maximum file size is 1MB. Selected file is")} ${(o.size/1024).toFixed(2)}KB.`}),i.current&&(i.current.value="");return}try{p(!0);const n=new FileReader;n.onloadend=()=>{j(n.result),p(!1)},n.readAsDataURL(o)}catch(n){console.error("Error reading file:",n),p(!1),w.toast.error(s("Failed to process image"),{description:n instanceof Error?n.message:s("Unknown error")})}}},[s]),D=()=>{j(""),i.current&&(i.current.value="")},F=()=>{var t;(t=i.current)==null||t.click()},S=()=>{u(!0),T.mutate({page:r,name:r.name,description:f.trim()||void 0,pageType:r.pageType,...c?{previewImage:c}:{}},{onSuccess:()=>{u(!1),m()},onError:()=>{u(!1)}})};return e.jsx(a.Dialog,{open:!0,onOpenChange:m,children:e.jsxs(a.DialogContent,{children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{children:s("Mark as template")}),e.jsxs(a.DialogDescription,{className:"space-y-1 py-4 text-xs text-slate-500",children:[s("Are you sure you want to mark this page as a template?"),e.jsx("br",{}),s("Templates can be used to create new pages with the same content.")]})]}),e.jsxs("div",{className:"mb-4 space-y-4 text-xs",children:[e.jsxs("div",{className:"space-y-3 rounded border bg-slate-50 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.Tag,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Page Name"),":"]}),e.jsx("span",{className:"font-semibold",children:y.startCase(r.name)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(d.File,{className:"h-4 w-4 text-slate-500"}),e.jsxs("span",{className:"font-medium text-slate-500",children:[s("Type"),":"]}),e.jsx("span",{className:"font-semibold",children:C})]})]}),e.jsxs("div",{children:[e.jsx(a.Label,{htmlFor:"description",className:"text-xs font-medium",children:s("Description (Optional)")}),e.jsx(a.Textarea,{id:"description",placeholder:s("Describe this template's purpose"),className:"mt-1 h-24 resize-none text-xs",value:f,onChange:t=>k(t.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(a.Label,{htmlFor:"previewImage",className:"text-xs font-medium",children:s("Preview Image (Optional)")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.Input,{type:"file",id:"previewImage",ref:i,onChange:I,accept:"image/*",className:"hidden"}),e.jsx(a.Button,{type:"button",variant:"outline",onClick:F,disabled:N,className:"w-full",children:N?e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),s("Uploading...")]}):e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(d.ImageIcon,{className:"h-4 w-4"}),s("Select image")]})}),c&&e.jsx(a.Button,{type:"button",variant:"outline",size:"icon",onClick:D,children:e.jsx(d.X,{className:"h-4 w-4"})})]}),c&&e.jsx("div",{className:"aspect-video overflow-hidden rounded-md border",children:e.jsx("img",{src:c,alt:s("Preview"),className:"h-full max-h-[200px] w-full object-contain"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:s("max 1mb")})]})]})]}),e.jsxs(a.DialogFooter,{className:g?"pointer-events-none opacity-75":"",children:[e.jsx(a.Button,{variant:"outline",onClick:t=>{t.stopPropagation(),m()},children:s("Cancel")}),e.jsx(a.Button,{variant:"default",disabled:g,onClick:S,children:s("Mark as template")})]})]})})};exports.default=A;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { r as P, m as z } from "./index-DOH-lluK.js";
|
|
3
3
|
import { useTranslation as E } from "@chaibuilder/sdk";
|
|
4
4
|
import { Dialog as L, DialogContent as S, DialogHeader as U, DialogTitle as B, DialogDescription as R, Label as w, Textarea as j, Input as O, Button as c, DialogFooter as X } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { startCase as y } from "lodash-es";
|
|
6
6
|
import { Tag as _, File as $, ImageIcon as H, X as K } from "lucide-react";
|
|
7
|
-
import { useState as
|
|
7
|
+
import { useState as m, useRef as Z, useCallback as q } from "react";
|
|
8
8
|
import { toast as k } from "sonner";
|
|
9
|
-
const G = 1 * 1024 * 1024, se = ({ page: n, onClose:
|
|
10
|
-
const { t: a } = E(), [g, p] =
|
|
9
|
+
const G = 1 * 1024 * 1024, se = ({ page: n, onClose: d }) => {
|
|
10
|
+
const { t: a } = E(), [g, p] = m(!1), [x, I] = m(""), [l, N] = m(""), [v, u] = m(!1), i = Z(null), T = P(), { data: h } = z(), f = h == null ? void 0 : h.find((s) => s.key === n.pageType), C = (f == null ? void 0 : f.name) || y(n.pageType), D = q((s) => {
|
|
11
11
|
var b;
|
|
12
12
|
const o = (b = s.target.files) == null ? void 0 : b[0];
|
|
13
13
|
if (o) {
|
|
@@ -45,7 +45,7 @@ const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
|
|
|
45
45
|
},
|
|
46
46
|
{
|
|
47
47
|
onSuccess: () => {
|
|
48
|
-
p(!1),
|
|
48
|
+
p(!1), d();
|
|
49
49
|
},
|
|
50
50
|
onError: () => {
|
|
51
51
|
p(!1);
|
|
@@ -53,7 +53,7 @@ const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
|
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ e(L, { open: !0, onOpenChange:
|
|
56
|
+
return /* @__PURE__ */ e(L, { open: !0, onOpenChange: d, children: /* @__PURE__ */ t(S, { children: [
|
|
57
57
|
/* @__PURE__ */ t(U, { children: [
|
|
58
58
|
/* @__PURE__ */ e(B, { children: a("Mark as template") }),
|
|
59
59
|
/* @__PURE__ */ t(R, { className: "space-y-1 py-4 text-xs text-slate-500", children: [
|
|
@@ -139,7 +139,7 @@ const G = 1 * 1024 * 1024, se = ({ page: n, onClose: m }) => {
|
|
|
139
139
|
{
|
|
140
140
|
variant: "outline",
|
|
141
141
|
onClick: (s) => {
|
|
142
|
-
s.stopPropagation(),
|
|
142
|
+
s.stopPropagation(), d();
|
|
143
143
|
},
|
|
144
144
|
children: a("Cancel")
|
|
145
145
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { c as h, d as u, L as w, B as p } from "./index-DOH-lluK.js";
|
|
3
3
|
import { useTranslation as f, useLanguages as P } from "@chaibuilder/sdk";
|
|
4
4
|
import { Card as C, CardHeader as S, CardTitle as L, CardContent as x, CardFooter as N, Button as v } from "@chaibuilder/sdk/ui";
|
|
5
5
|
import { get as B } from "lodash-es";
|
package/dist/{no-language-page-content-JO4YYUx7.cjs → no-language-page-content-CFVzHv_Y.cjs}
RENAMED
|
@@ -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-MzR4MaVE.cjs"),i=require("@chaibuilder/sdk"),t=require("@chaibuilder/sdk/ui"),w=require("lodash-es"),x=require("lucide-react"),P=()=>{const{t:a}=i.useTranslation(),[l,g]=n.useSearchParams(),c=l.get("lang"),u=n.useIsLanguagePageCreated(c),{setSelectedLang:d}=i.useLanguages(),h=()=>{const r=new URLSearchParams(window.location.search);r.delete("lang");const o=r.toString(),m=`${window.location.pathname}${o?`?${o}`:""}`;window.history.pushState({},"",m),g(r),d(""),window.dispatchEvent(new PopStateEvent("popstate"))};if(u)return null;const s=w.get(n.LANGUAGES,c);return e.jsx(n.BlurContainer,{children:e.jsxs(t.Card,{className:"mx-auto w-full max-w-md",children:[e.jsx(t.CardHeader,{className:"space-y-1",children:e.jsxs(t.CardTitle,{className:"flex items-center gap-2 text-2xl",children:[e.jsx(x.LockIcon,{className:"h-6 w-6 text-yellow-500"}),a("Page missing for"),' "',s,'" ',a("language"),"."]})}),e.jsx(t.CardContent,{className:"grid gap-4",children:e.jsxs("div",{children:[a("Page is not available in the"),' "',s,'" ',a("language. Either create the page in the"),' "',s,'"',a("language or switch to the base language.")]})}),e.jsx(t.CardFooter,{children:e.jsx(t.Button,{onClick:h,className:"w-full",variant:"destructive",children:a("Switch to default language")})})]})})};exports.default=P;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { c as g, d as n } from "./index-DOH-lluK.js";
|
|
3
|
+
import { lazy as s, Suspense as t } from "react";
|
|
4
|
+
const o = s(() => import("./no-language-page-content-C7oVsIYu.js")), l = () => {
|
|
5
|
+
const [e] = g(), r = e.get("lang");
|
|
6
|
+
return n(r) ? null : /* @__PURE__ */ a(t, { children: /* @__PURE__ */ a(o, {}) });
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
l as default
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("./index-MzR4MaVE.cjs"),n=require("react"),s=n.lazy(()=>Promise.resolve().then(()=>require("./no-language-page-content-CFVzHv_Y.cjs"))),g=()=>{const[r]=a.useSearchParams(),t=r.get("lang");return a.useIsLanguagePageCreated(t)?null:e.jsx(n.Suspense,{children:e.jsx(s,{})})};exports.default=g;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { jsx as s, jsxs as n, Fragment as We } from "react/jsx-runtime";
|
|
2
2
|
import { Input as M, CommandList as is, Label as I, Popover as ee, PopoverTrigger as se, Button as W, PopoverContent as le, Command as ne, CommandEmpty as ae, CommandGroup as G, CommandItem as R } from "@chaibuilder/sdk/ui";
|
|
3
3
|
import { useState as y, useRef as os, useEffect as Be, useMemo as $ } from "react";
|
|
4
|
-
import { r as te, S as cs, c as Oe } from "./slug-input-
|
|
4
|
+
import { r as te, S as cs, c as Oe } from "./slug-input-Bq48cfWr.js";
|
|
5
5
|
import { useChaiFeatureFlag as ye, usePermissions as us, useLanguages as ms } from "@chaibuilder/sdk";
|
|
6
6
|
import { isEmpty as Ie, startCase as de, filter as hs, find as ge, groupBy as ps, pick as ds, set as P } from "lodash-es";
|
|
7
7
|
import { ChevronDown as re, Search as ie, Check as U } from "lucide-react";
|
|
8
|
-
import {
|
|
9
|
-
import { useQuery as
|
|
8
|
+
import { aq as Re, ar as Ue, A as oe, m as fs, as as gs, g as ys, h as vs, i as Ns, ay as Ss, L as bs } from "./index-DOH-lluK.js";
|
|
9
|
+
import { useQuery as qe } from "@tanstack/react-query";
|
|
10
10
|
import { toast as E } from "sonner";
|
|
11
11
|
import { g as $e } from "./get-seo-defaults-9zHebckY.js";
|
|
12
12
|
function ws({
|
|
@@ -20,30 +20,30 @@ function ws({
|
|
|
20
20
|
Be(() => {
|
|
21
21
|
C(p + l);
|
|
22
22
|
}, [l, p]);
|
|
23
|
-
const F = (
|
|
24
|
-
const
|
|
25
|
-
if (!
|
|
26
|
-
const O =
|
|
27
|
-
C(
|
|
23
|
+
const F = (S) => {
|
|
24
|
+
const b = S.target.value;
|
|
25
|
+
if (!b.startsWith(p)) {
|
|
26
|
+
const O = b.replace(p, ""), q = p + O;
|
|
27
|
+
C(q), o(O);
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const t =
|
|
30
|
+
const t = b.substring(p.length).replace(/\//g, "").replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-_.]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").toLowerCase(), a = (t.match(/\./g) || []).length, d = a <= 1;
|
|
31
31
|
a > 1 ? u("Invalid slug. Only one dot (.) is allowed in the slug") : u(null), i && i(d);
|
|
32
32
|
const N = p + t;
|
|
33
33
|
C(N), o(t);
|
|
34
34
|
}, w = () => {
|
|
35
35
|
if (m.current) {
|
|
36
|
-
const
|
|
36
|
+
const S = m.current;
|
|
37
37
|
setTimeout(() => {
|
|
38
|
-
const
|
|
39
|
-
|
|
38
|
+
const b = p.length;
|
|
39
|
+
S.setSelectionRange(b, b);
|
|
40
40
|
}, 0);
|
|
41
41
|
}
|
|
42
|
-
}, B = (
|
|
43
|
-
const
|
|
44
|
-
(
|
|
42
|
+
}, B = (S) => {
|
|
43
|
+
const b = S.currentTarget;
|
|
44
|
+
(b.selectionStart || 0) <= p.length && setTimeout(() => {
|
|
45
45
|
const t = p.length;
|
|
46
|
-
|
|
46
|
+
b.setSelectionRange(t, t);
|
|
47
47
|
}, 0);
|
|
48
48
|
};
|
|
49
49
|
return /* @__PURE__ */ s("div", { children: /* @__PURE__ */ n("div", { className: "relative", children: [
|
|
@@ -92,7 +92,7 @@ function xs({
|
|
|
92
92
|
return w.filter(
|
|
93
93
|
(d) => d.name.toLowerCase().includes(a) || d.slug.toLowerCase().includes(a)
|
|
94
94
|
);
|
|
95
|
-
}, [w, f]),
|
|
95
|
+
}, [w, f]), S = (a) => Math.max(0, (a.match(/\//g) || []).length - 1), b = (a) => " ".repeat(a), h = (a) => {
|
|
96
96
|
if (a === "/") return "/";
|
|
97
97
|
const d = a.split("/").filter(Boolean);
|
|
98
98
|
if (d.length <= 1) {
|
|
@@ -153,7 +153,7 @@ function xs({
|
|
|
153
153
|
}
|
|
154
154
|
),
|
|
155
155
|
B.map((a) => {
|
|
156
|
-
const d = S(
|
|
156
|
+
const d = b(S(a.slug)), N = h(a.slug), O = /* @__PURE__ */ n("span", { className: "flex items-center text-sm", children: [
|
|
157
157
|
d,
|
|
158
158
|
a.name,
|
|
159
159
|
/* @__PURE__ */ n("span", { className: "text-xs text-gray-500", children: [
|
|
@@ -200,7 +200,7 @@ function xs({
|
|
|
200
200
|
children: [
|
|
201
201
|
/* @__PURE__ */ s("option", { value: "none", children: "None" }),
|
|
202
202
|
w.map((a) => {
|
|
203
|
-
const d =
|
|
203
|
+
const d = S(a.slug), N = d > 0 ? b(d) : "", O = h(a.slug);
|
|
204
204
|
return (g == null ? void 0 : g.id) === a.id || a.slug.startsWith(g == null ? void 0 : g.slug) ? null : /* @__PURE__ */ n("option", { value: a.id, children: [
|
|
205
205
|
N,
|
|
206
206
|
a.name,
|
|
@@ -244,11 +244,11 @@ const Cs = (...l) => l.filter(Boolean).join(" "), ks = ({
|
|
|
244
244
|
return d.length > 0 && (h[t] = d), h;
|
|
245
245
|
},
|
|
246
246
|
{}
|
|
247
|
-
),
|
|
247
|
+
), S = l.find((h) => h.id === o), b = S ? de(S.name) : "No Template";
|
|
248
248
|
return /* @__PURE__ */ n("div", { className: "space-y-4", children: [
|
|
249
249
|
F ? /* @__PURE__ */ n(ee, { open: u, onOpenChange: m, children: [
|
|
250
250
|
/* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ n(W, { variant: "outline", role: "combobox", className: "w-full justify-between", children: [
|
|
251
|
-
|
|
251
|
+
b,
|
|
252
252
|
/* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
253
253
|
] }) }),
|
|
254
254
|
/* @__PURE__ */ s(le, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ n(ne, { shouldFilter: !1, children: [
|
|
@@ -310,14 +310,14 @@ const Cs = (...l) => l.filter(Boolean).join(" "), ks = ({
|
|
|
310
310
|
] });
|
|
311
311
|
}, Ls = () => {
|
|
312
312
|
const l = Re(), o = Ue();
|
|
313
|
-
return
|
|
313
|
+
return qe({
|
|
314
314
|
queryKey: [oe.GET_LIBRARIES],
|
|
315
315
|
staleTime: "static",
|
|
316
316
|
queryFn: async () => await o(l, { action: oe.GET_LIBRARIES }) || []
|
|
317
317
|
});
|
|
318
318
|
}, Ts = (l) => {
|
|
319
319
|
const o = Re(), v = Ue();
|
|
320
|
-
return
|
|
320
|
+
return qe({
|
|
321
321
|
queryKey: [oe.GET_TEMPLATES_BY_TYPE, l],
|
|
322
322
|
staleTime: "static",
|
|
323
323
|
enabled: !!l,
|
|
@@ -344,19 +344,19 @@ const Cs = (...l) => l.filter(Boolean).join(" "), ks = ({
|
|
|
344
344
|
isLoading: v || i
|
|
345
345
|
};
|
|
346
346
|
}, V = (...l) => l.filter(Boolean).join(" ");
|
|
347
|
-
function
|
|
347
|
+
function zs({ addEditPage: l, close: o, closePanel: v }) {
|
|
348
348
|
var Ae, Fe;
|
|
349
|
-
const { data: p } = fs(), i = $(() => p ?? [], [p]), g = gs(), u = !!(l != null && l.id), { data: m } = ys(), { mutate: f, isPending: C } = vs(), { mutate: F, isPending: w } = Ns(), [B,
|
|
349
|
+
const { data: p } = fs(), i = $(() => p ?? [], [p]), g = gs(), u = !!(l != null && l.id), { data: m } = ys(), { mutate: f, isPending: C } = vs(), { mutate: F, isPending: w } = Ns(), [B, S] = y(null), [b, h] = y(!0), [t, a] = y((l == null ? void 0 : l.pageType) ?? "page"), { hasPermission: d } = us(), N = d(Ss.CHANGE_PAGE_TYPE), [O, q] = y(!1), [ze, _e] = y(""), { selectedLang: Ve, fallbackLang: Ge } = ms(), ve = Ve || Ge, [Y, Z] = y(""), [Ne, H] = y(!1), Se = $(() => {
|
|
350
350
|
const e = i.find((c) => c.key === t);
|
|
351
351
|
return (e == null ? void 0 : e.hasSlug) === !1;
|
|
352
|
-
}, [t, i]), [k, Me] = y((l == null ? void 0 : l.parent) ?? ""), [
|
|
352
|
+
}, [t, i]), [k, Me] = y((l == null ? void 0 : l.parent) ?? ""), [z, be] = y((l == null ? void 0 : l.name) ?? ""), [T, we] = y((l == null ? void 0 : l.dynamic) ?? !1), [j, K] = y(T ? "" : ((l == null ? void 0 : l.slug) ?? "").split("/").pop() || ""), [xe, Ce] = y((l == null ? void 0 : l.dynamicSlugCustom) ?? ""), [ke, Ye] = y(!0), [Qe, ue] = y(!1), [me, He] = y(""), { data: Le, isLoading: Ke } = js(t), Q = C || w, Te = ye("enable-add-page-dropdown"), he = $(() => !u || !(l != null && l.id) || !m ? null : m.find((e) => e.id === l.id), [u, l == null ? void 0 : l.id, m]), Ze = (he == null ? void 0 : he.online) || !1, Je = $(() => !u || !(l != null && l.id) || !m ? !1 : m.some((e) => e.parent === l.id), [u, l == null ? void 0 : l.id, m]), r = i.find((e) => e.key === t), _ = (e) => {
|
|
353
353
|
if (u && t !== e) {
|
|
354
|
-
|
|
354
|
+
_e(e), q(!0), Z(""), H(!1);
|
|
355
355
|
return;
|
|
356
356
|
}
|
|
357
357
|
a(e), Z(""), H(!1);
|
|
358
358
|
}, je = () => {
|
|
359
|
-
a(
|
|
359
|
+
a(ze), q(!1), we(!1);
|
|
360
360
|
}, Xe = (e) => {
|
|
361
361
|
we(e), e ? K("") : Ce("");
|
|
362
362
|
}, Pe = (e) => {
|
|
@@ -371,15 +371,15 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
371
371
|
K(j ? `${j}` : "");
|
|
372
372
|
}, Ee = (e) => {
|
|
373
373
|
He(e);
|
|
374
|
-
}, es = () =>
|
|
374
|
+
}, es = () => z.trim() ? T && !Ie(j) ? (S("Slug must be empty when using dynamic slug"), !1) : T && !ke ? (S("Dynamic slug is invalid"), !1) : !0 : (E.error("Name is required"), !1), ss = () => {
|
|
375
375
|
const e = {
|
|
376
376
|
pageType: r == null ? void 0 : r.key,
|
|
377
|
-
name:
|
|
377
|
+
name: z,
|
|
378
378
|
slug: "",
|
|
379
379
|
hasSlug: !1
|
|
380
380
|
};
|
|
381
381
|
u ? F(
|
|
382
|
-
{ id: l == null ? void 0 : l.id, name:
|
|
382
|
+
{ id: l == null ? void 0 : l.id, name: z },
|
|
383
383
|
{
|
|
384
384
|
onSuccess: () => {
|
|
385
385
|
E.success((r == null ? void 0 : r.name) + " updated successfully"), o();
|
|
@@ -392,13 +392,13 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
392
392
|
});
|
|
393
393
|
}, ls = (e, c) => {
|
|
394
394
|
if (!e.trim() && !T)
|
|
395
|
-
return
|
|
395
|
+
return S("Child page slug is required"), !1;
|
|
396
396
|
const D = te(c), x = Oe(D, e);
|
|
397
|
-
return Object.keys(
|
|
397
|
+
return Object.keys(bs).some((X) => x === `/${X}` || (x == null ? void 0 : x.startsWith(`/${X}/`))) ? (S("Slugs cannot start with a language code for primary page"), !1) : !0;
|
|
398
398
|
}, ns = (e, c) => {
|
|
399
399
|
const D = te(c), x = Oe(D, e), L = {
|
|
400
400
|
pageType: t,
|
|
401
|
-
name:
|
|
401
|
+
name: z,
|
|
402
402
|
slug: x.replace(/\/$/, ""),
|
|
403
403
|
// remove trailing slashes
|
|
404
404
|
parent: k,
|
|
@@ -432,7 +432,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
432
432
|
}, as = () => {
|
|
433
433
|
const e = {
|
|
434
434
|
pageType: t,
|
|
435
|
-
name:
|
|
435
|
+
name: z,
|
|
436
436
|
slug: j === "" ? "/" : `/${j.replace(/\/$/, "")}`,
|
|
437
437
|
template: me || void 0,
|
|
438
438
|
parent: null,
|
|
@@ -459,7 +459,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
459
459
|
});
|
|
460
460
|
}
|
|
461
461
|
}, De = (e) => {
|
|
462
|
-
if (e.preventDefault(),
|
|
462
|
+
if (e.preventDefault(), S(null), !!es()) {
|
|
463
463
|
if (!(r != null && r.hasSlug)) {
|
|
464
464
|
ss();
|
|
465
465
|
return;
|
|
@@ -514,11 +514,11 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
514
514
|
] }) }),
|
|
515
515
|
/* @__PURE__ */ n(ce, { className: "overflow-y-auto", children: [
|
|
516
516
|
/* @__PURE__ */ s(ae, { children: "No page type found." }),
|
|
517
|
-
u ?
|
|
517
|
+
u ? Se ? /* @__PURE__ */ s(G, { heading: "Partials", children: J.map((e) => /* @__PURE__ */ n(
|
|
518
518
|
R,
|
|
519
519
|
{
|
|
520
520
|
value: e.key,
|
|
521
|
-
onSelect: () =>
|
|
521
|
+
onSelect: () => _(e.key),
|
|
522
522
|
className: "flex cursor-pointer items-center justify-between",
|
|
523
523
|
children: [
|
|
524
524
|
e.name,
|
|
@@ -535,7 +535,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
535
535
|
R,
|
|
536
536
|
{
|
|
537
537
|
value: e.key,
|
|
538
|
-
onSelect: () =>
|
|
538
|
+
onSelect: () => _(e.key),
|
|
539
539
|
className: "flex cursor-pointer items-center justify-between",
|
|
540
540
|
children: [
|
|
541
541
|
e.name,
|
|
@@ -553,7 +553,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
553
553
|
R,
|
|
554
554
|
{
|
|
555
555
|
value: e.key,
|
|
556
|
-
onSelect: () =>
|
|
556
|
+
onSelect: () => _(e.key),
|
|
557
557
|
className: "flex cursor-pointer items-center justify-between",
|
|
558
558
|
children: [
|
|
559
559
|
e.name,
|
|
@@ -571,7 +571,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
571
571
|
R,
|
|
572
572
|
{
|
|
573
573
|
value: e.key,
|
|
574
|
-
onSelect: () =>
|
|
574
|
+
onSelect: () => _(e.key),
|
|
575
575
|
className: "flex cursor-pointer items-center justify-between",
|
|
576
576
|
children: [
|
|
577
577
|
e.name,
|
|
@@ -594,9 +594,9 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
594
594
|
id: "pageType",
|
|
595
595
|
value: t,
|
|
596
596
|
disabled: u && !N,
|
|
597
|
-
onChange: (e) =>
|
|
597
|
+
onChange: (e) => _(e.target.value),
|
|
598
598
|
className: `w-full rounded-md border border-gray-300 px-3 py-2 ${u && !N ? "cursor-not-allowed text-gray-500" : ""}`,
|
|
599
|
-
children: u ?
|
|
599
|
+
children: u ? Se ? /* @__PURE__ */ s("optgroup", { label: "Partials", children: i.filter((e) => e.hasSlug === !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) }) : /* @__PURE__ */ s("optgroup", { label: "Pages", children: i.filter((e) => e.hasSlug !== !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) }) : /* @__PURE__ */ n(We, { children: [
|
|
600
600
|
/* @__PURE__ */ s("optgroup", { label: "Pages", children: i.filter((e) => e.hasSlug !== !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) }),
|
|
601
601
|
/* @__PURE__ */ s("optgroup", { label: "Partials", children: i.filter((e) => e.hasSlug === !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) })
|
|
602
602
|
] })
|
|
@@ -605,7 +605,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
605
605
|
O && /* @__PURE__ */ n("div", { className: "mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3", children: [
|
|
606
606
|
/* @__PURE__ */ s("p", { className: "text-sm text-yellow-800", children: "Changing the page type may impact the page data. Are you sure you want to proceed?" }),
|
|
607
607
|
/* @__PURE__ */ n("div", { className: "mt-2 flex gap-2", children: [
|
|
608
|
-
/* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () =>
|
|
608
|
+
/* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () => q(!1), children: "Cancel" }),
|
|
609
609
|
/* @__PURE__ */ s(W, { variant: "default", size: "sm", onClick: je, children: "Confirm" })
|
|
610
610
|
] })
|
|
611
611
|
] })
|
|
@@ -637,8 +637,8 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
637
637
|
M,
|
|
638
638
|
{
|
|
639
639
|
id: "name",
|
|
640
|
-
value:
|
|
641
|
-
onChange: (e) =>
|
|
640
|
+
value: z,
|
|
641
|
+
onChange: (e) => be(e.target.value),
|
|
642
642
|
required: !0,
|
|
643
643
|
"aria-required": "true",
|
|
644
644
|
placeholder: "Enter page name"
|
|
@@ -705,7 +705,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
705
705
|
W,
|
|
706
706
|
{
|
|
707
707
|
disabled: Q || // Disable if regular slug is invalid and we're not using dynamic slug
|
|
708
|
-
!
|
|
708
|
+
!b && (!(r != null && r.dynamicSegments) || !T) || // Disable if dynamic slug is invalid and we are using dynamic slug
|
|
709
709
|
T && !ke,
|
|
710
710
|
type: "submit",
|
|
711
711
|
className: "w-full",
|
|
@@ -752,7 +752,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
752
752
|
{
|
|
753
753
|
value: e.key,
|
|
754
754
|
onSelect: () => {
|
|
755
|
-
|
|
755
|
+
_(e.key), H(!1);
|
|
756
756
|
},
|
|
757
757
|
className: "flex cursor-pointer items-center justify-between",
|
|
758
758
|
children: [
|
|
@@ -770,7 +770,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
770
770
|
id: "pageType",
|
|
771
771
|
value: t,
|
|
772
772
|
disabled: u && !N,
|
|
773
|
-
onChange: (e) =>
|
|
773
|
+
onChange: (e) => _(e.target.value),
|
|
774
774
|
className: `w-full rounded-md border border-gray-300 px-3 py-2 ${u && !N ? "cursor-not-allowed text-gray-500" : ""}`,
|
|
775
775
|
children: /* @__PURE__ */ s("optgroup", { label: "Partials", children: i.filter((e) => e.hasSlug === !1).map((e) => /* @__PURE__ */ s("option", { value: e.key, children: e.name }, e.key)) })
|
|
776
776
|
}
|
|
@@ -778,7 +778,7 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
778
778
|
O && /* @__PURE__ */ n("div", { className: "mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3", children: [
|
|
779
779
|
/* @__PURE__ */ s("p", { className: "text-sm text-yellow-800", children: "Changing the page type may impact the page data. Are you sure you want to proceed?" }),
|
|
780
780
|
/* @__PURE__ */ n("div", { className: "mt-2 flex gap-2", children: [
|
|
781
|
-
/* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () =>
|
|
781
|
+
/* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () => q(!1), children: "Cancel" }),
|
|
782
782
|
/* @__PURE__ */ s(W, { variant: "default", size: "sm", onClick: je, children: "Confirm" })
|
|
783
783
|
] })
|
|
784
784
|
] }),
|
|
@@ -786,11 +786,11 @@ function _s({ addEditPage: l, close: o, closePanel: v }) {
|
|
|
786
786
|
] }),
|
|
787
787
|
/* @__PURE__ */ n("div", { className: "space-y-0.5", children: [
|
|
788
788
|
/* @__PURE__ */ s(I, { htmlFor: "name", className: "text-sm", children: "Name" }),
|
|
789
|
-
/* @__PURE__ */ s(M, { id: "name", value:
|
|
789
|
+
/* @__PURE__ */ s(M, { id: "name", value: z, onChange: (e) => be(e.target.value), required: !0, "aria-required": "true" })
|
|
790
790
|
] }),
|
|
791
791
|
/* @__PURE__ */ s(W, { disabled: Q, type: "submit", className: "w-full", children: u ? Q ? "Updating..." : "Update " + (r == null ? void 0 : r.name) : Q ? "Creating..." : "Create " + (r == null ? void 0 : r.name) })
|
|
792
792
|
] });
|
|
793
793
|
}
|
|
794
794
|
export {
|
|
795
|
-
|
|
795
|
+
zs as default
|
|
796
796
|
};
|