@chaibuilder/sdk 4.0.0-beta.1 → 4.0.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -20
- package/dist/2SSKDMRQ-BnsZi3K3.cjs +1 -0
- package/dist/2SSKDMRQ-CnSDkQcy.js +42 -0
- package/dist/AP7HFJJL-B31839PG.cjs +1228 -0
- package/dist/AP7HFJJL-CymCmW14.js +9214 -0
- package/dist/IconPicker-B1rWC-Ex.js +59 -0
- package/dist/IconPicker-DREyo007.cjs +1 -0
- package/dist/WDYDFRGG-BUVnbAci.js +33 -0
- package/dist/WDYDFRGG-BxhOCHc3.cjs +1 -0
- package/dist/_commonjsHelpers-C6fGbg64.js +6 -0
- package/dist/_commonjsHelpers-DwGv2jUC.cjs +1 -0
- package/dist/actions-registery-CZ1w0NKa.js +15545 -0
- package/dist/actions-registery-YnFmU21O.cjs +418 -0
- package/dist/actions.cjs +1 -0
- package/dist/actions.d.ts +3202 -0
- package/dist/actions.js +216 -0
- package/dist/active-in-another-tab-B47YjQGN.cjs +1 -0
- package/dist/active-in-another-tab-CyjngVA6.js +34 -0
- package/dist/add-new-language-page-88xzrUy8.cjs +1 -0
- package/dist/add-new-language-page-WmlCnytQ.js +401 -0
- package/dist/add-new-page-VW2wAYZp.js +31 -0
- package/dist/add-new-page-soZ8GAkN.cjs +1 -0
- package/dist/ai-panel-content-7zCil042.cjs +1 -0
- package/dist/ai-panel-content-D_o7Q_A-.js +61 -0
- package/dist/ai-panel-default-lang-COYaxNwn.cjs +3 -0
- package/dist/ai-panel-default-lang-DnElspF0.js +341 -0
- package/dist/ai-panel-other-lang-CkynNlAU.cjs +1 -0
- package/dist/ai-panel-other-lang-Dp0E9_Hx.js +162 -0
- package/dist/ai-prompt-input-Bhc0ds7X.js +655 -0
- package/dist/ai-prompt-input-CThbVp0_.cjs +1 -0
- package/dist/ai-translation-prompt-C2kJQFDX.cjs +1 -0
- package/dist/ai-translation-prompt-CZ55HQmo.js +28 -0
- package/dist/apply-binding-6iwlED02.js +833 -0
- package/dist/apply-binding-KKp5PnpZ.cjs +1 -0
- package/dist/code-display-BnqzqzoP.cjs +1 -0
- package/dist/{code-display-337R7Dev.js → code-display-DhD_RBcg.js} +1 -1
- package/dist/code-editor-DRIAnNbb.js +50 -0
- package/dist/code-editor-o3___nu2.cjs +1 -0
- package/dist/common-functions-B3a4xKt_.cjs +1 -0
- package/dist/common-functions-D2lMFR6K.js +13 -0
- package/dist/continue-editing-in-this-client-CS2aQ7yY.js +24 -0
- package/dist/continue-editing-in-this-client-CtMYsk-A.cjs +1 -0
- package/dist/core-BoRDjj4h.cjs +1 -0
- package/dist/core-yvI6kCyw.js +56 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +51 -383
- package/dist/core.js +39 -106
- package/dist/{css-import-modal-DA2L6kwP.js → css-import-modal-Byg6wV0O.js} +36 -36
- package/dist/css-import-modal-CyqkXWCO.cjs +13 -0
- package/dist/delete-design-token-BRZZiWtQ.js +40 -0
- package/dist/delete-design-token-DkVs1oBf.cjs +1 -0
- package/dist/delete-page-BzyX9TN-.js +70 -0
- package/dist/delete-page-DxX7PFIE.cjs +1 -0
- package/dist/design-token-usage-CAHzEGgJ.cjs +1 -0
- package/dist/design-token-usage-xQs6SlaJ.js +113 -0
- package/dist/digital-asset-manager--uO8Agia.cjs +1 -0
- package/dist/digital-asset-manager-DbtwzxRz.js +876 -0
- package/dist/duplicate-page-BR7Dlo9d.js +133 -0
- package/dist/duplicate-page-CaNAbXwV.cjs +1 -0
- package/dist/dynamic-page-selector-Cb5r_W8s.js +85 -0
- package/dist/dynamic-page-selector-Cxk_gjni.cjs +1 -0
- package/dist/fonts-B-Xt29pe.cjs +1 -0
- package/dist/fonts-DRly3Wzd.js +78 -0
- package/dist/{get-chai-builder-tailwind-config-C6MHaUM0.cjs → get-chai-builder-tailwind-config-B9rCyiQo.cjs} +1 -1
- package/dist/{get-chai-builder-tailwind-config-BqaIvg8p.js → get-chai-builder-tailwind-config-DjoVOuAf.js} +13 -10
- package/dist/{get-chai-builder-theme-D0IsUvK4.js → get-chai-builder-theme-BYtp20KD.js} +4 -4
- package/dist/get-chai-builder-theme-Dl72X7cz.cjs +1 -0
- package/dist/get-seo-defaults-9zHebckY.js +65 -0
- package/dist/get-seo-defaults-Cw7vFt-B.cjs +1 -0
- package/dist/image-compression-DZ9WMmyn.cjs +1 -0
- package/dist/image-compression-DsZ1oqpb.js +37 -0
- package/dist/image-editor-DV8kUKhl.js +108 -0
- package/dist/image-editor-G-K28aTS.cjs +1 -0
- package/dist/index-B-rSiAp_.cjs +1 -0
- package/dist/index-Ct7ElCGK.js +19069 -0
- package/dist/index-DF5DEvqb.cjs +160 -0
- package/dist/index-Dxfyt4d4.js +39 -0
- package/dist/index-WQwzsC7A.cjs +5 -0
- package/dist/index-ZuacEL1j.js +4732 -0
- package/dist/json-diff-viewer-D7z4zNvv.cjs +8 -0
- package/dist/json-diff-viewer-krslPepD.js +258 -0
- package/dist/lang-panel-BwIewMyw.js +215 -0
- package/dist/lang-panel-DT96k1xg.cjs +1 -0
- package/dist/manage-design-tokens-Caz_20VK.js +240 -0
- package/dist/manage-design-tokens-CrmLe7UT.cjs +1 -0
- package/dist/mark-as-template-D295ZQtU.js +156 -0
- package/dist/mark-as-template-W3LmpiqN.cjs +1 -0
- package/dist/models-5gOsRC56.cjs +1 -0
- package/dist/models-D95ZYr_x.js +70 -0
- package/dist/nested-path-selector-content-CKYYK-C5.js +87 -0
- package/dist/nested-path-selector-content-CoS_d3dc.cjs +1 -0
- package/dist/no-language-page-content-BvqRBP6y.js +42 -0
- package/dist/no-language-page-content-DkfeMl90.cjs +1 -0
- package/dist/no-language-page-dialog-BcEoqyQB.cjs +1 -0
- package/dist/no-language-page-dialog-PjNqTUpl.js +10 -0
- package/dist/page-creator-C4gc5NSC.cjs +1 -0
- package/dist/page-creator-DiOITEMw.js +795 -0
- package/dist/page-lock-BdYmCks0.cjs +1 -0
- package/dist/page-lock-Bfbs6RgL.js +30 -0
- package/dist/page-locked-dialog-B1FAtK92.cjs +1 -0
- package/dist/page-locked-dialog-B6MKTRfY.js +133 -0
- package/dist/page-manager-new-CHDueBDk.cjs +1 -0
- package/dist/page-manager-new-CzX22g2n.js +394 -0
- package/dist/page-manager-search-and-filter-CM0UMb6U.js +201 -0
- package/dist/page-manager-search-and-filter-DkkRIH86.cjs +1 -0
- package/dist/page-revisions-content-ChY-4f2V.cjs +1 -0
- package/dist/page-revisions-content-NH9JK4Ey.js +445 -0
- package/dist/pages.cjs +1 -0
- package/dist/pages.d.ts +491 -0
- package/dist/pages.js +27 -0
- package/dist/plugin-3ZKK6RXm.js +245 -0
- package/dist/plugin-C6rgJDNQ.cjs +22 -0
- package/dist/publish-pages-content-D9aixMN5.js +178 -0
- package/dist/publish-pages-content-x-JuSFJ9.cjs +1 -0
- package/dist/register-partial-type-BjtdfKHE.js +36 -0
- package/dist/register-partial-type-ig9fUWIJ.cjs +1 -0
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +26 -13
- package/dist/render.js +130 -124
- package/dist/rte-widget-modal-BaHIuEjF.cjs +1 -0
- package/dist/rte-widget-modal-DOJEXLIf.js +38 -0
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.ts +306 -7
- package/dist/runtime.js +44 -1
- package/dist/save-to-lib-Cgpxw8-g.cjs +1 -0
- package/dist/save-to-lib-eiOc_SSN.js +422 -0
- package/dist/sdk.css +1 -1
- package/dist/selected-block-display-BgRY82CT.cjs +16 -0
- package/dist/selected-block-display-CBFePS19.js +319 -0
- package/dist/seo-panel-C1-iMOR1.js +798 -0
- package/dist/seo-panel-DfAb8U7W.cjs +2 -0
- package/dist/shared-json-ld-B4PxAM_0.js +565 -0
- package/dist/shared-json-ld-DzG398hr.cjs +1 -0
- package/dist/slug-input-AwNJs9im.js +86 -0
- package/dist/slug-input-C_ijLQ_X.cjs +1 -0
- package/dist/supabase-actions.cjs +1 -0
- package/dist/supabase-actions.d.ts +284 -0
- package/dist/supabase-actions.js +524 -0
- package/dist/take-over-request-BNxcjY2j.cjs +1 -0
- package/dist/take-over-request-C4FeDtN_.js +63 -0
- package/dist/theme-panel-footer-Cq9pljro.cjs +1 -0
- package/dist/theme-panel-footer-uBQqSJXm.js +25 -0
- package/dist/translation-warning-modal-B64YqlbI.js +26 -0
- package/dist/translation-warning-modal-BZAcwM2_.cjs +1 -0
- package/dist/unmark-as-template-CZ9sQp_P.js +39 -0
- package/dist/unmark-as-template-EVvk0vmp.cjs +1 -0
- package/dist/unpublish-page-D4VwOlxc.js +27 -0
- package/dist/unpublish-page-bdSmwAVQ.cjs +1 -0
- package/dist/use-page-expand-manager-B6XTvk0E.cjs +1 -0
- package/dist/use-page-expand-manager-Cf4MUEJw.js +85 -0
- package/dist/{tailwind.cjs → utils.cjs} +1 -1
- package/dist/{tailwind.d.ts → utils.d.ts} +12 -11
- package/dist/utils.js +7 -0
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +0 -6
- package/dist/web-blocks.js +248 -241
- package/dist/web-preview-Cio70gk5.cjs +1 -0
- package/dist/web-preview-Djy6WIyj.js +73 -0
- package/package.json +175 -105
- package/dist/IconPicker-CGWn9C4u.cjs +0 -1
- package/dist/IconPicker-QvxJ-4Ez.js +0 -64
- package/dist/apply-binding-DCno1xQL.js +0 -711
- package/dist/apply-binding-DvHNFLQD.cjs +0 -1
- package/dist/code-display-BZ1x7SqI.cjs +0 -1
- package/dist/code-editor-B28LoECM.cjs +0 -1
- package/dist/code-editor-CfG2FhJ-.js +0 -58
- package/dist/common-functions-BGzDsf1z.js +0 -14
- package/dist/common-functions-BZmyleS1.cjs +0 -1
- package/dist/css-import-modal-CENUYvcl.cjs +0 -13
- package/dist/get-chai-builder-theme-Ck_Z4Q-M.cjs +0 -1
- package/dist/index-CaGNHF7f.js +0 -12209
- package/dist/index-Gn6pJt2v.cjs +0 -166
- package/dist/mockServiceWorker.js +0 -307
- package/dist/plugin-B5627hMN.js +0 -195
- package/dist/plugin-UxTRfDum.cjs +0 -22
- package/dist/rte-widget-modal-DL739qeQ.cjs +0 -1
- package/dist/rte-widget-modal-Dte0od04.js +0 -41
- package/dist/tailwind.js +0 -7
- package/dist/tooltip-A4qGk781.cjs +0 -1
- package/dist/tooltip-tLiIOgjq.js +0 -1067
- package/dist/ui.cjs +0 -1
- package/dist/ui.d.ts +0 -415
- package/dist/ui.js +0 -129
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,795 @@
|
|
|
1
|
+
import { jsx as s, jsxs as l, Fragment as We } from "react/jsx-runtime";
|
|
2
|
+
import { I as M, j as is, aG as ye, L as $, a9 as ee, aa as se, B as W, P as ae, C as le, k as ne, l as V, m as R, am as os, n as cs } from "./index-Ct7ElCGK.js";
|
|
3
|
+
import { useState as y, useRef as us, useEffect as Ie, useMemo as B } from "react";
|
|
4
|
+
import { r as te, S as ms, c as Oe } from "./slug-input-AwNJs9im.js";
|
|
5
|
+
import { isEmpty as $e, startCase as de, filter as hs, find as ge, groupBy as ps, pick as ds, set as P } from "lodash-es";
|
|
6
|
+
import { ChevronDown as re, Search as ie, Check as U } from "lucide-react";
|
|
7
|
+
import { ar as Re, as as Ue, A as oe, m as fs, at as gs, g as ys, h as vs, i as Ns, ay as Ss, L as bs } from "./index-ZuacEL1j.js";
|
|
8
|
+
import { useQuery as ze } from "@tanstack/react-query";
|
|
9
|
+
import { toast as E } from "sonner";
|
|
10
|
+
import { g as Be } from "./get-seo-defaults-9zHebckY.js";
|
|
11
|
+
function ws({
|
|
12
|
+
value: a,
|
|
13
|
+
onChange: o,
|
|
14
|
+
placeholder: v = "Enter custom slug part",
|
|
15
|
+
dynamicPattern: p,
|
|
16
|
+
onValidationChange: i
|
|
17
|
+
}) {
|
|
18
|
+
const [g, u] = y(null), m = us(null), [f, C] = y(p + a);
|
|
19
|
+
Ie(() => {
|
|
20
|
+
C(p + a);
|
|
21
|
+
}, [a, p]);
|
|
22
|
+
const F = (S) => {
|
|
23
|
+
const b = S.target.value;
|
|
24
|
+
if (!b.startsWith(p)) {
|
|
25
|
+
const O = b.replace(p, ""), z = p + O;
|
|
26
|
+
C(z), o(O);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const t = b.substring(p.length).replace(/\//g, "").replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-_.]/g, "-").replace(/-+/g, "-").replace(/^-+/, "").toLowerCase(), n = (t.match(/\./g) || []).length, d = n <= 1;
|
|
30
|
+
n > 1 ? u("Invalid slug. Only one dot (.) is allowed in the slug") : u(null), i && i(d);
|
|
31
|
+
const N = p + t;
|
|
32
|
+
C(N), o(t);
|
|
33
|
+
}, w = () => {
|
|
34
|
+
if (m.current) {
|
|
35
|
+
const S = m.current;
|
|
36
|
+
setTimeout(() => {
|
|
37
|
+
const b = p.length;
|
|
38
|
+
S.setSelectionRange(b, b);
|
|
39
|
+
}, 0);
|
|
40
|
+
}
|
|
41
|
+
}, I = (S) => {
|
|
42
|
+
const b = S.currentTarget;
|
|
43
|
+
(b.selectionStart || 0) <= p.length && setTimeout(() => {
|
|
44
|
+
const t = p.length;
|
|
45
|
+
b.setSelectionRange(t, t);
|
|
46
|
+
}, 0);
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ s("div", { children: /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
49
|
+
/* @__PURE__ */ l("p", { className: "mb-2 text-xs text-gray-500", children: [
|
|
50
|
+
`${p}`,
|
|
51
|
+
" is a dynamic segment of slug"
|
|
52
|
+
] }),
|
|
53
|
+
/* @__PURE__ */ s(
|
|
54
|
+
M,
|
|
55
|
+
{
|
|
56
|
+
ref: m,
|
|
57
|
+
value: f,
|
|
58
|
+
onChange: F,
|
|
59
|
+
onFocus: w,
|
|
60
|
+
onClick: I,
|
|
61
|
+
placeholder: v,
|
|
62
|
+
className: g ? "border-red-500" : ""
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
g && /* @__PURE__ */ s("div", { className: "mt-1 text-xs text-red-500", children: g })
|
|
66
|
+
] }) });
|
|
67
|
+
}
|
|
68
|
+
const ce = ({ children: a, onWheel: o, ...v }) => /* @__PURE__ */ s(is, { ...v, onWheel: (i) => {
|
|
69
|
+
try {
|
|
70
|
+
i.preventDefault();
|
|
71
|
+
const g = i.currentTarget;
|
|
72
|
+
g.scrollTop += i.deltaY;
|
|
73
|
+
} catch {
|
|
74
|
+
i.preventDefault();
|
|
75
|
+
}
|
|
76
|
+
o && o(i);
|
|
77
|
+
}, children: a }), fe = (...a) => a.filter(Boolean).join(" ");
|
|
78
|
+
function xs({
|
|
79
|
+
pages: a,
|
|
80
|
+
selectedParentId: o,
|
|
81
|
+
onChange: v,
|
|
82
|
+
className: p,
|
|
83
|
+
id: i = "parentPage",
|
|
84
|
+
currentPage: g
|
|
85
|
+
}) {
|
|
86
|
+
const [u, m] = y(!1), [f, C] = y(""), F = ye("enable-add-page-dropdown");
|
|
87
|
+
F || (p = "w-full rounded-md border border-gray-300 px-3 py-2");
|
|
88
|
+
const w = B(() => !a || a.length === 0 ? [] : a.filter((d) => !$e(d.slug)).filter((d) => d.slug !== "/").sort((d, N) => d.slug.localeCompare(N.slug)), [a]), I = B(() => {
|
|
89
|
+
if (!f.trim()) return w;
|
|
90
|
+
const n = f.toLowerCase();
|
|
91
|
+
return w.filter(
|
|
92
|
+
(d) => d.name.toLowerCase().includes(n) || d.slug.toLowerCase().includes(n)
|
|
93
|
+
);
|
|
94
|
+
}, [w, f]), S = (n) => Math.max(0, (n.match(/\//g) || []).length - 1), b = (n) => " ".repeat(n), h = (n) => {
|
|
95
|
+
if (n === "/") return "/";
|
|
96
|
+
const d = n.split("/").filter(Boolean);
|
|
97
|
+
if (d.length <= 1) {
|
|
98
|
+
const N = d[0] || "";
|
|
99
|
+
return `/${te(N)}`;
|
|
100
|
+
}
|
|
101
|
+
return `/${te(d[d.length - 1])}`;
|
|
102
|
+
}, t = () => {
|
|
103
|
+
if (!o || o === "none") return "None";
|
|
104
|
+
const n = w.find((d) => d.id === o);
|
|
105
|
+
return n ? `${n.name} (${h(n.slug)})` : "None";
|
|
106
|
+
};
|
|
107
|
+
return /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
|
|
108
|
+
/* @__PURE__ */ s($, { htmlFor: i, className: "text-sm", children: "Parent" }),
|
|
109
|
+
F ? /* @__PURE__ */ l(ee, { open: u, onOpenChange: m, children: [
|
|
110
|
+
/* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(
|
|
111
|
+
W,
|
|
112
|
+
{
|
|
113
|
+
id: i,
|
|
114
|
+
variant: "outline",
|
|
115
|
+
role: "combobox",
|
|
116
|
+
className: fe("w-full justify-between", p),
|
|
117
|
+
"data-testid": "parent-page-selector",
|
|
118
|
+
children: [
|
|
119
|
+
t(),
|
|
120
|
+
/* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
) }),
|
|
124
|
+
/* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
|
|
125
|
+
/* @__PURE__ */ s("div", { className: "relative border-none py-2", children: /* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
126
|
+
/* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
|
|
127
|
+
/* @__PURE__ */ s(
|
|
128
|
+
M,
|
|
129
|
+
{
|
|
130
|
+
placeholder: "Search pages...",
|
|
131
|
+
className: "h-8 pl-8 text-xs",
|
|
132
|
+
value: f,
|
|
133
|
+
onChange: (n) => C(n.target.value)
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] }) }) }),
|
|
137
|
+
/* @__PURE__ */ l(ce, { className: "max-h-[300px] overflow-y-auto", children: [
|
|
138
|
+
/* @__PURE__ */ s(ne, { children: "No pages found." }),
|
|
139
|
+
/* @__PURE__ */ l(V, { children: [
|
|
140
|
+
/* @__PURE__ */ l(
|
|
141
|
+
R,
|
|
142
|
+
{
|
|
143
|
+
value: "none",
|
|
144
|
+
onSelect: () => {
|
|
145
|
+
v(""), m(!1), C("");
|
|
146
|
+
},
|
|
147
|
+
className: "flex cursor-pointer items-center justify-between",
|
|
148
|
+
children: [
|
|
149
|
+
/* @__PURE__ */ s("span", { children: "None" }),
|
|
150
|
+
/* @__PURE__ */ s(U, { className: fe("mr-2 h-4 w-4", o ? "opacity-0" : "opacity-100") })
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
),
|
|
154
|
+
I.map((n) => {
|
|
155
|
+
const d = b(S(n.slug)), N = h(n.slug), O = /* @__PURE__ */ l("span", { className: "flex items-center text-sm", children: [
|
|
156
|
+
d,
|
|
157
|
+
n.name,
|
|
158
|
+
/* @__PURE__ */ l("span", { className: "text-xs text-gray-500", children: [
|
|
159
|
+
" (",
|
|
160
|
+
N,
|
|
161
|
+
")"
|
|
162
|
+
] })
|
|
163
|
+
] });
|
|
164
|
+
return /* @__PURE__ */ l(
|
|
165
|
+
R,
|
|
166
|
+
{
|
|
167
|
+
value: n.id,
|
|
168
|
+
onSelect: () => {
|
|
169
|
+
v(n.id), m(!1), C("");
|
|
170
|
+
},
|
|
171
|
+
className: "flex cursor-pointer items-center justify-between whitespace-pre-wrap",
|
|
172
|
+
children: [
|
|
173
|
+
/* @__PURE__ */ s("span", { children: O }),
|
|
174
|
+
/* @__PURE__ */ s(
|
|
175
|
+
U,
|
|
176
|
+
{
|
|
177
|
+
className: fe(
|
|
178
|
+
"mr-2 h-4 w-4 shrink-0",
|
|
179
|
+
o === n.id ? "opacity-100" : "opacity-0"
|
|
180
|
+
)
|
|
181
|
+
}
|
|
182
|
+
)
|
|
183
|
+
]
|
|
184
|
+
},
|
|
185
|
+
n.id
|
|
186
|
+
);
|
|
187
|
+
})
|
|
188
|
+
] })
|
|
189
|
+
] })
|
|
190
|
+
] }) })
|
|
191
|
+
] }) : /* @__PURE__ */ l(
|
|
192
|
+
"select",
|
|
193
|
+
{
|
|
194
|
+
id: i,
|
|
195
|
+
value: o || "none",
|
|
196
|
+
onChange: (n) => v(n.target.value),
|
|
197
|
+
className: p,
|
|
198
|
+
"data-testid": "parent-page-selector",
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ s("option", { value: "none", children: "None" }),
|
|
201
|
+
w.map((n) => {
|
|
202
|
+
const d = S(n.slug), N = d > 0 ? b(d) : "", O = h(n.slug);
|
|
203
|
+
return (g == null ? void 0 : g.id) === n.id || n.slug.startsWith(g == null ? void 0 : g.slug) ? null : /* @__PURE__ */ l("option", { value: n.id, children: [
|
|
204
|
+
N,
|
|
205
|
+
n.name,
|
|
206
|
+
" (",
|
|
207
|
+
O,
|
|
208
|
+
")"
|
|
209
|
+
] }, n.id);
|
|
210
|
+
})
|
|
211
|
+
]
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
] });
|
|
215
|
+
}
|
|
216
|
+
const Cs = (...a) => a.filter(Boolean).join(" "), ks = ({
|
|
217
|
+
templates: a,
|
|
218
|
+
selectedTemplateId: o,
|
|
219
|
+
onSelectTemplate: v,
|
|
220
|
+
isLoading: p = !1
|
|
221
|
+
}) => {
|
|
222
|
+
const [i, g] = y(""), [u, m] = y(!1), [f, C] = y(""), F = ye("enable-add-page-dropdown");
|
|
223
|
+
if (Ie(() => {
|
|
224
|
+
if (o) {
|
|
225
|
+
const h = a.find((t) => t.id === o);
|
|
226
|
+
g((h == null ? void 0 : h.preview) || "");
|
|
227
|
+
} else
|
|
228
|
+
g("");
|
|
229
|
+
}, [o, a]), p)
|
|
230
|
+
return /* @__PURE__ */ s("div", { className: "flex h-fit items-center justify-center text-sm text-gray-500", children: "Loading templates..." });
|
|
231
|
+
if (a.length === 0)
|
|
232
|
+
return null;
|
|
233
|
+
const w = {};
|
|
234
|
+
a.forEach((h) => {
|
|
235
|
+
const t = h.libraryName;
|
|
236
|
+
w[t] || (w[t] = []), w[t].push(h);
|
|
237
|
+
});
|
|
238
|
+
const I = Object.entries(w).reduce(
|
|
239
|
+
(h, [t, n]) => {
|
|
240
|
+
const d = n.filter(
|
|
241
|
+
(N) => N.name.toLowerCase().includes(f.toLowerCase()) || t.toLowerCase().includes(f.toLowerCase())
|
|
242
|
+
);
|
|
243
|
+
return d.length > 0 && (h[t] = d), h;
|
|
244
|
+
},
|
|
245
|
+
{}
|
|
246
|
+
), S = a.find((h) => h.id === o), b = S ? de(S.name) : "No Template";
|
|
247
|
+
return /* @__PURE__ */ l("div", { className: "space-y-4", children: [
|
|
248
|
+
F ? /* @__PURE__ */ l(ee, { open: u, onOpenChange: m, children: [
|
|
249
|
+
/* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(W, { variant: "outline", role: "combobox", className: "w-full justify-between", children: [
|
|
250
|
+
b,
|
|
251
|
+
/* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
252
|
+
] }) }),
|
|
253
|
+
/* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
|
|
254
|
+
/* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
255
|
+
/* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
|
|
256
|
+
/* @__PURE__ */ s(
|
|
257
|
+
M,
|
|
258
|
+
{
|
|
259
|
+
placeholder: "Search templates...",
|
|
260
|
+
className: "h-8 pl-8 text-xs",
|
|
261
|
+
value: f,
|
|
262
|
+
onChange: (h) => C(h.target.value)
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
] }) }),
|
|
266
|
+
/* @__PURE__ */ l(ce, { className: "max-h-[300px] overflow-y-auto", children: [
|
|
267
|
+
/* @__PURE__ */ s(ne, { children: "No templates found." }),
|
|
268
|
+
Object.entries(I).map(([h, t]) => /* @__PURE__ */ s(V, { heading: h, children: t.map((n) => /* @__PURE__ */ l(
|
|
269
|
+
R,
|
|
270
|
+
{
|
|
271
|
+
value: n.id,
|
|
272
|
+
onSelect: () => {
|
|
273
|
+
v(n.id), m(!1), C("");
|
|
274
|
+
},
|
|
275
|
+
className: "flex cursor-pointer items-center justify-between",
|
|
276
|
+
children: [
|
|
277
|
+
de(n.name),
|
|
278
|
+
/* @__PURE__ */ s(
|
|
279
|
+
U,
|
|
280
|
+
{
|
|
281
|
+
className: Cs(
|
|
282
|
+
"mr-2 h-4 w-4",
|
|
283
|
+
o === n.id ? "opacity-100" : "opacity-0"
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
]
|
|
288
|
+
},
|
|
289
|
+
n.id
|
|
290
|
+
)) }, h))
|
|
291
|
+
] })
|
|
292
|
+
] }) })
|
|
293
|
+
] }) : /* @__PURE__ */ l(
|
|
294
|
+
"select",
|
|
295
|
+
{
|
|
296
|
+
className: "w-full rounded-md border border-gray-300 px-3 py-2",
|
|
297
|
+
value: o,
|
|
298
|
+
onChange: (h) => v(h.target.value),
|
|
299
|
+
children: [
|
|
300
|
+
/* @__PURE__ */ s("option", { value: "", children: "No Template" }),
|
|
301
|
+
Object.entries(w).map(([h, t]) => /* @__PURE__ */ s("optgroup", { label: h, children: t.map((n) => /* @__PURE__ */ s("option", { value: n.id, children: de(n.name) }, n.id)) }, h))
|
|
302
|
+
]
|
|
303
|
+
}
|
|
304
|
+
),
|
|
305
|
+
i && /* @__PURE__ */ l("div", { className: "mt-3 overflow-hidden rounded border", children: [
|
|
306
|
+
/* @__PURE__ */ s("div", { className: "max-h-[200px] overflow-auto", children: /* @__PURE__ */ s("img", { src: i, alt: "Template Preview", className: "w-full object-contain" }) }),
|
|
307
|
+
/* @__PURE__ */ s("div", { className: "border-t bg-gray-50 p-2 text-xs text-gray-500", children: "Template preview" })
|
|
308
|
+
] })
|
|
309
|
+
] });
|
|
310
|
+
}, Ls = () => {
|
|
311
|
+
const a = Re(), o = Ue();
|
|
312
|
+
return ze({
|
|
313
|
+
queryKey: [oe.GET_LIBRARIES],
|
|
314
|
+
staleTime: "static",
|
|
315
|
+
queryFn: async () => await o(a, { action: oe.GET_LIBRARIES }) || []
|
|
316
|
+
});
|
|
317
|
+
}, Ts = (a) => {
|
|
318
|
+
const o = Re(), v = Ue();
|
|
319
|
+
return ze({
|
|
320
|
+
queryKey: [oe.GET_TEMPLATES_BY_TYPE, a],
|
|
321
|
+
staleTime: "static",
|
|
322
|
+
enabled: !!a,
|
|
323
|
+
queryFn: async () => {
|
|
324
|
+
const p = await v(o, {
|
|
325
|
+
action: oe.GET_TEMPLATES_BY_TYPE,
|
|
326
|
+
data: { pageType: a }
|
|
327
|
+
});
|
|
328
|
+
return (a ? hs(p, { pageType: a }) : p) || [];
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
}, js = (a) => {
|
|
332
|
+
const { data: o = [], isLoading: v } = Ts(a), { data: p = [], isLoading: i } = Ls(), g = B(() => v || i ? [] : o.map((m) => {
|
|
333
|
+
const f = ge(p, { id: m.library });
|
|
334
|
+
return {
|
|
335
|
+
...m,
|
|
336
|
+
libraryName: (f == null ? void 0 : f.type) !== "shared" ? "Site Library" : (f == null ? void 0 : f.name) + " Library",
|
|
337
|
+
libraryType: f == null ? void 0 : f.type
|
|
338
|
+
};
|
|
339
|
+
}), [o, p, v, i]), u = B(() => ps(g, "libraryName"), [g]);
|
|
340
|
+
return {
|
|
341
|
+
data: g,
|
|
342
|
+
groupedData: u,
|
|
343
|
+
isLoading: v || i
|
|
344
|
+
};
|
|
345
|
+
}, G = (...a) => a.filter(Boolean).join(" ");
|
|
346
|
+
function zs({ addEditPage: a, close: o, closePanel: v }) {
|
|
347
|
+
var Ae, Fe;
|
|
348
|
+
const { data: p } = fs(), i = B(() => p ?? [], [p]), g = gs(), u = !!(a != null && a.id), { data: m } = ys(), { mutate: f, isPending: C } = vs(), { mutate: F, isPending: w } = Ns(), [I, S] = y(null), [b, h] = y(!0), [t, n] = y((a == null ? void 0 : a.pageType) ?? "page"), { hasPermission: d } = os(), N = d(Ss.CHANGE_PAGE_TYPE), [O, z] = y(!1), [_e, qe] = y(""), { selectedLang: Ge, fallbackLang: Ve } = cs(), ve = Ge || Ve, [Y, Z] = y(""), [Ne, H] = y(!1), Se = B(() => {
|
|
349
|
+
const e = i.find((c) => c.key === t);
|
|
350
|
+
return (e == null ? void 0 : e.hasSlug) === !1;
|
|
351
|
+
}, [t, i]), [k, Me] = y((a == null ? void 0 : a.parent) ?? ""), [_, be] = y((a == null ? void 0 : a.name) ?? ""), [T, we] = y((a == null ? void 0 : a.dynamic) ?? !1), [j, K] = y(T ? "" : ((a == null ? void 0 : a.slug) ?? "").split("/").pop() || ""), [xe, Ce] = y((a == null ? void 0 : a.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 = B(() => !u || !(a != null && a.id) || !m ? null : m.find((e) => e.id === a.id), [u, a == null ? void 0 : a.id, m]), Ze = (he == null ? void 0 : he.online) || !1, Je = B(() => !u || !(a != null && a.id) || !m ? !1 : m.some((e) => e.parent === a.id), [u, a == null ? void 0 : a.id, m]), r = i.find((e) => e.key === t), q = (e) => {
|
|
352
|
+
if (u && t !== e) {
|
|
353
|
+
qe(e), z(!0), Z(""), H(!1);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
n(e), Z(""), H(!1);
|
|
357
|
+
}, je = () => {
|
|
358
|
+
n(_e), z(!1), we(!1);
|
|
359
|
+
}, Xe = (e) => {
|
|
360
|
+
we(e), e ? K("") : Ce("");
|
|
361
|
+
}, Pe = (e) => {
|
|
362
|
+
if (Me(e), e && e !== "none") {
|
|
363
|
+
const c = m == null ? void 0 : m.find((x) => x.id === e), D = (c == null ? void 0 : c.slug) || "";
|
|
364
|
+
if (j.startsWith(D)) {
|
|
365
|
+
const x = j.slice(D.length).replace(/^\/+/, "");
|
|
366
|
+
K(x);
|
|
367
|
+
} else
|
|
368
|
+
K(j.replace(/^\/+/, ""));
|
|
369
|
+
} else
|
|
370
|
+
K(j ? `${j}` : "");
|
|
371
|
+
}, Ee = (e) => {
|
|
372
|
+
He(e);
|
|
373
|
+
}, es = () => _.trim() ? T && !$e(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 = () => {
|
|
374
|
+
const e = {
|
|
375
|
+
pageType: r == null ? void 0 : r.key,
|
|
376
|
+
name: _,
|
|
377
|
+
slug: "",
|
|
378
|
+
hasSlug: !1
|
|
379
|
+
};
|
|
380
|
+
u ? F(
|
|
381
|
+
{ id: a == null ? void 0 : a.id, name: _ },
|
|
382
|
+
{
|
|
383
|
+
onSuccess: () => {
|
|
384
|
+
E.success((r == null ? void 0 : r.name) + " updated successfully"), o();
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
) : f(e, {
|
|
388
|
+
onSuccess: (c) => {
|
|
389
|
+
o(), g(c.page.id, v);
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
}, as = (e, c) => {
|
|
393
|
+
if (!e.trim() && !T)
|
|
394
|
+
return S("Child page slug is required"), !1;
|
|
395
|
+
const D = te(c), x = Oe(D, e);
|
|
396
|
+
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;
|
|
397
|
+
}, ls = (e, c) => {
|
|
398
|
+
const D = te(c), x = Oe(D, e), L = {
|
|
399
|
+
pageType: t,
|
|
400
|
+
name: _,
|
|
401
|
+
slug: x.replace(/\/$/, ""),
|
|
402
|
+
// remove trailing slashes
|
|
403
|
+
parent: k,
|
|
404
|
+
dynamic: T,
|
|
405
|
+
hasSlug: !0,
|
|
406
|
+
template: me || void 0,
|
|
407
|
+
tracking: {},
|
|
408
|
+
seo: {},
|
|
409
|
+
jsonLD: {}
|
|
410
|
+
};
|
|
411
|
+
if (T && (L.dynamicSlugCustom = xe), u) {
|
|
412
|
+
const A = ds(L, ["pageType", "parent", "name", "slug", "dynamic", "dynamicSlugCustom"]);
|
|
413
|
+
F(
|
|
414
|
+
{ id: a == null ? void 0 : a.id, ...A },
|
|
415
|
+
{
|
|
416
|
+
onSuccess: () => {
|
|
417
|
+
E.success("Page updated successfully"), o();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
);
|
|
421
|
+
} else {
|
|
422
|
+
const A = ge(i, { key: t });
|
|
423
|
+
A != null && A.trackingDefault && (L.tracking = A.trackingDefault);
|
|
424
|
+
const { seo: X, jsonLD: ts } = Be(A, ve);
|
|
425
|
+
P(L, "seo", X), P(L, "jsonLD", ts), f(L, {
|
|
426
|
+
onSuccess: (rs) => {
|
|
427
|
+
o(), g(rs.page.id, v);
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
}, ns = () => {
|
|
432
|
+
const e = {
|
|
433
|
+
pageType: t,
|
|
434
|
+
name: _,
|
|
435
|
+
slug: j === "" ? "/" : `/${j.replace(/\/$/, "")}`,
|
|
436
|
+
template: me || void 0,
|
|
437
|
+
parent: null,
|
|
438
|
+
tracking: {}
|
|
439
|
+
};
|
|
440
|
+
if (u)
|
|
441
|
+
F(
|
|
442
|
+
{ id: a == null ? void 0 : a.id, ...e },
|
|
443
|
+
{
|
|
444
|
+
onSuccess: () => {
|
|
445
|
+
E.success("Page updated successfully"), o();
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
);
|
|
449
|
+
else {
|
|
450
|
+
const c = ge(i, { key: t });
|
|
451
|
+
c != null && c.trackingDefault && (e.tracking = c.trackingDefault);
|
|
452
|
+
const { seo: D, jsonLD: x } = Be(c, ve);
|
|
453
|
+
P(e, "seo", D), P(e, "jsonLD", x), f(e, {
|
|
454
|
+
onSuccess: (L) => {
|
|
455
|
+
var A;
|
|
456
|
+
(A = L == null ? void 0 : L.page) != null && A.id && g(L.page.id, v), o();
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}, De = (e) => {
|
|
461
|
+
if (e.preventDefault(), S(null), !!es()) {
|
|
462
|
+
if (!(r != null && r.hasSlug)) {
|
|
463
|
+
ss();
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
if (k && k !== "none") {
|
|
467
|
+
const c = m == null ? void 0 : m.find((x) => x.id === k), D = (c == null ? void 0 : c.slug) || "";
|
|
468
|
+
if (!as(j, D))
|
|
469
|
+
return;
|
|
470
|
+
ls(j, D);
|
|
471
|
+
} else
|
|
472
|
+
ns();
|
|
473
|
+
}
|
|
474
|
+
}, { pagesType: pe, partialsType: J } = B(() => {
|
|
475
|
+
const e = (c) => Y ? c.name.toLowerCase().includes(Y.toLowerCase()) || c.key.toLowerCase().includes(Y.toLowerCase()) : !0;
|
|
476
|
+
return {
|
|
477
|
+
pagesType: i.filter((c) => c.hasSlug !== !1 && e(c)),
|
|
478
|
+
partialsType: i.filter((c) => c.hasSlug === !1 && e(c))
|
|
479
|
+
};
|
|
480
|
+
}, [i, Y]);
|
|
481
|
+
return r != null && r.hasSlug ? /* @__PURE__ */ l("form", { onSubmit: De, className: "mx-auto w-full max-w-md space-y-4", children: [
|
|
482
|
+
/* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
|
|
483
|
+
/* @__PURE__ */ s($, { htmlFor: "pageType", className: "text-sm", children: "Type" }),
|
|
484
|
+
Te ? /* @__PURE__ */ l(ee, { open: Ne, onOpenChange: H, children: [
|
|
485
|
+
/* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(
|
|
486
|
+
W,
|
|
487
|
+
{
|
|
488
|
+
variant: "outline",
|
|
489
|
+
role: "combobox",
|
|
490
|
+
disabled: u && !N,
|
|
491
|
+
className: G(
|
|
492
|
+
"w-full justify-between",
|
|
493
|
+
u && !N ? "cursor-not-allowed text-gray-500" : ""
|
|
494
|
+
),
|
|
495
|
+
children: [
|
|
496
|
+
(r == null ? void 0 : r.name) || "Select page type",
|
|
497
|
+
/* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
498
|
+
]
|
|
499
|
+
}
|
|
500
|
+
) }),
|
|
501
|
+
/* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
|
|
502
|
+
/* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
503
|
+
/* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
|
|
504
|
+
/* @__PURE__ */ s(
|
|
505
|
+
M,
|
|
506
|
+
{
|
|
507
|
+
placeholder: "Search page types...",
|
|
508
|
+
className: "h-8 pl-8 text-xs",
|
|
509
|
+
value: Y,
|
|
510
|
+
onChange: (e) => Z(e.target.value)
|
|
511
|
+
}
|
|
512
|
+
)
|
|
513
|
+
] }) }),
|
|
514
|
+
/* @__PURE__ */ l(ce, { className: "overflow-y-auto", children: [
|
|
515
|
+
/* @__PURE__ */ s(ne, { children: "No page type found." }),
|
|
516
|
+
u ? Se ? /* @__PURE__ */ s(V, { heading: "Partials", children: J.map((e) => /* @__PURE__ */ l(
|
|
517
|
+
R,
|
|
518
|
+
{
|
|
519
|
+
value: e.key,
|
|
520
|
+
onSelect: () => q(e.key),
|
|
521
|
+
className: "flex cursor-pointer items-center justify-between",
|
|
522
|
+
children: [
|
|
523
|
+
e.name,
|
|
524
|
+
/* @__PURE__ */ s(
|
|
525
|
+
U,
|
|
526
|
+
{
|
|
527
|
+
className: G("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
]
|
|
531
|
+
},
|
|
532
|
+
e.key
|
|
533
|
+
)) }) : /* @__PURE__ */ s(V, { heading: "Pages", children: pe.map((e) => /* @__PURE__ */ l(
|
|
534
|
+
R,
|
|
535
|
+
{
|
|
536
|
+
value: e.key,
|
|
537
|
+
onSelect: () => q(e.key),
|
|
538
|
+
className: "flex cursor-pointer items-center justify-between",
|
|
539
|
+
children: [
|
|
540
|
+
e.name,
|
|
541
|
+
/* @__PURE__ */ s(
|
|
542
|
+
U,
|
|
543
|
+
{
|
|
544
|
+
className: G("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
|
|
545
|
+
}
|
|
546
|
+
)
|
|
547
|
+
]
|
|
548
|
+
},
|
|
549
|
+
e.key
|
|
550
|
+
)) }) : /* @__PURE__ */ l(We, { children: [
|
|
551
|
+
pe.length > 0 && /* @__PURE__ */ s(V, { heading: "Pages", children: pe.map((e) => /* @__PURE__ */ l(
|
|
552
|
+
R,
|
|
553
|
+
{
|
|
554
|
+
value: e.key,
|
|
555
|
+
onSelect: () => q(e.key),
|
|
556
|
+
className: "flex cursor-pointer items-center justify-between",
|
|
557
|
+
children: [
|
|
558
|
+
e.name,
|
|
559
|
+
/* @__PURE__ */ s(
|
|
560
|
+
U,
|
|
561
|
+
{
|
|
562
|
+
className: G("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
|
|
563
|
+
}
|
|
564
|
+
)
|
|
565
|
+
]
|
|
566
|
+
},
|
|
567
|
+
e.key
|
|
568
|
+
)) }),
|
|
569
|
+
J.length > 0 && /* @__PURE__ */ s(V, { heading: "Partials", children: J.map((e) => /* @__PURE__ */ l(
|
|
570
|
+
R,
|
|
571
|
+
{
|
|
572
|
+
value: e.key,
|
|
573
|
+
onSelect: () => q(e.key),
|
|
574
|
+
className: "flex cursor-pointer items-center justify-between",
|
|
575
|
+
children: [
|
|
576
|
+
e.name,
|
|
577
|
+
/* @__PURE__ */ s(
|
|
578
|
+
U,
|
|
579
|
+
{
|
|
580
|
+
className: G("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0")
|
|
581
|
+
}
|
|
582
|
+
)
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
e.key
|
|
586
|
+
)) })
|
|
587
|
+
] })
|
|
588
|
+
] })
|
|
589
|
+
] }) })
|
|
590
|
+
] }) : /* @__PURE__ */ s(
|
|
591
|
+
"select",
|
|
592
|
+
{
|
|
593
|
+
id: "pageType",
|
|
594
|
+
value: t,
|
|
595
|
+
disabled: u && !N,
|
|
596
|
+
onChange: (e) => q(e.target.value),
|
|
597
|
+
className: `w-full rounded-md border border-gray-300 px-3 py-2 ${u && !N ? "cursor-not-allowed text-gray-500" : ""}`,
|
|
598
|
+
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__ */ l(We, { children: [
|
|
599
|
+
/* @__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)) }),
|
|
600
|
+
/* @__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)) })
|
|
601
|
+
] })
|
|
602
|
+
}
|
|
603
|
+
),
|
|
604
|
+
O && /* @__PURE__ */ l("div", { className: "mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3", children: [
|
|
605
|
+
/* @__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?" }),
|
|
606
|
+
/* @__PURE__ */ l("div", { className: "mt-2 flex gap-2", children: [
|
|
607
|
+
/* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () => z(!1), children: "Cancel" }),
|
|
608
|
+
/* @__PURE__ */ s(W, { variant: "default", size: "sm", onClick: je, children: "Confirm" })
|
|
609
|
+
] })
|
|
610
|
+
] })
|
|
611
|
+
] }),
|
|
612
|
+
!u && (r == null ? void 0 : r.hasSlug) && Le.length > 0 && /* @__PURE__ */ l("div", { className: "space-y-1", children: [
|
|
613
|
+
/* @__PURE__ */ s($, { className: "mb-1 block text-sm", children: "Template" }),
|
|
614
|
+
/* @__PURE__ */ s(
|
|
615
|
+
ks,
|
|
616
|
+
{
|
|
617
|
+
templates: Le,
|
|
618
|
+
selectedTemplateId: me,
|
|
619
|
+
onSelectTemplate: Ee,
|
|
620
|
+
isLoading: Ke
|
|
621
|
+
}
|
|
622
|
+
)
|
|
623
|
+
] }),
|
|
624
|
+
/* @__PURE__ */ s(
|
|
625
|
+
xs,
|
|
626
|
+
{
|
|
627
|
+
pages: m,
|
|
628
|
+
selectedParentId: k,
|
|
629
|
+
onChange: Pe,
|
|
630
|
+
currentPage: a
|
|
631
|
+
}
|
|
632
|
+
),
|
|
633
|
+
/* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
|
|
634
|
+
/* @__PURE__ */ s($, { htmlFor: "name", className: "text-sm", children: "Name" }),
|
|
635
|
+
/* @__PURE__ */ s(
|
|
636
|
+
M,
|
|
637
|
+
{
|
|
638
|
+
id: "name",
|
|
639
|
+
value: _,
|
|
640
|
+
onChange: (e) => be(e.target.value),
|
|
641
|
+
required: !0,
|
|
642
|
+
"aria-required": "true",
|
|
643
|
+
placeholder: "Enter page name"
|
|
644
|
+
}
|
|
645
|
+
)
|
|
646
|
+
] }),
|
|
647
|
+
(r == null ? void 0 : r.dynamicSegments) && k && k !== "none" && /* @__PURE__ */ l("div", { className: "space-y-2", children: [
|
|
648
|
+
/* @__PURE__ */ l("div", { className: "flex items-center space-x-2", children: [
|
|
649
|
+
/* @__PURE__ */ s(
|
|
650
|
+
"input",
|
|
651
|
+
{
|
|
652
|
+
type: "checkbox",
|
|
653
|
+
id: "useDynamicSlug",
|
|
654
|
+
checked: T,
|
|
655
|
+
onChange: (e) => Xe(e.target.checked),
|
|
656
|
+
className: "rounded border-gray-300"
|
|
657
|
+
}
|
|
658
|
+
),
|
|
659
|
+
/* @__PURE__ */ s($, { htmlFor: "useDynamicSlug", className: "text-sm", children: "Use Dynamic Slug" })
|
|
660
|
+
] }),
|
|
661
|
+
T && /* @__PURE__ */ s("div", { className: "space-y-2", children: /* @__PURE__ */ s("div", { className: "space-y-0.5", children: /* @__PURE__ */ s(
|
|
662
|
+
ws,
|
|
663
|
+
{
|
|
664
|
+
value: xe,
|
|
665
|
+
onChange: Ce,
|
|
666
|
+
dynamicPattern: (r == null ? void 0 : r.dynamicSlug) || "{{id}}",
|
|
667
|
+
placeholder: "Enter custom slug part (optional)",
|
|
668
|
+
onValidationChange: Ye
|
|
669
|
+
}
|
|
670
|
+
) }) })
|
|
671
|
+
] }),
|
|
672
|
+
(!(r != null && r.dynamicSegments) || !T) && /* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
|
|
673
|
+
/* @__PURE__ */ s($, { htmlFor: "slug", className: "text-sm", children: "Slug" }),
|
|
674
|
+
/* @__PURE__ */ s(
|
|
675
|
+
ms,
|
|
676
|
+
{
|
|
677
|
+
value: j,
|
|
678
|
+
onChange: (e) => {
|
|
679
|
+
var c;
|
|
680
|
+
K(e), u && e !== (((c = a == null ? void 0 : a.slug) == null ? void 0 : c.split("/").pop()) || "") ? ue(!!(Ze || Je)) : ue(!1);
|
|
681
|
+
},
|
|
682
|
+
placeholder: k && k !== "none" ? "Enter page slug" : t === "page" ? "Leave empty for home page" : "Required - e.g. your-slug",
|
|
683
|
+
parentSlug: k && k !== "none" ? (Fe = m == null ? void 0 : m.find((e) => e.id === k)) == null ? void 0 : Fe.slug : void 0,
|
|
684
|
+
onValidationChange: h
|
|
685
|
+
}
|
|
686
|
+
),
|
|
687
|
+
I && /* @__PURE__ */ s("p", { className: "text-xs text-red-500", children: I }),
|
|
688
|
+
Qe && /* @__PURE__ */ s("div", { className: "mt-4 rounded-md border border-amber-200 bg-amber-50 p-3", children: /* @__PURE__ */ l("div", { className: "flex items-start space-x-2", children: [
|
|
689
|
+
/* @__PURE__ */ s("div", { className: "flex-shrink-0", children: /* @__PURE__ */ s("svg", { className: "h-5 w-5 text-amber-400", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ s(
|
|
690
|
+
"path",
|
|
691
|
+
{
|
|
692
|
+
fillRule: "evenodd",
|
|
693
|
+
d: "M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z",
|
|
694
|
+
clipRule: "evenodd"
|
|
695
|
+
}
|
|
696
|
+
) }) }),
|
|
697
|
+
/* @__PURE__ */ l("div", { className: "flex-1", children: [
|
|
698
|
+
/* @__PURE__ */ s("h3", { className: "text-sm font-medium text-amber-800", children: "Slug Change Warning" }),
|
|
699
|
+
/* @__PURE__ */ s("div", { className: "mt-1 text-sm text-amber-700", children: /* @__PURE__ */ s("p", { children: "The previous URL and any child pages will become inaccessible. You may want to set up a redirect to avoid broken links." }) })
|
|
700
|
+
] })
|
|
701
|
+
] }) })
|
|
702
|
+
] }),
|
|
703
|
+
/* @__PURE__ */ s(
|
|
704
|
+
W,
|
|
705
|
+
{
|
|
706
|
+
disabled: Q || // Disable if regular slug is invalid and we're not using dynamic slug
|
|
707
|
+
!b && (!(r != null && r.dynamicSegments) || !T) || // Disable if dynamic slug is invalid and we are using dynamic slug
|
|
708
|
+
T && !ke,
|
|
709
|
+
type: "submit",
|
|
710
|
+
className: "w-full",
|
|
711
|
+
children: u ? Q ? "Updating..." : "Update page" : Q ? "Creating..." : "Create Page"
|
|
712
|
+
}
|
|
713
|
+
)
|
|
714
|
+
] }) : /* @__PURE__ */ l("form", { onSubmit: De, className: "mx-auto w-full max-w-md space-y-4", children: [
|
|
715
|
+
/* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
|
|
716
|
+
/* @__PURE__ */ s($, { htmlFor: "pageType", className: "text-sm", children: "Type" }),
|
|
717
|
+
Te ? /* @__PURE__ */ l(ee, { open: Ne, onOpenChange: H, children: [
|
|
718
|
+
/* @__PURE__ */ s(se, { asChild: !0, children: /* @__PURE__ */ l(
|
|
719
|
+
W,
|
|
720
|
+
{
|
|
721
|
+
variant: "outline",
|
|
722
|
+
role: "combobox",
|
|
723
|
+
disabled: u && !N,
|
|
724
|
+
className: G(
|
|
725
|
+
"w-full justify-between",
|
|
726
|
+
u && !N ? "cursor-not-allowed text-gray-500" : ""
|
|
727
|
+
),
|
|
728
|
+
children: [
|
|
729
|
+
(r == null ? void 0 : r.name) || "Select page type",
|
|
730
|
+
/* @__PURE__ */ s(re, { className: "ml-2 h-4 w-4 shrink-0 opacity-50" })
|
|
731
|
+
]
|
|
732
|
+
}
|
|
733
|
+
) }),
|
|
734
|
+
/* @__PURE__ */ s(ae, { className: "w-[var(--radix-popover-trigger-width)] p-0", align: "start", children: /* @__PURE__ */ l(le, { shouldFilter: !1, children: [
|
|
735
|
+
/* @__PURE__ */ s("div", { className: "sticky top-0 z-10 bg-white px-3 py-2", children: /* @__PURE__ */ l("div", { className: "relative", children: [
|
|
736
|
+
/* @__PURE__ */ s(ie, { strokeWidth: 2, className: "absolute left-2 top-2 h-4 w-4 text-gray-400" }),
|
|
737
|
+
/* @__PURE__ */ s(
|
|
738
|
+
M,
|
|
739
|
+
{
|
|
740
|
+
placeholder: "Search page types...",
|
|
741
|
+
className: "h-8 pl-8 text-xs",
|
|
742
|
+
value: Y,
|
|
743
|
+
onChange: (e) => Z(e.target.value)
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
] }) }),
|
|
747
|
+
/* @__PURE__ */ l(ce, { className: "max-h-[200px] overflow-y-auto", children: [
|
|
748
|
+
/* @__PURE__ */ s(ne, { children: "No page type found." }),
|
|
749
|
+
/* @__PURE__ */ s(V, { heading: "Partials", children: J.map((e) => /* @__PURE__ */ l(
|
|
750
|
+
R,
|
|
751
|
+
{
|
|
752
|
+
value: e.key,
|
|
753
|
+
onSelect: () => {
|
|
754
|
+
q(e.key), H(!1);
|
|
755
|
+
},
|
|
756
|
+
className: "flex cursor-pointer items-center justify-between",
|
|
757
|
+
children: [
|
|
758
|
+
e.name,
|
|
759
|
+
/* @__PURE__ */ s(U, { className: G("mr-2 h-4 w-4", t === e.key ? "opacity-100" : "opacity-0") })
|
|
760
|
+
]
|
|
761
|
+
},
|
|
762
|
+
e.key
|
|
763
|
+
)) })
|
|
764
|
+
] })
|
|
765
|
+
] }) })
|
|
766
|
+
] }) : /* @__PURE__ */ s(
|
|
767
|
+
"select",
|
|
768
|
+
{
|
|
769
|
+
id: "pageType",
|
|
770
|
+
value: t,
|
|
771
|
+
disabled: u && !N,
|
|
772
|
+
onChange: (e) => q(e.target.value),
|
|
773
|
+
className: `w-full rounded-md border border-gray-300 px-3 py-2 ${u && !N ? "cursor-not-allowed text-gray-500" : ""}`,
|
|
774
|
+
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)) })
|
|
775
|
+
}
|
|
776
|
+
),
|
|
777
|
+
O && /* @__PURE__ */ l("div", { className: "mt-2 rounded-md border border-yellow-200 bg-yellow-50 p-3", children: [
|
|
778
|
+
/* @__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?" }),
|
|
779
|
+
/* @__PURE__ */ l("div", { className: "mt-2 flex gap-2", children: [
|
|
780
|
+
/* @__PURE__ */ s(W, { variant: "outline", size: "sm", onClick: () => z(!1), children: "Cancel" }),
|
|
781
|
+
/* @__PURE__ */ s(W, { variant: "default", size: "sm", onClick: je, children: "Confirm" })
|
|
782
|
+
] })
|
|
783
|
+
] }),
|
|
784
|
+
/* @__PURE__ */ s("p", { className: "text-xs text-gray-500", children: (Ae = i.find((e) => e.key === t)) == null ? void 0 : Ae.helpText })
|
|
785
|
+
] }),
|
|
786
|
+
/* @__PURE__ */ l("div", { className: "space-y-0.5", children: [
|
|
787
|
+
/* @__PURE__ */ s($, { htmlFor: "name", className: "text-sm", children: "Name" }),
|
|
788
|
+
/* @__PURE__ */ s(M, { id: "name", value: _, onChange: (e) => be(e.target.value), required: !0, "aria-required": "true" })
|
|
789
|
+
] }),
|
|
790
|
+
/* @__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) })
|
|
791
|
+
] });
|
|
792
|
+
}
|
|
793
|
+
export {
|
|
794
|
+
zs as default
|
|
795
|
+
};
|